0) { echo json_encode($Fetch[0], JSON_UNESCAPED_UNICODE); } break; case "set"; //修改文件索引数据库 if ($field == "accese_time") { $value = mTime(); } $doc_id = $_POST["doc_id"]; $query = "UPDATE fileindex SET $field='$value' where user_id='$uid' AND id='{$doc_id}'"; $stmt = @PDO_Execute($query); if (!$stmt || ($stmt && $stmt->errorCode() != 0)) { $error = PDO_ErrorInfo(); echo json_encode(array("error" => $error[2], "message" => $query), JSON_UNESCAPED_UNICODE); } else { echo json_encode(array("error" => false, "message" => $query), JSON_UNESCAPED_UNICODE); } break; case "share": //修改文件索引数据库 if (isset($_POST["file"])) { if (isset($_POST["share"])) { $share = $_POST["share"]; } else { $share = 0; } $fileList = $_POST["file"]; $aFileList = str_getcsv($fileList); if (count($aFileList) > 0) { $strFileList = "("; foreach ($aFileList as $file) { $strFileList .= "'{$file}',"; } $strFileList = mb_substr($strFileList, 0, mb_strlen($strFileList, "UTF-8") - 1, "UTF-8"); $strFileList .= ")"; $query = "UPDATE fileindex SET share='$share' where user_id='$uid' AND id in $strFileList"; $stmt = @PDO_Execute($query); if (!$stmt || ($stmt && $stmt->errorCode() != 0)) { $error = PDO_ErrorInfo(); echo "error:{$error[2]}"; } else { echo "ok" . $query; } } } break; case "delete": //移到回收站 { if (isset($_POST["file"])) { $fileList = $_POST["file"]; $aFileList = str_getcsv($fileList); if (count($aFileList) > 0) { $strFileList = "("; foreach ($aFileList as $file) { $strFileList .= "'{$file}',"; } $strFileList = mb_substr($strFileList, 0, mb_strlen($strFileList, "UTF-8") - 1, "UTF-8"); $strFileList .= ")"; $query = "UPDATE fileindex SET status='0',share='0' where user_id='$uid' AND id in $strFileList"; $stmt = @PDO_Execute($query); if (!$stmt || ($stmt && $stmt->errorCode() != 0)) { $error = PDO_ErrorInfo(); echo "error:{$error[2]}"; } else { echo "ok"; } } } break; } case "restore": //从回收站中恢复 if (isset($_POST["file"])) { $fileList = $_POST["file"]; $aFileList = str_getcsv($fileList); if (count($aFileList) > 0) { $strFileList = "("; foreach ($aFileList as $file) { $strFileList .= "'{$file}',"; } $strFileList = mb_substr($strFileList, 0, mb_strlen($strFileList, "UTF-8") - 1, "UTF-8"); $strFileList .= ")"; $query = "UPDATE fileindex SET status='1' where user_id='$uid' AND id in $strFileList"; $stmt = @PDO_Execute($query); if (!$stmt || ($stmt && $stmt->errorCode() != 0)) { $error = PDO_ErrorInfo(); echo "error:{$error[2]}"; } else { echo "ok"; } } } break; case "remove": //彻底删除文件 if (isset($_POST["file"])) { $fileList = $_POST["file"]; $aFileList = str_getcsv($fileList); if (count($aFileList) > 0) { $strFileList = "("; //删除文件 foreach ($aFileList as $file) { if (!unlink($dir . $file)) { echo ("Error deleting $file"); } $strFileList .= "'{$file}',"; } $strFileList = mb_substr($strFileList, 0, mb_strlen($strFileList, "UTF-8") - 1, "UTF-8"); $strFileList .= ")"; //删除记录 $query = "DELETE FROM fileindex WHERE user_id='$uid' AND id in $strFileList"; $stmt = @PDO_Execute($query); if (!$stmt || ($stmt && $stmt->errorCode() != 0)) { $error = PDO_ErrorInfo(); echo "error:{$error[2]}"; } else { echo "删除" . count($aFileList) . "个文件。"; } } } break; case "remove_all": // 清空回收站 break; }