本文整理汇总了PHP中discuz_upload类的典型用法代码示例。如果您正苦于以下问题:PHP discuz_upload类的具体用法?PHP discuz_upload怎么用?PHP discuz_upload使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了discuz_upload类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadFile
function uploadFile($file)
{
global $_G;
$upload = new discuz_upload();
if (!$upload->init($file, 'common', rand(0, 100000), 'bigapp_' . md5_file($file['tmp_name']))) {
returnData(7, 'init discuz init failed');
}
if (!$upload->save()) {
returnData(8, 'save file as attachment failed');
}
$url = $upload->attach['attachment'];
if (strpos($_G['setting']['attachurl'], 'http') === false) {
$url = $_G['siteurl'] . $_G['setting']['attachurl'] . 'common/' . $url;
} else {
$url = $_G['setting']['attachurl'] . 'common/' . $url;
}
return $url;
}
示例2: forum_upload
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);
}
}
示例3: unset
}
unset($setarr[$key]);
}
}
if ($_G['gp_deletefile'] && is_array($_G['gp_deletefile'])) {
foreach ($_G['gp_deletefile'] as $key => $value) {
if (isset($_G['cache']['profilesetting'][$key])) {
@unlink(getglobal('setting/attachdir') . './profile/' . $space[$key]);
@unlink(getglobal('setting/attachdir') . './profile/' . $verifyinfo['field'][$key]);
$verifyarr[$key] = $setarr[$key] = '';
}
}
}
if ($_FILES) {
require_once libfile('class/upload');
$upload = new discuz_upload();
foreach ($_FILES as $key => $file) {
if (!isset($_G['cache']['profilesetting'][$key])) {
continue;
}
if (!empty($file) && $file['error'] == 0 || !empty($space[$key]) && empty($_G['gp_deletefile'][$key])) {
$value = '1';
} else {
$value = '';
}
if (profile_check($key, $value, $space)) {
$upload->init($file, 'profile');
$attach = $upload->attach;
if (!$upload->error()) {
$upload->save();
if (!$upload->get_image_info($attach['target'])) {
示例4: elseif
} elseif (strlen($advnew['title']) > 50) {
cpmsg('adv_title_more', '', 'error');
} elseif ($advnew['endtime'] && ($advnew['endtime'] <= TIMESTAMP || $advnew['endtime'] <= $advnew['starttime'])) {
cpmsg('adv_endtime_invalid', '', 'error');
} elseif ($advnew['style'] == 'code' && !$advnew['code']['html'] || $advnew['style'] == 'text' && (!$advnew['text']['title'] || !$advnew['text']['link']) || $advnew['style'] == 'image' && (!$_FILES['advnewimage'] && !$_G['gp_advnewimage'] || !$advnew['image']['link']) || $advnew['style'] == 'flash' && (!$_FILES['advnewflash'] && !$_G['gp_advnewflash'] || !$advnew['flash']['width'] || !$advnew['flash']['height'])) {
cpmsg('adv_parameter_invalid', '', 'error');
}
if ($operation == 'add') {
$advid = DB::insert('advertisement', array('available' => 1, 'type' => $type), 1);
} else {
$type = DB::result_first("SELECT type FROM " . DB::table('advertisement') . " WHERE advid='{$advid}'");
}
if ($advnew['style'] == 'image' || $advnew['style'] == 'flash') {
if ($_FILES['advnew' . $advnew['style']]) {
require_once libfile('class/upload');
$upload = new discuz_upload();
if ($upload->init($_FILES['advnew' . $advnew['style']], 'common') && $upload->save()) {
$advnew[$advnew['style']]['url'] = $_G['setting']['attachurl'] . 'common/' . $upload->attach['attachment'];
}
} else {
$advnew[$advnew['style']]['url'] = $_G['gp_advnew' . $advnew['style']];
}
}
foreach ($advnew[$advnew['style']] as $key => $val) {
$advnew[$advnew['style']][$key] = dstripslashes($val);
}
$advnew['displayorder'] = isset($advnew['displayorder']) ? implode("\t", $advnew['displayorder']) : '';
$advnew['code'] = encodeadvcode($advnew);
$extra = $type != 'custom' ? '' : '&customid=' . $parameters['extra']['customid'];
$advnew['parameters'] = addslashes(serialize(array_merge(is_array($parameters) ? $parameters : array(), array('style' => $advnew['style']), $advnew['style'] == 'code' ? array() : $advnew[$advnew['style']], array('html' => $advnew['code']), array('displayorder' => $advnew['displayorder']))));
$advnew['code'] = addslashes($advnew['code']);
示例5: showmessage
} else {
showmessage('diy_export_tpl_invalid', '/');
}
}
showmessage('diy_operation_invalid', '/');
} elseif ($op == 'import') {
$tpl = $_POST['tpl'] ? $_POST['tpl'] : $_GET['tpl'];
tpl_checkperm($tpl);
if (submitcheck('importsubmit')) {
$isinner = false;
$filename = '';
if ($_POST['importfilename']) {
$filename = DISCUZ_ROOT . './template/default/portal/diyxml/' . $_POST['importfilename'] . '.xml';
$isinner = true;
} else {
$upload = new discuz_upload();
$upload->init($_FILES['importfile'], 'temp');
$attach = $upload->attach;
if (!$upload->error()) {
$upload->save();
}
if ($upload->error()) {
showmessage($upload->error(), 'portal.php', array('status' => $upload->error()));
} else {
$filename = $attach['target'];
}
}
if ($filename) {
$arr = import_diy($filename);
if (!$isinner) {
@unlink($filename);
示例6: stringtopic
function stringtopic($value, $key = '', $force = false, $rlength = 0)
{
if ($key === '') {
$key = $value;
}
$basedir = !getglobal('setting/attachdir') ? './data/attachment' : getglobal('setting/attachdir');
$url = !getglobal('setting/attachurl') ? './data/attachment/' : getglobal('setting/attachurl');
$subdir1 = substr(md5($key), 0, 2);
$subdir2 = substr(md5($key), 2, 2);
$target = 'temp/' . $subdir1 . '/' . $subdir2 . '/';
$targetname = substr(md5($key), 8, 16) . '.png';
discuz_upload::check_dir_exists('temp', $subdir1, $subdir2);
if (!$force && file_exists($basedir . '/' . $target . $targetname)) {
return $url . $target . $targetname;
}
$value = str_replace("\n", '', $value);
$fontfile = $fontname = '';
$ttfenabled = false;
$size = 10;
$w = 130;
$rowh = 25;
$value = explode("\r", $value);
if ($rlength) {
$temp = array();
foreach ($value as $str) {
$strlen = dstrlen($str);
if ($strlen > $rlength) {
for ($i = 0; $i < $strlen; $i++) {
$sub = cutstr($str, $rlength, '');
$temp[] = $sub;
$str = substr($str, strlen($sub));
$strlen = $strlen - $rlength;
}
} else {
$temp[] = $str;
}
}
$value = $temp;
unset($temp);
}
if (function_exists('imagettftext')) {
$fontroot = DISCUZ_ROOT . './static/image/seccode/font/ch/';
$dirs = opendir($fontroot);
while ($entry = readdir($dirs)) {
if ($entry != '.' && $entry != '..' && in_array(strtolower(fileext($entry)), array('ttf', 'ttc'))) {
$fontname = $entry;
break;
}
}
if (!empty($fontname)) {
$fontfile = DISCUZ_ROOT . './static/image/seccode/font/ch/' . $fontname;
}
if ($fontfile) {
if (strtoupper(CHARSET) != 'UTF-8') {
include DISCUZ_ROOT . './source/class/class_chinese.php';
$cvt = new Chinese(CHARSET, 'utf8');
$value = $cvt->Convert(implode("\r", $value));
$value = explode("\r", $value);
}
$ttfenabled = true;
}
}
foreach ($value as $str) {
if ($ttfenabled) {
$box = imagettfbbox($size, 0, $fontfile, $str);
$height = max($box[1], $box[3]) - min($box[5], $box[7]);
$len = max($box[2], $box[4]) - min($box[0], $box[6]);
$rowh = max(array($height, $rowh));
} else {
$len = strlen($str) * 12;
}
$w = max(array($len, $w));
}
$h = $rowh * count($value) + count($value) * 2;
$im = @imagecreate($w, $h);
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 60, 60, 60);
$h = $ttfenabled ? $rowh : 4;
foreach ($value as $str) {
if ($ttfenabled) {
imagettftext($im, $size, 0, 0, $h, $text_color, $fontfile, $str);
$h += 2;
} else {
imagestring($im, $size, 0, $h, $str, $text_color);
}
$h += $rowh;
}
imagepng($im, $basedir . '/' . $target . $targetname);
imagedestroy($im);
return $url . $target . $targetname;
}
示例7: save_to_local
function save_to_local($source, $target)
{
if (!discuz_upload::is_upload_file($source)) {
$succeed = false;
} elseif (@copy($source, $target)) {
$succeed = true;
} elseif (function_exists('move_uploaded_file') && @move_uploaded_file($source, $target)) {
$succeed = true;
} elseif (@is_readable($source) && @($fp_s = fopen($source, 'rb')) && @($fp_t = fopen($target, 'wb'))) {
while (!feof($fp_s)) {
$s = @fread($fp_s, 1024 * 512);
@fwrite($fp_t, $s);
}
fclose($fp_s);
fclose($fp_t);
$succeed = true;
}
if ($succeed) {
$this->errorcode = 0;
@chmod($target, 0644);
@unlink($source);
} else {
$this->errorcode = 0;
}
return $succeed;
}
示例8: template
}
} else {
if ($_G['gp_ac'] == "upload") {
if ($_G['gp_inajax'] != "yes") {
$imgexts = "jpg, jpeg, gif, png, bmp";
include template("pdnovel/upload");
} else {
if (!in_array(strrchr(strtolower($_FILES['file']['name']), "."), array(".gif", ".jpg", ".jpeg", ".bmp", ".png"))) {
novel_upload_error($upload->error());
}
if ($version == 'X2.5') {
require_once "source/class/discuz/discuz_upload.php";
} elseif ($version == 'X2') {
require_once "source/class/class_upload.php";
}
$upload = new discuz_upload();
$upload->init($_FILES['file']);
$attach = $upload->attach;
if (!$upload->error()) {
$upload->save();
}
if ($upload->error()) {
novel_upload_error($upload->error());
}
if ($attach) {
echo "data/attachment/temp/" . $attach['attachment'];
}
}
}
}
}
示例9: on_register
//.........这里部分代码省略.........
} elseif ($uid == -2) {
showmessage('profile_username_protect');
} elseif ($uid == -3) {
showmessage('profile_username_duplicate');
} elseif ($uid == -4) {
showmessage('profile_email_illegal');
} elseif ($uid == -5) {
showmessage('profile_email_domain_illegal');
} elseif ($uid == -6) {
showmessage('profile_email_duplicate');
} else {
showmessage('undefined_action');
}
}
} else {
list($uid, $username, $email) = $activation;
}
$_G['username'] = $username;
if (getuserbyuid($uid, 1)) {
if (!$activation) {
uc_user_delete($uid);
}
showmessage('profile_uid_duplicate', '', array('uid' => $uid));
}
$password = md5(random(10));
$secques = $questionid > 0 ? random(8) : '';
if (isset($_POST['birthmonth']) && isset($_POST['birthday'])) {
$profile['constellation'] = get_constellation($_POST['birthmonth'], $_POST['birthday']);
}
if (isset($_POST['birthyear'])) {
$profile['zodiac'] = get_zodiac($_POST['birthyear']);
}
if ($_FILES) {
$upload = new discuz_upload();
foreach ($_FILES as $key => $file) {
$field_key = 'field_' . $key;
if (!empty($_G['cache']['fields_register'][$field_key]) && $_G['cache']['fields_register'][$field_key]['formtype'] == 'file') {
$upload->init($file, 'profile');
$attach = $upload->attach;
if (!$upload->error()) {
$upload->save();
if (!$upload->get_image_info($attach['target'])) {
@unlink($attach['target']);
continue;
}
$attach['attachment'] = dhtmlspecialchars(trim($attach['attachment']));
if ($_G['cache']['fields_register'][$field_key]['needverify']) {
$verifyarr[$key] = $attach['attachment'];
} else {
$profile[$key] = $attach['attachment'];
}
}
}
}
}
if ($setregip !== null) {
if ($setregip == 1) {
C::t('common_regip')->update_count_by_ip($_G['clientip']);
} else {
C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => 1, 'dateline' => $_G['timestamp']));
}
}
if ($invite && $this->setting['inviteconfig']['invitegroupid']) {
$groupinfo['groupid'] = $this->setting['inviteconfig']['invitegroupid'];
}
$init_arr = array('credits' => explode(',', $this->setting['initcredits']), 'profile' => $profile, 'emailstatus' => $emailstatus);
示例10: on_register
//.........这里部分代码省略.........
showmessage('profile_username_protect');
} elseif ($uid == -3) {
showmessage('profile_username_duplicate');
} elseif ($uid == -4) {
showmessage('profile_email_illegal');
} elseif ($uid == -5) {
showmessage('profile_email_domain_illegal');
} elseif ($uid == -6) {
showmessage('profile_email_duplicate');
} else {
showmessage('undefined_action');
}
}
} else {
list($uid, $username, $email) = $activation;
}
$_G['username'] = $username;
if (DB::result_first("SELECT uid FROM " . DB::table('common_member') . " WHERE uid='{$uid}'")) {
if (!$activation) {
uc_user_delete($uid);
}
showmessage('profile_uid_duplicate', '', array('uid' => $uid));
}
$password = md5(random(10));
$secques = $questionid > 0 ? random(8) : '';
if (isset($_POST['birthmonth']) && isset($_POST['birthday'])) {
$profile['constellation'] = get_constellation($_POST['birthmonth'], $_POST['birthday']);
}
if (isset($_POST['birthyear'])) {
$profile['zodiac'] = get_zodiac($_POST['birthyear']);
}
if ($_FILES) {
require_once libfile('class/upload');
$upload = new discuz_upload();
foreach ($_FILES as $key => $file) {
$field_key = 'field_' . $key;
if (!empty($_G['cache']['fields_register'][$field_key]) && $_G['cache']['fields_register'][$field_key]['formtype'] == 'file') {
$upload->init($file, 'profile');
$attach = $upload->attach;
if (!$upload->error()) {
$upload->save();
if (!$upload->get_image_info($attach['target'])) {
@unlink($attach['target']);
continue;
}
$attach['attachment'] = dhtmlspecialchars(trim($attach['attachment']));
if ($_G['cache']['fields_register'][$field_key]['needverify']) {
$verifyarr[$key] = $attach['attachment'];
} else {
$profile[$key] = $attach['attachment'];
}
}
}
}
}
if ($regipsql) {
DB::query($regipsql);
}
if ($invite && $this->setting['inviteconfig']['invitegroupid']) {
$groupinfo['groupid'] = $this->setting['inviteconfig']['invitegroupid'];
}
$init_arr = explode(',', $this->setting['initcredits']);
$userdata = array('uid' => $uid, 'username' => $username, 'password' => $password, 'email' => $email, 'adminid' => 0, 'groupid' => $groupinfo['groupid'], 'regdate' => TIMESTAMP, 'credits' => $init_arr[0], 'timeoffset' => 9999);
$status_data = array('uid' => $uid, 'regip' => $_G['clientip'], 'lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP, 'lastpost' => 0, 'lastsendmail' => 0);
$profile['uid'] = $uid;
$field_forum['uid'] = $uid;
示例11: exit
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: portalcp_upload.php 30107 2012-05-11 02:10:58Z svn_project_zhangjie $
*/
if (!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$operation = $_GET['op'] ? $_GET['op'] : '';
$upload = new discuz_upload();
$downremotefile = false;
$aid = intval(getgpc('aid'));
$catid = intval(getgpc('catid'));
if ($aid) {
$article = C::t('portal_article_title')->fetch($aid);
if (!$article) {
portal_upload_error(lang('portalcp', 'article_noexist'));
}
if (check_articleperm($catid, $aid, $article, false, true) !== true) {
portal_upload_error(lang('portalcp', 'article_noallowed'));
}
} else {
if (($return = check_articleperm($catid, $aid, null, false, true)) !== true) {
portal_upload_error(lang('portalcp', $return));
}
}
if ($operation == 'downremotefile') {
$arrayimageurl = $temp = $imagereplace = array();
示例12: onVideoAuthAuth
function onVideoAuthAuth($uId, $picData, $picExt = 'jpg', $isReward = false)
{
global $_G;
$res = $this->getUserSpace($uId);
if (!$res) {
return new ErrorResponse('1', "User({$uId}) Not Exists");
}
$allowPicType = array('jpg', 'jpeg', 'gif', 'png');
if (in_array($picExt, $allowPicType)) {
$pic = base64_decode($picData);
if (!$pic || strlen($pic) == strlen($picData)) {
$errCode = '200';
$errMessage = 'Error argument';
return new ErrorResponse($errCode, $errMessage);
}
$secret = md5($_G['timestamp'] . "\t" . $_G['uid']);
$picDir = DISCUZ_ROOT . './data/avatar/' . substr($secret, 0, 1);
if (!is_dir($picDir)) {
if (!mkdir($picDir, 0777)) {
$errCode = '300';
$errMessage = 'Cannot create directory';
return new ErrorResponse($errCode, $errMessage);
}
}
$picDir .= '/' . substr($secret, 1, 1);
if (!is_dir($picDir)) {
if (!@mkdir($picDir, 0777)) {
$errCode = '300';
$errMessage = 'Cannot create directory';
return new ErrorResponse($errCode, $errMessage);
}
}
$picPath = $picDir . '/' . $secret . '.' . $picExt;
$fp = @fopen($picPath, 'wb');
if ($fp) {
if (fwrite($fp, $pic) !== FALSE) {
fclose($fp);
require_once libfile('class/upload');
$upload = new discuz_upload();
if (!$upload->get_image_info($picPath)) {
@unlink($picPath);
} else {
DB::update('common_member', array('videophotostatus' => 1), array('uid' => $uId));
$count = DB::result(DB::query("SELECT COUNT(*) FROM " . DB::table('common_member_verify') . " WHERE uid='{$uId}'"), 0);
if (!$count) {
DB::insert('common_member_verify', array('uid' => $uId, 'verify7' => 1));
} else {
DB::update('common_member_verify', array('verify7' => 1), array('uid' => $uId));
}
$fields = array('videophoto' => $secret);
DB::update('common_member_field_home', $fields, array('uid' => $uId));
$result = DB::affected_rows();
if ($isReward) {
updatecreditbyaction('videophoto', $uId);
}
return $result;
}
}
fclose($fp);
}
}
$errCode = '300';
$errMessage = 'Video Auth Error';
return new ErrorResponse($errCode, $errMessage);
}
示例13: threadsort_insertfile
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}'");
}
}
示例14: dhtmlspecialchars
} else {
$chezhengname = dhtmlspecialchars(trim($_GET['chezhengname']));
$chezhengtitle = strip_tags(trim($_GET['chezhengtitle']));
$status = intval($_GET['status']);
$createtime = strtotime($_GET['createtime']);
$description = dhtmlspecialchars(trim($_GET['description']));
$chezhengsort = trim($_GET['chezhengsort']);
if (!$chezhengname) {
cpmsg(lang('plugin/yiqixueba', 'chezhengname_invalid'), '', 'error');
}
if (!ispluginkey($chezhengname)) {
cpmsg(lang('plugin/yiqixueba', 'chezhengname_invalid'), '', 'error');
}
$ico = addslashes($_GET['chezhengimages']);
if ($_FILES['chezhengimages']) {
$upload = new discuz_upload();
if ($upload->init($_FILES['chezhengimages'], 'common') && $upload->save()) {
$ico = $upload->attach['attachment'];
}
}
if ($_POST['delete'] && addslashes($_POST['chezhengimages'])) {
$valueparse = parse_url(addslashes($_POST['chezhengimages']));
if (!isset($valueparse['host']) && !strexists(addslashes($_POST['chezhengimages']), '{STATICURL}')) {
@unlink($_G['setting']['attachurl'] . 'common/' . addslashes($_POST['chezhengimages']));
}
$ico = '';
}
$data = array('chezhengname' => $chezhengname, 'chezhengtitle' => $chezhengtitle, 'description' => $description, 'chezhengimages' => $ico, 'chezhengsort' => $chezhengsort, 'status' => $status, 'createtime' => $createtime);
if ($chezhengid) {
$data['updatetime'] = time();
C::t(GM('cheyouhui_' . $infotype))->update($chezhengid, $data);
示例15: sanree_common_upload
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']) {
//.........这里部分代码省略.........