function forumselect($groupselectable = FALSE, $tableformat = 0)
{
    global $_DCACHE, $discuz_uid, $groupid, $fid, $gid, $indexname;
    if (!isset($_DCACHE['forums'])) {
        require_once DISCUZ_ROOT . './forumdata/cache/cache_forums.php';
    }
    $forumlist = $tableformat ? '<dl><dd><ul>' : '<optgroup label="&nbsp;">';
    foreach ($_DCACHE['forums'] as $forum) {
        if ($forum['type'] == 'group') {
            if ($tableformat) {
                $forumlist .= '</ul></dd></dl><dl><dt><a href="' . $indexname . '?gid=' . $forum['fid'] . '">' . $forum['name'] . '</a></dt><dd><ul>';
            } else {
                $forumlist .= $groupselectable ? '<option value="' . $forum['fid'] . '">' . $forum['name'] . '</option>' : '</optgroup><optgroup label="' . $forum['name'] . '">';
            }
            $visible[$forum['fid']] = true;
        } elseif ($forum['type'] == 'forum' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm']) || strstr($forum['users'], "\t{$discuz_uid}\t"))) {
            if ($tableformat) {
                $forumlist .= '<li' . ($fid == $forum['fid'] ? ' class="current"' : '') . '><a href="forumdisplay.php?fid=' . $forum['fid'] . '">' . $forum['name'] . '</a></li>';
            } else {
                $forumlist .= '<option value="' . $forum['fid'] . '">&nbsp; &gt; ' . $forum['name'] . '</option>';
            }
            $visible[$forum['fid']] = true;
        } elseif ($forum['type'] == 'sub' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm']) || strstr($forum['users'], "\t{$discuz_uid}\t"))) {
            if ($tableformat) {
                $forumlist .= '<li class="sub' . ($fid == $forum['fid'] ? ' current"' : '') . '"><a href="forumdisplay.php?fid=' . $forum['fid'] . '">' . $forum['name'] . '</a></li>';
            } else {
                $forumlist .= '<option value="' . $forum['fid'] . '">&nbsp; &nbsp; &nbsp; &gt; ' . $forum['name'] . '</option>';
            }
        }
    }
    $forumlist .= $tableformat ? '</ul></dd></dl>' : '</optgroup>';
    $forumlist = str_replace($tableformat ? '<dl><dd><ul></ul></dd></dl>' : '<optgroup label="&nbsp;"></optgroup>', '', $forumlist);
    return $forumlist;
}
Beispiel #2
0
 function common()
 {
     global $_G;
     $forums = array();
     $sql = !empty($_G['member']['accessmasks']) ? "SELECT f.fid, f.type, f.name, f.fup, f.status, ff.password, ff.redirect, ff.viewperm, ff.postperm, ff.threadtypes, ff.threadsorts\r\n\t\t\t\tFROM " . DB::table('forum_forum') . " f\r\n\t\t\t\tLEFT JOIN " . DB::table('forum_forumfield') . " ff ON ff.fid=f.fid\r\n\t\t\t\tLEFT JOIN " . DB::table('forum_access') . " a ON a.uid='{$_G['uid']}' AND a.allowview>'0' AND a.fid=f.fid\r\n\t\t\t\tWHERE f.status='1' ORDER BY f.type, f.displayorder" : "SELECT f.fid, f.type, f.name, f.fup, f.status, ff.password, ff.redirect, ff.viewperm, ff.postperm, ff.threadtypes, ff.threadsorts\r\n\t\t\t\tFROM " . DB::table('forum_forum') . " f\r\n\t\t\t\tLEFT JOIN " . DB::table('forum_forumfield') . " ff USING(fid)\r\n\t\t\t\tWHERE f.status='1' ORDER BY f.type, f.displayorder";
     $query = DB::query($sql);
     //$query = DB::query("SELECT f.fid, f.type, f.name, f.fup, f.status, ff.password, ff.redirect, ff.viewperm, ff.postperm, ff.threadtypes, ff.threadsorts FROM ".DB::table('forum_forum')." f LEFT JOIN ".DB::table('forum_forumfield')." ff ON ff.fid=f.fid LEFT JOIN ".DB::table('forum_access')." a ON a.fid=f.fid AND a.allowview>'0' WHERE f.status='1' ORDER BY f.type, f.displayorder");
     while ($forum = DB::fetch($query)) {
         if ($forum['redirect'] || $forum['password']) {
             continue;
         }
         if (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm'])) {
             $forum['name'] = strip_tags($forum['name']);
             if ($forum['threadsorts']) {
                 $forum['threadsorts'] = unserialize($forum['threadsorts']);
                 foreach ($forum['threadsorts']['types'] as $k => $v) {
                     $forum['threadsorts']['types'][$k] = strip_tags($v);
                 }
                 $forum['threadsorts'] = mobile_core::getvalues($forum['threadsorts'], array('required', 'types'));
             }
             if ($forum['threadtypes']) {
                 $forum['threadtypes'] = unserialize($forum['threadtypes']);
                 $unsetthreadtype = false;
                 if ($_G['adminid'] == 3 && strpos($forum['moderators'], $_G['username']) === false) {
                     $unsetthreadtype = true;
                 }
                 if ($_G['adminid'] == 0) {
                     $unsetthreadtype = true;
                 }
                 if ($unsetthreadtype) {
                     foreach ($forum['threadtypes']['moderators'] as $k => $v) {
                         if (!empty($v)) {
                             unset($forum['threadtypes']['types'][$k]);
                         }
                     }
                 }
                 $flag = 0;
                 foreach ($forum['threadtypes']['types'] as $k => $v) {
                     $forum['threadtypes']['types'][$k] = strip_tags($v);
                     if ($k == 0) {
                         $flag = 1;
                     }
                 }
                 if ($flag == 1) {
                     krsort($forum['threadtypes']['types']);
                 }
                 $forum['threadtypes'] = mobile_core::getvalues($forum['threadtypes'], array('required', 'types'));
             }
             $forums[] = mobile_core::getvalues($forum, array('fid', 'type', 'name', 'fup', 'viewperm', 'postperm', 'status', 'threadsorts', 'threadtypes'));
         }
     }
     $variable['forums'] = $forums;
     mobile_core::result(mobile_core::variable($variable));
 }
Beispiel #3
0
function getGroupFroumInfo($gid = null)
{
    global $_G, $expireTime;
    $oldGid = $_G['groupid'];
    if (!is_null($gid) && is_numeric($gid) && $gid >= 0) {
        $cacheKey = 'bigapp_group_fids_' . $gid;
        $_G['groupid'] = $gid;
    } else {
        $cacheKey = 'bigapp_group_fids_' . $_G['groupid'];
    }
    true === BIGAPP_DEV && runlog('bigapp', 'group key: ' . $cacheKey);
    loadcache($cacheKey);
    $forums = array();
    if (!isset($_G['cache'][$cacheKey]) || empty($_G['cache'][$cacheKey]) || TIMESTAMP - $_G['cache'][$cacheKey]['expiration'] > $expireTime) {
        $sql = "SELECT f.fid, f.type, f.name, f.fup, f.status, f.threads, f.posts, f.todayposts, " . "ff.password, ff.redirect, ff.viewperm, ff.postperm, ff.threadtypes, ff.threadsorts, ff.icon, ff.description, ff.moderators FROM " . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff USING(fid) WHERE f.status='1' ORDER BY f.type, f.displayorder";
        $query = DB::query($sql);
        while ($forum = DB::fetch($query)) {
            //过滤掉会跳转或需要密码的板块
            if ($forum['redirect'] || $forum['password']) {
                true === BIGAPP_DEV && runlog('bigapp', 'such forum will redirect or need password, ignore [ fid: ' . $forum['fid'] . ' ]');
                continue;
            }
            //板块存在用户组的权限设定,那么判定该用户组是否允许访问该板块
            if (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm'])) {
                $forums[$forum['fid']] = array('fid' => $forum['fid'], 'threadtypes' => unserialize($forum['threadtypes']));
                continue;
            }
            true === BIGAPP_DEV && runlog('bigapp', 'viewperm has been set [ perm: ' . $forum['viewperm'] . ', group id: ' . $_G['groupid'] . ', ignore fid: ' . $forum['fid'] . ' ]');
        }
        savecache($cacheKey, array('variable' => $forums, 'expiration' => TIMESTAMP));
        true === BIGAPP_DEV && runlog('bigapp', 'save forum ids to cache for group id [ group id: ' . $_G['groupid'] . ' ]');
    } else {
        true === BIGAPP_DEV && runlog('bigapp', 'get forum ids from cache data [ group id: ' . $_G['groupid'] . '  ]');
        $forums = $_G['cache'][$cacheKey]['variable'];
    }
    true === BIGAPP_DEV && runlog('bigapp', 'get group forum info finished [ fids: ' . json_encode(array_keys($forums)) . ' ]');
    $_G['groupid'] = $oldGid;
    return $forums;
}
 function common()
 {
     global $_G;
     $forums = array();
     $query = DB::query("SELECT f.fid, f.type, f.name, f.fup, f.status, ff.password, ff.redirect, ff.viewperm, ff.postperm, ff.threadtypes, ff.threadsorts FROM " . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff ON ff.fid=f.fid LEFT JOIN " . DB::table('forum_access') . " a ON a.fid=f.fid AND a.allowview>'0' WHERE f.status='1' ORDER BY f.type, f.displayorder");
     while ($forum = DB::fetch($query)) {
         if ($forum['redirect'] || $forum['password']) {
             continue;
         }
         if (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm'])) {
             if ($forum['threadsorts']) {
                 $forum['threadsorts'] = mobile_core::getvalues(unserialize($forum['threadsorts']), array('required', 'types'));
             }
             if ($forum['threadtypes']) {
                 $forum['threadtypes'] = mobile_core::getvalues(unserialize($forum['threadtypes']), array('required', 'types'));
             }
             $forums[] = mobile_core::getvalues($forum, array('fid', 'type', 'name', 'fup', 'viewperm', 'postperm', 'status', 'threadsorts', 'threadtypes'));
         }
     }
     $variable['forums'] = $forums;
     mobile_core::result(mobile_core::variable($variable));
 }
function forumselect($groupselectable = FALSE, $tableformat = 0, $selectedfid = 0, $showhide = FALSE, $evalue = FALSE, $special = 0)
{
    global $_G;
    if (!isset($_G['cache']['forums'])) {
        loadcache('forums');
    }
    $forumcache =& $_G['cache']['forums'];
    $forumlist = $tableformat ? '<dl><dd><ul>' : '<optgroup label="&nbsp;">';
    foreach ($forumcache as $forum) {
        if ((!$forum['status'] || $forum['status'] == 2) && !$showhide) {
            continue;
        }
        if ($forum['type'] == 'group') {
            if ($tableformat) {
                $forumlist .= '</ul></dd></dl><dl><dt><a href="forum.php?gid=' . $forum['fid'] . '">' . $forum['name'] . '</a></dt><dd><ul>';
            } else {
                $forumlist .= $groupselectable ? '<option value="' . ($evalue ? 'gid_' : '') . $forum['fid'] . '" class="bold">--' . $forum['name'] . '</option>' : '</optgroup><optgroup label="--' . $forum['name'] . '">';
            }
            $visible[$forum['fid']] = true;
        } elseif ($forum['type'] == 'forum' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm']) || strstr($forum['users'], "\t{$_G['uid']}\t")) && (!$special || substr($forum['allowpostspecial'], -$special, 1))) {
            if ($tableformat) {
                $forumlist .= '<li' . ($_G['fid'] == $forum['fid'] ? ' class="current"' : '') . '><a href="forum.php?mod=forumdisplay&fid=' . $forum['fid'] . '">' . $forum['name'] . '</a></li>';
            } else {
                $forumlist .= '<option value="' . ($evalue ? 'fid_' : '') . $forum['fid'] . '"' . ($selectedfid && $selectedfid == $forum['fid'] ? ' selected' : '') . '>' . $forum['name'] . '</option>';
            }
            $visible[$forum['fid']] = true;
        } elseif ($forum['type'] == 'sub' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm']) || strstr($forum['users'], "\t{$_G['uid']}\t")) && (!$special || substr($forum['allowpostspecial'], -$special, 1))) {
            if ($tableformat) {
                $forumlist .= '<li class="sub' . ($_G['fid'] == $forum['fid'] ? ' current' : '') . '"><a href="forum.php?mod=forumdisplay&fid=' . $forum['fid'] . '">' . $forum['name'] . '</a></li>';
            } else {
                $forumlist .= '<option value="' . ($evalue ? 'fid_' : '') . $forum['fid'] . '"' . ($selectedfid && $selectedfid == $forum['fid'] ? ' selected' : '') . '>&nbsp; &nbsp; &nbsp; ' . $forum['name'] . '</option>';
            }
        }
    }
    $forumlist .= $tableformat ? '</ul></dd></dl>' : '</optgroup>';
    $forumlist = str_replace($tableformat ? '<dl><dd><ul></ul></dd></dl>' : '<optgroup label="&nbsp;"></optgroup>', '', $forumlist);
    return $forumlist;
}
Beispiel #6
0
$showthreadsorts = 0;
$quotemessage = '';
if ($special == 5) {
    $debate = array_merge($thread, daddslashes(C::t('forum_debate')->fetch($_G['tid'])));
    $firststand = C::t('forum_debatepost')->get_firststand($_G['tid'], $_G['uid']);
    $stand = $firststand ? $firststand : intval($_GET['stand']);
    if ($debate['endtime'] && $debate['endtime'] < TIMESTAMP) {
        showmessage('debate_end');
    }
}
if (!$_G['uid'] && !(!$_G['forum']['replyperm'] && $_G['group']['allowreply'] || $_G['forum']['replyperm'] && forumperm($_G['forum']['replyperm']))) {
    showmessage('replyperm_login_nopermission', NULL, array(), array('login' => 1));
} elseif (empty($_G['forum']['allowreply'])) {
    if (!$_G['forum']['replyperm'] && !$_G['group']['allowreply']) {
        showmessage('replyperm_none_nopermission', NULL, array(), array('login' => 1));
    } elseif ($_G['forum']['replyperm'] && !forumperm($_G['forum']['replyperm'])) {
        showmessagenoperm('replyperm', $_G['forum']['fid']);
    }
} elseif ($_G['forum']['allowreply'] == -1) {
    showmessage('post_forum_newreply_nopermission', NULL);
}
if (!$_G['uid'] && ($_G['setting']['need_avatar'] || $_G['setting']['need_email'] || $_G['setting']['need_friendnum'])) {
    showmessage('replyperm_login_nopermission', NULL, array(), array('login' => 1));
}
if (empty($thread)) {
    showmessage('thread_nonexistence');
} elseif ($thread['price'] > 0 && $thread['special'] == 0 && !$_G['uid']) {
    showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
}
checklowerlimit('reply', 0, 1, $_G['forum']['fid']);
if ($_G['setting']['commentnumber'] && !empty($_GET['comment'])) {
function rssforumperm($forum)
{
    $is_allowed = $forum['type'] != 'group' && (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm'], 7));
    return $is_allowed;
}
Beispiel #8
0
 function tasklist($item)
 {
     global $_G;
     $multipage = '';
     $page = max(1, intval($_GET['page']));
     $start_limit = ($page - 1) * $_G['tpp'];
     $tasklist = $endtaskids = $magicids = $medalids = $groupids = array();
     $updated = FALSE;
     $num = 0;
     foreach (C::t('common_task')->fetch_all_by_status($_G['uid'], $item) as $task) {
         if ($item == 'new' || $item == 'canapply') {
             list($task['allowapply'], $task['t']) = $this->checknextperiod($task);
             if ($task['allowapply'] < 0) {
                 continue;
             }
             $task['noperm'] = $task['applyperm'] && $task['applyperm'] != 'all' && !($task['applyperm'] == 'member' && $_G['adminid'] == '0' || $task['applyperm'] == 'admin' && $_G['adminid'] > '0' || forumperm($task['applyperm']));
             $task['appliesfull'] = $task['tasklimits'] && $task['achievers'] >= $task['tasklimits'];
             if ($item == 'canapply' && ($task['noperm'] || $task['appliesfull'])) {
                 continue;
             }
         }
         $num++;
         if ($task['reward'] == 'magic') {
             $magicids[] = $task['prize'];
         } elseif ($task['reward'] == 'medal') {
             $medalids[] = $task['prize'];
         } elseif ($task['reward'] == 'invite') {
             $invitenum = $task['prize'];
         } elseif ($task['reward'] == 'group') {
             $groupids[] = $task['prize'];
         }
         if ($task['available'] == '2' && ($task['starttime'] > TIMESTAMP || $task['endtime'] && $task['endtime'] <= TIMESTAMP)) {
             $endtaskids[] = $task['taskid'];
         }
         $csc = explode("\t", $task['csc']);
         $task['csc'] = floatval($csc[0]);
         $task['lastupdate'] = intval($csc[1]);
         if (!$updated && $item == 'doing' && $task['csc'] < 100) {
             $updated = TRUE;
             $escript = explode(':', $task['scriptname']);
             if (count($escript) > 1) {
                 include_once DISCUZ_ROOT . './source/plugin/' . $escript[0] . '/task/task_' . $escript[1] . '.php';
                 $taskclassname = 'task_' . $escript[1];
             } else {
                 require_once libfile('task/' . $task['scriptname'], 'class');
                 $taskclassname = 'task_' . $task['scriptname'];
             }
             $taskclass = new $taskclassname();
             $task['applytime'] = $task['dateline'];
             if (method_exists($taskclass, 'csc')) {
                 $result = $taskclass->csc($task);
             } else {
                 showmessage('task_not_found', '', array('taskclassname' => $taskclassname));
             }
             if ($result === TRUE) {
                 $task['csc'] = '100';
                 C::t('common_mytask')->update($_G['uid'], $task['taskid'], array('csc' => $task['csc']));
             } elseif ($result === FALSE) {
                 C::t('common_mytask')->update($_G['uid'], $task['taskid'], array('status' => -1));
             } else {
                 $task['csc'] = floatval($result['csc']);
                 C::t('common_mytask')->update($_G['uid'], $task['taskid'], array('csc' => $task['csc'] . "\t" . $_G['timestamp']));
             }
         }
         if (in_array($item, array('done', 'failed')) && $task['period']) {
             list($task['allowapply'], $task['t']) = $this->checknextperiod($task);
             $task['allowapply'] = $task['allowapply'] > 0 ? 1 : 0;
         }
         $task['icon'] = $task['icon'] ? $task['icon'] : 'task.gif';
         if (strtolower(substr($task['icon'], 0, 7)) != 'http://') {
             $escript = explode(':', $task['scriptname']);
             if (count($escript) > 1 && file_exists(DISCUZ_ROOT . './source/plugin/' . $escript[0] . '/task/task_' . $escript[1] . '.gif')) {
                 $task['icon'] = 'source/plugin/' . $escript[0] . '/task/task_' . $escript[1] . '.gif';
             } else {
                 $task['icon'] = 'static/image/task/' . $task['icon'];
             }
         }
         $task['dateline'] = $task['dateline'] ? dgmdate($task['dateline'], 'u') : '';
         $tasklist[] = $task;
     }
     if ($magicids) {
         foreach (C::t('common_magic')->fetch_all($magicids) as $magic) {
             $this->listdata[$magic['magicid']] = $magic['name'];
         }
     }
     if ($medalids) {
         foreach (C::t('forum_medal')->fetch_all($medalids) as $medal) {
             $this->listdata[$medal['medalid']] = $medal['name'];
         }
     }
     if ($groupids) {
         foreach (C::t('common_usergroup')->fetch_all($groupids) as $group) {
             $this->listdata[$group['groupid']] = $group['grouptitle'];
         }
     }
     if ($invitenum) {
         $this->listdata[$invitenum] = $_G['lang']['invite_code'];
     }
     if ($endtaskids) {
     }
     return $tasklist;
 }
Beispiel #9
0
    $bi = 1;
    foreach ($feeds['data'] as $k => $feed) {
        $trans['{addbuddy}'] = $feed['uid'] != $discuz_uid ? '<a href="my.php?item=buddylist&newbuddyid=' . $feed['uid'] . '&buddysubmit=yes" id="ajax_buddy_' . $bi++ . '" onclick="ajaxmenu(this, 3000);doane(event);"><img style="vertical-align:middle" src="manyou/images/myadd.gif" /></a>' : '';
        $feeds['data'][$k]['title'] = strtr($feed['title'], $trans);
        $feeds['data'][$k]['body'] = strtr($feed['body'], $trans);
        $feeds['data'][$k]['title'] = preg_replace("/<a(.+?)href=([\\'\"]?)([^>\\s]+)\\2([^>]*)>/i", '<a target="_blank" \\1 href="\\3&from=indexfeeds" \\4>', $feeds['data'][$k]['title']);
        $feeds['data'][$k]['body'] = preg_replace("/<a(.+?)href=([\\'\"]?)([^>\\s]+)\\2([^>]*)>/i", '<a target="_blank" \\1 href="\\3&from=indexfeeds" \\4>', $feeds['data'][$k]['body']);
        list($feeds['data'][$k]['body'], $feeds['data'][$k]['general']) = explode(chr(0) . chr(0) . chr(0), $feeds['data'][$k]['body']);
        $feeds['data'][$k]['icon_image'] = 'http://appicon.manyou.com/icons/' . $feed['appid'];
        $dateline = $feed['dbdateline'] + $timeoffset * 3600;
        $feeds['data'][$k]['date'] = gmdate($dateformat, $dateline);
        if ($feeddate != $feeds['data'][$k]['date']) {
            $feeds['data'][$k]['daterange'] = $feeds['data'][$k]['date'];
        } else {
            $feeds['data'][$k]['daterange'] = '';
        }
        $feeddate = $feeds['data'][$k]['date'];
    }
}
$multi = $feeds['multipage'];
$feeds = $feeds['data'];
$sql = !empty($accessmasks) ? "SELECT f.threads, f.posts, f.todayposts, ff.viewperm, a.allowview FROM {$tablepre}forums f\r\n\t\tLEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid\r\n\t\tLEFT JOIN {$tablepre}access a ON a.uid='{$discuz_uid}' AND a.fid=f.fid\r\n\t\tWHERE f.status='1' ORDER BY f.type, f.displayorder" : "SELECT f.threads, f.posts, f.todayposts, ff.viewperm FROM {$tablepre}forums f\r\n\t\tLEFT JOIN {$tablepre}forumfields ff USING(fid)\r\n\t\tWHERE f.status='1' ORDER BY f.type, f.displayorder";
$query = $db->query($sql);
while ($forumdata = $db->fetch_array($query)) {
    if (!$forumdata['viewperm'] || $forumdata['viewperm'] && forumperm($forumdata['viewperm']) || !empty($forumdata['allowview'])) {
        $threads += $forumdata['threads'];
        $posts += $forumdata['posts'];
        $todayposts += $forumdata['todayposts'];
    }
}
include template('discuz_feeds');
Beispiel #10
0
}
$discuz_action = 12;
if ($special == 5) {
    $debate = array_merge($thread, $db->fetch_first("SELECT * FROM {$tablepre}debates WHERE tid='{$tid}'"));
    $standquery = $db->query("SELECT stand FROM {$tablepre}debateposts WHERE tid='{$tid}' AND uid='{$discuz_uid}' AND stand<>'0' ORDER BY dateline LIMIT 1");
    $firststand = $db->result_first("SELECT stand FROM {$tablepre}debateposts WHERE tid='{$tid}' AND uid='{$discuz_uid}' AND stand<>'0' ORDER BY dateline LIMIT 1");
    if ($debate['endtime'] && $debate['endtime'] < $timestamp) {
        showmessage('debate_end');
    }
}
if (!$discuz_uid && !(!$forum['replyperm'] && $allowreply || $forum['replyperm'] && forumperm($forum['replyperm']))) {
    showmessage('replyperm_login_nopermission', NULL, 'NOPERM');
} elseif (empty($forum['allowreply'])) {
    if (!$forum['replyperm'] && !$allowreply) {
        showmessage('replyperm_none_nopermission', NULL, 'NOPERM');
    } elseif ($forum['replyperm'] && !forumperm($forum['replyperm'])) {
        showmessagenoperm('replyperm', $forum['fid']);
    }
} elseif ($forum['allowreply'] == -1) {
    showmessage('post_forum_newreply_nopermission', NULL, 'HALTED');
}
if (empty($thread)) {
    showmessage('thread_nonexistence');
} elseif ($thread['price'] > 0 && $thread['special'] == 0 && !$discuz_uid) {
    showmessage('group_nopermission', NULL, 'NOPERM');
}
checklowerlimit($replycredits);
if ($special == 127) {
    $postinfo = $db->fetch_first("SELECT message FROM {$tablepre}posts WHERE tid='{$tid}' AND first='1'");
    $sppos = strrpos($postinfo['message'], chr(0) . chr(0) . chr(0));
    $specialextra = substr($postinfo['message'], $sppos + 3);
Beispiel #11
0
 function common()
 {
     global $_G;
     loadcache('mobile_pnewpic');
     loadcache('forums');
     $maxnum = 50000;
     $maxtid = C::t('forum_thread')->fetch_max_tid();
     $limittid = max(0, $maxtid - $maxnum);
     $this->page = intval($_GET['page']) ? intval($_GET['page']) : 1;
     $start = ($this->page - 1) * $this->perpage;
     $num = $this->perpage;
     if ($_G['cache']['mobile_pnewpic'] && TIMESTAMP - $_G['cache']['mobile_pnewpic']['cachetime'] < 900) {
         $tids = array_slice($_G['cache']['mobile_pnewpic']['data'], $start, $num);
         if (empty($tids)) {
             return;
         }
     } else {
         $tids = array();
     }
     $tsql = $addsql = '';
     $updatecache = false;
     $fids = array();
     if ($_G['setting']['followforumid']) {
         $addsql .= ' AND ' . DB::field('fid', $_G['setting']['followforumid'], '<>');
     }
     if ($tids) {
         $tids = dintval($tids, true);
         $tidsql = DB::field('tid', $tids);
     } else {
         $tidsql = 'tid>' . intval($limittid);
         $addsql .= ' AND attachment=2 AND displayorder>=0 ORDER BY tid DESC LIMIT 600';
         $tids = array();
         foreach ($_G['cache']['forums'] as $fid => $forum) {
             if ($forum['type'] != 'group' && $forum['status'] > 0 && (!$forum['viewperm'] && $_G['group']['readaccess']) || $forum['viewperm'] && forumperm($forum['viewperm'])) {
                 $fids[] = $fid;
             }
         }
         if (empty($fids)) {
             return;
         }
         $updatecache = true;
     }
     $list = $threadids = array();
     $n = 0;
     $query = DB::query("SELECT * FROM " . DB::table('forum_thread') . " WHERE " . $tidsql . $addsql);
     while ($thread = DB::fetch($query)) {
         if (empty($tids) && ($thread['isgroup'] || !in_array($thread['fid'], $fids))) {
             continue;
         }
         if ($thread['displayorder'] < 0) {
             continue;
         }
         $threadids[] = $thread['tid'];
         if ($tids || $n >= $start && $n < $start + $num) {
             $list[$thread['tid']] = $thread;
         }
         $n++;
     }
     $threadlist = array();
     if ($tids) {
         foreach ($tids as $key => $tid) {
             if ($list[$tid]) {
                 $threadlist[$tid] = $list[$tid];
             }
         }
     } else {
         $threadlist = $list;
     }
     unset($list);
     $images = array();
     if ($threadlist) {
         $query = DB::query("SELECT * FROM " . DB::table('forum_threadimage') . " WHERE " . DB::field('tid', array_keys($threadlist)));
         while ($image = DB::fetch($query)) {
             if ($image['remote']) {
                 $img = $_G['setting']['ftp']['attachurl'] . 'forum/' . $image['attachment'];
             } else {
                 $img = $_G['setting']['attachurl'] . 'forum/' . $image['attachment'];
             }
             $images[$image['tid']] = $img;
         }
     }
     if ($updatecache) {
         $data = array('cachetime' => TIMESTAMP, 'data' => $threadids);
         $_G['cache']['mobile_pnewpic'] = $data;
         savecache('mobile_pnewpic', $_G['cache']['mobile_pnewpic']);
     }
     foreach ($threadlist as $thread) {
         $this->field('author', '0', $thread['author']);
         $this->field('dateline', '0', $thread['dateline']);
         $this->field('replies', '1', $thread['replies']);
         $this->field('views', '2', $thread['views']);
         $this->id = $thread['tid'];
         $this->title = $thread['subject'];
         $this->image = $images[$thread['tid']] ? $images[$thread['tid']] : STATICURL . 'image/common/nophoto.gif';
         $this->icon = '1';
         $this->poptype = '0';
         $this->popvalue = '';
         $this->clicktype = 'tid';
         $this->clickvalue = $thread['tid'];
         $this->insertrow();
     }
 }
            showmessage('post_subject_toolong');
        }
        $query = $db->query("UPDATE {$tablepre}threads SET subject='{$subjectnew}' WHERE tid='{$tid}'");
        $query = $db->query("UPDATE {$tablepre}posts SET subject='{$subjectnew}' WHERE tid='{$tid}' AND first='1'");
        showmessage('<a href="viewthread.php?tid=' . $tid . '">' . stripslashes($subjectnew) . '</a>');
    }
} elseif ($action == 'editmessage') {
    $orig = $db->fetch_first("SELECT m.adminid, p.first, p.authorid, p.author, p.dateline, p.anonymous, p.invisible, p.message FROM {$tablepre}posts p\r\n\t\tLEFT JOIN {$tablepre}members m ON m.uid=p.authorid\r\n\t\tWHERE p.pid='{$pid}' AND p.invisible > -1");
    if (empty($orig)) {
        showmessage('post_check', NULL, 'AJAXERROR');
    }
    periodscheck('postbanperiods');
    if (empty($forum['allowview'])) {
        if (!$forum['viewperm'] && !$readaccess) {
            showmessage('group_nopermission', NULL, 'NOPERM');
        } elseif ($forum['viewperm'] && !forumperm($forum['viewperm'])) {
            showmessage('forum_nopermission', NULL, 'NOPERM');
        }
    }
    if (!$forum['ismoderator'] || !$alloweditpost || in_array($orig['adminid'], array(1, 2, 3)) && $adminid > $orig['adminid']) {
        showmessage('post_edit_nopermission', NULL, 'HALTED');
    }
    if (!submitcheck('editmessagesubmit', 1)) {
        include template('modcp_editpost');
        exit;
    } else {
        require_once DISCUZ_ROOT . './include/discuzcode.func.php';
        if ($do == 'notupdate') {
            $message = $orig['message'];
            $message = discuzcode($message, 0, 0, 0, $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'] && $showimages ? 1 : 0, $forum['allowhtml'], 0, 0, $orig['authorid']);
            showmessage(stripslashes($message));
Beispiel #13
0
    foreach ($oldtids as $oldtid) {
        $oldtid && ($oldtidsnew[] = $oldtid);
    }
    if ($oldtidsnew) {
        $query = DB::query("SELECT tid, subject FROM " . DB::table('forum_thread') . " WHERE tid IN (" . dimplode($oldtidsnew) . ")");
        while ($oldthread = DB::fetch($query)) {
            $oldthreads[$oldthread['tid']] = $oldthread['subject'];
        }
    }
}
$_G['group']['allowpost'] = !$_G['forum']['postperm'] && $_G['group']['allowpost'] || $_G['forum']['postperm'] && forumperm($_G['forum']['postperm']) || isset($_G['forum']['allowpost']) && $_G['forum']['allowpost'] == 1 && $_G['group']['allowpost'];
$fastpost = $_G['setting']['fastpost'] && $_G['group']['allowpost'] && !$_G['forum']['allowspecialonly'] && !$_G['forum']['threadsorts']['required'];
$fastpost = $fastpost && !$_G['forum']['allowspecialonly'];
$_G['group']['allowpost'] = isset($_G['forum']['allowpost']) && $_G['forum']['allowpost'] == -1 ? false : $_G['group']['allowpost'];
$_G['forum']['allowpostattach'] = isset($_G['forum']['allowpostattach']) ? $_G['forum']['allowpostattach'] : '';
$allowpostattach = $fastpost && ($_G['forum']['allowpostattach'] != -1 && ($_G['forum']['allowpostattach'] == 1 || !$_G['forum']['postattachperm'] && $_G['group']['allowpostattach'] || $_G['forum']['postattachperm'] && forumperm($_G['forum']['postattachperm'])));
if ($fastpost) {
    if (!$_G['adminid'] && (!cknewuser(1) || $_G['setting']['newbiespan'] && (!getuserprofile('lastpost') || TIMESTAMP - getuserprofile('lastpost') < $_G['setting']['newbiespan'] * 60) && TIMESTAMP - $_G['member']['regdate'] < $_G['setting']['newbiespan'] * 60)) {
        $fastpost = false;
    }
    $usesigcheck = $_G['uid'] && $_G['group']['maxsigsize'];
    $seccodecheck = $_G['setting']['seccodestatus'] & 4 && (!$_G['setting']['seccodedata']['minposts'] || getuserprofile('posts') < $_G['setting']['seccodedata']['minposts']);
    $secqaacheck = $_G['setting']['secqaa']['status'] & 2 && (!$_G['setting']['secqaa']['minposts'] || getuserprofile('posts') < $_G['setting']['secqaa']['minposts']);
}
$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;
Beispiel #14
0
 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 = $_G['gp_special'];
 $specials = $special ? implode(',', $special) : '';
 $srchfilter = in_array($_G['gp_srchfilter'], array('all', 'digest', 'top')) ? $_G['gp_srchfilter'] : 'all';
 function getvariable()
 {
     global $_G;
     if (empty($_G['forum'])) {
         $allowpost = 0;
     } elseif (!$_G['uid'] && !(!$_G['forum']['postperm'] && $_G['group']['allowpost'] || $_G['forum']['postperm'] && forumperm($_G['forum']['postperm']))) {
         $allowpost = 0;
     } elseif (empty($_G['forum']['allowpost'])) {
         if (!$_G['forum']['postperm'] && !$_G['group']['allowpost']) {
             $allowpost = 0;
         } elseif ($_G['forum']['postperm'] && !forumperm($_G['forum']['postperm'])) {
             $allowpost = 0;
         } else {
             $allowpost = 1;
         }
     } elseif ($_G['forum']['allowpost'] == -1) {
         $allowpost = 0;
     } else {
         $allowpost = 1;
     }
     if (empty($_G['forum'])) {
         $allowreply = 0;
     } elseif (!$_G['uid'] && !(!$_G['forum']['replyperm'] && $_G['group']['allowreply'] || $_G['forum']['replyperm'] && forumperm($_G['forum']['replyperm']))) {
         $allowreply = 0;
     } elseif (empty($_G['forum']['allowreply'])) {
         if (!$_G['forum']['replyperm'] && !$_G['group']['allowreply']) {
             $allowreply = 0;
         } elseif ($_G['forum']['replyperm'] && !forumperm($_G['forum']['replyperm'])) {
             $allowreply = 0;
         } else {
             $allowreply = 1;
         }
     } elseif ($_G['forum']['allowreply'] == -1) {
         $allowreply = 0;
     } else {
         $allowreply = 1;
     }
     $mobile_attachextensions = array('jpg', 'jpeg', 'gif', 'png', 'mp3', 'txt', 'zip', 'rar', 'pdf');
     $_G['forum']['allowpostattach'] = isset($_G['forum']['allowpostattach']) ? $_G['forum']['allowpostattach'] : '';
     $allowupload = $_G['forum']['allowpostattach'] != -1 && ($_G['forum']['allowpostattach'] == 1 || !$_G['forum']['postattachperm'] && $_G['group']['allowpostattach'] || $_G['forum']['postattachperm'] && forumperm($_G['forum']['postattachperm']));
     $allowupload = $allowupload && (!$_G['group']['maxattachnum'] || $_G['group']['maxattachnum'] && $_G['group']['maxattachnum'] > getuserprofile('todayattachs'));
     $attachremain = array();
     if ($allowupload) {
         $attachextensions = !$_G['group']['attachextensions'] ? $mobile_attachextensions : array_map('trim', explode(',', $_G['group']['attachextensions']));
         $allowupload = $forummaxattachsize = array();
         loadcache('attachtype');
         if (isset($_G['cache']['attachtype'][$_G['forum']['fid']])) {
             $attachtype = $_G['cache']['attachtype'][$_G['forum']['fid']];
         } elseif (isset($_G['cache']['attachtype'][0])) {
             $attachtype = $_G['cache']['attachtype'][0];
         } else {
             $attachtype = array();
         }
         if ($attachtype) {
             foreach ($attachtype as $extension => $maxsize) {
                 $forummaxattachsize[$extension] = $maxsize;
             }
         }
         foreach ($mobile_attachextensions as $ext) {
             if (in_array($ext, $attachextensions)) {
                 if (isset($forummaxattachsize[$ext])) {
                     if ($forummaxattachsize[$ext] > 0) {
                         $allowupload[$ext] = $forummaxattachsize[$ext] ? $forummaxattachsize[$ext] : $_G['group']['maxattachsize'];
                     } else {
                         $allowupload[$ext] = 0;
                     }
                 } else {
                     $allowupload[$ext] = -1;
                 }
             } else {
                 $allowupload[$ext] = 0;
             }
         }
         $attachremain = array('size' => $_G['group']['maxsizeperday'] ? $_G['group']['maxsizeperday'] - getuserprofile('todayattachsize') : -1, 'count' => $_G['group']['maxattachnum'] ? $_G['group']['maxattachnum'] - getuserprofile('todayattachs') : -1);
     } else {
         $allowupload = array();
     }
     $uploadhash = md5(substr(md5($_G['config']['security']['authkey']), 8) . $_G['uid']);
     $allowperm = array();
     $allowperm['allowperm'] = array();
     $allowkey = array('allowpost', 'allowreply', 'allowupload', 'attachremain', 'uploadhash');
     foreach ($allowkey as $key) {
         if (!empty(${$key}) || ${$key} === 0 || !empty($_GET['debug'])) {
             $allowperm['allowperm'][$key] = ${$key};
         }
     }
     return $allowperm;
 }
Beispiel #16
0
<?php

/*
	[Discuz!] (C)2001-2009 Comsenz Inc.
	This is NOT a freeware, use is subject to license terms

	$Id: leftmenu.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
define('NOROBOT', TRUE);
require_once './include/common.inc.php';
require_once DISCUZ_ROOT . './include/forum.func.php';
$forumlist = $collapse = $gid = array();
$newthreads = round(($timestamp - $lastvisit + 600) / 1000) * 1000;
$sql = !empty($accessmasks) ? "SELECT f.fid, f.fup, f.type, f.name, ff.viewperm, a.allowview FROM {$tablepre}forums f\r\n\t\tLEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid\r\n\t\tLEFT JOIN {$tablepre}access a ON a.uid='{$discuz_uid}' AND a.fid=f.fid\r\n\t\tWHERE f.status>'0' ORDER BY f.type, f.displayorder" : "SELECT f.fid, f.fup, f.type, f.name, ff.viewperm FROM {$tablepre}forums f\r\n\t\tLEFT JOIN {$tablepre}forumfields ff USING(fid)\r\n\t\tWHERE f.status>'0' ORDER BY f.type, f.displayorder";
$query = $db->query($sql);
$forumdata = $forumlist = $haschild = array();
while ($forumdata = $db->fetch_array($query)) {
    if (!$forumdata['viewperm'] || $forumdata['viewperm'] && forumperm($forumdata['viewperm']) || !empty($forumdata['allowview']) || isset($forumdata['users']) && strstr($forumdata['users'], "\t{$discuz_uid}\t")) {
        $forumdata['name'] = addslashes($forumdata['name']);
        $forumdata['type'] != 'group' && ($haschild[$forumdata['fup']] = true);
        $forumlist[] = $forumdata;
    }
}
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}sessions");
$onlinenum = $db->result($query, 0);
include template('leftmenu');
Beispiel #17
0
function rssforumperm($forum)
{
    global $_G;
    return $forum['type'] != 'group' && (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm']) || $_G['member']['accessmasks']);
}
 $id = empty($_GET['id']) ? 0 : intval($_GET['id']);
 $spaceuid = empty($_GET['spaceuid']) ? 0 : intval($_GET['spaceuid']);
 $idtype = $title = $icon = '';
 switch ($type) {
     case 'thread':
         $idtype = 'tid';
         $thread = C::t('forum_thread')->fetch($id);
         $title = $thread['subject'];
         $icon = '<img src="static/image/feed/thread.gif" alt="thread" class="vm" /> ';
         break;
     case 'forum':
         $idtype = 'fid';
         $foruminfo = C::t('forum_forum')->fetch($id);
         loadcache('forums');
         $forum = $_G['cache']['forums'][$id];
         if (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm']) || strstr($forum['users'], "\t{$_G['uid']}\t")) {
             $title = $foruminfo['status'] != 3 ? $foruminfo['name'] : '';
             $icon = '<img src="static/image/feed/discuz.gif" alt="forum" class="vm" /> ';
         }
         break;
     case 'blog':
         $idtype = 'blogid';
         $bloginfo = C::t('home_blog')->fetch($id);
         $title = $bloginfo['uid'] == $spaceuid ? $bloginfo['subject'] : '';
         $icon = '<img src="static/image/feed/blog.gif" alt="blog" class="vm" /> ';
         break;
     case 'group':
         $idtype = 'gid';
         $foruminfo = C::t('forum_forum')->fetch($id);
         $title = $foruminfo['status'] == 3 ? $foruminfo['name'] : '';
         $icon = '<img src="static/image/feed/group.gif" alt="group" class="vm" /> ';
Beispiel #19
0
 function common()
 {
     global $_G;
     $this->page = intval($_GET['page']) ? intval($_GET['page']) : 1;
     $start = ($this->page - 1) * $this->perpage;
     $num = $this->perpage;
     loadcache('forum_guide');
     $dateline = 0;
     $maxnum = 50000;
     $_G['setting']['guide'] = unserialize($_G['setting']['guide']);
     if ($_G['setting']['guide']['digestdt']) {
         $dateline = time() - intval($_G['setting']['guide']['digestdt']);
     }
     $maxtid = C::t('forum_thread')->fetch_max_tid();
     $limittid = max(0, $maxtid - $maxnum);
     $tids = array_slice($_G['cache']['forum_guide']['digest']['data'], $start, $num);
     $query = C::t('forum_thread')->fetch_all_for_guide('digest', $limittid, $tids, $_G['setting']['heatthread']['guidelimit'], $dateline);
     $fids = array();
     loadcache('forums');
     foreach ($_G['cache']['forums'] as $fid => $forum) {
         if ($forum['type'] != 'group' && $forum['status'] > 0 && (!$forum['viewperm'] && $_G['group']['readaccess']) || $forum['viewperm'] && forumperm($forum['viewperm'])) {
             $fids[] = $fid;
         }
     }
     $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 ($tids || $n >= $start && $n < $start + $num) {
             $list[$thread['tid']] = $thread;
         }
         $n++;
     }
     $threadlist = array();
     if ($tids) {
         foreach ($tids as $key => $tid) {
             if ($list[$tid]) {
                 $threadlist[$key] = $list[$tid];
             }
         }
     } else {
         $threadlist = $list;
     }
     unset($list);
     foreach ($threadlist as $thread) {
         $this->field('author', '0', $thread['author']);
         $this->field('dateline', '0', $thread['dateline']);
         $this->field('replies', '1', $thread['replies']);
         $this->field('views', '2', $thread['views']);
         $this->id = $thread['tid'];
         $this->title = $thread['subject'];
         $this->image = '';
         $this->icon = '1';
         $this->poptype = '0';
         $this->popvalue = '';
         $this->clicktype = 'tid';
         $this->clickvalue = $thread['tid'];
         $this->insertrow();
     }
 }
        $thread['id'] = 'stickthread_' . $thread['tid'];
        $separatepos++;
    } elseif (in_array($thread['displayorder'], array(4, 5))) {
        $thread['id'] = 'floatthread_' . $thread['tid'];
    } else {
        $thread['id'] = 'normalthread_' . $thread['tid'];
    }
    $iscircle && $thread['sgid'] && ($sgids[] = $thread['sgid']);
    $threadlist[] = $thread;
}
$separatepos = $separatepos ? $separatepos + 1 : ($announcement ? 1 : 0);
$visitedforums = $visitedforums ? visitedforums() : '';
$forumselect = $forummenu = '';
$typeselect = typeselect($typeid, '', 'onchange="if(this.options[this.selectedIndex].className) {this.form.action=this.form.action + \'&previewpost=yes&showpreview=no\';this.form.submit();}"');
$usesigcheck = $discuz_uid && $sigstatus ? 'checked="checked"' : '';
$allowpost = !$forum['postperm'] && $allowpost || $forum['postperm'] && forumperm($forum['postperm']) || !empty($forum['allowpost']);
$showpoll = $showtrade = $showreward = $showactivity = $showdebate = $showvideo = 0;
if ($forum['allowpostspecial']) {
    $showpoll = $forum['allowpostspecial'] & 1;
    $showtrade = $forum['allowpostspecial'] & 2;
    $showreward = isset($extcredits[$creditstrans]) && $forum['allowpostspecial'] & 4;
    $showactivity = $forum['allowpostspecial'] & 8;
    $showdebate = $forum['allowpostspecial'] & 16;
    $showvideo = $forum['allowpostspecial'] & 32 && $videoopen;
}
if ($allowpost) {
    $allowpostpoll = $allowpostpoll && $showpoll;
    $allowposttrade = $allowposttrade && $showtrade;
    $allowpostreward = $allowpostreward && $showreward;
    $allowpostactivity = $allowpostactivity && $showactivity;
    $allowpostdebate = $allowpostdebate && $showdebate;
    }
    exit;
}
$filename = $_G['setting']['attachdir'] . '/forum/' . $attach['attachment'];
if (!$attach['remote'] && !is_readable($filename)) {
    if (!$requestmode) {
        showmessage('attachment_nonexistence');
    } else {
        exit;
    }
}
if (!$requestmode) {
    if (!$ispaid && !$forum['allowgetattach']) {
        if (!$forum['getattachperm'] && !$allowgetattach) {
            showmessage('getattachperm_none_nopermission', NULL, array(), array('login' => 1));
        } elseif ($forum['getattachperm'] && !forumperm($forum['getattachperm']) || $forum['viewperm'] && !forumperm($forum['viewperm'])) {
            showmessagenoperm('getattachperm', $forum['fid']);
        }
    }
    $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 = $_G['gp_ck'];
                $t = $_G['gp_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 {
    $thread = getpostinfo($tid, 'tid', array('fid', 'tid', 'authorid', 'special'));
    checkmagicperm($magicperm['forum'], $thread['fid']);
    if ($thread['authorid'] != $discuz_uid) {
        showmessage('magics_operation_nopermission');
    }
    if ($thread['special']) {
        $query = $db->query("SELECT allowpostspecial FROM {$tablepre}forums WHERE fid='{$moveto}'");
        if (!substr(sprintf('%04b', $forum['allowpostspecial']), -$thread['special'], 1)) {
            showmessage('admin_move_nopermission');
        }
    }
    $query = $db->query("SELECT postperm FROM {$tablepre}forumfields WHERE fid='{$moveto}'");
    if ($forum = $db->fetch_array($query)) {
        if (!$forum['postperm'] && !$allowpost) {
            showmessage('group_nopermission');
        } elseif ($forum['postperm'] && !forumperm($forum['postperm'])) {
            showmessage('post_forum_newthread_nopermission');
        }
    }
    $db->query("UPDATE {$tablepre}threads SET fid='{$moveto}', moderated='1' WHERE tid='{$tid}'");
    $db->query("UPDATE {$tablepre}posts SET fid='{$moveto}' WHERE tid='{$tid}'");
    require_once DISCUZ_ROOT . './include/post.func.php';
    updateforumcount($moveto);
    updateforumcount($thread['fid']);
    usemagic($magicid, $magic['num']);
    updatemagiclog($magicid, '2', '1', '0', $tid);
    updatemagicthreadlog($tid, $magicid, $magic['identifier']);
    showmessage('magics_operation_succeed', '', 1);
}
function showmagic()
{
Beispiel #23
0
    $modforums = array('fids' => '', 'list' => array(), 'recyclebins' => array());
    $comma = '';
    if ($_G['adminid'] == 3) {
        $query = DB::query("SELECT m.fid, f.name, f.recyclebin\n\t\t\t\tFROM " . DB::table('forum_moderator') . " m\n\t\t\t\tLEFT JOIN " . DB::table('forum_forum') . " f ON f.fid=m.fid\n\t\t\t\tWHERE m.uid='{$_G['uid']}' AND f.status='1' AND f.type<>'group'");
        while ($tforum = DB::fetch($query)) {
            $modforums['fids'] .= $comma . $tforum['fid'];
            $comma = ',';
            $modforums['recyclebins'][$tforum['fid']] = $tforum['recyclebin'];
            $modforums['list'][$tforum['fid']] = strip_tags($tforum['name']);
        }
    } else {
        $sql = $_G['member']['accessmasks'] ? "SELECT f.fid, f.name, f.threads, f.recyclebin, ff.viewperm, a.allowview FROM " . DB::table('forum_forum') . " f\n\t\t\t\tLEFT JOIN " . DB::table('forum_forumfield') . " ff ON ff.fid=f.fid\n\t\t\t\tLEFT JOIN " . DB::table('forum_access') . " a ON a.uid='{$_G['uid']}' AND a.fid=f.fid\n\t\t\t\tWHERE f.status='1' AND ff.redirect=''" : "SELECT f.fid, f.name, f.threads, f.recyclebin, ff.viewperm, ff.redirect FROM " . DB::table('forum_forum') . " f\n\t\t\t\tLEFT JOIN " . DB::table('forum_forumfield') . " ff USING(fid)\n\t\t\t\tWHERE f.status='1' AND f.type<>'group' AND ff.redirect=''";
        $query = DB::query($sql);
        while ($tforum = DB::fetch($query)) {
            $tforum['allowview'] = !isset($tforum['allowview']) ? '' : $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);
}
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 {
Beispiel #24
0
}
if (empty($_G['forum']['fid']) || $_G['forum']['type'] == 'group') {
    showmessage('forum_nonexistence');
}
if ($special != 2 || !submitcheck('topicsubmit', 0, $seccodecheck, $secqaacheck)) {
    showmessage('undefined_action', NULL);
}
if (!$_G['group']['allowposttrade']) {
    showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
}
if (!$_G['uid'] && !(!$_G['forum']['postperm'] && $_G['group']['allowpost'] || $_G['forum']['postperm'] && forumperm($_G['forum']['postperm']))) {
    showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
} elseif (empty($_G['forum']['allowpost'])) {
    if (!$_G['forum']['postperm'] && !$_G['group']['allowpost']) {
        showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
    } elseif ($_G['forum']['postperm'] && !forumperm($_G['forum']['postperm'])) {
        showmessage('post_forum_newthread_nopermission', NULL);
    }
} elseif ($_G['forum']['allowpost'] == -1) {
    showmessage('post_forum_newthread_nopermission', NULL);
}
checklowerlimit('post');
if ($post_invalid = checkpost($subject, $message, 1)) {
    showmessage($post_invalid, '', array('minpostsize' => $_G['setting']['minpostsize'], 'maxpostsize' => $_G['setting']['maxpostsize']));
}
if (checkflood()) {
    showmessage('post_flood_ctrl', '', array('floodctrl' => $_G['setting']['floodctrl']));
}
$item_price = floatval($_G['gp_item_price']);
$item_credit = intval($_G['gp_item_credit']);
$_G['gp_item_name'] = censor($_G['gp_item_name']);
Beispiel #25
0
        showmessagenoperm('viewperm', $_G['fid']);
    }
} elseif ($_G['forum']['allowview'] == -1) {
    showmessage('forum_access_view_disallow');
}
formulaperm($_G['forum']['formulaperm']);
if (!$_G['adminid'] && $_G['setting']['newbiespan'] && (!getuserprofile('lastpost') || TIMESTAMP - getuserprofile('lastpost') < $_G['setting']['newbiespan'] * 3600)) {
    if (TIMESTAMP - DB::result_first("SELECT regdate FROM " . DB::table('common_member') . " WHERE uid='{$_G['uid']}'") < $_G['setting']['newbiespan'] * 3600) {
        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'];
if ($_G['group']['attachextensions']) {
    $imgexts = explode(',', str_replace(' ', '', $_G['group']['attachextensions']));
    $imgexts = array_intersect(array('jpg', 'jpeg', 'gif', 'png', 'bmp'), $imgexts);
    $imgexts = implode(', ', $imgexts);
} else {
    $imgexts = 'jpg, jpeg, gif, png, bmp';
}
$allowuploadnum = TRUE;
if ($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) {
    if ($_G['group']['maxattachnum']) {
        $allowuploadnum = $_G['group']['maxattachnum'] - DB::result_first("SELECT count(*) FROM " . DB::table('forum_attachment') . " WHERE uid='{$_G['uid']}' AND dateline>'{$_G['timestamp']}'-86400");
        $allowuploadnum = $allowuploadnum < 0 ? 0 : $allowuploadnum;
        $_G['group']['allowpostimage'] = $_G['group']['allowpostattach'] = $allowuploadnum ? $allowuploadnum : 0;
    }
if($sortid && $forum['threadsorts']['types'][$sortid]) {
	$sortlistarray = sortshowlist($searchoid, $searchvid, $threadids, $searchoption, $selectadd);
	$stemplate = $sortlistarray['stemplate'] ? $sortlistarray['stemplate'] : '';
	$threadlist = $sortlistarray['thread']['list'] ? $sortlistarray['thread']['list'] : $threadlist;
	$threadcount = !empty($sortlistarray['thread']['count']) ? $sortlistarray['thread']['count'] : $threadcount;
	$multipage = $sortlistarray['thread']['multipage'] ? $sortlistarray['thread']['multipage'] : $multipage;
	$sortthreadlist = $sortlistarray['sortthreadlist'] ? $sortlistarray['sortthreadlist'] : array();
}

$separatepos = $separatepos ? $separatepos + 1 : ($announcement ? 1 : 0);

$visitedforums = $visitedforums ? visitedforums() : '';
$forummenu = '';

$usesigcheck = $discuz_uid && $sigstatus ? 'checked="checked"' : '';
$allowpost = (!$forum['postperm'] && $allowpost) || ($forum['postperm'] && forumperm($forum['postperm'])) || ($forum['allowpost'] == 1 && $allowpost);
$fastpost = $fastpost && !$forum['allowspecialonly'];
$allowpost = $forum['allowpost'] != -1 ? $allowpost : false;
$addfeedcheck = $customaddfeed & 1 ? 'checked="checked"': '';

$showpoll = $showtrade = $showreward = $showactivity = $showdebate = 0;
if($forum['allowpostspecial']) {
	$showpoll = $forum['allowpostspecial'] & 1;
	$showtrade = $forum['allowpostspecial'] & 2;
	$showreward = isset($extcredits[$creditstransextra[2]]) && ($forum['allowpostspecial'] & 4);
	$showactivity = $forum['allowpostspecial'] & 8;
	$showdebate = $forum['allowpostspecial'] & 16;
}

if($allowpost) {
	$allowpostpoll = $allowpostpoll && $showpoll;
        }
    }
    showmessage('replynotice_error', 'forum.php?mod=viewthread&tid=' . $tid);
} elseif ($_GET['action'] == 'removeindexheats') {
    if ($_G['adminid'] != 1) {
        showmessage('no_privilege_indexheats');
    }
    C::t('forum_thread')->update($_G['tid'], array('heats' => 0));
    require_once libfile('function/cache');
    updatecache('heats');
    dheader('Location: ' . dreferer());
} else {
    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'])) {
            showmessage('forum_nopermission', NULL, array($_G['group']['grouptitle']), array('login' => 1));
        }
    }
    $thread = C::t('forum_thread')->fetch($_G['tid']);
    if (!($thread['displayorder'] >= 0 || $thread['displayorder'] == -4 && $thread['authorid'] == $_G['uid'])) {
        $thread = array();
    }
    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));
    }
    if ($_G['forum']['password'] && $_G['forum']['password'] != $_G['cookie']['fidpw' . $_G['fid']]) {
        showmessage('forum_passwd', "forum.php?mod=forumdisplay&fid={$_G['fid']}");
    }
    if (!$thread) {
        showmessage('thread_nonexistence');
    include template('search_trade');
} else {
    checklowerlimit($creditspolicy['search'], -1);
    $srchtxt = isset($srchtxt) ? trim($srchtxt) : '';
    $srchuname = isset($srchuname) ? trim($srchuname) : '';
    $forumsarray = array();
    if (!empty($srchfid)) {
        foreach (is_array($srchfid) ? $srchfid : explode('_', $srchfid) as $forum) {
            if ($forum = intval(trim($forum))) {
                $forumsarray[] = $forum;
            }
        }
    }
    $fids = $comma = '';
    foreach ($_DCACHE['forums'] as $fid => $forum) {
        if ($forum['type'] != 'group' && (!$forum['viewperm'] && $readaccess) || $forum['viewperm'] && forumperm($forum['viewperm'])) {
            if (!$forumsarray || in_array($fid, $forumsarray)) {
                $fids .= "{$comma}'{$fid}'";
                $comma = ',';
            }
        }
    }
    $srchfilter = in_array($srchfilter, array('all', 'digest', 'top')) ? $srchfilter : 'all';
    $searchstring = 'trade|' . addslashes($srchtxt) . '|' . intval($srchtypeid) . '|' . intval($srchuid) . '|' . $srchuname . '|' . addslashes($fids) . '|' . intval($srchfrom) . '|' . intval($before) . '|' . $srchfilter;
    $searchindex = array('id' => 0, 'dateline' => '0');
    $query = $db->query("SELECT searchid, dateline,\r\n\t\t('{$searchctrl}'<>'0' AND " . (empty($discuz_uid) ? "useip='{$onlineip}'" : "uid='{$discuz_uid}'") . " AND {$timestamp}-dateline<{$searchctrl}) AS flood,\r\n\t\t(searchstring='{$searchstring}' AND expiration>'{$timestamp}') AS indexvalid\r\n\t\tFROM {$tablepre}searchindex\r\n\t\tWHERE ('{$searchctrl}'<>'0' AND " . (empty($discuz_uid) ? "useip='{$onlineip}'" : "uid='{$discuz_uid}'") . " AND {$timestamp}-dateline<{$searchctrl}) OR (searchstring='{$searchstring}' AND expiration>'{$timestamp}')\r\n\t\tORDER BY flood");
    while ($index = $db->fetch_array($query)) {
        if ($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
            $searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
            break;
        } elseif ($index['flood']) {
Beispiel #29
0
            updatepostcredits('+', $discuz_uid, $postcredits);
            $lastpost = "{$tid}\t{$subject}\t{$timestamp}\t{$discuz_user}";
            $db->query("UPDATE {$tablepre}forums SET lastpost='{$lastpost}', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='{$fid}'", 'UNBUFFERED');
            if ($forum['type'] == 'sub') {
                $db->query("UPDATE {$tablepre}forums SET lastpost='{$lastpost}' WHERE fid='{$forum['fup']}'", 'UNBUFFERED');
            }
            wapmsg('post_newthread_succeed', array('title' => 'post_newthread_forward', 'link' => "index.php?action=thread&amp;tid={$tid}"));
        }
    }
} elseif ($do == 'reply') {
    $discuz_action = 196;
    $thread = $db->fetch_first("SELECT * FROM {$tablepre}threads WHERE tid='{$tid}'");
    if (!$thread) {
        wapmsg('thread_nonexistence');
    }
    if (empty($forum['allowreply']) && (!$forum['replyperm'] && !$allowreply || $forum['replyperm'] && !forumperm($forum['replyperm']))) {
        wapmsg('post_newreply_nopermission');
    }
    if ($thread['closed'] && !$forum['ismoderator']) {
        wapmsg('post_thread_closed');
    }
    if ($post_autoclose = checkautoclose()) {
        wapmsg($post_autoclose);
    }
    if (empty($message)) {
        echo "<p>{$lang['message']}<input type=\"text\" name=\"message\" value=\"\" format=\"M*m\" /><br />\n" . "<anchor title=\"{$lang['submit']}\">{$lang['submit']}" . "<go method=\"post\" href=\"index.php?action=post&amp;do=reply&amp;fid={$fid}&amp;tid={$tid}&amp;sid={$sid}\">\n" . "<postfield name=\"subject\" value=\"\$(subject)\" />\n" . "<postfield name=\"message\" value=\"\$(message)\" />\n" . "<postfield name=\"formhash\" value=\"" . formhash() . "\" />\n" . "</go></anchor><br /><br />\n" . "<a href=\"index.php?action=thread&amp;tid={$tid}\">{$lang['return_thread']}</a><br />\n" . "<a href=\"index.php?action=forum&amp;fid={$fid}\">{$lang['return_forum']}</a></p>\n";
    } else {
        if ($message == '') {
            wapmsg('post_sm_isnull');
        }
        if ($post_invalid = checkpost()) {
Beispiel #30
0
    if (!$forum['viewperm'] && !$readaccess) {
        showmessage('group_nopermission', NULL, 'NOPERM');
    } elseif ($forum['viewperm'] && !forumperm($forum['viewperm'])) {
        showmessage('forum_nopermission', NULL, 'NOPERM');
    }
} elseif ($forum['allowview'] == -1) {
    showmessage('forum_access_view_disallow');
}
formulaperm($forum['formulaperm']);
if (!$adminid && $newbiespan && (!$lastpost || $timestamp - $lastpost < $newbiespan * 3600)) {
    if ($timestamp - $db->result_first("SELECT regdate FROM {$tablepre}members WHERE uid='{$discuz_uid}'") < $newbiespan * 3600) {
        showmessage('post_newbie_span');
    }
}
$special = empty($special) || !is_numeric($special) || $special < 0 || $special > 6 ? 0 : intval($special);
$allowpostattach = $forum['allowpostattach'] != -1 && ($forum['allowpostattach'] == 1 || !$forum['postattachperm'] && $allowpostattach || $forum['postattachperm'] && forumperm($forum['postattachperm']));
$attachextensions = $forum['attachextensions'] ? $forum['attachextensions'] : $attachextensions;
$enctype = $allowpostattach ? 'enctype="multipart/form-data"' : '';
$maxattachsize_mb = $maxattachsize / 1048576 >= 1 ? round($maxattachsize / 1048576, 1) . 'M' : round($maxattachsize / 1024) . 'K';
$postcredits = $forum['postcredits'] ? $forum['postcredits'] : $creditspolicy['post'];
$replycredits = $forum['replycredits'] ? $forum['replycredits'] : $creditspolicy['reply'];
$digestcredits = $forum['digestcredits'] ? $forum['digestcredits'] : $creditspolicy['digest'];
$postattachcredits = $forum['postattachcredits'] ? $forum['postattachcredits'] : $creditspolicy['postattach'];
$maxprice = isset($extcredits[$creditstrans]) ? $maxprice : 0;
$extra = rawurlencode($extra);
$notifycheck = empty($emailnotify) ? '' : 'checked="checked"';
$stickcheck = empty($sticktopic) ? '' : 'checked="checked"';
$digestcheck = empty($addtodigest) ? '' : 'checked="checked"';
$subject = isset($subject) ? dhtmlspecialchars(censor(trim($subject))) : '';
$subject = !empty($subject) ? str_replace("\t", ' ', $subject) : $subject;
$message = isset($message) ? censor(trim($message)) : '';