mac 安装 node

文件写LOG.TXT 进行显示

2401_83442865: <?php error_reporting( E_ALL&~E_NOTICE );?> <body> <script language="javascript"> function clearfun(){ document.form1.username.value="" } function Checklon() { if (document.form1.username.value== "") { alert("\请输入用户名!"); document.form1.username.focus(); } else if (document.form1.message.value == "") { alert("\请输入备注信息"); document.form1.message.focus(); }else { return true; } return false; } </script> <?php function get_upload_file($CONSTANT) { //$path="./upload/"; $path="./".$CONSTANT."/"; if(!file_exists($path)){ mkdir("$path", 0777); } $tp = array("image/gif","image/jpeg","image/jpg","image/png","application/octet-stream","application/kswps","application/x-zip"); if(!in_array($_FILES["filename"]["type"],$tp)){ echo "<script>alert('上传文件格式不对');</script>"; exit; } $fileSize=$_FILES["filename"]["size"]; $file_size_max=1000000; if($fileSize>$file_size_max){ echo "<script>alert('文件太大,重新上传');</script>"; //echo "文件太大,重新上传"; exit; } if($_FILES["filename"]["name"]){ $file_expansion=substr($_FILES["filename"]["name"],-4,4); $file_name=time().rand(); $file_prixf=$path.$file_name; $file_new= $file_prixf.$file_expansion; $flag=1; if($flag) $result=move_uploaded_file($_FILES["filename"]["tmp_name"],$file_new); } $username=addslashes($_POST['username']); $data=date('Y-m-d',time()); $message=addslashes($_POST['message']); $file = 'log.txt';//要写入文件的文件名,如果文件不存在,将会创建一个 $val=$username.",".$message.",".substr($file_new,1).",".$file_name.",".$data."\r\n"; $val=str_replace("*","",$val); if($f = file_put_contents($file, $val,FILE_APPEND)){ echo "<script>alert('写入成功');</script>"; } } define("CONSTANT", "upload"); if (isset($_POST['Submit'])&& ($_POST['hiddens']=true)){ get_upload_file(CONSTANT);//写入表单所有数据 调用函数 } ?> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1" οnsubmit="return Checklon()"> <table width="372" height="143" border="1"> <tr> <td width="80">姓名:</td> <td width="276"><input name="username" type="text" id="username" οnclick="clearfun()" value="" /></td> </tr> <tr> <td>上传:</td> <td><input name="filename" type="file" id="filename" /> <input name="hiddens" type="hidden" value="1"></input> </td> </tr> <tr> <td>备注:</td> <td><textarea name="message" rows="5" id="message"></textarea></td> </tr> <tr> <td height="29" colspan="2" align="center"><input type="submit" name="Submit" value="提交" /></td> </tr> </table> </form> </body> <span style="color:#FF0000;"><strong><span style="font-size:18px;">下面是用函数封闭显示 日志页面</span></strong></span> <pre name="code" class="php"><?php error_reporting( E_ALL&~E_NOTICE ); function get_show_upload_list($upload_log){ $len=strlen(file_get_contents($upload_log)); $content=substr(file_get_contents($upload_log),0,$len-2); $spilt=str_replace(" ","",$content); $spilt=explode("\r\n",$content); $data = array(); foreach($spilt as $val){ $spilt2=explode(",",$val); $new_arr = array( 'username' => $spilt2[0], 'message' => $spilt2[1], 'url' => $spilt2[2], 'file_name' => $spilt2[3], 'date' => $spilt2[4] ); $data[] = $new_arr; } return $data; } $upload_log='log.txt';//传的LOG 日志文件; var_dump(get_show_upload_list($upload_log)); ?>

上一篇:网络安全的几种攻击方法