Example #1
0
    if (strcmp($mime, $check["mime"]) == 0) {
        $supported = true;
    }
}
if (!$supported) {
    echo ajax_format($resp, $check["mime"] . " not supported ({$fname}).");
    exit;
}
$ok = false;
if (strcmp($check["mime"], "image/jpeg") == 0) {
    $img = imagecreatefromjpeg($_FILES["pic"]["tmp_name"]);
    $ok = @imagejpeg($img, $path);
} elseif (strcmp($check["mime"], "image/gif") == 0) {
    $img = imagecreatefromgif($_FILES["pic"]["tmp_name"]);
    $ok = @imagegif($img, $path);
} elseif (strcmp($check["mime"], "image/png") == 0) {
    $img = imagecreatefrompng($_FILES["pic"]["tmp_name"]);
    $ok = @imagepng($img, $path);
}
if (!$ok) {
    echo ajax_format($resp, "failed to save {$fname}.");
    exit;
}
$size = filesize($path);
$resp["name"] = $fname;
$resp["URL"] = util_empty(conf_read("url")) ? "err: URL not set" : conf_read("url") . "/" . $fname;
$resp["mine"] = $check["mime"];
$resp["size"] = $size;
$resp["hsize"] = util_human_size($size);
$resp["root"] = util_empty(conf_read("url")) ? "err: URL not set" : conf_read("url");
echo ajax_format($resp, "");
Example #2
0
util_define_timezone();
$resp = array();
if (isset($_POST["resend"])) {
    $resp["resend"] = $_POST["resend"];
}
if (!secu_isloged() && (!isset($_POST["pass"]) || !secu_login($_POST["pass"]))) {
    echo ajax_format($resp, "wrong password.");
    exit;
}
if (!isset($_POST["file"])) {
    echo ajax_format($resp, "file name missing.");
    exit;
}
$name = basename($_POST["file"]);
$file = dir_pic_path($name);
if (!is_readable($file)) {
    echo ajax_format(array(), "could not open " . $name . " (check permission).");
    exit;
}
$size = getimagesize($file);
if ($size === false) {
    echo ajax_format(array(), "could not open " . $_POST["file"] . ".");
    exit;
}
$resp["name"] = $name;
$resp["type"] = $size["mime"];
$resp["URL"] = util_empty(conf_read("url")) ? "err: URL not set" : conf_read("url") . "/" . $name;
$resp["added"] = date(util_empty(conf_read("timeformat")) ? "d F Y" : conf_read("timeformat"), filemtime($file));
$resp["size"] = util_human_size(filesize($file));
$resp["dimensions"] = $size[0] . 'x' . $size[1];
echo ajax_format($resp);