Example #1
0
 function cms_block_center_downloads()
 {
     global $db, $cache, $config, $template, $theme, $images, $lang, $table_prefix, $block_id, $cms_config_vars;
     include IP_ROOT_PATH . PA_FILE_DB_PATH . 'pafiledb_constants.' . PHP_EXT;
     $template->_tpldata['dlrow.'] = array();
     $template->_tpldata['dlrow2.'] = array();
     $sql = "SELECT * FROM " . PA_FILES_TABLE . "\n\t\t\t\t\t\tWHERE file_approved = '1'\n\t\t\t\t\t\t\tORDER BY file_dls DESC LIMIT 0," . $cms_config_vars['md_num_top_downloads'][$block_id];
     $result = $db->sql_query($sql);
     $i = 1;
     while ($file_most = $db->sql_fetchrow($result)) {
         $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2'];
         $template->assign_block_vars('dlrow', array('NUMBER_MOST' => strval($i), 'ROW_CLASS' => $row_class, 'FILELINK_MOST' => append_sid('dload.' . PHP_EXT . '?action=file&file_id=' . $file_most['file_id']), 'FILENAME_MOST' => $file_most['file_name'], 'DESCRIP_MOST' => $file_most['file_desc'], 'INFO_MOST' => $file_most['file_dls'] . ' ' . $lang['Dls']));
         $i++;
     }
     $sql = "SELECT * FROM " . PA_FILES_TABLE . "\n\t\t\t\t\t\tWHERE file_approved = '1'\n\t\t\t\t\t\t\tORDER BY file_time DESC LIMIT 0," . $cms_config_vars['md_num_new_downloads'][$block_id];
     $result = $db->sql_query($sql);
     $i = 1;
     while ($file_latest = $db->sql_fetchrow($result)) {
         $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2'];
         $template->assign_block_vars('dlrow2', array('NUMBER_LATEST' => strval($i), 'FILELINK_LATEST' => append_sid('dload.' . PHP_EXT . '?action=file&file_id=' . $file_latest['file_id']), 'ROW_CLASS' => $row_class, 'FILENAME_LATEST' => $file_latest['file_name'], 'DESCRIP_LATEST' => $file_latest['file_desc'], 'INFO_LATEST' => create_date_ip($config['default_dateformat'], $file_latest['file_time'], $config['board_timezone'])));
         $i++;
     }
     $db->sql_freeresult($result);
     $template->assign_vars(array('TOP_DOWNLOADS' => $lang['Top_downloads'], 'NEW_DOWNLOADS' => $lang['New_downloads']));
 }
Example #2
0
 function cms_block_recent_articles()
 {
     // if article approved in the table is equal to 1 the article has been approved, else it is not approved, so don't show it.
     global $db, $cache, $config, $template, $user, $lang, $table_prefix, $style_row, $block_id, $cms_config_vars;
     $template->_tpldata['recent_articles.'] = array();
     @(include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
     $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " ORDER BY article_id DESC LIMIT " . $cms_config_vars['md_total_articles'][$block_id];
     $result = $db->sql_query($sql);
     //now lets get our info
     if ($row = $db->sql_fetchrow($result)) {
         $i = 0;
         do {
             if ($row['approved'] == 1) {
                 $title = $row['article_title'];
                 $author_id = $row['article_author_id'];
                 $author = colorize_username($author_id);
                 $article_category_id = $row['article_id'];
                 $url = append_sid(IP_ROOT_PATH . 'kb.' . PHP_EXT . '?mode=article&k=' . $article_category_id);
                 if ($cms_config_vars['md_recent_articles_style'][$block_id] == '1') {
                     $style_row = 'articles_scroll';
                 } else {
                     $style_row = 'articles_static';
                 }
                 $template->assign_block_vars($style_row, '');
                 // Convert and clean special chars!
                 $title = htmlspecialchars_clean($title);
                 $template->assign_block_vars($style_row . '.recent_articles', array('TITLE' => $title, 'U_ARTICLE' => $url, 'AUTHOR' => $author, 'DATE' => create_date_ip($config['default_dateformat'], $row['article_date'], $config['board_timezone'])));
             }
             $i++;
         } while ($row = $db->sql_fetchrow($result));
         $db->sql_freeresult($result);
     }
 }
Example #3
0
 function cms_block_recent_topics()
 {
     global $db, $cache, $config, $template, $user, $lang, $block_id, $cms_config_vars;
     $template->_tpldata['recent_topic_row.'] = array();
     $except_forums = build_exclusion_forums_list();
     $current_time = time();
     $extra = "AND t.topic_time <= {$current_time}";
     $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\n\t\t\tFROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u\n\t\t\tWHERE t.forum_id NOT IN (" . $except_forums . ")\n\t\t\t\tAND t.topic_status <> 2\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\t\t{$extra}\n\t\t\tORDER BY p.post_time DESC\n\t\t\tLIMIT " . $cms_config_vars['md_num_recent_topics'][$block_id];
     $result = $db->sql_query($sql);
     $number_recent_topics = $db->sql_numrows($result);
     $recent_topic_row = array();
     while ($row1 = $db->sql_fetchrow($result)) {
         $recent_topic_row[] = $row1;
     }
     $db->sql_freeresult($result);
     if ($cms_config_vars['md_recent_topics_style'][$block_id]) {
         $style_row = 'scroll';
     } else {
         $style_row = 'static';
     }
     $template->assign_block_vars($style_row, '');
     for ($i = 0; $i < $number_recent_topics; $i++) {
         $recent_topic_row[$i]['topic_title'] = censor_text($recent_topic_row[$i]['topic_title']);
         // Convert and clean special chars!
         $topic_title = htmlspecialchars_clean($recent_topic_row[$i]['topic_title']);
         $template->assign_block_vars($style_row . '.recent_topic_row', array('U_TITLE' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $recent_topic_row[$i]['forum_id'] . '&amp;' . POST_TOPIC_URL . '=' . $recent_topic_row[$i]['topic_id'] . '&amp;' . POST_POST_URL . '=' . $recent_topic_row[$i]['post_id']) . '#p' . $recent_topic_row[$i]['post_id'], 'L_TITLE' => $topic_title, 'L_BY' => $lang['By'], 'L_ON' => $lang['POSTED_ON'], 'S_POSTER' => colorize_username($recent_topic_row[$i]['user_id'], $recent_topic_row[$i]['username'], $recent_topic_row[$i]['user_color'], $recent_topic_row[$i]['user_active']), 'S_POSTTIME' => create_date_ip($config['default_dateformat'], $recent_topic_row[$i]['post_time'], $config['board_timezone'])));
     }
 }
Example #4
0
 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'])));
         }
     }
 }
Example #5
0
 function cms_block_new_downloads()
 {
     global $db, $cache, $config, $template, $theme, $lang, $table_prefix, $block_id, $cms_config_vars;
     $template->_tpldata['dlrow2.'] = array();
     $sql = "SELECT * FROM " . $table_prefix . "pa_files ORDER BY file_time DESC LIMIT 0," . $cms_config_vars['md_num_new_downloads'][$block_id];
     if (!($result = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, 'Could not query database for the most downloads');
     }
     $i = 1;
     while ($file_latest = $db->sql_fetchrow($result)) {
         $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2'];
         $template->assign_block_vars('dlrow2', array('NUMBER_LATEST' => strval($i), 'FILELINK_LATEST' => append_sid('dload.' . PHP_EXT . '?action=file&file_id=' . $file_latest['file_id']), 'ROW_CLASS' => $row_class, 'FILENAME_LATEST' => $file_latest['file_name'], 'DESCRIP_LATEST' => $file_latest['file_desc'], 'INFO_LATEST' => create_date_ip($config['default_dateformat'], $file_latest['file_time'], $config['board_timezone'])));
         $i++;
     }
 }
/**
*
* @Extra credits for this file
* Mohd - (mohdalbasri@hotmail.com)
*
*/
function display_comments(&$file_data)
{
    global $pafiledb, $pafiledb_config, $pafiledb_functions;
    global $db, $cache, $config, $template, $images, $user, $lang, $bbcode;
    @(include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
    @(include_once IP_ROOT_PATH . 'includes/functions_users.' . PHP_EXT);
    $template->assign_vars(array('L_COMMENTS' => $lang['Comments']));
    $sql = 'SELECT c.*, u.username, u.user_id, u.user_active, u.user_color, u.user_level, u.user_allow_viewemail, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_msnm, u.user_skype, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_from, u.user_from_flag, u.user_rank, u.user_rank2, u.user_rank3, u.user_rank4, u.user_rank5, u.user_birthday, u.user_gender, u.user_allow_viewonline, u.user_lastvisit, u.user_session_time, u.user_style, u.user_lang
		FROM ' . PA_COMMENTS_TABLE . ' AS c
			LEFT JOIN ' . USERS_TABLE . " AS u ON c.poster_id = u.user_id\n\t\tWHERE c.file_id = '" . $file_data['file_id'] . "'\n\t\tORDER BY c.comments_time ASC";
    $result = $db->sql_query($sql);
    if (!($comment_number = $db->sql_numrows($result))) {
        $template->assign_vars(array('L_NO_COMMENTS' => $lang['No_comments'], 'NO_COMMENTS' => true));
    }
    $ranks_array = $cache->obtain_ranks(false);
    while ($comments_row = $db->sql_fetchrow($result)) {
        $time = create_date_ip($config['default_dateformat'], $comments_row['comments_time'], $config['board_timezone']);
        $comments_text = $comments_row['comments_text'];
        $comments_text = comment_suite($comments_text);
        $comments_text = censor_text($comments_text);
        //bbcode parser Start
        $bbcode->allow_html = $pafiledb_config['allow_html'] ? true : false;
        $bbcode->allow_bbcode = $pafiledb_config['allow_bbcode'] ? true : false;
        $bbcode->allow_smilies = $pafiledb_config['allow_smilies'] ? true : false;
        $comments_text = $bbcode->parse($comments_text);
        //bbcode parser End
        $poster = $comments_row['user_id'] == ANONYMOUS ? $lang['Guest'] : colorize_username($comments_row['user_id'], $comments_row['username'], $comments_row['user_color'], $comments_row['user_active']);
        $user_info = array();
        $user_info = generate_user_info($comments_row);
        foreach ($user_info as $k => $v) {
            ${$k} = $v;
        }
        $poster_posts = $comments_row['user_id'] != ANONYMOUS ? $lang['Posts'] . ': ' . $comments_row['user_posts'] : '';
        $poster_from = $user_info['from'];
        $poster_joined = $user_info['joined'];
        $poster_avatar = $user_info['avatar'];
        // Mighty Gorgon - Multiple Ranks - BEGIN
        $user_ranks = generate_ranks($comments_row, $ranks_array);
        // Mighty Gorgon - Multiple Ranks - END
        $comments_text = str_replace("\n", "\n<br />\n", $comments_text);
        $template->assign_block_vars('text', array('POSTER' => $poster, 'U_COMMENT_DELETE' => $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_delete_comment'] && $file_info['user_id'] == $user->data['user_id'] || $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_mod'] ? append_sid('dload.' . PHP_EXT . "?action=post_comment&amp;cid={$comments_row['comments_id']}&amp;delete=do&amp;file_id={$file_data['file_id']}") : '', 'AUTH_COMMENT_DELETE' => $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_delete_comment'] && $file_info['user_id'] == $user->data['user_id'] || $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_mod'] ? true : false, 'DELETE_IMG' => $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_delete_comment'] && $file_info['user_id'] == $user->data['user_id'] || $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_mod'] ? $images['icon_delpost'] : '', 'ICON_MINIPOST_IMG' => IP_ROOT_PATH . $images['icon_minipost'], 'ICON_SPACER' => IP_ROOT_PATH . $images['spacer'], 'GENDER' => $user_info['gender'], 'USER_RANK_01' => $user_ranks['rank_01_html'], 'USER_RANK_01_IMG' => $user_ranks['rank_01_img_html'], 'USER_RANK_02' => $user_ranks['rank_02_html'], 'USER_RANK_02_IMG' => $user_ranks['rank_02_img_html'], 'USER_RANK_03' => $user_ranks['rank_03_html'], 'USER_RANK_03_IMG' => $user_ranks['rank_03_img_html'], 'USER_RANK_04' => $user_ranks['rank_04_html'], 'USER_RANK_04_IMG' => $user_ranks['rank_04_img_html'], 'USER_RANK_05' => $user_ranks['rank_05_html'], 'USER_RANK_05_IMG' => $user_ranks['rank_05_img_html'], 'POSTER_JOINED' => $poster_joined, 'POSTER_POSTS' => $poster_posts, 'POSTER_FROM' => $poster_from, 'POSTER_AVATAR' => $poster_avatar, 'TITLE' => $comments_row['comments_title'], 'TIME' => $time, 'TEXT' => $comments_text));
    }
    $db->sql_freeresult($result);
    $template->assign_vars(array('REPLY_IMG' => $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_post_comment'] ? $images['pa_comment_post'] : '', 'AUTH_POST' => $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_post_comment'] ? true : false, 'L_COMMENT_DO' => $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_post_comment'] ? $lang['Comment_do'] : '', 'L_COMMENTS' => $lang['Comments'], 'L_AUTHOR' => $lang['Author'], 'L_POSTED' => $lang['Posted'], 'L_COMMENT_SUBJECT' => $lang['Comment_subject'], 'L_COMMENT_ADD' => $lang['Comment_add'], 'L_COMMENT_DELETE' => $lang['Comment_delete'], 'L_COMMENTS_NAME' => $lang['Name'], 'L_BACK_TO_TOP' => $lang['Back_to_top'], 'SPACER' => $images['spacer'], 'U_COMMENT_DO' => append_sid('dload.' . PHP_EXT . '?action=post_comment&amp;file_id=' . $file_data['file_id'])));
}
Example #7
0
			$first_post_time = create_date_ip($config['default_dateformat'], $topic_rowset[$i]['topic_time'], $config['board_timezone']);
			//$first_post_author = ($topic_rowset[$i]['topic_starter_id'] == ANONYMOUS) ? (($topic_rowset[$i]['topic_starter_guest'] != '') ? $topic_rowset[$i]['topic_starter_guest'] . ' ' : $lang['Guest'] . ' ') : '<a href="' . append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $topic_rowset[$i]['topic_starter_id']) . '">' . $topic_rowset[$i]['topic_starter'] . '</a> ';
			$first_post_author =  colorize_username($topic_rowset[$i]['topic_starter_id'], $topic_rowset[$i]['topic_starter'], $topic_rowset[$i]['topic_starter_color'], $topic_rowset[$i]['topic_starter_active']);

			$first_post_url = ($type == 'shadow') ? '' : '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id) . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';

			$last_post_time = create_date_ip($config['default_dateformat'], $topic_rowset[$i]['post_time'], $config['board_timezone']);
			//$last_post_author = ($topic_rowset[$i]['user_id'] == ANONYMOUS) ? (($topic_rowset[$i]['post_username'] != '') ? $topic_rowset[$i]['post_username'] . ' ' : $lang['Guest'] . ' ') : '<a href="' . append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $topic_rowset[$i]['user_id']) . '">' . $topic_rowset[$i]['username'] . '</a> ';
			$last_post_author =  colorize_username($topic_rowset[$i]['user_id'], $topic_rowset[$i]['username'], $topic_rowset[$i]['user_color'], $topic_rowset[$i]['user_active']);
			$last_post_url = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $topic_rowset[$i]['topic_last_post_id']) . '#p' . $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';

			$u_view_topic = 'modcp.' . PHP_EXT . '?mode=split&amp;' . POST_TOPIC_URL . '=' . $topic_id . '&amp;sid=' . $user->data['session_id'];
			$topic_replies = $topic_rowset[$i]['topic_replies'];

			$last_post_time = create_date_ip($config['default_dateformat'], $topic_rowset[$i]['post_time'], $config['board_timezone']);

			$template->assign_block_vars('topicrow', array(
				'U_VIEW_TOPIC' => $u_view_topic,
				'TOPIC_ID' => $topic_id,
				'TOPIC_FOLDER_IMG' => $topic_link['image'],
				'L_TOPIC_FOLDER_ALT' => $topic_link['image_alt'],
				'TOPIC_AUTHOR' => $topic_author,
				'TOPIC_TITLE' => $topic_title,
				'TOPIC_TYPE' => $topic_link['type'],
				'TOPIC_TYPE_ICON' => $topic_link['icon'],
				'TOPIC_CLASS' => (!empty($topic_link['class_new']) ? ('topiclink' . $topic_link['class_new']) : $topic_link['class']),
				'CLASS_NEW' => $topic_link['class_new'],
				'NEWEST_POST_IMG' => $topic_link['newest_post_img'],
				'GOTO_PAGE' => $topic_pagination['base'],
				'GOTO_PAGE_FULL' => $topic_pagination['full'],
function album_build_last_comments_info($cats)
{
    global $db, $cache, $config, $template, $user, $lang, $bbcode, $album_config, $album_data;
    @(include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
    $number_of_comments = 5;
    $album_show_pic_url = 'album_showpage.' . PHP_EXT;
    if ($cats == '') {
        $sql_where = '';
    } else {
        $sql_where = 'WHERE a.pic_cat_id IN (' . $cats . ')';
    }
    //$sql_group = 'GROUP BY c.comment_pic_id';
    $sql_group = '';
    // get last comment information, and user, comment and pic informations
    $sql = "SELECT c.*, u.user_id, u.username, u.user_active, u.user_color, a.*\n\t\tFROM " . ALBUM_COMMENT_TABLE . " AS c\n\t\tLEFT JOIN " . USERS_TABLE . " AS u ON c.comment_user_id = u.user_id\n\t\tLEFT JOIN " . ALBUM_TABLE . " AS a ON c.comment_pic_id = a.pic_id\n\t\t{$sql_where}\n\t\t{$sql_group}\n\t\tORDER BY c.comment_id DESC\n\t\tLIMIT {$number_of_comments}";
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $commentsrow[] = $row;
    }
    $db->sql_freeresult($result);
    if (sizeof($commentsrow) > 0) {
        $template->assign_block_vars('recent_comments_block', array('L_COMMENTS' => $lang['Comments'], 'L_LAST_COMMENT' => $lang['Last_Comment'], 'L_LAST_COMMENT_INFO' => $lang['Last_Comments']));
        for ($i = 0; $i < sizeof($commentsrow); $i++) {
            if ($commentsrow[$i]['comment_username'] == ALBUM_GUEST || $commentsrow[$i]['comment_username'] == '') {
                $poster = $commentsrow[$i]['comment_username'] == '' ? $lang['Guest'] : $commentsrow[$i]['comment_username'];
            } else {
                $poster = colorize_username($commentsrow[$i]['user_id'], $commentsrow[$i]['username'], $commentsrow[$i]['user_color'], $commentsrow[$i]['user_active']);
            }
            $info .= '<br />' . $lang['Pic_Image'] . ': <a href="' . append_sid(album_append_uid($album_show_pic_url . '?pic_id=' . $commentsrow[$i]['pic_id'])) . '">' . $commentsrow[$i]['pic_title'] . '</a>';
            $pic_preview = '';
            $pic_preview_hs = '';
            if ($album_config['lb_preview']) {
                $slideshow_cat = '';
                $slideshow = !empty($slideshow_cat) ? ', { slideshowGroup: \'' . $slideshow_cat . '\' } ' : '';
                $pic_preview_hs = ' class="highslide" onclick="return hs.expand(this' . $slideshow . ');"';
                $pic_preview = 'onmouseover="showtrail(\'' . append_sid(album_append_uid('album_picm.' . PHP_EXT . '?pic_id=' . $commentsrow[$i]['pic_id'])) . '\',\'' . addslashes($commentsrow[$i]['pic_title']) . '\', ' . $album_config['midthumb_width'] . ', ' . $album_config['midthumb_height'] . ')" onmouseout="hidetrail()"';
            }
            $commentsrow[$i]['comment_text'] = censor_text($commentsrow[$i]['comment_text']);
            $html_on = $user->data['user_allowhtml'] && $config['allow_html'] ? 1 : 0;
            $bbcode_on = $user->data['user_allowbbcode'] && $config['allow_bbcode'] ? 1 : 0;
            $smilies_on = $user->data['user_allowsmile'] && $config['allow_smilies'] ? 1 : 0;
            $bbcode->allow_html = $html_on;
            $bbcode->allow_bbcode = $bbcode_on;
            $bbcode->allow_smilies = $smilies_on;
            $commentsrow[$i]['comment_text'] = $bbcode->parse($commentsrow[$i]['comment_text']);
            $commentsrow[$i]['comment_text'] = strtr($commentsrow[$i]['comment_text'], array_flip(get_html_translation_table(HTML_ENTITIES)));
            $commentsrow[$i]['comment_text'] = $bbcode->acronym_pass($commentsrow[$i]['comment_text']);
            $commentsrow[$i]['comment_text'] = $bbcode->autolink_text($commentsrow[$i]['comment_text'], '999999');
            $template_vars = array('POSTER' => $poster, 'PIC_PREVIEW_HS' => $pic_preview_hs, 'PIC_PREVIEW' => $pic_preview, 'COMMENT_TEXT' => $commentsrow[$i]['comment_text'], 'GROUP_NAME' => 'comments');
            album_build_detail_vars($template_vars, $commentsrow[$i]);
            // Overwrite the picture time with the comment time
            $template_vars['TIME'] = create_date_ip($config['default_dateformat'], $commentsrow[$i]['comment_time'], $config['board_timezone']);
            $template->assign_block_vars('recent_comments_block.comment_row', $template_vars);
        }
    }
}
	$reg_length = $row['reg_length'];

	$reg_max_option1 = $row['topic_reg_max_option1'];
	$reg_max_option2 = $row['topic_reg_max_option2'];
	$reg_max_option3 = $row['topic_reg_max_option3'];

	$self_registered = 0;

	for($u = 0; $u < $numregs; $u++)
	{
		if ($reg_info[$u]['user_id'] == $user->data['user_id'])
		{
			$self_registered = $reg_info[$u]['registration_status'];
		}
		$current_user = colorize_username($reg_info[$u]['user_id'], $reg_info[$u]['username'], $reg_info[$u]['user_color'], $reg_info[$u]['user_active']);
		$user_registered = create_date_ip($config['default_dateformat'], $reg_info[$u]['registration_time'], $config['board_timezone']);
		$reg_option_data = '<tr><td><span class="gensmall">' . $current_user . '</span></td><td class="gensmall">' . $user_registered . '</td></tr>';
		if ($reg_info[$u]['registration_status'] == REG_OPTION1)
		{
			$option1_count++;
			$template->assign_block_vars('reg_option1_users', array(
				'USER' => $current_user,
				'DATE' => $user_registered,
				)
			);
			$reg_option1_data .= $reg_option_data;
		}
		elseif ($reg_info[$u]['registration_status'] == REG_OPTION2)
		{
			$option2_count++;
			$template->assign_block_vars('reg_option2_users', array(
Example #10
0
		}

		$message = str_replace('<', '&lt;', $message);
		$message = str_replace('>', '&gt;', $message);
		$message = str_replace('<br />', "\n", $message);

		if ($mode == 'quote')
		{
			if(preg_match('/\[hide/i', $message))
			{
				$search = array("/\[hide\](.*?)\[\/hide\]/");
				$replace = array('[hide]' . $lang['xs_bbc_hide_quote_message'] . '[/hide]');
				$message = preg_replace($search, $replace, $message);
			}

			$msg_date = create_date_ip($config['default_dateformat'], $postrow['post_time'], $config['board_timezone']);

			// Use trim to get rid of spaces placed there by MS-SQL 2000
			$quote_username = (trim($post_info['post_username']) != '') ? $post_info['post_username'] : $post_info['username'];
			//$message = '[quote="' . $quote_username . '"]' . $message . '[/quote]';
			$message = '[quote user="******" post="' . $post_id . '"]' . $message . '[/quote]';

			$subject = censor_text($subject);
			$message = censor_text($message);

			$subject = (((strlen($subject) > 0) && ((substr($subject, 0, strlen($lang['REPLY_PREFIX'])) == $lang['REPLY_PREFIX']) || (substr($subject, 0, strlen($lang['REPLY_PREFIX']))) == $lang['REPLY_PREFIX_OLD'])) ? '' : $lang['REPLY_PREFIX']) . $subject;
			$mode = 'reply';
		}
		else
		{
			$username = ($post_info['user_id'] == ANONYMOUS && !empty($post_info['post_username'])) ? $post_info['post_username'] : '';
Example #11
0
 function create_view_page(&$table_fields, &$inputs_array, $items_row, $template_row = 'field')
 {
     global $config, $template, $theme, $lang, $bbcode;
     $row_class = '';
     foreach ($table_fields as $k => $v) {
         $inputs_array[$k] = isset($items_row[$k]) ? $items_row[$k] : $v['default'];
         // We convert HTML entities only if we do not need to parse HTML...
         if (is_string($inputs_array[$k]) && !empty($v['html_parse'])) {
             $value = htmlspecialchars_decode($inputs_array[$k], ENT_COMPAT);
         }
         $auth_level = $v['view_level'];
         $is_auth = check_auth_level($auth_level);
         if ($is_auth) {
             $value = $inputs_array[$k];
             $s_bbcb = !empty($v['bbcode_box']) ? true : false;
             // SPECIAL PROCESSING - BEGIN
             // Convert back values from RADIO, SELECT or CHECKBOX
             if (in_array($v['type'], array('LIST_CHECKBOX', 'LIST_DROP', 'LIST_FLAGS', 'LIST_RADIO', 'LIST_RADIO_BR'))) {
                 $tmp_value = $this->get_lang_from_value($inputs_array[$k], $v['values']);
                 $value = $tmp_value != '' ? $tmp_value : $value;
             }
             // Convert empty numbers fields to 0
             if (!empty($v['is_number']) && empty($value)) {
                 $value = (int) 0;
             }
             // Apply number format if needed
             if (!empty($v['number_format'])) {
                 $v['number_format']['decimals'] = isset($v['number_format']['decimals']) ? $v['number_format']['decimals'] : (isset($lang['NUMBER_FORMAT_DECIMALS']) ? $lang['NUMBER_FORMAT_DECIMALS'] : 0);
                 $v['number_format']['decimals_sep'] = !empty($v['number_format']['decimals_sep']) ? $v['number_format']['decimals_sep'] : (isset($lang['NUMBER_FORMAT_DECIMALS_SEP']) ? $lang['NUMBER_FORMAT_DECIMALS_SEP'] : ',');
                 $v['number_format']['thousands_sep'] = !empty($v['number_format']['thousands_sep']) ? $v['number_format']['thousands_sep'] : (isset($lang['NUMBER_FORMAT_THOUSANDS_SEP']) ? $lang['NUMBER_FORMAT_THOUSANDS_SEP'] : '.');
                 $value = number_format($inputs_array[$k], $v['number_format']['decimals'], $v['number_format']['decimals_sep'], $v['number_format']['thousands_sep']);
             }
             // Create rating image
             if (!empty($v['is_rating'])) {
                 $rating = $value;
                 $rating_path = !empty($v['rating_path']) ? $v['rating_path'] : IP_ROOT_PATH . 'images/rates/';
                 $rating_min = !empty($v['rating_min']) ? $v['rating_min'] : 0;
                 $rating_max = !empty($v['rating_max']) ? $v['rating_max'] : 10;
                 $rating_extension = !empty($v['rating_extension']) ? $v['rating_extension'] : 'png';
                 $value = '<img src="' . $this->build_rating_image($rating, $rating_path, $rating_min, $rating_max, $rating_extension) . '" alt="' . $rating . '" title="' . $rating . '" />';
             }
             // Text processing... BBCode, HTML or plain text
             if ($s_bbcb || !empty($v['bbcode_parse'])) {
                 $value = $bbcode->parse($inputs_array[$k]);
             } else {
                 if (empty($v['html_parse']) && in_array($v['type'], array('TEXT', 'HTMLTEXT'))) {
                     $value = nl2br($inputs_array[$k]);
                 }
             }
             // Convert dates and times
             $v['datetime_format'] = !empty($v['datetime_format']) ? $v['datetime_format'] : 'unix';
             switch ($v['datetime_format']) {
                 case 'mysql':
                     $output = !empty($v['is_date']) ? 'date' : (!empty($v['is_time']) ? 'time' : 'datetime');
                     $value = format_date_mysql_php($inputs_array[$k], $output, 'php');
                     break;
                 default:
                     if (!empty($v['is_time'])) {
                         $value = create_date_ip($config['default_dateformat'], $inputs_array[$k], $config['board_timezone']);
                     }
                     if (!empty($v['is_date'])) {
                         $value = create_date($this->date_format_php, $inputs_array[$k], $config['board_timezone']);
                     }
                     break;
             }
             // Create user link (with user_id)
             if ($v['is_user_id']) {
                 $value = colorize_username($inputs_array[$k]);
             }
             // Create user link (with username)
             if ($v['is_username']) {
                 $target_userid = $this->get_user_id($inputs_array[$k]);
                 $value = colorize_username($target_userid);
             }
             // Create user link (with username)
             if ($v['type'] == 'PASSWORD') {
                 $value = '********';
             }
             // Create thumbnails for images
             if ($v['is_image']) {
                 $value = '<a href="' . append_sid($inputs_array[$k]) . '"><img src="' . append_sid(CMS_PAGE_IMAGE_THUMBNAIL . '?pic_id=' . urlencode($inputs_array[$k]) . (isset($v['thumbnail_size']) ? '&amp;thumbnail_size=' . intval($v['thumbnail_size']) : '')) . '" alt="" /></a>';
             }
             if (!empty($v['display_func']) && function_exists($v['display_func'])) {
                 $value = $v['display_func']($inputs_array[$k]);
             }
             // SPECIAL PROCESSING - END
             $row_class = ip_zebra_rows($row_class);
             $template_row = empty($template_row) ? 'field' : (string) $template_row;
             $template->assign_block_vars($template_row, array('CLASS' => $row_class, 'L_NAME' => $this->get_lang($v['lang_key']), 'L_EXPLAIN' => !empty($v['explain']) ? $this->get_lang($v['explain']) : '', 'S_BBCB' => $s_bbcb ? true : false, 'VALUE' => !empty($value) || $value === 0 ? $value : '&nbsp;'));
         }
     }
 }
Example #12
0
	// SELF AUTH - BEGIN
	// Comment the lines below if you wish to show RESERVED topics for AUTH_SELF.
	/*
	if ((($user->data['user_level'] != ADMIN) && ($user->data['user_level'] != MOD)) && (intval($is_auth_ary[$line[$i]['forum_id']]['auth_read']) == AUTH_SELF) && ($line[$i]['first_poster_id'] != $user->data['user_id']))
	{
		$first_author = $lang['Reserved_Author'];
		$last_author = $lang['Reserved_Author'];
		$topic_title = $lang['Reserved_Topic'];
	}
	*/
	// SELF AUTH - END

	if($mode == 'utview')
	{
		$last_time = $last_time = create_date_ip($config['default_dateformat'], $line[$i]['view_time'], $config['board_timezone']);;
		$last_author = '';
		$last_url = '';
	}

	$template->assign_block_vars('recent', array(
		'ROW_CLASS' => (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2'],

		'TOPIC_ID' => $topic_id,
		'TOPIC_FOLDER_IMG' => $topic_link['image'],
		'L_TOPIC_FOLDER_ALT' => $topic_link['image_alt'],
		'TOPIC_TITLE' => $topic_title,
		'TOPIC_TITLE_PLAIN' => $topic_title_plain,
		'TOPIC_TYPE' => $topic_link['type'],
		'TOPIC_TYPE_ICON' => $topic_link['icon'],
		'TOPIC_CLASS' => (!empty($topic_link['class_new']) ? ('topiclink' . $topic_link['class_new']) : $topic_link['class']),
Example #13
0
 function cms_block_album()
 {
     global $db, $cache, $config, $template, $theme, $images, $user, $lang, $table_prefix, $block_id, $cms_config_vars, $cms_config_layouts, $cms_page, $album_config;
     $cms_page_id_tmp = 'album';
     $cms_auth_level_tmp = isset($cms_config_layouts[$cms_page_id_tmp]['view']) ? $cms_config_layouts[$cms_page_id_tmp]['view'] : AUTH_ALL;
     $process_block = check_page_auth($cms_page_id_tmp, $cms_auth_level_tmp, true);
     if (!$process_block) {
         return;
     }
     if (!defined('IMG_THUMB')) {
         define('IMG_THUMB', true);
     }
     $template->_tpldata['recent_pics.'] = array();
     $template->_tpldata['recent_details.'] = array();
     $template->_tpldata['no_pics'] = array();
     /*
     echo($cms_config_vars['md_pics_all'][$block_id] . '<br />');
     echo($cms_config_vars[$block_id . '_' . 'md_pics_all']);
     exit;
     */
     include_once ALBUM_MOD_PATH . 'album_common.' . PHP_EXT;
     global $album_config;
     $sql = "SELECT c.*, COUNT(p.pic_id) AS count\n\t\t\t\tFROM " . ALBUM_CAT_TABLE . " AS c\n\t\t\t\t\tLEFT JOIN " . ALBUM_TABLE . " AS p ON c.cat_id = p.pic_cat_id\n\t\t\t\t" . ($cms_config_vars['md_pics_all'][$block_id] == '1' ? '' : 'WHERE cat_user_id = 0') . "\n\t\t\t\tGROUP BY cat_id\n\t\t\t\tORDER BY cat_order ASC";
     $result = $db->sql_query($sql);
     $catrows = array();
     while ($row = $db->sql_fetchrow($result)) {
         $album_user_access = album_user_access($row['cat_id'], $row, 1, 0, 0, 0, 0, 0);
         // VIEW
         if ($album_user_access['view'] == 1) {
             $catrows[] = $row;
         }
     }
     $db->sql_freeresult($result);
     if ($cms_config_vars['md_pics_all'][$block_id] == '1') {
         $allowed_cat = '0';
         // For Recent Public Pics below
     } else {
         $allowed_cat = '';
     }
     // $catrows now stores all categories which this user can view. Dump them out!
     for ($i = 0; $i < sizeof($catrows); $i++) {
         // Build allowed category-list (for recent pics after here)
         $allowed_cat .= $allowed_cat == '' ? $catrows[$i]['cat_id'] : ',' . $catrows[$i]['cat_id'];
         // Get Last Pic of this Category
         if ($catrows[$i]['count'] == 0) {
             //
             // Oh, this category is empty
             //
             $last_pic_info = $lang['No_Pics'];
             $u_last_pic = '';
             $last_pic_title = '';
         } else {
             // Check Pic Approval
             if ($catrows[$i]['cat_approval'] == ALBUM_ADMIN || $catrows[$i]['cat_approval'] == ALBUM_MOD) {
                 $pic_approval_sql = 'AND p.pic_approval = 1';
                 // Pic Approval ON
             } else {
                 $pic_approval_sql = '';
                 // Pic Approval OFF
             }
         }
     }
     if ($cms_config_vars['md_pics_all'][$block_id] == '1') {
         $pics_allowed = '0';
     } else {
         $pics_allowed = '';
     }
     $no_pics = false;
     if ($allowed_cat != $pics_allowed) {
         $category_id = $cms_config_vars['md_cat_id'][$block_id];
         if ($cms_config_vars['md_pics_sort'][$block_id] == '1') {
             if ($category_id != 0) {
                 $sql = "SELECT p.*, u.user_id, u.username, u.user_active, u.user_color, r.rate_pic_id, AVG(r.rate_point) AS rating, COUNT(DISTINCT c.comment_id) AS comments\n\t\t\t\t\t\tFROM " . ALBUM_TABLE . " AS p\n\t\t\t\t\t\t\tLEFT JOIN " . USERS_TABLE . " AS u ON p.pic_user_id = u.user_id\n\t\t\t\t\t\t\tLEFT JOIN " . ALBUM_CAT_TABLE . " AS ct ON p.pic_cat_id = ct.cat_id\n\t\t\t\t\t\t\tLEFT JOIN " . ALBUM_RATE_TABLE . " AS r ON p.pic_id = r.rate_pic_id\n\t\t\t\t\t\t\tLEFT JOIN " . ALBUM_COMMENT_TABLE . " AS c ON p.pic_id = c.comment_pic_id\n\t\t\t\t\t\tWHERE p.pic_cat_id IN ({$allowed_cat}) AND (p.pic_approval = 1 OR ct.cat_approval = 0) AND pic_cat_id IN ({$category_id})\n\t\t\t\t\t\tGROUP BY p.pic_id\n\t\t\t\t\t\tORDER BY RAND()\n\t\t\t\t\t\tLIMIT " . $cms_config_vars['md_pics_number'][$block_id];
             } else {
                 $sql = "SELECT p.*, u.user_id, u.username, u.user_active, u.user_color, r.rate_pic_id, AVG(r.rate_point) AS rating, COUNT(DISTINCT c.comment_id) AS comments\n\t\t\t\t\t\tFROM " . ALBUM_TABLE . " AS p\n\t\t\t\t\t\t\tLEFT JOIN " . USERS_TABLE . " AS u ON p.pic_user_id = u.user_id\n\t\t\t\t\t\t\tLEFT JOIN " . ALBUM_CAT_TABLE . " AS ct ON p.pic_cat_id = ct.cat_id\n\t\t\t\t\t\t\tLEFT JOIN " . ALBUM_RATE_TABLE . " AS r ON p.pic_id = r.rate_pic_id\n\t\t\t\t\t\t\tLEFT JOIN " . ALBUM_COMMENT_TABLE . " AS c ON p.pic_id = c.comment_pic_id\n\t\t\t\t\t\tWHERE p.pic_cat_id IN ({$allowed_cat}) AND (p.pic_approval = 1 OR ct.cat_approval = 0)\n\t\t\t\t\t\tGROUP BY p.pic_id\n\t\t\t\t\t\tORDER BY RAND()\n\t\t\t\t\t\tLIMIT " . $cms_config_vars['md_pics_number'][$block_id];
             }
         } elseif ($cms_config_vars['md_pics_sort'][$block_id] == '0') {
             if ($category_id != 0) {
                 $sql = "SELECT p.*, u.user_id, u.username, u.user_active, u.user_color, r.rate_pic_id, AVG(r.rate_point) AS rating, COUNT(DISTINCT c.comment_id) AS comments\n\t\t\t\t\t\tFROM " . ALBUM_TABLE . " AS p\n\t\t\t\t\t\t\tLEFT JOIN " . USERS_TABLE . " AS u ON p.pic_user_id = u.user_id\n\t\t\t\t\t\t\tLEFT JOIN " . ALBUM_CAT_TABLE . " AS ct ON p.pic_cat_id = ct.cat_id\n\t\t\t\t\t\t\tLEFT JOIN " . ALBUM_RATE_TABLE . " AS r ON p.pic_id = r.rate_pic_id\n\t\t\t\t\t\t\tLEFT JOIN " . ALBUM_COMMENT_TABLE . " AS c ON p.pic_id = c.comment_pic_id\n\t\t\t\t\t\tWHERE p.pic_cat_id IN ({$allowed_cat}) AND (p.pic_approval = 1 OR ct.cat_approval = 0) AND pic_cat_id IN ({$category_id})\n\t\t\t\t\t\tGROUP BY p.pic_id\n\t\t\t\t\t\tORDER BY pic_time DESC\n\t\t\t\t\t\tLIMIT " . $cms_config_vars['md_pics_number'][$block_id];
             } else {
                 $sql = "SELECT p.*, u.user_id, u.username, u.user_active, u.user_color, r.rate_pic_id, AVG(r.rate_point) AS rating, COUNT(DISTINCT c.comment_id) AS comments\n\t\t\t\t\t\tFROM " . ALBUM_TABLE . " AS p\n\t\t\t\t\t\t\tLEFT JOIN " . USERS_TABLE . " AS u ON p.pic_user_id = u.user_id\n\t\t\t\t\t\t\tLEFT JOIN " . ALBUM_CAT_TABLE . " AS ct ON p.pic_cat_id = ct.cat_id\n\t\t\t\t\t\t\tLEFT JOIN " . ALBUM_RATE_TABLE . " AS r ON p.pic_id = r.rate_pic_id\n\t\t\t\t\t\t\tLEFT JOIN " . ALBUM_COMMENT_TABLE . " AS c ON p.pic_id = c.comment_pic_id\n\t\t\t\t\t\tWHERE p.pic_cat_id IN ({$allowed_cat}) AND (p.pic_approval = 1 OR ct.cat_approval = 0)\n\t\t\t\t\t\tGROUP BY p.pic_id\n\t\t\t\t\t\tORDER BY pic_time DESC\n\t\t\t\t\t\tLIMIT " . $cms_config_vars['md_pics_number'][$block_id];
             }
         }
         $result = $db->sql_query($sql);
         $recentrow = array();
         while ($row = $db->sql_fetchrow($result)) {
             $recentrow[] = $row;
         }
         $db->sql_freeresult($result);
         $total_pics = sizeof($recentrow);
         if ($total_pics > 0) {
             $total_rows = ceil($total_pics / $cms_config_vars['md_pics_rows_number'][$block_id]);
             $total_cols = ceil($total_pics / $cms_config_vars['md_pics_cols_number'][$block_id]);
             $image_counter = 0;
             while ($image_counter < $total_pics) {
                 for ($i = 0; $i < $cms_config_vars['md_pics_rows_number'][$block_id]; $i++) {
                     $template->assign_block_vars('recent_pics', array());
                     for ($j = 0; $j < $cms_config_vars['md_pics_cols_number'][$block_id]; $j++) {
                         if ($image_counter >= $total_pics) {
                             $template->assign_block_vars('recent_pics.recent_no_detail', array());
                         } else {
                             if (!$recentrow[$image_counter]['rating']) {
                                 $recentrow[$image_counter]['rating'] = $lang['Not_rated'];
                             } else {
                                 $recentrow[$image_counter]['rating'] = round($recentrow[$image_counter]['rating'], 2);
                             }
                             if ($recentrow[$image_counter]['user_id'] == ALBUM_GUEST || $recentrow[$image_counter]['username'] == '') {
                                 $recent_poster = $recentrow[$image_counter]['pic_username'] == '' ? $lang['Guest'] : $recentrow[$image_counter]['pic_username'];
                             } else {
                                 $recent_poster = colorize_username($recentrow[$image_counter]['user_id'], $recentrow[$image_counter]['username'], $recentrow[$image_counter]['user_color'], $recentrow[$image_counter]['user_active']);
                             }
                             $thumbnail_file = append_sid(album_append_uid('album_thumbnail.' . PHP_EXT . '?pic_id=' . $recentrow[$image_counter]['pic_id']));
                             if ($album_config['thumbnail_cache'] == true && $album_config['quick_thumbs'] == true) {
                                 $thumbnail_file = picture_quick_thumb($recentrow[$image_counter]['pic_filename'], $recentrow[$image_counter]['pic_thumbnail'], $thumbnail_file);
                             }
                             $pic_sp_link = append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $recentrow[$image_counter]['pic_id']));
                             $pic_dl_link = append_sid(album_append_uid('album_pic.' . PHP_EXT . '?pic_id=' . $recentrow[$image_counter]['pic_id']));
                             $template->assign_block_vars('recent_pics.recent_detail', array('U_PIC' => $album_config['fullpic_popup'] ? $pic_dl_link : $pic_sp_link, 'U_PIC_SP' => $pic_sp_link, 'U_PIC_DL' => $pic_dl_link, 'IS_FIRST_PIC' => $image_counter == 0 ? true : false, 'THUMBNAIL' => $thumbnail_file, 'DESC' => $recentrow[$image_counter]['pic_desc'], 'TITLE' => $recentrow[$image_counter]['pic_title'], 'POSTER' => $recent_poster, 'TIME' => create_date_ip($config['default_dateformat'], $recentrow[$image_counter]['pic_time'], $config['board_timezone']), 'VIEW' => $recentrow[$image_counter]['pic_view_count'], 'RATING' => $album_config['rate'] == 1 ? $lang['Rating'] . ': ' . $recentrow[$image_counter]['rating'] . '<br />' : '', 'COMMENTS' => $album_config['comment'] == 1 ? $lang['Comments'] . ': ' . $recentrow[$image_counter]['comments'] . '<br />' : ''));
                             if ($image_counter == 0) {
                                 $template->assign_vars(array('HS_GALLERY_ID' => 'hs_gallery_id_' . $recentrow[$image_counter]['pic_id'], 'HS_PIC_ID' => 'hs_pic_id_' . $recentrow[$image_counter]['pic_id'], 'HS_PIC_TITLE' => $recentrow[$image_counter]['pic_title'], 'HS_PIC_FULL' => $pic_dl_link, 'HS_PIC_THUMB' => $thumbnail_file));
                             }
                         }
                         $image_counter++;
                     }
                 }
             }
         } else {
             // No Pics Found
             $template->assign_block_vars('no_pics', array());
             $no_pics = true;
         }
     } else {
         // No Cats Found
         $template->assign_block_vars('no_pics', array());
         $no_pics = true;
     }
     $template->assign_vars(array('S_COL_WIDTH' => 100 / ($cms_config_vars['md_pics_cols_number'][$block_id] == 0 ? 4 : $cms_config_vars['md_pics_cols_number'][$block_id]) . '%', 'S_THUMBNAIL_SIZE' => $album_config['thumbnail_size'], 'TARGET_BLANK' => $album_config['fullpic_popup'] ? 'target="_blank"' : '', 'S_HIGHSLIDE' => !empty($config['thumbnail_highslide']) ? true : false, 'S_HIGHSLIDER' => !empty($cms_config_vars['md_pics_slider'][$block_id]) ? true : false, 'S_JQ_NIVO_SLIDER' => !empty($cms_config_vars['md_pics_slider'][$block_id]) ? true : false, 'S_SLIDER_ID' => 'cms_slider_' . $block_id, 'S_NO_PICS' => !empty($no_pics) ? true : false, 'L_NO_PICS' => $lang['No_Pics'], 'L_PIC_TITLE' => $lang['Pic_Title'], 'L_VIEW' => $lang['View'], 'L_POSTER' => $lang['Poster'], 'L_POSTED' => $lang['Posted'], 'U_ALBUM' => append_sid('album.' . PHP_EXT), 'L_ALBUM' => $lang['Album']));
 }
     $bbcode->allow_bbcode = $config['allow_bbcode'] ? true : false;
     $bbcode->allow_smilies = $config['allow_smilies'] ? true : false;
     $pic_desc = $bbcode->parse($pic_desc);
 } else {
     $pic_desc = nl2br(htmlspecialchars($pic_desc));
 }
 $pic_sp_link = append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $thispic['pic_id']));
 $pic_dl_link = append_sid(album_append_uid('album_pic.' . PHP_EXT . '?pic_id=' . $thispic['pic_id']));
 $pic_full_set = $picm == false || $nuff_display == true ? true : false;
 $user_info = array();
 $user_info = generate_user_info($thispic);
 foreach ($user_info as $k => $v) {
     ${$k} = $v;
 }
 $poster_avatar = $user_info['avatar'];
 $template->assign_vars(array('CAT_TITLE' => $thispic['cat_title'], 'U_VIEW_CAT' => append_sid(album_append_uid('album_cat.' . PHP_EXT . '?cat_id=' . $cat_id)), 'ALBUM_NAVIGATION_ARROW' => ALBUM_NAV_ARROW, 'NAV_CAT_DESC' => $album_nav_cat_desc, 'EDIT' => $auth_data['moderator'] || $user->data['user_id'] == $thispic['pic_user_id'] ? '<a href="' . append_sid(album_append_uid('album_edit.' . PHP_EXT . '?pic_id=' . $thispic['pic_id'])) . '">' . $edit_link_content . '</a>' : '', 'DELETE' => $auth_data['moderator'] || $user->data['user_id'] == $thispic['pic_user_id'] ? '<a href="' . append_sid(album_append_uid('album_delete.' . PHP_EXT . '?pic_id=' . $thispic['pic_id'])) . '">' . $delete_link_content . '</a>' : '', 'LOCK' => $auth_data['moderator'] ? '<a href="' . append_sid(album_append_uid('album_modcp.' . PHP_EXT . '?mode=' . ($thispic['pic_lock'] == 0 ? 'lock' : 'unlock') . '&amp;pic_id=' . $thispic['pic_id'])) . '">' . $lock_link_content . '</a>' : '', 'MOVE' => $auth_data['moderator'] ? '<a href="' . append_sid(album_append_uid('album_modcp.' . PHP_EXT . '?mode=move&amp;pic_id=' . $thispic['pic_id'])) . '">' . $move_link_content . '</a>' : '', 'COPY' => $auth_data['moderator'] ? '<a href="' . append_sid(album_append_uid('album_modcp.' . PHP_EXT . '?mode=copy&amp;pic_id=' . $thispic['pic_id'])) . '">' . $copy_link_content . '</a>' : '', 'U_PIC_FULL_URL' => $server_url . $pic_fullpath, 'U_PIC' => $pic_link, 'U_PIC_SP' => $pic_sp_link, 'U_PIC_DL' => $pic_dl_link, 'U_PIC_L1' => $pic_full_set ? '' : '<a href="' . append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?full=true&amp;pic_id=' . $pic_id . $sort_append . $nuffimage_vars)) . '">', 'U_PIC_L2' => $pic_full_set ? '' : '</a>', 'U_PIC_CLICK' => $pic_full_set ? '' : $lang['Click_enlarge'], 'U_PIC_THUMB' => append_sid(album_append_uid('album_thumbnail.' . PHP_EXT . '?pic_id=' . $pic_id . $sort_append)), 'U_SMILEY_CREATOR' => append_sid('smiley_creator.' . PHP_EXT . '?mode=text2shield'), 'PIC_COUNT' => sprintf($lang['Pics_Counter'], $new_pic_array_id + 1, $total_pic_count), 'NEXT_PIC' => $next_pic, 'PREV_PIC' => $prev_pic, 'L_PIC_DETAILS' => $lang['Pic_Details'], 'L_PIC_SIZE' => $lang['Pic_Size'], 'L_PIC_TYPE' => $lang['Pic_Type'], 'PIC_HEIGHT' => $pic_full_set ? $pic_height : $album_config['midthumb_height'], 'PIC_WIDTH' => $pic_full_set ? $pic_width : $album_config['midthumb_width'], 'PIC_SIZE' => $pic_width . ' x ' . $pic_height . ' (' . intval($pic_filesize / 1024) . 'KB)', 'PIC_TYPE' => strtoupper(substr($thispic['pic_filename'], strlen($thispic['pic_filename']) - 3, 3)), 'PIC_ID' => $pic_id, 'PIC_BBCODE' => '[albumimg]' . $pic_id . '[/albumimg]', 'PIC_TITLE' => $thispic['pic_title'], 'PIC_DESC' => $pic_desc, 'S_THUMBNAIL_SIZE' => $album_config['thumbnail_size'], 'POSTER' => $poster, 'POSTER_AVATAR' => $poster_avatar, 'PIC_TIME' => create_date_ip($config['default_dateformat'], $thispic['pic_time'], $config['board_timezone']), 'PIC_VIEW' => $thispic['pic_view_count'], 'PIC_COMMENTS' => $total_comments, 'TARGET_BLANK' => $album_config['fullpic_popup'] ? 'target="_blank"' : '', 'L_PIC_ID' => $lang['Pic_ID'], 'L_PIC_BBCODE' => $lang['Pic_BBCode'], 'L_PIC_TITLE' => $lang['Pic_Image'], 'L_PIC_DESC' => $lang['Pic_Desc'], 'L_POSTER' => $lang['Pic_Poster'], 'L_POSTED' => $lang['Posted'], 'L_VIEW' => $lang['Views'], 'L_COMMENTS' => $lang['Comments'], 'L_RATING' => $lang['Rating'], 'L_EDIT' => $lang['Edit'], 'L_DELETE' => $lang['Delete'], 'L_USER_WWW' => $lang['Website'], 'L_USER_EMAIL' => $lang['Send_Email'], 'L_USER_PROFILE' => $lang['Profile'], 'L_ONLINE_STATUS' => $lang['Online_status'], 'L_PM' => $lang['Private_Message'], 'L_POST_YOUR_COMMENT' => $lang['Post_your_comment'], 'L_MESSAGE' => $lang['Message'], 'L_USERNAME' => $lang['Username'], 'L_COMMENT_NO_TEXT' => $lang['Comment_no_text'], 'L_COMMENT_TOO_LONG' => $lang['Comment_too_long'], 'L_MAX_LENGTH' => $lang['Max_length'], 'S_MAX_LENGTH' => $album_config['desc_length'], 'L_ORDER' => $lang['Order'], 'L_SORT' => $lang['Sort'], 'L_ASC' => $lang['Sort_Ascending'], 'L_DESC' => $lang['Sort_Descending'], 'L_BACK_TO_TOP' => $lang['Back_to_top'], 'L_COMMENT_WATCH' => $lang['Pic_comment_notification'], 'SORT_ASC' => $sort_order == 'ASC' ? 'selected="selected"' : '', 'SORT_DESC' => $sort_order == 'DESC' ? 'selected="selected"' : '', 'L_SUBMIT' => $lang['Submit'], 'S_ALBUM_ACTION' => append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id)), 'U_COMMENT_WATCH_LINK' => $is_watching_comments ? '<a href="' . append_sid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . '&amp;unwatch=comment') . '">' . $lang['Unwatch_pic'] . '</a>' : ($user->data['session_logged_in'] ? '<a href="' . append_sid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . '&amp;watch=comment') . '">' . $lang['Watch_pic'] . '</a>' : ''), 'S_RATE_MSG' => !$user->data['session_logged_in'] && $auth_data['rate'] == 0 ? $lang['Login_To_Vote'] : ($own_pic_rate == true && $user->data['user_level'] != ADMIN ? $lang['Own_Pic_Rate'] : ($already_rated == true && $user->data['user_level'] != ADMIN ? $lang['Already_rated'] : $lang['Please_Rate_It'])), 'PIC_RATING' => $image_rating . ($own_pic_rate == true && $user->data['user_level'] != ADMIN ? '&nbsp;(' . $lang['Own_Pic_Rate'] . ')' : ($already_rated == true && $user->data['user_level'] != ADMIN ? '&nbsp;(' . $lang['Already_rated'] . ')' : '')), 'L_CURRENT_RATING' => $lang['Current_Rating'], 'L_PLEASE_RATE_IT' => $lang['Please_Rate_It']));
 // Social Bookmarks
 if ($config['show_social_bookmarks'] == true) {
     $template->assign_block_vars('social_bookmarks', array());
 }
 $topic_title_enc = urlencode(ip_utf8_decode($thispic['pic_title']));
 $topic_title_enc_utf8 = urlencode($thispic['pic_title']);
 $topic_link = 'album_showpage.' . PHP_EXT . '?pic_id=' . $thispic['pic_id'] . $full_size_param . $nuffimage_vars . $sort_append;
 $topic_url_enc = urlencode(ip_utf8_decode(create_server_url() . $topic_link));
 $topic_url_enc_utf8 = urlencode(create_server_url() . $topic_link);
 $template->assign_vars(array('TOPIC_TITLE_ENC' => $topic_title_enc, 'TOPIC_TITLE_ENC_UTF8' => $topic_title_enc_utf8, 'TOPIC_URL_ENC' => $topic_url_enc, 'TOPIC_URL_ENC_UTF8' => $topic_url_enc_utf8, 'U_TELL' => append_sid('tellafriend.' . PHP_EXT . '?topic_title=' . $topic_title_enc . '&amp;topic_url=' . urlencode(ip_utf8_decode(str_replace('&amp;', '&', $topic_link)))), 'L_SHARE_TOPIC' => $lang['ShareThisTopic']));
 // BBCBMG - BEGIN
 include IP_ROOT_PATH . 'includes/bbcb_mg.' . PHP_EXT;
 $template->assign_var_from_handle('BBCB_MG', 'bbcb_mg');
 // BBCBMG - END
 // BBCBMG SMILEYS - BEGIN
Example #15
0
	$bbcode->allow_smilies = (($config['allow_smilies'] && $shout_row['user_allowsmile'] && ($shout != '') && $shout_row['enable_smilies']) ? true : false);
	$shout = $bbcode->parse($shout);
	$shout = (!$shout_row['shout_active']) ? $shout : $lang['Shout_censor'];
	$shout = censor_text($shout);

	//$shout = str_replace("\n", "\n<br />\n", $shout);

	$shout = (preg_match('/<a/', $shout)) ? str_replace('">', '" target="_top">', $shout) : $shout;

	$shout = $bbcode->acronym_pass($shout);
	$shout = $bbcode->autolink_text($shout, '999999');

	$template->assign_block_vars('shoutrow', array(
		'ROW_CLASS' => $row_class,
		'SHOUT' => $shout,
		'TIME' => create_date_ip($lang['Shoutbox_date'], $shout_row['shout_session_time'], $config['board_timezone']),
		'USERNAME' => $username,
		'PROFILE' => ($user_id == ANONYMOUS) ? '' : append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $shout_row['user_id']),
		)
	);
}

$template->assign_vars(array(
	'U_SHOUTBOX_VIEW' => append_sid('shoutbox_view.' . PHP_EXT),
	'T_NAME' => $theme['template_name'],
	'T_URL' => 'templates/' . $theme['template_name'],
	'T_HEAD_STYLESHEET' => $theme['head_stylesheet'],
	'S_CONTENT_ENCODING' => $lang['ENCODING']
	)
);
Example #16
0
 function fetch_posts($forum_sql, $number_of_posts, $text_length, $show_portal = false, $sort_mode = 0, $single_post = false, $only_auth_view = true)
 {
     global $db, $cache, $config, $user, $bbcode, $lofi;
     if (!class_exists('bbcode') || empty($bbcode)) {
         @(include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
     }
     $except_forums = build_exclusion_forums_list($only_auth_view);
     $add_to_sql = '';
     if (empty($single_post) && !empty($forum_sql)) {
         $except_forums_exp = explode(',', str_replace(' ', '', $except_forums));
         $allowed_forums_exp = explode(',', str_replace(' ', '', $forum_sql));
         $except_forums = '';
         for ($e = 0; $e < sizeof($except_forums_exp); $e++) {
             if (!in_array($except_forums_exp[$e], $allowed_forums_exp)) {
                 $except_forums .= $except_forums == '' ? $except_forums_exp[$e] : ', ' . $except_forums_exp[$e];
             }
         }
         $add_to_sql .= ' AND t.forum_id IN (' . $forum_sql . ')';
         $add_to_sql .= ' AND t.forum_id NOT IN (' . $except_forums . ')';
     } else {
         $add_to_sql .= ' AND t.forum_id NOT IN (' . $except_forums . ')';
     }
     if (!empty($show_portal)) {
         $add_to_sql .= ' AND t.topic_show_portal = 1';
     }
     if ($sort_mode == 1) {
         // Random
         $order_sql = 'RAND()';
     } elseif ($sort_mode == 2) {
         // Alphabetical
         $order_sql = 't.topic_title ASC';
     } else {
         // Recent
         $order_sql = 't.topic_time DESC';
     }
     if ($number_of_posts != 0) {
         $limit_sql = ' LIMIT 0,' . $number_of_posts;
     } else {
         $limit_sql = '';
     }
     if (!empty($single_post)) {
         $single_post_id = $forum_sql;
         $sql = "SELECT p.post_id, p.topic_id, p.forum_id, p.enable_html, p.enable_bbcode, p.enable_smilies, p.post_attachment, p.enable_autolinks_acronyms, p.post_text, p.post_text_compiled, t.forum_id, t.topic_time, t.topic_title, t.topic_first_post_id, t.topic_attachment, t.topic_views, t.topic_replies, u.username, u.user_id, u.user_active, u.user_color\n\t\t\t\t\tFROM " . POSTS_TABLE . " AS p, " . TOPICS_TABLE . " AS t, " . USERS_TABLE . " AS u\n\t\t\t\t\tWHERE p.post_id = '" . $single_post_id . "'\n\t\t\t\t\t\t" . $add_to_sql . "\n\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\tAND p.poster_id = u.user_id";
     } else {
         $sql = "SELECT t.topic_id, t.topic_time, t.topic_title, t.forum_id, t.topic_poster, t.topic_first_post_id, t.topic_status, t.topic_show_portal, t.topic_attachment, t.topic_views, t.topic_replies, u.username, u.user_id, u.user_active, u.user_color, p.post_id, p.enable_html, p.enable_bbcode, p.enable_smilies, p.post_attachment, p.enable_autolinks_acronyms, p.post_text, p.post_text_compiled\n\t\t\t\t\tFROM " . TOPICS_TABLE . " AS t, " . USERS_TABLE . " AS u, " . POSTS_TABLE . " AS p\n\t\t\t\t\tWHERE t.topic_time <= " . time() . "\n\t\t\t\t\t\t" . $add_to_sql . "\n\t\t\t\t\t\tAND t.topic_poster = u.user_id\n\t\t\t\t\t\tAND t.topic_first_post_id = p.post_id\n\t\t\t\t\t\tAND t.topic_status <> 2\n\t\t\t\t\tORDER BY " . $order_sql . $limit_sql;
     }
     // query the database
     $result = $db->sql_query($sql);
     // fetch all postings
     $posts = array();
     if ($row = $db->sql_fetchrow($result)) {
         $i = 0;
         do {
             $posts[$i]['enable_bbcode'] = $row['enable_bbcode'];
             $posts[$i]['enable_html'] = $row['enable_html'];
             $posts[$i]['enable_smilies'] = $row['enable_smilies'];
             $posts[$i]['enable_autolinks_acronyms'] = $row['enable_autolinks_acronyms'];
             $posts[$i]['post_text'] = $row['post_text'];
             $posts[$i]['forum_id'] = $row['forum_id'];
             $posts[$i]['topic_id'] = $row['topic_id'];
             $posts[$i]['topic_first_post_id'] = $row['topic_first_post_id'];
             $posts[$i]['topic_views'] = $row['topic_views'];
             $posts[$i]['topic_replies'] = $row['topic_replies'];
             $posts[$i]['topic_time'] = create_date_ip($config['default_dateformat'], $row['topic_time'], $config['board_timezone']);
             $posts[$i]['topic_title'] = $row['topic_title'];
             $posts[$i]['user_id'] = $row['user_id'];
             $posts[$i]['username'] = $row['username'];
             $posts[$i]['user_active'] = $row['user_active'];
             $posts[$i]['user_color'] = $row['user_color'];
             $posts[$i]['topic_attachment'] = $row['topic_attachment'];
             $posts[$i]['post_id'] = $row['post_id'];
             $posts[$i]['post_attachment'] = $row['post_attachment'];
             if ($text_length >= 0) {
                 $message = $posts[$i]['post_text'];
                 $message_compiled = empty($posts[$i]['post_text_compiled']) || !empty($user->data['session_logged_in']) || !empty($config['posts_precompiled']) ? false : $posts[$i]['post_text_compiled'];
                 $bbcode->allow_bbcode = $config['allow_bbcode'] && $user->data['user_allowbbcode'] && $posts[$i]['enable_bbcode'] ? true : false;
                 $bbcode->allow_html = ($config['allow_html'] && $user->data['user_allowhtml'] || $config['allow_html_only_for_admins']) && $posts[$i]['enable_html'] ? true : false;
                 $bbcode->allow_smilies = $config['allow_smilies'] && $posts[$i]['enable_smilies'] && !$lofi ? true : false;
                 $clean_tags = false;
                 if (strlen($posts[$i]['post_text']) > $text_length && $text_length > 0) {
                     $clean_tags = true;
                     $posts[$i]['striped'] = 1;
                 }
                 $posts[$i]['post_text'] = $message_compiled === false ? $bbcode->parse($posts[$i]['post_text'], '', false, $clean_tags) : $message_compiled;
                 if (!empty($clean_tags)) {
                     $posts[$i]['post_text'] = strlen($posts[$i]['post_text']) > $text_length ? truncate_html_string($posts[$i]['post_text'], $text_length) : $posts[$i]['post_text'];
                 }
                 $posts[$i]['post_text'] = censor_text($posts[$i]['post_text']);
                 //Acronyms, AutoLinks - BEGIN
                 if ($posts[$i]['enable_autolinks_acronyms']) {
                     $posts[$i]['post_text'] = $bbcode->acronym_pass($posts[$i]['post_text']);
                     $posts[$i]['post_text'] = $bbcode->autolink_text($posts[$i]['post_text'], '999999');
                 }
                 //Acronyms, AutoLinks - END
             }
             $posts[$i]['topic_title'] = censor_text($posts[$i]['topic_title']);
             $i++;
         } while ($row = $db->sql_fetchrow($result));
     }
     $db->sql_freeresult($result);
     // return the result
     return $posts;
 }
function build_index($cur = 'Root', $cat_break = false, &$forum_moderators, $real_level = -1, $max_level = -1, &$keys)
{
    global $template, $db, $cache, $config, $user, $lang, $images, $theme;
    global $tree, $bbcode, $lofi;
    if (empty($bbcode)) {
        include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT;
    }
    // init
    $display = false;
    // get the sub_forum switch value
    $sub_forum = intval($config['sub_forum']);
    if ($sub_forum == 2 && defined('IN_VIEWFORUM')) {
        $sub_forum = 1;
    }
    $pack_first_level = $sub_forum == 2;
    // verify the cat_break parm
    if ($cur != 'Root' && $real_level == -1) {
        $cat_break = false;
    }
    // display the level
    $CH_this = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
    // display each kind of row
    // root level head
    if ($real_level == -1) {
        // get max inc level
        $max = -1;
        if ($sub_forum == 2) {
            $max = 0;
        }
        if ($sub_forum == 1) {
            $max = 1;
        }
        $keys = array();
        $keys = get_auth_keys($cur, false, -1, $max);
        $max_level = get_max_depth($cur, false, -1, $keys, $max);
    }
    // table header
    if ($config['split_cat'] && $cat_break && $real_level == 0 || (!$config['split_cat'] || !$cat_break) && $real_level == -1) {
        // if break, get the local max level
        if ($config['split_cat'] && $cat_break && $real_level == 0) {
            $max_level = 0;
            // the array is sorted
            $start = false;
            $stop = false;
            for ($i = 0; $i < sizeof($keys['id']) && !$stop; $i++) {
                if ($start && $tree['main'][$keys['idx'][$i]] == $tree['main'][$CH_this]) {
                    $stop = true;
                    $break;
                }
                if ($keys['id'][$i] == $cur) {
                    $start = true;
                }
                if ($start && !$stop && $keys['level'][$i] > $max_level) {
                    $max_level = $keys['level'][$i];
                }
            }
        }
        $template->assign_block_vars('catrow', array('MAIN_CAT_ID' => $cur));
        $template->assign_block_vars('catrow.tablehead', array('L_FORUM' => $CH_this < 0 ? $lang['Forum'] : get_object_lang($cur, 'name'), 'INC_SPAN' => $max_level + 2));
    }
    // get the level
    $level = $keys['level'][$keys['keys'][$cur]];
    // sub-forum view management
    $pull_down = true;
    if ($sub_forum > 0) {
        $pull_down = false;
        // JHL 2012/03/09
        //if (($real_level == 0) && ($sub_forum == 1))
        if ($real_level == 0 && ($sub_forum == 1 || $sub_forum == 3)) {
            $pull_down = true;
        }
    }
    if ($level >= 0) {
        // cat header row
        if ($tree['type'][$CH_this] == POST_CAT_URL && $pull_down) {
            // display a cat row
            $cat = $tree['data'][$CH_this];
            $cat_id = $tree['id'][$CH_this];
            // get the class colors
            $class_catLeft = 'cat';
            $class_cat = 'cat';
            $class_rowpic = 'rowpic';
            // send to template
            $template->assign_block_vars('catrow', array('MAIN_CAT_ID' => $cur));
            $template->assign_block_vars('catrow.cathead', array('CAT_TITLE' => get_object_lang($cur, 'name'), 'CAT_DESC' => preg_replace('/<[^>]+>/', '', get_object_lang($cur, 'desc')), 'CLASS_CATLEFT' => $class_catLeft, 'CLASS_CAT' => $class_cat, 'CLASS_ROWPIC' => $class_rowpic, 'INC_SPAN' => $max_level - $level + 2, 'U_VIEWCAT' => append_sid(CMS_PAGE_FORUM . '?' . POST_CAT_URL . '=' . $cat_id)));
            // add indentation to the display
            for ($k = 1; $k <= $level; $k++) {
                $template->assign_block_vars('catrow.cathead.inc', array('INC_CLASS' => $k % 2 ? $theme['td_class1'] : $theme['td_class2']));
            }
            // something displayed
            $display = true;
        }
    }
    // forum header row
    if ($level >= 0) {
        if ($tree['type'][$CH_this] == POST_FORUM_URL || $tree['type'][$CH_this] == POST_CAT_URL && !$pull_down) {
            // get the data
            $data = $tree['data'][$CH_this];
            $id = $tree['id'][$CH_this];
            $type = $tree['type'][$CH_this];
            $sub = !empty($tree['sub'][$cur]) && $tree['auth'][$cur]['tree.auth_view'];
            // specific to the data type
            $title = get_object_lang($cur, 'name');
            $desc = get_object_lang($cur, 'desc');
            // specific to something attached
            if ($sub) {
                $i_new = $images['forum_sub_unread'];
                $a_new = $lang['New_posts'];
                $i_norm = $images['forum_sub_read'];
                $a_norm = $lang['No_new_posts'];
                $i_locked = $images['forum_sub_locked_read'];
                $a_locked = $lang['Forum_locked'];
            } else {
                $i_new = $images['forum_nor_unread'];
                $a_new = $lang['New_posts'];
                $i_norm = $images['forum_nor_read'];
                $a_norm = $lang['No_new_posts'];
                $i_locked = $images['forum_nor_locked_read'];
                $a_locked = $lang['Forum_locked'];
            }
            // forum link type
            if ($tree['type'][$CH_this] == POST_FORUM_URL && !empty($tree['data'][$CH_this]['forum_link'])) {
                $i_new = $images['forum_link'];
                $a_new = $lang['Forum_link'];
                $i_norm = $images['forum_link'];
                $a_norm = $lang['Forum_link'];
                $i_locked = $images['forum_link'];
                $a_locked = $lang['Forum_link'];
            }
            // front icon
            $link_class = !empty($data['tree.unread_topics']) ? '-new' : '';
            $folder_image = !empty($data['tree.unread_topics']) ? $i_new : $i_norm;
            $folder_alt = !empty($data['tree.unread_topics']) ? $a_new : $a_norm;
            if ($data['tree.locked']) {
                $folder_image = $i_locked;
                $folder_alt = $a_locked;
            }
            // moderators list
            $l_moderators = '';
            $moderator_list = '';
            if ($type == POST_FORUM_URL) {
                if (sizeof($forum_moderators[$id]) > 0) {
                    $l_moderators = sizeof($forum_moderators[$id]) == 1 ? $lang['Moderator'] : $lang['Moderators'];
                    $moderator_list = implode(', ', $forum_moderators[$id]);
                }
            }
            // last post
            $last_post = $lang['No_Posts'];
            if (isset($data['tree.forum_last_post_id']) && $data['tree.forum_last_post_id'] && (isset($data['tree.topic_last_post_auth']) && $data['tree.topic_last_post_auth'])) {
                $topic_title = htmlspecialchars_clean($data['tree.topic_title']);
                $topic_title_plain = $topic_title;
                $topic_title_short = $topic_title;
                // SMILEYS IN TITLE - BEGIN
                if ($config['smilies_topic_title'] && !$lofi) {
                    $bbcode->allow_smilies = $config['allow_smilies'] ? true : false;
                    $topic_title = $bbcode->parse_only_smilies($topic_title);
                }
                // SMILEYS IN TITLE - END
                $topic_title = empty($data['title_compl_infos']) ? $topic_title : $data['title_compl_infos'] . ' ' . $topic_title;
                if (strlen($topic_title) > intval($config['last_topic_title_length']) - 3) {
                    // remove tags from the short version, in case a smiley or a quick title prefix is in there
                    $topic_title_short = substr(strip_tags($topic_title), 0, intval($config['last_topic_title_length'])) . '...';
                }
                $topic_title = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . (!empty($data['forum_id']) ? POST_FORUM_URL . '=' . $data['forum_id'] . '&amp;' : '') . POST_POST_URL . '=' . $data['tree.forum_last_post_id']) . '#p' . $data['tree.forum_last_post_id'] . '" title="' . $topic_title_plain . '">' . $topic_title_short . '</a><br />';
                $last_post_time = create_date_ip($config['default_dateformat'], $data['tree.post_time'], $config['board_timezone']);
                $last_post = $config['last_topic_title'] ? $topic_title : '';
                $last_post .= $last_post_time . '<br />';
                $last_post .= $data['tree.post_user_id'] == ANONYMOUS ? $data['tree.post_username'] . ' ' : colorize_username($data['tree.post_user_id'], $data['tree.post_username'], $data['tree.user_color'], $data['tree.user_active']);
                $last_post .= '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . (!empty($data['forum_id']) ? POST_FORUM_URL . '=' . $data['forum_id'] . '&amp;' : '') . POST_POST_URL . '=' . $data['tree.forum_last_post_id']) . '#p' . $data['tree.forum_last_post_id'] . '" title="' . $topic_title_plain . '"><img src="' . ($data['tree.unread_topics'] ? $images['icon_newest_reply'] : $images['icon_latest_reply']) . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
            }
            // links to sub-levels
            $links = '';
            // JHL 2012/03/09
            //if ($sub && (!$pull_down || (($type == POST_FORUM_URL) && ($sub_forum > 0))) && (intval($config['sub_level_links']) > 0))
            if ($sub && (!$pull_down || $type == POST_FORUM_URL && $sub_forum > 0) && (intval($config['sub_level_links']) > 0 && $sub_forum != 3)) {
                for ($j = 0; $j < sizeof($tree['sub'][$cur]); $j++) {
                    if ($tree['auth'][$tree['sub'][$cur][$j]]['auth_view']) {
                        $wcur = $tree['sub'][$cur][$j];
                        $wthis = $tree['keys'][$wcur];
                        $wdata = $tree['data'][$wthis];
                        $wname = get_object_lang($wcur, 'name');
                        $wdesc = get_object_lang($wcur, 'desc');
                        switch ($tree['type'][$wthis]) {
                            case POST_FORUM_URL:
                                $wpgm = append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $tree['id'][$wthis]);
                                break;
                            case POST_CAT_URL:
                                $wpgm = append_sid(CMS_PAGE_FORUM . '?' . POST_CAT_URL . '=' . $tree['id'][$wthis]);
                                break;
                            default:
                                $wpgm = append_sid(CMS_PAGE_FORUM);
                                break;
                        }
                        $link = '';
                        $wdesc = preg_replace('/<[^>]+>/', '', $wdesc);
                        if (intval($config['sub_level_links']) == 2) {
                            $wsub = !empty($tree['sub'][$wcur]) && $tree['auth'][$wcur]['tree.auth_view'];
                            // specific to something attached
                            if ($wsub) {
                                $wi_new = $images['icon_minicat_new'];
                                $wa_new = $lang['New_posts'];
                                $wi_norm = $images['icon_minicat'];
                                $wa_norm = $lang['No_new_posts'];
                                $wi_locked = $images['icon_minicat_locked'];
                                $wa_locked = $lang['Forum_locked'];
                            } else {
                                $wi_new = $images['icon_minipost_new'];
                                $wa_new = $lang['New_posts'];
                                $wi_norm = $images['icon_minipost'];
                                $wa_norm = $lang['No_new_posts'];
                                $wi_locked = $images['icon_minipost_lock'];
                                $wa_locked = $lang['Forum_locked'];
                            }
                            // forum link type
                            if ($tree['type'][$wthis] == POST_FORUM_URL && !empty($wdata['forum_link'])) {
                                $wi_new = $images['icon_minilink'];
                                $wa_new = $lang['Forum_link'];
                                $wi_norm = $images['icon_minilink'];
                                $wa_norm = $lang['Forum_link'];
                                $wi_locked = $images['icon_minilink'];
                                $wa_locked = $lang['Forum_link'];
                            }
                            // front icon
                            $wfolder_image = $wdata['tree.unread_topics'] ? $wi_new : $wi_norm;
                            $wfolder_alt = $wdata['tree.unread_topics'] ? $wa_new : $wa_norm;
                            if ($wdata['tree.locked']) {
                                $wfolder_image = $wi_locked;
                                $wfolder_alt = $wa_locked;
                            }
                            if ($lofi == true) {
                                $wlast_post = '';
                            } else {
                                $wlast_post = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $wdata['tree.forum_last_post_id']) . '#p' . $wdata['tree.forum_last_post_id'] . '">';
                                $wlast_post .= '<img src="' . $wfolder_image . '" alt="' . $wfolder_alt . '" title="' . $wfolder_alt . '" /></a>&nbsp;';
                            }
                        }
                        $class = $wfolder_image == $wi_new ? 'forumlink2-new' : 'forumlink2';
                        if ($wname != '') {
                            $link = '<a href="' . $wpgm . '" title="' . $wdesc . '" class="' . $class . '">' . $wname . '</a>';
                        }
                        if ($link != '') {
                            $links .= ($links != '' ? ', ' : '') . $wlast_post . $link;
                        }
                    }
                }
            }
            // forum icon
            $icon_img = empty($data['icon']) ? '' : (isset($images[$data['icon']]) ? $images[$data['icon']] : $data['icon']);
            // UPI2DB - BEGIN
            if ($user->data['upi2db_access']) {
                $folder_image_ar_big = $images['forum_nor_ar'];
                $cat_image_ar_big = $images['forum_sub_ar'];
                $forum_id = $data['forum_id'];
                if (!$data['tree.unread_topics'] && !$sub) {
                    if (is_array($user->data['upi2db_unread']['always_read']['forums']) && !in_array($forum_id, $user->data['upi2db_unread']['always_read']['forums'])) {
                        $mark_always_read = '<a href="' . append_sid(CMS_PAGE_FORUM . '?forum_id=' . $forum_id . '&amp;always_read=set') . '"><img src="' . $folder_image . '" alt="' . $lang['upi2db_always_read_forum'] . '" title="' . $lang['upi2db_always_read_forum'] . '" /></a>';
                    } else {
                        $mark_always_read = '<a href="' . append_sid(CMS_PAGE_FORUM . '?forum_id=' . $forum_id . '&amp;always_read=unset') . '"><img src="' . $folder_image_ar_big . '" alt="' . $lang['upi2db_always_read_forum_unset'] . '" title="' . $lang['upi2db_always_read_forum_unset'] . '" /></a>';
                    }
                } else {
                    if ($sub) {
                        $mark_always_read = '<img src="' . $folder_image . '" alt="' . $lang['upi2db_cat_cant_mark_always_read'] . '" title="' . $lang['upi2db_cat_cant_mark_always_read'] . '" />';
                    } else {
                        $mark_always_read = '<img src="' . $folder_image . '" alt="' . $folder_alt . '" title="' . $folder_alt . '" />';
                    }
                }
            } else {
                $mark_always_read = '<img src="' . $folder_image . '" alt="' . $folder_alt . '" title="' . $folder_alt . '" />';
            }
            // UPI2DB - END
            if ($config['url_rw'] == true || $config['url_rw_guests'] == true && $user->data['user_id'] == ANONYMOUS) {
                $url_viewforum = $type == POST_FORUM_URL ? append_sid(str_replace('--', '-', make_url_friendly($title) . '-vf' . $id . '.html')) : append_sid(str_replace('--', '-', make_url_friendly($title) . '-vc' . $id . '.html'));
            } else {
                $url_viewforum = $type == POST_FORUM_URL ? append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $id) : append_sid(CMS_PAGE_FORUM . '?' . POST_CAT_URL . '=' . $id);
            }
            // send to template
            if ($config['show_rss_forum_icon'] && $data['forum_index_icons'] == 1 && $type == POST_FORUM_URL) {
                $rss_feed_icon = '';
                if (!$data['tree.locked'] && $user->data['session_logged_in']) {
                    $rss_feed_icon .= '&nbsp;<a href="' . append_sid(CMS_PAGE_POSTING . '?mode=newtopic&amp;' . POST_FORUM_URL . '=' . $id) . '"><img src="' . $images['vf_topic_nor'] . '" alt="' . $lang['Post_new_topic'] . '" title="' . $lang['Post_new_topic'] . '" /></a>';
                }
                $rss_feed_icon .= '&nbsp;<a href="' . append_sid('rss.' . PHP_EXT . '?' . POST_FORUM_URL . '=' . $id) . '"><img src="' . $images['nav_menu_feed'] . '" alt="' . $lang['Rss_news_feeds'] . '" title="' . $lang['Rss_news_feeds'] . '" /></a>';
            } else {
                $rss_feed_icon = '&nbsp;';
            }
            $template->assign_block_vars('catrow', array());
            $template->assign_block_vars('catrow.forumrow', array('FORUM_FOLDER_IMG' => $folder_image, 'ICON_IMG' => $icon_img, 'RSS_FEED_ICON' => $rss_feed_icon, 'FORUM_NAME' => $title, 'FORUM_DESC' => $desc, 'FORUM_TYPE' => $type == POST_FORUM_URL ? 'forum' : 'category', 'POSTS' => $data['tree.forum_posts'], 'TOPICS' => $data['tree.forum_topics'], 'ONLINE' => $config['show_forums_online_users'] == true ? '<br />' . $lang['Online'] . ':&nbsp;' . $data['tree.forum_online'] : '', 'LAST_POST' => $last_post, 'MODERATORS' => $moderator_list, 'L_MODERATOR' => empty($moderator_list) ? '' : (empty($l_moderators) ? '<br />' : '<br /><b>' . $l_moderators . ':</b>&nbsp;'), 'L_LINKS' => empty($links) ? '' : (empty($lang['Subforums']) ? '' : '<b>' . $lang['Subforums'] . ':</b>&nbsp;'), 'LINKS_BR' => empty($links) ? '' : '<br />', 'LINKS_ROWSPAN' => empty($links) ? '' : ' rowspan="2"', 'LINKS' => $links, 'L_FORUM_FOLDER_ALT' => $folder_alt, 'U_MARK_ALWAYS_READ' => $mark_always_read, 'L_POST_NEW_TOPIC' => $lang['Post_new_topic'], 'U_VIEWFORUM' => $url_viewforum, 'U_POST_NEW_TOPIC' => append_sid(CMS_PAGE_POSTING . '?mode=newtopic&amp;' . POST_FORUM_URL . '=' . $id), 'LINK_CLASS' => $link_class, 'INC_SPAN' => $max_level - $level + 1, 'INC_CLASS' => !($level % 2) ? $theme['td_class1'] : $theme['td_class2']));
            // display icon
            if (!empty($icon_img)) {
                $template->assign_block_vars('catrow.forumrow.forum_icon', array());
            }
            // add indentation to the display
            for ($k = 1; $k <= $level; $k++) {
                $template->assign_block_vars('catrow.forumrow.inc', array('INC_CLASS' => $k % 2 ? $theme['td_class1'] : $theme['td_class2']));
            }
            // forum link type
            if ($tree['type'][$CH_this] == POST_FORUM_URL && !empty($tree['data'][$CH_this]['forum_link'])) {
                $s_hit_count = '';
                if ($tree['data'][$CH_this]['forum_link_hit_count']) {
                    $s_hit_count = sprintf($lang['Forum_link_visited'], $tree['data'][$CH_this]['forum_link_hit']);
                }
                $template->assign_block_vars('catrow.forumrow.forum_link', array('HIT_COUNT' => $s_hit_count));
            } else {
                $template->assign_block_vars('catrow.forumrow.forum_link_no', array());
            }
            // something displayed
            $display = true;
        }
    }
    // display sub-levels
    if (!empty($tree['sub'][$cur])) {
        for ($i = 0; $i < sizeof($tree['sub'][$cur]); $i++) {
            if (!empty($keys['keys'][$tree['sub'][$cur][$i]])) {
                $wdisplay = build_index($tree['sub'][$cur][$i], $cat_break, $forum_moderators, $level + 1, $max_level, $keys);
                if ($wdisplay) {
                    $display = true;
                }
            }
        }
    }
    if ($level >= 0) {
        // forum footer row
        if ($tree['type'][$CH_this] == POST_FORUM_URL) {
        }
    }
    if ($level >= 0) {
        // cat footer
        if ($tree['type'][$CH_this] == POST_CAT_URL && $pull_down) {
            $template->assign_block_vars('catrow', array());
            $template->assign_block_vars('catrow.catfoot', array('INC_SPAN' => $max_level - $level + 5));
            // add indentation to the display
            for ($k = 1; $k <= $level; $k++) {
                $template->assign_block_vars('catrow.catfoot.inc', array('INC_SPAN' => $max_level - $level + 5, 'INC_CLASS' => $k % 2 ? $theme['td_class1'] : $theme['td_class2']));
            }
        }
    }
    // root level footer
    if ($config['split_cat'] && $cat_break && $real_level == 0 || (!$config['split_cat'] || !$cat_break) && $real_level == -1) {
        $template->assign_block_vars('catrow', array());
        $template->assign_block_vars('catrow.tablefoot', array());
    }
    return $display;
}
Example #18
0
        $filename_2 = '';
        if (strlen($filename) > 32) {
            $filename_2 = substr($filename, 0, 30) . '...';
        }
        $view_attachment = append_sid(IP_ROOT_PATH . 'download.' . PHP_EXT . '?id=' . intval($attachments[$i]['attach_id']));
        if ($filename_2 != '') {
            $filename_link = '<a href="' . $view_attachment . '" class="gen" title="' . $filename . '" target="_blank">' . $filename_2 . '</a>';
        } else {
            $filename_link = '<a href="' . $view_attachment . '" class="gen" target="_blank">' . $filename . '</a>';
        }
        if ($attachments[$i]['download_count'] > 0 && $user->data['user_level'] == ADMIN) {
            $download_count_link = '<a href="' . append_sid('attachments.' . PHP_EXT . '?attach_id=' . intval($attachments[$i]['attach_id'])) . '">' . $attachments[$i]['download_count'] . '</a>';
        } else {
            $download_count_link = $attachments[$i]['download_count'];
        }
        $template->assign_block_vars('attachrow', array('ROW_NUMBER' => $i + ($_GET['start'] + 1), 'ROW_CLASS' => $row_class, 'FILENAME' => $filename, 'COMMENT' => $comment_field, 'SIZE' => round($attachments[$i]['filesize'] / 1024, 2), 'DOWNLOAD_COUNT' => $download_count_link, 'POST_TIME' => create_date_ip($config['default_dateformat'], $attachments[$i]['filetime'], $config['board_timezone']), 'POST_TITLE' => $post_title, 'VIEW_ATTACHMENT' => $filename_link));
    }
    $gen_pagination = false;
    if ((!$forum_id || $forum_id == '-1') && $display_all_forums) {
        $gen_pagination = true;
        $sql = "SELECT count(*) AS total\n\t\t\tFROM " . $attach_table . " a, " . POSTS_TABLE . " p\n\t\t\tWHERE (a.post_id = p.post_id) AND (p.forum_id IN (" . implode(', ', $forum_ids) . "))";
        $result = $db->sql_query($sql);
    } elseif ($is_auth_ary[$forum_id]['auth_read'] && $is_download_auth_ary[$forum_id]['auth_download'] && $num_attachments > 0) {
        $gen_pagination = true;
        $sql = "SELECT count(*) AS total\n\t\t\tFROM " . $attach_table . " a, " . POSTS_TABLE . " p\n\t\t\tWHERE (a.post_id = p.post_id) AND (p.forum_id = " . $forum_id . ")";
        $result = $db->sql_query($sql);
    }
    $pagination_append = POST_FORUM_URL . '=' . $forum_id . '&amp;';
}
$pagination = '&nbsp;';
$page_number = '&nbsp;';
Example #19
0
		$flag = $row['privmsgs_type'];

		$icon_flag = ($flag == PRIVMSGS_NEW_MAIL || $flag == PRIVMSGS_UNREAD_MAIL) ? $images['pm_unreadmsg'] : $images['pm_readmsg'];
		$icon_flag_alt = ($flag == PRIVMSGS_NEW_MAIL || $flag == PRIVMSGS_UNREAD_MAIL) ? $lang['Unread_message'] : $lang['Read_message'];

		$msg_userid = $row['user_id'];
		$msg_username = colorize_username($row['user_id'], $row['username'], $row['user_color'], $row['user_active']);

		$u_from_user_profile = append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $msg_userid);

		$msg_subject = $row['privmsgs_subject'];
		$msg_subject = censor_text($msg_subject);
		$u_subject = append_sid(CMS_PAGE_PRIVMSG . '?folder=' . $folder . '&amp;mode=read&amp;' . POST_POST_URL . '=' . $privmsg_id);

		$msg_date = create_date_ip($config['default_dateformat'], $row['privmsgs_date'], $config['board_timezone']);

		if (($flag == PRIVMSGS_NEW_MAIL) && ($folder == 'inbox'))
		{
			$msg_subject = '<b>' . $msg_subject . '</b>';
			$msg_date = '<b>' . $msg_date . '</b>';
			$msg_username = '******' . $msg_username . '</b>';
		}

		$row_class = (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2'];
		$i++;

		$template->assign_block_vars('listrow', array(
			'ROW_CLASS' => $row_class,
			'FROM' => $msg_username,
			'SUBJECT' => $msg_subject,
Example #20
0
 function main($action)
 {
     global $template, $lang, $config, $pafiledb_config, $db, $images, $user;
     if (!$this->auth_global['auth_search']) {
         if (!$user->data['session_logged_in']) {
             redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=dload.' . PHP_EXT . '&action=stats', true));
         }
         $message = sprintf($lang['Sorry_auth_search'], $this->auth_global['auth_search_type']);
         message_die(GENERAL_MESSAGE, $message);
     }
     include IP_ROOT_PATH . 'includes/functions_search.' . PHP_EXT;
     $search_keywords = request_var('search_keywords', '', true);
     $search_keywords = htmlspecialchars_decode($search_keywords, ENT_COMPAT);
     $search_author = request_var('search_author', '', true);
     $search_author = htmlspecialchars_decode($search_author, ENT_COMPAT);
     $search_id = request_var('search_id', 0);
     $search_terms = request_var('search_terms', '');
     $search_terms = $search_terms == 'all' ? 1 : 0;
     $cat_id = request_var('cat_id', 0);
     $comments_search = request_var('comments_search', '');
     $comments_search = $comments_search == 'YES' ? 1 : 0;
     $start = request_var('start', 0);
     $start = $start < 0 ? 0 : $start;
     $sort_method = request_var('sort_method', $pafiledb_config['sort_method']);
     $sort_method = check_var_value($sort_method, array('file_name', 'file_time', 'file_dls', 'file_rating', 'file_update_time'));
     $sort_method = $sort_method == 'file_rating' ? 'rating' : $sort_method;
     $sort_order = request_var('order', $pafiledb_config['sort_order']);
     $sort_order = check_var_value($sort_order, array('DESC', 'ASC'));
     $limit_sql = $start == 0 ? $pafiledb_config['settings_file_page'] : $start . ',' . $pafiledb_config['settings_file_page'];
     // encoding match for workaround
     $multibyte_charset = 'utf-8, big5, shift_jis, euc-kr, gb2312';
     if (isset($_POST['submit']) || $search_author != '' || $search_keywords != '' || $search_id) {
         $store_vars = array('search_results', 'total_match_count', 'split_search', 'sort_method', 'sort_order');
         if ($search_author != '' || $search_keywords != '') {
             if ($search_author != '' && $search_keywords == '') {
                 $search_author = str_replace('*', '%', trim($search_author));
                 $sql = get_users_sql($search_author, true, false, true, false);
                 $result = $db->sql_query($sql);
                 $matching_userids = '';
                 if ($row = $db->sql_fetchrow($result)) {
                     do {
                         $matching_userids .= ($matching_userids != '' ? ', ' : '') . $row['user_id'];
                     } while ($row = $db->sql_fetchrow($result));
                 } else {
                     message_die(GENERAL_MESSAGE, $lang['No_search_match']);
                 }
                 $sql = "SELECT *\n\t\t\t\t\t\tFROM " . PA_FILES_TABLE . "\n\t\t\t\t\t\tWHERE user_id IN ({$matching_userids})";
                 $result = $db->sql_query($sql);
                 $search_ids = array();
                 while ($row = $db->sql_fetchrow($result)) {
                     if ($this->auth[$row['file_catid']]['auth_view']) {
                         $search_ids[] = $row['file_id'];
                     }
                 }
                 $db->sql_freeresult($result);
                 $total_match_count = sizeof($search_ids);
             } elseif ($search_keywords != '') {
                 stopwords_synonyms_init();
                 $split_search = array();
                 $split_search = !strstr($multibyte_charset, $lang['ENCODING']) ? split_words(clean_words('search', stripslashes($search_keywords), $stopwords_array, $synonyms_array), 'search') : split(' ', $search_keywords);
                 $word_count = 0;
                 $current_match_type = 'or';
                 $word_match = array();
                 $result_list = array();
                 for ($i = 0; $i < sizeof($split_search); $i++) {
                     switch ($split_search[$i]) {
                         case 'and':
                             $current_match_type = 'and';
                             break;
                         case 'or':
                             $current_match_type = 'or';
                             break;
                         case 'not':
                             $current_match_type = 'not';
                             break;
                         default:
                             if (!empty($search_terms)) {
                                 $current_match_type = 'and';
                             }
                             $match_word = addslashes('%' . str_replace('*', '', $split_search[$i]) . '%');
                             $sql = "SELECT file_id\n\t\t\t\t\t\t\t\t\tFROM " . PA_FILES_TABLE . "\n\t\t\t\t\t\t\t\t\tWHERE (file_name LIKE '{$match_word}'\n\t\t\t\t\t\t\t\t\tOR file_creator LIKE '{$match_word}'\n\t\t\t\t\t\t\t\t\tOR file_desc LIKE '{$match_word}'\n\t\t\t\t\t\t\t\t\tOR file_longdesc LIKE '{$match_word}')";
                             $result = $db->sql_query($sql);
                             $row = array();
                             while ($temp_row = $db->sql_fetchrow($result)) {
                                 $row[$temp_row['file_id']] = 1;
                                 if (!$word_count) {
                                     $result_list[$temp_row['file_id']] = 1;
                                 } elseif ($current_match_type == 'or') {
                                     $result_list[$temp_row['file_id']] = 1;
                                 } elseif ($current_match_type == 'not') {
                                     $result_list[$temp_row['file_id']] = 0;
                                 }
                             }
                             if ($current_match_type == 'and' && $word_count) {
                                 @reset($result_list);
                                 while (list($file_id, $match_count) = @each($result_list)) {
                                     if (!$row[$file_id]) {
                                         $result_list[$file_id] = 0;
                                     }
                                 }
                             }
                             if ($comments_search) {
                                 $sql = "SELECT file_id\n\t\t\t\t\t\t\t\t\tFROM " . PA_COMMENTS_TABLE . "\n\t\t\t\t\t\t\t\t\tWHERE (comments_title LIKE '{$match_word}'\n\t\t\t\t\t\t\t\t\tOR comments_text LIKE '{$match_word}')";
                                 $result = $db->sql_query($sql);
                                 $row = array();
                                 while ($temp_row = $db->sql_fetchrow($result)) {
                                     $row[$temp_row['file_id']] = 1;
                                     if (!$word_count) {
                                         $result_list[$temp_row['file_id']] = 1;
                                     } else {
                                         if ($current_match_type == 'or') {
                                             $result_list[$temp_row['file_id']] = 1;
                                         } else {
                                             if ($current_match_type == 'not') {
                                                 $result_list[$temp_row['file_id']] = 0;
                                             }
                                         }
                                     }
                                 }
                                 if ($current_match_type == 'and' && $word_count) {
                                     @reset($result_list);
                                     while (list($file_id, $match_count) = @each($result_list)) {
                                         if (!$row[$file_id]) {
                                             $result_list[$file_id] = 0;
                                         }
                                     }
                                 }
                             }
                             $word_count++;
                             $db->sql_freeresult($result);
                     }
                 }
                 @reset($result_list);
                 $search_ids = array();
                 while (list($file_id, $matches) = each($result_list)) {
                     if ($matches) {
                         $search_ids[] = $file_id;
                     }
                 }
                 unset($result_list);
                 $total_match_count = sizeof($search_ids);
             }
             // Author name search
             if ($search_author != '') {
                 $search_author = str_replace('*', '%', trim($db->sql_escape($search_author)));
             }
             if ($total_match_count) {
                 $where_sql = $cat_id ? 'AND file_catid IN (' . $this->gen_cat_ids($cat_id, '') . ')' : '';
                 if ($search_author == '') {
                     $sql = "SELECT file_id, file_catid\n\t\t\t\t\t\t\tFROM " . PA_FILES_TABLE . "\n\t\t\t\t\t\t\tWHERE file_id IN (" . implode(", ", $search_ids) . ")\n\t\t\t\t\t\t\t\t{$where_sql}\n\t\t\t\t\t\t\tGROUP BY file_id";
                 } else {
                     $from_sql = PA_FILES_TABLE . " f";
                     if ($search_author != '') {
                         $from_sql .= ", " . USERS_TABLE . " u";
                         $where_sql .= " AND u.user_id = f.user_id AND u.username LIKE '{$search_author}' ";
                     }
                     $where_sql .= $cat_id ? 'AND file_catid IN (' . $this->gen_cat_ids($cat_id, '') . ')' : '';
                     $sql = "SELECT f.file_id, f.file_catid\n\t\t\t\t\t\t\tFROM {$from_sql}\n\t\t\t\t\t\t\tWHERE f.file_id IN (" . implode(", ", $search_ids) . ")\n\t\t\t\t\t\t\t{$where_sql}\n\t\t\t\t\t\t\tGROUP BY f.file_id";
                 }
                 $result = $db->sql_query($sql);
                 $search_ids = array();
                 while ($row = $db->sql_fetchrow($result)) {
                     if ($this->auth[$row['file_catid']]['auth_view']) {
                         $search_ids[] = $row['file_id'];
                     }
                 }
                 $db->sql_freeresult($result);
                 $total_match_count = sizeof($search_ids);
             } else {
                 message_die(GENERAL_MESSAGE, $lang['No_search_match']);
             }
             //
             // Finish building query (for all combinations)
             // and run it ...
             //
             $expiry_time = $current_time - $config['session_length'];
             $sql = "SELECT session_id\n\t\t\t\t\tFROM " . SESSIONS_TABLE . "\n\t\t\t\t\tWHERE session_time > {$expiry_time}";
             $db->sql_return_on_error(true);
             $result = $db->sql_query($sql);
             $db->sql_return_on_error(false);
             if ($result) {
                 $delete_search_ids = array();
                 while ($row = $db->sql_fetchrow($result)) {
                     $delete_search_ids[] = "'" . $row['session_id'] . "'";
                 }
                 if (sizeof($delete_search_ids)) {
                     $sql = "DELETE FROM " . SEARCH_TABLE . "\n\t\t\t\t\t\t\tWHERE session_id NOT IN (" . implode(", ", $delete_search_ids) . ")";
                     $result = $db->sql_query($sql);
                 }
             }
             // Store new result data
             $search_results = implode(', ', $search_ids);
             $store_search_data = array();
             for ($i = 0; $i < sizeof($store_vars); $i++) {
                 $store_search_data[$store_vars[$i]] = ${$store_vars}[$i];
             }
             $result_array = serialize($store_search_data);
             unset($store_search_data);
             mt_srand((double) microtime() * 1000000);
             $search_id = mt_rand();
             $sql = "UPDATE " . SEARCH_TABLE . "\n\t\t\t\t\tSET search_id = {$search_id}, search_array = '" . $db->sql_escape($result_array) . "'\n\t\t\t\t\tWHERE session_id = '" . $user->data['session_id'] . "'";
             $db->sql_return_on_error(true);
             $result = $db->sql_query($sql);
             $db->sql_return_on_error(false);
             if (!$result || !$db->sql_affectedrows()) {
                 $sql = "INSERT INTO " . SEARCH_TABLE . " (search_id, session_id, search_array)\n\t\t\t\t\t\tVALUES({$search_id}, '" . $user->data['session_id'] . "', '" . $db->sql_escape($result_array) . "')";
                 $result = $db->sql_query($sql);
             }
         } else {
             $search_id = intval($search_id);
             if ($search_id) {
                 $sql = "SELECT search_array\n\t\t\t\t\t\tFROM " . SEARCH_TABLE . "\n\t\t\t\t\t\tWHERE search_id = {$search_id}\n\t\t\t\t\t\tAND session_id = '" . $user->data['session_id'] . "'";
                 $result = $db->sql_query($sql);
                 if ($row = $db->sql_fetchrow($result)) {
                     $search_data = unserialize($row['search_array']);
                     for ($i = 0; $i < sizeof($store_vars); $i++) {
                         ${$store_vars}[$i] = $search_data[$store_vars[$i]];
                     }
                 }
             }
         }
         if ($search_results != '') {
             $sql = "SELECT f1.*, AVG(r.rate_point) AS rating, COUNT(r.votes_file) AS total_votes, u.user_id, u.username, u.user_active, u.user_color, c.cat_id, c.cat_name, COUNT(cm.comments_id) AS total_comments\n\t\t\t\t\tFROM (" . PA_FILES_TABLE . " AS f1, " . PA_CATEGORY_TABLE . " AS c)\n\t\t\t\t\t\tLEFT JOIN " . PA_VOTES_TABLE . " AS r ON f1.file_id = r.votes_file\n\t\t\t\t\t\tLEFT JOIN " . USERS_TABLE . " AS u ON f1.user_id = u.user_id\n\t\t\t\t\t\tLEFT JOIN " . PA_COMMENTS_TABLE . " AS cm ON f1.file_id = cm.file_id\n\t\t\t\t\tWHERE f1.file_id IN ({$search_results})\n\t\t\t\t\tAND c.cat_id = f1.file_catid\n\t\t\t\t\tAND f1.file_approved = '1'\n\t\t\t\t\tGROUP BY f1.file_id\n\t\t\t\t\tORDER BY {$sort_method} {$sort_order}\n\t\t\t\t\tLIMIT {$limit_sql}";
             $result = $db->sql_query($sql);
             $searchset = array();
             while ($row = $db->sql_fetchrow($result)) {
                 $searchset[] = $row;
             }
             $db->sql_freeresult($result);
             $l_search_matches = $total_match_count == 1 ? sprintf($lang['Found_search_match'], $total_match_count) : sprintf($lang['Found_search_matches'], $total_match_count);
             $template->assign_vars(array('L_SEARCH_MATCHES' => $l_search_matches));
             for ($i = 0; $i < sizeof($searchset); $i++) {
                 $cat_url = append_sid('dload.' . PHP_EXT . '?action=category&amp;cat_id=' . $searchset[$i]['cat_id']);
                 $file_url = append_sid('dload.' . PHP_EXT . '?action=file&amp;file_id=' . $searchset[$i]['file_id']);
                 //===================================================
                 // Format the date for the given file
                 //===================================================
                 $date = create_date_ip($config['default_dateformat'], $searchset[$i]['file_time'], $config['board_timezone']);
                 //===================================================
                 // Get rating for the file and format it
                 //===================================================
                 //$rating = ($searchset[$i]['rating'] != 0) ? round($searchset[$i]['rating'], 2) . ' / 10' : $lang['Not_rated'];
                 //$rating2 = ($searchset[$i]['rating'] != 0) ? sprintf("%.1f", round(($searchset[$i]['rating']), 2) / 2) : '0.0';
                 $rating2 = $searchset[$i]['rating'] != 0 ? sprintf("%.1f", round($searchset[$i]['rating'], 0) / 2) : '0.0';
                 //===================================================
                 // If the file is new then put a new image in front of it
                 //===================================================
                 $is_new = false;
                 if (time() - $pafiledb_config['settings_newdays'] * 24 * 60 * 60 < $searchset[$i]['file_time']) {
                     $is_new = true;
                 }
                 $xs_new = $is_new ? '-new' : '';
                 //===================================================
                 // Get the post icon fot this file
                 //===================================================
                 if ($searchset[$i]['file_pin'] != FILE_PINNED) {
                     if ($searchset[$i]['file_posticon'] == 'none' || $searchset[$i]['file_posticon'] == 'none.gif') {
                         $posticon = '<img src="' . IP_ROOT_PATH . FILES_ICONS_DIR . 'default.png" alt="" />';
                         //$posticon = '&nbsp;';
                     } else {
                         $posticon = '<img src="' . FILES_ICONS_DIR . $searchset[$i]['file_posticon'] . '" alt="" />';
                     }
                 } else {
                     $posticon = '<img src="' . $images['forum_link'] . '" alt="" />';
                 }
                 $poster = $searchset[$i]['user_id'] == ANONYMOUS ? $lang['Guest'] : colorize_username($searchset[$i]['user_id'], $searchset[$i]['username'], $searchset[$i]['user_color'], $searchset[$i]['user_active']);
                 $template->assign_block_vars('searchresults', array('CAT_NAME' => $searchset[$i]['cat_name'], 'FILE_NEW_IMAGE' => $images['pa_file_new'], 'PIN_IMAGE' => $posticon, 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'XS_NEW' => $xs_new, 'IS_NEW_FILE' => $is_new, 'FILE_NAME' => $searchset[$i]['file_name'], 'FILE_DESC' => $searchset[$i]['file_desc'], 'FILE_SUBMITER' => $poster, 'DATE' => $date, 'RATING' => $rating2, 'DOWNLOADS' => $searchset[$i]['file_dls'], 'U_FILE' => $file_url, 'U_CAT' => $cat_url));
             }
             $base_url = append_sid('dload.' . PHP_EXT . '?action=search&amp;search_id=' . $search_id);
             $template->assign_vars(array('PAGINATION' => generate_pagination($base_url, $total_match_count, $pafiledb_config['settings_file_page'], $start), 'PAGE_NUMBER' => sprintf($lang['Page_of'], floor($start / $pafiledb_config['settings_file_page']) + 1, ceil($total_match_count / $pafiledb_config['settings_file_page'])), 'DOWNLOAD' => $pafiledb_config['settings_dbname'], 'L_HOME' => $lang['Home'], 'U_INDEX_HOME' => append_sid(CMS_PAGE_HOME), 'U_DOWNLOAD' => append_sid('dload.' . PHP_EXT), 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'XS_NEW' => $xs_new, 'L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_RATE' => $lang['DlRating'], 'L_DOWNLOADS' => $lang['Dls'], 'L_DATE' => $lang['Date'], 'L_NAME' => $lang['Name'], 'L_FILE' => $lang['File'], 'L_SUBMITER' => $lang['Submiter'], 'L_CATEGORY' => $lang['Category'], 'L_NEW_FILE' => $lang['New_file']));
             $this->display($lang['Download'], 'pa_search_result.tpl');
         } else {
             message_die(GENERAL_MESSAGE, $lang['No_search_match']);
         }
     }
     if (!isset($_POST['submit']) || $search_author == '' && $search_keywords == '' && !$search_id) {
         $dropmenu = $this->jumpmenu_option();
         $template->assign_vars(array('S_SEARCH_ACTION' => append_sid('dload.php'), 'S_CAT_MENU' => $dropmenu, 'DOWNLOAD' => $pafiledb_config['settings_dbname'], 'U_INDEX_HOME' => append_sid(CMS_PAGE_HOME), 'U_DOWNLOAD' => append_sid('dload.' . PHP_EXT), 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'XS_NEW' => $xs_new, 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_SEARCH_OPTIONS' => $lang['Search_options'], 'L_SEARCH_KEYWORDS' => $lang['Search_keywords'], 'L_SEARCH_KEYWORDS_EXPLAIN' => $lang['Search_keywords_explain'], 'L_SEARCH_AUTHOR' => $lang['Search_author'], 'L_SEARCH_AUTHOR_EXPLAIN' => $lang['Search_author_explain'], 'L_SEARCH_ANY_TERMS' => $lang['Search_for_any'], 'L_SEARCH_ALL_TERMS' => $lang['Search_for_all'], 'L_INCLUDE_COMMENTS' => $lang['Include_comments'], 'L_SORT_BY' => $lang['Select_sort_method'], 'L_SORT_DIR' => $lang['Order'], 'L_SORT_ASCENDING' => $lang['Sort_Ascending'], 'L_SORT_DESCENDING' => $lang['Sort_Descending'], 'L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_RATING' => $lang['DlRating'], 'L_DOWNLOADS' => $lang['Dls'], 'L_DATE' => $lang['Date'], 'L_NAME' => $lang['Name'], 'L_UPDATE_TIME' => $lang['Update_time'], 'L_SEARCH' => $lang['Search'], 'L_SEARCH_FOR' => $lang['Search_for'], 'L_ALL' => $lang['All'], 'L_CHOOSE_CAT' => $lang['Choose_cat']));
         $this->display($lang['Download'], 'pa_search_body.tpl');
     }
 }
Example #21
0
 /**
  * Prepares the comments for display.
  *
  * @param integer  the article id to fetch the comments for.
  *
  * @return void
  *
  * @access public
  */
 function renderComments($article_id, $start = 0)
 {
     global $config, $user, $lang;
     $trimmed = false;
     $comments = $this->data->fetchPosts($article_id, $start);
     $this->item_count = $this->data->fetchPostsCount($article_id);
     if (is_array($comments)) {
         foreach ($comments as $comment) {
             $comment['post_text'] = $this->parseMessage($comment['post_text'], $comment['enable_bbcode'], $comment['enable_html'], $comment['enable_smilies'], $comment['enable_autolinks_acronyms']);
             $dateformat = $user->data['user_id'] == ANONYMOUS ? $config['default_dateformat'] : $user->data['user_dateformat'];
             $timezone = $user->data['user_id'] == ANONYMOUS ? $config['board_timezone'] : $user->data['user_timezone'];
             $this->setBlockVariables('comments', array('L_TITLE' => $comment['post_subject'], 'POST_DATE' => create_date_ip($dateformat, $comment['post_time'], $timezone), 'L_POSTER' => colorize_username($comment['user_id'], $comment['username'], $comment['user_color'], $comment['user_active']), 'BODY' => $comment['post_text']));
         }
     }
 }
if (!empty($group_by)) {
    $group_by_array = array('host' => 'host', 'url' => 'url', 't_url' => 't_url', 'ip' => 'ip');
    $group_by_field = isset($group_by_array[$group_by]) ? $group_by_array[$group_by] : $group_by_array[0];
    $total_hits = true;
    $select_sql = ", SUM(hits) AS total_hits ";
    $group_by_sql = " GROUP BY " . $group_by_field . " ";
    $total_sql = "SELECT count(distinct(" . $group_by_field . ")) AS total FROM " . REFERERS_TABLE;
    $order_by = $mode == 'hits' ? 'total_hits' : $order_by;
}
$order_by = $group_by_sql . " ORDER BY " . $order_by . " " . $sort_dir . " LIMIT {$start}, " . $config['topics_per_page'];
$sql = "SELECT *" . $select_sql . " FROM " . REFERERS_TABLE . $order_by;
$result = $db->sql_query($sql);
$i = 0;
while ($row = $db->sql_fetchrow($result)) {
    $row_class = $i % 2 ? $theme['td_class2'] : $theme['td_class1'];
    $max_chars = 50;
    $url_name = strlen($row['url']) > $max_chars ? substr($row['url'], 0, $max_chars) . '...' : $row['url'];
    $t_url_name = strlen($row['t_url']) > $max_chars ? substr($row['t_url'], 0, $max_chars) . '...' : $row['t_url'];
    $template->assign_block_vars('refersrow', array('ID' => $i + ($start + 1), 'REFER_ID' => $row['id'], 'ROW_CLASS' => $row_class, 'HOST' => $row['host'], 'URL' => '<a href="' . htmlspecialchars($row['url']) . '" rel="nofollow" target="_blank">' . htmlspecialchars($url_name) . '</a>', 'T_URL' => '<a href="' . append_sid(IP_ROOT_PATH . $row['t_url']) . '" target="_blank">' . htmlspecialchars($t_url_name) . '</a>', 'IP' => '<a href="http://whois.sc/' . htmlspecialchars(urlencode($row['ip'])) . '" target="_blank">' . htmlspecialchars($row['ip']) . '</a>', 'HITS' => $total_hits ? $row['total_hits'] : $row['hits'], 'FIRST' => create_date_ip($config['default_dateformat'], $row['firstvisit'], $config['board_timezone']), 'LAST' => create_date_ip($config['default_dateformat'], $row['lastvisit'], $config['board_timezone'])));
    $i++;
}
$sql = !empty($total_sql) ? $total_sql : "SELECT count(*) AS total FROM " . REFERERS_TABLE;
$result = $db->sql_query($sql);
if ($total = $db->sql_fetchrow($result)) {
    $total_referers = $total['total'];
    $pagination = generate_pagination('admin_referers.' . PHP_EXT . '?mode=' . $mode . '&amp;order=' . $sort_dir . '&amp;group_by=' . $group_by, $total_referers, $config['topics_per_page'], $start) . '&nbsp;';
}
$db->sql_freeresult($result);
$template->assign_vars(array('PAGINATION' => $pagination, 'PAGE_NUMBER' => sprintf($lang['Page_of'], floor($start / $config['topics_per_page']) + 1, ceil($total_referers / $config['topics_per_page'])), 'L_GOTO_PAGE' => $lang['Goto_page']));
$template->pparse('body');
include IP_ROOT_PATH . ADM . '/page_footer_admin.' . PHP_EXT;
Example #23
0
            $folder_alt = $similar['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
            $newest_img = '';
        }
    } else {
        $folder_image = $folder;
        $folder_alt = $similar['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
        $newest_img = '';
    }
    $similar['topic_title'] = censor_text($similar['topic_title']);
    $similar_topic_title = strlen($similar['topic_title']) > 45 ? substr($similar['topic_title'], 0, 42) . '...' : $similar['topic_title'];
    // Convert and clean special chars!
    $similar_topic_title = htmlspecialchars_clean($similar_topic_title);
    // SMILEYS IN TITLE - BEGIN
    if ($config['smilies_topic_title'] == true && !$lofi) {
        $bbcode->allow_smilies = $config['allow_smilies'] ? true : false;
        $similar_topic_title = $bbcode->parse_only_smilies($similar_topic_title);
    }
    // SMILEYS IN TITLE - END
    $topic_url = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $similar['topic_id']) . '" class="' . $topic_class . '">' . $similar_topic_title . '</a>';
    $author = $similar['user_id'] != ANONYMOUS ? colorize_username($similar['user_id'], $similar['username'], $similar['user_color'], $similar['user_active']) : ($similar['post_username'] != '' ? '<span style="font-weight: bold; color: ' . $config['active_users_color'] . '">' . $similar['post_username'] . '</span>' : '<span style="font-weight: bold; color: ' . $config['active_users_color'] . '">' . $lang['Guest'] . '</span>');
    $forum_url = append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $similar['forum_id']);
    $forum = '<a href="' . $forum_url . '">' . $similar['forum_name'] . '</a>';
    $last_post_author = $similar['id2'] != ANONYMOUS ? colorize_username($similar['id2'], $similar['user2'], $similar['user_color2'], $similar['user_active2']) : ($similar['post_username2'] != '' ? '<span style="font-weight: bold; color: ' . $config['active_users_color'] . '">' . $similar['post_username2'] . '</span>' : '<span style="font-weight: bold; color: ' . $config['active_users_color'] . '">' . $lang['Guest'] . '</span>');
    $post_url = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $similar['topic_last_post_id']) . '#p' . $similar['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a><br />' . $last_post_author;
    //$post_time = create_date_ip($config['default_dateformat'], $similar['topic_time'], $config['board_timezone']);
    $post_time = create_date_ip($config['default_dateformat'], $similar['topic_last_post_time'], $config['board_timezone']);
    $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2'];
    $template->assign_block_vars('similar.topics', array('ROW_CLASS' => $row_class, 'FOLDER' => $folder_image, 'ALT' => $folder_alt, 'TYPE' => $topic_type, 'TITLE' => $topic_url, 'AUTHOR' => $author, 'FORUM' => $forum, 'REPLIES' => $replies, 'NEWEST' => $newest_img, 'POST_TIME' => $post_time, 'POST_URL' => $post_url));
}
//for
$template->assign_var_from_handle('SIMILAR_VIEWTOPIC', 'similar_viewtopic');
Example #24
0
		else
		{
			$delshout_url = '';
			$delshout_img = '';
			$delshout = '';

			$censorshout_url = '';
			$censorshout_img = '';
			$censorshout = '';
		}
	}

	$template->assign_block_vars('shoutrow', array(
		'ROW_CLASS' => $row_class,
		'SHOUT' => $shout,
		'TIME' => create_date_ip($config['default_dateformat'], $shout_row['shout_session_time'], $config['board_timezone']),
		'SHOUT_USERNAME' => $shout_username,
		'GENDER' => $gender,
		'AVATAR' => $user_avatar,
		'USER_RANK' => $user_rank,
		'RANK_IMAGE' => $rank_image,
		'JOINED' => $user_joined,
		'POSTS' => $user_posts,
		'FROM' => $user_from,

		'IP_IMG' => $ip_img,
		'IP_URL' => $ip_url,
		'IP' => $ip,
		'DELETE_IMG' => $delshout_img,
		'DELETE_URL' => $delshout_url,
		'DELETE' => $delshout,
Example #25
0
 function main($action)
 {
     global $db, $cache, $config, $images, $user, $lang, $bbcode, $pafiledb_config, $template, $pafiledb_functions;
     @(include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
     $cat_id = request_var('cat_id', 0);
     $file_id = request_var('file_id', 0);
     $action = request_var('action', '');
     if ($file_id == 0 && $action != '') {
         $file_id_array = array();
         $file_id_array = explode('=', $action);
         $file_id = $file_id_array[1];
     }
     if (empty($file_id)) {
         message_die(GENERAL_MESSAGE, $lang['File_not_exist']);
     }
     // =======================================================
     // file id is not set, give him/her a nice error message
     // =======================================================
     $sql = "SELECT f.*, AVG(r.rate_point) AS rating, COUNT(r.votes_file) AS total_votes, u.user_id, u.username, u.user_active, u.user_color, COUNT(c.comments_id) as total_comments\n\t\t\tFROM " . PA_FILES_TABLE . " AS f\n\t\t\t\tLEFT JOIN " . PA_VOTES_TABLE . " AS r ON f.file_id = r.votes_file\n\t\t\t\tLEFT JOIN " . USERS_TABLE . " AS u ON f.user_id = u.user_id\n\t\t\t\tLEFT JOIN " . PA_COMMENTS_TABLE . " AS c ON f.file_id = c.file_id\n\t\t\tWHERE f.file_id = " . (int) $file_id . "\n\t\t\tAND f.file_approved = 1\n\t\t\tGROUP BY f.file_id ";
     $result = $db->sql_query($sql);
     //===================================================
     // file doesn't exist'
     //===================================================
     if (!($file_data = $db->sql_fetchrow($result))) {
         message_die(GENERAL_MESSAGE, $lang['File_not_exist']);
     }
     $db->sql_freeresult($result);
     //===================================================
     // Pafiledb auth for viewing file
     //===================================================
     if (!$this->auth[$file_data['file_catid']]['auth_view_file']) {
         if (!$user->data['session_logged_in']) {
             redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=dload.' . PHP_EXT . '&action=file&file_id=' . $file_id, true));
         }
         $message = sprintf($lang['Sorry_auth_view'], $this->auth[$file_data['file_catid']]['auth_view_file_type']);
         message_die(GENERAL_MESSAGE, $message);
     }
     $this->generate_category_nav($file_data['file_catid']);
     $template->assign_vars(array('L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'U_INDEX_HOME' => append_sid(CMS_PAGE_HOME), 'U_DOWNLOAD_HOME' => append_sid('dload.' . PHP_EXT), 'FILE_NAME' => $file_data['file_name'], 'DOWNLOAD' => $pafiledb_config['settings_dbname']));
     //===================================================
     // Prepare file info to display them
     //===================================================
     $file_time = create_date_ip($config['default_dateformat'], $file_data['file_time'], $config['board_timezone']);
     $file_last_download = $file_data['file_last'] ? create_date_ip($config['default_dateformat'], $file_data['file_last'], $config['board_timezone']) : $lang['never'];
     $file_update_time = $file_data['file_update_time'] ? create_date_ip($config['default_dateformat'], $file_data['file_update_time'], $config['board_timezone']) : $lang['never'];
     $file_author = trim($file_data['file_creator']);
     $file_version = trim($file_data['file_version']);
     $file_screenshot_url = trim($file_data['file_ssurl']);
     $file_website_url = trim($file_data['file_docsurl']);
     //$file_rating = ($file_data['rating'] != 0) ? round($file_data['rating'], 2) . ' / 10' : $lang['Not_rated'];
     //$file_rating2 = ($file_data['rating'] != 0) ? sprintf("%.1f", round(($file_data['rating']), 2)/2) : '0.0';
     $file_rating2 = $file_data['rating'] != 0 ? sprintf("%.1f", round($file_data['rating'], 0) / 2) : '0.0';
     $file_download_link = $file_data['file_license'] > 0 ? append_sid('dload.' . PHP_EXT . '?action=license&amp;license_id=' . $file_data['file_license'] . '&amp;file_id=' . $file_id) : append_sid('dload.' . PHP_EXT . '?action=download&amp;file_id=' . $file_id);
     $file_size = $pafiledb_functions->get_file_size($file_id, $file_data);
     /*
     $file_poster = ($file_data['user_id'] != ANONYMOUS) ? '<a href="' . append_sid(CMS_PAGE_PROFILE.'?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $file_data['user_id']) . '">' : '';
     $file_poster .= ($file_data['user_id'] != ANONYMOUS) ? $file_data['username'] : $lang['Guest'];
     $file_poster .= ($file_data['user_id'] != ANONYMOUS) ? '</a>' : '';
     */
     $file_poster = $file_data['user_id'] == ANONYMOUS ? $lang['Guest'] : colorize_username($file_data['user_id'], $file_data['username'], $file_data['user_color'], $file_data['user_active']);
     $bbcode->allow_html = $config['allow_html'] ? true : false;
     $bbcode->allow_bbcode = $config['allow_bbcode'] ? true : false;
     $bbcode->allow_smilies = $config['allow_smilies'] ? true : false;
     $file_long_desc = $bbcode->parse($file_data['file_longdesc']);
     $template->assign_vars(array('L_CLICK_HERE' => $lang['Click_here'], 'L_AUTHOR' => $lang['Creator'], 'L_VERSION' => $lang['Version'], 'L_SCREENSHOT' => $lang['Scrsht'], 'L_WEBSITE' => $lang['Docs'], 'L_FILE' => $lang['File'], 'L_EDIT' => $lang['Editfile'], 'L_DELETE' => $lang['Deletefile'], 'L_DESC' => $lang['Desc'], 'L_VOTES' => $lang['Votes'], 'L_DATE' => $lang['Date'], 'L_UPDATE_TIME' => $lang['Update_time'], 'L_LASTTDL' => $lang['Lastdl'], 'L_DLS' => $lang['Dls'], 'L_RATING' => $lang['DlRating'], 'L_SIZE' => $lang['File_size'], 'L_DOWNLOAD' => $lang['Downloadfile'], 'L_RATE' => $lang['Rate'], 'L_EMAIL' => $lang['Emailfile'], 'L_SUBMITED_BY' => $lang['Submiter'], 'SHOW_AUTHOR' => !empty($file_author) ? true : false, 'SHOW_VERSION' => !empty($file_version) ? true : false, 'SHOW_SCREENSHOT' => !empty($file_screenshot_url) ? true : false, 'SHOW_WEBSITE' => !empty($file_website_url) ? true : false, 'SS_AS_LINK' => $file_data['file_sshot_link'] ? true : false, 'FILE_NAME' => $file_data['file_name'], 'FILE_LONGDESC' => $file_long_desc, 'FILE_SUBMITED_BY' => $file_poster, 'FILE_AUTHOR' => $file_author, 'FILE_VERSION' => $file_version, 'FILE_SCREENSHOT' => $file_screenshot_url, 'FILE_WEBSITE' => $file_website_url, 'AUTH_EDIT' => $this->auth[$file_data['file_catid']]['auth_edit_file'] && $file_data['user_id'] == $user->data['user_id'] || $this->auth[$file_data['file_catid']]['auth_mod'] ? true : false, 'AUTH_DELETE' => $this->auth[$file_data['file_catid']]['auth_delete_file'] && $file_data['user_id'] == $user->data['user_id'] || $this->auth[$file_data['file_catid']]['auth_mod'] ? true : false, 'AUTH_DOWNLOAD' => $this->auth[$file_data['file_catid']]['auth_download'] ? true : false, 'AUTH_RATE' => $this->auth[$file_data['file_catid']]['auth_rate'] ? true : false, 'AUTH_EMAIL' => $this->auth[$file_data['file_catid']]['auth_email'] ? true : false, 'INCLUDE_COMMENTS' => $this->auth[$file_data['file_catid']]['auth_view_comment'] ? true : false, 'DELETE_IMG' => $images['icon_delpost'], 'EDIT_IMG' => $images['icon_edit'], 'DOWNLOAD_IMG' => $images['pa_download'], 'RATE_IMG' => $images['pa_rate'], 'EMAIL_IMG' => $images['pa_email'], 'FILE_VOTES' => $file_data['total_votes'], 'TIME' => $file_time, 'UPDATE_TIME' => $file_data['file_update_time'] != $file_data['file_time'] ? $file_update_time : $lang['never'], 'RATING' => $file_rating2, 'FILE_DLS' => intval($file_data['file_dls']), 'FILE_SIZE' => $file_size, 'LAST' => $file_last_download, 'U_DELETE' => append_sid('dload.' . PHP_EXT . '?action=user_upload&amp;do=delete&amp;file_id=' . $file_id), 'U_EDIT' => append_sid('dload.' . PHP_EXT . '?action=user_upload&amp;file_id=' . $file_id), 'U_DOWNLOAD' => $file_download_link, 'U_RATE' => append_sid('dload.' . PHP_EXT . '?action=rate&amp;file_id=' . $file_id), 'U_EMAIL' => append_sid('dload.' . PHP_EXT . '?action=email&amp;file_id=' . $file_id)));
     $custom_fields = new custom_fields();
     $custom_fields->custom_table = PA_CUSTOM_TABLE;
     $custom_fields->custom_data_table = PA_CUSTOM_DATA_TABLE;
     $custom_fields->init();
     $custom_fields->display_data($file_id);
     if ($this->auth[$file_data['file_catid']]['auth_view_comment']) {
         include IP_ROOT_PATH . PA_FILE_DB_PATH . 'functions_comment.' . PHP_EXT;
         display_comments($file_data);
     }
     $this->display($lang['Download'], 'pa_file_body.tpl');
 }
function topic_list($box, $tpl = '', $topic_rowset, $list_title = '', $split_type = false, $display_nav_tree = true, $footer = '', $inbox = true, $select_field = '', $select_type = 0, $select_formname = '', $select_values = array())
{
    global $template, $db, $cache, $config, $user, $lang, $images, $theme;
    global $tree, $bbcode, $user;
    static $box_id;
    // save template state
    $sav_tpl = $template->_tpldata;
    // init
    if (empty($tpl)) {
        $tpl = 'topics_list_box';
    }
    if (empty($list_title)) {
        $list_title = $lang['Topics'];
    }
    if (!empty($select_values) && !is_array($select_values)) {
        $s_values = $select_values;
        $select_values = array();
        $select_values[] = $s_values;
    }
    // selections
    $select_multi = false;
    $select_unique = false;
    if (!empty($select_field) && $select_type > 0 && !empty($select_formname)) {
        switch ($select_type) {
            case 1:
                $select_multi = true;
                break;
            case 2:
                $select_unique = true;
                break;
        }
    }
    // get split params
    $switch_split_global_announce = isset($config['split_global_announce']) && isset($lang['Post_Global_Announcement']) ? intval($config['split_global_announce']) : false;
    $switch_split_announce = isset($config['split_announce']) ? intval($config['split_announce']) : false;
    $switch_split_sticky = isset($config['split_sticky']) ? intval($config['split_sticky']) : false;
    $switch_split_news = isset($config['split_news']) ? intval($config['split_news']) : false;
    // set in separate table
    $split_box = $inbox && (isset($config['split_topic_split']) ? intval($config['split_topic_split']) : false);
    // take care of the context
    if (!$split_type) {
        $split_box = false;
        $switch_split_global_announce = false;
        $switch_split_announce = false;
        $switch_split_sticky = false;
        $switch_split_news = false;
    }
    if (!$switch_split_global_announce && !$switch_split_announce && !$switch_split_sticky && !$switch_split_news) {
        $split_type = false;
        $split_box = false;
    }
    // read the user cookie
    $tracking_forums = isset($_COOKIE[$config['cookie_name'] . '_f']) ? unserialize($_COOKIE[$config['cookie_name'] . '_f']) : array();
    $tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_t']) ? unserialize($_COOKIE[$config['cookie_name'] . '_t']) : array();
    $tracking_all = isset($_COOKIE[$config['cookie_name'] . '_f_all']) ? intval($_COOKIE[$config['cookie_name'] . '_f_all']) : NULL;
    // categories hierarchy v 2 compliancy
    $cat_hierarchy = function_exists('get_auth_keys');
    if (!$cat_hierarchy) {
        // standard read
        $is_auth = array();
        $is_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $user->data);
    }
    // topic icon present
    $icon_installed = function_exists('get_icon_title');
    // get a default title
    if (empty($list_title)) {
        $list_title = $lang['forum'];
    }
    // choose template
    $template->set_filenames(array($tpl => $tpl . '.tpl'));
    // check if user replied to the topic
    $user_topics = array();
    if ($user->data['user_id'] != ANONYMOUS) {
        // get all the topic ids to display
        $topic_ids = array();
        for ($i = 0; $i < sizeof($topic_rowset); $i++) {
            $topic_item_type = substr($topic_rowset[$i]['topic_id'], 0, 1);
            $topic_id = intval(substr($topic_rowset[$i]['topic_id'], 1));
            if ($topic_item_type == POST_TOPIC_URL) {
                $topic_ids[] = $topic_id;
            }
        }
        // check if the user replied to
        if (!empty($topic_ids)) {
            // check the posts
            $s_topic_ids = implode(', ', $topic_ids);
            $sql = "SELECT DISTINCT topic_id FROM " . POSTS_TABLE . "\n\t\t\t\t\tWHERE topic_id IN ({$s_topic_ids})\n\t\t\t\t\t\tAND poster_id = " . $user->data['user_id'];
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $user_topics[POST_TOPIC_URL . $row['topic_id']] = true;
            }
        }
    }
    // initiate
    $template->assign_block_vars($tpl, array('FORMNAME' => $select_formname, 'FIELDNAME' => $select_field));
    // spanning of the first column (list name)
    $span_left = 1;
    if (sizeof($topic_rowset) > 0) {
        // add folder image
        $span_left++;
    }
    if ($icon_installed) {
        // add topic icon
        $span_left++;
    }
    if ($select_unique) {
        // selection in front is asked
        $span_left++;
    }
    // spanning of the whole line (bottom row and/or empty list)
    $span_all = $span_left + 4;
    if ($select_multi && sizeof($topic_rowset) > 0) {
        $span_all++;
    }
    // display topics
    $color = false;
    $prec_topic_type = '';
    $header_sent = false;
    if (!isset($box_id)) {
        $box_id = -1;
    }
    for ($i = 0; $i < sizeof($topic_rowset); $i++) {
        $topic_item_type = substr($topic_rowset[$i]['topic_id'], 0, 1);
        $topic_id = intval(substr($topic_rowset[$i]['topic_id'], 1));
        $topic_title = censor_text($topic_rowset[$i]['topic_title']);
        $replies = $topic_rowset[$i]['topic_replies'];
        $topic_type = $topic_rowset[$i]['topic_type'];
        $user_replied = !empty($user_topics) && isset($user_topics[$topic_rowset[$i]['topic_id']]);
        $force_type_display = false;
        $forum_id = $topic_rowset[$i]['forum_id'];
        if (defined('POST_BIRTHDAY') && $topic_type == POST_BIRTHDAY) {
            $topic_type = $lang['Birthday'] . ': ';
        } elseif ($topic_type == POST_NEWS) {
            $topic_type = $lang['News'] . ': ';
        } elseif ($topic_type == POST_GLOBAL_ANNOUNCE) {
            $topic_type = $lang['Topic_Global_Announcement'] . ' ';
        } elseif ($topic_type == POST_ANNOUNCE) {
            $topic_type = $lang['Topic_Announcement'] . ' ';
        } elseif ($topic_type == POST_STICKY) {
            $topic_type = $lang['Topic_Sticky'] . ' ';
        } else {
            $topic_type = '';
        }
        if (!empty($topic_rowset[$i]['poll_start']) && $topic_rowset[$i]['topic_status'] != TOPIC_MOVED) {
            $topic_type .= $lang['Topic_Poll'] . ' ';
            $force_type_display = true;
        }
        if (defined('POST_BIRTHDAY') && $topic_rowset[$i]['topic_type'] == POST_BIRTHDAY) {
            $folder_image = $images['folder_birthday'];
            $folder_alt = $lang['HAPPY_BIRTHDAY'];
            $newest_post_img = '';
        } elseif ($topic_rowset[$i]['topic_status'] == TOPIC_MOVED) {
            $topic_type = $lang['Topic_Moved'] . ' ';
            $topic_id = $topic_rowset[$i]['topic_moved_id'];
            $folder_image = $images['topic_nor_read'];
            $folder_alt = $lang['Topics_Moved'];
            $newest_post_img = '';
            $force_type_display = true;
        } else {
            /*
            define('USER_REPLIED_ICON', true);
            $user_replied = true;
            */
            if (defined('POST_BIRTHDAY') && $topic_rowset[$i]['topic_type'] == POST_BIRTHDAY) {
                $folder = $images['folder_birthday'];
                $folder_new = $images['folder_birthday'];
            } elseif ($topic_rowset[$i]['topic_type'] == POST_NEWS) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_read_own'] : $images['topic_nor_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_unread_own'] : $images['topic_nor_unread'];
            } elseif ($topic_rowset[$i]['topic_type'] == POST_GLOBAL_ANNOUNCE) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_glo_read_own'] : $images['topic_glo_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_glo_unread_own'] : $images['topic_glo_unread'];
            } elseif ($topic_rowset[$i]['topic_type'] == POST_ANNOUNCE) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_ann_read_own'] : $images['topic_ann_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_ann_unread_own'] : $images['topic_ann_unread'];
            } elseif ($topic_rowset[$i]['topic_type'] == POST_STICKY) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_imp_read_own'] : $images['topic_imp_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_imp_unread_own'] : $images['topic_imp_unread'];
            } elseif ($topic_rowset[$i]['topic_status'] == TOPIC_LOCKED) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_locked_read_own'] : $images['topic_nor_locked_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_locked_unread_own'] : $images['topic_nor_locked_unread'];
            } else {
                if ($replies >= $config['hot_threshold']) {
                    $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_hot_read_own'] : $images['topic_hot_read'];
                    $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_hot_unread_own'] : $images['topic_hot_unread'];
                } else {
                    $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_read_own'] : $images['topic_nor_read'];
                    $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_unread_own'] : $images['topic_nor_unread'];
                }
            }
            $newest_post_img = '';
            if ($user->data['session_logged_in'] && $topic_item_type == POST_TOPIC_URL) {
                // UPI2DB - BEGIN
                if (!$user->data['upi2db_access']) {
                    // UPI2DB - END
                    if ($topic_rowset[$i]['post_time'] > $user->data['user_lastvisit']) {
                        if (!empty($tracking_topics) || !empty($tracking_forums) || !empty($tracking_all)) {
                            $unread_topics = true;
                            if (!empty($tracking_topics[$topic_id])) {
                                if ($tracking_topics[$topic_id] >= $topic_rowset[$i]['post_time']) {
                                    $unread_topics = false;
                                }
                            }
                            if (!empty($tracking_forums[$forum_id])) {
                                if ($tracking_forums[$forum_id] >= $topic_rowset[$i]['post_time']) {
                                    $unread_topics = false;
                                }
                            }
                            if (!empty($tracking_all)) {
                                if ($tracking_all >= $topic_rowset[$i]['post_time']) {
                                    $unread_topics = false;
                                }
                            }
                            if ($unread_topics) {
                                $folder_image = $folder_new;
                                $folder_alt = $lang['New_posts'];
                                $newest_post_img = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . "?" . POST_TOPIC_URL . "={$topic_id}&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" /></a> ';
                            } else {
                                $folder_image = $folder;
                                $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                                $newest_post_img = '';
                            }
                        } else {
                            $folder_image = $folder_new;
                            $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['New_posts'];
                            $newest_post_img = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . "?" . POST_TOPIC_URL . "={$topic_id}&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" /></a> ';
                        }
                    } else {
                        $folder_image = $folder;
                        $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                        $newest_post_img = '';
                    }
                    // UPI2DB - BEGIN
                } else {
                    viewforum_calc_unread($user->data['upi2db_unread'], $topic_id, $topic_rowset, $i, $folder_new, $folder, $folder_alt, $folder_image, $newest_post_img, $upi2db_status);
                }
                // UPI2DB - END
            } else {
                $folder_image = $folder;
                $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                $newest_post_img = '';
            }
        }
        // generate list of page for the topic
        $topic_pagination = generate_topic_pagination($forum_id, $topic_id, $replies);
        $topic_author = '';
        $first_post_time = '';
        $last_post_time = '';
        $last_post_url = '';
        $views = '';
        switch ($topic_item_type) {
            case POST_USERS_URL:
                $view_topic_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id);
                break;
            default:
                $view_topic_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id);
                $topic_author = $topic_rowset[$i]['user_id'] != ANONYMOUS ? '<a href="' . append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $topic_rowset[$i]['user_id']) . '">' : '';
                $topic_author .= $topic_rowset[$i]['user_id'] != ANONYMOUS ? $topic_rowset[$i]['username'] : ($topic_rowset[$i]['post_username'] != '' ? $topic_rowset[$i]['post_username'] : $lang['Guest']);
                $topic_author .= $topic_rowset[$i]['user_id'] != ANONYMOUS ? '</a>' : '';
                $first_post_time = create_date_ip($config['default_dateformat'], $topic_rowset[$i]['topic_time'], $config['board_timezone']);
                $last_post_time = create_date_ip($config['default_dateformat'], $topic_rowset[$i]['post_time'], $config['board_timezone']);
                $last_post_author = $topic_rowset[$i]['id2'] == ANONYMOUS ? $topic_rowset[$i]['post_username2'] != '' ? $topic_rowset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' : '<a href="' . append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $topic_rowset[$i]['id2']) . '">' . $topic_rowset[$i]['user2'] . '</a>';
                $last_post_url = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $topic_rowset[$i]['topic_last_post_id']) . '#p' . $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
                $views = $topic_rowset[$i]['topic_views'];
                // BEGIN cmx_mod
                $news_label = $topic_rowset[$i]['news_id'] > 0 ? $lang['News'] . ':' : '';
                // END cmx_mod
                break;
        }
        // categories hierarchy v 2 compliancy
        $nav_tree = '';
        if ($display_nav_tree && !empty($topic_rowset[$i]['forum_id'])) {
            if ($cat_hierarchy) {
                if ($tree['auth'][POST_FORUM_URL . $topic_rowset[$i]['forum_id']]['tree.auth_view']) {
                    $nav_tree = make_cat_nav_tree(POST_FORUM_URL . $topic_rowset[$i]['forum_id'], '', '', 'gensmall');
                }
            } else {
                if ($is_auth[$topic_rowset[$i]['forum_id']]['auth_view']) {
                    $nav_tree = '<a href="' . append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $topic_rowset[$i]['forum_id']) . '" class="gensmall">' . $topic_rowset[$i]['forum_name'] . '</a>';
                }
            }
        }
        if (!empty($nav_tree)) {
            $nav_tree = '[ ' . $nav_tree . ' ]';
        }
        // get the type for rupture
        $topic_real_type = $topic_rowset[$i]['topic_type'];
        // if no split between global and standard announcement, group them with standard announcement
        if (!$switch_split_global_announce && $topic_real_type == POST_GLOBAL_ANNOUNCE) {
            $topic_real_type = POST_ANNOUNCE;
        }
        // if no split between announce and sticky, group them with sticky
        if (!$switch_split_announce && $topic_real_type == POST_ANNOUNCE) {
            $topic_real_type = POST_NEWS;
        }
        // if no split between news and global announcement, group them with normal
        if (!$switch_split_news && $topic_real_type == POST_NEWS) {
            $topic_real_type = POST_STICKY;
        }
        // if no split between sticky and normal, group them with normal
        if (!$switch_split_sticky && $topic_real_type == POST_STICKY) {
            $topic_real_type = POST_NORMAL;
        }
        // check if rupture
        $rupt = false;
        // split
        if ($i == 0 || $split_type) {
            if ($i == 0) {
                $rupt = true;
            }
            // check the rupt
            if ($prec_topic_type != $topic_real_type) {
                $rupt = true;
            }
        }
        $prec_topic_type = $topic_real_type;
        // header
        if ($rupt) {
            // close the prec box
            if ($split_box && $i != 0) {
                // footer
                $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all));
                // table closure
                $template->assign_block_vars($tpl . '.row.footer_table', array());
                // spacing
                $template->assign_block_vars($tpl . '.row', array());
                $template->assign_block_vars($tpl . '.row.spacer', array());
                // unset header
                $header_sent = false;
            }
            // get box title
            $main_title = $list_title;
            $sub_title = $list_title;
            switch ($topic_real_type) {
                case POST_BIRTHDAY:
                    $sub_title = $lang['Birthday'];
                    break;
                case POST_NEWS:
                    $sub_title = $lang['News'];
                    break;
                case POST_GLOBAL_ANNOUNCE:
                    $sub_title = $lang['Post_Global_Announcement'];
                    break;
                case POST_ANNOUNCE:
                    $sub_title = $lang['Post_Announcement'];
                    break;
                case POST_STICKY:
                    $sub_title = $lang['Post_Sticky'];
                    break;
                case POST_CALENDAR:
                    $sub_title = $lang['Calendar_event'];
                    break;
                case POST_NORMAL:
                    $sub_title = $lang['Topics'];
                    break;
            }
            $template->assign_block_vars($tpl . '.row', array('L_TITLE' => !$split_box ? $main_title : $sub_title, 'L_REPLIES' => $lang['Replies'], 'L_AUTHOR' => $lang['Author'], 'L_VIEWS' => $lang['Views'], 'L_LASTPOST' => $lang['Last_Post'], 'COLSPAN' => $span_all));
            // open a new box
            if ($split_box || $i == 0) {
                $box_id++;
                $template->assign_block_vars($tpl . '.row.header_table', array('COLSPAN' => $span_left, 'BOX_ID' => $box_id));
                // selection fields
                if ($select_multi) {
                    $template->assign_block_vars($tpl . '.row.header_table.multi_selection', array());
                }
                // set header
                $header_sent = true;
            }
            // not in box, send a row title
            if ($split_type && !$split_box) {
                $template->assign_block_vars($tpl . '.row', array('L_TITLE' => $sub_title, 'COLSPAN' => $span_all));
                $template->assign_block_vars($tpl . '.row.header_row', array());
            }
        }
        // erase the type before the title if split
        if ($split_type && $topic_real_type == $topic_rowset[$i]['topic_type'] && !$force_type_display) {
            $topic_type = '';
        }
        // get the announces dates
        $topic_announces_dates = '';
        // get the calendar dates
        $topic_calendar_dates = '';
        if (function_exists(get_calendar_title)) {
            $topic_calendar_dates = get_calendar_title($topic_rowset[$i]['topic_calendar_time'], $topic_rowset[$i]['topic_calendar_duration']);
        }
        // get the topic icons
        $icon = '';
        if ($icon_installed) {
            $type = $topic_rowset[$i]['topic_type'];
            if ($type == POST_NORMAL) {
                if (defined('POST_CALENDAR') && !empty($topic_rowset[$i]['topic_calendar_time'])) {
                    $type = POST_CALENDAR;
                }
                if (defined('POST_PICTURE') && !empty($topic_rowset[$i]['topic_pic_url'])) {
                    $type = POST_PICTURE;
                }
            }
            $icon = get_icon_title($topic_rowset[$i]['topic_icon'], 1, $type);
        }
        // UPI2DB - BEGIN
        if ($user->data['upi2db_access']) {
            $mark_always_read = mark_always_read($topic_rowset[$i]['topic_type'], $topic_id, $forum_id, 'viewforum', 'icon', $user->data['upi2db_unread'], $start, $folder_image);
        } else {
            $mark_always_read = '<img src="' . $folder_image . '" alt="' . $folder_alt . '" title="' . $folder_alt . '" />';
        }
        // UPI2DB - END
        // send topic to template
        $selected = !empty($select_values) && in_array($topic_rowset[$i]['topic_id'], $select_values);
        $color = !$color;
        $template->assign_block_vars($tpl . '.row', array('ROW_CLASS' => $color || !defined('TOPIC_ALTERNATE_ROW_CLASS') ? $theme['td_class1'] : $theme['td_class2'], 'ROW_FOLDER_CLASS' => $user_replied && defined('USER_REPLIED_CLASS') ? USER_REPLIED_CLASS : ($color || !defined('TOPIC_ALTERNATE_ROW_CLASS') ? $theme['td_class1'] : $theme['td_class2']), 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'TOPIC_FOLDER_IMG' => $folder_image, 'TOPIC_AUTHOR' => $topic_author, 'TOPIC_DESCRIPTION' => $topic_desc, 'GOTO_PAGE' => $topic_pagination['base'], 'GOTO_PAGE_FULL' => $topic_pagination['full'], 'TOPIC_NAV_TREE' => !empty($nav_tree) ? (empty($goto_page) ? '<br />' : '') . $nav_tree : '', 'REPLIES' => $replies, 'NEWEST_POST_IMG' => $newest_post_img, 'TOPIC_ATTACHMENT_IMG' => topic_attachment_image($topic_rowset[$i]['topic_attachment']), 'ICON' => $icon, 'TOPIC_TITLE' => $topic_title, 'TOPIC_ANNOUNCES_DATES' => $topic_announces_dates, 'TOPIC_CALENDAR_DATES' => $topic_calendar_dates, 'TOPIC_TYPE' => $topic_type, 'VIEWS' => $views, 'FIRST_POST_TIME' => $first_post_time, 'LAST_POST_TIME' => $last_post_time, 'LAST_POST_AUTHOR' => $last_post_author, 'LAST_POST_IMG' => $last_post_url, 'L_NEWS' => $news_label, 'L_TOPIC_FOLDER_ALT' => $folder_alt, 'U_VIEW_TOPIC' => $view_topic_url, 'BOX_ID' => $box_id, 'FID' => $topic_rowset[$i]['topic_id'], 'U_MARK_ALWAYS_READ' => $mark_always_read, 'L_SELECT' => $selected && ($select_multi || $select_unique) ? 'checked="checked"' : ''));
        $template->assign_block_vars($tpl . '.row.topic', array());
        if (!empty($topic_rowset[$i]['topic_desc']) && $config['show_topic_description']) {
            $template->assign_block_vars($tpl . '.row.topic.switch_topic_desc', array());
        }
        // selection fields
        if ($select_multi) {
            $template->assign_block_vars($tpl . '.row.topic.multi_selection', array());
        }
        if ($select_unique) {
            $template->assign_block_vars($tpl . '.row.topic.single_selection', array());
        }
        // icons
        if ($icon_installed) {
            $template->assign_block_vars($tpl . '.row.topic.icon', array());
        }
        // nav tree asked
        if ($display_nav_tree && !empty($nav_tree)) {
            $template->assign_block_vars($tpl . '.row.topic.nav_tree', array());
        }
    }
    // end for topic_rowset read
    // send an header if missing
    if (!$header_sent) {
        $template->assign_block_vars($tpl . '.row', array('L_TITLE' => $list_title, 'L_REPLIES' => $lang['Replies'], 'L_AUTHOR' => $lang['Author'], 'L_VIEWS' => $lang['Views'], 'L_LASTPOST' => $lang['Last_Post'], 'COLSPAN' => $span_all));
        // open a new box
        $template->assign_block_vars($tpl . '.row.header_table', array('COLSPAN' => $span_left));
    }
    // no data
    if (sizeof($topic_rowset) == 0) {
        // send no topics notice
        $template->assign_block_vars($tpl . '.row', array('L_NO_TOPICS' => $lang['No_search_match'], 'COLSPAN' => $span_all));
        $template->assign_block_vars($tpl . '.row.no_topics', array());
    }
    // bottom line
    if (!empty($footer)) {
        $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all, 'FOOTER' => $footer));
        $template->assign_block_vars($tpl . '.row.bottom', array());
    }
    // table closure
    $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all));
    $template->assign_block_vars($tpl . '.row.footer_table', array());
    // spacing
    if (empty($footer)) {
        // spacing
        $template->assign_block_vars($tpl . '.row', array());
        $template->assign_block_vars($tpl . '.row.spacer', array());
    }
    // transfert to a var
    $template->assign_var_from_handle('_box', $tpl);
    $res = $template->_tpldata['.'][0]['_box'];
    // restore template saved state
    $template->_tpldata = $sav_tpl;
    // assign value to the main template
    $template->assign_vars(array($box => $res));
}
Example #27
0
				FROM " . PROFILE_VIEW_TABLE . " p, " . USERS_TABLE . " u
				WHERE p.viewer_id = u.user_id
					AND p.user_id = " . $user_id . "
				ORDER BY p.view_stamp DESC
				LIMIT " . $start . ", " . $config['posts_per_page'];
$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
	$viewer = $row['viewer_id'];
	$viewer_avatar = user_get_avatar($row['viewer_id'], $row['user_level'], $row['user_avatar'], $row['user_avatar_type'], $row['user_allowavatar']);
	$template->assign_block_vars('row', array(
		'AVATAR' => $viewer_avatar,
		'VIEW_BY' => colorize_username($viewer, $row['username'], $row['user_color'], $row['user_active']),
		'NUMBER' => $row['counter'],
		'STAMP' => create_date_ip($user->data['user_dateformat'], $row['view_stamp'], $user->data['user_timezone'])
		)
	);
}

$template->assign_vars(array(
	'PAGINATION' => generate_pagination('profile_view_user.' . PHP_EXT . '?' . POST_USERS_URL . '=' . $user_id, $total, $config['posts_per_page'], $start),
	'PROFILE' => '<a href="' . append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $user_id) . '" class="nav-current">' . $profile['username'] . '</a>',
	'L_VIEW_TITLE' => $meta_content['page_title'],
	'L_VIEWER' => $lang['Username'],
	'L_NUMBER' => $lang['Views'],
	'L_STAMP' => $lang['Last_updated']
	)
);

full_page_generation('profile_view_user_body.tpl', $lang['Profile'] . ' - ' . $lang['Views'], '', '');
Example #28
0
        } elseif ($draft_row[$i]['forum_id'] != 0) {
            $sql_d = "SELECT f.*\n\t\t\t\tFROM " . FORUMS_TABLE . " f\n\t\t\t\tWHERE f.forum_id = '" . $draft_row[$i]['forum_id'] . "'\n\t\t\t\tLIMIT 1";
            $result_d = $db->sql_query($sql_d);
            $draft_row_data = $db->sql_fetchrow($result_d);
            $db->sql_freeresult($result_d);
            $draft_image = '<img src="' . $images['topic_nor_unread'] . '" alt="" />';
            $draft_type = $lang['Drafts_NT'];
            $draft_load = 'loadn';
            $draft_cat_link = append_sid(IP_ROOT_PATH . CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $draft_row_data['forum_id']);
            $draft_title_link = append_sid(IP_ROOT_PATH . 'drafts.' . PHP_EXT . '?mode=' . $draft_load . '&amp;d=' . $draft_row[$i]['draft_id']);
            $draft_row[$i]['draft_cat'] = '<a href="' . $draft_cat_link . '">' . $draft_row_data['forum_name'] . '</a>';
            $draft_row[$i]['draft_title'] = '<a href="' . $draft_title_link . '">' . $draft_row[$i]['draft_subject'] . '</a>';
        } else {
            $draft_image = '<img src="' . $images['topic_nor_read'] . '" alt="" />';
            $draft_type = $lang['Drafts_NPM'];
            $draft_load = 'loadp';
            $draft_cat_link = append_sid(IP_ROOT_PATH . CMS_PAGE_PRIVMSG);
            $draft_title_link = append_sid(IP_ROOT_PATH . 'drafts.' . PHP_EXT . '?mode=' . $draft_load . '&amp;d=' . $draft_row[$i]['draft_id']);
            $draft_subject = $draft_row[$i]['draft_subject'] ? $draft_row[$i]['draft_subject'] : '...';
            // Missing subject produces an empty link
            $draft_row[$i]['draft_cat'] = '<a href="' . $draft_cat_link . '">' . $lang['Drafts_NPM'] . '</a>';
            $draft_row[$i]['draft_title'] = '<a href="' . $draft_title_link . '">' . $draft_subject . '</a>';
        }
        $row_class = ip_zebra_rows($row_class);
        $template->assign_block_vars('draft_row', array('ROW_CLASS' => $row_class, 'S_DRAFT_ID' => $draft_row[$i]['draft_id'], 'DRAFT_IMG' => $draft_image, 'DRAFT_TYPE' => $draft_type, 'DRAFT_CAT_LINK' => $draft_cat_link, 'DRAFT_CAT' => $draft_row[$i]['draft_cat'], 'DRAFT_TITLE_LINK' => $draft_title_link, 'DRAFT_TITLE' => $draft_row[$i]['draft_title'], 'DRAFT_TIME' => create_date_ip($config['default_dateformat'], $draft_row[$i]['save_time'], $config['board_timezone']), 'U_DRAFT_LOAD' => append_sid(IP_ROOT_PATH . 'drafts.' . PHP_EXT . '?mode=' . $draft_load . '&amp;d=' . $draft_row[$i]['draft_id']), 'U_DRAFT_DELETE' => append_sid(IP_ROOT_PATH . 'drafts.' . PHP_EXT . '?mode=delete&amp;d=' . $draft_row[$i]['draft_id'])));
    }
    $template->assign_vars(array('PAGINATION' => generate_pagination('drafts.' . PHP_EXT . '?mode=list', $drafts_count, $config['topics_per_page'], $start), 'PAGE_NUMBER' => sprintf($lang['Page_of'], floor($start / $config['topics_per_page']) + 1, ceil($drafts_count / $config['topics_per_page'])), 'L_GOTO_PAGE' => $lang['Goto_page']));
} else {
    $template->assign_block_vars('switch_no_drafts', array());
}
full_page_generation('drafts_body.tpl', $lang['Drafts'], '', '');
        foreach ($info_array as $module_name => $file_array) {
            if ($file_array['junior_admin'] == true) {
                if ($cat_started == false) {
                    $template->assign_block_vars('catrow', array('CAT' => isset($lang[$cat]) ? $lang[$cat] : preg_replace("/_/", ' ', $cat), 'NUM' => $i));
                    $cat_started = true;
                }
                $file_hash = $file_array['file_hash'];
                $checked = in_array($file_hash, $user_module_list) ? 'checked="checked"' : '';
                $template->assign_block_vars('catrow.modulerow', array('ROW' => $i % 2 ? 'row1' : 'row2', 'NAME' => isset($lang[$module_name]) ? $lang[$module_name] : preg_replace("/_/", ' ', $module_name), 'FILENAME' => $file_array['filename'], 'FILE_HASH' => $file_hash, 'CHECKED' => $checked));
            }
        }
        $i++;
    }
    $disabled = 'disabled';
    $disabled_text = $lang['Disabled_Color_Groups'];
    $template->assign_vars(array('USER_ID' => $user_id, 'USERNAME_FULL' => colorize_username($row['user_id'], $row['username'], $row['user_color'], $row['user_active']), 'USERNAME' => $row['username'], 'DISABLED' => $disabled, 'DISABLED_TEXT' => $disabled_text, 'START_DATE' => $jr_admin_row['start_date'] ? create_date_ip($config['default_dateformat'], $jr_admin_row['start_date'], $config['board_timezone']) : $lang['Never'], 'UPDATE_DATE' => $jr_admin_row['update_date'] ? create_date_ip($config['default_dateformat'], $jr_admin_row['update_date'], $config['board_timezone']) : $lang['Never'], 'NOTES' => $jr_admin_row['admin_notes'], 'NOTES_VIEW_CHECKED' => $jr_admin_row['notes_view'] ? 'checked="checked"' : '', 'ADMIN_TEXT' => $row['user_level'] == ADMIN ? $lang['Admin_Note'] : ''));
    $template->set_filenames(array('body' => ADM_TPL . 'jr_admin_user_permissions.tpl'));
} else {
    //Update info like module list and color groups
    if (isset($_POST['update_user']) && !empty($user_id)) {
        $user_update_list = '';
        foreach ($_POST as $key => $val) {
            if (preg_match($update_find_pattern, $key)) {
                $user_update_list .= !empty($user_update_list) ? EXPLODE_SEPARATOR_CHAR : '';
                $user_update_list .= preg_replace($update_find_pattern, '', $key);
            }
        }
        if (!jr_admin_user_exist($user_id)) {
            //If the user_id doesn't exist in the table, we need to add it
            //before we can update!
            sql_query_nivisec('INSERT INTO ' . JR_ADMIN_TABLE . "\n\t\t\t(user_id, start_date) VALUES ({$user_id}, " . time() . ')', $lang['Error_Module_Table']);
Example #30
0
function ratings_large()
{
    global $template, $db, $config, $theme, $lang, $meta_content, $forum_top;
    if (!isset($forum_top)) {
        $forum_top = -1;
    }
    $top_rated_row = top_rated_topics($config['large_rating_return_limit'], $forum_top);
    $rank = 0;
    if (sizeof($top_rated_row)) {
        for ($i = 0; $i < sizeof($top_rated_row); $i++) {
            $last_rate_info = last_rating_info($top_rated_row[$i]['topic_id']);
            $template->assign_block_vars('topicrow', array('RANK' => ++$rank, 'CLASS' => !($rank % 2) ? $theme['td_class2'] : $theme['td_class1'], 'URL' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $top_rated_row[$i]['topic_id']), 'LAST_RATER' => id_to_value($last_rate_info['user'], 'user'), 'LAST_RATER_TIME' => create_date_ip($config['default_dateformat'], $last_rate_info['time'], $config['board_timezone']), 'TITLE' => id_to_value($top_rated_row[$i]['topic_id'], 'topic'), 'FORUM' => id_to_value(id_to_value($top_rated_row[$i]['topic_id'], 'topictoforum'), 'forum'), 'RATING' => sprintf('%.2f', $top_rated_row[$i]['average']), 'MIN' => $top_rated_row[$i]['min'], 'MAX' => $top_rated_row[$i]['max'], 'L_VIEW_DETAILS' => $config['allow_ext_rating'] ? sprintf($lang['View_Details_2'], append_sid('rate.' . PHP_EXT . '?rate_mode=detailed&amp;topic_id=' . $top_rated_row[$i]['topic_id'])) : '', 'NUMBER_OF_RATES' => $top_rated_row[$i]['rating_number']));
        }
    } else {
        $template->assign_block_vars('notopics', array('MESSAGE' => $lang['No_Topics_Rated']));
    }
    $template->assign_vars(array('PAGE_NAME' => $meta_content['page_title'], 'L_FOR_FORUM' => $forum_top != -1 ? sprintf($lang['For_Forum'], id_to_value($forum_top, 'forum')) : $lang['All_Forums'], 'L_LAST_RATED' => $lang['Last_Rated'], 'L_RATES' => $lang['Number_of_Rates'], 'L_RATING' => $lang['Rating'], 'L_MIN' => $lang['Min_Rating'], 'L_MAX' => $lang['Max_Rate'], 'S_FORUMS' => make_forum_drop_down_box(), 'S_MODE_ACTION' => append_sid('rate.' . PHP_EXT), 'L_BY_FORUM' => $lang['By_Forum'], 'L_VIEW' => $lang['Go']));
    // JHL: Template vars commented out to use standard TPL features
    /*
    $template->set_filenames(array('body' => 'rate_main.tpl'));
    $template->pparse('body');
    */
}