基於文本的訪客簽到簿_PHP教程

來源:互聯網
上載者:User
一個很偶然的機會,在網上看到了有人用PHP+MYSQL作了一個訪客簽到簿, 當時覺得很有用處所以自己也很 想搞一個。但是用MYSQL覺得有點在材小用,所以就搞了一個基於文本的訪客簽到簿。其功能與我在網上看 到的用MYSQL作的差不多,在這裡我將其源碼公布,希望它對放大網友學習PHP有所協助。限於本人的水平, 其中定有BUG,還希望朋友發現了不要忘告訴我一下。本簽到簿由要兩個檔案組成:一個是存放簽到資訊的sign.txt檔案, 該檔案可以由NOTEPAD來建立;第二個 是處理資訊的sign.php檔案。在斑竹園的首頁有它的示範,歡迎去看看。下面
就是sign.php的原始碼:
sign.php
if(isset($name)&&isset($msg)){
$name=ltrim($name);
$t=date(y年m月d日);
$dat="[".$t."]";
$msg=ltrim($msg);
$name=trim($name);
$msg=trim($msg);
$pristr=$name."  ".$dat." ".$msg."\n";
$f=fopen("sign.txt","a");
fwrite($f,$pristr);
fclose($f);
}
$file=file("sign.txt");
if(!isset($pagenum)){
$pagenum=1;
}
$lesssign=0;
$num=count($file);
$dispnumed=6*($pagenum-1);
$dispnumbeg=$num-$dispnumed;
$artnumeof1=6*$pagenum;
$isdispnum=$num-$artnumeof1;
if($isdispnum<=0){
$dispnumeof=1;
$lesssign=1;
}
else{
$dispnumeof=$isdispnum+1;
}
$sign=0;
$pagec=0;
for($icount=0;($icount<$num)&&($sign==0);$icount+=6){
for($i=0;$i<=6;$i++){
if(($icount*6+$i)==$num){
$sign=1;
}
}
$pagec++;
}
$pagecount=$pagec;
echo"









































"; $fuhao="◇ "; $color=e9eae9; $iscolor=0; $lessnum=5; echo" "; for($i=$dispnumbeg;$i>=$dispnumeof;$i--){ $linknum=$num-$i; $lessnum--; $stringmsg1=$file[($i-1)]; $stringmsg2=strrev($stringmsg1); $stringmsg3=strstr($stringmsg2,"psbn"); $stringmsg=strrev($stringmsg3); $stringlink=strstr($file[($i-1)],"http"); $dispvar=$fuhao.$stringmsg; echo" "; if($iscolor==0){ $color=ffffff; $iscolor=1; } else{ $color=e9eae9; $iscolor=0; } } if($lesssign==1){ for($iless=$lessnum;$iless>0;$iless--){ echo" "; if($iscolor==0){ $color=ffffff; $iscolor=1; } else{ $color=e9eae9; $iscolor=0; } } } echo" "; echo""; echo" "; echo"
";
echo"斑竹園簽到簿";
echo"
";
echo$dispvar;
echo "";
echo"";
echo$stringlink;
echo"";
echo"
";
echo $fuhao."
\n";
echo"
";
?>

http://www.bkjia.com/PHPjc/315547.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/315547.htmlTechArticle一個很偶然的機會,在網上看到了有人用PHP+MYSQL作了一個訪客簽到簿, 當時覺得很有用處所以自己也很 想搞一個。但是用MYSQL覺得有點在材...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.