Various bugfixes, mostly with URL generation (maintenance commit, may not be in a working state)
authorDan
Sun, 02 Sep 2007 10:56:36 -0400
changeset 4 eb9ed4c366d0
parent 3 c0c445d4a13e
child 5 e3d7322305bf
Various bugfixes, mostly with URL generation (maintenance commit, may not be in a working state)
plugins/PunBB.php
punbb/footer.php
punbb/include/common.php
punbb/include/common_admin.php
punbb/include/enano_dbal.php
punbb/include/functions.php
punbb/index.php
punbb/userlist.php
--- a/plugins/PunBB.php	Thu Jul 12 15:00:35 2007 -0400
+++ b/plugins/PunBB.php	Sun Sep 02 10:56:36 2007 -0400
@@ -36,9 +36,9 @@
 $plugins->attachHook('session_started', '
     $pid = RenderMan::strToPageId($paths->get_pageid_from_url());
 
-    if ( getConfig("punbb_installed") == "yes" && getConfig("punbb_version") == PUNANO_VERSION && $pid[0] == "Forum" && $pid[1] == "Special" )
+    if ( getConfig("punbb_installed") == "yes" && getConfig("punbb_version") == PUNANO_VERSION && preg_match("#^Forum(/.*)?$#", $pid[0]) && $pid[1] == "Special" )
     {
-      require( "punbb/include/common.php" );
+      require( ENANO_ROOT . "/punbb/include/common.php" );
     }
     ');
 
@@ -204,7 +204,7 @@
 function punano_upgrade()
 {
   global $db, $session, $paths, $template, $plugins; // Common objects
-  
+  die('Punano upgrade was requested but this isn\'t implemented yet.');
 }
 
 function punano_main()
@@ -261,6 +261,7 @@
 
   if ( $session->auth_level < $need_level )
   {
+    $need_level = ( $session->user_level > $need_level ) ? $session->user_level : $need_level;
     redirect( makeUrlNS('Special', 'Login/' . $paths->fullpage, 'level=' . $need_level, false), 'Permission denied', 'You need to have permission level ' . $session->userlevel_to_string($need_level) . ' to use the PunBB administration console.', 2);
   }
   
--- a/punbb/footer.php	Thu Jul 12 15:00:35 2007 -0400
+++ b/punbb/footer.php	Sun Sep 02 10:56:36 2007 -0400
@@ -112,10 +112,11 @@
 // Display debug info (if enabled/defined)
 if (defined('PUN_DEBUG'))
 {
+  global $pun_start;
 	// Calculate script generation time
 	list($usec, $sec) = explode(' ', microtime());
 	$time_diff = sprintf('%.3f', ((float)$usec + (float)$sec) - $pun_start);
-	echo "\t\t\t".'<p class="conr">[ Generated in '.$time_diff.' seconds, '.$pun_db->get_num_queries().' queries executed ]</p>'."\n";
+	echo "\t\t\t".'<p class="conr">[ PunBB time: '.$time_diff.' seconds, '.$pun_db->get_num_queries().' queries executed ]</p>'."\n";
 }
 
 ?>
--- a/punbb/include/common.php	Thu Jul 12 15:00:35 2007 -0400
+++ b/punbb/include/common.php	Sun Sep 02 10:56:36 2007 -0400
@@ -23,11 +23,11 @@
 ************************************************************************/
 
 // Enable DEBUG mode by removing // from the following line
-define('PUN_DEBUG', 1);
+// define('PUN_DEBUG', 1);
 
 // This displays all executed queries in the page footer.
 // DO NOT enable this in a production environment!
-define('PUN_SHOW_QUERIES', 1);
+// define('PUN_SHOW_QUERIES', 1);
 
 if (!defined('PUN_ROOT'))
 	exit('The constant PUN_ROOT must be defined and point to a valid PunBB installation root directory.');
@@ -47,13 +47,14 @@
 
 // Record the start time (will be used to calculate the generation time for the page)
 
-function get_microtime()
+function pun_microtime()
 {
   list($usec, $sec) = explode(' ', microtime());
   return ((float)$usec + (float)$sec);
 }
 
-$pun_start = get_microtime();
+$GLOBALS['pun_start'] = pun_microtime();
+$pun_start =& $GLOBALS['pun_start'];
 
 // Make sure PHP reports all errors except E_NOTICE. PunBB supports E_ALL, but a lot of scripts it may interact with, do not.
 error_reporting(E_ALL);
--- a/punbb/include/common_admin.php	Thu Jul 12 15:00:35 2007 -0400
+++ b/punbb/include/common_admin.php	Sun Sep 02 10:56:36 2007 -0400
@@ -86,7 +86,7 @@
 <?php
 
 		while (list(, $cur_plugin) = @each($plugins))
-			echo "\t\t\t\t\t".'<li'.(($page == $cur_plugin[1]) ? ' class="isactive"' : '').'><a href="admin_loader.php?plugin='.$cur_plugin[1].'">'.str_replace('_', ' ', $cur_plugin[0]).'</a></li>'."\n";
+			echo "\t\t\t\t\t".'<li'.(($page == $cur_plugin[1]) ? ' class="isactive"' : '').'><a href="' . makeUrlNS('Special', 'Forum/Admin_Loader', 'plugin='.$cur_plugin[1], true) . '">'.str_replace('_', ' ', $cur_plugin[0]).'</a></li>'."\n";
 
 ?>
 				</ul>
--- a/punbb/include/enano_dbal.php	Thu Jul 12 15:00:35 2007 -0400
+++ b/punbb/include/enano_dbal.php	Sun Sep 02 10:56:36 2007 -0400
@@ -61,7 +61,7 @@
 	{
     global $db;
 		if (defined('PUN_SHOW_QUERIES'))
-			$q_start = get_microtime();
+			$q_start = pun_microtime();
 
 		if ($unbuffered)
 			$this->query_result = $db->sql_unbuffered_query($sql);
@@ -71,7 +71,7 @@
 		if ($this->query_result)
 		{
 			if (defined('PUN_SHOW_QUERIES'))
-				$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
+				$this->saved_queries[] = array($sql, sprintf('%.5f', pun_microtime() - $q_start));
 
 			++$this->num_queries;
 
--- a/punbb/include/functions.php	Thu Jul 12 15:00:35 2007 -0400
+++ b/punbb/include/functions.php	Sun Sep 02 10:56:36 2007 -0400
@@ -241,19 +241,19 @@
   global $db, $session, $paths, $template, $plugins; // Common objects
 
 	// Index and Userlist should always be displayed
-	$links[] = '<li id="navindex"><a href="index.php">'.$lang_common['Index'].'</a>';
-	$links[] = '<li id="navuserlist"><a href="userlist.php">'.$lang_common['User list'].'</a>';
+	$links[] = '<li id="navindex"><a href="' . makeUrlNS('Special', 'Forum/Index') . '">'.$lang_common['Index'].'</a>';
+	$links[] = '<li id="navuserlist"><a href="' . makeUrlNS('Special', 'Forum/Userlist') . '">'.$lang_common['User list'].'</a>';
 
 	if ($pun_config['o_rules'] == '1')
-		$links[] = '<li id="navrules"><a href="misc.php?action=rules">'.$lang_common['Rules'].'</a>';
+		$links[] = '<li id="navrules"><a href="' . makeUrlNS('Special', 'Forum/Misc', 'action=rules', true) . '">'.$lang_common['Rules'].'</a>';
 
 	if ( !$session->user_logged_in )
 	{
 		if ($pun_user['g_search'] == '1')
-			$links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
+			$links[] = '<li id="navsearch"><a href="' . makeUrlNS('Special', 'Forum/Search') . '">'.$lang_common['Search'].'</a>';
 
-		$links[] = '<li id="navregister"><a href="register.php">'.$lang_common['Register'].'</a>';
-		// $links[] = '<li id="navlogin"><a href="login.php">'.$lang_common['Login'].'</a>';
+		$links[] = '<li id="navregister"><a href="' . makeUrlNS('Special', 'Forum/Register') . '">'.$lang_common['Register'].'</a>';
+		// $links[] = '<li id="navlogin"><a href="' . makeUrlNS('Special', 'Forum/login') . '">'.$lang_common['Login'].'</a>';
 
 		$info = $lang_common['Not logged in'];
 	}
@@ -262,16 +262,16 @@
 		if ($pun_user['g_id'] < USER_LEVEL_ADMIN)
 		{
 			if ($pun_user['g_search'] == '1')
-				$links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
+				$links[] = '<li id="navsearch"><a href="' . makeUrlNS('Special', 'Forum/Search') . '">'.$lang_common['Search'].'</a>';
 
-			$links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>';
+			$links[] = '<li id="navprofile"><a href="' . makeUrlNS('Special', 'Forum/Profile', 'id='.$pun_user['id'], true) . '">'.$lang_common['Profile'].'</a>';
 			// $links[] = '<li id="navlogout"><a href="login.php?action=out&amp;id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>';
 		}
 		else
 		{
-			$links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
-			$links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>';
-			$links[] = '<li id="navadmin"><a href="admin_index.php">'.$lang_common['Admin'].'</a>';
+			$links[] = '<li id="navsearch"><a href="' . makeUrlNS('Special', 'Forum/Search') . '">'.$lang_common['Search'].'</a>';
+			$links[] = '<li id="navprofile"><a href="' . makeUrlNS('Special', 'Forum/Profile', 'id='.$pun_user['id'], true) . '">'.$lang_common['Profile'].'</a>';
+			$links[] = '<li id="navadmin"><a href="' . makeUrlNS('Special', 'Forum/Admin_Index') . '">'.$lang_common['Admin'].'</a>';
 			// $links[] = '<li id="navlogout"><a href="login.php?action=out&amp;id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>';
 		}
 	}
@@ -305,13 +305,13 @@
 		<div class="box">
 			<div class="inbox">
 				<ul>
-					<li<?php if ($page == 'essentials') echo ' class="isactive"'; ?>><a href="profile.php?section=essentials&amp;id=<?php echo $id ?>"><?php echo $lang_profile['Section essentials'] ?></a></li>
-					<li<?php if ($page == 'personal') echo ' class="isactive"'; ?>><a href="profile.php?section=personal&amp;id=<?php echo $id ?>"><?php echo $lang_profile['Section personal'] ?></a></li>
-					<li<?php if ($page == 'messaging') echo ' class="isactive"'; ?>><a href="profile.php?section=messaging&amp;id=<?php echo $id ?>"><?php echo $lang_profile['Section messaging'] ?></a></li>
-					<li<?php if ($page == 'personality') echo ' class="isactive"'; ?>><a href="profile.php?section=personality&amp;id=<?php echo $id ?>"><?php echo $lang_profile['Section personality'] ?></a></li>
-					<li<?php if ($page == 'display') echo ' class="isactive"'; ?>><a href="profile.php?section=display&amp;id=<?php echo $id ?>"><?php echo $lang_profile['Section display'] ?></a></li>
-					<li<?php if ($page == 'privacy') echo ' class="isactive"'; ?>><a href="profile.php?section=privacy&amp;id=<?php echo $id ?>"><?php echo $lang_profile['Section privacy'] ?></a></li>
-<?php if ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_ban_users'] == '1')): ?>					<li<?php if ($page == 'admin') echo ' class="isactive"'; ?>><a href="profile.php?section=admin&amp;id=<?php echo $id ?>"><?php echo $lang_profile['Section admin'] ?></a></li>
+					<li<?php if ($page == 'essentials') echo ' class="isactive"'; ?>><a href="<?php echo makeUrlNS('Special', 'Forum/Profile', 'section=essentials&id=' . $id, true); ?>"><?php echo $lang_profile['Section essentials'] ?></a></li>
+					<li<?php if ($page == 'personal') echo ' class="isactive"'; ?>><a href="<?php echo makeUrlNS('Special', 'Forum/Profile', 'section=personal&id=' . $id, true); ?>"><?php echo $lang_profile['Section personal'] ?></a></li>
+					<li<?php if ($page == 'messaging') echo ' class="isactive"'; ?>><a href="<?php echo makeUrlNS('Special', 'Forum/Profile', 'section=messaging&id=' . $id, true); ?>"><?php echo $lang_profile['Section messaging'] ?></a></li>
+					<li<?php if ($page == 'personality') echo ' class="isactive"'; ?>><a href="<?php echo makeUrlNS('Special', 'Forum/Profile', 'section=personality&id=' . $id, true); ?>"><?php echo $lang_profile['Section personality'] ?></a></li>
+					<li<?php if ($page == 'display') echo ' class="isactive"'; ?>><a href="<?php echo makeUrlNS('Special', 'Forum/Profile', 'section=display&id=' . $id, true); ?>"><?php echo $lang_profile['Section display'] ?></a></li>
+					<li<?php if ($page == 'privacy') echo ' class="isactive"'; ?>><a href="<?php echo makeUrlNS('Special', 'Forum/Profile', 'section=privacy&id=' . $id, true); ?>"><?php echo $lang_profile['Section privacy'] ?></a></li>
+<?php if ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_ban_users'] == '1')): ?>					<li<?php if ($page == 'admin') echo ' class="isactive"'; ?>><a href="<?php echo makeUrlNS('Special', 'Forum/Profile', 'section=admin&id=' . $id, true); ?>"><?php echo $lang_profile['Section admin'] ?></a></li>
 <?php endif; ?>				</ul>
 			</div>
 		</div>
@@ -644,6 +644,9 @@
 {
 	global $pun_config, $lang_common;
   
+  // This doesn't seem to work with Enano...
+  return true;
+  
   $script = preg_replace('/\.php$/i', '', $script);
   
   if ( isset($_SERVER['HTTP_REFERER']) )
--- a/punbb/index.php	Thu Jul 12 15:00:35 2007 -0400
+++ b/punbb/index.php	Sun Sep 02 10:56:36 2007 -0400
@@ -97,7 +97,7 @@
 	}
 	else
 	{
-		$forum_field = '<h3><a href="viewforum.php?id='.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
+		$forum_field = '<h3><a href="' . makeUrlNS('Special', 'Forum/ViewForum', 'id='.$cur_forum['fid'], true) . '">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
 		$num_topics = $cur_forum['num_topics'];
 		$num_posts = $cur_forum['num_posts'];
 	}
@@ -108,7 +108,7 @@
 
 	// If there is a last_post/last_poster.
 	if ($cur_forum['last_post'] != '')
-		$last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';
+		$last_post = '<a href="' . makeUrlNS('Special', 'Forum/ViewTopic', 'pid='.$cur_forum['last_post_id'], true) . '#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';
 	else
 		$last_post = '&nbsp;';
 
--- a/punbb/userlist.php	Thu Jul 12 15:00:35 2007 -0400
+++ b/punbb/userlist.php	Sun Sep 02 10:56:36 2007 -0400
@@ -157,7 +157,7 @@
 <?php
 
 // Grab the users
-$result = $pun_db->query('SELECT u.id, eu.username, u.title, u.num_posts, u.registered, g.g_id, g.g_user_title FROM '.$pun_db->prefix.'users AS u LEFT JOIN '.table_prefix.'users AS eu ON eu.user_id=u.id LEFT JOIN '.$pun_db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $pun_db->error());
+$result = $pun_db->query('SELECT u.id, eu.username, u.title, u.num_posts, eu.reg_time AS registered, g.g_id, g.g_user_title FROM '.$pun_db->prefix.'users AS u LEFT JOIN '.table_prefix.'users AS eu ON eu.user_id=u.id LEFT JOIN '.$pun_db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $pun_db->error());
 if ($pun_db->num_rows($result))
 {
 	while ($user_data = $pun_db->fetch_assoc($result))