function common()
 {
     global $_G;
     if (empty($_G['uid'])) {
         self::error('api_uploadavatar_unavailable_user');
     }
     if (empty($_FILES['Filedata'])) {
         self::error('api_uploadavatar_unavailable_pic');
     }
     list($width, $height, $type, $attr) = getimagesize($_FILES['Filedata']['tmp_name']);
     $imgtype = array(1 => '.gif', 2 => '.jpg', 3 => '.png');
     $filetype = $imgtype[$type];
     if (!$filetype) {
         $filetype = '.jpg';
     }
     $avatarpath = $_G['setting']['attachdir'];
     $tmpavatar = $avatarpath . './temp/upload' . $_G['uid'] . $filetype;
     file_exists($tmpavatar) && @unlink($tmpavatar);
     if (@copy($_FILES['Filedata']['tmp_name'], $tmpavatar) || @move_uploaded_file($_FILES['Filedata']['tmp_name'], $tmpavatar)) {
         @unlink($_FILES['Filedata']['tmp_name']);
         list($width, $height, $type, $attr) = getimagesize($tmpavatar);
         if ($width < 10 || $height < 10 || $type == 4) {
             @unlink($tmpavatar);
             self::error('api_uploadavatar_unusable_image');
         }
     } else {
         @unlink($_FILES['Filedata']['tmp_name']);
         self::error('api_uploadavatar_service_unwritable');
     }
     $tmpavatarbig = './temp/upload' . $_G['uid'] . 'big' . $filetype;
     $tmpavatarmiddle = './temp/upload' . $_G['uid'] . 'middle' . $filetype;
     $tmpavatarsmall = './temp/upload' . $_G['uid'] . 'small' . $filetype;
     $image = new image();
     if ($image->Thumb($tmpavatar, $tmpavatarbig, 200, 250, 1) <= 0) {
         //$image->error();
         self::error('api_uploadavatar_unusable_image');
     }
     if ($image->Thumb($tmpavatar, $tmpavatarmiddle, 120, 120, 1) <= 0) {
         //$image->error();
         self::error('api_uploadavatar_unusable_image');
     }
     if ($image->Thumb($tmpavatar, $tmpavatarsmall, 48, 48, 2) <= 0) {
         //$image->error();
         self::error('api_uploadavatar_unusable_image');
     }
     $this->tmpavatar = $tmpavatar;
     $this->tmpavatarbig = $avatarpath . $tmpavatarbig;
     $this->tmpavatarmiddle = $avatarpath . $tmpavatarmiddle;
     $this->tmpavatarsmall = $avatarpath . $tmpavatarsmall;
 }
 function common()
 {
     global $_G;
     if (!defined('IN_DISCUZ') || empty($_GET['aid']) || empty($_GET['size']) || empty($_GET['key'])) {
         header('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
         exit;
     }
     $allowsize = array('960x960', '268x380', '266x698', '2000x2000');
     if (!in_array($_GET['size'], $allowsize)) {
         header('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
         exit;
     }
     $nocache = !empty($_GET['nocache']) ? 1 : 0;
     $daid = intval($_GET['aid']);
     $type = !empty($_GET['type']) ? $_GET['type'] : 'fixwr';
     list($w, $h) = explode('x', $_GET['size']);
     $dw = intval($w);
     $dh = intval($h);
     $thumbfile = 'image/' . $daid . '_' . $dw . '_' . $dh . '.jpg';
     $parse = parse_url($_G['setting']['attachurl']);
     $attachurl = !isset($parse['host']) ? $_G['siteurl'] . $_G['setting']['attachurl'] : $_G['setting']['attachurl'];
     if (!$nocache) {
         if (file_exists($_G['setting']['attachdir'] . $thumbfile)) {
             dheader('location: ' . $attachurl . $thumbfile);
         }
     }
     define('NOROBOT', TRUE);
     $id = !empty($_GET['atid']) ? $_GET['atid'] : $daid;
     if (md5($id . '|' . $dw . '|' . $dh) != $_GET['key']) {
         dheader('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
     }
     if ($attach = C::t('forum_attachment_n')->fetch('aid:' . $daid, $daid, array(1, -1))) {
         if (!$dw && !$dh && $attach['tid'] != $id) {
             dheader('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
         }
         dheader('Expires: ' . gmdate('D, d M Y H:i:s', TIMESTAMP + 3600) . ' GMT');
         if ($attach['remote']) {
             $filename = $_G['setting']['ftp']['attachurl'] . 'forum/' . $attach['attachment'];
         } else {
             $filename = $_G['setting']['attachdir'] . 'forum/' . $attach['attachment'];
         }
         require_once libfile('class/image');
         $img = new image();
         if ($img->Thumb($filename, $thumbfile, $w, $h, $type)) {
             if ($nocache) {
                 dheader('Content-Type: image');
                 @readfile($_G['setting']['attachdir'] . $thumbfile);
                 @unlink($_G['setting']['attachdir'] . $thumbfile);
             } else {
                 dheader('location: ' . $attachurl . $thumbfile);
             }
         } else {
             dheader('Content-Type: image');
             @readfile($filename);
         }
     }
     exit;
 }
    $upload->init($_FILES['attach'], 'portal');
    $attach = $upload->attach;
    if (!$upload->error()) {
        $upload->save();
    }
    if ($upload->error()) {
        portal_upload_error($upload->error());
    }
    $attachs[] = $attach;
}
if ($attachs) {
    foreach ($attachs as $attach) {
        if ($attach['isimage']) {
            require_once libfile('class/image');
            $image = new image();
            $attach['thumb'] = $image->Thumb($attach['target'], '', '300', '300', 2);
            $image->Watermark($attach['target']);
        }
        if (getglobal('setting/ftp/on')) {
            if (ftpcmd('upload', 'portal/' . $attach['attachment'])) {
                if ($attach['thumb']) {
                    ftpcmd('upload', 'portal/' . $attach['attachment'] . '.thumb.jpg');
                }
                $attach['remote'] = 1;
            } else {
                if (getglobal('setting/ftp/mirror')) {
                    @unlink($attach['target']);
                    @unlink($attach['target'] . '.thumb.jpg');
                    portal_upload_error(lang('portalcp', 'upload_remote_failed'));
                }
            }
function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name = '', $title = '', $delsize = 0, $from = false)
{
    global $_G, $space;
    if ($albumid < 0) {
        $albumid = 0;
    }
    $setarr = array();
    require_once libfile('class/upload');
    $upload = new discuz_upload();
    $filepath = $upload->get_target_dir('album') . $upload->get_target_filename('album') . '.' . $fileext;
    $newfilename = $_G['setting']['attachdir'] . './album/' . $filepath;
    if ($handle = fopen($newfilename, 'wb')) {
        if (fwrite($handle, $strdata) !== FALSE) {
            fclose($handle);
            $size = filesize($newfilename);
            if (empty($space)) {
                $_G['member'] = $space = getspace($_G['uid']);
                $_G['username'] = addslashes($space['username']);
            }
            $_G['member'] = $space;
            $maxspacesize = checkperm('maxspacesize');
            $maxspacesize = $maxspacesize * 1024 * 1024;
            if ($maxspacesize) {
                space_merge($space, 'common_member_count');
                space_merge($space, 'common_member_field_home');
                if ($space['attachsize'] + $size - $delsize > $maxspacesize + $space['addsize']) {
                    @unlink($newfilename);
                    return -1;
                }
            }
            if (!$upload->get_image_info($newfilename)) {
                @unlink($newfilename);
                return -2;
            }
            require_once libfile('class/image');
            $image = new image();
            $result = $image->Thumb($newfilename, NULL, 140, 140, 1);
            $thumb = empty($result) ? 0 : 1;
            $image->Watermark($newfilename);
            $pic_remote = 0;
            $album_picflag = 1;
            if (getglobal('setting/ftp/on')) {
                $ftpresult_thumb = 0;
                $ftpresult = ftpupload('album/' . $filepath);
                if ($ftpresult) {
                    if ($thumb) {
                        ftpupload('album/' . $filepath . '.thumb.jpg');
                    }
                    $pic_remote = 1;
                    $album_picflag = 2;
                } else {
                    if (getglobal('setting/ftp/mirror')) {
                        @unlink($newfilename);
                        @unlink($newfilename . '.thumb.jpg');
                        return -3;
                    }
                }
            }
            $filename = addslashes($name ? $name : substr(strrchr($filepath, '/'), 1));
            $title = getstr($title, 200, 1, 1, 1);
            if ($albumid) {
                $albumid = album_creat_by_id($albumid);
            } else {
                $albumid = 0;
            }
            $setarr = array('albumid' => $albumid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'filename' => $filename, 'postip' => $_G['clientip'], 'title' => $title, 'type' => $fileext, 'size' => $size, 'filepath' => $filepath, 'thumb' => $thumb, 'remote' => $pic_remote);
            $setarr['picid'] = DB::insert('home_pic', $setarr, 1);
            DB::query("UPDATE " . DB::table('common_member_count') . " SET attachsize=attachsize+{$size} WHERE uid='{$_G['uid']}'");
            include_once libfile('function/stat');
            updatestat('pic');
            return $setarr;
        } else {
            fclose($handle);
        }
    }
    return -3;
}
Beispiel #5
0
        dheader('location: ' . $attachurl . $thumbfile);
    }
}
define('NOROBOT', TRUE);
$id = !empty($_GET['atid']) ? $_GET['atid'] : $daid;
if (brand_dsign($id . '|' . $dw . '|' . $dh) != $_GET['key']) {
    ///dheader('location: '.$_G['siteurl'].'static/image/common/none.gif');
}
if ($attach = C::t('#sanree_brand#sanree_brand_businesses')->getbusinesses_by_bid($daid)) {
    if (!$dw && !$dh) {
        dheader('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
    }
    dheader('Expires: ' . gmdate('D, d M Y H:i:s', TIMESTAMP + 3600) . ' GMT');
    $filename = $_G['setting']['attachdir'] . 'category/' . $attach['poster'];
    require_once libfile('class/image');
    $img = new image();
    if ($img->Thumb($filename, $thumbfile, $w, $h, $type)) {
        if ($nocache) {
            dheader('Content-Type: image');
            @readfile($_G['setting']['attachdir'] . $thumbfile);
            @unlink($_G['setting']['attachdir'] . $thumbfile);
        } else {
            dheader('location: ' . $attachurl . $thumbfile);
        }
    } else {
        dheader('Content-Type: image');
        @readfile($filename);
    }
    exit;
}
dheader('location: ' . $_G['siteurl'] . 'static/image/common/nophoto.gif');
Beispiel #6
0
function setthreadcover($pid, $tid = 0, $aid = 0)
{
    global $_G;
    $cover = 0;
    if (empty($_G['uid']) || !intval($_G['setting']['forumpicstyle']['thumbwidth']) || !intval($_G['setting']['forumpicstyle']['thumbwidth'])) {
        return false;
    }
    if (($pid || $aid) && empty($tid)) {
        if ($aid) {
            $attachtable = getattachtablebyaid($aid);
            $wheresql = "aid='{$aid}' AND isimage IN ('1', '-1')";
        } else {
            $attachtable = getattachtablebypid($pid);
            $wheresql = "pid='{$pid}' AND isimage IN ('1', '-1') ORDER BY width DESC LIMIT 1";
        }
        $query = DB::query("SELECT * FROM " . DB::table($attachtable) . " WHERE {$wheresql}");
        if (!($attach = DB::fetch($query))) {
            return false;
        }
        if (empty($_G['forum']['ismoderator']) && $_G['uid'] != $attach['uid']) {
            return false;
        }
        $pid = empty($pid) ? $attach['pid'] : $pid;
        $tid = empty($tid) ? $attach['tid'] : $tid;
        $basedir = !$_G['setting']['attachdir'] ? DISCUZ_ROOT . './data/attachment/' : $_G['setting']['attachdir'];
        $coverdir = 'threadcover/' . substr(md5($tid), 0, 2) . '/' . substr(md5($tid), 2, 2) . '/';
        dmkdir($basedir . './forum/' . $coverdir);
        $picsource = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment'];
        require_once libfile('class/image');
        $image = new image();
        if ($image->Thumb($picsource, 'forum/' . $coverdir . $tid . '.jpg', $_G['setting']['forumpicstyle']['thumbwidth'], $_G['setting']['forumpicstyle']['thumbheight'], 2)) {
            $remote = '';
            if (getglobal('setting/ftp/on')) {
                if (ftpcmd('upload', 'forum/' . $coverdir . $tid . '.jpg')) {
                    $remote = '-';
                }
            }
            $cover = DB::result_first("SELECT COUNT(*) FROM " . DB::table($attachtable) . " WHERE pid='{$pid}' AND isimage IN ('1', '-1')");
            $cover = $remote . $cover;
        } else {
            return false;
        }
    }
    if ($tid || $cover) {
        if (empty($cover)) {
            $oldcover = DB::result_first("SELECT cover FROM " . DB::table('forum_thread') . " WHERE tid='{$tid}'");
            $cover = DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($tid)) . " WHERE pid='{$pid}' AND isimage IN ('1', '-1')");
            $cover = $cover && $oldcover < 0 ? '-' . $cover : $cover;
        }
        DB::update('forum_thread', array('cover' => $cover), array('tid' => $tid));
    }
    return true;
}
function setthreadcover($pid, $tid = 0, $aid = 0, $countimg = 0, $imgurl = '')
{
    global $_G;
    $cover = 0;
    if (empty($_G['uid']) || !intval($_G['setting']['forumpicstyle']['thumbheight']) || !intval($_G['setting']['forumpicstyle']['thumbwidth'])) {
        return false;
    }
    if (($pid || $aid) && empty($countimg)) {
        if (empty($imgurl)) {
            if ($aid) {
                $attachtable = 'aid:' . $aid;
                $attach = C::t('forum_attachment_n')->fetch('aid:' . $aid, $aid, array(1, -1));
            } else {
                $attachtable = 'pid:' . $pid;
                $attach = C::t('forum_attachment_n')->fetch_max_image('pid:' . $pid, 'pid', $pid);
            }
            if (!$attach) {
                return false;
            }
            if (empty($_G['forum']['ismoderator']) && $_G['uid'] != $attach['uid']) {
                return false;
            }
            $pid = empty($pid) ? $attach['pid'] : $pid;
            $tid = empty($tid) ? $attach['tid'] : $tid;
            $picsource = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment'];
        } else {
            $attachtable = 'pid:' . $pid;
            $picsource = $imgurl;
        }
        $basedir = !$_G['setting']['attachdir'] ? DISCUZ_ROOT . './data/attachment/' : $_G['setting']['attachdir'];
        $coverdir = 'threadcover/' . substr(md5($tid), 0, 2) . '/' . substr(md5($tid), 2, 2) . '/';
        dmkdir($basedir . './forum/' . $coverdir);
        require_once libfile('class/image');
        $image = new image();
        if ($image->Thumb($picsource, 'forum/' . $coverdir . $tid . '.jpg', $_G['setting']['forumpicstyle']['thumbwidth'], $_G['setting']['forumpicstyle']['thumbheight'], 2)) {
            $remote = '';
            if (getglobal('setting/ftp/on')) {
                if (ftpcmd('upload', 'forum/' . $coverdir . $tid . '.jpg')) {
                    $remote = '-';
                }
            }
            $cover = C::t('forum_attachment_n')->count_image_by_id($attachtable, 'pid', $pid);
            if ($imgurl && empty($cover)) {
                $cover = 1;
            }
            $cover = $remote . $cover;
        } else {
            return false;
        }
    }
    if ($countimg) {
        if (empty($cover)) {
            $thread = C::t('forum_thread')->fetch($tid);
            $oldcover = $thread['cover'];
            $cover = C::t('forum_attachment_n')->count_image_by_id('tid:' . $tid, 'pid', $pid);
            if ($cover) {
                $cover = $oldcover < 0 ? '-' . $cover : $cover;
            }
        }
    }
    if ($cover) {
        C::t('forum_thread')->update($tid, array('cover' => $cover));
        return true;
    }
}
function block_template($bid)
{
    global $_G;
    $block = empty($_G['block'][$bid]) ? array() : $_G['block'][$bid];
    $theclass = block_getclass($block['blockclass'], false);
    $thestyle = !empty($block['styleid']) ? block_getstyle($block['styleid']) : dunserialize($block['blockstyle']);
    if (empty($block) || empty($theclass) || empty($thestyle)) {
        return false;
    }
    $template = block_build_template($thestyle['template']);
    if (!empty($block['itemlist'])) {
        if ($thestyle['moreurl']) {
            $template = str_replace('{moreurl}', 'portal.php?mod=block&bid=' . $bid, $template);
        }
        $fields = array('picwidth' => array(), 'picheight' => array(), 'target' => array(), 'currentorder' => array());
        if ($block['hidedisplay']) {
            $fields = array_merge($fields, $theclass['fields']);
        } else {
            $thestyle['fields'] = !empty($thestyle['fields']) && is_array($thestyle['fields']) ? $thestyle['fields'] : block_parse_fields($template);
            foreach ($thestyle['fields'] as $k) {
                if (isset($theclass['fields'][$k])) {
                    $fields[$k] = $theclass['fields'][$k];
                }
            }
        }
        $order = 0;
        $dynamicparts = array();
        foreach ($block['itemlist'] as $position => $blockitem) {
            $itemid = $blockitem['itemid'];
            $order++;
            $rkey = $rpattern = $rvalue = $rtpl = array();
            $rkeyplug = false;
            if (isset($thestyle['template']['index']) && is_array($thestyle['template']['index']) && isset($thestyle['template']['index'][$order])) {
                $rkey[] = 'index_' . $order;
                $rpattern[] = '/\\s*\\[index=' . $order . '\\](.*?)\\[\\/index\\]\\s*/is';
                $rvalue[] = '';
                $rtpl[] = $thestyle['template']['index'][$order];
            }
            if (empty($rkey)) {
                $rkey[] = 'loop';
                $rpattern[] = '/\\s*\\[loop\\](.*?)\\[\\/loop\\]\\s*/is';
                $rvalue[] = isset($dynamicparts['loop']) ? $dynamicparts['loop'][1] : '';
                if (is_array($thestyle['template']['order']) && isset($thestyle['template']['order'][$order])) {
                    $rtpl[] = $thestyle['template']['order'][$order];
                } elseif (is_array($thestyle['template']['order']) && isset($thestyle['template']['order']['odd']) && $order % 2 == 1) {
                    $rtpl[] = $thestyle['template']['order']['odd'];
                } elseif (is_array($thestyle['template']['order']) && isset($thestyle['template']['order']['even']) && $order % 2 == 0) {
                    $rtpl[] = $thestyle['template']['order']['even'];
                } else {
                    $rtpl[] = $thestyle['template']['loop'];
                }
            }
            if (!empty($thestyle['template']['indexplus'])) {
                foreach ($thestyle['template']['indexplus'] as $k => $v) {
                    if (isset($v[$order])) {
                        $rkey[] = 'index' . $k . '=' . $order;
                        $rkeyplug = true;
                        $rpattern[] = '/\\[index' . $k . '=' . $order . '\\](.*?)\\[\\/index' . $k . '\\]/is';
                        $rvalue[] = '';
                        $rtpl[] = $v[$order];
                    }
                }
            }
            if (empty($rkeyplug)) {
                if (!empty($thestyle['template']['loopplus'])) {
                    foreach ($thestyle['template']['loopplus'] as $k => $v) {
                        $rkey[] = 'loop' . $k;
                        $rpattern[] = '/\\s*\\[loop' . $k . '\\](.*?)\\[\\/loop' . $k . '\\]\\s*/is';
                        $rvalue[] = isset($dynamicparts['loop' . $k]) ? $dynamicparts['loop' . $k][1] : '';
                        if (is_array($thestyle['template']['orderplus'][$k]) && isset($thestyle['template']['orderplus'][$k][$order])) {
                            $rtpl[] = $thestyle['template']['orderplus'][$k][$order];
                        } elseif (is_array($thestyle['template']['orderplus'][$k]) && isset($thestyle['template']['orderplus'][$k]['odd']) && $order % 2 == 1) {
                            $rtpl[] = $thestyle['template']['orderplus'][$k]['odd'];
                        } elseif (is_array($thestyle['template']['orderplus'][$k]) && isset($thestyle['template']['orderplus'][$k]['even']) && $order % 2 == 0) {
                            $rtpl[] = $thestyle['template']['orderplus'][$k]['even'];
                        } else {
                            $rtpl[] = $thestyle['template']['loopplus'][$k];
                        }
                    }
                }
            }
            $blockitem['fields'] = !empty($blockitem['fields']) ? $blockitem['fields'] : array();
            $blockitem['fields'] = is_array($blockitem['fields']) ? $blockitem['fields'] : dunserialize($blockitem['fields']);
            if (!empty($blockitem['showstyle'])) {
                $blockitem['fields']['showstyle'] = dunserialize($blockitem['showstyle']);
            }
            isset($blockitem['fields']['lastpost']) && ($block['dateuformat'] = 'u');
            $blockitem = $blockitem['fields'] + $blockitem;
            $blockitem['picwidth'] = !empty($block['picwidth']) ? intval($block['picwidth']) : 'auto';
            $blockitem['picheight'] = !empty($block['picheight']) ? intval($block['picheight']) : 'auto';
            $blockitem['target'] = !empty($block['target']) ? ' target="_' . $block['target'] . '"' : '';
            $blockitem['currentorder'] = $order;
            $blockitem['parity'] = $order % 2;
            $searcharr = $replacearr = array();
            $searcharr[] = '{parity}';
            $replacearr[] = $blockitem['parity'];
            foreach ($fields as $key => $field) {
                $replacevalue = $blockitem[$key];
                $field['datatype'] = !empty($field['datatype']) ? $field['datatype'] : '';
                if ($field['datatype'] == 'int') {
                    // int
                    $replacevalue = intval($replacevalue);
                } elseif ($field['datatype'] == 'string') {
                    $replacevalue = preg_quote($replacevalue);
                } elseif ($field['datatype'] == 'date') {
                    $replacevalue = dgmdate($replacevalue, $block['dateuformat'] ? 'u' : $block['dateformat'], '9999', $block['dateuformat'] ? $block['dateformat'] : '');
                } elseif ($field['datatype'] == 'title') {
                    //title
                    $searcharr[] = '{title-title}';
                    $replacearr[] = preg_quote(!empty($blockitem['fields']['fulltitle']) ? $blockitem['fields']['fulltitle'] : dhtmlspecialchars($replacevalue));
                    $searcharr[] = '{alt-title}';
                    $replacearr[] = preg_quote(!empty($blockitem['fields']['fulltitle']) ? $blockitem['fields']['fulltitle'] : dhtmlspecialchars($replacevalue));
                    $replacevalue = preg_quote($replacevalue);
                    if ($blockitem['showstyle'] && ($style = block_showstyle($blockitem['showstyle'], 'title'))) {
                        $replacevalue = '<font style="' . $style . '">' . $replacevalue . '</font>';
                    }
                } elseif ($field['datatype'] == 'summary') {
                    //summary
                    $replacevalue = preg_quote($replacevalue);
                    if ($blockitem['showstyle'] && ($style = block_showstyle($blockitem['showstyle'], 'summary'))) {
                        $replacevalue = '<font style="' . $style . '">' . $replacevalue . '</font>';
                    }
                } elseif ($field['datatype'] == 'pic') {
                    if ($blockitem['picflag'] == '1') {
                        $replacevalue = $_G['setting']['attachurl'] . $replacevalue;
                    } elseif ($blockitem['picflag'] == '2') {
                        $replacevalue = $_G['setting']['ftp']['attachurl'] . $replacevalue;
                    }
                    if ($blockitem['picflag'] && $block['picwidth'] && $block['picheight'] && $block['picwidth'] != 'auto' && $block['picheight'] != 'auto') {
                        if ($blockitem['makethumb'] == 1) {
                            if ($blockitem['picflag'] == '1') {
                                $replacevalue = $_G['setting']['attachurl'] . $blockitem['thumbpath'];
                            } elseif ($blockitem['picflag'] == '2') {
                                $replacevalue = $_G['setting']['ftp']['attachurl'] . $blockitem['thumbpath'];
                            }
                        } elseif (!$_G['block_makethumb'] && !$blockitem['makethumb']) {
                            C::t('common_block_item')->update($itemid, array('makethumb' => 2));
                            require_once libfile('class/image');
                            $image = new image();
                            $thumbpath = block_thumbpath($block, $blockitem);
                            if ($_G['setting']['ftp']['on']) {
                                $ftp =& discuz_ftp::instance();
                                $ftp->connect();
                                if ($ftp->connectid && $ftp->ftp_size($thumbpath) > 0 || ($return = $image->Thumb($replacevalue, $thumbpath, $block['picwidth'], $block['picheight'], 2) && $ftp->upload($_G['setting']['attachurl'] . '/' . $thumbpath, $thumbpath))) {
                                    $picflag = 1;
                                    //common_block_pic表中的picflag标识(0本地,1远程)
                                    $_G['block_makethumb'] = true;
                                    @unlink($_G['setting']['attachdir'] . './' . $thumbpath);
                                }
                            } elseif (file_exists($_G['setting']['attachdir'] . $thumbpath) || ($return = $image->Thumb($replacevalue, $thumbpath, $block['picwidth'], $block['picheight'], 2))) {
                                $picflag = 0;
                                //common_block_pic表中的picflag标识(0本地,1远程)
                                $_G['block_makethumb'] = true;
                            }
                            if ($_G['block_makethumb']) {
                                C::t('common_block_item')->update($itemid, array('makethumb' => 1, 'thumbpath' => $thumbpath));
                                C::t('common_block')->clear_cache($block['bid']);
                                $thumbdata = array('bid' => $block['bid'], 'itemid' => $itemid, 'pic' => $thumbpath, 'picflag' => $picflag, 'type' => '0');
                                C::t('common_block_pic')->insert($thumbdata);
                            }
                        }
                    }
                }
                $searcharr[] = '{' . $key . '}';
                $replacearr[] = $replacevalue;
                if ($block['hidedisplay']) {
                    if (strpos($replacevalue, "\\") !== false) {
                        $replacevalue = str_replace(array('\\.', '\\\\', '\\+', '\\*', '\\?', '\\[', '\\^', '\\]', '\\$', '\\(', '\\)', '\\{', '\\}', '\\=', '\\!', '\\<', '\\>', '\\|', '\\:', '\\-'), array('.', '\\', '+', '*', '?', '[', '^', ']', '$', '(', ')', '{', '}', '=', '!', '<', '>', '|', ':', '-'), $replacevalue);
                    }
                    $_G['block_' . $bid][$order - 1][$key] = $replacevalue;
                }
            }
            foreach ($rtpl as $k => $str_template) {
                if ($str_template) {
                    $str_template = preg_replace('/title=[\'"]{title}[\'"]/', 'title="{title-title}"', $str_template);
                    $str_template = preg_replace('/alt=[\'"]{title}[\'"]/', 'alt="{alt-title}"', $str_template);
                    $rvalue[$k] .= str_replace($searcharr, $replacearr, $str_template);
                    $dynamicparts[$rkey[$k]] = array($rpattern[$k], $rvalue[$k]);
                }
            }
        }
        // foreach($block['itemlist'] as $itemid=>$blockitem) {
        foreach ($dynamicparts as $value) {
            $template = preg_replace($value[0], $value[1], $template);
        }
        $template = str_replace('\\', '&#92;', stripslashes($template));
    }
    $template = preg_replace('/\\s*\\[(order\\d*)=\\w+\\](.*?)\\[\\/\\1\\]\\s*/is', '', $template);
    $template = preg_replace('/\\s*\\[(index\\d*)=\\w+\\](.*?)\\[\\/\\1\\]\\s*/is', '', $template);
    $template = preg_replace('/\\s*\\[(loop\\d{0,1})\\](.*?)\\[\\/\\1\\]\\s*/is', '', $template);
    return $template;
}
 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;
     $this->uid = intval($_G['gp_uid']);
     $swfhash = md5(substr(md5($_G['config']['security']['authkey']), 8) . $this->uid);
     if (!$_FILES['Filedata']['error'] && $_G['gp_hash'] == $swfhash) {
         $this->aid = 0;
         $this->simple = !empty($_G['gp_simple']) ? $_G['gp_simple'] : 0;
         $_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'] > DB::result_first("SELECT count(*) FROM " . DB::table('forum_attachment') . " WHERE uid='{$_G['uid']}' AND dateline>'{$_G['timestamp']}'-86400");
         if (!$allowupload) {
             $this->uploadmsg(9);
         }
         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->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->uploadmsg(4);
             } elseif ($upload->attach['size'] > $type['maxsize']) {
                 $this->uploadmsg(5);
             }
         }
         if ($upload->attach['size'] && $_G['group']['maxsizeperday']) {
             $todaysize = intval(DB::result_first("SELECT SUM(filesize) FROM " . DB::table('forum_attachment') . " WHERE uid='{$_G['uid']}' AND dateline>'{$_G['timestamp']}'-86400"));
             $todaysize += $upload->attach['size'];
             if ($todaysize >= $_G['group']['maxsizeperday']) {
                 $this->uploadmsg(6);
             }
         }
         $upload->save();
         if ($upload->error() == -103) {
             $this->uploadmsg(8);
         } elseif ($upload->error()) {
             $this->uploadmsg(9);
         }
         $thumb = $remote = $width = 0;
         if ($upload->attach['isimage']) {
             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;
             $image->Watermark($upload->attach['target']);
             $width = $image->imginfo['width'];
         }
         if (!$this->simple) {
             $upload->attach['name'] = diconv($upload->attach['name'], 'utf-8');
         }
         if ($_G['gp_type'] != 'image' && $upload->attach['isimage']) {
             $upload->attach['isimage'] = -1;
         }
         DB::query("INSERT INTO " . DB::table('forum_attachment') . " (tid, pid, dateline, readperm, price, filename, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote, width)\n\t\t\t\tVALUES ('0', '0', '{$_G['timestamp']}', '0', '0', '" . $upload->attach['name'] . "', '" . $upload->attach['type'] . "', '" . $upload->attach['size'] . "', '" . $upload->attach['attachment'] . "', '0', '" . $upload->attach['isimage'] . "', '" . $this->uid . "', '{$thumb}', '{$remote}', '{$width}')");
         $this->aid = DB::insert_id();
         $this->uploadmsg(0);
     }
 }
Beispiel #11
0
function upload_image($file_name, $type = 'space', $_w = 200, $_h = 200, $cut = 1)
{
    global $_G;
    $attachdir = $_G['setting']['attachdir'];
    $attachurl = $_G['setting']['attachurl'];
    $file = $_FILES[$file_name];
    if ($_FILES[$file_name]['size']) {
        $upload = new discuz_upload();
        if (!$upload->init($file, $type)) {
            return false;
        }
        $upload->save();
        require_once libfile('class/image');
        $image = new image();
        $thumbTarget = $type . '/' . date('Ym') . '/' . date('d') . '/' . $upload->attach['attachment'];
        $image->Thumb($upload->attach['target'], $thumbTarget, $_w, $_h, $cut);
        @unlink($image->source);
        if (!empty($_GET['temp_' . $file_name])) {
            $_goods_pic = addslashes($_GET['temp_' . $file_name]);
            @unlink($_goods_pic);
        }
        return $attachurl . $thumbTarget;
    } elseif (isset($_GET['temp_' . $file_name])) {
        return addslashes($_GET['temp_' . $file_name]);
    }
}
Beispiel #12
0
 public function getThumb($path, $width, $height, $original)
 {
     global $_G;
     $imgcachePath = './imgcache/';
     $cachepath = str_replace(':', '/', $path);
     $cachepath = preg_replace("/\\/+/", '/', str_replace(':', '/', $path));
     if ($original) {
         $imgurl = self::getStream($path);
         $imginfo = @getimagesize($imgurl);
         header('Content-Type: ' . image_type_to_mime_type($imginfo[2]));
         @readfile($imgurl);
         @flush();
         @ob_flush();
         exit;
     }
     $target = $imgcachePath . $cachepath . '.' . $width . '_' . $height . '.jpeg';
     if (@getimagesize($_G['setting']['attachdir'] . $target)) {
         header('Content-Type: image/JPEG');
         @ob_end_clean();
         if (getglobal('gzipcompress')) {
             @ob_start('ob_gzhandler');
         }
         @readfile($_G['setting']['attachdir'] . $target);
         @flush();
         @ob_flush();
         exit;
     }
     $imgurl = self::getStream($path);
     $imginfo = @getimagesize($imgurl);
     if (is_array($imginfo) && $imginfo[0] < $width && $imginfo[1] < $height) {
         header("Content-Type: " . image_type_to_mime_type($imginfo[2]));
         @ob_end_clean();
         if (getglobal('gzipcompress')) {
             @ob_start('ob_gzhandler');
         }
         @readfile($imgurl);
         @flush();
         @ob_flush();
         exit;
     }
     //生成缩略图
     include_once libfile('class/image');
     $image = new image();
     if ($thumb = $image->Thumb($imgurl, $target, $width, $height, 1)) {
         header('Content-Type: image/JPEG');
         @ob_end_clean();
         if (getglobal('gzipcompress')) {
             @ob_start('ob_gzhandler');
         }
         @readfile($_G['setting']['attachdir'] . $target);
         @flush();
         @ob_flush();
         exit;
     } else {
         header('Content-Type: image/PNG');
         @ob_end_clean();
         if (getglobal('gzipcompress')) {
             @ob_start('ob_gzhandler');
         }
         @readfile($imgurl);
         @flush();
         @ob_flush();
     }
 }
 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);
 }
Beispiel #14
0
function block_template($bid)
{
    global $_G;
    $block = empty($_G['block'][$bid]) ? array() : $_G['block'][$bid];
    $theclass = block_getclass($block['blockclass']);
    // for short
    $thestyle = $theclass['style'][$block['styleid']];
    // for short
    if (empty($block) || empty($theclass) || empty($thestyle)) {
        return;
    }
    $template = '';
    if ($block['itemlist']) {
        $template = $thestyle['template']['header'];
        $order = 0;
        foreach ($block['itemlist'] as $blockitem) {
            $order++;
            if (isset($thestyle['template']['order'][$order])) {
                $theteamplte = $thestyle['template']['order'][$order];
            } else {
                $theteamplte = $thestyle['template']['loop'];
            }
            $blockitem['showstyle'] = !empty($blockitem['showstyle']) ? unserialize($blockitem['showstyle']) : array();
            $blockitem['fields'] = !empty($blockitem['fields']) ? $blockitem['fields'] : array();
            $blockitem['fields'] = is_array($blockitem['fields']) ? $blockitem['fields'] : unserialize($blockitem['fields']);
            $blockitem['picwidth'] = !empty($block['picwidth']) ? intval($block['picwidth']) : 'auto';
            $blockitem['picheight'] = !empty($block['picheight']) ? intval($block['picheight']) : 'auto';
            $blockitem['target'] = !empty($block['target']) ? ' target="_' . $block['target'] . '"' : '';
            $fields = array('picwidth' => array(), 'picheight' => array(), 'target' => array());
            $fields = array_merge($fields, $theclass['fields']);
            $searcharr = $replacearr = array();
            foreach ($fields as $key => $field) {
                $replacevalue = isset($blockitem[$key]) ? $blockitem[$key] : (isset($blockitem['fields'][$key]) ? $blockitem['fields'][$key] : '');
                $field['datatype'] = !empty($field['datatype']) ? $field['datatype'] : '';
                if ($field['datatype'] == 'int') {
                    // int
                    $replacevalue = intval($replacevalue);
                } elseif ($field['datatype'] == 'string') {
                    $replacevalue = dhtmlspecialchars($replacevalue);
                } elseif ($field['datatype'] == 'date') {
                    $replacevalue = dgmdate($replacevalue, 'u');
                } elseif ($field['datatype'] == 'title') {
                    //title
                    $replacevalue = stripslashes($replacevalue);
                    $style = block_showstyle($blockitem['showstyle'], 'title');
                    if ($style) {
                        $theteamplte = preg_replace('/title=[\'"]{title}[\'"]/', 'title="{title-title}"', $theteamplte);
                        $theteamplte = preg_replace('/alt=[\'"]{title}[\'"]/', 'alt="{alt-title}"', $theteamplte);
                        $searcharr[] = '{title-title}';
                        $replacearr[] = $replacevalue;
                        $searcharr[] = '{alt-title}';
                        $replacearr[] = $replacevalue;
                        $replacevalue = '<font style="' . $style . '">' . $replacevalue . '</font>';
                    }
                } elseif ($field['datatype'] == 'summary') {
                    //summary
                    $replacevalue = stripslashes($replacevalue);
                    $style = block_showstyle($blockitem['showstyle'], 'summary');
                    if ($style) {
                        $replacevalue = htmlspecialchars($replacevalue);
                        $replacevalue = '<font style="' . $style . '">' . $replacevalue . '</font>';
                    }
                } elseif ($field['datatype'] == 'pic') {
                    if ($blockitem['picflag'] == '1') {
                        $replacevalue = $_G['setting']['attachurl'] . $replacevalue;
                    } elseif ($blockitem['picflag'] == '2') {
                        $replacevalue = $_G['setting']['ftp']['attachurl'] . $replacevalue;
                    }
                    if ($block['picwidth'] && $block['picheight'] && $block['picwidth'] != 'auto' && $block['picheight'] != 'auto') {
                        if ($blockitem['makethumb'] == 1) {
                            $replacevalue = $_G['setting']['attachurl'] . block_thumbpath($block, $blockitem);
                        } elseif (!$_G['block_makethumb'] && !$blockitem['makethumb']) {
                            require_once libfile('class/image');
                            $image = new image();
                            $thumbpath = block_thumbpath($block, $blockitem);
                            $return = $image->Thumb($replacevalue, $thumbpath, $block['picwidth'], $block['picheight'], 2);
                            if ($return) {
                                DB::update('common_block_item', array('makethumb' => 1), array('itemid' => $blockitem['itemid']));
                                $replacevalue = $_G['setting']['attachurl'] . $thumbpath;
                            } else {
                                DB::update('common_block_item', array('makethumb' => 2), array('itemid' => $blockitem['itemid']));
                            }
                            $_G['block_makethumb'] = true;
                        }
                    }
                }
                $searcharr[] = '{' . $key . '}';
                $replacearr[] = $replacevalue;
            }
            $template .= str_replace($searcharr, $replacearr, $theteamplte);
        }
        $template .= $thestyle['template']['footer'];
    }
    return $template;
}
/**
 *
 * 在 DISCUZ_ROOT/source/function_spacecp.php 基础上做了改动
 *
 * @author HanPengyu
 * @copyright 2012-2014 Appbyme
 */
function mobcent_pic_save($FILE, $albumid, $title, $iswatermark = true, $catid = 0)
{
    global $_G, $space;
    if ($albumid < 0) {
        $albumid = 0;
    }
    $allowpictype = array('jpg', 'jpeg', 'gif', 'png');
    $upload = new discuz_upload();
    $upload->init($FILE, 'album');
    if ($upload->error()) {
        return lang('spacecp', 'lack_of_access_to_upload_file_size');
    }
    if (!$upload->attach['isimage']) {
        return lang('spacecp', 'only_allows_upload_file_types');
    }
    $oldgid = $_G['groupid'];
    if (empty($space)) {
        $_G['member'] = $space = getuserbyuid($_G['uid']);
        $_G['username'] = $space['username'];
        $_G['groupid'] = $space['groupid'];
    }
    $_G['member'] = $space;
    loadcache('usergroup_' . $space['groupid'], $oldgid != $_G['groupid'] ? true : false);
    $_G['group'] = $_G['cache']['usergroup_' . $space['groupid']];
    if (!checkperm('allowupload')) {
        return lang('spacecp', 'not_allow_upload');
    }
    if (!cknewuser(1)) {
        if ($_G['setting']['newbiespan'] && $_G['timestamp'] - $_G['member']['regdate'] < $_G['setting']['newbiespan'] * 60) {
            return lang('message', 'no_privilege_newbiespan', array('newbiespan' => $_G['setting']['newbiespan']));
        }
        if ($_G['setting']['need_avatar'] && empty($_G['member']['avatarstatus'])) {
            return lang('message', 'no_privilege_avatar');
        }
        if ($_G['setting']['need_email'] && empty($_G['member']['emailstatus'])) {
            return lang('message', 'no_privilege_email');
        }
        if ($_G['setting']['need_friendnum']) {
            space_merge($_G['member'], 'count');
            if ($_G['member']['friends'] < $_G['setting']['need_friendnum']) {
                return lang('message', 'no_privilege_friendnum', array('friendnum' => $_G['setting']['need_friendnum']));
            }
        }
    }
    if ($_G['group']['maximagesize'] && $upload->attach['size'] > $_G['group']['maximagesize']) {
        return lang('spacecp', 'files_can_not_exceed_size', array('extend' => $upload->attach['ext'], 'size' => sizecount($_G['group']['maximagesize'])));
    }
    $maxspacesize = checkperm('maxspacesize');
    if ($maxspacesize) {
        space_merge($space, 'count');
        space_merge($space, 'field_home');
        if ($space['attachsize'] + $upload->attach['size'] > $maxspacesize + $space['addsize'] * 1024 * 1024) {
            return lang('spacecp', 'inadequate_capacity_space');
        }
    }
    $showtip = true;
    $albumfriend = 0;
    if ($albumid) {
        $catid = intval($catid);
        $albumid = album_creat_by_id($albumid, $catid);
    } else {
        $albumid = 0;
        $showtip = false;
    }
    $upload->save();
    if ($upload->error()) {
        return lang('spacecp', 'mobile_picture_temporary_failure');
    }
    if (!$upload->attach['imageinfo'] || !in_array($upload->attach['imageinfo']['2'], array(1, 2, 3, 6))) {
        @unlink($upload->attach['target']);
        return lang('spacecp', 'only_allows_upload_file_types');
    }
    $new_name = $upload->attach['target'];
    require_once libfile('class/image');
    $image = new image();
    $result = $image->Thumb($new_name, '', 140, 140, 1);
    $thumb = empty($result) ? 0 : 1;
    if ($_G['setting']['maxthumbwidth'] && $_G['setting']['maxthumbheight']) {
        if ($_G['setting']['maxthumbwidth'] < 300) {
            $_G['setting']['maxthumbwidth'] = 300;
        }
        if ($_G['setting']['maxthumbheight'] < 300) {
            $_G['setting']['maxthumbheight'] = 300;
        }
        $image->Thumb($new_name, '', $_G['setting']['maxthumbwidth'], $_G['setting']['maxthumbheight'], 1, 1);
    }
    // 支持客户端上传相册水印 Author:HanPengyu Data:2014/12/04
    Yii::import('application.components.discuz.source.class.class_image', true);
    $image = new Mobcent_Image();
    $image->makeWatermark($new_name, '', 'album');
    // if ($iswatermark) {
    //     $image->Watermark($new_name, '', 'album');
    // }
    $pic_remote = 0;
    $album_picflag = 1;
    if (getglobal('setting/ftp/on')) {
        $ftpresult_thumb = 0;
        $ftpresult = ftpcmd('upload', 'album/' . $upload->attach['attachment']);
        if ($ftpresult) {
            @unlink($_G['setting']['attachdir'] . 'album/' . $upload->attach['attachment']);
            if ($thumb) {
                $thumbpath = getimgthumbname($upload->attach['attachment']);
                ftpcmd('upload', 'album/' . $thumbpath);
                @unlink($_G['setting']['attachdir'] . 'album/' . $thumbpath);
            }
            $pic_remote = 1;
            $album_picflag = 2;
        } else {
            if (getglobal('setting/ftp/mirror')) {
                @unlink($upload->attach['target']);
                @unlink(getimgthumbname($upload->attach['target']));
                return lang('spacecp', 'ftp_upload_file_size');
            }
        }
    }
    $title = getstr($title, 200);
    $title = censor($title);
    if (censormod($title) || $_G['group']['allowuploadmod']) {
        $pic_status = 1;
    } else {
        $pic_status = 0;
    }
    $setarr = array('albumid' => $albumid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'filename' => addslashes($upload->attach['name']), 'postip' => $_G['clientip'], 'title' => $title, 'type' => addslashes($upload->attach['ext']), 'size' => $upload->attach['size'], 'filepath' => $upload->attach['attachment'], 'thumb' => $thumb, 'remote' => $pic_remote, 'status' => $pic_status);
    $setarr['picid'] = C::t('home_pic')->insert($setarr, 1);
    C::t('common_member_count')->increase($_G['uid'], array('attachsize' => $upload->attach['size']));
    include_once libfile('function/stat');
    if ($pic_status) {
        updatemoderate('picid', $setarr['picid']);
    }
    updatestat('pic');
    return $setarr;
}
Beispiel #16
0
function block_template($bid)
{
    global $_G;
    $block = empty($_G['block'][$bid]) ? array() : $_G['block'][$bid];
    $theclass = block_getclass($block['blockclass'], false);
    $thestyle = !empty($block['styleid']) ? block_getstyle($block['styleid']) : unserialize($block['blockstyle']);
    if (empty($block) || empty($theclass) || empty($thestyle)) {
        return;
    }
    $template = block_build_template($thestyle['template']);
    if (!empty($block['itemlist'])) {
        $fields = array('picwidth' => array(), 'picheight' => array(), 'target' => array(), 'currentorder' => array());
        if ($block['hidedisplay']) {
            $fields = array_merge($fields, $theclass['fields']);
        } else {
            $thestyle['fields'] = !empty($thestyle['fields']) && is_array($thestyle['fields']) ? $thestyle['fields'] : block_parse_fields($template);
            foreach ($thestyle['fields'] as $k) {
                if (isset($theclass['fields'][$k])) {
                    $fields[$k] = $theclass['fields'][$k];
                }
            }
        }
        $order = 0;
        $dynamicparts = array();
        foreach ($block['itemlist'] as $itemid => $blockitem) {
            $order++;
            $rkey = $rpattern = $rvalue = $rtpl = array();
            $rkeyplug = false;
            if (isset($thestyle['template']['index']) && is_array($thestyle['template']['index']) && isset($thestyle['template']['index'][$order])) {
                $rkey[] = 'index_' . $order;
                $rpattern[] = '/\\s*\\[index=' . $order . '\\](.*?)\\[\\/index\\]\\s*/is';
                $rvalue[] = '';
                $rtpl[] = $thestyle['template']['index'][$order];
            }
            if (empty($rkey)) {
                $rkey[] = 'loop';
                $rpattern[] = '/\\s*\\[loop\\](.*?)\\[\\/loop\\]\\s*/is';
                $rvalue[] = isset($dynamicparts['loop']) ? $dynamicparts['loop'][1] : '';
                if (is_array($thestyle['template']['order']) && isset($thestyle['template']['order'][$order])) {
                    $rtpl[] = $thestyle['template']['order'][$order];
                } elseif (is_array($thestyle['template']['order']) && isset($thestyle['template']['order']['odd']) && $order % 2 == 1) {
                    $rtpl[] = $thestyle['template']['order']['odd'];
                } elseif (is_array($thestyle['template']['order']) && isset($thestyle['template']['order']['even']) && $order % 2 == 0) {
                    $rtpl[] = $thestyle['template']['order']['even'];
                } else {
                    $rtpl[] = $thestyle['template']['loop'];
                }
            }
            if (!empty($thestyle['template']['indexplus'])) {
                foreach ($thestyle['template']['indexplus'] as $k => $v) {
                    if (isset($v[$order])) {
                        $rkey[] = 'index' . $k . '=' . $order;
                        $rkeyplug = true;
                        $rpattern[] = '/\\[index' . $k . '=' . $order . '\\](.*?)\\[\\/index' . $k . '\\]/is';
                        $rvalue[] = '';
                        $rtpl[] = $v[$order];
                    }
                }
            }
            if (empty($rkeyplug)) {
                if (!empty($thestyle['template']['loopplus'])) {
                    foreach ($thestyle['template']['loopplus'] as $k => $v) {
                        $rkey[] = 'loop' . $k;
                        $rpattern[] = '/\\s*\\[loop' . $k . '\\](.*?)\\[\\/loop' . $k . '\\]\\s*/is';
                        $rvalue[] = isset($dynamicparts['loop' . $k]) ? $dynamicparts['loop' . $k][1] : '';
                        if (is_array($thestyle['template']['orderplus'][$k]) && isset($thestyle['template']['orderplus'][$k][$order])) {
                            $rtpl[] = $thestyle['template']['orderplus'][$k][$order];
                        } elseif (is_array($thestyle['template']['orderplus'][$k]) && isset($thestyle['template']['orderplus'][$k]['odd']) && $order % 2 == 1) {
                            $rtpl[] = $thestyle['template']['order' . $k]['odd'];
                        } elseif (is_array($thestyle['template']['orderplus'][$k]) && isset($thestyle['template']['orderplus'][$k]['even']) && $order % 2 == 0) {
                            $rtpl[] = $thestyle['template']['orderplus'][$k]['even'];
                        } else {
                            $rtpl[] = $thestyle['template']['loopplus'][$k];
                        }
                    }
                }
            }
            $blockitem['fields'] = !empty($blockitem['fields']) ? $blockitem['fields'] : array();
            $blockitem['fields'] = is_array($blockitem['fields']) ? $blockitem['fields'] : unserialize($blockitem['fields']);
            $blockitem['showstyle'] = !empty($blockitem['showstyle']) ? unserialize($blockitem['showstyle']) : array();
            $blockitem['showstyle'] = !empty($blockitem['showstyle']) ? $blockitem['showstyle'] : (!empty($blockitem['fields']['showstyle']) ? $blockitem['fields']['showstyle'] : array());
            $blockitem['picwidth'] = !empty($block['picwidth']) ? intval($block['picwidth']) : 'auto';
            $blockitem['picheight'] = !empty($block['picheight']) ? intval($block['picheight']) : 'auto';
            $blockitem['target'] = !empty($block['target']) ? ' target="_' . $block['target'] . '"' : '';
            $blockitem['currentorder'] = $order;
            $blockitem['parity'] = $order % 2;
            $searcharr = $replacearr = array();
            $searcharr[] = '{parity}';
            $replacearr[] = $blockitem['parity'];
            foreach ($fields as $key => $field) {
                $replacevalue = isset($blockitem[$key]) ? $blockitem[$key] : (isset($blockitem['fields'][$key]) ? $blockitem['fields'][$key] : '');
                $field['datatype'] = !empty($field['datatype']) ? $field['datatype'] : '';
                if ($field['datatype'] == 'int') {
                    // int
                    $replacevalue = intval($replacevalue);
                } elseif ($field['datatype'] == 'string') {
                    $replacevalue = $replacevalue;
                } elseif ($field['datatype'] == 'date') {
                    $replacevalue = dgmdate($replacevalue, $block['dateuformat'] ? 'u' : $block['dateformat'], '9999', $block['dateuformat'] ? $block['dateformat'] : '');
                } elseif ($field['datatype'] == 'title') {
                    //title
                    $replacevalue = stripslashes($replacevalue);
                    $searcharr[] = '{title-title}';
                    $replacearr[] = !empty($blockitem['fields']['fulltitle']) ? $blockitem['fields']['fulltitle'] : htmlspecialchars($replacevalue);
                    $searcharr[] = '{alt-title}';
                    $replacearr[] = !empty($blockitem['fields']['fulltitle']) ? $blockitem['fields']['fulltitle'] : htmlspecialchars($replacevalue);
                    if ($blockitem['showstyle'] && ($style = block_showstyle($blockitem['showstyle'], 'title'))) {
                        $replacevalue = '<font style="' . $style . '">' . $replacevalue . '</font>';
                    }
                } elseif ($field['datatype'] == 'summary') {
                    //summary
                    $replacevalue = stripslashes($replacevalue);
                    if ($blockitem['showstyle'] && ($style = block_showstyle($blockitem['showstyle'], 'summary'))) {
                        $replacevalue = '<font style="' . $style . '">' . $replacevalue . '</font>';
                    }
                } elseif ($field['datatype'] == 'pic') {
                    if ($blockitem['picflag'] == '1') {
                        $replacevalue = $_G['setting']['attachurl'] . $replacevalue;
                    } elseif ($blockitem['picflag'] == '2') {
                        $replacevalue = $_G['setting']['ftp']['attachurl'] . $replacevalue;
                    }
                    if ($blockitem['picflag'] && $block['picwidth'] && $block['picheight'] && $block['picwidth'] != 'auto' && $block['picheight'] != 'auto') {
                        if ($blockitem['makethumb'] == 1) {
                            if ($blockitem['picflag'] == '1') {
                                $replacevalue = $_G['setting']['attachurl'] . $blockitem['thumbpath'];
                            } elseif ($blockitem['picflag'] == '2') {
                                $replacevalue = $_G['setting']['ftp']['attachurl'] . $blockitem['thumbpath'];
                            }
                        } elseif (!$_G['block_makethumb'] && !$blockitem['makethumb']) {
                            $where = array('itemid' => $blockitem['itemid']);
                            DB::update('common_block_item', array('makethumb' => 2), $where);
                            require_once libfile('class/image');
                            $image = new image();
                            $thumbpath = block_thumbpath($block, $blockitem);
                            if ($_G['setting']['ftp']['on']) {
                                require_once libfile('class/ftp');
                                $ftp =& discuz_ftp::instance();
                                $ftp->connect();
                                if ($ftp->connectid && $ftp->ftp_size($thumbpath) > 0 || ($return = $image->Thumb($replacevalue, $thumbpath, $block['picwidth'], $block['picheight'], 2) && $ftp->upload($_G['setting']['attachurl'] . '/' . $thumbpath, $thumbpath))) {
                                    /*vot*/
                                    $picflag = 1;
                                    //common_block_pic table: picflag identity (0 = local, 1 = remote)
                                    $_G['block_makethumb'] = true;
                                    @unlink($_G['setting']['attachdir'] . './' . $thumbpath);
                                }
                            } elseif (file_exists($_G['setting']['attachdir'] . $thumbpath) || ($return = $image->Thumb($replacevalue, $thumbpath, $block['picwidth'], $block['picheight'], 2))) {
                                /*vot*/
                                $picflag = 0;
                                //common_block_pic table: picflag identity (0 = local, 1 = remote)
                                $_G['block_makethumb'] = true;
                            }
                            if ($_G['block_makethumb']) {
                                DB::update('common_block_item', array('makethumb' => 1, 'thumbpath' => $thumbpath), $where);
                                $thumbdata = array('bid' => $block['bid'], 'itemid' => $blockitem['itemid'], 'pic' => $thumbpath, 'picflag' => $picflag, 'type' => '0');
                                DB::insert('common_block_pic', $thumbdata);
                            }
                        }
                    }
                }
                $searcharr[] = '{' . $key . '}';
                $replacearr[] = $replacevalue;
                if ($block['hidedisplay']) {
                    $_G['block_' . $bid][$order - 1][$key] = $replacevalue;
                }
            }
            foreach ($rtpl as $k => $str_template) {
                if ($str_template) {
                    $str_template = preg_replace('/title=[\'"]{title}[\'"]/', 'title="{title-title}"', $str_template);
                    $str_template = preg_replace('/alt=[\'"]{title}[\'"]/', 'alt="{alt-title}"', $str_template);
                    $rvalue[$k] .= str_replace($searcharr, $replacearr, $str_template);
                    $dynamicparts[$rkey[$k]] = array($rpattern[$k], $rvalue[$k]);
                }
            }
        }
        // foreach($block['itemlist'] as $itemid=>$blockitem) {
        foreach ($dynamicparts as $value) {
            $template = stripslashes(preg_replace($value[0], preg_quote($value[1]), $template));
        }
    }
    $template = preg_replace('/\\s*\\[(order\\d{0,1})=\\w+\\](.*?)\\[\\/\\1\\]\\s*/is', '', $template);
    $template = preg_replace('/\\s*\\[(index\\d{0,1})=\\w+\\](.*?)\\[\\/\\1\\]\\s*/is', '', $template);
    $template = preg_replace('/\\s*\\[(loop\\d{0,1})\\](.*?)\\[\\/\\1\\]\\s*/is', '', $template);
    return $template;
}
Beispiel #17
0
function QQGroupUpload($tid) {
	global $_G;
	$imageDir = 'qqgroup';
	$imageName = 'miniportal_tid_'.$tid.'.jpg';
	$fieldName = 'imageFile';

	$_FILES[$fieldName]['name'] = addslashes(urldecode($_FILES[$fieldName]['name']));
	$_FILES[$fieldName]['type'] = addslashes(urldecode($_FILES[$fieldName]['type']));
	$upload = new discuz_upload();
	$upload->init($_FILES[$fieldName]);
	$attach = & $upload->attach;

	if (!$attach['isimage']) {
		return false;
	}
	if ($attach['size'] > 5000000) {
		return false;
	}

	$upload->save();

	list($imgwidth, $imgheight) = $attach['imageinfo'];
	if($imgwidth < 75 || $imgheight < 75) {
		@unlink($attach['target']);
		return false;
	}

	require_once libfile('class/image');
	$image = new image;
	$image->param['thumbquality'] = 100;
	$thumbTarget = $imageDir.'/'.$imageName;
	@unlink($_G['setting']['attachdir'].'./'.$thumbTarget);

	$thumb = $image->Thumb($attach['target'], $thumbTarget, 75, 75) ? 1 : 0;

	if(!$thumb && !@copy($attach['target'], $_G['setting']['attachdir'].'./'.$thumbTarget)) {
		@unlink($attach['target']);
		return false;
	}

	@unlink($attach['target']);

	$res = $attach;
	$res['thumbTarget'] = $thumbTarget;

	return $res;

}
        $dragpl = ($cbgboxheight - $cboxheight) / 2;
    } else {
        $prefix = $_GET['picflag'] == 2 ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl'];
    }
    include_once template("common/misc_imgcropper");
} else {
    $cropfile = md5($_GET['cutimg']) . '.jpg';
    $ictype = $_GET['ictype'];
    if ($ictype == 'block') {
        require_once libfile('function/block');
        $block = C::t('common_block')->fetch($_GET['bid']);
        $cropfile = block_thumbpath($block, array('picflag' => intval($_GET['picflag']), 'pic' => $_GET['cutimg']));
        $cutwidth = $block['picwidth'];
        $cutheight = $block['picheight'];
    } else {
        $cutwidth = $_GET['cutwidth'];
        $cutheight = $_GET['cutheight'];
    }
    $top = intval($_GET['cuttop'] < 0 ? 0 : $_GET['cuttop']);
    $left = intval($_GET['cutleft'] < 0 ? 0 : $_GET['cutleft']);
    $picwidth = $cutwidth > $_GET['picwidth'] ? $cutwidth : $_GET['picwidth'];
    $picheight = $cutheight > $_GET['picheight'] ? $cutheight : $_GET['picheight'];
    require_once libfile('class/image');
    $image = new image();
    $prefix = $_GET['picflag'] == 2 ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl'];
    if (!$image->Thumb($prefix . $_GET['cutimg'], $cropfile, $picwidth, $picheight)) {
        showmessage('imagepreview_errorcode_' . $image->errorcode, null, null, array('showdialog' => true, 'closetime' => true));
    }
    $image->Cropper($image->target, $cropfile, $cutwidth, $cutheight, $left, $top);
    showmessage('do_success', dreferer(), array('icurl' => $cropfile), array('showdialog' => true, 'closetime' => true));
}
function upload_icon_banner(&$data, $file, $type)
{
    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));
    }
    $upload = new discuz_upload();
    $uploadtype = $data['status'] == 3 ? 'group' : 'common';
    if (!$upload->init($file, $uploadtype, $data['extid'], $type)) {
        return false;
    }
    if (!$upload->save()) {
        if (!defined('IN_ADMINCP')) {
            showmessage($upload->errormessage());
        } else {
            cpmsg($upload->errormessage(), '', 'error');
        }
    }
    if ($data['status'] == 3 && $type == 'icon') {
        require_once libfile('class/image');
        $img = new image();
        $img->Thumb($upload->attach['target'], './' . $uploadtype . '/' . $upload->attach['attachment'], 48, 48, 'fixwr');
    }
    return $upload->attach['attachment'];
}
Beispiel #20
0
 $targetPath = $attachDir . '/' . $newFilename;
 //DEBUG 阿里云OSS处理 TODO 待优化示例 http://help.aliyun.com/manual?spm=0.0.0.0.vVdtHC&helpId=181
 if ($_G['setting']['aliyun_oss']) {
     upload_file($tempPath, $targetPath);
 } else {
     rename($tempPath, $targetPath);
     @chmod($targetPath, 0755);
 }
 //DEBUG 生成缩略图
 if ($thumb == 1 && !empty($thumb_width) && !empty($thumb_height)) {
     list($img_width, $img_height) = getimagesize($targetPath);
     $thumbfile = '../' . $attachSubDir . '/' . $newFilename . '_small.jpg';
     if ($img_width > $thumb_width || $img_height > $thumb_height) {
         require_once libfile('class/image');
         $img = new image();
         if (!$img->Thumb($targetPath, $thumbfile, $thumb_width, $thumb_height)) {
             $return_array = array("errcode" => 'e_2013', "errmsg" => lang('error', 'e_2013'), "data" => $msg);
             echo json_ext($return_array);
             //echo "{'err':'".lang('error','e_2013')."','msg':".$msg."}";
             die;
         }
     } else {
         upload_file($targetPath, $targetPath . '_small.jpg');
     }
 }
 $target_path = str_replace(SITE_ROOT, '', $targetPath);
 $target_path_json = jsonString($target_path);
 if ($msgType == 1) {
     $msg = "'{$target_path_json}'";
 } else {
     $msg = array('url' => $target_path, 'file_name' => $file_name);
Beispiel #21
0
     }
 }
 topic_checkperm($topic);
 $upload = new discuz_upload();
 $upload->init($_FILES['attach'], 'portal');
 $attach = $upload->attach;
 if (!$upload->error()) {
     $upload->save();
 }
 if ($upload->error()) {
     topic_upload_error($attach, $upload->error());
 } else {
     if ($attach['isimage']) {
         require_once libfile('class/image');
         $image = new image();
         $attach['thumb'] = $image->Thumb($attach['target'], '', '80', '50');
     }
     if (getglobal('setting/ftp/on')) {
         if (ftpcmd('upload', 'portal/' . $attach['attachment'])) {
             if ($attach['thumb']) {
                 ftpcmd('upload', 'portal/' . getimgthumbname($attach['attachment']));
             }
             $attach['remote'] = 1;
         } else {
             if (getglobal('setting/ftp/mirror')) {
                 @unlink($attach['target']);
                 @unlink(getimgthumbname($attach['target']));
                 topic_upload_error($attach, 'diy_remote_upload_failed');
             }
         }
     }
Beispiel #22
0
function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name = '', $title = '', $delsize = 0, $from = false)
{
    global $_G, $space;
    if ($albumid < 0) {
        $albumid = 0;
    }
    $allowPicType = array('jpg', 'jpeg', 'gif', 'png');
    if (!in_array($fileext, $allowPicType)) {
        return -3;
    }
    $setarr = array();
    $upload = new discuz_upload();
    $filepath = $upload->get_target_dir('album') . $upload->get_target_filename('album') . '.' . $fileext;
    $newfilename = $_G['setting']['attachdir'] . './album/' . $filepath;
    if ($handle = fopen($newfilename, 'wb')) {
        if (fwrite($handle, $strdata) !== FALSE) {
            fclose($handle);
            $size = filesize($newfilename);
            if (empty($space)) {
                $_G['member'] = $space = getuserbyuid($_G['uid']);
                $_G['username'] = $space['username'];
            }
            $_G['member'] = $space;
            loadcache('usergroup_' . $space['groupid']);
            $_G['group'] = $_G['cache']['usergroup_' . $space['groupid']];
            $maxspacesize = checkperm('maxspacesize');
            if ($maxspacesize) {
                space_merge($space, 'count');
                space_merge($space, 'field_home');
                if ($space['attachsize'] + $size - $delsize > $maxspacesize + $space['addsize'] * 1024 * 1024) {
                    @unlink($newfilename);
                    return -1;
                }
            }
            if (!$upload->get_image_info($newfilename)) {
                @unlink($newfilename);
                return -2;
            }
            require_once libfile('class/image');
            $image = new image();
            $result = $image->Thumb($newfilename, NULL, 140, 140, 1);
            $thumb = empty($result) ? 0 : 1;
            $image->Watermark($newfilename);
            $pic_remote = 0;
            $album_picflag = 1;
            if (getglobal('setting/ftp/on')) {
                $ftpresult_thumb = 0;
                $ftpresult = ftpcmd('upload', 'album/' . $filepath);
                if ($ftpresult) {
                    @unlink($_G['setting']['attachdir'] . 'album/' . $filepath);
                    if ($thumb) {
                        $thumbpath = getimgthumbname($filepath);
                        ftpcmd('upload', 'album/' . $thumbpath);
                        @unlink($_G['setting']['attachdir'] . 'album/' . $thumbpath);
                    }
                    $pic_remote = 1;
                    $album_picflag = 2;
                } else {
                    if (getglobal('setting/ftp/mirror')) {
                        @unlink($newfilename);
                        @unlink(getimgthumbname($newfilename));
                        return -3;
                    }
                }
            }
            $filename = $name ? $name : substr(strrchr($filepath, '/'), 1);
            $title = getstr($title, 200);
            $title = censor($title);
            if (censormod($title) || $_G['group']['allowuploadmod']) {
                $pic_status = 1;
            } else {
                $pic_status = 0;
            }
            if ($albumid) {
                $albumid = album_creat_by_id($albumid);
            } else {
                $albumid = 0;
            }
            $setarr = array('albumid' => $albumid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'filename' => $filename, 'postip' => $_G['clientip'], 'title' => $title, 'type' => $fileext, 'size' => $size, 'filepath' => $filepath, 'thumb' => $thumb, 'remote' => $pic_remote, 'status' => $pic_status);
            $setarr['picid'] = C::t('home_pic')->insert($setarr, 1);
            C::t('common_member_count')->increase($_G['uid'], array('attachsize' => $size));
            include_once libfile('function/stat');
            updatestat('pic');
            return $setarr;
        } else {
            fclose($handle);
        }
    }
    return -3;
}
Beispiel #23
0
     @unlink($attach['target']);
     continue;
 }
 $attach['size'] = filesize($attach['target']);
 $upload->attach = $attach;
 $thumb = $width = 0;
 if ($upload->attach['isimage']) {
     if ($_G['setting']['thumbsource'] && $_G['setting']['sourcewidth'] && $_G['setting']['sourceheight']) {
         $image = new image();
         $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']) {
         $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]';
 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);
 }
Beispiel #25
0
 /**
  * 上传至uc头像
  */
 public static function upload($uid, $localFile)
 {
     global $_G;
     if (!$uid || !$localFile) {
         return false;
     }
     list($width, $height, $type, $attr) = getimagesize($localFile);
     if (!$width) {
         return false;
     }
     if ($width < 10 || $height < 10 || $type == 4) {
         return false;
     }
     $imageType = array(1 => '.gif', 2 => '.jpg', 3 => '.png');
     $fileType = $imgType[$type];
     if (!$fileType) {
         $fileType = '.jpg';
     }
     $avatarPath = $_G['setting']['attachdir'];
     $tmpAvatar = $avatarPath . './temp/upload' . $uid . $fileType;
     file_exists($tmpAvatar) && @unlink($tmpAvatar);
     file_put_contents($tmpAvatar, file_get_contents($localFile));
     if (!is_file($tmpAvatar)) {
         return false;
     }
     $tmpAvatarBig = './temp/upload' . $uid . 'big' . $fileType;
     $tmpAvatarMiddle = './temp/upload' . $uid . 'middle' . $fileType;
     $tmpAvatarSmall = './temp/upload' . $uid . 'small' . $fileType;
     $image = new image();
     if ($image->Thumb($tmpAvatar, $tmpAvatarBig, 200, 250, 1) <= 0) {
         return false;
     }
     if ($image->Thumb($tmpAvatar, $tmpAvatarMiddle, 120, 120, 1) <= 0) {
         return false;
     }
     if ($image->Thumb($tmpAvatar, $tmpAvatarSmall, 48, 48, 2) <= 0) {
         return false;
     }
     $tmpAvatarBig = $avatarPath . $tmpAvatarBig;
     $tmpAvatarMiddle = $avatarPath . $tmpAvatarMiddle;
     $tmpAvatarSmall = $avatarPath . $tmpAvatarSmall;
     $avatar1 = self::byte2hex(file_get_contents($tmpAvatarBig));
     $avatar2 = self::byte2hex(file_get_contents($tmpAvatarMiddle));
     $avatar3 = self::byte2hex(file_get_contents($tmpAvatarSmall));
     $extra = '&avatar1=' . $avatar1 . '&avatar2=' . $avatar2 . '&avatar3=' . $avatar3;
     $result = self::uc_api_post_ex('user', 'rectavatar', array('uid' => $uid), $extra);
     @unlink($tmpAvatar);
     @unlink($tmpAvatarBig);
     @unlink($tmpAvatarMiddle);
     @unlink($tmpAvatarSmall);
     return true;
 }
Beispiel #26
0
         $settingnew['imageimpath'] = str_replace('\\', '/', $settingnew['imageimpath']);
         if (!preg_match('/^[\\!@#\\$%\\^&\\(\\)_\\+\\-\\=\\{\\}\\[\\];\',\\.\\/\\:\\w\\s]+$/', $settingnew['imageimpath'])) {
             $settingnew['imageimpath'] = '';
         }
     }
     $_G['setting']['imagelib'] = $settingnew['imagelib'];
     $_G['setting']['imageimpath'] = $settingnew['imageimpath'];
     $_G['setting']['thumbwidth'] = $settingnew['thumbwidth'];
     $_G['setting']['thumbheight'] = $settingnew['thumbheight'];
     $_G['setting']['thumbquality'] = $settingnew['thumbquality'];
     require_once libfile('class/image');
     @unlink(DISCUZ_ROOT . $_G['setting']['attachdir'] . './temp/watermark_temp1.jpg');
     @unlink(DISCUZ_ROOT . $_G['setting']['attachdir'] . './temp/watermark_temp2.jpg');
     $image = new image();
     $r = 0;
     if (!($r = $image->Thumb(DISCUZ_ROOT . './static/image/admincp/watermarkpreview.jpg', 'temp/watermark_temp1.jpg', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], 1))) {
         $r = $image->error();
     }
     $sizetarget1 = $image->imginfo['size'];
     $image->Thumb(DISCUZ_ROOT . './static/image/admincp/watermarkpreview.jpg', 'temp/watermark_temp2.jpg', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], 2);
     $sizetarget2 = $image->imginfo['size'];
     if ($r > 0) {
         showsubmenu('imagepreview_thumb');
         $sizesource = filesize(DISCUZ_ROOT . './static/image/admincp/watermarkpreview.jpg');
         echo '<img src="data/attachment/temp/watermark_temp1.jpg?' . random(5) . '"><br /><br />' . $lang['imagepreview_imagesize_source'] . ' ' . number_format($sizesource) . ' Bytes &nbsp;&nbsp;' . $lang['imagepreview_imagesize_target'] . ' ' . number_format($sizetarget1) . ' Bytes (' . sprintf("%2.1f", $sizetarget1 / $sizesource * 100) . '%)<br /><br />';
         echo '<img src="data/attachment/temp/watermark_temp2.jpg?' . random(5) . '"><br /><br />' . $lang['imagepreview_imagesize_source'] . ' ' . number_format($sizesource) . ' Bytes &nbsp;&nbsp;' . $lang['imagepreview_imagesize_target'] . ' ' . number_format($sizetarget2) . ' Bytes (' . sprintf("%2.1f", $sizetarget2 / $sizesource * 100) . '%)';
     } else {
         cpmsg('imagepreview_errorcode_' . $r, '', 'error');
     }
 } else {
     $type = $_GET['type'];
Beispiel #27
0
function dzz_backimg_save($FILE, $dir = 'appimg')
{
    global $_G;
    $allowpictype = array('jpg', 'jpeg', 'gif', 'png');
    $upload = new dzz_upload();
    $upload->init($FILE, $dir);
    if ($upload->error()) {
        return $upload->errormessage();
    }
    if (!$upload->attach['isimage']) {
        return '只能上传图片文件';
    }
    $upload->save();
    if ($upload->error()) {
        return '保存失败';
    }
    $setarr = array('filepath' => $dir . '/' . $upload->attach['attachment'], 'thumb' => 0);
    //生成缩略图
    require_once libfile('class/image');
    $image = new image();
    if ($thumb = $image->Thumb($_G['setting']['attachurl'] . $setarr['filepath'], '', 101, 101, 1)) {
        $setarr['thumb'] = $thumb;
    }
    return $setarr;
}
Beispiel #28
0
 $_FILES["Filedata"]['name'] = addslashes(diconv(urldecode($_FILES["Filedata"]['name']), 'UTF-8'));
 $upload->init($_FILES['Filedata'], 'portal');
 $attach = $upload->attach;
 if (!$upload->error()) {
     $upload->save();
 }
 if ($upload->error()) {
     $errorcode = 4;
 }
 if (!$errorcode) {
     if ($attach['isimage'] && empty($_G['setting']['portalarticleimgthumbclosed'])) {
         require_once libfile('class/image');
         $image = new image();
         $thumbimgwidth = $_G['setting']['portalarticleimgthumbwidth'] ? $_G['setting']['portalarticleimgthumbwidth'] : 300;
         $thumbimgheight = $_G['setting']['portalarticleimgthumbheight'] ? $_G['setting']['portalarticleimgthumbheight'] : 300;
         $attach['thumb'] = $image->Thumb($attach['target'], '', $thumbimgwidth, $thumbimgheight, 2);
         $image->Watermark($attach['target'], '', 'portal');
     }
     if (getglobal('setting/ftp/on') && (!$_G['setting']['ftp']['allowedexts'] && !$_G['setting']['ftp']['disallowedexts'] || $_G['setting']['ftp']['allowedexts'] && in_array($attach['ext'], $_G['setting']['ftp']['allowedexts']) || $_G['setting']['ftp']['disallowedexts'] && !in_array($attach['ext'], $_G['setting']['ftp']['disallowedexts'])) && (!$_G['setting']['ftp']['minsize'] || $attach['size'] >= $_G['setting']['ftp']['minsize'] * 1024)) {
         if (ftpcmd('upload', 'portal/' . $attach['attachment']) && (!$attach['thumb'] || ftpcmd('upload', 'portal/' . getimgthumbname($attach['attachment'])))) {
             @unlink($_G['setting']['attachdir'] . '/portal/' . $attach['attachment']);
             @unlink($_G['setting']['attachdir'] . '/portal/' . getimgthumbname($attach['attachment']));
             $attach['remote'] = 1;
         } else {
             if (getglobal('setting/ftp/mirror')) {
                 @unlink($attach['target']);
                 @unlink(getimgthumbname($attach['target']));
                 $errorcode = 5;
             }
         }
     }
Beispiel #29
0
function pic_upload($FILES, $type = 'album', $thumb_width = 0, $thumb_height = 0, $thumb_type = 2)
{
    $upload = new discuz_upload();
    $result = array('pic' => '', 'thumb' => 0, 'remote' => 0);
    $upload->init($FILES, $type);
    if ($upload->error()) {
        return array();
    }
    $upload->save();
    if ($upload->error()) {
        return array();
    }
    $result['pic'] = $upload->attach['attachment'];
    if ($thumb_width && $thumb_height) {
        require_once libfile('class/image');
        $image = new image();
        if ($image->Thumb($upload->attach['target'], '', $thumb_width, $thumb_height, $thumb_type)) {
            $result['thumb'] = 1;
        }
    }
    if (getglobal('setting/ftp/on')) {
        if (ftpcmd('upload', $type . '/' . $upload->attach['attachment'])) {
            if ($result['thumb']) {
                ftpcmd('upload', $type . '/' . getimgthumbname($upload->attach['attachment']));
            }
            ftpcmd('close');
            $result['remote'] = 1;
        } else {
            if (getglobal('setting/ftp/mirror')) {
                @unlink($upload->attach['target']);
                @unlink(getimgthumbname($upload->attach['target']));
                return array();
            }
        }
    }
    return $result;
}
Beispiel #30
0
function upload_images($file, $type, $thumbwidth = 176, $thumbheight = 176)
{
    global $_G;
    require_once libfile('class/upload');
    $upload = new discuz_upload();
    if (!$upload->init($file, $type)) {
        return false;
    }
    if (!$upload->save()) {
        if (!defined('IN_ADMINCP')) {
            showmessage($upload->errormessage());
        } else {
            cpmsg($upload->errormessage(), '', 'error');
        }
    }
    if (!empty($_G['cache']['modulelist'][$type]['mid'])) {
        $mid = $_G['cache']['modulelist'][$type]['mid'];
    } else {
        $_G['cache']['modulelist'][$type]['mid'] = $mid = DB::result_first("SELECT mid FROM " . DB::table('common_module') . " WHERE identifier='{$type}' AND available='1'");
    }
    $isimage = $upload->attach['isimage'] ? 1 : 0;
    $data = array('mid' => $mid, 'authorid' => $_G['uid'], 'filesize' => $upload->attach['size'], 'type' => $isimage, 'filename' => $upload->attach['name'], 'url' => $upload->attach['attachment']);
    $return = $upload->attach;
    DB::insert('common_attachment', $data, true);
    $return['aid'] = DB::insert_id();
    if (!$return['aid']) {
        if (!defined('IN_ADMINCP')) {
            showmessage('common_attachment_error');
        } else {
            cpmsg('common_attachment_error', '', 'error');
        }
    }
    require_once libfile('class/image');
    $image = new image();
    $source = $_G['setting']['attachdir'] . $type . '/' . $upload->attach['attachment'];
    $setting_thumbwidth = $thumbwidth > 10 && $thumbwidth < 1000 ? intval($thumbwidth) : 176;
    $setting_thumbheight = $thumbheight > 10 && $thumbheight < 1000 ? intval($thumbheight) : 176;
    $isthumb = $image->Thumb($source, '', $setting_thumbwidth, $setting_thumbheight);
    if (!$isthumb) {
        $thumbtarget = $_G['setting']['attachdir'] . $type . '/' . $upload->attach['attachment'] . '.thumb.jpg';
        $isthumb = @copy($source, $thumbtarget);
    }
    if (!$isthumb) {
        if (!defined('IN_ADMINCP')) {
            showmessage('thumb_error');
        } else {
            cpmsg('thumb_error', '', 'error');
        }
    }
    return $return;
}