コード例 #1
0
ファイル: random_topics.php プロジェクト: ALTUN69/icy_phoenix
 function cms_block_random_topics()
 {
     global $db, $cache, $config, $template, $user, $lang, $bbcode, $block_id, $cms_config_vars;
     @(include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
     $template->_tpldata['random_topic_row.'] = array();
     $bbcode->allow_html = $user->data['user_allowhtml'] && $config['allow_html'] ? true : false;
     $bbcode->allow_bbcode = $user->data['user_allowbbcode'] && $config['allow_bbcode'] ? true : false;
     $bbcode->allow_smilies = $user->data['user_allowsmile'] && $config['allow_smilies'] ? true : false;
     $allowed_forum_id = build_allowed_forums_list();
     if ($allowed_forum_id != '') {
         $allow_forum_id = $cms_config_vars['md_random_topics_forums'][$block_id];
         if ($allow_forum_id == '0') {
             $allowed_forums_sql = 'AND t.forum_id IN (' . $allowed_forum_id . ')';
         } else {
             $allowed_forums = explode(',', $allow_forum_id);
             $allowed_forums_tmp = explode(',', $allowed_forum_id);
             $allowed_forum_id = '';
             for ($i = 0; $i < sizeof($allowed_forums); $i++) {
                 for ($j = 0; $j < sizeof($allowed_forums_tmp); $j++) {
                     if ($allowed_forums[$i] == $allowed_forums_tmp[$j]) {
                         $allowed_forum_id .= $allowed_forums[$i] . ',';
                         break;
                     }
                 }
             }
             if ($allowed_forum_id != '') {
                 $allowed_forum_id = substr($allowed_forum_id, -1, 1) == ',' ? substr($allowed_forum_id, 0, -1) : $allowed_forum_id;
                 $allowed_forums_sql = 'AND t.forum_id IN (' . $allowed_forum_id . ')';
             } else {
                 $no_topics_found = true;
             }
         }
     } else {
         $allowed_forums_sql = '';
     }
     $sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username, u.user_active, u.user_color, f.forum_name\n\t\t\tFROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u, " . FORUMS_TABLE . " AS f\n\t\t\tWHERE t.topic_status <> 2\n\t\t\t\t" . $allowed_forums_sql . "\n\t\t\t\tAND f.forum_id = t.forum_id\n\t\t\t\tAND p.post_id = t.topic_last_post_id\n\t\t\t\tAND p.poster_id = u.user_id\n\t\t\tORDER BY RAND()\n\t\t\tLIMIT " . $cms_config_vars['md_num_random_topics'][$block_id];
     $result = $db->sql_query($sql);
     $number_random_topics = $db->sql_numrows($result);
     $random_topic_row = array();
     while ($row1 = $db->sql_fetchrow($result)) {
         $random_topic_row[] = $row1;
     }
     $db->sql_freeresult($result);
     if ($number_random_topics == 0 || $no_topics_found == true) {
         $template->assign_block_vars('no_topics', array('L_NO_TOPICS' => $lang['No_topics_found']));
     } else {
         if ($cms_config_vars['md_random_topics_style'][$block_id]) {
             $style_row = 'scroll';
         } else {
             $style_row = 'static';
         }
         $template->assign_block_vars($style_row, '');
         for ($i = 0; $i < $number_random_topics; $i++) {
             $random_topic_row[$i]['topic_title'] = censor_text($recent_topic_row[$i]['topic_title']);
             $template->assign_block_vars($style_row . '.random_topic_row', array('U_FORUM' => append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $random_topic_row[$i]['forum_id']), 'L_FORUM' => $random_topic_row[$i]['forum_name'], 'U_TITLE' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $random_topic_row[$i]['forum_id'] . '&amp;' . POST_TOPIC_URL . '=' . $random_topic_row[$i]['topic_id'] . '&amp;' . POST_POST_URL . '=' . $random_topic_row[$i]['post_id']) . '#p' . $random_topic_row[$i]['post_id'], 'L_TITLE' => $bbcode->parse(htmlspecialchars($random_topic_row[$i]['topic_title'])), 'L_BY' => $lang['By'], 'L_ON' => $lang['POSTED_ON'], 'S_POSTER' => colorize_username($random_topic_row[$i]['user_id'], $random_topic_row[$i]['username'], $random_topic_row[$i]['user_color'], $random_topic_row[$i]['user_active']), 'S_POSTTIME' => create_date_ip($config['default_dateformat'], $random_topic_row[$i]['post_time'], $config['board_timezone'])));
         }
     }
 }
コード例 #2
0
function get_forum_most_active($user_id)
{
    global $db, $cache, $config, $auth, $user, $lang;
    $user_id = (int) $user_id;
    if (empty($user_id)) {
        return $user_most_active;
    }
    $most_active_id = array();
    $allowed_forums = build_allowed_forums_list(true);
    $forum_sql = sizeof($allowed_forums) ? ' AND ' . $db->sql_in_set('forum_id', $allowed_forums) : '';
    // Obtain active forum
    // Maybe we should add a check on post count switch for forums? ==> " AND f.forum_postcount = 1"
    $sql = "SELECT forum_id, COUNT(post_id) AS num_posts\n\t\tFROM " . POSTS_TABLE . "\n\t\tWHERE poster_id = " . (int) $user_id . "\n\t\t\t{$forum_sql}\n\t\tGROUP BY forum_id\n\t\tORDER BY num_posts DESC";
    $result = $db->sql_query_limit($sql, 1);
    $active_f_row = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);
    if (!empty($active_f_row)) {
        $sql = "SELECT forum_name\n\t\t\tFROM " . FORUMS_TABLE . "\n\t\t\tWHERE forum_id = " . $active_f_row['forum_id'];
        $result = $db->sql_query($sql, 0, 'forum_name_', FORUMS_CACHE_FOLDER);
        $active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name');
        $db->sql_freeresult($result);
    }
    $active_f_name = $lang['No_Posts'];
    $active_f_id = 0;
    $active_f_count = 0;
    /*
    $active_f_pct = '';
    */
    if (!empty($active_f_row['num_posts'])) {
        $active_f_name = $active_f_row['forum_name'];
        $active_f_id = $active_f_row['forum_id'];
        $active_f_count = $active_f_row['num_posts'];
        /*
        $active_f_pct = ($userdata['user_posts']) ? ($active_f_count / $userdata['user_posts']) * 100 : 0;
        */
    }
    return array('forum_id' => $active_f_id, 'forum_name' => $active_f_name, 'posts' => $active_f_count);
}
コード例 #3
0
 function cms_block_calendar_events()
 {
     global $db, $cache, $config, $template, $theme, $user, $lang, $bbcode, $block_id, $cms_config_vars;
     $show_end_date = !empty($cms_config_vars['md_events_end'][$block_id]) ? true : false;
     $events_number = (int) $cms_config_vars['md_events_num'][$block_id];
     $events_number = $events_number < 2 ? 10 : $events_number;
     $allow_forum_id = str_replace(' ', '', $cms_config_vars['md_events_forums_id'][$block_id]);
     $allow_forum_id_array = explode(',', $allow_forum_id);
     $allowed_forum_ids = build_allowed_forums_list(true);
     $allowed_forum_id_array = !empty($allow_forum_id) ? array_intersect($allowed_forum_ids, $allow_forum_id_array) : $allowed_forum_ids;
     if (empty($allowed_forum_id_array)) {
         $template->assign_var('NO_EVENTS', true);
     } else {
         $allowed_forum_ids_sql = ' AND t.forum_id IN (' . implode(',', $allowed_forum_id_array) . ') ';
         $sql = "SELECT t.*, f.forum_name\n\t\t\t\tFROM " . FORUMS_TABLE . " AS f, " . TOPICS_TABLE . " AS t\n\t\t\t\tWHERE t.topic_status <> 2\n\t\t\t\t\t" . $allowed_forums_sql . "\n\t\t\t\t\tAND f.forum_id = t.forum_id\n\t\t\t\t\tAND t.topic_calendar_time > " . time() . "\n\t\t\t\tORDER BY t.topic_calendar_time ASC\n\t\t\t\tLIMIT " . $events_number;
         $result = $db->sql_query($sql);
         $events_number_counter = $db->sql_numrows($result);
         if (empty($result) || empty($events_number_counter)) {
             $template->assign_var('NO_EVENTS', true);
         } else {
             $template->assign_var('SHOW_END_TIME', $show_end_date);
             $i = 0;
             $event_rows = $db->sql_fetchrowset($result);
             $db->sql_freeresult($result);
             $topic_ids = array();
             foreach ($event_rows as $event_row) {
                 $topic_ids[] = $event_row['topic_id'];
             }
             if ($user->data['session_logged_in'] && !$user->data['is_bot']) {
                 $sql = "SELECT topic_id, registration_status FROM " . REGISTRATION_TABLE . "\n\t\t\t\t\t\t\tWHERE " . $db->sql_in_set('topic_id', $topic_ids) . "\n\t\t\t\t\t\t\tAND registration_user_id = " . $user->data['user_id'];
                 $result = $db->sql_query($sql);
                 $reg_rows = $db->sql_fetchrowset($result);
                 $db->sql_freeresult($result);
                 $reg_array = array();
                 foreach ($reg_rows as $reg_row) {
                     $reg_array[$reg_row['topic_id']] = $reg_row['registration_status'];
                 }
             }
             foreach ($event_rows as $event_row) {
                 $event_row['topic_title'] = censor_text($event_row['topic_title']);
                 $reg_info = '';
                 if (!empty($event_row['topic_reg']) && $user->data['session_logged_in'] && !$user->data['is_bot']) {
                     $reg_info = '&nbsp;<span class="text_orange">&bull;</span>';
                     if (!empty($reg_array[$event_row['topic_id']])) {
                         /*
                         define('REG_OPTION1', 1);
                         define('REG_OPTION2', 2);
                         define('REG_OPTION3', 3);
                         define('REG_UNREGISTER', 4);
                         */
                         if ($reg_array[$event_row['topic_id']] == REG_OPTION1) {
                             $reg_info = '&nbsp;<span class="text_green">&bull;</span>';
                         } elseif ($reg_array[$event_row['topic_id']] == REG_OPTION2) {
                             $reg_info = '&nbsp;<span class="text_blue">&bull;</span>';
                         } elseif ($reg_array[$event_row['topic_id']] == REG_OPTION3) {
                             $reg_info = '&nbsp;<span class="text_red">&bull;</span>';
                         }
                     }
                 }
                 $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2'];
                 $template->assign_block_vars('event_row', array('ROW_CLASS' => $row_class, 'EVENT_START_DATE' => gmdate($lang['DATE_FORMAT_DATE'], $event_row['topic_calendar_time']), 'EVENT_START_TIME' => gmdate($lang['DATE_FORMAT_TIME'], $event_row['topic_calendar_time']), 'EVENT_END_DATE' => gmdate($lang['DATE_FORMAT_DATE'], $event_row['topic_calendar_time'] + $event_row['topic_calendar_duration']), 'EVENT_END_TIME' => gmdate($lang['DATE_FORMAT_TIME'], $event_row['topic_calendar_time'] + $event_row['topic_calendar_duration']), 'U_EVENT_FORUM' => append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $event_row['forum_id']), 'L_EVENT_FORUM' => $event_row['forum_name'], 'U_EVENT_TITLE' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $event_row['forum_id'] . '&amp;' . POST_TOPIC_URL . '=' . $event_row['topic_id']), 'L_EVENT_TITLE' => $event_row['topic_title'] . $reg_info));
                 $i++;
             }
         }
     }
 }