if (empty($_COOKIE["uid"]) || (int) $_COOKIE["uid"] < 1) { header("Location: login.php"); exit; } $uid = $_COOKIE["uid"]; $userinfo = $db->getOne("SELECT username FROM users WHERE id='{$uid}' LIMIT 1"); $username = $userinfo["username"]; if (isset($_GET["id"])) { $id = trim($_GET["id"]); $fileRow = $db->getOne("SELECT id, file_key, file_name, file_size, created_at FROM uploads WHERE id='{$id}' LIMIT 1"); $key = $fileRow["file_key"]; $attName = $fileRow["file_name"]; if (!empty($id)) { list($result, $code, $error) = $rs->Get($key, $attName); if ($code == 200) { $previewURL = QBox_FileOp_ImagePreviewURL($result['url'], 0); } else { $errnum = $code; $errmsg = QBox_ErrorMessage($code, $error); } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>相册 - 浏览图片</title> </head> <body>
$key = isset($_POST["key"]) ? trim($_POST["key"]) : ""; $act = isset($_POST["action"]) ? strtolower(trim($_POST["action"])) : ""; $fileRow = $db->getOne("SELECT file_name FROM uploads WHERE file_key='{$key}' AND user_id=0 LIMIT 1"); $attName = $fileRow["file_name"]; list($result, $code, $error) = $rs->Get($key, $attName); if ($code != 200) { echo json_encode(array("code" => $code, "data" => array("errmsg" => QBox_ErrorMessage($code, $error)))); exit(-1); } $opURL = $result['url']; switch ($act) { case "image_info": $url = QBox_FileOp_ImageInfoURL($opURL); break; case "image_preview": $thumbType = isset($_POST["type"]) ? (int) trim($_POST["type"]) : 1; $url = QBox_FileOp_ImagePreviewURL($opURL, $thumbType); break; case "make_style": $templPngFile = isset($_POST["imagefile"]) ? trim($_POST["imagefile"]) : ""; $paramStr = isset($_POST["imagedesc"]) ? trim($_POST["imagedesc"]) : ""; $quality = isset($_POST["quality"]) ? (int) trim($_POST["quality"]) : 85; $url = QBox_FileOp_StylePreviewURL($opURL, $templPngFile, $paramStr, $quality); break; default: $resp = json_encode(array("code" => 400, "data" => array("errmsg" => "Invalid URL, Unknow <action>: {$act}"))); die($resp); exit(-1); } $resp = json_encode(array("code" => 200, "data" => array("url" => $url))); die($resp);