コード例 #1
0
ファイル: test_imagewatermark.php プロジェクト: chaobj001/tt
<?php

//ͼƬˮӡÀà²âÊÔ
//by indraw
//2004/11/18
error_reporting(E_ERROR | E_WARNING | E_PARSE);
include 'ImageWatermark.class.php';
//---------------------------------------------------------
//echo("test:");
//echo(utf8_encode("ÄãºÃ°¡"));
//ʹÓ÷½·¨:
$img = new Watermark();
$img->wm_text = "ÄãºÃÂð£¿fadsfa";
$img->wm_text_font = "simkai.ttf";
$img->wm_image_name = "./aaa.jpg";
$img->wm_text_size = "40";
$img->create("./test.jpg");
//---------------------------------------------------------
コード例 #2
0
ファイル: uploadify.php プロジェクト: Jesuslagliva12/OpenAPI
    if ($met_big_wate == 1) {
        $img = new Watermark();
        if ($met_wate_class == 2) {
            $img->met_image_name = $met_wate_bigimg;
            $img->met_image_pos = $met_watermark;
        } else {
            $img->met_text = $met_text_wate;
            $img->met_text_size = $met_text_bigsize;
            $img->met_text_color = $met_text_color;
            $img->met_text_angle = $met_text_angle;
            $img->met_text_pos = $met_watermark;
            $img->met_text_font = $met_text_fonts;
        }
        $img->src_image_name = "../" . $imgurls;
        $img->save_file = $f->waterpath . $f->savename;
        $img->create();
        $imgurls = "../upload/" . date('Ym') . "/watermark/" . $f->savename;
    }
    $metinfo = '1$' . $imgurls;
} elseif ($type == 'skin') {
    /*模板文件*/
    $filetype = explode('.', $_FILES['Filedata']['name']);
    if ($filetype[count($filetype) - 1] == 'zip') {
        if (stristr($met_file_format, 'zip') === false) {
            echo $lang_jsx36;
            die;
        }
        //if(!is_writable('../../templates/'))@chmod('../../templates/',0777);
        $filenamearray = explode('.zip', $_FILES['Filedata']['name']);
        $skin_if = $db->get_one("SELECT * FROM {$met_skin_table} WHERE skin_file='{$filenamearray[0]}'");
        if ($skin_if) {
コード例 #3
0
ファイル: save.php プロジェクト: nanfs/lt
        if ($met_thumb_wate == 1) {
            require_once ROOTPATH_ADMIN . 'include/watermark.class.php';
            $img = new Watermark();
            if ($met_wate_class == 2) {
                $img->met_image_pos = $met_watermark;
                $img->met_image_name = $depth . $met_wate_img;
            } else {
                $img->met_text = $met_text_wate;
                $img->met_text_color = $met_text_color;
                $img->met_text_angle = $met_text_angle;
                $img->met_text_pos = $met_watermark;
                $img->met_text_font = $depth . $met_text_fonts;
                $img->met_text_size = $met_text_size;
            }
            $img->save_file = $imgurls;
            $img->create($imgurls);
        }
        $imgurl = '../upload/images/' . $filenameimg;
        $imgurls = str_replace('../../', '', $imgurls);
    }
}
if ($action == "add") {
    $access = $access != "" ? $access : "0";
    if (!$description) {
        $description = strip_tags($content);
        $description = str_replace("\n", '', $description);
        $description = str_replace("\r", '', $description);
        $description = str_replace("\t", '', $description);
        $description = mb_substr($description, 0, 200, 'utf-8');
    }
    if ($links) {
コード例 #4
0
ファイル: FileUpload.php プロジェクト: Jesuslagliva12/OpenAPI
 /**
  * send response (save uploaded file, resize if required)
  * @access public
  *
  */
 public function sendResponse()
 {
     global $met_wate_class, $met_wate_bigimg, $met_text_wate, $met_text_bigsize, $met_text_color, $met_text_angle, $met_watermark, $met_text_fonts, $met_big_wate, $met_file_maxsize, $met_img_rename;
     $iErrorNumber = CKFINDER_CONNECTOR_ERROR_NONE;
     $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
     $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
     $oRegistry->set("FileUpload_fileName", "unknown file");
     $uploadedFile = array_shift($_FILES);
     if (!isset($uploadedFile['name'])) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID);
     }
     $sUnsafeFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(CKFinder_Connector_Utils_Misc::mbBasename($uploadedFile['name']));
     $sFileName = str_replace(array(":", "*", "?", "|", "/", "——", " "), "_", $sUnsafeFileName);
     if ($_config->getDisallowUnsafeCharacters()) {
         $sFileName = str_replace(";", "_", $sFileName);
     }
     if ($_config->forceAscii()) {
         $sFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sFileName);
     }
     $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);
     $sFileName = str_replace(' ', '', $sFileName);
     if ($met_img_rename) {
         $sFileName = date("Ymd") . "_" . date("His") . "." . $sExtension;
     }
     if ($sFileName != $sUnsafeFileName) {
         $iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
     }
     $oRegistry->set("FileUpload_fileName", $sFileName);
     $this->checkConnector();
     $this->checkRequest();
     if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
     }
     $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
     if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sFileName) || $_resourceTypeConfig->checkIsHiddenFile($sFileName)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
     }
     $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
     if (!$resourceTypeInfo->checkExtension($sFileName)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
     }
     $sFileNameOrginal = $sFileName;
     $oRegistry->set("FileUpload_fileName", $sFileName);
     $oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
     $maxSize = $resourceTypeInfo->getMaxSize();
     if (!$_config->checkSizeAfterScaling() && $maxSize && $uploadedFile['size'] > $maxSize) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
     }
     if ($uploadedFile['size'] > $met_file_maxsize * 1024 * 1024) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG_MET);
     }
     $htmlExtensions = $_config->getHtmlExtensions();
     $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
     if ($htmlExtensions && !CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive($sExtension, $htmlExtensions) && ($detectHtml = CKFinder_Connector_Utils_FileSystem::detectHtml($uploadedFile['tmp_name'])) === true) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
     }
     $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
     $secureImageUploads = $_config->getSecureImageUploads();
     if ($secureImageUploads && ($isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($uploadedFile['tmp_name'], $sExtension)) === false) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
     }
     switch ($uploadedFile['error']) {
         case UPLOAD_ERR_OK:
             break;
         case UPLOAD_ERR_INI_SIZE:
         case UPLOAD_ERR_FORM_SIZE:
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
             break;
         case UPLOAD_ERR_PARTIAL:
         case UPLOAD_ERR_NO_FILE:
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
             break;
         case UPLOAD_ERR_NO_TMP_DIR:
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR);
             break;
         case UPLOAD_ERR_CANT_WRITE:
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
             break;
         case UPLOAD_ERR_EXTENSION:
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
             break;
     }
     $sServerDir = $this->_currentFolder->getServerPath();
     $iCounter = 0;
     while (true) {
         $sFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($sServerDir, $sFileName);
         if (file_exists($sFilePath)) {
             $iCounter++;
             $sFileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($sFileNameOrginal) . "(" . $iCounter . ")" . "." . CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
             $oRegistry->set("FileUpload_fileName", $sFileName);
             $iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_FILE_RENAMED;
         } else {
             //move_uploaded_file($uploadedFile['tmp_name'], $sFilePath)
             if (false === copy($uploadedFile['tmp_name'], $sFilePath)) {
                 $iErrorNumber = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
             } else {
                 if (isset($detectHtml) && $detectHtml === -1 && CKFinder_Connector_Utils_FileSystem::detectHtml($sFilePath) === true) {
                     @unlink($sFilePath);
                     $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
                 } else {
                     if (isset($isImageValid) && $isImageValid === -1 && CKFinder_Connector_Utils_FileSystem::isImageValid($sFilePath, $sExtension) === false) {
                         @unlink($sFilePath);
                         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
                     }
                 }
             }
             if (is_file($sFilePath) && ($perms = $_config->getChmodFiles())) {
                 $oldumask = umask(0);
                 chmod($sFilePath, $perms);
                 umask($oldumask);
             }
             break;
         }
     }
     $sFileName_water = $sFileName;
     if (stristr(PHP_OS, "WIN")) {
         $sFileName_water = iconv("GBK", "utf-8", $sFileName);
     }
     if ($met_big_wate == 1) {
         require_once CKFINDER_CONNECTOR_CONFIG_watermark_PATHX;
         $img = new Watermark();
         if ($met_wate_class == 2) {
             $img->met_image_name = CKFINDER_CONNECTOR_CONFIG_img_PATHX . $met_wate_bigimg;
             $img->met_image_pos = $met_watermark;
         } else {
             $img->met_text = $met_text_wate;
             $img->met_text_size = $met_text_bigsize;
             $img->met_text_color = $met_text_color;
             $img->met_text_angle = $met_text_angle;
             $img->met_text_pos = $met_watermark;
             $img->met_text_font = CKFINDER_CONNECTOR_CONFIG_fonts_PATHX . $met_text_fonts;
         }
         if (!file_exists(CKFINDER_CONNECTOR_CONFIG_upload_PATHX . "/images/watermark/")) {
             mkdir(CKFINDER_CONNECTOR_CONFIG_upload_PATHX . "/images/watermark/");
         }
         $img->src_image_name = CKFINDER_CONNECTOR_CONFIG_upload_PATHX . "/images/{$sFileName_water}";
         $img->save_file = CKFINDER_CONNECTOR_CONFIG_upload_PATHX . "/images/watermark/{$sFileName_water}";
         $img->create();
     }
     if (!$_config->checkSizeAfterScaling()) {
         $this->_errorHandler->throwError($iErrorNumber, true, false);
     }
     //resize image if required
     require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/Thumbnail.php";
     $_imagesConfig = $_config->getImagesConfig();
     /*图片如果超过设定最大值,则把图片缩小
             if ($_imagesConfig->getMaxWidth()>0 && $_imagesConfig->getMaxHeight()>0 && $_imagesConfig->getQuality()>0) {
                 CKFinder_Connector_CommandHandler_Thumbnail::createThumb($sFilePath, $sFilePath, $_imagesConfig->getMaxWidth(), $_imagesConfig->getMaxHeight(), $_imagesConfig->getQuality(), true) ;
             }
     		*/
     if ($met_big_wate == 1) {
         $oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl() . 'watermark/');
     }
     if ($_config->checkSizeAfterScaling()) {
         //check file size after scaling, attempt to delete if too big
         clearstatcache();
         if ($maxSize && filesize($sFilePath) > $maxSize) {
             @unlink($sFilePath);
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
         } else {
             $this->_errorHandler->throwError($iErrorNumber, true, false);
         }
     }
     CKFinder_Connector_Core_Hooks::run('AfterFileUpload', array(&$this->_currentFolder, &$uploadedFile, &$sFilePath));
 }
コード例 #5
0
ファイル: upload.php プロジェクト: Vatia13/megaportal
         						if ($image_max_height == 0) $srcHeight = $image_max_width*$srcHeight/$srcWidth;
         					}
         
         					if ($image_max_height != 0 && $srcHeight > $image_max_height && $image_resizing_override === FALSE){
         						$resize = TRUE;
         						$srcHeight = $image_max_height;
         
         						if ($image_max_width == 0) $srcWidth = $image_max_height*$srcWidth/$srcHeight;
         					}
         
         					if ($resize) create_img($targetFile, $targetFile, $srcWidth, $srcHeight, $image_max_mode);
         				}
         			} */
         // watermark_image($targetFile,'new_image');
         if (isset($_GET['wm']) == true) {
             $wMark->create($targetFile, $config['wm']);
             $wMark->font = $config['wm_font_url'];
             $wMark->font_size = 15;
             $wMark->save();
         }
         // not enough memory
         if ($memory_error) {
             unlink($targetFile);
             header('HTTP/1.1 406 Not enought Memory', TRUE, 406);
             exit;
         }
     }
     echo $_FILES['file']['name'];
 } else {
     header('HTTP/1.1 406 file not permitted', TRUE, 406);
     exit;