to platinum(白金): 好像不能用var定义变量,会出先Parse error: parse error in \webroot\index.php on line 20的错!用@倒是很好使,用@是申明一个新变量吗? 源程序: ×××××××××××××××××××××××××××××××××××××× <?php $counterFile ="counter.txt"; $sort; function displayCounter($counterFile,&$num) { $fp = fopen($counterFile,"rw"); $num = fgets($fp,5); $num += 1; exec( "rm -rf $counterFile"); exec( "echo $num > $counterFile"); } if (!file_exists($counterFile)) { exec( "echo 0 > $counterFile"); }displayCounter($counterFile,&$sort); $logfile="log.txt"; $fd=fopen($logfile,"a"); $ip=$REMOTE_ADDR; $temp=$GLOBALS["HTTP_REFERER"]; $str=$ip."...............".date("Y-m-d")."......第".$sort."贵宾".$temp."\r\n"; fputs($fd,$str,4096); fclose($fd); ?> ×××××××××××××××××××××××××××××××××××××× 出错: ×××××××××××××××××××××××××××××××××××××× Warning: Undefined variable: sort in e:\users\huang\webroot\index.php on line 20Warning: Unable to fork [rm -rf counter.txt] in e:\users\huang\webroot\index.php on line 25Warning: Unable to fork [echo 1 > counter.txt] in e:\users\huang\webroot\index.php on line 26Warning: Undefined index: HTTP_REFERER in e:\users\huang\webroot\index.php on line 36 求救!!!!谢谢!
这些不是大错误, 在程序最开头加上 error_reporting(0);
to qsnake(呵呵): 怎么能这样说呢!不能写文件! 还有你说那样有什么安全漏洞?能否告知一二?
if(!isset($变量名))
定义 $变量名;
OK啦,不会再出现变量没有定义的错误啦
这是我的亲身体会
好像不能用var定义变量,会出先Parse error: parse error in \webroot\index.php on line 20的错!用@倒是很好使,用@是申明一个新变量吗?
源程序:
××××××××××××××××××××××××××××××××××××××
<?php
$counterFile ="counter.txt";
$sort;
function displayCounter($counterFile,&$num) {
$fp = fopen($counterFile,"rw");
$num = fgets($fp,5);
$num += 1;
exec( "rm -rf $counterFile");
exec( "echo $num > $counterFile");
}
if (!file_exists($counterFile)) {
exec( "echo 0 > $counterFile");
}displayCounter($counterFile,&$sort);
$logfile="log.txt";
$fd=fopen($logfile,"a");
$ip=$REMOTE_ADDR;
$temp=$GLOBALS["HTTP_REFERER"];
$str=$ip."...............".date("Y-m-d")."......第".$sort."贵宾".$temp."\r\n";
fputs($fd,$str,4096);
fclose($fd);
?>
××××××××××××××××××××××××××××××××××××××
出错:
××××××××××××××××××××××××××××××××××××××
Warning: Undefined variable: sort in e:\users\huang\webroot\index.php on line 20Warning: Unable to fork [rm -rf counter.txt] in e:\users\huang\webroot\index.php on line 25Warning: Unable to fork [echo 1 > counter.txt] in e:\users\huang\webroot\index.php on line 26Warning: Undefined index: HTTP_REFERER in e:\users\huang\webroot\index.php on line 36
求救!!!!谢谢!
在程序最开头加上
error_reporting(0);
怎么能这样说呢!不能写文件!
还有你说那样有什么安全漏洞?能否告知一二?
你的系统是windows,“rm -rf"这些是 linux的命令,当然不行
exec这个函数不记得在windows下是否能用。
你的计数器文件,不必每次都删除了再重建啊,每次修改文件内容就行了。