search
Homephp教程php手册基于文本的访客签到簿_php基础

一个很偶然的机会,在网上看到了有人用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      $dispnumeof=1;
      $lesssign=1;
    }
    else{
      $dispnumeof=$isdispnum+1;
    }
    $sign=0;
    $pagec=0;
     for($icount=0;($icount      for($i=0;$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"斑竹园签到簿";
    echo"
";
       echo$dispvar;
       echo "基于文本的访客签到簿_php基础";
       echo"";
       echo$stringlink;
       echo"
";
       echo"
";
       echo $fuhao."
\n";
       echo"
";
    echo"称呼:";
    echo"";
    echo"地址:";
    echo"";
    echo"";
    echo"
";
   ?> 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools