文章出處
文章列表
文件管理系統
<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8"> </head> <body> <?php $path = @$_GET["path"]; if(empty($path)) $path = "./"; $filterList = array("filesystem.php"); $filename = trim($path,"/")."/".@$_GET["name"]; switch(@$_GET["action"]) { case "del" : @unlink($filename); break; case "add" : echo $path; if( file_exists($filename) ) { die("file exists"); }else{ $f = fopen($filename,"w"); fclose($f); } echo $filename; break; case "edit" : $fielinfo = file_get_contents($filename); echo "<br>"; echo "<form action='filesystem.php?action=update' method='post'>"; echo "<textarea name='content'> {$fielinfo} </textarea>"; echo "<input type='hidden' value='{$filename}' name='name'>"; echo "<input type='submit'>"; echo "</form>"; break; break; case "update" : $content = $_POST["content"]; $f = $_POST["name"]; file_put_contents($f, $content); break; default: } if( !file_exists($path) || !is_dir($path) ) { die( $path."目錄無效" ); }; echo "<p>{$path}目錄</p>"; echo "<p> <form action='filesystem.php' method='get'> 創建文件 : <input type='hidden' name='path' value='{$path}'><input type='hidden' name='action' value='add'></input> <input name='name'><input type='submit'></input></form></p>"; echo "<table border='1'>"; $dir = opendir($path); if($dir) { $i = 0; while($f = readdir($dir)) { if($f=="."|| $f=="..") continue; $file = trim($path, "/")."/".$f; $i++; echo "<tr>"; echo "<td> {$i} </td>"; echo "<td> {$f} </td>"; echo "<td>".filetype($file)."</td>"; echo "<td>".filesize($file)."</td>"; echo "<td>".date("Y-m-d",filectime($file))."</td>"; if( !in_array($f, $filterList) ) { echo "<td><a href='filesystem.php?path={$path}&name={$f}&action=del'>刪除</a></td>"; echo "<td><a href='filesystem.php?path={$path}&name={$f}&action=edit'>編輯</a></td>"; } echo "</tr>"; } } closedir($dir); echo "</table>"; ?> </body> </html>
只能管理文件, 不能管理目錄..
打印萬年歷, 這個666了, 邏輯剛開始沒搞懂...:
<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8"> </head> <body> <?php @$y = $_GET["Y"] ? $_GET["Y"] : date("Y"); @$m = $_GET["m"] ? $_GET["m"] : date("m"); echo $y; echo $m; $t = date("t",mktime(0,0,0,$m, 1, $y)); $w = date("w",mktime(0,0,0,$m, 1, $y)); $arr = array("周一","周二","周三","周四","周五","周六","周日"); echo "<h4>{$y}年{$m}月</h4>"; echo "<table><thead><tr>"; foreach($arr as $d) { echo "<td>{$d}</td>"; } echo "</tr></thead><tbody>"; echo "<tr>"; $temp = 1; for($i=1; $i<$t+1; ) { for($j=0;$j<7;$j++) { if($temp<($w+1)) { echo "<td>_</td>"; $temp++; continue; } if($i<$t+1 ) { echo "<td>{$i}</td>"; $i++; } } echo "</tr><tr>"; } echo "</tr>"; echo "</tbody>"; echo "</table>"; ?> </body> </html>
php高版本還支持定界符, 相對于js中的``符號, 內部的代碼會原封不動的輸出:
<?php $str = 'abc'; print<<<EOF {$str}efg EOF; ?>
foreach循環輸出object對象的key和值:
<?php $arr = array("a"=>"aa", "b"=>"bb", "c"=>"cc"); foreach( $arr as $k => $val) { echo $k ."+"; echo $val. "\n"; } ?>
$GLOBALS['var'] 是外部的全局變量$var本身。
global $var 是外部$var的同名引用或者指針。(錯誤:是個別名引用而已,非指針!!!)
把字符串轉化為base64編碼:
<?php echo base64_encode("string"); ?>
廈門點燃未來網絡科技有限公司, 是廈門最好的微信應用, 小程序, 微信網站, 公眾號開發公司
EOF
文章列表
全站熱搜