Kan ikke få et Baggrundsbillede ind (PHP)
hej hejNu fik jeg endelig min tæller op men nu gider den ikke at vise baggrund. Hjælp!!! Jeg synes jeg har prøvet mange forskellige metoder, men jeg er heller ikke særlig grov til php.
Her er mit tællerscript: Uanset hvor jeg placere mit html baggrundsbillede scipt virker det ikke.
<?php
/*
############################
#### ip/txtCounter v1.2 ####
############################
you can just copy this script to your homepage (eg main page)
or you can use "include(./counter.php)" but if you do so you
need to set the variables yourself!
for this script you need 3 files:
- counter.php -> thats the file you are reading. You can copy all the code to your index.php
- iplog.txt -> can be a blank txt-file, CHMOD 0777
- countlog.txt -> should contain nothing but a number, CHMOD 0777
If the permissions are not set properly the counter wont count.
But you dont get any error message!
setup: http://yourdomain.tld/filename.php?output=1
this will give you some output plus the (very easy) setup
but you still need to set some variables in this file!
to reset the iplog.txt:
http://yourdomain.tld/filename.php?reset=1
you might want to set up a cronjob that does it for you
crojob that resets iplog.txt at 1AM:
0 1 * * * wget http://yourdomain.tld/?reset=1
(with "wget" you can do it from a different server too!)
This script was made by Claude Martin
Homepage: http://veganismus.ch/iptxtcnt/
Do whatever you like to do with it!
*/
//set this:
/*this will be your "password"
note: there is no password for ?reset=1
but you will have to use:
http://yourdomain.tld/filename.php?output=YourPasswordHere
*/
$pass = "1";
$amount = 10; //if you want the script to store 10 IPs enter 10 here!
//this is only a good thing if you use include():
//$countertxt = "Visits since " . filemtime(__FILE__) . ": ";
$countertxt = "You are visitor #";
$lastupdatetxt = "Last Update: ";
/*the script needs the name of the file
if you use include: $file = "index.php"; (or whatever the name of the file is
if you copy paste all this code to the index-file: */
$file = basename(__FILE__); //name of this file - change it if you get an error message
$filepath = __FILE__; //here I need the hole path
/* this would be something like this
last Update: Wednesday, 01th of January 2003 @ 05:51:38 AM
but you might want to use an european format:
$dateformat = "d. m. Y @ H:i";
More info about dates: http://de3.php.net/manual/en/function.date.php
*/
$dateformat = "l, dS of F Y @ H:i:s T";
/* here you can enter you own IP. this only makes sense if you have a static IP!
Then the counter ignores you. as the webmaster you have to check your
page very often but you dont want to boost the counter. */
$webmaster = "Your IP here";
echo "<font size='2' color='#000000'>"; //format the text here
$pre = "<strong>"; //this tag makes the count and date bold
$suf = "</strong>"; //$countertxt and $lastupdatetxt are not affected by this tags!
//you dont need to change anything of the following script (but you can if you want to)
/* IP */
$ip = file("iplog.txt");
/* opens iplog.txt -> $ip[0] = 123.12.132.12; $ip[2] = 234.23.234.13; and so on
when you look at the file the newest entry will be in the first line
but here I need it as the last one so I resort it
*/
krsort($ip);
reset ($ip);
$k = 0;
while (list ($key, $val) = each ($ip)) {
$rip[$k] = $val; //this is ReverseIP
$k++;
}
//get IP of current client
if (getenv(HTTP_CLIENT_IP)){ $clientip=getenv(HTTP_CLIENT_IP); } else { $clientip=getenv(REMOTE_ADDR); }
$isnew = "true"; //assuming that the client is a new one
$end = count($rip); //thats the number of IPs in $rip
if ($output == $pass) {
echo "<p><hr>Output enabled!<p>";
echo "Your IP is: $clientip\n";
if ( $clientip == $webmaster ) {echo " - Hello Master!";} else {echo " - that's NOT the IP of the webmaster!";}
//if ( $clientip == $webmaster ) {echo " - Hello Master!";} else {exit;} //you can use this line instead for more security
echo "<br>Here are the stored IPs:\n<p>";
}
for($i=0;$i<$end;$i++)
{
if ($output == $pass) { echo "<a href='http://samspade.org/t/lookat?a=" . trim($rip[$i], "\n") . "' target='_blank'>$rip[$i]</a><br>\n"; }
if ($reset) { $rip[$i] = ""; $isnew = "false";} //this will reset the list. you can do this with a cronjob
if( $clientip . "\n" == $rip[$i]) {$isnew = "false";} //so he was here before!
}
if ( $clientip == $webmaster ) {$isnew = "false";}
if ($isnew=="true"){
$newkey = count($rip) + 1; //thats what the counter does: he's counting!
$rip[$newkey] = $clientip . "\n"; //add new IP (with linebreak!)
}
// resort the IPs again so they can be saved
krsort($rip);
reset ($rip);
$k = 0;
while (list ($key, $val) = each ($rip)) {
$ip[$k] = $val; //this is something like iplog.txt IP but with the new IP
$k++;
}
for($i=0;$i<$amount;$i++)
{
$iplog = $iplog . $ip[$i]; //note: there already is a linebreak!
}
$log1 = @fopen("iplog.txt","w"); // opens to write
@fwrite($log1, $iplog);
@fclose($log1);
/* counter */
$log2 = fopen("countlog.txt","r"); //opens countlog.txt to read
$count = fgets($log2,1000);
fclose($log2);
if ($output == $pass) { echo "<p>Click <a href='./$file?reset=1'>here</a> to reset the list. (All IPs will be deleted - the counter will NOT be reset!)\n";
echo "\n<br><form action='./$file' method='post'>Password: <input name='pwd' type='password' value='1' size='5' maxlength='20'> New value: <input name='setcount' type='text' value='?' size='5' maxlength='20'><input type='submit' name='Submit' value='Set Counter'></form><hr>\n";
}
if ($isnew == "true") {$count=$count + 1 ;}
if ($setcount != "" & $pwd == $pass) {$count=$setcount; $isnew="true";} // sets new value
echo $countertxt;
echo $pre . $count . $suf ;
echo "\n<br>" ;
if ($isnew == "true")
{
$log2 = @fopen("countlog.txt","w"); // saves the new value to ountlog.txt
@fwrite($log2, $count);
@fclose($log2);
}
/* Last Update */
echo $lastupdatetxt;
echo $pre;
echo date($dateformat, filemtime($filepath));
echo "$suf</font>";
?>
