Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 03-26-2002, 06:15 PM   #1
Sexymail
So Fucking Banned
 
Join Date: Feb 2002
Location: Texas
Posts: 350
anyone with a simple php script?

I need a php script that will split my hits between 2 urls. for example.
1 hit in = redirects to url 1
another hit in = redirects to url 2
another hit in = redirects to url 1
so on and so forth......
Sexymail is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2002, 07:11 PM   #2
Cirrus
Confirmed User
 
Join Date: Feb 2002
Location: www.Reyko.com
Posts: 1,145
PHP Code:
<?
$url=Array(
  "http://site1.com",
  "http://site2.com"
);



$filename="count.txt";
if (file_exists($filename)):
    $file=file($filename);
    $hits=intval($file[0])+1;
    $fp=fopen($filename,"w+");
else:
    $fp=fopen($filename,"w");
    $hits=0;
endif;
if ($hits>=count($url)) $hits = 0;
fputs($fp,"$hits\n");
fclose($fp);

header("Location: $url[$hits]");


?>
set appropriate CHMOD to count.txt -
I do not claim that this is the best solution
Cirrus is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2002, 08:17 PM   #3
Sexymail
So Fucking Banned
 
Join Date: Feb 2002
Location: Texas
Posts: 350
thank you
Sexymail is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2002, 08:21 PM   #4
KC
Confirmed User
 
Industry Role:
Join Date: Jan 1995
Posts: 2,417
PHP Code:

<?
        $url1 = "http://www.myfirsturl.com/?mycode";
        $url2 = "http://www.mysecondurl.com/?myothercode";
        
        if (((date("s") + 1) % 2) == 0) {
                // even # of seconds
                $location = $url1;  
        } else {
                // odd # of seconds
                $location = $url2; 
        }
         
        header("Location: $location");
?>

Here's a quick and dirty UNTESTED! way to do it...

If you only want to redirect between 2 URLs and you want to keep them pretty even but not necessarily EXACTLY even, I would do something like that that didn't involve file I/O... any time you touch the disk it's going to get slow especially if you're going to throw a lot of traffic at it.

This just checks to see if the current second is even or odd and then forwards to either url1 or url2...

If you're only talking about 2 URLs and not needing to track any stats, I'd say something like this would work pretty damn well. \

So just copy that code into a php file, update the 2 urls and send traffic directly to the php page you create.

Good Luck!
-KC
__________________

Jupiter Hosting, Inc.
Vice President, Business Development
kc (AT) jupiterhosting.com
KC is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2002, 10:45 PM   #5
Sexymail
So Fucking Banned
 
Join Date: Feb 2002
Location: Texas
Posts: 350
thx fellas, i went with KC's seems to be working great sofar
i appreciate the input
Sexymail is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-27-2002, 12:43 AM   #6
4Pics
Confirmed User
 
Industry Role:
Join Date: Dec 2001
Posts: 7,952
What's wrong with how i am doing it


<?

$urls = array(
1 => "http://www.url1.com",
2 => "http://www.url2.com",
3 => "http://www.url3.com",
4 => "http://www.url4.com",
);

srand ((double) microtime() * 1000000);
$randnum = rand(1,4);
$goto = $urls[$randnum];

header("Location: $goto");

?>

Last edited by 4Pics; 03-27-2002 at 12:45 AM..
4Pics is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-27-2002, 12:54 AM   #7
KC
Confirmed User
 
Industry Role:
Join Date: Jan 1995
Posts: 2,417
4Pics,

Your's will work well also...

For something simple like this, as long as it isn't hitting a database or reading & writing to a text file, just about ANYTHING will work...

-KC
__________________

Jupiter Hosting, Inc.
Vice President, Business Development
kc (AT) jupiterhosting.com
KC is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-27-2002, 07:46 AM   #8
Big E
Registered User
 
Industry Role:
Join Date: Mar 2002
Location: San Diego, CA
Posts: 935
I dunno what you're using this for, but you might consider stashing a cookie so that if/when the user/visitor ever comes back, he gets the alternate URL on the second visit.

Then you can do a "porn site" Survivor test where you can run 3-4-5 front ends, all receiving equal amounts of traffic and figure out which one is doing worst - pull it out, redesign it and put it back in the rotation and repeat.
Big E is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-27-2002, 08:57 AM   #9
zubr
Confirmed User
 
Join Date: Jan 2002
Location: Toronto
Posts: 1,227
Do it with java script - no server load + it will work for 99% of browsers.... if a simple java script wont work on the user, how can you expect a sponsor to track the signup??
__________________
Alex - ICQ:61889253 - MSN:zubr_zubr at hotmail.com - Skype:zubrzubr
zubr is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-27-2002, 01:29 PM   #10
KC
Confirmed User
 
Industry Role:
Join Date: Jan 1995
Posts: 2,417
Quote:
Do it with java script - no server load + it will work for 99% of browsers.... if a simple java script wont work on the user, how can you expect a sponsor to track the signup??
99% of browsers have javascipt... but how many have JS, but have it disabled?

I think relying on a browser to do a rotation job is unreliable. Especially when you have a fast server side technology like PHP available to you. (as this guy did)

PHP doing something like this could easily hanle millions of hits per day, depending on the hardware. Speed and server load won't be a problem with something like this.

-KC
__________________

Jupiter Hosting, Inc.
Vice President, Business Development
kc (AT) jupiterhosting.com
KC is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-27-2002, 03:41 PM   #11
Sexymail
So Fucking Banned
 
Join Date: Feb 2002
Location: Texas
Posts: 350
Yeah, i thought about javascript, but like you say most asswipes have it off or its not supported in some way, so php seemed like the only way togo, as far as cookies go, these visitors will only hit the site once (98% sure of that) so no need to stick a big fat nasty cookie in thier pc
Sexymail is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-27-2002, 03:42 PM   #12
KC
Confirmed User
 
Industry Role:
Join Date: Jan 1995
Posts: 2,417
Quote:
no need to stick a big fat nasty cookie in thier pc
I think everyone should just set as many damn cookies as possible!! ;)
__________________

Jupiter Hosting, Inc.
Vice President, Business Development
kc (AT) jupiterhosting.com
KC is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.