PHP实用小程序(七)
<? //用COOKIE保存投票人的投票记录 if($vote && !$already_voted) SetCookie("already_voted","1"); ?> <html> <head> <title>简易投票系统</title> </head> <body alink="#FF0000" link="#000099" vlink="#CC6600" topmargin="8" leftmargin="0" bgColor="#FFFFFF"> <br><center><font color=green>简易投票系统-学习PHP 4.0容易吗?</font></center><br> <table cellspacing=0 bordercolordark=#FFFFFF width="60%" bordercolorlight=#000000 border=1 align="center" cellpadding="2"> <tr> <td align="center"> <form action="<?echo $PHP_SELF?>" method="post" name="frmVote"> <br>添加一个投票类别: <input type="text" name="newvoteitem" size="20" maxlength="30"><input type=submit value="添 加"><br><br> <? //连接数据库 mysql_connect("localhost","root",""); $mysqldb="test"; if($newvoteitem) { //添加新的投票项 if(!mysql_db_query($mysqldb,"insert into vote values ('$newvoteitem',0)")) { echo "添加出错!<br>"; } } //用COOKIE保存投票人的投票记录 if($vote && $already_voted) { echo "<font color=red>请您不要重复投票,谢谢!</font><br><br>\n"; } else if($vote) { if(!mysql_db_query($mysqldb,"update vote set votes=votes+1 where name='$vote'")) { echo "投票出错!<br>"; } } //计算总投票数 $result=mysql_db_query($mysqldb,"select sum(votes) as sum from vote"); if($result) { $sum=(int) mysql_result($result,0,"sum"); mysql_free_result($result); } //读出投票项数据 $result=mysql_db_query($mysqldb,"select * from vote order by votes DESC"); ?> <table cellspacing=0 bordercolordark=#FFFFFF width="90%" bordercolorlight=#000000 border=1 align="center" cellpadding="2"> <tr> <td align="center" width="15%">投票</td> <td align="center" width="60%">选项</td> <td align="center" width="25%">票数/比例</td> </tr> <? //循环读出投票项 while($row=mysql_fetch_row($result)) { //计算百分比 $per=(int)(100*$row[1]/$sum); ?> <tr> <td align="center"><input type=radio name=vote value="<?echo $row[0]?>"></td> <td><?echo $row[0]?></td> <td align="right"><?echo $row[1]?><img src="blue.gif" height=10 width="<?echo $per?>"><?echo $per?></td> </tr> <? } //释放结果集 mysql_free_result($result); ?> </table> <br><input type=submit value="投 票"> </form> </td> </tr> </table> </BODY> </HTML>
<? require("config.php"); $sqldo="select count(*) as title from $mytable where sub_id<1"; $result=mysql_query($sqldo); $message_count=mysql_result($result,0,"title"); ?> <table border="0" width="75%" cellspacing="0" cellpadding="0" align="center"> <tr bgcolor="FFEAA2"> <td width="100%" height="18" valign="bottom" align="right">留言总数:<font color=red><?echo $message_count?></font> | <a href="guestbook.php">看留言</a> </td> </tr> </table> <? if ($doadd) { $name=htmlspecialchars($name); $email=htmlspecialchars($email); $comefrom=htmlspecialchars($comefrom); $homepage=htmlspecialchars($homepage); $icq=htmlspecialchars($icq); $oicq=htmlspecialchars($oicq); $image=htmlspecialchars($image); $comment=htmlspecialchars($comment); if ($name&&$comment) { $add_time=date("Y")."-".date("m")."-".date("d")." ".date("H").":".date("i").":".date("s"); $result=mysql_query("insert into $mytable (sub_id,name,email,comefrom,homepage,icq,oicq,image,comment,password,add_time) values ('$sub_id','$name','$email','$comefrom','$homepage','$icq','$oicq','$image','$comment','$password','$add_time')"); if ($notify) { $message="$comment\n\n$name $email\n\n$add_time"; mail($admin_email, "有新的留言: ".$name, $message, "From: ".$email."\nReply-To: ".$email."\nX-Mailer: PHP/" . phpversion()); } echo "<p align=\"center\">您的留言发送成功,谢谢!<a href=\"guestbook.php\">查看留言请返回</a></p>\n"; } else { echo "<p align=\"center\">姓名和内容必须填写!<a href=\"JavaScript:history.back()\">返回</a></p>\n"; } } else { if ($reply&&$recid) { echo "<p align=\"center\">回复留言</p>"; $sub_id="<input type=\"hidden\" name=\"sub_id\" value=\"$recid\">"; } else { echo "<p align=\"center\">填写留言</p>"; } echo "<form method=\"POST\" action=\"add.php\"> <table border=\"0\" width=\"75%\" align=\"center\"> <tr> <td> <div align=\"center\"> <table border=\"0\" width=\"80%\" cellpadding=\"20\" cellspacing=\"0\"> <tr> <td width=\"100%\" bgcolor=\"FFFBEC\">姓名: <input type=\"text\" name=\"name\" size=\"25\">$sub_id 电子邮件: <input type=\"text\" name=\"email\" size=\"25\"><br> 来自: <input type=\"text\" name=\"comefrom\" size=\"25\"> 主页地址: <input type=\"text\" name=\"homepage\" size=\"25\"><br> OICQ: <input type=\"text\" name=\"oicq\" size=\"25\"> <p>表情: "; $con=1; while ( list( $key, $val ) = each( $images ) ) { $checked=""; if ($con==1) { $checked=" checked"; $con=0; } echo "<input type=\"radio\" value=\"$key\" name=\"image\"$checked><img border=\"0\" src=\"$imgdir/$key\" alt=\"$val\"> "; } echo "</p>\n <p><b>留言:</b><br> <textarea rows=\"4\" name=\"comment\" cols=\"72\"></textarea></p> <p><input type=\"submit\" value=\"发送留言\" name=\"doadd\"> <input type=\"reset\" value=\"擦掉重写\" name=\"B2\"></td> </tr> </table> </div> </td> </tr> </table> </center> </div> </form> "; } ?>
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>PHP4.0 +MYSQL 留言本</title> <style type="text/css"> <!-- input { font-size:9pt; } A:link {text-decoration: underline; font-size:9pt;color:000059} A:visited {text-decoration: underline; font-size:9pt;color:000059} A:active {text-decoration: underline; font-size:9pt} A:hover {text-decoration:underline;color:red} body,table {font-size: 9pt} tr,td{font-size:9pt} --> </style> </head> <body alink="#FF0000" link="#000099" vlink="#CC6600" topmargin="8" leftmargin="0" bgColor="#FFFFFF"> <center><font color=red size=6>PHP4.0+MYSQL 留言本</font></center><br> <? $dbuser=mysql_connect('localhost','root',''); $mydb=mysql_select_db('test',$dbuser); $mytable="guestbook"; // 表名 $page_size=8; $notify=1; $imgdir="images"; $images=array( "say.gif" => "随便说说", "happy.gif" => "高兴", "sad.gif" => "悲伤", "toohappy.gif" => "大笑", "wilk.gif" => "眨眼", "warning.gif" => "警告", "question.gif" => "问题", "reply.gif" => "回答", "attention.gif" => "注意", "agree.gif" => "同意", "other.gif" => "号外" ); ?>
<? require("config.php"); if (!$page) { $page=1; } $sqldo="select count(*) as title from $mytable where sub_id<1"; $result=mysql_query($sqldo); $message_count=mysql_result($result,0,"title"); $page_count=ceil($message_count/$page_size); $offset=($page-1)*$page_size; $sqldo="select * from $mytable where sub_id<1 order by id desc limit $offset, $page_size"; $result=mysql_query($sqldo); ?> <table border="0" width="70%" cellspacing="0" cellpadding="0" align="center"> <tr bgcolor="FFEAA2"> <td width="100%" height="18" valign="bottom" align="right">留言总数:<font color=red><?echo $message_count?></font> | <a href="add.php">写留言</a> </td> </tr> </table> <br> <table border="0" width="70%" cellspacing="0" cellpadding="0" align="center"> <? if($result) { while($myrow=mysql_fetch_array($result)) { listtopic($myrow,"70%",1); $sqldo2="select * from $mytable where sub_id=$myrow[id] order by add_time"; $result2=mysql_query($sqldo2); if($result2) { $rows2=mysql_num_rows($result2); if($rows2) { ?> <tr> <td width="100%"> <table border="0" width="100%" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="5%" bgcolor="FFFECC" align="center">回<br>复</td> <td width="95%"> <? while($myrow2=mysql_fetch_array($result2)) { listtopic($myrow2,"100%",0); echo " </table>"; } ?> </td> </tr> </table> </td> </tr> <? } } echo " </table> <br> "; } $prev_page=$page-1; $next_page=$page+1; echo " <p align=\"center\">| "; if ($page<=1){ echo "第一页 | "; } else{ echo "<a href='$PATH_INFO?page=1'>第一页</a> | "; } if ($prev_page<1){ echo "上一页 | "; } else{ echo "<a href='$PATH_INFO?page=$prev_page'>上一页</a> | "; } if ($next_page>$page_count){ echo "下一页 | "; } else{ echo "<a href='$PATH_INFO?page=$next_page'>下一页</a> | "; } if ($page>=$page_count){ echo "最后一页 |</p>\n"; } else{ echo "<a href='$PATH_INFO?page=$page_count'>最后一页</a> |</p>\n"; } } function listtopic($myrow,$this_table_width,$is_reply) { global $imgdir; $comment=nl2br($myrow[comment]); if ($myrow[email]) { $line1_left="<img border=\"0\" src=\"$imgdir\\$myrow[image]\"> <a href=\"mailto:$myrow[email]\">$myrow[name]</a>"; } else { $line1_left="<img border=\"0\" src=\"$imgdir\\$myrow[image]\"> $myrow[name]"; } if ($myrow[comefrom]) { $line1_left .= " 来自: $myrow[comefrom]"; } else { $line1_right=""; } if ($myrow[oicq]) { $line1_right .= " <img border=\"0\" src=\"$imgdir\\oicq.gif\" alt=\"OICQ:$myrow[oicq]\">"; } if ($myrow[homepage]) { $line1_right .= " <a href=\"$myrow[homepage]\" target=\"_blank\"><img border=\"0\" src=\"$imgdir\\homepage.gif\" alt=\"主页:$myrow[homepage]\"></a>"; } if ($is_reply) { $toolsbar="<a href=\"add.php?reply=1&recid=$myrow[id]\" $table_head_bodystyle>回复</a> "; } $toolsbar .= "修改 删除 "; ?> <table border="0" width="<?echo $this_table_width?>" align="center"> <tr> <td width="100%" bgcolor="fff8d9"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="50%"><?echo $line1_left?></td> <td width="50%" align="right"><?echo $line1_right?> </td> </tr> </table> </td> </tr> <tr> <td width="100%" bgcolor="FFFBEC"><?echo $comment?></td> </tr> <tr> <td width="100%" bgcolor="FFFBEC"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="50%">留言时间:<?echo $myrow[add_time]?></td> <td width="50%" align="right"><?echo $toolsbar?></td> </tr> </table> </td> </tr> <? } ?>
<? // 本例来自与ZEND网站,由HUNTE整理 if($action1){ //如果文件上传,进行处理 ?> <html> <head> <title>多文件上传</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body bgcolor="#FFFFFF" text="#000000"> <p><font face="Arial, Helvetica, sans-serif"><font size="+1">文件上传处理</font><br><br> <? set_time_limit(60); // 以确保较大文件上传 $path1 = dirname($PATH_TRANSLATED)."/upload/"; //输出上传路径; //print $path1."<br>"; // assign our path in a form PHP for Windows understands for($i=1;$i<3;$i++) { $temp1="file".$i; $temp2="file".$i."_name"; $source=$$temp1; $source_name=$$temp2; // print $temp."=".$$temp."<br>"; //print $file1_name; //print $file2_name; //exit; //***************** //$source = $file1; //$source_name = $file1_name; //print $source."<br>"; //print $source_name; //exit; if(($source <> "none")&&($source <> "")) { // see if the file exists; non-existing file has name of "none" if($error1 <> 1) { // no need to copy a file if directory not write-enabled $dest = $path1.$source_name; // append file name to our path if(copy($source,$dest)){ // copy the file from the temp directory to the upload directory, and test for success echo "$source has been uploaded<br>\n"; $imagesize = getimagesize($dest); switch($imagesize[2]) { case 0: echo "<br> Image is a unknown <br>"; //unlink($dest); exit; case 1: echo "<br> Image is a GIF <br>"; echo "$dest has a width of $imagesize[0]<br>"; echo "$dest has a height of $imagesize[1]<br>"; $newname = $path1; $newname .=$i.time() . ".gif"; if(copy($dest,$newname)) { //echo "<br> GIF Rename Successful from $dest to $newname"; }else { //echo "<br> GIF Rename Unsuccessful"; } //unlink ($dest); break; case 2: echo "<br> Image is a JPG <br>"; echo "$dest has a width of $imagesize[0]<br>"; echo "$dest has a height of $imagesize[1]<br>"; $newname = $path1; $newname .=$i.time() . ".jpg"; if(copy($dest,$newname)) { //echo "<br> JPG Rename Successful from $dest to $newname"; }else { //echo "<br> JPG Rename Unsuccessful"; } //unlink ($dest); break; case 3: echo "<br> Image is a PNG <br>"; echo "$dest has a width of $imagesize[0]<br>"; echo "$dest has a height of $imagesize[1]<br>"; $newname = $path1; $newname .=time() . ".png"; if(copy($dest,$newname)) { //echo "<br> PNG Rename Successful from $dest to $newname"; }else { //echo "<br> PNG Rename Unsuccessful"; } //unlink ($dest); break; } }else { echo "Upload directory not write-enabled\n"; // you need to write-enable the upload directory $error1 = 1; // set flag } } //unlink($source); // delete the file from the temp directory } ?> <image src="upload/<? print basename($newname)?>"> <? } //end for ?> <br><a href="90.php">Back</a> </font></p> </body> </html> <? } else { ?> <html> <head> <title>多文件上传</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body bgcolor="#FFFFFF" text="#000000"> <p><font face="Arial, Helvetica, sans-serif"><font size="+1">File Upload</font><br><br> If your browser is upload-enabled, you will see "Browse" (Netscape, Internet Explorer) or ". . ." (Opera) buttons below. Use them to select file(s) to upload, then click the "Upload" button. After the files have been uploaded, you will see a results screen.<br> <form method="post" enctype="multipart/form-data" action="90.php"> <input type="hidden" name="MAX_FILE_SIZE" value="800000"> <input type="hidden" name="action1" value="1"> File 1: <input type="file" name="file1" size="30"><br> File 2: <input type="file" name="file2" size="30"><br> <br> <input type="submit" value="Upload"> </form> </font></p> </body> </html> <? } ?>
<?php //计数器 //本计数器无需数据库支持。 //说明: // $five,$four等标量表示零的个数,放在数字前构成6位 //的来访者数目。当然,如果你的网站 //浏览量十分巨大,你可以添加$six,$seven等等构成更大的数字显 //示来访者的数目。 function Counter() { $five="00000"; $four="0000"; $three="000"; $two="00"; $one="0"; $counter="counternumber.dat"; //存放访客数目的文件.dat格式 if (!file_exists($counter)) //判断文件是否存在,如果不存在以写方式建立一个文件 { $counter=fopen($counter,"w"); fputs($counter,"0"); fclose($counter); } else { $num=file($counter,"r"); //如果文件存在则读出文件,并加1 $num[0]+=1; if($num[0]<10){ //判断数字的大小,如果小于100000根据不同情况在前面 print "$five"."$num[0]"; //加上不同个数的0,为了凑够6位。 }elseif($num[0]<100){ print "$four"."$num[0]"; }elseif($num[0]<1000){ print "$three"."$num[0]"; }elseif($num[0]<10000){ print "$two"."$num[0]"; }elseif($num[0]<100000){ print "$one"."$num[0]"; }else{ print "$num[0]"; } } $fp=fopen($counter,"w"); //以写入文件方式打开文件 fputs($fp,"$num[0]"); //将加过1的数字放入文件中 fclose($fp); //关闭文件 } ?> <!-- 可以用<?php Counter()?>形式调用函数,并用html标记或 CSS样式单来修饰显示出的数字,如下所示 --> <html> <body> <U> <B> <FONT SIZE="9" face="verdana" COLOR="#ffcc00"> <?php Counter()?> </FONT> </B> </U> </body> </html>
<? highlight_file($filename); //高亮显示文件代码 ?>
<body bgcolor="#fafad2"> <? require ("phplist.inc"); if ($rootpath=="") {$rootpath=$htmlroot;} function filelist($pathname){ //遍历所有的文件和目录,$pathnam为起始目录,$searchs为搜索关键字 global $htmlroot; if (eregi("[/][.][.]$",$pathname)) { $temp=split("[/]",$pathname); $pathname=""; for ($tt=1;$tt<(count($temp)-2);$tt++) $pathname=$pathname."/".$temp[$tt]; } echo $pathname."<br>"; $handle=opendir($pathname); //打开目录 if (@chdir($pathname)) { //cd 进入目录,若无权限则不进入 $file = readdir($handle); //读出所有当前目录下的元素名,第一次读出为‘。’,指上层目录 while ($file = readdir($handle)) { //若有元素就进行以下处理 $fname=$pathname."/".$file; //将元素名与当前目录名结合组成完整的文件名,并赋值给$fname if ((is_file($file)) and (ereg("\.php[3]{0,1}$",$file) or ereg("\.htm[l]{0,1}$",$file))) //判断是否为文件并且是否以.php和.php3结尾 { $temppp=split($htmlroot,$fname); echo "<a href=$temppp[1]>".$file."</a> ".filesize($file)."bytes <a href=codeshow.php?filename=$fname><font size=-1>源文件</font></a><br>"; //findinfile($fname,$searchs); //调用findinfile函数 } elseif (is_dir($fname)) { //判断是否为目录 linkres($fname); //filelist($fname,$searchs);} //递归调用filelist函数 } } chdir(".."); //结束当前递归,返回上层 } closedir($handle); //关闭当前目录读取 } // function linkres($filename){ $tpath=split("/web/html",$filename); $turepath=$tpath[1]; ereg("[^\\\/\~]{0,}$",$filename,$res); //$ft=filetitle($filename); //if ($ft=="") $ft="无标题"; echo "<a href=phplist.php?rootpath=$filename>".$res[0]."</a> <dir><br>"; } // filelist($rootpath); ?> </body>
<html> <head> <Title>简易聊天室</title> </head> <body TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0> <TABLE width="100%" border="0" cellspacing="0" cellpadding="0"> <tr align="left" bgcolor="#666666"> <td height="20"> <? /*If you have ICQ List you vin here.*/ $uin = "20559508"; /*Dat file name. Make sure it is in the same folder*/ $talk_back_ok = "msg.txt"; /*Webmasters Image Location(put url not path)*/ $webmaster_image = "kmoo.gif"; /*Webmasters Name*/ $webmaster_name = "root"; /*Webmasters Password*/ $pass = ""; /*messages displayed*/ $help_lenght = 20; /*Home Long can the lake each message*/ $max_single_msg_lenght = 100000; $max_file_size = $help_lenght * $max_single_msg_lenght; ?></b></i> </td></tr> <tr bgcolor="#FFCC66"> <td><img src="pix.gif" width="1" height="4" alt=""></td> </tr></TABLE> <TABLE width="100%" border=0 cellspacing=0 cellpadding=0 bgcolor="#EFEFEF"> <tr bgcolor="#666666"><td align="left"> <TABLE width="100%" height="500" border=0 cellspacing=0 cellpadding=0 bgcolor="#EFEFEF"> <tr align="left"><td valign="top"><font size="-1" color="#666666"> <? $person = str_replace ("\n"," ", $person); $person = str_replace ("<", " ", $person); $person = str_replace (">", " ", $person); $person = stripslashes ($person); ?> <table width="100%" border="0"> <TR><form action="gorilla.php" method="post"><TD align="left"> <FONT SIZE="-1">妮称:</FONT><input type="text" name="person" size="12" maxlength="80" value="<? echo $person; ?>"> <FONT SIZE="-1"></FONT> <input type="text" name="message" size=60> <input type="submit" value="发言"> </TD></form></TR> <? /* check if file size is over maximum*/ $file_size= filesize($talk_back); if ($file_size > $max_file_size) { $lines = file($talk_back_ok); $a = count($lines); $u = $a - $help_lenght; for($i = $a; $i >= $u ;$i--){ $msg_old = $lines[$i] . $msg_old; } $deleted = unlink($talk_back_ok); $fp = fopen($talk_back_ok, "a+"); $fw = fwrite($fp, $msg_old); fclose($fp); } $msg = str_replace ("\n"," ", $message); $msg = str_replace ("\n"," ", $message); $msg = str_replace ("<", " ", $msg); $msg = str_replace (">", " ", $msg); $msg = stripslashes ($msg); if($person == $pass) { $sign = ("<img src= '$webmaster_image'> $webmaster_name"); } else { $sign = ($person); } if ($msg != "" && $person != ""){ $time = gmDate("h:i"); $fp = fopen($talk_back_ok, "a+"); $fw = fwrite($fp, "\n<tr><td><FONT SIZE=\"+1\"><b> $sign :</b></FONT><FONT SIZE=\"-2\" color=\"red\"><I>$time</I></FONT> :<FONT SIZE=\"-1\"> $msg<br></FONT></td></tr>"); fclose($fp); } ?> </table> </CENTER> </font></td></tr></TABLE></td></tr></TABLE> </body></html>
<html> <head> <Title> 聊天室 </title> </head> <META HTTP-EQUIV=Refresh CONTENT="5; URL=gorilla2.php"> <body bgcolor="#EFEFEF"> <? /*Dat file name. Make sure it is in the same folder*/ $talk_back_ok = "msg.txt"; /*Webmasters Name*/ /*Webmasters Password*/ /*messages displayed*/ $help_lenght = 15; /*Home Long can the lake each message*/ $max_single_msg_lenght = 100000; $max_file_size = $help_lenght * $max_single_msg_lenght; ?> <? /* check if file size is over maximum*/ $file_size= filesize($talk_back); if ($file_size > $max_file_size) { $lines = file($talk_back_ok); $a = count($lines); $u = $a - $help_lenght; for($i = $a; $i >= $u ;$i--){ $msg_old = $lines[$i] . $msg_old; } $deleted = unlink($talk_back_ok); $fp = fopen($talk_back_ok, "a+"); $fw = fwrite($fp, $msg_old); fclose($fp); } $msg = str_replace ("\n"," ", $message); $msg = str_replace ("\n"," ", $message); $msg = str_replace ("<", " ", $msg); $msg = str_replace (">", " ", $msg); $msg = stripslashes ($msg); if($person == $pass) { $sign = ("<img src= '$webmaster_image'> $webmaster_name"); } else { $sign = ($person); } if ($msg != "" && $person != ""){ $time = gmDate("h:i"); $fp = fopen($talk_back_ok, "a+"); $fw = fwrite($fp, "\n<tr><td><FONT SIZE=\"+1\"><b> $sign :</b></FONT><FONT SIZE=\"-2\" color=\"red\"><I>$time</I></FONT> :<FONT SIZE=\"-1\"> $msg<br></FONT></td></tr>"); fclose($fp); } $lines = file($talk_back_ok); $a = count($lines); $u = $a - $help_lenght; for($i = $a; $i >= $u ;$i--){ echo $lines[$i]; } ?><BR> </body></html>
<html>
<head><Title>
在线聊天
</title></head>
<!-- frames -->
<frameset rows="82%,*" BORDER="0">
<frame name="top" src="gorilla2.php" marginwidth="0" marginheight="0" scrolling="no" FRAMEBORDER="NO" noresize>
<frame name="bottom" src="gorilla.php" marginwidth="0" marginheight="0" scrolling="yes" frameborder="no" noresize>
</frameset>
<body>
</body>
</html>
<? $adminpsd = "xlj"; //管理密码 $newsbook = "./data/newsbook.txt"; //新闻存放的文件 $refreshbook = "./data/refreshbook.txt"; //防刷新的文件 $line_max = 5; //显示的最大纪录数 $dot_pic = "dot2.gif"; //图片 ?>
<? require "config.php"; ?> <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <style type="text/css"> <!-- input { font-size:9pt;} A:link {text-decoration: underline; font-size:9pt;color:000059} A:visited {text-decoration: underline; font-size:9pt;color:000059} A:active {text-decoration: none; font-size:9pt} A:hover {text-decoration:underline;color:red} body,table {font-size: 9pt} tr,td{font-size:9pt} --> </style> <title>简单的新闻公告栏</title> </HEAD> <body alink="#FF0000" link="#000099" vlink="#CC6600" topmargin="8" leftmargin="0" bgColor="#FFFFFF"> <br> <? $line_array=file($newsbook); $linenum=count($line_array); if($table!=1) { ?> <table width=70% bgcolor="FFFBEC" align="center"> <tr> <td width=5%></td><td width=95%></td> </tr> <? } $i=0; while($i<$linenum && $i<$line_max) { $line="$line_array[$i]\n"; print "$line"; $i++; } if($table!=1) { ?> </table> <? } ?> </body> </html>
<?require "config.php";?> <? if($password !=$adminpsd) { print "管理密码错!<br>";exit; } $title=ereg_replace("\r\n",'<br>',$title); $addline="<tr><td valign=top><img border=0 src=$dot_pic></td><td>$title</td></tr></td>"; //查数据文件是否存在 if(!file_exists($refreshbook)) { $f = fopen("$refreshbook","w"); fclose($f); } if(!file_exists($newsbook)) { $f = fopen("$newsbook","w"); fclose($f); } $f = fopen("$refreshbook","r"); $line_has1 = fread($f,filesize("$refreshbook")); fclose($f); if($addline==$line_has1) { print "数据已经登录,请勿刷新!<br>"; exit; } else { $f = fopen("$refreshbook","w"); fwrite($f,"$addline"); fclose($f); } //先读出原有数据 $f = fopen("$newsbook","r"); $line_has = fread($f,filesize("$newsbook")); fclose($f); //用覆盖方式(w)将原数据及新数据写回去 $f = fopen("$newsbook","w"); fwrite($f,"$addline\n"); #写进去,要加 \n fwrite($f,"$line_has"); fclose($f); print "录入完成,谢谢!<br>";exit; ?>
<html> <head> <title>PHP目录树演示</title> <style> BODY { font-family : Verdana,Arial; } TD { font-family : Verdana,Arial; font-size : 8pt; } A { text-decoration : none; background-color : #EEFFEE; } </style> </head> <body bgcolor=#eeffee link=#339933> <h4>PHP目录树演示</h4> <?php /*********************************************/ /* PHP目录树演示 */ /*********************************************/ /*********************************************/ /* 文件结构 */ /*********************************************/ $treefile = "demomenu.txt"; /*********************************************/ /* 包函树节点 */ /*********************************************/ require "treemenu.inc"; ?> </body> </html>
<? $file=file("record.txt"); $intt=sizeof($file); $file2=array(); $cont=$intt/3; $conttj=1; for($i=0;$i<$intt;$i=$i+3) { if($file[$i] == $id."\n") { $k=$i; for($j=$conttj;$j<=$cont;$j++) { $file[$k]=$file[$k+3]; $file[$k+1]=$file[$k+4]; $file[$k+2]=$file[$k+5]; $k=$k+3; } $conttj=$conttj+1; } } $intt2=sizeof($file); $f2=fopen("record.txt","w+"); for($i=0;$i<$intt2;$i++) { fputs($f2,$file[$i]); } ?>
<HTML>
<HEAD>
<TITLE>访客留言本</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR>
</HEAD>
<FRAMESET border=false cols=300,* frameBorder=0 frameSpacing=0>
<FRAME name=contents src="leftnew.php" target="right">
<FRAME name=right src="listnew.php"><NOFRAMES>
<body>
</body>
</NOFRAMES>
</FRAMESET>
</HTML>
View Raw Code? <HTML> <HEAD> <TITLE>访客留言本</TITLE> <META content="text/html; charset=gb2312" http-equiv=Content-Type> <META content="MSHTML 5.00.2614.3500" name=GENERATOR> <link rel="stylesheet" href="css.css"> </HEAD> <script language="JavaScript"> <!-- function Juge(theForm) { if (theForm.name.value == "") { alert("请输入您的姓名!"); theForm.name.focus(); return (false); } if (theForm.txt.value == "") { alert("请输入留言内容!"); theForm.txt.focus(); return (false); } } //--> </script> <body alink="#FF0000" link="#000099" vlink="#CC6600" bgColor="#CCCCCC"> <TABLE align=center border=0 cellPadding=0 cellSpacing=1 width=264> <TBODY> <TR> <TD> <TABLE border=0 cellPadding=5 cellSpacing=1 width="60%" align="center"> <TR vAlign=top> <TD bgColor=#ffffff><IMG src="images/doodle_title.gif"></TD> </TR> <TBODY> <TR vAlign=top> <FORM action=listnew.php?type=add method=post target=right onSubmit="return Juge(this)"> <TD bgColor=#ffffff> <div align="center"><BR> 姓名 <INPUT class=stedit name=name size=24> <BR> 信箱 <INPUT class=stedit name=email size=24 value=@> <BR> 主页 <INPUT class=stedit name=url size=24 value=http://> <BR> 主题 <INPUT class=stedit name=title size=24> <BR> 选项 <INPUT CHECKED id=radio1 name=sex type=radio value=1> 男 <INPUT id=radio2 name=sex type=radio value=0> 女 <SELECT class=stbtm name=mind size=1 style="BACKGROUND-COLOR: #f5f5f5; FONT-SIZE: 9pt"> <OPTION selected value=01>大家讨论</OPTION> <OPTION value=02>真高兴</OPTION> <OPTION value=03>不高兴</OPTION> <OPTION value=04>很满意</OPTION> <OPTION value=05>我赞同</OPTION> <OPTION value=06>说得好</OPTION> <OPTION value=07>你真傻</OPTION> <OPTION value=08>交个朋友</OPTION> <OPTION value=09>请注意</OPTION> <OPTION value=10>为什么</OPTION> <OPTION value=11>真奇怪</OPTION> <OPTION value=12>还不错</OPTION> <OPTION value=13>我愤怒</OPTION> <OPTION value=14>我伤心</OPTION> </SELECT> <BR> 内 容 <BR> <textarea class="stedit" cols="25" name="txt" rows="7"></textarea> <BR> <IMG border=0 height=5 src="" width=1><BR> <input class=stedit name=Submit type=submit value=" 提 交 "> <input class=stedit name=Submit2 type=reset value=" 清 除 "> </div> </TD> </FORM> </TR> </TBODY> </TABLE> </TD></TR> </TABLE> <br> </BODY> </HTML>
<? if($type=="add") { $file=file("record.txt"); $intt=sizeof($file); $tx=$file[0]+1; $f = fopen("record.txt","r+"); $msg = fread($f,filesize("record.txt")) ; fclose($f); $f = fopen("record.txt","r+"); $text=$txt; $text=htmlspecialchars($text); $text=ereg_replace("\r\n","<br>",$text); $text=ereg_replace("\r","<br>",$text); $text=$text."\n"; $t = date(Y年m月d日H时i分); $line1=$name."||".$email."||".$url."||".$sex."||".$mind."||".$title."||".$t."\n"; if(str_replace("\n","",$file[2])!=trim($text)) { fputs($f,$tx."\n"); fputs($f,$line1); fputs($f,$text); fputs($f,$msg); fclose($f);} } ?> <? $filename="record.txt"; $file=file($filename); $intt=sizeof($file); $pagesize=3; $pagecount=round(($intt/3)/$pagesize) ; if($pagesize*$pagecount<$intt/3) { $pagecount++; } if($pagepage2) { $page=$pagepage2-1; if($pagepage2>$pagecount) { $page=$pagecount-1;} if($pagepage2<1) { $page=0;} } $pagecount2=$pagecount-1; $page2=$page+1; $pp=$page*$pagesize*3; $pp2=$pp+$pagesize*3; $nextpage=$page+1; $prevpage=$page-1; ?> <HTML> <HEAD> <meta http-equiv="cache-control" content="private"></meta> <meta http-equiv="Pragma" content="no-cache"></meta> <link rel="stylesheet" href="css.css"> </HEAD> <BODY aLink=#000000 bgColor=#f5f5f5 link=#000000 text=#000000 vLink=#999999> <FORM action=listnew.php method=post name=form1> <table border=0 cellpadding=0 cellspacing=0 width=380 align="center"> <tbody> <tr> <td><img height=12 src="images/newtop.gif" width=380></td> </tr> <tr bgcolor=#ffffff> <td background=images/newbg.gif> <table align=center border=0 cellpadding=0 cellspacing=0 width=363> <tbody> <tr> <td style="FONT-SIZE: 9pt" width="257"> <div align=center>目前共有<font face=Tahoma><?echo $intt/3;?></font>条留言 <?if ($page != 0){ ?> <a href=listnew.php?page=<?echo $prevpage?>><img alt=后页 border=0 src="images/menu_left_a.gif"></a> <?}?> <? if ($page != $pagecount2) {?> <a href=listnew.php?page=<?echo $nextpage?>><img alt=后页 border=0 src="images/menu_right_a.gif"></a> <?} ?> 第<b><font face=Tahoma><?echo $page2."/".$pagecount; ?></font></b> </div> </td> <td style="FONT-SIZE: 9pt" width="106"> 第 <input class=stbtm name=pagepage2 size=2> 页 <input alt=跳转 border=0 name=Submit2 src="images/go2.gif" type=image value=跳转> </td> </tr> </tbody> </table> </td> </tr> <tr> <td><img height=8 src="images/newdo.gif" width=380></td> </tr> </tbody> </table> </FORM> <? for($i=$pp;$i<$pp2;$i=$i+3) { if($i<$intt) { $tp=explode("||",$file[$i+1]); ?> <br> <table width="50" border="0" cellspacing="0" cellpadding="0" align="center"> <tr background="images/newbg.gif" valign="top"> <td height="101" background="images/newbg.gif"><img src="images/newtop.gif" width="380" height="12"><br> <table cellspacing=1 cellpadding=3 width="95%" border=0 align="center"> <tr> <td bgcolor="#FFFFFF" width="40" align="center"><a href="mailto:<?echo $tp[1];?>"><img alt=给我来信! border=0 src="images/<?echo $tp[3].$tp[4]?>.gif" ></a></td> <td bgcolor="#FFFFFF" width="320"><a href="mailto:<?echo $tp[1];?>"><font size=2><b><?echo $tp[0];?></b></font></a> <a href="<?echo $tp[2];?>" target=_blank><font face="Verdana, Arial, Helvetica, sans-serif" size=1><?echo $tp[2];?></font></a><br> <a href="<?echo $tp[2];?>" target=_blank></a><font face=Tahoma><br> <?echo $tp[6];?></font></td> </tr> <tbody> <tr bgcolor="#ffffff"> <td colspan="2" style="font-size: 12px" background="images/dotbg.gif"> <div align="center"> <b>留言主题:<?echo $tp[5];?></b></div> </td> </tr> <tr> <td bgcolor=#f5f5f5 colspan="2"> <table width="95%" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td style="font-size: 9pt"><?echo $file[$i+2];?></td> </tr> </table> </table> </td> </tr> </table> <div align="center"><img src="images/newdo.gif" width="380" height="8" align="top"> </div> <p> <? } } ?> <FORM action=listnew.php method=post name=form1> <table border=0 cellpadding=0 cellspacing=0 width=380 align="center"> <tbody> <tr> <td><img height=12 src="images/newtop.gif" width=380></td> </tr> <tr bgcolor=#ffffff> <td background=images/newbg.gif> <table align=center border=0 cellpadding=0 cellspacing=0 width=363> <tbody> <tr> <td style="FONT-SIZE: 9pt" width="257"> <div align=center>目前共有<font face=Tahoma><?echo $intt/3;?></font>条留言 <?if ($page != 0){ ?> <a href=listnew.php?page=<?echo $prevpage?>><img alt=后页 border=0 src="images/menu_left_a.gif"></a> <?}?> <? if ($page != $pagecount2) {?> <a href=listnew.php?page=<?echo $nextpage?>><img alt=后页 border=0 src="images/menu_right_a.gif"></a> <?} ?> 第<b><font face=Tahoma><?echo $page2."/".$pagecount; ?></font></b> </div> </td> <td style="FONT-SIZE: 9pt" width="106"> 第 <input class=stbtm name=pagepage2 size=2> 页 <input alt=跳转 border=0 name=Submit22 src="images/go2.gif" type=image value=跳转> </td> </tr> </tbody> </table> </td> </tr> <tr> <td><img height=8 src="images/newdo.gif" width=380></td> </tr> </tbody> </table> </FORM> </BODY> </HTML>
<? //----------------------------------------------------------------- // 安装说明: // 1,把97-1.php(就是本文件)加到一个PHP页中。 // 2,设置好选票数据文件和选票IP记录文件的路径及文件名,并设置属性为666(保证可读写)。 // 安装完成了(太简单拉^_^) //----------------------------------------------------------------- // 选票数据文件的格式说明: // 该文件只有1行,共分成11段,每段都用“|”分隔,内容如下(“[]”内为说明如该段不需要有内容,则需将其空出来。) // [选票标题]|[选择A]|[选择A的得票数]|[选择B]|[选择B的得票数]|[选择C]|[选择C的得票数]|[选择D]|[选择D的得票数]|[选择E]|[选择E的得票数] //----------------------------------------------------------------- // 选票IP记录文件的格式说明: // 这个文件不需要编辑,只是为了防止某些人重复投票而做的IP判断过滤。 // 文件的格式就是每个IP值占一行,有多少人投票就有多少行。 // 该文件的初始状态就是为空(0字节)。 //----------------------------------------------------------------- $file="97_data.txt"; /*选票数据文件*/ $fd=fopen("$file","r"); $fd_data=fread($fd,filesize($file)); fclose($fd); list($votez_name,$vote1_name,$vote1_counter,$vote2_name,$vote2_counter,$vote3_name,$vote3_counter,$vote4_name,$vote4_counter,$vote5_name,$vote5_counter)=split("\|",$fd_data); $votez_counter=$vote1_counter+$vote2_counter+$vote3_counter+$vote4_counter+$vote5_counter; if($vote1_counter>0){$vote1_countera=substr($vote1_counter/$votez_counter*100,0,4)."%";}else{$vote1_countera="0.00%";} if($vote2_counter>0){$vote2_countera=substr($vote2_counter/$votez_counter*100,0,4)."%";}else{$vote2_countera="0.00%";} if($vote3_counter>0){$vote3_countera=substr($vote3_counter/$votez_counter*100,0,4)."%";}else{$vote3_countera="0.00%";} if($vote4_counter>0){$vote4_countera=substr($vote4_counter/$votez_counter*100,0,4)."%";}else{$vote4_countera="0.00%";} if($vote5_counter>0){$vote5_countera=substr($vote5_counter/$votez_counter*100,0,4)."%";}else{$vote5_countera="0.00%";} echo "<hr size=0 color=#FFC864><img src=97_img.php?vote1=$vote1_counter&vote2=$vote2_counter&vote3=$vote3_counter&vote4=$vote4_counter&vote5=$vote5_counter><br> $votez_name<br> 总票数:<font color=#FF0000><b>$votez_counter</b></font>票<br> <a href=97-2.php?vote=1><font color=#FF0000>选择A:</font><b>$vote1_name</b></a><br>(<font color=#FF0000><b>$vote1_counter</b></font>票|<font color=#0F0F0F>$vote1_countera</font>)<br> <a href=97-2.php?vote=2><font color=#FF8040>选择B:</font><b>$vote2_name</b></a><br>(<font color=#FF0000><b>$vote2_counter</b></font>票|<font color=#0F0F0F>$vote2_countera</font>)<br> <a href=97-2.php?vote=3><font color=#DFDF00>选择C:</font><b>$vote3_name</b></a><br>(<font color=#FF0000><b>$vote3_counter</b></font>票|<font color=#0F0F0F>$vote3_countera</font>)<br> <a href=97-2.php?vote=4><font color=#00C800>选择D:</font><b>$vote4_name</b></a><br>(<font color=#FF0000><b>$vote4_counter</b></font>票|<font color=#0F0F0F>$vote4_countera</font>)<br> <a href=97-2.php?vote=5><font color=#0000FF>选择E:</font><b>$vote5_name</b></a><br>(<font color=#FF0000><b>$vote5_counter</b></font>票|<font color=#0F0F0F>$vote5_countera</font>)<br> <hr size=0 color=#FFC864>"; //----------------------------------------------------------------- ?>
<? $file1="97_data.txt"; /*选票数据文件*/ $file2="97_ip.txt"; /*选票IP记录文件*/ //--------------------------------------------------- $this_ip=getenv("REMOTE_ADDR")."\n"; $fd2=fopen("$file2","r"); $fd_data2=fread($fd2,filesize($file2)); fclose($fd2); if(!ereg($this_ip,$fd_data2)){ $fd2=fopen("$file2","a"); $fd_write2=fwrite($fd2,$this_ip,strlen($this_ip)); fclose($fd2); //--------------------------------------------------- $fd1=fopen("$file1","r"); $fd_data1=fread($fd1,filesize($file1)); fclose($fd1); list($votez_name,$vote1_name,$vote1_counter,$vote2_name,$vote2_counter,$vote3_name,$vote3_counter,$vote4_name,$vote4_counter,$vote5_name,$vote5_counter)=split("\|",$fd_data1); //--------------------------------------------------- if(!empty($vote)){ if($vote==1 && !empty($vote1_name)){$vote1_counter++; }elseif($vote==2 && !empty($vote2_name)){$vote2_counter++; }elseif($vote==3 && !empty($vote3_name)){$vote3_counter++; }elseif($vote==4 && !empty($vote4_name)){$vote4_counter++; }elseif($vote==5 && !empty($vote5_name)){$vote5_counter++; } $fd_data1="$votez_name|$vote1_name|$vote1_counter|$vote2_name|$vote2_counter|$vote3_name|$vote3_counter|$vote4_name|$vote4_counter|$vote5_name|$vote5_counter"; $fd1=fopen("$file1","w"); $fd_write1=fwrite($fd1,$fd_data1,strlen($fd_data1)); fclose($fd1); } } //--------------------------------------------------- ?> <html><head><meta http-equiv='Refresh' content='0; URL=97-1.php'></head> <body><p>谢谢您对本站的支持,三秒后将自动返回……</p></body></html>
<? Header("Content-type: image/gif"); /**************************************/ /** 程序:选票统计 **/ /** 文件:emi_vote.php **/ /** 日期:2000/01/25 **/ /** 版本:v1.0 **/ /** 作者:emildy **/ /** 主页:http://www.e-mi.net **/ /** 请勿删除此段版权信息 谢谢合作 **/ /**************************************/ $votez=$vote1+$vote2+$vote3+$vote4+$vote5; if($vote1>0){$vote1a=$vote1/$votez*360;}else{$vote1a=0;} if($vote2>0){$vote2a=$vote2/$votez*360;}else{$vote2a=0;} if($vote3>0){$vote3a=$vote3/$votez*360;}else{$vote3a=0;} if($vote4>0){$vote4a=$vote4/$votez*360;}else{$vote4a=0;} if($vote5>0){$vote5a=$vote5/$votez*360;}else{$vote5a=0;} $img_output=ImageCreate(88,70); $color0a=imagecolorallocate($img_output,255,255,255); /*白*/ $color0b=imagecolorallocate($img_output, 0, 0, 0); /*黑*/ $color1a=imagecolorallocate($img_output,255, 0, 0); /*红a*/ $color1b=imagecolorallocate($img_output,200, 0, 0); /*红b*/ $color2a=imagecolorallocate($img_output,255,128, 64); /*橙a*/ $color2b=imagecolorallocate($img_output,198, 64, 0); /*橙b*/ $color3a=imagecolorallocate($img_output,255,255, 0); /*黄a*/ $color3b=imagecolorallocate($img_output,200,200, 0); /*黄b*/ $color4a=imagecolorallocate($img_output,133,248, 18); /*绿a*/ $color4b=imagecolorallocate($img_output, 0,200, 0); /*绿b*/ $color5a=imagecolorallocate($img_output, 0, 0,255); /*蓝a*/ $color5b=imagecolorallocate($img_output, 0, 0,200); /*蓝b*/ imagecolortransparent($img_output,$color0a); /*白色为透明色*/ $picture_x=43; /*饼图的中心点-X*/ $picture_y=30; /*饼图的中心点-Y*/ $picture_w=80; /*饼图的中心点-w*/ $picture_h=40; /*饼图的中心点-h*/ for($temp_a=$picture_y+11;$temp_a>$picture_y;$temp_a--){ if($vote5>0){for($temp_b=$picture_w;$temp_b>0;$temp_b--){imagearc($img_output,$picture_x,$temp_a,$temp_b,$temp_b*5/8,0 ,$vote5a ,$color5b);}} if($vote4>0){for($temp_b=$picture_w;$temp_b>0;$temp_b--){imagearc($img_output,$picture_x,$temp_a,$temp_b,$temp_b*5/8,$vote5a ,$vote5a+$vote4a ,$color4b);}} if($vote3>0){for($temp_b=$picture_w;$temp_b>0;$temp_b--){imagearc($img_output,$picture_x,$temp_a,$temp_b,$temp_b*5/8,$vote5a+$vote4a ,$vote5a+$vote4a+$vote3a ,$color3b);}} if($vote2>0){for($temp_b=$picture_w;$temp_b>0;$temp_b--){imagearc($img_output,$picture_x,$temp_a,$temp_b,$temp_b*5/8,$vote5a+$vote4a+$vote3a ,$vote5a+$vote4a+$vote3a+$vote2a,$color2b);}} if($vote1>0){for($temp_b=$picture_w;$temp_b>0;$temp_b--){imagearc($img_output,$picture_x,$temp_a,$temp_b,$temp_b*5/8,$vote5a+$vote4a+$vote3a+$vote2a,360 ,$color1b);}} } if($vote5>0){for($temp_b=$picture_w;$temp_b>0;$temp_b--){imagearc($img_output,$picture_x,$picture_y,$temp_b,$temp_b*5/8,0 ,$vote5a ,$color5a);}} if($vote4>0){for($temp_b=$picture_w;$temp_b>0;$temp_b--){imagearc($img_output,$picture_x,$picture_y,$temp_b,$temp_b*5/8,$vote5a ,$vote5a+$vote4a ,$color4a);}} if($vote3>0){for($temp_b=$picture_w;$temp_b>0;$temp_b--){imagearc($img_output,$picture_x,$picture_y,$temp_b,$temp_b*5/8,$vote5a+$vote4a ,$vote5a+$vote4a+$vote3a ,$color3a);}} if($vote2>0){for($temp_b=$picture_w;$temp_b>0;$temp_b--){imagearc($img_output,$picture_x,$picture_y,$temp_b,$temp_b*5/8,$vote5a+$vote4a+$vote3a ,$vote5a+$vote4a+$vote3a+$vote2a,$color2a);}} if($vote1>0){for($temp_b=$picture_w;$temp_b>0;$temp_b--){imagearc($img_output,$picture_x,$picture_y,$temp_b,$temp_b*5/8,$vote5a+$vote4a+$vote3a+$vote2a,360 ,$color1a);}} ImageGif($img_output); ImageDestory($img_output); ?>
View Raw Code? <? //世纪万年历 #这是唯一的设置-请输入php文件的位置 $file="http://192.168.1.168/php/rl/s2m.php"; //#农历每月的天数 $everymonth=array( 0=>array(8,0,0,0,0,0,0,0,0,0,0,0,29,30,7,1), 1=>array(0,29,30,29,29,30,29,30,29,30,30,30,29,0,8,2), 2=>array(0,30,29,30,29,29,30,29,30,29,30,30,30,0,9,3), 3=>array(5,29,30,29,30,29,29,30,29,29,30,30,29,30,10,4), 4=>array(0,30,30,29,30,29,29,30,29,29,30,30,29,0,1,5), 5=>array(0,30,30,29,30,30,29,29,30,29,30,29,30,0,2,6), 6=>array(4,29,30,30,29,30,29,30,29,30,29,30,29,30,3,7), 7=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,4,8), 8=>array(0,30,29,29,30,30,29,30,29,30,30,29,30,0,5,9), 9=>array(2,29,30,29,29,30,29,30,29,30,30,30,29,30,6,10), 10=>array(0,29,30,29,29,30,29,30,29,30,30,30,29,0,7,11), 11=>array(6,30,29,30,29,29,30,29,29,30,30,29,30,30,8,12), 12=>array(0,30,29,30,29,29,30,29,29,30,30,29,30,0,9,1), 13=>array(0,30,30,29,30,29,29,30,29,29,30,29,30,0,10,2), 14=>array(5,30,30,29,30,29,30,29,30,29,30,29,29,30,1,3), 15=>array(0,30,29,30,30,29,30,29,30,29,30,29,30,0,2,4), 16=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,3,5), 17=>array(2,30,29,29,30,29,30,30,29,30,30,29,30,29,4,6), 18=>array(0,30,29,29,30,29,30,29,30,30,29,30,30,0,5,7), 19=>array(7,29,30,29,29,30,29,29,30,30,29,30,30,30,6,8), 20=>array(0,29,30,29,29,30,29,29,30,30,29,30,30,0,7,9), 21=>array(0,30,29,30,29,29,30,29,29,30,29,30,30,0,8,10), 22=>array(5,30,29,30,30,29,29,30,29,29,30,29,30,30,9,11), 23=>array(0,29,30,30,29,30,29,30,29,29,30,29,30,0,10,12), 24=>array(0,29,30,30,29,30,30,29,30,29,30,29,29,0,1,1), 25=>array(4,30,29,30,29,30,30,29,30,30,29,30,29,30,2,2), 26=>array(0,29,29,30,29,30,29,30,30,29,30,30,29,0,3,3), 27=>array(0,30,29,29,30,29,30,29,30,29,30,30,30,0,4,4), 28=>array(2,29,30,29,29,30,29,29,30,29,30,30,30,30,5,5), 29=>array(0,29,30,29,29,30,29,29,30,29,30,30,30,0,6,6), 30=>array(6,29,30,30,29,29,30,29,29,30,29,30,30,29,7,7), 31=>array(0,30,30,29,30,29,30,29,29,30,29,30,29,0,8,8), 32=>array(0,30,30,30,29,30,29,30,29,29,30,29,30,0,9,9), 33=>array(5,29,30,30,29,30,30,29,30,29,30,29,29,30,10,10), 34=>array(0,29,30,29,30,30,29,30,29,30,30,29,30,0,1,11), 35=>array(0,29,29,30,29,30,29,30,30,29,30,30,29,0,2,12), 36=>array(3,30,29,29,30,29,29,30,30,29,30,30,30,29,3,1), 37=>array(0,30,29,29,30,29,29,30,29,30,30,30,29,0,4,2), 38=>array(7,30,30,29,29,30,29,29,30,29,30,30,29,30,5,3), 39=>array(0,30,30,29,29,30,29,29,30,29,30,29,30,0,6,4), 40=>array(0,30,30,29,30,29,30,29,29,30,29,30,29,0,7,5), 41=>array(6,30,30,29,30,30,29,30,29,29,30,29,30,29,8,6), 42=>array(0,30,29,30,30,29,30,29,30,29,30,29,30,0,9,7), 43=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,10,8), 44=>array(4,30,29,30,29,30,29,30,29,30,30,29,30,30,1,9), 45=>array(0,29,29,30,29,29,30,29,30,30,30,29,30,0,2,10), 46=>array(0,30,29,29,30,29,29,30,29,30,30,29,30,0,3,11), 47=>array(2,30,30,29,29,30,29,29,30,29,30,29,30,30,4,12), 48=>array(0,30,29,30,29,30,29,29,30,29,30,29,30,0,5,1), 49=>array(7,30,29,30,30,29,30,29,29,30,29,30,29,30,6,2), 50=>array(0,29,30,30,29,30,30,29,29,30,29,30,29,0,7,3), 51=>array(0,30,29,30,30,29,30,29,30,29,30,29,30,0,8,4), 52=>array(5,29,30,29,30,29,30,29,30,30,29,30,29,30,9,5), 53=>array(0,29,30,29,29,30,30,29,30,30,29,30,29,0,10,6), 54=>array(0,30,29,30,29,29,30,29,30,30,29,30,30,0,1,7), 55=>array(3,29,30,29,30,29,29,30,29,30,29,30,30,30,2,8), 56=>array(0,29,30,29,30,29,29,30,29,30,29,30,30,0,3,9), 57=>array(8,30,29,30,29,30,29,29,30,29,30,29,30,29,4,10), 58=>array(0,30,30,30,29,30,29,29,30,29,30,29,30,0,5,11), 59=>array(0,29,30,30,29,30,29,30,29,30,29,30,29,0,6,12), 60=>array(6,30,29,30,29,30,30,29,30,29,30,29,30,29,7,1), 61=>array(0,30,29,30,29,30,29,30,30,29,30,29,30,0,8,2), 62=>array(0,29,30,29,29,30,29,30,30,29,30,30,29,0,9,3), 63=>array(4,30,29,30,29,29,30,29,30,29,30,30,30,29,10,4), 64=>array(0,30,29,30,29,29,30,29,30,29,30,30,30,0,1,5), 65=>array(0,29,30,29,30,29,29,30,29,29,30,30,29,0,2,6), 66=>array(3,30,30,30,29,30,29,29,30,29,29,30,30,29,3,7), 67=>array(0,30,30,29,30,30,29,29,30,29,30,29,30,0,4,8), 68=>array(7,29,30,29,30,30,29,30,29,30,29,30,29,30,5,9), 69=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,6,10), 70=>array(0,30,29,29,30,29,30,30,29,30,30,29,30,0,7,11), 71=>array(5,29,30,29,29,30,29,30,29,30,30,30,29,30,8,12), 72=>array(0,29,30,29,29,30,29,30,29,30,30,29,30,0,9,1), 73=>array(0,30,29,30,29,29,30,29,29,30,30,29,30,0,10,2), 74=>array(4,30,30,29,30,29,29,30,29,29,30,30,29,30,1,3), 75=>array(0,30,30,29,30,29,29,30,29,29,30,29,30,0,2,4), 76=>array(8,30,30,29,30,29,30,29,30,29,29,30,29,30,3,5), 77=>array(0,30,29,30,30,29,30,29,30,29,30,29,29,0,4,6), 78=>array(0,30,29,30,30,29,30,30,29,30,29,30,29,0,5,7), 79=>array(6,30,29,29,30,29,30,30,29,30,30,29,30,29,6,8), 80=>array(0,30,29,29,30,29,30,29,30,30,29,30,30,0,7,9), 81=>array(0,29,30,29,29,30,29,29,30,30,29,30,30,0,8,10), 82=>array(4,30,29,30,29,29,30,29,29,30,29,30,30,30,9,11), 83=>array(0,30,29,30,29,29,30,29,29,30,29,30,30,0,10,12), 84=>array(10,30,29,30,30,29,29,30,29,29,30,29,30,30,1,1), 85=>array(0,29,30,30,29,30,29,30,29,29,30,29,30,0,2,2), 86=>array(0,29,30,30,29,30,30,29,30,29,30,29,29,0,3,3), 87=>array(6,30,29,30,29,30,30,29,30,30,29,30,29,29,4,4), 88=>array(0,30,29,30,29,30,29,30,30,29,30,30,29,0,5,5), 89=>array(0,30,29,29,30,29,29,30,30,29,30,30,30,0,6,6), 90=>array(5,29,30,29,29,30,29,29,30,29,30,30,30,30,7,7), 91=>array(0,29,30,29,29,30,29,29,30,29,30,30,30,0,8,8), 92=>array(0,29,30,30,29,29,30,29,29,30,29,30,30,0,9,9), 93=>array(3,29,30,30,29,30,29,30,29,29,30,29,30,29,10,10), 94=>array(0,30,30,30,29,30,29,30,29,29,30,29,30,0,1,11), 95=>array(8,29,30,30,29,30,29,30,30,29,29,30,29,30,2,12), 96=>array(0,29,30,29,30,30,29,30,29,30,30,29,29,0,3,1), 97=>array(0,30,29,30,29,30,29,30,30,29,30,30,29,0,4,2), 98=>array(5,30,29,29,30,29,29,30,30,29,30,30,29,30,5,3), 99=>array(0,30,29,29,30,29,29,30,29,30,30,30,29,0,6,4), 100=>array(0,30,30,29,29,30,29,29,30,29,30,30,29,0,7,5), 101=>array(4,30,30,29,30,29,30,29,29,30,29,30,29,30,8,6), 102=>array(0,30,30,29,30,29,30,29,29,30,29,30,29,0,9,7), 103=>array(0,30,30,29,30,30,29,30,29,29,30,29,30,0,10,8), 104=>array(2,29,30,29,30,30,29,30,29,30,29,30,29,30,1,9), 105=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,2,10), 106=>array(7,30,29,30,29,30,29,30,29,30,30,29,30,30,3,11), 107=>array(0,29,29,30,29,29,30,29,30,30,30,29,30,0,4,12), 108=>array(0,30,29,29,30,29,29,30,29,30,30,29,30,0,5,1), 109=>array(5,30,30,29,29,30,29,29,30,29,30,29,30,30,6,2), 110=>array(0,30,29,30,29,30,29,29,30,29,30,29,30,0,7,3), 111=>array(0,30,29,30,30,29,30,29,29,30,29,30,29,0,8,4), 112=>array(4,30,29,30,30,29,30,29,30,29,30,29,30,29,9,5), 113=>array(0,30,29,30,29,30,30,29,30,29,30,29,30,0,10,6), 114=>array(9,29,30,29,30,29,30,29,30,30,29,30,29,30,1,7), 115=>array(0,29,30,29,29,30,29,30,30,30,29,30,29,0,2,8), 116=>array(0,30,29,30,29,29,30,29,30,30,29,30,30,0,3,9), 117=>array(6,29,30,29,30,29,29,30,29,30,29,30,30,30,4,10), 118=>array(0,29,30,29,30,29,29,30,29,30,29,30,30,0,5,11), 119=>array(0,30,29,30,29,30,29,29,30,29,29,30,30,0,6,12), 120=>array(4,29,30,30,30,29,30,29,29,30,29,30,29,30,7,1) ); ############################## #农历天干 $mten=array("null","甲","乙","丙","丁","戊","己","庚","辛","壬","癸"); #农历地支 $mtwelve=array("null","子(鼠)","丑(牛)","寅(虎)","卯(兔)","辰(龙)", "巳(蛇)","午(马)","未(羊)","申(猴)","酉(鸡)","戌(狗)","亥(猪)"); #农历月份 $mmonth=array("闰","正","二","三","四","五","六", "七","八","九","十","十一","十二","月"); #农历日 $mday=array("null","初一","初二","初三","初四","初五","初六","初七","初八","初九","初十", "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十", "廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十"); ############################## #赋给初值 #天干地支 $ten=0; $twelve=0; #星期 $week=5; #农历日 $md=0; #农历月 $mm=0; #阳历总天数 至1900年12月21日 $total=11; #阴历总天数 $mtotal=0; ############################## #获得当日日期 $today=getdate(); #如果没有输入,设为当日日期 if ($year=="" or $month=="" or ($year<1901 or $year>2020) or ($month<1 or $month>12)){ $year=$today[year]; $month=$today[mon]; } ############################## #计算到所求日期阳历的总天数-自1900年12月21日始 #先算年的和 for ($y=1901;$y<$year;$y++){ $total+=365; if ($y%4==0) $total ++; } #再加当年的几个月 switch ($month){ case 12: $total+=30; case 11: $total+=31; case 10: $total+=30; case 9: $total+=31; case 8: $total+=31; case 7: $total+=30; case 6: $total+=31; case 5: $total+=30; case 4: $total+=31; case 3: $total+=28; case 2: $total+=31; } #如果当年是闰年还要加一天 if ($year%4==0 and $month>2){ $total++; } #顺便算出当月1日星期几 $week=($total+$week)%7; ############################## #用农历的天数累加来判断是否超过阳历的天数 $flag1=0;#判断跳出循环的条件 $j=0; while ($j<=120){ $i=1; while ($i<=13){ $mtotal+=$everymonth[$j][$i]; if ($mtotal>=$total){ $flag1=1; break; } $i++; } if ($flag1==1) break; $j++; } ############################## #计算所求月份1号的农历日期 $md=$everymonth[$j][$i]-($mtotal-$total); #月头空开的天数 $k=$week; #是否跨越一年 switch ($month){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: $dd=31; break; case 4: case 6: case 9: case 11: $dd=30; break; case 2: if ($year%4==0){ $dd=29; }else{ $dd=28; } break; } #是否跨越一年 $ty=0; if ((($everymonth[$j][0]<>0 and $i==13) or ($everymonth[$j][0]==0 and $i==12)) and $mtotal-$total<$dd) $ty=1; ?> <html> <head> <title>世纪万年历</title> <style type="text/css"> <!-- input { font-size:9pt;} A:link {text-decoration: underline; font-size:9pt;color:000059} A:visited {text-decoration: underline; font-size:9pt;color:000059} A:active {text-decoration: none; font-size:9pt} A:hover {text-decoration:underline;color:red} body,table {font-size: 9pt} tr,td{font-size:9pt} --> </style> </head> <body alink="#FF0000" link="#000099" vlink="#CC6600" topmargin="8" leftmargin="0" bgColor="#FFFFFF"> <? //打印年月抬头 echo "<p align=\"center\"><font size=\"6\"><b>".$year."年".$month."月</b></font></p>\n"; if($ty==0) { echo "<p align=\"center\"><b><font size=\"4\">".$mten[$everymonth[$j][14]].$mtwelve[$everymonth[$j][15]]."年</font></b></p>"; } else { echo "<p align=\"center\"><b><font size=\"4\">".$mten[$everymonth[$j][14]].$mtwelve[$everymonth[$j][15]]."/".$mten[$everymonth[$j+1][14]].$mtwelve[$everymonth[$j+1][15]]."年</font></b></p>"; } ?> <div align="center"> <center> <table border="1" width="85%"> <tr> <td align="center" bgcolor="#CCCCCC"><font color="#FF0000"><b>星期日</b></font></td> <td width="14%" align="center" bgcolor="#CCCCCC"><b>星期一</b></td> <td width="14%" align="center" bgcolor="#CCCCCC"><b>星期二</b></td> <td width="14%" align="center" bgcolor="#CCCCCC"><b>星期三</b></td> <td width="14%" align="center" bgcolor="#CCCCCC"><b>星期四</b></td> <td width="14%" align="center" bgcolor="#CCCCCC"><b>星期五</b></td> <td width="14%" align="center" bgcolor="#CCCCCC"><b>星期六</b></td> </tr> <? $day=1; $line=0; while ($day<=$dd){ echo "<tr>\n"; for ($s=0;$s<=6;$s++){ if ($k<>0 or $day>$dd){ echo "<td width=\"14%\" align=\"center\"> </td>\n"; $k--; }else{ //设置字符颜色 switch ($s){ case 1: case 2: case 3: case 4: case 5: $color="#000000"; break; case 0: $color="#FF0000"; break; case 6: $color="#008000"; break; } #生成中文农历 if ($md==1){#1日打印月份 if ($everymonth[$j][0]<>0 and $everymonth[$j][0]<$i){ $mm=$i-1; }else{ $mm=$i; } if ($i==$everymonth[$j][0]+1 and $everymonth[$j][0]<>0) $chi=$mmonth[0].$mmonth[$mm];#闰月 else $chi=$mmonth[$mm].$mmonth[13]; }else{ $chi=$mday[$md]; } echo "<td width=\"14%\" align=\"center\"><font color=\"$color\"><b>$day </b> <b><font size=\"2\">$chi</font></b></font></td>\n"; $day++; $md++; if ($md>$everymonth[$j][$i]){ $md=1; $i++; } if (($i>12 and $everymonth[$j][0]==0) or ($i>13 and $everymonth[$j][0]<>0)){ $i=1; $j++; } } } echo "</tr>\n"; $line++; } ?> </table> </center> </div> <?php #补足空行 for ($l=1;$l<=(6-$line);$l++){ echo "<table border=\"0\" width=\"100%\">\n"; echo "<tr>\n"; echo "<td width=\"100%\"><font color=\"#CCFFFF\">a</font></td>\n"; echo "</tr>\n"; echo "</table>\n"; } #打印上一月,下一月 $ly=$ny=$year; $last=$month-1; if ($last==0){ $last=12; $ly--; } $next=$month+1; if ($next==13){ $next=1; $ny++; } if ($ly>=1901) echo "<p align=\"center\"><a href=\"".$file."?year=".$ly."&month=".$last."\"><<上一个月</a> \n"; else echo "<p align=\"center\">"; if ($ny<=2020) echo "<a href=\"".$file."?year=".$ny."&month=".$next."\">下一个月>></a></p>\n"; ?> <?php echo "<form method=\"POST\" action=\"".$file."\">\n"; ?> <p align="center"><font color="#000000">年份:</font><select size="1" name="year"> <option>2020</option> <option>2019</option> <option>2018</option> <option>2017</option> <option>2016</option> <option>2015</option> <option>2014</option> <option>2013</option> <option>2012</option> <option>2011</option> <option>2010</option> <option>2009</option> <option>2008</option> <option>2007</option> <option>2006</option> <option>2005</option> <option>2004</option> <option>2003</option> <option>2002</option> <option>2001</option> <option selected>2000</option> <option>1999</option> <option>1998</option> <option>1997</option> <option>1996</option> <option>1995</option> <option>1994</option> <option>1993</option> <option>1992</option> <option>1991</option> <option>1990</option> <option>1989</option> <option>1988</option> <option>1987</option> <option>1986</option> <option>1985</option> <option>1984</option> <option>1983</option> <option>1982</option> <option>1981</option> <option>1980</option> <option>1979</option> <option>1978</option> <option>1977</option> <option>1976</option> <option>1975</option> <option>1974</option> <option>1973</option> <option>1972</option> <option>1971</option> <option>1970</option> <option>1969</option> <option>1968</option> <option>1967</option> <option>1966</option> <option>1965</option> <option>1964</option> <option>1963</option> <option>1962</option> <option>1961</option> <option>1960</option> <option>1959</option> <option>1958</option> <option>1957</option> <option>1956</option> <option>1955</option> <option>1954</option> <option>1953</option> <option>1952</option> <option>1951</option> <option>1950</option> <option>1949</option> <option>1948</option> <option>1947</option> <option>1946</option> <option>1945</option> <option>1944</option> <option>1943</option> <option>1942</option> <option>1941</option> <option>1940</option> <option>1939</option> <option>1938</option> <option>1937</option> <option>1936</option> <option>1935</option> <option>1934</option> <option>1933</option> <option>1932</option> <option>1931</option> <option>1930</option> <option>1929</option> <option>1928</option> <option>1927</option> <option>1926</option> <option>1925</option> <option>1924</option> <option>1923</option> <option>1922</option> <option>1921</option> <option>1920</option> <option>1919</option> <option>1918</option> <option>1917</option> <option>1916</option> <option>1915</option> <option>1914</option> <option>1913</option> <option>1912</option> <option>1911</option> <option>1910</option> <option>1909</option> <option>1908</option> <option>1907</option> <option>1906</option> <option>1905</option> <option>1904</option> <option>1903</option> <option>1902</option> <option>1901</option> </select><font color="#000000">年</font><font color="#000000"> 月份:<select size="1" name="month"> <option selected>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> <option>11</option> <option>12</option> </select>月 </font><input type="submit" value="查询" name="B1"></p> </form> </body> </html>
<? // PHPMINE v1.0 //来源http://www.phpvault.com //是根据microsoft的挖地雷游戏编写 print "<html>"; print "<head>"; print "<title>PHP挖地雷</title>"; print "</head>"; print "<body bgcolor=#FFFFCC><center>"; print "<font size=3 face=Verdana><b>PHP挖地雷</b>"; if ($submit=="") { $NumMine=4; $RowSize=5; $ColSize=5; $generer=1; } if($generer==1) { srand((double)microtime()*100000000); $time_start=time(); //判断输入的数值是否正确 if(($RowSize<=1) || ($ColSize<=1) || ($NumMine==0)) { print "<p><br><font size=-1 color=red>行数,列数或地雷数输入错误!!</font>"; exit; } if($NumMine > $RowSize*$ColSize) { print "<p><br><font size=-1 color=red>地雷数太多!</font>"; exit; } //初始化 for($Row=1;$Row<=$RowSize;$Row++) { for($Col=1;$Col<=$ColSize;$Col++) { $Mine[$Row][$Col]="0"; $Decouv[$Row][$Col]="0"; } } $index=0; while($index<$NumMine) { $Row=rand(1,$RowSize); $Col=rand(1,$ColSize); if($Mine[$Row][$Col]=="0") { $Mine[$Row][$Col]="1"; $index++; } } } else { $perdu=0; $reste=$RowSize*$ColSize; for($Row=1;$Row<=$RowSize;$Row++) { for($Col=1;$Col<=$ColSize;$Col++) { $temp="Mine".($Row*($ColSize+1)+$Col); $Mine[$Row][$Col]=$$temp; $temp="Decouv".($Row*($ColSize+1)+$Col); $Decouv[$Row][$Col]=$$temp; if($Decouv[$Row][$Col]=="1") {$reste=$reste-1;} $temp="submit".($Row*($ColSize+1)+$Col); if($$temp=="ok") { $reste=$reste-1; if($Mine[$Row][$Col]=="0") { $Decouv[$Row][$Col]="1"; } else { $perdu=1; } } } } if($perdu==1) { print "<h2><font color=red>您输啦!</font></h2>"; for($i=1;$i<=$RowSize;$i++) { for($j=1;$j<=$ColSize;$j++) { $Decouv[$i][$j]="1"; } } } if(($reste==$NumMine)&&($perdu!=1)) { print "<h2>你赢啦!</h2>"; $time_stop=time(); $time=$time_stop-$time_start; print "<p><font size=-1><i>您的分数: $time</i></font>"; for ($i=1;$i<=$RowSize;$i++) { for($j=1;$j<=$ColSize;$j++) { $Decouv[$i][$j]="1"; } } } } print "<form method=get action='$PHP_SELF'>"; print "<input type=hidden name=time_start value=$time_start>"; print "<input type=hidden name=NumMine value=$NumMine>"; print "<input type=hidden name=RowSize value=$RowSize>"; print "<input type=hidden name=ColSize value=$ColSize>"; print "<input type=hidden name=generer value=0>"; print "<p><table border=1 cellpadding=8>"; for($Row=1; $Row<=$RowSize; $Row++) { print "<tr>"; for($Col=1; $Col<=$ColSize; $Col++) { $nb=0; for($i=-1; $i<=1; $i++) { for($j=-1; $j<=1; $j++) { if($Mine[$Row+$i][$Col+$j] == "1") { $nb++; } } } print "<td width=15 height=15 align=center valign=middle>"; if($Decouv[$Row][$Col]=="1") { if($nb==0) { print " "; } else { if($Mine[$Row][$Col]=="1") { print "<font color=red>*</font>"; } else { print "$nb"; } } } else { print "<input type=hidden name=submit value=ok>"; print "<input type=submit name=submit".($Row*($ColSize+1)+$Col)." value=ok>"; } print "<input type=hidden name=Mine".($Row*($ColSize+1)+$Col)." value=".$Mine[$Row][$Col].">"; print "<input type=hidden name=Decouv".($Row*($ColSize+1)+$Col)." value=".$Decouv[$Row][$Col].">"; print "</td>"; } print "</tr>"; } print "</table>"; print "</form>"; ?> <hr> <form method=post> 行数 : <input type=text name=RowSize value=5 size=2> <br> 列数 : <input type=text name=ColSize value=5 size=2> <br> 地雷数 : <input type=text name=NumMine value=4 size=2> <p> <input type=submit name=submit value=开始> <input type=hidden name=generer value=1> </form> </body> </html>