?? ok.php
字號:
<?php
$MAX_SIZE = 20000000;
$FILE_MIMES = array('application/x-bittorrent');
$FILE_EXTS = array('.torrent');
$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$upload_dir = "files/";
$upload_url = $url_dir."/files/";
$message ="";
/************************************************************
* 創建上傳目錄
************************************************************/
if (!is_dir("files")) {
if (!mkdir($upload_dir))
die ("upload_files directory doesn't exist and creation failed");
if (!chmod($upload_dir,0755))
die ("change permission to 755 failed.");
}
/************************************************************
* 用戶請求進程
************************************************************/
if ($_REQUEST[del] && $DELETABLE) {
$resource = fopen("log.txt","a");
fwrite($resource,date("Ymd h:i:s")."DELETE - $_SERVER[REMOTE_ADDR]"."$_REQUEST[del]\n");
fclose($resource);
if (strpos($_REQUEST[del],"/.")>0); //可能遭到攻擊
else if (strpos($_REQUEST[del],"files/") === false); //可能遭到攻擊
else if (substr($_REQUEST[del],0,6)=="files/") {
unlink($_REQUEST[del]);
print "<script>window.location.href='$url_this?message=deleted successfully'</script>";
}
}
else if ($_FILES['userfile']) {
$resource = fopen("log.txt","a");
fwrite($resource,date("Ymd h:i:s")."UPLOAD - $_SERVER[REMOTE_ADDR]"
.$_FILES['userfile']['name']." "
.$_FILES['userfile']['type']."\n");
fclose($resource);
$file_type = $_FILES['userfile']['type'];
$file_name = $_FILES['userfile']['name'];
$file_ext = substr($file_name,strrpos($file_name,"."));
//文件大小檢查
if ( $_FILES['userfile']['size'] > $MAX_SIZE)
$message = "";
//文件類型/擴展名檢查
else if (!in_array($file_type, $FILE_MIMES)
&& !in_array($file_ext, $FILE_EXTS) )
$message = "";
else
$message = do_upload($upload_dir, $upload_url);
print "<script>window.location.href='$url_this?message=$message'</script>";
}
else if (!$_FILES['userfile']);
else
$message = "Invalid File Specified.";
/************************************************************
* 列出文件
************************************************************/
function do_upload($upload_dir, $upload_url) {
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = date("ymdhis").".torrent";
$file_path = $upload_dir.$file_name;
//文件名字檢查
if ( $file_name =="") {
$message = "Invalid File Name Specified";
return $message;
}
$result = move_uploaded_file($temp_name, $file_path);
if (!chmod($file_path,0755))
$message = "";
else
$message = ($result)?"$file_path" :
"Somthing is wrong with uploading a file.";
return $message;
}
if($message !==""){
//list.php article子目錄中
$title = $_POST['title'];
$content = $_POST['content'];
$writer = $_POST['writer'];
$fl = $_POST['fl'];
require "lib.php";
$db = db_connect();
global $db;
if ($title != "")
{
//String_dowith, text_dowith分別調用了以前的函數
$title = string_dowith($title);
$content = text_dowith($content);
$importtime = date("Y-m-d H:i:s");
$click = 1;
//將文章寫入數據庫表
$sql = "insert into article ";
$sql = $sql."(title,content,importtime,writer,click,parent,adda,fl)";
$sql = $sql." values('$title','$content','$importtime','$writer','$click','$parent','$message','$fl')";
$result = mysql_query($sql, $db) or db_error();
}
}
?>
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=index.php">
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -