Ejemplo n.º 1
0
    showsetting(lang('plugin/wechat', 'wsq_fid'), '', '', $forums, 0, 0, lang('plugin/wechat', 'wsq_fid_comment'));
    if (!empty($_G['setting']['domain']['root']['forum'])) {
        showsetting(lang('plugin/wechat', 'wsq_domain'), '', '', 'http://<input type="text" name="setting[wsq_domain]" class="txt" value="' . $setting['wsq_domain'] . '" style="width:100px; margin-right:0px;" >.' . $_G['setting']['domain']['root']['forum'], !function_exists('domain_create'), 0, lang('plugin/wechat', 'wsq_domain_comment'));
    } else {
        showsetting(lang('plugin/wechat', 'wsq_domain'), 'setting[wsq_domain]', '', 'text', 1, 0, lang('plugin/wechat', 'wsq_domain_comment'));
    }
    showsetting(lang('plugin/wechat', 'wechat_float_qrcode'), 'setting[wechat_float_qrcode]', $setting['wechat_float_qrcode'], 'radio');
    showsetting(lang('plugin/wechat', 'wsq_wapdefault'), 'setting[wsq_wapdefault]', $setting['wsq_wapdefault'], 'radio');
    showsubmit('settingsubmit');
    showtablefooter();
    showformfooter();
} else {
    if ($_FILES['wsq_sitelogo']['tmp_name']) {
        $upload = new discuz_upload();
        if (!$upload->init($_FILES['wsq_sitelogo'], 'common', random(3, 1), random(8)) || !$upload->save()) {
            cpmsg($upload->errormessage(), '', 'error');
        }
        $parsev = parse_url($_G['setting']['attachurl']);
        $_GET['setting']['wsq_sitelogo'] = ($parsev['host'] ? '' : $_G['siteurl']) . $_G['setting']['attachurl'] . 'common/' . $upload->attach['attachment'];
    } else {
        $_GET['setting']['wsq_sitelogo'] = $setting['wsq_sitelogo'];
    }
    if (!$_GET['setting']['wsq_fid']) {
        cpmsg(lang('plugin/wechat', 'wsq_fid_empty'), '', 'error');
    }
    if (!$setting['wsq_sitetoken']) {
        $siteinfo = wsq::register($_GET['setting']['wsq_sitename'], $_GET['setting']['wsq_siteurl'], $_GET['setting']['wsq_sitelogo'], $_GET['setting']['wsq_sitesummary'], $setting['wechat_mtype'], $setting['wechat_qrtype']);
        if (!$siteinfo || $siteinfo->code) {
            cpmsg(lang('plugin/wechat', 'wsq_api_register_error'), '', 'error');
        }
        $_GET['setting']['wsq_siteid'] = $siteinfo->res->siteid;
Ejemplo n.º 2
0
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'];
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
function threadsort_insertfile($tid, &$files, $sortid, $edit = 0, $modidentifier, $channel)
{
    global $_G;
    $allowtype = 'jpg, jpeg, gif, bmp, png';
    $newfiles = $aid = array();
    if (empty($tid)) {
        return;
    }
    if ($files['categoryimg']) {
        foreach ($files['categoryimg']['name'] as $key => $val) {
            $newfiles[$key]['name'] = $val;
            $newfiles[$key]['type'] = $files['categoryimg']['type'][$key];
            $newfiles[$key]['tmp_name'] = $files['categoryimg']['tmp_name'][$key];
            $newfiles[$key]['error'] = $files['categoryimg']['error'][$key];
            $newfiles[$key]['size'] = $files['categoryimg']['size'][$key];
        }
    } else {
        return;
    }
    require_once libfile('class/upload');
    $upload = new discuz_upload();
    $uploadtype = 'category';
    if ($channel['imageinfo']['watermarkstatus']) {
        require_once libfile('class/house_image');
        $image = new image($channel);
    }
    foreach ($newfiles as $key => $file) {
        if (!$upload->init($file, $uploadtype)) {
            continue;
        }
        if (!$upload->save()) {
            if (count($newfiles) == 1) {
                showmessage($upload->errormessage());
            }
        }
        $newattach[$key] = $upload->attach['attachment'];
        if ($channel['imageinfo']['watermarkstatus']) {
            $image->Watermark($upload->attach['target']);
        }
        DB::query("INSERT INTO " . DB::table('category_' . $modidentifier . '_pic') . " (tid, url, dateline) VALUES ('{$tid}', '" . $upload->attach['attachment'] . "', '" . TIMESTAMP . "')");
        $aid[$key] = DB::insert_id();
    }
    $attachnum = $edit ? intval(DB::result_first("SELECT COUNT(*) FROM " . DB::table('category_' . $modidentifier . '_pic') . " WHERE tid='{$tid}'")) : intval(count($aid));
    if (substr($_G['gp_coverpic'], 0, 4) == 'old_') {
        $newaid = substr($_G['gp_coverpic'], 4);
    } else {
        $_G['gp_coverpic'] = intval($_G['gp_coverpic']);
        if ($aid[$_G['gp_coverpic']]) {
            $newaid = $aid[$_G['gp_coverpic']];
        } else {
            $aid = array_slice($aid, 0, 1);
            $newaid = $aid[0];
        }
    }
    if (!empty($newaid)) {
        DB::query("UPDATE " . DB::table('category_sortvalue') . "{$sortid} SET attachid='{$newaid}', attachnum='{$attachnum}' WHERE tid='{$tid}'");
    }
}
Ejemplo n.º 5
0
function myupload_icon_banner($bid, &$data, $file, $uid)
{
    global $_G;
    $data['extid'] = empty($data['extid']) ? $data['fid'] : $data['extid'];
    if (empty($data['extid'])) {
        return '';
    }
    if ($data['status'] == 3 && $_G['setting']['group_imgsizelimit']) {
        $file['size'] > $_G['setting']['group_imgsizelimit'] * 1024 && showmessage('file_size_overflow', '', array('size' => $_G['setting']['group_imgsizelimit'] * 1024));
    }
    $appVer = $_G['setting']['version'];
    if ($appVer == 'X2') {
        require_once libfile('class/upload');
    }
    $upload = new discuz_upload();
    if (!$upload->init($file, 'category')) {
        return false;
    }
    if (!$upload->save()) {
        if (!defined('IN_ADMINCP')) {
            showmessage($upload->errormessage());
        } else {
            cpmsg($upload->errormessage(), '', 'error');
        }
    }
    $aid = getattachnewaid($uid);
    $insert = array('aid' => $aid, 'dateline' => $_G['timestamp'], 'filename' => censor($upload->attach['name']), 'filesize' => $upload->attach['size'], 'attachment' => $upload->attach['attachment'], 'isimage' => $upload->attach['isimage'], 'uid' => $uid, 'thumb' => $thumb, 'remote' => $remote, 'width' => $width);
    C::t('#sanree_brand#sanree_brand_attachment')->insert($insert);
    return array($upload->attach['attachment'], $aid);
}