<?php
defined('IN_PHPCMS') or exit('No permission resources.');
$session_storage = 'session_'.pc_base::load_config('system','session_storage');
pc_base::load_sys_class($session_storage);
if(param::get_cookie('sys_lang')) {
define('SYS_STYLE',param::get_cookie('sys_lang'));
} else {
define('SYS_STYLE','zh-cn');
}
class attachments {
private $att_db;
function __construct() {
pc_base::load_app_func('global');
$this->upload_url = pc_base::load_config('system','upload_url');
$this->upload_path = pc_base::load_config('system','upload_path');
$this->imgext = array('jpg','gif','png','bmp','jpeg');
$this->userid = $_SESSION['userid'] ? $_SESSION['userid'] : (param::get_cookie('_userid') ? param::get_cookie('_userid') : sys_auth($_POST['userid_flash'],'DECODE'));
$this->isadmin = $this->admin_username = $_SESSION['roleid'] ? 1 : 0;
$this->groupid = param::get_cookie('_groupid') ? param::get_cookie('_groupid') : 8;
//判断是否登录
if(empty($this->userid)){
showmessage(L('please_login','','member'));
}
}
/**
* 常规上传
*/
public function upload() {
$grouplist = getcache('grouplist','member');
if($this->isadmin==0 && !$grouplist[$this->groupid]['allowattachment']) return false;
if($this->isadmin==1) define('IN_ADMIN',true);
pc_base::load_sys_class('attachment','',0);
$module = trim($_GET['module']);
$catid = intval($_GET['catid']);
$siteid = $this->get_siteid();
$site_setting = get_site_setting($siteid);
$site_allowext = $site_setting['upload_allowext'];
$attachment = new attachment($module,$catid,$siteid);
$attachment->set_userid($this->userid);
$a = $attachment->upload('upload',$site_allowext);
if($a){
$filepath = $attachment->uploadedfiles[0]['filepath'];
$fn = intval($_GET['CKEditorFuncNum']);
$this->upload_json($a[0],$filepath,$attachment->uploadedfiles[0]['filename']);
$attachment->mkhtml($fn,$this->upload_url.$filepath,'');
}
}
/**
* swfupload上传附件(已改)
* web uploader上传
*/
public function swfupload(){
$grouplist = getcache('grouplist','member');
$siteid = $this->get_siteid();
if(isset($_GET['dosubmit'])){
// if( $_POST['swf_auth_key'] != md5(pc_base::load_config('system','auth_key').$_POST['SWFUPLOADSESSID']) || ($_POST['isadmin']==0 && !$grouplist[$_POST['groupid']]['allowattachment'])) exit();//暂时取消判断
pc_base::load_sys_class('attachment','',0);
$siteid = get_siteid();
$attachment = new attachment($_POST['module'],$_POST['catid'],$siteid);
$attachment->set_userid($this->userid);
$site_setting = get_site_setting($siteid);
$site_allowext = $site_setting['upload_allowext'];
$aids = $attachment->upload('file',$site_allowext,'','',array($_POST['thumb_width'],$_POST['thumb_height']),$_POST['watermark_enable']);
if($aids[0]) {
$filename= (strtolower(CHARSET) != 'utf-8') ? iconv('gbk', 'utf-8', $attachment->uploadedfiles[0]['filename']) : $attachment->uploadedfiles[0]['filename'];
if($attachment->uploadedfiles[0]['isimage']) {
$res = array(
'status' => 1,
'aid' => $aids[0],
'filepath' => $this->upload_url.$attachment->uploadedfiles[0]['filepath'],
'fileext' => $attachment->uploadedfiles[0]['fileext'],
'isimage' => $attachment->uploadedfiles[0]['isimage'],
'title' => str_replace('.'.$attachment->uploadedfiles[0]['fileext'],'',$filename),
'fileimg' => $this->upload_url.$attachment->uploadedfiles[0]['filepath'],
'filename' => $filename
);
echo json_encode($res);
} else {
$fileext = $attachment->uploadedfiles[0]['fileext'];
if($fileext == 'zip' || $fileext == 'rar') $fileext = 'rar';
elseif($fileext == 'doc' || $fileext == 'docx') $fileext = 'doc';
elseif($fileext == 'xls' || $fileext == 'xlsx') $fileext = 'xls';
elseif($fileext == 'ppt' || $fileext == 'pptx') $fileext = 'ppt';
elseif ($fileext == 'flv' || $fileext == 'swf' || $fileext == 'rm' || $fileext == 'rmvb') $fileext = 'flv';
else $fileext = 'do';
$res = array(
'status' => 1,
'aid' => $aids[0],
'filepath' => $this->upload_url.$attachment->uploadedfiles[0]['filepath'],
'fileext' => $fileext,
'isimage' => $attachment->uploadedfiles[0]['isimage'],
'title' => str_replace('.'.$attachment->uploadedfiles[0]['fileext'],'',$filename),
'fileimg' => file_icon($this->upload_url.$attachment->uploadedfiles[0]['filepath']),
'filename' => $filename
);
echo json_encode($res);
}
exit;
} else {
echo '0,'.$attachment->error();
exit;
}
} else {
if($this->isadmin==0 && !$grouplist[$this->groupid]['allowattachment']) showmessage(L('att_no_permission'));
$args = $_GET['args'];
$authkey = $_GET['authkey'];
if(upload_key($args) != $authkey) showmessage(L('attachment_parameter_error'));
extract(getswfinit($_GET['args']));
$siteid = $this->get_siteid();
$site_setting = get_site_setting($siteid);
$file_size_limit = sizecount($site_setting['upload_maxsize']*1024);
$filetype = str_replace('|',',',$file_types_post);
$att_not_used = param::get_cookie('att_json');
if(empty($att_not_used) || !isset($att_not_used)) $tab_status = ' class="on"';
if(!empty($att_not_used)) $div_status = ' hidden';
//获取临时未处理文件列表
$att = $this->att_not_used();
$userid_flash=sys_auth($this->userid, 'ENCODE');
// include $this->admin_tpl('swfupload');
include $this->admin_tpl('webuploader');
}
}
/**
* 系统自带swfupload备份
*/
public function swfupload_old(){
$grouplist = getcache('grouplist','member');
if(isset($_POST['dosubmit'])){
if( $_POST['swf_auth_key'] != md5(pc_base::load_config('system','auth_key').$_POST['SWFUPLOADSESSID']) || ($_POST['isadmin']==0 && !$grouplist[$_POST['groupid']]['allowattachment'])) exit();
pc_base::load_sys_class('attachment','',0);
$attachment = new attachment($_POST['module'],$_POST['catid'],$_POST['siteid']);
$attachment->set_userid($_POST['userid']);
$siteid = get_siteid();
$site_setting = get_site_setting($siteid);
$site_allowext = $site_setting['upload_allowext'];
$aids = $attachment->upload('Filedata',$site_allowext,'','',array($_POST['thumb_width'],$_POST['thumb_height']),$_POST['watermark_enable']);
if($aids[0]) {
$filename= (strtolower(CHARSET) != 'utf-8') ? iconv('gbk', 'utf-8', $attachment->uploadedfiles[0]['filename']) : $attachment->uploadedfiles[0]['filename'];
if($attachment->uploadedfiles[0]['isimage']) {
echo $aids[0].','.$this->upload_url.$attachment->uploadedfiles[0]['filepath'].','.$attachment->uploadedfiles[0]['isimage'].','.$filename;
} else {
$fileext = $attachment->uploadedfiles[0]['fileext'];
if($fileext == 'zip' || $fileext == 'rar') $fileext = 'rar';
elseif($fileext == 'doc' || $fileext == 'docx') $fileext = 'doc';
elseif($fileext == 'xls' || $fileext == 'xlsx') $fileext = 'xls';
elseif($fileext == 'ppt' || $fileext == 'pptx') $fileext = 'ppt';
elseif ($fileext == 'flv' || $fileext == 'swf' || $fileext == 'rm' || $fileext == 'rmvb') $fileext = 'flv';
else $fileext = 'do';
echo $aids[0].','.$this->upload_url.$attachment->uploadedfiles[0]['filepath'].','.$fileext.','.$filename;
}
exit;
} else {
echo '0,'.$attachment->error();
exit;
}
} else {
if($this->isadmin==0 && !$grouplist[$this->groupid]['allowattachment']) showmessage(L('att_no_permission'));
$args = $_GET['args'];
$authkey = $_GET['authkey'];
if(upload_key($args) != $authkey) showmessage(L('attachment_parameter_error'));
extract(getswfinit($_GET['args']));
$siteid = $this->get_siteid();
$site_setting = get_site_setting($siteid);
$file_size_limit = sizecount($site_setting['upload_maxsize']*1024);
$att_no

qq_39161501
- 粉丝: 103
最新资源
- 物联网综合测试试题及答案.docx
- 基于PLC的锅炉燃烧控制系统的设计_毕业论文.doc
- 先来先服务调度算法C语言实现.doc
- Go Web编程实战派源码-Go资源
- 基于无线传感器网络技术的粮食存储环境监测系统11new.doc
- 定稿:基于单片机的电子血压计的设计确定版.doc
- 圣象地板网络营销策划案.ppt
- 解决方案第一章matlab概述.ppt
- 网络人才需求形势与职业生涯规划.pptx
- 网络公司实习报告最新9篇.docx
- Win64OpenSSL-3_5_1.zip
- 安全教育--网络安全说课件.ppt
- 高中数学-1.3算法案例三课件-新人教A版必修3.ppt
- 电子商务合作协议.doc
- 基于台达EX型PLC的X光机自动化.doc
- 绿色智能家居的研析.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



评论1