Ejemplo n.º 1
0
 public function _index($album, $sub_tool = FALSE)
 {
     # this is a hack for allowed sub_tools only.
     if (!is_object($album)) {
         $album = ORM::factory('album')->where('fk_site', $this->site_id)->find($album);
         if (!$album->loaded) {
             return $this->wrap_tool('album error, please contact support', 'album', $album);
         }
     }
     # set the thumbnail size USES TOGGLE:
     $thumb_size = (isset($album->toggle) and is_numeric($album->toggle)) ? $album->toggle : 75;
     # images
     $images = json_decode($album->images);
     if (NULL === $images or !is_array($images)) {
         return $this->wrap_tool('no images.', 'album', $album);
     }
     foreach ($images as $image) {
         $image->thumb = image::thumb($image->path, $thumb_size);
     }
     $display_view = empty($album->view) ? 'lightbox' : $album->view;
     $primary = $this->{$display_view}($album, $images);
     # add custom javascript;
     $primary->global_readyJS(self::javascripts($album));
     return $this->wrap_tool($primary, 'album', $album, $sub_tool);
 }
Ejemplo n.º 2
0
 public function manage()
 {
     $album = $this->get_parent('album');
     if ($_POST) {
         if (NULL === json_decode($_POST['images'])) {
             die('data is not properly formed JSON');
         }
         $album->images = $_POST['images'];
         $album->save();
         die('Album saved');
     }
     # images
     $images = json_decode($album->images);
     if (NULL === $images) {
         $images = array();
     }
     foreach ($images as $image) {
         $image->thumb = image::thumb($image->path);
     }
     $primary = new View('edit_album/manage');
     $primary->album = $album;
     $primary->images = $images;
     $primary->img_path = $this->assets->assets_url();
     die($primary);
 }
Ejemplo n.º 3
0
 /**
  * 储存文件
  * @param string $file 储存的文件
  * @return boolean
  */
 private function save($file)
 {
     $is_img = 0;
     $uploadFileName = mt_rand(1, 9999) . time() . "." . $file['ext'];
     $filePath = $this->path . $uploadFileName;
     if (in_array(strtolower($file['ext']), array("jpeg", "jpg", "bmp", "gif", "png")) && getimagesize($file['tmp_name'])) {
         $imgDir = C("UPLOAD_IMG_DIR") ? C("UPLOAD_IMG_DIR") . "/" : "";
         $filePath = $this->path . $imgDir . $uploadFileName;
         if (!$this->checkDir($this->path . $imgDir)) {
             $this->error = '图片上传目录创建失败或不可写';
             return false;
         }
         $is_img = 1;
     }
     if (!move_uploaded_file($file['tmp_name'], $filePath)) {
         $this->error('移动临时文件失败');
         return false;
     }
     if (!$is_img) {
         $filePath = ltrim(str_replace(ROOT_PATH, '', $filePath), '/');
         $arr = array("path" => $filePath, 'fieldname' => $file['fieldname'], 'image' => 0);
     } else {
         //处理图像类型文件
         $img = new image();
         $imgInfo = getimagesize($filePath);
         //对原图进行缩放
         if (C("UPLOAD_IMG_RESIZE_ON") && ($imgInfo[0] > C("UPLOAD_IMG_MAX_WIDTH") || $imgInfo[1] > C("UPLOAD_IMG_MAX_HEIGHT"))) {
             $img->thumb($filePath, $uploadFileName, C("UPLOAD_IMG_MAX_WIDTH"), C("UPLOAD_IMG_MAX_HEIGHT"), 5, $this->path);
         }
         //生成缩略图
         if ($this->thumbOn) {
             $args = array();
             if (empty($this->thumb)) {
                 array_unshift($args, $filePath);
             } else {
                 array_unshift($args, $filePath, "", "");
                 $args = array_merge($args, $this->thumb);
             }
             $thumbFile = call_user_func_array(array($img, "thumb"), $args);
         }
         //加水印
         if ($this->waterMarkOn) {
             $img->water($filePath);
         }
         $filePath = trim(str_replace(ROOT_PATH, '', $filePath), '/');
         if ($this->thumbOn) {
             $thumbFile = trim(str_replace(ROOT_PATH, '', $thumbFile), '/');
             $arr = array("path" => $filePath, "thumb" => $thumbFile, 'fieldname' => $file['fieldname'], 'image' => 1);
         } else {
             $arr = array("path" => $filePath, 'fieldname' => $file['fieldname'], 'image' => 1);
         }
     }
     $arr['path'] = preg_replace('@\\./@', '', $arr['path']);
     //上传时间
     $arr['uptime'] = time();
     $info = pathinfo($filePath);
     $arr['fieldname'] = $file['fieldname'];
     $arr['basename'] = $info['basename'];
     $arr['filename'] = $info['filename'];
     $arr['size'] = $file['size'];
     $arr['ext'] = $file['ext'];
     $dir = str_ireplace("\\", "/", dirname($arr['path']));
     $arr['dir'] = substr($dir, "-1") == "/" ? $dir : $dir . "/";
     return $arr;
 }
Ejemplo n.º 4
0
 public static function clip_thumb($sourcefile, $destfile, $forcedwidth = 80, $forcedheight = 80)
 {
     // 获取原图片宽高
     $getimgsize = getimagesize($sourcefile);
     if (empty($getimgsize)) {
         return 0;
     } else {
         $src_width = $getimgsize[0];
         $src_height = $getimgsize[1];
         if ($src_width == 0 || $src_height == 0) {
             return 0;
         }
     }
     $src_scale = $src_width / $src_height;
     $des_scale = $forcedwidth / $forcedheight;
     if ($src_width <= $forcedwidth && $src_height <= $forcedheight) {
         $des_width = $src_width;
         $des_height = $src_height;
         $n = image::clip($sourcefile, $destfile, 0, 0, $des_width, $des_height);
         return filesize($destfile);
         // 原图为横着的矩形
     } elseif ($src_scale >= $des_scale) {
         // 以原图的高度作为标准,进行缩略
         $des_height = $src_height;
         $des_width = $src_height / $des_scale;
         $n = image::clip($sourcefile, $destfile, 0, 0, $des_width, $des_height);
         if ($n <= 0) {
             return 0;
         }
         $r = image::thumb($destfile, $destfile, $forcedwidth, $forcedheight);
         return $r['filesize'];
         // 原图为竖着的矩形
     } else {
         // 以原图的宽度作为标准,进行缩略
         $des_width = $src_width;
         $des_height = $src_width / $des_scale;
         /* echo "src_scale: $src_scale, src_width: $src_width, src_height: $src_height \n";
            echo "des_scale: $des_scale, forcedwidth: $forcedwidth, forcedheight: $forcedheight \n";
            echo "des_width: $des_width, des_height: $des_height \n";
            exit; */
         $n = image::clip($sourcefile, $destfile, 0, 0, $des_width, $des_height);
         if ($n <= 0) {
             return 0;
         }
         $r = image::thumb($destfile, $destfile, $forcedwidth, $forcedheight);
         return $r['filesize'];
     }
 }
Ejemplo n.º 5
0
//上传成功文件物理路径
$info = pathinfo($field);
$fileData = array();
$fileData[0]['path'] = $field;
//上传后的大图
$fileData[0]['url'] = __ROOT__ . '/' . $field;
//上传后的大图URL
$json = array();
$json['state'] = $state;
$json['fid'] = md5($field);
if (getimagesize($field)) {
    //图片裁切处理
    $img = new image();
    $img->water($field);
    $json['thumb']['file'] = __ROOT__ . '/' . $field;
    $json['thumb']['w'] = $display_width;
    $json['thumb']['h'] = $display_height;
}
if ($imagesize && getimagesize($field)) {
    //图片裁切处理
    $n = 1;
    for ($i = 0; $i < count($size); $i += 2) {
        $toFile = $info['filename'] . $n . '.' . $info['extension'];
        $img->thumb($field, $toFile, '', $size[$i], $size[$i + 1], $thumb_type);
        $fileData[$n]['path'] = $info['dirname'] . '/' . $toFile;
        $n++;
    }
}
$json['file'] = $fileData;
echo json_encode($json);
exit;
Ejemplo n.º 6
0
    /**
     * 储存文件
     * @param string $file 储存的文件
     * @return boolean
     */
    private function save($file)
    {
        $is_img = 0;
        $uploadFileName = mt_rand(1, 9999) . time() . "." . $file['ext'];
        $filePath = $this->path . $uploadFileName;
        if (in_array(strtolower($file ['ext']), array("jpeg", "jpg", "bmp", "gif", "png")) && getimagesize($file ['tmp_name'])) {
            $imgDir = C("UPLOAD_IMG_DIR") ? C("UPLOAD_IMG_DIR") . "/" : "";
            $filePath = $this->path . $imgDir . $uploadFileName;
            if (!$this->checkDir($this->path . $imgDir)) {
                $this->error = L("upload_save_error1");
                return false;
            }
            $is_img = 1;
        }
        if (!move_uploaded_file($file ['tmp_name'], $filePath)) {
            $this->error(L("upload_save_error2"));
            return false;
        }

        if (!$is_img) {
            $filePath = ltrim(str_replace(PATH_ROOT, '', $filePath), '/');
            return array("path" => $filePath, 'fieldname' => $file['fieldname']);
        }
        //处理图像类型文件
        $img = new image ();
        //对原图进行缩放
        if (C("UPLOAD_IMG_RESIZE_ON")) {
            $img->thumb($filePath, $uploadFileName, '', C("UPLOAD_IMG_MAX_WIDTH"), C("UPLOAD_IMG_MAX_HEIGHT"), 5);
        }
        //生成缩略图
        if ($this->thumbOn) {
            $args = array();
            if (empty($this->thumb)) {
                array_unshift($args, $filePath);
            } else {
                array_unshift($args, $filePath, "", "");
                $args = array_merge($args, $this->thumb);
            }
            $thumbFile = call_user_func_array(array($img, "thumb"), $args);
        }
        //加水印
        if ($this->waterMarkOn) {
            $img->water($filePath);
        }
        $filePath = ltrim(str_replace(ROOT_PATH, '', $filePath), '/');
        $arr = array();
        if ($this->thumbOn) {
            $thumbFile = ltrim(str_replace(PATH_ROOT, '', $thumbFile), '/');
            $arr = array("path" => $filePath, "thumb" => $thumbFile);
        } else {
            $arr = array("path" => $filePath);
        }
        return array_merge($arr, $file);
    }
Ejemplo n.º 7
0
	/**
	 *  上传头像处理
	 *  传入头像压缩包,解压到指定文件夹后删除非图片文件
	 */
	public function uploadavatar() {
		
		//根据用户id创建文件夹
		if(isset($this->data['uid']) && isset($this->data['avatardata'])) {
			$this->uid = intval($this->data['uid']);
			$this->avatardata = $this->data['avatardata'];
		} else {
			exit('0');
		}
		
		$dir1 = ceil($this->uid / 10000);
		$dir2 = ceil($this->uid % 10000 / 1000);
		
		//创建图片存储文件夹
		$avatarfile = pc_base::load_config('system', 'upload_path').'avatar/';
		$dir = $avatarfile.$dir1.'/'.$dir2.'/'.$this->uid.'/';
		if(!file_exists($dir)) {
			mkdir($dir, 0777, true);
		}
		//存储flashpost图片
		$filename = $dir.'180x180.jpg';

		$fp = fopen($filename, 'w');
		fwrite($fp, $this->avatardata);
		fclose($fp);

		$avatararr = array('180x180.jpg', '30x30.jpg', '45x45.jpg', '90x90.jpg');
		$files = glob($dir."*");
		foreach($files as $_files) {
			if(is_dir($_files)) dir_delete($_files);
			if(!in_array(basename($_files), $avatararr)) @unlink($_files);
		}
		if($handle = opendir($dir)) {
		    while(false !== ($file = readdir($handle))) {
				if($file !== '.' && $file !== '..') {
					if(!in_array($file, $avatararr)) {
						@unlink($dir.$file);
					} else {
						$info = @getimagesize($dir.$file);
						if(!$info || $info[2] !=2) {
							@unlink($dir.$file);
						}
					}
				}
		    }
		    closedir($handle);    
		}

		pc_base::load_sys_class('image','','0');
		$image = new image(1,0);
		$image->thumb($filename, $dir.'30x30.jpg', 30, 30);
		$image->thumb($filename, $dir.'45x45.jpg', 45, 45);
		$image->thumb($filename, $dir.'90x90.jpg', 90, 90);
		
		$this->db->update(array('avatar'=>1), array('uid'=>$this->uid));
		exit('1');
	}
Ejemplo n.º 8
0
             $image->watertext();
         }
     }
     if ($DT['water_type'] && $DT['water_com'] && $_groupid > 5) {
         $image = new image(DT_ROOT . '/' . $saveto);
         $image->text = $_company;
         $image->pos = 5;
         $image->watertext();
     }
     if ($from == 'photo') {
         $DT['thumb_album'] = 0;
     }
     $image = new image(DT_ROOT . '/' . $do->saveto);
     $image->thumb($width, $height, $DT['thumb_album']);
     $image = new image(DT_ROOT . '/' . $middle);
     $image->thumb($DT['middle_w'], $DT['middle_h'], $DT['thumb_album']);
     if ($DT['water_middle'] && $DT['water_type']) {
         if ($DT['water_type'] == 2) {
             $image = new image(DT_ROOT . '/' . $middle);
             $image->waterimage();
         } else {
             if ($DT['water_type'] == 1) {
                 $image = new image(DT_ROOT . '/' . $middle);
                 $image->watertext();
             }
         }
     }
 } else {
     if ($from == 'editor') {
         if ($_groupid == 1 && !isset($watermark)) {
             $DT['water_type'] = 0;
Ejemplo n.º 9
0
         if (!$img_info || $img_info[0] < 128 || $img_info[1] < 128) {
             file_del($file);
         }
         $img_info or message($L['avatar_img_t']);
         $img_info[0] >= 128 or message($L['avatar_img_w']);
         $img_info[1] >= 128 or message($L['avatar_img_h']);
         $par = 'auth=' . encrypt($_userid . '|' . $_username, DT_KEY . 'AVATAR');
         require DT_ROOT . '/include/image.class.php';
         $image = new image($file);
         $image->thumb(128, 128);
         $par .= '&pic1=' . urlencode(base64_encode(file_get($file)));
         $image = new image($file);
         $image->thumb(48, 48);
         $par .= '&pic2=' . urlencode(base64_encode(file_get($file)));
         $image = new image($file);
         $image->thumb(20, 20);
         $par .= '&pic3=' . urlencode(base64_encode(file_get($file)));
         file_del($file);
         $arr = dcurl(DT_PATH . 'api/avatar/upload.php', $par);
         if (strpos($arr, ':1}') !== false) {
             dheader('?itemid=' . $DT_TIME);
         }
         dalert($L['avatar_img_e'] . $arr, '?itemid=' . $DT_TIME);
     } else {
         message($upload->errmsg);
     }
     break;
 case 'delete':
     if ($avatar) {
         $img = array();
         $img[1] = useravatar($_userid, 'large', 0, 2);
Ejemplo n.º 10
0
<?php 
$class = 'albums' == $mode ? 'to_album' : 'to_editor';
$tmb_size = 75;
foreach ($files as $path => $data) {
    $data = explode('|', $data);
    list($type, $name) = $data;
    # show files
    if ('file' == $type) {
        $css_id = str_replace('.', '_', $name);
        $path = str_replace(':', '/', $path);
        $url = $this->assets->assets_url() . '/' . $path;
        $url_thumb = image::thumb($url);
        $display_name = '10' < strlen($name) ? substr($name, 0, 10) . '...' : $name;
        $ext = strtolower(strrchr($name, "."));
        # if image show thumbnail
        $img = array_key_exists($ext, $image_types) ? "<img src='{$url_thumb}' class='{$class} image_file' rel='{$url}' title='{$name}' width='{$tmb_size}' height='{$tmb_size}' alt='{$path}'>" : "<img src='/_assets/images/admin/file.gif' title='{$name}' width='{$tmb_size}' height='{$tmb_size}' alt=''>";
        ?>
		<div id="<?php 
        echo $css_id;
        ?>
" class="file_asset asset" rel="<?php 
        echo $path;
        ?>
">
			<span class="icon info">&#160; &#160;</span>
			<?php 
        echo $img;
        ?>
			<span title="<?php 
        echo $name;
Ejemplo n.º 11
0
<?php 
if (!empty($sub_categories)) {
    echo "<div><b>Filter By Sub Category</b>{$sub_categories}</div>";
}
?>
<!-- end duplicated -->

<div class="list_showroom">
	<?php 
foreach ($items as $item) {
    # images
    $images = json_decode($item->images);
    if (!empty($images) and is_array($images)) {
        # show the thumb of the first image in the album.
        # echo kohana::debug($images);
        $small = image::thumb($images[0]->path, 0);
        $image = "<img src=\"{$img_path}/{$small}\" alt=\"{$images[0]->caption}\">";
    }
    ?>
		
		<div id="showroom_item_<?php 
    echo $item->id;
    ?>
" class="showroom_item" rel="<?php 
    echo $item->id;
    ?>
">
			<div class="item_name">
				<?php 
    echo $item->name;
    ?>
Ejemplo n.º 12
0
	 <small>(<?php 
echo $items->count();
?>
 results)</small>
</div>

<div class="showroom_items_wrapper">
	<?php 
$counter = 0;
foreach ($items as $item) {
    # images
    $images = json_decode($item->images);
    if (!empty($images) and is_array($images)) {
        # show the thumb of the first image in the album.
        $full_path = $images[0]->path;
        $thumb = image::thumb($full_path, $thumb_size);
        $image = "<img src='{$img_path}/{$thumb}' width='{$thumb_size}' height='{$thumb_size}' alt='{$images[0]->caption}'>";
    }
    ?>
	
		<div id="showroom_item_<?php 
    echo $item->id;
    ?>
" class="showroom_item" rel="<?php 
    echo $item->id;
    ?>
">
			<?php 
    if (isset($image)) {
        ?>
				<div class="item_image"><a href="<?php 
Ejemplo n.º 13
0
function save_thumb($content, $no, $width = 120, $height = 90)
{
    global $DT, $DT_TIME, $_userid;
    if (!$_userid || !$content) {
        return '';
    }
    $ext = 'jpg|jpeg|gif|png|bmp';
    if (!preg_match_all("/src=([\"|']?)([^ \"'>]+\\.({$ext}))\\1/i", $content, $matches)) {
        return '';
    }
    require_once DT_ROOT . '/include/image.class.php';
    $dftp = false;
    if ($DT['ftp_remote'] && $DT['remote_url']) {
        require_once DT_ROOT . '/include/ftp.class.php';
        $ftp = new dftp($DT['ftp_host'], $DT['ftp_user'], $DT['ftp_pass'], $DT['ftp_port'], $DT['ftp_path'], $DT['ftp_pasv'], $DT['ftp_ssl']);
        $dftp = $ftp->connected;
    }
    $urls = $oldpath = $newpath = array();
    $DT['uploaddir'] or $DT['uploaddir'] = 'Ym/d';
    foreach ($matches[2] as $k => $url) {
        if ($k == $no - 1) {
            $filedir = 'file/upload/' . timetodate($DT_TIME, $DT['uploaddir']) . '/';
            $filepath = DT_PATH . $filedir;
            $fileroot = DT_ROOT . '/' . $filedir;
            $file_ext = file_ext($url);
            $filename = timetodate($DT_TIME, 'H-i-s') . '-' . rand(10, 99) . '-' . $_userid . '.' . $file_ext;
            $newfile = $fileroot . $filename;
            if (file_copy($url, $newfile)) {
                if (is_image($newfile)) {
                    if (!@getimagesize($newfile)) {
                        file_del($newfile);
                        return '';
                    }
                    $image = new image($newfile);
                    $image->thumb($width, $height);
                }
                $newurl = linkurl($filepath . $filename);
                if ($dftp) {
                    $exp = explode("file/upload/", $newurl);
                    if ($ftp->dftp_put($filedir . $filename, $exp[1])) {
                        $newurl = $DT['remote_url'] . $exp[1];
                        file_del($newfile);
                    }
                }
                return $newurl;
            }
        }
    }
    unset($matches);
    return '';
}
Ejemplo n.º 14
0
 public function editAction()
 {
     //判断是否添加
     if (trim($this->getRequest()->getPost('document_submit', 0))) {
         //获取数据
         $document_id = trim($this->getRequest()->getPost('document_id', 0));
         $pageId = $this->getRequest()->getPost('document_pageid', 0);
         $table_name = $this->getRequest()->getPost('table_name', 0);
         //**************依据模型处理与模型关联的数据表**********************
         $docData = $this->getRequest()->getPost();
         $document_catid = trim($this->getRequest()->getPost('document_catid', 0));
         if (!$document_catid) {
             echo '<script>alert("请选择正确的所属栏目!");window.history.go(-1);</script>';
             exit;
         }
         $document_detail = (array) $this->db_category->get_category_detail($document_catid);
         $modelid = $document_detail[0]['modelid'];
         $where = array("AND" => array("status" => 1, "modelid" => $modelid));
         //获取该模型的所有启用字段
         $fields = $this->db_modelFields->get_column_by_where("field", $where);
         //自动接收表单数据并过滤
         foreach ($docData as $key => $val) {
             if (in_array($key, $fields)) {
                 $data[$key] = trim($val);
             }
         }
         if (in_array('updatetime', $fields)) {
             $data['updatetime'] = $_SERVER['time'];
         }
         if (in_array('uid', $fields)) {
             $data['uid'] = $this->_user['uid'];
         }
         if (in_array('thumb', $fields)) {
             $fileInfo = $this->getRequest()->getFiles();
             //                var_dump($fileInfo);
             $filename = image::safe_name($fileInfo['thumb']['name'], '/uploadfile/image/');
             $data['thumb'] = image::thumb($fileInfo['thumb']['tmp_name'], '/uploadfile/image/' . $filename);
         }
         $data['catid'] = $document_catid;
         //            var_dump($data);die;
         //判断数据是否正常
         if (isset($data['title']) && empty($data['title'])) {
             echo '<script>alert("请填写标题!");window.history.go(-1);</script>';
             exit;
         }
         if (isset($data['content']) && empty($data['content'])) {
             echo '<script>alert("请填写内容!");window.history.go(-1);</script>';
             exit;
         }
         //将数据添加到表中
         if ($table_name == 'news') {
             $content = $data['content'];
             unset($data['content']);
             if ($this->db_document->document_update($document_id, $data, $table_name) && $this->db_document->document_update($document_id, array('content' => $content), 'news_data') || $this->db_document->document_update($document_id, $data, $table_name) || $this->db_document->document_update($document_id, array('content' => $content), 'news_data')) {
                 echo '<script>alert("操作成功");window.location.href="/admin/document/index?' . $pageId . '";</script>';
             } else {
                 echo '<script>alert("操作失败");window.history.go(-1);</script>';
             }
         } else {
             if ($id = $this->db_document->document_update($document_id, $data, $table_name)) {
                 echo '<script>alert("操作成功");window.location.href="/admin/document/index?' . $pageId . '";</script>';
             } else {
                 echo '<script>alert("操作失败");window.history.go(-1);</script>';
             }
         }
         exit;
     } else {
         Yaf_Controller_Abstract::redirect("/admin/document/index");
         exit;
     }
 }
Ejemplo n.º 15
0
 /**
  * 附件上传方法
  * @param $field 上传字段
  * @param $alowexts 允许上传类型
  * @param $maxsize 最大上传大小
  * @param $overwrite 是否覆盖原有文件
  * @param $thumb_setting 缩略图设置
  * @param $watermark_enable  是否添加水印
  */
 function upload($field, $alowexts = '', $maxsize = 0, $overwrite = 0, $thumb_setting = array(), $watermark_enable = 1)
 {
     if (!isset($_FILES[$field])) {
         $this->error = UPLOAD_ERR_OK;
         return false;
     }
     if (empty($alowexts) || $alowexts == '') {
         $site_setting = $this->_get_site_setting($this->siteid);
         $alowexts = $site_setting['upload_allowext'];
     }
     $fn = $_GET['CKEditorFuncNum'] ? $_GET['CKEditorFuncNum'] : '1';
     $this->field = $field;
     $this->savepath = $this->upload_root . $this->upload_dir . date('Y/md/');
     $this->alowexts = $alowexts;
     $this->maxsize = $maxsize;
     $this->overwrite = $overwrite;
     $uploadfiles = array();
     $description = isset($GLOBALS[$field . '_description']) ? $GLOBALS[$field . '_description'] : array();
     if (is_array($_FILES[$field]['error'])) {
         $this->uploads = count($_FILES[$field]['error']);
         foreach ($_FILES[$field]['error'] as $key => $error) {
             if ($error === UPLOAD_ERR_NO_FILE) {
                 continue;
             }
             if ($error !== UPLOAD_ERR_OK) {
                 $this->error = $error;
                 return false;
             }
             $uploadfiles[$key] = array('tmp_name' => $_FILES[$field]['tmp_name'][$key], 'name' => $_FILES[$field]['name'][$key], 'type' => $_FILES[$field]['type'][$key], 'size' => $_FILES[$field]['size'][$key], 'error' => $_FILES[$field]['error'][$key], 'description' => $description[$key], 'fn' => $fn);
         }
     } else {
         $this->uploads = 1;
         if (!$description) {
             $description = '';
         }
         $uploadfiles[0] = array('tmp_name' => $_FILES[$field]['tmp_name'], 'name' => $_FILES[$field]['name'], 'type' => $_FILES[$field]['type'], 'size' => $_FILES[$field]['size'], 'error' => $_FILES[$field]['error'], 'description' => $description, 'fn' => $fn);
     }
     if (!dir_create($this->savepath)) {
         $this->error = '8';
         return false;
     }
     if (!is_dir($this->savepath)) {
         $this->error = '8';
         return false;
     }
     @chmod($this->savepath, 0777);
     if (!is_writeable($this->savepath)) {
         $this->error = '9';
         return false;
     }
     if (!$this->is_allow_upload()) {
         $this->error = '13';
         return false;
     }
     $aids = array();
     foreach ($uploadfiles as $k => $file) {
         $fileext = fileext($file['name']);
         if ($file['error'] != 0) {
             $this->error = $file['error'];
             return false;
         }
         if (!preg_match("/^(" . $this->alowexts . ")\$/", $fileext)) {
             $this->error = '10';
             return false;
         }
         if ($this->maxsize && $file['size'] > $this->maxsize) {
             $this->error = '11';
             return false;
         }
         if (!$this->isuploadedfile($file['tmp_name'])) {
             $this->error = '12';
             return false;
         }
         $temp_filename = $this->getname($fileext);
         $savefile = $this->savepath . $temp_filename;
         $savefile = preg_replace("/(php|phtml|php3|php4|jsp|exe|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\\.|\$)/i", "_\\1\\2", $savefile);
         $filepath = preg_replace(new_addslashes("|^" . $this->upload_root . "|"), "", $savefile);
         if (!$this->overwrite && file_exists($savefile)) {
             continue;
         }
         $upload_func = $this->upload_func;
         if (@$upload_func($file['tmp_name'], $savefile)) {
             $this->uploadeds++;
             @chmod($savefile, 0644);
             @unlink($file['tmp_name']);
             $file['name'] = iconv("utf-8", CHARSET, $file['name']);
             $file['name'] = safe_replace($file['name']);
             $uploadedfile = array('filename' => $file['name'], 'filepath' => $filepath, 'filesize' => $file['size'], 'fileext' => $fileext, 'fn' => $file['fn']);
             $thumb_enable = is_array($thumb_setting) && ($thumb_setting[0] > 0 || $thumb_setting[1] > 0) ? 1 : 0;
             $image = new image($thumb_enable, $this->siteid);
             if ($thumb_enable) {
                 $image->thumb($savefile, '', $thumb_setting[0], $thumb_setting[1]);
             }
             if ($watermark_enable) {
                 $image->watermark($savefile, $savefile);
             }
             $aids[] = $this->add($uploadedfile);
         }
     }
     return $aids;
 }
Ejemplo n.º 16
0
 if (file_copy($f, DT_ROOT . '/' . $L)) {
     file_copy($f, DT_ROOT . '/' . $M);
     file_copy($f, DT_ROOT . '/' . $T);
     if ($DT['water_type'] == 2) {
         $image = new image(DT_ROOT . '/' . $L);
         $image->waterimage();
     } else {
         if ($DT['water_type'] == 1) {
             $image = new image(DT_ROOT . '/' . $L);
             $image->watertext();
         }
     }
     $image = new image(DT_ROOT . '/' . $M);
     $image->thumb($DT['middle_w'], $DT['middle_h']);
     $image = new image(DT_ROOT . '/' . $T);
     $image->thumb(100, 100);
     $saveto = linkurl($T);
     if ($DT['ftp_remote'] && $DT['remote_url']) {
         if ($ftp->connected) {
             $exp = explode("file/upload/", $saveto);
             $_saveto = 'file/upload/' . $exp[1];
             $remote = $exp[1];
             if ($ftp->dftp_put($_saveto, $remote)) {
                 $saveto = $DT['remote_url'] . $remote;
                 file_del(DT_ROOT . '/' . $_saveto);
                 if (strpos($_saveto, '.thumb.') !== false) {
                     $local = str_replace('.thumb.' . $ext, '', $_saveto);
                     $remote = str_replace('.thumb.' . $ext, '', $exp[1]);
                     $ftp->dftp_put($local, $remote);
                     file_del(DT_ROOT . '/' . $local);
                     $local = str_replace('.thumb.' . $ext, '.middle.' . $ext, $_saveto);
Ejemplo n.º 17
0
/**
 * 生成缩略图函数
 * @param  $imgurl 图片路径
 * @param  $width  缩略图宽度
 * @param  $height 缩略图高度
 * @param  $autocut 是否自动裁剪 默认裁剪,当高度或宽度有一个数值为0是,自动关闭
 * @param  $smallpic 无图片是默认图片路径
 */
function thumb($imgurl, $width = 100, $height = 100, $autocut = 1, $smallpic = 'nopic.gif')
{
    global $image;
    $upload_url = pc_base::load_config('system', 'upload_url');
    $upload_path = pc_base::load_config('system', 'upload_path');
    if (empty($imgurl)) {
        return IMG_PATH . $smallpic;
    }
    $imgurl_replace = str_replace($upload_url, '', $imgurl);
    if (!extension_loaded('gd') || strpos($imgurl_replace, '://')) {
        return $imgurl;
    }
    if (!file_exists($upload_path . $imgurl_replace)) {
        return IMG_PATH . $smallpic;
    }
    list($width_t, $height_t, $type, $attr) = getimagesize($upload_path . $imgurl_replace);
    if ($width >= $width_t || $height >= $height_t) {
        return $imgurl;
    }
    $newimgurl = dirname($imgurl_replace) . '/thumb_' . $width . '_' . $height . '_' . basename($imgurl_replace);
    if (file_exists($upload_path . $newimgurl)) {
        return $upload_url . $newimgurl;
    }
    if (!is_object($image)) {
        pc_base::load_sys_class('image', '', '0');
        $image = new image(1, 0);
    }
    return $image->thumb($upload_path . $imgurl_replace, $upload_path . $newimgurl, $width, $height, '', $autocut) ? $upload_url . $newimgurl : $imgurl;
}
Ejemplo n.º 18
0
	<div class="single_name">
		<? echo $item->name?>
	</div>
	
	<div class="single_link">
		<b>Link to this item:</b> <input type="text" value="<?php 
echo url::site("{$page_name}/0{$item->id}/{$item->url}");
?>
" style="width:80%">
	</div>	
	
	<div class="single_body">
		<? echo $item->body?>
	</div>

	<div class="single_image">
		<?php 
# images
$images = json_decode($item->images);
if (!empty($images) and is_array($images)) {
    foreach ($images as $image) {
        $path = image::thumb($image->path, 0);
        $img = "<img src=\"{$img_path}/{$path}\" alt=\"{$image->caption}\">";
        echo "{$img}";
        echo "<span>{$image->caption}</span>";
    }
}
?>
	</div>

</div>