Beispiel #1
0
<?php

/**
 * Spic <https://github.com/ricain/spic>
 * @author Jean Mercadier <jmercadier.fr>
 * @license The MIT License
 */
require_once __DIR__ . "/../private/lib/secu.lib.php";
require_once __DIR__ . "/../private/lib/dir.lib.php";
require_once __DIR__ . "/../private/lib/ajax.lib.php";
require_once __DIR__ . "/../private/lib/util.lib.php";
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;
}
$resp["list"] = dir_list();
echo ajax_format($resp);
Beispiel #2
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, "");