当前位置: 首页>>代码示例>>PHP>>正文


PHP isImage函数代码示例

本文整理汇总了PHP中isImage函数的典型用法代码示例。如果您正苦于以下问题:PHP isImage函数的具体用法?PHP isImage怎么用?PHP isImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了isImage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveFile

 /**
  * 保存一些文件的信息到数据库中
  *
  * @access private
  */
 private function saveFile($files, $file)
 {
     $fileExt = $file->getClientOriginalExtension();
     $isImage = isImage($fileExt) ? Attachment::IS_IMAGE_YES : Attachment::IS_IMAGE_NO;
     $datas = $this->generDatas($files, $file, $fileExt, $isImage);
     with(new Attachment())->addFile($datas);
 }
开发者ID:pfdtk,项目名称:bmsys,代码行数:12,代码来源:UploadController.php

示例2: getIcon

function getIcon($link)
{
    if (isImage($link)) {
        return "style='background-image:url({$link}); background-color:black;'";
    } else {
        return "style='background-image:url(design/images/unknown_ico.png);'";
    }
}
开发者ID:Borisas,项目名称:home-web-server,代码行数:8,代码来源:index.php

示例3: loadFile

function loadFile($targetpath)
{
    $newName = $targetpath . DIRECTORY_SEPARATOR . basename($_FILES['image']['name']);
    switch (true) {
        case !is_uploaded_file($_FILES['image']['tmp_name']):
            switch ($_FILES['image']['error']) {
                case 1:
                    $_SESSION['error'] = 'UPLOAD_ERR_INI_SIZE';
                    break;
                case 2:
                    $_SESSION['error'] = 'UPLOAD_ERR_FORM_SIZE';
                    break;
                case 3:
                    $_SESSION['error'] = 'UPLOAD_ERR_PARTIAL';
                    break;
                case 4:
                    $_SESSION['error'] = 'UPLOAD_ERR_NO_FILE';
                    break;
                case 6:
                    $_SESSION['error'] = 'UPLOAD_ERR_NO_TMP_DIR';
                    break;
                case 7:
                    $_SESSION['error'] = 'UPLOAD_ERR_CANT_WRITE';
                    break;
                case 8:
                    $_SESSION['error'] = 'UPLOAD_ERR_EXTENSION';
                    break;
            }
            break;
        case file_exists($newName):
            $_SESSION['error'] = 'FILE_EXISTS';
            break;
        case !isImage($_FILES['image']['name']):
            $_SESSION['error'] = 'NOT_AN_IMAGE';
            break;
        case !isReadable($_FILES['image']['tmp_name']) || '' == getimagesize($_FILES['image']['tmp_name'])[3]:
            $_SESSION['error'] = 'NOT_FOR_READ';
            break;
        case move_uploaded_file($_FILES['image']['tmp_name'], $newName):
            $_SESSION['name'] = basename($_FILES['image']['name']);
            $_SESSION['date'] = date("d.m.y H:i:s", filectime($newName));
            $_SESSION['path'] = $newName;
            $_SESSION['size_px'] = getimagesize($newName)[3];
            $_SESSION['size_mb'] = filesize($newName);
            header('Location: index.php');
        default:
            $_SESSION['error'] = 'UNKNOWN_ERROR';
            break;
    }
}
开发者ID:tanyushechka,项目名称:php1galery,代码行数:50,代码来源:functions.php

示例4: getImages

/**
 * Get all images in specified folder.
 * @param string $folder  path to directory to read
 * @return array          array containing image data
 */
function getImages($folder)
{
    $images = array();
    if ($handle = opendir($folder)) {
        while (false !== ($file = readdir($handle))) {
            $path = $folder . $file;
            if (!is_dir($path) && isImage($file)) {
                list($width, $height) = getimagesize($path);
                $images[$file] = array('is_dir' => false, 'name' => $file, 'short' => strlen($file) > 30 ? substr($file, 0, 20) . '...' . substr($file, -10) : $file, 'link' => $path, 'thumb' => $file, 'width' => $width, 'height' => $height, 'size' => getSize($path));
            }
        }
        closedir($handle);
    }
    ksort($images);
    return $images;
}
开发者ID:benct,项目名称:web-gallery,代码行数:21,代码来源:func.php

示例5: getImageFiles

/**
 * Возвращает массив файлов изображений из папки
 */
function getImageFiles($dir = '.', $exclude)
{
    $files = array();
    $a = scandir($dir);
    foreach ($a as $k => $v) {
        if ($v == '.' || $v == '..') {
            continue;
        }
        if (is_dir(HFile::addSlashPath($dir) . $v)) {
            $files = array_merge($files, getImageFiles(HFile::addSlashPath($dir) . $v, $exclude));
        } else {
            if (isImage(HFile::getExtension($v))) {
                $files[] = str_replace($exclude, '', HFile::addSlashPath($dir) . $v);
            }
        }
    }
    return $files;
}
开发者ID:Cranky4,项目名称:npfs,代码行数:21,代码来源:clearPreview.php

示例6: util_fetchUrl

 if (file_exists($fileName)) {
     $haveFile = true;
 } else {
     $haveFile = false;
     $img = util_fetchUrl($book->imageUrl);
     if ($img !== false) {
         // Dump the image to a file
         $file = fopen($fileName, "w");
         fwrite($file, $img);
         fclose($file);
         $haveFile = true;
     }
 }
 $alreadyResized = file_exists($thumbName);
 if ($haveFile && !$alreadyResized) {
     $imgType = isImage($fileName);
     if ($imgType == IMG_NORMAL) {
         list($width, $height, $bytes) = preg_split('/\\|/', getImageInfo($fileName));
         print "  {$width}x{$height}, {$bytes} bytes ";
         OS::executeAndAssert("convert -trim -fuzz \"3%\" -geometry 200x84 \"{$fileName}\" \"{$thumbName}\"");
         if ($width <= 90 && $height <= 90) {
             print "*small* ";
         }
         list($thumbWidth, $thumbHeight, $ignored) = preg_split('/\\|/', getImageInfo($thumbName));
         $book->thumbWidth = $thumbWidth;
         $book->thumbHeight = $thumbHeight;
         $book->save();
     } else {
         if ($imgType == IMG_NOT_JPEG) {
             print "  Not an image ";
         } else {
开发者ID:nastasie-octavian,项目名称:DEXonline,代码行数:31,代码来源:importDivertaCsv.php

示例7: isImage

function isImage($tempFile)
{
    // Get the size of the image
    $size = getimagesize($tempFile);
    if (isset($size) && $size[0] && $size[1] && $size[0] * $size[1] > 0) {
        return true;
    } else {
        return false;
    }
}
if (!empty($_FILES)) {
    $fileData = $_FILES['Filedata'];
    if ($fileData) {
        $tempFile = $fileData['tmp_name'];
        $uploadDir = $_SERVER['DOCUMENT_ROOT'] . $uploadDir;
        $targetFile = $uploadDir . $fileData['name'];
        // Validate the file type
        $fileTypes = array('jpg', 'jpeg', 'gif', 'png');
        // Allowed file extensions
        $fileParts = pathinfo($fileData['name']);
        // Validate the filetype
        if (in_array(strtolower($fileParts['extension']), $fileTypes) && filesize($tempFile) > 0 && isImage($tempFile)) {
            // Save the file
            move_uploaded_file($tempFile, $targetFile);
            echo 1;
        } else {
            // The file type wasn't allowed
            echo 'Invalid file type.';
        }
    }
}
开发者ID:yaosir1993,项目名称:eipk_kjjr,代码行数:31,代码来源:uploadifive-image-only.php

示例8: _getLevelsCreateForm

function _getLevelsCreateForm($iLevelId, $bActive = false)
{
    $sSubmitUrl = BX_DOL_URL_ADMIN . 'memb_levels.php';
    $aLevel = array();
    if (($bEdit = $iLevelId != 0) === true) {
        $aLevel = $GLOBALS['MySQL']->getRow("SELECT `Name` AS `Name`, `Description` AS `Description`, `Order` AS `Order` FROM `sys_acl_levels` WHERE `ID`='" . $iLevelId . "' LIMIT 1");
    }
    $aForm = array('form_attrs' => array('id' => 'adm-mlevels-create', 'action' => $sSubmitUrl . '?tab=levels_add', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => 'sys_acl_levels', 'key' => 'ID', 'uri' => '', 'uri_title' => '', 'submit_name' => 'Submit')), 'inputs' => array('Active' => array('type' => 'hidden', 'name' => 'Active', 'value' => 'no', 'db' => array('pass' => 'Xss')), 'Purchasable' => array('type' => 'hidden', 'name' => 'Purchasable', 'value' => 'yes', 'db' => array('pass' => 'Xss')), 'Removable' => array('type' => 'hidden', 'name' => 'Removable', 'value' => 'yes', 'db' => array('pass' => 'Xss')), 'Name' => array('type' => 'text', 'name' => 'Name', 'caption' => _t('_adm_txt_mlevels_name'), 'value' => isset($aLevel['Name']) ? $aLevel['Name'] : '', 'required' => true, 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'length', 'params' => array(3, 100), 'error' => _t('_adm_txt_mlevels_name_err'))), 'Icon' => array('type' => 'file', 'name' => 'Icon', 'caption' => _t('_adm_txt_mlevels_icon'), 'required' => true, 'checker' => array('func' => '', 'params' => '', 'error' => _t('_adm_txt_mlevels_icon_err'))), 'Description' => array('type' => 'textarea', 'name' => 'Description', 'caption' => _t('_adm_txt_mlevels_description'), 'value' => isset($aLevel['Description']) ? $aLevel['Description'] : '', 'db' => array('pass' => 'XssHtml')), 'Order' => array('type' => 'text', 'name' => 'Order', 'caption' => _t('_adm_txt_mlevels_order'), 'value' => isset($aLevel['Order']) ? $aLevel['Order'] : 0, 'required' => true, 'db' => array('pass' => 'Int'), 'checker' => array('func' => 'preg', 'params' => array('/^[1-9][0-9]*$/'), 'error' => _t('_adm_txt_mlevels_order_err'))), 'Submit' => array('type' => 'submit', 'name' => 'Submit', 'value' => _t('_adm_btn_mlevels_add'))));
    //--- Convert Add to Edit
    if ($bEdit) {
        unset($aForm['inputs']['Active']);
        unset($aForm['inputs']['Purchasable']);
        unset($aForm['inputs']['Removable']);
        unset($aForm['inputs']['Icon']);
        $aForm['form_attrs']['action'] = $sSubmitUrl . '?action=edit&level=' . $iLevelId;
        $aForm['inputs']['Submit']['value'] = _t('_adm_btn_mlevels_save');
        $aForm['inputs']['ID'] = array('type' => 'hidden', 'name' => 'ID', 'value' => $iLevelId, 'db' => array('pass' => 'Int'));
    }
    $oForm = new BxTemplFormView($aForm);
    $oForm->initChecker();
    if ($oForm->isSubmittedAndValid()) {
        //--- Add new level
        if (!$bEdit) {
            $sFilePath = BX_DIRECTORY_PATH_ROOT . 'media/images/membership/';
            $sFileName = time();
            $sFileExt = '';
            if ($GLOBALS['MySQL']->getOne("SELECT `Name` FROM `sys_acl_levels` WHERE `Name`='" . $oForm->getCleanValue('Name') . "' LIMIT 1")) {
                $oForm->aInputs['Name']['error'] = _t('_adm_txt_mlevels_name_err_non_uniq');
            } elseif (isImage($_FILES['Icon']['type'], $sFileExt) && !empty($_FILES['Icon']['tmp_name']) && move_uploaded_file($_FILES['Icon']['tmp_name'], $sFilePath . $sFileName . '.' . $sFileExt)) {
                $sPath = $sFilePath . $sFileName . '.' . $sFileExt;
                imageResize($sPath, $sPath, 110, 110);
                $iId = (int) $oForm->insert(array('Icon' => $sFileName . '.' . $sFileExt));
                if ($iId != 0) {
                    $sName = $oForm->getCleanValue('Name');
                    addStringToLanguage('_adm_txt_mp_' . strtolower($sName), $sName);
                }
                header('Location: ' . $sSubmitUrl);
                exit;
            } else {
                $oForm->aInputs['Icon']['error'] = $oForm->aInputs['Icon']['checker']['error'];
            }
        } else {
            $bResult = $oForm->update($iLevelId);
            if ($bResult !== false) {
                deleteStringFromLanguage('_adm_txt_mp_' . strtolower($aLevel['Name']));
                $sName = $oForm->getCleanValue('Name');
                addStringToLanguage('_adm_txt_mp_' . strtolower($sName), $sName);
            }
            header('Location: ' . $sSubmitUrl);
            exit;
        }
    }
    return $GLOBALS['oAdmTemplate']->parseHtmlByName('mlevels_create.html', array('display' => $bActive ? 'block' : 'none', 'form' => $oForm->getCode()));
}
开发者ID:newton27,项目名称:dolphin.pro,代码行数:54,代码来源:memb_levels.php

示例9: run

 /**
  * Execute action when called for explicitly by the user
  * @return void
  */
 function run()
 {
     global $USER, $CONFIG, $Templates, $Controller;
     /**
      * User input types
      */
     $_REQUEST->setType('w', 'numeric');
     $_REQUEST->setType('h', 'numeric');
     $_REQUEST->setType('mw', 'numeric');
     $_REQUEST->setType('mh', 'numeric');
     $_REQUEST->setType('ok', 'string');
     $_REQUEST->setType('to', 'numeric');
     $_REQUEST->setType('fcontent', 'any');
     $_REQUEST->setType('action', 'string');
     $_REQUEST->setType('imgrot', 'numeric');
     $_REQUEST->setType('rot', 'numeric');
     if (@filesize($this->path)) {
         if ($this->may($USER, READ)) {
             switch ($_REQUEST['action']) {
                 case 'edit':
                     if ($this->may($USER, EDIT)) {
                         if (in_array($this->extension, $CONFIG->extensions->plaintext)) {
                             /**
                              * Save changes
                              */
                             if ($_REQUEST['editFile']) {
                                 file_put_contents($p, mb_detect_encoding(file_get_contents($p)) == "UTF-8" ? utf8($_REQUEST['fcontent']) : deutf8($_REQUEST['fcontent']));
                                 if ($_REQUEST['mkcopy']) {
                                     redirect(array('id' => $copy->ID, 'action' => 'edit', 'ok' => 'true'));
                                 }
                             }
                             /**
                              * Display page for editing plain text documents
                              */
                             $tmp = new TextArea(__('File contents'), 'fcontent', utf8(file_get_contents($this->path)));
                             $tmp->class = 'large';
                             $formfields[] = $tmp;
                             unset($tmp);
                         }
                         $formfields[] = new Checkbox(__('Save as copy'), 'mkcopy', $_REQUEST['mkcopy']);
                         $nav = '<div class="nav"><a href="' . url(array('id' => $this->DirID)) . '">' . icon('small/arrow_left') . __('Back') . '</a></div>';
                         $this->content = array('header' => __('Editing file') . ': ' . $this->basename, 'main' => $nav . $form->collection(new Set($formfields)));
                         $t = 'admin';
                         if ($_REQUEST['popup']) {
                             $t = 'popup';
                         }
                         $Templates->{$t}->render();
                     } else {
                         errorPage(401);
                     }
                     break;
                 case 'download':
                 default:
                     if (strpos($this->path, $this->rootDir()) === 0) {
                         $p = $this->path;
                         $n = $this->basename;
                         if (isImage($this->path) && ($_REQUEST['w'] || $_REQUEST['h'] || $_REQUEST['mw'] || $_REQUEST['mh'] || isset($_REQUEST['tr']) || isset($_REQUEST['tg']) || isset($_REQUEST['tb']) || isset($_REQUEST['rot'])) && function_exists("gd_info")) {
                             $s = getimagesize($this->path);
                             // s(1) / s(0) = h / w
                             if ($_REQUEST['mw'] && $s[0] > $_REQUEST['mw']) {
                                 $_REQUEST['h'] = round($s[1] * $_REQUEST['mw'] / $s[0]);
                                 $_REQUEST['w'] = round($_REQUEST['mw']);
                             }
                             if ($_REQUEST['mh'] && $s[1] > $_REQUEST['mh']) {
                                 $_REQUEST['w'] = round($s[0] * $_REQUEST['mh'] / $s[1]);
                                 $_REQUEST['h'] = round($_REQUEST['mh']);
                             }
                             $p = $this->getConvertedImage($_REQUEST['w'], $_REQUEST['h'], $_REQUEST['rot'], $_REQUEST['tr'], $_REQUEST['tg'], $_REQUEST['tb'], false);
                             $n = pathinfo($p, PATHINFO_BASENAME);
                         }
                         $this->stream($p);
                     }
             }
         } else {
             while (ob_get_level()) {
                 @ob_end_clean();
             }
             die;
         }
     }
 }
开发者ID:jonatanolofsson,项目名称:solidba.se,代码行数:85,代码来源:File.php

示例10: links_editLink

 case 'ajax_saveLink':
     $returnText .= $action($selector, $link_id1, $link_id2, $link_label, $what);
     break;
 case 'ajax_loadImage':
     $returnText .= $action($collection_id, $package_id);
     break;
 case 'links_editLink':
     $returnText .= links_editLink($collection_id, $package_id, $link_coll, $link_type, $link_pack, $link_part, $link_id, $loc4msg, $what);
     break;
 case 'get_file':
     $icon = DCTL_APPS_PATH . 'img' . SYS_PATH_SEP . 'missing.gif';
     $fPath = DCTL_PROJECT_PATH . $collection_id . SYS_PATH_SEP . $url;
     if (is_file($fPath)) {
         $mime = getMIME($fPath);
         $ext = strtolower(substr($fPath, -3, 3));
         if (isImage($mime, $ext)) {
             $icon = $fPath;
         }
     }
     $iconMime = image2MIME($icon);
     if ($iconMime == false) {
         $iconMime = "image/jpeg";
     }
     header("Content-type: {$iconMime}", true);
     readfile($icon);
     break;
 case 'load_preview':
     $fPath = preg_replace('%' . HOST_BASE_PATH . '%', FS_BASE_PATH, $url, 1);
     if (is_file($fPath)) {
         $big = $fPath;
         $med = str_ireplace(DCTL_MEDIA_BIG, DCTL_MEDIA_MED, $fPath);
开发者ID:noveopiu,项目名称:dCTL,代码行数:31,代码来源:indexAjax.php

示例11: cutImage

 /**
  * 开始处理裁剪
  *
  * @param  string $realFile 所要处理的图片的位置
  * @param  string $savePath 所要保存的位置
  * @return string           处理后的图片
  */
 private function cutImage($realFile, $savePath)
 {
     if (!isImage(strtolower($this->file->getClientOriginalExtension()))) {
         return [];
     }
     $imagine = new \Imagine\Gd\Imagine();
     $mode = \Imagine\Image\ImageInterface::THUMBNAIL_INSET;
     $result = [];
     foreach ($this->params['thumbSetting'] as $key => $value) {
         if (isset($value['width'], $value['height']) and is_numeric($value['width']) and is_numeric($value['height'])) {
             $size = new \Imagine\Image\Box($value['width'], $value['height']);
             $saveName = $this->getCutImageSaveName($savePath, $value['width'], $value['height']);
             $imagine->open($realFile)->thumbnail($size, $mode)->save($saveName);
             $result[] = substr(str_replace($this->getConfigSavePath(), '', $saveName), 1);
         }
     }
     return $result;
 }
开发者ID:pfdtk,项目名称:bmsys,代码行数:25,代码来源:Process.php

示例12: run

 public function run()
 {
     $action = I('get.action');
     $result = array();
     switch ($action) {
         case 'config':
             $result = $this->confing;
             break;
             //上传涂鸦
         //上传涂鸦
         case 'uploadscrawl':
             $catid = I('get.catid');
             $module = I('get.module', $catid ? 'content' : MODULE_NAME, 'trim');
             $base64Data = $_POST[$this->confing['scrawlFieldName']];
             if (empty($base64Data)) {
                 exit(json_encode(array('state' => '没有涂鸦内容!')));
             }
             $img = base64_decode($base64Data);
             $oriName = 'scrawl.png';
             $fileType = 'png';
             $fileSize = strlen($img);
             //上传目录
             $savePath = D('Attachment/Attachment')->getFilePath($module, 'Y/m', time());
             $up = new \UploadFile();
             //保存文件名
             $fileName = $up->getSaveName(array('name' => $oriName, 'extension' => 'png'));
             //保存地址
             $filePath = $savePath . $fileName;
             //保存后的访问地址
             $url = self::$Cache['Config']['sitefileurl'] . str_replace(array(C('UPLOADFILEPATH'), '//', '\\'), array('', '/', '\\/'), $filePath);
             //写入临时文件
             if (file_put_contents($filePath, $img)) {
                 $result = array('state' => 'SUCCESS', 'url' => $url, 'title' => $oriName, 'original' => $oriName);
             } else {
                 exit(json_encode(array('state' => '保存失败!')));
             }
             break;
             //上传图片
         //上传图片
         case 'uploadimage':
             $catid = I('get.catid');
             $module = I('get.module', $catid ? 'content' : MODULE_NAME, 'trim');
             $Attachment = service('Attachment', array('module' => $module, 'catid' => $catid, 'userid' => $this->uid, 'isadmin' => $this->isadmin));
             //设置上传类型,强制为图片类型
             $Attachment->uploadallowext = array("jpg", "png", "gif", "jpeg");
             if ($this->isadmin < 1) {
                 //如果是非后台用户,进行权限判断
                 $member_group = cache('Member_group');
                 if ((int) $member_group[$this->groupid]['allowattachment'] < 1) {
                     exit(json_encode(array('state' => '没有上传权限!')));
                 }
             }
             //开始上传
             $info = $Attachment->upload();
             if ($info) {
                 // 设置附件cookie
                 $Attachment->upload_json($info[0]['aid'], $info[0]['url'], str_replace(array("\\", "/"), "", $info[0]['name']));
                 $result = array('state' => 'SUCCESS', 'url' => $info[0]['url'], 'title' => str_replace(array("\\", "/"), "", $pictitle ? $pictitle : $info[0]['name']), 'original' => $info[0]['name']);
             } else {
                 $result = array('state' => $Attachment->getError() ?: '上传失败');
             }
             break;
             //图片在线管理
         //图片在线管理
         case 'listfile':
         case 'listimage':
             $listArr = $this->att_not_used();
             $list = array();
             foreach ($listArr as $rs) {
                 if (!isImage($rs['src']) && $action != 'listfile') {
                     continue;
                 }
                 $list[] = array('url' => $rs['src'], 'mtime' => time());
             }
             $result = array('state' => 'SUCCESS', 'list' => $list, 'total' => count($listArr));
             break;
             //上传视频
         //上传视频
         case 'uploadvideo':
             //上传附件
         //上传附件
         case 'uploadfile':
             $catid = I('get.catid');
             $module = I('get.module', $catid ? 'content' : MODULE_NAME, 'trim');
             $Attachment = service('Attachment', array('module' => $module, 'catid' => $catid, 'userid' => $this->uid, 'isadmin' => $this->isadmin));
             //设置上传类型
             if ($this->isadmin) {
                 $Attachment->uploadallowext = explode('|', self::$Cache['Config']['uploadallowext']);
             } else {
                 $Attachment->uploadallowext = explode('|', self::$Cache['Config']['qtuploadallowext']);
             }
             //回调函数
             $Callback = false;
             if ($this->isadmin < 1) {
                 //如果是非后台用户,进行权限判断
                 $member_group = cache('Member_group');
                 if ((int) $member_group[$this->groupid]['allowattachment'] < 1) {
                     exit(json_encode(array('state' => '没有上传权限!')));
                 }
             }
//.........这里部分代码省略.........
开发者ID:sandom123,项目名称:king400,代码行数:101,代码来源:UeditorController.class.php

示例13: cutImage

 /**
  * 开始处理裁剪
  *
  * @param  string $realFile 所要处理的图片的位置
  * @param  string $savePath 所要保存的位置
  * @return string           处理后的图片
  */
 private function cutImage($realFile, $savePath)
 {
     if (!isImage($this->file->getClientOriginalExtension())) {
         throw new \Exception("Image thumb must be images.");
     }
     $imagine = new \Imagine\Gd\Imagine();
     $mode = \Imagine\Image\ImageInterface::THUMBNAIL_INSET;
     $result = [];
     foreach ($this->params['thumbSetting'] as $key => $value) {
         if (isset($value['width'], $value['height']) and is_numeric($value['width']) and is_numeric($value['height'])) {
             $size = new \Imagine\Image\Box($value['width'], $value['height']);
             $saveName = $savePath . $this->getSaveFileName() . '_' . $value['width'] . '_' . $value['height'] . '_thumb.' . $this->file->getClientOriginalExtension();
             $imagine->open($realFile)->thumbnail($size, $mode)->save($saveName);
             $result[] = str_replace('/', '', str_replace($this->getConfigSavePath(), '', $saveName));
         }
     }
     return $result;
 }
开发者ID:mikegit2014,项目名称:laravelback,代码行数:25,代码来源:Process.php

示例14: validation

 function validation($addmemberclass, $editid)
 {
     global $db;
     $error = array();
     $postvar = $addmemberclass->getPostVar();
     $user_id = $_SESSION['USER_ID'];
     $title = trim($postvar['title']);
     $file = $_FILES['file']['name'];
     $from_to = trim($postvar['from_to']);
     $image_type = $_FILES['file']['type'];
     $start_time = trim($postvar['start_time']);
     $end_time = trim($postvar['end_time']);
     $venue = trim($postvar['venue']);
     $description = trim($postvar['description']);
     $link = trim($postvar['link']);
     $status = trim($postvar['status']);
     $image_alignment = trim($postvar['image_alignment']);
     $current_date = date('m-d-Y');
     $exps = explode("-", $from_to);
     $fromdate = $exps[0];
     $todate = $exps[1];
     $error = array();
     if ($title == '') {
         $error[1] = "Please Enter Title ";
     } else {
         if (strlen($title) < 3) {
             $error[1] = "Please Enter at least 3 characters";
         }
     }
     if ($file != '') {
         if (isImage($image_type)) {
             $error[2] = isImage($image_type);
         }
     }
     /*if($image_alignment	==	'')
     		{
     			$error[3] 	=	"Please Select Image Alignment."; 
     		}	*/
     if ($start_time == '') {
         $error[4] = "Please Enter Meeting Start Time";
     }
     if ($end_time == '') {
         $error[5] = "Please Enter Meeting End Time";
     }
     if ($venue == '') {
         $error[6] = "Please Enter Meeting Venue.";
     }
     if ($description == '') {
         $error[7] = "Please Enter Meeting Description";
     }
     if ($link != '') {
         if (isUrl($link) == 0) {
             $error[8] = "Please Enter Valid Link URL";
         }
     }
     if ($status == '') {
         $error[9] = "Please Select Status.";
     }
     if ($from_to == '') {
         $error[10] = "Please Enter Start AND End Date.";
     }
     /*elseif($from_to!="")
     		{	echo $fromdate;
     			echo "==".$current_date;
     			if(strtotime($fromdate) < strtotime($current_date))
     			{
     				$error[10]	=	"Please Enter Start Date Is Wrong.";
     			}
     		}*/
     return $error;
 }
开发者ID:Entellus,项目名称:System,代码行数:71,代码来源:add_meeting_manager.php

示例15: edit_account

 public function edit_account()
 {
     if (null != $this->input->post('edit_account_btn')) {
         $data_post = $this->input->post();
         $this->load->helper('Validation');
         $this->load->helper('HTMLPurifier');
         $config = HTMLPurifier_Config::createDefault();
         $purifier = new HTMLPurifier($config);
         //====================== Validate  ======================
         $error = array();
         if (empty($_POST["username"])) {
             $error[] = "Username không được rỗng";
         } else {
             if ((preg_match('/^[A-Za-z0-9_\\.]{4,30}$/', $_POST["username"], $maches) || preg_match('/^[A-Za-z0-9_\\.]{4,30}$/', $_POST["username"], $maches)) && (strlen($_POST["username"]) >= 4 && strlen($_POST["username"]) <= 30)) {
                 $username = $_POST["username"];
                 $username = trim_input(trim($_POST["username"]));
                 $username_exist = $this->Account->check_username_exist($username, $data_post['id']);
                 if ($username_exist) {
                     $error[] = "Username đã tồn tại";
                 }
             } else {
                 $error[] = "Username gồm kí tự a-Z và có độ dài 4 - 30";
             }
         }
         $regex = "/^[a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-zA-Z]+\$/";
         if (empty($_POST["email"])) {
             $error[] = "Email không được rỗng!";
         } elseif (preg_match($regex, $_POST["email"], $maches)) {
             $insert_data['email'] = $_POST["email"];
         } else {
             $error[] = "Email không hợp lệ!";
         }
         if ($_POST['password'] != '' && strlen($_POST['password']) < 4) {
             $error[] = "Password phải nhiều hơn hoặc bằng 4 kí tự!";
         }
         if ($data_post['password'] != '') {
             if (strlen($_POST['password']) < 4 || strlen($_POST['password']) > 32) {
                 $error[] = "Password từ 4 đến 32 kí tự!";
             } else {
                 $data_update['password'] = md5($data_post['password']);
             }
         }
         if (!empty($_FILES['avatar']['name'])) {
             $avatar_name = $_FILES['avatar']['name'];
             $tmp = new SplFileInfo($avatar_name);
             $avatar_type = $tmp->getExtension();
             if (strtolower($avatar_type) != 'jpg' && strtolower($avatar_type) != 'gif' && strtolower($avatar_type) != 'png') {
                 $error[] = "Định dạng ảnh đại diện sản phẩm không cho phép!";
             } elseif (!isImage($_FILES['avatar']['tmp_name'])) {
                 $error[] = "Ảnh đại diện sản phẩm không phải là file ảnh!";
             } elseif ($_FILES['avatar']['size'] > 2048000) {
                 $error[] = "Ảnh đại diện sản phẩm phải nhỏ hơn 2MB";
             } else {
                 $tmp_name_avatar = $_FILES['avatar']['tmp_name'];
                 $data_update['avatar'] = md5($_POST["username"]) . '-' . time() . '.' . $avatar_type;
             }
         }
         //====================== Validate  ======================
         if (count($error) > 0) {
             $redata['re_id'] = $_POST['id'];
             $redata['re_username'] = $_POST['username'];
             $redata['re_email'] = $_POST['email'];
             $redata['avatar'] = $this->Account->get_avatar_by_id($_POST['id']);
             $alert_time = 20000;
             set_notice('status', FAILED_STATUS, $error, $alert_time);
             $data['subData'] = $redata;
             $data['title'] = "Cập nhật tài khoản";
             $data['subView'] = '/account/edit_account_layout';
             $this->load->view('/main/main_layout', $data);
         } else {
             $id = $data_post['id'];
             $data_update['username'] = $purifier->purify($data_post['username']);
             $data_update['email'] = $data_post['email'];
             $old_avatar = $this->Account->get_avatar_by_id($id);
             $rs = $this->Account->update($id, $data_update);
             if (rs) {
                 // ============= Upload anh avatar ===================
                 if ($rs && isset($_FILES['avatar'])) {
                     $path = "public/img/avatar/";
                     if (move_uploaded_file($tmp_name_avatar, $path . $data_update['avatar'])) {
                         resizeImage($path . $data_update['avatar'], $path . $data_update['avatar'], 600, 600);
                         @unlink($path . $old_avatar);
                     }
                 }
                 // ============= Upload anh avatar ===================
                 $this->load->model('Login_model', 'Login');
                 $user = $this->Login->getInfo($username);
                 $_SESSION['user'] = $user;
                 $content = 'Cập nhật tài khoản thành công.';
                 set_notice('status', SUCCESS_STATUS, $content);
                 header('location:' . base_url() . 'index.php/_admin/order/show_order');
             } else {
                 $content = 'Cập nhật tài khoản thất bại.';
                 set_notice('status', FAILED_STATUS, $content);
                 header('location:' . base_url() . 'index.php/_admin/order/show_order');
             }
         }
     } else {
         if (null !== $this->uri->segment(4) && is_numeric($this->uri->segment(4)) && $this->Account->has_account_exist_by_id($this->uri->segment(4))) {
             $account_id = $this->uri->segment(4);
//.........这里部分代码省略.........
开发者ID:tuanvu5503,项目名称:thungrac.vn,代码行数:101,代码来源:Account.php


注:本文中的isImage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。