$var) {
foreach($var as $id => $val) {
$attachments[$id][$key] = $val;
}
}
}
if(empty($attachments)) {
return FALSE;
}
foreach($attachments as $key => $attach) {
$attach_saved = false;
$attach['uid'] = $discuz_uid;
if(!disuploadedfile($attach['tmp_name']) || !($attach['tmp_name'] != 'none' && $attach['tmp_name'] && $attach['name'])) {
continue;
}
$filename = daddslashes($attach['name']);
$attach['ext'] = strtolower(fileext($attach['name']));
$extension = in_array($attach['ext'], $safeext) ? $attach['ext'] : 'attach';
if(in_array($attach['ext'], $imgext)) {
$attach['isimage'] = 1;
}else{
$attach['isimage'] = 0;
}
$attach['thumb'] = 0;
$attach['name'] = htmlspecialchars($attach['name'], ENT_QUOTES);
if(strlen($attach['name']) > 90) {
$attach['name'] = 'abbr_'.md5($attach['name']).'.'.$attach['ext'];
}
if($attachextensions && (!preg_match("/(^|\s|,)".preg_quote($attach['ext'], '/')."($|\s|,)/i", $attachextensions) || !$attach['ext'])) {
upload_error('post_attachment_ext_notallowed', $attacharray);
}
if(empty($attach['size'])) {
upload_error('post_attachment_size_invalid', $attacharray);
}
if($maxattachsize && $attach['size'] > $maxattachsize) {
upload_error('post_attachment_toobig', $attacharray);
}
$query = $db->query("SELECT maxsize FROM {$tablepre}attachtypes WHERE extension='".addslashes($attach['ext'])."'");
if($type = $db->fetch_array($query)) {
if($type['maxsize'] == 0) {
upload_error('post_attachment_ext_notallowed', $attacharray);
} elseif($attach['size'] > $type['maxsize']) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$typemaxsize = sizecount($type['maxsize']);
upload_error('post_attachment_type_toobig', $attacharray);
}
}
if($attach['size'] && $maxsizeperday) {
if(!isset($todaysize)) {
$query = $db->query("SELECT SUM(filesize) FROM {$tablepre}attachments
WHERE uid='$GLOBALS[discuz_uid]' AND dateline>'$GLOBALS[timestamp]'-86400");
$todaysize = intval($db->result($query, 0));
}
$todaysize += $attach['size'];
if($todaysize >= $maxsizeperday) {
upload_error('post_attachment_quota_exceed', $attacharray);
}
}
if($attachsave) {
switch($attachsave) {
case 1: $attach_subdir = 'forumid_'.$GLOBALS['fid']; break;
case 2: $attach_subdir = 'ext_'.$extension; break;
case 3: $attach_subdir = 'month_'.date('ym'); break;
case 4: $attach_subdir = 'day_'.date('ymd'); break;
}
$attach_dir = $attachdir.'/'.$attach_subdir;
if(!is_dir($attach_dir)) {
@mkdir($attach_dir, 0777);
@fclose(fopen($attach_dir.'/index.htm', 'w'));
}
$attach['attachment'] = $attach_subdir.'/';
} else {
$attach['attachment'] = '';
}
$attach['attachment'] .= preg_replace("/(php|phtml|php3|php4|jsp|exe|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\.|$)/i", "_\\1\\2",
date('Ymd').'_'.substr(md5($filename.microtime()), 12).random(12).'.'.$extension);
$target = $attachdir.'/'.$attach['attachment'];
if(@copy($attach['tmp_name'], $target) || (function_exists('move_uploaded_file') && @move_uploaded_file($attach['tmp_name'], $target))) {
@unlink($attach['tmp_name']);
$attach_saved = true;
}
if(!$attach_saved && @is_readable($attach['tmp_name'])) {
@$fp = fopen($attach['tmp_name'], 'rb');
@flock($fp, 2);
@$attachedfile = fread($fp, $attach['size']);
@fclose($fp);
@$fp = fopen($target, 'wb');
@flock($fp, 2);
if(@fwrite($fp, $attachedfile)) {
@unlink($attach['tmp_name']);
$attach_saved = true;
}
@fclose($fp);
}
if($attach_saved) {
@chmod($target, 0644);
if(in_array($attach['ext'], array('jpg', 'jpeg', 'gif', 'png', 'swf', 'bmp')) && function_exists('getimagesize') && !@getimagesize($target)) {
@unlink($target);
upload_error('post_attachment_ext_notallowed', $attacharray);
} else {
require_once DISCUZ_ROOT.'./include/image.class.php';
$image = new Image($attachedfile, $target, $attach);
if($image->imagecreatefromfunc && $image->imagefunc) {
$image->Thumb($thumbwidth, $thumbheight);
$image->Watermark();
$attach = $image->attach;
}
$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;
}
$_DTYPE = $checkoption = $optionlist = array();
if($typeid) {
threadtype_checkoption();
}
if(empty($action)) {
$action='newthread'; //此处ET修改
}
if(empty($topicsubmit)) {
$topicsubmit='yes'; //此处ET修改
}
/*
if($action == 'smilies' && $smileyinsert) {
$smile = isset($_DCOOKIE['smile']) ? explode('D', $_DCOOKIE['smile']) : array();
$stypeid = intval($stypeid ? $stypeid : $smile[0]);
$stypeid = isset($_DCACHE['smileytypes'][$stypeid]) ? $stypeid : (isset($_DCACHE['smileytypes'][STYPEID]) ? STYPEID : key($_DCACHE['smileytypes']));
$smilies = $_DCACHE['smilies_display'][$stypeid];
$page = max(1, intval(isset($_GET['page']) ? $_GET['page'] : (!isset($_GET['stypeid']) || $_GET['stypeid'] == $smile[0] ? $smile[1] : 1)));
$spp = $smcols * $smrows;
$multipage = multi(count($smilies), $spp, $page, 'post.php?action=smilies&stypeid='.$stypeid.'&inajax=1', 0, 10, FALSE, TRUE);
$smilies = arrayslice($smilies, $spp * ($page - 1), $spp);
dsetcookie('smile', $stypeid.'D'.$page, 86400 * 365);
include template('post_smilies');
exit;
}elseif($action == 'threadtypes') {
threadtype_optiondata();
$template = intval($operate) ? 'search_typeoption' : 'post_typeoption';
include template($template);
exit;
} elseif(($forum['simple'] & 1) || $forum['redirect']) {
showmessage('forum_disablepost');
}
*/
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$navigation = $navtitle = $thread = '';
/*
if($action == 'edit' || $action == 'reply') {
$query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid='$tid'".($auditstatuson ? '' : " AND displayorder>='0'"));
if($thread = $db->fetch_array($query)) {
$navigation = "» $thread[subject]";
$navtitle = $thread['subject'].' - ';
if($thread['readperm'] && $thread['readperm'] > $readaccess && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
showmessage('thread_nopermission', NULL, 'NOPERM');
}
$fid = $thread['fid'];
$special = $thread['special'];
} else {
showmessage('thread_nonexistence');
}
}
*/
$navigation = "» $forum[name] $navigation";
$navtitle = $navtitle.strip_tags($forum['name']).' - ';
if($forum['type'] == 'sub') {
$query = $db->query("SELECT name, fid FROM {$tablepre}forums WHERE fid='$forum[fup]'");
$fup = $db->fetch_array($query);
$navigation = "» $fup[name] $navigation";
$navtitle = $navtitle.strip_tags($fup['name']).' - ';
}
periodscheck('postbanperiods');
/*
if($forum['password'] && $forum['password'] != $_DCOOKIE['fidpw'.$fid]) {
dheader("Location: {$boardurl}forumdisplay.php?fid=$fid&sid=$sid");
}
*/
/*用户组、版块操作权限校验
if(empty($forum['allowview'])) {
if(!$forum['viewperm'] && !$readaccess) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($forum['viewperm'] && !forumperm($forum['viewperm'])) {
showmessage('forum_nopermission', NULL, 'NOPERM');
}
}
*/
forumformulaperm($forum['formulaperm']);
/*注册时间限制
if(!$adminid && $newbiespan && (!$lastpost || $timestamp - $lastpost < $newbiespan * 3600)) {
$query = $db->query("SELECT regdate FROM {$tablepre}members WHERE uid='$discuz_uid'");
if($timestamp - ($db->result($query, 0)) < $newbiespan * 3600) {
showmessage('post_newbie_span');
}
}
*/
$special = empty($special) || !is_numeric($special) || $special < 0 || $special > 6 ? 0 : intval($special);
$allowpostattach = !empty($forum['allowpostattach']) || (!$forum['postattachperm'] && $allowpostattach) || ($forum['postattachperm'] && forumperm($forum['postattachperm']));
$attachextensions = $forum['attachextensions'] ? $forum['attachextensions'] : $attachextensions;
$enctype = $allowpostattach ? 'enctype="multipart/form-data"' : '';
$maxattachsize_kb = $maxattachsize / 1000;
$postcredits = $forum['postcredits'] ? $forum['postcredits'] : $creditspolicy['post'];
$replycredits = $forum['replycredits'] ? $forum['replycredits'] : $creditspolicy['reply'];
$digestcredits = $forum['digestcredits'] ? $forum['digestcredits'] : $creditspolicy['digest'];
$postattachcredits = $forum['postattachcredits'] ? $forum['postattachcredits'] : $creditspolicy['postattach'];
$maxprice = isset($extcredits[$creditstrans]) ? $maxprice : 0;
$extra = rawurlencode($extra);
$blogcheck = empty($isblog) && empty($addtoblog) ? '' : 'checked="checked"';
$notifycheck = empty($emailnotify) ? '' : 'checked="checked"';
$stickcheck = empty($sticktopic) ? '' : 'checked="checked"';
$digestcheck = empty($addtodigest) ? '' : 'checked="checked"';
$subject = isset($subject) ? dhtmlspecialchars(censor(trim($subject))) : '';
$message = isset($message) ? censor(trim($message)) : '';
$readperm = isset($readperm) ? intval($readperm) : 0;
$price = isset($price) ? intval($price) : 0;
/* [hide]权限校验
if(empty($bbcodeoff) && !$allowhidecode && !empty($message) && preg_match("/\[hide=?\d*\].+?\[\/hide\]/is", preg_replace("/(\[code\](.+?)\[\/code\])/is", ' ', $message))) {
showmessage('post_hide_nopermission');
}
*/
if(periodscheck('postmodperiods', 0)) {
$modnewthreads = $modnewreplies = 1;
} else {
$censormod = censormod($subject."\t".$message);
$modnewthreads = (!$allowdirectpost || $allowdirectpost == 1) && ($forum['modnewposts'] || $censormod) ? 1 : 0;
$modnewreplies = (!$allowdirectpost || $allowdirectpost == 2) && ($forum['modnewposts'] == 2 || $censormod) ? 1 : 0;
}
$urloffcheck = $usesigcheck = $smileyoffcheck = $codeoffcheck = $htmloncheck = $emailcheck = '';
$seccodecheck = ($seccodestatus & 4) && (!$seccodedata['minposts'] || $posts < $seccodedata['minposts']);
$secqaacheck = $secqaa['status'][2] && (!$secqaa['minposts'] || $posts < $secqaa['minposts']);
if($iscircle = $supe['status'] && $supe['circlestatus'] && $forum['status'] == 2) {
unset($forum['threadtypes']);
}
$allowpostpoll = $allowpost && $allowpostpoll && ($forum['allowpostspecial'] & 1);
$allowposttrade = $allowpost && $allowposttrade && ($forum['allowpostspecial'] & 2);
$allowpostreward = $allowpost && $allowpostreward && ($forum['allowpostspecial'] & 4) && isset($extcredits[$creditstrans]);
$allowpostactivity = $allowpost && $allowpostactivity && ($forum['allowpostspecial'] & 8);
$allowpostdebate = $allowpost && $allowpostdebate && ($forum['allowpostspecial'] & 16);
$allowpostvideo = $allowpost && $allowpostvideo && ($forum['allowpostspecial'] & 32) && $videoopen;
$allowanonymous = $forum['allowanonymous'] || $allowanonymous ? 1 : 0;
if($action == 'newthread' && $forum['allowspecialonly'] && !$special) {
if($allowpostpoll) {
$special = 1;
} elseif($allowposttrade) {
$special = 2;
} elseif($allowpostreward) {
$special = 3;
} elseif($allowpostactivity) {
$special = 4;
} elseif($allowpostdebate) {
$special = 5;
} elseif($allowpostvideo) {
$special = 6;
}
if(!$special) {
//showmessage('undefined_action', NULL, 'HALTED');
echo('[err]undefined_action[/err]');
dexit();
}
}
$editorid = 'posteditor';
$editoroptions = str_pad(decbin($editoroptions), 2, 0, STR_PAD_LEFT);
$editormode = $editormode == 2 ? $editoroptions{0} : $editormode;
$allowswitcheditor = $editoroptions{1};
$advanceeditor = $special ? 0 : 1;
$previewdisplay = !empty($previewpost) ? '' : 'none';
if(!empty($previewpost) || (empty($previewpost) && empty($topicsubmit) && empty($replysubmit) && empty($editsubmit))) {
!$typeid && preg_replace("/.*typeid%3D(\d+).*/e", "\$typeid = \\1;", $extra);
if($discuz_uid && $sigstatus && !$usesigcheck) {
$usesigcheck = 'checked="checked"';
}
$trade = array();
if(($action == 'newthread' || $action == 'reply') && $special == 2) {
$query = $db->query("SELECT alipay FROM {$tablepre}memberfields WHERE uid='$discuz_uid'");
$trade['account'] = $db->result($query, 0);
$trade['amount'] = 1;
$trade['transport'] = 2;
}
$currtime = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);
if(empty($previewpost)) {
$subject = $message = $polloptions = '';
} else {
$subject = stripslashes($subject);
$message = stripslashes($message);
$message_preview = discuzcode($message, !empty($smileyoff), !empty($bbcodeoff), !empty($htmlon), $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'], $forum['allowhtml'], 0, 1);
$message = $editormode == 1 && $bbinsert && !(isopera() && isopera() < 9) ? $message_preview : dhtmlspecialchars($message);
$urloffcheck = !empty($parseurloff) ? 'checked="checked"' : '';
$usesigcheck = !empty($usesig) ? 'checked="checked"' : '';
$smileyoffcheck = !empty($smileyoff) ? 'checked="checked"' : '';
$codeoffcheck = !empty($bbcodeoff) ? 'checked="checked"' : '';
$htmloncheck = !empty($htmlon) ? 'checked="checked"' : '';
$emailcheck = !empty($emailnotify) ? 'checked="checked"' : '';
$topicsubmit = $replysubmit = $editsubmit = '';
}
} else {
if((!empty($topicsubmit) || !empty($replysubmit)) && (($seccodecheck && !isset($seccodeverify)) || ($secqaacheck && !isset($secanswer)))) {
if($seccodecheck) {
$seccode = random(6, 1) + $seccode{0} * 1000000;
}
if($secqaacheck) {
$seccode = random(1, 1) * 1000000 + substr($seccode, -6);
}
$request = array
(
'method' => $_SERVER['REQUEST_METHOD'],
'action' => $PHP_SELF,
'elements' => ''
);
$quesand = '?';
foreach($_GET as $key => $value) {
$request['action'] .= $quesand.rawurlencode($key).'='.rawurlencode($value);
$quesand = '&';
}
foreach($_POST as $key => $value) {
if(is_array($value)) {
foreach($value as $arraykey => $arrayvalue) {
$request['elements'] .= '';
}
} else {
$request['elements'] .= '';
}
}
include template('post_seccode');
dexit();
}
}
/*
if($action == 'newthread') {
require_once DISCUZ_ROOT.'./include/newthread.inc.php';
} elseif($action == 'reply') {
require_once DISCUZ_ROOT.'./include/newreply.inc.php';
} elseif($action == 'edit') {
require_once DISCUZ_ROOT.'./include/editpost.inc.php';
} elseif($action == 'import') {
require_once DISCUZ_ROOT.'./include/supesite_import.inc.php';
} elseif($action == 'newtrade') {
require_once DISCUZ_ROOT.'./include/newtrade.inc.php';
}
*/
//取用户名
$discuz_user=$_POST['username'];
$query =$db->query("SELECT uid,password,secques FROM {$tablepre}members m WHERE m.username='$discuz_user'");
if ($rs=$db->fetch_row($query)){
list($discuz_uid,$discuz_pw, $discuz_secques ) =$rs;
}
else
{
echo('[err]帐号错误[/err]');
$db->close;
dexit();
}
if ($discuz_pw<>md5($_POST['password'])){
echo('[err]密码错误[/err]');
$db->close;
dexit();
}
//以下为newthread.inc.php内容
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$discuz_action = 11;
if(empty($forum['fid']) || $forum['type'] == 'group') {
//showmessage('forum_nonexistence');
echo('[err]指定的版块不存在[/err]');
$db->close;
dexit();
}
if(($special == 1 && !$allowpostpoll) || ($special == 2 && !$allowposttrade) || ($special == 3 && !$allowpostreward) || ($special == 4 && !$allowpostactivity) || ($special == 5 && !$allowpostdebate) || ($special == 6 && !$allowpostvideo)) {
//showmessage('group_nopermission', NULL, 'NOPERM');
echo('[err]您所在的用户组(管理员)无法进行此操作[/err]');
$db->close;
dexit(); }
$sgid = intval($sgid);
if($iscircle) {
$mycircles = array();
if($discuz_uid) {
supe_dbconnect();
$query = $supe['db']->query("SELECT gid, groupname FROM {$supe[tablepre]}groupuid WHERE uid='$discuz_uid' AND flag>0", 'SILENT');
while($mycircle = $supe['db']->fetch_array($query)) {
$mycircles[$mycircle['gid']] = cutstr($mycircle['groupname'], 30);
}
}
if($sgid) {
supe_dbconnect();
$query = $supe['db']->query("SELECT g.groupname, gf.headerimage, gf.css FROM {$supe[tablepre]}groups g, {$supe[tablepre]}groupfields gf WHERE g.gid='$sgid' AND g.flag=1 AND g.gid=gf.gid", 'SILENT');
$circle = $supe['db']->fetch_array($query);
if(!$discuz_uid || !$supe['db']->result($supe['db']->query("SELECT COUNT(*) FROM {$supe[tablepre]}groupuid WHERE uid='$discuz_uid' AND gid='$sgid' AND flag>0", 'SILENT'), 0)) {
//showmessage('circle_nopermission');
echo('[err]你尚未加入本圈[/err]');
$db->close;
dexit();
}
}
}
/*组权限校验
if(!$discuz_uid && !((!$forum['postperm'] && $allowpost) || ($forum['postperm'] && forumperm($forum['postperm'])))) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif(empty($forum['allowpost'])) {
if(!$forum['postperm'] && !$allowpost) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($forum['postperm'] && !forumperm($forum['postperm'])) {
showmessage('post_forum_newthread_nopermission', NULL, 'HALTED');
}
}
*/
$isblog = empty($isblog) ? '' : 'yes';
if($isblog && (!$allowuseblog || !$forum['allowshare'])) {
//showmessage('post_newthread_blog_invalid', NULL, 'HALT');
echo('[err]无权加入日志[/err]');
$db->close;
dexit();
}
/*QIHOO转帖校验
if($url && !empty($qihoo['relate']['webnum'])) {
$from = in_array($from, array('direct', 'iframe')) ? $from : '';
if($data = @implode('', file("http://search.qihoo.com/sint/content.html?surl=$url&md5=$md5&ocs=$charset&ics=$charset&from=$from"))) {
preg_match_all("/(\w+):([^\>]+)/i", $data, $data);
if(!$data[2][1]) {
$subject = trim($data[2][3]);
$message = !$editormode ? str_replace('[br]', "\n", trim($data[2][4])) : str_replace('[br]', '
', trim($data[2][4]));
} else {
showmessage('reprint_invalid');
}
}
}
*/
checklowerlimit($postcredits);
/*if(!submitcheck('topicsubmit', 0, $seccodecheck, $secqaacheck)) {
$special = !$allowspecialonly ? intval($special) : 'only';
$modelid = $modelid ? intval($modelid) : '';
$typeselect = typeselect($selecttypeid, $special, '', $modelid);
$icons = '';
if(!$special && is_array($_DCACHE['icons'])) {
$key = 1;
foreach($_DCACHE['icons'] as $id => $icon) {
$icons .= ' ';
$icons .= !(++$key % 10) ? '
' : '';
}
}
if($special == 2 && $allowposttrade) {
$expiration_7days = date('Y-m-d', $timestamp + 86400 * 7);
$expiration_14days = date('Y-m-d', $timestamp + 86400 * 14);
$trade['expiration'] = $expiration_month = date('Y-m-d', mktime(0, 0, 0, date('m')+1, date('d'), date('Y')));
$expiration_3months = date('Y-m-d', mktime(0, 0, 0, date('m')+3, date('d'), date('Y')));
$expiration_halfyear = date('Y-m-d', mktime(0, 0, 0, date('m')+6, date('d'), date('Y')));
$expiration_year = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y')+1));
$tradetypeselect = '';
$forum['tradetypes'] = $forum['tradetypes'] == '' ? -1 : unserialize($forum['tradetypes']);
if($tradetypes && !empty($forum['tradetypes'])) {
$tradetypeselect = '';
}
} elseif($special == 6 && $allowpostvideo) {
$query = $db->query("SELECT value FROM {$tablepre}settings WHERE variable='videoinfo'");
$settings = unserialize($db->result($query, 0));
$vclassesselect = "