📄 post.func.php
字号:
imageJPEG($dst_photo, $target, $watermarkquality);
break;
case 'image/gif':
imageGIF($dst_photo, $target);
break;
case 'image/png':
imagePNG($dst_photo, $target);
break;
}
}
$attach['size'] = filesize($target);
}
}
$attach['remote'] = ftpupload($target, $attach['attachment'], $attach['thumb']);
$attach['perm'] = $allowsetattachperm ? $attachperm[$key] : 0;
$attach['description'] = cutstr(dhtmlspecialchars($attachdesc[$key]), 100);
$attach['price'] = $maxprice ? (intval($attachprice[$key]) <= $maxprice ? intval($attachprice[$key]) : $maxprice) : 0;
$attacharray[$key] = $attach;
}
} else {
upload_error('post_attachment_save_error', $attacharray);
}
}
return !empty($attacharray) ? $attacharray : false;
}
function upload_error($message, $attacharray = array()) {
if(!empty($attacharray)) {
foreach($attacharray as $attach) {
@unlink($GLOBALS['attachdir'].'/'.$attach['attachment']);
}
}
showmessage($message);
}
$ftp['pwd'] = FALSE;
function ftpupload($source, $dest, $havethumb = 0) {
global $authkey, $ftp;
if($ftp['on']) {
require_once DISCUZ_ROOT.'./include/ftp.func.php';
if(!$ftp['connid']) {
if(!($ftp['connid'] = dftp_connect($ftp['host'], $ftp['username'], authcode($ftp['password'], 'DECODE', md5($authkey)), $ftp['attachdir'], $ftp['port'], $ftp['ssl']))) {
return 0;
}
$ftp['pwd'] = FALSE;
}
$tmp = explode('/', $dest);
if(count($tmp) > 1) {
if(!$ftp['pwd'] && !dftp_chdir($ftp['connid'], $tmp[0])) {
if(!dftp_mkdir($ftp['connid'], $tmp[0])) {
errorlog('FTP', "Mkdir '$ftp[attachdir]/$tmp[0]' error.", 0);
return 0;
}
if(!function_exists('ftp_chmod') || !dftp_chmod($ftp['connid'], 0777, $tmp[0])) {
dftp_site($ftp['connid'], "'CHMOD 0777 $tmp[0]'");
}
if(!dftp_chdir($ftp['connid'], $tmp[0])) {
errorlog('FTP', "Chdir '$ftp[attachdir]/$tmp[0]' error.", 0);
return 0;
}
dftp_put($ftp['connid'], 'index.htm', $GLOBALS['attachdir'].'/index.htm', FTP_BINARY);
}
$dest = $tmp[1];
$ftp['pwd'] = TRUE;
}
if(dftp_put($ftp['connid'], $dest, $source, FTP_BINARY)) {
if($havethumb) {
if(dftp_put($ftp['connid'], $dest.'.thumb.jpg', $source.'.thumb.jpg', FTP_BINARY)) {
@unlink($source);
@unlink($source.'.thumb.jpg');
return 1;
} else {
dftp_delete($ftp['connid'], $dest);
}
} else {
@unlink($source);
return 1;
}
}
errorlog('FTP', "Upload '$source' error.", 0);
}
return 0;
}
function checkflood() {
global $db, $tablepre, $disablepostctrl, $floodctrl, $maxpostsperhour, $discuz_uid, $timestamp, $lastpost, $forum;
if(!$disablepostctrl && $discuz_uid) {
$floodmsg = $floodctrl && ($timestamp - $floodctrl <= $lastpost) ? 'post_flood_ctrl' : '';
if(empty($floodmsg) && $maxpostsperhour) {
$query = $db->query("SELECT COUNT(*) from {$tablepre}posts WHERE authorid='$discuz_uid' AND dateline>$timestamp-3600");
$floodmsg = ($userposts = $db->result($query, 0)) && ($userposts >= $maxpostsperhour) ? 'thread_maxpostsperhour_invalid' : '';
}
if(empty($floodmsg)) {
return FALSE;
} elseif(!defined('CURSCRIPT') || CURSCRIPT != 'wap') {
showmessage($floodmsg);
} else {
wapmsg($floodmsg);
}
}
return FALSE;
}
function checkpost() {
global $subject, $message, $disablepostctrl, $minpostsize, $maxpostsize;
if(strlen($subject) > 80) {
return 'post_subject_toolong';
}
if(!$disablepostctrl) {
if($maxpostsize && strlen($message) > $maxpostsize) {
return 'post_message_toolong';
} elseif($minpostsize && strlen(preg_replace("/\[quote\].+?\[\/quote\]/is", '', $message)) < $minpostsize) {
return 'post_message_tooshort';
}
}
return FALSE;
}
function checkbbcodes($message, $bbcodeoff) {
return !$bbcodeoff && !preg_match("/\[.+\]/s", $message) ? -1 : $bbcodeoff;
}
function checksmilies($message, $smileyoff) {
$smilies = array();
if(!empty($GLOBALS['_DCACHE']['smilies']) && is_array($GLOBALS['_DCACHE']['smilies'])) {
foreach($GLOBALS['_DCACHE']['smilies']['searcharray'] as $smiley) {
$smilies[] = substr($smiley, 1, -1);
}
}
return !$smileyoff && !preg_match('/'.implode('|', $smilies).'/', stripslashes($message)) ? -1 : $smileyoff;
}
function updatepostcredits($operator, $uidarray, $creditsarray) {
global $db, $tablepre, $discuz_uid, $timestamp;
$membersarray = $postsarray = array();
foreach((is_array($uidarray) ? $uidarray : array($uidarray)) as $id) {
$membersarray[intval(trim($id))]++;
}
foreach($membersarray as $uid => $posts) {
$postsarray[$posts][] = $uid;
}
$lastpostadd = $uidarray == $discuz_uid ? ", lastpost='$timestamp'" : '';
$creditsadd1 = '';
if(is_array($creditsarray)) {
foreach($creditsarray as $id => $addcredits) {
$creditsadd1 .= ", extcredits$id=extcredits$id$operator$addcredits*\$posts";
}
}
foreach($postsarray as $posts => $uidarray) {
$uids = implode(',', $uidarray);
eval("\$creditsadd2 = \"$creditsadd1\";");
$db->query("UPDATE {$tablepre}members SET posts=posts+('$operator$posts') $lastpostadd $creditsadd2 WHERE uid IN ($uids)", 'UNBUFFERED');
}
}
function updateattachcredits($operator, $uidarray, $creditsarray) {
global $db, $tablepre, $discuz_uid;
$creditsadd1 = '';
if(is_array($creditsarray)) {
foreach($creditsarray as $id => $addcredits) {
$creditsadd1[] = "extcredits$id=extcredits$id$operator$addcredits*\$attachs";
}
}
if(is_array($creditsadd1)) {
$creditsadd1 = implode(', ', $creditsadd1);
foreach($uidarray as $uid => $attachs) {
eval("\$creditsadd2 = \"$creditsadd1\";");
$db->query("UPDATE {$tablepre}members SET $creditsadd2 WHERE uid = $uid", 'UNBUFFERED');
}
}
}
function updateforumcount($fid) {
global $db, $tablepre, $lang;
$query = $db->query("SELECT COUNT(*) AS threadcount, SUM(t.replies)+COUNT(*) AS replycount
FROM {$tablepre}threads t, {$tablepre}forums f
WHERE f.fid='$fid' AND t.fid=f.fid AND t.displayorder>='0'");
extract($db->fetch_array($query));
$query = $db->query("SELECT tid, subject, author, lastpost, lastposter FROM {$tablepre}threads
WHERE fid='$fid' AND displayorder>='0' ORDER BY lastpost DESC LIMIT 1");
$thread = $db->fetch_array($query);
$thread['subject'] = addslashes($thread['subject']);
$thread['lastposter'] = $thread['author'] ? addslashes($thread['lastposter']) : $lang['anonymous'];
$db->query("UPDATE {$tablepre}forums SET posts='$replycount', threads='$threadcount', lastpost='$thread[tid]\t$thread[subject]\t$thread[lastpost]\t$thread[lastposter]' WHERE fid='$fid'", 'UNBUFFERED');
}
function updatethreadcount($tid, $updateattach = 0) {
global $db, $tablepre, $lang;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0'");
$replycount = $db->result($query, 0) - 1;
$query = $db->query("SELECT author, anonymous, dateline FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' ORDER BY dateline DESC LIMIT 1");
$lastpost = $db->fetch_array($query);
$lastpost['author'] = $lastpost['anonymous'] ? $lang['anonymous'] : addslashes($lastpost['author']);
if($updateattach) {
$query = $db->query("SELECT attachment FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' AND attachment>0 LIMIT 1");
$attachadd = ', attachment=\''.($db->num_rows($query)).'\'';
} else {
$attachadd = '';
}
$db->query("UPDATE {$tablepre}threads SET replies='$replycount', lastposter='$lastpost[author]', lastpost='$lastpost[dateline]' $attachadd WHERE tid='$tid'", 'UNBUFFERED');
}
function updatemodlog($tids, $action, $expiration = 0, $iscron = 0) {
global $db, $tablepre, $timestamp;
$uid = empty($iscron) ? $GLOBALS['discuz_uid'] : 0;
$username = empty($iscron) ? $GLOBALS['discuz_user'] : 0;
$expiration = empty($expiration) ? 0 : intval($expiration);
$data = $comma = '';
foreach(explode(',', str_replace(array('\'', ' '), array('', ''), $tids)) as $tid) {
if($tid) {
$data .= "{$comma} ('$tid', '$uid', '$username', '$timestamp', '$action', '$expiration', '1')";
$comma = ',';
}
}
!empty($data) && $db->query("INSERT INTO {$tablepre}threadsmod (tid, uid, username, dateline, action, expiration, status) VALUES $data", 'UNBUFFERED');
}
function isopera() {
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if(strpos($useragent, 'opera') !== false) {
preg_match('/opera(\/| )([0-9\.]+)/', $useragent, $regs);
return $regs[2];
}
return FALSE;
}
function deletethreadcaches($tids) {
global $cachethreadon;
if(!$cachethreadon) {
return FALSE;
}
include_once DISCUZ_ROOT.'./include/forum.func.php';
if(!empty($tids)) {
foreach(explode(',', $tids) as $tid) {
$fileinfo = getcacheinfo($tid);
@unlink($fileinfo['filename']);
}
}
return TRUE;
}
function arrayslice($array, $offset, $length) {
if(PHP_VERSION >= '5.0.2') {
return array_slice($array, $offset, $length, TRUE);
} else {
$array = array_chunk($array, $length, TRUE);
return $array[$offset / $length];
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -