#1: Random Affiliate
Code:
<?php
srand ((double) microtime() * 1000000);
$randnum = rand(1,5);
$affiliateimg = array(
"http://nitrox.uni.cc/img/links/zymic.gif",
"http://nitrox.uni.cc/img/links/arialvision.jpg",
"http://nitrox.uni.cc/img/links/mathibus.jpg",
"http://nitrox.uni.cc/img/links/toostrange.gif",
"http://nitrox.uni.cc/img/links/spiritdesigns.jpg",
);
$affiliatelink = array(
"http://topsites.bvdesigns.net/in.php?uid=496&id=068",
"http://www.arialvision.com",
"http://www.mathibus.com",
"http://www.toostrange.de",
"http://www.spiritdesigns.net",
);
?>
<a href=http://www.htmlforums.com/archive/index.php/"<?php echo $affiliatelink[$randnum]; ?>" target="_blank"><img src="<?php echo $affiliateimg[$randnum]; ?>" border="0" width="88" height="31" alt=""></a>
Problem: Sometimes it displays a broken image with a link that goes to the page you are currently on.
EDIT
Fix: Change $randnum = rand(1,5); to $randnum = rand(0,4);
One problem left!
#2: IN Click Counter
Well I want to track how many hits I am getting from my affiliates. I want to assign a number to each one. For example -- index.php?in=1 ... then it would record a hit from affiliate #1. So I tried making the script.
Here's what I came up with:
<?php
$in = stripslashes($in);
// <!-- m --><a class="postlink" href="http://www.arialvision.com/">http://www.arialvision.com/</a><!-- m -->
if ($in=="1") {
$file=fopen("/home/nitrox/public_html/click/i-1.txt","r+");
$count=fread($file,filesize("/home/nitrox/public_html/click/i-1.txt"));
fclose($file);
$count ++;
$file=fopen("/home/nitrox/public_html/click/i-1.txt","w+");
fputs($file, $count);
fclose($file);
}
// <!-- m --><a class="postlink" href="http://www.mathibus.com/">http://www.mathibus.com/</a><!-- m -->
if ($in=="2") {
$file=fopen("/home/nitrox/public_html/click/i-2.txt","r+");
$count=fread($file,filesize("/home/nitrox/public_html/click/i-2.txt"));
fclose($file);
$count ++;
$file=fopen("/home/nitrox/public_html/click/i-2.txt","w+");
fputs($file, $count);
fclose($file);
}
// <!-- m --><a class="postlink" href="http://www.toostrange.de">http://www.toostrange.de</a><!-- m -->
if ($in=="3") {
$file=fopen("/home/nitrox/public_html/click/i-3.txt","r+");
$count=fread($file,filesize("/home/nitrox/public_html/click/i-3.txt"));
fclose($file);
$count ++;
$file=fopen("/home/nitrox/public_html/click/i-3.txt","w+");
fputs($file, $count);
fclose($file);
}
// <!-- m --><a class="postlink" href="http://topsites.bvdesigns.net/?uid=496">http://topsites.bvdesigns.net/?uid=496</a><!-- m -->
if ($in=="4") {
$file=fopen("/home/nitrox/public_html/click/i-4.txt","r+");
$count=fread($file,filesize("/home/nitrox/public_html/click/i-4.txt"));
fclose($file);
$count ++;
$file=fopen("/home/nitrox/public_html/click/i-4.txt","w+");
fputs($file, $count);
fclose($file);
}
// <!-- m --><a class="postlink" href="http://mikies.cybiker.com/topsites">http://mikies.cybiker.com/topsites</a><!-- m -->
if ($in=="5") {
$file=fopen("/home/nitrox/public_html/click/i-5.txt","r+");
$count=fread($file,filesize("/home/nitrox/public_html/click/i-5.txt"));
fclose($file);
$count ++;
$file=fopen("/home/nitrox/public_html/click/i-5.txt","w+");
fputs($file, $count);
fclose($file);
}
?>
Well this was working when I tested it, but when I put it on the very top of index.php -- it doesn't work anymore. So, since I'm asking here I might as well ask how to do what I REALLY wanted it to do. I want it to record all to one file. So assign each affiliate a number. E.g. make a file called click.txt and the script would write to that. It could look something like this:
// Affiliate #1
5
// Affiliate #2
85
// Affiliate #3
20
// Affiliate #4
32
Etc. So when someone went to index.php?in=1 it would add 1 to the affiliate #1 row. I had no clue how to do this, so I made seperate files for each. So since I'm asking, can someone tell me how I can do it all in one file?
I'd really appreciate it if you could help me get these two scripts working. Thanks!doing all in one file will be very difficult. use a db instead.I got a friend of mine to script for me.
Thanks guys.
Code:
<?php
srand ((double) microtime() * 1000000);
$randnum = rand(1,5);
$affiliateimg = array(
"http://nitrox.uni.cc/img/links/zymic.gif",
"http://nitrox.uni.cc/img/links/arialvision.jpg",
"http://nitrox.uni.cc/img/links/mathibus.jpg",
"http://nitrox.uni.cc/img/links/toostrange.gif",
"http://nitrox.uni.cc/img/links/spiritdesigns.jpg",
);
$affiliatelink = array(
"http://topsites.bvdesigns.net/in.php?uid=496&id=068",
"http://www.arialvision.com",
"http://www.mathibus.com",
"http://www.toostrange.de",
"http://www.spiritdesigns.net",
);
?>
<a href=http://www.htmlforums.com/archive/index.php/"<?php echo $affiliatelink[$randnum]; ?>" target="_blank"><img src="<?php echo $affiliateimg[$randnum]; ?>" border="0" width="88" height="31" alt=""></a>
Problem: Sometimes it displays a broken image with a link that goes to the page you are currently on.
EDIT
Fix: Change $randnum = rand(1,5); to $randnum = rand(0,4);
One problem left!
#2: IN Click Counter
Well I want to track how many hits I am getting from my affiliates. I want to assign a number to each one. For example -- index.php?in=1 ... then it would record a hit from affiliate #1. So I tried making the script.
Here's what I came up with:
<?php
$in = stripslashes($in);
// <!-- m --><a class="postlink" href="http://www.arialvision.com/">http://www.arialvision.com/</a><!-- m -->
if ($in=="1") {
$file=fopen("/home/nitrox/public_html/click/i-1.txt","r+");
$count=fread($file,filesize("/home/nitrox/public_html/click/i-1.txt"));
fclose($file);
$count ++;
$file=fopen("/home/nitrox/public_html/click/i-1.txt","w+");
fputs($file, $count);
fclose($file);
}
// <!-- m --><a class="postlink" href="http://www.mathibus.com/">http://www.mathibus.com/</a><!-- m -->
if ($in=="2") {
$file=fopen("/home/nitrox/public_html/click/i-2.txt","r+");
$count=fread($file,filesize("/home/nitrox/public_html/click/i-2.txt"));
fclose($file);
$count ++;
$file=fopen("/home/nitrox/public_html/click/i-2.txt","w+");
fputs($file, $count);
fclose($file);
}
// <!-- m --><a class="postlink" href="http://www.toostrange.de">http://www.toostrange.de</a><!-- m -->
if ($in=="3") {
$file=fopen("/home/nitrox/public_html/click/i-3.txt","r+");
$count=fread($file,filesize("/home/nitrox/public_html/click/i-3.txt"));
fclose($file);
$count ++;
$file=fopen("/home/nitrox/public_html/click/i-3.txt","w+");
fputs($file, $count);
fclose($file);
}
// <!-- m --><a class="postlink" href="http://topsites.bvdesigns.net/?uid=496">http://topsites.bvdesigns.net/?uid=496</a><!-- m -->
if ($in=="4") {
$file=fopen("/home/nitrox/public_html/click/i-4.txt","r+");
$count=fread($file,filesize("/home/nitrox/public_html/click/i-4.txt"));
fclose($file);
$count ++;
$file=fopen("/home/nitrox/public_html/click/i-4.txt","w+");
fputs($file, $count);
fclose($file);
}
// <!-- m --><a class="postlink" href="http://mikies.cybiker.com/topsites">http://mikies.cybiker.com/topsites</a><!-- m -->
if ($in=="5") {
$file=fopen("/home/nitrox/public_html/click/i-5.txt","r+");
$count=fread($file,filesize("/home/nitrox/public_html/click/i-5.txt"));
fclose($file);
$count ++;
$file=fopen("/home/nitrox/public_html/click/i-5.txt","w+");
fputs($file, $count);
fclose($file);
}
?>
Well this was working when I tested it, but when I put it on the very top of index.php -- it doesn't work anymore. So, since I'm asking here I might as well ask how to do what I REALLY wanted it to do. I want it to record all to one file. So assign each affiliate a number. E.g. make a file called click.txt and the script would write to that. It could look something like this:
// Affiliate #1
5
// Affiliate #2
85
// Affiliate #3
20
// Affiliate #4
32
Etc. So when someone went to index.php?in=1 it would add 1 to the affiliate #1 row. I had no clue how to do this, so I made seperate files for each. So since I'm asking, can someone tell me how I can do it all in one file?
I'd really appreciate it if you could help me get these two scripts working. Thanks!doing all in one file will be very difficult. use a db instead.I got a friend of mine to script for me.
Thanks guys.