Пример #1
0
 /**
  * 保存一些文件的信息到数据库中
  *
  * @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);
 }
Пример #2
0
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);'";
    }
}
Пример #3
0
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;
    }
}
Пример #4
0
/**
 * 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;
}
Пример #5
0
/**
 * Возвращает массив файлов изображений из папки
 */
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;
}
 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 {
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.';
        }
    }
}
Пример #8
0
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()));
}
Пример #9
0
 /**
  * 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;
         }
     }
 }
Пример #10
0
 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);
Пример #11
0
 /**
  * 开始处理裁剪
  *
  * @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;
 }
Пример #12
0
 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' => '没有上传权限!')));
                 }
             }
             //开始上传
             $info = $Attachment->upload($Callback);
             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'], 'name' => str_replace(array("\\", "/"), "", $pictitle ? $pictitle : $info[0]['name']), 'size' => $info[0]['size'], 'type' => '.' . $info[0]['extension'], 'original' => $info[0]['name']);
             } else {
                 $result = array('state' => $Attachment->getError() ?: '上传失败');
             }
             break;
         default:
             $result = array('state' => '请求地址出错');
             break;
     }
     exit(json_encode($result));
 }
Пример #13
0
 /**
  * 开始处理裁剪
  *
  * @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;
 }
Пример #14
0
 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;
 }
Пример #15
0
 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);
             $data['account_info'] = $this->Account->get_account_info($account_id);
             $data['subView'] = '/account/edit_account_layout';
             $data['title'] = "Cập nhật tài khoản";
             $data['subData'] = $data;
             $this->load->view('/main/main_layout', $data);
         } else {
             $data['pre_page'] = base_url() . 'index.php/_admin/acticle/show_account';
             $this->load->view('/error/404_layout', $data);
         }
     }
 }
Пример #16
0
        ?>
'><?php 
        echo substr($document['file_name'], 0, 20);
        ?>
</a><BR><span class="<?php 
        echo $ud_status;
        ?>
"><?php 
        echo ucfirst($ud_status);
        ?>
</span></td>
              <?php 
        if ($numFiles < 50) {
            ?>
<td height="30"><?php 
            if (isImage($document['file_name'])) {
                ?>
<a target="_blank" href='<?php 
                echo "../gateway/" . $_SESSION['gw_folder'] . "UserDocuments/" . $document['file_type'] . "/" . $document['file_name'];
                ?>
'><img width="150" height="100" src='<?php 
                echo "../gateway/" . $_SESSION['gw_folder'] . "UserDocuments/" . $document['file_type'] . "/" . $document['file_name'];
                ?>
'></a><?php 
            }
            ?>
</td><?php 
        }
        ?>
              
   			  <td height="30">
Пример #17
0
function PageCodeCreate()
{
    $aForm = array('form_attrs' => array('id' => 'adm-mlevels-create', 'action' => $GLOBALS['site']['url_admin'] . 'memb_levels.php', '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' => '', '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'), 'value' => '', 'checker' => array('func' => '', 'params' => '', 'error' => _t('_adm_txt_mlevels_icon_err'))), 'Description' => array('type' => 'textarea', 'name' => 'description', 'caption' => _t('_adm_txt_mlevels_description'), 'value' => '', 'db' => array('pass' => 'XssHtml')), 'submit' => array('type' => 'submit', 'name' => 'submit', 'value' => _t('_adm_btn_mlevels_add'))));
    $oForm = new BxTemplFormView($aForm);
    $oForm->initChecker();
    $bFile = true;
    $sFilePath = BX_DIRECTORY_PATH_ROOT . 'media/images/membership/';
    $sFileName = time();
    $sFileExt = '';
    if ($oForm->isSubmittedAndValid() && ($bFile = 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) {
            addStringToLanguage("_adm_txt_mp_" . strtolower(bx_get('name')), bx_get('name'));
        }
        header('Location: ' . $oForm->aFormAttrs['action']);
    } else {
        if (!$bFile) {
            $oForm->aInputs['Icon']['error'] = $oForm->aInputs['Icon']['checker']['error'];
        }
        return DesignBoxAdmin(_t('_adm_box_cpt_mlevel_create'), $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oForm->getCode())));
    }
}
Пример #18
0
 function run()
 {
     global $Templates, $CONFIG;
     $_GET->setType('path', 'string');
     $_GET->setType('page', 'numeric');
     $this->page = $_GET['page'];
     if (!$this->page || !is_numeric($this->page) || $this->page < 1) {
         $this->page = 1;
     }
     //JS::loadjQuery(false);
     //JS::lib('jquery/jquery.timer*');
     //JS::lib('jquery/jquery.lightbox*');
     //Head::add('lightbox/jquery.lightbox-0.5.css', 'css-lib');
     //FIXME: Yweb-sökväg!!!!!!!
     //Head::add('/templates/yweb/js/subnav.js', 'js-url');
     Head::add('/templates/yweb/gallery.css', 'css-url');
     $path = $_REQUEST['path'] ? $_REQUEST['path'] : @substr($_SERVER['REQUEST_URI'], strlen($this->galleryDirPublic));
     $upath = urldecode($path);
     $path = deutf8($upath);
     if (substr($path, 0, strlen($this->thumbDirPublic)) == $this->thumbDirPublic) {
         $rpath = realpath($this->thumbDirLocal . substr($upath, strlen($this->thumbDirPublic)));
     } else {
         $rpath = realpath($this->getPathLocal() . $path);
     }
     if (is_file($rpath)) {
         if (strpos($rpath, $this->getPathLocal()) === 0 || strpos($rpath, $this->getThumbPathLocal()) === 0) {
             File::stream($rpath, !isImage($rpath));
         } else {
             errorPage(401);
         }
     } else {
         $this->albumName = $path;
         $this->ualbumName = $upath;
         $this->setContent('menu', $this->submenu());
         $this->setContent('main', $this->displayGallery());
         $Templates->yweb('empty')->render();
     }
 }
Пример #19
0
 public function public_crop_upload()
 {
     $Prefix = "thumb_";
     //默认裁减图片前缀
     C('SHOW_PAGE_TRACE', false);
     if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
         $pic = $GLOBALS["HTTP_RAW_POST_DATA"];
         if (isset($_GET['width']) && !empty($_GET['width'])) {
             $width = intval($_GET['width']);
         }
         if (isset($_GET['height']) && !empty($_GET['height'])) {
             $height = intval($_GET['height']);
         }
         if (isset($_GET['file']) && !empty($_GET['file'])) {
             if (isImage($_GET['file']) == false) {
                 exit;
             }
             $file = urldecode($_GET['file']);
             $basename = basename($file);
             if (strpos($basename, $Prefix) !== false) {
                 $file_arr = explode('_', $basename);
                 $basename = array_pop($file_arr);
             }
             $new_file = $Prefix . $width . '_' . $height . '_' . $basename;
             //栏目ID
             $catid = I('get.catid', 0, 'intval');
             $module = I('get.module');
             $Attachment = service("Attachment", array("module" => $module, "catid" => $catid));
             //附件存放路径
             $file_path = $Attachment->savePath;
             //附件原始名称
             $filename = basename($file);
             //上传文件的后缀类型
             $fileextension = fileext($file);
             //保存图片
             file_put_contents($file_path . $new_file, $pic);
             //图片信息
             $info = array("name" => $filename, "type" => "", "size" => filesize($file_path . $new_file), "key" => "", "extension" => $fileextension, "savepath" => $file_path, "savename" => $new_file, "hash" => md5(str_replace($Attachment->uploadfilepath, "", $file_path . $new_file)));
             $info['url'] = $Attachment->sitefileurl . str_replace($Attachment->uploadfilepath, '', $info['savepath'] . $info['savename']);
             $Attachment->movingFiles($info['savepath'] . $info['savename'], $info['savepath'] . $info['savename']);
         } else {
             return false;
         }
         echo $info['url'];
         exit;
     }
 }
Пример #20
0
 function image($image, $album, $size = array(), $user_size = array(), $active = true, $controller, $users, $smart = null, $watermark = null)
 {
     $data = array();
     if ($active && !$image['active']) {
         return '';
     }
     $size_str = '';
     $arr = unserialize($image['anchor']);
     if (empty($arr)) {
         $x = $y = 50;
     } else {
         $x = $arr['x'];
         $y = $arr['y'];
     }
     if (isImage($image['src'])) {
         foreach ($size as $s) {
             $s = explode(',', $s);
             $pre_array = array('width' => $s[1], 'height' => $s[2], 'square' => $s[3], 'quality' => $s[4], 'sharpening' => $s[5], 'anchor_x' => $x, 'anchor_y' => $y);
             if (!is_null($watermark) && $watermark > 0) {
                 $watermark_array = array('watermark_id' => $watermark, 'watermark_location' => $controller->watermarks[$watermark]['position'], 'watermark_opacity' => $controller->watermarks[$watermark]['opacity']);
                 $pre_water_array = array_merge($pre_array, $watermark_array);
             }
             list($w, $h) = computeSize(ALBUMS . DS . 'album-' . $image['aid'] . DS . 'lg' . DS . $image['src'], $s[1], $s[2], $s[3]);
             $data[$s[0]] = array();
             $data[$s[0]]['url'] = __p(array_merge(array('src' => $image['src'], 'album_id' => $image['aid']), $pre_array));
             if (isset($pre_water_array)) {
                 $data[$s[0]]['watermarked_url'] = __p(array_merge(array('src' => $image['src'], 'album_id' => $image['aid'], 'modified_on' => $image['modified_on']), $pre_water_array));
             }
             $data[$s[0]]['width'] = $w;
             $data[$s[0]]['height'] = $h;
         }
     } else {
         if (!empty($image['lg_preview'])) {
             list($p, $x, $y) = explode(':', $image['lg_preview']);
             $local_path = ALBUMS . DS . 'album-' . $image['aid'] . DS . 'lg' . DS . $p;
             $original = DIR_HOST . '/' . ALBUM_DIR . '/album-' . $image['aid'] . DS . 'lg' . DS . $p;
             list($_w, $_h) = getimagesize($local_path);
             $data['lg_preview'] = array('src' => $p, 'focal' => array('x' => $x, 'y' => $y), 'original' => array('url' => $original, 'width' => $_w, 'height' => $_h));
             foreach ($size as $s) {
                 $s = explode(',', $s);
                 $pre_array = array('width' => $s[1], 'height' => $s[2], 'square' => $s[3], 'quality' => $s[4], 'sharpening' => $s[5], 'anchor_x' => $x, 'anchor_y' => $y);
                 if (!is_null($watermark)) {
                     $watermark_array = array('watermark_id' => $watermark['id'], 'watermark_location' => $watermark['position'], 'watermark_opacity' => $watermark['opacity']);
                     $pre_array = array_merge($pre_array, $watermark_array);
                 }
                 list($w, $h) = computeSize(ALBUMS . DS . 'album-' . $image['aid'] . DS . 'lg' . DS . $p, $s[1], $s[2], $s[3]);
                 $data[$s[0]]['url'] = __p(array_merge(array('src' => $p, 'album_id' => $image['aid'], 'modified_on' => $image['modified_on']), $pre_array));
                 $data[$s[0]]['width'] = $w;
                 $data[$s[0]]['height'] = $h;
             }
         }
         if (!empty($image['tn_preview'])) {
             list($p, $x, $y) = explode(':', $image['tn_preview']);
             $local_path = ALBUMS . DS . 'album-' . $image['aid'] . DS . 'lg' . DS . $p;
             list($_w, $_h) = getimagesize($local_path);
             $original = DIR_HOST . '/' . ALBUM_DIR . '/album-' . $image['aid'] . DS . 'lg' . DS . $p;
             $data['thumb_preview'] = array('src' => $p, 'focal' => array('x' => $x, 'y' => $y), 'original' => array('url' => $original, 'width' => $_w, 'height' => $_h));
             foreach ($size as $s) {
                 $s = explode(',', $s);
                 $pre_array = array('width' => $s[1], 'height' => $s[2], 'square' => $s[3], 'quality' => $s[4], 'sharpening' => $s[5], 'anchor_x' => $x, 'anchor_y' => $y);
                 list($w, $h) = computeSize(ALBUMS . DS . 'album-' . $image['aid'] . DS . 'lg' . DS . $p, $s[1], $s[2], $s[3]);
                 $data['thumb_preview'][$s[0]]['url'] = __p(array_merge(array('src' => $p, 'album_id' => $image['aid'], 'modified_on' => $image['modified_on']), $pre_array));
                 $data['thumb_preview'][$s[0]]['width'] = $w;
                 $data['thumb_preview'][$s[0]]['height'] = $h;
             }
         }
     }
     $local_path = ALBUMS . DS . 'album-' . $image['aid'] . DS . 'lg' . DS . $image['src'];
     if (isImage($image['src'])) {
         list($original_w, $original_h) = getimagesize($local_path);
     } else {
         $original_w = $original_h = 0;
     }
     $original = DIR_HOST . '/' . ALBUM_DIR . '/album-' . $image['aid'] . '/lg/' . $image['src'];
     if (empty($image['title']) && !empty($album['title_template'])) {
         if (is_null($smart)) {
             $image['title'] = $controller->Director->formTitle($image, $album);
         } else {
             $image['title'] = $controller->Director->formTitle($image, $smart, $album);
         }
     }
     if (empty($image['caption']) && !empty($album['caption_template'])) {
         if (is_null($smart)) {
             $image['caption'] = $controller->Director->formCaption($image, $album);
         } else {
             $image['caption'] = $controller->Director->formCaption($image, $smart, $album);
         }
     }
     if (empty($image['link']) && !empty($album['link_template'])) {
         @(list($image['link'], $image['target']) = $controller->Director->formLink($image, $album));
     }
     if (!empty($image['start_on']) || !empty($image['end_on'])) {
         $data['schedule'] = array('begin' => $image['start_on'], 'end' => $image['end_on']);
     }
     $data['creator'] = $this->user($image['created_by'], $users, $user_size);
     $data['updater'] = $this->user($image['updated_by'], $users, $user_size);
     $data['public'] = $this->user(null, $users, $user_size);
     $data['title'] = convert_smart_quotes($image['title']);
     $data['caption'] = convert_smart_quotes($image['caption']);
     $data['id'] = $image['id'];
     $data['src'] = $image['src'];
     $data['album_id'] = $image['aid'];
     $data['is_video'] = $image['is_video'];
     $data['tags'] = $image['tags'];
     $data['link'] = $image['link'];
     $data['active'] = $image['active'];
     $data['seq'] = $image['seq'];
     $data['pause'] = $image['pause'];
     $data['target'] = $image['target'];
     $data['modified'] = $image['modified_on'];
     $data['created'] = $image['created_on'];
     $data['public'] = $image['public'];
     $data['captured_on'] = $image['captured_on'];
     $data['filesize'] = $image['filesize'];
     $data['original'] = array('url' => $original, 'width' => $original_w, 'height' => $original_h);
     $data['focal'] = array('x' => $x, 'y' => $y);
     $mimes = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'flv' => 'video/x-flv', 'f4v' => 'video/f4v', 'swf' => 'application/x-shockwave-flash', 'mov' => 'video/quicktime', 'mp4' => 'video/mp4', 'm4v' => 'video/x-m4v', '3gp' => 'video/3gpp', '3g2' => 'video/3gpp2');
     $info = pathinfo($local_path);
     if (array_key_exists($info['extension'], $mimes)) {
         $data['mime_type'] = $mimes[$info['extension']];
     } else {
         if (function_exists('mime_content_type')) {
             $data['mime_type'] = mime_content_type($local_path);
         } else {
             $data['mime_type'] = '';
         }
     }
     if ($controller->includeMeta) {
         list($mdata, $dummy) = $controller->Director->imageMetaData(ALBUMS . DS . 'album-' . $image['aid'] . DS . 'lg' . DS . $image['src']);
         if (!empty($mdata)) {
             $data['iptc'] = array();
             $data['exif'] = array();
             foreach ($controller->Director->iptcTags as $tag) {
                 $tag_clean = str_replace(' ', '_', $tag);
                 $data['iptc'][$tag_clean] = $controller->Director->parseMetaTags("iptc:{$tag}", $mdata, 'w');
             }
             foreach ($controller->Director->exifTags as $tag) {
                 $tag_clean = str_replace(' ', '_', $tag);
                 $data['exif'][$tag_clean] = $controller->Director->parseMetaTags("exif:{$tag}", $mdata, 'w');
             }
         }
     }
     if (!is_null($smart)) {
         $data['original_album'] = array('id' => $album['id'], 'title' => $album['name'], 'tags' => $album['tags']);
     }
     return $data;
 }
Пример #21
0
                // Get the file path
                $name_background_image = $_FILES['background_image_upload']['name'];
                $temp_background_image = $_FILES['background_image_upload']['tmp_name'];
                $path_background_image = JAPPIX_BASE . '/store/backgrounds/' . $name_background_image;
                // An error occured?
                if (!isSafeAllowed($name_background_image) || $_FILES['background_image_upload']['error'] || !move_uploaded_file($temp_background_image, $path_background_image)) {
                    ?>

        <p class="info smallspace fail"><?php 
                    _e("The image could not be received, would you mind retry?");
                    ?>
</p>

    <?php 
                } else {
                    if (!isImage($name_background_image)) {
                        // Remove the image file
                        if (file_exists($path_background_image)) {
                            unlink($path_background_image);
                        }
                        ?>

        <p class="info smallspace fail"><?php 
                        _e("This is not a valid image, please use PNG, GIF or JPG!");
                        ?>
</p>

    <?php 
                    } else {
                        ?>
Пример #22
0
 function cs_replace_image_links_with_local($zarray, $attack = false)
 {
     //$new_array = array ();
     if ($attack) {
         return get_template_directory_uri() . '/assets/images/tbtheme.png';
     }
     if (!is_array($zarray)) {
         return $zarray;
     } else {
         foreach ($zarray as $key => $val) {
             $image_folder = '';
             $image_path = '';
             if (!is_array($val)) {
                 // FUNCTIA DE SCHIMBAT URL SI UPLOAD POZA IN FOLDERUL WP-CONTENT
                 if (isImage($val)) {
                     $i = $_POST['theme'];
                     $image_name = basename($val);
                     $image_path_on_upload = explode('/wp-content/uploads/', $val);
                     $wp_upload_dir = wp_upload_dir();
                     if (!empty($image_path_on_upload[1])) {
                         $image_to_check = $image_path_on_upload[1];
                         $image_folder = explode($image_name, $image_path_on_upload[1]);
                         $image_folder = $image_folder[0];
                         $image_path = get_template_directory() . '/images/demo_images/' . $image_folder . $image_name;
                     }
                     if (file_exists($image_path)) {
                         if (!is_dir($wp_upload_dir['basedir'] . '/' . $image_folder)) {
                             if (!mkdir($wp_upload_dir['basedir'] . '/' . $image_folder, 0777, true)) {
                                 echo 'Directory could not be created : ' . $image_folder;
                             }
                         }
                         // Check if file is not already uploaded
                         if (!file_exists($wp_upload_dir['basedir'] . '/' . $image_folder . $image_name)) {
                             $wp_filetype = wp_check_filetype(basename($image_name), null);
                             if (!@copy($image_path, $wp_upload_dir['basedir'] . '/' . $image_folder . $image_name)) {
                                 echo 'Could not copy file';
                             }
                             $attachment = array('guid' => $wp_upload_dir['baseurl'] . '/' . $image_folder . basename($image_name), 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($image_name)), 'post_content' => '', 'post_status' => 'inherit');
                             $attach_id = wp_insert_attachment($attachment, $wp_upload_dir['basedir'] . '/' . $image_folder . $image_name);
                             // you must first include the image.php file
                             // for the function wp_generate_attachment_metadata() to work
                             require_once ABSPATH . 'wp-admin/includes/image.php';
                             $attach_data = wp_generate_attachment_metadata($attach_id, $image_name);
                             wp_update_attachment_metadata($attach_id, $attach_data);
                             $new_array[$key] = $wp_upload_dir['baseurl'] . '/' . $image_folder . basename($image_name);
                         } else {
                             $new_array[$key] = $wp_upload_dir['baseurl'] . '/' . $image_folder . basename($image_name);
                         }
                     } else {
                         $image_path = get_template_directory() . '/images/demo_images/' . 'sample.png';
                         if (!is_dir($wp_upload_dir['basedir'] . '/' . $image_folder)) {
                             if (!mkdir($wp_upload_dir['basedir'] . '/' . $image_folder, 0777, true)) {
                                 echo 'Directory could not be created : ' . $image_folder;
                             }
                         }
                         // Check if file is not already uploaded
                         if (!file_exists($wp_upload_dir['basedir'] . '/' . $image_folder . 'sample.png')) {
                             $wp_filetype = wp_check_filetype(basename($image_name), null);
                             if (!@copy($image_path, $wp_upload_dir['basedir'] . '/' . $image_folder . 'sample.png')) {
                                 echo 'Could not copy file';
                             }
                             $attachment = array('guid' => $wp_upload_dir['baseurl'] . '/' . $image_folder . 'sample.png', 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', 'sample.png'), 'post_content' => '', 'post_status' => 'inherit');
                             $attach_id = wp_insert_attachment($attachment, $wp_upload_dir['basedir'] . '/' . $image_folder . 'sample.png');
                             global $sample_image_id;
                             $sample_image_id = $attach_id;
                             // you must first include the image.php file
                             // for the function wp_generate_attachment_metadata() to work
                             require_once ABSPATH . 'wp-admin/includes/image.php';
                             $attach_data = wp_generate_attachment_metadata($attach_id, $image_name);
                             wp_update_attachment_metadata($attach_id, $attach_data);
                             $new_array[$key] = $wp_upload_dir['baseurl'] . '/' . $image_folder . 'sample.png';
                         } else {
                             $new_array[$key] = $wp_upload_dir['baseurl'] . '/' . $image_folder . 'sample.png';
                         }
                     }
                 } else {
                     $new_array[$key] = $val;
                 }
             } else {
                 $new_array[$key] = cs_replace_image_links_with_local($val);
             }
         }
     }
     return $new_array;
 }
Пример #23
0
 public function doedit()
 {
     if (isset($_POST["btnSubmit"])) {
         //============================== Purifier ==============================
         $this->load->helper('Validation');
         $this->load->helper('HTMLPurifier');
         $config = HTMLPurifier_Config::createDefault();
         $purifier = new HTMLPurifier($config);
         // $clean_html = $purifier->purify($dirty_html); //su dung
         //============================== Purifier ==============================
         $update_data = array();
         $war = array();
         $loi = array();
         $has_new_detail_image = false;
         $product_id = $_POST['product_id'];
         $page = isset($_POST['page']) && is_numeric($_POST['page']) ? $_POST['page'] : 1;
         $old_detail_image = $this->Product->get_detail_image($product_id);
         $old_avatar = $this->Product->get_avatar($product_id);
         $delete_detail_img = empty($_POST['delete_detail_img']) ? array() : $_POST['delete_detail_img'];
         if (count($_FILES['detail_img']['name']) > 0) {
             $imgs = $_FILES['detail_img'];
             $url = '';
             $tmp_name_detail_img = array();
             for ($i = 0; $i < count($_FILES['detail_img']['name']); $i++) {
                 if ($_FILES['detail_img']['name'][$i] != '') {
                     $tmp = new SplFileInfo($_FILES['detail_img']['name'][$i]);
                     $type = $tmp->getExtension();
                     if (strtolower($type) != 'jpg' && strtolower($type) != 'gif' && strtolower($type) != 'png') {
                         $war[] = "Dịnh dạng ảnh chi tiết sản phẩm không cho phép!";
                         $type = $tmp->getExtension();
                     } elseif ($_FILES['detail_img']['size'][$i] > 1024000) {
                         $war[] = "Ảnh chi tiết sản phẩm phải nhỏ hơn 2MB";
                     } elseif (!isImage($_FILES['detail_img']['tmp_name'][$i])) {
                         $war[] = "Ảnh chi tiết không phải là file ảnh!";
                     } else {
                         $url = $url . '|' . htmlspecialchars(md5($_POST['product_name'])) . '-' . $i . time() . '.' . $type;
                         $tmp_name_detail_img[] = $_FILES['detail_img']['tmp_name'][$i];
                     }
                 }
             }
             if (trim($url, '|') != '') {
                 $new_detail_image = trim($url, '|');
                 $update_data['detail_image'] = $old_detail_image . '|' . $new_detail_image;
                 $update_data['detail_image'] = trim($update_data['detail_image'], '|');
                 $has_new_detail_image = true;
             }
         }
         if (!empty($delete_detail_img)) {
             if ($has_new_detail_image) {
                 foreach ($delete_detail_img as $value) {
                     $update_data['detail_image'] = str_replace($value . '|', '', $update_data['detail_image']);
                 }
             } else {
                 $update_data['detail_image'] = $old_detail_image . '|';
                 foreach ($delete_detail_img as $value) {
                     $update_data['detail_image'] = str_replace($value . '|', '', $update_data['detail_image']);
                 }
             }
             $update_data['detail_image'] = trim($update_data['detail_image'], '|');
         }
         $update_data['product_name'] = trim_input($_POST["product_name"]);
         $update_data['category_id'] = $_POST["category_id"];
         $update_data['des'] = $purifier->purify($_POST["des"]);
         $update_data['price'] = trim_input($_POST["price"]);
         $update_data['size'] = $purifier->purify($_POST["size"]);
         $update_data['substance'] = $purifier->purify($_POST["substance"]);
         //====================== Validate START ======================
         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') {
                 $loi[] = "Định dạng ảnh đại diện sản phẩm không cho phép!";
             } elseif (!isImage($_FILES['avatar']['tmp_name'])) {
                 $loi[] = "Ảnh đại diện sản phẩm không phải là file ảnh!";
             } elseif ($_FILES['avatar']['size'] > 2048000) {
                 $loi[] = "Ảnh đại diện sản phẩm phải nhỏ hơn 2MB";
             } else {
                 $tmp_name_avatar = $_FILES['avatar']['tmp_name'];
                 $update_data['image'] = md5($update_data['product_name']) . '-' . time() . '.' . $avatar_type;
             }
         }
         if (empty($_POST["product_name"])) {
             $loi[] = "Tên sản phẩm không được rỗng";
         } elseif (strip_tags($_POST["product_name"]) == '') {
             $loi[] = "Tên sản phẩm không hợp lệ!";
         } else {
             if (strlen($_POST["product_name"]) >= 4 && strlen($_POST["product_name"]) <= 100) {
                 $update_data['product_name'] = $_POST["product_name"];
                 $update_data['product_name'] = trim($_POST["product_name"]);
                 $update_data['product_name'] = strip_tags($_POST["product_name"]);
                 $update_data['product_name'] = addslashes($update_data['product_name']);
                 $product_name_exist = $this->Product->has_exist_product_name($update_data['product_name'], $product_id);
                 if ($product_name_exist) {
                     $loi[] = "Sản phẩm đã tồn tại";
                 }
             } else {
                 $loi[] = "Tên sản phẩm phải dài hơn 4 và nhỏ hơn 100 kí tự!";
             }
         }
         if (empty($update_data['category_id'])) {
             $loi[] = "Chưa chọn loại sản phẩm!";
         } elseif (!is_numeric($update_data['category_id']) || !$this->Category->has_sub_category_exist_by_id($update_data['category_id'])) {
             $loi[] = "Loại sản phẩm không hợp lệ!";
         }
         if (!empty($update_data['price'])) {
             if (!is_numeric($update_data['price'])) {
                 $loi[] = "Giá phải là kiểu số!";
             }
         }
         //====================== Validate END ======================
         if (count($loi) > 0) {
             $alert_time = 20000;
             set_notice(FAILED_STATUS, $loi, $alert_time);
             $data['category'] = $this->Category->list_all_sub_category();
             $redata['info'] = $this->Product->get_product_by_id($product_id);
             $redata['re_product_name'] = $_POST['product_name'];
             $redata['re_category_id'] = $_POST['category_id'];
             $redata['re_price'] = $_POST['price'];
             $redata['re_size'] = $_POST['size'];
             $redata['re_substance'] = $_POST['substance'];
             $redata['re_des'] = $_POST['des'];
             $redata['re_page'] = $page;
             $data['subView'] = '/product/edit_product_layout';
             $data['title'] = 'Cập nhật sản phẩm';
             $data['subData'] = $redata;
             $this->load->view('/main/main_layout', $data);
         } else {
             $rs = $this->Product->update($product_id, $update_data);
             // ============= Xoa anh chi tiet ===================
             if ($rs && !empty($delete_detail_img)) {
                 foreach ($delete_detail_img as $value) {
                     @unlink('public/img/detail_img/' . $value);
                 }
             }
             // ============= Xoa anh chi tiet ===================
             // ============= Upload anh chi tiet ===================
             if ($rs && $has_new_detail_image) {
                 $detail_image_name = explode('|', $new_detail_image);
                 for ($i = 0; $i < count($detail_image_name); $i++) {
                     $path = "public/img/detail_img/";
                     move_uploaded_file($tmp_name_detail_img[$i], $path . $detail_image_name[$i]);
                     resizeImage($path . $detail_image_name[$i], $path . $detail_image_name[$i], 600, 600);
                 }
             }
             // ============= Upload anh chi tiet ===================
             // ============= Upload anh avatar ===================
             if ($rs && isset($_FILES['avatar'])) {
                 $path = "public/img/products/";
                 if (move_uploaded_file($tmp_name_avatar, $path . $update_data['image'])) {
                     resizeImage($path . $update_data['image'], $path . $update_data['image'], 600, 600);
                     @unlink('public/img/products/' . $old_avatar);
                 }
             }
             // ============= Upload anh avatar ===================
             if ($rs) {
                 if (!empty($war)) {
                     $war['title'] = 'Cập nhật sản phẩm <span style="color:blue;"> ' . $update_data['product_name'] . '</span> thành công!';
                     $content = $war;
                     $alert_time = 15000;
                     set_notice(FAILED_STATUS, $content, $alert_time);
                     header('location:' . base_url() . 'index.php/_admin/product');
                 } else {
                     $mess = 'Cập nhật sản phẩm <span style="color:blue;"> ' . $update_data['product_name'] . '</span> thành công!';
                     set_notice(SUCCESS_STATUS, $mess);
                     header('location:' . base_url() . 'index.php/_admin/product');
                 }
             } else {
                 $mess = 'Có lỗi xảy ra cập nhật sản phẩm.';
                 set_notice(FAILED_STATUS, $mess);
                 header('location:' . base_url() . 'index.php/_admin/product/add_product');
             }
         }
     }
 }
Пример #24
0
    $tmpfilepath = "rgthumb.cachedimg.{$imgName}";
    $fg = fg(str_replace(" ", "%20", $imgFile));
    if (!$fg) {
        error("File could not be loaded.\nCheck if FREAD may access external files.");
    }
    $fw = fw($tmpfilepath, $fg);
    if (!$fw) {
        error("File could not be saved to local server.\nTmpFilePath: {$tmpfilepath}");
    }
    $imgFile = $tmpfilepath;
}
// Catch errors
if (!file_exists($imgFile)) {
    error("File doesn't exist.");
}
if (!isImage($imgFile) && !$force) {
    error("File is not an image.");
}
// Create Image
// Setup
$offset_top = 0;
$offset_left = 0;
// Dimensions
list($imgoWidth, $imgoHeight) = @getimagesize("{$imgFile}");
// Memory
$memUsageAprox = $imgoWidth * $imgoHeight * 4;
$memUsageAproxKb = round($memUsageAprox / 1024);
$memLimitBytes = calculateBytes(get_cfg_var("memory_limit"));
$memLimitKb = round($memLimitBytes / 1024);
/*
	if ($cfg["remotePreResizerEnabled"] && $memUsageAproxKb>$memLimitKb) {
Пример #25
0
 public function add_slider()
 {
     if (isset($_POST['edit_slider_btn'])) {
         $data_post = $this->input->post();
         $this->load->helper('Validation');
         $this->load->helper('HTMLPurifier');
         $config = HTMLPurifier_Config::createDefault();
         $purifier = new HTMLPurifier($config);
         //====================== Validate START ======================
         $error = array();
         $link_slider = array();
         for ($i = 0; $i < count($_FILES['image_slider']['name']); $i++) {
             $data_insert['link_slider'][$i] = '';
             if ($_FILES['image_slider']['name'][$i] != '') {
                 $tmp = new SplFileInfo($_FILES['image_slider']['name'][$i]);
                 $type = $tmp->getExtension();
                 if (strtolower($type) != 'jpg' && strtolower($type) != 'gif' && strtolower($type) != 'png') {
                     $error[] = "Không đúng định dạng ảnh cho phép!";
                 } elseif (!isImage($_FILES['image_slider']['tmp_name'][$i])) {
                     $error[] = "Không phải là file ảnh!";
                 } elseif ($_FILES['image_slider']['size'][$i] > 2048000) {
                     $error[] = "Ảnh lớn hơn 2MB";
                 } else {
                     $data_insert['link_slider'][$i] = $i . microtime() . '.' . $type;
                     $tmp_name_image_slider[$i] = $_FILES['image_slider']['tmp_name'][$i];
                 }
             } else {
                 $error[] = "Bắt buộc phải upload 1 ảnh cho 1 slide.";
             }
         }
         for ($i = 0; $i < count($data_post['des_slider']); $i++) {
             if ($data_post['des_slider'][$i] !== '') {
                 $data_insert['des_slider'][$i] = $purifier->purify($data_post['des_slider'][$i]);
             } else {
                 $data_insert['des_slider'][$i] = '';
             }
         }
         //====================== Validate END ======================
         if (count($error) > 0) {
             $alert_time = 15000;
             set_notice('status', FAILED_STATUS, $error, $alert_time);
             $redata['re_des_slider'] = $data_post['des_slider'];
             $data['subView'] = '/manage_site/slider/add_slider_layout';
             $data['title'] = "Thêm hình ảnh vào slider";
             $data['subData'] = $redata;
             $this->load->view('/main/main_layout', $data);
         } else {
             $tmp_insert = array();
             for ($i = 0; $i < count($data_post['des_slider']); $i++) {
                 // $this->Slider->insert($data_insert[]);
                 $tmp_insert['link_slider'] = $data_insert['link_slider'][$i];
                 $tmp_insert['des_slider'] = $data_insert['des_slider'][$i];
                 $tmp_rs = $this->Slider->insert($tmp_insert);
             }
             // ============= Upload anh image_slider ===================
             for ($i = 0; $i < count($_FILES['image_slider']['name']); $i++) {
                 if (!empty($_FILES['image_slider']['name'][$i])) {
                     $path = "public/img/slider/";
                     if (move_uploaded_file($tmp_name_image_slider[$i], $path . $data_insert['link_slider'][$i])) {
                         resizeImage($path . $data_insert['link_slider'][$i], $path . $data_insert['link_slider'][$i], 400, 400);
                     }
                 }
             }
             // ============= Upload anh image_slider ===================
             $content = 'Thêm mới slide thành công.';
             set_notice('status', SUCCESS_STATUS, $content);
             header('location:' . base_url() . 'index.php/_admin/manage_site/slider/show_slider');
         }
     } else {
         $data['subView'] = '/manage_site/slider/add_slider_layout';
         $data['title'] = "Thêm hình ảnh vào slider";
         $data['subData'] = $data;
         $this->load->view('/main/main_layout', $data);
     }
 }
Пример #26
0
/**
 * Receive an image or zip of images in $_FILES['img'] and save the image(s) to the specified directory
 *
 * @param object object to store response messages
 * @param string filesystem directory to save image(s) to
 *
 * @return bool true on success
 */
function receiveUpload($response, $dir)
{
    if (empty($_FILES['img'])) {
        $response->message = 'No file specified';
        $response->error = true;
        return false;
    }
    $errors = ['Success', 'File too large (exceeds upload_max_filesize in php.ini)', 'File too large (exceeds MAX_FILE_SIZE)', 'Partial file received', 'No file specified', 'No tmp dir', 'Could not write to disk'];
    if ($_FILES['img']['error']) {
        $response->message = $errors[$_FILES['img']['error']];
        $response->error = true;
        return false;
    }
    $zip = zip_open($_FILES['img']['tmp_name']);
    if ($zip && is_resource($zip)) {
        $i = 0;
        while ($zip_entry = zip_read($zip)) {
            $path = zip_entry_name($zip_entry);
            $pathInfo = pathinfo($path);
            $filename = $pathInfo['basename'];
            $dest = $dir . '/' . $filename;
            if (empty($pathInfo['extension'])) {
                continue;
            }
            if (!in_array(mb_strtolower($pathInfo['extension']), ['png', 'gif', 'jpg', 'jpeg'])) {
                continue;
            }
            if (zip_entry_open($zip, $zip_entry, 'r')) {
                file_put_contents($dest, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
                zip_entry_close($zip_entry);
                if (!isImage($dest)) {
                    unlink($dest);
                } else {
                    $i++;
                }
            }
        }
        zip_close($zip);
        $response->message = 'Unzipped ' . $i . ' images';
        return true;
    }
    // Check the file is OK
    if (!isImage($_FILES['img']['tmp_name'])) {
        $response->message = 'Invalid image file: Please use PNG, JPEG and GIF files only';
        $response->error = true;
        return false;
    }
    if (!move_uploaded_file($_FILES['img']['tmp_name'], $dir . '/' . $_FILES['img']['name'])) {
        $response->message = 'Error moving uploaded file';
        $response->error = true;
        return false;
    }
    $response->message = 'Uploaded successfully';
    return true;
}
Пример #27
0
}
//FIM DO TRECHO SOBRE OS E-MAIL ENVIADOS
#############################################################
$qryTela = "select * from imagens where img_oco = " . $row['numero'] . "";
$execTela = mysql_query($qryTela) or die(TRANS('MSG_ERR_NOT_INFO_IMAGE'));
//$rowTela = mysql_fetch_array($execTela);
$isTela = mysql_num_rows($execTela);
$cont = 0;
print "<table>";
while ($rowTela = mysql_fetch_array($execTela)) {
    //if ($isTela !=0) {
    $cont++;
    print "<tr>";
    $size = round($rowTela['img_size'] / 1024, 1);
    print "<TD  bgcolor='" . TD_COLOR . "' >" . TRANS('FIELD_ATTACH') . " " . $cont . "&nbsp;[" . $rowTela['img_tipo'] . "](" . $size . "k):</td>";
    if (isImage($rowTela["img_tipo"])) {
        $viewImage = "&nbsp;<a onClick=\"javascript:popupWH('../../includes/functions/showImg.php?" . "file=" . $row['numero'] . "&cod=" . $rowTela['img_cod'] . "'," . $rowTela['img_largura'] . "," . $rowTela['img_altura'] . ")\" " . "title='View the file'><img src='../../includes/icons/kghostview.png' width='16px' height='16px' border='0'></a>";
    } else {
        $viewImage = "";
    }
    print "<td colspan='5' ><a onClick=\"redirect('../../includes/functions/download.php?" . "file=" . $row['numero'] . "&cod=" . $rowTela['img_cod'] . "')\" title='Download the file'>" . "<img src='../../includes/icons/attach2.png' width='16px' height='16px' border='0'>" . "" . $rowTela['img_nome'] . "</a>" . $viewImage . "</TD>";
    print "</tr>";
}
print "</table>";
print "<br>";
$qrySubCall = "select * from ocodeps where dep_pai = " . $row['numero'] . "";
$execSubCall = mysql_query($qrySubCall) or die(TRANS('MSG_ERR_RESCUE_INFO_SUBCALL') . '<br>' . $qrySubCall);
$existeSub = mysql_num_rows($execSubCall);
if ($existeSub > 0) {
    $comDeps = false;
    while ($rowSubPai = mysql_fetch_array($execSubCall)) {
Пример #28
0
$r = "/^((http|https|ftp):\\/\\/)?[a-zA-Z0-9]+([-_\\.]?[a-zA-Z0-9])*\\.[a-zA-Z0-9]{2,4}(\\/{1}[-_~&=\\?\\.a-zA-Z0-9]*)*\$/";
if (isset($_SESSION['step_pp_7']['photo_alt_data'])) {
    if (strlen($_SESSION['step_pp_7']['photo_alt_data']) == 0) {
        echo "<h2 class=\"error\">" . $webgen_photo_h2_alt[$language] . "</h2>";
    }
    if ($_SESSION['step_pp_5']['photo_file'] == "url") {
        if (strlen($_SESSION['step_pp_7']['photo_src_data']) == 0) {
            echo "<h2 class=\"error\">" . $webgen_photo_empty_src[$language] . "</h2>";
        } elseif (!preg_match($r, $_SESSION['step_pp_7']['photo_src_data'])) {
            echo "<h2 class=\"error\">" . $webgen_photo_invalid_src[$language] . "</h2>";
        }
    } elseif ($_SESSION['step_pp_5']['photo_file'] == "file") {
        if ($_SESSION['step_pp_7']['photo_file_upload']['photo_copy_data']['size'] > 2621440) {
            echo "<h2 class=\"error\">" . $webgen_photo_h2_big[$language] . "</h2>";
        }
        if (!isImage($_SESSION['step_pp_7']['photo_file_upload']['photo_copy_data']['type'])) {
            echo "<h2 class=\"error\">" . $webgen_photo_h2_empty[$language] . "</h2>";
        }
    }
}
?>

<form action="<?php 
echo $_SERVER['REQUEST_URI'];
?>
" method="post" enctype="multipart/form-data">   
    <ul class="clear">        
        <li>
            <label>
                <?php 
echo $webgen_photo_photo_alt[$language];
function getBackgrounds()
{
    // Initialize the result array
    $array = array();
    // Scan the background directory
    $scan = scandir(JAPPIX_BASE . '/store/backgrounds/');
    foreach ($scan as $current) {
        if (isImage($current)) {
            array_push($array, $current);
        }
    }
    return $array;
}
Пример #30
0
// Handle if image is located on remote server
if ($imgIsRemote) {
	
	// It is: attempt to download to local server
	$srcFileExtension = substr($imgFile, strrpos($imgFile,".")+1);
	$tmpfilepath = "rgthumb.cachedimg.{$imgName}";
	$fg = fg(str_replace(" ","%20",$imgFile)); if (!$fg) { error("File could not be loaded.\nCheck if FREAD may access external files."); }
	$fw = fw($tmpfilepath,$fg); if (!$fw) { error("File could not be saved to local server.\nTmpFilePath: {$tmpfilepath}"); }
	$imgFile = $tmpfilepath;
	
	}

// Catch errors
if (!file_exists($imgFile)) { error("File doesn't exist."); }
if (!isImage($imgFile) && !$force) { error("File is not an image."); }

// Create Image
	
	// Setup
	$offset_top = 0;
	$offset_left = 0;
	
	// Dimensions
	list($imgoWidth, $imgoHeight) = @getimagesize("{$imgFile}");
		
	// Memory				
	$memUsageAprox = ($imgoWidth * $imgoHeight) * 4;
	$memUsageAproxKb = round($memUsageAprox / (1024));
				
	$memLimitBytes = calculateBytes(get_cfg_var("memory_limit"));