* @license MIT License {@link http://www.opensource.org/licenses/mit-license.php} */ header('Pragma: no-cache'); header('Cache-Control: no-store'); header('Content-type: application/json'); require_once 'bootstrap.php'; /** * 响应并分发请求 */ $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;
if ($code != 200) { $msg = QBox\ErrorMessage($code, $error); echo "set Protected code failed: {$code} - {$msg}\n"; } list($result, $code, $error) = $rs->setSeparator("_"); if ($code == 200) { $msg = QBox\ErrorMessage($code, $error); echo "set Separator failed: {$code} - {$msg}\n"; } list($result, $code, $error) = $rs->setStyle($style, $param); if ($code == 200) { $sql = "INSERT INTO `wmstyles`(`user_id`, `style`, `value`)\n\t\t\tVALUES ('{$uid}', '{$style}', '{$param}')"; $db->insert($sql); header("Location: index.php"); } else { $msg = QBox\ErrorMessage($code, $error); echo "set samll.jpg Style failed: {$code} - {$msg}\n"; } } } ?> <!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> <p>欢迎您,<?php echo $username;
/** * 生成 JSON 格式的输出 */ function generate_output_data($result, $code, $error) { $result = $code == 200 ? $result : array("errmsg" => QBox\ErrorMessage($code, $error)); return json_encode(array("code" => $code, "data" => $result)); }