コード例 #1
0
 /**
  * 文件上传处理
  *
  * @return void
  */
 public function swfupload()
 {
     if (IS_POST) {
         $ext = 'jpg,gif,png,js,css,html,swf,zip';
         $path = $this->input->post('path');
         if (!is_dir($path)) {
             exit('0,目录(' . $path . ')不存在');
         }
         $this->load->library('upload', array('max_size' => 1024 * 1024, 'overwrite' => TRUE, 'file_name' => '', 'upload_path' => $path, 'allowed_types' => str_replace(',', '|', $ext), 'file_ext_tolower' => TRUE));
         if ($this->upload->do_upload('Filedata')) {
             $info = $this->upload->data();
             $_ext = str_replace('.', '', $info['file_ext']);
             $file = str_replace(FCPATH, '', $info['full_path']);
             if (!is_file(FCPATH . $file)) {
                 $file = SITE_URL . 'dayrui/statics/images/ext/blank.gif';
             }
             $icon = is_file(FCPATH . 'dayrui/statics/images/ext/' . $_ext . '.gif') ? SITE_URL . 'dayrui/statics/images/ext/' . $_ext . '.gif' : SITE_URL . 'dayrui/statics/images/ext/blank.gif';
             //唯一ID,文件全路径,图标,文件名称,文件大小,扩展名
             exit('1,' . $file . ',' . $icon . ',' . str_replace(array('|', '.' . $_ext), '', $info['client_name']) . ',' . dr_format_file_size($info['file_size'] * 1024) . ',' . $_ext);
         } else {
             exit('0,' . $this->upload->display_errors('', ''));
         }
     }
 }
コード例 #2
0
ファイル: system_helper.php プロジェクト: surgeon-xie/jxseo
/**
 * 附件信息
 *
 * @param	string	$key
 * @return  array
 */
function dr_file_info($key)
{
    if (!$key) {
        return NULL;
    }
    if (is_numeric($key)) {
        $info = get_attachment($key);
        if (!$info) {
            return NULL;
        }
        if (in_array($info['fileext'], array('jpg', 'gif', 'png'))) {
            $info['icon'] = SITE_URL . 'dayrui/statics/images/ext/jpg.gif';
        } else {
            $info['icon'] = is_file(FCPATH . 'dayrui/statics/images/ext/' . $info['fileext'] . '.gif') ? SITE_URL . 'dayrui/statics/images/ext/' . $info['fileext'] . '.gif' : SITE_URL . 'dayrui/statics/images/ext/blank.gif';
        }
        $info['size'] = dr_format_file_size($info['filesize']);
        return $info;
    } else {
        return array('icon' => SITE_URL . 'dayrui/statics/images/ext/url.gif', 'size' => '');
    }
}
コード例 #3
0
 private function _get_format_data($data)
 {
     if (!$data) {
         return NULL;
     }
     foreach ($data as $i => $t) {
         if ($t['remote']) {
             // 附件配置信息
             $config = $this->ci->get_cache('siteinfo', SITE_ID, 'remote', $t['remote']);
             $data[$i]['attachment'] = $config['SITE_ATTACH_URL'] . '/' . $t['attachment'];
         } else {
             $data[$i]['attachment'] = dr_file($t['attachment']);
         }
         $data[$i]['ext'] = $t['fileext'];
         if (in_array($t['fileext'], array('jpg', 'gif', 'png'))) {
             $data[$i]['show'] = $data[$i]['attachment'];
             $data[$i]['icon'] = SITE_URL . 'omooo/statics/images/ext/jpg.gif';
         } else {
             $data[$i]['show'] = is_file(FCPATH . 'omooo/statics/images/ext/' . $t['fileext'] . '.png') ? SITE_URL . 'omooo/statics/images/ext/' . $t['fileext'] . '.png' : SITE_URL . 'omooo/statics/images/ext/blank.png';
             $data[$i]['icon'] = is_file(FCPATH . 'omooo/statics/images/ext/' . $t['fileext'] . '.gif') ? SITE_URL . 'omooo/statics/images/ext/' . $t['fileext'] . '.gif' : SITE_URL . 'omooo/statics/images/ext/blank.gif';
         }
         $data[$i]['size'] = dr_format_file_size($t['filesize']);
     }
     return $data;
 }
コード例 #4
0
ファイル: D_Common.php プロジェクト: surgeon-xie/jxseo
 /**
  * 获取系统运行信息
  *
  * @return  string
  */
 public function get_system_run_info()
 {
     return dr_lang('314', $this->benchmark->elapsed_time('total_execution_time_start', 'total_execution_time_end'), count($this->db->queries), str_replace(' ', '', dr_format_file_size(memory_get_usage() / 4)));
 }
コード例 #5
0
ファイル: Api.php プロジェクト: xxjuan/php-coffee
 /**
  * Ueditor上传(图片)
  * 向浏览器返回数据json数据
  * {
  *   'url'      :'a.jpg',   //保存后的文件路径
  *   'title'    :'hello',   //文件描述,对图片来说在前端会添加到title属性上
  *   'original' :'b.jpg',   //原始文件名
  *   'state'    :'SUCCESS'  //上传状态,成功时返回SUCCESS,其他任何值将原样返回至图片上传框中
  * }
  * @return void
  */
 public function ueupload()
 {
     if (!$this->uid) {
         exit("{'url':'','title':'','original':'','state':'" . lang('m-039') . "'}");
     }
     // 是否允许上传附件
     if (!$this->member['adminid'] && !$this->member_rule['is_upload']) {
         exit("{'url':'','title':'','original':'','state':'" . lang('m-143') . "'}");
     }
     if (!$this->member['adminid'] && $this->member_rule['attachsize']) {
         // 附件总大小判断
         $data = $this->db->select_sum('filesize')->where('uid', $this->uid)->get('attachment')->row_array();
         $filesize = (int) $data['filesize'];
         if ($filesize > $this->member_rule['attachsize'] * 1024 * 1024) {
             exit("{'url':'','title':'','original':'','state':'" . dr_lang('m-147', $this->member_rule['attachsize'] . 'MB', dr_format_file_size($filesize)) . "'}");
         }
     }
     $path = FCPATH . 'member/uploadfile/' . date('Ym', SYS_TIME) . '/';
     if (!is_dir($path)) {
         dr_mkdirs($path);
     }
     $type = $this->input->get('type');
     $_ext = $type == 'img' ? 'gif|jpg|png' : 'gz|7z|tar|ppt|pptx|xls|xlsx|rar|doc|docx|zip|pdf|txt|swf|mkv|avi|rm|rmvb|mpeg|mpg|ogg|mov|wmv|mp4|webm';
     $this->load->library('upload', array('max_size' => '999999', 'overwrite' => FALSE, 'file_name' => substr(md5(time()), 0, 10), 'upload_path' => $path, 'allowed_types' => $_ext));
     if ($this->upload->do_upload('upfile')) {
         $info = $this->upload->data();
         $this->load->model('attachment_model');
         $result = $this->attachment_model->upload($this->uid, $info);
         if (!is_array($result)) {
             exit('0,' . $result);
         }
         list($id, $file, $_ext) = $result;
         $url = $type == 'file' ? dr_down_file($id) : dr_file($file);
         $title = htmlspecialchars($this->input->post('pictitle', TRUE), ENT_QUOTES);
         exit("{'id':'" . $id . "','fileType':'." . $_ext . "', 'url':'" . $url . "','title':'" . $title . "','original':'" . str_replace('|', '_', $info['client_name']) . "','state':'SUCCESS'}");
     } else {
         exit("{'url':'','title':'','original':'','state':'" . $this->upload->display_errors('', '') . "'}");
     }
 }
コード例 #6
0
ファイル: controller.php プロジェクト: xxjuan/php-coffee
// 验证用户
if (!$this->uid) {
    echo json_encode(array('state' => lang('m-039')));
    exit;
}
// 是否允许上传附件
if (!$this->member['adminid'] && !$this->member_rule['is_upload']) {
    echo json_encode(array('state' => lang('m-143')));
    exit;
}
// 附件总大小判断
if (!$this->member['adminid'] && $this->member_rule['attachsize']) {
    $data = $this->db->select_sum('filesize')->where('uid', $this->uid)->get('attachment')->row_array();
    $filesize = (int) $data['filesize'];
    if ($filesize > $this->member_rule['attachsize'] * 1024 * 1024) {
        echo json_encode(array('state' => dr_lang('m-147', $this->member_rule['attachsize'] . 'MB', dr_format_file_size($filesize))));
        exit;
    }
}
// 上传目录
define('DR_UE_PATH', 'member/uploadfile/ueditor/' . date('Ym', SYS_TIME) . '/');
if (!is_dir(FCPATH . DR_UE_PATH)) {
    dr_mkdirs(FCPATH . DR_UE_PATH);
}
$CONFIG = json_decode(preg_replace("/\\/\\*[\\s\\S]+?\\*\\//", "", file_get_contents("config.json")), true);
$action = $_GET['action'];
switch ($action) {
    case 'config':
        $result = json_encode($CONFIG);
        break;
        /* 上传图片 */
コード例 #7
0
ファイル: Mform.php プロジェクト: xxjuan/php-coffee
 public function import()
 {
     if (IS_POST) {
         $file = FCPATH . $this->dir . '/config/form.php';
         if (!is_file($file)) {
             $this->admin_msg(dr_lang('335', $this->dir . '/config/form.php'));
         }
         $this->load->model('module_model');
         if ($this->module_model->import_form($this->dir)) {
             $this->admin_msg(lang('014'), dr_url('mform/index', array('dir' => $this->dir)), 2);
         } else {
             $this->admin_msg(lang('336'));
         }
     }
     $this->template->assign('size', dr_format_file_size(@filesize(FCPATH . $this->dir . '/config/form.php')));
     $this->template->display('mform_import.html');
 }