Example #1
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;
 }
/**
 * 文件真实地址
 *
 * @param	string	$id
 * @return  array
 */
function dr_get_file($id)
{
    if (!$id) {
        return '';
    }
    if (is_numeric($id)) {
        // 表示附件id
        $info = get_attachment($id);
        $id = $info['attachment'] ? $info['attachment'] : '';
    }
    $file = dr_file($id);
    return $file ? $file : '';
}
    /* 列出图片 */
    case 'listimage':
    default:
        $allowFiles = $CONFIG['imageManagerAllowFiles'];
        $listSize = $CONFIG['imageManagerListSize'];
        $path = $CONFIG['imageManagerListPath'];
}
$allowFiles = substr(str_replace(".", ",", join("", $allowFiles)), 1);
/* 获取参数 */
$size = isset($_GET['size']) ? $_GET['size'] : $listSize;
$start = isset($_GET['start']) ? $_GET['start'] : 0;
$end = $start + $size;
/* 获取文件列表 */
$this->load->model('attachment_model');
$this->attachment_model->siteid = max(1, (int) $this->input->get('siteid'));
$result = $this->attachment_model->upload($uid, $info);
$this->load->model('attachment_model');
$data = $this->attachment_model->get_unused($this->uid, $allowFiles);
if (!$data) {
    return json_encode(array("state" => "no match file", "list" => array(), "start" => $start, "total" => count($files)));
}
$files = array();
foreach ($data as $t) {
    $files[] = array('id' => 'finecms_img_' . $t['id'], 'url' => dr_file($t['attachment']), 'mtime' => $t['inputtime']);
}
if (!count($files)) {
    return json_encode(array("state" => "no match file", "list" => array(), "start" => $start, "total" => count($files)));
}
/* 返回数据 */
$result = json_encode(array("state" => "SUCCESS", "list" => $files, "start" => $start, "total" => count($files)));
return $result;
Example #4
0
 /**
  * Ueditor未使用的图片
  * 图片id|地址一ue_separate_ue图片id|地址二ue_separate_ue图片id|地址三
  * @return void
  */
 public function uemanager()
 {
     if (!$this->uid) {
         return NULL;
     }
     $this->load->model('attachment_model');
     $data = $this->attachment_model->get_unused($this->uid, 'jpg,png,gif');
     if (!$data) {
         return NULL;
     }
     $result = array();
     foreach ($data as $t) {
         $result[] = dr_file($t['attachment']) . '?dr_image_id=' . $t['id'];
     }
     echo implode('ue_separate_ue', $result);
 }
 /**
  * 字段入库值
  */
 public function insert_value($field)
 {
     $value = $this->ci->post[$field['fieldname']];
     // 下载远程图片
     if (preg_match_all("/(src)=([\"|']?)([^ \"'>]+\\.(gif|jpg|jpeg|png))\\2/i", $value, $imgs)) {
         $uid = isset($this->ci->_data['uid']) ? $this->ci->_data['uid'] : $this->ci->uid;
         $down = FALSE;
         // 附件总大小判断
         if ($uid && $uid == $this->ci->uid && !$this->ci->member['adminid'] && $this->ci->member_rule['attachsize']) {
             $data = $this->ci->db->select_sum('filesize')->where('uid', $uid)->get($this->ci->db->dbprefix('attachment'))->row_array();
             if ($filesize <= $this->ci->member_rule['attachsize'] * 1024 * 1024) {
                 $down = TRUE;
             }
         }
         // 开始下载远程图片
         if ($down) {
             $this->ci->load->model('attachment_model');
             foreach ($imgs[3] as $i => $img) {
                 if ($uid && (strpos($img, SITE_URL) === FALSE || strpos($img, SITE_ATTACH_URL) === FALSE)) {
                     $result = $this->ci->attachment_model->catcher($uid, $img);
                     if (is_array($result)) {
                         list($id, $file, $_ext) = $result;
                         $value = str_replace($imgs[0][$i], " id=\"{$id}\" src=\"" . dr_file($file) . "\"", $value);
                     }
                 }
             }
         }
     }
     // 第一张作为缩略图
     if (isset($this->ci->post['thumb']) && (!($thumb = dr_string2array($this->ci->data[1]['thumb'])) || !$thumb['file']) && preg_match("/(src)=([\"|']?)([^ \"'>]+\\.(gif|jpg|jpeg|png))\\2/Ui", $value, $img)) {
         $this->ci->data[1]['thumb'] = $img[3];
     }
     // 描述截取
     if (isset($this->ci->post['description']) && !$this->ci->data[1]['description']) {
         $this->ci->data[1]['description'] = str_replace(array(' ', PHP_EOL, '  '), '', dr_strcut(dr_clearhtml($value), 200));
     }
     $this->ci->data[$field['ismain']][$field['fieldname']] = $value;
 }
Example #6
0
 /**
  * 字段入库值
  */
 public function insert_value($field)
 {
     $value = $this->ci->post[$field['fieldname']];
     $value = str_replace('class="pagebreak" name="dr_page_break"', 'name="dr_page_break" class="pagebreak"', $value);
     $value = str_replace('name="dr_page_break" class="pagebreak"', 'class="pagebreak"', $value);
     $value = str_replace('id="undefined"', '', $value);
     $attach = array();
     // 下载远程图片
     if ($field['fieldname'] == 'content' && preg_match_all("/(src)=([\"|']?)([^ \"'>]+\\.(gif|jpg|jpeg|png))\\2/i", $value, $imgs)) {
         $uid = isset($_POST['data']['uid']) ? (int) $_POST['data']['uid'] : $this->ci->uid;
         $down = FALSE;
         // 附件总大小判断
         if ($uid == $this->ci->uid && ($this->ci->member['adminid'] || $this->ci->member_rule['attachsize'])) {
             $data = $this->ci->db->select_sum('filesize')->where('uid', $uid)->get('attachment')->row_array();
             if ($this->ci->member['adminid'] || $data['filesize'] <= $this->ci->member_rule['attachsize'] * 1024 * 1024) {
                 $down = TRUE;
             }
         }
         $this->ci->load->model('attachment_model');
         foreach ($imgs[3] as $i => $img) {
             $timg = 1;
             // 开始下载远程图片
             if ($down && $uid) {
                 $result = $this->ci->attachment_model->catcher($uid, $img);
                 if (is_array($result)) {
                     list($id, $file, $_ext) = $result;
                     $timg = 0;
                     $value = str_replace($imgs[0][$i], " id=\"finecms_img_{$id}\" src=\"" . dr_file($file) . "\"", $value);
                     $attach[] = $id;
                 }
             }
             // 当不下载图片
             if ($timg) {
                 if (preg_match('/<img id="finecms_img_([0-9]+)"([\\w|\\s|=\\."]*)src="' . str_replace('/', '\\/', $img) . '"/iU', $value, $match)) {
                     $attach[] = (int) $match[1];
                 } elseif (preg_match('/<img src="' . str_replace('/', '\\/', $img) . '"(.*)id="finecms_img_([0-9]+)"/iU', $value, $match)) {
                     $attach[] = (int) $match[2];
                 } else {
                     if (strpos($img, 'ueditor142') === FALSE) {
                         $attach[] = $img;
                     }
                 }
             }
         }
     }
     //
     // 第一张作为缩略图
     if ($field['fieldname'] == 'content' && isset($_POST['data']['thumb']) && !$_POST['data']['thumb']) {
         if ($attach) {
             $this->ci->data[1]['thumb'] = $attach[0];
         } else {
             // 筛选是否存在图片
             if (preg_match("/index\\.php\\?c=api&m=thumb&id=([0-9]+)&/U", $value, $img)) {
                 $this->ci->data[1]['thumb'] = intval($img[1]);
             }
         }
     }
     $this->ci->data[$field['ismain']][$field['fieldname']] = $value;
 }