diff options
author | James Atkinson <thefinn@users.sourceforge.net> | 2001-02-23 23:39:42 +0000 |
---|---|---|
committer | James Atkinson <thefinn@users.sourceforge.net> | 2001-02-23 23:39:42 +0000 |
commit | 4e5538cb78ceb8e93ae10ec9ad306547e6014972 (patch) | |
tree | b235f5d42c0186805d4e6bfd8df5a78a6cf24b88 | |
parent | 8523870f8e55c5e170529a68eec6a93b0059d5a2 (diff) | |
download | forums-4e5538cb78ceb8e93ae10ec9ad306547e6014972.tar forums-4e5538cb78ceb8e93ae10ec9ad306547e6014972.tar.gz forums-4e5538cb78ceb8e93ae10ec9ad306547e6014972.tar.bz2 forums-4e5538cb78ceb8e93ae10ec9ad306547e6014972.tar.xz forums-4e5538cb78ceb8e93ae10ec9ad306547e6014972.zip |
Viewforum works, and error die outputs nice, templated, errors
git-svn-id: file:///svn/phpbb/trunk@37 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/db.php | 9 | ||||
-rw-r--r-- | phpBB/functions/error.php | 5 | ||||
-rw-r--r-- | phpBB/functions/functions.php | 50 | ||||
-rw-r--r-- | phpBB/viewforum.php | 17 |
4 files changed, 54 insertions, 27 deletions
diff --git a/phpBB/db.php b/phpBB/db.php index 3f37068919..951235eabe 100644 --- a/phpBB/db.php +++ b/phpBB/db.php @@ -37,6 +37,10 @@ switch($dbms) break; } + +// Setup what template to use. Currently just use default +$template = new Template("./templates/Default", "keep"); + // Make the database connection. $db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, false); if(!$db) @@ -59,7 +63,7 @@ $userdata = Array(); $sql = "SELECT * FROM ".CONFIG_TABLE." WHERE selected = 1"; if(!$result = $db->sql_query($sql)) { - error_die($db, QUERY_ERROR); + error_die($db, SQL_CONNECT); } else { @@ -110,7 +114,4 @@ if (!$user_logged_in) } } -// Setup what template to use. Currently just use default -$template = new Template("./templates/Default", "keep"); - ?> diff --git a/phpBB/functions/error.php b/phpBB/functions/error.php index 6b53da1838..f8182335f2 100644 --- a/phpBB/functions/error.php +++ b/phpBB/functions/error.php @@ -25,6 +25,11 @@ function error_die($db, $error_code = "", $error_msg = "") { global $template, $phpEx; + + if(!$template->get("overall_header")) + { + include('page_header.'.$phpEx); + } if(!$error_msg) { switch($error_code) diff --git a/phpBB/functions/functions.php b/phpBB/functions/functions.php index 941ccd0e22..5d660f8db9 100644 --- a/phpBB/functions/functions.php +++ b/phpBB/functions/functions.php @@ -76,39 +76,51 @@ function get_newest_user($db) function make_jumpbox($db, $phpEx) { - $boxstring = " <FORM ACTION=\"viewforum.$phpEx\" METHOD=\"GET\"> + Jump to: <SELECT NAME=\"forum_id\"><OPTION VALUE=\"-1\">Select Forum</OPTION> "; $sql = "SELECT cat_id, cat_title FROM ".CATEGORIES_TABLE." ORDER BY cat_order"; - $result = $db->sql_query($sql); - if($total_cats = $db->sql_numrows($result)) + if($result = $db->sql_query($sql)) { - for($x = 0; $x < $total_cats; $x++) + if($total_cats = $db->sql_numrows($result)) { - $boxstring .= "<OPTION VALUE=\"-1\"> </OPTION>\n"; - $boxstring .= "<OPTION VALUE=\"-1\">".stripslashes($cat_rows[$x]["cat_title"])."</OPTION>\n"; - $boxstring .= "<OPTION VALUE=\"-1\">----------------</OPTION>\n"; $cat_rows = $db->sql_fetchrowset($result); - $f_sql = "SELECT forum_name, forum_id FROM ".FORUMS_TABLE." - WHERE cat_id = ". $cat_rows[$x]["cat_id"] . " ORDER BY forum_id"; - if($f_result = $db->sql_query($f_sql)) + for($x = 0; $x < $total_cats; $x++) { - if($total_forums = $db->sql_numrows($f_result)) { - $f_rows = $db->sql_fetchrowset($f_result); - for($y = 0; $y < $total_forums; $y++) - { - $name = stripslashes($f_rows[$y]["forum_name"]); - $boxstring .= "<OPTION VALUE=\"".$f_rows[$y]["forum_id"]."\">$name</OPTION>\n"; - } - } + $boxstring .= "<OPTION VALUE=\"-1\"> </OPTION>\n"; + $boxstring .= "<OPTION VALUE=\"-1\">".stripslashes($cat_rows[$x]["cat_title"])."</OPTION>\n"; + $boxstring .= "<OPTION VALUE=\"-1\">----------------</OPTION>\n"; + + $f_sql = "SELECT forum_name, forum_id FROM ".FORUMS_TABLE." + WHERE cat_id = ". $cat_rows[$x]["cat_id"] . " ORDER BY forum_id"; + if($f_result = $db->sql_query($f_sql)) + { + if($total_forums = $db->sql_numrows($f_result)) + { + $f_rows = $db->sql_fetchrowset($f_result); + for($y = 0; $y < $total_forums; $y++) + { + $name = stripslashes($f_rows[$y]["forum_name"]); + $boxstring .= "<OPTION VALUE=\"".$f_rows[$y]["forum_id"]."\">$name</OPTION>\n"; + } + } + } + else + { + $boxstring .= "<option value=\"-1\">Error!</option>\n"; + } } } + else + { + $boxstring .= "<option value=\"-1\">No Forums to Jump to</option>\n"; + } } else { - $boxstring .= "<option value=\"-1\">No Forums to Jump to</option>\n"; + $boxstring .= "<option value=\"-1\">Cat Error</option>\n"; } $boxstring .= "</SELECT>\n<br><INPUT TYPE=\"SUBMIT\" VALUE=\"Jump\"></FORM>"; diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 03368d71b8..b11ae6143f 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -30,27 +30,36 @@ include('functions/functions.'.$phpEx); include('functions/error.'.$phpEx); include('db.'.$phpEx); +// Check if the user has acutally sent a forum ID with his/her request +// If not give them a nice error page. if(isset($forum_id)) { $sql = "SELECT f.forum_type, f.forum_name - FROM ".FORUMS_TABLE." f - WHERE forum_id = '$forum_id'"; + FROM ".FORUMS_TABLE." f + WHERE forum_id = '$forum_id'"; } else { - error_die($db, "You have reached this page in error, please go back and try again"); + error_die($db, "", "You have reached this page in error, please go back and try again"); } if(!$result = $db->sql_query($sql)) { error_die($db, QUERY_ERROR); } -$total_rows = $db->sql_numrows($result); + +// 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($db, "", "The forum you selected does not exist. Please go back and try again."); +} + $forum_row = $db->sql_fetchrowset($result); if(!$forum_row) { error_die($db, QUERY_ERROR); } + $forum_name = stripslashes($forum_row[0]["forum_name"]); $forum_moderators = "<a href=\"profile.$phpEx?mode=viewprofile&user_id=1\">james</a>"; $pagetype = "viewforum"; |