mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-13 20:32:11 +02:00
Viewforum works, and error die outputs nice, templated, errors
git-svn-id: file:///svn/phpbb/trunk@37 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
8523870f8e
commit
4e5538cb78
@ -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");
|
||||
|
||||
?>
|
||||
|
@ -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)
|
||||
|
@ -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>";
|
||||
|
||||
|
@ -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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user