예제 #1
0
파일: download.php 프로젝트: vinod-co/centa
$title = check_var('path', 'GET', true, false, true);
$base_dir = $cfg_web_root . 'qti/exports/';
$accessfile = $base_dir . $path . "/access.xml";
if (!file_exists($accessfile)) {
    exit;
}
$xmlStr = file_get_contents($accessfile);
$xml = simplexml_load_string($xmlStr);
if ($userObject->get_user_ID() != $xml->owner) {
    exit;
}
$xmlfile = $base_dir . $path . "/" . $file;
$ext = strtolower(substr($file, strrpos($file, ".") + 1));
$filename = $file;
if ($title) {
    $filename = CleanFileName($title) . "." . $ext;
}
function head($text)
{
    header($text);
}
head('Pragma: public');
if ($ext == "xml") {
    head('Content-Type: text/xml; charset=UTF-8');
} elseif ($ext == "zip") {
    head('Content-Type: application/zip');
} else {
    if ($ext == "png") {
        head('Content-Type: image/png');
    } else {
        if ($ext == "gif") {
예제 #2
0
        $new_height = $thumbnail_target_height;
        $new_width = $img_ratio * $thumbnail_target_height;
    } else {
        $new_height = $thumbnail_target_width / $img_ratio;
        $new_width = $thumbnail_target_width;
    }
    if ($new_height > $thumbnail_target_height) {
        $new_height = $thumbnail_target_height;
    }
    if ($new_width > $thumbnail_target_width) {
        $new_height = $thumbnail_target_width;
    }
    $new_img = ImageCreateTrueColor(100, 100);
    if (!@imagefilledrectangle($new_img, 0, 0, $thumbnail_target_width - 1, $thumbnail_target_height - 1, 0)) {
        // Fill the image black
        echo "ERROR:Could not fill new image";
        exit(0);
    }
    if (!@imagecopyresampled($new_img, $img, ($thumbnail_target_width - $new_width) / 2, ($thumbnail_target_height - $new_height) / 2, 0, 0, $new_width, $new_height, $width, $height)) {
        echo "ERROR:Could not resize image";
        exit(0);
    }
    if (!isset($_SESSION["file_info"])) {
        $_SESSION["file_info"] = array();
    }
    imagejpeg($new_img, $path . "/th/" . CleanFileName($_FILES["Filedata"]["name"]));
    chmod($path . "/th/" . $_FILES["Filedata"]["name"], 0777);
    imagedestroy($new_img);
}
imagedestroy($img);
imagedestroy($image_p);