예제 #1
0
파일: class_gd.php 프로젝트: Evrika/Vidal
 /** Neka si predstavim vyobrazhaem pravoygylnik s razmeri $width i $height.
  * Izobrazhenieto shte se preorazmeri taka che to shte izliza ot tozi pravoygylnik,
  * no samo po edno (x ili y) izmerenie
  * @param integer $width
  * @param integer $height
  * @return bool */
 public function resize_overflow($width, $height)
 {
     $big = $this->width / $this->height > $width / $height ? $this->width * $height / $this->height : $this->height * $width / $this->width;
     $big = intval($big);
     $return = $img = new gd($this->image, $big);
     if ($return) {
         $this->image = $img->get_image();
         $this->width = $img->get_width();
         $this->height = $img->get_height();
     }
     return $return;
 }
예제 #2
0
 protected function act_thumb()
 {
     $this->getDir($this->get['dir'], true);
     if (!isset($this->get['file']) || !isset($this->get['dir'])) {
         $this->sendDefaultThumb();
     }
     $file = $this->get['file'];
     if (basename($file) != $file) {
         $this->sendDefaultThumb();
     }
     $file = "{$this->thumbsDir}/{$this->type}/{$this->get['dir']}/{$file}";
     if (!is_file($file) || !is_readable($file)) {
         $file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/" . basename($file);
         if (!is_file($file) || !is_readable($file)) {
             $this->sendDefaultThumb($file);
         }
         $image = new gd($file);
         if ($image->init_error) {
             $this->sendDefaultThumb($file);
         }
         $browsable = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG);
         if (in_array($image->type, $browsable) && $image->get_width() <= $this->config['thumbWidth'] && $image->get_height() <= $this->config['thumbHeight']) {
             $type = $image->type == IMAGETYPE_GIF ? "gif" : ($image->type == IMAGETYPE_PNG ? "png" : "jpeg");
             $type = "image/{$type}";
             httpCache::file($file, $type);
         } else {
             $this->sendDefaultThumb($file);
         }
     }
     httpCache::file($file, "image/jpeg");
 }
예제 #3
0
<?php

include_once "inc/classes/class_gd.php";
$gd = new gd();
include_once "modules/tournament2/class_tournament.php";
$tfunc = new tfunc();
$qacc = $_GET["qacc"];
$tournamentid = $_GET["tournamentid"];
$gameid1 = $_GET["gameid1"];
$gameid2 = $_GET["gameid2"];
$score_team1 = $_POST["score_team1"];
$score_team2 = $_POST["score_team2"];
$score_comment = $_POST["score_comment"];
## Ueberschreibungsabfrage
if ($_GET["qacc"] == 1) {
    $score_team1 = $_GET["score_team1"];
    $score_team2 = $_GET["score_team2"];
    $score_comment = $_GET["score_comment"];
}
########## Infos holen
$tournament = $db->qry_first("SELECT name, teamplayer, over18, status, mode, mapcycle, UNIX_TIMESTAMP(starttime) AS starttime, max_games, game_duration, break_duration, tournamentid FROM %prefix%tournament_tournaments WHERE tournamentid = %int%", $tournamentid);
$map = explode("\n", $tournament["mapcycle"]);
if ($map[0] == "") {
    $map[0] = t('unbekannt');
}
$games = $db->qry_first("SELECT COUNT(*) AS anz FROM %prefix%t2_games WHERE (tournamentid = %int%) AND (round=0) GROUP BY round", $tournamentid);
$team_anz = $games["anz"];
$team1 = $db->qry_first("SELECT games.group_nr, games.round, games.position, games.score, games.comment, games.server_id, teams.name, teams.teamid, teams.disqualified, user.userid, user.username\n  FROM %prefix%t2_games AS games\n  LEFT JOIN %prefix%t2_teams AS teams ON games.leaderid = teams.leaderid\n  LEFT JOIN %prefix%user AS user ON user.userid = teams.leaderid\n  WHERE (teams.tournamentid = %int%) AND (games.gameid = %int%)\n  ", $tournamentid, $gameid1);
$team2 = $db->qry_first("SELECT games.round, games.position, games.score, games.comment, games.server_id, teams.name, teams.teamid, teams.disqualified, user.userid, user.username\n  FROM %prefix%t2_games AS games\n  LEFT JOIN %prefix%t2_teams AS teams ON games.leaderid = teams.leaderid\n  LEFT JOIN %prefix%user AS user ON user.userid = teams.leaderid\n  WHERE (teams.tournamentid = %int%) AND (games.gameid = %int%)\n  ", $tournamentid, $gameid2);
########## Einschränkungen prüfen
if ($tournament["name"] == "") {
예제 #4
0
 protected function makeThumb($file, $overwrite = true)
 {
     $gd = new gd($file);
     // Drop files which are not GD handled images
     if ($gd->init_error) {
         return true;
     }
     $thumb = substr($file, strlen($this->config['uploadDir']));
     $thumb = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'] . "/" . $thumb;
     $thumb = path::normalize($thumb);
     $thumbDir = dirname($thumb);
     if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true)) {
         return false;
     }
     if (!$overwrite && is_file($thumb)) {
         return true;
     }
     // Images with smaller resolutions than thumbnails
     if ($gd->get_width() <= $this->config['thumbWidth'] && $gd->get_height() <= $this->config['thumbHeight']) {
         $browsable = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG);
         // Drop only browsable types
         if (in_array($gd->type, $browsable)) {
             return true;
         }
         // Resize image
     } elseif (!$gd->resize_fit($this->config['thumbWidth'], $this->config['thumbHeight'])) {
         return false;
     }
     // Save thumbnail
     return $gd->imagejpeg($thumb, $this->config['jpegQuality']);
 }
예제 #5
0
 protected function act_upload()
 {
     $baseDir = dirname($this->config['uploadDir']);
     if (!isset($this->post['dir']) || false === ($dir = "{$baseDir}/{$this->post['dir']}") || !is_dir($dir) || !is_readable($dir) || !is_writable($dir)) {
         die($this->label("Cannot access or write to upload folder."));
     }
     $message = $this->checkUploadedFile();
     if ($message !== true) {
         if (isset($this->file['tmp_name'])) {
             @unlink($this->file['tmp_name']);
         }
         die($message);
     }
     $sufix = "";
     $i = 1;
     $ext = $this->getExtension($this->file['name'], false);
     $base = strlen($ext) ? substr($this->file['name'], 0, -strlen($ext) - 1) : $this->file['name'];
     do {
         $target = "{$dir}/{$base}{$sufix}" . (strlen($ext) ? ".{$ext}" : "");
         $sufix = "(" . $i++ . ")";
     } while (file_exists($target));
     if (!move_uploaded_file($this->file['tmp_name'], $target)) {
         @unlink($this->file['tmp_name']);
         die($this->label("Cannot move uploaded file to target folder."));
     } elseif (function_exists('chmod')) {
         chmod($target, $this->config['filePerms']);
     }
     echo "/" . basename($target);
     // THUMBNAIL GENERATION
     $gd = new gd($target);
     if ($gd->init_error) {
         return;
     }
     // Images with smaller resolutions than thumbnails
     if ($gd->get_width() <= $this->config['thumbWidth'] && $gd->get_height() <= $this->config['thumbHeight']) {
         $browsable = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_JPEG2000, IMAGETYPE_PNG);
         // Browsable types does not need a thumbnail
         if (in_array($gd->type, $browsable)) {
             return;
         }
         // Resize image
     } elseif (!$gd->resize_fit($this->config['thumbWidth'], $this->config['thumbHeight'])) {
         return;
     }
     // Check thumbnail directory
     $thumb = "{$baseDir}/{$this->config['thumbsDir']}/{$this->post['dir']}";
     if (!is_dir($thumb) && !helper::rmkdir($thumb, $this->config['dirPerms'])) {
         return;
     }
     $thumb .= "/" . basename($target);
     // Save thumbnail
     $gd->imagejpeg($thumb, $this->config['jpegQuality']);
 }
예제 #6
0
 function FetchAttachmentRow($file)
 {
     include_once "inc/classes/class_gd.php";
     $gd = new gd();
     $FileEnding = strtolower(substr($file, strrpos($file, '.'), 5));
     if ($FileEnding == '.png' or $FileEnding == '.gif' or $FileEnding == '.jpg' or $FileEnding == '.jpeg') {
         $FileNamePath = strtolower(substr($file, 0, strrpos($file, '.')));
         $FileThumb = $FileNamePath . '_thumb' . $FileEnding;
         $gd->CreateThumb($file, $FileThumb, '300', '300');
         return HTML_NEWLINE . HTML_NEWLINE . '<a href="' . $file . '" target="_blank"><img src="' . $FileThumb . '" border="0" /></a>';
     } else {
         return HTML_NEWLINE . HTML_NEWLINE . $this->FetchIcon($file, 'download') . ' (' . t('Angehängte Datei herunterladen') . ')';
     }
 }
예제 #7
0
 protected function checkUploadedFile()
 {
     $config =& $this->config;
     $file =& $this->file;
     if (!is_array($file) || !isset($file['name'])) {
         return $this->label("Unknown error");
     }
     $extension = preg_match('/^.*\\.([^\\.]*)$/s', $file['name'], $patt) ? strtolower($patt[1]) : "";
     $extensions = strtolower(helper::clear_whitespaces($this->types[$this->type]));
     // CHECK FOR UPLOAD ERRORS
     if ($file['error']) {
         return $file['error'] == UPLOAD_ERR_INI_SIZE ? $this->label("The uploaded file exceeds {size} bytes.", array('size' => ini_get('upload_max_filesize'))) : ($file['error'] == UPLOAD_ERR_FORM_SIZE ? $this->label("The uploaded file exceeds {size} bytes.", array('size' => $_GET['MAX_FILE_SIZE'])) : ($file['error'] == UPLOAD_ERR_PARTIAL ? $this->label("The uploaded file was only partially uploaded.") : ($file['error'] == UPLOAD_ERR_NO_FILE ? $this->label("No file was uploaded.") : ($file['error'] == UPLOAD_ERR_NO_TMP_DIR ? $this->label("Missing a temporary folder.") : ($file['error'] == UPLOAD_ERR_CANT_WRITE ? $this->label("Failed to write file.") : $this->label("Unknown error."))))));
     } elseif (substr($file['name'], 0, 1) == ".") {
         return $this->label("File name shouldn't begins with '.'");
     } elseif (!$this->validateExtension($extension, $this->type)) {
         return $this->label("Denied file extension.");
     } elseif (preg_match('/^\\*([^ ]+)(.*)?$/s', $extensions, $patt)) {
         list($extensions, $type, $params) = $patt;
         if (class_exists("type_{$type}")) {
             $class = "type_{$type}";
             $type = new $class();
             $cfg = $config;
             if (strlen($params)) {
                 $cfg['params'] = trim($params);
             }
             $response = $type->checkFile($file['tmp_name'], $cfg);
             if ($response !== true) {
                 return $this->label($response);
             }
         } else {
             return $this->label("Unexisting directory type.");
         }
     }
     // IMAGE RESIZE
     $gd = new gd($file['tmp_name']);
     if (!$gd->init_error && ($config['maxImageWidth'] || $config['maxImageHeight']) && ($gd->get_width() > $config['maxImageWidth'] || $gd->get_height() > $config['maxImageHeight']) && (!$gd->resize_fit($config['maxImageWidth'], $config['maxImageHeight']) || !$gd->imagejpeg($file['tmp_name'], $config['jpegQuality']))) {
         return $this->label("The image is too big and/or cannot be resized.");
     }
     return true;
 }
예제 #8
0
파일: show.php 프로젝트: eistr2n/lansuite
<?php

include_once "inc/classes/class_gd.php";
$gd = new gd();
# Forbid changedir to upper directories
$_GET['file'] = str_replace('/..', '', $_GET['file']);
$_GET['file'] = str_replace('\\..', '', $_GET['file']);
$icon_dir = "ext_inc/picgallery_icon/";
function IsSupportedVideo($ext)
{
    if ($ext == "mp4" or $ext == "mpg" or $ext == "mpeg" or $ext == "ogv") {
        return true;
    } else {
        return false;
    }
}
// Returns, wheather the supplied extension is supported, or not.
function IsSupportedType($ext)
{
    $ext = strtolower($ext);
    if (($ext == "jpeg" or $ext == "jpg") and ImageTypes() & IMG_JPG or $ext == "png" and ImageTypes() & IMG_PNG or $ext == "gif" and ImageTypes() & IMG_GIF or $ext == "wbmp" and ImageTypes() & IMG_WBMP or $ext == "bmp" or IsSupportedVideo($ext)) {
        return true;
    } else {
        return false;
    }
}
function IsPackage($ext)
{
    $ext = strtolower($ext);
    if ($ext == "zip" or $ext == "tar" or $ext == "rar" or $ext == "ace" or $ext == "gz" or $ext == "bz") {
        return true;
예제 #9
0
 protected function makeThumb2($target, $fileUpload = null, $overwrite = true)
 {
     $gd = new gd($fileUpload);
     // Drop files which are not GD handled images
     if ($gd->init_error) {
         return true;
     }
     $mpid = strtok($target, '/');
     $thumb = str_replace($mpid, "{$mpid}/{$this->config['thumbsDir']}", $target);
     $thumb = path::normalize($thumb);
     //if (!$overwrite && is_file($thumb))
     //    return true;
     // Resize image
     if (!$gd->resize_fit($this->config['thumbWidth'], $this->config['thumbHeight'])) {
         return false;
     }
     // Save thumbnail
     $temp = tempnam(sys_get_temp_dir(), uniqid());
     if (!$gd->imagejpeg($temp, $this->config['jpegQuality'])) {
         @unlink($temp);
         return false;
     }
     $bucket = 'xinxintong';
     $alioss = $this->get_alioss();
     $rsp = $alioss->upload_file_by_file($bucket, $thumb, $temp);
     @unlink($temp);
     return true;
 }