Moved config, images vars to arrays and various other fixes

git-svn-id: file:///svn/phpbb/trunk@237 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2001-05-03 22:10:23 +00:00
parent df716e1e83
commit aa8a051a98
16 changed files with 437 additions and 362 deletions

View file

@ -22,35 +22,34 @@
* *
***************************************************************************/ ***************************************************************************/
//
// Define some basic configuration arrays
//
$board_config = Array();
$userdata = Array();
$theme = Array();
$images = Array();
include('config.'.$phpEx); include('config.'.$phpEx);
include('includes/constants.'.$phpEx); include('includes/constants.'.$phpEx);
//
// Default variable values - most if not all
// of these have equivalents in a DB table but
// for situations where the DB cannot be read or where
// data is missing this data is used instead
//
//$date_format = "m-d-Y H:i:s"; // American datesformat
$date_format = "D, M d Y h:i:s a"; // European datesformat
$url_images = "images"; $url_images = "images";
$image_quote = "$url_images/quote.gif"; $images['quote'] = "$url_images/quote.gif";
$images['edit'] = "$url_images/edit.gif";
$image_edit = "$url_images/edit.gif"; $images['profile'] = "$url_images/profile.gif";
$image_profile = "$url_images/profile.gif"; $images['email'] = "$url_images/email.gif";
$image_email = "$url_images/email.gif"; $images['pmsg'] = "$url_images/pm.gif";
$image_pmsg = "$url_images/pm.gif"; $images['delpost'] = "$url_images/edit.gif";
$image_delpost = "$url_images/edit.gif"; $images['ip'] = "$url_images/ip_logged.gif";
$images['www'] = "$url_images/www_icon.gif";
$image_ip = "$url_images/ip_logged.gif"; $images['icq'] = "$url_images/icq_add.gif";
$images['aim'] = "$url_images/aim.gif";
$image_www = "$url_images/www_icon.gif"; $images['yim'] = "$url_images/yim.gif";
$image_icq = "$url_images/icq_add.gif"; $images['msnm'] = "$url_images/msnm.gif";
$image_aim = "$url_images/aim.gif"; $images['quote'] = "$url_images/quote.gif";
$image_yim = "$url_images/yim.gif"; $images['posticon'] = "$url_images/posticon.gif";
$image_msnm = "$url_images/msnm.gif"; $images['folder'] = "$url_images/folder.gif";
$theme = array(); $images['latest_reply'] = "$url_images/latest_reply.gif";
// Find Users real IP (if possible) // Find Users real IP (if possible)
$user_ip = ($HTTP_X_FORWARDED_FOR) ? $HTTP_X_FORWARDED_FOR : $REMOTE_ADDR; $user_ip = ($HTTP_X_FORWARDED_FOR) ? $HTTP_X_FORWARDED_FOR : $REMOTE_ADDR;
@ -63,43 +62,54 @@ include('includes/auth.'.$phpEx);
include('includes/functions.'.$phpEx); include('includes/functions.'.$phpEx);
include('includes/db.'.$phpEx); include('includes/db.'.$phpEx);
// Initalize to keep safe //
$userdata = Array();
// Setup forum wide options. // Setup forum wide options.
// This is also the first DB query/connect // This is also the first DB query/connect
//
$sql = "SELECT * $sql = "SELECT *
FROM ".CONFIG_TABLE." FROM ".CONFIG_TABLE."
WHERE selected = 1"; WHERE selected = '1'";
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
// Our template class hasn't been instantiated so we do it here. //
// Define some basic configuration
// vars, necessary since we haven't
// been able to get them from the DB
//
$board_config['default_template'] = "Default";
$board_config['default_timezone'] = 0;
$board_config['default_dateformat'] = "d M Y H:i";
$board_config['default_theme'] = 1;
$board_config['default_lang'] = "english";
// Our template class hasn't been instantiated
// so we do it here.
$template = new Template("templates/Default"); $template = new Template("templates/Default");
error_die(SQL_QUERY, "Could not query config information.", __LINE__, __FILE__); error_die(SQL_QUERY, "Could not query config information.", __LINE__, __FILE__);
} }
else else
{ {
$config = $db->sql_fetchrow($result); $config = $db->sql_fetchrow($result);
$sitename = stripslashes($config["sitename"]);
$allow_html = $config["allow_html"]; $board_config['sitename'] = stripslashes($config['sitename']);
$allow_bbcode = $config["allow_bbcode"]; $board_config['allow_html'] = $config['allow_html'];
$allow_sig = $config["allow_sig"]; $board_config['allow_bbcode'] = $config['allow_bbcode'];
$allow_namechange = $config["allow_namechange"]; $board_config['allow_sig'] = $config['allow_sig'];
$posts_per_page = $config["posts_per_page"]; $board_config['allow_namechange'] = $config['allow_namechange'];
$hot_threshold = $config["hot_threshold"]; $board_config['require_activation'] = $config['require_activation'];
$topics_per_page = $config["topics_per_page"]; $board_config['override_user_themes'] = $config['override_themes'];
$override_user_themes = $config["override_themes"]; $board_config['posts_per_page'] = $config['posts_per_page'];
$email_sig = stripslashes($config["email_sig"]); $board_config['topics_per_page'] = $config['topics_per_page'];
$email_from = $config["email_from"]; $board_config['default_theme'] = $config['default_theme'];
$default_lang = $config["default_lang"]; $board_config['default_dateformat'] = stripslashes($config['default_dateformat']);
$default_theme = $config['default_theme']; $board_config['default_template'] = stripslashes($config['sys_template']);
$default_dateformat = $config['default_dateformat']; $board_config['default_timezone'] = $config['system_timezone'];
$require_activation = $config["require_activation"]; $board_config['default_lang'] = stripslashes($config['default_lang']);
$sys_timezone = $config["system_timezone"]; $board_config['board_email'] = stripslashes(str_replace("<br />", "\n", $config['email_sig']));
$sys_template = $config['sys_template']; $board_config['board_email_from'] = stripslashes($config['email_from']);
$sys_lang = $default_lang;
} }
include('language/lang_'.$default_lang.'.'.$phpEx); include('language/lang_'.$board_config['default_lang'].'.'.$phpEx);
?> ?>

View file

@ -144,11 +144,9 @@ function make_jumpbox()
// Initialise user settings on page load // Initialise user settings on page load
function init_userprefs($userdata) function init_userprefs($userdata)
{ {
global $override_user_theme, $template, $sys_template; global $board_config, $theme, $template, $lang, $phpEx;
global $default_lang, $default_theme, $date_format, $sys_timezone;
global $theme;
if(!$override_user_themes) if(!$board_config['override_user_themes'])
{ {
if(($userdata['user_id'] != ANONYMOUS || $userdata['user_id'] != DELETED) && $userdata['user_theme']) if(($userdata['user_id'] != ANONYMOUS || $userdata['user_id'] != DELETED) && $userdata['user_theme'])
{ {
@ -156,24 +154,24 @@ function init_userprefs($userdata)
} }
else else
{ {
$theme = setuptheme($default_theme); $theme = setuptheme($board_config['default_theme']);
} }
} }
else else
{ {
$theme = setuptheme($override_user_theme); $theme = setuptheme($board_config['override_user_themes']);
} }
if($userdata['user_lang'] != '') if($userdata['user_lang'] != '')
{ {
$default_lang = $userdata['user_lang']; $board_config['default_lang'] = $userdata['user_lang'];
} }
if($userdata['user_dateformat'] != '') if($userdata['user_dateformat'] != '')
{ {
$date_format = $userdata['user_dateformat']; $board_config['default_dateformat'] = $userdata['user_dateformat'];
} }
if(isset($userdata['user_timezone'])) if(isset($userdata['user_timezone']))
{ {
$sys_timezone = $userdata['user_timezone']; $board_config['default_timezone'] = $userdata['user_timezone'];
} }
// Setup user's Template // Setup user's Template
if($userdata['user_template'] != '') if($userdata['user_template'] != '')
@ -182,35 +180,35 @@ function init_userprefs($userdata)
} }
else else
{ {
$template = new Template("templates/".$sys_template); $template = new Template("templates/".$board_config['default_template']);
} }
// Include the appropriate language file ... if it exists. //
if(!strstr($PHP_SELF, "admin")) // This is currently worthless since all the individual
// language variables will only be locally defined in this
// function and not accessible to the board code globally.
// This will be fixed by moving all $l_xxxx vars into a single
// $lang[''] array
//
if( file_exists("language/lang_".$board_config['default_lang'].".".$phpEx) )
{ {
if(file_exists('language/lang_'.$default_lang.'.'.$phpEx)) include('language/lang_'.$board_config['default_lang'].'.'.$phpEx);
{
include('language/lang_'.$default_lang.'.'.$phpEx);
}
} }
else else
{ {
if(strstr($PHP_SELF, "topicadmin")) include('language/lang_english'.$phpEx);
{
include('language/lang_'.$default_lang.'.'.$phpEx);
}
else
{
include('../language/lang_'.$default_lang.'.'.$phpEx);
}
} }
return; return;
} }
function setuptheme($theme) function setuptheme($theme)
{ {
global $db; global $db;
$sql = "SELECT * FROM ".THEMES_TABLE." WHERE themes_id = '$theme'";
$sql = "SELECT *
FROM ".THEMES_TABLE."
WHERE themes_id = '$theme'";
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {

View file

@ -53,17 +53,17 @@ else
// //
// Do timezone text output // Do timezone text output
// //
if($sys_timezone < 0) if($board_config['default_timezone'] < 0)
{ {
$s_timezone = "$l_all_times GMT - ".(-$sys_timezone)." $l_hours"; $s_timezone = "$l_all_times GMT - ".(-$board_config['default_timezone'])." $l_hours";
} }
else if($sys_timezone == 0) else if($board_config['default_timezone'] == 0)
{ {
$s_timezone = "$l_all_times GMT"; $s_timezone = "$l_all_times GMT";
} }
else else
{ {
$s_timezone = "$l_all_times GMT + $sys_timezone $l_hours"; $s_timezone = "$l_all_times GMT + ".$board_config['default_timezone']." $l_hours";
} }
// //
@ -73,8 +73,7 @@ else
$sql = "SELECT u.username, u.user_id, s.session_logged_in $sql = "SELECT u.username, u.user_id, s.session_logged_in
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
WHERE u.user_id = s.session_user_id WHERE u.user_id = s.session_user_id
AND s.session_time >= '".(time()-300)."' AND s.session_time >= '".(time() - 300)."'";
";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if(!$result) if(!$result)
{ {
@ -109,7 +108,7 @@ $l_is_are = ($logged_online == 1) ? $l_is : $l_are;
$userlist = ($logged_online > 0) ? "$l_Registered $l_r_user_s: " . $userlist : "$l_Registered $l_r_user_s: $l_None"; $userlist = ($logged_online > 0) ? "$l_Registered $l_r_user_s: " . $userlist : "$l_Registered $l_r_user_s: $l_None";
$template->assign_vars(array( $template->assign_vars(array(
"SITENAME" => $sitename, "SITENAME" => $board_config['sitename'],
"PHPEX" => $phpEx, "PHPEX" => $phpEx,
"PHPSELF" => $PHP_SELF, "PHPSELF" => $PHP_SELF,
@ -147,9 +146,11 @@ $template->assign_vars(array(
"L_AUTO_LOGIN" => $l_autologin, "L_AUTO_LOGIN" => $l_autologin,
"L_AUTHOR" => $l_author, "L_AUTHOR" => $l_author,
"L_MESSAGE" => $l_message, "L_MESSAGE" => $l_message,
"L_BY" => $l_by,
"L_LOGIN_LOGOUT" => $l_login_logout, "L_LOGIN_LOGOUT" => $l_login_logout,
"U_INDEX" => "index.".$phpEx,
"U_REGISTER" => "profile.".$phpEx."?mode=register", "U_REGISTER" => "profile.".$phpEx."?mode=register",
"U_PROFILE" => "profile.".$phpEx."?mode=editprofile", "U_PROFILE" => "profile.".$phpEx."?mode=editprofile",
"U_PRIVATEMSGS" => "priv_msgs.".$phpEx."?mode=read", "U_PRIVATEMSGS" => "priv_msgs.".$phpEx."?mode=read",
@ -241,7 +242,8 @@ switch($pagetype)
$template->assign_vars(array( $template->assign_vars(array(
"FORUM_ID" => $forum_id, "FORUM_ID" => $forum_id,
"FORUM_NAME" => $forum_name, "FORUM_NAME" => $forum_name,
"MODERATORS" => $forum_moderators)); "MODERATORS" => $forum_moderators,
"USERS_BROWSING" => $users_browsing));
$template->pparse("header"); $template->pparse("header");
break; break;
@ -262,7 +264,8 @@ switch($pagetype)
"FORUM_NAME" => $forum_name, "FORUM_NAME" => $forum_name,
"TOPIC_ID" => $topic_id, "TOPIC_ID" => $topic_id,
"TOPIC_TITLE" => $topic_title, "TOPIC_TITLE" => $topic_title,
"POST_FORUM_URL" => POST_FORUM_URL)); "POST_FORUM_URL" => POST_FORUM_URL,
"USERS_BROWSING" => $users_browsing));
$template->pparse("header"); $template->pparse("header");
break; break;
@ -306,12 +309,10 @@ switch($pagetype)
break; break;
case 'register': case 'register':
if(!isset($agreed)) if(!isset($HTTP_POST_VARS['agreed']) && !isset($HTTP_GET_VARS['agreed']))
{ {
if(!isset($coppa)) $coppa = (!isset($HTTP_POST_VARS['coppa'])) ? FALSE : TRUE;
{
$coppa = FALSE;
}
$template->set_filenames(array( $template->set_filenames(array(
"body" => "agreement.tpl")); "body" => "agreement.tpl"));
$template->assign_vars(array( $template->assign_vars(array(

View file

@ -50,11 +50,12 @@ switch($pagetype)
// //
if($userdata['session_logged_in']) if($userdata['session_logged_in'])
{ {
$admin_link = "<a href=\"admin/index.php\">Administration Panel</a>"; $admin_link = "<a href=\"admin/index.$phpEx\">Administration Panel</a>";
} }
$current_time = time(); $current_time = time();
$template->assign_vars(array("PHPBB_VERSION" => "2.0-alpha", $template->assign_vars(array(
"CURRENT_TIME" => create_date($date_format, $current_time, $sys_timezone), "PHPBB_VERSION" => "2.0-alpha",
"CURRENT_TIME" => create_date($board_config['default_dateformat'], $current_time, $board_config['default_timezone']),
"ADMIN_LINK" => $admin_link)); "ADMIN_LINK" => $admin_link));
$template->pparse("overall_footer"); $template->pparse("overall_footer");

View file

@ -122,15 +122,15 @@ if($total_categories)
( $category_rows[$i]["cat_id"] == $viewcat) ) ( $category_rows[$i]["cat_id"] == $viewcat) )
{ {
$folder_image = "<img src=\"images/folder.gif\">"; $folder_image = "<img src=\"".$images['folder']."\">";
$posts = $forum_rows[$j]["forum_posts"]; $posts = $forum_rows[$j]["forum_posts"];
$topics = $forum_rows[$j]["forum_topics"]; $topics = $forum_rows[$j]["forum_topics"];
if($forum_rows[$j]["username"] != "" && $forum_rows[$j]["post_time"] > 0) if($forum_rows[$j]["username"] != "" && $forum_rows[$j]["post_time"] > 0)
{ {
$last_post_time = create_date($date_format, $forum_rows[$j]["post_time"], $sys_timezone); $last_post_time = create_date($board_config['default_dateformat'], $forum_rows[$j]["post_time"], $board_config['default_timezone']);
$last_post = $last_post_time."<br>by "; $last_post = $last_post_time."<br>by ";
$last_post .= "<a href=\"profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=".$forum_rows[$j]["user_id"]; $last_post .= "<a href=\"profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=".$forum_rows[$j]["user_id"];
$last_post .= "\">".$forum_rows[$j]["username"]."</a>&nbsp;<a href=\"viewtopic.".$phpEx."?t=".$forum_rows[$j]['topic_id']."\"><img src=\"images/latest_reply.gif\" width=\"20\" height=\"11\" border=\"0\" alt=\"View Latest Post\"></a>"; $last_post .= "\">".$forum_rows[$j]["username"]."</a>&nbsp;<a href=\"viewtopic.".$phpEx."?t=".$forum_rows[$j]['topic_id']."\"><img src=\"".$images['latest_reply']."\" width=\"20\" height=\"11\" border=\"0\" alt=\"View Latest Post\"></a>";
} }
else else
{ {

View file

@ -111,17 +111,18 @@ $l_indextitle = "Forum Index";
// Members and profile // Members and profile
$l_reginfo = "Registration Information"; $l_reginfo = "Registration Information";
$l_profileinfo = "Profile Information (this information will be publicly viewable)"; $l_profile_info = "Profile Information";
$l_profile_info_notice = "This information will be publicly viewable";
$l_profile = "Profile"; $l_profile = "Profile";
$l_register = "Register"; $l_register = "Register";
$l_onlyreq = "Only requried if being changed"; $l_onlyreq = "Only requried if being changed";
$l_location = "From"; $l_location = "From";
$l_viewpostuser = "View posts by this user"; $l_view_users_posts = "View posts by this user";
$l_perday = "$l_messages per day"; $l_per_day = "$l_messages per day";
$l_oftotal = "of total"; $l_of_total = "of total";
$l_url = "URL"; $l_url = "URL";
$l_icq = "ICQ"; $l_icq = "ICQ";
$l_icqnumber = "ICQ Number"; $l_icq_number = "ICQ Number";
$l_icqadd = "Add"; $l_icqadd = "Add";
$l_icqpager = "Pager"; $l_icqpager = "Pager";
$l_aim = "AIM"; $l_aim = "AIM";
@ -138,11 +139,15 @@ $l_usertaken = "The $l_username you picked has been taken.";
$l_userdisallowed= "The $l_username you picked has been disallowed by the administrator. $l_tryagain"; $l_userdisallowed= "The $l_username you picked has been disallowed by the administrator. $l_tryagain";
$l_infoupdated = "Your Information has been updated"; $l_infoupdated = "Your Information has been updated";
$l_publicmail = "Allow other users to view my $l_emailaddress"; $l_publicmail = "Allow other users to view my $l_emailaddress";
$l_itemsreq = "Items marked with a * are required"; $l_itemsreq = "Items marked with a * are required unless stated otherwise";
$l_nouserid = "You must supply a user ID number in order to view profile data."; $l_nouserid = "You must supply a user ID number in order to view profile data.";
$l_viewingprofile = "Viewing profile of "; $l_viewingprofile = "Viewing profile of ";
$l_hidden = "hidden"; $l_hidden = "hidden";
$l_boardtemplate = "Select Template"; $l_boardtemplate = "Select Template";
$l_date_format = "Date format";
$l_date_format_explanation = "Only change this if you know what you are doing!";
$l_password_if_changed = "You only need to supply a password if you want to change it.";
$l_password_confirm_if_changed = "You only need to confirm your password if you changed it above.";
// Viewforum // Viewforum
@ -234,8 +239,7 @@ $l_faxinfo = "
"; ";
$l_coppa = "Your account has been created, however in complance with the COPPA act you must print out this page and have you parent or guardian mail it to: <br>$l_mailingaddress<br>Or fax it to: <br>$l_faxinfo<br> Once this information has been recived your account will be activated by the administrator and you will recive and email notification."; $l_coppa = "Your account has been created, however in complance with the COPPA act you must print out this page and have you parent or guardian mail it to: <br>$l_mailingaddress<br>Or fax it to: <br>$l_faxinfo<br> Once this information has been recived your account will be activated by the administrator and you will recive and email notification.";
$l_welcomesubj = "Welcome to $sitename Forums"; $l_welcomesubj = "Welcome to $sitename Forums";
$l_welcomemail = $l_welcomemail = "
"
$l_welcomesubj, $l_welcomesubj,
Please keep this email for your records. Please keep this email for your records.
@ -253,11 +257,9 @@ However, should you forget your password we provide an easy to use script to gen
Thank you for registering. Thank you for registering.
$email_sig
"; ";
$l_welcomeemailactivate = $l_welcomeemailactivate = "
"
$l_welcomesubj, $l_welcomesubj,
Please keep this email for your records. Please keep this email for your records.
@ -278,7 +280,6 @@ However, should you forget your password we provide an easy to use script to gen
Thank you for registering. Thank you for registering.
$email_sig
"; ";
$l_beenadded = "You have been added to the database."; $l_beenadded = "You have been added to the database.";
@ -380,7 +381,7 @@ Thank you for using $sitename forums.
Have a nice day. Have a nice day.
$email_sig'; ';
$l_quotemsg = '[quote]\nOn $m[post_time], $m[username] wrote:\n$text\n[/quote]'; $l_quotemsg = '[quote]\nOn $m[post_time], $m[username] wrote:\n$text\n[/quote]';
@ -414,7 +415,7 @@ $l_wrongmail = "The email address you entered does not match the one stored in o
$l_passsubj = "$sitename Forums Password Change"; $l_passsubj = "$sitename Forums Password Change";
$l_pwdmessage = 'Dear $checkinfo[username], $l_pwdmessage = "Dear $checkinfo[username],
You are receiving this email because you (or someone pretending to be you) You are receiving this email because you (or someone pretending to be you)
has requested a passwordchange on $sitename forums. If you believe you have has requested a passwordchange on $sitename forums. If you believe you have
received this message in error simply delete it and your password will remain received this message in error simply delete it and your password will remain
@ -431,7 +432,7 @@ and you may login to the profile section and change it as desired.
Thank you for using $sitename Forums Thank you for using $sitename Forums
$email_sig'; ";
$l_passsent = "Your password has changed to a new, random, password. Please check your email on how to complete the password change procedure."; $l_passsent = "Your password has changed to a new, random, password. Please check your email on how to complete the password change procedure.";
$l_emailpass = "Email Lost Password"; $l_emailpass = "Email Lost Password";

View file

@ -122,8 +122,9 @@ else
"body" => "login_body.tpl", "body" => "login_body.tpl",
) )
); );
if($mode) if(isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']))
{ {
$mode = (isset($HTTP_POST_VARS['mode'])) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
$forward_page .= "?mode=".$mode; $forward_page .= "?mode=".$mode;
} }

View file

@ -253,7 +253,7 @@ switch($mode)
"L_USERNAME" => $l_username, "L_USERNAME" => $l_username,
"L_VIEW_USERS_POSTS" => $l_view_users_posts, "L_VIEW_USERS_POSTS" => $l_view_users_posts,
"L_JOINED" => $l_joined, "L_JOINED" => $l_joined,
"JOINED" => create_date($date_format, $profiledata['user_regdate'], $sys_timezone), "JOINED" => create_date($board_config['default_dateformat'], $profiledata['user_regdate'], $board_config['default_timezone']),
"POSTS_PER_DAY" => $posts_per_day, "POSTS_PER_DAY" => $posts_per_day,
"L_PER_DAY" => $l_per_day, "L_PER_DAY" => $l_per_day,
"POSTS" => $profiledata['user_posts'], "POSTS" => $profiledata['user_posts'],
@ -293,7 +293,15 @@ switch($mode)
$page_title = "$l_register"; $page_title = "$l_register";
include('includes/page_header.'.$phpEx); include('includes/page_header.'.$phpEx);
$template->set_filenames(array("body" => "profile_add_body.tpl")); if(isset($HTTP_POST_VARS['submit']))
{
}
else
{
$template->set_filenames(array(
"body" => "profile_add_body.tpl"));
$template->assign_vars(array( $template->assign_vars(array(
"COPPA" => 0, "COPPA" => 0,
"MODE" => $mode, "MODE" => $mode,
@ -304,7 +312,7 @@ switch($mode)
"MSN" => $userdata['user_msnm'], "MSN" => $userdata['user_msnm'],
"AIM" => $userdata['user_aim'], "AIM" => $userdata['user_aim'],
"OCCUPATION" => $userdata['user_occ'], "OCCUPATION" => $userdata['user_occ'],
"SIGNATURE" => $userdata['user_sig'], "SIGNATURE" => str_replace("<br>", "\n", $userdata['user_sig']),
"INTERESTS" => $userdata['user_interests'], "INTERESTS" => $userdata['user_interests'],
"LOCATION" => $userdata['user_from'], "LOCATION" => $userdata['user_from'],
"WEBSITE" => $userdata['user_website'], "WEBSITE" => $userdata['user_website'],
@ -319,7 +327,7 @@ switch($mode)
"ALWAYS_ALLOW_SMILIES_YES" => ($userdata['user_desmile']) ? "CHECKED" : "", "ALWAYS_ALLOW_SMILIES_YES" => ($userdata['user_desmile']) ? "CHECKED" : "",
"ALWAYS_ALLOW_SMILIES_NO" => (!$userdata['user_desmile']) ? "CHECKED" : "", "ALWAYS_ALLOW_SMILIES_NO" => (!$userdata['user_desmile']) ? "CHECKED" : "",
"LANGUAGE_SELECT" => language_select($userdata['user_lang']), "LANGUAGE_SELECT" => language_select($userdata['user_lang']),
"THEME_SELECT" => theme_select($theme['theme_id']), "THEME_SELECT" => theme_select($userdata['user_theme']),
"TIMEZONE_SELECT" => tz_select($userdata['user_timezone']), "TIMEZONE_SELECT" => tz_select($userdata['user_timezone']),
"DATE_FORMAT" => $userdata['user_dateformat'], "DATE_FORMAT" => $userdata['user_dateformat'],
"TEMPLATE_SELECT" => template_select($userdata['user_template']), "TEMPLATE_SELECT" => template_select($userdata['user_template']),
@ -361,6 +369,7 @@ switch($mode)
$template->pparse("body"); $template->pparse("body");
include('includes/page_tail.'.$phpEx); include('includes/page_tail.'.$phpEx);
}
break; break;
case 'register': case 'register':
@ -387,13 +396,11 @@ switch($mode)
$allowbbcode = $HTTP_POST_VARS['allowbbcode']; $allowbbcode = $HTTP_POST_VARS['allowbbcode'];
$allowsmilies = $HTTP_POST_VARS['allowsmilies']; $allowsmilies = $HTTP_POST_VARS['allowsmilies'];
$user_theme = ($HTTP_POST_VARS['theme']) ? $HTTP_POST_VARS['theme'] : $default_theme; $user_theme = ($HTTP_POST_VARS['theme']) ? $HTTP_POST_VARS['theme'] : $board_config['default_theme'];
$user_lang = ($HTTP_POST_VARS['language']) ? $HTTP_POST_VARS['language'] : $default_lang; $user_lang = ($HTTP_POST_VARS['language']) ? $HTTP_POST_VARS['language'] : $board_config['default_lang'];
$user_timezone = (isset($HTTP_POST_VARS['timezone'])) ? $HTTP_POST_VARS['timezone'] : $sys_timezone; $user_timezone = (isset($HTTP_POST_VARS['timezone'])) ? $HTTP_POST_VARS['timezone'] : $board_config['default_timezone'];
$user_template = ($HTTP_POST_VARS['template']) ? $HTTP_POST_VARS['template'] : $sys_template; $user_template = ($HTTP_POST_VARS['template']) ? $HTTP_POST_VARS['template'] : $board_config['default_template'];
$user_dateformat = ($HTTP_POST_VARS['dateformat']) ? trim($HTTP_POST_VARS['dateformat']) : $default_dateformat; $user_dateformat = ($HTTP_POST_VARS['dateformat']) ? trim($HTTP_POST_VARS['dateformat']) : $board_config['default_dateformat'];
$submit = $HTTP_POST_VARS['submit'];
list($hr, $min, $sec, $mon, $day, $year) = explode(",", gmdate("H,i,s,m,d,Y", time())); list($hr, $min, $sec, $mon, $day, $year) = explode(",", gmdate("H,i,s,m,d,Y", time()));
$regdate = gmmktime($hr, $min, $sec, $mon, $day, $year); $regdate = gmmktime($hr, $min, $sec, $mon, $day, $year);
@ -402,14 +409,15 @@ switch($mode)
$page_title = "$l_register"; $page_title = "$l_register";
include('includes/page_header.'.$phpEx); include('includes/page_header.'.$phpEx);
if(!isset($agreed))
if(!isset($HTTP_POST_VARS['agreed']) && !isset($HTTP_GET_VARS['agreed']))
{ {
$template->pparse("body"); $template->pparse("body");
include('includes/page_tail.'.$phpEx); include('includes/page_tail.'.$phpEx);
} }
else else
{ {
if(isset($submit)) if(isset($HTTP_POST_VARS['submit']))
{ {
$error = FALSE; $error = FALSE;
if(empty($username) || empty($password) || empty($password_confirm) || empty($email)) if(empty($username) || empty($password) || empty($password_confirm) || empty($email))
@ -437,7 +445,7 @@ switch($mode)
} }
} }
if(isset($submit) && !$error) if(isset($HTTP_POST_VARS['submit']) && !$error)
{ {
// //
// The AUTO_INCREMENT field in MySQL v3.23 doesn't work // The AUTO_INCREMENT field in MySQL v3.23 doesn't work
@ -463,7 +471,7 @@ switch($mode)
(user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_desmile, user_html, user_bbcode, user_timezone, user_dateformat, user_lang, user_template, user_theme, user_active, user_actkey) (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_desmile, user_html, user_bbcode, user_timezone, user_dateformat, user_lang, user_template, user_theme, user_active, user_actkey)
VALUES VALUES
('$new_user_id', '$username', '$regdate', '$md_pass', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$viewemail', '$aim', '$yim', '$msn', '$attachsig', '$allowsmilies', '$allowhtml', '$allowbbcode', '$user_timezone', '$user_dateformat', '$user_lang', '$user_template', '$user_theme', "; ('$new_user_id', '$username', '$regdate', '$md_pass', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$viewemail', '$aim', '$yim', '$msn', '$attachsig', '$allowsmilies', '$allowhtml', '$allowbbcode', '$user_timezone', '$user_dateformat', '$user_lang', '$user_template', '$user_theme', ";
if($require_activation || $coppa) if($require_activation || $HTTP_POST_VARS['coppa'])
{ {
$act_key = generate_activation_key(); $act_key = generate_activation_key();
$sql .= "0, '$act_key')"; $sql .= "0, '$act_key')";
@ -533,10 +541,11 @@ switch($mode)
$coppa = FALSE; $coppa = FALSE;
} }
if(!isset($selected_template)) if(!isset($user_template))
{ {
$selected_template = $sys_template; $selected_template = $board_config['default_template'];
} }
$template->assign_vars(array( $template->assign_vars(array(
"MODE" => $mode, "MODE" => $mode,
"USERNAME" => $username, "USERNAME" => $username,
@ -605,6 +614,7 @@ switch($mode)
break; break;
case 'activate': case 'activate':
$sql = "SELECT user_id $sql = "SELECT user_id
FROM ".USERS_TABLE." FROM ".USERS_TABLE."
WHERE user_actkey = '$act_key'"; WHERE user_actkey = '$act_key'";

View file

@ -15,11 +15,11 @@
<!-- BEGIN topicrow --> <!-- BEGIN topicrow -->
<tr bgcolor="#DDDDDD" class="tablebody"> <tr bgcolor="#DDDDDD" class="tablebody">
<td width="5%" align="center" valign="middle">{topicrow.FOLDER}</td> <td width="5%" align="center" valign="middle">{topicrow.FOLDER}</td>
<td><a href="viewtopic.{PHPEX}?{S_TOPICS_URL}={topicrow.TOPIC_ID}&{topicrow.REPLIES}">{topicrow.TOPIC_TITLE}</a>{topicrow.GOTO_PAGE}</td> <td><a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a>&nbsp;{topicrow.GOTO_PAGE}</td>
<td width="5%" align="center" valign="middle">{topicrow.REPLIES}</td> <td width="5%" align="center" valign="middle">{topicrow.REPLIES}</td>
<td width="10%" align="center" valign="middle">{topicrow.TOPIC_POSTER}</td> <td width="10%" align="center" valign="middle">{topicrow.TOPIC_POSTER}</td>
<td width="5%" align="center" valign="middle">{topicrow.VIEWS}</td> <td width="5%" align="center" valign="middle">{topicrow.VIEWS}</td>
<td width="15%" align="center" valign="middle">{topicrow.LAST_POST}</td> <td width="15%" align="center" valign="middle">{topicrow.LAST_POST_TIME}<br />{L_BY} <a href="{topicrow.U_LAST_POST_USER_PROFILE}">{topicrow.LAST_POST_USER}</a></td>
</tr> </tr>
<!-- END topicrow --> <!-- END topicrow -->
</table> </table>

View file

@ -8,7 +8,7 @@
<td> <td>
<table border="0" width="100%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1"> <table border="0" width="100%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1">
<tr> <tr>
<td align="left" style="{font-size: 8pt;}"><a href="posting.{PHPEX}?mode=newtopic&{S_FORUMS_URL}={FORUM_ID}"><img src="images/newpost.jpg" height="50" width="250" alt="Post New Topic" border="0"></a></td> <td align="left" style="{font-size: 8pt;}"><a href="{U_POST_NEW_TOPIC}"><img src="images/newpost.jpg" height="50" width="250" alt="Post New Topic" border="0"></a></td>
</tr> </tr>
</table> </table>
</td> </td>

View file

@ -24,7 +24,7 @@
<table border="0" width="100%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1"> <table border="0" width="100%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1">
<tr> <tr>
<td align="right" style="{font-size: 8pt;}"> <td align="right" style="{font-size: 8pt;}">
<a href="posting.{PHPEX}?mode=newtopic&{S_FORUMS_URL}={FORUM_ID}"> <a href="{U_POST_NEW_TOPIC}">
<img src="images/newpost.jpg" height="50" width="250" alt="Post New Topic" border="0"> <img src="images/newpost.jpg" height="50" width="250" alt="Post New Topic" border="0">
</a> </a>
</td> </td>

View file

@ -4,9 +4,9 @@
<tr> <tr>
<td> <td>
<table border="0" width="100%" cellpadding="3" cellspacing="1"> <table border="0" width="100%" cellpadding="3" cellspacing="1">
<tr><td wdith="90%" class="tablebody" bgcolor="#CCCCCC">This topic is {PAGES} long. {PAGINATION}</td> <tr><td wdith="90%" class="tablebody" bgcolor="#CCCCCC">This topic is {PAGES} {L_PAGES} long. {PAGINATION}</td>
<td width="5%" class="tableheader" align="center"><a href="viewtopic.{PHPEX}?{S_TOPICS_URL}={TOPIC_ID}&view=older"><img src="images/prev.gif" alt="View previous topic" border="0"></a></td> <td width="5%" class="tableheader" align="center"><a href="{U_VIEW_OLDER_TOPIC}"><img src="images/prev.gif" alt="View previous topic" border="0"></a></td>
<td width="5%" class="tableheader" align="center"><a href="viewtopic.{PHPEX}?{S_TOPICS_URL}={TOPIC_ID}&view=newer"><img src="images/next.gif" alt="View next topic" border="0"></a></td> <td width="5%" class="tableheader" align="center"><a href="{U_VIEW_NEWER_TOPIC}"><img src="images/next.gif" alt="View next topic" border="0"></a></td>
</tr> </tr>
</table> </table>
</td> </td>
@ -57,11 +57,11 @@
<td width="90%" class="tablebody" bgcolor="#CCCCCC"><table width="100%" cellspacing="0" cellpadding="0" border="0"> <td width="90%" class="tablebody" bgcolor="#CCCCCC"><table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr> <tr>
<td align="left" nowrap><b>{S_TIMEZONE}</b></td> <td align="left" nowrap><b>{S_TIMEZONE}</b></td>
<td align="right" nowrap>This topic is {PAGES} long. {PAGINATION}</td> <td align="right" nowrap>This topic is {PAGES} {L_PAGES} long. {PAGINATION}</td>
</tr> </tr>
</table></td> </table></td>
<td width="5%" class="tableheader" align="center"><a href="viewtopic.{PHPEX}?{S_TOPICS_URL}={TOPIC_ID}&view=older"><img src="images/prev.gif" alt="View previous topic" border="0"></a></td> <td width="5%" class="tableheader" align="center"><a href="{U_VIEW_OLDER_TOPIC}"><img src="images/prev.gif" alt="View previous topic" border="0"></a></td>
<td width="5%" class="tableheader" align="center"><a href="viewtopic.{PHPEX}?{S_TOPICS_URL}={TOPIC_ID}&view=newer"><img src="images/next.gif" alt="View next topic" border="0"></a></td> <td width="5%" class="tableheader" align="center"><a href="{U_VIEW_NEWER_TOPIC}"><img src="images/next.gif" alt="View next topic" border="0"></a></td>
</tr> </tr>
</table> </table>
</td> </td>

View file

@ -9,9 +9,9 @@
<table border="0" width="100%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1"> <table border="0" width="100%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1">
<tr> <tr>
<td align="left" style="{font-size: 8pt;}"> <td align="left" style="{font-size: 8pt;}">
<a href="posting.{PHPEX}?mode=newtopic&{S_FORUMS_URL}={FORUM_ID}"> <a href="{U_POST_NEW_TOPIC}">
<img src="images/newpost.jpg" height="50" width="125" alt="Post New Topic" border="0"></a>&nbsp; <img src="images/newpost.jpg" height="50" width="125" alt="Post New Topic" border="0"></a>&nbsp;
<a href="posting.{PHPEX}?mode=reply&{S_TOPICS_URL}={TOPIC_ID}"> <a href="{U_POST_REPLY_TOPIC}">
<img src="images/reply.jpg" height="50" width="125" alt="Reply to this topic" border="0"> <img src="images/reply.jpg" height="50" width="125" alt="Reply to this topic" border="0">
</a> </a>
</td> </td>

View file

@ -9,7 +9,7 @@
<table border="0" width="100%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1"> <table border="0" width="100%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1">
<tr> <tr>
<td align="left" valign="bottom" style="{font-size: 8pt; height: 55px;}" nowrap> <td align="left" valign="bottom" style="{font-size: 8pt; height: 55px;}" nowrap>
<a href="index.{PHPEX}">{SITENAME} - Forum Index</a> >> <a href="viewforum.{PHPEX}?{S_FORUMS_URL}={FORUM_ID}">{FORUM_NAME}</a> >> {TOPIC_TITLE} <a href="{U_INDEX}">{SITENAME} - Forum Index</a> >> <a href="{U_VIEW_FORUM}">{FORUM_NAME}</a> >> {TOPIC_TITLE}
</td> </td>
</tr> </tr>
</table> </table>
@ -22,11 +22,7 @@
<table border="0" width="100%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1"> <table border="0" width="100%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1">
<tr> <tr>
<td align="right" style="{font-size: 8pt;}"> <td align="right" style="{font-size: 8pt;}">
<a href="posting.{PHPEX}?mode=newtopic&{S_FORUMS_URL}={FORUM_ID}"> <a href="{U_POST_NEW_TOPIC}"><img src="images/newpost.jpg" height="50" width="125" alt="Post New Topic" border="0"></a>&nbsp;<a href="{U_POST_REPLY_TOPIC}"><img src="images/reply.jpg" height="50" width="125" alt="Reply to this topic" border="0"></a>
<img src="images/newpost.jpg" height="50" width="125" alt="Post New Topic" border="0"></a>&nbsp;
<a href="posting.{PHPEX}?mode=reply&{S_TOPICS_URL}={TOPIC_ID}">
<img src="images/reply.jpg" height="50" width="125" alt="Reply to this topic" border="0">
</a>
</td> </td>
</tr> </tr>
</table> </table>

View file

@ -23,6 +23,9 @@
include('extension.inc'); include('extension.inc');
include('common.'.$phpEx); include('common.'.$phpEx);
$pagetype = "viewforum";
$page_title = "View Forum - $forum_name";
// //
// Obtain which forum id is required // Obtain which forum id is required
// //
@ -35,21 +38,10 @@ else
$forum_id = ($HTTP_GET_VARS['forum']) ? $HTTP_GET_VARS['forum'] : $HTTP_POST_VARS['forum']; $forum_id = ($HTTP_GET_VARS['forum']) ? $HTTP_GET_VARS['forum'] : $HTTP_POST_VARS['forum'];
} }
$pagetype = "viewforum";
$page_title = "View Forum - $forum_name";
// //
// Start session management // Check if the user has actually sent a forum ID with his/her request
//
$userdata = session_pagestart($user_ip, $forum_id, $session_length);
init_userprefs($userdata);
//
// End session management
//
// Check if the user has acutally sent a forum ID with his/her request
// If not give them a nice error page. // If not give them a nice error page.
//
if(isset($forum_id)) if(isset($forum_id))
{ {
$sql = "SELECT f.forum_type, f.forum_name, f.forum_topics, u.username, u.user_id $sql = "SELECT f.forum_type, f.forum_name, f.forum_topics, u.username, u.user_id
@ -63,21 +55,31 @@ else
error_die(GENERAL_ERROR, "You have reached this page in error, please go back and try again"); error_die(GENERAL_ERROR, "You have reached this page in error, please go back and try again");
} }
//
// Start session management
//
$userdata = session_pagestart($user_ip, $forum_id, $session_length);
init_userprefs($userdata);
//
// End session management
//
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
error_die(SQL_QUERY, "Couldn't obtain forums information.", __LINE__, __FILE__); error_die(SQL_QUERY, "Couldn't obtain forums information.", __LINE__, __FILE__);
} }
// If the query doesn't return any rows this
// isn't a valid forum. Inform the user.
if(!$total_rows = $db->sql_numrows($result))
{
error_die(GENERAL_ERROR, "The forum you selected does not exist. Please go back and try again.");
}
// //
// Add checking for private forums here!! // Add checking for private forums here!!
// //
// If the query dosan't return any rows this isn't a valid forum. Inform the user.
if(!$total_rows = $db->sql_numrows($result))
{
error_die(GENERAL_ERROR, "The forum you selected does not exist. Please go back and try again.");
}
$forum_row = $db->sql_fetchrowset($result); $forum_row = $db->sql_fetchrowset($result);
if(!$forum_row) if(!$forum_row)
@ -91,12 +93,10 @@ for($x = 0; $x < $db->sql_numrows($result); $x++)
{ {
if($x > 0) if($x > 0)
$forum_moderators .= ", "; $forum_moderators .= ", ";
$forum_moderators .= "<a href=\"profile.$phpEx?mode=viewprofile&user_id=".$forum_row[$x]["user_id"]."\">".$forum_row[$x]["username"]."</a>";
$forum_moderators .= "<a href=\"profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=".$forum_row[$x]["user_id"]."\">".$forum_row[$x]["username"]."</a>";
} }
include('includes/page_header.'.$phpEx);
if(!isset($start)) if(!isset($start))
{ {
$start = 0; $start = 0;
@ -109,13 +109,29 @@ $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as i
LEFT JOIN " . USERS_TABLE . " u2 ON p.poster_id = u2.user_id LEFT JOIN " . USERS_TABLE . " u2 ON p.poster_id = u2.user_id
WHERE t.forum_id = '$forum_id' WHERE t.forum_id = '$forum_id'
ORDER BY topic_time DESC ORDER BY topic_time DESC
LIMIT $start, $topics_per_page"; LIMIT $start, ".$board_config['topics_per_page'];
if(!$t_result = $db->sql_query($sql)) if(!$t_result = $db->sql_query($sql))
{ {
error_die(SQL_QUERY, "Couldn't obtain topic information.", __LINE__, __FILE__); error_die(SQL_QUERY, "Couldn't obtain topic information.", __LINE__, __FILE__);
} }
$total_topics = $db->sql_numrows(); $total_topics = $db->sql_numrows($t_result);
//
// Post URL generation for
// templating vars
//
$post_new_topic_url = "posting.".$phpEx."?mode=newtopic&".POST_FORUM_URL."=$forum_id";
$template->assign_vars(array(
"U_POST_NEW_TOPIC" => $post_new_topic_url));
//
// Dump out the page header
//
include('includes/page_header.'.$phpEx);
//
// Okay, lets dump out the page ...
//
if($total_topics) if($total_topics)
{ {
$topic_rowset = $db->sql_fetchrowset($t_result); $topic_rowset = $db->sql_fetchrowset($t_result);
@ -124,15 +140,15 @@ if($total_topics)
$topic_title = stripslashes($topic_rowset[$x]["topic_title"]); $topic_title = stripslashes($topic_rowset[$x]["topic_title"]);
$topic_id = $topic_rowset[$x]["topic_id"]; $topic_id = $topic_rowset[$x]["topic_id"];
$replies = $topic_rowset[$x]["topic_replies"]; $replies = $topic_rowset[$x]["topic_replies"];
if($replies > $posts_per_page) if($replies > $board_config['posts_per_page'])
{ {
$goto_page = "&nbsp;&nbsp;&nbsp;(<img src=\"images/posticon.gif\">$l_gotopage: "; $goto_page = "&nbsp;&nbsp;&nbsp;(<img src=\"".$images['posticon']."\">$l_gotopage: ";
$times = 1; $times = 1;
for($i = 0; $i < ($replies + 1); $i += $posts_per_page) for($i = 0; $i < ($replies + 1); $i += $board_config['posts_per_page'])
{ {
if($times > 4) if($times > 4)
{ {
if(($i + $posts_per_page) >= ($replies + 1)) if(($i + $board_config['posts_per_page']) >= ($replies + 1))
{ {
$goto_page.=" ... <a href=\"viewtopic.$phpEx?".POST_TOPIC_URL."=".$topic_id."&start=$i\">$times</a>"; $goto_page.=" ... <a href=\"viewtopic.$phpEx?".POST_TOPIC_URL."=".$topic_id."&start=$i\">$times</a>";
} }
@ -153,34 +169,48 @@ if($total_topics)
{ {
$goto_page = ""; $goto_page = "";
} }
$folder_img = "<img src=\"".$images['folder']."\">";
$view_topic_url = "viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&".$replies;
$topic_poster = stripslashes($topic_rowset[$x]["username"]); $topic_poster = stripslashes($topic_rowset[$x]["username"]);
$views = $topic_rowset[$x]["topic_views"]; $topic_poster_profile_url = "profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=".$topic_rowset[$x]["user_id"];
$last_post_time = create_date($date_format, $topic_rowset[$x]["post_time"], $sys_timezone);
$last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$x]["post_time"], $board_config['default_timezone']);
$last_post_user = $topic_rowset[$x]["user2"]; $last_post_user = $topic_rowset[$x]["user2"];
$folder_img = "<img src=\"images/folder.gif\">"; $last_post_profile_url = "profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=".$topic_rowset[$x]["id2"];
$template->assign_block_vars(
"topicrow", array("FORUM_ID" => $forum_id, $views = $topic_rowset[$x]["topic_views"];
$template->assign_block_vars("topicrow", array(
"FORUM_ID" => $forum_id,
"TOPIC_ID" => $topic_id, "TOPIC_ID" => $topic_id,
"FOLDER" => $folder_img, "FOLDER" => $folder_img,
"TOPIC_POSTER" => "<a href=\"profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=".$topic_rowset[$x]["user_id"]."\">".$topic_poster."</a>", "TOPIC_POSTER" => $topic_poster,
"U_TOPIC_POSTER_PROFILE" => $topic_poster_profile_url,
"GOTO_PAGE" => $goto_page, "GOTO_PAGE" => $goto_page,
"REPLIES" => $replies, "REPLIES" => $replies,
"TOPIC_TITLE" => $topic_title, "TOPIC_TITLE" => $topic_title,
"VIEWS" => $views, "VIEWS" => $views,
"LAST_POST" => $last_post_time . "<br />$l_by <a href=\"profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=".$topic_rowset[$x]["id2"]."\">" . $last_post_user ."</a>")); "LAST_POST_TIME" => $last_post_time,
"LAST_POST_USER" => $last_post_user,
"U_VIEW_TOPIC" => $view_topic_url,
"U_LAST_POST_USER_PROFILE" => $last_post_profile_url));
} }
$count = 1; $count = 1;
$next = $start + $topics_per_page; $next = $start + $board_config['topics_per_page'];
if($topics_count > $topics_per_page) if($topics_count > $board_config['topics_per_page'])
{ {
if($next < $topics_count) if($next < $topics_count)
{ {
$pagination = "<a href=\"viewforum.$phpEx?forum_id=$forum_id&start=$next\">$l_nextpage</a> | "; $pagination = "<a href=\"viewforum.$phpEx?".POST_FORUM_URL."=$forum_id&start=$next\">$l_nextpage</a> | ";
} }
for($x = 0; $x < $topics_count; $x++) for($x = 0; $x < $topics_count; $x++)
{ {
if(!($x % $topics_per_page)) if(!($x % $board_config['topics_per_page']))
{ {
if($x == $start) if($x == $start)
{ {
@ -198,7 +228,8 @@ if($total_topics)
} }
} }
} }
$template->assign_vars(array("PAGINATION" => $pagination)); $template->assign_vars(array(
"PAGINATION" => $pagination));
$template->pparse("body"); $template->pparse("body");
} }
else else

View file

@ -24,6 +24,9 @@ include('extension.inc');
include('common.'.$phpEx); include('common.'.$phpEx);
include('includes/bbcode.'.$phpEx); include('includes/bbcode.'.$phpEx);
$page_title = "View Topic - $topic_title";
$pagetype = "viewtopic";
if(!isset($HTTP_GET_VARS['topic'])) // For backward compatibility if(!isset($HTTP_GET_VARS['topic'])) // For backward compatibility
{ {
$topic_id = $HTTP_GET_VARS[POST_TOPIC_URL]; $topic_id = $HTTP_GET_VARS[POST_TOPIC_URL];
@ -84,11 +87,9 @@ for($x = 0; $x < $total_rows; $x++)
// Add checking for private forums here // Add checking for private forums here
// //
$total_replies = $forum_row[0]["topic_replies"] + 1;
$page_title = "View Topic - $topic_title";
$pagetype = "viewtopic"; $total_replies = $forum_row[0]["topic_replies"] + 1;
include('includes/page_header.'.$phpEx);
if(!isset($start)) if(!isset($start))
{ {
@ -103,7 +104,7 @@ $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website,
AND (r.rank_special = 1) AND (r.rank_special = 1)
WHERE p.topic_id = '$topic_id' WHERE p.topic_id = '$topic_id'
ORDER BY p.post_time ASC ORDER BY p.post_time ASC
LIMIT $start, $posts_per_page"; LIMIT $start, ".$board_config['posts_per_page'];
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
error_die(SQL_QUERY, "Couldn't obtain post/user information.", __LINE__, __FILE__); error_die(SQL_QUERY, "Couldn't obtain post/user information.", __LINE__, __FILE__);
@ -122,14 +123,39 @@ if(!$ranks_result = $db->sql_query($sql))
$postrow = $db->sql_fetchrowset($result); $postrow = $db->sql_fetchrowset($result);
$ranksrow = $db->sql_fetchrowset($ranksresult); $ranksrow = $db->sql_fetchrowset($ranksresult);
//
// Post, reply and other URL generation for
// templating vars
//
$new_topic_url = "posting.".$phpEx."?mode=newtopic&".POST_FORUM_URL."=$forum_id";
$reply_topic_url = "posting.".$phpEx."?mode=reply&".POST_TOPIC_URL."=$topic_id";
$view_forum_url = "viewforum.".$phpEx."?".POST_FORUM_URL."=$forum_id";
$view_older_topic_url = "viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&view=older";
$view_newer_topic_url = "viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&view=newer";
$template->assign_vars(array(
"U_POST_NEW_TOPIC" => $new_topic_url,
"U_VIEW_FORUM" => $view_forum_url,
"U_VIEW_OLDER_TOPIC" => $view_older_topic_url,
"U_VIEW_NEWER_TOPIC" => $view_newer_topic_url,
"U_POST_REPLY_TOPIC" => $reply_topic_url));
//
// Dump out the page header
//
include('includes/page_header.'.$phpEx);
//
// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...
//
for($x = 0; $x < $total_posts; $x++) for($x = 0; $x < $total_posts; $x++)
{ {
$poster = stripslashes($postrow[$x]["username"]); $poster = stripslashes($postrow[$x]["username"]);
$poster_id = $postrow[$x]["user_id"]; $poster_id = $postrow[$x]["user_id"];
$post_date = create_date($date_format, $postrow[$x]["post_time"], $sys_timezone); $post_date = create_date($board_config['default_dateformat'], $postrow[$x]["post_time"], $board_config['default_timezone']);
$poster_posts = $postrow[$x]["user_posts"]; $poster_posts = $postrow[$x]["user_posts"];
$poster_from = ($postrow[$x]["user_from"]) ? "$l_from: ".$postrow[$x]["user_from"] : ""; $poster_from = ($postrow[$x]["user_from"]) ? "$l_from: ".$postrow[$x]["user_from"] : "";
$poster_joined = create_date($date_format, $postrow[$x]["user_regdate"], $sys_timezone); $poster_joined = create_date($board_config['default_dateformat'], $postrow[$x]["user_regdate"], $board_config['default_timezone']);
if($poster_id != ANONYMOUS && $poster_id != DELETED) if($poster_id != ANONYMOUS && $poster_id != DELETED)
{ {
if(!$postrow[$x]["rank_title"]) if(!$postrow[$x]["rank_title"])
@ -154,16 +180,14 @@ for($x = 0; $x < $total_posts; $x++)
$poster_rank = ""; $poster_rank = "";
} }
$profile_img = "<a href=\"profile.$phpEx?mode=viewprofile&user_id=$poster_id\"><img src=\"".$images['profile']."\" alt=\"$l_profileof $poster\" border=\"0\"></a>";
$email_img = ($postrow[$x]["user_viewemail"] == 1) ? "<a href=\"mailto:".$postrow[$x]["user_email"]."\"><img src=\"".$images['email']."\" alt=\"$l_email $poster\" border=\"0\"></a>" : "";
$profile_img = "<a href=\"profile.$phpEx?mode=viewprofile&user_id=$poster_id\"><img src=\"$image_profile\" alt=\"$l_profileof $poster\" border=\"0\"></a>"; $www_img = ($postrow[$x]["user_website"]) ? "<a href=\"".$postrow[$x]["user_website"]."\"><img src=\"".$images['www']."\" alt=\"$l_viewsite\" border=\"0\"></a>" : "";
$email_img = ($postrow[$x]["user_viewemail"] == 1) ? "<a href=\"mailto:".$postrow[$x]["user_email"]."\"><img src=\"$image_email\" alt=\"$l_email $poster\" border=\"0\"></a>" : "";
$www_img = ($postrow[$x]["user_website"]) ? "<a href=\"".$postrow[$x]["user_website"]."\"><img src=\"$image_www\" alt=\"$l_viewsite\" border=\"0\"></a>" : "";
if($postrow[$x]["user_icq"]) if($postrow[$x]["user_icq"])
{ {
$icq_status_img = "<a href=\"http://wwp.icq.com/".$postrow[$x]["user_icq"]."#pager\"><img src=\"http://online.mirabilis.com/scripts/online.dll?icq=".$postrow[$x]["user_icq"]."&img=5\" alt=\"$l_icqstatus\" border=\"0\"></a>"; $icq_status_img = "<a href=\"http://wwp.icq.com/".$postrow[$x]["user_icq"]."#pager\"><img src=\"http://online.mirabilis.com/scripts/online.dll?icq=".$postrow[$x]["user_icq"]."&img=5\" alt=\"$l_icqstatus\" border=\"0\"></a>";
$icq_add_img = "<a href=\"http://wwp.icq.com/scripts/search.dll?to=".$postrow[$x]["user_icq"]."\"><img src=\"$image_icq\" alt=\"$l_icq\" border=\"0\"></a>"; $icq_add_img = "<a href=\"http://wwp.icq.com/scripts/search.dll?to=".$postrow[$x]["user_icq"]."\"><img src=\"".$images['icq']."\" alt=\"$l_icq\" border=\"0\"></a>";
} }
else else
{ {
@ -171,30 +195,30 @@ for($x = 0; $x < $total_posts; $x++)
$icq_add_img = ""; $icq_add_img = "";
} }
$aim_img = ($postrow[$x]["user_aim"]) ? "<a href=\"aim:goim?screenname=".$postrow[$x]["user_aim"]."&message=Hello+Are+you+there?\"><img src=\"$image_aim\" border=\"0\"></a>" : ""; $aim_img = ($postrow[$x]["user_aim"]) ? "<a href=\"aim:goim?screenname=".$postrow[$x]["user_aim"]."&message=Hello+Are+you+there?\"><img src=\"".$images['aim']."\" border=\"0\"></a>" : "";
$msn_img = ($postrow[$x]["user_msnm"]) ? "<a href=\"profile.$phpEx?mode=viewprofile&user_id=$poster_id\"><img src=\"$image_msn\" border=\"0\"></a>" : ""; $msn_img = ($postrow[$x]["user_msnm"]) ? "<a href=\"profile.$phpEx?mode=viewprofile&user_id=$poster_id\"><img src=\"".$images['msn']."\" border=\"0\"></a>" : "";
$yim_img = ($postrow[$x]["user_yim"]) ? "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=".$postrow[$x]["user_yim"]."&.src=pg\"><img src=\"$image_yim\" border=\"0\"></a>" : ""; $yim_img = ($postrow[$x]["user_yim"]) ? "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=".$postrow[$x]["user_yim"]."&.src=pg\"><img src=\"".$images['yim']."\" border=\"0\"></a>" : "";
$edit_img = "<a href=\"posting.$phpEx?mode=editpost&post_id=".$postrow[$x]["post_id"]."&topic_id=$topic_id&forum_id=$forum_id\"><img src=\"$image_edit\" alt=\"$l_editdelete\" border=\"0\"></a>"; $edit_img = "<a href=\"posting.$phpEx?mode=editpost&post_id=".$postrow[$x]["post_id"]."&topic_id=$topic_id&forum_id=$forum_id\"><img src=\"".$images['edit']."\" alt=\"$l_editdelete\" border=\"0\"></a>";
$quote_img = "<a href=\"posting.$phpEx?mode=reply&quote=true&post_id=".$postrow[$x]["post_id"]."&topic_id=$topic_id&forum_id=$forum_id\"><img src=\"$image_quote\" alt=\"$l_replyquote\" border=\"0\"></a>"; $quote_img = "<a href=\"posting.$phpEx?mode=reply&quote=true&post_id=".$postrow[$x]["post_id"]."&topic_id=$topic_id&forum_id=$forum_id\"><img src=\"".$images['quote']."\" alt=\"$l_replyquote\" border=\"0\"></a>";
$pmsg_img = "<a href=\"priv_msgs.$phpEx?mode=send\"><img src=\"$image_pmsg\" alt=\"$l_sendpmsg\" border=\"0\"></a>"; $pmsg_img = "<a href=\"priv_msgs.$phpEx?mode=send\"><img src=\"".$images['pmsg']."\" alt=\"$l_sendpmsg\" border=\"0\"></a>";
if($is_moderator) if($is_moderator)
{ {
$ip_img = "<a href=\"topicadmin.$phpEx?mode=viewip&user_id=".$poster_id."\"><img src=\"$image_ip\" alt=\"$l_viewip\" border=\"0\"></a>"; $ip_img = "<a href=\"topicadmin.$phpEx?mode=viewip&user_id=".$poster_id."\"><img src=\"".$images['ip']."\" alt=\"$l_viewip\" border=\"0\"></a>";
$delpost_img = "<a href=\"topicadmin.$phpEx?mode=delpost$post_id=".$postrow[$x]["post_id"]."\"><img src=\"$image_delpost\" alt=\"$l_delete\" border=\"0\"></a>"; $delpost_img = "<a href=\"topicadmin.$phpEx?mode=delpost$post_id=".$postrow[$x]["post_id"]."\"><img src=\"".$images['delpost']."\" alt=\"$l_delete\" border=\"0\"></a>";
} }
$message = stripslashes($postrow[$x]["post_text"]); $message = stripslashes($postrow[$x]["post_text"]);
$bbcode_uid = $postrow[$x]['bbcode_uid']; $bbcode_uid = $postrow[$x]['bbcode_uid'];
$user_sig = stripslashes($postrow[$x]['user_sig']); $user_sig = stripslashes($postrow[$x]['user_sig']);
if(!$allow_html) if(!$board_config['allow_html'])
{ {
$user_sig = strip_tags($user_sig); $user_sig = strip_tags($user_sig);
$message = strip_tags($message); $message = strip_tags($message);
} }
if($allow_bbcode) if($board_config['allow_bbcode'])
{ {
// do bbcode stuff here // do bbcode stuff here
$sig_uid = make_bbcode_uid(); $sig_uid = make_bbcode_uid();
@ -233,7 +257,8 @@ for($x = 0; $x < $total_posts; $x++)
$message = eregi_replace("\[addsig]$", "<br />_________________<br />" . nl2br($user_sig), $message); $message = eregi_replace("\[addsig]$", "<br />_________________<br />" . nl2br($user_sig), $message);
$template->assign_block_vars("postrow", array("TOPIC_TITLE" => $topic_title, $template->assign_block_vars("postrow", array(
"TOPIC_TITLE" => $topic_title,
"POSTER_NAME" => $poster, "POSTER_NAME" => $poster,
"POSTER_RANK" => $poster_rank, "POSTER_RANK" => $poster_rank,
"RANK_IMAGE" => $rank_image, "RANK_IMAGE" => $rank_image,
@ -258,25 +283,25 @@ for($x = 0; $x < $total_posts; $x++)
"DELPOST_IMG" => $delpost_img)); "DELPOST_IMG" => $delpost_img));
} }
if($total_replies > $posts_per_page) if($total_replies > $board_config['posts_per_page'])
{ {
$times = 0; $times = 0;
for($x = 0; $x < $total_replies; $x += $posts_per_page) for($x = 0; $x < $total_replies; $x += $board_config['posts_per_page'])
{ {
$times++; $times++;
} }
$pages = $times . " pages"; $pages = $times . " $l_pages";
$times = 1; $times = 1;
$pagination = "$l_gotopage ("; $pagination = "$l_gotopage (";
$last_page = $start - $posts_per_page; $last_page = $start - $board_config['posts_per_page'];
if($start > 0) if($start > 0)
{ {
$pagination .= "<a href=\"$PHP_SELF?".POST_TOPIC_URL."=$topic_id&forum_id=$forum_id&start=$last_page\">$l_prevpage</a> "; $pagination .= "<a href=\"$PHP_SELF?".POST_TOPIC_URL."=$topic_id&start=$last_page\">$l_prevpage</a> ";
} }
for($x = 0; $x < $total_replies; $x += $posts_per_page) for($x = 0; $x < $total_replies; $x += $board_config['posts_per_page'])
{ {
if($times != 1) if($times != 1)
{ {
@ -292,24 +317,25 @@ if($total_replies > $posts_per_page)
} }
else else
{ {
$pagination .= "<a href=\"$PHP_SELF?".POST_TOPIC_URL."=$topic_id&forum_id=$forum_id&start=$x\">$times</a>"; $pagination .= "<a href=\"$PHP_SELF?".POST_TOPIC_URL."=$topic_id&start=$x\">$times</a>";
} }
$times++; $times++;
} }
if(($start + $posts_per_page) < $total_replies) if(($start + $board_config['posts_per_page']) < $total_replies)
{ {
$next_page = $start + $posts_per_page; $next_page = $start + $board_config['posts_per_page'];
$pagination .= " <a href=\"$PHP_SELF?".POST_TOPIC_URL."=$topic_id&forum_id=$forum_id&start=$next_page\">$l_nextpage</a>"; $pagination .= " <a href=\"$PHP_SELF?".POST_TOPIC_URL."=$topic_id&start=$next_page\">$l_nextpage</a>";
} }
$pagination .= " )"; $pagination .= " )";
} }
else else
{ {
$pages = "1 page"; $pages = "1 $l_page";
} }
$template->assign_vars(array("PAGES" => $pages, $template->assign_vars(array(
"PAGES" => $pages,
"PAGINATION" => $pagination)); "PAGINATION" => $pagination));
$template->pparse("body"); $template->pparse("body");