Beispiel #1
0
 function domanage()
 {
     if ($_FILES['Filedata']) {
         require_once iPATH . 'include/upload.class.php';
         $this->iCMS->config['iswatermark'] = false;
         $this->iCMS->config['isthumb'] = false;
         $ext = FS::getExt($_FILES['Filedata']['name']);
         $F = iUpload::FILES("Filedata", 0, '', 'avatar', 'tmp_' . member::$uId . '.' . strtolower($ext), 'avatar');
         //            echo FS::fp($F["FilePath"],'+http');
         echo '../' . $this->iCMS->config['uploadfiledir'] . '/' . $F["FilePath"];
     } else {
         $_dir = ceil(member::$uId / 500);
         $data = file_get_contents("php://input");
         $length = strlen($data);
         $lastIndex = 0;
         $sizeIndex = 0;
         $sizeArray = array(120, 48, 24);
         //同时上传3个尺寸的头像。 分割数据
         while ($lastIndex < $length) {
             $a = unpack('L', $data[$lastIndex + 3] . $data[$lastIndex + 2] . $data[$lastIndex + 1] . $data[$lastIndex]);
             $lastIndex += 4;
             $avatarData = substr($data, $lastIndex, $a[1]);
             $lastIndex += $a[1];
             $avatar = 'avatar/' . $_dir . '/' . member::$uId . '_' . $sizeArray[$sizeIndex] . '.gif';
             $fp = FS::fp($avatar, '+iPATH');
             @FS::mkdir(dirname($fp));
             @FS::write($fp, $avatarData);
             $sizeIndex++;
         }
         $rootpf = FS::fp('avatar/tmp_' . member::$uId, '+iPATH');
         foreach (glob($rootpf . "*") as $_fp) {
             file_exists($_fp) && FS::del($_fp);
         }
     }
 }
Beispiel #2
0
 function get_file($key, $method)
 {
     $dirPath = $this->_dirs . '/' . (strpos($key, '/') !== false ? dirname($key) : '');
     if ($this->_dir_level != -1) {
         $a = str_split(md5($key), $this->_dir_level);
         $dirPath .= '/' . implode('/', $a) . '/';
     }
     if (!file_exists($dirPath) && $method == 'add') {
         FS::mkdir($dirPath);
     }
     $strrchr = strrchr($key, '/');
     $strrchr !== false && ($key = $strrchr);
     return $dirPath . $key . '.php';
 }
Beispiel #3
0
 function Content($mid, $id)
 {
     global $iCMS;
     if (empty($id) || !$iCMS->config['ishtm'] || strstr($iCMS->config['aRule'], '{PHP}')) {
         return false;
     }
     $iCMS->mode = 'CreateHtml';
     $iCMS->htmlConf = array('enable' => true, 'ext' => $rs['htmlext'] ? $rs['htmlext'] : $iCMS->config['htmlext']);
     $html = $iCMS->content($mid, $id);
     FS::mkdir($iCMS->result->iurl->dir);
     FS::write($iCMS->result->iurl->path, $html, false);
     return true;
 }
Beispiel #4
0
 function thumbnail($upfiledir, $src, $tName, $tw = '', $th = '', $scale = true, $tDir = "thumb")
 {
     global $iCMS;
     $R = array();
     $tw = empty($tw) ? $iCMS->config['thumbwidth'] : (int) $tw;
     $th = empty($th) ? $iCMS->config['thumbhight'] : (int) $th;
     if ($tw && $th) {
         list($width, $height, $type) = @getimagesize($src);
         if ($width < 1 && $height < 1) {
             $R['width'] = $tw;
             $R['height'] = $th;
             $R['src'] = $src;
             return $R;
         }
         if ($width > $tw || $height > $th) {
             $R['src'] = $upfiledir . $tDir . "/" . $tName . '_' . $tw . 'x' . $th . '.' . substr(strrchr($src, "."), 1);
             if (in_array('Gmagick', get_declared_classes())) {
                 $image = new Gmagick();
                 $image->readImage($src);
                 $im = self::scale(array("tw" => $tw, "th" => $th, "w" => $image->getImageWidth(), "h" => $image->getImageHeight()));
                 $image->resizeImage($im['w'], $im['h'], null, 1);
                 $image->cropImage($tw, $th, 0, 0);
                 //$image->thumbnailImage($gm_w,$gm_h);
                 FS::mkdir($upfiledir . $tDir);
                 $image->writeImage($R['src']);
                 $image->destroy();
             } else {
                 $im = self::scale(array("tw" => $tw, "th" => $th, "w" => $width, "h" => $height), $scale);
                 $R['width'] = $im['w'];
                 $R['height'] = $im['h'];
                 $res = self::imagecreate($type, $src);
                 if ($res) {
                     $thumb = imagecreatetruecolor($im['w'], $im['h']);
                     imagecopyresampled($thumb, $res, 0, 0, 0, 0, $im['w'], $im['h'], $width, $height);
                     //PHP_VERSION != '4.3.2' && self::UnsharpMask($thumb);
                     FS::mkdir($upfiledir . $tDir);
                     self::image($thumb, $type, $R['src']);
                 } else {
                     $R['src'] = $src;
                 }
             }
         } else {
             $R['width'] = $width;
             $R['height'] = $height;
             $R['src'] = $src;
         }
         return $R;
     }
 }
Beispiel #5
0
function adm($rs)
{
    global $iCMS;
    $rs->code = stripslashes_deep(unserialize($rs->code));
    $file = FS::path(iPATH . $iCMS->config['htmldir'] . '/!adm') . '/';
    FS::mkdir($file);
    switch ($rs->load) {
        case "js":
            $file .= "{$rs->style}-{$rs->id}.js";
            $html = "/*\n广告:{$rs->varname}\n标签:<!--{iCMS:advertise name=\"{$rs->varname}\"}-->\n*/\n";
            if ($rs->status) {
                $html .= "var timestamp = Date.parse(new Date());\n";
                $html .= "var startime = Date.parse(new Date(\"" . get_date($rs->starttime, 'Y/m/d') . "\"));\n";
                $rs->endtime && ($html .= "var endtime = Date.parse(new Date(\"" . get_date($rs->endtime, 'Y/m/d') . "\"));\n");
                $html .= "if(timestamp>=startime";
                $rs->endtime && ($html .= "||timestamp<endtime");
                $html .= "){\n";
                $html .= document(getadvhtml($rs->style, $rs->code));
                $html .= "}";
            }
            break;
        case "iframe":
            $file .= "{$rs->style}-{$rs->id}.html";
            $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script type="text/javascript">function resizeFrame(){try{ var frames=parent.document.documentElement.getElementsByTagName("iframe"); for(var i=0;i<frames.length;i++){ frames[i].style.height=document.body.scrollHeight+"px"; var topPos=location.href.indexOf("#top");if(topPos>0){location.href=location.href.substring(0,topPos)+"#top1"}break;}}}catch(e){return;}}</script></head><body>' . getadvhtml($rs->style, $rs->code) . '</body><script type="text/javascript">resizeFrame();</scrip</html>';
            break;
        case "shtml":
            $file .= "{$rs->style}-{$rs->id}.shtml";
            $html = getadvhtml($rs->style, $rs->code);
            break;
    }
    $rs->src = $file;
    $iCMS->setCache('system/adm/' . md5($rs->varname), $rs, 0);
    if ($fn) {
        return $file;
    }
    $rs->load && FS::write($file, $html);
}
Beispiel #6
0
 function update($n)
 {
     @set_time_limit(0);
     // Unzip uses a lot of memory
     @ini_set('memory_limit', '256M');
     require_once iPATH . 'include/pclzip.class.php';
     $zipName = 'iCMS ' . self::$iCMSVER . '.patch.' . $n . '.zip';
     $zipFile = PATCH_DIR . '/' . $zipName;
     //临时文件
     $msg = '正在对 [' . $zipName . '] 更新包进行解压缩<icms>';
     $zip = new PclZip($zipFile);
     if (false == ($archive_files = $zip->extract(PCLZIP_OPT_EXTRACT_AS_STRING))) {
         exit("ZIP包错误");
     }
     if (0 == count($archive_files)) {
         exit("空的ZIP文件");
     }
     $msg .= '解压完成开始更新程序#<icms>';
     foreach ($archive_files as $file) {
         $folder = $file['folder'] ? $file['filename'] : dirname($file['filename']);
         $dp = iPATH . $folder;
         if (!FS::exists($dp)) {
             $msg .= '创建 [' . $dp . '] 文件夹<icms>';
             //self::mkdir($path.'/'.$folder);
         }
         if (empty($file['folder'])) {
             $fp = iPATH . $file['filename'];
             $bfp = iPATH . $n . 'bak/' . $file['filename'];
             if (FS::exists($fp)) {
                 $msg .= '备份 [' . $fp . '] 文件 到 [' . $bfp . ']<icms>';
                 FS::mkdir(dirname($bfp));
                 rename($fp, $bfp);
                 //备份旧文件
             }
             $msg .= '更新 [' . $fp . '] 文件<icms>';
             FS::write($fp, $file['content']);
             $msg .= '[' . $fp . '] 更新完成!#<icms>';
         }
     }
     $msg .= '清除临时文件!<icms>注:原文件备份在 [' . iPATH . $n . 'bak/] 目录<icms>如没有特殊用处请删除此目录!#<icms>';
     FS::rmdir(PATCH_DIR, true, 'version.txt');
     return $msg;
 }
Beispiel #7
0
 function docrop()
 {
     //header('Content-type: image/jpeg');
     $tMap = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
     $pic = $_POST['pFile'];
     $iPic = uploadpath($pic, '+iPATH');
     list($width, $height, $type) = @getimagesize($iPic);
     $_width = $_POST['width'];
     $_height = $_POST['height'];
     $w = $_POST['w'];
     $h = $_POST['h'];
     $x = $_POST['x'];
     $y = $_POST['y'];
     if ($width == $w && $height == $h) {
         javascript::alert('源图小于或等于剪裁尺寸,不剪裁!', 'js:parent.iCMS.insert("' . $pic . '","' . $_POST['callback'] . '");');
     }
     if ($width == $_width && $height == $_height) {
         //不对源图缩放
         $_img = iUpload::imagecreate($tMap[$type], $iPic);
         $_Type = $_img['type'];
     } else {
         $img = iUpload::imagecreate($tMap[$type], $iPic);
         $_Type = $img['type'];
         if ($img['res']) {
             $thumb = imagecreatetruecolor($_width, $_height);
             imagecopyresampled($thumb, $img['res'], 0, 0, 0, 0, $_width, $_height, $width, $height);
             $_tmpfile = FS::path_join(iPATH, $iCMS->config['uploadfiledir']) . '/crop_tmp_' . time() . rand(1, 999999);
             iUpload::image($thumb, $_Type, $_tmpfile);
             $_tmpfile .= '.' . $_Type;
             $_img = iUpload::imagecreate($tMap[$type], $_tmpfile);
             FS::del($_tmpfile);
         }
     }
     if ($_img['res']) {
         $_thumb = imagecreatetruecolor($w, $h);
         imagecopyresampled($_thumb, $_img['res'], 0, 0, $x, $y, $w, $h, $w, $h);
         $thumbpath = substr($iPic, 0, strrpos($iPic, '/')) . "/thumb";
         $picName = substr($iPic, 0, strrpos($iPic, '.'));
         $picName = substr($picName, strrpos($picName, '/'));
         $fileName = $thumbpath . $picName . '_' . $w . 'x' . $h;
         FS::mkdir($thumbpath);
         iUpload::image($_thumb, $_img['type'], $fileName);
         $fileName .= '.' . $_Type;
         javascript::dialog($pic . '<br />剪裁成功!', 'js:parent.iCMS.insert("' . uploadpath($fileName, '-iPATH') . '","' . $_POST['callback'] . '");parent.iCMS_WINDOW_' . iCMSKEY . '.close();');
     }
 }
Beispiel #8
0
 function content($id, $mid, $table = NULL)
 {
     global $iCMS;
     if (empty($id) || empty($mid)) {
         return false;
     }
     $iCMS->mode = 'CreateHtml';
     $iCMS->htmlConf = array('enable' => true, 'ext' => $rs['htmlext'] ? $rs['htmlext'] : $iCMS->config['htmlext']);
     $html = $iCMS->content($id, $mid, $table);
     if (!$html) {
         return false;
     }
     FS::mkdir($iCMS->metadata->iurl->dir);
     FS::write($iCMS->metadata->iurl->path, $html, false);
     return true;
 }
Beispiel #9
0
 function docrop()
 {
     $pic = $_POST['pFile'];
     $iPic = FS::fp($pic, '+iPATH');
     list($width, $height, $type) = @getimagesize($iPic);
     $_width = $_POST['width'];
     $_height = $_POST['height'];
     $w = $_POST['w'];
     $h = $_POST['h'];
     $x = $_POST['x'];
     $y = $_POST['y'];
     $ext = FS::getExt($pic);
     if ($width == $w && $height == $h) {
         javascript::alert('源图小于或等于剪裁尺寸,不剪裁!', 'js:parent.iCMS.insert("' . $pic . '","' . $_POST['callback'] . '");');
     }
     $imgres = iUpload::imagecreate($type, $iPic);
     if ($width != $_width || $height != $_height) {
         //对源图缩放
         $thumb = imagecreatetruecolor($_width, $_height);
         imagecopyresampled($thumb, $imgres, 0, 0, 0, 0, $_width, $_height, $width, $height);
         $_tmpfile = FS::path_join(iPATH, $this->iCMS->config['uploadfiledir']) . '/crop_tmp_' . time() . rand(1, 999999) . '.' . $ext;
         iUpload::image($thumb, $type, $_tmpfile);
         $imgres = iUpload::imagecreate($type, $_tmpfile);
         FS::del($_tmpfile);
     }
     if ($imgres) {
         $_thumb = imagecreatetruecolor($w, $h);
         imagecopyresampled($_thumb, $imgres, 0, 0, $x, $y, $w, $h, $w, $h);
         $thumbpath = substr($iPic, 0, strrpos($iPic, '/')) . "/thumb";
         $picName = substr($iPic, 0, strrpos($iPic, '.'));
         $picName = substr($picName, strrpos($picName, '/'));
         $fileName = $thumbpath . $picName . '_' . $w . 'x' . $h . '.' . $ext;
         FS::mkdir($thumbpath);
         iUpload::image($_thumb, $type, $fileName);
         javascript::dialog($pic . '<br />剪裁成功!', 'js:parent.iCMS.insert("' . FS::fp($fileName, '-iPATH') . '","' . $_POST['callback'] . '");parent.iCMS_WINDOW_' . iCMSKEY . '.close();');
     }
 }