XtGem Forum catalog
sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql); } if ( $row = $db->sql_fetchrow($result) ) { $i = 0; do { if ( $row['site_order'] ) { if ( $row['site_time'] < time() ) { $sqldel = "DELETE FROM ".$table_prefix."shop_sites WHERE id = " . $row['id']; $resultdel = $db->sql_query($sqldel); } else { $niz .= '' . $row['site_desc'] . '
'; } } else { if ( $row['site_time'] < time() ) { $sqldel = "DELETE FROM ".$table_prefix."shop_sites WHERE id = " . $row['id']; $resultdel = $db->sql_query($sqldel); } else { $verh .= '' . $row['site_desc'] . '
'; } } $i++; } while ( $row = $db->sql_fetchrow($result) ); $db->sql_freeresult($result); } $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array(); $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array(); $total_posts = get_db_stat('postcount'); $total_users = get_db_stat('usercount'); $total_attach = get_db_stat('attachcount'); $newest_userdata = get_db_stat('newestuser'); $newest_user = $newest_userdata['username']; $newest_uid = $newest_userdata['user_id']; $statistika = "

".sprintf($lang['Posted_articles_total'], $total_posts)."
\n".sprintf($lang['Attach_total'], $total_attach)."
\n".sprintf($lang['Registered_users_total'], $total_users)."
\n".sprintf($lang['Newest_user'], '', $newest_user, '')."

"; $ban_information = session_userban($user_ip, $userdata['user_id']); if ($ban_information) { $ban = '
Chú ý!
Của bạn '.$ban_information.'
'; } else { $ban = ''; } $sql = "SELECT c.cat_id, c.cat_title, c.cat_order FROM " . CATEGORIES_TABLE . " c ORDER BY c.cat_order"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql); } $category_rows = array(); while ($row = $db->sql_fetchrow($result)) { $category_rows[] = $row; } $db->sql_freeresult($result); $total_categories = count($category_rows); $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id FROM (( " . FORUMS_TABLE . " f LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id ) LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id ) ORDER BY f.cat_id, f.forum_order"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql); } $forum_data = array(); while( $row = $db->sql_fetchrow($result) ) { $forum_data[] = $row; } $db->sql_freeresult($result); $total_forums = count($forum_data); if ($userdata['session_logged_in']) { if ($userdata['user_lastvisit'] < (time() - 5184000)) { $userdata['user_lastvisit'] = time() - 5184000; } $sql = "SELECT t.forum_id, t.topic_id, p.post_time FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p WHERE p.post_id = t.topic_last_post_id AND p.post_time > " . $userdata['user_lastvisit'] . " AND t.topic_moved_id = 0"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql); } $new_topic_data = array(); while( $topic_data = $db->sql_fetchrow($result) ) { $new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time']; } $db->sql_freeresult($result); } $admin_link = ( $userdata['user_level'] == ADMIN ) ? '- ' . $lang['Admin_panel'] . '' : ''; $is_auth_ary = array(); $is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data); $MAX_STR_LEN = 60; $MAX_TOPICS = 10; $AUTH_SECRUITY = 1; $sortby="topic_last_post_id"; function cutStr($str) { global $MAX_STR_LEN; $str = (strlen($str) > $MAX_STR_LEN) ? (substr($str, 0, $MAX_STR_LEN - 1) . "...") : $str; return $str; } $is_auth_ary_top5 = array(); $is_auth_ary_top5 = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); $auth_forum_ary_top5 = array(); $sql = "SELECT forum_id FROM " . FORUMS_TABLE; if( !$q_forums = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch forum info fail', __LINE__, __FILE__, $sql); } while( $forum_row = $db->sql_fetchrow($q_forums) ) { $forum_id1 = $forum_row['forum_id']; if( $is_auth_ary_top5[$forum_id1]['auth_read'] == 1) { if(function_exists("array_push")) { array_push($auth_forum_ary_top5, $forum_id1); } else { $auth_id=count($auth_forum_ary_top5); $auth_forum_ary_top5[$auth_id]=$forum_id1; } } } if( sizeOf($auth_forum_ary_top5) == 0 || !$AUTH_SECRUITY ) { $auth_forums_top5 = ""; } else { $auth_forums_top5 = 'AND f.forum_id IN('; if(sizeOf($auth_forum_ary_top5) > 1) { $auth_forums_top5 .= implode (',', $auth_forum_ary_top5); } else { $auth_forums_top5 .= $auth_forum_ary_top5[0]; } $auth_forums_top5 .= ')'; } $sql = "SELECT topic_id, topic_title, topic_poster, topic_views, topic_replies, topic_last_post_id, f.forum_id, forum_name FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f WHERE t.forum_id = f.forum_id AND topic_moved_id = '0' $auth_forums_top5 ORDER BY $sortby DESC LIMIT 0, $MAX_TOPICS"; if( !$result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch topic info fail', __LINE__, __FILE__, $sql); } while( $rows = $db->sql_fetchrow($result) ) { $topic_url = append_sid("viewtopic.$phpEx?t=" . $rows['topic_id']); $forum_url = append_sid("viewforum.$phpEx?f=" . $rows['forum_id']); $topic_poster = $rows['topic_poster']; $topic_last_post_id = $rows['topic_last_post_id']; $sql = "SELECT post_username, user_id, username FROM " . POSTS_TABLE . ", " . USERS_TABLE . " WHERE topic_id = '" . $rows['topic_id'] . "' AND poster_id = user_id ORDER BY post_id LIMIT 0, 1"; if( !$p_result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch topic poster fail', __LINE__, __FILE__, $sql); } $p_row = $db->sql_fetchrow($p_result); $poster_name = ( $topic_poster != ANONYMOUS ) ? $p_row['username'] : ( !$p_row['post_username'] ? $lang['Guest'] : $p_row['post_username']); $poster_url = ( $topic_poster != ANONYMOUS && !$p_row['post_username'] ) ? ('' . "$poster_name") : $poster_name; $sql = "SELECT post_username, user_id, username, post_time FROM " . POSTS_TABLE . ", " . USERS_TABLE . " WHERE post_id = '$topic_last_post_id' AND poster_id = user_id"; if( !$r_result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Toplist ERROR: Fetch topic last replier fail', __LINE__, __FILE__, $sql); } $r_row = $db->sql_fetchrow($r_result); $replier_id = $r_row['user_id']; $replier_name = ( $replier_id != ANONYMOUS ) ? $r_row['username'] : ( !$r_row['post_username'] ? $lang['Guest'] : $r_row['post_username']); $replier_url = ( $replier_id != ANONYMOUS && !$r_row['post_username'] ) ? ('' . "$replier_name") : $replier_name; $last_post_url = append_sid("viewtopic.$phpEx?p=$topic_last_post_id#$topic_last_post_id"); $template->assign_block_vars("toprow", array( 'FORUM_NAME' => $rows['forum_name'], 'FORUM_URL' => $forum_url, 'TOPIC' => cutStr($rows['topic_title']), 'TOPIC_URL' => $topic_url, 'TOPIC_VIEWS' => $rows['topic_views'], 'TOPIC_REPLIES' => $rows['topic_replies'], 'POST_TIME' => create_date($board_config['default_dateformat'], $r_row['post_time'], $board_config['board_timezone']), 'POSTER_URL' => $poster_url, 'REPLIER_URL' => $replier_url, 'LAST_POST_URL' => $last_post_url )); } $sql = ($board_config['birthday_check_day']) ? "SELECT user_id, username, user_birthday,user_level FROM " . USERS_TABLE. " WHERE user_birthday!=999999 ORDER BY username" :""; if($result = $db->sql_query($sql)) { if (!empty($result)) { $time_now = time(); $this_year = create_date('Y', $time_now, $board_config['board_timezone']); $date_today = create_date('Ymd', $time_now, $board_config['board_timezone']); $date_forward = create_date('Ymd', $time_now+($board_config['birthday_check_day']*86400), $board_config['board_timezone']); while ($birthdayrow = $db->sql_fetchrow($result)) { $user_birthday2 = $this_year.($user_birthday = realdate("md",$birthdayrow['user_birthday'] )); if ( $user_birthday2 < $date_today ) $user_birthday2 += 10000; if ( $user_birthday2 > $date_today && $user_birthday2 <= $date_forward ) { $user_age = ( $this_year.$user_birthday < $date_today ) ? $this_year - realdate ('Y',$birthdayrow['user_birthday'])+1 : $this_year- realdate ('Y',$birthdayrow['user_birthday']); switch ($birthdayrow['user_level']) { case ADMIN : $birthdayrow['username'] = $birthdayrow['username']; $style_color = 'style="color:#ffcc00"'; break; case MOD : $birthdayrow['username'] = $birthdayrow['username']; $style_color = 'style="color:#943043"'; break; default: $style_color = ''; } $birthday_week_list .= ' ' . $birthdayrow['username'] . ' ('.$user_age.'),'; } else if ( $user_birthday2 == $date_today ) { $user_age = $this_year - realdate ( 'Y',$birthdayrow['user_birthday'] ); switch ($birthdayrow['user_level']) { case ADMIN : $birthdayrow['username'] = $birthdayrow['username']; $style_color = 'style="color:#ffcc00"'; break; case MOD : $birthdayrow['username'] = $birthdayrow['username']; $style_color = 'style="color:#943043"'; break; default: $style_color = ''; } $birthday_today_list .= ' ' . $birthdayrow['username'] . ' ('.$user_age.'),'; } } if ($birthday_today_list) $birthday_today_list[ strlen( $birthday_today_list)-1] = ' '; if ($birthday_week_list) $birthday_week_list[ strlen( $birthday_week_list)-1] = ' '; } $db->sql_freeresult($result); } define('SHOW_ONLINE', true); $page_title = $lang['Index']; include($phpbb_root_path . 'includes/page_header.'.$phpEx); $template->set_filenames(array( 'body' => 'index_body.tpl') ); $template->assign_vars(array( 'STATISTIKA' => $statistika, 'L_WHOSBIRTHDAY_WEEK' => ($board_config['birthday_check_day'] > 1) ? sprintf( (($birthday_week_list) ? $lang['Birthday_week'] : $lang['Nobirthday_week']), $board_config['birthday_check_day']).$birthday_week_list : '', 'L_WHOSBIRTHDAY_TODAY' => ($board_config['birthday_check_day']) ? ($birthday_today_list) ? $lang['Birthday_today'].$birthday_today_list : $lang['Nobirthday_today'] : '', 'ADMIN_LINK' => $admin_link, 'VERH' => $verh, 'NIZ' => $niz, 'BAN_INFO' => $ban) ); if (!empty($board_config['index_announcement'])) { $announcement = smilies_pass($board_config['index_announcement']); $announcement = str_replace("\n", "\n
\n", $announcement); $template->assign_block_vars('announcement', array( 'ANNOUNCEMENT' => $announcement) ); } $display_categories = array(); for ($i = 0; $i < $total_forums; $i++ ) { if ($is_auth_ary[$forum_data[$i]['forum_id']]['auth_view']) { $display_categories[$forum_data[$i]['cat_id']] = true; } } for($i = 0; $i < $total_categories; $i++) { $cat_id = $category_rows[$i]['cat_id']; if (isset($display_categories[$cat_id]) && $display_categories[$cat_id]) { $template->assign_block_vars('catrow', array( 'CAT_DESC' => $category_rows[$i]['cat_title'], 'U_VIEWCAT' => append_sid("index.$phpEx?" . POST_CAT_URL . "=$cat_id")) ); if ( $viewcat == $cat_id || $viewcat == -1 ) { for($j = 0; $j < $total_forums; $j++) { if ( $forum_data[$j]['cat_id'] == $cat_id ) { $forum_id = $forum_data[$j]['forum_id']; if ( $is_auth_ary[$forum_id]['auth_view'] ) { $posts = $forum_data[$j]['forum_posts']; $template->assign_block_vars('catrow.forumrow', array( 'FORUM_NAME' => $forum_data[$j]['forum_name'], 'POSTS' => $forum_data[$j]['forum_posts'], 'TOPICS' => $forum_data[$j]['forum_topics'], 'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id")) ); } } } } } } $template->pparse('body'); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); ?>