First commit

This commit is contained in:
2025-06-18 10:24:27 +08:00
commit ebc39cd5dd
3873 changed files with 412712 additions and 0 deletions

View File

@@ -0,0 +1,744 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_ajax.php 36278 2016-12-09 07:52:35Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
if(!in_array($_GET['action'], array('checkusername', 'checkemail', 'checkinvitecode', 'checkuserexists', 'quickclear', 'setnav')) && !$_G['setting']['forumstatus']) {
showmessage('forum_status_off');
}
if($_GET['action'] == 'checkusername') {
$username = trim($_GET['username']);
$usernamelen = dstrlen($username);
if($usernamelen < 3) {
showmessage('profile_username_tooshort', '', array(), array('handle' => false));
} elseif($usernamelen > 15) {
showmessage('profile_username_toolong', '', array(), array('handle' => false));
}
loaducenter();
$ucresult = uc_user_checkname($username);
if($ucresult == -1) {
showmessage('profile_username_illegal', '', array(), array('handle' => false));
} elseif($ucresult == -2) {
showmessage('profile_username_protect', '', array(), array('handle' => false));
} elseif($ucresult == -3) {
if(C::t('common_member')->fetch_by_username($username) || C::t('common_member_archive')->fetch_by_username($username)) {
showmessage('register_check_found', '', array(), array('handle' => false));
} else {
showmessage('register_activation', '', array(), array('handle' => false));
}
}
$censorexp = '/^('.str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote(($_G['setting']['censoruser'] = trim($_G['setting']['censoruser'])), '/')).')$/i';
if($_G['setting']['censoruser'] && @preg_match($censorexp, $username)) {
showmessage('profile_username_protect', '', array(), array('handle' => false));
}
} elseif($_GET['action'] == 'checkemail') {
require_once libfile('function/member');
checkemail($_GET['email']);
} elseif($_GET['action'] == 'checkinvitecode') {
$invitecode = trim($_GET['invitecode']);
if(!$invitecode) {
showmessage('no_invitation_code', '', array(), array('handle' => false));
}
$result = array();
if($invite = C::t('common_invite')->fetch_by_code($invitecode)) {
if(empty($invite['fuid']) && (empty($invite['endtime']) || $_G['timestamp'] < $invite['endtime'])) {
$result['uid'] = $invite['uid'];
$result['id'] = $invite['id'];
}
}
if(empty($result)) {
showmessage('wrong_invitation_code', '', array(), array('handle' => false));
}
} elseif($_GET['action'] == 'checkuserexists') {
if(C::t('common_member')->fetch_by_username(trim($_GET['username'])) || C::t('common_member_archive')->fetch_by_username(trim($_GET['username']))) {
showmessage('<img src="'.$_G['style']['imgdir'].'/check_right.gif" width="13" height="13">', '', array(), array('msgtype' => 3));
} else {
showmessage('username_nonexistence', '', array(), array('msgtype' => 3));
}
} elseif($_GET['action'] == 'attachlist') {
require_once libfile('function/post');
loadcache('groupreadaccess');
$attachlist = getattach($_GET['pid'], intval($_GET['posttime']), $_GET['aids']);
$attachlist = $attachlist['attachs']['unused'];
$_G['group']['maxprice'] = isset($_G['setting']['extcredits'][$_G['setting']['creditstrans']]) ? $_G['group']['maxprice'] : 0;
include template('common/header_ajax');
include template('forum/ajax_attachlist');
include template('common/footer_ajax');
dexit();
} elseif($_GET['action'] == 'imagelist') {
require_once libfile('function/post');
$attachlist = getattach($_GET['pid'], intval($_GET['posttime']), $_GET['aids']);
$imagelist = $attachlist['imgattachs']['unused'];
include template('common/header_ajax');
include template('forum/ajax_imagelist');
include template('common/footer_ajax');
dexit();
} elseif($_GET['action'] == 'get_rushreply_membernum') {
$tid = intval($_GET['tid']);
if($tid) {
$membernum = C::t('forum_post')->count_author_by_tid($tid);
showmessage('thread_reshreply_membernum', '', array('membernum' => intval($membernum - 1)), array('alert' => 'info'));
}
dexit();
} elseif($_GET['action'] == 'deleteattach') {
$count = 0;
if(isset($_GET['aids']) && isset($_GET['formhash']) && formhash() == $_GET['formhash']) {
foreach($_GET['aids'] as $aid) {
$attach = C::t('forum_attachment_n')->fetch_attachment('aid:'.$aid, $aid);
if($attach && ($attach['pid'] && $attach['pid'] == $_GET['pid'] && $_G['uid'] == $attach['uid'])) {
updatecreditbyaction('postattach', $attach['uid'], array(), '', -1, 1, $_G['fid']);
}
if($attach && ($attach['pid'] && $attach['pid'] == $_GET['pid'] && $_G['uid'] == $attach['uid'] || $_G['forum']['ismoderator'] || !$attach['pid'] && $_G['uid'] == $attach['uid'])) {
C::t('forum_attachment_n')->delete_attachment('aid:'.$aid, $aid);
C::t('forum_attachment')->delete($aid);
dunlink($attach);
$count++;
}
}
}
include template('common/header_ajax');
echo $count;
include template('common/footer_ajax');
dexit();
} elseif($_GET['action'] == 'secondgroup') {
require_once libfile('function/group');
$groupselect = get_groupselect($_GET['fupid'], $_GET['groupid']);
include template('common/header_ajax');
include template('forum/ajax_secondgroup');
include template('common/footer_ajax');
dexit();
} elseif($_GET['action'] == 'displaysearch_adv') {
$display = $_GET['display'] == 1 ? 1 : '';
dsetcookie('displaysearch_adv', $display);
} elseif($_GET['action'] == 'checkgroupname') {
$groupname = trim($_GET['groupname']);
if(empty($groupname)) {
showmessage('group_name_empty', '', array(), array('msgtype' => 3));
}
$tmpname = cutstr($groupname, 20, '');
if($tmpname != $groupname) {
showmessage('group_name_oversize', '', array(), array('msgtype' => 3));
}
if(C::t('forum_forum')->fetch_fid_by_name($groupname)) {
showmessage('group_name_exist', '', array(), array('msgtype' => 3));
}
showmessage('', '', array(), array('msgtype' => 3));
include template('common/header_ajax');
include template('common/footer_ajax');
dexit();
} elseif($_GET['action'] == 'getthreadtypes') {
include template('common/header_ajax');
if(empty($_GET['selectname'])) $_GET['selectname'] = 'threadtypeid';
echo '<select name="'.$_GET['selectname'].'" '.($_GET['selectclass'] ? 'class="'.$_GET['selectclass'].'"' : '').'>';
if(!empty($_G['forum']['threadtypes']['types'])) {
if(!$_G['forum']['threadtypes']['required']) {
echo '<option value="0"></option>';
}
foreach($_G['forum']['threadtypes']['types'] as $typeid => $typename) {
if($_G['forum']['threadtypes']['moderators'][$typeid] && $_G['forum'] && !$_G['forum']['ismoderator']) {
continue;
}
echo '<option value="'.$typeid.'">'.$typename.'</option>';
}
} else {
echo '<option value="0" /></option>';
}
echo '</select>';
include template('common/footer_ajax');
} elseif($_GET['action'] == 'getimage') {
$_GET['aid'] = intval($_GET['aid']);
$image = C::t('forum_attachment_n')->fetch_attachment('aid:'.$_GET['aid'], $_GET['aid'], 1);
include template('common/header_ajax');
if($image['aid']) {
echo '<img src="'.getforumimg($image['aid'], 1, 300, 300, 'fixnone').'" id="image_'.$image['aid'].'" onclick="insertAttachimgTag(\''.$image['aid'].'\')" width="'.($image['width'] < 110 ? $image['width'] : 110).'" cwidth="'.($image['width'] < 300 ? $image['width'] : 300).'" />';
}
include template('common/footer_ajax');
dexit();
} elseif($_GET['action'] == 'setthreadcover') {
$aid = intval($_GET['aid']);
$imgurl = $_GET['imgurl'];
require_once libfile('function/post');
if($_G['forum'] && ($aid || $imgurl)) {
if($imgurl) {
$tid = intval($_GET['tid']);
$pid = intval($_GET['pid']);
} else {
$threadimage = C::t('forum_attachment_n')->fetch_attachment('aid:'.$aid, $aid);
$tid = $threadimage['tid'];
$pid = $threadimage['pid'];
}
if($tid && $pid) {
$thread =get_thread_by_tid($tid);
} else {
$thread = array();
}
if(empty($thread) || (!$_G['forum']['ismoderator'] && $_G['uid'] != $thread['authorid'])) {
if($_GET['newthread']) {
showmessage('set_cover_faild', '', array(), array('msgtype' => 3));
} else {
showmessage('set_cover_faild', '', array(), array('closetime' => 3));
}
}
if(setthreadcover($pid, $tid, $aid, 0, $imgurl)) {
if(empty($imgurl)) {
C::t('forum_threadimage')->delete_by_tid($threadimage['tid']);
C::t('forum_threadimage')->insert(array(
'tid' => $threadimage['tid'],
'attachment' => $threadimage['attachment'],
'remote' => $threadimage['remote'],
));
}
if($_GET['newthread']) {
showmessage('set_cover_succeed', '', array(), array('msgtype' => 3));
} else {
showmessage('set_cover_succeed', '', array(), array('alert' => 'right', 'closetime' => 1));
}
}
}
if($_GET['newthread']) {
showmessage('set_cover_faild', '', array(), array('msgtype' => 3));
} else {
showmessage('set_cover_faild', '', array(), array('closetime' => 3));
}
} elseif($_GET['action'] == 'updateattachlimit') {
$_G['forum']['allowpostattach'] = isset($_G['forum']['allowpostattach']) ? $_G['forum']['allowpostattach'] : '';
$_G['group']['allowpostattach'] = $_G['forum']['allowpostattach'] != -1 && ($_G['forum']['allowpostattach'] == 1 || (!$_G['forum']['postattachperm'] && $_G['group']['allowpostattach']) || ($_G['forum']['postattachperm'] && forumperm($_G['forum']['postattachperm'])));
$_G['forum']['allowpostimage'] = isset($_G['forum']['allowpostimage']) ? $_G['forum']['allowpostimage'] : '';
$_G['group']['allowpostimage'] = $_G['forum']['allowpostimage'] != -1 && ($_G['forum']['allowpostimage'] == 1 || (!$_G['forum']['postimageperm'] && $_G['group']['allowpostimage']) || ($_G['forum']['postimageperm'] && forumperm($_G['forum']['postimageperm'])));
$allowuploadnum = $allowuploadtoday = TRUE;
if($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) {
if($_G['group']['maxattachnum']) {
$allowuploadnum = $_G['group']['maxattachnum'] - getuserprofile('todayattachs');
$allowuploadnum = $allowuploadnum < 0 ? 0 : $allowuploadnum;
if(!$allowuploadnum) {
$allowuploadtoday = false;
}
}
if($_G['group']['maxsizeperday']) {
$allowuploadsize = $_G['group']['maxsizeperday'] - getuserprofile('todayattachsize');
$allowuploadsize = $allowuploadsize < 0 ? 0 : $allowuploadsize;
if(!$allowuploadsize) {
$allowuploadtoday = false;
}
$allowuploadsize = $allowuploadsize / 1048576 >= 1 ? round(($allowuploadsize / 1048576), 1).'MB' : round(($allowuploadsize / 1024)).'KB';
}
}
include template('common/header_ajax');
include template('forum/post_attachlimit');
include template('common/footer_ajax');
exit;
} elseif($_GET['action'] == 'forumchecknew' && !empty($_GET['fid']) && !empty($_GET['time'])) {
$fid = intval($_GET['fid']);
$time = intval($_GET['time']);
if(!getgpc('uncheck')) {
$foruminfo = C::t('forum_forum')->fetch($fid);
$lastpost_str = $foruminfo['lastpost'];
if($lastpost_str) {
$lastpost = explode("\t", $lastpost_str);
unset($lastpost_str);
}
include template('common/header_ajax');
echo $lastpost['2'] > $time ? 1 : 0 ;
include template('common/footer_ajax');
exit;
} else {
$_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
$query = C::t('forum_forumfield')->fetch($fid);
$forum_field['threadtypes'] = dunserialize($query['threadtypes']);
$forum_field['threadsorts'] = dunserialize($query['threadsorts']);
if($forum_field['threadtypes']['types']) {
safefilter($forum_field['threadtypes']['types']);
}
if($forum_field['threadtypes']['options']['name']) {
safefilter($forum_field['threadtypes']['options']['name']);
}
if($forum_field['threadsorts']['types']) {
safefilter($forum_field['threadsorts']['types']);
}
unset($query);
$forum_field = daddslashes($forum_field);
$todaytime = strtotime(dgmdate(TIMESTAMP, 'Ymd'));
foreach(C::t('forum_thread')->fetch_all_by_fid_lastpost($fid, $time, TIMESTAMP) as $thread) {
$thread['icontid'] = $thread['forumstick'] || !$thread['moved'] && $thread['isgroup'] != 1 ? $thread['tid'] : $thread['closed'];
if(!$thread['forumstick'] && ($thread['isgroup'] == 1 || $thread['fid'] != $_G['fid'])) {
$thread['icontid'] = $thread['closed'] > 1 ? $thread['closed'] : $thread['tid'];
}
list($thread['subject'], $thread['author'], $thread['lastposter']) = daddslashes(array($thread['subject'], $thread['author'], $thread['lastposter']));
$thread['dateline'] = $thread['dateline'] > $todaytime ? "<span class=\"xi1\">".dgmdate($thread['dateline'], 'd')."</span>" : "<span>".dgmdate($thread['dateline'], 'd')."</span>";
$thread['lastpost'] = dgmdate($thread['lastpost']);
if(isset($forum_field['threadtypes']['prefix'])) {
if($forum_field['threadtypes']['prefix'] == 1) {
$thread['threadtype'] = $forum_field['threadtypes']['types'][$thread['typeid']] ? '<em>[<a href="forum.php?mod=forumdisplay&fid='.$fid.'&filter=typeid&typeid='.$thread['typeid'].'">'.$forum_field['threadtypes']['types'][$thread['typeid']].'</a>]</em> ' : '' ;
} elseif($forum_field['threadtypes']['prefix'] == 2) {
$thread['threadtype'] = $forum_field['threadtypes']['icons'][$thread['typeid']] ? '<em><a href="forum.php?mod=forumdisplay&fid='.$fid.'&filter=typeid&typeid='.$thread['typeid'].'"><img src="'.$forum_field['threadtypes']['icons'][$thread['typeid']].'"/></a></em> ' : '' ;
}
}
if(isset($forum_field['threadsorts']['prefix'])) {
$thread['threadsort'] = $forum_field['threadsorts']['types'][$thread['sortid']] ? '<em>[<a href="forum.php?mod=forumdisplay&fid='.$fid.'&filter=sortid&typeid='.$thread['sortid'].'">'.$forum_field['threadsorts']['types'][$thread['sortid']].'</a>]</em>' : '' ;
}
if($thread['highlight']) {
$string = sprintf('%02d', $thread['highlight']);
$stylestr = sprintf('%03b', $string[0]);
$thread['highlight'] = ' style="';
$thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
$thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
$thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
$thread['highlight'] .= $string[1] ? 'color: '.$_G['forum_colorarray'][$string[1]].';' : '';
if($thread['bgcolor']) {
$thread['highlight'] .= "background-color: $thread[bgcolor];";
}
$thread['highlight'] .= '"';
} else {
$thread['highlight'] = '';
}
$target = $thread['isgroup'] == 1 || $thread['forumstick'] ? ' target="_blank"' : ' onclick="atarget(this)"';
if(is_array($_G['setting']['rewritestatus']) && in_array('forum_viewthread', $_G['setting']['rewritestatus'])) {
$thread['threadurl'] = '<a href="'.rewriteoutput('forum_viewthread', 1, '', $thread['tid'], 1, '', '').'"'.$thread['highlight'].$target.'class="s xst">'.$thread['subject'].'</a>';
} else {
$thread['threadurl'] = '<a href="forum.php?mod=viewthread&amp;tid='.$thread['tid'].'"'.$thread['highlight'].$target.'class="s xst">'.$thread['subject'].'</a>';
}
if(is_array($_G['setting']['rewritestatus']) && in_array($thread['displayorder'], array(1, 2, 3, 4))) {
$thread['id'] = 'stickthread_'.$thread['tid'];
} else {
$thread['id'] = 'normalthread_'.$thread['tid'];
}
$thread['threadurl'] = $thread['threadtype'].$thread['threadsort'].$thread['threadurl'];
if(is_array($_G['setting']['rewritestatus']) && in_array('home_space', $_G['setting']['rewritestatus'])) {
$thread['authorurl'] = '<a href="'.rewriteoutput('home_space', 1, '', $thread['authorid'], '', '').'">'.$thread['author'].'</a>';
$thread['lastposterurl'] = '<a href="'.rewriteoutput('home_space', 1, '', '', rawurlencode($thread['lastposter']), '').'">'.$thread['lastposter'].'</a>';
} else {
$thread['authorurl'] = '<a href="home.php?mod=space&uid='.$thread['authorid'].'">'.$thread['author'].'</a>';
$thread['lastposterurl'] = '<a href="home.php?mod=space&username='.rawurlencode($thread['lastposter']).'">'.$thread['lastposter'].'</a>';
}
$threadlist[] = $thread;
}
if($threadlist) {
krsort($threadlist);
}
include template('forum/ajax_threadlist');
}
} elseif($_GET['action'] == 'downremoteimg') {
if(!$_G['group']['allowdownremoteimg']) {
dexit();
}
$_GET['message'] = str_replace(array("\r", "\n"), array($_GET['wysiwyg'] ? '<br />' : '', "\\n"), $_GET['message']);
preg_match_all("/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]|\[img=\d{1,4}[x|\,]\d{1,4}\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is", $_GET['message'], $image1, PREG_SET_ORDER);
preg_match_all("/\<img.+\bsrc\b\s*=('|\"|)(.*)('|\"|)([\s].*)?\>/ismU", $_GET['message'], $image2, PREG_SET_ORDER);
$temp = $aids = $existentimg = array();
if(is_array($image1) && !empty($image1)) {
foreach($image1 as $value) {
$temp[] = array(
'0' => $value[0],
'1' => trim(!empty($value[1]) ? $value[1] : $value[2])
);
}
}
if(is_array($image2) && !empty($image2)) {
foreach($image2 as $value) {
$temp[] = array(
'0' => $value[0],
'1' => trim($value[2])
);
}
}
require_once libfile('class/image');
if(is_array($temp) && !empty($temp)) {
$upload = new discuz_upload();
$attachaids = array();
foreach($temp as $value) {
$imageurl = $value[1];
$hash = md5($imageurl);
if(strlen($imageurl)) {
$imagereplace['oldimageurl'][] = $value[0];
if(!isset($existentimg[$hash])) {
$existentimg[$hash] = $imageurl;
$attach['ext'] = $upload->fileext($imageurl);
if(!$upload->is_image_ext($attach['ext'])) {
continue;
}
$content = '';
if(preg_match('/^(http(s?):\/\/|\.)/i', $imageurl)) {
$content = dfsockopen($imageurl);
} elseif(preg_match('/^('.preg_quote(getglobal('setting/attachurl'), '/').')/i', $imageurl)) {
$imagereplace['newimageurl'][] = $value[0];
}
if(empty($content)) continue;
$patharr = explode('/', $imageurl);
$attach['name'] = trim($patharr[count($patharr)-1]);
$attach['thumb'] = '';
$attach['isimage'] = $upload -> is_image_ext($attach['ext']);
$attach['extension'] = $upload -> get_target_extension($attach['ext']);
$attach['attachdir'] = $upload -> get_target_dir('forum');
$attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename('forum').'.'.$attach['extension'];
$attach['target'] = getglobal('setting/attachdir').'./forum/'.$attach['attachment'];
if(!@$fp = fopen($attach['target'], 'wb')) {
continue;
} else {
flock($fp, 2);
fwrite($fp, $content);
fclose($fp);
}
if(!$upload->get_image_info($attach['target'])) {
@unlink($attach['target']);
continue;
}
$attach['size'] = filesize($attach['target']);
$upload->attach = $attach;
$thumb = $width = $height = 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'];
$height = $image->imginfo['height'];
$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'];
$height = $image->imginfo['height'];
}
if($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) {
list($width, $height) = @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' => strip_tags(str_replace('"', '', $upload->attach['name'])),
'filesize' => $upload->attach['size'],
'attachment' => $upload->attach['attachment'],
'isimage' => $upload->attach['isimage'],
'uid' => $_G['uid'],
'thumb' => $thumb,
'remote' => '0',
'width' => $width,
'height' => $height
);
C::t("forum_attachment_unused")->insert($setarr);
$attachaids[$hash] = $imagereplace['newimageurl'][] = '[attachimg]'.$aid.'[/attachimg]';
} else {
$imagereplace['newimageurl'][] = $attachaids[$hash];
}
}
}
if(!empty($aids)) {
require_once libfile('function/post');
}
$_GET['message'] = str_replace($imagereplace['oldimageurl'], $imagereplace['newimageurl'], $_GET['message']);
}
$_GET['message'] = addcslashes($_GET['message'], '/"\'');
print <<<EOF
<script type="text/javascript">
parent.ATTACHORIMAGE = 1;
parent.updateDownImageList('{$_GET['message']}');
</script>
EOF;
dexit();
} elseif($_GET['action'] == 'exif') {
$exif = C::t('forum_attachment_exif')->fetch($_GET['aid']);
$s = $exif['exif'];
if(!$s) {
require_once libfile('function/attachment');
$s = getattachexif($_GET['aid']);
C::t('forum_attachment_exif')->insert_exif($_GET['aid'], $s);
}
include template('common/header_ajax');
echo $s;
include template('common/footer_ajax');
exit;
} elseif($_GET['action'] == 'getthreadclass') {
$fid = intval($_GET['fid']);
$threadclass = '';
if($fid) {
$option = array();
$forumfield = C::t('forum_forumfield')->fetch($fid);
if(!empty($forumfield['threadtypes'])) {
foreach(C::t('forum_threadclass')->fetch_all_by_fid($fid) as $tc) {
$option[] = '<option value="'.$tc['typeid'].'">'.$tc['name'].'</option>';
}
if(!empty($option)) {
$threadclass .= '<option value="">'.lang('forum/template', 'modcp_select_threadclass').'</option>';
$threadclass .= implode('', $option);
}
}
}
if(!empty($threadclass)) {
$threadclass = '<select name="typeid" id="typeid" width="168" class="ps">'.$threadclass.'</select>';
}
include template('common/header_ajax');
echo $threadclass;
include template('common/footer_ajax');
exit;
} elseif($_GET['action'] == 'forumjump') {
require_once libfile('function/forumlist');
$favforums = C::t('home_favorite')->fetch_all_by_uid_idtype($_G['uid'], 'fid');
$visitedforums = array();
if($_G['cookie']['visitedfid']) {
loadcache('forums');
foreach(explode('D', $_G['cookie']['visitedfid']) as $fid) {
$fid = intval($fid);
$visitedforums[$fid] = $_G['cache']['forums'][$fid]['name'];
}
}
$forumlist = forumselect(FALSE, 1);
include template('forum/ajax_forumlist');
} elseif($_GET['action'] == 'quickreply') {
$tid = intval($_GET['tid']);
$fid = intval($_GET['fid']);
if($tid) {
$thread = C::t('forum_thread')->fetch_thread($tid);
if($thread && !getstatus($thread['status'], 2)) {
$list = C::t('forum_post')->fetch_all_by_tid('tid:'.$tid, $tid, true, 'DESC', 0, 10, null, 0);
loadcache('smilies');
foreach($list as $pid => $post) {
if($post['first']) {
unset($list[$pid]);
} else {
$post['message'] = preg_replace($_G['cache']['smilies']['searcharray'], '', $post['message']);
$post['message'] = preg_replace("/\{\:soso_((e\d+)|(_\d+_\d))\:\}/", '', $post['message']);
$list[$pid]['message'] = cutstr(preg_replace("/\[.+?\]/is", '', dhtmlspecialchars($post['message'])), 300) ;
}
}
krsort($list);
}
}
list($seccodecheck, $secqaacheck) = seccheck('post', 'reply');
include template('forum/ajax_quickreply');
} elseif($_GET['action'] == 'getpost') {
$tid = intval($_GET['tid']);
$fid = intval($_GET['fid']);
$pid = intval($_GET['pid']);
$thread = C::t('forum_thread')->fetch_thread($tid);
$post = C::t('forum_post')->fetch_post($thread['posttableid'], $pid);
if($_G['uid'] != $post['authorid']) {
showmessage('quickclear_noperm');
}
include template('forum/ajax_followpost');
} elseif($_GET['action'] == 'quickclear') {
$uid = intval($_GET['uid']);
if($_G['adminid'] != 1) {
showmessage('quickclear_noperm');
}
include_once libfile('function/misc');
include_once libfile('function/member');
if(!submitcheck('qclearsubmit')) {
$crimenum_avatar = crime('getcount', $uid, 'crime_avatar');
$crimenum_sightml = crime('getcount', $uid, 'crime_sightml');
$crimenum_customstatus = crime('getcount', $uid, 'crime_customstatus');
$crimeauthor = getuserbyuid($uid);
$crimeauthor = $crimeauthor['username'];
include template('forum/ajax');
} else {
if(empty($_GET['operations'])) {
showmessage('quickclear_need_operation');
}
$reason = checkreasonpm();
$allowop = array('avatar', 'sightml', 'customstatus');
$cleartype = array();
if(in_array('avatar', $_GET['operations'])) {
C::t('common_member')->update($uid, array('avatarstatus'=>0));
loaducenter();
uc_user_deleteavatar($uid);
$cleartype[] = lang('forum/misc', 'avatar');
crime('recordaction', $uid, 'crime_avatar', lang('forum/misc', 'crime_reason', array('reason' => $reason)));
}
if(in_array('sightml', $_GET['operations'])) {
C::t('common_member_field_forum')->update($uid, array('sightml' => ''), 'UNBUFFERED');
$cleartype[] = lang('forum/misc', 'signature');
crime('recordaction', $uid, 'crime_sightml', lang('forum/misc', 'crime_reason', array('reason' => $reason)));
}
if(in_array('customstatus', $_GET['operations'])) {
C::t('common_member_field_forum')->update($uid, array('customstatus' => ''), 'UNBUFFERED');
$cleartype[] = lang('forum/misc', 'custom_title');
crime('recordaction', $uid, 'crime_customstatus', lang('forum/misc', 'crime_reason', array('reason' => $reason)));
}
if(($_G['group']['reasonpm'] == 2 || $_G['group']['reasonpm'] == 3) || !empty($_GET['sendreasonpm'])) {
sendreasonpm(array('authorid' => $uid), 'reason_quickclear', array(
'cleartype' => implode(',', $cleartype),
'reason' => $reason,
'from_id' => 0,
'from_idtype' => 'quickclear'
));
}
showmessage('quickclear_success', $_POST['redirect'], array(), array('showdialog'=>1, 'closetime' => true, 'msgtype' => 2, 'locationtime' => 1));
}
} elseif($_GET['action'] == 'getpostfeed') {
if(!$_G['setting']['followstatus']) {
showmessage('follow_status_off');
}
$tid = intval($_GET['tid']);
$pid = intval($_GET['pid']);
$flag = intval($_GET['flag']);
$feed = $thread = array();
if($tid) {
$thread = C::t('forum_thread')->fetch_thread($tid);
if(empty($_G['setting']['followforumid']) || $thread['fid'] != $_G['setting']['followforumid']) {
$flag = 0;
}
if($flag) {
$post = C::t('forum_post')->fetch_post($thread['posttableid'], $pid);
if($thread['tid'] != $post['tid']) {
showmessage('quickclear_noperm');
}
require_once libfile('function/discuzcode');
require_once libfile('function/followcode');
$post['message'] = followcode($post['message'], $tid, $pid);
} else {
if(!isset($_G['cache']['forums'])) {
loadcache('forums');
}
$feedid = intval($_GET['feedid']);
$feed = C::t('forum_threadpreview')->fetch($tid);
if($feedid) {
$feed = array_merge($feed, C::t('home_follow_feed')->fetch_by_feedid($feedid));
}
$post['message'] = $feed['content'];
}
}
include template('forum/ajax_followpost');
} elseif($_GET['action'] == 'setnav') {
if($_G['adminid'] != 1) {
showmessage('quickclear_noperm');
}
$allowfuntype = array('portal', 'forum', 'friend', 'group', 'follow', 'collection', 'guide', 'feed', 'blog', 'doing', 'album', 'share', 'wall', 'homepage', 'ranklist', 'medal', 'task', 'magic', 'favorite');
$type = in_array($_GET['type'], $allowfuntype) ? trim($_GET['type']) : '';
$do = in_array($_GET['do'], array('open', 'close')) ? $_GET['do'] : 'close';
if(!submitcheck('funcsubmit')) {
$navtitle = lang('spacecp', $do == 'open' ? 'select_the_navigation_position' : 'close_module', array('type' => lang('spacecp', $type)));
$closeprompt = lang('spacecp', 'close_module', array('type' => lang('spacecp', $type)));
include template('forum/ajax');
} else {
if(!empty($type)) {
$funkey = $type.'status';
$funstatus = $do == 'open' ? 1 : 0;
if($type != 'homepage') {
$identifier = array('portal' => 1, 'forum' => 2, 'group' => 3, 'feed' => 4, 'ranklist' => 8, 'follow' => 9, 'guide' => 10, 'collection' => 11, 'blog' => 12, 'album' => 13, 'share' => 14, 'doing' => 15, 'friend' => 26, 'favorite' => 27, 'medal' => 29, 'task' => 30, 'magic' => 31);
$navdata = array('available' => -1);
$navtype = $do == 'open' ? array() : array(0, 3);
if(in_array($type, array('blog', 'album', 'share', 'doing', 'follow', 'friend', 'favorite', 'medal', 'task', 'magic'))) {
$navtype[] = 2;
}
if($do == 'close' && $type == 'medal') {
if(intval(C::t('forum_medal')->count_by_available()) > 0) {
showmessage('medals_existence', dreferer(), array(), array('showdialog' => true, 'locationtime' => true));
exit;
}
}
if($do == 'close' && $type == 'forum') {
if($_G['setting']['groupstatus'] || $_G['setting']['guidestatus'] || $_G['setting']['collectionstatus'] || $_G['setting']['followstatus']) {
showmessage('close_ggcf_before_close_forum', dreferer(), array(), array('showdialog' => true, 'locationtime' => true));
exit;
}
}
if($do == 'open' && in_array($type, array('group', 'guide', 'collection', 'follow'))) {
if(!$_G['setting']['forumstatus']) {
showmessage('open_forum_before_open_ggcf', dreferer(), array(), array('showdialog' => true, 'locationtime' => true));
exit;
}
}
if($do == 'open') {
if($_GET['location']['header']) {
$navtype[] = 0;
$navdata['available'] = 1;
}
if($_GET['location']['quick']) {
$navtype[] = 3;
$navdata['available'] = 1;
}
$navdata['available'] = $navdata['available'] == 1 ? 1 : 0;
if(empty($_GET['location']['header']) || empty($_GET['location']['quick'])) {
C::t('common_nav')->update_by_navtype_type_identifier(array(0, 2, 3), 0, array("$type", "$identifier[$type]"), array('available' => 0));
}
}
if($navtype) {
C::t('common_nav')->update_by_navtype_type_identifier($navtype, 0, array("$type", "$identifier[$type]"), $navdata);
if(in_array($type, array('blog', 'album', 'share', 'doing', 'follow')) && !$navdata['available']) {
C::t('common_nav')->update_by_navtype_type_identifier(array(2), 0, array("$type"), array('available' => 1));
}
}
}
C::t('common_setting')->update_setting($funkey, $funstatus);
$setting[$funkey] = $funstatus;
if(!function_exists('updatecache')) {
include libfile('function/cache');
}
updatecache('setting');
}
showmessage('do_success', dreferer(), array(), array('showdialog' => true, 'locationtime' => true));
}
exit;
} elseif($_GET['action'] == 'checkpostrule') {
require_once libfile('function/post');
include template('common/header_ajax');
$_POST = array('action' => $_GET['ac']);
list($seccodecheck, $secqaacheck) = seccheck('post', $_GET['ac']);
if($seccodecheck || $secqaacheck) {
include template('forum/seccheck_post');
}
include template('common/footer_ajax');
exit;
}
showmessage('succeed', '', array(), array('handle' => false));
?>

View File

@@ -0,0 +1,40 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_announcement.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
require_once libfile('function/discuzcode');
$announcedata = C::t('forum_announcement')->fetch_all_by_date($_G['timestamp']);
if(!count($announcedata)) {
showmessage('announcement_nonexistence');
}
$announcelist = array();
foreach ($announcedata as $announce) {
$announce['authorenc'] = rawurlencode($announce['author']);
$tmp = explode('.', dgmdate($announce['starttime'], 'Y.m'));
$months[$tmp[0].$tmp[1]] = $tmp;
if(!empty($_GET['m']) && $_GET['m'] != dgmdate($announce['starttime'], 'Ym')) {
continue;
}
$announce['starttime'] = dgmdate($announce['starttime'], 'd');
$announce['endtime'] = $announce['endtime'] ? dgmdate($announce['endtime'], 'd') : '';
$announce['message'] = $announce['type'] == 1 ? "[url]{$announce['message']}[/url]" : $announce['message'];
$announce['message'] = nl2br(discuzcode($announce['message'], 0, 0, 1, 1, 1, 1, 1));
$announcelist[] = $announce;
}
$annid = isset($_GET['id']) ? intval($_GET['id']) : 0;
include template('forum/announcement');
?>

View File

@@ -0,0 +1,395 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_attachment.php 34304 2014-01-15 11:11:23Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
@list($_GET['aid'], $_GET['k'], $_GET['t'], $_GET['uid'], $_GET['tableid']) = daddslashes(explode('|', base64_decode($_GET['aid'])));
$requestmode = !empty($_GET['request']) && empty($_GET['uid']);
$aid = intval($_GET['aid']);
$k = $_GET['k'];
$t = $_GET['t'];
$authk = !$requestmode ? substr(md5($aid.md5($_G['config']['security']['authkey']).$t.$_GET['uid']), 0, 8) : md5($aid.md5($_G['config']['security']['authkey']).$t);
$sameuser = !empty($_GET['uid']) && $_GET['uid'] == $_G['uid'];
if($k !== $authk || $t > TIMESTAMP + 3600) {
if(!$requestmode) {
showmessage('attachment_nonexistence');
} else {
exit;
}
}
if(!empty($_GET['findpost']) && ($attach = C::t('forum_attachment')->fetch($aid))) {
dheader('location: forum.php?mod=redirect&goto=findpost&pid='.$attach['pid'].'&ptid='.$attach['tid']);
}
if($_GET['uid'] != $_G['uid'] && $_GET['uid']) {
$_G['uid'] = $_GET['uid'] = intval($_GET['uid']);
$member = getuserbyuid($_GET['uid']);
loadcache('usergroup_'.$member['groupid']);
$_G['group'] = $_G['cache']['usergroup_'.$member['groupid']];
$_G['group']['grouptitle'] = $_G['cache']['usergroup_'.$_G['groupid']]['grouptitle'];
$_G['group']['color'] = $_G['cache']['usergroup_'.$_G['groupid']]['color'];
}
$tableid = 'aid:'.$aid;
if($_G['setting']['attachexpire']) {
if(TIMESTAMP - $t > $_G['setting']['attachexpire'] * 3600) {
$aid = intval($aid);
if($attach = C::t('forum_attachment_n')->fetch_attachment($tableid, $aid)) {
if($attach['isimage']) {
dheader('location: '.$_G['siteurl'].'static/image/common/none.gif');
} else {
if(!$requestmode) {
if($sameuser) {
showmessage('attachment_expired', '', array('aid' => aidencode($aid, 0, $attach['tid']), 'pid' => $attach['pid'], 'tid' => $attach['tid']));
} else {
showmessage('attachment_expired_nosession', '', array('pid' => $attach['pid'], 'tid' => $attach['tid']));
}
} else {
exit;
}
}
} else {
if(!$requestmode) {
showmessage('attachment_nonexistence');
} else {
exit;
}
}
}
}
$readmod = getglobal('config/download/readmod');
$readmod = $readmod > 0 && $readmod < 5 ? $readmod : 2;
$refererhost = parse_url($_SERVER['HTTP_REFERER']);
$serverhost = $_SERVER['HTTP_HOST'];
if(($pos = strpos($serverhost, ':')) !== FALSE) {
$serverhost = substr($serverhost, 0, $pos);
}
if(!$requestmode && $_G['setting']['attachrefcheck'] && $_SERVER['HTTP_REFERER'] && !($refererhost['host'] == $serverhost)) {
showmessage('attachment_referer_invalid', NULL);
}
periodscheck('attachbanperiods');
loadcache('threadtableids');
$threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
if(!in_array(0, $threadtableids)) {
$threadtableids = array_merge(array(0), $threadtableids);
}
$archiveid = in_array($_GET['archiveid'], $threadtableids) ? intval($_GET['archiveid']) : 0;
$attachexists = FALSE;
if(!empty($aid) && is_numeric($aid)) {
$attach = C::t('forum_attachment_n')->fetch_attachment($tableid, $aid);
$thread = C::t('forum_thread')->fetch_by_tid_displayorder($attach['tid'], 0, '>=', null, $archiveid);
if($_G['uid'] && $attach['uid'] != $_G['uid']) {
if($attach) {
$attachpost = C::t('forum_post')->fetch_post($thread['posttableid'], $attach['pid'], false);
$attach['invisible'] = $attachpost['invisible'];
unset($attachpost);
}
if($attach && $attach['invisible'] == 0) {
$thread && $attachexists = TRUE;
}
} else {
$attachexists = TRUE;
}
}
if(!$attachexists) {
if(!$requestmode) {
showmessage('attachment_nonexistence');
} else {
exit;
}
}
if(!$requestmode) {
$forum = C::t('forum_forumfield')->fetch_info_for_attach($thread['fid'], $_G['uid']);
$_GET['fid'] = $forum['fid'];
if($attach['isimage']) {
$allowgetattach = ($_G['uid'] == $attach['uid']) ? true : ((!empty($forum['allowgetimage'])) ? ($forum['allowgetimage'] == 1 ? true : false) : ($forum['getattachperm'] ? forumperm($forum['getattachperm']) : $_G['group']['allowgetimage']));
} else {
$allowgetattach = ($_G['uid'] == $attach['uid']) ? true : ((!empty($forum['allowgetattach'])) ? ($forum['allowgetattach'] == 1 ? true : false) : ($forum['getattachperm'] ? forumperm($forum['getattachperm']) : $_G['group']['allowgetattach']));
}
if(($attach['readperm'] && $attach['readperm'] > $_G['group']['readaccess']) && $_G['adminid'] <= 0 && !($_G['uid'] && $_G['uid'] == $attach['uid'])) {
$allowgetattach = FALSE;
showmessage('attachment_forum_nopermission', NULL, array(), array('login' => 1));
}
$ismoderator = in_array($_G['adminid'], array(1, 2)) ? 1 : ($_G['adminid'] == 3 ? C::t('forum_moderator')->fetch_uid_by_tid($attach['tid'], $_G['uid'], $archiveid) : 0);
$ispaid = FALSE;
$exemptvalue = $ismoderator ? 128 : 16;
if(!$thread['special'] && $thread['price'] > 0 && (!$_G['uid'] || ($_G['uid'] != $attach['uid'] && !($_G['group']['exempt'] & $exemptvalue)))) {
if(!$_G['uid'] || $_G['uid'] && !($ispaid = C::t('common_credit_log')->count_by_uid_operation_relatedid($_G['uid'], 'BTC', $attach['tid']))) {
showmessage('attachment_payto', 'forum.php?mod=viewthread&tid='.$attach['tid']);
}
}
$exemptvalue = $ismoderator ? 64 : 8;
if($attach['price'] && (!$_G['uid'] || ($_G['uid'] != $attach['uid'] && !($_G['group']['exempt'] & $exemptvalue)))) {
$payrequired = $_G['uid'] ? !C::t('common_credit_log')->count_by_uid_operation_relatedid($_G['uid'], 'BAC', $attach['aid']) : 1;
$payrequired && showmessage('attachement_payto_attach', 'forum.php?mod=misc&action=attachpay&aid='.$attach['aid'].'&tid='.$attach['tid']);
}
if(!$ispaid && !$allowgetattach) {
if(($forum['getattachperm'] && !forumperm($forum['getattachperm'])) || ($forum['viewperm'] && !forumperm($forum['viewperm']))) {
showmessagenoperm('getattachperm', $forum['fid']);
} else {
showmessage('getattachperm_none_nopermission', NULL, array(), array('login' => 1));
}
}
}
$isimage = $attach['isimage'];
$_G['setting']['ftp']['hideurl'] = $_G['setting']['ftp']['hideurl'] || ($isimage && !empty($_GET['noupdate']) && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp');
if(empty($_GET['nothumb']) && $attach['isimage'] && $attach['thumb']) {
$db = DB::object();
$db->close();
!$_G['config']['output']['gzip'] && ob_end_clean();
dheader('Content-Disposition: inline; filename='.getimgthumbname($attach['filename']));
dheader('Content-Type: image/pjpeg');
if($attach['remote']) {
$_G['setting']['ftp']['hideurl'] ? getremotefile(getimgthumbname($attach['attachment'])) : dheader('location:'.$_G['setting']['ftp']['attachurl'].'forum/'.getimgthumbname($attach['attachment']));
} else {
getlocalfile($_G['setting']['attachdir'].'/forum/'.getimgthumbname($attach['attachment']));
}
exit();
}
$filename = $_G['setting']['attachdir'].'/forum/'.$attach['attachment'];
if(!$attach['remote'] && !is_readable($filename)) {
if(!$requestmode) {
showmessage('attachment_nonexistence');
} else {
exit;
}
}
if(!$requestmode) {
$exemptvalue = $ismoderator ? 32 : 4;
if(!$isimage && !($_G['group']['exempt'] & $exemptvalue)) {
$creditlog = updatecreditbyaction('getattach', $_G['uid'], array(), '', 1, 0, $thread['fid']);
if($creditlog['updatecredit']) {
if($_G['uid']) {
$k = $_GET['ck'];
$t = $_GET['t'];
if(empty($k) || empty($t) || $k != substr(md5($aid.$t.md5($_G['config']['security']['authkey'])), 0, 8) || TIMESTAMP - $t > 3600) {
dheader('location: forum.php?mod=misc&action=attachcredit&aid='.$attach['aid'].'&formhash='.FORMHASH);
exit();
}
} else {
showmessage('attachment_forum_nopermission', NULL, array(), array('login' => 1));
}
}
}
}
$range_start = 0;
$range_end = 0;
$has_range_header = false;
if(($readmod == 4 || $readmod == 1) && !empty($_SERVER['HTTP_RANGE'])) {
$has_range_header = true;
list($range_start, $range_end) = explode('-',(str_replace('bytes=', '', $_SERVER['HTTP_RANGE'])));
}
if(!$requestmode && !$has_range_header && empty($_GET['noupdate'])) {
if($_G['setting']['delayviewcount']) {
$_G['forum_logfile'] = './data/cache/forum_attachviews_'.intval(getglobal('config/server/id')).'.log';
if(substr(TIMESTAMP, -1) == '0') {
attachment_updateviews($_G['forum_logfile']);
}
if(file_put_contents(DISCUZ_ROOT.$_G['forum_logfile'], "$aid\n", FILE_APPEND) === false) {
if($_G['adminid'] == 1) {
showmessage('view_log_invalid', '', array('logfile' => $_G['forum_logfile']));
}
C::t('forum_attachment')->update_download($aid);
}
} else {
C::t('forum_attachment')->update_download($aid);
}
}
$db = DB::object();
$db->close();
!$_G['config']['output']['gzip'] && ob_end_clean();
if($attach['remote'] && !$_G['setting']['ftp']['hideurl'] && $isimage) {
dheader('location:'.$_G['setting']['ftp']['attachurl'].'forum/'.$attach['attachment']);
}
$mimetype = ext_to_mimetype($attach['filename']);
$filesize = !$attach['remote'] ? filesize($filename) : $attach['filesize'];
if ($has_range_header && !$range_end) $range_end = $filesize - 1;
$filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($attach['filename']) : rawurlencode(diconv($attach['filename'], CHARSET, 'UTF-8'));
$rfc6266blacklist = strexists($_SERVER['HTTP_USER_AGENT'], 'UCBrowser') || strexists($_SERVER['HTTP_USER_AGENT'], 'Quark') || strexists($_SERVER['HTTP_USER_AGENT'], 'SogouM') || strexists($_SERVER['HTTP_USER_AGENT'], 'baidu');
dheader('Date: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT');
dheader('Last-Modified: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT');
dheader('Content-Encoding: none');
if($isimage && !empty($_GET['noupdate']) || !empty($_GET['request'])) {
$cdtype = 'inline';
} else {
$cdtype = 'attachment';
}
dheader('Content-Disposition: '.$cdtype.'; '.'filename="'.$filenameencode.'"'.(($attach['filename'] == $filenameencode || $rfc6266blacklist) ? '' : '; filename*=utf-8\'\''.$filenameencode));
if($isimage) {
dheader('Content-Type: image');
} else {
dheader('Content-Type: ' . $mimetype);
}
dheader('Content-Length: '.$filesize);
if(!$attach['remote']) {
$xsendfile = getglobal('config/download/xsendfile');
if(!empty($xsendfile)) {
$type = intval($xsendfile['type']);
if($isimage){
$type = 0;
}
$cmd = '';
switch ($type) {
case 1: $cmd = 'X-Accel-Redirect'; $url = $xsendfile['dir'].$attach['attachment']; break;
case 2: $cmd = $_SERVER['SERVER_SOFTWARE'] <'lighttpd/1.5' ? 'X-LIGHTTPD-send-file' : 'X-Sendfile'; $url = $filename; break;
case 3: $cmd = 'X-Sendfile'; $url = $filename; break;
}
if($cmd) {
dheader("$cmd: $url");
exit();
}
}
if (($readmod == 4) || ($readmod == 1)) {
dheader('Accept-Ranges: bytes');
if($has_range_header) {
$rangesize = ($range_end - $range_start) >= 0 ? ($range_end - $range_start) + 1 : 0;
dheader('Content-Length: '.$rangesize);
dheader('HTTP/1.1 206 Partial Content');
dheader('Content-Range: bytes '.$range_start.'-'.$range_end.'/'.($filesize));
}
}
}
$attach['remote'] ? getremotefile($attach['attachment']) : getlocalfile($filename, $readmod, $range_start, $range_end);
function getremotefile($file) {
global $_G;
@set_time_limit(0);
if(!@readfile($_G['setting']['ftp']['attachurl'].'forum/'.$file)) {
$ftp = ftpcmd('object');
$tmpfile = @tempnam($_G['setting']['attachdir'], '');
if(is_object($ftp) && $ftp->ftp_get($tmpfile, 'forum/'.$file, FTP_BINARY)) {
@readfile($tmpfile);
@unlink($tmpfile);
} else {
@unlink($tmpfile);
return FALSE;
}
}
return TRUE;
}
function getlocalfile($filename, $readmod = 2, $range_start = 0, $range_end = 0) {
if($readmod == 1 || $readmod == 3 || $readmod == 4) {
if($fp = @fopen($filename, 'rb')) {
@fseek($fp, $range_start);
if(function_exists('fpassthru') && ($readmod == 3 || $readmod == 4) && ($range_end <= 0)) {
@fpassthru($fp);
} else {
if ($range_end > 0) {
send_file_by_chunk($fp, $range_end - $range_start + 1);
} else {
send_file_by_chunk($fp);
}
}
}
@fclose($fp);
} else {
@readfile($filename);
}
@flush(); @ob_flush();
}
function send_file_by_chunk($fp, $limit = PHP_INT_MAX) {
static $CHUNK_SIZE = 65536;
$count = 0;
while (!feof($fp)) {
$size_to_read = $CHUNK_SIZE;
if ($count + $size_to_read > $limit) $size_to_read = $limit - $count;
$buf = fread($fp, $size_to_read);
echo $buf;
flush();
ob_flush();
$count += strlen($buf);
if ($count >= $limit) break;
}
}
function attachment_updateviews($logfile) {
$viewlog = $viewarray = array();
$newlog = DISCUZ_ROOT.$logfile.random(6);
if(@rename(DISCUZ_ROOT.$logfile, $newlog)) {
$viewlog = file($newlog);
unlink($newlog);
if(is_array($viewlog) && !empty($viewlog)) {
$viewlog = array_count_values($viewlog);
foreach($viewlog as $id => $views) {
if($id > 0) {
$viewarray[$views][] = intval($id);
}
}
foreach($viewarray as $views => $ids) {
C::t('forum_attachment')->update_download($ids, $views);
}
}
}
}
function ext_to_mimetype($path) {
$ext = pathinfo($path, PATHINFO_EXTENSION);
$map = array(
'aac' => 'audio/aac',
'flac' => 'audio/flac',
'mp3' => 'audio/mpeg',
'm4a' => 'audio/mp4',
'wav' => 'audio/wav',
'ogg' => 'audio/ogg',
'weba' => 'audio/webm',
'flv' => 'video/x-flv',
'mp4' => 'video/mp4',
'm4v' => 'video/mp4',
'3gp' => 'video/3gpp',
'ogv' => 'video/ogg',
'webm' => 'video/webm'
);
$mime = $map[$ext];
if (!$mime) $mime = "application/octet-stream";
return $mime;
}
?>

View File

@@ -0,0 +1,44 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_collection.php 28448 2012-03-01 03:27:53Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['setting']['collectionstatus']) {
showmessage('collection_status_off');
}
require_once libfile('function/collection');
$tpp = $_G['setting']['topicperpage']; //per page
$maxteamworkers = $_G['setting']['collectionteamworkernum'];
$action = trim($_GET['action']);
$ctid = $_GET['ctid'];
$page = $_GET['page'];
$tid = intval($_GET['tid']);
$op = trim($_GET['op']);
$page = $page ? $page : 1;
if(!is_array($ctid)) {
$ctid = intval($ctid);
$_G['collection'] = C::t('forum_collection')->fetch($ctid);
}
$allowaction = array('index', 'view', 'edit', 'follow', 'comment', 'mycollection', 'all');
if(!in_array($action, $allowaction)) {
$action = 'index';
}
require_once libfile('collection/'.$action, 'include');
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,748 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_group.php 33695 2013-08-03 04:39:22Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['setting']['groupstatus']) {
showmessage('group_module_status_off');
}
require_once libfile('function/group');
$_G['action']['action'] = 3;
$_G['action']['fid'] = $_G['fid'];
$_G['basescript'] = 'group';
$actionarray = array('join', 'out', 'create', 'viewmember', 'manage', 'index', 'memberlist', 'recommend');
$action = getgpc('action') && in_array($_GET['action'], $actionarray) ? $_GET['action'] : 'index';
if(in_array($action, array('join', 'out', 'create', 'manage', 'recommend'))) {
if(empty($_G['uid'])) {
showmessage('not_loggedin', '', '', array('login' => 1));
}
}
if(empty($_G['fid']) && $action != 'create') {
showmessage('group_rediret_now', 'group.php');
}
$first = &$_G['cache']['grouptype']['first'];
$second = &$_G['cache']['grouptype']['second'];
$rssauth = $_G['rssauth'];
$rsshead = $_G['setting']['rssstatus'] ? ('<link rel="alternate" type="application/rss+xml" title="'.$_G['setting']['bbname'].' - '.$navtitle.'" href="'.$_G['siteurl'].'forum.php?mod=rss&fid='.$_G['fid'].'&amp;auth='.$rssauth."\" />\n") : '';
if($_G['fid']) {
if($_G['forum']['status'] != 3) {
showmessage('forum_not_group', 'group.php');
} elseif($_G['forum']['level'] == -1) {
showmessage('group_verify', '', array(), array('alert' => 'info'));
} elseif($_G['forum']['jointype'] < 0 && !$_G['forum']['ismoderator']) {
showmessage('forum_group_status_off', 'group.php');
}
$groupcache = getgroupcache($_G['fid'], array('replies', 'views', 'digest', 'lastpost', 'ranking', 'activityuser', 'newuserlist'), 604800);
$_G['forum']['icon'] = get_groupimg($_G['forum']['icon'], 'icon');
$_G['forum']['banner'] = get_groupimg($_G['forum']['banner']);
$_G['forum']['dateline'] = dgmdate($_G['forum']['dateline'], 'd');
$_G['forum']['posts'] = intval($_G['forum']['posts']);
$_G['grouptypeid'] = $_G['forum']['fup'];
$groupuser = C::t('forum_groupuser')->fetch_userinfo($_G['uid'], $_G['fid']);
$onlinemember = grouponline($_G['fid'], 1);
$groupmanagers = $_G['forum']['moderators'];
$nav = get_groupnav($_G['forum']);
$groupnav = $nav['nav'];
$seodata = array('forum' => $_G['forum']['name'], 'first' => $nav['first']['name'], 'second' => $nav['second']['name'], 'gdes' => $_G['forum']['description']);
list($navtitle, $metadescription, $metakeywords) = get_seosetting('grouppage', $seodata);
if(!$navtitle) {
$navtitle = helper_seo::get_title_page($_G['forum']['name'], $_G['page']).' - '.$_G['setting']['navs'][3]['navname'];
$nobbname = false;
} else {
$nobbname = true;
}
if(!$metakeywords) {
$metakeywords = $_G['forum']['name'];
}
if(!$metadescription) {
$metadescription = $_G['forum']['name'];
}
$_G['seokeywords'] = $_G['setting']['seokeywords']['group'];
$_G['seodescription'] = $_G['setting']['seodescription']['group'];
}
if(in_array($action, array('out', 'viewmember', 'manage', 'index', 'memberlist'))) {
$status = groupperm($_G['forum'], $_G['uid'], $action, $groupuser);
if($status == -1) {
showmessage('forum_not_group', 'group.php');
} elseif($status == 1) {
showmessage('forum_group_status_off');
}
if($action != 'index') {
if($status == 2) {
showmessage('forum_group_noallowed', "forum.php?mod=group&fid={$_G['fid']}");
} elseif($status == 3) {
showmessage('forum_group_moderated', "forum.php?mod=group&fid={$_G['fid']}");
}
}
}
if(in_array($action, array('index')) && $status != 2) {
$newuserlist = $activityuserlist = array();
foreach($groupcache['newuserlist']['data'] as $user) {
$newuserlist[$user['uid']] = $user;
$newuserlist[$user['uid']]['online'] = !empty($onlinemember['list']) && is_array($onlinemember['list']) && !empty($onlinemember['list'][$user['uid']]) ? 1 : 0;
}
$activityuser = array_slice($groupcache['activityuser']['data'], 0, 8);
foreach($activityuser as $user) {
$activityuserlist[$user['uid']] = $user;
$activityuserlist[$user['uid']]['online'] = !empty($onlinemember['list']) && is_array($onlinemember['list']) && !empty($onlinemember['list'][$user['uid']]) ? 1 : 0;
}
$groupviewed_list = get_viewedgroup();
}
$showpoll = $showtrade = $showreward = $showactivity = $showdebate = 0;
if($_G['forum']['allowpostspecial']) {
$showpoll = $_G['forum']['allowpostspecial'] & 1;
$showtrade = $_G['forum']['allowpostspecial'] & 2;
$showreward = isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]) && ($_G['forum']['allowpostspecial'] & 4);
$showactivity = $_G['forum']['allowpostspecial'] & 8;
$showdebate = $_G['forum']['allowpostspecial'] & 16;
}
if($_G['group']['allowpost']) {
$_G['group']['allowpostpoll'] = $_G['group']['allowpostpoll'] && $showpoll;
$_G['group']['allowposttrade'] = $_G['group']['allowposttrade'] && $showtrade;
$_G['group']['allowpostreward'] = $_G['group']['allowpostreward'] && $showreward;
$_G['group']['allowpostactivity'] = $_G['group']['allowpostactivity'] && $showactivity;
$_G['group']['allowpostdebate'] = $_G['group']['allowpostdebate'] && $showdebate;
}
if($action == 'index') {
$newthreadlist = $livethread = array();
if($status != 2) {
loadcache('forumstick');
$forumstickytids = '';
if(isset($_G['cache']['forumstick'][$_G['forum']['fup']])) {
$forumstickytids = $_G['cache']['forumstick'][$_G['forum']['fup']];
}
require_once libfile('function/feed');
if($forumstickytids) {
foreach(C::t('forum_thread')->fetch_all_by_tid_or_fid($_G['fid'], $forumstickytids) as $row) {
$row['dateline'] = dgmdate($row['dateline'], 'd');
$row['lastpost'] = dgmdate($row['lastpost'], 'u');
$row['allreplies'] = $row['replies'] + $row['comments'];
$row['lastposterenc'] = rawurlencode($row['lastposter']);
$stickythread[$row['tid']] = $row;
}
}
$newthreadlist = getgroupcache($_G['fid'], array('dateline'), 0, 10, 0, 1);
foreach($newthreadlist['dateline']['data'] as $key => $thread) {
if(!empty($stickythread) && $stickythread[$thread['tid']]) {
unset($newthreadlist['dateline']['data'][$key]);
continue;
}
$newthreadlist['dateline']['data'][$key]['allreplies'] = $newthreadlist['dateline']['data'][$key]['replies'] + $newthreadlist['dateline']['data'][$key]['comments'];
if($thread['closed'] == 1) {
$newthreadlist['dateline']['data'][$key]['folder'] = 'lock';
} elseif(empty($_G['cookie']['oldtopics']) || strpos($_G['cookie']['oldtopics'], 'D'.$thread['tid'].'D') === FALSE) {
$newthreadlist['dateline']['data'][$key]['folder'] = 'new';
} else {
$newthreadlist['dateline']['data'][$key]['folder'] = 'common';
}
}
if($stickythread) {
$newthreadlist['dateline']['data'] = array_merge($stickythread, $newthreadlist['dateline']['data']);
}
$groupfeedlist = array();
if(!IS_ROBOT) {
$activityuser = array_keys($groupcache['activityuser']['data']);
if($activityuser) {
$query = C::t('home_feed')->fetch_all_by_uid_dateline($activityuser);
foreach($query as $feed) {
if($feed['friend'] == 0) {
$groupfeedlist[] = mkfeed($feed);
}
}
}
}
if($_G['forum']['livetid']) {
include_once libfile('function/post');
$livethread = C::t('forum_thread')->fetch_thread($_G['forum']['livetid']);
$livepost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['forum']['livetid']);
$livemessage = threadmessagecutstr($livethread, $livepost['message'], 200);
$liveallowpostreply = $groupuser['uid'] && $groupuser['level'] ? true : false;
list($seccodecheck, $secqaacheck) = seccheck('post', 'newthread');
}
} else {
$newuserlist = $activityuserlist = array();
$newuserlist = array_slice($groupcache['newuserlist']['data'], 0, 4);
foreach($newuserlist as $user) {
$newuserlist[$user['uid']] = $user;
$newuserlist[$user['uid']]['online'] = !empty($onlinemember['list']) && is_array($onlinemember['list']) && !empty($onlinemember['list'][$user['uid']]) ? 1 : 0;
}
}
write_groupviewed($_G['fid']);
include template('diy:group/group:'.$_G['fid']);
} elseif($action == 'memberlist') {
$oparray = array('card', 'address', 'alluser');
$op = getgpc('op') && in_array($_GET['op'], $oparray) ? $_GET['op'] : 'alluser';
$page = intval(getgpc('page')) ? intval($_GET['page']) : 1;
$perpage = 50;
$start = ($page - 1) * $perpage;
$alluserlist = $adminuserlist = array();
$staruserlist = $page < 2 ? C::t('forum_groupuser')->groupuserlist($_G['fid'], 'lastupdate', 0, 0, array('level' => '3'), array('uid', 'username', 'level', 'joindateline', 'lastupdate')) : '';
$adminlist = $groupmanagers && $page < 2 ? $groupmanagers : array();
if($op == 'alluser') {
$alluserlist = C::t('forum_groupuser')->groupuserlist($_G['fid'], 'lastupdate', $perpage, $start, "AND level='4'", '', $onlinemember['list']);
$multipage = multi($_G['forum']['membernum'], $perpage, $page, 'forum.php?mod=group&action=memberlist&op=alluser&fid='.$_G['fid']);
if($adminlist) {
foreach($adminlist as $user) {
$adminuserlist[$user['uid']] = $user;
$adminuserlist[$user['uid']]['online'] = $onlinemember['list'] && is_array($onlinemember['list']) && $onlinemember['list'][$user['uid']] ? 1 : 0;
}
}
}
include template('diy:group/group:'.$_G['fid']);
} elseif($action == 'join') {
if(!submitcheck('groupjoin')) {
dheader('location: '.$_G['siteurl']."forum.php?mod=forumdisplay&fid={$_G['fid']}&extra=join");
}
$inviteuid = 0;
$membermaximum = $_G['current_grouplevel']['specialswitch']['membermaximum'];
if(!empty($membermaximum)) {
$curnum = C::t('forum_groupuser')->fetch_count_by_fid($_G['fid']);
if($curnum >= $membermaximum) {
showmessage('group_member_maximum', '', array('membermaximum' => $membermaximum));
}
}
if($groupuser['uid']) {
showmessage('group_has_joined', "forum.php?mod=group&fid={$_G['fid']}");
} else {
$modmember = 4;
$showmessage = 'group_join_succeed';
$confirmjoin = TRUE;
$inviteuid = C::t('forum_groupinvite')->fetch_uid_by_inviteuid($_G['fid'], $_G['uid']);
if($_G['forum']['jointype'] == 1) {
if(!$inviteuid) {
$confirmjoin = FALSE;
$showmessage = 'group_join_need_invite';
}
} elseif($_G['forum']['jointype'] == 2) {
$modmember = !empty($groupmanagers[$inviteuid]) || $_G['adminid'] == 1 ? 4 : 0;
!empty($groupmanagers[$inviteuid]) && $showmessage = 'group_join_apply_succeed';
}
if($confirmjoin) {
C::t('forum_groupuser')->insert($_G['fid'], $_G['uid'], $_G['username'], $modmember, TIMESTAMP, TIMESTAMP);
if($_G['forum']['jointype'] == 2 && (empty($inviteuid) || empty($groupmanagers[$inviteuid]))) {
foreach($groupmanagers as $manage) {
notification_add($manage['uid'], 'group', 'group_member_join', array('fid' => $_G['fid'], 'groupname' => $_G['forum']['name'], 'url' => $_G['siteurl'].'forum.php?mod=group&action=manage&op=checkuser&fid='.$_G['fid']), 1);
}
} else {
}
if($inviteuid) {
C::t('forum_groupinvite')->delete_by_inviteuid($_G['fid'], $_G['uid']);
}
if($modmember == 4) {
C::t('forum_forumfield')->update_membernum($_G['fid']);
}
C::t('forum_forumfield')->update($_G['fid'], array('lastupdate' => TIMESTAMP));
}
include_once libfile('function/stat');
updatestat('groupjoin');
delgroupcache($_G['fid'], array('activityuser', 'newuserlist'));
showmessage($showmessage, "forum.php?mod=group&fid={$_G['fid']}");
}
} elseif($action == 'out') {
if(!submitcheck('groupexit')) {
showmessage('undefined_action');
}
if($_G['uid'] == $_G['forum']['founderuid']) {
showmessage('group_exit_founder');
}
$showmessage = 'group_exit_succeed';
C::t('forum_groupuser')->delete_by_fid($_G['fid'], $_G['uid']);
C::t('forum_forumfield')->update_membernum($_G['fid'], -1);
update_groupmoderators($_G['fid']);
delgroupcache($_G['fid'], array('activityuser', 'newuserlist'));
showmessage($showmessage, "forum.php?mod=forumdisplay&fid={$_G['fid']}");
} elseif($action == 'create') {
if(!$_G['group']['allowbuildgroup']) {
showmessage('group_create_usergroup_failed', "group.php");
}
$creditstransextra = $_G['setting']['creditstransextra']['12'] ? $_G['setting']['creditstransextra']['12'] : $_G['setting']['creditstrans'];
if($_G['group']['buildgroupcredits']) {
if(empty($creditstransextra)) {
$_G['group']['buildgroupcredits'] = 0;
} else {
getuserprofile('extcredits'.$creditstransextra);
if($_G['member']['extcredits'.$creditstransextra] < $_G['group']['buildgroupcredits']) {
showmessage('group_create_usergroup_credits_failed', '', array('buildgroupcredits' => $_G['group']['buildgroupcredits']. $_G['setting']['extcredits'][$creditstransextra]['unit'].$_G['setting']['extcredits'][$creditstransextra]['title']));
}
}
}
$groupnum = C::t('forum_forumfield')->fetch_groupnum_by_founderuid($_G['uid']);
$allowbuildgroup = $_G['group']['allowbuildgroup'] - $groupnum;
if($allowbuildgroup < 1) {
showmessage('group_create_max_failed');
}
$_GET['fupid'] = intval($_GET['fupid']);
$_GET['groupid'] = intval($_GET['groupid']);
if(!submitcheck('createsubmit')) {
$groupselect = get_groupselect(getgpc('fupid'), getgpc('groupid'));
} else {
$parentid = intval($_GET['parentid']);
$fup = intval($_GET['fup']);
$name = censor(dhtmlspecialchars(cutstr(trim($_GET['name']), 20, '')), NULL, FALSE, FALSE);
$censormod = censormod($name);
if(empty($name)) {
showmessage('group_name_empty');
} elseif($censormod) {
showmessage('group_name_failed');
} elseif(empty($parentid) && empty($fup)) {
showmessage('group_category_empty');
}
if(empty($_G['cache']['grouptype']['first'][$parentid]) && empty($_G['cache']['grouptype']['second'][$fup])
|| $_G['cache']['grouptype']['first'][$parentid]['secondlist'] && !in_array($_G['cache']['grouptype']['second'][$fup]['fid'], $_G['cache']['grouptype']['first'][$parentid]['secondlist'])) {
showmessage('group_category_error');
}
if(empty($fup)) {
$fup = $parentid;
}
if(C::t('forum_forum')->fetch_fid_by_name($name)) {
showmessage('group_name_exist');
}
require_once libfile('function/discuzcode');
$descriptionnew = discuzcode(dhtmlspecialchars(censor(trim($_GET['descriptionnew']), NULL, FALSE, FALSE)), 0, 0, 0, 0, 1, 1, 0, 0, 1);
$censormod = censormod($descriptionnew);
if($censormod) {
showmessage('group_description_failed');
}
if(empty($_G['setting']['groupmod']) || $_G['adminid'] == 1) {
$levelinfo = C::t('forum_grouplevel')->fetch_by_credits();
$levelid = $levelinfo['levelid'];
} else {
$levelid = -1;
}
$newfid = C::t('forum_forum')->insert_group($fup, 'sub', $name, '3', $levelid);
if($newfid) {
$jointype = intval($_GET['jointype']);
$gviewperm = intval($_GET['gviewperm']);
$fieldarray = array('fid' => $newfid, 'description' => $descriptionnew, 'jointype' => $jointype, 'gviewperm' => $gviewperm, 'dateline' => TIMESTAMP, 'founderuid' => $_G['uid'], 'foundername' => $_G['username'], 'membernum' => 1);
C::t('forum_forumfield')->insert($fieldarray);
C::t('forum_forumfield')->update_groupnum($fup, 1);
C::t('forum_groupuser')->insert($newfid, $_G['uid'], $_G['username'], 1, TIMESTAMP);
require_once libfile('function/cache');
updatecache('grouptype');
}
if($creditstransextra && $_G['group']['buildgroupcredits']) {
updatemembercount($_G['uid'], array($creditstransextra => -$_G['group']['buildgroupcredits']), 1, 'BGR', $newfid);
}
include_once libfile('function/stat');
updatestat('group');
if($levelid == -1) {
showmessage('group_create_mod_succeed', "group.php?mod=my&view=manager", array(), array('alert' => 'right', 'showdialog' => 1, 'showmsg' => true, 'locationtime' => true));
}
showmessage('group_create_succeed', "forum.php?mod=group&action=manage&fid=$newfid", array(), array('showdialog' => 1, 'showmsg' => true, 'locationtime' => true));
}
include template('diy:group/group:'.$_G['fid']);
} elseif($action == 'manage'){
if(!$_G['forum']['ismoderator']) {
showmessage('group_admin_noallowed');
}
$specialswitch = $_G['current_grouplevel']['specialswitch'];
$oparray = array('group', 'checkuser', 'manageuser', 'threadtype', 'demise');
$_GET['op'] = getgpc('op') && in_array($_GET['op'], $oparray) ? $_GET['op'] : 'group';
if(empty($groupmanagers[$_G['uid']]) && !in_array($_GET['op'], array('group', 'threadtype', 'demise')) && $_G['adminid'] != 1) {
showmessage('group_admin_noallowed');
}
$page = intval(getgpc('page')) ? intval($_GET['page']) : 1;
$perpage = 50;
$start = ($page - 1) * $perpage;
$url = 'forum.php?mod=group&action=manage&op='.$_GET['op'].'&fid='.$_G['fid'];
if($_GET['op'] == 'group') {
$domainlength = checkperm('domainlength');
if(submitcheck('groupmanage')) {
$forumarr = array();
if(isset($_GET['domain']) && $_G['forum']['domain'] != $_GET['domain']) {
$domain = strtolower(trim($_GET['domain']));
if($_G['setting']['allowgroupdomain'] && !empty($_G['setting']['domain']['root']['group']) && $domainlength) {
checklowerlimit('modifydomain');
}
require_once libfile('function/delete');
if(empty($domainlength) || empty($domain)) {
$domain = '';
deletedomain($_G['fid'], 'group');
} else {
require_once libfile('function/domain');
if(domaincheck($domain, $_G['setting']['domain']['root']['group'], $domainlength)) {
deletedomain($_G['fid'], 'group');
C::t('common_domain')->insert(array('domain' => $domain, 'domainroot' => $_G['setting']['domain']['root']['group'], 'id' => $_G['fid'], 'idtype' => 'group'));
}
}
$forumarr['domain'] = $domain;
updatecreditbyaction('modifydomain');
}
if(($_GET['name'] && !empty($specialswitch['allowchangename'])) || ($_GET['fup'] && !empty($specialswitch['allowchangetype']))) {
if($_G['uid'] != $_G['forum']['founderuid'] && $_G['adminid'] != 1) {
showmessage('group_edit_only_founder');
}
$fup = intval($_GET['fup']);
$parentid = intval($_GET['parentid']);
if(isset($_GET['name'])) {
$_GET['name'] = censor(dhtmlspecialchars(cutstr(trim($_GET['name']), 20, '')), NULL, FALSE, FALSE);
if(empty($_GET['name'])) {
showmessage('group_name_empty');
}
$censormod = censormod($_GET['name']);
if($censormod) {
showmessage('group_name_failed');
}
} elseif(isset($_GET['parentid']) && empty($parentid) && empty($fup)) {
showmessage('group_category_empty');
}
if(!empty($_GET['name']) && $_GET['name'] != $_G['forum']['name']) {
if(C::t('forum_forum')->fetch_fid_by_name($_GET['name'])) {
showmessage('group_name_exist', $url);
}
$forumarr['name'] = $_GET['name'];
}
if(empty($fup)) {
$fup = $parentid;
}
if(isset($_GET['parentid']) && $fup != $_G['forum']['fup']) {
$forumarr['fup'] = $fup;
}
}
if($forumarr) {
C::t('forum_forum')->update($_G['fid'], $forumarr);
if($forumarr['fup']) {
C::t('forum_forumfield')->update_groupnum($forumarr['fup'], 1);
C::t('forum_forumfield')->update_groupnum($_G['forum']['fup'], -1);
require_once libfile('function/cache');
updatecache('grouptype');
}
}
$setarr = array();
$deletebanner = $_GET['deletebanner'];
$iconnew = upload_icon_banner($_G['forum'], $_FILES['iconnew'], 'icon');
$bannernew = upload_icon_banner($_G['forum'], $_FILES['bannernew'], 'banner');
if($iconnew) {
$setarr['icon'] = $iconnew;
$group_recommend = dunserialize($_G['setting']['group_recommend']);
if($group_recommend[$_G['fid']]) {
$group_recommend[$_G['fid']]['icon'] = get_groupimg($iconnew);
C::t('common_setting')->update_setting('group_recommend', $group_recommend);
include libfile('function/cache');
updatecache('setting');
}
}
if($bannernew && empty($deletebanner)) {
$setarr['banner'] = $bannernew;
} elseif($deletebanner) {
$setarr['banner'] = '';
@unlink($_G['forum']['banner']);
}
require_once libfile('function/discuzcode');
$_GET['descriptionnew'] = discuzcode(censor(trim($_GET['descriptionnew']), NULL, FALSE, FALSE), 0, 0, 0, 0, 1, 1, 0, 0, 1);
$censormod = censormod($_GET['descriptionnew']);
if($censormod) {
showmessage('group_description_failed');
}
$_GET['jointypenew'] = intval($_GET['jointypenew']);
if($_GET['jointypenew'] == '-1' && $_G['uid'] != $_G['forum']['founderuid']) {
showmessage('group_close_only_founder');
}
$_GET['gviewpermnew'] = intval($_GET['gviewpermnew']);
$setarr['description'] = $_GET['descriptionnew'];
$setarr['jointype'] = $_GET['jointypenew'];
$setarr['gviewperm'] = $_GET['gviewpermnew'];
C::t('forum_forumfield')->update($_G['fid'], $setarr);
showmessage('group_setup_succeed', $url);
} else {
$firstgid = $_G['cache']['grouptype']['second'][$_G['forum']['fup']]['fup'];
$groupselect = get_groupselect($firstgid ? $firstgid : $_G['forum']['fup'], $_G['forum']['fup']);
$gviewpermselect = $jointypeselect = array('','','');
require_once libfile('function/editor');
$_G['forum']['descriptionnew'] = html2bbcode($_G['forum']['description']);
$jointypeselect[$_G['forum']['jointype']] = 'checked="checked"';
$gviewpermselect[$_G['forum']['gviewperm']] = 'checked="checked"';
if($_G['setting']['allowgroupdomain'] && !empty($_G['setting']['domain']['root']['group']) && $domainlength) {
loadcache('creditrule');
getuserprofile('extcredits1');
$rule = $_G['cache']['creditrule']['modifydomain'];
$credits = $consume = $common = '';
for($i = 1; $i <= 8; $i++) {
if($_G['setting']['extcredits'][$i] && $rule['extcredits'.$i]) {
$consume .= $common.$_G['setting']['extcredits'][$i]['title'].$rule['extcredits'.$i].$_G['setting']['extcredits'][$i]['unit'];
$credits .= $common.$_G['setting']['extcredits'][$i]['title'].$_G['member']['extcredits'.$i].$_G['setting']['extcredits'][$i]['unit'];
$common = ',';
}
}
}
}
} elseif($_GET['op'] == 'checkuser') {
$checktype = 0;
$checkusers = array();
if(!empty($_GET['uid'])) {
$checkusers = array($_GET['uid']);
$checktype = intval($_GET['checktype']);
} elseif(getgpc('checkall') == 1 || getgpc('checkall') == 2) {
$checktype = $_GET['checkall'];
$query = C::t('forum_groupuser')->fetch_all_by_fid($_G['fid'], 1);
foreach($query as $row) {
$checkusers[] = $row['uid'];
}
}
if($checkusers) {
foreach($checkusers as $uid) {
$notification = $checktype == 1 ? 'group_member_check' : 'group_member_check_failed';
notification_add($uid, 'group', $notification, array('fid' => $_G['fid'], 'groupname' => $_G['forum']['name'], 'url' => $_G['siteurl'].'forum.php?mod=group&fid='.$_G['fid']), 1);
}
if($checktype == 1) {
C::t('forum_groupuser')->update_for_user($checkusers, $_G['fid'], null, null, 4);
C::t('forum_forumfield')->update_membernum($_G['fid'], count($checkusers));
} elseif($checktype == 2) {
C::t('forum_groupuser')->delete_by_fid($_G['fid'], $checkusers);
}
if($checktype == 1) {
showmessage('group_moderate_succeed', $url);
} else {
showmessage('group_moderate_failed', $url);
}
} else {
$checkusers = array();
$userlist = C::t('forum_groupuser')->groupuserlist($_G['fid'], 'joindateline', $perpage, $start, array('level' => 0));
$checknum = C::t('forum_groupuser')->fetch_count_by_fid($_G['fid'], 1);
$multipage = multi($checknum, $perpage, $page, $url);
foreach($userlist as $user) {
$user['joindateline'] = date('Y-m-d H:i', $user['joindateline']);
$checkusers[$user['uid']] = $user;
}
}
} elseif($_GET['op'] == 'manageuser') {
$mtype = array(1 => lang('group/template', 'group_moderator'), 2 => lang('group/template', 'group_moderator_vice'), 3 => lang('group/template', 'group_star_member_title'), 4 => lang('group/misc', 'group_normal_member'), 5 => lang('group/misc', 'group_goaway'));
if(!submitcheck('manageuser')) {
$userlist = array();
if(empty($_GET['srchuser'])) {
$staruserlist = $page < 2 ? C::t('forum_groupuser')->groupuserlist($_G['fid'], '', 0, 0, array('level' => '3'), array('uid', 'username', 'level', 'joindateline', 'lastupdate')) : '';
$adminuserlist = $groupmanagers && $page < 2 ? $groupmanagers : array();
$multipage = multi($_G['forum']['membernum'], $perpage, $page, $url);
} else {
$start = 0;
}
$userlist = C::t('forum_groupuser')->groupuserlist($_G['fid'], '', $perpage, $start, $_GET['srchuser'] ? "AND username like '".addslashes($_GET['srchuser'])."%'" : "AND level='4'");
} else {
$muser = getgpc('muid');
$targetlevel = $_GET['targetlevel'];
if($muser && is_array($muser)) {
foreach($muser as $muid => $mlevel) {
if($_G['adminid'] != 1 && $_G['forum']['founderuid'] != $_G['uid'] && $groupmanagers[$muid] && $groupmanagers[$muid]['level'] <= $groupuser['level']) {
showmessage('group_member_level_admin_noallowed.', $url);
}
if($_G['adminid'] == 1 || ($muid != $_G['uid'] && ($_G['forum']['founderuid'] == $_G['uid'] || !$groupmanagers[$muid] || $groupmanagers[$muid]['level'] > $groupuser['level']))) {
if($targetlevel != 5) {
C::t('forum_groupuser')->update_for_user($muid, $_G['fid'], null, null, $targetlevel);
} else {
if(!$groupmanagers[$muid] || count($groupmanagers) > 1) {
C::t('forum_groupuser')->delete_by_fid($_G['fid'], $muid);
C::t('forum_forumfield')->update_membernum($_G['fid'], -1);
} else {
showmessage('group_only_one_moderator', $url);
}
}
}
}
update_groupmoderators($_G['fid']);
showmessage('group_setup_succeed', $url.'&page='.$page);
} else {
showmessage('group_choose_member', $url);
}
}
} elseif($_GET['op'] == 'threadtype') {
if(empty($specialswitch['allowthreadtype'])) {
showmessage('group_level_cannot_do');
}
if($_G['uid'] != $_G['forum']['founderuid'] && $_G['adminid'] != 1) {
showmessage('group_threadtype_only_founder');
}
$typenumlimit = 20;
if(!submitcheck('groupthreadtype')) {
$threadtypes = $checkeds = array();
if(empty($_G['forum']['threadtypes'])) {
$checkeds['status'][0] = 'checked';
$display = 'none';
} else {
$display = '';
$_G['forum']['threadtypes']['status'] = 1;
foreach($_G['forum']['threadtypes'] as $key => $val) {
$val = intval($val);
$checkeds[$key][$val] = 'checked';
}
}
foreach(C::t('forum_threadclass')->fetch_all_by_fid($_G['fid']) as $type) {
$type['enablechecked'] = isset($_G['forum']['threadtypes']['types'][$type['typeid']]) ? ' checked="checked"' : '';
$type['name'] = dhtmlspecialchars($type['name']);
$threadtypes[] = $type;
}
} else {
$threadtypesnew = $_GET['threadtypesnew'];
$threadtypesnew['types'] = $threadtypes['special'] = $threadtypes['show'] = array();
if(is_array($_GET['newname']) && $_GET['newname']) {
$newname = array_unique($_GET['newname']);
if($newname) {
foreach($newname as $key => $val) {
$val = dhtmlspecialchars(censor(cutstr(trim($val), 16, '')));
if($_GET['newenable'][$key] && $val) {
$newtype = C::t('forum_threadclass')->fetch_by_fid_name($_G['fid'], $val);
$newtypeid = $newtype['typeid'];
if(!$newtypeid) {
$typenum = C::t('forum_threadclass')->count_by_fid($_G['fid']);
if($typenum < $typenumlimit) {
$threadtypes_newdisplayorder = intval($_GET['newdisplayorder'][$key]);
$newtypeid = C::t('forum_threadclass')->insert(array('fid' => $_G['fid'], 'name' => $val, 'displayorder' => $threadtypes_newdisplayorder), true);
}
}
if($newtypeid) {
$threadtypesnew['options']['name'][$newtypeid] = $val;
$threadtypesnew['options']['displayorder'][$newtypeid] = $threadtypes_newdisplayorder;
$threadtypesnew['options']['enable'][$newtypeid] = 1;
}
}
}
}
$threadtypesnew['status'] = 1;
} else {
$newname = array();
}
if($threadtypesnew['status']) {
if(is_array($threadtypesnew['options']) && $threadtypesnew['options']) {
if(!empty($threadtypesnew['options']['enable'])) {
$typeids = array_keys($threadtypesnew['options']['enable']);
} else {
$typeids = array(0);
}
if(!empty($threadtypesnew['options']['delete'])) {
C::t('forum_threadclass')->delete_by_typeid_fid($threadtypesnew['options']['delete'], $_G['fid']);
}
foreach(C::t('forum_threadclass')->fetch_all_by_typeid_fid($typeids, $_G['fid']) as $type) {
if($threadtypesnew['options']['name'][$type['typeid']] != $type['name'] || $threadtypesnew['options']['displayorder'][$type['typeid']] != $type['displayorder']) {
$threadtypesnew['options']['name'][$type['typeid']] = dhtmlspecialchars(censor(cutstr(trim($threadtypesnew['options']['name'][$type['typeid']]), 16, '')));
$threadtypesnew['options']['displayorder'][$type['typeid']] = intval($threadtypesnew['options']['displayorder'][$type['typeid']]);
C::t('forum_threadclass')->update_by_typeid_fid($type['typeid'], $_G['fid'], array(
'name' => $threadtypesnew['options']['name'][$type['typeid']],
'displayorder' => $threadtypesnew['options']['displayorder'][$type['typeid']],
));
}
}
}
if($threadtypesnew && $typeids) {
foreach(C::t('forum_threadclass')->fetch_all_by_typeid($typeids) as $type) {
if($threadtypesnew['options']['enable'][$type['typeid']]) {
$threadtypesnew['types'][$type['typeid']] = $threadtypesnew['options']['name'][$type['typeid']];
}
}
}
$threadtypesnew = !empty($threadtypesnew) ? serialize($threadtypesnew) : '';
} else {
$threadtypesnew = '';
}
C::t('forum_forumfield')->update($_G['fid'], array('threadtypes' => $threadtypesnew));
showmessage('group_threadtype_edit_succeed', $url);
}
} elseif($_GET['op'] == 'demise') {
if((!empty($_G['forum']['founderuid']) && $_G['forum']['founderuid'] == $_G['uid']) || $_G['adminid'] == 1) {
$ucresult = $allowbuildgroup = $groupnum = 0;
if(count($groupmanagers) <= 1) {
showmessage('group_cannot_demise');
}
if(submitcheck('groupdemise')) {
$suid = intval($_GET['suid']);
if(empty($suid)) {
showmessage('group_demise_choose_receiver');
}
if(empty($_GET['grouppwd'])) {
showmessage('group_demise_password');
}
loaducenter();
$ucresult = uc_user_login($_G['uid'], $_GET['grouppwd'], 1);
if(!is_array($ucresult) || $ucresult[0] < 1) {
showmessage('group_demise_password_error');
}
$user = getuserbyuid($suid);
loadcache('usergroup_'.$user['groupid']);
$allowbuildgroup = $_G['cache']['usergroup_'.$user['groupid']]['allowbuildgroup'];
if($allowbuildgroup > 0) {
$groupnum = C::t('forum_forumfield')->fetch_groupnum_by_founderuid($suid);
}
if(empty($allowbuildgroup) || $allowbuildgroup - $groupnum < 1) {
showmessage('group_demise_receiver_cannot_do');
}
C::t('forum_forumfield')->update($_G['fid'], array('founderuid' => $suid, 'foundername' => $user['username']));
C::t('forum_groupuser')->update_for_user($suid, $_G['fid'], NULL, NULL, 1);
update_groupmoderators($_G['fid']);
sendpm($suid, lang('group/misc', 'group_demise_message_title', array('forum' => $_G['forum']['name'])), lang('group/misc', 'group_demise_message_body', array('forum' => $_G['forum']['name'], 'siteurl' => $_G['siteurl'], 'fid' => $_G['fid'])), $_G['uid']);
showmessage('group_demise_succeed', 'forum.php?mod=group&action=manage&fid='.$_G['fid']);
}
} else {
showmessage('group_demise_founder_only');
}
} else {
showmessage('undefined_action');
}
include template('diy:group/group:'.$_G['fid']);
} elseif($action == 'recommend') {
if(!$_G['forum']['ismoderator'] || !in_array($_G['adminid'], array(1,2))) {
showmessage('group_admin_noallowed');
}
if(submitcheck('grouprecommend')) {
if($_GET['recommend'] != $_G['forum']['recommend']) {
C::t('forum_forum')->update($_G['fid'], array('recommend' => intval($_GET['recommend'])));
require_once libfile('function/cache');
updatecache('forumrecommend');
}
showmessage('grouprecommend_succeed', '', array(), array('alert' => 'right', 'closetime' => true, 'showdialog' => 1));
} else {
require_once libfile('function/forumlist');
$forumselect = forumselect(FALSE, 0, $_G['forum']['recommend']);
}
include template('group/group_recommend');
}
?>

View File

@@ -0,0 +1,485 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_guide.php 34066 2013-09-27 08:36:09Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['setting']['guidestatus']) {
showmessage('guide_status_off');
}
$view = $_GET['view'];
loadcache('forum_guide');
require_once libfile('function/forumlist');
$setting_guide = dunserialize($_G['setting']['guide']);
$setting_guide['index'] = $setting_guide['index'] ? $setting_guide['index'] : 'hot';
if(!in_array($view, array('hot', 'digest', 'new', 'my', 'newthread', 'sofa', 'index'))) {
$view = $setting_guide['index'];
}
$lang = lang('forum/template');
$navtitle = $lang['guide'].'-'.$lang['guide_'.$view];
$perpage = 50;
$start = $perpage * ($_G['page'] - 1);
$data = array();
if($_GET['rss'] == 1) {
if(!$_G['setting']['rssstatus']) {
exit('RSS Disabled');
}
if($view == 'index' || $view == 'my') {
showmessage('URL_ERROR');
}
$ttl = 30;
$charset = $_G['config']['output']['charset'];
dheader("Content-type: application/xml");
echo "<?xml version=\"1.0\" encoding=\"".$charset."\"?>\n".
"<rss version=\"2.0\">\n".
" <channel>\n".
" <title>{$_G['setting']['bbname']} - {$lang['guide']} - ".$lang['guide_'.$view]."</title>\n".
" <link>{$_G['siteurl']}forum.php?mod=guide&amp;view=$view</link>\n".
" <description>".$lang['guide_'.$view]."</description>\n".
" <copyright>Copyright(C) {$_G['setting']['bbname']}</copyright>\n".
" <generator>Discuz! Board by Comsenz Inc.</generator>\n".
" <lastBuildDate>".gmdate('r', TIMESTAMP)."</lastBuildDate>\n".
" <ttl>$ttl</ttl>\n".
" <image>\n".
" <url>{$_G['siteurl']}static/image/common/logo_88_31.gif</url>\n".
" <title>{$_G['setting']['bbname']}</title>\n".
" <link>{$_G['siteurl']}</link>\n".
" </image>\n";
$info = C::t('forum_rsscache')->fetch_all_by_guidetype($view, $perpage);
if(empty($info) || (TIMESTAMP - $info[0]['lastupdate'] > $ttl * 60)) {
update_guide_rsscache($view, $perpage);
}
foreach($info as $thread) {
list($thread['description'], $attachremote, $attachfile, $attachsize) = explode("\t", $thread['description']);
if($attachfile) {
if($attachremote) {
$filename = $_G['setting']['ftp']['attachurl'].'forum/'.$attachfile;
} else {
$filename = $_G['siteurl'].$_G['setting']['attachurl'].'forum/'.$attachfile;
}
}
echo " <item>\n".
" <title>".$thread['subject']."</title>\n".
" <link>{$_G['siteurl']}".($trewriteflag ? rewriteoutput('forum_viewthread', 1, '', $thread['tid']) : "forum.php?mod=viewthread&amp;tid={$thread['tid']}")."</link>\n".
" <description><![CDATA[".dhtmlspecialchars($thread['description'])."]]></description>\n".
" <category>".dhtmlspecialchars($thread['forum'])."</category>\n".
" <author>".dhtmlspecialchars($thread['author'])."</author>\n".
($attachfile ? '<enclosure url="'.$filename.'" length="'.$attachsize.'" type="image/jpeg" />' : '').
" <pubDate>".gmdate('r', $thread['dateline'])."</pubDate>\n".
" </item>\n";
}
echo " </channel>\n".
"</rss>";
exit();
}
if($view != 'index') {
$theurl = 'forum.php?mod=guide&view='.$view;
if($view == 'my') {
if(!$_G['uid']) {
showmessage('to_login', '', array(), array('login' => 1));
}
$lang = lang('forum/template');
$filter_array = array( 'common' => $lang['have_posted'], 'save' => $lang['guide_draft'], 'close' => $lang['close'], 'aduit' => $lang['pending'], 'ignored' => $lang['have_ignored'], 'recyclebin' => $lang['forum_recyclebin']);
$viewtype = in_array($_GET['type'], array('reply', 'thread', 'postcomment')) ? $_GET['type'] : 'thread';
if($searchkey = stripsearchkey($_GET['searchkey'])) {
$searchkey = dhtmlspecialchars($searchkey);
}
$theurl .= '&type='.$viewtype;
$filter = in_array($_GET['filter'], array_keys($filter_array)) ? $_GET['filter'] : '';
$searchbody = 0;
if($filter) {
$theurl .= '&filter='.$filter;
$searchbody = 1;
}
if($_GET['fid']) {
$theurl .= '&fid='.intval($_GET['fid']);
$searchbody = 1;
}
if($searchkey) {
$theurl .= '&searchkey='.$searchkey;
$searchbody = 1;
}
require_once libfile('function/forumlist');
$orderactives[$viewtype] = 'class="a"';
$forumlist = forumselect(FALSE, 0, intval($_GET['fid']));
$data['my'] = get_my_threads($viewtype, $_GET['fid'], $filter, $searchkey, $start, $perpage, $theurl);
$tids = $data['my']['tids'];
$posts = $data['my']['posts'];
} else {
$data[$view] = get_guide_list($view, $start, $perpage);
}
if(empty($data['my']['multi'])) {
$multipage = multi($data[$view]['threadcount'], $perpage, $_G['page'], $theurl, $_G['setting']['threadmaxpages']);
} else {
$multipage = $data['my']['multi'];
}
} else {
$data['hot'] = get_guide_list('hot', 0, 30);
$data['digest'] = get_guide_list('digest', 0, 30);
$data['new'] = get_guide_list('new', 0, 30);
$data['newthread'] = get_guide_list('newthread', 0, 30);
}
loadcache('stamps');
$currentview[$view] = 'class="xw1 a"';
$navigation = $view != 'index' ? ' <em>&rsaquo;</em> <a href="forum.php?mod=guide&view='.$view.'">'.$lang['guide_'.$view].'</a>' : '';
include template('diy:forum/guide');
function get_guide_list($view, $start = 0, $num = 50, $again = 0) {
global $_G;
$setting_guide = dunserialize($_G['setting']['guide']);
if(!in_array($view, array('hot', 'digest', 'new', 'newthread', 'sofa'))) {
return array();
}
loadcache('forums');
$cachetimelimit = ($view != 'sofa') ? 900 : 60;
$cache = $_G['cache']['forum_guide'][$view.($view=='sofa' && $_G['fid'] ? $_G['fid'] : '')];
$notsofatids = array();
if($cache && (TIMESTAMP - $cache['cachetime']) < $cachetimelimit) {
$tids = is_array($cache['data']) ? $cache['data'] : array();
$threadcount = count($tids);
$tids = array_slice($tids, $start, $num, true);
$updatecache = false;
if(empty($tids)) {
return array();
}
} else {
$dateline = 0;
$maxnum = 50000;
if($setting_guide[$view.'dt']) {
$dateline = time() - intval($setting_guide[$view.'dt']);
}
if($view != 'sofa') {
$maxtid = C::t('forum_thread')->fetch_max_tid();
$limittid = max(0,($maxtid - $maxnum));
if($again) {
$limittid = max(0,($limittid - $maxnum));
}
$tids = array();
}
foreach($_G['cache']['forums'] as $fid => $forum) {
if($forum['type'] != 'group' && $forum['status'] > 0 && !$forum['viewperm'] && !$forum['havepassword']) {
$fids[$fid] = $fid;
}
}
if(empty($fids)) {
return array();
}
if($view == 'sofa') {
$sofa = C::t('forum_sofa')->fetch_all_by_fid($fids, $start, $num);
$tids = array_keys($sofa);
}
$updatecache = true;
}
$query = C::t('forum_thread')->fetch_all_for_guide($view, $limittid, $tids, $_G['setting']['heatthread']['guidelimit'], $dateline);
$list = array();
$n = 0;
foreach($query as $thread) {
if(empty($tids) && ($thread['isgroup'] || !in_array($thread['fid'], $fids))) {
continue;
}
if($thread['displayorder'] < 0) {
continue;
}
if($view == 'sofa' && $thread['replies'] > 0) {
$notsofatids[] = $thread['tid'];
continue;
}
$thread = guide_procthread($thread);
$threadids[] = $thread['tid'];
if($tids || ($n >= $start && $n < ($start + $num))) {
$list[$thread['tid']] = $thread;
$fids[$thread['fid']] = $thread['fid'];
}
$n ++;
}
if($limittid > $maxnum && !$again && count($list) < 50) {
return get_guide_list($view, $start, $num, 1);
}
$forumnames = array();
if($fids) {
$forumnames = C::t('forum_forum')->fetch_all_name_by_fid($fids);
}
$threadlist = array();
if($tids) {
$threadids = array();
foreach($tids as $key => $tid) {
if($list[$tid]) {
$threadlist[$key] = $list[$tid];
$threadids[] = $tid;
}
}
} else {
$threadlist = $list;
}
unset($list);
if($updatecache) {
$threadids = is_array($threadids) ? $threadids : array();
$threadcount = count($threadids);
$data = array('cachetime' => TIMESTAMP, 'data' => $threadids);
$_G['cache']['forum_guide'][$view.($view=='sofa' && $_G['fid'] ? $_G['fid'] : '')] = $data;
savecache('forum_guide', $_G['cache']['forum_guide']);
if(!empty($notsofatids)) {
C::t('forum_sofa')->delete($notsofatids);
}
}
return array('forumnames' => $forumnames, 'threadcount' => $threadcount, 'threadlist' => $threadlist);
}
function get_my_threads($viewtype, $fid = 0, $filter = '', $searchkey = '', $start = 0, $perpage = 20, $theurl = '') {
global $_G;
$fid = $fid ? intval($fid) : null;
loadcache('forums');
$dglue = '=';
if($viewtype == 'thread') {
$authorid = $_G['uid'];
$dglue = '=';
if($filter == 'recyclebin') {
$displayorder = -1;
} elseif($filter == 'aduit') {
$displayorder = -2;
} elseif($filter == 'ignored') {
$displayorder = -3;
} elseif($filter == 'save') {
$displayorder = -4;
} elseif($filter == 'close') {
$closed = 1;
} elseif($filter == 'common') {
$closed = 0;
$displayorder = 0;
$dglue = '>=';
}
$gids = $fids = $forums = $list = array();
foreach(C::t('forum_thread')->fetch_all_by_authorid_displayorder($authorid, $displayorder, $dglue, $closed, $searchkey, $start, $perpage, null, $fid) as $tid => $value) {
if(!isset($_G['cache']['forums'][$value['fid']])) {
$gids[$value['fid']] = $value['fid'];
} else {
$forumnames[$value['fid']] = array('fid'=> $value['fid'], 'name' => $_G['cache']['forums'][$value['fid']]['name']);
}
$list[$value['tid']] = guide_procthread($value);
}
if(!empty($gids)) {
$gforumnames = C::t('forum_forum')->fetch_all_name_by_fid($gids);
foreach($gforumnames as $fid => $val) {
$forumnames[$fid] = $val;
}
}
$listcount = count($list);
} elseif($viewtype == 'postcomment') {
require_once libfile('function/post');
$pids = $tids = array();
$postcommentarr = C::t('forum_postcomment')->fetch_all_by_authorid($_G['uid'], $start, $perpage);
foreach($postcommentarr as $value) {
$pids[] = $value['pid'];
$tids[] = $value['tid'];
}
$pids = C::t('forum_post')->fetch_all_post(0, $pids);
$tids = C::t('forum_thread')->fetch_all($tids);
$list = $fids = array();
foreach($postcommentarr as $value) {
$value['authorid'] = $pids[$value['pid']]['authorid'];
$value['fid'] = $pids[$value['pid']]['fid'];
$value['invisible'] = $pids[$value['pid']]['invisible'];
$value['dateline'] = $pids[$value['pid']]['dateline'];
$value['message'] = $pids[$value['pid']]['message'];
$value['special'] = $tids[$value['tid']]['special'];
$value['status'] = $tids[$value['tid']]['status'];
$value['subject'] = $tids[$value['tid']]['subject'];
$value['digest'] = $tids[$value['tid']]['digest'];
$value['attachment'] = $tids[$value['tid']]['attachment'];
$value['replies'] = $tids[$value['tid']]['replies'];
$value['views'] = $tids[$value['tid']]['views'];
$value['lastposter'] = $tids[$value['tid']]['lastposter'];
$value['lastpost'] = $tids[$value['tid']]['lastpost'];
$value['icon'] = $tids[$value['tid']]['icon'];
$value['tid'] = $pids[$value['pid']]['tid'];
$fids[] = $value['fid'];
$value['comment'] = messagecutstr($value['comment'], 100);
$list[] = guide_procthread($value);
}
unset($pids, $tids, $postcommentarr);
if($fids) {
$fids = array_unique($fids);
$forumnames = C::t('forum_forum')->fetch_all_name_by_fid($fids);
}
$listcount = count($list);
} else {
$invisible = null;
if($filter == 'recyclebin') {
$invisible = -5;
} elseif($filter == 'aduit') {
$invisible = -2;
} elseif($filter == 'save' || $filter == 'ignored') {
$invisible = -3;
$displayorder = -4;
} elseif($filter == 'close') {
$closed = 1;
} elseif($filter == 'common') {
$invisible = 0;
$displayorder = 0;
$dglue = '>=';
$closed = 0;
}
require_once libfile('function/post');
$followfid = getglobal('setting/followforumid');
$posts = C::t('forum_post')->fetch_all_by_authorid(0, $_G['uid'], true, 'DESC', $start, $perpage, null, $invisible, $fid, $followfid);
$listcount = count($posts);
foreach($posts as $pid => $post) {
$tids[$post['tid']][] = $pid;
$post['message'] = $post['status'] & 1 && $_G['adminid'] != 1 ? '' : (!getstatus($post['status'], 2) || $post['authorid'] == $_G['uid'] ? messagecutstr($post['message'], 100) : '');
$posts[$pid] = $post;
}
if(!empty($tids)) {
$threads = C::t('forum_thread')->fetch_all_by_tid_displayorder(array_keys($tids), $displayorder, $dglue, array(), $closed);
foreach($threads as $tid => $thread) {
if(!isset($_G['cache']['forums'][$thread['fid']])) {
$gids[$thread['fid']] = $thread['fid'];
} else {
$forumnames[$thread['fid']] = array('fid' => $thread['fid'], 'name' => $_G['cache']['forums'][$thread['fid']]['name']);
}
$threads[$tid] = guide_procthread($thread);
}
if(!empty($gids)) {
$groupforums = C::t('forum_forum')->fetch_all_name_by_fid($gids);
foreach($groupforums as $fid => $val) {
$forumnames[$fid] = $val;
}
}
$list = array();
foreach($tids as $key => $val) {
$list[$key] = $threads[$key];
}
unset($threads);
}
}
$multi = simplepage($listcount, $perpage, $_G['page'], $theurl);
return array('forumnames' => $forumnames, 'threadcount' => $listcount, 'threadlist' => $list, 'multi' => $multi, 'tids' => $tids, 'posts' => $posts);
}
function guide_procthread($thread) {
global $_G;
$todaytime = strtotime(dgmdate(TIMESTAMP, 'Ymd'));
$thread['lastposterenc'] = rawurlencode($thread['lastposter']);
$thread['multipage'] = '';
$topicposts = $thread['special'] ? $thread['replies'] : $thread['replies'] + 1;
if($topicposts > $_G['ppp']) {
$pagelinks = '';
$thread['pages'] = ceil($topicposts / $_G['ppp']);
for($i = 2; $i <= 6 && $i <= $thread['pages']; $i++) {
$pagelinks .= "<a href=\"forum.php?mod=viewthread&tid={$thread['tid']}&amp;extra=$extra&amp;page=$i\">$i</a>";
}
if($thread['pages'] > 6) {
$pagelinks .= "..<a href=\"forum.php?mod=viewthread&tid={$thread['tid']}&amp;extra=$extra&amp;page={$thread['pages']}\">{$thread['pages']}</a>";
}
$thread['multipage'] = '&nbsp;...'.$pagelinks;
}
if($thread['highlight']) {
$_G['forum_colorarray'] = $_G['forum_colorarray'] ? $_G['forum_colorarray'] : array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
$string = sprintf('%02d', $thread['highlight']);
$stylestr = sprintf('%03b', $string[0]);
$thread['highlight'] = ' style="';
$thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
$thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
$thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
$thread['highlight'] .= $string[1] ? 'color: '.$_G['forum_colorarray'][$string[1]].';' : '';
$thread['highlight'] .= '"';
} else {
$thread['highlight'] = '';
}
$thread['recommendicon'] = '';
if(!empty($_G['setting']['recommendthread']['status']) && $thread['recommends']) {
foreach($_G['setting']['recommendthread']['iconlevels'] as $k => $i) {
if($thread['recommends'] > $i) {
$thread['recommendicon'] = $k+1;
break;
}
}
}
$thread['moved'] = $thread['heatlevel'] = $thread['new'] = 0;
$thread['icontid'] = $thread['forumstick'] || !$thread['moved'] && $thread['isgroup'] != 1 ? $thread['tid'] : $thread['closed'];
$thread['folder'] = 'common';
$thread['dbdateline'] = $thread['dateline'];
$thread['weeknew'] = TIMESTAMP - 604800 <= $thread['dbdateline'];
if($thread['replies'] > $thread['views']) {
$thread['views'] = $thread['replies'];
}
if($_G['setting']['heatthread']['iconlevels']) {
foreach($_G['setting']['heatthread']['iconlevels'] as $k => $i) {
if($thread['heats'] > $i) {
$thread['heatlevel'] = $k + 1;
break;
}
}
}
$thread['istoday'] = $thread['dateline'] > $todaytime ? 1 : 0;
$thread['dateline'] = dgmdate($thread['dateline'], 'u', '9999', getglobal('setting/dateformat'));
$thread['dblastpost'] = $thread['lastpost'];
$thread['lastpost'] = dgmdate($thread['lastpost'], 'u');
if(in_array($thread['displayorder'], array(1, 2, 3, 4))) {
$thread['id'] = 'stickthread_'.$thread['tid'];
} else {
$thread['id'] = 'normalthread_'.$thread['tid'];
}
$thread['rushreply'] = getstatus($thread['status'], 3);
return $thread;
}
function update_guide_rsscache($type, $perpage) {
global $_G;
$processname = 'guide_rss_cache';
if(discuz_process::islocked($processname, 600)) {
return false;
}
C::t('forum_rsscache')->delete_by_guidetype($type);
require_once libfile('function/post');
$data = get_guide_list($type, 0, $perpage);
foreach($data['threadlist'] as $thread) {
$thread['author'] = $thread['author'] != '' ? addslashes($thread['author']) : 'Anonymous';
$thread['subject'] = addslashes($thread['subject']);
$post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
$attachdata = '';
if($post['attachment'] == 2) {
$attach = C::t('forum_attachment_n')->fetch_max_image('tid:'.$thread['tid'], 'pid', $post['pid']);
$attachdata = "\t".$attach['remote']."\t".$attach['attachment']."\t".$attach['filesize'];
}
$thread['message'] = $post['message'];
$thread['status'] = $post['status'];
$thread['description'] = $thread['readperm'] > 0 || $thread['price'] > 0 || $thread['status'] & 1 ? '' : addslashes(messagecutstr($thread['message'], 250 - strlen($attachdata)).$attachdata);
C::t('forum_rsscache')->insert(array(
'lastupdate'=>$_G['timestamp'],
'fid'=>$thread['fid'],
'tid'=>$thread['tid'],
'dateline'=>$thread['dbdateline'],
'forum'=>strip_tags($data['forumnames'][$thread['fid']]['name']),
'author'=>$thread['author'],
'subject'=>$thread['subject'],
'description'=>$thread['description'],
'guidetype'=>$type
), false, true);
}
discuz_process::unlock($processname);
return true;
}
?>

View File

@@ -0,0 +1,61 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_image.php 32531 2013-02-06 10:15:19Z zhangguosheng $
*/
if(!defined('IN_DISCUZ') || empty($_GET['aid']) || empty($_GET['size']) || empty($_GET['key'])) {
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/'.helper_attach::makethumbpath($daid, $dw, $dh);$attachurl = helper_attach::attachpreurl();
if(!$nocache) {
if(file_exists($_G['setting']['attachdir'].$thumbfile)) {
dheader('location: '.$attachurl.$thumbfile);
}
}
define('NOROBOT', TRUE);
$id = !empty($_GET['atid']) ? $_GET['atid'] : $daid;
if(dsign($id.'|'.$dw.'|'.$dh) != $_GET['key']) {
dheader('location: '.$_G['siteurl'].'static/image/common/none.gif');
}
if($attach = C::t('forum_attachment_n')->fetch_attachment('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);
}
}
?>

View File

@@ -0,0 +1,550 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_index.php 36265 2016-11-04 07:10:47Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
require_once libfile('function/forumlist');
$gid = intval(getgpc('gid'));
$showoldetails = get_index_online_details();
if(!$_G['uid'] && !$gid && $_G['setting']['cacheindexlife'] && !defined('IN_ARCHIVER') && !defined('IN_MOBILE') && !IS_ROBOT) {
get_index_page_guest_cache();
}
$newthreads = round((TIMESTAMP - $_G['member']['lastvisit'] + 600) / 1000) * 1000;
$catlist = $forumlist = $sublist = $forumname = $collapse = $favforumlist = array();
$threads = $posts = $todayposts = $announcepm = 0;
$postdata = $_G['cache']['historyposts'] ? explode("\t", $_G['cache']['historyposts']) : array(0,0);
$postdata[0] = intval($postdata[0]);
$postdata[1] = intval($postdata[1]);
list($navtitle, $metadescription, $metakeywords) = get_seosetting('forum');
if(!$navtitle) {
$navtitle = $_G['setting']['navs'][2]['navname'];
$nobbname = false;
} else {
$nobbname = true;
}
if(!$metadescription) {
$metadescription = $navtitle;
}
if(!$metakeywords) {
$metakeywords = $navtitle;
}
if($_G['setting']['indexhot']['status'] && $_G['cache']['heats']['expiration'] < TIMESTAMP) {
require_once libfile('function/cache');
updatecache('heats');
}
if($_G['uid'] && empty($_G['cookie']['nofavfid'])) {
$favfids = array();
$forum_favlist = C::t('home_favorite')->fetch_all_by_uid_idtype($_G['uid'], 'fid');
if(!$forum_favlist) {
dsetcookie('nofavfid', 1, 31536000);
}
foreach($forum_favlist as $key => $favorite) {
if(defined('IN_MOBILE')) {
$forum_favlist[$key]['title'] = strip_tags($favorite['title']);
}
$favfids[] = $favorite['id'];
}
if($favfids) {
$favforumlist = C::t('forum_forum')->fetch_all($favfids);
$favforumlist_fields = C::t('forum_forumfield')->fetch_all($favfids);
foreach($favforumlist as $id => $forum) {
if($favforumlist_fields[$forum['fid']]['fid']) {
$favforumlist[$id] = array_merge($forum, $favforumlist_fields[$forum['fid']]);
}
$favforumlist[$id]['extra'] = empty($favforumlist[$id]['extra']) ? array() : dunserialize($favforumlist[$id]['extra']);
if(!is_array($favforumlist[$id]['extra'])) {
$favforumlist[$id]['extra'] = array();
}
forum($favforumlist[$id]);
}
}
}
if(!$gid && $_G['setting']['collectionstatus'] && ($_G['setting']['collectionrecommendnum'] || !$_G['setting']['hidefollowcollection'])) {
require_once libfile('function/cache');
loadcache('collection_index');
$collectionrecommend = dunserialize($_G['setting']['collectionrecommend']);
if(TIMESTAMP - $_G['cache']['collection_index']['dateline'] > 3600 * 4) {
$collectiondata = $followdata = array();
if($_G['setting']['collectionrecommendnum']) {
if($collectionrecommend['ctids']) {
$collectionrecommend['ctidsKey'] = array_keys($collectionrecommend['ctids']);
$tmpcollection = C::t('forum_collection')->fetch_all($collectionrecommend['ctidsKey']);
foreach($collectionrecommend['ctids'] as $ctid=>$setcollection) {
if($tmpcollection[$ctid]) {
$collectiondata[$ctid] = $tmpcollection[$ctid];
}
}
unset($tmpcollection, $ctid, $setcollection);
}
if($collectionrecommend['autorecommend']) {
require_once libfile('function/collection');
$autorecommenddata = getHotCollection(500);
}
}
savecache('collection_index', array('dateline' => TIMESTAMP, 'data' => $collectiondata, 'auto' => $autorecommenddata));
$collectiondata = array('data' => $collectiondata, 'auto' => $autorecommenddata);
} else {
$collectiondata = &$_G['cache']['collection_index'];
}
if($_G['setting']['showfollowcollection']) {
$followcollections = $_G['uid'] ? C::t('forum_collectionfollow')->fetch_all_by_uid($_G['uid']) : array();;
if($followcollections) {
$collectiondata['follows'] = C::t('forum_collection')->fetch_all(array_keys($followcollections), 'dateline', 'DESC', 0, $_G['setting']['showfollowcollection']);
}
}
if($collectionrecommend['autorecommend'] && $collectiondata['auto']) {
$randrecommend = array_rand($collectiondata['auto'], min($collectionrecommend['autorecommend'], count($collectiondata['auto'])));
if($randrecommend && !is_array($randrecommend)) {
$collectiondata['data'][$randrecommend] = $collectiondata['auto'][$randrecommend];
} else {
foreach($randrecommend as $ctid) {
$collectiondata['data'][$ctid] = $collectiondata['auto'][$ctid];
}
}
}
if($collectiondata['data']) {
$collectiondata['data'] = array_slice($collectiondata['data'], 0, $collectionrecommend['autorecommend'], true);
}
}
if(empty($gid) && empty($_G['member']['accessmasks']) && empty($showoldetails) && !IS_ROBOT) {
$memindex = get_index_memory_by_groupid($_G['member']['groupid']);
extract($memindex);
if(defined('FORUM_INDEX_PAGE_MEMORY') && FORUM_INDEX_PAGE_MEMORY) {
categorycollapse();
if(!defined('IN_ARCHIVER')) {
include template('diy:forum/discuz');
} else {
include loadarchiver('forum/discuz');
}
dexit();
}
}
$grids = array();
if($_G['setting']['grid']['showgrid']) {
loadcache('grids');
$cachelife = $_G['setting']['grid']['cachelife'] ? $_G['setting']['grid']['cachelife'] : 600;
$now = dgmdate(TIMESTAMP, lang('forum/misc', 'y_m_d')).' '.lang('forum/misc', 'week_'.dgmdate(TIMESTAMP, 'w'));
if(TIMESTAMP - $_G['cache']['grids']['cachetime'] < $cachelife) {
$grids = $_G['cache']['grids'];
} else {
$images = array();
$_G['setting']['grid']['fids'] = in_array(0, $_G['setting']['grid']['fids']) ? 0 : $_G['setting']['grid']['fids'];
if($_G['setting']['grid']['gridtype']) {
$grids['digest'] = C::t('forum_thread')->fetch_all_for_guide('digest', 0, array(), 3, 0, 0, 10, $_G['setting']['grid']['fids']);
} else {
$images = C::t('forum_threadimage')->fetch_all_order_by_tid_for_guide(10, 0, $_G['setting']['grid']['fids']);
foreach($images as $key => $value) {
$tids[$value['tid']] = $value['tid'];
}
$grids['image'] = C::t('forum_thread')->fetch_all_by_tid($tids);
}
$grids['newthread'] = C::t('forum_thread')->fetch_all_for_guide('newthread', 0, array(), 0, 0, 0, 10, $_G['setting']['grid']['fids']);
$grids['newreply'] = C::t('forum_thread')->fetch_all_for_guide('reply', 0, array(), 0, 0, 0, 10, $_G['setting']['grid']['fids']);
$grids['hot'] = C::t('forum_thread')->fetch_all_for_guide('hot', 0, array(), 3, 0, 0, 10, $_G['setting']['grid']['fids']);
$_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
foreach($grids as $type => $gridthreads) {
foreach($gridthreads as $key => $gridthread) {
$gridthread['dateline'] = str_replace('"', '\'', dgmdate($gridthread['dateline'], 'u', '9999', getglobal('setting/dateformat')));
$gridthread['lastpost'] = str_replace('"', '\'', dgmdate($gridthread['lastpost'], 'u', '9999', getglobal('setting/dateformat')));
if($gridthread['highlight'] && $_G['setting']['grid']['highlight']) {
$string = sprintf('%02d', $gridthread['highlight']);
$stylestr = sprintf('%03b', $string[0]);
$gridthread['highlight'] = ' style="';
$gridthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
$gridthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
$gridthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
$gridthread['highlight'] .= $string[1] ? 'color: '.$_G['forum_colorarray'][$string[1]] : '';
$gridthread['highlight'] .= '"';
} else {
$gridthread['highlight'] = '';
}
if($_G['setting']['grid']['textleng']) {
$gridthread['oldsubject'] = dhtmlspecialchars($gridthread['subject']);
$gridthread['subject'] = cutstr($gridthread['subject'], $_G['setting']['grid']['textleng']);
}
$grids[$type][$key] = $gridthread;
}
}
if(!$_G['setting']['grid']['gridtype']) {
$grids['slide'] = $focuspic = $focusurl = $focustext = array();
$grids['focus'] = 'config=5|0xffffff|0x0099ff|50|0xffffff|0x0099ff|0x000000';
foreach($grids['image'] as $ithread) {
if($ithread['displayorder'] < 0) {
continue;
}
if($images[$ithread['tid']]['remote']) {
$imageurl = $_G['setting']['ftp']['attachurl'].'forum/'.$images[$ithread['tid']]['attachment'];
} else {
$imageurl = $_G['setting']['attachurl'].'forum/'.$images[$ithread['tid']]['attachment'];
}
$grids['slide'][$ithread['tid']] = array(
'image' => $imageurl,
'url' => 'forum.php?mod=viewthread&tid='.$ithread['tid'],
'subject' => addslashes($ithread['subject'])
);
}
$grids['slide'] = array_reverse($grids['slide'], true);
}
$grids['cachetime'] = TIMESTAMP;
savecache('grids', $grids);
}
}
if(!$gid && (!defined('FORUM_INDEX_PAGE_MEMORY') || !FORUM_INDEX_PAGE_MEMORY)) {
$announcements = get_index_announcements();
$forums = C::t('forum_forum')->fetch_all_by_status(1);
$fids = array();
foreach($forums as $forum) {
$fids[$forum['fid']] = $forum['fid'];
}
$forum_access = array();
if(!empty($_G['member']['accessmasks'])) {
$forum_access = C::t('forum_access')->fetch_all_by_fid_uid($fids, $_G['uid']);
}
$forum_fields = C::t('forum_forumfield')->fetch_all($fids);
foreach($forums as $forum) {
if($forum_fields[$forum['fid']]['fid']) {
$forum = (array_key_exists('fid', $forum) && array_key_exists($forum['fid'], $forum_fields)) ? array_merge($forum, $forum_fields[$forum['fid']]) : $forum;
}
if(!empty($forum_access['fid'])) {
$forum = (array_key_exists('fid', $forum) && array_key_exists($forum['fid'], $forum_access)) ? array_merge($forum, $forum_access[$forum['fid']]) : $forum;
}
$forumname[$forum['fid']] = strip_tags($forum['name']);
$forum['extra'] = empty($forum['extra']) ? array() : dunserialize($forum['extra']);
if(!is_array($forum['extra'])) {
$forum['extra'] = array();
}
if($forum['type'] != 'group') {
$threads += $forum['threads'];
$posts += $forum['posts'];
$todayposts += $forum['todayposts'];
if($forum['type'] == 'forum' && isset($catlist[$forum['fup']])) {
if(forum($forum)) {
$catlist[$forum['fup']]['forums'][] = $forum['fid'];
$forum['orderid'] = $catlist[$forum['fup']]['forumscount']++;
$forum['subforums'] = '';
$forumlist[$forum['fid']] = $forum;
}
} elseif(isset($forumlist[$forum['fup']])) {
$forumlist[$forum['fup']]['threads'] += $forum['threads'];
$forumlist[$forum['fup']]['posts'] += $forum['posts'];
$forumlist[$forum['fup']]['todayposts'] += $forum['todayposts'];
if($_G['setting']['subforumsindex'] && $forumlist[$forum['fup']]['permission'] == 2 && !($forumlist[$forum['fup']]['simple'] & 16) || ($forumlist[$forum['fup']]['simple'] & 8)) {
$forumurl = !empty($forum['domain']) && !empty($_G['setting']['domain']['root']['forum']) ? $_G['scheme'].'://'.$forum['domain'].'.'.$_G['setting']['domain']['root']['forum'] : 'forum.php?mod=forumdisplay&fid='.$forum['fid'];
$forumlist[$forum['fup']]['subforums'] .= (empty($forumlist[$forum['fup']]['subforums']) ? '' : ', ').'<a href="'.$forumurl.'" '.(!empty($forum['extra']['namecolor']) ? ' style="color: ' . $forum['extra']['namecolor'].';"' : '') . '>'.$forum['name'].'</a>';
}
}
} else {
if($forum['moderators']) {
$forum['moderators'] = moddisplay($forum['moderators'], 'flat');
}
$forum['forumscount'] = 0;
$catlist[$forum['fid']] = $forum;
}
}
unset($forum_access, $forum_fields);
foreach($catlist as $catid => $category) {
$catlist[$catid]['collapseimg'] = 'collapsed_no.gif';
$catlist[$catid]['collapseicon'] = '_no';
if($catlist[$catid]['forumscount'] && $category['forumcolumns']) {
$catlist[$catid]['forumcolwidth'] = (floor(100 / $category['forumcolumns']) - 0.1).'%';
$catlist[$catid]['endrows'] = '';
if($colspan = $category['forumscount'] % $category['forumcolumns']) {
while(($category['forumcolumns'] - $colspan) > 0) {
$catlist[$catid]['endrows'] .= '<td width="'.$catlist[$catid]['forumcolwidth'].'">&nbsp;</td>';
$colspan ++;
}
}
} elseif(empty($category['forumscount'])) {
unset($catlist[$catid]);
}
}
unset($catid, $category);
if(isset($catlist[0]) && $catlist[0]['forumscount']) {
$catlist[0]['fid'] = 0;
$catlist[0]['type'] = 'group';
$catlist[0]['name'] = $_G['setting']['bbname'];
$catlist[0]['collapseimg'] = 'collapsed_no.gif';
$catlist[0]['collapseicon'] = '_no';
} else {
unset($catlist[0]);
}
if(!IS_ROBOT && ($_G['setting']['whosonlinestatus'] == 1 || $_G['setting']['whosonlinestatus'] == 3)) {
$_G['setting']['whosonlinestatus'] = 1;
$onlineinfo = explode("\t", $_G['cache']['onlinerecord']);
if(empty($_G['cookie']['onlineusernum'])) {
$onlinenum = C::app()->session->count();
if($onlinenum > $onlineinfo[0]) {
$onlinerecord = "$onlinenum\t".TIMESTAMP;
C::t('common_setting')->update_setting('onlinerecord', $onlinerecord);
savecache('onlinerecord', $onlinerecord);
$onlineinfo = array($onlinenum, TIMESTAMP);
}
dsetcookie('onlineusernum', intval($onlinenum), 300);
} else {
$onlinenum = intval($_G['cookie']['onlineusernum']);
}
$onlineinfo[1] = dgmdate($onlineinfo[1], 'd');
$detailstatus = $showoldetails == 'yes' || (((!isset($_G['cookie']['onlineindex']) && !$_G['setting']['whosonline_contract']) || $_G['cookie']['onlineindex']) && $onlinenum < 500 && !$showoldetails);
$guestcount = $membercount = $invisiblecount = 0;
if(!empty($_G['setting']['sessionclose'])) {
$detailstatus = false;
$membercount = C::app()->session->count(1);
$guestcount = $onlinenum - $membercount;
}
if($detailstatus) {
$actioncode = lang('action');
$_G['uid'] && updatesession();
$whosonline = array();
$_G['setting']['maxonlinelist'] = $_G['setting']['maxonlinelist'] ? $_G['setting']['maxonlinelist'] : 500;
foreach(C::app()->session->fetch_member(1, 0, $_G['setting']['maxonlinelist']) as $online){
$membercount ++;
if($online['invisible']) {
$invisiblecount++;
continue;
} else {
$online['icon'] = !empty($_G['cache']['onlinelist'][$online['groupid']]) ? $_G['cache']['onlinelist'][$online['groupid']] : $_G['cache']['onlinelist'][0];
}
$online['lastactivity'] = dgmdate($online['lastactivity'], 't');
$whosonline[] = $online;
}
if(isset($_G['cache']['onlinelist'][7]) && $_G['setting']['maxonlinelist'] > $membercount) {
foreach(C::app()->session->fetch_member(2, 0, $_G['setting']['maxonlinelist'] - $membercount) as $online){
$online['icon'] = $_G['cache']['onlinelist'][7];
$online['username'] = $_G['cache']['onlinelist']['guest'];
$online['lastactivity'] = dgmdate($online['lastactivity'], 't');
$whosonline[] = $online;
}
}
unset($actioncode, $online);
if($onlinenum > $_G['setting']['maxonlinelist']) {
$membercount = C::app()->session->count(1);
$invisiblecount = C::app()->session->count_invisible();
}
if($onlinenum < $membercount) {
$onlinenum = C::app()->session->count();
dsetcookie('onlineusernum', intval($onlinenum), 300);
}
$invisiblecount = intval($invisiblecount);
$guestcount = $onlinenum - $membercount;
unset($online);
}
} else {
$_G['setting']['whosonlinestatus'] = 0;
}
if(defined('FORUM_INDEX_PAGE_MEMORY') && !FORUM_INDEX_PAGE_MEMORY) {
$key = !IS_ROBOT ? $_G['member']['groupid'] : 'for_robot';
memory('set', 'forum_index_page_'.$key, array(
'catlist' => $catlist,
'forumlist' => $forumlist,
'sublist' => $sublist,
'whosonline' => $whosonline,
'onlinenum' => $onlinenum,
'membercount' => $membercount,
'guestcount' => $guestcount,
'grids' => $grids,
'announcements' => $announcements,
'threads' => $threads,
'posts' => $posts,
'todayposts' => $todayposts,
'onlineinfo' => $onlineinfo,
'announcepm' => $announcepm), getglobal('setting/memory/forumindex'));
}
} else {
require_once DISCUZ_ROOT.'./source/include/misc/misc_category.php';
}
if(defined('IN_ARCHIVER')) {
include loadarchiver('forum/discuz');
exit();
}
categorycollapse();
if($gid && !empty($catlist)) {
$_G['category'] = $catlist[$gid];
$forumseoset = array(
'seotitle' => $catlist[$gid]['seotitle'],
'seokeywords' => $catlist[$gid]['keywords'],
'seodescription' => $catlist[$gid]['seodescription']
);
$seodata = array('fgroup' => $catlist[$gid]['name']);
list($navtitle, $metadescription, $metakeywords) = get_seosetting('threadlist', $seodata, $forumseoset);
if(empty($navtitle)) {
$navtitle = $navtitle_g;
$nobbname = false;
} else {
$nobbname = true;
}
$_G['fid'] = $gid;
}
include template('diy:forum/discuz:'.$gid);
function get_index_announcements() {
global $_G;
$announcements = '';
if($_G['cache']['announcements']) {
$readapmids = !empty($_G['cookie']['readapmid']) ? explode('D', $_G['cookie']['readapmid']) : array();
foreach($_G['cache']['announcements'] as $announcement) {
if(!$announcement['endtime'] || $announcement['endtime'] > TIMESTAMP && (empty($announcement['groups']) || in_array($_G['member']['groupid'], $announcement['groups']))) {
if(empty($announcement['type'])) {
$announcements .= '<li><span><a href="forum.php?mod=announcement&id='.$announcement['id'].'" target="_blank" class="xi2">'.$announcement['subject'].
'</a></span><em>('.dgmdate($announcement['starttime'], 'd').')</em></li>';
} elseif($announcement['type'] == 1) {
$announcements .= '<li><span><a href="'.$announcement['message'].'" target="_blank" class="xi2">'.$announcement['subject'].
'</a></span><em>('.dgmdate($announcement['starttime'], 'd').')</em></li>';
}
}
}
}
return $announcements;
}
function get_index_page_guest_cache() {
global $_G;
$indexcache = getcacheinfo(0);
if(TIMESTAMP - $indexcache['filemtime'] > $_G['setting']['cacheindexlife']) {
@unlink($indexcache['filename']);
define('CACHE_FILE', $indexcache['filename']);
} elseif($indexcache['filename']) {
$start_time = microtime(TRUE);
$filemtime = $indexcache['filemtime'];
ob_start(function($input) use (&$filemtime) {
return replace_formhash($filemtime, $input);
});
readfile($indexcache['filename']);
$updatetime = dgmdate($filemtime, 'Y-m-d H:i:s');
$debuginfo = ", Updated at $updatetime";
if(getglobal('setting/debug')) {
$gzip = $_G['gzipcompress'] ? ', Gzip On' : '';
$debuginfo .= ', Processed in '.sprintf("%0.6f", microtime(TRUE) - $start_time).' second(s)'.$gzip;
}
echo '<script type="text/javascript">$("debuginfo") ? $("debuginfo").innerHTML = "'.$debuginfo.'." : "";</script></body></html>';
ob_end_flush();
exit();
}
}
function get_index_memory_by_groupid($key) {
$enable = getglobal('setting/memory/forumindex');
if($enable !== null && memory('check')) {
if(IS_ROBOT) {
$key = 'for_robot';
}
$ret = memory('get', 'forum_index_page_'.$key);
define('FORUM_INDEX_PAGE_MEMORY', $ret ? 1 : 0);
if($ret) {
return $ret;
}
}
return array('none' => null);
}
function get_index_online_details() {
$showoldetails = getgpc('showoldetails');
switch($showoldetails) {
case 'no': dsetcookie('onlineindex', ''); break;
case 'yes': dsetcookie('onlineindex', 1, 86400 * 365); break;
}
return $showoldetails;
}
function do_forum_bind_domains() {
global $_G;
if($_G['setting']['binddomains'] && $_G['setting']['forumdomains']) {
$loadforum = isset($_G['setting']['binddomains'][$_SERVER['HTTP_HOST']]) ? max(0, intval($_G['setting']['binddomains'][$_SERVER['HTTP_HOST']])) : 0;
if($loadforum) {
dheader('Location: '.$_G['setting']['siteurl'].'/forum.php?mod=forumdisplay&fid='.$loadforum);
}
}
}
function categorycollapse() {
global $_G, $collapse, $catlist;
if(!$_G['uid']) {
return;
}
foreach($catlist as $fid => $forum) {
if(!isset($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], '_category_'.$fid.'_') === FALSE) {
$catlist[$fid]['collapseimg'] = 'collapsed_no.gif';
$catlist[$fid]['collapseicon'] = '_no';
$collapse['category_'.$fid] = '';
} else {
$catlist[$fid]['collapseimg'] = 'collapsed_yes.gif';
$catlist[$fid]['collapseicon'] = '_yes';
$collapse['category_'.$fid] = 'display: none';
}
}
for($i = -2; $i <= 0; $i++) {
if(!isset($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], '_category_'.$i.'_') === FALSE) {
$collapse['collapseimg_'.$i] = 'collapsed_no.gif';
$collapse['collapseicon_'.$i] = '_no';
$collapse['category_'.$i] = '';
} else {
$collapse['collapseimg_'.$i] = 'collapsed_yes.gif';
$collapse['collapseicon_'.$i] = '_yes';
$collapse['category_'.$i] = 'display: none';
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,205 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_modcp.php 28867 2012-03-16 02:27:08Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('IN_MODCP', true);
if(!$_G['setting']['forumstatus'] && !in_array($_GET['action'], array('', 'home', 'moderate', 'ban', 'ipban', 'member', 'log', 'login', 'logout'))) {
showmessage('forum_status_off');
} else if(!$_G['setting']['forumstatus']) {
unset($_G['fid'], $_GET['fid'], $_POST['fid']);
}
$cpscript = basename($_G['PHP_SELF']);
if(!empty($_G['forum']) && $_G['forum']['status'] == 3) {
showmessage('group_admin_enter_panel', 'forum.php?mod=group&action=manage&fid='.$_G['fid']);
}
$modsession = new discuz_panel(MODCP_PANEL);
if(getgpc('login_panel') && getgpc('cppwd') && submitcheck('submit')) {
$modsession->dologin($_G['uid'], getgpc('cppwd'), true);
}
if(!$modsession->islogin) {
$_GET['action'] = 'login';
}
if(getgpc('action') == 'logout') {
$modsession->dologout();
showmessage('modcp_logout_succeed', 'forum.php');
}
$modforums = $modsession->get('modforums');
$_GET['action'] = empty($_GET['action']) ? (($_G['setting']['forumstatus'] && $_G['fid']) ? 'thread' : 'home') : $_GET['action'];
$op = getgpc('op');
if($modforums === null) {
$modforums = array('fids' => '', 'list' => array(), 'recyclebins' => array());
$comma = '';
if($_G['adminid'] == 3) {
foreach(C::t('forum_moderator')->fetch_all_by_uid_forum($_G['uid']) as $tforum) {
$modforums['fids'] .= $comma.$tforum['fid']; $comma = ',';
$modforums['recyclebins'][$tforum['fid']] = $tforum['recyclebin'];
$modforums['list'][$tforum['fid']] = strip_tags($tforum['name']);
}
} else {
$query = C::t('forum_forum')->fetch_all_info_by_fids(0, 1, 0, 0, 0, 1, 1);
if(!empty($_G['member']['accessmasks'])) {
$fids = array_keys($query);
$accesslist = C::t('forum_access')->fetch_all_by_fid_uid($fids, $_G['uid']);
foreach($query as $key => $val) {
$query[$key]['allowview'] = $accesslist[$key];
}
}
foreach($query as $tforum) {
$tforum['allowview'] = !isset($tforum['allowview']) ? 0 : $tforum['allowview'];
if($tforum['allowview'] == 1 || ($tforum['allowview'] == 0 && ((!$tforum['viewperm'] && $_G['group']['readaccess']) || ($tforum['viewperm'] && forumperm($tforum['viewperm']))))) {
$modforums['fids'] .= $comma.$tforum['fid']; $comma = ',';
$modforums['recyclebins'][$tforum['fid']] = $tforum['recyclebin'];
$modforums['list'][$tforum['fid']] = strip_tags($tforum['name']);
}
}
}
$modsession->set('modforums', $modforums, true);
}
$threadclasslist = array();
if($_G['fid'] && in_array($_G['fid'], explode(',', $modforums['fids']))) {
foreach(C::t('forum_threadclass')->fetch_all_by_fid($_G['fid']) as $tc) {
$threadclasslist[] = $tc;
}
}
if($_G['fid'] && $_G['forum']['ismoderator']) {
dsetcookie('modcpfid', $_G['fid']);
$forcefid = "&amp;fid={$_G['fid']}";
} elseif(!empty($modforums) && count($modforums['list']) == 1) {
$forcefid = "&amp;fid={$modforums['fids']}";
} else {
$forcefid = '';
}
$script = $modtpl = '';
switch ($_GET['action']) {
case 'announcement':
$_G['group']['allowpostannounce'] && $script = 'announcement';
break;
case 'member':
$op == 'edit' && $_G['group']['allowedituser'] && $script = 'member';
$op == 'ban' && ($_G['group']['allowbanuser'] || $_G['group']['allowbanvisituser']) && $script = 'member';
$op == 'ipban' && $_G['group']['allowbanip'] && $script = 'member';
break;
case 'moderate':
($op == 'threads' || $op == 'replies') && $_G['group']['allowmodpost'] && $script = 'moderate';
$op == 'members' && $_G['group']['allowmoduser'] && $script = 'moderate';
break;
case 'forum':
$op == 'editforum' && $_G['group']['alloweditforum'] && $script = 'forum';
$op == 'recommend' && $_G['group']['allowrecommendthread'] && $script = 'forum';
break;
case 'forumaccess':
$_G['group']['allowedituser'] && $script = 'forumaccess';
break;
case 'log':
$_G['group']['allowviewlog'] && $script = 'log';
break;
case 'login':
$script = $modsession->islogin ? 'home' : 'login';
break;
case 'thread':
$script = 'thread';
break;
case 'recyclebin':
$script = 'recyclebin';
break;
case 'recyclebinpost':
$script = 'recyclebinpost';
break;
case 'plugin':
$script = 'plugin';
break;
case 'report':
$script = 'report';
break;
default:
$_GET['action'] = $script = 'home';
$modtpl = 'modcp_home';
}
$script = empty($script) ? 'noperm' : $script;
$modtpl = empty($modtpl) ? (!empty($script) ? 'modcp_'.$script : '') : $modtpl;
$modtpl = 'forum/' . $modtpl;
$op = isset($op) ? trim($op) : '';
if($script != 'log') {
require_once libfile('function/misc');
$extra = implodearray(array('GET' => $_GET, 'POST' => $_POST), array('cppwd', 'formhash', 'submit', 'addsubmit'));
$modcplog = array(TIMESTAMP, $_G['username'], $_G['adminid'], $_G['clientip'], $_GET['action'], $op, $_G['fid'], $extra);
writelog('modcp', implode("\t", clearlogstring($modcplog)));
}
require DISCUZ_ROOT.'./source/include/modcp/modcp_'.$script.'.php';
$reportnum = $modpostnum = $modthreadnum = $modforumnum = 0;
$modforumnum = count($modforums['list']);
$modnum = '';
if($modforumnum) {
if(!empty($_G['setting']['moddetail'])) {
if($_G['group']['allowmodpost']) {
$modnum = C::t('common_moderate')->count_by_idtype_status_fid('tid', 0, explode(',', $modforums['fids']));
$modnum += C::t('common_moderate')->count_by_idtype_status_fid('pid', 0, explode(',', $modforums['fids']));
}
if($_G['group']['allowmoduser']) {
$modnum += C::t('common_member_validate')->count_by_status(0);
}
}
}
switch($_G['adminid']) {
case 1: $access = '1,2,3,4,5,6,7'; break;
case 2: $access = '2,3,6,7'; break;
default: $access = '1,3,5,7'; break;
}
$notenum = C::t('common_adminnote')->count_by_access(explode(',', $access));
include template('forum/modcp');
function getposttableselect() {
global $_G;
loadcache('posttable_info');
if(!empty($_G['cache']['posttable_info']) && is_array($_G['cache']['posttable_info'])) {
$posttableselect = '<select name="posttableid" id="posttableid" class="ps">';
foreach($_G['cache']['posttable_info'] as $posttableid => $data) {
$posttableselect .= '<option value="'.$posttableid.'"'.($_GET['posttableid'] == $posttableid ? ' selected="selected"' : '').'>'.($data['memo'] ? $data['memo'] : 'post_'.$posttableid).'</option>';
}
$posttableselect .= '</select>';
} else {
$posttableselect = '';
}
return $posttableselect;
}
?>

View File

@@ -0,0 +1,400 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_post.php 36293 2016-12-14 02:50:56Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
cknewuser();
require_once libfile('class/credit');
require_once libfile('function/post');
require_once libfile('function/forumlist');
$pid = intval(getgpc('pid'));
$sortid = intval(getgpc('sortid'));
$typeid = intval(getgpc('typeid'));
$special = intval(getgpc('special'));
parse_str(getgpc('extra'), $_GET['extra']);
$_GET['extra'] = http_build_query($_GET['extra']);
$postinfo = array('subject' => '');
$thread = array('readperm' => '', 'pricedisplay' => '', 'hiddenreplies' => '');
$_G['forum_dtype'] = $_G['forum_checkoption'] = $_G['forum_optionlist'] = $tagarray = $_G['forum_typetemplate'] = array();
if($sortid) {
require_once libfile('post/threadsorts', 'include');
}
if($_G['forum']['status'] == 3) {
if(!helper_access::check_module('group')) {
showmessage('group_status_off');
}
require_once libfile('function/group');
$status = groupperm($_G['forum'], $_G['uid'], 'post');
if($status == -1) {
showmessage('forum_not_group', 'index.php');
} elseif($status == 1) {
showmessage('forum_group_status_off');
} elseif($status == 2) {
showmessage('forum_group_noallowed', "forum.php?mod=group&fid={$_G['fid']}");
} elseif($status == 3) {
showmessage('forum_group_moderated');
} elseif($status == 4) {
if($_G['uid']) {
showmessage('forum_group_not_groupmember', "", array('fid' => $_G['fid']), array('showmsg' => 1));
} else {
showmessage('forum_group_not_groupmember_guest', "", array('fid' => $_G['fid']), array('showmsg' => 1, 'login' => 1));
}
} elseif($status == 5) {
showmessage('forum_group_moderated', "", array('fid' => $_G['fid']), array('showmsg' => 1));
}
}
if(empty($_GET['action'])) {
showmessage('undefined_action', NULL);
} elseif($_GET['action'] == 'albumphoto') {
require libfile('post/albumphoto', 'include');
} elseif(($_G['forum']['simple'] & 1) || $_G['forum']['redirect']) {
showmessage('forum_disablepost');
}
require_once libfile('function/discuzcode');
$space = array();
space_merge($space, 'field_home');
if($_GET['action'] == 'reply') {
$addfeedcheck = !empty($space['privacy']['feed']['newreply']) ? 'checked="checked"': '';
} else {
$addfeedcheck = !empty($space['privacy']['feed']['newthread']) ? 'checked="checked"': '';
}
$navigation = $navtitle = '';
if(!empty($_GET['cedit'])) {
unset($_G['inajax'], $_GET['infloat'], $_GET['ajaxtarget'], $_GET['handlekey']);
}
if($_GET['action'] == 'edit' || $_GET['action'] == 'reply') {
$thread = C::t('forum_thread')->fetch_thread($_G['tid']);
if(!$_G['forum_auditstatuson'] && !($thread['displayorder']>=0 || (in_array($thread['displayorder'], array(-4, -2)) && $thread['authorid']==$_G['uid']))) {
$thread = array();
}
if(!empty($thread)) {
if($thread['readperm'] && $thread['readperm'] > $_G['group']['readaccess'] && !$_G['forum']['ismoderator'] && $thread['authorid'] != $_G['uid']) {
showmessage('thread_nopermission', NULL, array('readperm' => $thread['readperm']), array('login' => 1));
}
$_G['fid'] = $thread['fid'];
$special = $thread['special'];
} else {
showmessage('thread_nonexistence');
}
if($thread['closed'] == 1 && !$_G['forum']['ismoderator']) {
showmessage('post_thread_closed');
}
if(!$thread['isgroup'] && $post_autoclose = checkautoclose($thread)) {
showmessage($post_autoclose, '', array('autoclose' => $_G['forum']['autoclose']));
}
}
if($_G['forum']['status'] == 3) {
$returnurl = 'forum.php?mod=forumdisplay&fid='.$_G['fid'].(!empty($_GET['extra']) ? '&action=list&'.preg_replace("/^(&)*/", '', $_GET['extra']) : '').'#groupnav';
$nav = get_groupnav($_G['forum']);
$navigation = ' <em>&rsaquo;</em> <a href="group.php">'.$_G['setting']['navs'][3]['navname'].'</a> '.$nav['nav'];
} else {
loadcache('forums');
$returnurl = 'forum.php?mod=forumdisplay&fid='.$_G['fid'].(!empty($_GET['extra']) ? '&'.preg_replace("/^(&)*/", '', $_GET['extra']) : '');
$navigation = ' <em>&rsaquo;</em> <a href="forum.php">'.$_G['setting']['navs'][2]['navname'].'</a>';
if($_G['forum']['type'] == 'sub') {
$fup = $_G['cache']['forums'][$_G['forum']['fup']]['fup'];
$t_link = $_G['cache']['forums'][$fup]['type'] == 'group' ? 'forum.php?gid='.$fup : 'forum.php?mod=forumdisplay&fid='.$fup;
$navigation .= ' <em>&rsaquo;</em> <a href="'.$t_link.'">'.($_G['cache']['forums'][$fup]['name']).'</a>';
}
if($_G['forum']['fup']) {
$fup = $_G['forum']['fup'];
$t_link = $_G['cache']['forums'][$fup]['type'] == 'group' ? 'forum.php?gid='.$fup : 'forum.php?mod=forumdisplay&fid='.$fup;
$navigation .= ' <em>&rsaquo;</em> <a href="'.$t_link.'">'.($_G['cache']['forums'][$fup]['name']).'</a>';
}
$t_link = 'forum.php?mod=forumdisplay&fid='.$_G['fid'].($_GET['extra'] && !IS_ROBOT ? '&'.$_GET['extra'] : '');
$navigation .= ' <em>&rsaquo;</em> <a href="'.$t_link.'">'.($_G['forum']['name']).'</a>';
unset($t_link, $t_name);
}
periodscheck('postbanperiods');
if($_G['forum']['password'] && $_G['forum']['password'] != $_G['cookie']['fidpw'.$_G['fid']]) {
showmessage('forum_passwd', "forum.php?mod=forumdisplay&fid={$_G['fid']}");
}
if(empty($_G['forum']['allowview'])) {
if(!$_G['forum']['viewperm'] && !$_G['group']['readaccess']) {
showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
} elseif($_G['forum']['viewperm'] && !forumperm($_G['forum']['viewperm'])) {
showmessagenoperm('viewperm', $_G['fid']);
}
} elseif($_G['forum']['allowview'] == -1) {
showmessage('forum_access_view_disallow');
}
formulaperm($_G['forum']['formulaperm']);
if(in_array($_G['adminid'], array(0, -1)) && $_G['setting']['newbiespan'] && (!getuserprofile('lastpost') || TIMESTAMP - getuserprofile('lastpost') < $_G['setting']['newbiespan'] * 60) && TIMESTAMP - getglobal('member/regdate') < $_G['setting']['newbiespan'] * 60) {
showmessage('post_newbie_span', '', array('newbiespan' => $_G['setting']['newbiespan']));
}
$special = $special > 0 && $special < 7 || $special == 127 ? intval($special) : 0;
$_G['forum']['allowpostattach'] = isset($_G['forum']['allowpostattach']) ? $_G['forum']['allowpostattach'] : '';
$_G['group']['allowpostattach'] = $_G['forum']['allowpostattach'] != -1 && ($_G['forum']['allowpostattach'] == 1 || (!$_G['forum']['postattachperm'] && $_G['group']['allowpostattach']) || ($_G['forum']['postattachperm'] && forumperm($_G['forum']['postattachperm'])));
$_G['forum']['allowpostimage'] = isset($_G['forum']['allowpostimage']) ? $_G['forum']['allowpostimage'] : '';
$_G['group']['allowpostimage'] = $_G['forum']['allowpostimage'] != -1 && ($_G['forum']['allowpostimage'] == 1 || (!$_G['forum']['postimageperm'] && $_G['group']['allowpostimage']) || ($_G['forum']['postimageperm'] && forumperm($_G['forum']['postimageperm'])));
$_G['group']['attachextensions'] = $_G['forum']['attachextensions'] ? $_G['forum']['attachextensions'] : $_G['group']['attachextensions'];
require_once libfile('function/upload');
$swfconfig = getuploadconfig($_G['uid'], $_G['fid']);
$imgexts = str_replace(array(';', '*.'), array(', ', ''), $swfconfig['imageexts']['ext']);
$allowuploadnum = $allowuploadtoday = TRUE;
if($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) {
if($_G['group']['maxattachnum']) {
$allowuploadnum = $_G['group']['maxattachnum'] - getuserprofile('todayattachs');
$allowuploadnum = $allowuploadnum < 0 ? 0 : $allowuploadnum;
if(!$allowuploadnum) {
$allowuploadtoday = false;
}
}
if($_G['group']['maxsizeperday']) {
$allowuploadsize = $_G['group']['maxsizeperday'] - getuserprofile('todayattachsize');
$allowuploadsize = $allowuploadsize < 0 ? 0 : $allowuploadsize;
if(!$allowuploadsize) {
$allowuploadtoday = false;
}
$allowuploadsize = $allowuploadsize / 1048576 >= 1 ? round(($allowuploadsize / 1048576), 1).'MB' : round(($allowuploadsize / 1024)).'KB';
}
}
$allowpostimg = $_G['group']['allowpostimage'] && $imgexts;
$enctype = ($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) ? 'enctype="multipart/form-data"' : '';
$maxattachsize_mb = $_G['group']['maxattachsize'] / 1048576 >= 1 ? round(($_G['group']['maxattachsize'] / 1048576), 1).'MB' : round(($_G['group']['maxattachsize'] / 1024)).'KB';
$_G['group']['maxprice'] = isset($_G['setting']['extcredits'][$_G['setting']['creditstrans']]) ? $_G['group']['maxprice'] : 0;
$extra = !empty($_GET['extra']) ? rawurlencode($_GET['extra']) : '';
$notifycheck = empty($emailnotify) ? '' : 'checked="checked"';
$stickcheck = empty($sticktopic) ? '' : 'checked="checked"';
$digestcheck = empty($addtodigest) ? '' : 'checked="checked"';
$subject = isset($_GET['subject']) ? dhtmlspecialchars(censor(trim($_GET['subject']), NULL, FALSE, FALSE)) : '';
$subject = !empty($subject) ? str_replace("\t", ' ', $subject) : $subject;
$message = isset($_GET['message']) ? censor($_GET['message'], NULL, FALSE, FALSE) : '';
$polloptions = isset($polloptions) ? censor(trim($polloptions)) : '';
$readperm = isset($_GET['readperm']) ? intval($_GET['readperm']) : 0;
$price = isset($_GET['price']) ? intval($_GET['price']) : 0;
if(empty($bbcodeoff) && !$_G['group']['allowhidecode'] && !empty($message) && preg_match("/\[hide=?d?\d*,?\d*\].*?\[\/hide\]/is", preg_replace("/(\[code\](.+?)\[\/code\])/is", ' ', $message))) {
showmessage('post_hide_nopermission');
}
$urloffcheck = $usesigcheck = $smileyoffcheck = $codeoffcheck = $htmloncheck = $emailcheck = '';
list($seccodecheck, $secqaacheck) = seccheck('post', $_GET['action']);
$_G['group']['allowpostpoll'] = $_G['group']['allowpost'] && $_G['group']['allowpostpoll'] && ($_G['forum']['allowpostspecial'] & 1);
$_G['group']['allowposttrade'] = $_G['group']['allowpost'] && $_G['group']['allowposttrade'] && ($_G['forum']['allowpostspecial'] & 2);
$_G['group']['allowpostreward'] = $_G['group']['allowpost'] && $_G['group']['allowpostreward'] && ($_G['forum']['allowpostspecial'] & 4);
$_G['group']['allowpostactivity'] = $_G['group']['allowpost'] && $_G['group']['allowpostactivity'] && ($_G['forum']['allowpostspecial'] & 8);
$_G['group']['allowpostdebate'] = $_G['group']['allowpost'] && $_G['group']['allowpostdebate'] && ($_G['forum']['allowpostspecial'] & 16);
$usesigcheck = $_G['uid'] && $_G['group']['maxsigsize'] ? 'checked="checked"' : '';
$ordertypecheck = !empty($thread['tid']) && getstatus($thread['status'], 4) ? 'checked="checked"' : '';
$imgcontentcheck = !empty($thread['tid']) && getstatus($thread['status'], 15) ? 'checked="checked"' : '';
$specialextra = !empty($_GET['specialextra']) ? $_GET['specialextra'] : '';
$_G['forum']['threadplugin'] = dunserialize($_G['forum']['threadplugin']);
if($specialextra && $_G['group']['allowpost'] && $_G['setting']['threadplugins'] &&
(!array_key_exists($specialextra, $_G['setting']['threadplugins']) ||
!in_array($specialextra, is_array($_G['forum']['threadplugin']) ? $_G['forum']['threadplugin'] : (is_array(dunserialize($_G['forum']['threadplugin'])) ? dunserialize($_G['forum']['threadplugin']) : array())) ||
(is_array($_G['group']['allowthreadplugin']) && !in_array($specialextra, $_G['group']['allowthreadplugin'])))) {
$specialextra = '';
}
if($special == 3 && !isset($_G['setting']['extcredits'][$_G['setting']['creditstrans']])) {
showmessage('reward_credits_closed');
}
$_G['group']['allowanonymous'] = $_G['forum']['allowanonymous'] || $_G['group']['allowanonymous'] ? 1 : 0;
if($_GET['action'] == 'newthread' && $_G['forum']['allowspecialonly'] && !$special) {
if($_G['group']['allowpostpoll']) {
$special = 1;
} elseif($_G['group']['allowposttrade']) {
$special = 2;
} elseif($_G['group']['allowpostreward']) {
$special = 3;
} elseif($_G['group']['allowpostactivity']) {
$special = 4;
} elseif($_G['group']['allowpostdebate']) {
$special = 5;
} elseif($_G['group']['allowpost'] && $_G['setting']['threadplugins'] && $_G['group']['allowthreadplugin']) {
if(empty($_GET['specialextra'])) {
foreach($_G['forum']['threadplugin'] as $tpid) {
if(array_key_exists($tpid, $_G['setting']['threadplugins']) && is_array($_G['group']['allowthreadplugin']) && in_array($tpid, $_G['group']['allowthreadplugin'])){
$specialextra=$tpid;
break;
}
}
}
$threadpluginary = array_intersect($_G['forum']['threadplugin'], $_G['group']['allowthreadplugin']);
$specialextra = in_array($specialextra, $threadpluginary) ? $specialextra : '';
}
if(!$special && !$specialextra) {
showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
}
}
if(!$sortid && !$specialextra) {
$postspecialcheck[$special] = ' class="a"';
}
$editorid = 'e';
$_G['setting']['editoroptions'] = str_pad(decbin($_G['setting']['editoroptions']), 3, 0, STR_PAD_LEFT);
$editormode = $_G['setting']['editoroptions'][0];
$allowswitcheditor = $_G['setting']['editoroptions'][1];
$editor = array(
'editormode' => $editormode,
'allowswitcheditor' => $allowswitcheditor,
'allowhtml' => $_G['forum']['allowhtml'],
'allowsmilies' => $_G['forum']['allowsmilies'],
'allowbbcode' => $_G['forum']['allowbbcode'],
'allowimgcode' => $_G['forum']['allowimgcode'],
'allowresize' => 1,
'allowchecklength' => 1,
'allowtopicreset' => 1,
'textarea' => 'message',
'simplemode' => !isset($_G['cookie']['editormode_'.$editorid]) ? !$_G['setting']['editoroptions'][2] : $_G['cookie']['editormode_'.$editorid],
);
if($specialextra) {
$special = 127;
}
if($_GET['action'] == 'newthread') {
$policykey = 'post';
} elseif($_GET['action'] == 'reply') {
$policykey = 'reply';
} else {
$policykey = '';
}
$policykeys = array('postattach', $policykey);
loadcache('creditrule');
foreach ($policykeys as $key) {
if($key && is_array($_G['cache']['creditrule'][$key])) {
$data = array();
$creditrule = $_G['cache']['creditrule'][$key];
for($i = 1; $i <= 8; $i++) {
if($creditrule['extcredits'.$i]) {
$data[$i] = $creditrule['extcredits'.$i];
}
}
$_G['setting']['creditspolicy'][$key] = $data;
}
}
$postattachcredits = !empty($_G['forum']['postattachcredits']) ? $_G['forum']['postattachcredits'] : $_G['setting']['creditspolicy']['postattach'];
if($policykey) {
$postcredits = getglobal('forum/'.$policykey.'credits') ? getglobal('forum/'.$policykey.'credits') : $_G['setting']['creditspolicy'][$policykey];
}
$albumlist = array();
if(helper_access::check_module('album') && $_G['group']['allowupload'] && $_G['uid']) {
$query = C::t('home_album')->fetch_all_by_uid($_G['uid'], 'updatetime');
foreach($query as $value) {
if($value['picnum']) {
$albumlist[] = $value;
}
}
}
$posturl = "action={$_GET['action']}&fid={$_G['fid']}".
(!empty($_G['tid']) ? "&tid={$_G['tid']}" : '').
(!empty($pid) ? "&pid=$pid" : '').
(!empty($special) ? "&special=$special" : '').
(!empty($sortid) ? "&sortid=$sortid" : '').
(!empty($typeid) ? "&typeid=$typeid" : '').
(!empty($_GET['firstpid']) ? "&firstpid=".$_GET['firstpid'] : '').
(!empty($_GET['addtrade']) ? "&addtrade=".$_GET['addtrade'] : '');
if($_GET['action'] == 'reply') {
check_allow_action('allowreply');
} else {
check_allow_action('allowpost');
}
if($special == 4) {
$_G['setting']['activityfield'] = $_G['setting']['activityfield'] ? dunserialize($_G['setting']['activityfield']) : array();
}
if(helper_access::check_module('album') && $_G['group']['allowupload'] && $_G['setting']['albumcategorystat'] && !empty($_G['cache']['albumcategory'])) {
require_once libfile('function/portalcp');
}
$navtitle = lang('core', 'title_'.$_GET['action'].'_post');
list($modnewthreads, $modnewreplies) = threadmodstatus('');
if($_GET['action'] == 'newthread' || $_GET['action'] == 'newtrade') {
loadcache('groupreadaccess');
$navtitle .= ' - '.$_G['forum']['name'];
require_once libfile('post/newthread', 'include');
} elseif($_GET['action'] == 'reply') {
$navtitle .= ' - '.$thread['subject'].' - '.$_G['forum']['name'];
require_once libfile('post/newreply', 'include');
} elseif($_GET['action'] == 'edit') {
loadcache('groupreadaccess');
$navtitle .= ' - '.$thread['subject'].' - '.$_G['forum']['name'];
require_once libfile('post/editpost', 'include');
}
function check_allow_action($action = 'allowpost') {
global $_G;
if(isset($_G['forum'][$action]) && $_G['forum'][$action] == -1) {
showmessage('forum_access_disallow');
}
}
function recent_use_tag() {
$tagarray = $stringarray = array();
$string = '';
$i = 0;
$query = C::t('common_tagitem')->select(0, 0, 'tid', 'itemid', 'DESC', 10);
foreach($query as $result) {
if($i > 4) {
break;
}
if($tagarray[$result['tagid']] == '') {
$i++;
}
$tagarray[$result['tagid']] = 1;
}
if($tagarray) {
$query = C::t('common_tag')->fetch_all(array_keys($tagarray));
foreach($query as $result) {
$tagarray[$result['tagid']] = $result['tagname'];
}
}
return $tagarray;
}
?>

View File

@@ -0,0 +1,151 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_redirect.php 28464 2012-03-01 06:35:27Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
foreach(array('pid', 'ptid', 'authorid', 'ordertype', 'postno') as $k) {
$$k = !empty($_GET[$k]) ? intval($_GET[$k]) : 0;
}
if(empty($_GET['goto']) && $ptid) {
$_GET['goto'] = 'findpost';
}
if($_GET['goto'] == 'findpost') {
$post = $thread = array();
if($ptid) {
$thread = get_thread_by_tid($ptid);
}
if($pid) {
if($thread) {
$post = C::t('forum_post')->fetch_post($thread['posttableid'], $pid);
} else {
$post = get_post_by_pid($pid);
}
if($post && empty($thread)) {
$thread = get_thread_by_tid($post['tid']);
}
}
if(empty($thread)) {
showmessage('thread_nonexistence');
} else {
$tid = $thread['tid'];
}
if(empty($pid)) {
if($postno) {
if(getstatus($thread['status'], 3)) {
$rowarr = C::t('forum_post')->fetch_all_by_tid_position($thread['posttableid'], $ptid, $postno);
$pid = $rowarr[0]['pid'];
}
if($pid) {
$post = C::t('forum_post')->fetch_post($thread['posttableid'], $pid);
if($post['invisible'] != 0) {
$post = array();
}
} else {
$postno = $postno > 1 ? $postno - 1 : 0;
$post = C::t('forum_post')->fetch_visiblepost_by_tid($thread['posttableid'], $ptid, $postno);
}
}
}
if(empty($post)) {
if($ptid) {
header("HTTP/1.1 301 Moved Permanently");
dheader("Location: forum.php?mod=viewthread&tid=$ptid");
} else {
showmessage('post_check', NULL, array('tid' => $ptid));
}
} else {
$pid = $post['pid'];
}
$ordertype = !isset($_GET['ordertype']) && getstatus($thread['status'], 4) ? 1 : $ordertype;
if($thread['special'] == 2 || C::t('forum_threaddisablepos')->fetch($tid)) {
$curpostnum = C::t('forum_post')->count_by_tid_dateline($thread['posttableid'], $tid, $post['dateline']);
} else {
if($thread['maxposition']) {
$maxposition = $thread['maxposition'];
} else {
$maxposition = C::t('forum_post')->fetch_maxposition_by_tid($thread['posttableid'], $tid);
}
$thread['replies'] = $maxposition;
$curpostnum = $post['position'];
}
if($ordertype != 1) {
$page = ceil($curpostnum / $_G['ppp']);
} elseif($curpostnum > 1) {
$page = ceil(($thread['replies'] - $curpostnum + 3) / $_G['ppp']);
} else {
$page = 1;
}
if($thread['special'] == 2 && C::t('forum_trade')->check_goods($pid)) {
header("HTTP/1.1 301 Moved Permanently");
dheader("Location: forum.php?mod=viewthread&do=tradeinfo&tid=$tid&pid=$pid");
}
$authoridurl = $authorid ? '&authorid='.$authorid : '';
$ordertypeurl = $ordertype ? '&ordertype='.$ordertype : '';
header("HTTP/1.1 301 Moved Permanently");
dheader("Location: forum.php?mod=viewthread&tid=$tid&page=$page$authoridurl$ordertypeurl".(isset($_GET['modthreadkey']) && ($modthreadkey = modauthkey($tid)) ? "&modthreadkey=$modthreadkey": '')."#pid$pid");
}
if(empty($_G['thread'])) {
showmessage('thread_nonexistence');
}
if($_GET['goto'] == 'lastpost') {
$pageadd = '';
if(!getstatus($_G['thread'], 4)) {
$page = ceil(($_G['thread']['special'] ? $_G['thread']['replies'] : $_G['thread']['replies'] + 1) / $_G['ppp']);
$pageadd = $page > 1 ? '&page='.$page : '';
}
dheader('Location: forum.php?mod=viewthread&tid='.$_G['tid'].$pageadd.'#lastpost');
} elseif($_GET['goto'] == 'nextnewset' || $_GET['goto'] == 'nextoldset') {
$lastpost = $_G['thread']['lastpost'];
$glue = '<';
$sort = 'DESC';
if($_GET['goto'] == 'nextnewset') {
$glue = '>';
$sort = 'ASC';
}
$next = C::t('forum_thread')->fetch_next_tid_by_fid_lastpost($_G['fid'], $lastpost, $glue, $sort, $_G['thread']['threadtableid']);
if($next) {
dheader("Location: forum.php?mod=viewthread&tid=$next");
} elseif($_GET['goto'] == 'nextnewset') {
showmessage('redirect_nextnewset_nonexistence');
} else {
showmessage('redirect_nextoldset_nonexistence');
}
} else {
showmessage('undefined_action', NULL);
}
?>

View File

@@ -0,0 +1,161 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_rss.php 33056 2013-04-15 06:44:56Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
error_reporting(0);
define('IN_DISCUZ', TRUE);
define('DISCUZ_ROOT', '');
loadcache('forums');
if(!$_G['setting']['rssstatus']) {
exit('RSS Disabled');
}
$ttl = $_G['setting']['rssttl'] ? $_G['setting']['rssttl']: 30;
$num = 20;
$_G['groupid'] = 7;
$_G['uid'] = 0;
$_G['username'] = $_G['member']['password'] = '';
$rssfid = empty($_GET['fid']) ? 0 : intval($_GET['fid']);
$forumname = '';
if(empty($rssfid)) {
foreach($_G['cache']['forums'] as $fid => $forum) {
if(rssforumperm($forum)) {
$fidarray[] = $fid;
}
}
} else {
$forum = isset($_G['cache']['forums'][$rssfid]) && $_G['cache']['forums'][$rssfid]['type'] != 'group' ? $_G['cache']['forums'][$rssfid] : array();
if(!isset($_G['cache']['forums'][$rssfid])) {
$forum = $_G['cache']['forums'][$rssfid] = array();
$subforum = C::t('forum_forum')->fetch_info_by_fid($rssfid);
if($subforum['type'] == 'sub') {
$forum = $_G['cache']['forums'][$rssfid] = $subforum;
}
}
if($forum && rssforumperm($forum)) {
$fidarray = array($rssfid);
$forumname = dhtmlspecialchars($_G['cache']['forums'][$rssfid]['name']);
} else {
exit('Specified forum not found');
}
}
$frewriteflag = $trewriteflag = 0;
$havedomain = implode('', $_G['setting']['domain']['app']);
if(is_array($_G['setting']['rewritestatus']) && in_array('forum_forumdisplay', $_G['setting']['rewritestatus'])) {
$frewriteflag = 1;
}
if(is_array($_G['setting']['rewritestatus']) && in_array('forum_viewthread', $_G['setting']['rewritestatus'])) {
$trewriteflag = 1;
}
$charset = $_G['config']['output']['charset'];
dheader("Content-type: application/xml");
echo "<?xml version=\"1.0\" encoding=\"".$charset."\"?>\n".
"<rss version=\"2.0\">\n".
" <channel>\n".
(count($fidarray) > 1 ?
" <title>{$_G['setting']['bbname']}</title>\n".
" <link>{$_G['siteurl']}forum.php</link>\n".
" <description>Latest $num threads of all forums</description>\n"
:
" <title>{$_G['setting']['bbname']} - $forumname</title>\n".
" <link>{$_G['siteurl']}".($frewriteflag ? rewriteoutput('forum_forumdisplay', 1, '', $rssfid) : "forum.php?mod=forumdisplay&amp;fid=$rssfid")."</link>\n".
" <description>Latest $num threads of $forumname</description>\n"
).
" <copyright>Copyright(C) {$_G['setting']['bbname']}</copyright>\n".
" <generator>Discuz! Board by Comsenz Inc.</generator>\n".
" <lastBuildDate>".gmdate('r', TIMESTAMP)."</lastBuildDate>\n".
" <ttl>$ttl</ttl>\n".
" <image>\n".
" <url>{$_G['siteurl']}static/image/common/logo_88_31.gif</url>\n".
" <title>{$_G['setting']['bbname']}</title>\n".
" <link>{$_G['siteurl']}</link>\n".
" </image>\n";
if($fidarray) {
$alldata = C::t('forum_rsscache')->fetch_all_by_fid($fidarray, $num);
if($alldata) {
foreach($alldata as $thread) {
if(TIMESTAMP - $thread['lastupdate'] > $ttl * 60) {
updatersscache($num);
break;
} else {
list($thread['description'], $attachremote, $attachfile, $attachsize) = explode("\t", $thread['description']);
if($attachfile) {
if($attachremote) {
$filename = $_G['setting']['ftp']['attachurl'].'forum/'.$attachfile;
} else {
$filename = (!strstr($_G['setting']['attachurl'], '://') ? $_G['siteurl'] : '').$_G['setting']['attachurl'].'forum/'.$attachfile;
}
}
echo " <item>\n".
" <title>".$thread['subject']."</title>\n".
" <link>{$_G['siteurl']}".($trewriteflag ? rewriteoutput('forum_viewthread', 1, '', $thread['tid']) : "forum.php?mod=viewthread&amp;tid={$thread['tid']}")."</link>\n".
" <description><![CDATA[".dhtmlspecialchars($thread['description'])."]]></description>\n".
" <category>".dhtmlspecialchars($thread['forum'])."</category>\n".
" <author>".dhtmlspecialchars($thread['author'])."</author>\n".
($attachfile ? '<enclosure url="'.$filename.'" length="'.$attachsize.'" type="image/jpeg" />' : '').
" <pubDate>".gmdate('r', $thread['dateline'])."</pubDate>\n".
" </item>\n";
}
}
} else {
updatersscache($num);
}
}
echo " </channel>\n".
"</rss>";
function updatersscache($num) {
global $_G;
$processname = 'forum_rss_cache';
if(discuz_process::islocked($processname, 600)) {
return false;
}
C::t('forum_rsscache')->truncate();
require_once libfile('function/post');
foreach($_G['cache']['forums'] as $fid => $forum) {
if($forum['type'] != 'group') {
$forum['name'] = addslashes($forum['name']);
foreach(C::t('forum_thread')->fetch_all_by_fid_displayorder($fid, 0, null, null, 0, $num, 'tid') as $thread) {
$thread['author'] = $thread['author'] != '' ? addslashes($thread['author']) : 'Anonymous';
$thread['subject'] = addslashes($thread['subject']);
$post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
$attachdata = '';
$thread['message'] = $post['message'];
$thread['status'] = $post['status'];
$thread['description'] = $thread['readperm'] > 0 || $thread['price'] > 0 || $thread['status'] & 1 ? '' : addslashes(threadmessagecutstr($thread, $thread['message'], 250 - strlen($attachdata)).$attachdata);
C::t('forum_rsscache')->insert(array(
'lastupdate'=>$_G['timestamp'],
'fid'=>$fid,
'tid'=>$thread['tid'],
'dateline'=>$thread['dateline'],
'forum'=>$forum['name'],
'author'=>$thread['author'],
'subject'=>$thread['subject'],
'description'=>$thread['description']
), false, true);
}
}
}
discuz_process::unlock($processname);
return true;
}
?>

View File

@@ -0,0 +1,69 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
*
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
global $_G;
$op = in_array($_GET['op'], array('search', 'manage', 'set')) ? $_GET['op'] : '';
$taglist = array();
$thread = & $_G['thread'];
if($op == 'search') {
$searchkey = stripsearchkey($_GET['searchkey']);
$query = C::t('common_tag')->fetch_all_by_status(0, $searchkey, 50, 0);
foreach($query as $value) {
$taglist[] = $value;
}
$searchkey = dhtmlspecialchars($searchkey);
} elseif($op == 'manage') {
if($_G['tid']) {
$tagarray_all = $array_temp = $threadtag_array = array();
$tags = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['tid']);
$tags = $tags['tags'];
$tagarray_all = explode("\t", $tags);
if($tagarray_all) {
foreach($tagarray_all as $var) {
if($var) {
$array_temp = explode(',', $var);
$threadtag_array[] = $array_temp['1'];
}
}
}
$tags = implode(',', $threadtag_array);
$recent_use_tag = array();
$i = 0;
$query = C::t('common_tagitem')->select(0, 0, 'tid', 'itemid', 'DESC', 10);
foreach($query as $result) {
if($i > 4) {
break;
}
if($recent_use_tag[$result['tagid']] == '') {
$i++;
}
$recent_use_tag[$result['tagid']] = 1;
}
if($recent_use_tag) {
$query = C::t('common_tag')->fetch_all(array_keys($recent_use_tag));
foreach($query as $result) {
$recent_use_tag[$result['tagid']] = $result['tagname'];
}
}
}
} elseif($op == 'set' && $_GET['formhash'] == FORMHASH && $_G['group']['allowmanagetag']) {
$class_tag = new tag();
$tagstr = $class_tag->update_field($_GET['tags'], $_G['tid'], 'tid', $_G['thread']);
C::t('forum_post')->update_by_tid('tid:'.$_G['tid'], $_G['tid'], array('tags' => $tagstr), false, false, 1);
}
include_once template("forum/tag");
?>

View File

@@ -0,0 +1,102 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_topicadmin.php 30872 2012-06-27 10:11:44Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
$_G['inajax'] = 1;
$_GET['topiclist'] = !empty($_GET['topiclist']) ? (is_array($_GET['topiclist']) ? array_unique($_GET['topiclist']) : $_GET['topiclist']) : array();
loadcache(array('modreasons', 'stamptypeid', 'threadtableids'));
require_once libfile('function/post');
require_once libfile('function/misc');
$modpostsnum = 0;
$resultarray = $thread = array();
$threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
$specialperm = $_GET['action'] == 'stickreply' && $_G['thread']['authorid'] == $_G['uid'];
if(!$specialperm && (!$_G['uid'] || !$_G['forum']['ismoderator'])) {
showmessage('admin_nopermission', NULL);
}
$frommodcp = !empty($_GET['frommodcp']) ? intval($_GET['frommodcp']) : 0;
$navigation = $navtitle = '';
if(!empty($_G['tid'])) {
$_GET['archiveid'] = intval($_GET['archiveid']);
$archiveid = 0;
if(!empty($_GET['archiveid']) && in_array($_GET['archiveid'], $threadtableids)) {
$archiveid = $_GET['archiveid'];
}
$displayorder = !$_G['forum_auditstatuson'] ? 0 : null;
$thread = C::t('forum_thread')->fetch_by_tid_fid_displayorder($_G['tid'], $_G['fid'], $displayorder, $archiveid);
if(!$thread) {
showmessage('thread_nonexistence');
}
$navigation .= " &raquo; <a href=\"forum.php?mod=viewthread&tid={$_G['tid']}\">{$thread['subject']}</a> ";
$navtitle .= ' - '.$thread['subject'].' - ';
if($thread['special'] && in_array($_GET['action'], array('copy', 'split', 'merge'))) {
showmessage('special_noaction');
}
}
if(($_G['group']['reasonpm'] == 2 || $_G['group']['reasonpm'] == 3) || !empty($_GET['sendreasonpm'])) {
$forumname = strip_tags($_G['forum']['name']);
$sendreasonpm = 1;
} else {
$sendreasonpm = 0;
}
$_GET['handlekey'] = 'mods';
if(preg_match('/^\w+$/', $_GET['action']) && file_exists($topicadminfile = libfile('topicadmin/'.$_GET['action'], 'include'))) {
require_once $topicadminfile;
} else {
showmessage('undefined_action', NULL);
}
if($resultarray) {
if($resultarray['modtids']) {
updatemodlog($resultarray['modtids'], $modaction, $resultarray['expiration']);
}
updatemodworks($modaction, $modpostsnum);
if(is_array($resultarray['modlog'])) {
if(isset($resultarray['modlog']['tid'])) {
modlog($resultarray['modlog'], $modaction);
} else {
foreach($resultarray['modlog'] as $thread) {
modlog($thread, $modaction);
}
}
}
if($resultarray['reasonpm']) {
$modactioncode = lang('forum/modaction');
$modaction = $modactioncode[$modaction];
foreach($resultarray['reasonpm']['data'] as $var) {
sendreasonpm($var, $resultarray['reasonpm']['item'], $resultarray['reasonvar'], $resultarray['reasonpm']['notictype']);
}
}
showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'), $resultarray['redirect']);
}
?>

View File

@@ -0,0 +1,377 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum_trade.php 27054 2011-12-31 06:04:21Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
$apitype = $_GET['apitype'];
if(!$_G['uid']) {
showmessage('not_loggedin', NULL, array(), array('login' => 1));
}
$page = max(1, intval($_GET['page']));
$orderid = $_GET['orderid'];
if(!empty($orderid) && empty($_GET['apitype'])) {
$orderinfo = C::t('forum_tradelog')->fetch($orderid);
$paytype = $orderinfo['paytype'];
if($paytype == 1) {
$apitype = 'alipay';
}
if($paytype == 2) {
$apitype = 'tenpay';
}
}
require_once libfile('function/trade');
if(!empty($orderid)) {
$language = lang('forum/misc');
$tradelog = C::t('forum_tradelog')->fetch($orderid);
if(!$_G['forum_auditstatuson'] && (empty($tradelog) || $_G['uid'] != $tradelog['sellerid'] && $_G['uid'] != $tradelog['buyerid'])) {
showmessage('undefined_action', NULL);
}
$limit = 6;
$query = C::t('forum_trade')->fetch_all_for_seller($tradelog['sellerid'], $limit);
$usertrades = array();
$usertradecount = 0;
foreach($query as $usertrade) {
$usertradecount++;
$usertrades[] = $usertrade;
}
$trade_message = '';
$currentcredit = $_G['setting']['creditstrans'] ? getuserprofile('extcredits'.$_G['setting']['creditstrans']) : 0;
$discountprice = $tradelog['baseprice'] * $tradelog['number'];
if(!empty($_GET['pay']) && !$tradelog['offline'] && $tradelog['status'] == 0 && $tradelog['buyerid'] == $_G['uid']) {
if($_G['setting']['creditstransextra'][5] != -1 && $tradelog['credit']) {
if($tradelog['credit'] > getuserprofile('extcredits'.$_G['setting']['creditstransextra'][5])) {
showmessage('trade_credit_lack');
}
updatemembercount($tradelog['buyerid'], array($_G['setting']['creditstransextra'][5] => -$tradelog['credit']));
}
$trade = C::t('forum_trade')->fetch_goods($tradelog['tid'], $tradelog['pid']);
if($_G['uid'] && $currentcredit < $discountcredit && $tradelog['discount']) {
showmessage('trade_credits_no_enough', '', array('credittitle' => $_G['setting']['extcredits'][$_G['setting']['creditstrans']]['title']));
}
$pay = array();
$pay['commision'] = 0;
$transport = $tradelog['transport'];
$transportfee = 0;
trade_setprice(array('fee' => $fee, 'trade' => $trade, 'transport' => $transport), $price, $pay, $transportfee);
$payurl = trade_payurl($pay, $trade, $tradelog);
$paytype = 0;
if($apitype == 'alipay') {
$paytype = 1;
} elseif($apitype == 'tenpay') {
$paytype = 2;
}
C::t('forum_tradelog')->update($orderid, array('paytype' => $paytype));
showmessage('trade_directtopay', $payurl);
}
if(submitcheck('offlinesubmit') && in_array($_GET['offlinestatus'], trade_offline($tradelog, 0))) {
loaducenter();
$ucresult = uc_user_login($_G['username'], $_GET['password']);
list($tmp['uid']) = daddslashes($ucresult);
if($tmp['uid'] <= 0) {
showmessage('trade_password_error', 'forum.php?mod=trade&orderid='.$orderid);
}
if($_GET['offlinestatus'] == 4) {
if($_G['setting']['creditstransextra'][5] != -1 && $tradelog['credit']) {
if($tradelog['credit'] > getuserprofile('extcredits'.$_G['setting']['creditstransextra'][5])) {
showmessage('trade_credit_lack');
}
updatemembercount($tradelog['buyerid'], array($_G['setting']['creditstransextra'][5] => -$tradelog['credit']));
}
$trade = C::t('forum_trade')->fetch_goods($tradelog['tid'], $tradelog['pid']);
notification_add($tradelog['sellerid'], 'goods', 'trade_seller_send', array(
'buyerid' => $tradelog['buyerid'],
'buyer' => $tradelog['buyer'],
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
} elseif($_GET['offlinestatus'] == 5) {
notification_add($tradelog['buyerid'], 'goods', 'trade_buyer_confirm', array(
'sellerid' => $tradelog['sellerid'],
'seller' => $tradelog['seller'],
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
} elseif($_GET['offlinestatus'] == 7) {
if($_G['setting']['creditstransextra'][5] != -1 && $tradelog['basecredit']) {
$netcredit = round($tradelog['number'] * $tradelog['basecredit'] * (1 - $_G['setting']['creditstax']));
updatemembercount($tradelog['sellerid'], array($_G['setting']['creditstransextra'][5] => $netcredit));
} else {
$netcredit = 0;
}
$data = array('lastbuyer' => $tradelog['buyer'], 'lastupdate' => $_G['timestamp']);
C::t('forum_trade')->update_trade($tradelog['tid'], $tradelog['pid'], $data);
C::t('forum_trade')->update_counter($tradelog['tid'], $tradelog['pid'], $tradelog['number'], $tradelog['price'], $netcredit);
notification_add($tradelog['sellerid'], 'goods', 'trade_success', array(
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
notification_add($tradelog['buyerid'], 'goods', 'trade_success', array(
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
} elseif($_GET['offlinestatus'] == 17) {
C::t('forum_trade')->update_counter($tradelog['tid'], $tradelog['pid'], 0, 0, 0, $tradelog['number']);
notification_add($tradelog['sellerid'], 'goods', 'trade_fefund_success', array(
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
notification_add($tradelog['buyerid'], 'goods', 'trade_fefund_success', array(
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
if($_G['setting']['creditstransextra'][5] != -1 && $tradelog['basecredit']) {
updatemembercount($tradelog['buyerid'], array($_G['setting']['creditstransextra'][5] => $tradelog['number'] * $tradelog['basecredit']));
}
}
$_GET['message'] = trim($_GET['message']);
if($_GET['message']) {
$_GET['message'] = $tradelog['message']."\t\t\t".$_G['uid']."\t".$_G['member']['username']."\t".TIMESTAMP."\t".nl2br(strip_tags(substr($_GET['message'], 0, 200)));
} else {
$_GET['message'] = $tradelog['message'];
}
C::t('forum_tradelog')->update($orderid, array(
'status' => $_GET['offlinestatus'],
'lastupdate' => $_G['timestamp'],
'message' => $_GET['message']
));
showmessage('trade_orderstatus_updated', 'forum.php?mod=trade&orderid='.$orderid);
}
if(submitcheck('tradesubmit')) {
if($tradelog['status'] == 0) {
$update = array();
$oldbasecredit = $tradelog['basecredit'];
$oldnumber = $tradelog['number'];
if($tradelog['sellerid'] == $_G['uid']) {
$tradelog['baseprice'] = floatval($_GET['newprice']);
$tradelog['basecredit'] = intval($_GET['newcredit']);
if(!$tradelog['baseprice'] < 0 || $tradelog['basecredit'] < 0) {
showmessage('trade_pricecredit_error');
}
$tradelog['transportfee'] = intval($_GET['newfee']);
$newnumber = $tradelog['number'];
$update = array(
'baseprice' => $tradelog['baseprice'],
'basecredit' => $tradelog['basecredit'],
'transportfee' => $tradelog['transportfee']
);
notification_add($tradelog['buyerid'], 'goods', 'trade_order_update_sellerid', array(
'seller' => $tradelog['seller'],
'sellerid' => $tradelog['sellerid'],
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
}
if($tradelog['buyerid'] == $_G['uid']) {
$newnumber = intval($_GET['newnumber']);
if($newnumber <= 0) {
showmessage('trade_input_no');
}
$trade = C::t('forum_trade')->fetch_goods($tradelog['tid'], $tradelog['pid']);
if($newnumber > $trade['amount'] + $tradelog['number']) {
showmessage('trade_lack');
}
$amount = $trade['amount'] + $tradelog['number'] - $newnumber;
C::t('forum_trade')->update_trade($tradelog['tid'], $tradelog['pid'], array('amount' => $amount));
$tradelog['number'] = $newnumber;
$update = array(
'number' => $tradelog['number'],
'discount' => 0,
'buyername' => dhtmlspecialchars($_GET['newbuyername']),
'buyercontact' => dhtmlspecialchars($_GET['newbuyercontact']),
'buyerzip' => dhtmlspecialchars($_GET['newbuyerzip']),
'buyerphone' => dhtmlspecialchars($_GET['newbuyerphone']),
'buyermobile' => dhtmlspecialchars($_GET['newbuyermobile']),
'buyermsg' => dhtmlspecialchars($_GET['newbuyermsg'])
);
notification_add($tradelog['sellerid'], 'goods', 'trade_order_update_buyerid', array(
'buyer' => $tradelog['buyer'],
'buyerid' => $tradelog['buyerid'],
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
}
if($update) {
if($tradelog['discount']) {
$tradelog['baseprice'] = $tradelog['baseprice'] - $tax;
$price = $tradelog['baseprice'] * $tradelog['number'];
} else {
$price = $tradelog['baseprice'] * $tradelog['number'];
}
if($_G['setting']['creditstransextra'][5] != -1 && ($oldnumber != $newnumber || $oldbasecredit != $tradelog['basecredit'])) {
$tradelog['credit'] = $newnumber * $tradelog['basecredit'];
$update['credit'] = $tradelog['credit'];
}
$update['price'] = $price + ($tradelog['transport'] == 2 ? $tradelog['transportfee'] : 0);
C::t('forum_tradelog')->update($orderid, $update);
$tradelog = C::t('forum_tradelog')->fetch($orderid);
}
}
}
$tradelog['lastupdate'] = dgmdate($tradelog['lastupdate'], 'u');
$tradelog['statusview'] = trade_getstatus($tradelog['status']);
$messagelist = array();
if($tradelog['offline']) {
$offlinenext = trade_offline($tradelog, 1, $trade_message);
$message = explode("\t\t\t", $tradelog['message']);
foreach($message as $row) {
$row = explode("\t", $row);
$row[2] = dgmdate($row[2], 'u');
$row[0] && $messagelist[] = $row;
}
} else {
$loginurl = trade_getorderurl($tradelog['tradeno']);
}
$trade = C::t('forum_trade')->fetch_goods($tradelog['tid'], $tradelog['pid']);
include template('forum/trade_view');
} else {
if(empty($_GET['pid'])) {
$pid = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['tid']);
$pid = $pid['pid'];
} else {
$pid = $_GET['pid'];
}
$thread = C::t('forum_thread')->fetch_thread($_G['tid']);
if($thread['closed']) {
showmessage('trade_closed', 'forum.php?mod=viewthread&tid='.$_G['tid'].'&page='.$page);
}
$trade = C::t('forum_trade')->fetch_goods($_G['tid'], $pid);
if(empty($trade)) {
showmessage('trade_not_found');
}
$fromcode = false;
if($trade['closed']) {
showmessage('trade_closed', 'forum.php?mod=viewthread&tid='.$_G['tid'].'&page='.$page);
}
if($trade['price'] <= 0 && $trade['credit'] <= 0) {
showmessage('trade_invalid', 'forum.php?mod=viewthread&tid='.$_G['tid'].'&page='.$page);
}
if($trade['credit'] > 0 && $_G['setting']['creditstransextra'][5] == -1) {
showmessage('trade_credit_invalid', 'forum.php?mod=viewthread&tid='.$_G['tid'].'&page='.$page);
}
$limit = 6;
$query = C::t('forum_trade')->fetch_all_for_seller($trade['sellerid'], $limit);
$usertrades = array();
$usertradecount = 0;
foreach($query as $usertrade) {
$usertradecount++;
$usertrades[] = $usertrade;
}
if($_GET['action'] != 'trade' && !submitcheck('tradesubmit')) {
$lastbuyerinfo = dhtmlspecialchars(C::t('forum_tradelog')->fetch_last($_G['uid']));
$extra = rawurlencode($extra);
include template('forum/trade');
} else {
if($trade['sellerid'] == $_G['uid']) {
showmessage('trade_by_myself');
} elseif($_GET['number'] <= 0) {
showmessage('trade_input_no');
} elseif(!$fromcode && $_GET['number'] > $trade['amount']) {
showmessage('trade_lack');
}
$pay['number'] = $_GET['number'];
$pay['price'] = $trade['price'];
$credit = 0;
if($_G['setting']['creditstransextra'][5] != -1 && $trade['credit']) {
$credit = $_GET['number'] * $trade['credit'];
}
$price = $pay['price'] * $pay['number'];
$buyercredits = 0;
$pay['commision'] = 0;
$orderid = $pay['orderid'] = dgmdate(TIMESTAMP, 'YmdHis').random(18);
$transportfee = 0;
trade_setprice(array('fee' => $fee, 'trade' => $trade, 'transport' => $_GET['transport']), $price, $pay, $transportfee);
$buyerid = $_G['uid'] ? $_G['uid'] : 0;
$_G['username'] = $_G['username'] ? $_G['username'] : $guestuser;
$trade = daddslashes($trade, 1);
$buyermsg = dhtmlspecialchars($_GET['buyermsg']);
$buyerzip = dhtmlspecialchars($_GET['buyerzip']);
$buyerphone = dhtmlspecialchars($_GET['buyerphone']);
$buyermobile = dhtmlspecialchars($_GET['buyermobile']);
$buyername = dhtmlspecialchars($_GET['buyername']);
$buyercontact = dhtmlspecialchars($_GET['buyercontact']);
$offline = !empty($_GET['offline']) ? 1 : 0;
C::t('forum_tradelog')->insert(array(
'tid' => $trade['tid'],
'pid' => $trade['pid'],
'orderid' => $orderid,
'subject' => $trade['subject'],
'price' => $price,
'quality' => $trade['quality'],
'itemtype' => $trade['itemtype'],
'number' => $_GET['number'],
'tax' => $tax,
'locus' => $trade['locus'],
'sellerid' => $trade['sellerid'],
'seller' => $trade['seller'],
'selleraccount' => $trade['account'],
'tenpayaccount' => $trade['tenpayaccount'],
'buyerid' => $_G['uid'],
'buyer' => $_G['username'],
'buyercontact' => $buyercontact,
'buyercredits' => 0,
'buyermsg' => $buyermsg,
'lastupdate' => $_G['timestamp'],
'offline' => $offline,
'buyerzip' => $buyerzip,
'buyerphone' => $buyerphone,
'buyermobile' => $buyermobile,
'buyername' => $buyername,
'transport' => $_GET['transport'],
'transportfee' => $transportfee,
'baseprice' => $trade['price'],
'discount' => 0,
'credit' => $credit,
'basecredit' => $trade['credit']
));
C::t('forum_trade')->update_counter($trade['tid'], $trade['pid'], 0, 0, 0, '-'.$_GET['number']);
showmessage('trade_order_created', 'forum.php?mod=trade&orderid='.$orderid);
}
}
?>

File diff suppressed because it is too large Load Diff

View File

View File

@@ -0,0 +1,30 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: group_attentiongroup.php 25889 2011-11-24 09:52:20Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$_GET['handlekey'] = 'attentiongroup';
require_once libfile('function/group');
$usergroups = update_usergroups($_G['uid']);
$attentiongroup = !empty($_G['member']['attentiongroup']) ? explode(',', $_G['member']['attentiongroup']) : array();
$counttype = count($attentiongroup);
if(submitcheck('attentionsubmit')) {
if(is_array($_GET['attentiongroupid'])) {
$_GET['attentiongroupid'] = array_slice($_GET['attentiongroupid'], 0, 5);
C::t('common_member_field_forum')->update($_G['uid'], array('attentiongroup' => implode(',', $_GET['attentiongroupid'])));
} else {
C::t('common_member_field_forum')->update($_G['uid'], array('attentiongroup' => ''));
}
showmessage('setup_finished', 'group.php?mod=my&view=groupthread');
}
include template('group/group_attentiongroup');
?>

View File

@@ -0,0 +1,168 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: group_index.php 36284 2016-12-12 00:47:50Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$navtitle = '';
$gid = intval(getgpc('gid'));
$sgid = intval(getgpc('sgid'));
$groupids = $typelist = array();
$groupnav = '';
$selectorder = array('default' => '', 'thread' => '', 'membernum' => '', 'dateline' => '', 'activity' => '');
if(!empty($_GET['orderby'])) {
$selectorder[$_GET['orderby']] = 'selected';
} else {
$selectorder['default'] = 'selected';
}
$first = &$_G['cache']['grouptype']['first'];
$second = &$_G['cache']['grouptype']['second'];
require_once libfile('function/group');
$url = $_G['basescript'].'.php';
if($gid) {
if(!empty($first[$gid])) {
$curtype = $first[$gid];
if($curtype['secondlist']) {
foreach($curtype['secondlist'] as $fid) {
$typelist[$fid] = $second[$fid];
}
$groupids = $first[$gid]['secondlist'];
}
$groupids[] = $gid;
$url .= '?gid='.$gid;
$fup = $gid;
} else {
$gid = 0;
}
} elseif($sgid) {
if(!empty($second[$sgid])) {
$curtype = $second[$sgid];
$fup = $curtype['fup'];
$groupids = array($sgid);
$url .= '?sgid='.$sgid;
} else {
$sgid = 0;
}
}
if(empty($curtype)) {
if($_G['uid'] && empty($_G['mod'])) {
$usergroups = getuserprofile('groups');
if(!empty($usergroups)) {
dheader('Location:group.php?mod=my');
exit;
}
}
$curtype = array();
} else {
$nav = get_groupnav($curtype);
$groupnav = $nav['nav'];
$_G['grouptypeid'] = $curtype['fid'];
$perpage = 10;
if($curtype['forumcolumns'] > 1) {
$curtype['forumcolwidth'] = (floor(100 / $curtype['forumcolumns']) - 0.1).'%';
$perpage = $curtype['forumcolumns'] * 10;
}
}
$seodata = array('first' => $nav['first']['name'], 'second' => $nav['second']['name']);
list($navtitle, $metadescription, $metakeywords) = get_seosetting('group', $seodata);
$data = $randgrouplist = $randgroupdata = $grouptop = $newgrouplist = $fids = array();
$topgrouplist = $_G['cache']['groupindex']['topgrouplist'];
$lastupdategroup = $_G['cache']['groupindex']['lastupdategroup'];
$todayposts = intval($_G['cache']['groupindex']['todayposts']);
$groupnum = intval($_G['cache']['groupindex']['groupnum']);
$cachetimeupdate = TIMESTAMP - intval($_G['cache']['groupindex']['updateline']);
if(empty($_G['cache']['groupindex']) || $cachetimeupdate > 3600 || empty($lastupdategroup)) {
$data['randgroupdata'] = $randgroupdata = grouplist('lastupdate', array('ff.membernum', 'ff.icon'), 80);
$data['topgrouplist'] = $topgrouplist = grouplist('activity', array('f.commoncredits', 'ff.membernum', 'ff.icon'), 10);
$data['updateline'] = TIMESTAMP;
$groupdata = C::t('forum_forum')->fetch_group_counter();
$data['todayposts'] = $todayposts = $groupdata['todayposts'];
$data['groupnum'] = $groupnum = $groupdata['groupnum'];
foreach($first as $id => $toptype) {
if(empty($toptype['secondlist'])) $toptype['secondlist'][] = $id;
$query = C::t('forum_forum')->fetch_all_sub_group_by_fup($toptype['secondlist']);
foreach($query as $row) {
if(!in_array($row['fid'], $fids)){
$fids[] = $row['fid'];
}
}
foreach($query as $row) {
$data['lastupdategroup'][$id][] = $row;
}
if(empty($data['lastupdategroup'][$id])) $data['lastupdategroup'][$id] = array();
}
$lastupdategroupdetail = grouplist('activity', array('ff.membernum', 'ff.icon'), count($fids), $fids);
foreach($data['lastupdategroup'] as $id => $toptype) {
foreach($toptype as $key => $detail) {
$data['lastupdategroup'][$id][$key] = array_merge($lastupdategroupdetail[$detail['fid']], $detail);
}
}
$lastupdategroup = $data['lastupdategroup'];
savecache('groupindex', $data);
}
$list = array();
if($groupids) {
$orderby = in_array(getgpc('orderby'), array('membernum', 'dateline', 'thread', 'activity')) ? getgpc('orderby') : 'displayorder';
$page = intval(getgpc('page')) ? intval($_GET['page']) : 1;
$page = $page > 65535 ? 1 : $page;
$start = ($page - 1) * $perpage;
$getcount = grouplist('', '', '', $groupids, 1, 1);
if($getcount) {
$list = grouplist($orderby, '', array($start, $perpage), $groupids, 1);
$multipage = multi($getcount, $perpage, $page, $url."&orderby=$orderby");
}
}
$endrows = $curtype['forumcolumns'] > 1 ? str_repeat('<td width="'.$curtype['forumcolwidth'].'"></td>', $curtype['forumcolumns'] - count($list) % $curtype['forumcolumns']) : '';
$groupviewed_list = get_viewedgroup();
if(empty($sgid) && empty($gid)) {
foreach($first as $key => $val) {
if(is_array($val['secondlist']) && !empty($val['secondlist'])) {
$first[$key]['secondlist'] = array_slice($val['secondlist'], 0, 8);
}
}
}
if(!$navtitle || !empty($sgid) || !empty($gid)) {
if(!$navtitle) {
$navtitle = !empty($gid) ? $nav['first']['name'] : (!empty($sgid) ? $nav['second']['name'] : '');
}
$navtitle = (!empty($sgid) || !empty($gid) ? helper_seo::get_title_page($navtitle, $_G['page']).' - ' : '').$_G['setting']['navs'][3]['navname'];
$nobbname = false;
} else {
$nobbname = true;
}
if(!$metakeywords) {
$metakeywords = $_G['setting']['navs'][3]['navname'];
}
if(!$metadescription) {
$metadescription = $_G['setting']['navs'][3]['navname'];
}
if(empty($curtype)) {
include template('diy:group/index');
} else {
if(empty($sgid)) {
include template('diy:group/type:'.$gid);
} else {
include template('diy:group/type:'.$fup);
}
}
?>

View File

@@ -0,0 +1,165 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: group_my.php 30630 2012-06-07 07:16:14Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$_G['mnid'] = 'mn_group';
if(!$_G['uid']) {
showmessage('to_login', null, array(), array('showmsg' => true, 'login' => 1));
}
require_once libfile('function/group');
$view = $_GET['view'] && in_array($_GET['view'], array('manager', 'join', 'groupthread', 'mythread')) ? $_GET['view'] : 'groupthread';
$actives = array('manager' => '', 'join' => '', 'groupthread' => '', 'mythread' => '');
$actives[$view] = ' class="a"';
$perpage = 20;
$page = intval($_GET['page']) ? intval($_GET['page']) : 1;
$start = ($page - 1) * $perpage;
if($view == 'groupthread' || $view == 'mythread') {
$typeid = intval($_GET['typeid']);
$attentiongroups = $usergroups = array();
$usergroups = update_usergroups($_G['uid']);
if($view == 'groupthread' && empty($typeid) && !empty($usergroups['grouptype'])) {
$attentiongroup = $_G['member']['attentiongroup'];
if(empty($attentiongroup)) {
$attentiongroups = array_slice(array_keys($usergroups['groups']), 0, 1);
} else {
$attentiongroups = explode(',', $attentiongroup);
}
$attentionthread = $attentiongroup_icon = array();
$attentiongroupfid = '';
$query = C::t('forum_forum')->fetch_all_info_by_fids($attentiongroups);
foreach($query as $row) {
$attentiongroup_icon[$row['fid']] = get_groupimg($row['icon'], 'icon');
}
foreach($attentiongroups as $groupid) {
$attentiongroupfid .= $attentiongroupfid ? ','.$groupid : $groupid;
if($page == 1) {
foreach(C::t('forum_thread')->fetch_all_by_fid_displayorder($groupid, 0, null, null, 0, 5, 'lastpost', 'DESC', '=') as $thread) {
$attentionthread[$groupid][$thread['tid']]['fid'] = $thread['fid'];
$attentionthread[$groupid][$thread['tid']]['subject'] = $thread['subject'];
$attentionthread[$groupid][$thread['tid']]['groupname'] = $usergroups['groups'][$thread['fid']];
$attentionthread[$groupid][$thread['tid']]['views'] = $thread['views'];
$attentionthread[$groupid][$thread['tid']]['replies'] = $thread['replies'];
$attentionthread[$groupid][$thread['tid']]['lastposter'] = $thread['lastposter'];
$attentionthread[$groupid][$thread['tid']]['lastpost'] = dgmdate($thread['lastpost'], 'u');
$attentionthread[$groupid][$thread['tid']]['folder'] = 'common';
if(empty($_G['cookie']['oldtopics']) || strpos($_G['cookie']['oldtopics'], 'D'.$thread['tid'].'D') === FALSE) {
$attentionthread[$groupid][$thread['tid']]['folder'] = 'new';
}
}
}
}
}
$mygrouplist = mygrouplist($_G['uid'], 'lastupdate', array('f.name', 'ff.icon'), 50);
if($mygrouplist) {
$managegroup = $commongroup = $groupthreadlist = array();
foreach($mygrouplist as $fid => $group) {
if($group['level'] == 1 || $group['level'] == 2) {
if(count($managegroup) == 8) {
continue;
}
$managegroup[$fid]['name'] = $group['name'];
$managegroup[$fid]['icon'] = $group['icon'];
} else {
if(count($commongroup) == 8) {
continue;
}
$commongroup[$fid]['name'] = $group['name'];
$commongroup[$fid]['icon'] = $group['icon'];
}
}
$mygroupfid = array_keys($mygrouplist);
if($typeid && !empty($usergroups['grouptype'][$typeid]['groups'])) {
$mygroupfid = explode(',', $usergroups['grouptype'][$typeid]['groups']);
$typeurl = '&typeid='.$typeid;
} else {
$typeid = 0;
}
if(!empty($attentiongroupfid) && !empty($mygroupfid)) {
$mygroupfid = array_diff($mygroupfid, explode(',', $attentiongroupfid));
}
if($mygroupfid) {
$lastpost = 0;
$displayorder = null;
if($view != 'mythread') {
$displayorder = 0;
$lastpost = TIMESTAMP - 86400*30;
}
$authorid = $_G['uid'];
foreach(C::t('forum_thread')->fetch_all_by_fid_authorid_displayorder($mygroupfid, $authorid, $displayorder, $lastpost, $start, $perpage) as $thread) {
$groupthreadlist[$thread['tid']]['fid'] = $thread['fid'];
$groupthreadlist[$thread['tid']]['subject'] = $thread['subject'];
$groupthreadlist[$thread['tid']]['groupname'] = $mygrouplist[$thread['fid']]['name'];
$groupthreadlist[$thread['tid']]['views'] = $thread['views'];
$groupthreadlist[$thread['tid']]['replies'] = $thread['replies'];
$groupthreadlist[$thread['tid']]['lastposter'] = $thread['lastposter'];
$groupthreadlist[$thread['tid']]['lastpost'] = dgmdate($thread['lastpost'], 'u');
$groupthreadlist[$thread['tid']]['folder'] = 'common';
if(empty($_G['cookie']['oldtopics']) || strpos($_G['cookie']['oldtopics'], 'D'.$thread['tid'].'D') === FALSE) {
$groupthreadlist[$thread['tid']]['folder'] = 'new';
}
}
if($view == 'mythread') {
$multipage = simplepage(count($groupthreadlist), $perpage, $page, 'group.php?mod=my&view='.$view.$typeurl);
}
}
}
} elseif($view == 'manager' || $view == 'join') {
$perpage = 40;
$start = ($page - 1) * $perpage;
$ismanager = $view == 'manager' ? 1 : 2;
$num = mygrouplist($_G['uid'], 'lastupdate', array('f.name', 'ff.icon'), 0, 0, $ismanager, 1);
$multipage = multi($num, $perpage, $page, 'group.php?mod=my&view='.$view);
$grouplist = mygrouplist($_G['uid'], 'lastupdate', array('f.name', 'ff.icon'), $perpage, $start, $ismanager);
}
$frienduidarray = $friendgrouplist = $randgroupdata = $randgrouplist = $randgroup = array();
loadcache('groupindex');
$randgroupdata = $_G['cache']['groupindex']['randgroupdata'];
if($randgroupdata) {
foreach($randgroupdata as $groupid => $rgroup) {
if($rgroup['iconstatus']) {
$randgrouplist[$groupid] = $rgroup;
}
}
}
if(count($randgrouplist) > 9) {
foreach(array_rand($randgrouplist, 9) as $fid) {
$randgroup[] = $randgrouplist[$fid];
}
} elseif (count($randgrouplist)) {
$randgroup = $randgrouplist;
}
require_once libfile('function/friend');
$frienduid = friend_list($_G['uid'], 50);
if($frienduid && is_array($frienduid)) {
foreach($frienduid as $friend) {
$frienduidarray[] = $friend['fuid'];
}
$fids = C::t('forum_groupuser')->fetch_all_fid_by_uids($frienduidarray);
$query = C::t('forum_forum')->fetch_all_info_by_fids($fids, 0, 9);
foreach($query as $group) {
$icon = get_groupimg($group['icon'], 'icon');
$friendgrouplist[$group['fid']] = array('fid' => $group['fid'], 'name' => $group['name'], 'icon' => $icon);
}
}
$navtitle = $_G['username'].lang('core', 'title_of').$_G['setting']['navs'][3]['navname'];
include_once template("diy:group/group_my");
?>

View File

View File

@@ -0,0 +1,324 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: home_editor.php 35193 2015-02-02 02:15:19Z hypowang $
*/
if (!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if (empty($_GET['charset']) || !in_array(strtolower($_GET['charset']), array('gbk', 'big5', 'utf-8')))
$_GET['charset'] = '';
$allowhtml = empty($_GET['allowhtml']) ? 0 : 1;
$doodle = empty($_GET['doodle']) ? 0 : 1;
$isportal = empty($_GET['isportal']) ? 0 : 1;
if (empty($_GET['op'])) {
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="<?php echo $_GET['charset']; ?>" />
<meta name="renderer" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Editor</title>
<script type="text/javascript" src="<?php echo STATICURL; ?>js/common.js"></script>
<script type="text/javascript" src="<?php echo STATICURL; ?>js/home.js"></script>
<script language="javascript" src="<?php echo STATICURL; ?>image/editor/editor_base.js"></script>
<style type="text/css">
html, body { height: 100%; }
body{margin:0;padding:0;}
body, td, input, button, select, textarea {font: 12px/1.5em Tahoma, Arial, Helvetica, sans-serif;}
textarea { resize: none; font-size: 14px; line-height: 1.8em; }
.submit { padding: 0 10px; height: 22px; border: 1px solid; border-color: #DDD #264F6E #264F6E #DDD; background: #2782D6; color: #FFF; line-height: 20px; letter-spacing: 1px; cursor: pointer; }
a.dm{text-decoration:none}
a.dm:hover{text-decoration:underline}
a{font-size:12px}
img{border:0}
td.icon{width:24px;height:24px;text-align:center;vertical-align:middle}
td.sp{width:8px;height:24px;text-align:center;vertical-align:middle}
td.xz{width:47px;height:24px;text-align:center;vertical-align:middle}
td.bq{width:49px;height:24px;text-align:center;vertical-align:middle}
div a.n{height:16px;line-height:16px;display:block;padding:2px;color:#000000;text-decoration:none}
div a.n:hover{background:#E5E5E5}
.r_op { float: right; }
.eMenu{position:absolute;margin-top: -2px;background:#FFFFFF;border:1px solid #C5C5C5;padding:4px}
.eMenu ul, .eMenu ul li { margin: 0; padding: 0; }
.eMenu ul li{list-style: none;float:left}
#editFaceBox { padding: 5px; }
#editFaceBox li { width: 25px; height: 25px; overflow: hidden; }
.t_input { padding: 3px 2px; border-style: solid; border-width: 1px; border-color: #7C7C7C #C3C3C3 #DDD; line-height: 16px; }
a.n1{height:16px;line-height:16px;display:block;padding:2px;color:#000000;text-decoration:none}
a.n1:hover{background:#E5E5E5}
a.cs{height:15px;position:relative}
*:lang(zh) a.cs{height:12px}
.cs .cb{font-size:0;display:block;width:10px;height:8px;position:absolute;left:4px;top:3px;cursor:hand!important;cursor:pointer}
.cs span{position:absolute;left:19px;top:0px;cursor:hand!important;cursor:pointer;color:#333}
.fRd1 .cb{background-color:#800}
.fRd2 .cb{background-color:#800080}
.fRd3 .cb{background-color:#F00}
.fRd4 .cb{background-color:#F0F}
.fBu1 .cb{background-color:#000080}
.fBu2 .cb{background-color:#00F}
.fBu3 .cb{background-color:#0FF}
.fGn1 .cb{background-color:#008080}
.fGn2 .cb{background-color:#008000}
.fGn3 .cb{background-color:#808000}
.fGn4 .cb{background-color:#0F0}
.fYl1 .cb{background-color:#FC0}
.fBk1 .cb{background-color:#000}
.fBk2 .cb{background-color:#808080}
.fBk3 .cb{background-color:#C0C0C0}
.fWt0 .cb{background-color:#FFF;border:1px solid #CCC}
.mf_nowchose{height:30px;background-color:#DFDFDF;border:1px solid #B5B5B5;border-left:none}
.mf_other{height:30px;border-left:1px solid #B5B5B5}
.mf_otherdiv{height:30px;width:30px;border:1px solid #FFF;border-right-color:#D6D6D6;border-bottom-color:#D6D6D6;background-color:#F8F8F8}
.mf_otherdiv2{height:30px;width:30px;border:1px solid #B5B5B5;border-left:none;border-top:none}
.mf_link{font-size:12px;color:#000000;text-decoration:none}
.mf_link:hover{font-size:12px;color:#000000;text-decoration:underline}
.ico{height:24px;width:24px;vertical-align:middle;text-align:center}
.ico2{height:24px;width:27px;vertical-align:middle;text-align:center}
.ico3{height:24px;width:25px;vertical-align:middle;text-align:center}
.ico4{height:24px;width:8px;vertical-align:middle;text-align:center}
.edTb { background: #F2F2F2; }
.icons a,.sepline,.switch{background-image:url(<?php echo STATICURL; ?>image/editor/editor.gif)}
.toobar, .toobarmini{position:relative;height:26px;overflow:hidden}
.toobarmini .icoSwitchTxt, .toobarmini .tble{ display: none !important;}
.toobar .icoSwitchMdi{ display: none;}
.tble{position:absolute;left:0;top:2px }
*:lang(zh) .tble{top:2px}
.tbri{width:60px;position:absolute;right:3px;top:2px;}
.icons a{width:20px;height:20px;background-repeat:no-repeat;display:block;float:left;border:1px solid #F2F2F2;}
*:lang(zh) .icons a{margin-right:1px}
.icons a:hover{border-color: #369 #CCC;background-color:#FFF}
a.icoCut{background-position:-140px -60px;}
a.icoCpy{background-position:-160px -60px;}
a.icoPse{background-position:-40px -60px}
a.icoFfm{background-position:-100px 0}
a.icoFsz{background-position:-120px 0;}
a.icoWgt{background-position:0 0;}
a.icoIta{background-position:-20px 0;}
a.icoUln{background-position:-40px 0;}
a.icoAgn{background-position:-60px 0}
a.icoAgL{background-position:-80px -20px}
a.icoAgC{background-position:-240px -40px}
a.icoAgR{background-position:-260px -40px}
a.icoLst{background-position:-100px -20px}
a.icoOdt{background-position:-180px -60px}
a.icoIdt{background-position:-180px -60px}
a.icoFcl{background-position:-60px 0}
a.icoBcl{background-position:-80px 0}
a.icoUrl{background-position:-40px -20px;}
a.icoMoveUrl{background-position:-60px -20px}
a.icoRenew {background-position:-180px -40px}
a.icoFace {background-position:-20px -20px}
a.icoPage {background-position:-200px -60px}
a.icoDown {background-position:-80px -60px}
a.icoDoodle {background-position:-260px -60px}
a.icoImg{background-position:0 -20px}
a.icoAttach{background-position:-200px -20px}
a.icoSwf{background-position:-240px -20px}
a.icoSwitchTxt{background-position:-220px -60px;float:right}
a.icoFullTxt{ float: right; width: 35px; height: 20px; line-height: 20px; border: 1px solid #C2D5E3; background: url(<?php echo STATICURL; ?>image/common/card_btn.png) repeat-x 0 100%; text-align: center; color: #333; text-decoration: none; }
a.icoSwitchMdi{background-position:-239px -60px;float:right}
.edTb{border-bottom:1px solid #c5c5c5;background-position:0 -28px}
.sepline{width:4px;height:20px;margin-top:2px;margin-right:3px;background-position:-476px 0;background-repeat:no-repeat;float:left }
</style>
<script language="JavaScript">
function fontname(obj){format('fontname',obj.innerHTML);obj.parentNode.style.display='none'}
function fontsize(size,obj){format('fontsize',size);obj.parentNode.style.display='none'}
</script>
</head>
<body style="overflow-y:hidden">
<div style="height:100%">
<div style="position: absolute;width: 100%;height: 31px;">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="edTb">
<tr>
<td height="31" style="padding-left:3px">
<div class="toobar" id="dvToolbar">
<div class="icons tble">
<a href="javascript:;" class="icoCut" title="<?php echo lang('home/editor', 'editor_cut'); ?>" onClick="format('Cut');return false;"></a>
<a href="javascript:;" class="icoCpy" title="<?php echo lang('home/editor', 'editor_copy'); ?>" onClick="format('Copy');return false;"></a>
<a href="javascript:;" class="icoPse" title="<?php echo lang('home/editor', 'editor_paste'); ?>" onClick="format('Paste');return false;"></a>
<div class="sepline"></div>
<a href="javascript:;" class="icoFfm" id="imgFontface" title="<?php echo lang('home/editor', 'editor_font'); ?>" onClick="fGetEv(event);fDisplayElement('fontface','');return false;"></a>
<a href="javascript:;" class="icoFsz" id="imgFontsize" title="<?php echo lang('home/editor', 'editor_fontsize'); ?>" onClick="fGetEv(event);fDisplayElement('fontsize','');return false;"></a>
<a href="javascript:;" class="icoWgt" onClick="format('Bold');return false;" title="<?php echo lang('home/editor', 'editor_fontbold'); ?>"></a>
<a href="javascript:;" class="icoIta" title="<?php echo lang('home/editor', 'editor_fontitalic'); ?>" onClick="format('Italic');return false;"></a>
<a href="javascript:;" class="icoUln" onClick="format('Underline');return false;" title="<?php echo lang('home/editor', 'editor_fontunderline'); ?>"></a>
<a href="javascript:;" class="icoFcl" title="<?php echo lang('home/editor', 'editor_funtcolor'); ?>" onClick="foreColor(event);return false;" id="imgFontColor"></a>
<a href="javascript:;" class="icoAgL" id="imgJustifyleft" onClick="fGetEv(event);format('Justifyleft');return false;" title="<?php echo lang('home/editor', 'editor_align_left'); ?>"></a>
<a href="javascript:;" class="icoAgC" id="imgJustifycenter" onClick="fGetEv(event);format('Justifycenter');return false;" title="<?php echo lang('home/editor', 'editor_align_center'); ?>"></a>
<a href="javascript:;" class="icoAgR" id="imgJustifyright" onClick="fGetEv(event);format('Justifyright');return false;" title="<?php echo lang('home/editor', 'editor_align_right'); ?>"></a>
<a href="javascript:;" class="icoLst" id="imgList" onClick="fGetEv(event);fDisplayElement('divList','');return false;"title="<?php echo lang('home/editor', 'editor_list'); ?>"></a>
<a href="javascript:;" class="icoOdt" id="imgInOut" onClick="fGetEv(event);fDisplayElement('divInOut','');return false;" title="<?php echo lang('home/editor', 'editor_indent'); ?>"></a>
<div class="sepline"></div>
<a href="javascript:;" class="icoUrl" id="icoUrl" onClick="createLink(event, 1);return false;" title="<?php echo lang('home/editor', 'editor_hyperlink'); ?>"></a>
<a href="javascript:;" class="icoMoveUrl" onClick="clearLink();return false;" title="<?php echo lang('home/editor', 'editor_remove_link'); ?>"></a>
<a href="javascript:;" class="icoImg" id="icoImg" onClick="parent.createImageBox(<?php echo ($isportal ? 'parent.check_catid' : '')?>);return false;" title="<?php echo lang('home/editor', 'editor_link_image'); ?>"></a>
<?php if ($isportal) { ?>
<a href="javascript:;" class="icoAttach" id="icoAttach" onClick="parent.createAttachBox(<?php echo ($isportal ? 'parent.check_catid' : '')?>);return false;" title="<?php echo lang('home/editor', 'editor_link_attach'); ?>"></a>
<?php } ?>
<a href="javascript:;" class="icoSwf" id="icoSwf" onClick="createFlash(event, 1);return false;" title="<?php echo lang('home/editor', 'editor_link_flash'); ?>"></a>
<a href="javascript:;" class="icoFace" id="faceBox" onClick="faceBox(event);return false;" title="<?php echo lang('home/editor', 'editor_insert_smiley'); ?>"></a>
<?php if ($doodle) { ?>
<a href="javascript:;" class="icoDoodle" id="doodleBox" onClick="doodleBox(event, this.id);return false;" title="<?php echo lang('home/editor', 'editor_doodle'); ?>"></a>
<?php } ?>
<?php if ($isportal) { ?>
<a href="javascript:;" class="icoPage" id="icoPage" onClick="pageBreak(event, 1);return false;" title="<?php echo lang('home/editor', 'editor_pagebreak'); ?>"></a>
<a href="javascript:;" class="icoDown" id="icoDown" onClick="parent.downRemoteFile();return false;" title="<?php echo lang('home/editor', 'editor_download_remote'); ?>"></a>
<?php } ?>
<a href="javascript:;" class="icoRenew" onClick="renewContent();return false;" title="<?php echo lang('home/editor', 'editor_restore'); ?>"></a>
<?php if ($allowhtml) { ?>
<input type="checkbox" value="1" name="switchMode" id="switchMode" style="float:left;margin-top:6px!important;margin-top:2px" onClick="setMode(this.checked)" onMouseOver="fSetModeTip(this)" onMouseOut="fHideTip()">
<?php } else { ?>
<input type="hidden" value="1" name="switchMode" id="switchMode">
<?php } ?>
</div>
<div class="icons tbri">
<a href="javascript:;" class="icoSwitchMdi" title="<?php echo lang('home/editor', 'editor_switch_media'); ?>" onClick="changeEditType(true, event);return false;"></a>
<a href="javascript:;" class="icoSwitchTxt" title="<?php echo lang('home/editor', 'editor_switch_text'); ?>" onClick="changeEditType(false, event);return false;"></a>
<a href="javascript:;" class="icoFullTxt" onClick="changeEditFull(true, event);return false;"><?php echo lang('home/editor', 'editor_full_screen'); ?></a>
</div>
</div>
</td>
</tr>
</table>
<div style="width:100px;height:100px;position:absolute;display:none;top:-500px;left:-500px" ID="dvPortrait"></div>
<div id="fontface" class="eMenu" style="z-index:99;display:none;top:35px;left:2px;width:110px;height:265px">
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px '<?php echo lang('home/editor', 'editor_font_song'); ?>';"><?php echo lang('home/editor', 'editor_font_song'); ?></a>
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px '<?php echo lang('home/editor', 'editor_font_hei'); ?>';"><?php echo lang('home/editor', 'editor_font_hei'); ?></a>
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px '<?php echo lang('home/editor', 'editor_font_kai'); ?>';"><?php echo lang('home/editor', 'editor_font_kai'); ?></a>
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px '<?php echo lang('home/editor', 'editor_font_li'); ?>';"><?php echo lang('home/editor', 'editor_font_li'); ?></a>
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px '<?php echo lang('home/editor', 'editor_font_you'); ?>';"><?php echo lang('home/editor', 'editor_font_you'); ?></a>
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px Arial;">Arial</a>
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px 'Arial Narrow';">Arial Narrow</a>
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px 'Arial Black';">Arial Black</a>
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px 'Comic Sans MS';">Comic Sans MS</a>
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px Courier;">Courier</a>
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px System;">System</a>
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px 'Times New Roman';">Times New Roman</a>
<a href="javascript:;" onClick="fontname(this);return false;" class="n" style="font:normal 12px Verdana;">Verdana</a>
</div>
<div id="fontsize" class="eMenu" style="display:none;top:35px;left:26px;width:125px;height:120px">
<a href="javascript:;" onClick="fontsize(1,this);return false;" class="n" style="font-size:xx-small;line-height:120%;"><?php echo lang('home/editor', 'editor_fontsize_xxsmall'); ?></a>
<a href="javascript:;" onClick="fontsize(2,this);return false;" class="n" style="font-size:x-small;line-height:120%;"><?php echo lang('home/editor', 'editor_fontsize_xsmall'); ?></a>
<a href="javascript:;" onClick="fontsize(3,this);return false;" class="n" style="font-size:small;line-height:120%;"><?php echo lang('home/editor', 'editor_fontsize_small'); ?></a>
<a href="javascript:;" onClick="fontsize(4,this);return false;" class="n" style="font-size:medium;line-height:120%;"><?php echo lang('home/editor', 'editor_fontsize_medium'); ?></a>
<a href="javascript:;" onClick="fontsize(5,this);return false;" class="n" style="font-size:large;line-height:120%;"><?php echo lang('home/editor', 'editor_fontsize_large'); ?></a>
</div>
<div id="divList" class="eMenu" style="display:none;top:35px;left:26px;width:64px;height:40px;"><a href="javascript:;" onClick="format('Insertorderedlist');fHide(this.parentNode);return false;" class="n"><?php echo lang('home/editor', 'editor_list_order'); ?></a><a href="javascript:;" onClick="format('Insertunorderedlist');fHide(this.parentNode);return false;" class="n"><?php echo lang('home/editor', 'editor_list_unorder'); ?></a></div>
<div id="divInOut" class="eMenu" style="display:none;top:35px;left:26px;width:64px;height:40px;"><a href="javascript:;" onClick="format('Indent');fHide(this.parentNode);return false;" class="n"><?php echo lang('home/editor', 'editor_indent_inc'); ?></a><a href="javascript:;" onClick="format('Outdent');fHide(this.parentNode);return false;" class="n"><?php echo lang('home/editor', 'editor_indent_dec'); ?></a></div>
<div id="dvForeColor" class="eMenu" style="display:none;top:35px;left:26px;width:90px;">
<a href="javascript:;" onClick="format(gSetColorType,'#800000');return false;" class="n cs fRd1"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_darkred'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#800080');return false;" class="n cs fRd2"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_purple'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#F00000');return false;" class="n cs fRd3"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_red'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#F000F0');return false;" class="n cs fRd4"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_pink'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#000080');return false;" class="n cs fBu1"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_darkblue'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#0000F0');return false;" class="n cs fBu2"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_blue'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#00F0F0');return false;" class="n cs fBu3"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_lakeblue'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#008080');return false;" class="n cs fGn1"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_greenblue'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#008000');return false;" class="n cs fGn2"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_green'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#808000');return false;" class="n cs fGn3"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_olives'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#00F000');return false;" class="n cs fGn4"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_lightgreen'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#F0C000');return false;" class="n cs fYl1"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_orange'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#000000');return false;" class="n cs fBk1"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_black'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#808080');return false;" class="n cs fBk2"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_grey'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#C0C0C0');return false;" class="n cs fBk3"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_silver'); ?></span></a>
<a href="javascript:;" onClick="format(gSetColorType,'#FFFFFF');return false;" class="n cs fWt0"><b class="cb"></b><span><?php echo lang('home/editor', 'editor_color_white'); ?></span></a>
</div>
<div id="editFaceBox" class="eMenu" style="display:none;top:35px;left:26px;width:165px;"></div>
<div id="createUrl" class="eMenu" style="display:none;top:35px;left:26px;width:300px;font-size:12px">
<?php echo lang('home/editor', 'editor_prompt_textlink'); ?>:<br/>
<input type="text" id="insertUrl" name="url" value="http://" onfocus="checkURL(this, 1);" onblur="checkURL(this, 0);" class="t_input" style="width: 190px;"> <input type="button" onclick="createLink();" name="createURL" value="<?php echo lang('home/editor', 'editor_ok'); ?>" class="submit" /> <a href="javascript:;" onclick="fHide($('createUrl'));return false;"><?php echo lang('home/editor', 'editor_cancel'); ?></a>
</div>
<div id="createImg" class="eMenu" style="display:none;top:35px;left:26px;width:300px;font-size:12px">
<?php echo lang('home/editor', 'editor_prompt_imagelink'); ?>:<br/>
<input type="text" id="imgUrl" name="imgUrl" value="http://" onfocus="checkURL(this, 1);" onblur="checkURL(this, 0);" class="t_input" style="width: 190px;" /> <input type="button" onclick="createImg();" name="createURL" value="<?php echo lang('home/editor', 'editor_ok'); ?>" class="submit" /> <a href="javascript:;" onclick="fHide($('createImg'));return false;"><?php echo lang('home/editor', 'editor_cancel'); ?></a>
</div>
<div id="createSwf" class="eMenu" style="display:none;top:35px;left:26px;width:400px;font-size:12px">
<?php echo lang('home/editor', 'editor_prompt_videolink'); ?>:<br/>
<select name="vtype" id="vtype">
<option value="0"><?php echo lang('home/editor', 'editor_prompt_video_flash'); ?></option>
<option value="1"><?php echo lang('home/editor', 'editor_prompt_video_media'); ?></option>
<option value="2"><?php echo lang('home/editor', 'editor_prompt_video_real'); ?></option>
<option value="3"><?php echo lang('home/editor', 'editor_prompt_mp3'); ?></option>
</select>
<input type="text" id="videoUrl" name="videoUrl" value="http://" onfocus="checkURL(this, 1);" onblur="checkURL(this, 0);" class="t_input" style="width: 200px;" />
<input type="button" onclick="createFlash();" name="createURL" value="<?php echo lang('home/editor', 'editor_ok'); ?>" class="submit" />
<a href="javascript:;" onclick="fHide($('createSwf'));return false;"><?php echo lang('home/editor', 'editor_cancel'); ?></a>
</div>
<div id="createPage" class="eMenu" style="display:none;top:35px;left:26px;width:300px;font-size:12px">
<?php echo lang('home/editor', 'editor_prompt_pagetitle'); ?>:<br/>
<input type="text" id="pageTitle" name="pageTitle" value="" class="t_input" style="width: 190px;" /> <input type="button" onclick="pageBreak();" name="createURL" value="<?php echo lang('home/editor', 'editor_ok'); ?>" class="submit" /> <a href="javascript:;" onclick="fHide($('createPage'));return false;"><?php echo lang('home/editor', 'editor_cancel'); ?></a>
</div>
</div>
<div style="height: 100%;padding-top: 31px;box-sizing: border-box;">
<textarea id="dvtext" style="overflow-y:auto; margin-top: 0; padding:0px 4px 4px;width:100%;height:100%;word-wrap:break-word;border:0;display:none;"></textarea>
<div id="dvhtml" style="height:100%;width:100%;overflow:hidden">
<SCRIPT LANGUAGE="JavaScript">
function blank_load() {
var inihtml = '';
var obj = parent.document.getElementById('uchome-ttHtmlEditor');
if(obj) {
inihtml = obj.value;
}
if(! inihtml && !window.Event) {
inihtml = '<div></div>';
}
if(!inihtml) {
inihtml = '&nbsp;';
}
window.frames['HtmlEditor'].document.body.innerHTML = inihtml;
}
document.write('<div id="divEditor" style="padding-left:4px;height:100%;background-color:#fff"><IFRAME class="HtmlEditor" ID="HtmlEditor" name="HtmlEditor" style="height:100%;width:100%;" frameBorder="0" marginHeight=0 marginWidth=0 src="home.php?mod=editor&op=blank&charset=<?php echo $_GET['charset']; ?>" onload="blank_load();"></IFRAME></div>');
</SCRIPT>
<textarea id="sourceEditor" style="overflow-y:auto;padding-left:4px;width:100%;height:100%;word-wrap:break-word;display:none;border:0;"></textarea>
</div>
</div>
</div>
<input type="hidden" name="uchome-editstatus" id="uchome-editstatus" value="html">
</body>
</html>
<?php
} else {
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="<?php echo $_GET['charset']; ?>" />
<meta name="renderer" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Editor</title>
<style>
body { margin: 0; padding: 0; word-wrap: break-word; font-size:14px; line-height:1.8em; font-family: Tahoma, Arial, Helvetica, snas-serif; }
</style>
</head>
<body>
</body>
</html>
<?php
}?>

View File

@@ -0,0 +1,264 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: home_follow.php 33660 2013-07-29 07:51:05Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['setting']['followstatus']) {
showmessage('follow_status_off');
}
if(!$_G['uid']) {
showmessage('login_before_enter_home', null, array(), array('showmsg' => true, 'login' => 1));
}
$dos = array('feed', 'follower', 'following', 'view');
$do = (!empty($_GET['do']) && in_array($_GET['do'], $dos)) ? $_GET['do'] : (!$_GET['uid'] ? 'feed' : 'view');
$page = empty($_GET['page']) ? 1 : intval($_GET['page']);
if($page<1) $page=1;
$perpage = 20;
$start = ($page-1)*$perpage;
$multi = '';
$theurl = 'home.php?mod='.($do == 'view' ? 'space' : 'follow').(!in_array($do, array('feed', 'view')) ? '&do='.$do : '');
$uid = $_GET['uid'] ? $_GET['uid'] : $_G['uid'];
$viewself = $uid == $_G['uid'] ? true : false;
$space = $viewself ? $_G['member'] : getuserbyuid($uid, 1);
if(empty($space)) {
showmessage('follow_visituser_not_exist');
} elseif(in_array($space['groupid'], array(4, 5, 6)) && ($_G['adminid'] != 1 && $space['uid'] != $_G['uid'])) {
dheader("Location:home.php?mod=space&uid=$uid&do=profile");
}
space_merge($space, 'count');
space_merge($space, 'profile');
space_merge($space, 'field_home');
if($viewself) {
$showguide = false;
} else {
$theurl .= $uid ? '&uid='.$uid : '';
$do = $do == 'feed' ? 'view' : $do;
$flag = C::t('home_follow')->fetch_status_by_uid_followuid($_G['uid'], $uid);
}
$showrecommend = true;
$archiver = $primary = 1;
$followerlist = array();
$space['bio'] = cutstr($space['bio'], 200);
$lastviewtime = 0;
if($do == 'feed') {
$view = 'follow';
if(in_array($_GET['view'], array('special', 'follow', 'other'))) {
$view = $_GET['view'];
$theurl .= '&view='.$_GET['view'];
}
$vuid = $view == 'other' ? 0 : $_G['uid'];
$list = getfollowfeed($vuid, $view, false, $start, $perpage);
if((empty($list['feed']) || !is_array($list['feed']) || count($list['feed']) < 20) && (!empty($list['user']) || $view == 'other')) {
$primary = 0;
$alist = getfollowfeed($vuid, $view, true, $start, $perpage);
if(empty($list['feed']) && empty($alist['feed'])) {
$showguide = true;
$archiver = 0;
} else {
$showguide = false;
foreach($alist as $key => $values) {
if($key != 'user') {
foreach($values as $id => $value) {
if(!isset($list[$key][$id])) {
$list[$key][$id] = $value;
}
}
}
}
}
} elseif(empty($list['user']) && $view != 'other') {
$archiver = $primary = 0;
$showguide = false;
}
if($showguide) {
if(!empty($_G['cookie']['lastshowtime'])) {
$time = explode('|', $_G['cookie']['lastshowtime']);
$today = strtotime(dgmdate($_G['timestamp'], 'Y-m-d'));
if($time[0] == $uid && (TIMESTAMP - $time[1] < 86400 && $time[1] > $today)) {
$showguide = false;
}
}
dsetcookie('lastshowtime', $uid.'|'.TIMESTAMP, 86400);
}
if(!empty($_G['cookie']['lastviewtime'])) {
$time = explode('|', $_G['cookie']['lastviewtime']);
if($time[0] == $_G['uid']) {
$lastviewtime = $time[1];
}
} else {
$lastviewtime = getuserprofile('lastactivity');
}
dsetcookie('lastviewtime', $_G['uid'].'|'.TIMESTAMP, 31536000);
if($_G['member']['newprompt_num']['follow']) {
C::t('home_notification')->delete_by_type('follow', $_G['uid']);
helper_notification::update_newprompt($_G['uid'], 'follow');
}
$recommend = $users = array();
if(helper_access::check_module('follow')) {
loadcache('recommend_follow');
if(empty($_G['cache']['recommend_follow']) || !empty($_G['cache']['recommend_follow']) && (empty($_G['cache']['recommend_follow']['users']) || TIMESTAMP - $_G['cache']['recommend_follow']['dateline'] > 86400)) {
foreach(C::t('home_specialuser')->fetch_all_by_status(0, 10) as $value) {
$recommend[$value['uid']] = $value['username'];
}
unset($recommend[$_G['uid']]);
if(count($recommend) < 10) {
$followuser = C::t('common_member_count')->range_by_field(0, 100, 'follower', 'DESC');
$userstatus = C::t('common_member_status')->fetch_all_orderby_lastpost(array_keys($followuser), 0, 20);
$users = C::t('common_member')->fetch_all_username_by_uid(array_keys($userstatus));
}
savecache('recommend_follow', array('dateline'=>TIMESTAMP, 'users'=>$users, 'defaultusers' => $recommend));
} else {
$users = &$_G['cache']['recommend_follow']['users'];
$recommend = &$_G['cache']['recommend_follow']['defaultusers'];
}
if(!empty($users)) {
if(count($recommend) < 10) {
$randkeys = array_rand($users, min(count($users), 11 - count($recommend)));
foreach($randkeys as $ruid) {
if($ruid != $_G['uid']) {
$recommend[$ruid] = $users[$ruid];
}
}
}
}
if($do == 'following') {
foreach($list as $ruid => $user) {
if(isset($recommend[$ruid])) {
unset($recommend[$ruid]);
}
}
}
if($recommend) {
$users = C::t('home_follow')->fetch_all_by_uid_followuid($_G['uid'], array_keys($recommend));
foreach($users as $ruid => $user) {
if(isset($recommend[$ruid])) {
unset($recommend[$ruid]);
}
}
}
}
$navactives = array('feed' => ' class="a"');
$actives = array($view => ' class="a"');
list($seccodecheck, $secqaacheck) = seccheck('publish');
} elseif($do == 'view') {
$list = getfollowfeed($uid, 'self', false, $start, $perpage);
if(empty($list['feed'])) {
$primary = 0;
$list = getfollowfeed($uid, 'self', true, $start, $perpage);
if(empty($list['user'])) {
$archiver = 0;
}
}
if(!isset($_G['cache']['forums'])) {
loadcache('forums');
}
if(helper_access::check_module('follow')) {
$followerlist = C::t('home_follow')->fetch_all_following_by_uid($uid, 0, 9);
}
list($seccodecheck, $secqaacheck) = seccheck('publish');
} elseif($do == 'follower') {
$count = C::t('home_follow')->count_follow_user($uid, 1);
if($viewself && !empty($_G['member']['newprompt_num']['follower'])) {
$newfollower = C::t('home_notification')->fetch_all_by_uid($uid, -1, 'follower', 0, $_G['member']['newprompt_num']['follower']);
$newfollower_list = array();
foreach($newfollower as $val) {
$newfollower_list[] = $val['from_id'];
}
C::t('home_notification')->delete_by_type('follower', $_G['uid']);
helper_notification::update_newprompt($_G['uid'], 'follower');
}
if($count) {
$list = C::t('home_follow')->fetch_all_follower_by_uid($uid, $start, $perpage);
$multi = multi($count, $perpage, $page, $theurl);
}
if(helper_access::check_module('follow')) {
$followerlist = C::t('home_follow')->fetch_all_following_by_uid($uid, 0, 9);
}
$navactives = array($do => ' class="a"');
} elseif($do == 'following') {
$count = C::t('home_follow')->count_follow_user($uid);
if($count) {
$status = $_GET['status'] ? 1 : 0;
$list = C::t('home_follow')->fetch_all_following_by_uid($uid, $status, $start, $perpage);
$multi = multi($count, $perpage, $page, $theurl);
}
if(helper_access::check_module('follow')) {
$followerlist = C::t('home_follow')->fetch_all_follower_by_uid($uid, 9);
}
$navactives = array($do => ' class="a"');
}
if(($do == 'follower' || $do == 'following') && $list) {
$uids = array_keys($list);
$fieldhome = C::t('common_member_field_home')->fetch_all($uids);
foreach($fieldhome as $fuid => $val) {
$list[$fuid]['recentnote'] = $val['recentnote'];
}
$memberinfo = C::t('common_member_count')->fetch_all($uids);
$memberprofile = C::t('common_member_profile')->fetch_all($uids);
if(!$viewself) {
$myfollow = C::t('home_follow')->fetch_all_by_uid_followuid($_G['uid'], $uids);
foreach($uids as $muid) {
$list[$muid]['mutual'] = 0;
if(!empty($myfollow[$muid])) {
$list[$muid]['mutual'] = $myfollow[$muid]['mutual'] ? 1 : -1;
}
}
}
$specialfollow = C::t('home_follow')->fetch_all_following_by_uid($uid, 1, 10);
}
if($viewself) {
if(!isset($_G['cache']['forums'])) {
loadcache('forums');
}
$fields = C::t('forum_forumfield')->fetch_all_by_fid(array_keys($_G['cache']['forums']));
foreach($fields as $fid => $field) {
if(!empty($field['threadsorts'])) {
unset($_G['cache']['forums'][$fid]);
}
}
require_once libfile('function/forumlist');
$forumlist = forumselect();
$defaultforum = $_G['setting']['followforumid'] ? $_G['cache']['forums'][$_G['setting']['followforumid']] : array();
require_once libfile('function/upload');
$swfconfig = getuploadconfig($_G['uid']);
}
if($do == 'feed') {
$navigation = ' <em>&rsaquo;</em> <a href="home.php?mod=follow&view='.$view.'">'.lang('space', 'follow_view_'.$view).'</a>';
$navtitle = lang('space', 'follow_view_'.$view);
} elseif($do == 'view') {
$navigation = ' <em>&rsaquo;</em> <a href="home.php?mod=space&uid='.$uid.'">'.$space['username'].'</a>';
if($type != 'feed') {
$navigation .= ' <em>&rsaquo;</em> '.lang('space', 'follow_view_type_feed').'</a>';
}
$navtitle = lang('space', 'follow_view_feed', array('who' => $space['username']));
} else {
$navigation = ' <em>&rsaquo;</em> <a href="home.php?mod=space&uid='.$uid.'">'.$space['username'].'</a> <em>&rsaquo;</em> '.lang('space', 'follow_view_'.($viewself?'my':'do').'_'.$do);
$navtitle = lang('space', 'follow_view_'.($viewself?'my':'do').'_'.$do);
}
$metakeywords = $navtitle;
$metadescription = $navtitle;
$navtitle = helper_seo::get_title_page($navtitle, $_G['page']);
include template('diy:home/follow_feed');
?>

View File

@@ -0,0 +1,153 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: home_invite.php 25756 2011-11-22 02:47:45Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$id = intval($_GET['id']);
$uid = intval($_GET['u']);
$acceptconfirm = false;
if($_G['setting']['regstatus'] < 2) {
showmessage('not_open_invite', '', array(), array('return' => true));
}
if($_G['uid']) {
if($_GET['accept'] == 'yes') {
$cookies = empty($_G['cookie']['invite_auth'])?array():explode(',', $_G['cookie']['invite_auth']);
if(empty($cookies)) {
showmessage('invite_code_error', '', array(), array('return' => true));
}
if(count($cookies) == 3) {
$uid = intval($cookies[0]);
$_GET['c'] = $cookies[1];
} else {
$id = intval($cookies[0]);
$_GET['c'] = $cookies[1];
}
$acceptconfirm = true;
} elseif($_GET['accept'] == 'no') {
dsetcookie('invite_auth', '');
showmessage('invite_accept_no', 'home.php');
}
}
if($id) {
$invite = C::t('common_invite')->fetch($id);
if(empty($invite) || $invite['code'] != $_GET['c']) {
showmessage('invite_code_error', '', array(), array('return' => true));
}
if($invite['fuid'] && $invite['fuid'] != $_G['uid']) {
showmessage('invite_code_fuid', '', array(), array('return' => true));
}
if($invite['endtime'] && $_G['timestamp'] > $invite['endtime']) {
C::t('common_invite')->delete($id);
showmessage('invite_code_endtime_error', '', array(), array('return' => true));
}
$uid = $invite['uid'];
$cookievar = "$id,{$invite['code']}";
} elseif ($uid) {
$id = 0;
$invite_code = helper_invite::generate_key($uid);
if($_GET['c'] !== $invite_code) {
showmessage('invite_code_error', '', array(), array('return' => true));
}
$inviteuser = getuserbyuid($uid);
loadcache('usergroup_'.$inviteuser['groupid']);
if(!empty($_G['cache']['usergroup_'.$inviteuser['groupid']]) && (!$_G['cache']['usergroup_'.$inviteuser['groupid']]['allowinvite'] || $_G['cache']['usergroup_'.$inviteuser['groupid']]['inviteprice'])) {
showmessage('invite_code_error', '', array(), array('return' => true));
}
$cookievar = "$uid,$invite_code,0";
} else {
showmessage('invite_code_error', '', array(), array('return' => true));
}
$space = getuserbyuid($uid);
if(empty($space)) {
showmessage('space_does_not_exist', '', array(), array('return' => true));
}
$jumpurl = 'home.php?mod=space&uid='.$uid;
if($acceptconfirm) {
dsetcookie('invite_auth', '');
if($_G['uid'] == $uid) {
showmessage('should_not_invite_your_own', '', array(), array('return' => true));
}
require_once libfile('function/friend');
if(friend_check($uid)) {
showmessage('you_have_friends', $jumpurl);
}
$fields = C::t('common_member_field_home')->fetch($uid);
if(!$fields['allowasfriend']) {
showmessage('is_blacklist');
}
require_once libfile('function/spacecp');
if(isblacklist($uid)) {
showmessage('is_blacklist');
}
friend_make($space['uid'], $space['username']);
if($id) {
C::t('common_invite')->update($id, array('fuid'=>$_G['uid'], 'fusername'=>$_G['username'], 'regdateline' => $_G['timestamp'], 'status' => 2));
notification_add($uid, 'friend', 'invite_friend', array('actor' => '<a href="home.php?mod=space&uid='.$_G['uid'].'" target="_blank">'.$_G['username'].'</a>'), 1);
}
space_merge($space, 'field_home');
if(is_array($space['privacy']) && !empty($space['privacy']['feed']['invite'])) {
require_once libfile('function/feed');
$tite_data = array('username' => '<a href="home.php?mod=space&uid='.$_G['uid'].'">'.$_G['username'].'</a>');
feed_add('friend', 'feed_invite', $tite_data, '', array(), '', array(), array(), '', '', '', 0, 0, '', $space['uid'], $space['username']);
}
if($_G['setting']['inviteconfig']['inviteaddcredit']) {
updatemembercount($_G['uid'],
array($_G['setting']['inviteconfig']['inviterewardcredit'] => $_G['setting']['inviteconfig']['inviteaddcredit']));
}
if($_G['setting']['inviteconfig']['invitedaddcredit']) {
updatemembercount($uid,
array($_G['setting']['inviteconfig']['inviterewardcredit'] => $_G['setting']['inviteconfig']['invitedaddcredit']));
}
include_once libfile('function/stat');
updatestat('invite');
showmessage('invite_friend_ok', $jumpurl);
} else {
dsetcookie('invite_auth', $cookievar, 604800);
}
space_merge($space, 'count');
space_merge($space, 'field_home');
space_merge($space, 'profile');
$flist = array();
$query = C::t('home_friend')->fetch_all_by_uid($uid, 0, 12, true);
foreach($query as $value) {
$value['uid'] = $value['fuid'];
$value['username'] = $value['fusername'];
$flist[] = $value;
}
$jumpurl = urlencode($jumpurl);
include_once template('home/invite');
?>

View File

@@ -0,0 +1,524 @@
<?php
/*
[Discuz!] (C)2001-2099 Comsenz Inc111.
This is NOT a freeware, use is subject to license terms
$Id: home_magic.php 33875 2013-08-26 07:33:49Z andyzheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['uid']) {
showmessage('not_loggedin', NULL, array(), array('login' => 1));
}
if(!$_G['setting']['creditstransextra'][3]) {
showmessage('credits_transaction_disabled');
} elseif(!$_G['setting']['magicstatus']) {
showmessage('magics_close');
}
require_once libfile('function/magic');
loadcache('magics');
$_G['mnid'] = 'mn_common';
$magiclist = array();
$_G['tpp'] = 16;
$page = max(1, intval($_GET['page']));
$action = $_GET['action'];
$operation = $_GET['operation'];
$start_limit = ($page - 1) * $_G['tpp'];
$_GET['idtype'] = dhtmlspecialchars($_GET['idtype']);
$comma = $typeadd = $filteradd = $forumperm = $targetgroupperm = '';
$magicarray = is_array($_G['cache']['magics']) ? $_G['cache']['magics'] : array();
if(!$_G['uid'] && ($operation || $action == 'mybox')) {
showmessage('not_loggedin', NULL, array(), array('login' => 1));
}
if(!$_G['group']['allowmagics']) {
showmessage('magics_nopermission');
}
$totalweight = getmagicweight($_G['uid'], $magicarray);
$allowweight = $_G['group']['maxmagicsweight'] - $totalweight;
$location = 0;
if(empty($action) && !empty($_GET['mid'])) {
$_GET['magicid'] = C::t('common_member_magic')->fetch_magicid_by_identifier($_G['uid'], $_GET['mid']);
if(!$_GET['magicid']) {
$magic = C::t('common_magic')->fetch_by_identifier($_GET['mid']);
if(!$magic['price'] && $magic['num']) {
getmagic($magic['magicid'], 1, $magic['weight'], $totalweight, $_G['uid'], $_G['group']['maxmagicsweight']);
updatemagiclog($magic['magicid'], '1', 1, $magic['price'].'|'.$magic['credit'], $_G['uid']);
C::t('common_magic')->update_salevolume($magic['magicid'], 1);
updatemembercount($_G['uid'], array($magic['credit'] => -0), true, 'BMC', $magic['magicid']);
$_GET['magicid'] = $magic['magicid'];
}
}
if($_GET['magicid']) {
$action = 'mybox';
$operation = 'use';
} else {
$action = 'shop';
$operation = 'buy';
$location = 1;
}
}
$action = empty($action) ? 'shop' : $action;
$actives[$action] = ' class="a"';
if($action == 'shop') {
$operation = empty($operation) ? 'index' : $operation;
if(in_array($operation, array('index', 'hot'))) {
$subactives[$operation] = 'class="a"';
$filteradd = '';
if($operation == 'index') {
$navtitle = lang('core', 'title_magics_shop');
} else {
$navtitle = lang('core', 'title_magics_hot');
}
$magiccount = C::t('common_magic')->count_page($operation);
$multipage = multi($magiccount, $_G['tpp'], $page, "home.php?mod=magic&action=shop&operation=$operation");
foreach(C::t('common_magic')->fetch_all_page($operation, $start_limit, $_G['tpp']) as $magic) {
$magic['discountprice'] = $_G['group']['magicsdiscount'] ? intval($magic['price'] * ($_G['group']['magicsdiscount'] / 10)) : intval($magic['price']);
$eidentifier = explode(':', $magic['identifier']);
if(count($eidentifier) > 1) {
$magic['pic'] = 'source/plugin/'.$eidentifier[0].'/magic/magic_'.$eidentifier[1].'.gif';
} else {
$magic['pic'] = STATICURL.'image/magic/'.strtolower($magic['identifier']).'.gif';
}
$magiclist[] = $magic;
}
$magiccredits = array();
foreach($magicarray as $magic) {
$magiccredits[$magic['credit']] = $magic['credit'];
}
} elseif($operation == 'buy') {
$magic = C::t('common_magic')->fetch_by_identifier($_GET['mid']);
if(!$magic || !$magic['available']) {
showmessage('magics_nonexistence');
}
$magicperm = dunserialize($magic['magicperm']);
$useperm = (strstr($magicperm['usergroups'], "\t{$_G['groupid']}\t") || empty($magicperm['usergroups'])) ? '1' : '0';
if(!$useperm) {
showmessage('magics_use_nopermission');
}
$querystring = array();
foreach($_GET as $k => $v) {
$querystring[] = rawurlencode($k).'='.rawurlencode($v);
}
$querystring = implode('&', $querystring);
$eidentifier = explode(':', $magic['identifier']);
if(count($eidentifier) > 1) {
$magicfile = './source/plugin/'.$eidentifier[0].'/magic/magic_'.$eidentifier[1].'.php';
$magicclass = 'magic_'.$eidentifier[1];
} else {
$magicfile = './source/class/magic/magic_'.$magic['identifier'].'.php';
$magicclass = 'magic_'.$magic['identifier'];
}
if(!@include_once DISCUZ_ROOT.$magicfile) {
showmessage('magics_filename_nonexistence', '', array('file' => $magicfile));
}
$magicclass = new $magicclass;
$magicclass->magic = $magic;
$magicclass->parameters = $magicperm;
if(method_exists($magicclass, 'buy')) {
$magicclass->buy();
}
$magic['discountprice'] = $_G['group']['magicsdiscount'] ? intval($magic['price'] * ($_G['group']['magicsdiscount'] / 10)) : intval($magic['price']);
if(count($eidentifier) > 1) {
$magic['pic'] = 'source/plugin/'.$eidentifier[0].'/magic/magic_'.$eidentifier[1].'.gif';
} else {
$magic['pic'] = STATICURL.'image/magic/'.strtolower($magic['identifier']).'.gif';
}
$magic['credit'] = $magic['credit'] ? $magic['credit'] : $_G['setting']['creditstransextra'][3];
$useperoid = magic_peroid($magic, $_G['uid']);
if(!submitcheck('operatesubmit')) {
if($magicperm['targetgroups']) {
loadcache('usergroups');
foreach(explode("\t", $magicperm['targetgroups']) as $_G['groupid']) {
if(isset($_G['cache']['usergroups'][$_G['groupid']])) {
$targetgroupperm .= $comma.$_G['cache']['usergroups'][$_G['groupid']]['grouptitle'];
$comma = '&nbsp;';
}
}
}
if($magicperm['forum']) {
loadcache('forums');
foreach(explode("\t", $magicperm['forum']) as $fid) {
if(isset($_G['cache']['forums'][$fid])) {
$forumperm .= $comma.'<a href="forum.php?mod=forumdisplay&fid='.$fid.'" target="_blank">'.$_G['cache']['forums'][$fid]['name'].'</a>';
$comma = '&nbsp;';
}
}
}
include template('home/space_magic_shop_opreation');
dexit();
} else {
$magicnum = intval($_GET['magicnum']);
$magic['weight'] = $magic['weight'] * $magicnum;
$totalprice = $magic['discountprice'] * $magicnum;
if(getuserprofile('extcredits'.$magic['credit']) < $totalprice) {
if($_G['setting']['ec_ratio'] && $_G['setting']['creditstrans'][0] == $magic['credit']) {
showmessage('magics_credits_no_enough_and_charge', '', array('credit' => $_G['setting']['extcredits'][$magic['credit']]['title']));
} else {
showmessage('magics_credits_no_enough', '', array('credit' => $_G['setting']['extcredits'][$magic['credit']]['title']));
}
} elseif($magic['num'] < $magicnum) {
showmessage('magics_num_no_enough');
} elseif(!$magicnum || $magicnum < 0) {
showmessage('magics_num_invalid');
}
getmagic($magic['magicid'], $magicnum, $magic['weight'], $totalweight, $_G['uid'], $_G['group']['maxmagicsweight']);
updatemagiclog($magic['magicid'], '1', $magicnum, $magic['price'].'|'.$magic['credit'], $_G['uid']);
C::t('common_magic')->update_salevolume($magic['magicid'], $magicnum);
updatemembercount($_G['uid'], array($magic['credit'] => -$totalprice), true, 'BMC', $magic['magicid']);
showmessage('magics_buy_succeed', 'home.php?mod=magic&action=mybox', array('magicname' => $magic['name'], 'num' => $magicnum, 'credit' => $totalprice.' '.$_G['setting']['extcredits'][$magic['credit']]['unit'].$_G['setting']['extcredits'][$magic['credit']]['title']));
}
} elseif($operation == 'give') {
if($_G['group']['allowmagics'] < 2) {
showmessage('magics_nopermission');
}
$magic = C::t('common_magic')->fetch_by_identifier($_GET['mid']);
if(!$magic || !$magic['available']) {
showmessage('magics_nonexistence');
}
$magic['discountprice'] = $_G['group']['magicsdiscount'] ? intval($magic['price'] * ($_G['group']['magicsdiscount'] / 10)) : intval($magic['price']);
$eidentifier = explode(':', $magic['identifier']);
if(count($eidentifier) > 1) {
$magic['pic'] = 'source/plugin/'.$eidentifier[0].'/magic/magic_'.$eidentifier[1].'.gif';
} else {
$magic['pic'] = STATICURL.'image/magic/'.strtolower($magic['identifier']).'.gif';
}
if(!submitcheck('operatesubmit')) {
include libfile('function/friend');
$buddyarray = friend_list($_G['uid'], 20);
include template('home/space_magic_shop_opreation');
dexit();
} else {
$magicnum = intval($_GET['magicnum']);
$totalprice = $magic['price'] * $magicnum;
if(getuserprofile('extcredits'.$magic['credit']) < $totalprice) {
if($_G['setting']['ec_ratio'] && $_G['setting']['creditstrans'][0] == $magic['credit']) {
showmessage('magics_credits_no_enough_and_charge', '', array('credit' => $_G['setting']['extcredits'][$magic['credit']]['title']));
} else {
showmessage('magics_credits_no_enough', '', array('credit' => $_G['setting']['extcredits'][$magic['credit']]['title']));
}
} elseif($magic['num'] < $magicnum) {
showmessage('magics_num_no_enough');
} elseif(!$magicnum || $magicnum < 0) {
showmessage('magics_num_invalid');
}
$toname = dhtmlspecialchars(trim($_GET['tousername']));
if(!$toname) {
showmessage('magics_username_nonexistence');
}
$givemessage = dhtmlspecialchars(trim($_GET['givemessage']));
givemagic($toname, $magic['magicid'], $magicnum, $magic['num'], $totalprice, $givemessage, $magicarray);
C::t('common_magic')->update_salevolume($magic['magicid'], $magicnum);
updatemembercount($_G['uid'], array($magic['credit'] => -$totalprice), true, 'BMC', $magicid);
showmessage('magics_buygive_succeed', 'home.php?mod=magic&action=shop', array('magicname' => $magic['name'], 'toname' => $toname, 'num' => $magicnum, 'credit' => $_G['setting']['extcredits'][$magic['credit']]['title'].' '.$totalprice.' '.$_G['setting']['extcredits'][$magic['credit']]['unit']), array('locationtime' => true));
}
} else {
showmessage('undefined_action');
}
} elseif($action == 'mybox') {
if(empty($operation)) {
$pid = !empty($_GET['pid']) ? intval($_GET['pid']) : 0;
$magiccount = C::t('common_member_magic')->count_by_uid($_G['uid']);
$multipage = multi($magiccount, $_G['tpp'], $page, "home.php?mod=magic&action=mybox&pid=$pid$typeadd");
$query = C::t('common_member_magic')->fetch_all_magic($_G['uid'], null, $start_limit, $_G['tpp']);
foreach($query as $value) {
$magicids[] = $value['magicid'];
}
$magicm = C::t('common_magic')->fetch_all($magicids);
foreach($query as $curmagicid => $mymagic) {
$mymagic = $mymagic + $magicm[$mymagic['magicid']];
$eidentifier = explode(':', $mymagic['identifier']);
if(count($eidentifier) > 1) {
$mymagic['pic'] = 'source/plugin/'.$eidentifier[0].'/magic/magic_'.$eidentifier[1].'.gif';
} else {
$mymagic['pic'] = STATICURL.'image/magic/'.strtolower($mymagic['identifier']).'.gif';
}
$mymagic['weight'] = intval($mymagic['weight'] * $mymagic['num']);
$mymagic['type'] = $mymagic['type'];
$mymagiclist[] = $mymagic;
}
$navtitle = lang('core', 'title_magics_user');
} else {
$magicid = intval($_GET['magicid']);
$membermagic = C::t('common_member_magic')->fetch_magic($_G['uid'], $magicid);
$magic = $membermagic + C::t('common_magic')->fetch($magicid);
if(!$membermagic) {
showmessage('magics_nonexistence');
} elseif(!$magic['num']) {
C::t('common_member_magic')->delete_magic($_G['uid'], $magic['magicid']);
showmessage('magics_nonexistence');
}
$magicperm = dunserialize($magic['magicperm']);
$eidentifier = explode(':', $magic['identifier']);
if(count($eidentifier) > 1) {
$magic['pic'] = 'source/plugin/'.$eidentifier[0].'/magic/magic_'.$eidentifier[1].'.gif';
} else {
$magic['pic'] = STATICURL.'image/magic/'.strtolower($magic['identifier']).'.gif';
}
if($operation == 'use') {
$useperm = (strstr($magicperm['usergroups'], "\t{$_G['groupid']}\t") || empty($magicperm['usergroups'])) ? '1' : '0';
if(!$useperm) {
showmessage('magics_use_nopermission');
}
if($magic['num'] <= 0) {
C::t('common_member_magic')->delete_magic($_G['uid'], $magic['magicid']);
showmessage('magics_nopermission');
}
$magic['weight'] = intval($magicarray[$magic['magicid']]['weight'] * $magic['num']);
if(count($eidentifier) > 1) {
$magicfile = './source/plugin/'.$eidentifier[0].'/magic/magic_'.$eidentifier[1].'.php';
$magicclass = 'magic_'.$eidentifier[1];
} else {
$magicfile = './source/class/magic/magic_'.$magic['identifier'].'.php';
$magicclass = 'magic_'.$magic['identifier'];
}
if(!@include_once DISCUZ_ROOT.$magicfile) {
showmessage('magics_filename_nonexistence', '', array('file' => $magicfile));
}
$magicclass = new $magicclass;
$magicclass->magic = $magic;
$magicclass->parameters = $magicperm;
$useperoid = magic_peroid($magic, $_G['uid']);
if(submitcheck('usesubmit')) {
if(discuz_process::islocked('magiclock_'.$_G['uid'].'_'.$magicid, 0, 1)) {
showmessage('magics_locked');
}
if($useperoid !== true && $useperoid <= 0) {
showmessage('magics_outofperoid_'.$magic['useperoid'], '', array('usenum' => $magic['usenum']));
}
if(method_exists($magicclass, 'usesubmit')) {
$magicclass->usesubmit();
}
dexit();
}
include template('home/space_magic_mybox_opreation');
dexit();
} elseif($operation == 'sell') {
$magic['price'] = $_G['group']['magicsdiscount'] ? intval($magic['price'] * ($_G['group']['magicsdiscount'] / 10)) : intval($magic['price']);
$discountprice = floor($magic['price'] * $_G['setting']['magicdiscount'] / 100);
if(!submitcheck('operatesubmit')) {
include template('home/space_magic_mybox_opreation');
dexit();
} else {
if(discuz_process::islocked('magiclock_'.$_G['uid'].'_'.$magicid, 0, 1)) {
showmessage('magics_locked');
}
$magicnum = intval($_GET['magicnum']);
if(!$magicnum || $magicnum < 0) {
showmessage('magics_num_invalid');
} elseif($magicnum > $magic['num']) {
showmessage('magics_amount_no_enough');
}
usemagic($magic['magicid'], $magic['num'], $magicnum);
updatemagiclog($magic['magicid'], '2', $magicnum, '0', 0, 'sell');
$totalprice = $discountprice * $magicnum;
updatemembercount($_G['uid'], array($magic['credit'] => $totalprice));
showmessage('magics_sell_succeed', 'home.php?mod=magic&action=mybox', array('magicname' => $magic['name'], 'num' => $magicnum, 'credit' => $totalprice.' '.$_G['setting']['extcredits'][$magic['credit']]['unit'].$_G['setting']['extcredits'][$magic['credit']]['title']));
}
} elseif($operation == 'drop') {
if(!submitcheck('operatesubmit')) {
include template('home/space_magic_mybox_opreation');
dexit();
} else {
$magicnum = intval($_GET['magicnum']);
if(!$magicnum || $magicnum < 0) {
showmessage('magics_num_invalid');
} elseif($magicnum > $magic['num']) {
showmessage('magics_amount_no_enough');
}
usemagic($magic['magicid'], $magic['num'], $magicnum);
updatemagiclog($magic['magicid'], '2', $magicnum, '0', 0, 'drop');
showmessage('magics_drop_succeed', 'home.php?mod=magic&action=mybox', array('magicname' => $magic['name'], 'num' => $magicnum), array('locationtime' => true));
}
} elseif($operation == 'give') {
if($_G['group']['allowmagics'] < 2) {
showmessage('magics_nopermission');
}
if(!submitcheck('operatesubmit')) {
include libfile('function/friend');
$buddyarray = friend_list($_G['uid'], 20);
include template('home/space_magic_mybox_opreation');
dexit();
} else {
if($_G['setting']['submitlock'] && discuz_process::islocked('magiclock_'.$_G['uid'].'_'.$magicid, 0, 1)) {
showmessage('magics_locked');
}
$magicnum = intval($_GET['magicnum']);
$toname = dhtmlspecialchars(trim($_GET['tousername']));
if(!$toname) {
showmessage('magics_username_nonexistence');
} elseif($magicnum < 0 || $magic['num'] < $magicnum) {
showmessage('magics_num_invalid');
}
$givemessage = dhtmlspecialchars(trim($_GET['givemessage']));
givemagic($toname, $magic['magicid'], $magicnum, $magic['num'], '0', $givemessage, $magicarray);
}
} else {
showmessage('undefined_action');
}
}
} elseif($action == 'log') {
$subactives[$operation] = 'class="a"';
$loglist = array();
if($operation == 'uselog') {
$count = C::t('common_magiclog')->count_by_uid_action($_G['uid'], 2);
if($count) {
$multipage = multi($count, $_G['tpp'], $page, 'home.php?mod=magic&action=log&amp;operation=uselog');
$logs = C::t('common_magiclog')->fetch_all_by_uid_action($_G['uid'], 2, $start_limit, $_G['tpp']);
$luids=array();
foreach($luids as $log) {
$luids[$log['uid']] = $log['uid'];
}
foreach($logs as $log) {
$log['dateline'] = dgmdate($log['dateline'], 'u');
$log['name'] = $magicarray[$log['magicid']]['name'];
$loglist[] = $log;
}
}
} elseif($operation == 'buylog') {
$count = C::t('common_magiclog')->count_by_uid_action($_G['uid'], 1);
if($count) {
$multipage = multi($count, $_G['tpp'], $page, 'home.php?mod=magic&action=log&amp;operation=buylog');
foreach(C::t('common_magiclog')->fetch_all_by_uid_action($_G['uid'], 1, $start_limit, $_G['tpp']) as $log) {
$log['credit'] = $log['credit'] ? $log['credit'] : $_G['setting']['creditstransextra'][3];
$log['dateline'] = dgmdate($log['dateline'], 'u');
$log['name'] = $magicarray[$log['magicid']]['name'];
$loglist[] = $log;
}
}
} elseif($operation == 'givelog') {
$count = C::t('common_magiclog')->count_by_uid_action($_G['uid'], 3);
if($count) {
$multipage = multi($count, $_G['tpp'], $page, 'home.php?mod=magic&action=log&amp;operation=givelog');
$uids = null;
$query = C::t('common_magiclog')->fetch_all_by_uid_action($_G['uid'], 3, $start_limit, $_G['tpp']);
foreach($query as $log) {
$uids[] = $log['targetuid'];
}
if($uids != null) {
$memberdata = C::t('common_member')->fetch_all_username_by_uid($uids);
}
foreach($query as $log) {
$log['username'] = $memberdata[$log['targetuid']];
$log['dateline'] = dgmdate($log['dateline'], 'u');
$log['name'] = $magicarray[$log['magicid']]['name'];
$loglist[] = $log;
}
}
} elseif($operation == 'receivelog') {
$count = C::t('common_magiclog')->count_by_targetuid_action($_G['uid'], 3);
if($count) {
$multipage = multi($count, $_G['tpp'], $page, 'home.php?mod=magic&action=log&amp;operation=receivelog');
$logs = C::t('common_magiclog')->fetch_all_by_targetuid_action($_G['uid'], 3, $start_limit, $_G['tpp']);
$luids = array();
foreach($logs as $log) {
$luids[$log['uid']] = $log['uid'];
}
$members = C::t('common_member')->fetch_all_username_by_uid($luids);
foreach($logs as $log) {
$log['username'] = $members[$log['uid']];
$log['dateline'] = dgmdate($log['dateline'], 'u');
$log['name'] = $magicarray[$log['magicid']]['name'];
$loglist[] = $log;
}
}
}
$navtitle = lang('core', 'title_magics_log');
} else {
showmessage('undefined_action');
}
include template('home/space_magic');
?>

View File

@@ -0,0 +1,186 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: home_medal.php 28887 2012-03-16 10:17:38Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['setting']['medalstatus']) {
showmessage('medal_status_off');
}
loadcache('medals');
if(!$_G['uid'] && $_GET['action']) {
showmessage('not_loggedin', NULL, array(), array('login' => 1));
}
$_G['mnid'] = 'mn_common';
$medallist = $medallogs = array();
$tpp = 10;
$page = max(1, intval($_GET['page']));
$start_limit = ($page - 1) * $tpp;
if(empty($_GET['action'])) {
include libfile('function/forum');
$medalcredits = array();
foreach(C::t('forum_medal')->fetch_all_data(1) as $medal) {
$medal['permission'] = medalformulaperm(serialize(array('medal' => dunserialize($medal['permission']))), $medal['type']);
$medal['image'] = preg_match('/^https?:\/\//is', $medal['image']) ? $medal['image'] : STATICURL.'image/common/'.$medal['image'];
if($medal['price']) {
$medal['credit'] = $medal['credit'] ? $medal['credit'] : $_G['setting']['creditstransextra'][3];
$medalcredits[$medal['credit']] = $medal['credit'];
}
$medallist[$medal['medalid']] = $medal;
}
$memberfieldforum = C::t('common_member_field_forum')->fetch($_G['uid']);
$membermedal = $memberfieldforum['medals'] ? explode("\t", $memberfieldforum['medals']) : array();
$membermedal = array_map('intval', $membermedal);
$lastmedals = $uids = array();
foreach(C::t('forum_medallog')->fetch_all_lastmedal(10) as $id => $lastmedal) {
$lastmedal['dateline'] = dgmdate($lastmedal['dateline'], 'u');
$lastmedals[$id] = $lastmedal;
$uids[] = $lastmedal['uid'];
}
$lastmedalusers = C::t('common_member')->fetch_all($uids);
$mymedals = C::t('common_member_medal')->fetch_all_by_uid($_G['uid']);
$mymedals = array_keys($mymedals);
$applylogs = C::t('forum_medallog')->fetch_all_by_type(2);
foreach ($applylogs as $id => $log) {
$log['uid'] == $_G['uid'] && $mymedals[$log['medalid']] = $log['medalid'];
}
} elseif($_GET['action'] == 'confirm') {
include libfile('function/forum');
$medal = C::t('forum_medal')->fetch($_GET['medalid']);
$medal['permission'] = medalformulaperm(serialize(array('medal' => dunserialize($medal['permission']))), $medal['type']);
$medal['image'] = preg_match('/^https?:\/\//is', $medal['image']) ? $medal['image'] : STATICURL.'image/common/'.$medal['image'];
if($medal['price']) {
$medal['credit'] = $medal['credit'] ? $medal['credit'] : $_G['setting']['creditstransextra'][3];
$medalcredits[$medal['credit']] = $medal['credit'];
}
include template('home/space_medal_float');
} elseif($_GET['action'] == 'apply' && submitcheck('medalsubmit')) {
$medalid = intval($_GET['medalid']);
$_G['forum_formulamessage'] = $_G['forum_usermsg'] = $medalnew = '';
$medal = C::t('forum_medal')->fetch($medalid);
if(!$medal['type']) {
showmessage('medal_apply_invalid');
}
if(C::t('common_member_medal')->count_by_uid_medalid($_G['uid'], $medalid)) {
showmessage('medal_apply_existence', 'home.php?mod=medal');
}
$applysucceed = FALSE;
$medalpermission = $medal['permission'] ? dunserialize($medal['permission']) : array();
if($medalpermission[0] || $medalpermission['usergroupallow']) {
include libfile('function/forum');
medalformulaperm(serialize(array('medal' => $medalpermission)), $medal['type']);
if($_G['forum_formulamessage']) {
showmessage('medal_permforum_nopermission', 'home.php?mod=medal', array('formulamessage' => $_G['forum_formulamessage'], 'usermsg' => $_G['forum_usermsg']));
} else {
$applysucceed = TRUE;
}
} else {
$applysucceed = TRUE;
}
if($applysucceed) {
$expiration = empty($medal['expiration'])? 0 : TIMESTAMP + $medal['expiration'] * 86400;
if($medal['type'] == 1) {
if($medal['price']) {
$medal['credit'] = $medal['credit'] ? $medal['credit'] : $_G['setting']['creditstransextra'][3];
if($medal['price'] > getuserprofile('extcredits'.$medal['credit'])) {
showmessage('medal_not_get_credit', '', array('credit' => $_G['setting']['extcredits'][$medal['credit']]['title']));
}
updatemembercount($_G['uid'], array($medal['credit'] => -$medal['price']), true, 'BME', $medal['medalid']);
}
$memberfieldforum = C::t('common_member_field_forum')->fetch($_G['uid']);
$usermedal = $memberfieldforum;
unset($memberfieldforum);
$medal['medalid'] = $medal['medalid'].(empty($expiration) ? '' : '|'.$expiration);
$medalnew = $usermedal['medals'] ? $usermedal['medals']."\t".$medal['medalid'] : $medal['medalid'];
C::t('common_member_field_forum')->update($_G['uid'], array('medals' => $medalnew));
C::t('common_member_medal')->insert(array('uid' => $_G['uid'], 'medalid' => $medal['medalid']), 0, 1);
$medalmessage = 'medal_get_succeed';
} else {
if(C::t('forum_medallog')->count_by_verify_medalid($_G['uid'], $medal['medalid'])) {
showmessage('medal_apply_existence', 'home.php?mod=medal');
}
$medalmessage = 'medal_apply_succeed';
manage_addnotify('verifymedal');
}
C::t('forum_medallog')->insert(array(
'uid' => $_G['uid'],
'medalid' => $medalid,
'type' => $medal['type'],
'dateline' => TIMESTAMP,
'expiration' => $expiration,
'status' => ($expiration ? 1 : 0),
));
showmessage($medalmessage, 'home.php?mod=medal', array('medalname' => $medal['name']));
}
} elseif($_GET['action'] == 'log') {
include libfile('function/forum');
foreach(C::t('forum_medal')->fetch_all_data(1) as $medal) {
$medal['image'] = preg_match('/^https?:\/\//is', $medal['image']) ? $medal['image'] : STATICURL.'image/common/'.$medal['image'];
$medallist[$medal['medalid']] = $medal;
}
$memberfieldforum = C::t('common_member_field_forum')->fetch($_G['uid']);
$membermedal = $memberfieldforum['medals'] ? explode("\t", $memberfieldforum['medals']) : array();
foreach($membermedal as $k => $medal) {
if(!in_array($medal, array_keys($medallist))) {
unset($membermedal[$k]);
}
}
$medalcount = count($membermedal);
if(!empty($membermedal)) {
$mymedal = array();
foreach($membermedal as $medalid) {
if($medalpos = strpos($medalid, '|')) {
$medalid = substr($medalid, 0, $medalpos);
}
$mymedal['name'] = $_G['cache']['medals'][$medalid]['name'];
$mymedal['image'] = $medallist[$medalid]['image'];
$mymedals[] = $mymedal;
}
}
$medallognum = C::t('forum_medallog')->count_by_uid($_G['uid']);
$multipage = multi($medallognum, $tpp, $page, "home.php?mod=medal&action=log");
foreach(C::t('forum_medallog')->fetch_all_by_uid($_G['uid'], $start_limit, $tpp) as $medallog) {
$medallog['name'] = $_G['cache']['medals'][$medallog['medalid']]['name'];
$medallog['dateline'] = dgmdate($medallog['dateline']);
$medallog['expiration'] = !empty($medallog['expiration']) ? dgmdate($medallog['expiration']) : '';
$medallogs[] = $medallog;
}
} else {
showmessage('undefined_action');
}
$navtitle = lang('core', 'title_medals_list');
include template('home/space_medal');
?>

View File

@@ -0,0 +1,24 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: home_misc.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$ac = empty($_GET['ac']) ? '' : $_GET['ac'];
$acs = isset($_G['group']['allowvisit']) && $_G['group']['allowvisit'] ? array('swfupload', 'inputpwd', 'ajax', 'sendmail', 'emailcheck') : array('swfupload', 'sendmail', 'emailcheck');
if(empty($ac) || !in_array($ac, $acs)) {
showmessage('enter_the_space', 'home.php?mod=space');
}
$theurl = 'home.php?mod=misc&ac='.$ac;
require_once libfile('misc/'.$ac, 'include');
?>

View File

@@ -0,0 +1,78 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: home_rss.php 25756 2011-11-22 02:47:45Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if (!$_G['setting']['blogstatus']) {
showmessage('blog_status_off');
}
$pagenum = 20;
$siteurl = getsiteurl();
$uid = empty($_GET['uid'])?0:intval($_GET['uid']);
$list = array();
if(!empty($uid)) {
$space = getuserbyuid($uid, 1);
}
if(empty($space)) {
$space['username'] = $_G['setting']['sitename'];
$space['name'] = $_G['setting']['sitename'];
$space['email'] = $_G['setting']['adminemail'];
$space['space_url'] = $siteurl;
} else {
$space['username'] = $space['username'].'@'.$_G['setting']['sitename'];
$space['space_url'] = $siteurl."home.php?mod=space&amp;uid={$space['uid']}";
}
$uidsql = empty($space['uid'])?'':" AND b.uid='{$space['uid']}'";
$data_blog = C::t('home_blog')->range_blog(0, $pagenum, 'DESC', 'dateline', 0, null, $uid);
$blogids = array_keys($data_blog);
$data_blogfield = C::t('home_blogfield')->fetch_all($blogids);
$charset = $_G['config']['output']['charset'];
dheader("Content-type: application/xml");
echo "<?xml version=\"1.0\" encoding=\"".$charset."\"?>\n".
"<rss version=\"2.0\">\n".
" <channel>\n".
" <title>{$space['username']}</title>\n".
" <link>{$space['space_url']}</link>\n".
" <description>{$_G['setting']['bbname']}</description>\n".
" <copyright>Copyright(C) {$_G['setting']['bbname']}</copyright>\n".
" <generator>Discuz! Board by Comsenz Inc.</generator>\n".
" <lastBuildDate>".gmdate('r', TIMESTAMP)."</lastBuildDate>\n".
" <image>\n".
" <url>{$_G['siteurl']}static/image/common/logo_88_31.gif</url>\n".
" <title>{$_G['setting']['bbname']}</title>\n".
" <link>{$_G['siteurl']}</link>\n".
" </image>\n";
foreach($data_blog as $curblogid => $value) {
$value = array_merge($value, (array)$data_blogfield[$curblogid]);
$value['message'] = getstr($value['message'], 300, 0, 0, 0, -1);
if($value['pic']) {
$value['pic'] = pic_cover_get($value['pic'], $value['picflag']);
$value['message'] .= "<br /><img src=\"{$value['pic']}\">";
}
echo " <item>\n".
" <title>".$value['subject']."</title>\n".
" <link>{$_G['siteurl']}home.php?mod=space&amp;uid={$value['uid']}&amp;do=blog&amp;id={$value['blogid']}</link>\n".
" <description><![CDATA[".dhtmlspecialchars($value['message'])."]]></description>\n".
" <author>".dhtmlspecialchars($value['username'])."</author>\n".
" <pubDate>".gmdate('r', $value['dateline'])."</pubDate>\n".
" </item>\n";
}
echo " </channel>\n".
"</rss>";
?>

View File

@@ -0,0 +1,123 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: home_space.php 36337 2017-01-05 06:34:27Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$dos = array('index', 'doing', 'blog', 'album', 'friend', 'wall',
'notice', 'share', 'home', 'pm', 'favorite',
'thread', 'trade', 'poll', 'activity', 'debate', 'reward', 'profile', 'plugin', 'follow');
$do = (!empty($_GET['do']) && in_array($_GET['do'], $dos)) ? $_GET['do'] : 'index';
if(!in_array($do, array('home', 'doing', 'blog', 'album', 'share', 'wall'))) {
$_G['mnid'] = 'mn_common';
}
if(empty($_G['uid']) && in_array(getgpc('do'), array('thread', 'trade', 'poll', 'activity', 'debate', 'reward'))) {
showmessage('login_before_enter_home', null, array(), array('showmsg' => true, 'login' => 1));
}
$uid = empty($_GET['uid']) ? 0 : intval($_GET['uid']);
$member = array();
if(getgpc('username')) {
$member = C::t('common_member')->fetch_by_username($_GET['username']);
if(empty($member) && !($member = C::t('common_member_archive')->fetch_by_username($_GET['username']))) {
showmessage('space_does_not_exist');
}
$uid = $member['uid'];
$member['self'] = $uid == $_G['uid'] ? 1 : 0;
}
if(getgpc('view') == 'admin') {
$_GET['do'] = $do;
}
if(empty($uid) || in_array($do, array('notice', 'pm'))) $uid = $_G['uid'];
if(empty($_GET['do']) && !isset($_GET['diy'])) {
if($_G['adminid'] == 1) {
if($_G['setting']['allowquickviewprofile']) {
if(!$_G['inajax']) dheader("Location:home.php?mod=space&uid=$uid&do=profile");
}
}
if(helper_access::check_module('follow')) {
$do = $_GET['do'] = 'follow';
} else {
$do = $_GET['do'] = !$_G['setting']['homepagestyle'] ? 'profile' : 'index';
}
} elseif(empty($_GET['do']) && isset($_GET['diy']) && !empty($_G['setting']['homepagestyle'])) {
$_GET['do'] = 'index';
}
if($_GET['do'] == 'follow') {
if($uid != $_G['uid']) {
$_GET['do'] = 'view';
$_GET['uid'] = $uid;
}
require_once libfile('home/follow', 'module');
exit;
} elseif(empty($_GET['do']) && !$_G['inajax'] && !helper_access::check_module('follow')) {
$do = 'profile';
}
if($uid && empty($member)) {
$space = getuserbyuid($uid, 1);
if(empty($space)) {
showmessage('space_does_not_exist');
}
} else {
$space = &$member;
}
if(empty($space)) {
if(in_array($do, array('doing', 'blog', 'album', 'share', 'home', 'trade', 'poll', 'activity', 'debate', 'reward', 'group'))) {
if(empty($_GET['view']) || $_GET['view'] == 'all') {
$_GET['view'] = 'all';
$space['uid'] = 0;
$space['self'] = 0;
} else {
showmessage('login_before_enter_home', null, array(), array('showmsg' => true, 'login' => 1));
}
} else {
showmessage('login_before_enter_home', null, array(), array('showmsg' => true, 'login' => 1));
}
} else {
$navtitle = $space['username'];
if($space['status'] == -1 && $_G['adminid'] != 1) {
showmessage('space_has_been_locked');
}
if(in_array($space['groupid'], array(4, 5, 6)) && ($_G['adminid'] != 1 && $space['uid'] != $_G['uid'])) {
$_GET['do'] = $do = 'profile';
}
$encodeusername = rawurlencode($space['username']);
if($do != 'profile' && $do != 'index' && !ckprivacy($do, 'view')) {
$_G['privacy'] = 1;
require_once libfile('space/profile', 'include');
include template('home/space_privacy');
exit();
}
if(!$space['self'] && getgpc('view') != 'eccredit' && getgpc('view') != 'admin') $_GET['view'] = 'me';
}
$diymode = 0;
list($seccodecheck, $secqaacheck) = seccheck('publish');
if($do != 'index') {
$_G['disabledwidthauto'] = 0;
}
require_once libfile('function/friend');
$isfriend = friend_check($space['uid']);
require_once libfile('space/'.$do, 'include');
?>

View File

@@ -0,0 +1,63 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: home_spacecp.php 33660 2013-07-29 07:51:05Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
require_once libfile('function/spacecp');
require_once libfile('function/magic');
$acs = array('doing', 'upload', 'comment', 'blog', 'album', 'common', 'class',
'swfupload', 'poke', 'friend', 'eccredit', 'favorite', 'follow',
'avatar', 'profile', 'theme', 'feed', 'privacy', 'pm', 'share', 'invite','sendmail',
'credit', 'payment', 'usergroup', 'domain', 'click','magic', 'top', 'index', 'plugin', 'search', 'promotion');
$_GET['ac'] = $ac = (empty($_GET['ac']) || !in_array($_GET['ac'], $acs))?'profile':$_GET['ac'];
$op = empty($_GET['op'])?'':$_GET['op'];
if(!in_array($ac, array('doing', 'upload', 'blog', 'album'))) {
$_G['mnid'] = 'mn_common';
}
if($ac != 'comment' || !$_G['group']['allowcomment']) {
if($_G['uid'] || $ac.$op != 'paymentpay') {
if(empty($_G['uid'])) {
if($_SERVER['REQUEST_METHOD'] == 'GET') {
dsetcookie('_refer', rawurlencode($_SERVER['REQUEST_URI']));
} else {
dsetcookie('_refer', rawurlencode('home.php?mod=spacecp&ac='.$ac));
}
showmessage('to_login', '', array(), array('showmsg' => true, 'login' => 1));
}
$space = getuserbyuid($_G['uid']);
if(empty($space)) {
showmessage('space_does_not_exist');
}
space_merge($space, 'field_home');
if(($space['status'] == -1 || in_array($space['groupid'], array(4, 5, 6))) && $ac != 'usergroup') {
showmessage('space_has_been_locked');
}
}
}
$actives = array($ac => ' class="a"');
list($seccodecheck, $secqaacheck) = seccheck('publish');
$navtitle = lang('core', 'title_setup');
if(lang('core', 'title_memcp_'.$ac)) {
$navtitle = lang('core', 'title_memcp_'.$ac);
}
$_G['disabledwidthauto'] = 0;
require_once libfile('spacecp/'.$ac, 'include');
?>

View File

@@ -0,0 +1,125 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: home_task.php 27146 2012-01-06 09:34:49Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$_G['disabledwidthauto'] = 0;
require_once libfile('function/spacecp');
if(!$_G['setting']['taskstatus']) {
showmessage('task_close');
}
require_once libfile('class/task');
$tasklib = & task::instance();
$tasklib->update_available();
$_G['mnid'] = 'mn_common';
$id = intval($_GET['id']);
$do = empty($_GET['do']) ? '' : $_GET['do'];
if(empty($_G['uid'])) {
showmessage('to_login', null, array(), array('showmsg' => true, 'login' => 1));
}
$navtitle = lang('core', 'title_task');
if(empty($do)) {
$_GET['item'] = empty($_GET['item']) ? 'new' : $_GET['item'];
$actives = array($_GET['item'] => ' class="a"');
$tasklist = $tasklib->tasklist($_GET['item']);
$listdata = $tasklib->listdata;
if($_GET['item'] == 'doing' && empty($tasklist)) {
dsetcookie('taskdoing_'.$_G['uid']);
}
} elseif($do == 'view' && $id) {
cleartaskstatus();
$allowapply = $tasklib->view($id);
$task = & $tasklib->task;
$taskvars = & $tasklib->taskvars;
} elseif($do == 'apply' && $id) {
if(!$_G['uid']) {
showmessage('not_loggedin', NULL, array(), array('login' => 1));
}
$result = $tasklib->apply($id);
if($result === -1) {
showmessage('task_relatedtask', 'home.php?mod=task&do=view&id='.$tasklib->task['relatedtaskid']);
} elseif($result === -2) {
showmessage('task_grouplimit', 'home.php?mod=task&item=new');
} elseif($result === -3) {
showmessage('task_duplicate', 'home.php?mod=task&item=new');
} elseif($result === -4) {
showmessage('task_nextperiod', 'home.php?mod=task&item=new');
} elseif($result === -5) {
showmessage('task_exclusivetask', 'home.php?mod=task&item=new');
} else {
dsetcookie('taskdoing_'.$_G['uid'], 1, 7776000);
showmessage('task_applied', 'home.php?mod=task&do=view&id='.$id);
}
} elseif($do == 'delete' && $id) {
$result = $tasklib->delete($id);
showmessage('task_deleted', 'home.php?mod=task&item=doing');
} elseif($do == 'draw' && $id) {
if(!$_G['uid']) {
showmessage('not_loggedin', NULL, array(), array('login' => 1));
}
$result = $tasklib->draw($id);
if($result === -1) {
showmessage('task_up_to_limit', 'home.php?mod=task', array('tasklimits' => $tasklib->task['tasklimits']));
} elseif($result === -2) {
showmessage('task_failed', 'home.php?mod=task&item=failed');
} elseif($result === -3) {
showmessage($tasklib->messagevalues['msg'], 'home.php?mod=task&do=view&id='.$id, $tasklib->messagevalues['values']);
} elseif($result === -4) {
showmessage('task_exclusivetask', 'home.php?mod=task&item=new');
} else {
cleartaskstatus();
showmessage('task_completed', 'home.php?mod=task&item=done');
}
} elseif($do == 'giveup' && $id) {
$tasklib->giveup($id);
showmessage('task_giveup', 'home.php?mod=task&item=view&id='.$id);
} elseif($do == 'parter' && $id) {
$parterlist = $tasklib->parter($id);
include template('home/space_task_parter');
dexit();
} else {
showmessage('undefined_action');
}
include template('home/space_task');
function cleartaskstatus() {
global $_G;
if(!C::t('common_mytask')->count_mytask($_G['uid'], false, 0)) {
dsetcookie('taskdoing_'.$_G['uid']);
}
}
?>

View File

0
source/module/index.htm Normal file
View File

View File

View File

@@ -0,0 +1,117 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: member_connect.php 34239 2013-11-21 08:31:14Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
if(!$_G['setting']['connect']['allow']) {
showmessage('qqconnect:qqconnect_closed');
}
if($_GET['action'] == 'login') { // debug 已有账号,绑定我的账号走此分支
$ctl_obj = new logging_ctl();
$_G['setting']['seccodestatus'] = 0;
$ctl_obj->connect_guest = $connect_guest;
$ctl_obj->extrafile = libfile('member/connect_logging', 'module');
$ctl_obj->template = 'member/login';
$ctl_obj->on_login();
} else { // debug 完善我的资料,即添加个新的论坛账号走此分支
$_G['qc']['connect_auth_hash'] = $_GET['con_auth_hash'];
if(!$_G['qc']['connect_auth_hash']) {
$_G['qc']['connect_auth_hash'] = $_G['cookie']['con_auth_hash'];
}
$conopenid = authcode($_G['qc']['connect_auth_hash']);
$ctl_obj = new register_ctl();
$ctl_obj->setting = $_G['setting'];
if($_G['setting']['regconnect']) {
$ctl_obj->setting['regstatus'] = $ctl_obj->setting['regstatus'] ? $ctl_obj->setting['regstatus'] : 1;
}
$_G['setting']['regclosed'] = $_G['setting']['regconnect'] && !$_G['setting']['regstatus'];
loadcache('connect_blacklist');
if(in_array($conopenid, $_G['cache']['connect_blacklist'])) {
showmessage('qqconnect:connect_uin_in_blacklist', $referer, array('changeqqurl' => $_G['connect']['discuz_change_qq_url']));
}
$_G['qc']['uinlimit'] = $_G['setting']['connect']['register_uinlimit'] && C::t('#qqconnect#connect_memberbindlog')->count_uid_by_openid_type($conopenid, '1') >= $_G['setting']['connect']['register_uinlimit'];
if($_G['qc']['uinlimit']) {
$_G['setting']['regconnect'] = false;
}
if(!$_G['setting']['regconnect']) {
$ctl_obj->showregisterform = 0;
$ctl_obj->setting['sitemessage']['register'] = array();
}
if($_G['qc']['uinlimit']) {
$ctl_obj->showregisterform = 0;
$ctl_obj->setting['sitemessage']['register'] = array();
$ctl_obj->setting['regconnect'] = false;
}
if($_G['setting']['connect']['register_regverify']) {
$ctl_obj->setting['regverify'] = 0;
}
$_G['setting']['seccodestatus'] = 0;
$_G['setting']['secqaa']['status'] = 0;
$ctl_obj->setting['sendregisterurl'] = false;
$ctl_obj->connect_guest = $connect_guest;
loadcache(array('fields_connect_register', 'profilesetting'));
foreach($_G['cache']['fields_connect_register'] as $field => $data) {
unset($_G['cache']['fields_register'][$field]);
}
$_G['cache']['profilesetting']['gender']['unchangeable'] = 0;
$_G['cache']['profilesetting']['birthyear']['unchangeable'] = 0;
$_G['cache']['profilesetting']['birthmonth']['unchangeable'] = 0;
$_G['cache']['profilesetting']['birthday']['unchangeable'] = 0;
$_G['cache']['fields_register'] = array_merge($_G['cache']['fields_connect_register'], $_G['cache']['fields_register']);
if($_G['setting']['connect']['register_invite']) {
$ctl_obj->setting['regstatus'] = 1;
}
if(!$_G['setting']['connect']['register_regverify']) {
$ctl_obj->setting['seccodestatus'] = $_G['setting']['seccodestatus'];
$ctl_obj->setting['secqaa']['status'] = $_G['setting']['secqaa']['status'];
}
if(!defined('IN_MOBILE') || empty($_GET[$_G['setting']['reginput']['password']])) {
$ctl_obj->setting['ignorepassword'] = 1;
}
$ctl_obj->setting['checkuinlimit'] = 1;
$ctl_obj->setting['strongpw'] = 0;
$ctl_obj->setting['pwlength'] = 0;
if($_GET['ac'] == 'bind') {
$ctl_obj->setting['reglinkname'] = lang('plugin/qqconnect', 'connect_register_bind');
} else {
$ctl_obj->setting['reglinkname'] = lang('plugin/qqconnect', 'connect_register_profile');
}
$ctl_obj->extrafile = libfile('member/connect_register', 'module');
$ctl_obj->template = 'member/register';
$ctl_obj->on_register();
}
?>

View File

@@ -0,0 +1,56 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: member_connect_logging.php 33543 2013-07-03 06:01:33Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!empty($_POST)) {
if($result['member']['conisbind']) {
showmessage('qqconnect:connect_register_bind_already');
}
if($result['member']['groupid'] == 8) {
showmessage('qqconnect:connect_register_bind_need_inactive');
}
$conuin = $this->connect_guest['conuin'];
$conuinsecret = $this->connect_guest['conuinsecret'];
$conopenid = $this->connect_guest['conopenid'];
$conuintoken = $this->connect_guest['conuintoken'];
$user_auth_fields = 1;
$conispublishfeed = 0;
$conispublisht = 0;
$is_use_qqshow = 0;
if ($conopenid) {
C::t('#qqconnect#common_member_connect')->insert(array('uid' => $uid, 'conuin' => $conuin, 'conuinsecret' => $conuinsecret, 'conuintoken' => $conuintoken, 'conopenid' => $conopenid, 'conispublishfeed' => $conispublishfeed, 'conispublisht' => $conispublisht, 'conisregister' => '0', 'conisqzoneavatar' => '0', 'conisfeed' => $user_auth_fields, 'conisqqshow' => $is_use_qqshow), false, true);
C::t('common_member')->update($uid, array('conisbind' => '1'));
C::t('#qqconnect#connect_memberbindlog')->insert(array('uid' => $uid, 'uin' => $conopenid, 'type' => '1', 'dateline' => $_G['timestamp']));
C::t('#qqconnect#common_connect_guest')->delete($conopenid);
dsetcookie('connect_js_name', 'user_bind', 86400);
dsetcookie('connect_js_params', base64_encode(serialize(array('type' => 'registerbind'))), 86400);
dsetcookie('connect_login', 1, 31536000);
dsetcookie('connect_is_bind', '1', 31536000);
dsetcookie('connect_uin', $conopenid, 31536000);
dsetcookie('stats_qc_reg', 2, 86400);
if ($_GET['is_feed']) {
dsetcookie('connect_synpost_tip', 1, 31536000);
}
} else {
showmessage('qqconnect:connect_get_access_token_failed', dreferer());
}
}
?>

View File

@@ -0,0 +1,132 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: member_connect_register.php 33538 2013-07-02 05:01:37Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$from_connect = $_G['setting']['connect']['allow'] ? 1 : 0;
$_G['setting']['regname'] = $regname = 'connect';
if(empty($_POST)) {
$_G['qc']['connect_auth_hash'] = $_GET['con_auth_hash'];
$_G['qc']['dreferer'] = dreferer();
if(!$_G['qc']['connect_auth_hash']) {
$_G['qc']['connect_auth_hash'] = $_G['cookie']['con_auth_hash'];
}
$conopenid = authcode($_G['qc']['connect_auth_hash']);
if (empty($conopenid)) {
showmessage('qqconnect:connect_login_first', null, array(), array('showmsg' => true, 'login' => 1));
}
$_G['qc']['connect_is_feed'] = false;
$_G['qc']['connect_app_id'] = $_G['setting']['connectappid'];
$_G['qc']['connect_openid'] = $conopenid;
unset($auth_code, $conopenid);
$_G['qc']['connect_is_notify'] = true;
foreach($_G['cache']['fields_register'] as $field) {
$fieldid = $field['fieldid'];
$html = profile_setting($fieldid, $connectdefault);
if($html) {
$settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid];
$htmls[$fieldid] = $html;
}
}
} else {
if(!empty($_G['setting']['checkuinlimit']) && !empty($_GET['uin'])) {
if($_G['qc']['uinlimit']) {
showmessage('qqconnect:connect_register_uinlimit', '', array('limit' => $this->setting['connect']['register_uinlimit']));
}
if(!$_G['setting']['regconnect']) {
showmessage('qqconnect:connect_register_closed');
}
}
$conuin = $this->connect_guest['conuin'];
$conuinsecret = $this->connect_guest['conuinsecret'];
$conuintoken = $this->connect_guest['conuintoken'];
$conopenid = $this->connect_guest['conopenid'];
$cookie_expires = 2592000;
dsetcookie('client_created', TIMESTAMP, $cookie_expires);
dsetcookie('client_token', 1, $cookie_expires);
if (!$conuintoken || !$conopenid) {
showmessage('qqconnect:connect_get_request_token_failed');
}
if(C::t('#qqconnect#common_member_connect')->fetch_fields_by_openid($conopenid, 'uid')) {
showmessage('qqconnect:connect_register_bind_uin_already');
}
$conispublishfeed = 0;
$conispublisht = 0;
$userdata = array();
$userdata['avatarstatus'] = 0;
$userdata['conisbind'] = 1;
C::t('#qqconnect#common_member_connect')->insert(array(
'uid' => $uid,
'conuin' => $conuin,
'conuinsecret' => $conuinsecret,
'conuintoken' => $conuintoken,
'conopenid' => $conopenid,
'conispublishfeed' => $conispublishfeed,
'conispublisht' => $conispublisht,
'conisregister' => $this->setting['ignorepassword'] ? '1' : '0',
'conisqzoneavatar' => '0',
'conisfeed' => '1',
'conisqqshow' => '0',
));
dsetcookie('connect_js_name', 'user_bind', 86400);
dsetcookie('connect_js_params', base64_encode(serialize(array('type' => 'register'))), 86400);
dsetcookie('connect_login', 1, 31536000);
dsetcookie('connect_is_bind', '1', 31536000);
dsetcookie('connect_uin', $conopenid, 31536000);
dsetcookie('stats_qc_reg', 1, 86400);
if ($_GET['is_feed']) {
dsetcookie('connect_synpost_tip', 1, 31536000);
}
C::t('#qqconnect#connect_memberbindlog')->insert(array('uid' => $uid, 'uin' => $conopenid, 'type' => '1', 'dateline' => $_G['timestamp']));
dsetcookie('con_auth_hash');
C::t('#qqconnect#common_connect_guest')->delete($conopenid);
if(!function_exists('build_cache_userstats')) {
require_once libfile('cache/userstats', 'function');
}
build_cache_userstats();
if($_G['setting']['connect']['register_groupid']) {
$userdata['groupid'] = $groupinfo['groupid'] = $_G['setting']['connect']['register_groupid'];
}
C::t('common_member')->update($uid, $userdata);
if($_G['setting']['connect']['register_addcredit']) {
$addcredit = array('extcredits'.$_G['setting']['connect']['register_rewardcredit'] => $_G['setting']['connect']['register_addcredit']);
}
C::t('common_member_count')->increase($uid, $addcredit);
}
function connect_filter_username($username) {
$username = str_replace(' ', '_', trim($username));
return cutstr($username, 15, '');
}
?>

View File

@@ -0,0 +1,105 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: member_getpasswd.php 35030 2014-10-23 07:43:23Z laoguozhang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
$paramexist = preg_match_all('/(\?|&(amp)?(;)?)(.+?)=([^&?]*)/i', $_SERVER['QUERY_STRING'], $parammatchs);
if($paramexist){
foreach($parammatchs[5] as $paramk => $paramv){
$param[$parammatchs[4][$paramk]] = $paramv;
}
}
$uid = isset($_GET['uid']) ? $_GET['uid'] : $param['uid'];
$id = isset($_GET['id']) ? $_GET['id'] : $param['id'];
$sign = isset($_GET['sign']) ? $_GET['sign'] : $param['sign'];
if($uid && $id && $sign === make_getpws_sign($uid, $id)) {
$discuz_action = 141;
$member = getuserbyuid($uid, 1);
$table_ext = isset($member['_inarchive']) ? '_archive' : '';
$member = array_merge(C::t('common_member_field_forum'.$table_ext)->fetch($uid), $member);
list($dateline, $operation, $idstring) = explode("\t", $member['authstr']);
if($dateline < TIMESTAMP - 86400 * 3 || $operation != 1 || $idstring != $id) {
showmessage('getpasswd_illegal', NULL);
}
if(!submitcheck('getpwsubmit') || $_GET['newpasswd1'] != $_GET['newpasswd2']) {
$navtitle = lang('core', 'title_getpasswd');
$hashid = $id;
$uid = $_GET['uid'];
include template('member/getpasswd');
} else {
if($_GET['newpasswd1'] != addslashes($_GET['newpasswd1'])) {
showmessage('profile_passwd_illegal');
}
if($_G['setting']['pwlength']) {
if(strlen($_GET['newpasswd1']) < $_G['setting']['pwlength']) {
showmessage('profile_password_tooshort', '', array('pwlength' => $_G['setting']['pwlength']));
}
}
if($_G['setting']['strongpw']) {
$strongpw_str = array();
if(in_array(1, $_G['setting']['strongpw']) && !preg_match("/\d+/", $_GET['newpasswd1'])) {
$strongpw_str[] = lang('member/template', 'strongpw_1');
}
if(in_array(2, $_G['setting']['strongpw']) && !preg_match("/[a-z]+/", $_GET['newpasswd1'])) {
$strongpw_str[] = lang('member/template', 'strongpw_2');
}
if(in_array(3, $_G['setting']['strongpw']) && !preg_match("/[A-Z]+/", $_GET['newpasswd1'])) {
$strongpw_str[] = lang('member/template', 'strongpw_3');
}
if(in_array(4, $_G['setting']['strongpw']) && !preg_match("/[^a-zA-z0-9]+/", $_GET['newpasswd1'])) {
$strongpw_str[] = lang('member/template', 'strongpw_4');
}
if($strongpw_str) {
showmessage(lang('member/template', 'password_weak').implode(',', $strongpw_str));
}
}
loaducenter();
uc_user_edit(addslashes($member['username']), $_GET['newpasswd1'], $_GET['newpasswd1'], addslashes($member['email']), 1, 0);
$password = md5(random(10));
if(isset($member['_inarchive'])) {
C::t('common_member_archive')->move_to_master($member['uid']);
}
C::t('common_member')->update($uid, array('password' => $password));
C::t('common_member_field_forum')->update($uid, array('authstr' => ''));
if(!function_exists('sendmail')) {
include libfile('function/mail');
}
$reset_password_subject = array(
'tpl' => 'password_reset',
'var' => array(
'username' => $member['username'],
'bbname' => $_G['setting']['bbname'],
'siteurl' => $_G['setting']['securesiteurl'],
'datetime' => dgmdate(time(), 'Y-m-d H:i:s'),
'clientip' => $_G['clientip']
)
);
if(!sendmail("{$member['username']} <{$member['email']}>", $reset_password_subject)) {
runlog('sendmail', "{$member['email']} sendmail failed.");
}
showmessage('getpasswd_succeed', 'index.php', array(), array('login' => 1));
}
} else {
showmessage('parameters_error');
}
?>

View File

@@ -0,0 +1,26 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: member_logging.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
if(!in_array($_GET['action'], array('login', 'logout'))) {
showmessage('undefined_action');
}
$ctl_obj = new logging_ctl();
$ctl_obj->setting = $_G['setting'];
$method = 'on_'.$_GET['action'];
$ctl_obj->template = 'member/login';
$ctl_obj->$method();
?>

View File

@@ -0,0 +1,79 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: member_lostpasswd.php 35041 2014-10-29 08:05:36Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
$discuz_action = 141;
if(submitcheck('lostpwsubmit')) {
loaducenter();
$_GET['email'] = strtolower(trim($_GET['email']));
if($_GET['username']) {
list($tmp['uid'], , $tmp['email']) = uc_get_user(addslashes($_GET['username']));
$tmp['email'] = strtolower(trim($tmp['email']));
if($_GET['email'] != $tmp['email']) {
showmessage('getpasswd_account_notmatch');
}
$member = getuserbyuid($tmp['uid'], 1);
} else {
$emailcount = C::t('common_member')->count_by_email($_GET['email'], 1);
if(!$emailcount) {
showmessage('lostpasswd_email_not_exist');
}
if($emailcount > 1) {
showmessage('lostpasswd_many_users_use_email');
}
$member = C::t('common_member')->fetch_by_email($_GET['email'], 1);
list($tmp['uid'], , $tmp['email']) = uc_get_user(addslashes($member['username']));
$tmp['email'] = strtolower(trim($tmp['email']));
}
if(!$member) {
showmessage('getpasswd_account_notmatch');
} elseif($member['adminid'] == 1 || $member['adminid'] == 2) {
showmessage('getpasswd_account_invalid');
}
$table_ext = $member['_inarchive'] ? '_archive' : '';
if($member['email'] != $tmp['email']) {
C::t('common_member'.$table_ext)->update($tmp['uid'], array('email' => $tmp['email']));
}
$memberauthstr = C::t('common_member_field_forum'.$table_ext)->fetch($member['uid']);
list($dateline, $operation, $idstring) = explode("\t", $memberauthstr['authstr']);
$interval = $_G['setting']['mailinterval'] > 0 ? (int)$_G['setting']['mailinterval'] : 300;
if($dateline && $operation == 1 && $dateline > TIMESTAMP - $interval) {
showmessage('getpasswd_has_send', '', array('interval' => $interval));
}
$idstring = random(6);
C::t('common_member_field_forum'.$table_ext)->update($member['uid'], array('authstr' => "{$_G['timestamp']}\t1\t$idstring"));
require_once libfile('function/mail');
$get_passwd_message = array(
'tpl' => 'get_passwd',
'var' => array(
'username' => $member['username'],
'bbname' => $_G['setting']['bbname'],
'siteurl' => $_G['setting']['securesiteurl'],
'uid' => $member['uid'],
'idstring' => $idstring,
'clientip' => $_G['clientip'],
'sign' => make_getpws_sign($member['uid'], $idstring),
)
);
if(!sendmail("{$_GET['username']} <{$tmp['email']}>", $get_passwd_message)) {
runlog('sendmail', "{$tmp['email']} sendmail failed.");
}
showmessage('getpasswd_send_succeed', $_G['siteurl'], array(), array('showdialog' => 1, 'locationtime' => true));
}
?>

View File

@@ -0,0 +1,21 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: member_register.php 23897 2011-08-15 09:21:07Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
$ctl_obj = new register_ctl();
$ctl_obj->setting = $_G['setting'];
$ctl_obj->template = 'member/register';
$ctl_obj->on_register();
?>

View File

@@ -0,0 +1,32 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: member_regverify.php 28003 2012-02-20 09:55:39Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
if($_G['setting']['regverify'] == 2 && $_G['groupid'] == 8 && submitcheck('verifysubmit')) {
if(($verify_member = C::t('common_member_validate')->fetch($_G['uid'])) && $verify_member['status'] == 1) {
C::t('common_member_validate')->update($_G['uid'], array(
'submittimes' => $verify_member['submittimes']+1,
'submitdate' => $_G['timestamp'],
'status' => '0',
'message' => dhtmlspecialchars($_GET['regmessagenew'])
));
showmessage('submit_verify_succeed', 'home.php?mod=spacecp&ac=profile');
} else {
showmessage('undefined_action');
}
}
?>

View File

@@ -0,0 +1,34 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: member_switchstatus.php 27203 2012-01-11 03:14:19Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
if($_G['uid']) {
if(!$_G['group']['allowinvisible']) {
showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
}
$_G['session']['invisible'] = $_G['session']['invisible'] ? 0 : 1;
C::app()->session->update_by_uid($_G['uid'], array('invisible' => $_G['session']['invisible']));
C::t('common_member_status')->update($_G['uid'], array('invisible' => $_G['session']['invisible']), 'UNBUFFERED');
if(!empty($_G['setting']['sessionclose'])) {
dsetcookie('ulastactivity', TIMESTAMP.'|'.getuserprofile('invisible'), 31536000);
}
$language = lang('forum/misc');
$msg = $_G['session']['invisible'] ? $language['login_invisible_mode'] : $language['login_normal_mode'];
showmessage('<a href="member.php?mod=switchstatus" title="'.$language['login_switch_invisible_mode'].'" onclick="ajaxget(this.href, \'loginstatus\');return false;" class="xi2">'.$msg.'</a>', dreferer(), array(), array('msgtype' => 3, 'showmsg' => 1));
}
?>

View File

View File

@@ -0,0 +1,76 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_buyinvitecode.php 31572 2012-09-10 08:59:03Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(submitcheck('buysubmit')) {
if(payment::enable()) {
$language = lang('forum/misc');
$amount = intval($_GET['amount']);
$email = dhtmlspecialchars($_GET['email']);
if($amount < 1) {
showmessage('buyinvitecode_no_count');
}
if(strlen($email) < 6 || !preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email)) {
showmessage('buyinvitecode_email_error');
}
$price = $amount * $_G['setting']['inviteconfig']['invitecodeprice'] * 100;
$orderid = '';
$requesturl = payment::create_order(
'payment_invite',
$_G['setting']['bbname'].' - '.lang('forum/misc', 'invite_payment'),
lang('forum/misc', 'invite_forum_payment').' '.intval($amount).' '.lang('forum/misc', 'invite_forum_payment_unit'),
$price,
$_G['siteurl'] . 'misc.php?mod=buyinvitecode&action=paysucceed&orderid={out_biz_no}',
array(
'num' => $amount,
'email' => $email,
'ip' => $_G['clientip'],
'port' => $_G['remoteport']
)
);
include isset($_REQUEST['inajax']) ? template('common/header_ajax') : template('common/header');
echo '<form id="payform" action="'.$requesturl.'" method="post"></form><script type="text/javascript" reload="1">document.getElementById(\'payform\').submit();</script>';
include isset($_REQUEST['inajax']) ? template('common/footer_ajax') : template('common/footer');
dexit();
} else {
showmessage('action_closed', NULL);
}
}
if($_GET['action'] == 'paysucceed' && $_GET['orderid']) {
$orderid = $_GET['orderid'];
$order = C::t('forum_order')->fetch($orderid);
if(!$order) {
showmessage('parameters_error');
}
$codes = array();
foreach(C::t('common_invite')->fetch_all_orderid($orderid) as $code) {
$codes[] = $code['code'];
}
if(empty($codes)) {
showmessage('buyinvitecode_no_id');
}
$codetext = implode("\r\n", $codes);
}
if($_G['group']['maxinviteday']) {
$maxinviteday = time() + 86400 * $_G['group']['maxinviteday'];
} else {
$maxinviteday = time() + 86400 * 10;
}
$maxinviteday = dgmdate($maxinviteday, 'Y-m-d H:i');
$_G['setting']['inviteconfig']['invitecodeprompt'] = nl2br($_G['setting']['inviteconfig']['invitecodeprompt']);
include template('common/buyinvitecode');
?>

View File

@@ -0,0 +1,38 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_diyhelp.php 25889 2011-11-24 09:52:20Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$allowdiy = false; //diy权限:$_G['group']['allowdiy'] || $_G['group']['allowaddtopic'] && $topic['uid'] == $_G['uid'] || $_G['group']['allowmanagetopic']
$ref = $_GET['diy'] == 'yes';//DIY模式中
if(!$ref && $_GET['action'] == 'get') {
if($_GET['type'] == 'index') {
if($_G['group']['allowdiy']) {
$allowdiy = true;
}
} else if($_GET['type'] == 'topic') {
$topic = array();
$topicid = max(0, intval($_GET['topicid']));
if($topicid) {
if($_G['group']['allowmanagetopic']) {
$allowdiy = true;
} else if($_G['group']['allowaddtopic']) {
if(($topic=C::t('portal_topic')->fetch($topicid)) && $topic['uid'] == $_G['uid']) {
$allowdiy = true;
}
}
}
}
}
include_once template('portal/portal_diyhelp');
?>

View File

@@ -0,0 +1,15 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_error.php 6790 2010-03-25 12:30:53Z cnteacher $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
exit('Access Denied, Error mod request!')
?>

View File

@@ -0,0 +1,82 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_faq.php 32267 2012-12-12 03:26:40Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$keyword = isset($_GET['keyword']) ? dhtmlspecialchars($_GET['keyword']) : '';
$faqparent = $faqsub = array();
foreach(C::t('forum_faq')->fetch_all_by_fpid() as $faq) {
if(empty($faq['fpid'])) {
$faqparent[$faq['id']] = $faq;
if($_GET['id'] == $faq['id']) {
$ctitle = $faq['title'];
}
} else {
$faqsub[$faq['fpid']][] = $faq;
}
}
if($_GET['action'] == 'faq') {
$id = intval($_GET['id']);
$faq = C::t('forum_faq')->fetch_all_by_fpid($id);
if($faq) {
$ffaq = $faq[$id];
$navtitle = $ctitle;
$navigation = "<em>&rsaquo;</em> $ctitle";
$faqlist = array();
$messageid = empty($_GET['messageid']) ? 0 : $_GET['messageid'];
foreach(C::t('forum_faq')->fetch_all_by_fpid($id) as $faq) {
if(!$messageid) {
$messageid = $faq['id'];
}
$faqlist[] = $faq;
}
} else {
showmessage('faq_content_empty', 'misc.php?mod=faq');
}
} elseif($_GET['action'] == 'search') {
$navtitle = lang('core', 'search');
if(submitcheck('searchsubmit')) {
if(($keyword = $_GET['keyword'])) {
$sqlsrch = '';
$searchtype = in_array($_GET['searchtype'], array('all', 'title', 'message')) ? $_GET['searchtype'] : 'all';
$faqlist = array();
foreach(C::t('forum_faq')->fetch_all_by_fpid('', $keyword) as $faq) {
if(!empty($faq['fpid'])) {
$faq['title'] = preg_replace("/(?<=[\s\"\]>()]|[\x7f-\xff]|^)(".preg_quote($keyword, '/').")(([.,:;-?!()\s\"<\[]|[\x7f-\xff]|$))/siU", "<u><b><font color=\"#FF0000\">\\1</font></b></u>\\2", $faq['title']);
$faq['message'] = preg_replace("/(?<=[\s\"\]>()]|[\x7f-\xff]|^)(".preg_quote($keyword, '/').")(([.,:;-?!()\s\"<\[]|[\x7f-\xff]|$))/siU", "<u><b><font color=\"#FF0000\">\\1</font></b></u>\\2", $faq['message']);
$faqlist[] = $faq;
}
}
} else {
showmessage('faq_keywords_empty', 'misc.php?mod=faq');
}
$keyword = dhtmlspecialchars($keyword);
}
} elseif($_GET['action'] == 'plugin' && !empty($_GET['id'])) {
$navtitle = $_G['setting']['plugins']['faq'][$_GET['id']]['name'];
$navigation = '<em>&rsaquo;</em> '.$_G['setting']['plugins']['faq'][$_GET['id']]['name'];
include pluginmodule($_GET['id'], 'faq');
} else {
$navtitle = lang('core', 'faq');
}
include template('common/faq');
?>

View File

@@ -0,0 +1,48 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_getatuser.php 25782 2011-11-22 05:29:19Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$result = '';
$search_str = getgpc('search_str');
if($_G['uid']) {
$atlist = $atlist_cookie = array();
$limit = 200;
if(getcookie('atlist')) {
$cookies = explode(',', $_G['cookie']['atlist']);
foreach(C::t('common_member')->fetch_all($cookies, false) as $row) {
if ($row['uid'] != $_G['uid'] && in_array($row['uid'], $cookies)) {
$atlist_cookie[$row['uid']] = $row['username'];
}
}
}
foreach(C::t('home_follow')->fetch_all_following_by_uid($_G['uid'], 0, 0, $limit) as $row) {
if($atlist_cookie[$row['followuid']]) {
continue;
}
$atlist[$row['followuid']] = $row['fusername'];
}
$num = count($atlist);
if($num < $limit) {
$query = C::t('home_friend')->fetch_all_by_uid($_G['uid'], 0, $limit * 2);
foreach($query as $row) {
if(count($atlist) == $limit) {
break;
}
if($atlist_cookie[$row['fuid']]) {
continue;
}
$atlist[$row['fuid']] = $row['fusername'];
}
}
$result = implode(',', $atlist_cookie).($atlist_cookie && $atlist ? ',' : '').implode(',', $atlist);
}
include template('common/getatuser');
?>

View File

@@ -0,0 +1,66 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_imgcropper.php 36314 2016-12-19 08:02:23Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$_GET['img'] = htmlspecialchars($_GET['img']);
$_GET['bid'] = intval($_GET['bid']);
$_GET['picflag'] = intval($_GET['picflag']);
$_GET['ictype'] = !empty($_GET['ictype']) ? 'block' : '';
$_GET['width'] = intval($_GET['width']);
$_GET['height'] = intval($_GET['height']);
if(!submitcheck('imgcroppersubmit')) {
if($_GET['op'] == 'loadcropper') {
$cboxwidth = $_GET['width'] > 50 ? $_GET['width'] : 300;
$cboxheight = $_GET['height'] > 50 ? $_GET['height'] : 300;
$cbgboxwidth = $cboxwidth + 300;
$cbgboxheight = $cboxheight + 300;
$dragpl = ($cbgboxwidth - $cboxwidth)/2;
$dragpt = ($cbgboxheight - $cboxheight)/2;
} else {
$prefix = $_GET['picflag'] == 2 ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl'];
}
include_once template("common/misc_imgcropper");
} else {
$pathinfos = pathinfo($_GET['cutimg']);
if(!in_array(strtolower($pathinfos['extension']), array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) {
showmessage('imagepreview_errorcode_0', null, null, array('showdialog' => true, 'closetime' => true));
}
$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));
}
?>

View File

@@ -0,0 +1,92 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_initsys.php 36334 2017-01-03 01:32:35Z nemohou $
*/
@set_time_limit(0);
@ignore_user_abort(TRUE);
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(file_exists(DISCUZ_ROOT.'./data/install.lock') && file_exists(DISCUZ_ROOT.'./data/update.lock')) {
exit('Access Denied');
}
@touch(DISCUZ_ROOT.'./data/install.lock');
@touch(DISCUZ_ROOT.'./data/update.lock');
if(!($_G['adminid'] == 1 && $_GET['formhash'] == formhash()) && $_G['setting']) {
exit('Access Denied');
}
require_once libfile('function/cache');
updatecache();
require_once libfile('function/block');
blockclass_cache();
if($_G['config']['output']['tplrefresh']) {
cleartemplatecache();
}
$plugins = array('mobile');
$opens = array('mobile');
require_once libfile('function/plugin');
require_once libfile('function/admincp');
foreach($plugins as $pluginid) {
$importfile = DISCUZ_ROOT.'./source/plugin/'.$pluginid.'/discuz_plugin_'.$pluginid.'.xml';
if(!file_exists($importfile)) {
continue;
}
$systemvalue = 2;
$importtxt = @implode('', file($importfile));
$pluginarray = getimportdata('Discuz! Plugin', $importtxt);
$plugin = C::t('common_plugin')->fetch_by_identifier($pluginid);
if($plugin) {
$modules = dunserialize($plugin['modules']);
if($modules['system'] > 0) {
if($pluginarray['plugin']['version'] != $plugin['version']) {
pluginupgrade($pluginarray, '');
if($pluginarray['upgradefile']) {
$plugindir = DISCUZ_ROOT.'./source/plugin/'.$pluginarray['plugin']['directory'];
if(file_exists($plugindir.'/'.$pluginarray['upgradefile'])) {
@include_once $plugindir.'/'.$pluginarray['upgradefile'];
}
}
}
if($modules['system'] != $systemvalue) {
$modules['system'] = $systemvalue;
$modules = serialize($modules);
C::t('common_plugin')->update($plugin['pluginid'], array('modules' => $modules));
}
continue;
}
C::t('common_plugin')->delete_by_identifier($pluginid);
}
if($plugin['available']) {
$opens[] = $pluginid;
}
$pluginarray['plugin']['modules'] = dunserialize(dstripslashes($pluginarray['plugin']['modules']));
$pluginarray['plugin']['modules']['system'] = $systemvalue;
$pluginarray['plugin']['modules'] = serialize($pluginarray['plugin']['modules']);
plugininstall($pluginarray, '', in_array($pluginid, $opens));
if($pluginarray['installfile']) {
$plugindir = DISCUZ_ROOT.'./source/plugin/'.$pluginarray['plugin']['directory'];
if(file_exists($plugindir.'/'.$pluginarray['installfile'])) {
@include_once $plugindir.'/'.$pluginarray['installfile'];
}
}
}
?>

View File

@@ -0,0 +1,170 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_invite.php 33107 2013-04-26 03:43:21Z andyzheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['setting']['friendstatus']) {
showmessage("friend_status_off");
}
require_once libfile('function/friend');
$_GET['action'] = dhtmlspecialchars(preg_replace("/[^\[A-Za-z0-9_\]]/", '', $_GET['action']));
$friendgrouplist = friend_group_list();
if($_GET['action'] == 'group') {
$id = intval($_GET['id']);
$groupuserinfo = C::t('forum_groupuser')->fetch_userinfo($_G['uid'], $id);
if(empty($groupuserinfo['uid'])) {
showmessage('group_invite_failed');
}
$foruminfo = C::t('forum_forum')->fetch($id);
$grouplevel = $foruminfo['level'];
loadcache('grouplevels');
$grouplevel = $_G['grouplevels'][$grouplevel];
$membermaximum = $grouplevel['specialswitch']['membermaximum'];
if(!empty($membermaximum)) {
$curnum = C::t('forum_groupuser')->fetch_count_by_fid($id, -1);
if($curnum >= $membermaximum) {
showmessage('group_member_maximum', '', array('membermaximum' => $membermaximum));
}
}
$groupname = $foruminfo['name'];
$invitename = lang('group/misc', 'group_join', array('groupname' => $groupname));
if(!submitcheck('invitesubmit')) {
$friends = friend_list($_G['uid'], 100);
if(!empty($friends)) {
$frienduids = array_keys($friends);
$inviteduids = array();
$query = C::t('forum_groupinvite')->fetch_all_inviteuid($id, $frienduids, $_G['uid']);
foreach($query as $inviteuser) {
$inviteduids[$inviteuser['inviteuid']] = $inviteuser['inviteuid'];
}
$query = C::t('forum_groupuser')->fetch_all_userinfo($frienduids, $id);
foreach($query as $inviteuser) {
$inviteduids[$inviteuser['uid']] = $inviteuser['uid'];
}
}
$inviteduids = !empty($inviteduids) ? implode(',', $inviteduids) : '';
} else {
$uids = $_GET['uids'];
if($uids) {
if(count($uids) > 20) {
showmessage('group_choose_friends_max');
}
foreach(C::t('common_member')->fetch_all($uids, false, 0) as $uid => $user) {
C::t('forum_groupinvite')->insert(array('fid' => $id, 'uid' => $_G['uid'], 'inviteuid' => $uid, 'dateline' => TIMESTAMP), true, true);
$already = C::t('forum_groupinvite')->affected_rows();
if($already == 1) {
notification_add($uid, 'group', 'group_member_invite', array('groupname' => $groupname, 'fid' => $id, 'url' =>'forum.php?mod=group&action=join&fid='.$id, 'from_id' => $id, 'from_idtype' => 'invite_group'), 1);
}
}
showmessage('group_invite_succeed', "forum.php?mod=group&fid=$id");
} else {
showmessage('group_invite_choose_member', "forum.php?mod=group&fid=$id");
}
}
} elseif($_GET['action'] == 'thread') {
$inviteduids = array();
$id = intval($_GET['id']);
$thread = C::t('forum_thread')->fetch_thread($id);
$at = 0;
$maxselect = 20;
if(empty($_GET['activity'])) {
$at = 1;
$maxselect = 0;
if($_G['group']['allowat']) {
$atnum = 0;
foreach(C::t('home_notification')->fetch_all_by_authorid_fromid($_G['uid'], $id, 'at') as $row) {
$atnum ++;
$inviteduids[$row['uid']] = $row['uid'];
}
$maxselect = $_G['group']['allowat'] - $atnum;
} else {
showmessage('noperm_at_user');
}
if($maxselect <= 0) {
showmessage('thread_at_usernum_limit');
}
$invitename = lang('forum/misc', 'at_invite');
} else {
$invitename = lang('forum/misc', 'join_activity');
}
if(!submitcheck('invitesubmit')) {
$inviteduids = !empty($inviteduids) ? implode(',', $inviteduids) : '';
} else {
$uids = $_GET['uids'];
if($uids) {
if(count($uids) > $maxselect) {
showmessage('group_choose_friends_max');
}
$post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($id);
require_once libfile('function/post');
$post['message'] = threadmessagecutstr($thread, $post['message'], 150);
foreach(C::t('common_member')->fetch_all($uids, false, 0) as $uid => $user) {
if($at) {
notification_add($uid, 'at', 'at_message', array('from_id' => $id, 'from_idtype' => 'at', 'buyerid' => $_G['uid'], 'buyer' => $_G['username'], 'tid' => $id, 'subject' => $thread['subject'], 'pid' => $post['pid'], 'message' => $post['message']));
} else {
notification_add($uid, 'thread', 'thread_invite', array('subject' => $thread['subject'], 'invitename' => $invitename, 'tid' => $id, 'from_id' => $id, 'from_idtype' => 'invite_thread'));
}
}
showmessage(($at ? 'at_succeed' : 'group_invite_succeed'), "forum.php?mod=viewthread&tid=$id");
} else {
showmessage(($at ? 'at_choose_member' : 'group_invite_choose_member'), "forum.php?mod=viewthread&tid=$id");
}
}
} elseif($_GET['action'] == 'blog') {
$id = intval($_GET['id']);
$blog = C::t('home_blog')->fetch($id);
if(!submitcheck('invitesubmit')) {
$inviteduids = '';
} else {
$uids = $_GET['uids'];
if($uids) {
if(count($uids) > 20) {
showmessage('group_choose_friends_max');
}
foreach(C::t('common_member')->fetch_all($uids, false, 0) as $uid => $user) {
notification_add($uid, 'blog', 'blog_invite', array('subject' => $blog['subject'], 'uid' => $blog['uid'], 'blogid' => $id, 'from_id' => $id, 'from_idtype' => 'invite_blog'));
}
showmessage('group_invite_succeed', "home.php?mod=space&uid=".$blog['uid']."&do=blog&id=$id");
} else {
showmessage('group_invite_choose_member', "home.php?mod=space&uid=".$blog['uid']."&do=blog&id=$id");
}
}
} elseif($_GET['action'] == 'article') {
$id = intval($_GET['id']);
$article = C::t('portal_article_title')->fetch($id);
if(!submitcheck('invitesubmit')) {
$inviteduids = '';
} else {
require_once libfile('function/portal');
$article_url = fetch_article_url($article);
$uids = $_GET['uids'];
if($uids) {
if(count($uids) > 20) {
showmessage('group_choose_friends_max');
}
foreach(C::t('common_member')->fetch_all($uids, false, 0) as $uid => $user) {
notification_add($uid, 'article', 'article_invite', array('subject' => $article['title'], 'url' => $article_url, 'from_id' => $id, 'from_idtype' => 'invite_article'));
}
showmessage('group_invite_succeed', $article_url);
} else {
showmessage('group_invite_choose_member', $article_url);
}
}
}
include template('common/invite');
?>

View File

@@ -0,0 +1,94 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_mobile.php 36284 2016-12-12 00:47:50Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if($mod == 'mobile' && defined('IN_MOBILE')) {
if($_G['setting']['domain']['app']['mobile']) {
dheader('Location:'.$_G['scheme'].'://'.$_G['setting']['domain']['app']['mobile']);
} else {
dheader('Location:'.$_G['siteurl'].'forum.php?mobile=yes');
}
} elseif(!$_G['setting']['mobile']['allowmobile']) {
dheader("Location:".($_G['setting']['domain']['app']['default'] ? $_G['scheme'].'://'.$_G['setting']['domain']['app']['default'] : $_G['siteurl']));
}
include DISCUZ_ROOT.'./source/language/touch/lang_template.php';
$_G['lang'] = array_merge($_G['lang'], $lang);
$navtitle = $_G['lang']['misc_mobile_title'];
if(getgpc('view') == true) {
include libfile('function/forumlist');
loadcache('userstats');
loadcache('historyposts');
$postdata = $_G['cache']['historyposts'] ? explode("\t", $_G['cache']['historyposts']) : array(0,0);
$postdata[0] = intval($postdata[0]);
$postdata[1] = intval($postdata[1]);
$query = C::t('forum_forum')->fetch_all_forum(1);
$threads = $posts = $todayposts = 0;
foreach($query as $forum) {
if($forum['type'] != 'group') {
$threads += $forum['threads'];
$posts += $forum['posts'];
$todayposts += $forum['todayposts'];
if($forum['type'] == 'forum' && isset($catlist[$forum['fup']])) {
if(forum($forum)) {
$catlist[$forum['fup']]['forums'][] = $forum['fid'];
$forum['orderid'] = $catlist[$forum['fup']]['forumscount']++;
$forum['subforums'] = '';
$forumlist[$forum['fid']] = $forum;
}
} elseif(isset($forumlist[$forum['fup']])) {
$forumlist[$forum['fup']]['threads'] += $forum['threads'];
$forumlist[$forum['fup']]['posts'] += $forum['posts'];
$forumlist[$forum['fup']]['todayposts'] += $forum['todayposts'];
}
} else {
$forum['forumscount'] = 0;
$catlist[$forum['fid']] = $forum;
}
}
$_GET['forumlist'] = 1;
define('IN_MOBILE',2);
define('IN_PREVIEW',1);
ob_start();
include template('forum/discuz');
} else {
if(getglobal('setting/domain/app/mobile')) {
$url = $_G['scheme'].'://'.$_G['setting']['domain']['app']['mobile'];
$file = 'newmobiledomain.png';
} else {
$url = $_G['siteurl'];
$file = 'newmobile.png';
}
$qrimg = DISCUZ_ROOT.'./data/cache/'.$file;
if(!file_exists($qrimg)) {
require_once DISCUZ_ROOT.'source/plugin/mobile/qrcode.class.php';
QRcode::png($url, $qrimg, QR_ECLEVEL_Q, 4);
}
include template('touch/common/preview');
}
function output_preview() {
$content = ob_get_contents();
ob_end_clean();
ob_start();
$content = preg_replace_callback("/(\<a[^\>]+href=\").*?(\"[^\>]*\>)/", 'output_preview_callback_replace_href_21', $content);
$content = preg_replace("/\<script.+?\<\/script\>/", '', $content);
$content = str_replace('</body>' , '<script>document.querySelectorAll(\'a\').forEach(function (a) {a.addEventListener(\'click\', function (e) {e.preventDefault();return false;});})</script></body>', $content);
echo $content;
exit;
}
function output_preview_callback_replace_href_21($matches) {
return $matches[1].'misc.php?mod=mobile&view=true'.$matches[2];;
}
?>

View File

@@ -0,0 +1,72 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_patch.php 33690 2013-08-02 09:07:22Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if($_GET['action'] == 'pluginnotice') {
require_once libfile('function/admincp');
require_once libfile('function/plugin');
require_once libfile('function/cloudaddons');
$pluginarray = C::t('common_plugin')->fetch_all_data();
$addonids = $vers = array();
foreach($pluginarray as $row) {
if(ispluginkey($row['identifier'])) {
$addonids[] = $row['identifier'].'.plugin';
$vers[$row['identifier'].'.plugin'] = $row['version'];
}
}
$checkresult = dunserialize(cloudaddons_upgradecheck($addonids));
savecache('addoncheck_plugin', $checkresult);
$newversion = 0;
if(is_array($checkresult)) {
foreach($checkresult as $addonid => $value) {
list(, $newver, $sysver) = explode(':', $value);
if($sysver && $sysver > $vers[$addonid] || $newver) {
$newversion++;
}
}
}
include template('common/header_ajax');
if($newversion) {
$lang = lang('forum/misc');
echo '<div class="bm"><div class="bm_h cl"><a href="javascript:;" onclick="$(\'plugin_notice\').style.display=\'none\';setcookie(\'pluginnotice\', 1, 86400)" class="y" title="'.$lang['patch_close'].'">'.$lang['patch_close'].'</a>';
echo '<h2 class="i">'.$lang['plugin_title'].'</h2></div><div class="bm_c">';
echo '<div class="cl bbda pbm">'.lang('forum/misc', 'plugin_memo', array('number' => $newversion)).'</div>';
echo '<div class="ptn cl"><a href="admin.php?action=plugins" class="xi2 y">'.$lang['plugin_link'].' &raquo;</a></div>';
echo '</div></div>';
}
include template('common/footer_ajax');
exit;
} elseif($_GET['action'] == 'ipnotice') {
require_once libfile('function/misc');
include template('common/header_ajax');
if($_G['cookie']['lip'] && $_G['cookie']['lip'] != ',' && $_G['uid'] && getglobal('setting/disableipnotice') != 1) {
$status = C::t('common_member_status')->fetch($_G['uid']);
$lip = explode(',', $_G['cookie']['lip']);
$lastipConvert = convertip($lip[0]);
$lastipDate = dgmdate($lip[1]);
$nowipConvert = convertip($status['lastip']);
$lastipConvert = process_ipnotice($lastipConvert);
$nowipConvert = process_ipnotice($nowipConvert);
if($lastipConvert != $nowipConvert && stripos($lastipConvert, $nowipConvert) === false && stripos($nowipConvert, $lastipConvert) === false) {
$lang = lang('forum/misc');
include template('common/ipnotice');
}
}
include template('common/footer_ajax');
exit;
}
?>

View File

@@ -0,0 +1,486 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_ranklist.php 32807 2013-03-13 08:49:49Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['setting']['rankliststatus']) {
showmessage('ranklist_status_off');
}
$page = $_G['page'];
$type = $_GET['type'];
$_G['disabledwidthauto'] = 1;
if(!in_array($type, array('index', 'member', 'thread', 'blog', 'poll', 'picture', 'activity', 'forum', 'group'))) {
$type = 'index';
}
$ranklist_setting = $_G['setting']['ranklist'];
$navtitle = lang('core', 'title_ranklist_'.$type);
$allowtype = array('member' => 'ranklist', 'thread' => 'forum', 'blog' => 'blog', 'poll' => 'forum', 'picture' => 'album', 'activity' => 'forum', 'forum' => 'forum', 'group' => 'group');
if($type != 'index') {
if(!array_key_exists($type, $allowtype) || !$_G['setting'][$allowtype[$type].'status'] || !$ranklist_setting[$type]['available']) {
showmessage('ranklist_this_status_off');
}
}
include libfile('misc/ranklist_'.$type, 'include');
function getranklist_thread($num = 20, $view = 'replies', $orderby = 'all') {
global $_G;
$dateline = '';
$timestamp = 0;
if($orderby == 'today') {
$timestamp = TIMESTAMP - 86400;
} elseif($orderby == 'thisweek') {
$timestamp = TIMESTAMP - 604800;
} elseif($orderby == 'thismonth') {
$timestamp = TIMESTAMP - 2592000;
}
$data = array();
$rank = 0;
$notfid = $_G['setting']['ranklist']['ignorefid'] ? explode(',', $_G['setting']['ranklist']['ignorefid']) : array();
foreach(C::t('forum_thread')->fetch_all_rank_thread($timestamp, $notfid, $view, $num) as $thread) {
++$rank;
$thread['rank'] = $rank;
$thread['dateline'] = dgmdate($thread['dateline']);
$data[] = $thread;
}
return $data;
}
function getranklist_poll($num = 20, $view = 'heats', $orderby = 'all') {
global $_G;
$dateline = '';
$timestamp = 0;
if($orderby == 'today') {
$timestamp = TIMESTAMP - 86400;
} elseif($orderby == 'thisweek') {
$timestamp = TIMESTAMP - 604800;
} elseif($orderby == 'thismonth') {
$timestamp = TIMESTAMP - 2592000;
}
$data = array();
require_once libfile('function/forum');
$rank = 0;
$notfid = $_G['setting']['ranklist']['ignorefid'] ? explode(',', $_G['setting']['ranklist']['ignorefid']) : array();
foreach(C::t('forum_thread')->fetch_all_rank_poll($timestamp, $notfid, $view, $num) as $poll) {
++$rank;
$poll['rank'] = $rank;
$poll['avatar'] = avatar($poll['authorid'], 'small');
$poll['dateline'] = dgmdate($poll['dateline']);
$poll['pollpreview'] = explode("\t", trim($poll['pollpreview']));
$data[] = $poll;
}
return $data;
}
function getranklist_activity($num = 20, $view = 'heats', $orderby = 'all') {
global $_G;
$dateline = '';
$timestamp = 0;
if($orderby == 'today') {
$timestamp = TIMESTAMP - 86400;
} elseif($orderby == 'thisweek') {
$timestamp = TIMESTAMP - 604800;
} elseif($orderby == 'thismonth') {
$timestamp = TIMESTAMP - 2592000;
}
$data = array();
$rank = 0;$attachtables = array();
$notfid = $_G['setting']['ranklist']['ignorefid'] ? explode(',', $_G['setting']['ranklist']['ignorefid']) : array();
foreach(C::t('forum_thread')->fetch_all_rank_activity($timestamp, $notfid, $view, $num) as $thread) {
++$rank;
$thread['rank'] = $rank;
$thread['starttimefrom'] = dgmdate($thread['starttimefrom']);
if($thread['starttimeto']) {
$thread['starttimeto'] = dgmdate($thread['starttimeto']);
} else {
$thread['starttimeto'] = '';
}
if($thread['expiration'] && TIMESTAMP > $thread['expiration']) {
$thread['has_expiration'] = true;
} else {
$thread['has_expiration'] = false;
}
$data[$thread['tid']] = $thread;
$attachtables[getattachtableid($thread['tid'])][] = $thread['aid'];
}
foreach($attachtables as $attachtable => $aids) {
$attachs = C::t('forum_attachment_n')->fetch_all_attachment($attachtable, $aids);
foreach($attachs as $attach) {
$attach['attachurl'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$attach['attachment'];
$data[$attach['tid']] = array_merge($data[$attach['tid']], $attach);
}
}
return $data;
}
function getranklist_picture($num = 20, $view = 'hot', $orderby = 'all') {
if($orderby == 'thisweek') {
$timestamp = TIMESTAMP - 604800;
$dateline = 'p.'.DB::field('dateline', $timestamp, '>=');
} elseif($orderby == 'thismonth') {
$timestamp = TIMESTAMP - 2592000;
$dateline = 'p.'.DB::field('dateline', $timestamp, '>=');
} elseif($orderby == 'today') {
$timestamp = TIMESTAMP - 86400;
$dateline = 'p.'.DB::field('dateline', $timestamp, '>=');
}
$data = array();
$query = C::t('home_pic')->fetch_all_by_sql($dateline, 'p.'.DB::order($view, 'DESC'), 0, $num);
require_once libfile('function/home');
$rank = 0;
foreach($query as $value) {
++$rank;
$picture = array('picid' => $value['picid'], 'uid' => $value['uid'], 'username' => $value['username'], 'title' => $value['title'], 'filepath' => $value['filepath'], 'thumb' => $value['thumb'], 'remote' => $value['remote'], 'hot' => $value['hot'], 'sharetimes' => $value['sharetimes'], 'click1' => $value['click1'], 'click2' => $value['click2'], 'click3' => $value['click3'], 'click4' => $value['click4'], 'click5' => $value['click5'], 'click6' => $value['click6'], 'click7' => $value['click7'], 'click8' => $value['click8'], 'albumid' => $value['albumid'], 'albumname' => $value['albumname'], 'friend' => $value['friend']);
$picture['rank'] = $rank;
$picture['url'] = $picture['friend'] == 0 ? pic_get($picture['filepath'], 'album', $picture['thumb'], $picture['remote']) : STATICURL.'image/common/nopublish.svg';;
$picture['origurl'] = pic_get($picture['filepath'], 'album', 0, $picture['remote']);
$data[] = $picture;
}
return $data;
}
function getranklist_pictures_index($num = 20, $dateline = 0, $orderby = 'hot DESC') {
$picturelist = array();
$query = C::t('home_pic')->fetch_all_by_sql('p.hot>3', 'p.dateline DESC', 0, $num);
require_once libfile('function/home');
foreach($query as $value) {
$picture = array('picid' => $value['picid'], 'uid' => $value['uid'], 'username' => $value['username'], 'title' => $value['title'], 'filepath' => $value['filepath'], 'thumb' => $value['thumb'], 'remote' => $value['remote'], 'albumid' => $value['albumid'], 'albumname' => $value['albumname'], 'friend' => $value['friend']);
$picture['url'] = $picture['friend'] == 0 ? pic_get($picture['filepath'], 'album', $picture['thumb'], $picture['remote']) : STATICURL.'image/common/nopublish.svg';;
$picture['origurl'] = $picture['friend'] == 0 ? pic_get($picture['filepath'], 'album', 0, $picture['remote']) : STATICURL.'image/common/nopublish.svg';
$picturelist[] = $picture;
}
return $picturelist;
}
function getranklist_members($offset = 0, $limit = 20) {
require_once libfile('function/forum');
$members = array();
$topusers = C::t('home_show')->fetch_all_by_unitprice($offset, $limit, true);
foreach($topusers as $member) {
$member['avatar'] = avatar($member['uid'], 'small');
$member['note'] = htmlspecialchars(dhtmlspecialchars($member['note']));
$members[] = $member;
}
return $members;
}
function getranklist_girls($offset = 0, $limit = 20, $orderby = 'ORDER BY s.unitprice DESC, s.credit DESC') {
return C::t('common_member')->fetch_all_girls_for_ranklist($offset, $limit, $orderby);
}
function getranklist_blog($num = 20, $view = 'hot', $orderby = 'all') {
$dateline = $timestamp = '';
if($orderby == 'today') {
$timestamp = TIMESTAMP - 86400;
} elseif($orderby == 'thisweek') {
$timestamp = TIMESTAMP - 604800;
} elseif($orderby == 'thismonth') {
$timestamp = TIMESTAMP - 2592000;
}
$data = array();
$data_blog = C::t('home_blog')->range_blog(0, $num, 'DESC', $view, 0, 0, null, $timestamp);
$blogids = array_keys($data_blog);
$data_blogfield = C::t('home_blogfield')->fetch_all($blogids);
require_once libfile('function/forum');
require_once libfile('function/post');
$rank = 0;
foreach($data_blog as $curblogid => $blog) {
$blog = array_merge($blog, (array)$data_blogfield[$curblogid]);
++$rank;
$blog['rank'] = $rank;
$blog['dateline'] = dgmdate($blog['dateline']);
$blog['avatar'] = avatar($blog['uid'], 'small');
$blog['message'] = preg_replace('/<([^>]*?)>/', '', $blog['message']);
$blog['message'] = messagecutstr($blog['message'], 140);
$data[] = $blog;
}
return $data;
}
function getranklist_forum($num = 20, $view = 'threads') {
global $_G;
$data = array();
$timelimit = 0;
if($view == 'posts') {
$key = 'posts';
} elseif($view == 'today') {
$key = 'todayposts';
} else {
$key = 'threads';
}
$query = C::t('forum_forum')->fetch_all_for_ranklist(1, 0, $key, 0, $num, explode(',', $_G['setting']['ranklist']['ignorefid']));
$i = 1;
foreach($query as $row) {
$result = array('fid' => $row['fid'], 'name' => $row['name']);
$result['posts'] = $row[$key];
$result['rank'] = $i;
$data[] = $result;
$i++;
}
return $data;
}
function getranklist_group($num = 20, $view = 'threads') {
global $_G;
$timestamp = TIMESTAMP;
$data = array();
$timelimit = 0;
if($view == 'posts') {
$key = 'posts';
} elseif($view == 'today'){
$key = 'todayposts';
} elseif($view == 'credit'){
$key = 'commoncredits';
} elseif($view == 'member'){
$key = 'membernum';
} else {
$key = 'threads';
}
$query = C::t('forum_forum')->fetch_all_for_ranklist(3, 'sub', $key, 0, $num, explode(',', $_G['setting']['ranklist']['ignorefid']));
$i = 1;
foreach($query as $row) {
$result = array('fid' => $row['fid'], 'name' => $row['name']);
$result[$key] = $result['posts'] = $row[$key];
$result['rank'] = $i;
$data[] = $result;
$i++;
}
return $data;
}
function getranklist_member($num = 20, $view = 'credit', $orderby = 'all') {
$data = array();
$functionname = 'getranklist_member_'.$view;
$data = $functionname($num, $orderby);
return $data;
}
function getranklist_member_credit($num, $orderby) {
return C::t('common_member')->fetch_all_order_by_credit_for_ranklist($num, $orderby);
}
function getranklist_member_friendnum($num) {
return C::t('common_member')->fetch_all_order_by_friendnum_for_ranklist($num);
}
function getranklist_member_invite($num, $orderby) {
global $_G;
if($orderby == 'thisweek') {
$dateline = TIMESTAMP - 604800;
} elseif($orderby == 'thismonth') {
$dateline = TIMESTAMP - 2592000;
} elseif($orderby == 'today') {
$dateline = TIMESTAMP - 86400;
}
$invite = $invitearray = $inviteuidarray = $invitefieldarray = array();
foreach(C::t('common_invite')->fetch_all_invitenum_group_by_uid($dateline) as $result) {
$invitearray[] = $result;
$inviteuidarray[] = $result['uid'];
}
$invitememberfield = C::t('common_member')->fetch_all($inviteuidarray, false, 0);
if($invitearray) {
foreach($invitearray as $key => $var) {
$invite[] = $var;
$invite[$key]['username'] = $invitememberfield[$var['uid']]['username'];
$invite[$key]['groupid'] = $invitememberfield[$var['uid']]['groupid'];
}
}
return $invite;
}
function getranklist_member_onlinetime($num, $orderby) {
global $_G;
if($orderby == 'thismonth') {
$orderby = 'thismonth';
$online = 'thismonth AS onlinetime';
} elseif($orderby == 'all') {
$orderby = 'total';
$online = 'total AS onlinetime';
}
$onlinetime = $onlinetimearray = $onlinetimeuidarray = $onlinetimefieldarray = array();
$onlinetimearray = C::t('common_onlinetime')->range_by_field(0, $num, $orderby, 'DESC');
$onlinetimeuidarray = array_keys($onlinetimearray);
$onlinetimefieldarray = C::t('common_member')->fetch_all($onlinetimeuidarray, false, 0);
if($onlinetimearray) {
foreach($onlinetimearray as $key => $var) {
$var['onlinetime'] = $var[$orderby];
$var['username'] = $onlinetimefieldarray[$var['uid']]['username'];
$var['groupid'] = $onlinetimefieldarray[$var['uid']]['groupid'];
$onlinetime[$key] = $var;
}
}
return $onlinetime;
}
function getranklist_member_blog($num) {
global $_G;
$blogs = array();
$sql = "SELECT m.uid,m.username,m.groupid,c.blogs FROM ".DB::table('common_member').
" m LEFT JOIN ".DB::table('common_member_count')." c ON m.uid=c.uid WHERE c.blogs>0 ORDER BY blogs DESC LIMIT 0, $num";
$query = DB::query($sql);
while($result = DB::fetch($query)) {
$blogs[] = $result;
}
return $blogs;
}
function getranklist_member_gender($gender, $num = 20) {
global $_G;
$num = intval($num);
$num = $num ? $num : 20;
$users = array();
$query = DB::query("SELECT c.uid, c.views FROM ".DB::table('common_member_count')." c
LEFT JOIN ".DB::table('common_member_profile')." p ON c.uid=p.uid
WHERE c.views>0 AND p.gender = '$gender' ORDER BY c.views DESC LIMIT 0, $num");
while($user = DB::fetch($query)) {
$users[$user['uid']] = $user;
}
$uids = array_keys($users);
if($uids) {
foreach(C::t('common_member')->fetch_all($uids, false, 0) as $uid => $value) {
$users[$uid] = array_merge($users[$uid], $value);
}
}
return $users;
}
function getranklist_member_beauty($num = 20) {
return getranklist_member_gender(2, $num);
}
function getranklist_member_handsome($num = 20) {
return getranklist_member_gender(1, $num);
}
function getranklist_member_post($num, $orderby) {
global $_G;
$timestamp = TIMESTAMP;
$posts = array();
$timelimit = 0;
if($orderby == 'digestposts') {
$sql = "SELECT m.username, m.uid, mc.digestposts AS posts
FROM ".DB::table('common_member')." m
LEFT JOIN ".DB::table('common_member_count')." mc ON mc.uid=m.uid WHERE mc.digestposts>0
ORDER BY mc.digestposts DESC LIMIT 0, $num";
} elseif($orderby == 'thismonth') {
$timelimit = $timestamp-86400*30;
} elseif($orderby == 'today') {
$timelimit = $timestamp-86400;
} else {
$sql = "SELECT m.username, m.uid, mc.posts
FROM ".DB::table('common_member')." m
LEFT JOIN ".DB::table('common_member_count')." mc ON mc.uid=m.uid WHERE mc.posts>0
ORDER BY mc.posts DESC LIMIT 0, $num";
}
if($timelimit) {
$posts = C::t('forum_post')->fetch_all_top_post_author(0, $timelimit, $num);
} else {
$query = DB::query($sql);
while($result = DB::fetch($query)) {
$posts[] = $result;
}
}
return $posts;
}
function getranklistdata($type, $view = '', $orderby = 'all') {
if (!function_exists('getranklist_'.$type)) {
return array();
}
global $_G;
$cache_time = $_G['setting']['ranklist'][$type]['cache_time'];
$cache_num = $_G['setting']['ranklist'][$type]['show_num'];
if($cache_time <= 0 ) {
$cache_time = 5;
}
$cache_time = $cache_time * 3600;
if($cache_num <= 0 ) {
$cache_num = 20;
}
$ranklistvars = array();
loadcache('ranklist_'.$type);
if(!isset($_G['cache']['ranklist_'.$type]) || !is_array($_G['cache']['ranklist_'.$type])) {
$_G['cache']['ranklist_'.$type] = array();
}
if(!isset($_G['cache']['ranklist_'.$type][$view]) || !is_array($_G['cache']['ranklist_'.$type][$view])) {
$_G['cache']['ranklist_'.$type][$view] = array();
}
if(!isset($_G['cache']['ranklist_'.$type][$view][$orderby]) || !is_array($_G['cache']['ranklist_'.$type][$view][$orderby])) {
$_G['cache']['ranklist_'.$type][$view][$orderby] = array();
}
$ranklistvars = & $_G['cache']['ranklist_'.$type][$view][$orderby];
if(empty($ranklistvars['lastupdated']) || (TIMESTAMP - $ranklistvars['lastupdated'] > $cache_time)) {
$functionname = 'getranklist_'.$type;
if(!discuz_process::islocked('ranklist_update', 600)) {
$ranklistvars = $functionname($cache_num, $view, $orderby);
$ranklistvars['lastupdated'] = TIMESTAMP;
$ranklistvars['lastupdate'] = dgmdate(TIMESTAMP);
$ranklistvars['nextupdate'] = dgmdate(TIMESTAMP + $cache_time);
$_G['cache']['ranklist_'.$type][$view][$orderby] = $ranklistvars;
savecache('ranklist_'.$type, $_G['cache']['ranklist_'.$type]);
}
discuz_process::unlock('ranklist_update');
}
$_G['lastupdate'] = $ranklistvars['lastupdate'];
$_G['nextupdate'] = $ranklistvars['nextupdate'];
unset($ranklistvars['lastupdated'], $ranklistvars['lastupdate'], $ranklistvars['nextupdate']);
return $ranklistvars;
}
function getignorefid($pre = '') {
global $_G;
$fidsql = '';
if($_G['setting']['ranklist']['ignorefid']) {
$fidsql = ' AND '.($pre ? $pre.'.' : '').'fid NOT IN('.dimplode(explode(',', $_G['setting']['ranklist']['ignorefid'])).')';
}
return $fidsql;
}
?>

View File

@@ -0,0 +1,75 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_report.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(empty($_G['uid'])) {
showmessage('not_loggedin', null, array(), array('login' => 1));
}
$rtype = $_GET['rtype'];
$rid = intval($_GET['rid']);
$tid = intval($_GET['tid']);
$fid = intval($_GET['fid']);
$uid = intval($_GET['uid']);
$default_url = array(
'user' => 'home.php?mod=space&uid=',
'post' => 'forum.php?mod=redirect&goto=findpost&ptid='.$tid.'&pid=',
'thread' => 'forum.php?mod=viewthread&tid=',
'group' => 'forum.php?mod=group&fid=',
'album' => 'home.php?mod=space&do=album&uid='.$uid.'&id=',
'blog' => 'home.php?mod=space&do=blog&uid='.$uid.'&id=',
'pic' => 'home.php?mod=space&do=album&uid='.$uid.'&picid='
);
$url = '';
if($rid && !empty($default_url[$rtype])) {
$url = $default_url[$rtype].intval($rid);
} else {
$url = addslashes(dhtmlspecialchars(base64_decode($_GET['url'])));
$url = preg_match("/^http[s]?:\/\/[^\[\"']+$/i", trim($url)) ? trim($url) : '';
}
if(empty($url) || empty($_G['inajax'])) {
showmessage('report_parameters_invalid');
}
$urlkey = md5($url);
if(submitcheck('reportsubmit')) {
$message = censor(cutstr(dhtmlspecialchars(trim($_GET['message'])), 200, ''));
$message = $_G['username'].'&nbsp;:&nbsp;'.rtrim($message, "\\");
if($reportid = C::t('common_report')->fetch_by_urlkey($urlkey)) {
C::t('common_report')->update_num($reportid, $message);
} else {
$data = array('url' => $url, 'urlkey' => $urlkey, 'uid' => $_G['uid'], 'username' => $_G['username'], 'message' => $message, 'dateline' => TIMESTAMP);
if($fid) {
$data['fid'] = $fid;
}
C::t('common_report')->insert($data);
$report_receive = dunserialize($_G['setting']['report_receive']);
$moderators = array();
if($report_receive['adminuser']) {
foreach($report_receive['adminuser'] as $touid) {
notification_add($touid, 'report', 'new_report', array('from_id' => 1, 'from_idtype' => 'newreport', 'username' => $_G['username']), 1);
}
}
if($fid && $rtype == 'post') {
foreach(C::t('forum_moderator')->fetch_all_by_fid($fid, false) as $row) {
$moderators[] = $row['uid'];
}
if($report_receive['supmoderator']) {
$moderators = array_unique(array_merge($moderators, $report_receive['supmoderator']));
}
foreach($moderators as $touid) {
$touid != $_G['uid'] && !in_array($touid, $report_receive['adminuser']) && notification_add($touid, 'report', 'new_post_report', array('fid' => $fid, 'from_id' => 1, 'from_idtype' => 'newreport', 'username' => $_G['username']), 1);
}
}
}
showmessage('report_succeed', '', array(), array('closetime' => true, 'showdialog' => 1, 'alert' => 'right'));
}
require_once libfile('function/misc');
include template('common/report');
?>

View File

@@ -0,0 +1,214 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_seccode.php 34646 2014-06-17 03:23:15Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$idhash = isset($_GET['idhash']) && preg_match('/^\w+$/', $_GET['idhash']) ? $_GET['idhash'] : '';
$modid = isset($_GET['modid']) && preg_match('/^[\w:]+$/', $_GET['modid']) ? $_GET['modid'] : '';
if(getgpc('action') == 'update' && !defined("IN_MOBILE")) {
$message = '';
$showid = 'seccode_'.$idhash;
$rand = random(5, 1);
$htmlcode = '';
$ani = $_G['setting']['seccodedata']['animator'] ? '_ani' : '';
if($_G['setting']['seccodedata']['type'] == 2) {
$htmlcode = extension_loaded('ming') ?
"$('seccodeswf_$idhash').innerHTML='".lang('core', 'seccode_image'.$ani.'_tips')."' + AC_FL_RunContent('width', '".$_G['setting']['seccodedata']['width']."', 'height', '".$_G['setting']['seccodedata']['height']."', 'src', 'misc.php?mod=seccode&update=$rand&idhash=$idhash','quality', 'high', 'wmode', 'transparent', 'bgcolor', '#ffffff','align', 'middle', 'menu', 'false', 'allowScriptAccess', 'never');" :
"$('seccodeswf_$idhash').innerHTML='".lang('core', 'seccode_image'.$ani.'_tips')."' + AC_FL_RunContent('width', '".$_G['setting']['seccodedata']['width']."', 'height', '".$_G['setting']['seccodedata']['height']."', 'src', '{$_G['siteurl']}static/image/seccode/flash/flash2.swf', 'FlashVars', 'sFile=".rawurlencode("{$_G['siteurl']}misc.php?mod=seccode&update=$rand&idhash=$idhash")."', 'menu', 'false', 'allowScriptAccess', 'never', 'swLiveConnect', 'true', 'wmode', 'transparent');";
$message = '<span id="seccodeswf_'.$idhash.'"></span>';
} elseif($_G['setting']['seccodedata']['type'] == 3) {
$htmlcode = "(function(){var a=document.createElement('audio');a.src='{$_G['siteurl']}misc.php?mod=seccode&update=$rand&idhash=$idhash&fromFlash=1',a.style.display='none',$('seccodeplay_$idhash').onclick=function(){a.play()},$('seccodeswf_$idhash').appendChild(a)})();";
$message = '<span id="seccodeswf_'.$idhash.'">'.lang('core', 'seccode_sound_tips').'</span>'.lang('forum/misc', 'seccode_player', array('idhash' => $idhash));
} else {
if(!is_numeric($_G['setting']['seccodedata']['type']) && preg_match('/^[\w\d:_]+$/i', $_G['setting']['seccodedata']['type'])) {
$etype = explode(':', $_G['setting']['seccodedata']['type']);
if(count($etype) > 1) {
$codefile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/seccode/seccode_'.$etype[1].'.php';
$class = $etype[1];
} else {
$codefile = libfile('seccode/'.$_G['setting']['seccodedata']['type'], 'class');
$class = $_G['setting']['seccodedata']['type'];
}
if(file_exists($codefile)) {
@include_once $codefile;
$class = 'seccode_'.$class;
if(class_exists($class)) {
$code = new $class();
if(method_exists($code, 'make')) {
ob_start();
$seccode = $code->make($idhash, $modid);
make_seccode($seccode);
$message = preg_replace("/\r|\n/", '', ob_get_contents());
ob_end_clean();
}
}
}
} else {
$message = lang('core', 'seccode_image'.$ani.'_tips').'<img onclick="updateseccode(\''.$idhash.'\')" width="'.$_G['setting']['seccodedata']['width'].'" height="'.$_G['setting']['seccodedata']['height'].'" src="misc.php?mod=seccode&update='.$rand.'&idhash='.$idhash.'" class="vm" alt="" />';
}
}
$imemode = $_G['setting']['seccodedata']['type'] != 1 ? 'ime-mode:disabled;' : '';
$message = str_replace("'", "\'", $message);
$seclang = lang('forum/misc');
header("Content-Type: application/javascript");
echo <<<EOF
if($('$showid')) {
if(!$('v$showid')) {
var sectpl = seccheck_tpl['$idhash'] != '' ? seccheck_tpl['$idhash'].replace(/<hash>/g, 'code$idhash') : '';
var sectplcode = sectpl != '' ? sectpl.split('<sec>') : Array('<br />',': ','<br />','');
var string = '<input name="seccodehash" type="hidden" value="$idhash" /><input name="seccodemodid" type="hidden" value="$modid" />' + sectplcode[0] + '{$seclang['seccode']}' + sectplcode[1] + '<input name="seccodeverify" id="seccodeverify_$idhash" type="text" autocomplete="off" style="{$imemode}width:100px" class="txt px vm" onblur="checksec(\'code\', \'$idhash\', 0, null, \'$modid\')" />' +
' <a href="javascript:;" onclick="updateseccode(\'$idhash\');doane(event);" class="xi2">{$seclang['seccode_update']}</a>' +
'<span id="checkseccodeverify_$idhash"><i class="fico-checkbox fic4 fc-t fnmr vm"></i></span>' +
sectplcode[2] + '<span id="v$showid">$message</span>' + sectplcode[3];
evalscript(string);
$('$showid').innerHTML = string;
} else {
var string = '$message';
evalscript(string);
$('v$showid').innerHTML = string;
}
$htmlcode
}
EOF;
} elseif(getgpc('action') == 'update' && defined("IN_MOBILE") && constant("IN_MOBILE") == 2) {
$message = '';
$showid = 'seccode_'.$idhash;
$rand = random(5, 1);
$htmlcode = '';
$ani = $_G['setting']['seccodedata']['animator'] ? '_ani' : '';
if($_G['setting']['seccodedata']['type'] == 2 || $_G['setting']['seccodedata']['type'] == 3) {
$message = '<img onclick="updateseccode(\''.$idhash.'\')" width="'.$_G['setting']['seccodedata']['width'].'" height="'.$_G['setting']['seccodedata']['height'].'" src="misc.php?mod=seccode&mobile='.constant("IN_MOBILE").'&update='.$rand.'&idhash='.$idhash.'" class="seccodeimg" alt="" style="display: inline; visibility: visible;" />';
} else {
if(!is_numeric($_G['setting']['seccodedata']['type']) && preg_match('/^[\w\d:_]+$/i', $_G['setting']['seccodedata']['type'])) {
$etype = explode(':', $_G['setting']['seccodedata']['type']);
if(count($etype) > 1) {
$codefile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/seccode/seccode_'.$etype[1].'.php';
$class = $etype[1];
} else {
$codefile = libfile('seccode/'.$_G['setting']['seccodedata']['type'], 'class');
$class = $_G['setting']['seccodedata']['type'];
}
if(file_exists($codefile)) {
@include_once $codefile;
$class = 'seccode_'.$class;
if(class_exists($class)) {
$code = new $class();
if(method_exists($code, 'make')) {
ob_start();
$seccode = $code->make($idhash, $modid);
make_seccode($seccode);
$message = preg_replace("/\r|\n/", '', ob_get_contents());
ob_end_clean();
}
}
}
} else {
$message = '<img onclick="updateseccode(\''.$idhash.'\')" width="'.$_G['setting']['seccodedata']['width'].'" height="'.$_G['setting']['seccodedata']['height'].'" src="misc.php?mod=seccode&mobile='.constant("IN_MOBILE").'&update='.$rand.'&idhash='.$idhash.'" class="seccodeimg" alt="" style="display: inline; visibility: visible;" />';
}
}
$imemode = $_G['setting']['seccodedata']['type'] != 1 ? 'ime-mode:disabled;' : '';
$message = str_replace("'", "\'", $message);
$seclang = lang('forum/misc');
header("Content-Type: application/javascript");
echo <<<EOF
if(document.getElementById('$showid')) {
if(!document.getElementById('v$showid')) {
var sectpl = seccheck_tpl['$idhash'] != '' ? seccheck_tpl['$idhash'].replace(/<hash>/g, 'code$idhash') : '';
var sectplcode = sectpl != '' ? sectpl.split('<sec>') : Array('<br />',': ','<br />','');
var string = '<input name="seccodehash" type="hidden" value="$idhash" /><input name="seccodemodid" type="hidden" value="$modid" /><input type="text" class="txt px vm" style="ime-mode:disabled;width:115px;background:white;" autocomplete="off" value="" id="seccodeverify_$idhash" name="seccodeverify" placeholder="$seclang[seccode]" fwin="seccode"><span id="v$showid">$message</span>';
evalscript(string);
document.getElementById('$showid').innerHTML = string;
} else {
var string = '$message';
evalscript(string);
document.getElementById('v$showid').innerHTML = string;
}
$htmlcode
}
EOF;
} elseif(getgpc('action') == 'check') {
include template('common/header_ajax');
echo helper_seccheck::check_seccode($_GET['secverify'], $_GET['idhash'], 1, $modid, true) ? 'succeed' : 'invalid';
include template('common/footer_ajax');
} else {
$refererhost = parse_url(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
$refererhost['host'] = (isset($refererhost['host']) ? $refererhost['host'] : '').(!empty($refererhost['port']) ? (':'.$refererhost['port']) : '');
if(($_G['setting']['seccodedata']['type'] < 2 && ($refererhost['host'] != $_SERVER['HTTP_HOST'])) || ((defined("IN_MOBILE") && in_array($_G['setting']['seccodedata']['type'], array(2, 3)) && ($refererhost['host'] != $_SERVER['HTTP_HOST'])) && ($_G['setting']['seccodedata']['type'] == 2 && !extension_loaded('ming') && $_POST['fromFlash'] != 1 || $_G['setting']['seccodedata']['type'] == 3 && $_GET['fromFlash'] != 1))) {
exit('Access Denied');
}
if(is_numeric($_G['setting']['seccodedata']['type']) || !preg_match('/^[\w\d:_]+$/i', $_G['setting']['seccodedata']['type'])) {
$seccode = make_seccode();
if(!$_G['setting']['nocacheheaders']) {
@header("Expires: -1");
@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
@header("Pragma: no-cache");
}
require_once libfile('class/seccode');
$code = new seccode();
$code->code = $seccode;
$code->type = (in_array($_G['setting']['seccodedata']['type'], array(2, 3)) && defined("IN_MOBILE")) ? 0 : $_G['setting']['seccodedata']['type'];
$code->width = $_G['setting']['seccodedata']['width'];
$code->height = $_G['setting']['seccodedata']['height'];
$code->background = $_G['setting']['seccodedata']['background'];
$code->adulterate = $_G['setting']['seccodedata']['adulterate'];
$code->ttf = $_G['setting']['seccodedata']['ttf'];
$code->angle = $_G['setting']['seccodedata']['angle'];
$code->warping = $_G['setting']['seccodedata']['warping'];
$code->scatter = $_G['setting']['seccodedata']['scatter'];
$code->color = $_G['setting']['seccodedata']['color'];
$code->size = $_G['setting']['seccodedata']['size'];
$code->shadow = $_G['setting']['seccodedata']['shadow'];
$code->animator = $_G['setting']['seccodedata']['animator'];
$code->fontpath = DISCUZ_ROOT.'./static/image/seccode/font/';
$code->datapath = DISCUZ_ROOT.'./static/image/seccode/';
$code->includepath = DISCUZ_ROOT.'./source/class/';
$code->display();
} else {
$etype = explode(':', $_G['setting']['seccodedata']['type']);
if(count($etype) > 1) {
$codefile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/seccode/seccode_'.$etype[1].'.php';
$class = $etype[1];
} else {
$codefile = libfile('seccode/'.$_G['setting']['seccodedata']['type'], 'class');
$class = $_G['setting']['seccodedata']['type'];
}
if(file_exists($codefile)) {
@include_once $codefile;
$class = 'seccode_'.$class;
if(class_exists($class)) {
make_seccode();
$code = new $class();
$image = $code->image($idhash, $modid);
if($image) {
dheader('location: '.$image);
}
}
}
}
}
?>

View File

@@ -0,0 +1,54 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id$
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if($_GET['action'] == 'send') {
$refererhost = parse_url($_SERVER['HTTP_REFERER']);
$refererhost['host'] .= !empty($refererhost['port']) ? (':'.$refererhost['port']) : '';
if($refererhost['host'] != $_SERVER['HTTP_HOST']) {
showmessage('submit_invalid');
}
$svctype = empty($_GET['svctype']) ? 0 : $_GET['svctype'];
$secmobicc = empty($_GET['secmobicc']) ? $_G['member']['secmobicc'] : $_GET['secmobicc'];
$secmobile = empty($_GET['secmobile']) ? $_G['member']['secmobile'] : $_GET['secmobile'];
list($seccodecheck, $secqaacheck) = seccheck('card');
if((!$seccodecheck && !$secqaacheck) || submitcheck('seccodesubmit', 0, $seccodecheck, $secqaacheck)) {
$length = $_G['setting']['smsdefaultlength'] ? $_G['setting']['smsdefaultlength'] : 4;
$secmobseccode = random($length, 1);
if(empty($secmobicc) || !preg_match('#^(\d){1,3}$#', $secmobicc)) {
showmessage('profile_secmobicc_illegal');
} else if(empty($secmobile) || !preg_match('#^(\d){1,12}$#', $secmobile)) {
showmessage('profile_secmobile_illegal');
}
$result = sms::send($_G['uid'], 0, $svctype, $secmobicc, $secmobile, $secmobseccode, 0);
if($result >= 0) {
showmessage('secmobseccode_send_success', '', array(), array('alert' => 'right'));
} else {
if($result <= -1 && $result >= -9) {
showmessage('secmobseccode_send_err_'.abs($result));
} else {
showmessage('secmobseccode_send_failure');
}
}
} else {
$handlekey = 'sendsecmobseccode';
include template('common/secmobseccode');
}
}

View File

@@ -0,0 +1,93 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_secqaa.php 33682 2013-08-01 06:37:41Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$idhash = isset($_GET['idhash']) && preg_match('/^\w+$/', $_GET['idhash']) ? $_GET['idhash'] : '';
if($_GET['action'] == 'update' && !defined("IN_MOBILE")) {
$refererhost = parse_url($_SERVER['HTTP_REFERER']);
$refererhost['host'] .= !empty($refererhost['port']) ? (':'.$refererhost['port']) : '';
if($refererhost['host'] != $_SERVER['HTTP_HOST']) {
exit('Access Denied');
}
$message = '';
$showid = 'secqaa_'.$idhash;
if($_G['setting']['secqaa']) {
$question = make_secqaa();
}
$message = preg_replace("/\r|\n/", '', $question);
$message = str_replace("'", "\'", $message);
$seclang = lang('forum/misc');
header("Content-Type: application/javascript");
echo <<<EOF
if($('$showid')) {
var sectpl = seccheck_tpl['$idhash'] != '' && typeof seccheck_tpl['$idhash'] != 'undefined' ? seccheck_tpl['$idhash'].replace(/<hash>/g, 'code$idhash') : '';
var sectplcode = sectpl != '' ? sectpl.split('<sec>') : Array('<br />',': ','<br />','');
var string = '<input name="secqaahash" type="hidden" value="$idhash" />' + sectplcode[0] + '{$seclang['secqaa']}' + sectplcode[1] + '<input name="secanswer" id="secqaaverify_$idhash" type="text" autocomplete="off" style="{$imemode}width:100px" class="txt px vm" onblur="checksec(\'qaa\', \'$idhash\')" />' +
' <a href="javascript:;" onclick="updatesecqaa(\'$idhash\');doane(event);" class="xi2">{$seclang['seccode_update']}</a>' +
'<span id="checksecqaaverify_$idhash"><img src="' + STATICURL + 'image/common/none.gif" width="16" height="16" class="vm" /></span>' +
sectplcode[2] + '$message' + sectplcode[3];
evalscript(string);
$('$showid').innerHTML = string;
}
EOF;
} elseif(getgpc('action') == 'update' && defined("IN_MOBILE") && constant("IN_MOBILE") == 2) {
$refererhost = parse_url($_SERVER['HTTP_REFERER']);
$refererhost['host'] .= !empty($refererhost['port']) ? (':'.$refererhost['port']) : '';
if($refererhost['host'] != $_SERVER['HTTP_HOST']) {
exit('Access Denied');
}
$message = '';
$showid = 'secqaa_'.$idhash;
if($_G['setting']['secqaa']) {
$question = make_secqaa();
}
$message = preg_replace("/\r|\n/", '', $question);
$message = str_replace("'", "\'", $message);
$seclang = lang('forum/misc');
header("Content-Type: application/javascript");
echo <<<EOF
if(document.getElementById('$showid')) {
if(!document.getElementById('v$showid')) {
var sectpl = seccheck_tpl['$idhash'] != '' && typeof seccheck_tpl['$idhash'] != 'undefined' ? seccheck_tpl['$idhash'].replace(/<hash>/g, 'code$idhash') : '';
var sectplcode = sectpl != '' ? sectpl.split('<sec>') : Array('<br />',': ','','');
var string = '<input name="secqaahash" type="hidden" value="$idhash" /><input type="text" class="txt px vm" style="ime-mode:disabled;width:115px;background:white;" autocomplete="off" value="" name="secanswer" id="secqaaverify_$idhash" placeholder="$seclang[secqaa]" /><span id="v$showid"><a href="javascript:;" onclick="updatesecqaa(\'$idhash\');" class="xi2">' + '$message' +
'</a></span>' +
'<span id="checksecqaaverify_$idhash"></span>';
evalscript(string);
document.getElementById('$showid').innerHTML = string;
} else {
var string = '<a href="javascript:;" onclick="updatesecqaa(\'$idhash\');" class="xi2">' + '$message' +
'</a>';
evalscript(string);
document.getElementById('v$showid').innerHTML = string;
}
}
EOF;
} elseif($_GET['action'] == 'check') {
include template('common/header_ajax');
echo helper_seccheck::check_secqaa($_GET['secverify'], $idhash, true) ? 'succeed' : 'invalid';
include template('common/footer_ajax');
}
?>

View File

@@ -0,0 +1,554 @@
<?php
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: misc_stat.php 31889 2012-10-22 03:27:56Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('CACHE_TIME', 18000);
$op = getgpc('op');
if(!in_array($op, array('basic', 'trade', 'team', 'trend', 'modworks', 'memberlist', 'forumstat', 'trend'))) {
$op = 'basic';
}
if(!$_G['group']['allowstatdata'] && $op != 'trend') {
showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
}
$navtitle = lang('core', 'title_stats_'.$op).' - '.lang('core', 'title_stats');
loadcache('statvars');
if($op == 'basic') {
$statvars = getstatvars('basic');
extract($statvars);
include template('forum/stat_main');
} elseif($op == 'trade') {
$statvars = getstatvars('trade');
extract($statvars);
include template('forum/stat_trade');
} elseif($op == 'team') {
$statvars = getstatvars('team');
extract($statvars);
include template('forum/stat_team');
} elseif($op == 'modworks' && $_G['setting']['modworkstatus']) {
$statvars = getstatvars('modworks');
extract($statvars);
if($_GET['exportexcel']) {
$filename = 'stat_modworks_'.($username ? $username.'_' : '').$starttime.'_'.$endtime.'.csv';
$filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($filename) : rawurlencode(diconv($filename, CHARSET, 'UTF-8'));
$rfc6266blacklist = strexists($_SERVER['HTTP_USER_AGENT'], 'UCBrowser') || strexists($_SERVER['HTTP_USER_AGENT'], 'Quark') || strexists($_SERVER['HTTP_USER_AGENT'], 'SogouM') || strexists($_SERVER['HTTP_USER_AGENT'], 'baidu');
include template('forum/stat_misc_export');
$csvstr = ob_get_contents();
ob_end_clean();
header('Content-Encoding: none');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$filenameencode.'"'.(($filename == $filenameencode || $rfc6266blacklist) ? '' : '; filename*=utf-8\'\''.$filenameencode));
header('Pragma: no-cache');
header('Expires: 0');
if($_G['charset'] != 'gbk') {
$csvstr = diconv($csvstr, $_G['charset'], 'GBK');
}
echo $csvstr;
exit;
} else {
include template('forum/stat_misc');
}
} elseif($op == 'memberlist' && $_G['setting']['memliststatus']) {
$statvars = getstatvars('memberlist');
extract($statvars);
include template('forum/stat_memberlist');
} elseif($op == 'forumstat') {
$statvars = getstatvars('forumstat');
extract($statvars);
include template('forum/stat_misc');
} elseif($op == 'trend') {
include libfile('misc/stat', 'include');
} else {
showmessage('undefined_action');
}
function getstatvars($type) {
global $_G;
$statvars = & $_G['cache']['statvars'][$type];
if(!empty($statvars['lastupdated']) && TIMESTAMP - $statvars['lastupdated'] < CACHE_TIME) {
return $statvars;
}
switch($type) {
case 'basic':
case 'trade':
case 'onlinetime':
case 'team':
case 'modworks':
case 'memberlist':
case 'forumstat':
$statvars = call_user_func('getstatvars_'.$type, ($type == 'forumstat' ? getgpc('fid') : ''));//getstatvars_forumstat($_GET['fid']);
break;
}
return $statvars;
}
function getstatvars_basic() {
global $_G;
$statvars = array();
$statvars['members'] = C::t('common_member')->count();
$members_runtime = C::t('common_member')->fetch_runtime();
$statvars['membersaddavg'] = $members_runtime > 0.00001 ? (round($statvars['members'] / $members_runtime)) : 0;
$statvars['memnonpost'] = C::t('common_member_count')->count_by_posts(0);
$statvars['mempost'] = $statvars['members'] - $statvars['memnonpost'];
$statvars['admins'] = C::t('common_member')->count_admins();
$statvars['lastmember'] = C::t('common_member')->count_by_regdate(TIMESTAMP - 86400);
$statvars['mempostpercent'] = number_format((double)$statvars['mempost'] / $statvars['members'] * 100, 2);
$bestmember = C::t('forum_post')->fetch_all_top_post_author(0, $_G['timestamp']-86400, 1);
$bestmember = isset($bestmember[0]) ? $bestmember[0] : array('username' => '');
$bestmember['author'] = $bestmember['username'];
$statvars['bestmem'] = isset($bestmember['author']) ? $bestmember['author'] : null;
$statvars['bestmemposts'] = isset($bestmember['posts']) ? $bestmember['posts'] : null;
$postsinfo = C::t('forum_post')->fetch_posts(0);
$statvars['posts'] = $postsinfo['posts'];
$runtime= $postsinfo['runtime'];
$statvars['postsaddavg'] = $runtime > 0.00001 ? round($statvars['posts'] / $runtime) : 0;
$statvars['mempostavg'] = sprintf ("%01.2f", $statvars['members'] ? ($statvars['posts'] / $statvars['members']) : 0);
$statvars['forums'] = C::t('forum_forum')->fetch_all_fids(0, 'forum', 0, 0, 0, 1);
$hotforum = C::t('forum_forum')->fetch_all_for_ranklist(1, '', 'posts', 0, 1);
$statvars['hotforum'] = array('posts' => $hotforum[0]['posts'], 'threads' => $hotforum[0]['threads'], 'fid' => $hotforum[0]['fid'], 'name' => $hotforum[0]['name']);
$statvars['threads'] = C::t('forum_thread')->count_all_thread();
$statvars['postsaddtoday'] = C::t('forum_post')->count_by_dateline(0, TIMESTAMP - 86400);
$statvars['threadreplyavg'] = sprintf ("%01.2f", $statvars['threads'] ? (($statvars['posts'] - $statvars['threads']) / $statvars['threads']) : 0);
$statvars['membersaddtoday'] = $statvars['lastmember'];
$statvars['activeindex'] = round((($statvars['members'] ? ($statvars['membersaddavg'] / $statvars['members']) : 0) + ($statvars['posts'] ? ($statvars['postsaddavg'] / $statvars['posts']) : 0)) * 1500 + $statvars['threadreplyavg'] * 10 + $statvars['mempostavg'] * 1 + $statvars['mempostpercent'] / 10);
$statvars['lastupdate'] = dgmdate(TIMESTAMP);
$statvars['nextupdate'] = dgmdate(TIMESTAMP + CACHE_TIME);
$statvars['lastupdated'] = TIMESTAMP;
$_G['cache']['statvars']['basic'] = $statvars;
savecache('statvars', $_G['cache']['statvars']);
return $statvars;
}
function getstatvars_trade() {
global $_G;
$statvars = array();
$query = C::t('forum_trade')->fetch_all_statvars('tradesum');
foreach($query as $data) {
$tradesums[] = $data;
}
$statvars['tradesums'] = $tradesums;
$query = C::t('forum_trade')->fetch_all_statvars('credittradesum');
foreach($query as $data) {
$credittradesums[] = $data;
}
$statvars['credittradesums'] = $credittradesums;
$query = C::t('forum_trade')->fetch_all_statvars('totalitems');
foreach($query as $data) {
$totalitems[] = $data;
}
$statvars['totalitems'] = $totalitems;
$statvars['lastupdate'] = dgmdate(TIMESTAMP);
$statvars['nextupdate'] = dgmdate(TIMESTAMP + CACHE_TIME);
$statvars['lastupdated'] = TIMESTAMP;
$_G['cache']['statvars']['trade'] = $statvars;
savecache('statvars', $_G['cache']['statvars']);
return $statvars;
}
function getstatvars_team() {
global $_G;
$statvars = array();
$team = array();
$forums = $moderators = $members = $fuptemp = array();
$categories = array(0 => array('fid' => 0, 'fup' => 0, 'type' => 'group', 'name' => $_G['setting']['bbname']));
$uids = array();
foreach(C::t('forum_moderator')->fetch_all_no_inherited() as $moderator) {
$moderators[$moderator['fid']][] = $moderator['uid'];
$uids[$moderator['uid']] = $moderator['uid'];
}
$totaloffdays = $totalol = $totalthismonthol = 0;
$admins = array();
$members = C::t('common_member')->fetch_all($uids) + C::t('common_member')->fetch_all_by_adminid(array(1, 2));
$uids = array_keys($members);
$onlinetime = $_G['setting']['oltimespan'] ? C::t('common_onlinetime')->fetch_all($uids) : array();
$member_status = C::t('common_member_status')->fetch_all($uids);
$member_count = C::t('common_member_count')->fetch_all($uids);
foreach($members as $uid => $member) {
$member = array_merge($member, $member_status[$uid], $member_count[$uid], (array)$onlinetime[$uid]);
$member['thismonthol'] = $member['thismonth'];
$member['totalol'] = $member['total'];
if($member['adminid'] == 1 || $member['adminid'] == 2) {
$admins[] = $member['uid'];
}
$member['offdays'] = intval((TIMESTAMP - $member['lastactivity']) / 86400);
$totaloffdays += $member['offdays'];
if($_G['setting']['oltimespan']) {
$member['totalol'] = round($member['totalol'] / 60, 2);
$member['thismonthol'] = gmdate('Yn', $member['lastactivity']) == gmdate('Yn', TIMESTAMP) ? round($member['thismonthol'] / 60, 2) : 0;
$totalol += $member['totalol'];
$totalthismonthol += $member['thismonthol'];
}
$members[$member['uid']] = $member;
$uids[$member['uid']] = $member['uid'];
}
$totalthismonthposts = 0;
foreach(C::t('forum_post')->fetch_all_author_posts_by_dateline(0, $uids, $_G['timestamp']-86400*30) as $post) {
$members[$post['authorid']]['thismonthposts'] = $post['posts'];
$totalthismonthposts += $post['posts'];
}
$totalmodposts = $totalmodactions = 0;
if($_G['setting']['modworkstatus']) {
$starttime = gmdate("Y-m-1", TIMESTAMP + $_G['setting']['timeoffset'] * 3600);
foreach(C::t('forum_modwork')->fetch_all_user_count_by_dateline($starttime) as $member) {
$members[$member['uid']]['modactions'] = $member['actioncount'];
$totalmodactions += $member['actioncount'];
}
}
$query = C::t('forum_forum')->fetch_all_by_status(1, 1);
foreach($query as $val) {
$forum = array('fid' => $val['fid'], 'fup' => $val['fup'], 'type' => $val['type'], 'name' => $val['name'], 'inheritedmod' => $val['inheritedmod']);
$moderators[$forum['fid']] = (isset($moderators[$forum['fid']]) && is_array($moderators[$forum['fid']])) ? $moderators[$forum['fid']] : array();
$forum['moderators'] = count($moderators[$forum['fid']]);
switch($forum['type']) {
case 'group':
$categories[$forum['fid']] = $forum;
$forums[$forum['fid']][$forum['fid']] = $forum;
$catfid = $forum['fid'];
break;
case 'forum':
$forums[$forum['fup']][$forum['fid']] = $forum;
$fuptemp[$forum['fid']] = $forum['fup'];
$catfid = $forum['fup'];
break;
case 'sub':
$forums[$fuptemp[$forum['fup']]][$forum['fid']] = $forum;
$catfid = $fuptemp[$forum['fup']];
break;
}
if(!empty($moderators[$forum['fid']])) {
$categories[$catfid]['moderating'] = 1;
}
}
foreach($categories as $fid => $category) {
if(empty($category['moderating'])) {
unset($categories[$fid]);
}
}
$team = array (
'categories' => $categories,
'forums' => $forums,
'admins' => $admins,
'moderators' => $moderators,
'members' => $members,
'avgoffdays' => count($members) ? ($totaloffdays / count($members)) : 0,
'avgthismonthposts' => count($members) ? ($totalthismonthposts / count($members)) : 0,
'avgtotalol' => count($members) ? ($totalol / count($members)) : 0,
'avgthismonthol' => count($members) ? ($totalthismonthol / count($members)) : 0,
'avgmodactions' => count($members) ? ($totalmodactions / count($members)) : 0,
);
loadcache('usergroups');
if(is_array($team)) {
foreach($team['members'] as $uid => $member) {
$member['thismonthposts'] = intval($member['thismonthposts']);
$team['members'][$uid]['offdays'] = $member['offdays'] > $team['avgoffdays'] ? '<b><i>'.$member['offdays'].'</i></b>' : $member['offdays'];
$team['members'][$uid]['thismonthposts'] = $member['thismonthposts'] < $team['avgthismonthposts'] / 2 ? '<b><i>'.$member['thismonthposts'].'</i></b>' : $member['thismonthposts'];
$team['members'][$uid]['lastactivity'] = dgmdate($member['lastactivity'] + $_G['setting']['timeoffset'] * 3600, 'd');
$team['members'][$uid]['thismonthol'] = $member['thismonthol'] < $team['avgthismonthol'] / 2 ? '<b><i>'.$member['thismonthol'].'</i></b>' : $member['thismonthol'];
$team['members'][$uid]['totalol'] = $member['totalol'] < $team['avgtotalol'] / 2 ? '<b><i>'.$member['totalol'].'</i></b>' : $member['totalol'];
$team['members'][$uid]['modposts'] = $member['modposts'] < $team['avgmodposts'] / 2 ? '<b><i>'.intval($member['modposts']).'</i></b>' : intval($member['modposts']);
$team['members'][$uid]['modactions'] = $member['modactions'] < $team['avgmodactions'] / 2 ? '<b><i>'.intval($member['modactions']).'</i></b>' : intval($member['modactions']);
$team['members'][$uid]['grouptitle'] = $_G['cache']['usergroups'][$member['adminid']]['grouptitle'];
}
}
$statvars['team'] = $team;
$statvars['lastupdate'] = dgmdate(TIMESTAMP);
$statvars['nextupdate'] = dgmdate(TIMESTAMP + CACHE_TIME);
$statvars['lastupdated'] = TIMESTAMP;
$_G['cache']['statvars']['team'] = $statvars;
savecache('statvars', $_G['cache']['statvars']);
return $statvars;
}
function getstatvars_modworks() {
global $_G;
$statvars = array();
$before = $_GET['before'];
$before = (isset($before) && $before > 0 && $before <= $_G['setting']['maxmodworksmonths']) ? intval($before) : 0 ;
$modworks_starttime = $_GET['modworks_starttime'];
$modworks_endtime = $_GET['modworks_endtime'];
list($now['year'], $now['month'], $now['day']) = explode("-", dgmdate(TIMESTAMP, 'Y-n-j'));
$monthlinks = array();
$uid = !empty($_GET['uid']) ? $_GET['uid'] : 0;
for($i = 0; $i <= $_G['setting']['maxmodworksmonths']; $i++) {
$month = date("Y-m", mktime(0, 0, 0, $now['month'] - $i, 1, $now['year']));
if($i != $before) {
$monthlinks[$i] = "<li><a href=\"misc.php?mod=stat&op=modworks&before=$i&uid=$uid\" hidefocus=\"true\">$month</a></li>";
} else {
if(!isset($_GET['before']) && $modworks_starttime && $modworks_endtime) {
$starttime = dgmdate(strtotime($modworks_starttime), 'Y-m-d');
$endtime = dgmdate(strtotime($modworks_endtime), 'Y-m-d');
$monthlinks[$i] = "<li><a href=\"misc.php?mod=stat&op=modworks&before=$i&uid=$uid\" hidefocus=\"true\">$month</a></li>";
} else {
$starttime = $month.'-01';
$endtime = date("Y-m-01", mktime(0, 0, 0, $now['month'] - $i + 1 , 1, $now['year']));
$monthlinks[$i] = "<li class=\"xw1 a\"><a href=\"misc.php?mod=stat&op=modworks&before=$i&uid=$uid\" hidefocus=\"true\">$month</a></li>";
}
}
}
$statvars['monthlinks'] = $monthlinks;
$expiretime = date('Y-m', mktime(0, 0, 0, $now['month'] - $_G['setting']['maxmodworksmonths'] - 1, 1, $now['year']));
$mergeactions = array('OPN' => 'CLS', 'ECL' => 'CLS', 'UEC' => 'CLS', 'EOP' => 'CLS', 'UEO' => 'CLS',
'UDG' => 'DIG', 'EDI' =>'DIG', 'UED' => 'DIG', 'UST' => 'STK', 'EST' => 'STK', 'UES' => 'STK',
'DLP' => 'DEL', 'PRN' => 'DEL', 'UDL' => 'DEL', 'UHL' => 'HLT', 'EHL' => 'HLT', 'UEH' => 'HLT',
'SPL' => 'MRG', 'ABL' => 'EDT', 'RBL' => 'EDT');
if($uid) {
$uid = $_GET['uid'];
$member = getuserbyuid($uid, 1);
if(empty($member) || !is_array($member) || in_array($_G['adminid'], array(0, -1))) {
showmessage('member_not_found');
}
$modactions = $totalactions = array();
$starttime_dateline = strtotime($starttime);
$endtime_dateline = strtotime($endtime);
$endtime_dateline = $endtime_dateline > TIMESTAMP ? TIMESTAMP : $endtime_dateline;
while($starttime_dateline <= $endtime_dateline) {
$modactions[dgmdate($starttime_dateline, 'Y-m-d')] = array();
$starttime_dateline += 86400;
}
foreach(C::t('forum_modwork')->fetch_all_by_uid_dateline($uid, $starttime, $endtime) as $data) {
if(isset($mergeactions[$data['modaction']])) {
$data['modaction'] = $mergeactions[$data['modaction']];
}
$modactions[$data['dateline']]['total'] += $data['count'];
$modactions[$data['dateline']][$data['modaction']]['count'] += $data['count'];
$modactions[$data['dateline']][$data['modaction']]['posts'] += $data['posts'];
$totalactions[$data['modaction']]['count'] += $data['count'];
$totalactions[$data['modaction']]['posts'] += $data['posts'];
$totalactions['total'] += $data['count'];
}
$statvars['modactions'] = $modactions;
$statvars['totalactions'] = $totalactions;
$statvars['username'] = $member['username'];
} else {
$members = $total = array();
$uids = $totalmodactions = 0;
$members = C::t('common_member')->fetch_all_by_adminid(array(1, 2, 3));
foreach(C::t('forum_modwork')->fetch_all_user_count_posts_by_uid_dateline(array_keys($members), $starttime, $endtime) as $data) {
if(isset($mergeactions[$data['modaction']])) {
$data['modaction'] = $mergeactions[$data['modaction']];
}
$members[$data['uid']]['total'] += $data['count'];
$totalmodactioncount += $data['count'];
$members[$data['uid']][$data['modaction']]['count'] += $data['count'];
$members[$data['uid']][$data['modaction']]['posts'] += $data['posts'];
$total[$data['modaction']]['count'] += $data['count'];
$total[$data['modaction']]['posts'] += $data['posts'];
$total['total'] += $data['count'];
}
$avgmodactioncount = count($members) ? ($totalmodactioncount / count($members)) : 0;
foreach($members as $id => $member) {
$members[$id]['totalactions'] = intval($members[$id]['totalactions']);
$members[$id]['username'] = ($members[$id]['total'] < $avgmodactioncount / 2) ? ('<b><i>'.$members[$id]['username'].'</i></b>') : ($members[$id]['username']);
}
if(!empty($before)) {
C::t('forum_modwork')->delete_by_dateline($expiretime.'-01');
} else {
$members['thismonth'] = $starttime;
$members['lastupdate'] = TIMESTAMP;
unset($members['lastupdate'], $members['thismonth']);
}
$statvars['members'] = $members;
$statvars['total'] = $total;
}
$modactioncode = lang('forum/modaction');
$bgarray = array();
foreach($modactioncode as $key => $val) {
if(isset($mergeactions[$key])) {
unset($modactioncode[$key]);
}
}
$statvars['modactioncode'] = $modactioncode;
$tdcols = count($modactioncode) + 1;
$tdwidth = floor(90 / ($tdcols - 1)).'%';
$statvars['tdwidth'] = $tdwidth;
$statvars['uid'] = $uid;
$statvars['starttime'] = $starttime;
$statvars['endtime'] = $endtime;
return $statvars;
}
function getstatvars_memberlist() {
global $_G;
$statvars = array();
$srchmem = $_GET['srchmem'];
$page = $_G['setting']['membermaxpages'] && isset($_GET['page']) && $_GET['page'] > $_G['setting']['membermaxpages'] ? 1 : $_GET['page'];
if(empty($page)) {
$page = 1;
}
$start_limit = ($page - 1) * $_G['setting']['memberperpage'];
$statvars['memberlist'] = C::t('common_member')->fetch_all_stat_memberlist($srchmem, $_GET['order'], $_GET['asc'] ? 'ASC' : 'DESC', $start_limit, $_G['setting']['memberperpage']);
$num = !empty($srchmem) ? C::t('common_member')->count_by_like_username($srchmem) : C::t('common_member')->count();
$multipage = multi($num, $_G['setting']['memberperpage'], $page, 'misc.php?mod=stat&op=memberlist&srchmem='.rawurlencode($srchmem).'&order='.rawurlencode($_GET['order']).'&asc='.rawurlencode($_GET['asc']), $_G['setting']['membermaxpages']);
$statvars['multipage'] = $multipage;
return $statvars;
}
function getstatvars_forumstat($fid) {
global $_G;
$xml = '<'."?xml version=\"1.0\" encoding=\"utf-8\"?><chart>";
$statvars = array();
$monthdays = array('31', '29', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31');
if(!$fid) {
$query = C::t('forum_forum')->fetch_all_fids();
$forums = array();
foreach($query as $val) {
$forums[] = array('fid' => $val['fid'], 'type' => $val['type'], 'name' => $val['name'], 'posts' => $val['posts']);
}
$statvars['forums'] = $forums;
} else {
$foruminfo = C::t('forum_forum')->fetch($fid);
$statvars['foruminfo'] = array('fid' => $foruminfo['fid'], 'name' => $foruminfo['name'], 'posts' => $foruminfo['posts'], 'threads' => $foruminfo['threads'], 'todayposts' => $foruminfo['todayposts']);
$current_date = $end_date = date('Y-m-d');
$current_month = $end_month = date('Y-m');
$current_month_start = $end_month_start = $current_month . '-01';
if($_GET['month']) {
$end_month = trim($_GET['month']);
$month = substr($end_month, strpos($end_month, '-') + 1);
$end_date = $end_month . '-' . $monthdays[$month - 1];
$end_month_start = $end_month . '-' . '01';
}
$statvars['month'] = $end_month;
$logs = array();
$xml .= "<xaxis>";
$xmlvalue = '';
$xaxisindex = 0;
foreach(C::t('forum_statlog')->fetch_all_by_logdate($end_month_start, $end_date, $fid) as $log) {
$logs[] = $log;
list($yyyy, $mm, $dd) = explode('-', $log['logdate']);
$xaxisindex++;
$xml .= "<value xid=\"{$xaxisindex}\">{$mm}{$dd}</value>";
$xmlvalue .= "<value xid=\"{$xaxisindex}\">{$log['value']}</value>";
}
$xml .= "</xaxis>";
$xml .= "<graphs>";
$xml .= "<graph gid=\"0\" title=\"".diconv(lang('spacecp', 'do_stat_post_number'), CHARSET, 'UTF-8')."\">";
$xml .= $xmlvalue;
$xml .= "</graph>";
$xml .= "</graphs>";
$xml .= "</chart>";
if($_GET['xml']) {
@header("Expires: -1");
@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
@header("Pragma: no-cache");
@header("Content-type: application/xml; charset=utf-8");
echo $xml;
exit;
}
$statvars['logs'] = $logs;
$mindate = C::t('forum_statlog')->fetch_min_logdate_by_fid($fid);
if(!$mindate) {
return $statvars;
}
list($minyear, $minmonth, $minday) = explode('-', $mindate);
$minmonth = $minyear . '-' . $minmonth;
$month = $minmonth;
$monthlist = array();
while(datecompare($month, $current_month) <= 0) {
$monthlist[] = $month;
$month = getnextmonth($month);
}
$statvars['monthlist'] = $monthlist;
$monthposts = array();
foreach(C::t('forum_statlog')->fetch_all_by_fid_type($fid) as $data) {
list($year, $month, $day) = explode('-', $data['logdate']);
if(isset($monthposts[$year.'-'.$month])) {
$monthposts[$year.'-'.$month] += $data['value'];
} else {
$monthposts[$year.'-'.$month] = $data['value'];
}
}
$statvars['monthposts'] = $monthposts;
}
$statvars['statuspara'] = "misc.php?mod=stat&op=forumstat&fid=$fid&month={getgpc('month')}&xml=1";
return $statvars;
}
function datecompare($date1, $date2) {
$year1 = $month1 = $day1 = 1;
$year2 = $month2 = $day2 = 1;
list($year1, $month1, $day1) = explode('-', $date1);
list($year2, $month2, $day2) = explode('-', $date2);
return mktime(0, 0, 0, $month1, $day1, $year1) - mktime(0, 0, 0, $month2, $day2, $year2);
}
function getnextmonth($monthdate) {
list($year, $month) = explode('-', $monthdate);
$month = $month + 1;
if($month > 12) {
$month = 1;
$year = $year + 1;
}
$month = sprintf("%02d", $month);
return $year . '-' . $month;
}

View File

@@ -0,0 +1,252 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_swfupload.php 35377 2015-07-07 05:20:23Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$_G['uid'] = intval($_POST['uid']);
if((empty($_G['uid']) && $_GET['operation'] != 'upload') || $_POST['hash'] != md5(substr(md5($_G['config']['security']['authkey']), 8).$_G['uid'])) {
exit();
} else {
if($_G['uid']) {
$_G['member'] = getuserbyuid($_G['uid']);
}
$_G['groupid'] = $_G['member']['groupid'];
loadcache('usergroup_'.$_G['member']['groupid']);
$_G['group'] = $_G['cache']['usergroup_'.$_G['member']['groupid']];
}
if($_GET['operation'] == 'upload') {
if(empty($_GET['simple'])) {
$_FILES['Filedata']['name'] = diconv(urldecode($_FILES['Filedata']['name']), 'UTF-8');
$_FILES['Filedata']['type'] = $_GET['filetype'];
}
$forumattachextensions = '';
$fid = intval($_GET['fid']);
if($fid) {
$forum = $fid != $_G['fid'] ? C::t('forum_forum')->fetch_info_by_fid($fid) : $_G['forum'];
if($forum['status'] == 3 && $forum['level']) {
$levelinfo = C::t('forum_grouplevel')->fetch($forum['level']);
if($postpolicy = $levelinfo['postpolicy']) {
$postpolicy = dunserialize($postpolicy);
$forumattachextensions = $postpolicy['attachextensions'];
}
} else {
$forumattachextensions = $forum['attachextensions'];
}
if($forumattachextensions) {
$_G['group']['attachextensions'] = $forumattachextensions;
}
}
$upload = new forum_upload();
} elseif($_GET['operation'] == 'poll') {
if(!$_G['group']['allowpostpoll'] || !$_G['group']['allowpostimage']) {
exit("{\"aid\":0, \"errorcode\":4}");
}
$upload = new discuz_upload();
$_FILES["Filedata"]['name'] = addslashes(diconv(urldecode($_FILES["Filedata"]['name']), 'UTF-8'));
$upload->init($_FILES['Filedata'], 'forum');
$attach = $upload->attach;
if(!$upload->attach['isimage']) {
$errorcode = 4;
} else {
$upload->save();
$errorcode = 0;
}
if($upload->error()) {
$errorcode = 4;
} else {
if($attach['isimage']) {
require_once libfile('class/image');
$image = new image();
$thumbimgwidth = 300;
$thumbimgheight = 300;
$attach['thumb'] = $image->Thumb($attach['target'], '', $thumbimgwidth, $thumbimgheight, 2);
$image->Watermark($attach['target'], '', 'forum');
$imginfo = @getimagesize($attach['target']);
if($imginfo !== FALSE) {
$attach['width'] = $imginfo[0];
$attach['height'] = $imginfo[1];
}
}
if(ftpperm($attach['ext'], $attach['size'])) {
if(ftpcmd('upload', 'forum/'.$attach['attachment']) && (!$attach['thumb'] || ftpcmd('upload', 'forum/'.getimgthumbname($attach['attachment'])))) {
@unlink($_G['setting']['attachdir'].'/forum/'.$attach['attachment']);
@unlink($_G['setting']['attachdir'].'/forum/'.getimgthumbname($attach['attachment']));
$attach['remote'] = 1;
} else {
if(getglobal('setting/ftp/mirror')) {
@unlink($attach['target']);
@unlink(getimgthumbname($attach['target']));
$errorcode = 5;
}
}
}
}
if(!$errorcode) {
$aid = intval($_GET['aid']);
$setarr = array(
'uid' => $_G['uid'],
'filename' => $attach['name'],
'attachment' => $attach['attachment'],
'filesize' => $attach['size'],
'thumb' => $attach['thumb'],
'remote' => $attach['remote'],
'dateline' => $_G['timestamp'],
'width' => $attach['width'],
'height' => $attach['height']
);
$image = array();
if($aid) {
$image = C::t('forum_polloption_image')->fetch($aid);
}
if($image['uid'] == $_G['uid']) {
C::t('forum_polloption_image')->update($aid, $setarr);
@unlink($_G['setting']['attachdir'].'/forum/'.$image['attachment']);
@unlink($_G['setting']['attachdir'].'/forum/'.getimgthumbname($image['attachment']));
$attach['attachid'] = $aid;
} else {
$attach['attachid'] = C::t('forum_polloption_image')->insert($setarr, true);
}
require_once libfile('function/home');
$smallimg = pic_get($attach['attachment'], 'forum', $attach['thumb'], $attach['remote']);
$bigimg = pic_get($attach['attachment'], 'forum', 0, $attach['remote']);
echo "{\"aid\":{$attach['attachid']}, \"smallimg\":\"$smallimg\", \"bigimg\":\"$bigimg\", \"errorcode\":$errorcode}";
exit();
} else {
echo "{\"aid\":0, \"errorcode\":$errorcode}";
}
} elseif($_GET['operation'] == 'album') {
$showerror = true;
if(helper_access::check_module('album')) {
require_once libfile('function/spacecp');
if($_FILES["Filedata"]['error']) {
$file = lang('spacecp', 'file_is_too_big');
} else {
require_once libfile('function/home');
$_FILES["Filedata"]['name'] = addslashes(diconv(urldecode($_FILES["Filedata"]['name']), 'UTF-8'));
$file = pic_save($_FILES["Filedata"], 0, '', true, 0);
if(!empty($file) && is_array($file)) {
$url = pic_get($file['filepath'], 'album', $file['thumb'], $file['remote']);
$bigimg = pic_get($file['filepath'], 'album', 0, $file['remote']);
echo "{\"picid\":\"{$file['picid']}\", \"url\":\"$url\", \"bigimg\":\"$bigimg\"}";
$showerror = false;
}
}
}
if($showerror) {
echo "{\"picid\":\"0\", \"url\":\"0\", \"bigimg\":\"0\"}";
}
} elseif($_GET['operation'] == 'portal') {
$aid = intval($_POST['aid']);
$catid = intval($_POST['catid']);
$msg = '';
$errorcode = 0;
require_once libfile('function/portalcp');
if($aid) {
$article = C::t('portal_article_title')->fetch($aid);
if(!$article) {
$errorcode = 1;
}
if(check_articleperm($catid, $aid, $article, false, true) !== true) {
$errorcode = 2;
}
} else {
if(check_articleperm($catid, $aid, null, false, true) !== true) {
$errorcode = 3;
}
}
$upload = new discuz_upload();
$_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(ftpperm($attach['ext'], $attach['size'])) {
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;
}
}
}
$setarr = array(
'uid' => $_G['uid'],
'filename' => $attach['name'],
'attachment' => $attach['attachment'],
'filesize' => $attach['size'],
'isimage' => $attach['isimage'],
'thumb' => $attach['thumb'],
'remote' => $attach['remote'],
'filetype' => $attach['extension'],
'dateline' => $_G['timestamp'],
'aid' => $aid
);
$setarr['attachid'] = C::t('portal_attachment')->insert($setarr, true);
if($attach['isimage']) {
require_once libfile('function/home');
$smallimg = pic_get($attach['attachment'], 'portal', $attach['thumb'], $attach['remote']);
$bigimg = pic_get($attach['attachment'], 'portal', 0, $attach['remote']);
$coverstr = addslashes(serialize(array('pic'=>'portal/'.$attach['attachment'], 'thumb'=>$attach['thumb'], 'remote'=>$attach['remote'])));
echo "{\"aid\":{$setarr['attachid']}, \"isimage\":{$attach['isimage']}, \"smallimg\":\"$smallimg\", \"bigimg\":\"$bigimg\", \"errorcode\":$errorcode, \"cover\":\"$coverstr\"}";
exit();
} else {
$fileurl = 'portal.php?mod=attachment&id='.$attach['attachid'];
echo "{\"aid\":{$setarr['attachid']}, \"isimage\":{$attach['isimage']}, \"file\":\"$fileurl\", \"errorcode\":$errorcode}";
exit();
}
} else {
echo "{\"aid\":0, \"errorcode\":$errorcode}";
}
}
?>

View File

@@ -0,0 +1,175 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_tag.php 32232 2012-12-03 08:57:08Z zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$id = intval($_GET['id']);
$type = trim($_GET['type']);
$name = trim($_GET['name']);
$page = intval($_GET['page']);
if($type == 'countitem') {
$num = 0;
if($id) {
$num = C::t('common_tagitem')->count_by_tagid($id);
}
include_once template('tag/tag');
exit();
}
$taglang = lang('tag/template', 'tag');
if($id || $name) {
$tpp = 20;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
if($id) {
$tag = C::t('common_tag')->fetch_info($id);
} else {
if(!preg_match('/^([\x7f-\xff_-]|\w|\s)+$/', $name) || strlen($name) > 20) {
showmessage('parameters_error');
}
$name = addslashes($name);
$tag = C::t('common_tag')->fetch_info(0, $name);
}
if($tag['status'] == 1) {
showmessage('tag_closed');
}
$tagname = $tag['tagname'];
$id = $tag['tagid'];
$searchtagname = $name;
$navtitle = $tagname ? $taglang.' - '.$tagname : $taglang;
$metakeywords = $tagname ? $taglang.' - '.$tagname : $taglang;
$metadescription = $tagname ? $taglang.' - '.$tagname : $taglang;
$showtype = '';
$count = '';
$summarylen = 300;
if($type == 'thread') {
$showtype = 'thread';
$tidarray = $threadlist = array();
$count = C::t('common_tagitem')->select($id, 0, 'tid', '', '', 0, 0, 0, 1);
if($count) {
$query = C::t('common_tagitem')->select($id, 0, 'tid', '', '', $start_limit, $tpp);
foreach($query as $result) {
$tidarray[$result['itemid']] = $result['itemid'];
}
$threadlist = getthreadsbytids($tidarray);
$multipage = multi($count, $tpp, $page, "misc.php?mod=tag&id={$tag['tagid']}&type=thread");
}
} elseif($type == 'blog') {
$showtype = 'blog';
$blogidarray = $bloglist = array();
$count = C::t('common_tagitem')->select($id, 0, 'blogid', '', '', 0, 0, 0, 1);
if($count) {
$query = C::t('common_tagitem')->select($id, 0, 'blogid', '', '', $start_limit, $tpp);
foreach($query as $result) {
$blogidarray[$result['itemid']] = $result['itemid'];
}
$bloglist = getblogbyid($blogidarray);
$multipage = multi($count, $tpp, $page, "misc.php?mod=tag&id={$tag['tagid']}&type=blog");
}
} else {
$shownum = 20;
$tidarray = $threadlist = array();
$query = C::t('common_tagitem')->select($id, 0, 'tid', '', '', $shownum);
foreach($query as $result) {
$tidarray[$result['itemid']] = $result['itemid'];
}
$threadlist = getthreadsbytids($tidarray);
if(helper_access::check_module('blog')) {
$blogidarray = $bloglist = array();
$query = C::t('common_tagitem')->select($id, 0, 'blogid', '', '', $shownum);
foreach($query as $result) {
$blogidarray[$result['itemid']] = $result['itemid'];
}
$bloglist = getblogbyid($blogidarray);
}
}
include_once template('tag/tagitem');
} else {
$navtitle = $metakeywords = $metadescription = $taglang;
$viewthreadtags = 100;
$tagarray = array();
$query = C::t('common_tag')->fetch_all_by_status(0, '', $viewthreadtags, 0, 0, 'DESC');
foreach($query as $result) {
$tagarray[] = $result;
}
include_once template('tag/tag');
}
function getthreadsbytids($tidarray) {
global $_G;
$threadlist = array();
if(!empty($tidarray)) {
loadcache('forums');
include_once libfile('function_misc', 'function');
$fids = array();
foreach(C::t('forum_thread')->fetch_all_by_tid($tidarray) as $result) {
if($result['displayorder'] >= 0){
if(!isset($_G['cache']['forums'][$result['fid']]['name'])) {
$fids[$result['fid']][] = $result['tid'];
} else {
$result['name'] = $_G['cache']['forums'][$result['fid']]['name'];
}
$threadlist[$result['tid']] = procthread($result);
}
}
if(!empty($fids)) {
foreach(C::t('forum_forum')->fetch_all_by_fid(array_keys($fids)) as $fid => $forum) {
foreach($fids[$fid] as $tid) {
$threadlist[$tid]['forumname'] = $forum['name'];
}
}
}
}
return $threadlist;
}
function getblogbyid($blogidarray) {
global $_G, $summarylen;
$bloglist = array();
if(!empty($blogidarray)) {
$data_blog = C::t('home_blog')->fetch_all_blog($blogidarray, 'dateline', 'DESC');
$data_blogfield = C::t('home_blogfield')->fetch_all($blogidarray);
require_once libfile('function/spacecp');
require_once libfile('function/home');
$classarr = array();
foreach($data_blog as $curblogid => $result) {
$result = array_merge($result, (array)$data_blogfield[$curblogid]);
$result['dateline'] = dgmdate($result['dateline']);
$classarr = getclassarr($result['uid']);
$result['classname'] = $classarr[$result['classid']]['classname'];
if($result['friend'] == 4) {
$result['message'] = $result['pic'] = '';
} else {
$result['message'] = getstr($result['message'], $summarylen, 0, 0, 0, -1);
}
$result['message'] = preg_replace("/&[a-z]+\;/i", '', $result['message']);
if($result['pic']) {
$result['pic'] = pic_cover_get($result['pic'], $result['picflag']);
}
$bloglist[] = $result;
}
}
return $bloglist;
}
?>

View File

@@ -0,0 +1,53 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc_userstatus.php 32720 2013-03-04 10:21:58Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$output = array();
$output['uid'] = $_G['uid'];
$tablename = '';
if($_GET['type'] === 'topic' && $typeid = intval($_GET['typeid'])) {
$tablename = 'portal_topic';
C::t('portal_topic')->increase($typeid, array('viewnum' => 1));
} elseif($_GET['type'] === 'article' && $typeid = intval($_GET['typeid'])) {
C::t('portal_article_count')->increase($typeid, array('viewnum' => 1));
$tablename = 'portal_article_count';
}
if($tablename) {
$dynamicdata = C::t($tablename)->fetch($typeid);
$output['viewnum'] = $dynamicdata['viewnum'];
$output['commentnum'] = $dynamicdata['commentnum'];
}
if($output['uid']) {
$_G['style']['tplfile'] = 'misc/userstatus';
if(check_diy_perm($topic)){
require template('common/header_diynav');
echo $diynav;
}
$output['diynav'] = str_replace(array("\r", "\n"), '' ,ob_get_contents());
ob_end_clean();
$_G['gzipcompress'] ? ob_start('ob_gzhandler') : ob_start();
require template('common/header_userstatus');
$output['userstatus'] = str_replace(array("\r", "\n"), '' ,ob_get_contents());
ob_end_clean();
$_G['gzipcompress'] ? ob_start('ob_gzhandler') : ob_start();
require template('common/header_qmenu');
$output['qmenu'] = str_replace(array("\r", "\n"), '' ,ob_get_contents());
ob_end_clean();
$_G['gzipcompress'] ? ob_start('ob_gzhandler') : ob_start();
}
header("Content-Type: application/json");
echo helper_json::encode($output);
?>

View File

View File

@@ -0,0 +1,130 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: portal_attachment.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$operation = $_GET['op'] ? $_GET['op'] : '';
$id = empty($_GET['id']) ? 0 : intval($_GET['id']);
$aid = empty($_GET['aid']) ? '' : intval($_GET['aid']);
$attach = C::t('portal_attachment')->fetch($id);
if(empty($attach)) {
showmessage('portal_attachment_noexist');
}
if($operation == 'delete') {
if(!$_G['group']['allowmanagearticle'] && ($_G['uid'] != $attach['uid'] || $aid != $attach['aid'])) {
showmessage('portal_attachment_nopermission_delete');
}
if(!isset($_GET['formhash']) || formhash() != $_GET['formhash']) {
showmessage('portal_attachment_nopermission_delete');
}
if($aid) {
C::t('portal_article_title')->update($aid, array('pic' => ''));
}
C::t('portal_attachment')->delete($id);
pic_delete($attach['attachment'], 'portal', $attach['thumb'], $attach['remote']);
showmessage('portal_image_noexist');
} elseif($operation == 'getattach') {
require_once libfile('function/attachment');
if($attach['isimage']) {
require_once libfile('function/home');
$smallimg = pic_get($attach['attachment'], 'portal', $attach['thumb'], $attach['remote']);
$bigimg = pic_get($attach['attachment'], 'portal', 0, $attach['remote']);
$coverstr = addslashes(serialize(array('pic'=>'portal/'.$attach['attachment'], 'thumb'=>$attach['thumb'], 'remote'=>$attach['remote'])));
}
$attach['filetype'] = attachtype($attach['filetype']."\t".$attach['filetype']);
$attach['filesize'] = sizecount($attach['filesize']);
include template('portal/portal_attachment');
exit;
} else {
$filename = $_G['setting']['attachdir'].'/portal/'.$attach['attachment'];
if(!$attach['remote'] && !is_readable($filename)) {
showmessage('attachment_nonexistence');
}
$readmod = 2;//read local file's function: 1=fread 2=readfile 3=fpassthru 4=fpassthru+multiple
$range = 0;
if($readmod == 4 && !empty($_SERVER['HTTP_RANGE'])) {
list($range) = explode('-',(str_replace('bytes=', '', $_SERVER['HTTP_RANGE'])));
}
if($attach['remote'] && !$_G['setting']['ftp']['hideurl'] && $attach['isimage']) {
dheader('location:'.$_G['setting']['ftp']['attachurl'].'portal/'.$attach['attachment']);
}
$filesize = $attach['filesize'];
$filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($attach['filename']) : rawurlencode(diconv($attach['filename'], CHARSET, 'UTF-8'));
$rfc6266blacklist = strexists($_SERVER['HTTP_USER_AGENT'], 'UCBrowser') || strexists($_SERVER['HTTP_USER_AGENT'], 'Quark') || strexists($_SERVER['HTTP_USER_AGENT'], 'SogouM') || strexists($_SERVER['HTTP_USER_AGENT'], 'baidu');
dheader('Date: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT');
dheader('Last-Modified: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT');
dheader('Content-Encoding: none');
dheader('Content-Disposition: attachment; filename="'.$filenameencode.'"'.(($attach['filename'] == $filenameencode || $rfc6266blacklist) ? '' : '; filename*=utf-8\'\''.$filenameencode));
dheader('Content-Type: '.$attach['filetype']);
dheader('Content-Length: '.$filesize);
if($readmod == 4) {
dheader('Accept-Ranges: bytes');
if(!empty($_SERVER['HTTP_RANGE'])) {
$rangesize = ($filesize - $range) > 0 ? ($filesize - $range) : 0;
dheader('Content-Length: '.$rangesize);
dheader('HTTP/1.1 206 Partial Content');
dheader('Content-Range: bytes='.$range.'-'.($filesize-1).'/'.($filesize));
}
}
$attach['remote'] ? getremotefile($attach['attachment']) : getlocalfile($filename, $readmod, $range);
}
function getremotefile($file) {
global $_G;
@set_time_limit(0);
if(!@readfile($_G['setting']['ftp']['attachurl'].'portal/'.$file)) {
$ftp = new discuz_ftp();
if(!($_G['setting']['ftp']['connid'] = $ftp->connect())) {
return FALSE;
}
$tmpfile = @tempnam($_G['setting']['attachdir'], '');
if($ftp->ftp_get($_G['setting']['ftp']['connid'], $tmpfile, $file, FTP_BINARY)) {
@readfile($tmpfile);
@unlink($tmpfile);
} else {
@unlink($tmpfile);
return FALSE;
}
}
return TRUE;
}
function getlocalfile($filename, $readmod = 2, $range = 0) {
if($readmod == 1 || $readmod == 3 || $readmod == 4) {
if($fp = @fopen($filename, 'rb')) {
@fseek($fp, $range);
if(function_exists('fpassthru') && ($readmod == 3 || $readmod == 4)) {
@fpassthru($fp);
} else if(filesize($filename)) {
echo fread($fp, filesize($filename));
}
}
@fclose($fp);
} else {
@readfile($filename);
}
@flush();
@ob_flush();
}
?>

View File

@@ -0,0 +1,44 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: portal_block.php 24984 2011-10-20 07:59:00Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$bid = max(0,intval($_GET['bid']));
if(empty($bid)) {
showmessage('block_choose_bid', dreferer());
}
block_get($bid);
if(!isset($_G['block'][$bid])) {
showmessage('block_noexist', dreferer());
}
$block = &$_G['block'][$bid];
$blockmoreurl = $block['param']['moreurl'] = isset($block['param']['moreurl']) ? $block['param']['moreurl'] :
array('perpage' => 20, 'seotitle' => $block['name'], 'keywords' => '', 'description' => '');
$blocktype = $block['blockclass'];
if(!in_array($blocktype, array('forum_thread', 'portal_article', 'group_thread'), true)) {
showmessage('block_nomore', dreferer());
}
$perpage = max(1, intval($blockmoreurl['perpage']));
$curpage = max(1, intval($_GET['page']));
$start = ($curpage-1) * $perpage;
$count = C::t('common_block_item_data')->count_by_bid($bid);
$list = $count ? C::t('common_block_item_data')->fetch_all_by_bid($bid, 1, $start, $perpage) : array();
$multipage = $count ? multi($count, $perpage, $curpage, 'portal.php?mod=block&bid='.$bid) : '';
$navtitle = $blockmoreurl['seotitle'];
$metakeywords = $blockmoreurl['seokeywords'];
$metadescription = $blockmoreurl['seodescription'];
$file = 'portal/block_more_'.$blocktype;
include template('diy:'.$file);
?>

View File

@@ -0,0 +1,60 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: portal_comment.php 33660 2013-07-29 07:51:05Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$id = empty($_GET['id']) ? 0 : intval($_GET['id']);
$idtype = in_array($_GET['idtype'], array('aid', 'topicid')) ? $_GET['idtype'] : 'aid';
$url = '';
if(empty($id)) {
showmessage('comment_no_'.$idtype.'_id');
}
if($idtype == 'aid') {
$csubject = C::t('portal_article_title')->fetch($id);
if($csubject) {
$csubject = array_merge($csubject, C::t('portal_article_count')->fetch($id));
}
$url = fetch_article_url($csubject);
} elseif($idtype == 'topicid') {
$csubject = C::t('portal_topic')->fetch($id);
$url = fetch_topic_url($csubject);
}
if(empty($csubject)) {
showmessage('comment_'.$idtype.'_no_exist');
} elseif(empty($csubject['allowcomment'])) {
showmessage($idtype.'_comment_is_forbidden');
}
$perpage = 25;
$page = intval($_GET['page']);
if($page<1) $page = 1;
$start = ($page-1)*$perpage;
$commentlist = array();
$multi = '';
if($csubject['commentnum']) {
$pricount = 0;
$query = C::t('portal_comment')->fetch_all_by_id_idtype($id, $idtype, 'dateline', 'DESC', $start, $perpage);
foreach($query as $value) {
if($value['status'] == 0 || $value['uid'] == $_G['uid'] || $_G['adminid'] == 1) {
$commentlist[] = $value;
} else {
$pricount ++;
}
}
}
$multi = multi($csubject['commentnum'], $perpage, $page, "portal.php?mod=comment&id=$id&idtype=$idtype");
list($seccodecheck, $secqaacheck) = seccheck('publish');
include_once template("diy:portal/comment");
?>

View File

@@ -0,0 +1,33 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: portal_index.php 31313 2012-08-10 03:51:03Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
list($navtitle, $metadescription, $metakeywords) = get_seosetting('portal');
if(!$navtitle) {
$navtitle = $_G['setting']['navs'][1]['navname'];
$nobbname = false;
} else {
$nobbname = true;
}
if(!$metakeywords) {
$metakeywords = $_G['setting']['navs'][1]['navname'];
}
if(!$metadescription) {
$metadescription = $_G['setting']['navs'][1]['navname'];
}
if(isset($_G['makehtml'])){
helper_makehtml::portal_index();
}
include_once template('diy:portal/index');
?>

View File

@@ -0,0 +1,205 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: portal_list.php 33245 2013-05-09 02:02:59Z laoguozhang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$_G['catid'] = $catid = max(0,intval($_GET['catid']));
if(empty($catid)) {
showmessage('list_choose_category', dreferer());
}
$portalcategory = &$_G['cache']['portalcategory'];
$cat = $portalcategory[$catid];
if(empty($cat)) {
showmessage('list_category_noexist', dreferer());
}
require_once libfile('function/portalcp');
$categoryperm = getallowcategory($_G['uid']);
if($cat['closed'] && !$_G['group']['allowdiy'] && !$categoryperm[$catid]['allowmanage']) {
showmessage('list_category_is_closed', dreferer());
}
if(!isset($_G['makehtml'])) {
if(!empty($cat['url'])) dheader('location:'.$cat['url']);
if(defined('SUB_DIR') && $_G['siteurl']. substr(SUB_DIR, 1) != $cat['caturl'] || !defined('SUB_DIR') && $_G['siteurl'] != substr($cat['caturl'], 0, strrpos($cat['caturl'], '/')+1)) {
dheader('location:'.$cat['caturl'], true, '301');
}
}
$cat = category_remake($catid);
$navid = 'mn_P'.$cat['topid'];
foreach ($_G['setting']['navs'] as $navsvalue) {
if($navsvalue['navid'] == $navid && $navsvalue['available'] && $navsvalue['level'] == 0) {
$_G['mnid'] = $navid;
break;
}
}
$page = max(1, intval($_GET['page']));
foreach($cat['ups'] as $val) {
$cats[] = $val['catname'];
}
$bodycss = array($cat['topid'] => 'pg_list_'.$cat['topid']);
if($cat['upid']) {
$bodycss[$cat['upid']] = 'pg_list_'.$cat['upid'];
}
$bodycss[$cat['catid']] = 'pg_list_'.$cat['catid'];
$cat['bodycss'] = implode(' ', $bodycss);
$catseoset = array(
'seotitle' => $cat['seotitle'],
'seokeywords' => $cat['keyword'],
'seodescription' => $cat['description']
);
$seodata = array('firstcat' => $cats[0], 'secondcat' => $cats[1], 'curcat' => $cat['catname'], 'page' => intval($_GET['page']));
list($navtitle, $metadescription, $metakeywords) = get_seosetting('articlelist', $seodata, $catseoset);
if(!$navtitle) {
$navtitle = helper_seo::get_title_page($cat['catname'], $_G['page']);
$nobbname = false;
} else {
$nobbname = true;
}
if(!$metakeywords) {
$metakeywords = $cat['catname'];
}
if(!$metadescription) {
$metadescription = $cat['catname'];
}
if(isset($_G['makehtml'])){
helper_makehtml::portal_list($cat);
}
$file = 'portal/list:'.$catid;
$tpldirectory = '';
$primaltplname = $cat['primaltplname'];
if(strpos($primaltplname, ':') !== false) {
list($tpldirectory, $primaltplname) = explode(':', $primaltplname);
}
include template('diy:'.$file, NULL, $tpldirectory, NULL, $primaltplname);
function category_get_wheresql($cat) {
$wheresql = '';
if(is_array($cat)) {
$catid = $cat['catid'];
if(!empty($cat['subs'])) {
include_once libfile('function/portalcp');
$subcatids = category_get_childids('portal', $catid);
$subcatids[] = $catid;
$wheresql = "at.catid IN (".dimplode($subcatids).")";
} else {
$wheresql = "at.catid='$catid'";
}
}
$wheresql .= " AND at.status='0'";
return $wheresql;
}
function category_get_list($cat, $wheresql, $page = 1, $perpage = 0) {
global $_G;
$cat['perpage'] = empty($cat['perpage']) ? 15 : $cat['perpage'];
$cat['maxpages'] = empty($cat['maxpages']) ? 1000 : $cat['maxpages'];
$perpage = intval($perpage);
$page = intval($page);
$perpage = empty($perpage) ? $cat['perpage'] : $perpage;
$page = empty($page) ? 1 : min($page, $cat['maxpages']);
$start = ($page-1)*$perpage;
if($start<0) $start = 0;
$list = array();
$pricount = 0;
$multi = '';
$count = C::t('portal_article_title')->fetch_all_by_sql($wheresql, '', 0, 0, 1, 'at');
if($count) {
$query = C::t('portal_article_title')->fetch_all_by_sql($wheresql, 'ORDER BY at.dateline DESC', $start, $perpage, 0, 'at');
foreach($query as $value) {
$value['catname'] = $value['catid'] == $cat['catid'] ? $cat['catname'] : $_G['cache']['portalcategory'][$value['catid']]['catname'];
$value['onerror'] = '';
if($value['pic']) {
$value['pic'] = pic_get($value['pic'], '', $value['thumb'], $value['remote'], 1, 1);
}
$value['dateline'] = dgmdate($value['dateline']);
if($value['status'] == 0 || $value['uid'] == $_G['uid'] || $_G['adminid'] == 1) {
$list[] = $value;
} else {
$pricount++;
}
}
if(strpos($cat['caturl'], 'portal.php') === false) {
$cat['caturl'] .= 'index.php';
}
$multi = multi($count, $perpage, $page, $cat['caturl'], $cat['maxpages']);
}
return $return = array('list'=>$list,'count'=>$count,'multi'=>$multi,'pricount'=>$pricount);
}
function category_get_list_more($cat, $wheresql, $hassub = true,$hasnew = true,$hashot = true) {
global $_G;
$data = array();
$catid = $cat['catid'];
$cachearr = array();
if($hashot) $cachearr[] = 'portalhotarticle';
if($hasnew) $cachearr[] = 'portalnewarticle';
if($hassub) {
foreach($cat['children'] as $childid) {
$cachearr[] = 'subcate'.$childid;
}
}
$allowmemory = memory('check');
foreach ($cachearr as $key) {
$cachekey = $key.$catid;
$data[$key] = $allowmemory ? memory('get', $cachekey) : false;
if($data[$key] === false) {
$list = array();
$sql = '';
if($key == 'portalhotarticle') {
$dateline = TIMESTAMP - 3600 * 24 * 90;
$query = C::t('portal_article_count')->fetch_all_hotarticle($wheresql, $dateline);
} elseif($key == 'portalnewarticle') {
$query = C::t('portal_article_title')->fetch_all_by_sql($wheresql, 'ORDER BY at.dateline DESC', 0, 10, 0, 'at');
} elseif(substr($key, 0, 7) == 'subcate') {
$cacheid = intval(str_replace('subcate', '', $key));
if(!empty($_G['cache']['portalcategory'][$cacheid])) {
$where = '';
if(!empty($_G['cache']['portalcategory'][$cacheid]['children']) && dimplode($_G['cache']['portalcategory'][$cacheid]['children'])) {
$_G['cache']['portalcategory'][$cacheid]['children'][] = $cacheid;
$where = 'at.catid IN ('.dimplode($_G['cache']['portalcategory'][$cacheid]['children']).')';
} else {
$where = 'at.catid='.$cacheid;
}
$where .= " AND at.status='0'";
$query = C::t('portal_article_title')->fetch_all_by_sql($where, 'ORDER BY at.dateline DESC', 0, 10, 0, 'at');
}
}
if($query) {
foreach($query as $value) {
$value['catname'] = $value['catid'] == $cat['catid'] ? $cat['catname'] : $_G['cache']['portalcategory'][$value['catid']]['catname'];
if($value['pic']) $value['pic'] = pic_get($value['pic'], '', $value['thumb'], $value['remote'], 1, 1);
$value['timestamp'] = $value['dateline'];
$value['dateline'] = dgmdate($value['dateline']);
$list[] = $value;
}
}
$data[$key] = $list;
if($allowmemory) {
memory('set', $cachekey, $list, empty($list) ? 60 : 600);
}
}
}
return $data;
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: portal_portalcp.php 28492 2012-03-01 10:05:07Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$ac = in_array(getgpc('ac'), array('comment', 'article', 'related', 'block', 'portalblock', 'blockdata', 'topic', 'diy', 'upload', 'category', 'plugin', 'logout')) ? $_GET['ac'] : 'index';
if (!$_G['setting']['portalstatus'] && !in_array($ac, array('index', 'block', 'portalblock', 'blockdata', 'diy', 'logout'))) {
showmessage('portal_status_off');
}
$_G['disabledwidthauto'] = 0;
$admincp2 = getstatus($_G['member']['allowadmincp'], 2);
$admincp3 = getstatus($_G['member']['allowadmincp'], 3);
$admincp4 = getstatus($_G['member']['allowadmincp'], 4);
$admincp5 = getstatus($_G['member']['allowadmincp'], 5);
$admincp6 = getstatus($_G['member']['allowadmincp'], 6);
if (!$_G['inajax'] && in_array($ac, array('index', 'portalblock', 'blockdata', 'category', 'plugin')) && ($_G['group']['allowdiy'] || $_G['group']['allowmanagearticle'] || $admincp2 || $admincp3 || $admincp4 || $admincp6)) {
$modsession = new discuz_panel(PORTALCP_PANEL);
if(getgpc('login_panel') && getgpc('cppwd') && submitcheck('submit')) {
$modsession->dologin($_G['uid'], getgpc('cppwd'), true);
}
if(!$modsession->islogin) {
include template('portal/portalcp_login');
dexit();
}
}
if($ac == 'logout') {
$modsession = new discuz_panel(PORTALCP_PANEL);
$modsession->dologout();
showmessage('modcp_logout_succeed', 'index.php');
}
$navtitle = lang('core', 'title_'.$ac.'_management').' - '.lang('core', 'title_portal_management');
require_once libfile('function/portalcp');
require_once libfile('portalcp/'.$ac, 'include');
?>

View File

@@ -0,0 +1,143 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: portal_rss.php 24992 2011-10-20 09:41:00Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['setting']['rssstatus']) {
exit('RSS Disabled');
}
$ttl = $_G['setting']['rssttl'] ? $_G['setting']['rssttl']: 30;
$num = 20;
$_G['groupid'] = 7;
$_G['uid'] = 0;
$_G['username'] = $_G['member']['password'] = '';
$rsscatid = empty($_GET['catid']) ? 0 : intval($_GET['catid']);
$catname = '';
if(empty($rsscatid)) {
foreach($_G['cache']['portalcategory'] as $catid => $category) {
$catarray[] = $catid;
}
} else {
if(isset($_G['cache']['portalcategory'][$rsscatid])) {
$catarray = array($rsscatid);
$catname = dhtmlspecialchars($_G['cache']['portalcategory'][$rsscatid]['catname']);
} else {
exit('Specified article not found');
}
}
$rewriteflag = 0;
$havedomain = implode('', $_G['setting']['domain']['app']);
if(is_array($_G['setting']['rewritestatus']) && in_array('portal_article', $_G['setting']['rewritestatus'])) {
$rewriteflag = 1;
}
$charset = $_G['config']['output']['charset'];
dheader("Content-type: application/xml");
echo "<?xml version=\"1.0\" encoding=\"".$charset."\"?>\n".
"<rss version=\"2.0\">\n".
" <channel>\n".
(count($catarray) > 1 ?
" <title>{$_G['setting']['bbname']}</title>\n".
" <link>{$_G['siteurl']}forum.php</link>\n".
" <description>Latest $num articles of all categories</description>\n"
:
" <title>{$_G['setting']['bbname']} - $catname</title>\n".
" <link>{$_G['siteurl']}portal.php?mod=list&amp;catid=$rsscatid</link>\n".
" <description>Latest $num articles of $catname</description>\n"
).
" <copyright>Copyright(C) {$_G['setting']['bbname']}</copyright>\n".
" <generator>Discuz! Board by Comsenz Inc.</generator>\n".
" <lastBuildDate>".gmdate('r', TIMESTAMP)."</lastBuildDate>\n".
" <ttl>$ttl</ttl>\n".
" <image>\n".
" <url>{$_G['siteurl']}static/image/common/logo_88_31.gif</url>\n".
" <title>{$_G['setting']['bbname']}</title>\n".
" <link>{$_G['siteurl']}</link>\n".
" </image>\n";
if($catarray) {
$alldata = C::t('portal_rsscache')->fetch_all_by_catid($catarray, $num);
if($alldata) {
foreach($alldata as $article) {
if(TIMESTAMP - $article['lastupdate'] > $ttl * 60) {
updatersscache($num);
break;
} else {
list($article['description'], $attachremote, $attachfile, $attachsize) = explode("\t", $article['description']);
if($attachfile) {
if($attachremote) {
$filename = $_G['setting']['ftp']['attachurl'].'portal/'.$attachfile;
} else {
$filename = $_G['siteurl'].$_G['setting']['attachurl'].'portal/'.$attachfile;
}
}
echo " <item>\n".
" <title>".$article['subject']."</title>\n".
" <link>{$_G['siteurl']}".($rewriteflag ? rewriteoutput('portal_article', 1, '', $article['aid']) : "portal.php?mod=view&amp;aid={$article['aid']}")."</link>\n".
" <description><![CDATA[".dhtmlspecialchars($article['description'])."]]></description>\n".
" <category>".dhtmlspecialchars($article['catname'])."</category>\n".
" <author>".dhtmlspecialchars($article['author'])."</author>\n".
($attachfile ? '<enclosure url="'.$filename.'" length="'.$attachsize.'" type="image/jpeg" />'."\n" : '').
" <pubDate>".gmdate('r', $article['dateline'])."</pubDate>\n".
" </item>\n";
}
}
} else {
updatersscache($num);
}
}
echo " </channel>\n".
"</rss>";
function updatersscache($num) {
global $_G;
$processname = 'portal_rss_cache';
if(discuz_process::islocked($processname, 600)) {
return false;
}
C::t('portal_rsscache')->truncate();
require_once libfile('function/post');
foreach($_G['cache']['portalcategory'] as $catid => $catarray) {
$query = C::t('portal_article_title')->fetch_all_for_cat($catid, 0, 1, 0, $num);
$catarray['catname'] = addslashes($catarray['catname']);
foreach($query as $article) {
$article['author'] = $article['author'] != '' ? addslashes($article['author']) : ($article['username'] ? addslashes($article['username']) : 'Anonymous');
$article['title'] = addslashes($article['title']);
$articleattach = C::t('portal_attachment')->fetch_by_aid_image($article['aid']);
$attachdata = '';
if(!empty($articleattach)) {
$attachdata = "\t".$articleattach['remote']."\t".$articleattach['attachment']."\t".$articleattach['filesize'];
}
$article['description'] = addslashes(messagecutstr($article['summary'], 250 - strlen($attachdata)).$attachdata);
C::t('portal_rsscache')->insert(array(
'lastupdate'=>$_G['timestamp'],
'catid'=>$catid,
'aid'=>$article['aid'],
'dateline'=>$article['dateline'],
'catname'=>$catarray['catname'],
'author'=>$article['author'],
'subject'=>$article['title'],
'description'=>$article['description']
));
}
}
discuz_process::unlock($processname);
return true;
}
?>

View File

@@ -0,0 +1,85 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: portal_topic.php 33660 2013-07-29 07:51:05Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if($_GET['diy']=='yes' && !$_G['group']['allowaddtopic'] && !$_G['group']['allowmanagetopic']) {
$_GET['diy'] = '';
showmessage('topic_edit_nopermission');
}
$topicid = $_GET['topicid'] ? intval($_GET['topicid']) : 0;
if($topicid) {
$topic = C::t('portal_topic')->fetch($topicid);
} elseif($_GET['topic']) {
$topic = C::t('portal_topic')->fetch_by_name($_GET['topic']);
}
if(empty($topic)) {
showmessage('topic_not_exist');
}
if($topic['closed'] && !$_G['group']['allowmanagetopic'] && !($topic['uid'] == $_G['uid'] && $_G['group']['allowaddtopic'])) {
showmessage('topic_is_closed');
}
if($_GET['diy'] == 'yes' && $topic['uid'] != $_G['uid'] && !$_G['group']['allowmanagetopic']) {
$_GET['diy'] = '';
showmessage('topic_edit_nopermission');
}
if(!empty($_G['setting']['makehtml']['flag']) && $topic['htmlmade'] && !isset($_G['makehtml']) && empty($_GET['diy'])) {
dheader('location:'.fetch_topic_url($topic));
}
$topicid = intval($topic['topicid']);
C::t('portal_topic')->increase($topicid, array('viewnum' => 1));
$navtitle = $topic['title'];
$metadescription = empty($topic['summary']) ? $topic['title'] : $topic['summary'];
$metakeywords = empty($topic['keyword']) ? $topic['title'] : $topic['keyword'];
$attachtags = $aimgs = array();
list($seccodecheck, $secqaacheck) = seccheck('publish');
if(isset($_G['makehtml'])) {
helper_makehtml::portal_topic($topic);
}
$file = 'portal/portal_topic_content:'.$topicid;
$tpldirectory = '';
$primaltplname = $topic['primaltplname'];
if(strpos($primaltplname, ':') !== false) {
list($tpldirectory, $primaltplname) = explode(':', $primaltplname);
}
$topicurl = fetch_topic_url($topic);
include template('diy:'.$file, NULL, $tpldirectory, NULL, $primaltplname);
function portaltopicgetcomment($topcid, $limit = 20, $start = 0) {
global $_G;
$topcid = intval($topcid);
$limit = intval($limit);
$start = intval($start);
$data = array();
if($topcid) {
$query = C::t('portal_comment')->fetch_all_by_id_idtype($topcid, 'topicid', 'dateline', 'DESC', $start, $limit);
foreach($query as $value) {
if($value['status'] == 0 || $value['uid'] == $_G['uid'] || $_G['adminid'] == 1) {
$data[$value['cid']] = $value;
}
}
}
return $data;
}
?>

View File

@@ -0,0 +1,345 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: portal_view.php 33660 2013-07-29 07:51:05Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$aid = empty($_GET['aid'])?0:intval($_GET['aid']);
if(empty($aid)) {
header("HTTP/1.1 404 Not Found");
showmessage('view_no_article_id');
}
$article = C::t('portal_article_title')->fetch($aid);
require_once libfile('function/portalcp');
$categoryperm = getallowcategory($_G['uid']);
if(empty($article) || ($article['status'] > 0 && $article['uid'] != $_G['uid'] && !$_G['group']['allowmanagearticle'] && empty($categoryperm[$article['catid']]['allowmanage']) && $_G['adminid'] != 1 && $_GET['modarticlekey'] != modauthkey($article['aid']))) {
header("HTTP/1.1 404 Not Found");
showmessage('view_article_no_exist');
}
if(!empty($_G['setting']['antitheft']['allow']) && empty($_G['setting']['antitheft']['disable']['article']) && empty($_G['cache']['portalcategory'][$article['catid']]['noantitheft'])) {
helper_antitheft::check($aid, 'aid');
}
if(!empty($_G['setting']['makehtml']['flag']) && $article['htmlmade'] && !isset($_G['makehtml']) && empty($_GET['diy']) && empty($article['url'])) {
dheader('location:'. fetch_article_url($article));
}
$article_count = C::t('portal_article_count')->fetch($aid);
if($article_count) $article = array_merge($article_count, $article);
if($article_count) {
C::t('portal_article_count')->increase($aid, array('viewnum'=>1));
unset($article_count);
} else {
C::t('portal_article_count')->insert(array(
'aid'=>$aid,
'catid'=>$article['catid'],
'viewnum'=>1));
}
if($article['url']) {
if(!isset($_G['makehtml'])) {
dheader("location:{$article['url']}");
}
exit();
}
$cat = category_remake($article['catid']);
$article['pic'] = pic_get($article['pic'], '', $article['thumb'], $article['remote'], 1, 1);
$page = intval($_GET['page']);
if($page<1) $page = 1;
$content = $contents = array();
$multi = '';
$content = C::t('portal_article_content')->fetch_by_aid_page($aid, $page);
if($article['contents'] && $article['showinnernav']) {
foreach(C::t('portal_article_content')->fetch_all_by_aid($aid) as $value) {
$contents[] = $value;
}
if(empty($contents)) {
C::t('portal_article_content')->update($aid, array('showinnernav' => '0'));
}
}
require_once libfile('function/blog');
$content['content'] = blog_bbcode($content['content']);
if(!empty($_G['setting']['makehtml']['flag']) && $article['htmlmade']) {
$_caturl = $_G['cache']['portalcategory'][$cat['topid']]['domain'] ? $_G['cache']['portalcategory'][$cat['topid']]['caturl'] : '';
$viewurl = $_caturl.$article['htmldir'].$article['htmlname'].'{page}.'.$_G['setting']['makehtml']['extendname'];
unset($_caturl);
} else {
$viewurl = "portal.php?mod=view&aid=$aid";
}
$multi = multi($article['contents'], 1, $page, $viewurl);
$org = array();
if($article['idtype'] == 'tid' || $content['idtype']=='pid') {
$thread = $firstpost = array();
require_once libfile('function/discuzcode');
require_once libfile('function/forum');
$thread = get_thread_by_tid($article['id']);
if(!empty($thread)) {
if($content['idtype']=='pid') {
$firstpost = C::t('forum_post')->fetch_post($thread['posttableid'], $content['id']);
} else {
$firstpost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($article['id']);
}
if($firstpost && $firstpost['tid'] == $article['id']) {
$firstpost['uid'] = $firstpost['authorid'];
$firstpost['username'] = $firstpost['author'];
}
}
if(!empty($firstpost) && !empty($thread) && $thread['displayorder'] != -1) {
$_G['tid'] = $article['id'];
$aids = array();
$firstpost['message'] = $content['content'];
if($thread['attachment']) {
$_G['group']['allowgetimage'] = 1;
if(preg_match_all("/\[attach\](\d+)\[\/attach\]/i", $firstpost['message'], $matchaids)) {
$aids = $matchaids[1];
}
}
if($aids) {
parseforumattach($firstpost, $aids);
}
$content['content'] = $firstpost['message'];
$content['pid'] = $firstpost['pid'];
$org = $firstpost;
$org_url = "forum.php?mod=viewthread&tid={$article['id']}";
} else {
C::t('portal_article_title')->update($aid, array('id' => 0, 'idtype' => ''));
C::t('portal_article_content')->update_by_aid($aid, array('id' => 0, 'idtype' => ''));
}
} elseif($article['idtype']=='blogid') {
$org = C::t('home_blog')->fetch($article['id']);
if(empty($org)) {
C::t('portal_article_title')->update($aid, array('id' => 0, 'idtype' => ''));
dheader('location: '. fetch_article_url($article));
exit();
}
}
$article['related'] = array();
if(($relateds = C::t('portal_article_related')->fetch_all_by_aid($aid))) {
foreach(C::t('portal_article_title')->fetch_all(array_keys($relateds)) as $raid => $value) {
$value['uri'] = fetch_article_url($value);
$article['related'][$raid] = $value;
}
}
$article['allowcomment'] = !empty($cat['allowcomment']) && !empty($article['allowcomment']) ? 1 : 0;
$_G['catid'] = $_GET['catid'] = $article['catid'];
$common_url = '';
$commentlist = array();
if($article['allowcomment']) {
if($org && empty($article['owncomment'])) {
if($article['idtype'] == 'blogid') {
$common_url = "home.php?mod=space&uid={$org['uid']}&do=blog&id={$article['id']}";
$form_url = "home.php?mod=spacecp&ac=comment";
$article['commentnum'] = C::t('home_comment')->count_by_id_idtype($article['id'], 'blogid');
if($article['commentnum']) {
$query = C::t('home_comment')->fetch_all_by_id_idtype($article['id'], 'blogid', 0, 20, '', 'DESC');
foreach($query as $value) {
if($value['status'] == 0 || $_G['adminid'] == 1 || $value['uid'] == $_G['uid']) {
$commentlist[] = $value;
}
}
}
} elseif($article['idtype'] == 'tid') {
$common_url = "forum.php?mod=viewthread&tid={$article['id']}";
$form_url = "forum.php?mod=post&action=reply&tid={$article['id']}&replysubmit=yes&infloat=yes&handlekey=fastpost";
require_once libfile('function/discuzcode');
$posttable = empty($thread['posttable']) ? getposttablebytid($article['id']) : $thread['posttable'];
$_G['tid'] = $article['id'];
$article['commentnum'] = getcount($posttable, array('tid'=>$article['id'], 'first'=>'0'));
if($article['allowcomment'] && $article['commentnum']) {
$attachpids = $attachtags = array();
$_G['group']['allowgetattach'] = $_G['group']['allowgetimage'] = 1;
foreach(C::t('forum_post')->fetch_all_by_tid('tid:'.$article['id'], $article['id'], true, 'ASC', 0, 20, null, 0) as $value) {
$value['uid'] = $value['authorid'];
$value['username'] = $value['author'];
if($value['status'] != 1 && !$value['first']) {
$value['message'] = discuzcode($value['message'], $value['smileyoff'], $value['bbcodeoff'], $value['htmlon']);
$value['cid'] = $value['pid'];
$commentlist[$value['pid']] = $value;
if($value['attachment']) {
$attachpids[] = $value['pid'];
if(preg_match_all("/\[attach\](\d+)\[\/attach\]/i", $value['message'], $matchaids)) {
$attachtags[$value['pid']] = $matchaids[1];
}
}
}
}
if($attachpids) {
require_once libfile('function/attachment');
parseattach($attachpids, $attachtags, $commentlist);
}
}
}
} else {
$common_url = "portal.php?mod=comment&id=$aid&idtype=aid";
$form_url = "portal.php?mod=portalcp&ac=comment";
$query = C::t('portal_comment')->fetch_all_by_id_idtype($aid, 'aid', 'dateline', 'DESC', 0, 20);
$pricount = 0;
foreach($query as $value) {
if($value['status'] == 0 || $value['uid'] == $_G['uid'] || $_G['adminid'] == 1) {
$value['allowop'] = 1;
$commentlist[] = $value;
} else {
$pricount += 1;
}
}
}
}
$hash = md5($article['uid']."\t".$article['dateline']);
$id = $article['aid'];
$idtype = 'aid';
loadcache('click');
$clicks = empty($_G['cache']['click']['aid'])?array():$_G['cache']['click']['aid'];
$maxclicknum = 0;
foreach ($clicks as $key => $value) {
$value['clicknum'] = $article["click{$key}"];
$value['classid'] = mt_rand(1, 4);
if($value['clicknum'] > $maxclicknum) $maxclicknum = $value['clicknum'];
$clicks[$key] = $value;
}
$clickuserlist = array();
foreach(C::t('home_clickuser')->fetch_all_by_id_idtype($id, $idtype, 0, 24) as $value) {
$value['clickname'] = $clicks[$value['clickid']]['name'];
$clickuserlist[] = $value;
}
$article['timestamp'] = $article['dateline'];
$article['dateline'] = dgmdate($article['dateline']);
foreach($cat['ups'] as $val) {
$cats[] = $val['catname'];
}
$seodata = array('firstcat' => $cats[0], 'secondcat' => $cats[1], 'curcat' => $cat['catname'], 'subject' => $article['title'], 'user' => $article['username'], 'summary' => $article['summary'], 'page' => intval($_GET['page']));
list($navtitle, $metadescription, $metakeywords) = get_seosetting('article', $seodata);
if(empty($navtitle)) {
$navtitle = helper_seo::get_title_page($article['title'], $_G['page']).' - '.$cat['catname'];
$nobbname = false;
} else {
$nobbname = true;
}
if(empty($metakeywords)) {
$metakeywords = $article['title'];
}
if(empty($metadescription)) {
$metadescription = $article['summary'] ? $article['summary'] : $article['title'];
}
list($seccodecheck, $secqaacheck) = seccheck('publish');
$catid = $article['catid'];
if(!$_G['setting']['relatedlinkstatus']) {
$_G['relatedlinks'] = get_related_link('article');
} else {
$content['content'] = parse_related_link($content['content'], 'article');
}
if(isset($_G['makehtml'])) {
helper_makehtml::portal_article($cat, $article, $page);
}
portal_get_per_next_article($article);
$tpldirectory = '';
$articleprimaltplname = $cat['articleprimaltplname'];
if(strpos($articleprimaltplname, ':') !== false) {
list($tpldirectory, $articleprimaltplname) = explode(':', $articleprimaltplname);
}
include_once template("diy:portal/view:{$catid}", NULL, $tpldirectory, NULL, $articleprimaltplname);
function parseforumattach(&$post, $aids) {
global $_G;
if(($aids = array_unique($aids))) {
require_once libfile('function/attachment');
$finds = $replaces = array();
foreach(C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$post['tid'], 'aid', $aids) as $attach) {
$attach['url'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/';
$attach['dateline'] = dgmdate($attach['dateline'], 'u');
$extension = strtolower(fileext($attach['filename']));
$attach['ext'] = $extension;
$attach['imgalt'] = $attach['isimage'] ? strip_tags(str_replace('"', '\"', $attach['description'] ? $attach['description'] : $attach['filename'])) : '';
$attach['attachicon'] = attachtype($extension."\t".$attach['filetype']);
$attach['attachsize'] = sizecount($attach['filesize']);
$attach['refcheck'] = (!$attach['remote'] && $_G['setting']['attachrefcheck']) || ($attach['remote'] && ($_G['setting']['ftp']['hideurl'] || ($attach['isimage'] && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp')));
$aidencode = packaids($attach);
$widthcode = attachwidth($attach['width']);
$is_archive = $_G['forum_thread']['is_archived'] ? "&fid=".$_G['fid']."&archiveid=".$_G['forum_thread']['archiveid'] : '';
if($attach['isimage']) {
$attachthumb = getimgthumbname($attach['attachment']);
if($_G['setting']['thumbstatus'] && $attach['thumb']) {
$replaces[$attach['aid']] = "<a href=\"javascript:;\"><img id=\"_aimg_{$attach['aid']}\" aid=\"{$attach['aid']}\" onclick=\"zoom(this, this.getAttribute('zoomfile'), 0, 0, '{$_G['forum']['showexif']}')\"
zoomfile=\"".($attach['refcheck'] ? "forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes&nothumb=yes" : $attach['url'].$attach['attachment'])."\"
src=\"".($attach['refcheck'] ? "forum.php?mod=attachment{$is_archive}&aid=$aidencode" : $attach['url'].$attachthumb)."\" alt=\"{$attach['imgalt']}\" title=\"{$attach['imgalt']}\" w=\"{$attach['width']}\" /></a>";
} else {
$replaces[$attach['aid']] = "<img id=\"_aimg_{$attach['aid']}\" aid=\"{$attach['aid']}\"
zoomfile=\"".($attach['refcheck'] ? "forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes&nothumb=yes" : $attach['url'].$attach['attachment'])."\"
src=\"".($attach['refcheck'] ? "forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes " : $attach['url'].$attach['attachment'])."\" $widthcode alt=\"{$attach['imgalt']}\" title=\"{$attach['imgalt']}\" w=\"{$attach['width']}\" />";
}
} else {
$replaces[$attach['aid']] = "{$attach['attachicon']}<a href=\"forum.php?mod=attachment{$is_archive}&aid=$aidencode\" onmouseover=\"showMenu({'ctrlid':this.id,'pos':'12'})\" id=\"aid{$attach['aid']}\" target=\"_blank\">{$attach['filename']}</a>";
}
$finds[$attach['aid']] = '[attach]'.$attach['aid'].'[/attach]';
}
if($finds && $replaces) {
$post['message'] = str_ireplace($finds, $replaces, $post['message']);
}
}
}
function portal_get_per_next_article(&$article) {
$data = array();
$aids = array();
if($article['preaid']) {
$aids[$article['preaid']] = $article['preaid'];
}
if($article['nextaid']) {
$aids[$article['nextaid']] = $article['nextaid'];
}
if($aids) {
$data = C::t('portal_article_title')->fetch_all($aids);
foreach ($data as $aid => &$value) {
$value['url'] = fetch_article_url($value);
}
}
if($data[$article['preaid']]) {
$article['prearticle'] = $data[$article['preaid']];
}
if($data[$article['nextaid']]) {
$article['nextarticle'] = $data[$article['nextaid']];
}
}
?>

View File

View File

@@ -0,0 +1,149 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: search_album.php 29236 2012-03-30 05:34:47Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
require_once libfile('function/home');
if(!$_G['setting']['search']['album']['status']) {
showmessage('search_album_closed');
}
if($_G['adminid'] != 1 && !($_G['group']['allowsearch'] & 8)) {
showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
}
$_G['setting']['search']['album']['searchctrl'] = intval($_G['setting']['search']['album']['searchctrl']);
$srchmod = 4;
$cachelife_time = 300; // Life span for cache of searching in specified range of time
$cachelife_text = 3600; // Life span for cache of text searching
$srchtype = empty($_GET['srchtype']) ? '' : trim($_GET['srchtype']);
$searchid = isset($_GET['searchid']) ? intval($_GET['searchid']) : 0;
$srchtxt = $_GET['srchtxt'];
$keyword = isset($srchtxt) ? dhtmlspecialchars(trim($srchtxt)) : '';
if(!submitcheck('searchsubmit', 1)) {
include template('search/album');
} else {
$orderby = in_array($_GET['orderby'], array('dateline', 'replies', 'views')) ? $_GET['orderby'] : 'lastpost';
$ascdesc = isset($_GET['ascdesc']) && $_GET['ascdesc'] == 'asc' ? 'asc' : 'desc';
if(!empty($searchid)) {
$page = max(1, intval($_GET['page']));
$start_limit = ($page - 1) * $_G['tpp'];
$index = C::t('common_searchindex')->fetch_by_searchid_srchmod($searchid, $srchmod);
if(!$index) {
showmessage('search_id_invalid');
}
$keyword = dhtmlspecialchars($index['keywords']);
$keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : '';
$index['keywords'] = rawurlencode($index['keywords']);
$albumlist = array();
$maxalbum = $nowalbum = 0;
$query = C::t('home_album')->fetch_all_album(explode(',', $index['ids']), 'updatetime', $start_limit, $_G['tpp']);
foreach($query as $value) {
if($value['friend'] != 4 && ckfriend($value['uid'], $value['friend'], $value['target_ids'])) {
$value['pic'] = pic_cover_get($value['pic'], $value['picflag']);
} elseif ($value['picnum']) {
$value['pic'] = STATICURL.'image/common/nopublish.jpg';
} else {
$value['pic'] = '';
}
$value['albumname'] = bat_highlight($value['albumname'], $keyword);
$albumlist[$value['albumid']] = $value;
}
$multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=album&searchid=$searchid&orderby=$orderby&ascdesc=$ascdesc&searchsubmit=yes");
$url_forward = 'search.php?mod=album&'.$_SERVER['QUERY_STRING'];
include template('search/album');
} else {
$searchstring = 'album|title|'.addslashes($srchtxt);
$searchindex = array('id' => 0, 'dateline' => '0');
foreach(C::t('common_searchindex')->fetch_all_search($_G['setting']['search']['album']['searchctrl'], $_G['clientip'], $_G['uid'], $_G['timestamp'], $searchstring, $srchmod) as $index) {
if($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
$searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
break;
} elseif($_G['adminid'] != '1' && $index['flood']) {
showmessage('search_ctrl', 'search.php?mod=album', array('searchctrl' => $_G['setting']['search']['album']['searchctrl']));
}
}
if($searchindex['id']) {
$searchid = $searchindex['id'];
} else {
!($_G['group']['exempt'] & 2) && checklowerlimit('search');
if(!$srchtxt && !$srchuid && !$srchuname) {
dheader('Location: search.php?mod=album');
}
if($_G['adminid'] != '1' && $_G['setting']['search']['album']['maxspm']) {
if(C::t('common_searchindex')->count_by_dateline($_G['timestamp'], $srchmod) >= $_G['setting']['search']['album']['maxspm']) {
showmessage('search_toomany', 'search.php?mod=album', array('maxspm' => $_G['setting']['search']['album']['maxspm']));
}
}
$num = $ids = 0;
$_G['setting']['search']['album']['maxsearchresults'] = $_G['setting']['search']['album']['maxsearchresults'] ? intval($_G['setting']['search']['album']['maxsearchresults']) : 500;
list($srchtxt, $srchtxtsql) = searchkey($keyword, "albumname LIKE '%{text}%'", true);
$query = C::t('home_album')->fetch_albumid_by_searchkey($srchtxtsql, $_G['setting']['search']['album']['maxsearchresults']);
foreach($query as $album) {
$ids .= ','.$album['albumid'];
$num++;
}
unset($query);
$keywords = str_replace('%', '+', $srchtxt);
$expiration = TIMESTAMP + $cachelife_text;
$searchid = C::t('common_searchindex')->insert(array(
'srchmod' => $srchmod,
'keywords' => $keywords,
'searchstring' => $searchstring,
'useip' => $_G['clientip'],
'uid' => $_G['uid'],
'dateline' => $_G['timestamp'],
'expiration' => $expiration,
'num' => $num,
'ids' => $ids
), true);
!($_G['group']['exempt'] & 2) && updatecreditbyaction('search');
}
dheader("location: search.php?mod=album&searchid=$searchid&searchsubmit=yes&kw=".urlencode($keyword));
}
}
?>

View File

@@ -0,0 +1,159 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: search_blog.php 29236 2012-03-30 05:34:47Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
require_once libfile('function/home');
if(!$_G['setting']['search']['blog']['status']) {
showmessage('search_blog_closed');
}
if($_G['adminid'] != 1 && !($_G['group']['allowsearch'] & 4)) {
showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
}
$_G['setting']['search']['blog']['searchctrl'] = intval($_G['setting']['search']['blog']['searchctrl']);
$srchmod = 3;
$cachelife_time = 300; // Life span for cache of searching in specified range of time
$cachelife_text = 3600; // Life span for cache of text searching
$srchtype = empty($_GET['srchtype']) ? '' : trim($_GET['srchtype']);
$searchid = isset($_GET['searchid']) ? intval($_GET['searchid']) : 0;
$srchtxt = $_GET['srchtxt'];
$keyword = isset($srchtxt) ? dhtmlspecialchars(trim($srchtxt)) : '';
if(!submitcheck('searchsubmit', 1)) {
include template('search/blog');
} else {
$orderby = in_array($_GET['orderby'], array('dateline', 'replies', 'views')) ? $_GET['orderby'] : 'lastpost';
$ascdesc = isset($_GET['ascdesc']) && $_GET['ascdesc'] == 'asc' ? 'asc' : 'desc';
if(!empty($searchid)) {
$page = max(1, intval($_GET['page']));
$start_limit = ($page - 1) * $_G['tpp'];
$index = C::t('common_searchindex')->fetch_by_searchid_srchmod($searchid, $srchmod);
if(!$index) {
showmessage('search_id_invalid');
}
$keyword = dhtmlspecialchars($index['keywords']);
$keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : '';
$index['keywords'] = rawurlencode($index['keywords']);
$result = array();
$bloglist = array();
$pricount = 0;
$blogidarray = explode(',', $index['ids']);
$data_blog = C::t('home_blog')->fetch_all_blog($blogidarray, 'dateline', 'DESC', $start_limit, $_G['tpp']);
$data_blogfield = C::t('home_blogfield')->fetch_all($blogidarray);
foreach($data_blog as $curblogid => $value) {
$result = array_merge($result, (array)$data_blogfield[$curblogid]);
if(ckfriend($value['uid'], $value['friend'], $value['target_ids']) && ($value['status'] == 0 || $value['uid'] == $_G['uid'] || $_G['adminid'] == 1)) {
if($value['friend'] == 4) {
$value['message'] = $value['pic'] = '';
} else {
$value['message'] = bat_highlight($value['message'], $keyword);
$value['message'] = getstr($value['message'], 255, 0, 0, 0, -1);
}
$value['subject'] = bat_highlight($value['subject'], $keyword);
$value['dateline'] = dgmdate($value['dateline']);
$value['pic'] = pic_cover_get($value['pic'], $value['picflag']);
$bloglist[] = $value;
} else {
$pricount++;
}
}
$multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=blog&searchid=$searchid&orderby=$orderby&ascdesc=$ascdesc&searchsubmit=yes");
$url_forward = 'search.php?mod=blog&'.$_SERVER['QUERY_STRING'];
include template('search/blog');
} else {
$searchstring = 'blog|title|'.addslashes($srchtxt);
$searchindex = array('id' => 0, 'dateline' => '0');
foreach(C::t('common_searchindex')->fetch_all_search($_G['setting']['search']['blog']['searchctrl'], $_G['clientip'], $_G['uid'], $_G['timestamp'], $searchstring, $srchmod) as $index) {
if($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
$searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
break;
} elseif($_G['adminid'] != '1' && $index['flood']) {
showmessage('search_ctrl', 'search.php?mod=blog', array('searchctrl' => $_G['setting']['search']['blog']['searchctrl']));
}
}
if($searchindex['id']) {
$searchid = $searchindex['id'];
} else {
!($_G['group']['exempt'] & 2) && checklowerlimit('search');
if(!$srchtxt && !$srchuid && !$srchuname) {
dheader('Location: search.php?mod=blog');
}
if($_G['adminid'] != '1' && $_G['setting']['search']['blog']['maxspm']) {
if(C::t('common_searchindex')->count_by_dateline($_G['timestamp'], $srchmod) >= $_G['setting']['search']['blog']['maxspm']) {
showmessage('search_toomany', 'search.php?mod=blog', array('maxspm' => $_G['setting']['search']['blog']['maxspm']));
}
}
$num = $ids = 0;
$_G['setting']['search']['blog']['maxsearchresults'] = $_G['setting']['search']['blog']['maxsearchresults'] ? intval($_G['setting']['search']['blog']['maxsearchresults']) : 500;
list($srchtxt, $srchtxtsql) = searchkey($keyword, "subject LIKE '%{text}%'", true);
$query = C::t('home_blog')->fetch_blogid_by_subject($keyword, $_G['setting']['search']['blog']['maxsearchresults']);
foreach($query as $blog) {
$ids .= ','.$blog['blogid'];
$num++;
}
unset($query);
$keywords = str_replace('%', '+', $srchtxt);
$expiration = TIMESTAMP + $cachelife_text;
$searchid = C::t('common_searchindex')->insert(array(
'srchmod' => $srchmod,
'keywords' => $keywords,
'searchstring' => $searchstring,
'useip' => $_G['clientip'],
'uid' => $_G['uid'],
'dateline' => $_G['timestamp'],
'expiration' => $expiration,
'num' => $num,
'ids' => $ids
), true);
!($_G['group']['exempt'] & 2) && updatecreditbyaction('search');
}
dheader("location: search.php?mod=blog&searchid=$searchid&searchsubmit=yes&kw=".urlencode($keyword));
}
}
?>

View File

@@ -0,0 +1,146 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: search_collection.php 31371 2012-08-21 01:51:24Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
require_once libfile('function/home');
if(!$_G['setting']['search']['collection']['status']) {
showmessage('search_collection_closed');
}
if($_G['adminid'] != 1 && !($_G['group']['allowsearch'] & 64)) {
showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
}
$_G['setting']['search']['collection']['searchctrl'] = intval($_G['setting']['search']['collection']['searchctrl']);
$srchmod = 7;
$cachelife_time = 300; // Life span for cache of searching in specified range of time
$cachelife_text = 3600; // Life span for cache of text searching
$srchtype = empty($_GET['srchtype']) ? '' : trim($_GET['srchtype']);
$searchid = isset($_GET['searchid']) ? intval($_GET['searchid']) : 0;
$srchtxt = $_GET['srchtxt'];
$keyword = isset($srchtxt) ? dhtmlspecialchars(trim($srchtxt)) : '';
if(!submitcheck('searchsubmit', 1)) {
include template('search/collection');
} else {
$orderby = in_array($_GET['orderby'], array('follownum', 'threadnum', 'commentnum', 'dateline')) ? $_GET['orderby'] : 'dateline';
$ascdesc = isset($_GET['ascdesc']) && $_GET['ascdesc'] == 'asc' ? 'asc' : 'desc';
if(!empty($searchid)) {
$page = max(1, intval($_GET['page']));
$start_limit = ($page - 1) * $_G['tpp'];
$index = C::t('common_searchindex')->fetch_by_searchid_srchmod($searchid, $srchmod);
if(!$index) {
showmessage('search_id_invalid');
}
$keyword = dhtmlspecialchars($index['keywords']);
$keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : '';
$index['keywords'] = rawurlencode($index['keywords']);
require_once libfile('function/discuzcode');
$collectionlist = array();
$maxcollection = $nowcollection = 0;
$query = C::t('forum_collection')->fetch_all(explode(',', $index['ids']), $orderby, $ascdesc, $start_limit, $_G['tpp']);
foreach($query as $value) {
$value['lastupdate'] = dgmdate($value['lastupdate']);
$value['shortdesc'] = cutstr(strip_tags(discuzcode($value['desc'])), 50);
$value['name'] = bat_highlight($value['name'], $keyword);
$collectionlist[$value['ctid']] = $value;
}
$multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=collection&searchid=$searchid&orderby=$orderby&ascdesc=$ascdesc&searchsubmit=yes");
$url_forward = 'search.php?mod=collection&'.$_SERVER['QUERY_STRING'];
include template('search/collection');
} else {
$searchstring = 'collection|title|'.addslashes($srchtxt);
$searchindex = array('id' => 0, 'dateline' => '0');
foreach(C::t('common_searchindex')->fetch_all_search($_G['setting']['search']['collection']['searchctrl'], $_G['clientip'], $_G['uid'], $_G['timestamp'], $searchstring, $srchmod) as $index) {
if($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
$searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
break;
} elseif($_G['adminid'] != '1' && $index['flood']) {
showmessage('search_ctrl', 'search.php?mod=collection', array('searchctrl' => $_G['setting']['search']['collection']['searchctrl']));
}
}
if($searchindex['id']) {
$searchid = $searchindex['id'];
} else {
!($_G['group']['exempt'] & 2) && checklowerlimit('search');
if(!$srchtxt && !$srchuid && !$srchuname) {
dheader('Location: search.php?mod=collection');
}
if($_G['adminid'] != '1' && $_G['setting']['search']['collection']['maxspm']) {
if(C::t('common_searchindex')->count_by_dateline($_G['timestamp'], $srchmod) >= $_G['setting']['search']['collection']['maxspm']) {
showmessage('search_toomany', 'search.php?mod=collection', array('maxspm' => $_G['setting']['search']['collection']['maxspm']));
}
}
$num = $ids = 0;
$_G['setting']['search']['collection']['maxsearchresults'] = $_G['setting']['search']['collection']['maxsearchresults'] ? intval($_G['setting']['search']['collection']['maxsearchresults']) : 500;
list($srchtxt, $srchtxtsql) = searchkey($keyword, "name LIKE '%{text}%' OR keyword LIKE '%{text}%'", true);
$query = C::t('forum_collection')->fetch_ctid_by_searchkey($srchtxtsql, $_G['setting']['search']['collection']['maxsearchresults']);
foreach($query as $collection) {
$ids .= ','.$collection['ctid'];
$num++;
}
unset($query);
$keywords = str_replace('%', '+', $srchtxt);
$expiration = TIMESTAMP + $cachelife_text;
$searchid = C::t('common_searchindex')->insert(array(
'srchmod' => $srchmod,
'keywords' => $keywords,
'searchstring' => $searchstring,
'useip' => $_G['clientip'],
'uid' => $_G['uid'],
'dateline' => $_G['timestamp'],
'expiration' => $expiration,
'num' => $num,
'ids' => $ids
), true);
!($_G['group']['exempt'] & 2) && updatecreditbyaction('search');
}
dheader("location: search.php?mod=collection&searchid=$searchid&searchsubmit=yes&kw=".urlencode($keyword));
}
}
?>

View File

@@ -0,0 +1,417 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: search_forum.php 33198 2013-05-06 09:23:45Z jeffjzhang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
if(!$_G['setting']['search']['forum']['status']) {
showmessage('search_forum_closed');
}
if(in_array($_G['adminid'], array(0, -1)) && !($_G['group']['allowsearch'] & 2)) {
showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
}
$_G['setting']['search']['forum']['searchctrl'] = intval($_G['setting']['search']['forum']['searchctrl']);
require_once libfile('function/forumlist');
require_once libfile('function/forum');
require_once libfile('function/post');
loadcache(array('forums', 'posttable_info'));
$posttableselect = '';
if(!empty($_G['cache']['posttable_info']) && is_array($_G['cache']['posttable_info'])) {
$posttableselect = '<select name="seltableid" id="seltableid" class="ps" style="display:none">';
foreach($_G['cache']['posttable_info'] as $posttableid => $data) {
$posttableselect .= '<option value="'.$posttableid.'"'.($_GET['posttableid'] == $posttableid ? ' selected="selected"' : '').'>'.($data['memo'] ? $data['memo'] : 'post_'.$posttableid).'</option>';
}
$posttableselect .= '</select>';
}
$srchmod = 2;
$cachelife_time = 300; // Life span for cache of searching in specified range of time
$cachelife_text = 3600; // Life span for cache of text searching
$srchtype = empty($_GET['srchtype']) ? '' : trim($_GET['srchtype']);
$searchid = isset($_GET['searchid']) ? intval($_GET['searchid']) : 0;
$seltableid = intval(getgpc('seltableid'));
if($srchtype != 'title' && $srchtype != 'fulltext') {
$srchtype = '';
}
$srchtxt = trim(getgpc('srchtxt'));
$srchuid = intval(getgpc('srchuid'));
$srchuname = isset($_GET['srchuname']) ? trim(str_replace('|', '', $_GET['srchuname'])) : '';;
$srchfrom = intval(getgpc('srchfrom'));
$before = intval(getgpc('before'));
$srchfid = getgpc('srchfid');
$srhfid = intval($_GET['srhfid']);
$keyword = isset($srchtxt) ? dhtmlspecialchars(trim($srchtxt)) : '';
$forumselect = forumselect();
if(!empty($srchfid) && !is_numeric($srchfid)) {
$forumselect = str_replace('<option value="'.$srchfid.'">', '<option value="'.$srchfid.'" selected="selected">', $forumselect);
}
if(!submitcheck('searchsubmit', 1)) {
if(getgpc('adv')) {
include template('search/forum_adv');
} else {
include template('search/forum');
}
} else {
$orderby = in_array(getgpc('orderby'), array('dateline', 'replies', 'views')) ? $_GET['orderby'] : 'lastpost';
$ascdesc = isset($_GET['ascdesc']) && $_GET['ascdesc'] == 'asc' ? 'asc' : 'desc';
$orderbyselected = array($orderby => 'selected="selected"');
$ascchecked = array($ascdesc => 'checked="checked""');
if(!empty($searchid)) {
require_once libfile('function/misc');
$page = max(1, intval(getgpc('page')));
$start_limit = ($page - 1) * $_G['tpp'];
$index = C::t('common_searchindex')->fetch_by_searchid_srchmod($searchid, $srchmod);
if(!$index) {
showmessage('search_id_invalid');
}
$keyword = dhtmlspecialchars($index['keywords']);
$keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : '';
$index['keywords'] = rawurlencode($index['keywords']);
$searchstring = explode('|', $index['searchstring']);
$index['searchtype'] = $searchstring[0];//preg_replace("/^([a-z]+)\|.*/", "\\1", $index['searchstring']);
$searchstring[2] = base64_decode($searchstring[2]);
$srchuname = $searchstring[4];
$modfid = 0;
if($keyword) {
$modkeyword = str_replace(' ', ',', $keyword);
$fids = explode(',', str_replace('\\\'', '', $searchstring[5]));
foreach ($fids as $srchfid) {
if(!empty($srchfid) ) {
$forumselect = str_replace('<option value="'.$srchfid.'">', '<option value="'.$srchfid.'" selected="selected">', $forumselect);
}
}
if(count($fids) == 1 && in_array($_G['adminid'], array(1,2,3))) {
$modfid = $fids[0];
if($_G['adminid'] == 3 && !C::t('forum_moderator')->fetch_uid_by_fid_uid($modfid, $_G['uid'])) {
$modfid = 0;
}
}
}
$threadlist = $posttables = array();
foreach(C::t('forum_thread')->fetch_all_by_tid_fid_displayorder(explode(',',$index['ids']), null, 0, $orderby, $start_limit, $_G['tpp'], '>=', $ascdesc) as $thread) {
$thread['subject'] = bat_highlight($thread['subject'], $keyword);
$thread['realtid'] = $thread['isgroup'] == 1 ? $thread['closed'] : $thread['tid'];
$threadlist[$thread['tid']] = procthread($thread, 'dt');
$posttables[$thread['posttableid']][] = $thread['tid'];
}
if($threadlist) {
foreach($posttables as $tableid => $tids) {
foreach(C::t('forum_post')->fetch_all_by_tid($tableid, $tids, true, '', 0, 0, 1) as $post) {
if($post['status'] & 1) {
$threadlist[$post['tid']]['message'] = lang('forum/template', 'message_single_banned');
} else {
$threadlist[$post['tid']]['message'] = bat_highlight(threadmessagecutstr($threadlist[$post['tid']], $post['message'], 200), $keyword);
}
}
}
}
$multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=forum&searchid=$searchid&orderby=$orderby&ascdesc=$ascdesc&searchsubmit=yes");
$url_forward = 'search.php?mod=forum&'.$_SERVER['QUERY_STRING'];
$fulltextchecked = $searchstring[1] == 'fulltext' ? 'checked="checked"' : '';
$specials = explode(',', $searchstring[9]);
$srchfilter = $searchstring[8];
$before = $searchstring[7];
$srchfrom = $searchstring[6];
foreach($specials as $key) {
$specialchecked[$key] = 'checked="checked""';
}
$srchfilterchecked[$srchfilter] = 'checked="checked""';
$beforechecked = array($before => 'checked="checked""');
$srchfromselected = array($srchfrom => 'selected="selected"');
$advextra = '&orderby='.$orderby.'&ascdesc='.$ascdesc.'&searchid='.$searchid.'&searchsubmit=yes';
if($_GET['adv']) {
include template('search/forum_adv');
} else {
include template('search/forum');
}
} else {
if($_G['group']['allowsearch'] & 32 && $srchtype == 'fulltext') {
periodscheck('searchbanperiods');
} elseif($srchtype != 'title') {
$srchtype = 'title';
}
$forumsarray = array();
if(!empty($srchfid)) {
foreach((is_array($srchfid) ? $srchfid : explode('_', $srchfid)) as $forum) {
if($forum = intval(trim($forum))) {
$forumsarray[] = $forum;
}
}
}
$fids = $comma = '';
foreach($_G['cache']['forums'] as $fid => $forum) {
if($forum['type'] != 'group' && (!$forum['viewperm'] && $_G['group']['readaccess']) || ($forum['viewperm'] && forumperm($forum['viewperm']))) {
if(!$forumsarray || in_array($fid, $forumsarray)) {
$fids .= "$comma'$fid'";
$comma = ',';
}
}
}
if($_G['setting']['threadplugins'] && $specialplugin) {
$specialpluginstr = implode("','", $specialplugin);
$special[] = 127;
} else {
$specialpluginstr = '';
}
$special = getgpc('special');
$specials = $special ? implode(',', $special) : '';
$srchfilter = in_array(getgpc('srchfilter'), array('all', 'digest', 'top')) ? $_GET['srchfilter'] : 'all';
$searchstring = 'forum|'.$srchtype.'|'.base64_encode($srchtxt).'|'.intval($srchuid).'|'.$srchuname.'|'.addslashes($fids).'|'.intval($srchfrom).'|'.intval($before).'|'.$srchfilter.'|'.$specials.'|'.$specialpluginstr.'|'.$seltableid;
$searchindex = array('id' => 0, 'dateline' => '0');
foreach(C::t('common_searchindex')->fetch_all_search($_G['setting']['search']['forum']['searchctrl'], $_G['clientip'], $_G['uid'], $_G['timestamp'], $searchstring, $srchmod) as $index) {
if($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
$searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
break;
} elseif($_G['adminid'] != '1' && $index['flood']) {
showmessage('search_ctrl', 'search.php?mod=forum', array('searchctrl' => $_G['setting']['search']['forum']['searchctrl']));
}
}
if($searchindex['id']) {
$searchid = $searchindex['id'];
} else {
!($_G['group']['exempt'] & 2) && checklowerlimit('search');
if(!$srchtxt && !$srchuid && !$srchuname && !$srchfrom && !in_array($srchfilter, array('digest', 'top')) && !is_array($special)) {
dheader('Location: search.php?mod=forum');
} elseif(isset($srchfid) && !empty($srchfid) && $srchfid != 'all' && !(is_array($srchfid) && in_array('all', $srchfid)) && empty($forumsarray)) {
showmessage('search_forum_invalid', 'search.php?mod=forum');
} elseif(!$fids) {
showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
}
if($_G['adminid'] != '1' && $_G['setting']['search']['forum']['maxspm']) {
if(C::t('common_searchindex')->count_by_dateline($_G['timestamp'], $srchmod) >= $_G['setting']['search']['forum']['maxspm']) {
showmessage('search_toomany', 'search.php?mod=forum', array('maxspm' => $_G['setting']['search']['forum']['maxspm']));
}
}
if($srchtype == 'fulltext' && $_G['setting']['sphinxon']) {
require_once libfile('class/sphinx');
$s = new SphinxClient();
$s->setServer($_G['setting']['sphinxhost'], intval($_G['setting']['sphinxport']));
$s->setMaxQueryTime(intval($_G['setting']['sphinxmaxquerytime']));
$s->SetRankingMode($_G['setting']['sphinxrank']);
$s->setLimits(0, intval($_G['setting']['sphinxlimit']), intval($_G['setting']['sphinxlimit']));
$s->setGroupBy('tid', SPH_GROUPBY_ATTR);
if($srchfilter == 'digest') {
$s->setFilterRange('digest', 1, 3, false);
}
if($srchfilter == 'top') {
$s->setFilterRange('displayorder', 1, 2, false);
} else {
$s->setFilterRange('displayorder', 0, 2, false);
}
if(!empty($srchfrom) && empty($srchtxt) && empty($srchuid) && empty($srchuname)) {
$expiration = TIMESTAMP + $cachelife_time;
$keywords = '';
if($before) {
$spx_timemix = 0;
$spx_timemax = TIMESTAMP - $srchfrom;
} else {
$spx_timemix = TIMESTAMP - $srchfrom;
$spx_timemax = TIMESTAMP;
}
} else {
$uids = array();
if($srchuname) {
$uids = array_keys(C::t('common_member')->fetch_all_by_like_username($srchuname, 0, 50));
if(count($uids) == 0) {
$uids = array(0);
}
} elseif($srchuid) {
$uids = array($srchuid);
}
if(is_array($uids) && count($uids) > 0) {
$s->setFilter('authorid', $uids, false);
}
if($srchtxt) {
if(preg_match("/\".*\"/", $srchtxt)) {
$spx_matchmode = "PHRASE";
$s->setMatchMode(SPH_MATCH_PHRASE);
} elseif(preg_match("(AND|\+|&|\s)", $srchtxt) && !preg_match("(OR|\|)", $srchtxt)) {
$srchtxt = preg_replace("/( AND |&| )/is", "+", $srchtxt);
$spx_matchmode = "ALL";
$s->setMatchMode(SPH_MATCH_ALL);
} else {
$srchtxt = preg_replace("/( OR |\|)/is", "+", $srchtxt);
$spx_matchmode = 'ANY';
$s->setMatchMode(SPH_MATCH_ANY);
}
$srchtxt = str_replace('*', '%', addcslashes($srchtxt, '%_'));
foreach(explode('+', $srchtxt) as $text) {
$text = trim(daddslashes($text));
if($text) {
$sqltxtsrch .= $andor;
$sqltxtsrch .= $srchtype == 'fulltext' ? "(p.message LIKE '%".str_replace('_', '\_', $text)."%' OR p.subject LIKE '%$text%')" : "t.subject LIKE '%$text%'";
}
}
$sqlsrch .= " AND ($sqltxtsrch)";
}
if(!empty($srchfrom)) {
if($before) {
$spx_timemix = 0;
$spx_timemax = TIMESTAMP - $srchfrom;
} else {
$spx_timemix = TIMESTAMP - $srchfrom;
$spx_timemax = TIMESTAMP;
}
$s->setFilterRange('lastpost', $spx_timemix, $spx_timemax, false);
}
if(!empty($specials)) {
$s->setFilter('special', explode(",", $special), false);
}
$keywords = str_replace('%', '+', $srchtxt).(trim($srchuname) ? '+'.str_replace('%', '+', $srchuname) : '');
$expiration = TIMESTAMP + $cachelife_text;
}
if($srchtype == "fulltext") {
$result = $s->query("'".$srchtxt."'", $_G['setting']['sphinxmsgindex']);
} else {
$result = $s->query($srchtxt, $_G['setting']['sphinxsubindex']);
}
$tids = array();
if($result) {
if(is_array($result['matches'])) {
foreach($result['matches'] as $value) {
if($value['attrs']['tid']) {
$tids[$value['attrs']['tid']] = $value['attrs']['tid'];
}
}
}
}
if(count($tids) == 0) {
$ids = 0;
$num = 0;
} else {
$ids = implode(",", $tids);
$num = $result['total_found'];
}
} else {
$digestltd = $srchfilter == 'digest' ? "t.digest>'0' AND" : '';
$topltd = $srchfilter == 'top' ? "AND t.displayorder>'0'" : "AND t.displayorder>='0'";
if(!empty($srchfrom) && empty($srchtxt) && empty($srchuid) && empty($srchuname)) {
$searchfrom = $before ? '<=' : '>=';
$searchfrom .= TIMESTAMP - $srchfrom;
$sqlsrch = "FROM ".DB::table('forum_thread')." t WHERE $digestltd t.fid IN ($fids) $topltd AND t.lastpost$searchfrom";
$expiration = TIMESTAMP + $cachelife_time;
$keywords = '';
} else {
$sqlsrch = $srchtype == 'fulltext' ?
"FROM ".DB::table(getposttable($seltableid))." p, ".DB::table('forum_thread')." t WHERE $digestltd t.fid IN ($fids) $topltd AND p.tid=t.tid AND p.invisible='0'" :
"FROM ".DB::table('forum_thread')." t WHERE $digestltd t.fid IN ($fids) $topltd";
if($srchuname) {
$srchuid = array_keys(C::t('common_member')->fetch_all_by_like_username($srchuname, 0, 50));
if(!$srchuid) {
$sqlsrch .= ' AND 0';
}
}/* elseif($srchuid) {
$srchuid = "'$srchuid'";
}*/
if($srchtxt) {
$srcharr = $srchtype == 'fulltext' ? searchkey($keyword, "(p.message LIKE '%{text}%' OR p.subject LIKE '%{text}%')", true) : searchkey($keyword,"t.subject LIKE '%{text}%'", true);
$srchtxt = $srcharr[0];
$sqlsrch .= $srcharr[1];
}
if($srchuid) {
$sqlsrch .= ' AND '.($srchtype == 'fulltext' ? 'p' : 't').'.authorid IN ('.dimplode((array)$srchuid).')';
}
if(!empty($srchfrom)) {
$searchfrom = ($before ? '<=' : '>=').(TIMESTAMP - $srchfrom);
$sqlsrch .= " AND t.lastpost$searchfrom";
}
if(!empty($specials)) {
$sqlsrch .= " AND special IN (".dimplode($special).")";
}
$keywords = str_replace('%', '+', $srchtxt);
$expiration = TIMESTAMP + $cachelife_text;
}
$num = $ids = 0;
$_G['setting']['search']['forum']['maxsearchresults'] = $_G['setting']['search']['forum']['maxsearchresults'] ? intval($_G['setting']['search']['forum']['maxsearchresults']) : 500;
$query = DB::query("SELECT ".($srchtype == 'fulltext' ? 'DISTINCT' : '')." t.tid, t.closed, t.author, t.authorid $sqlsrch ORDER BY tid DESC LIMIT ".$_G['setting']['search']['forum']['maxsearchresults']);
while($thread = DB::fetch($query)) {
$ids .= ','.$thread['tid'];
$num++;
}
DB::free_result($query);
}
$searchid = C::t('common_searchindex')->insert(array(
'srchmod' => $srchmod,
'keywords' => $keywords,
'searchstring' => $searchstring,
'useip' => $_G['clientip'],
'uid' => $_G['uid'],
'dateline' => $_G['timestamp'],
'expiration' => $expiration,
'num' => $num,
'ids' => $ids
), true);
!($_G['group']['exempt'] & 2) && updatecreditbyaction('search');
}
dheader("location: search.php?mod=forum&searchid=$searchid&orderby=$orderby&ascdesc=$ascdesc&searchsubmit=yes&kw=".urlencode($keyword));
}
}
?>

View File

@@ -0,0 +1,204 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: search_group.php 30187 2012-05-16 03:24:35Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
require_once libfile('function/home');
require_once libfile('function/post');
if(!$_G['setting']['search']['group']['status']) {
showmessage('search_group_closed');
}
if($_G['adminid'] != 1 && !($_G['group']['allowsearch'] & 16)) {
showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
}
$_G['setting']['search']['group']['searchctrl'] = intval($_G['setting']['search']['group']['searchctrl']);
$srchmod = 5;
$cachelife_time = 300; // Life span for cache of searching in specified range of time
$cachelife_text = 3600; // Life span for cache of text searching
$srchtype = empty($_GET['srchtype']) ? '' : trim($_GET['srchtype']);
$searchid = isset($_GET['searchid']) ? intval($_GET['searchid']) : 0;
$srchtxt = $_GET['srchtxt'];
$srchfid = intval($_GET['srchfid']);
$viewgroup = intval($_GET['viewgroup']);
$keyword = isset($srchtxt) ? dhtmlspecialchars(trim($srchtxt)) : '';
if(!submitcheck('searchsubmit', 1)) {
include template('search/group');
} else {
$orderby = in_array($_GET['orderby'], array('dateline', 'replies', 'views')) ? $_GET['orderby'] : 'lastpost';
$ascdesc = isset($_GET['ascdesc']) && $_GET['ascdesc'] == 'asc' ? 'asc' : 'desc';
if(!empty($searchid)) {
require_once libfile('function/group');
$page = max(1, intval($_GET['page']));
$start_limit = ($page - 1) * $_G['tpp'];
$index = C::t('common_searchindex')->fetch_by_searchid_srchmod($searchid, $srchmod);
if(!$index) {
showmessage('search_id_invalid');
}
$keyword = dhtmlspecialchars($index['keywords']);
$keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : '';
$index['keywords'] = rawurlencode($index['keywords']);
$index['ids'] = dunserialize($index['ids']);
$searchstring = explode('|', $index['searchstring']);
$srchfid = $searchstring[2];
$threadlist = $grouplist = $posttables = array();
if($index['ids']['thread'] && ($searchstring[2] || empty($viewgroup))) {
require_once libfile('function/misc');
$threads = C::t('forum_thread')->fetch_all_by_tid_fid_displayorder(explode(',', $index['ids']['thread']), null, 0, $orderby, $start_limit, $_G['tpp'], '>=', $ascdesc);
foreach($threads as $value) {
$fids[$value['fid']] = $value['fid'];
}
$forums = C::t('forum_forum')->fetch_all_name_by_fid($fids);
foreach($threads as $thread) {
$thread['forumname'] = $forums[$thread['fid']]['name'];
$thread['subject'] = bat_highlight($thread['subject'], $keyword);
$thread['realtid'] = $thread['tid'];
$threadlist[$thread['tid']] = procthread($thread);
$posttables[$thread['posttableid']][] = $thread['tid'];
}
if($threadlist) {
foreach($posttables as $tableid => $tids) {
foreach(C::t('forum_post')->fetch_all_by_tid($tableid, $tids, true, '', 0, 0, 1) as $post) {
$threadlist[$post['tid']]['message'] = bat_highlight(threadmessagecutstr($threadlist[$post['tid']], $post['message'], 200), $keyword);
}
}
}
}
$groupnum = !empty($index['ids']['group']) ? count(explode(',', $index['ids']['group'])) - 1 : 0;
if($index['ids']['group'] && ($viewgroup || empty($searchstring[2]))) {
if(empty($viewgroup)) {
$index['ids']['group'] = implode(',', array_slice(explode(',', $index['ids']['group']), 0, 9));
}
if($viewgroup) {
$query = C::t('forum_forum')->fetch_all_info_by_fids(explode(',', $index['ids']['group']), 3, $_G['tpp'], 0, 0, 0, 0, 'sub', $start_limit);
} else {
$query = C::t('forum_forum')->fetch_all_info_by_fids(explode(',', $index['ids']['group']), 3, 0, 0, 0, 0, 0, 'sub');
}
foreach($query as $group) {
$group['icon'] = get_groupimg($group['icon'], 'icon');
$group['name'] = bat_highlight($group['name'], $keyword);
$group['description'] = bat_highlight($group['description'], $keyword);
$group['dateline'] = dgmdate($group['dateline'], 'u');
$grouplist[] = $group;
}
}
if(empty($viewgroup)) {
$multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=group&searchid=$searchid&orderby=$orderby&ascdesc=$ascdesc&searchsubmit=yes".($viewgroup ? '&viewgroup=1' : ''));
} else {
$multipage = multi($groupnum, $_G['tpp'], $page, "search.php?mod=group&searchid=$searchid&orderby=$orderby&ascdesc=$ascdesc&searchsubmit=yes".($viewgroup ? '&viewgroup=1' : ''));
}
$url_forward = 'search.php?mod=group&'.$_SERVER['QUERY_STRING'];
include template('search/group');
} else {
$srchuname = isset($_GET['srchuname']) ? trim($_GET['srchuname']) : '';
$searchstring = 'group|title|'.$srchfid.'|'.addslashes($srchtxt);
$searchindex = array('id' => 0, 'dateline' => '0');
foreach(C::t('common_searchindex')->fetch_all_search($_G['setting']['search']['group']['searchctrl'], $_G['clientip'], $_G['uid'], $_G['timestamp'], $searchstring, $srchmod) as $index) {
if($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
$searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
break;
} elseif($_G['adminid'] != '1' && $index['flood']) {
showmessage('search_ctrl', 'search.php?mod=group', array('searchctrl' => $_G['setting']['search']['group']['searchctrl']));
}
}
if($searchindex['id']) {
$searchid = $searchindex['id'];
} else {
!($_G['group']['exempt'] & 2) && checklowerlimit('search');
if(!$srchtxt && !$srchuid && !$srchuname) {
dheader('Location: search.php?mod=group');
}
if($_G['adminid'] != '1' && $_G['setting']['search']['group']['maxspm']) {
if(C::t('common_searchindex')->count_by_dateline($_G['timestamp'], $srchmod) >= $_G['setting']['search']['group']['maxspm']) {
showmessage('search_toomany', 'search.php?mod=group', array('maxspm' => $_G['setting']['search']['group']['maxspm']));
}
}
$num = $ids = $tnum = $tids = 0;
$_G['setting']['search']['group']['maxsearchresults'] = $_G['setting']['search']['group']['maxsearchresults'] ? intval($_G['setting']['search']['group']['maxsearchresults']) : 500;
list($srchtxt, $srchtxtsql) = searchkey($keyword, "subject LIKE '%{text}%'", true);
$threads = C::t('forum_thread')->fetch_all_by_tid_fid(0, $srchfid, 1, '', $keyword, $_G['setting']['search']['group']['maxsearchresults']);
foreach($threads as $value) {
$fids[$value['fid']] = $value['fid'];
}
$forums = C::t('forum_forum')->fetch_all_by_fid($fids);
foreach($threads as $thread) {
if($forums[$thread['fid']]['status'] == 3) {
$tids .= ','.$thread['tid'];
$tnum++;
}
}
if(!$srchfid) {
$srchtxtsql = str_replace('subject LIKE', 'name LIKE', $srchtxtsql);
$query = C::t('forum_forum')->fetch_all_fid_for_group(0, $_G['setting']['search']['group']['maxsearchresults'], 1, $srchtxtsql);
foreach($query as $group) {
$ids .= ','.$group['fid'];
$num++;
}
}
$allids = array('thread' => $tids, 'group' => $ids);
$keywords = str_replace('%', '+', $srchtxt);
$expiration = TIMESTAMP + $cachelife_text;
$searchid = C::t('common_searchindex')->insert(array(
'srchmod' => $srchmod,
'keywords' => $keywords,
'searchstring' => $searchstring,
'useip' => $_G['clientip'],
'uid' => $_G['uid'],
'dateline' => $_G['timestamp'],
'expiration' => $expiration,
'num' => $tnum,
'ids' => serialize($allids)
), true);
!($_G['group']['exempt'] & 2) && updatecreditbyaction('search');
}
dheader("location: search.php?mod=group&searchid=$searchid&searchsubmit=yes&kw=".urlencode($keyword));
}
}
?>

View File

@@ -0,0 +1,145 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: search_portal.php 33522 2013-06-28 02:58:15Z laoguozhang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
require_once libfile('function/home');
require_once libfile('function/portal');
if(!$_G['setting']['search']['portal']['status']) {
showmessage('search_portal_closed');
}
if($_G['adminid'] != 1 && !($_G['group']['allowsearch'] & 1)) {
showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
}
$_G['setting']['search']['portal']['searchctrl'] = intval($_G['setting']['search']['portal']['searchctrl']);
$srchmod = 1;
$cachelife_time = 300; // Life span for cache of searching in specified range of time
$cachelife_text = 3600; // Life span for cache of text searching
$srchtype = empty($_GET['srchtype']) ? '' : trim($_GET['srchtype']);
$searchid = isset($_GET['searchid']) ? intval($_GET['searchid']) : 0;
$srchtxt = $_GET['srchtxt'];
$keyword = isset($srchtxt) ? dhtmlspecialchars(trim($srchtxt)) : '';
if(!submitcheck('searchsubmit', 1)) {
include template('search/portal');
} else {
$orderby = in_array($_GET['orderby'], array('aid')) ? $_GET['orderby'] : 'aid';
$ascdesc = isset($_GET['ascdesc']) && $_GET['ascdesc'] == 'asc' ? 'asc' : 'desc';
if(!empty($searchid)) {
$page = max(1, intval($_GET['page']));
$start_limit = ($page - 1) * $_G['tpp'];
$index = C::t('common_searchindex')->fetch_by_searchid_srchmod($searchid, $srchmod);
if(!$index) {
showmessage('search_id_invalid');
}
$keyword = dhtmlspecialchars($index['keywords']);
$keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : '';
$index['keywords'] = rawurlencode($index['keywords']);
$articlelist = array();
$query = C::t('portal_article_title')->fetch_all_for_search(explode(',', $index['ids']), $orderby, $ascdesc, $start_limit, $_G['tpp']);
foreach($query as $article) {
$article['dateline'] = dgmdate($article['dateline']);
$article['pic'] = $article['pic'] ? pic_get($article['pic'], '', $article['thumb'], $article['remote'], 1, 1) : '';
$article['title'] = bat_highlight($article['title'], $keyword);
$article['summary'] = bat_highlight($article['summary'], $keyword);
$articlelist[] = $article;
}
$multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=portal&searchid=$searchid&orderby=$orderby&ascdesc=$ascdesc&searchsubmit=yes");
$url_forward = 'search.php?mod=portal&'.$_SERVER['QUERY_STRING'];
include template('search/portal');
} else {
!($_G['group']['exempt'] & 2) && checklowerlimit('search');
$searchstring = 'portal|title|'.addslashes($srchtxt);
$searchindex = array('id' => 0, 'dateline' => '0');
foreach(C::t('common_searchindex')->fetch_all_search($_G['setting']['search']['portal']['searchctrl'], $_G['clientip'], $_G['uid'], $_G['timestamp'], $searchstring, $srchmod) as $index) {
if($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
$searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
break;
} elseif($_G['adminid'] != '1' && $index['flood']) {
showmessage('search_ctrl', 'search.php?mod=portal', array('searchctrl' => $_G['setting']['search']['portal']['searchctrl']));
}
}
if($searchindex['id']) {
$searchid = $searchindex['id'];
} else {
if(!$srchtxt) {
dheader('Location: search.php?mod=portal');
}
if($_G['adminid'] != '1' && $_G['setting']['search']['portal']['maxspm']) {
if(C::t('common_searchindex')->count_by_dateline($_G['timestamp'], $srchmod) >= $_G['setting']['search']['portal']['maxspm']) {
showmessage('search_toomany', 'search.php?mod=portal', array('maxspm' => $_G['setting']['search']['portal']['maxspm']));
}
}
$num = $ids = 0;
$_G['setting']['search']['portal']['maxsearchresults'] = $_G['setting']['search']['portal']['maxsearchresults'] ? intval($_G['setting']['search']['portal']['maxsearchresults']) : 500;
list($srchtxt, $srchtxtsql) = searchkey($keyword, "title LIKE '%{text}%'", true);
$query = C::t('portal_article_title')->fetch_all_by_sql(' 1 '.$srchtxtsql, 'ORDER BY aid DESC ', 0, $_G['setting']['search']['portal']['maxsearchresults']);
foreach($query as $article) {
$ids .= ','.$article['aid'];
$num++;
}
$keywords = str_replace('%', '+', $srchtxt);
$expiration = TIMESTAMP + $cachelife_text;
$searchid = C::t('common_searchindex')->insert(array(
'srchmod' => $srchmod,
'keywords' => $keywords,
'searchstring' => $searchstring,
'useip' => $_G['clientip'],
'uid' => $_G['uid'],
'dateline' => $_G['timestamp'],
'expiration' => $expiration,
'num' => $num,
'ids' => $ids
), true);
!($_G['portal']['exempt'] & 2) && updatecreditbyaction('search');
}
dheader("location: search.php?mod=portal&searchid=$searchid&searchsubmit=yes&kw=".urlencode($keyword));
}
}
?>

View File

@@ -0,0 +1,33 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: search_user.php 36349 2017-01-16 03:05:23Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('NOROBOT', TRUE);
$url = '';
if($_G['setting']['domain']['app']['home'] || $_G['setting']['domain']['app']['default']) {
$domain = '';
if($_G['setting']['domain']['app']['home']) {
$domain = $_G['setting']['domain']['app']['home'];
} else {
$domain = $_G['setting']['domain']['app']['default'];
}
$url = $_G['scheme'].'://'.$domain.$_G['siteport'].'/';
}
$url .= 'home.php?mod=spacecp&ac=search';
if($_GET['srchtxt']) {
$url .= '&username='.$_GET['srchtxt'].'&searchsubmit=yes';
}
dheader('Location: '.$url);
?>