Example #1
0
$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);
Example #2
0
    header("Location: login.php");
    exit;
}
$uid = $_COOKIE["uid"];
$userinfo = $db->getOne("SELECT username FROM users WHERE id='{$uid}' LIMIT 1");
$username = $userinfo["username"];
$wmstyles = $db->getAll("SELECT * FROM wmstyles WHERE user_id='{$uid}'");
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>
<script type="text/javascript" src="assets/js/jquery.js"></script>