Beispiel #1
0
         if ($_FILES['file']['size'] > $config['limits']['image']['filesize'] * 1024 * 1024) {
             $tplname = 'message';
             tpl_set_var('messagetitle', $message_title_toobig);
             tpl_set_var('message_start', '');
             tpl_set_var('message_end', '');
             tpl_set_var('message', $message_toobig);
             tpl_BuildTemplate();
             exit;
         }
         if ($config['limits']['image']['resize'] == 1 && $_FILES['file']['size'] > 102400) {
             // Apply resize to uploaded image
             $image = new \lib\SimpleImage();
             $image->load($_FILES['file']['tmp_name']);
             if ($image->getHeight() > $image->getWidth() && $image->getHeight() > $config['limits']['image']['height']) {
                 //portrait
                 $image->resizeToHeight($config['limits']['image']['height']);
             }
             if ($image->getHeight() <= $image->getWidth() && $image->getWidth() > $config['limits']['image']['width']) {
                 $image->resizeToWidth($config['limits']['image']['width']);
             }
             $image->save($picdir . '/' . $uuid . '.' . $extension, resolveImageTypeByFileExtension($extension));
         } else {
             // Save uploaded image AS IS
             move_uploaded_file($_FILES['file']['tmp_name'], $picdir . '/' . $uuid . '.' . $extension);
         }
     }
 }
 // store
 $row['spoiler'] = isset($_REQUEST['spoiler']) ? $_REQUEST['spoiler'] : 0;
 if ($row['spoiler'] != 0 && $row['spoiler'] != 1) {
     $row['spoiler'] = 0;
$size = $_FILES['myfile']['size'];
if (strlen($name)) {
    $fileInfo = pathinfo($name);
    $txt = $fileInfo['filename'];
    $ext = strtolower($fileInfo['extension']);
    if (in_array($ext, $valid_formats)) {
        if ($size < 1024 * 1024 * 2) {
            // Image size max 2 MB
            $actual_image_name = powerTrailBase::powerTrailLogoFileName . $powerTrailId . "." . $ext;
            $result = 0;
            $target_path = $destination_path . $actual_image_name;
            $image = new \lib\SimpleImage();
            $image->load($_FILES['myfile']['tmp_name']);
            if ($image->getHeight() > $image->getWidth() && $image->getHeight() > 250) {
                //portrait
                $image->resizeToHeight(250);
            }
            if ($image->getHeight() < $image->getWidth() && $image->getWidth() > 250) {
                $image->resizeToWidth(250);
            }
            $image->save($target_path);
            $query = 'UPDATE `PowerTrail` SET `image`= :1 WHERE `id` = :2';
            $db = \lib\Database\DataBaseSingleton::Instance();
            $db->multiVariableQuery($query, $picurl . '/' . $actual_image_name, $powerTrailId);
            $result = '<img src="' . $picurl . '/' . $actual_image_name . '?' . rand(1000, 9999) . '" />';
        }
    }
}
?>

<script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php 
Beispiel #3
0
 if ($_FILES['file']['size'] > $maximumPictureWeight * 1024 * 1024) {
     // file too big
     $tplname = 'message';
     tpl_set_var('messagetitle', $message_title_toobig);
     tpl_set_var('message_start', '');
     tpl_set_var('message_end', '');
     tpl_set_var('message', $message_toobig);
     tpl_BuildTemplate();
     exit;
 }
 $uuid = create_uuid();
 $image = new \lib\SimpleImage();
 $image->load($_FILES['file']['tmp_name']);
 if ($image->getHeight() > $image->getWidth() && $image->getHeight() > 640) {
     //portrait
     $image->resizeToHeight(640);
 }
 if ($image->getHeight() <= $image->getWidth() && $image->getWidth() > 480) {
     $image->resizeToWidth(640);
 }
 $image->save($picdir . '/' . $uuid . '.' . $extension, resolveImageTypeByFileExtension($extension));
 sql("INSERT INTO pictures (`uuid`, `url`, `last_modified`, `title`, `description`, `desc_html`, `date_created`, `last_url_check`, `object_id`, `object_type`, `user_id`,`local`,`spoiler`,`display`,`node`,`seq`) VALUES ('&1', '&2', NOW(), '&3', '', 0, NOW(), NOW(),'&4', '&5', '&6', 1, '&7', '&8', '&9', '&10')", $uuid, $picurl . '/' . $uuid . '.' . $extension, $title, $objectid, $type, $usr['userid'], $bSpoiler == 1 ? '1' : '0', $bNoDisplay == 1 ? '0' : '1', $oc_nodeid, $def_seq);
 switch ($type) {
     // log
     case 1:
         sql("UPDATE `cache_logs` SET `picturescount`=`picturescount`+1 WHERE `id`='&1'", $objectid);
         tpl_redirect('viewcache.php?cacheid=' . urlencode($cacheid));
         break;
         // cache
     // cache
     case 2: