示例#1
0
// Sort out who the moderators are and if we are currently a moderator (or an admin)
$mods_array = $cur_topic['moderators'] != '' ? unserialize($cur_topic['moderators']) : array();
$is_admmod = $panther_user['is_admin'] || ($panther_user['g_moderator'] == '1' && $panther_user['g_global_moderator'] || isset($mods_array[$panther_user['username']])) ? true : false;
if ($is_admmod) {
    $admin_ids = get_admin_ids();
}
if ($cur_topic['password'] != '') {
    check_forum_login_cookie($cur_topic['forum_id'], $cur_topic['password']);
}
if ($cur_topic['protected'] == '1' && $panther_user['username'] != $cur_topic['poster'] && !$is_admmod) {
    message($lang_common['No permission']);
}
if ($panther_config['o_archiving'] == '1' && $cur_topic['archived'] == '0') {
    if ($cur_topic['archived'] !== '2') {
        $archive_rules = unserialize($panther_config['o_archive_rules']);
        $cur_topic['archived'] = check_archive_rules($archive_rules, $id);
    }
}
// Add/update this topic in our list of tracked topics
if (!$panther_user['is_guest']) {
    $tracked_topics = get_tracked_topics();
    $tracked_topics['topics'][$id] = time();
    set_tracked_topics($tracked_topics);
}
// Preg replace is slow!
$url_subject = url_friendly($cur_topic['subject']);
$url_forum = url_friendly($cur_topic['forum_name']);
// Determine the post offset (based on $_GET['p'])
$num_pages = ceil(($cur_topic['num_replies'] + 1) / $panther_user['disp_posts']);
$p = !isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages ? 1 : intval($_GET['p']);
$start_from = $panther_user['disp_posts'] * ($p - 1);
示例#2
0
 $sticky = isset($_POST['sticky']) ? intval($_POST['sticky']) : 0;
 $forums = isset($_POST['forums']) && is_array($_POST['forums']) ? array_map('intval', $_POST['forums']) : array(0);
 if (in_array(0, $forums) && count($forums) > 1) {
     message($lang_admin_archive['All forums message']);
 }
 if ($sticky > 2 || $sticky < 0 || $closed > 2 || $closed < 0) {
     message($lang_admin_archive['Open/close message']);
 }
 if ($time < 1) {
     message(sprintf($lang_admin_archive['Invalid time value'], strtolower($unit)));
 }
 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
     require PANTHER_ROOT . 'include/cache.php';
 }
 $rules = array('closed' => $closed, 'sticky' => $sticky, 'time' => $time, 'unit' => $unit, 'forums' => $forums);
 $topics = check_archive_rules($rules);
 $percentage = 0;
 if ($topics['count'] != 0 && $panther_config['o_archiving'] == '1') {
     $markers = $data = array();
     for ($i = 0; $i < count($topics['topics']); $i++) {
         $markers[] = '?';
         $data[] = $topics['topics'][$i];
     }
     $db->run('UPDATE ' . $db->prefix . 'topics SET archived=1 WHERE id IN (' . implode(',', $markers) . ')', $data);
     $percentage = round($topics['count'] / $total * 100, 2);
 }
 $update = array('conf_value' => serialize($rules));
 $data = array(':conf_name' => 'o_archive_rules');
 $db->update('config', $update, 'conf_name=:conf_name', $data);
 generate_config_cache();
 $redirect_lang = $panther_config['o_archiving'] == '1' ? sprintf($lang_admin_archive['Archive rules updated'], $topics['count'], $total, $percentage . '%') : $lang_admin_archive['Updated redirect'];