/** * 水印添加 * @param $source 原图片路径 * @param $target 生成水印图片途径,默认为空,覆盖原图 * @param $siteid 站点id,系统需根据站点id获取水印信息 */ function watermark($source, $target = '', $siteid) { global $image_w; if (empty($source)) { return $source; } if (!extension_loaded('gd') || strpos($source, '://')) { return $source; } if (!$target) { $target = $source; } if (!is_object($image_w)) { pc_base::load_sys_class('image', '', '0'); $image_w = new image(0, $siteid); } $image_w->watermark($source, $target); return $target; }
function WaterImg($srcFile, $fromGo = 'up') { include DEDEDATA . '/mark/inc_photowatermark_config.php'; require_once DEDEINC . '/image.class.php'; if (isset($GLOBALS['needwatermark'])) { $photo_markup = $photo_markdown = empty($GLOBALS['needwatermark']) ? '0' : '1'; } if ($photo_markup != '1' || $fromGo == 'collect' && $photo_markdown != '1') { return; } $info = ''; $srcInfo = @getimagesize($srcFile, $info); $srcFile_w = $srcInfo[0]; $srcFile_h = $srcInfo[1]; if ($srcFile_w < $photo_wwidth || $srcFile_h < $photo_wheight) { return; } if ($fromGo == 'up' && $photo_markup == '0') { return; } if ($fromGo == 'down' && $photo_markdown == '0') { return; } $TRUEMarkimg = DEDEDATA . '/mark/' . $photo_markimg; if (!file_exists($TRUEMarkimg) || empty($photo_markimg)) { $TRUEMarkimg = ""; } if ($photo_waterpos == 0) { $photo_waterpos = rand(1, 9); } $cfg_watermarktext = array(); if ($photo_marktype == '2') { if (file_exists(DEDEDATA . '/mark/simhei.ttf')) { $cfg_watermarktext['fontpath'] = DEDEDATA . '/mark/simhei.ttf'; } else { return; } } $cfg_watermarktext['text'] = $photo_watertext; $cfg_watermarktext['size'] = $photo_fontsize; $cfg_watermarktext['angle'] = '0'; $cfg_watermarktext['color'] = '255,255,255'; $cfg_watermarktext['shadowx'] = '0'; $cfg_watermarktext['shadowy'] = '0'; $cfg_watermarktext['shadowcolor'] = '0,0,0'; $photo_marktrans = 85; $img = new image($srcFile, 0, $cfg_watermarktext, $photo_waterpos, $photo_diaphaneity, $photo_wheight, $photo_wwidth, $photo_marktype, $photo_marktrans, $TRUEMarkimg); $img->watermark(0); }
/** * 附件上传方法 * @param $field 上传字段 * @param $alowexts 允许上传类型 * @param $maxsize 最大上传大小 * @param $overwrite 是否覆盖原有文件 * @param $thumb_setting 缩略图设置 * @param $watermark_enable 是否添加水印 */ function upload($field, $alowexts = '', $maxsize = 0, $overwrite = 0, $thumb_setting = array(), $watermark_enable = 1) { if (!isset($_FILES[$field])) { $this->error = UPLOAD_ERR_OK; return false; } if (empty($alowexts) || $alowexts == '') { $site_setting = $this->_get_site_setting($this->siteid); $alowexts = $site_setting['upload_allowext']; } $fn = $_GET['CKEditorFuncNum'] ? $_GET['CKEditorFuncNum'] : '1'; $this->field = $field; $this->savepath = $this->upload_root . $this->upload_dir . date('Y/md/'); $this->alowexts = $alowexts; $this->maxsize = $maxsize; $this->overwrite = $overwrite; $uploadfiles = array(); $description = isset($GLOBALS[$field . '_description']) ? $GLOBALS[$field . '_description'] : array(); if (is_array($_FILES[$field]['error'])) { $this->uploads = count($_FILES[$field]['error']); foreach ($_FILES[$field]['error'] as $key => $error) { if ($error === UPLOAD_ERR_NO_FILE) { continue; } if ($error !== UPLOAD_ERR_OK) { $this->error = $error; return false; } $uploadfiles[$key] = array('tmp_name' => $_FILES[$field]['tmp_name'][$key], 'name' => $_FILES[$field]['name'][$key], 'type' => $_FILES[$field]['type'][$key], 'size' => $_FILES[$field]['size'][$key], 'error' => $_FILES[$field]['error'][$key], 'description' => $description[$key], 'fn' => $fn); } } else { $this->uploads = 1; if (!$description) { $description = ''; } $uploadfiles[0] = array('tmp_name' => $_FILES[$field]['tmp_name'], 'name' => $_FILES[$field]['name'], 'type' => $_FILES[$field]['type'], 'size' => $_FILES[$field]['size'], 'error' => $_FILES[$field]['error'], 'description' => $description, 'fn' => $fn); } if (!dir_create($this->savepath)) { $this->error = '8'; return false; } if (!is_dir($this->savepath)) { $this->error = '8'; return false; } @chmod($this->savepath, 0777); if (!is_writeable($this->savepath)) { $this->error = '9'; return false; } if (!$this->is_allow_upload()) { $this->error = '13'; return false; } $aids = array(); foreach ($uploadfiles as $k => $file) { $fileext = fileext($file['name']); if ($file['error'] != 0) { $this->error = $file['error']; return false; } if (!preg_match("/^(" . $this->alowexts . ")\$/", $fileext)) { $this->error = '10'; return false; } if ($this->maxsize && $file['size'] > $this->maxsize) { $this->error = '11'; return false; } if (!$this->isuploadedfile($file['tmp_name'])) { $this->error = '12'; return false; } $temp_filename = $this->getname($fileext); $savefile = $this->savepath . $temp_filename; $savefile = preg_replace("/(php|phtml|php3|php4|jsp|exe|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\\.|\$)/i", "_\\1\\2", $savefile); $filepath = preg_replace(new_addslashes("|^" . $this->upload_root . "|"), "", $savefile); if (!$this->overwrite && file_exists($savefile)) { continue; } $upload_func = $this->upload_func; if (@$upload_func($file['tmp_name'], $savefile)) { $this->uploadeds++; @chmod($savefile, 0644); @unlink($file['tmp_name']); $file['name'] = iconv("utf-8", CHARSET, $file['name']); $file['name'] = safe_replace($file['name']); $uploadedfile = array('filename' => $file['name'], 'filepath' => $filepath, 'filesize' => $file['size'], 'fileext' => $fileext, 'fn' => $file['fn']); $thumb_enable = is_array($thumb_setting) && ($thumb_setting[0] > 0 || $thumb_setting[1] > 0) ? 1 : 0; $image = new image($thumb_enable, $this->siteid); if ($thumb_enable) { $image->thumb($savefile, '', $thumb_setting[0], $thumb_setting[1]); } if ($watermark_enable) { $image->watermark($savefile, $savefile); } $aids[] = $this->add($uploadedfile); } } return $aids; }
function inline_upload() { global $set, $db, $apx; $file = $_FILES['image']; //Prüfen ob eine Datei hochgeladen wurde, falls ja verschieben if (!$file['tmp_name']) { return; } if (!is_uploaded_file($file['tmp_name'])) { return; } if (!checkToken()) { printInvalidToken(); exit; } $ext = strtolower($this->mm->getext($file['name'])); if ($ext == 'gif') { $ext = 'jpg'; } $tempfile = md5(microtime()) . '.' . $ext; $this->mm->uploadfile($file, 'inline', $tempfile); //Nächste ID auslesen $tblinfo = $db->first("SHOW TABLE STATUS LIKE '" . PRE . "_inlinescreens'"); $now = time(); //Einheitliche Upload-Zeit, auch wenns nicht stimmt $newname = 'pic' . '-' . $tblinfo['Auto_increment'] . '.' . $ext; $newfile = 'inline/' . $newname; $popname = 'pic' . '-' . $tblinfo['Auto_increment'] . '-popup.' . $ext; $popfile = 'inline/' . $popname; //Bild einlesen require_once BASEDIR . 'lib/class.image.php'; $img = new image(); ////// NORMALES BILD list($picture, $picturetype) = $img->getimage('inline/' . $tempfile); //Skalieren if ($picture !== false && ($_POST['size_x'] || $_POST['size_y'])) { $scaled = $img->resize($picture, $_POST['size_x'], $_POST['size_y'], $set['mediamanager']['quality_resize'], 0); if ($scaled != $picture) { imagedestroy($picture); } $picture = $scaled; } //Wasserzeichen einfügen if ($picture !== false && $set['mediamanager']['watermark'] && $_POST['watermark']) { $watermarked = $img->watermark($picture, $set['mediamanager']['watermark'], $set['mediamanager']['watermark_position'], $set['mediamanager']['watermark_transp']); if ($watermarked != $picture) { imagedestroy($picture); } $picture = $watermarked; } //Bild erstellen $img->saveimage($picture, $picturetype, $newfile); imagedestroy($picture); ////// POPUP-BILD if ($_POST['popup']) { list($picture, $picturetype) = $img->getimage('inline/' . $tempfile); //Skalieren if ($picture !== false && ($_POST['popup_size_x'] || $_POST['popup_size_y'])) { $scaled = $img->resize($picture, $_POST['popup_size_x'], $_POST['popup_size_y'], $set['mediamanager']['quality_resize'], 0); if ($scaled != $picture) { imagedestroy($picture); } $picture = $scaled; } //Wasserzeichen einfügen if ($picture !== false && $set['mediamanager']['watermark'] && $_POST['popup_watermark']) { $watermarked = $img->watermark($picture, $set['mediamanager']['watermark'], $set['mediamanager']['watermark_position'], $set['mediamanager']['watermark_transp']); if ($watermarked != $picture) { imagedestroy($picture); } $picture = $watermarked; } //Bild erstellen $img->saveimage($picture, $picturetype, $popfile); imagedestroy($picture); } //Cachefile löschen $this->mm->deletefile('inline/' . $tempfile); $_POST['addtime'] = time(); $_POST['picture'] = $newfile; if ($_POST['popup']) { $_POST['popup'] = $popfile; } else { $_POST['popup'] = ''; } $db->dinsert(PRE . '_inlinescreens', 'module,mid,hash,picture,popup,align,text,addtime'); logit('MEDIAMANAGER_INLINE', 'ID #' . $db->insert_id()); printJSRedirect('action.php?action=mediamanager.inline&module=' . $_REQUEST['module'] . '&mid=' . $_REQUEST['mid'] . '&hash=' . $_REQUEST['hash'] . '&fields=' . $_REQUEST['fields']); exit; }
function padd() { global $set, $db, $apx; $_REQUEST['id'] = (int) $_REQUEST['id']; if (!$_REQUEST['id']) { die('missing ID!'); } if (!$this->access_pics($_REQUEST['id'], 'videos.padd')) { die('you have no right to access this video!'); } if ($_POST['send'] == 1) { require_once BASEDIR . 'lib/class.image.php'; $img = new image(); $tblinfo = $db->first("SHOW TABLE STATUS LIKE '" . PRE . "_videos_screens'"); $nextid = $tblinfo['Auto_increment']; //Bilder prüfen $error = array(); for ($i = 1; $i <= $set['videos']['addpics']; $i++) { if (!$_FILES['upload' . $i]['tmp_name']) { continue; } $imginfo = getimagesize($_FILES['upload' . $i]['tmp_name']); if (!in_array($imginfo[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) { $error[] = $apx->lang->get('MSG_NOIMAGE', array('NAME' => $_FILES['upload' . $i]['name'])); } if ($error) { info(implode('<br />', $error)); return; } } //Bilder abarbeiten for ($i = 1; $i <= $set['videos']['addpics']; $i++) { if (!$_FILES['upload' . $i]['tmp_name']) { continue; } $ext = strtolower($this->mm->getext($_FILES['upload' . $i]['name'])); if ($ext == 'gif') { $ext = 'jpg'; } $newname = 'pic' . '-' . $_POST['id'] . '-' . $nextid . '.' . $ext; $newfile = 'videos/screens/' . $newname; $thumbname = 'pic' . '-' . $_POST['id'] . '-' . $nextid . '-thumb.' . $ext; $thumbfile = 'videos/screens/' . $thumbname; //Erfolgreichen Upload prüfen if (!$this->mm->uploadfile($_FILES['upload' . $i], 'videos/screens', $newname)) { continue; } //Bild einlesen list($picture, $picturetype) = $img->getimage($newfile); //////// THUMBNAIL $thumbnail = $img->resize($picture, $set['videos']['thumbwidth'], $set['videos']['thumbheight'], $set['videos']['quality_resize'], $set['videos']['thumb_fit']); $img->saveimage($thumbnail, $picturetype, $thumbfile); //////// BILD //Bild skalieren if ($picture !== false && !$_POST['noresize' . $i] && $set['videos']['picwidth'] && $set['videos']['picheight']) { $scaled = $img->resize($picture, $set['videos']['picwidth'], $set['videos']['picheight'], $set['videos']['quality_resize'], 0); if ($scaled != $picture) { imagedestroy($picture); } $picture = $scaled; } //Wasserzeichen einfügen if ($picture !== false && $set['videos']['watermark'] && $_POST['watermark' . $i]) { $watermarked = $img->watermark($picture, $set['videos']['watermark'], $set['videos']['watermark_position'], $set['videos']['watermark_transp']); if ($watermarked != $picture) { imagedestroy($picture); } $picture = $watermarked; } //Bild erstellen $img->saveimage($picture, $picturetype, $newfile); //Cleanup imagedestroy($picture); imagedestroy($thumbnail); unset($picture, $thumbnail); //In DB eintragen $db->query("INSERT INTO " . PRE . "_videos_screens (videoid, thumbnail, picture) VALUES ('" . $_REQUEST['id'] . "', '" . addslashes($thumbfile) . "', '" . addslashes($newfile) . "')"); logit('VIDEOS_PADD', 'ID #' . $nextid); ++$nextid; } printJSRedirect('action.php?action=videos.pshow&id=' . $_REQUEST['id']); return; } else { for ($i = 1; $i <= $set['videos']['addpics']; $i++) { $_POST['watermark' . $i] = 1; $_POST['allowcoms' . $i] = 1; $_POST['allowrating' . $i] = 1; } } //Felder ausgeben for ($i = 1; $i <= $set['videos']['addpics']; $i++) { $upload[$i]['CAPTION'] = compatible_hsc($_POST['caption' . $i]); $upload[$i]['WATERMARK'] = 1; $upload[$i]['NORESIZE'] = 0; $upload[$i]['ALLOWCOMS'] = 1; $upload[$i]['ALLOWRATING'] = 1; } $apx->tmpl->assign('ID', $_REQUEST['id']); $apx->tmpl->assign('UPLOAD', $upload); $apx->tmpl->assign('SET_WATERMARK', iif($set['videos']['watermark'], 1, 0)); $apx->tmpl->assign('SET_NORESIZE', iif($set['videos']['picwidth'] && $set['videos']['picheight'], 1, 0)); $apx->tmpl->parse('padd'); }
$author = $_SESSION['adminname']; /* if(empty($name) || empty($p_xilie)){ refer('文章名称和文章系列不能为空!'); }elseif((!preg_match("/[0-9]{,4}/i",$price) && !empty($price)) || (!preg_match("/[0-9]{,4}/i",$p_num) && !empty($p_num))){ refer('文章价格和数量只能是数值,请重新填写!'); }*/ // print_r($file); //Array ( [name] => a002d.gif [type] => image/gif [tmp_name] => d:/webserver/Server/TEMP\php8E.tmp [error] => 0 [size] => 19675 ) if (!empty($file['name'])) { $uf = new FileUploader($_FILE['uploadpic']); $pic = $uf->move(ROOT_PATH . 'article_upimg', 2); $uppic = $pic[0] ? get_basename($pic[0]) : 'NULL'; $img = new image(ROOT_PATH . 'article_upimg/' . $uppic); //$img->thumbnail(150,150,ROOT_PATH . 'article_upimg/'.$uppic); $img->watermark(ROOT_PATH . 'include/watermark.png', '', '', ROOT_PATH . 'article_upimg/' . $uppic); } else { $uppic = $_POST['pic']; } $date = date('Y-m-j H:i:s'); if ($_GET['action'] == 'save') { $db->query("INSERT INTO `article` (`a_sort`,`a_ztid`,`aid`,`title`,`author`,`suggest`,`date`,`pic`,`content`) values ({$a_sort},{$a_ztid},{$aid},'{$title}','{$author}',{$suggest},now(),'{$uppic}','{$content}')"); refer('添加成功', 'article_edit.php'); } else { $id = $_POST['updateid']; $db->query("UPDATE `article` SET `p_xilie` = {$p_xilie},`p_sort` = {$p_sort},`p_pinpai` = {$p_pinpai},`name` = '{$name}',`size` = {$size},`xixiang` = '{$xixiang}',`price` = {$price},`p_num` = {$p_num},`suggest` = {$suggest},`pic` = '{$uppic}',`content` = '{$content}' WHERE `id` = {$id}"); refer('更新成功', 'article_manager.php'); } } $query = $db->query("SElECT * FROM `cdb_members` WHERE `uid` = {$uid}"); $result = $db->fetch_array($query);
/** * Unit test * @param string $file */ public static function run_test() { $img = new image(); $img->load('/tmp/test.jpg'); $img->resize(700); $img->watermark('/tmp/wm.png'); $img->resize(200); $img->save('/tmp/success.png'); }
function pictures() { global $set, $db, $apx; //Notwendig weil 1.7.0 beim Kopieren ein Bild mit ID 0 erzeugt hatte :/ if (isset($_REQUEST['delpic'])) { $_REQUEST['delpic'] = (int) $_REQUEST['delpic']; } else { $_REQUEST['delpic'] = null; } //Bilder auslesen list($pictures, $nextid) = $db->first("SELECT pictures,pictures_nextid FROM " . PRE . "_articles WHERE id='" . $_REQUEST['id'] . "'"); $pictures = unserialize($pictures); if (!is_array($pictures)) { $pictures = array(); } //Bild löschen if (isset($_REQUEST['delpic']) && isset($pictures[$_REQUEST['delpic']])) { if ($_POST['delpic']) { if (!checkToken()) { printInvalidToken(); } else { $picinfo = $pictures[$_REQUEST['delpic']]; require BASEDIR . 'lib/class.mediamanager.php'; $mm = new mediamanager(); if ($picinfo['thumbnail'] && file_exists(BASEDIR . getpath('uploads') . $picinfo['thumbnail'])) { $mm->deletefile($picinfo['thumbnail']); } if ($picinfo['picture'] && file_exists(BASEDIR . getpath('uploads') . $picinfo['picture'])) { $mm->deletefile($picinfo['picture']); } unset($pictures[$_REQUEST['delpic']]); $db->query("UPDATE " . PRE . "_articles SET pictures='" . addslashes(serialize($pictures)) . "' WHERE id='" . $_REQUEST['id'] . "' LIMIT 1"); printJSRedirect('action.php?action=' . $_REQUEST['action'] . '&id=' . $_REQUEST['id'] . '&pubnow=' . $_REQUEST['pubnow'] . '&pageid=pics'); } } else { tmessageOverlay('picdel', array('ID' => $_REQUEST['id'], 'DELPIC' => $_REQUEST['delpic'])); } } elseif ($_POST['send']) { require BASEDIR . 'lib/class.mediamanager.php'; $mm = new mediamanager(); require_once BASEDIR . 'lib/class.image.php'; $img = new image(); //Bilder abarbeiten for ($i = 1; $i <= 5; $i++) { if (!$_FILES['upload' . $i]['tmp_name']) { continue; } $ext = strtolower($mm->getext($_FILES['upload' . $i]['name'])); if ($ext == 'gif') { $ext = 'jpg'; } $newname = 'pic' . '-' . $_POST['id'] . '-' . $nextid . '.' . $ext; $newfile = 'articles/gallery/' . $newname; $thumbname = 'pic' . '-' . $_POST['id'] . '-' . $nextid . '-thumb.' . $ext; $thumbfile = 'articles/gallery/' . $thumbname; //Erfolgreichen Upload prüfen if (!$mm->uploadfile($_FILES['upload' . $i], 'articles/gallery', $newname)) { continue; } //Bild einlesen list($picture, $picturetype) = $img->getimage($newfile); //////// THUMBNAIL $thumbnail = $img->resize($picture, $set['articles']['thumbwidth'], $set['articles']['thumbheight'], $set['articles']['artpic_quality']); $img->saveimage($thumbnail, $picturetype, $thumbfile); //////// BILD //Bild skalieren if ($picture !== false && !$_POST['noresize' . $i] && $set['articles']['picwidth'] && $set['articles']['picheight']) { $scaled = $img->resize($picture, $set['articles']['picwidth'], $set['articles']['picheight'], $set['articles']['artpic_quality'], 0); if ($scaled != $picture) { imagedestroy($picture); } $picture = $scaled; } //Wasserzeichen einfügen if ($picture !== false && $set['articles']['watermark'] && $_POST['watermark' . $i]) { $watermarked = $img->watermark($picture, $set['articles']['watermark'], $set['articles']['watermark_position'], $set['articles']['watermark_transp']); if ($watermarked != $picture) { imagedestroy($picture); } $picture = $watermarked; } //Bild erstellen $img->saveimage($picture, $picturetype, $newfile); //Cleanup imagedestroy($picture); imagedestroy($thumbnail); unset($picture, $thumbnail); $pictures[$nextid] = array('picture' => $newfile, 'thumbnail' => $thumbfile); ++$nextid; } //Bilder eintragen $db->query("UPDATE " . PRE . "_articles SET pictures='" . addslashes(serialize($pictures)) . "',pictures_nextid='" . intval($nextid) . "' WHERE id='" . $_REQUEST['id'] . "' LIMIT 1"); //Artikel beenden if ($_POST['submit_finish']) { $this->finish_article(); return; } else { printJSRedirect('action.php?action=' . $_REQUEST['action'] . '&id=' . $_REQUEST['id'] . '&pubnow=' . $_REQUEST['pubnow'] . '&pageid=pics'); } } else { echo '<h2>' . $apx->lang->get(iif($this->type == 'normal', 'ARTICLE', strtoupper($this->type))) . ': ' . $this->title . '</h2>'; //Bilderserie auflisten foreach ($pictures as $id => $res) { ++$i; $picdata[$i]['ID'] = $id; $picdata[$i]['IMAGE'] = HTTPDIR . getpath('uploads') . $res['thumbnail']; $picdata[$i]['LINK'] = HTTPDIR . getpath('uploads') . $res['picture']; $picdata[$i]['OPTIONS'] .= optionHTMLOverlay('del.gif', $_REQUEST['action'], 'id=' . $_REQUEST['id'] . '&pageid=pics&delpic=' . $id . '&pubnow=' . $_REQUEST['pubnow'], $apx->lang->get('CORE_DEL')); } $apx->tmpl->assign('SET_WATERMARK', iif($set['articles']['watermark'], 1, 0)); $apx->tmpl->assign('SET_NORESIZE', iif($set['articles']['picwidth'] && $set['articles']['picheight'], 1, 0)); $apx->tmpl->assign('PIC', $picdata); $apx->tmpl->assign('PUBNOW', (int) $_REQUEST['pubnow']); $apx->tmpl->assign('ID', $_REQUEST['id']); $apx->tmpl->assign('ACTION', iif($_REQUEST['action'] == 'articles.add', 'add', 'edit')); $apx->tmpl->parse('pictures'); } }
function makeScreenshots($flvFile, $duration, $id) { $files = array(); $screenid = 1; require_once BASEDIR . 'lib/class.image.php'; $img = new image(); //Screenshots machen for ($i = 1; $i <= 10; $i += 2) { unset($output); $newname = 'pic-' . $id . '-' . $screenid . '.jpg'; $newfile = 'videos/screens/' . $newname; $thumbname = 'pic-' . $id . '-' . $screenid . '-thumb.jpg'; $thumbfile = 'videos/screens/' . $thumbname; //Screenshot erzeugen $screenfrom = floor($duration / 11 * $i); $cmd = $this->ffmpeg . ' -itsoffset -' . $screenfrom . ' -i ' . $flvFile . ' -vframes 1 -f mjpeg -sameq ' . BASEDIR . getpath('uploads') . $newfile . ' 2>&1'; exec($cmd, $output, $returnval); echo $cmd . "\n" . implode("\n", $output) . "\nreturns " . $returnval . "\n"; echo "\n--------------------------------------------\n\n"; $this->forceLogOut(); //Bild einlesen list($picture, $picturetype) = $img->getimage($newfile); //////// THUMBNAIL $thumbnail = $img->resize($picture, $this->thumbwidth, $this->thumbheight, $this->quality_resize, false); $img->saveimage($thumbnail, $picturetype, $thumbfile); //////// BILD //Bild skalieren if ($picture !== false && $this->picwidth && $this->picheight) { $scaled = $img->resize($picture, $this->picwidth, $this->picheight, $this->quality_resize, 0); if ($scaled != $picture) { imagedestroy($picture); } $picture = $scaled; } //Wasserzeichen einfügen if ($picture !== false && $this->watermark) { $watermarked = $img->watermark($picture, $this->watermark, $this->watermark_position, $this->watermark_transp); if ($watermarked != $picture) { imagedestroy($picture); } $picture = $watermarked; } //Bild erstellen $img->saveimage($picture, $picturetype, $newfile); //Cleanup imagedestroy($picture); imagedestroy($thumbnail); unset($picture, $thumbnail); $files[] = array('thumbnail' => $thumbfile, 'picture' => $newfile); ++$screenid; } return $files; }
function process_files($files) { global $set, $db, $apx; $tblinfo = $db->first("SHOW TABLE STATUS LIKE '" . PRE . "_gallery_pics'"); $now = time(); //Einheitliche Upload-Zeit, auch wenns nicht stimmt require_once BASEDIR . 'lib/class.image.php'; $img = new image(); $mm = new mediamanager(); foreach ($files as $file) { ++$i; $newname = 'pic' . '-' . ($tblinfo['Auto_increment'] + $i - 1) . '.' . $file['ext']; $newfile = 'gallery/' . $_REQUEST['id'] . '/' . $newname; $thumbname = 'pic' . '-' . ($tblinfo['Auto_increment'] + $i - 1) . '-thumb.' . $file['ext']; $thumbfile = 'gallery/' . $_REQUEST['id'] . '/' . $thumbname; //Bild einlesen list($picture, $picturetype) = $img->getimage($file['source']); //////// THUMBNAIL $thumbnail = $img->resize($picture, $set['gallery']['thumbwidth'], $set['gallery']['thumbheight'], $set['gallery']['quality_resize'], $set['gallery']['thumb_fit']); $img->saveimage($thumbnail, $picturetype, $thumbfile); //////// BILD //Skalieren if ($picture !== false && !$file['noresize'] && $set['gallery']['picwidth'] && $set['gallery']['picheight']) { $scaled = $img->resize($picture, $set['gallery']['picwidth'], $set['gallery']['picheight'], $set['gallery']['quality_resize'], 0); if ($scaled != $picture) { imagedestroy($picture); } $picture = $scaled; } //Wasserzeichen einfügen if ($picture !== false && $set['gallery']['watermark'] && $file['watermark']) { $watermarked = $img->watermark($picture, $set['gallery']['watermark'], $set['gallery']['watermark_position'], $set['gallery']['watermark_transp']); if ($watermarked != $picture) { imagedestroy($picture); } $picture = $watermarked; } //Bild erstellen $img->saveimage($picture, $picturetype, $newfile); //Cleanup imagedestroy($picture); imagedestroy($thumbnail); unset($picture, $thumbnail); if ($_POST['what'] != 'ftp' || $_POST['delpics']) { $mm->deletefile($file['source']); } $db->query("INSERT INTO " . PRE . "_gallery_pics VALUES (0,'" . $_REQUEST['id'] . "','" . $thumbfile . "','" . $newfile . "','" . addslashes($file['caption']) . "',0,'" . $now . "','" . (int) $file['allowcoms'] . "','" . (int) $file['allowrating'] . "','1','0')"); logit('GALLERY_PADD', 'ID #' . $db->insert_id()); } $this->files = $i; }