Esempio n. 1
0
 /**
  * 上传帖子图片(正常的附件目录)
  * 
  * @param mixed $uid        Description.
  * @param mixed $allowValue Description.
  *
  * @access private
  *
  * @return mixed Value.
  */
 private function _uploadAttach($uid, $allowValue)
 {
     global $_G;
     $fileExtension = FileUtils::getFileExtension($_FILES['uploadFile']['name'][$allowValue], 'jpg');
     $type = 'forum';
     $extid = 0;
     $forcename = '';
     Yii::import('application.components.discuz.source.class.discuz.discuz_upload', true);
     $upload = new Mobcent_upload();
     $attach['extension'] = $fileExtension;
     $attach['attachdir'] = $upload->get_target_dir($type, $extid);
     $filename = $upload->get_target_filename($type, $extid, $forcename) . '.' . $attach['extension'];
     $attach['attachment'] = $attach['attachdir'] . $filename;
     $attach['target'] = getglobal('setting/attachdir') . './' . $type . '/' . $attach['attachment'];
     $savePath = getglobal('setting/attachdir') . './' . $type . '/' . $attach['attachdir'];
     if (!is_dir($savePath)) {
         mkdir($savePath, 0777, true);
     }
     $remote = $width = $thumb = 0;
     $res = array();
     $saveName = $savePath . $filename;
     if (move_uploaded_file($_FILES['uploadFile']['tmp_name'][$allowValue], $saveName)) {
         $aid = getattachnewaid($uid);
         $img_info = getimagesize($attach['target']);
         $size = filesize($attach['target']);
         $insert = array('aid' => $aid, 'dateline' => $_G['timestamp'], 'filename' => $filename, 'filesize' => $size, 'attachment' => $attach['attachment'], 'isimage' => 1, 'uid' => $uid, 'thumb' => $thumb, 'remote' => $remote, 'width' => $img_info[0]);
         C::t('forum_attachment_unused')->insert($insert);
         // 添加水印
         Yii::import('application.components.discuz.source.class.class_image', true);
         $image = new Mobcent_Image();
         if ($image->param['watermarkstatus']['forum'] > 0) {
             $image->makeWatermark($attach['target'], '', 'forum');
         }
         $path_url = ImageUtils::getAttachUrl() . '/' . $type . '/' . $attach['attachment'];
         ImageUtils::getThumbImageEx($path_url, 10, false, false, true);
         $res['id'] = $aid;
         $res['urlName'] = $path_url;
     }
     return $res;
 }
Esempio n. 2
0
                     }
                     if ($_G['setting']['thumbstatus']) {
                         $image = new image();
                         $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], 0) ? 1 : 0;
                         $width = $image->imginfo['width'];
                     }
                     if ($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) {
                         list($width) = @getimagesize($upload->attach['target']);
                     }
                     if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
                         $image = new image();
                         $image->Watermark($attach['target'], '', 'forum');
                         $upload->attach['size'] = $image->imginfo['size'];
                     }
                 }
                 $aids[] = $aid = getattachnewaid();
                 $setarr = array('aid' => $aid, 'dateline' => $_G['timestamp'], 'filename' => $upload->attach['name'], 'filesize' => $upload->attach['size'], 'attachment' => $upload->attach['attachment'], 'isimage' => $upload->attach['isimage'], 'uid' => $_G['uid'], 'thumb' => $thumb, 'remote' => '0', 'width' => $width);
                 C::t("forum_attachment_unused")->insert($setarr);
                 $attachaids[$hash] = $imagereplace['newimageurl'][] = '[attachimg]' . $aid . '[/attachimg]';
             } else {
                 $imagereplace['newimageurl'][] = $attachaids[$hash];
             }
         }
     }
     if (!empty($aids)) {
         require_once libfile('function/post');
     }
     $_GET['message'] = str_replace($imagereplace['oldimageurl'], $imagereplace['newimageurl'], $_GET['message']);
 }
 $_GET['message'] = addcslashes($_GET['message'], '/"\'');
 print <<<EOF
 function forum_upload()
 {
     global $_G;
     $_G['uid'] = $this->uid = intval($_G['gp_uid']);
     $swfhash = md5(substr(md5($_G['config']['security']['authkey']), 8) . $this->uid);
     $this->aid = 0;
     $this->simple = !empty($_G['gp_simple']) ? $_G['gp_simple'] : 0;
     if ($_G['gp_hash'] != $swfhash) {
         $this->uploadmsg(10);
     }
     $_G['groupid'] = intval(DB::result_first("SELECT groupid FROM " . DB::table('common_member') . " WHERE uid='" . $this->uid . "'"));
     loadcache('usergroup_' . $_G['groupid']);
     $_G['group'] = $_G['cache']['usergroup_' . $_G['groupid']];
     require_once libfile('class/upload');
     $upload = new discuz_upload();
     $upload->init($_FILES['Filedata'], 'forum');
     $this->attach =& $upload->attach;
     if ($upload->error()) {
         $this->uploadmsg(2);
     }
     $allowupload = !$_G['group']['maxattachnum'] || $_G['group']['maxattachnum'] && $_G['group']['maxattachnum'] > getuserprofile('todayattachs');
     if (!$allowupload) {
         $this->uploadmsg(6);
     }
     if ($_G['group']['attachextensions'] && (!preg_match("/(^|\\s|,)" . preg_quote($upload->attach['ext'], '/') . "(\$|\\s|,)/i", $_G['group']['attachextensions']) || !$upload->attach['ext'])) {
         $this->uploadmsg(1);
     }
     if (empty($upload->attach['size'])) {
         $this->uploadmsg(2);
     }
     if ($_G['group']['maxattachsize'] && $upload->attach['size'] > $_G['group']['maxattachsize']) {
         $this->error_sizelimit = $_G['group']['maxattachsize'];
         $this->uploadmsg(3);
     }
     if ($type = DB::fetch_first("SELECT maxsize FROM " . DB::table('forum_attachtype') . " WHERE extension='" . addslashes($upload->attach['ext']) . "'")) {
         if ($type['maxsize'] == 0) {
             $this->error_sizelimit = 'ban';
             $this->uploadmsg(4);
         } elseif ($upload->attach['size'] > $type['maxsize']) {
             $this->error_sizelimit = $type['maxsize'];
             $this->uploadmsg(5);
         }
     }
     if ($upload->attach['size'] && $_G['group']['maxsizeperday']) {
         $todaysize = getuserprofile('todayattachsize') + $upload->attach['size'];
         if ($todaysize >= $_G['group']['maxsizeperday']) {
             $this->error_sizelimit = 'perday|' . $_G['group']['maxsizeperday'];
             $this->uploadmsg(11);
         }
     }
     updatemembercount($_G['uid'], array('todayattachs' => 1, 'todayattachsize' => $upload->attach['size']));
     $upload->save();
     if ($upload->error() == -103) {
         $this->uploadmsg(8);
     } elseif ($upload->error()) {
         $this->uploadmsg(9);
     }
     $thumb = $remote = $width = 0;
     if ($_G['gp_type'] == 'image' && !$upload->attach['isimage']) {
         $this->uploadmsg(7);
     }
     if ($upload->attach['isimage']) {
         if ($_G['setting']['thumbstatus']) {
             require_once libfile('class/image');
             $image = new image();
             $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], $_G['setting']['thumbsource']) ? 1 : 0;
             $width = $image->imginfo['width'];
         }
         if ($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) {
             list($width) = @getimagesize($upload->attach['target']);
         }
     }
     if ($_G['gp_type'] != 'image' && $upload->attach['isimage']) {
         $upload->attach['isimage'] = -1;
     }
     $this->aid = $aid = getattachnewaid($this->uid);
     DB::query("INSERT INTO " . DB::table('forum_attachment_unused') . " (aid, dateline, filename, filesize, attachment, isimage, uid, thumb, remote, width)\r\n\t\t\tVALUES ('{$aid}', '{$_G['timestamp']}', '" . $upload->attach['name'] . "', '" . $upload->attach['size'] . "', '" . $upload->attach['attachment'] . "', '" . $upload->attach['isimage'] . "', '" . $this->uid . "', '{$thumb}', '{$remote}', '{$width}')");
     $this->uploadmsg(0);
 }
$filesize = isset($_REQUEST['filesize']) ? $_REQUEST['filesize'] : '';
$width = isset($_REQUEST['width']) ? $_REQUEST['width'] : 0;
$cover = isset($_REQUEST['cover']) ? $_REQUEST['cover'] : 0;
if ($res['err'] != 1) {
    $path = '../data/attachment/forum/';
    $attachments = 'ios/' . date('YmdHsi') . md5(time()) . '.jpg';
    //$s=base64_decode($s);
    //file_put_contents($path .$attachments, $s);
    if (isset($_FILES['pic'])) {
        move_uploaded_file($_FILES["pic"]["tmp_name"], $path . $attachments);
    } else {
        $res['err'] = 1;
        echo json_encode($res);
        exit;
    }
    $aid = getattachnewaid($uid);
    $update = array();
    $update['aid'] = $aid;
    $update['tid'] = $tid;
    $update['pid'] = $pid;
    $update['uid'] = $uid;
    $update['dateline'] = time();
    $update['filename'] = $filename;
    $update['filesize'] = $filesize;
    $update['attachment'] = $attachments;
    $update['description'] = censor(cutstr(dhtmlspecialchars($description), 100));
    $update['readperm'] = 0;
    $update['price'] = 0;
    $update['isimage'] = 1;
    $update['width'] = $width;
    $update['thumb'] = 0;
 function sanree_common_upload($bid)
 {
     global $_G, $config;
     $this->uid = $_G['uid'];
     $where = ' AND uid=' . $_G['uid'];
     $maxpiccount = intval($config['maxpiccount']);
     if ($maxpiccount > 0 && $_G['uid'] != 1) {
         $piccount = C::t('#sanree_brand#sanree_brand_attachment')->count_by_where($where);
         if ($piccount > $maxpiccount) {
             $this->uploadmsg(12);
         }
     }
     $swfhash = md5(substr(md5($_G['config']['security']['authkey']), 8) . $this->uid);
     $this->aid = 0;
     $this->simple = 2;
     if ($_GET['hash'] != $swfhash) {
         $this->uploadmsg(10);
     }
     $appVer = $_G['setting']['version'];
     if ($appVer == 'X2') {
         require_once libfile('class/upload');
     }
     $upload = new discuz_upload();
     if (!$config['isbird']) {
         $upload->init($_FILES['Filedata'], 'common');
     } else {
         $file = 'Filedata' . $_G['sr_newbanner'];
         $upload->init($_FILES[$file], 'category');
         $this->newbanner_flag = $_G['sr_newbanner'];
     }
     $this->attach =& $upload->attach;
     if ($upload->error()) {
         $this->uploadmsg(2);
     }
     $allowupload = !$_G['group']['maxattachnum'] || $_G['group']['maxattachnum'] && $_G['group']['maxattachnum'] > getuserprofile('todayattachs');
     if (!$allowupload) {
         $this->uploadmsg(6);
     }
     if ($_G['group']['attachextensions'] && (!preg_match("/(^|\\s|,)" . preg_quote($upload->attach['ext'], '/') . "(\$|\\s|,)/i", $_G['group']['attachextensions']) || !$upload->attach['ext'])) {
         $this->uploadmsg(1);
     }
     if (empty($upload->attach['size'])) {
         $this->uploadmsg(2);
     }
     if ($_G['group']['maxattachsize'] && $upload->attach['size'] > $_G['group']['maxattachsize']) {
         $this->error_sizelimit = $_G['group']['maxattachsize'];
         $this->uploadmsg(3);
     }
     loadcache('attachtype');
     if ($_G['fid'] && isset($_G['cache']['attachtype'][$_G['fid']][$upload->attach['ext']])) {
         $maxsize = $_G['cache']['attachtype'][$_G['fid']][$upload->attach['ext']];
     } elseif (isset($_G['cache']['attachtype'][0][$upload->attach['ext']])) {
         $maxsize = $_G['cache']['attachtype'][0][$upload->attach['ext']];
     }
     if (isset($maxsize)) {
         if (!$maxsize) {
             $this->error_sizelimit = 'ban';
             $this->uploadmsg(4);
         } elseif ($upload->attach['size'] > $maxsize) {
             $this->error_sizelimit = $maxsize;
             $this->uploadmsg(5);
         }
     }
     if ($upload->attach['size'] && $_G['group']['maxsizeperday']) {
         $todaysize = getuserprofile('todayattachsize') + $upload->attach['size'];
         if ($todaysize >= $_G['group']['maxsizeperday']) {
             $this->error_sizelimit = 'perday|' . $_G['group']['maxsizeperday'];
             $this->uploadmsg(11);
         }
     }
     updatemembercount($_G['uid'], array('todayattachs' => 1, 'todayattachsize' => $upload->attach['size']));
     $upload->save();
     if ($upload->error() == -103) {
         $this->uploadmsg(8);
     } elseif ($upload->error()) {
         $this->uploadmsg(9);
     }
     $thumb = $remote = $width = 0;
     if (!$upload->attach['isimage']) {
         $this->uploadmsg(7);
     }
     if ($upload->attach['isimage']) {
         if ($_G['setting']['showexif']) {
             require_once libfile('function/attachment');
             $exif = getattachexif(0, $upload->attach['target']);
         }
         if ($_G['setting']['thumbsource'] || $_G['setting']['thumbstatus']) {
             require_once libfile('class/image');
             $image = new image();
         }
         if ($_G['setting']['thumbsource'] && $_G['setting']['sourcewidth'] && $_G['setting']['sourceheight']) {
             $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['sourcewidth'], $_G['setting']['sourceheight'], 1, 1) ? 1 : 0;
             $width = $image->imginfo['width'];
             $upload->attach['size'] = $image->imginfo['size'];
         }
         if ($_G['setting']['thumbstatus']) {
             $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], 0) ? 1 : 0;
             $width = $image->imginfo['width'];
         }
         if ($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) {
             list($width) = @getimagesize($upload->attach['target']);
         }
     }
     $this->aid = $aid = getattachnewaid($this->uid);
     $insert = array('aid' => $aid, 'dateline' => $_G['timestamp'], 'filename' => censor($upload->attach['name']), 'filesize' => $upload->attach['size'], 'attachment' => $upload->attach['attachment'], 'isimage' => $upload->attach['isimage'], 'uid' => $this->uid, 'thumb' => $thumb, 'remote' => $remote, 'width' => $width);
     ///C::t('forum_attachment_unused')->insert($insert);
     C::t('#sanree_brand#sanree_brand_attachment')->insert($insert);
     $result = C::t('#sanree_brand#sanree_brand_businesses')->getusername_by_bidanduid($_G['uid'], $bid);
     if ($result['banner']) {
         @unlink($_G['setting']['attachdir'] . 'common/' . $result['banner']);
     }
     if (!$config['isbird']) {
         $setarr = array();
         $setarr['banner'] = $upload->attach['attachment'];
         C::t('#sanree_brand#sanree_brand_businesses')->update($bid, $setarr);
     } else {
         $newbanner = explode(',', $result['newbanner']);
         $newbanner[$_G['sr_newbanner']] = $upload->attach['attachment'];
         $setarr = array();
         $setarr['newbanner'] = implode(',', $newbanner);
         C::t('#sanree_brand#sanree_brand_businesses')->update($bid, $setarr);
     }
     if ($upload->attach['isimage'] && $_G['setting']['showexif']) {
         ///C::t('forum_attachment_exif')->insert($aid, $exif);
     }
     $this->uploadmsg(0);
 }
 function forum_upload()
 {
     global $_G;
     $_G['uid'] = $this->uid = intval($_GET['uid']);
     $swfhash = md5(substr(md5($_G['config']['security']['authkey']), 8) . $this->uid);
     $this->aid = 0;
     $this->simple = !empty($_GET['simple']) ? $_GET['simple'] : 0;
     if ($_GET['hash'] != $swfhash) {
         $this->uploadmsg(10);
     }
     $upload = new discuz_upload();
     $upload->init($_FILES['Filedata'], 'forum');
     $this->attach =& $upload->attach;
     if ($upload->error()) {
         $this->uploadmsg(2);
     }
     $allowupload = !$_G['group']['maxattachnum'] || $_G['group']['maxattachnum'] && $_G['group']['maxattachnum'] > getuserprofile('todayattachs');
     if (!$allowupload) {
         $this->uploadmsg(6);
     }
     if ($_G['group']['attachextensions'] && (!preg_match("/(^|\\s|,)" . preg_quote($upload->attach['ext'], '/') . "(\$|\\s|,)/i", $_G['group']['attachextensions']) || !$upload->attach['ext'])) {
         $this->uploadmsg(1);
     }
     if (empty($upload->attach['size'])) {
         $this->uploadmsg(2);
     }
     if ($_G['group']['maxattachsize'] && $upload->attach['size'] > $_G['group']['maxattachsize']) {
         $this->error_sizelimit = $_G['group']['maxattachsize'];
         $this->uploadmsg(3);
     }
     loadcache('attachtype');
     if ($_G['fid'] && isset($_G['cache']['attachtype'][$_G['fid']][$upload->attach['ext']])) {
         $maxsize = $_G['cache']['attachtype'][$_G['fid']][$upload->attach['ext']];
     } elseif (isset($_G['cache']['attachtype'][0][$upload->attach['ext']])) {
         $maxsize = $_G['cache']['attachtype'][0][$upload->attach['ext']];
     }
     if (isset($maxsize)) {
         if (!$maxsize) {
             $this->error_sizelimit = 'ban';
             $this->uploadmsg(4);
         } elseif ($upload->attach['size'] > $maxsize) {
             $this->error_sizelimit = $maxsize;
             $this->uploadmsg(5);
         }
     }
     if ($upload->attach['size'] && $_G['group']['maxsizeperday']) {
         $todaysize = getuserprofile('todayattachsize') + $upload->attach['size'];
         if ($todaysize >= $_G['group']['maxsizeperday']) {
             $this->error_sizelimit = 'perday|' . $_G['group']['maxsizeperday'];
             $this->uploadmsg(11);
         }
     }
     updatemembercount($_G['uid'], array('todayattachs' => 1, 'todayattachsize' => $upload->attach['size']));
     $upload->save();
     if ($upload->error() == -103) {
         $this->uploadmsg(8);
     } elseif ($upload->error()) {
         $this->uploadmsg(9);
     }
     $thumb = $remote = $width = 0;
     if ($_GET['type'] == 'image' && !$upload->attach['isimage']) {
         $this->uploadmsg(7);
     }
     if ($upload->attach['isimage']) {
         if ($_G['setting']['showexif']) {
             require_once libfile('function/attachment');
             $exif = getattachexif(0, $upload->attach['target']);
         }
         if ($_G['setting']['thumbsource'] || $_G['setting']['thumbstatus']) {
             require_once libfile('class/image');
             $image = new image();
         }
         if ($_G['setting']['thumbsource'] && $_G['setting']['sourcewidth'] && $_G['setting']['sourceheight']) {
             $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['sourcewidth'], $_G['setting']['sourceheight'], 1, 1) ? 1 : 0;
             $width = $image->imginfo['width'];
             $upload->attach['size'] = $image->imginfo['size'];
         }
         if ($_G['setting']['thumbstatus']) {
             $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], 0) ? 1 : 0;
             $width = $image->imginfo['width'];
         }
         if ($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) {
             list($width) = @getimagesize($upload->attach['target']);
         }
     }
     if ($_GET['type'] != 'image' && $upload->attach['isimage']) {
         $upload->attach['isimage'] = -1;
     }
     $this->aid = $aid = getattachnewaid($this->uid);
     $insert = array('aid' => $aid, 'dateline' => $_G['timestamp'], 'filename' => censor($upload->attach['name']), 'filesize' => $upload->attach['size'], 'attachment' => $upload->attach['attachment'], 'isimage' => $upload->attach['isimage'], 'uid' => $this->uid, 'thumb' => $thumb, 'remote' => $remote, 'width' => $width);
     C::t('forum_attachment_unused')->insert($insert);
     if ($upload->attach['isimage'] && $_G['setting']['showexif']) {
         C::t('forum_attachment_exif')->insert($aid, $exif);
     }
     $this->uploadmsg(0);
 }
Esempio n. 7
0
function myupload_icon_banner($bid, &$data, $file, $uid)
{
    global $_G;
    $data['extid'] = empty($data['extid']) ? $data['fid'] : $data['extid'];
    if (empty($data['extid'])) {
        return '';
    }
    if ($data['status'] == 3 && $_G['setting']['group_imgsizelimit']) {
        $file['size'] > $_G['setting']['group_imgsizelimit'] * 1024 && showmessage('file_size_overflow', '', array('size' => $_G['setting']['group_imgsizelimit'] * 1024));
    }
    $appVer = $_G['setting']['version'];
    if ($appVer == 'X2') {
        require_once libfile('class/upload');
    }
    $upload = new discuz_upload();
    if (!$upload->init($file, 'category')) {
        return false;
    }
    if (!$upload->save()) {
        if (!defined('IN_ADMINCP')) {
            showmessage($upload->errormessage());
        } else {
            cpmsg($upload->errormessage(), '', 'error');
        }
    }
    $aid = getattachnewaid($uid);
    $insert = array('aid' => $aid, 'dateline' => $_G['timestamp'], 'filename' => censor($upload->attach['name']), 'filesize' => $upload->attach['size'], 'attachment' => $upload->attach['attachment'], 'isimage' => $upload->attach['isimage'], 'uid' => $uid, 'thumb' => $thumb, 'remote' => $remote, 'width' => $width);
    C::t('#sanree_brand#sanree_brand_attachment')->insert($insert);
    return array($upload->attach['attachment'], $aid);
}