# HG changeset patch # User Dan # Date 1184216641 14400 # Node ID a8a21e1c7afa71495f9c202365a4568b92794b65 # Parent 8f6143115bf5110aa4b2a1898be3453e0732cfd3 Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go. diff -r 8f6143115bf5 -r a8a21e1c7afa plugins/PunBB.php --- a/plugins/PunBB.php Wed Jul 11 21:28:39 2007 -0400 +++ b/plugins/PunBB.php Thu Jul 12 01:04:01 2007 -0400 @@ -30,9 +30,23 @@ \'namespace\'=>\'Special\', \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', )); + '); +$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" ) + { + require( "punbb/include/common.php" ); + } + '); + define('PUNANO_VERSION', '0.1.12.15'); +define('PUNBB_VERSION', '1.2.15'); +define('PUN_ROOT', ENANO_ROOT . '/punbb/'); +define('PUN', ''); +define('PUN_DISABLE_BUFFERING', ''); function page_Special_Forum() { @@ -63,7 +77,123 @@ $url = makeUrlNS('Special', 'Login/' . $paths->page, 'level=' . USER_LEVEL_ADMIN, true); redirect($url, 'Permission denied', 'You need to have an active high-privilege session to set up Punano.', 4); } + + $template->header(); + // Permissions are good + if ( isset($_POST['do_install']) ) + { + $result = _punano_perform_install(); + if ( $result ) + { + echo '

PunBB installation has succeeded.

'; + echo '

Take me to my forum!

'; + } + } + else + { + $url = makeUrlNS('Special', 'Forum'); + ?> +
+

Before Punano can be used, you need to install the database.

+

This process will create several new tables in your database, and then fill them in with a default configuration for PunBB. + You should only continue if you have CREATE TABLE and CREATE INDEX privileges on your database.

+

+
+ footer(); + +} + +function _punano_perform_install() +{ + global $db, $session, $paths, $template, $plugins; // Common objects + $db_prefix = table_prefix . 'pun_'; + $admin_email = getConfig('contact_email'); + $pun_version = PUNBB_VERSION; + + $schema = file_get_contents( ENANO_ROOT . '/punbb/schema.sql' ); + if ( empty($schema) ) + { + echo 'ERROR: cannot load schema file!'; + return false; + } + + $replace = array( + '{{TABLE_PREFIX}}' => $db_prefix, + '{{ENANO_ADMIN_EMAIL}}' => $admin_email, + '{{PUN_VERSION}}' => $pun_version + ); + + $schema = strtr($schema, $replace); + + // Build an array of queries (from Enano's install.php) + $schema = explode("\n", $schema); + + foreach ( $schema as $i => $sql ) + { + $query =& $schema[$i]; + $t = trim($query); + if ( empty($t) || preg_match('/^(\#|--)/i', $t) ) + { + unset($schema[$i]); + unset($query); + } + } + + $schema = array_values($schema); + $schema = implode("\n", $schema); + $schema = explode(";\n", $schema); + + foreach ( $schema as $i => $sql ) + { + $query =& $schema[$i]; + if ( substr($query, ( strlen($query) - 1 ), 1 ) != ';' ) + { + $query .= ';'; + } + if ( !$db->check_query($query) ) + { + echo 'ERROR: Query safety check failed.
' . $query . '
'; + } + } + + foreach ( $schema as $query ) + { + if ( !$db->sql_query($query) ) + { + echo $db->get_error(); + return false; + } + } + + // Insert users + $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE user_id > 1;'); + if ( !$q ) + { + echo $db->get_error(); + return false; + } + $uid_list = array(); + while ( $row = $db->fetchrow_num() ) + { + $uid_list[] = $row[0]; + } + $query = 'INSERT INTO '.table_prefix.'pun_users(id) VALUES(' . implode('),(', $uid_list) . ');'; + + if ( !$db->sql_query($query) ) + { + echo $db->get_error(); + return false; + } + + setConfig('punbb_installed', 'yes'); + setConfig('punbb_version', PUNANO_VERSION); + + return true; + } function punano_upgrade() @@ -76,6 +206,24 @@ { global $db, $session, $paths, $template, $plugins; // Common objects + // At this point, the PunBB API is already loaded + // So we'll include one of the Pun frontend files + + $valid = array('delete', 'edit', 'extern', 'help', 'index', 'misc', 'moderate', 'post', 'profile', 'search', 'userlist', 'viewforum', 'viewtopic'); + + $file = 'index'; + if ( $x = $paths->getParam(0) ) + { + $x = preg_replace('/\.php$/', '', $x); + if ( in_array(strtolower($x), $valid) ) + { + $file = strtolower($x); + } + } + + // Don't worry. This is sanitized. + require PUN_ROOT . $file . '.php'; + } ?> diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/admin_bans.php --- a/punbb/admin_bans.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/admin_bans.php Thu Jul 12 01:04:01 2007 -0400 @@ -26,12 +26,15 @@ // Tell header.php to use the admin template define('PUN_ADMIN_CONSOLE', 1); -define('PUN_ROOT', './'); -require PUN_ROOT.'include/common.php'; +//define('PUN_ROOT', './'); +//require PUN_ROOT.'include/common.php'; + +global $pun_db, $pun_user, $pun_config, $lang_common; + require PUN_ROOT.'include/common_admin.php'; -if ($pun_user['g_id'] > PUN_MOD || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_ban_users'] == '0')) +if ($pun_user['g_id'] < PUN_MOD || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_ban_users'] == '0')) message($lang_common['No permission']); @@ -49,9 +52,9 @@ $user_id = $add_ban; - $result = $db->query('SELECT group_id, username, email FROM '.$db->prefix.'users WHERE id='.$user_id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); - if ($db->num_rows($result)) - list($group_id, $ban_user, $ban_email) = $db->fetch_row($result); + $result = $pun_db->query('SELECT group_id, username, email FROM '.$pun_db->prefix.'users WHERE id='.$user_id) or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error()); + if ($pun_db->num_rows($result)) + list($group_id, $ban_user, $ban_email) = $pun_db->fetch_row($result); else message('No user by that ID registered.'); } @@ -61,9 +64,9 @@ if ($ban_user != '') { - $result = $db->query('SELECT id, group_id, username, email FROM '.$db->prefix.'users WHERE username=\''.$db->escape($ban_user).'\' AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); - if ($db->num_rows($result)) - list($user_id, $group_id, $ban_user, $ban_email) = $db->fetch_row($result); + $result = $pun_db->query('SELECT id, group_id, username, email FROM '.$pun_db->prefix.'users WHERE username=\''.$pun_db->escape($ban_user).'\' AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error()); + if ($pun_db->num_rows($result)) + list($user_id, $group_id, $ban_user, $ban_email) = $pun_db->fetch_row($result); else message('No user by that username registered. If you want to add a ban not tied to a specific username just leave the username blank.'); } @@ -76,8 +79,8 @@ // If we have a $user_id, we can try to find the last known IP of that user if (isset($user_id)) { - $result = $db->query('SELECT poster_ip FROM '.$db->prefix.'posts WHERE poster_id='.$user_id.' ORDER BY posted DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); - $ban_ip = ($db->num_rows($result)) ? $db->result($result) : ''; + $result = $pun_db->query('SELECT poster_ip FROM '.$pun_db->prefix.'posts WHERE poster_id='.$user_id.' ORDER BY posted DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); + $ban_ip = ($pun_db->num_rows($result)) ? $pun_db->result($result) : ''; } $mode = 'add'; @@ -88,9 +91,9 @@ if ($ban_id < 1) message($lang_common['Bad request']); - $result = $db->query('SELECT username, ip, email, message, expire FROM '.$db->prefix.'bans WHERE id='.$ban_id) or error('Unable to fetch ban info', __FILE__, __LINE__, $db->error()); - if ($db->num_rows($result)) - list($ban_user, $ban_ip, $ban_email, $ban_message, $ban_expire) = $db->fetch_row($result); + $result = $pun_db->query('SELECT username, ip, email, message, expire FROM '.$pun_db->prefix.'bans WHERE id='.$ban_id) or error('Unable to fetch ban info', __FILE__, __LINE__, $pun_db->error()); + if ($pun_db->num_rows($result)) + list($ban_user, $ban_ip, $ban_email, $ban_message, $ban_expire) = $pun_db->fetch_row($result); else message($lang_common['Bad request']); @@ -238,21 +241,21 @@ else $ban_expire = 'NULL'; - $ban_user = ($ban_user != '') ? '\''.$db->escape($ban_user).'\'' : 'NULL'; - $ban_ip = ($ban_ip != '') ? '\''.$db->escape($ban_ip).'\'' : 'NULL'; - $ban_email = ($ban_email != '') ? '\''.$db->escape($ban_email).'\'' : 'NULL'; - $ban_message = ($ban_message != '') ? '\''.$db->escape($ban_message).'\'' : 'NULL'; + $ban_user = ($ban_user != '') ? '\''.$pun_db->escape($ban_user).'\'' : 'NULL'; + $ban_ip = ($ban_ip != '') ? '\''.$pun_db->escape($ban_ip).'\'' : 'NULL'; + $ban_email = ($ban_email != '') ? '\''.$pun_db->escape($ban_email).'\'' : 'NULL'; + $ban_message = ($ban_message != '') ? '\''.$pun_db->escape($ban_message).'\'' : 'NULL'; if ($_POST['mode'] == 'add') - $db->query('INSERT INTO '.$db->prefix.'bans (username, ip, email, message, expire) VALUES('.$ban_user.', '.$ban_ip.', '.$ban_email.', '.$ban_message.', '.$ban_expire.')') or error('Unable to add ban', __FILE__, __LINE__, $db->error()); + $pun_db->query('INSERT INTO '.$pun_db->prefix.'bans (username, ip, email, message, expire) VALUES('.$ban_user.', '.$ban_ip.', '.$ban_email.', '.$ban_message.', '.$ban_expire.')') or error('Unable to add ban', __FILE__, __LINE__, $pun_db->error()); else - $db->query('UPDATE '.$db->prefix.'bans SET username='.$ban_user.', ip='.$ban_ip.', email='.$ban_email.', message='.$ban_message.', expire='.$ban_expire.' WHERE id='.intval($_POST['ban_id'])) or error('Unable to update ban', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'bans SET username='.$ban_user.', ip='.$ban_ip.', email='.$ban_email.', message='.$ban_message.', expire='.$ban_expire.' WHERE id='.intval($_POST['ban_id'])) or error('Unable to update ban', __FILE__, __LINE__, $pun_db->error()); // Regenerate the bans cache require_once PUN_ROOT.'include/cache.php'; generate_bans_cache(); - redirect('admin_bans.php', 'Ban '.(($_POST['mode'] == 'edit') ? 'edited' : 'added').'. Redirecting …'); + pun_redirect('admin_bans.php', 'Ban '.(($_POST['mode'] == 'edit') ? 'edited' : 'added').'. Redirecting …'); } @@ -265,13 +268,13 @@ if ($ban_id < 1) message($lang_common['Bad request']); - $db->query('DELETE FROM '.$db->prefix.'bans WHERE id='.$ban_id) or error('Unable to delete ban', __FILE__, __LINE__, $db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'bans WHERE id='.$ban_id) or error('Unable to delete ban', __FILE__, __LINE__, $pun_db->error()); // Regenerate the bans cache require_once PUN_ROOT.'include/cache.php'; generate_bans_cache(); - redirect('admin_bans.php', 'Ban removed. Redirecting …'); + pun_redirect('admin_bans.php', 'Ban removed. Redirecting …'); } @@ -310,10 +313,10 @@
query('SELECT id, username, ip, email, message, expire FROM '.$db->prefix.'bans ORDER BY id') or error('Unable to fetch ban list', __FILE__, __LINE__, $db->error()); -if ($db->num_rows($result)) +$result = $pun_db->query('SELECT id, username, ip, email, message, expire FROM '.$pun_db->prefix.'bans ORDER BY id') or error('Unable to fetch ban list', __FILE__, __LINE__, $pun_db->error()); +if ($pun_db->num_rows($result)) { - while ($cur_ban = $db->fetch_assoc($result)) + while ($cur_ban = $pun_db->fetch_assoc($result)) { $expire = format_time($cur_ban['expire'], true); diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/admin_categories.php --- a/punbb/admin_categories.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/admin_categories.php Thu Jul 12 01:04:01 2007 -0400 @@ -26,12 +26,15 @@ // Tell header.php to use the admin template define('PUN_ADMIN_CONSOLE', 1); -define('PUN_ROOT', './'); -require PUN_ROOT.'include/common.php'; +//define('PUN_ROOT', './'); +//require PUN_ROOT.'include/common.php'; + +global $pun_db, $pun_user, $pun_config, $lang_common; + require PUN_ROOT.'include/common_admin.php'; -if ($pun_user['g_id'] > PUN_ADMIN) +if ($pun_user['g_id'] < PUN_ADMIN) message($lang_common['No permission']); @@ -44,9 +47,9 @@ if ($new_cat_name == '') message('You must enter a name for the category.'); - $db->query('INSERT INTO '.$db->prefix.'categories (cat_name) VALUES(\''.$db->escape($new_cat_name).'\')') or error('Unable to create category', __FILE__, __LINE__, $db->error()); + $pun_db->query('INSERT INTO '.$pun_db->prefix.'categories (cat_name) VALUES(\''.$pun_db->escape($new_cat_name).'\')') or error('Unable to create category', __FILE__, __LINE__, $pun_db->error()); - redirect('admin_categories.php', 'Category added. Redirecting …'); + pun_redirect('admin_categories.php', 'Category added. Redirecting …'); } @@ -63,45 +66,45 @@ { @set_time_limit(0); - $result = $db->query('SELECT id FROM '.$db->prefix.'forums WHERE cat_id='.$cat_to_delete) or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); - $num_forums = $db->num_rows($result); + $result = $pun_db->query('SELECT id FROM '.$pun_db->prefix.'forums WHERE cat_id='.$cat_to_delete) or error('Unable to fetch forum list', __FILE__, __LINE__, $pun_db->error()); + $num_forums = $pun_db->num_rows($result); for ($i = 0; $i < $num_forums; ++$i) { - $cur_forum = $db->result($result, $i); + $cur_forum = $pun_db->result($result, $i); // Prune all posts and topics prune($cur_forum, 1, -1); // Delete the forum - $db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$cur_forum) or error('Unable to delete forum', __FILE__, __LINE__, $db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'forums WHERE id='.$cur_forum) or error('Unable to delete forum', __FILE__, __LINE__, $pun_db->error()); } // Locate any "orphaned redirect topics" and delete them - $result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error()); - $num_orphans = $db->num_rows($result); + $result = $pun_db->query('SELECT t1.id FROM '.$pun_db->prefix.'topics AS t1 LEFT JOIN '.$pun_db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $pun_db->error()); + $num_orphans = $pun_db->num_rows($result); if ($num_orphans) { for ($i = 0; $i < $num_orphans; ++$i) - $orphans[] = $db->result($result, $i); + $orphans[] = $pun_db->result($result, $i); - $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $pun_db->error()); } // Delete the category - $db->query('DELETE FROM '.$db->prefix.'categories WHERE id='.$cat_to_delete) or error('Unable to delete category', __FILE__, __LINE__, $db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'categories WHERE id='.$cat_to_delete) or error('Unable to delete category', __FILE__, __LINE__, $pun_db->error()); // Regenerate the quickjump cache require_once PUN_ROOT.'include/cache.php'; generate_quickjump_cache(); - redirect('admin_categories.php', 'Category deleted. Redirecting …'); + pun_redirect('admin_categories.php', 'Category deleted. Redirecting …'); } else // If the user hasn't comfirmed the delete { - $result = $db->query('SELECT cat_name FROM '.$db->prefix.'categories WHERE id='.$cat_to_delete) or error('Unable to fetch category info', __FILE__, __LINE__, $db->error()); - $cat_name = $db->result($result); + $result = $pun_db->query('SELECT cat_name FROM '.$pun_db->prefix.'categories WHERE id='.$cat_to_delete) or error('Unable to fetch category info', __FILE__, __LINE__, $pun_db->error()); + $cat_name = $pun_db->result($result); $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Categories'; require PUN_ROOT.'header.php'; @@ -143,8 +146,8 @@ $cat_order = $_POST['cat_order']; $cat_name = $_POST['cat_name']; - $result = $db->query('SELECT id, disp_position FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error()); - $num_cats = $db->num_rows($result); + $result = $pun_db->query('SELECT id, disp_position FROM '.$pun_db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $pun_db->error()); + $num_cats = $pun_db->num_rows($result); for ($i = 0; $i < $num_cats; ++$i) { @@ -154,25 +157,25 @@ if (!@preg_match('#^\d+$#', $cat_order[$i])) message('Position must be an integer value.'); - list($cat_id, $position) = $db->fetch_row($result); + list($cat_id, $position) = $pun_db->fetch_row($result); - $db->query('UPDATE '.$db->prefix.'categories SET cat_name=\''.$db->escape($cat_name[$i]).'\', disp_position='.$cat_order[$i].' WHERE id='.$cat_id) or error('Unable to update category', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'categories SET cat_name=\''.$pun_db->escape($cat_name[$i]).'\', disp_position='.$cat_order[$i].' WHERE id='.$cat_id) or error('Unable to update category', __FILE__, __LINE__, $pun_db->error()); } // Regenerate the quickjump cache require_once PUN_ROOT.'include/cache.php'; generate_quickjump_cache(); - redirect('admin_categories.php', 'Categories updated. Redirecting …'); + pun_redirect('admin_categories.php', 'Categories updated. Redirecting …'); } // Generate an array with all categories -$result = $db->query('SELECT id, cat_name, disp_position FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error()); -$num_cats = $db->num_rows($result); +$result = $pun_db->query('SELECT id, cat_name, disp_position FROM '.$pun_db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $pun_db->error()); +$num_cats = $pun_db->num_rows($result); for ($i = 0; $i < $num_cats; ++$i) - $cat_list[] = $db->fetch_row($result); + $cat_list[] = $pun_db->fetch_row($result); $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Categories'; diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/admin_censoring.php --- a/punbb/admin_censoring.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/admin_censoring.php Thu Jul 12 01:04:01 2007 -0400 @@ -26,12 +26,15 @@ // Tell header.php to use the admin template define('PUN_ADMIN_CONSOLE', 1); -define('PUN_ROOT', './'); -require PUN_ROOT.'include/common.php'; +//define('PUN_ROOT', './'); +//require PUN_ROOT.'include/common.php'; + +global $pun_db, $pun_user, $pun_config, $lang_common; + require PUN_ROOT.'include/common_admin.php'; -if ($pun_user['g_id'] > PUN_MOD) +if ($pun_user['g_id'] < PUN_MOD) message($lang_common['No permission']); @@ -46,9 +49,9 @@ if ($search_for == '' || $replace_with == '') message('You must enter both a word to censor and text to replace it with.'); - $db->query('INSERT INTO '.$db->prefix.'censoring (search_for, replace_with) VALUES (\''.$db->escape($search_for).'\', \''.$db->escape($replace_with).'\')') or error('Unable to add censor word', __FILE__, __LINE__, $db->error()); + $pun_db->query('INSERT INTO '.$pun_db->prefix.'censoring (search_for, replace_with) VALUES (\''.$pun_db->escape($search_for).'\', \''.$pun_db->escape($replace_with).'\')') or error('Unable to add censor word', __FILE__, __LINE__, $pun_db->error()); - redirect('admin_censoring.php', 'Censor word added. Redirecting …'); + pun_redirect('admin_censoring.php', 'Censor word added. Redirecting …'); } @@ -65,9 +68,9 @@ if ($search_for == '' || $replace_with == '') message('You must enter both text to search for and text to replace with.'); - $db->query('UPDATE '.$db->prefix.'censoring SET search_for=\''.$db->escape($search_for).'\', replace_with=\''.$db->escape($replace_with).'\' WHERE id='.$id) or error('Unable to update censor word', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'censoring SET search_for=\''.$pun_db->escape($search_for).'\', replace_with=\''.$pun_db->escape($replace_with).'\' WHERE id='.$id) or error('Unable to update censor word', __FILE__, __LINE__, $pun_db->error()); - redirect('admin_censoring.php', 'Censor word updated. Redirecting …'); + pun_redirect('admin_censoring.php', 'Censor word updated. Redirecting …'); } @@ -78,9 +81,9 @@ $id = intval(key($_POST['remove'])); - $db->query('DELETE FROM '.$db->prefix.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__, __LINE__, $db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__, __LINE__, $pun_db->error()); - redirect('admin_censoring.php', 'Censor word removed. Redirecting …'); + pun_redirect('admin_censoring.php', 'Censor word removed. Redirecting …'); } @@ -125,8 +128,8 @@
query('SELECT id, search_for, replace_with FROM '.$db->prefix.'censoring ORDER BY id') or error('Unable to fetch censor word list', __FILE__, __LINE__, $db->error()); -if ($db->num_rows($result)) +$result = $pun_db->query('SELECT id, search_for, replace_with FROM '.$pun_db->prefix.'censoring ORDER BY id') or error('Unable to fetch censor word list', __FILE__, __LINE__, $pun_db->error()); +if ($pun_db->num_rows($result)) { ?> @@ -141,7 +144,7 @@ fetch_assoc($result)) + while ($cur_word = $pun_db->fetch_assoc($result)) echo "\t\t\t\t\t\t\t\t".' '."\n"; ?> diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/admin_forums.php --- a/punbb/admin_forums.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/admin_forums.php Thu Jul 12 01:04:01 2007 -0400 @@ -26,12 +26,15 @@ // Tell header.php to use the admin template define('PUN_ADMIN_CONSOLE', 1); -define('PUN_ROOT', './'); -require PUN_ROOT.'include/common.php'; +//define('PUN_ROOT', './'); +//require PUN_ROOT.'include/common.php'; + +global $pun_db, $pun_user, $pun_config, $lang_common; + require PUN_ROOT.'include/common_admin.php'; -if ($pun_user['g_id'] > PUN_ADMIN) +if ($pun_user['g_id'] < PUN_ADMIN) message($lang_common['No permission']); @@ -44,13 +47,13 @@ if ($add_to_cat < 1) message($lang_common['Bad request']); - $db->query('INSERT INTO '.$db->prefix.'forums (cat_id) VALUES('.$add_to_cat.')') or error('Unable to create forum', __FILE__, __LINE__, $db->error()); + $pun_db->query('INSERT INTO '.$pun_db->prefix.'forums (cat_id) VALUES('.$add_to_cat.')') or error('Unable to create forum', __FILE__, __LINE__, $pun_db->error()); // Regenerate the quickjump cache require_once PUN_ROOT.'include/cache.php'; generate_quickjump_cache(); - redirect('admin_forums.php', 'Forum added. Redirecting …'); + pun_redirect('admin_forums.php', 'Forum added. Redirecting …'); } @@ -71,31 +74,31 @@ prune($forum_id, 1, -1); // Locate any "orphaned redirect topics" and delete them - $result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error()); - $num_orphans = $db->num_rows($result); + $result = $pun_db->query('SELECT t1.id FROM '.$pun_db->prefix.'topics AS t1 LEFT JOIN '.$pun_db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $pun_db->error()); + $num_orphans = $pun_db->num_rows($result); if ($num_orphans) { for ($i = 0; $i < $num_orphans; ++$i) - $orphans[] = $db->result($result, $i); + $orphans[] = $pun_db->result($result, $i); - $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $pun_db->error()); } // Delete the forum and any forum specific group permissions - $db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to delete forum', __FILE__, __LINE__, $db->error()); - $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'forums WHERE id='.$forum_id) or error('Unable to delete forum', __FILE__, __LINE__, $pun_db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $pun_db->error()); // Regenerate the quickjump cache require_once PUN_ROOT.'include/cache.php'; generate_quickjump_cache(); - redirect('admin_forums.php', 'Forum deleted. Redirecting …'); + pun_redirect('admin_forums.php', 'Forum deleted. Redirecting …'); } else // If the user hasn't confirmed the delete { - $result = $db->query('SELECT forum_name FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error()); - $forum_name = pun_htmlspecialchars($db->result($result)); + $result = $pun_db->query('SELECT forum_name FROM '.$pun_db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $pun_db->error()); + $forum_name = pun_htmlspecialchars($pun_db->result($result)); $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums'; @@ -140,14 +143,14 @@ if (!@preg_match('#^\d+$#', $disp_position)) message('Position must be a positive integer value.'); - $db->query('UPDATE '.$db->prefix.'forums SET disp_position='.$disp_position.' WHERE id='.intval($forum_id)) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'forums SET disp_position='.$disp_position.' WHERE id='.intval($forum_id)) or error('Unable to update forum', __FILE__, __LINE__, $pun_db->error()); } // Regenerate the quickjump cache require_once PUN_ROOT.'include/cache.php'; generate_quickjump_cache(); - redirect('admin_forums.php', 'Forums updated. Redirecting …'); + pun_redirect('admin_forums.php', 'Forums updated. Redirecting …'); } @@ -175,16 +178,16 @@ if ($cat_id < 1) message($lang_common['Bad request']); - $forum_desc = ($forum_desc != '') ? '\''.$db->escape($forum_desc).'\'' : 'NULL'; - $redirect_url = ($redirect_url != '') ? '\''.$db->escape($redirect_url).'\'' : 'NULL'; + $forum_desc = ($forum_desc != '') ? '\''.$pun_db->escape($forum_desc).'\'' : 'NULL'; + $redirect_url = ($redirect_url != '') ? '\''.$pun_db->escape($redirect_url).'\'' : 'NULL'; - $db->query('UPDATE '.$db->prefix.'forums SET forum_name=\''.$db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'forums SET forum_name=\''.$pun_db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $pun_db->error()); // Now let's deal with the permissions if (isset($_POST['read_forum_old'])) { - $result = $db->query('SELECT g_id, g_read_board, g_post_replies, g_post_topics FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); - while ($cur_group = $db->fetch_assoc($result)) + $result = $pun_db->query('SELECT g_id, g_read_board, g_post_replies, g_post_topics FROM '.$pun_db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $pun_db->error()); + while ($cur_group = $pun_db->fetch_assoc($result)) { $read_forum_new = ($cur_group['g_read_board'] == '1') ? isset($_POST['read_forum_new'][$cur_group['g_id']]) ? '1' : '0' : intval($_POST['read_forum_old'][$cur_group['g_id']]); $post_replies_new = isset($_POST['post_replies_new'][$cur_group['g_id']]) ? '1' : '0'; @@ -195,13 +198,13 @@ { // If the new settings are identical to the default settings for this group, delete it's row in forum_perms if ($read_forum_new == '1' && $post_replies_new == $cur_group['g_post_replies'] && $post_topics_new == $cur_group['g_post_topics']) - $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'forum_perms WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $pun_db->error()); else { // Run an UPDATE and see if it affected a row, if not, INSERT - $db->query('UPDATE '.$db->prefix.'forum_perms SET read_forum='.$read_forum_new.', post_replies='.$post_replies_new.', post_topics='.$post_topics_new.' WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error()); - if (!$db->affected_rows()) - $db->query('INSERT INTO '.$db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$cur_group['g_id'].', '.$forum_id.', '.$read_forum_new.', '.$post_replies_new.', '.$post_topics_new.')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'forum_perms SET read_forum='.$read_forum_new.', post_replies='.$post_replies_new.', post_topics='.$post_topics_new.' WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to insert group forum permissions', __FILE__, __LINE__, $pun_db->error()); + if (!$pun_db->affected_rows()) + $pun_db->query('INSERT INTO '.$pun_db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$cur_group['g_id'].', '.$forum_id.', '.$read_forum_new.', '.$post_replies_new.', '.$post_topics_new.')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $pun_db->error()); } } } @@ -211,28 +214,28 @@ require_once PUN_ROOT.'include/cache.php'; generate_quickjump_cache(); - redirect('admin_forums.php', 'Forum updated. Redirecting …'); + pun_redirect('admin_forums.php', 'Forum updated. Redirecting …'); } else if (isset($_POST['revert_perms'])) { confirm_referrer('admin_forums.php'); - $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $pun_db->error()); // Regenerate the quickjump cache require_once PUN_ROOT.'include/cache.php'; generate_quickjump_cache(); - redirect('admin_forums.php?edit_forum='.$forum_id, 'Permissions reverted to defaults. Redirecting …'); + pun_redirect('admin_forums.php?edit_forum='.$forum_id, 'Permissions reverted to defaults. Redirecting …'); } // Fetch forum info - $result = $db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error()); - if (!$db->num_rows($result)) + $result = $pun_db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id FROM '.$pun_db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $pun_db->error()); + if (!$pun_db->num_rows($result)) message($lang_common['Bad request']); - $cur_forum = $db->fetch_assoc($result); + $cur_forum = $pun_db->fetch_assoc($result); $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums'; @@ -265,8 +268,8 @@ query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error()); - while ($cur_cat = $db->fetch_assoc($result)) + $result = $pun_db->query('SELECT id, cat_name FROM '.$pun_db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $pun_db->error()); + while ($cur_cat = $pun_db->fetch_assoc($result)) echo "\t\t\t\t\t\t\t\t\t".''."\n"; ?> @@ -409,10 +412,10 @@ $tabindex_count = 4; // Display all the categories and forums -$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.disp_position FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); +$result = $pun_db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.disp_position FROM '.$pun_db->prefix.'categories AS c INNER JOIN '.$pun_db->prefix.'forums AS f ON c.id=f.cat_id ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $pun_db->error()); $cur_category = 0; -while ($cur_forum = $db->fetch_assoc($result)) +while ($cur_forum = $pun_db->fetch_assoc($result)) { if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? { diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/admin_groups.php --- a/punbb/admin_groups.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/admin_groups.php Thu Jul 12 01:04:01 2007 -0400 @@ -26,12 +26,15 @@ // Tell header.php to use the admin template define('PUN_ADMIN_CONSOLE', 1); -define('PUN_ROOT', './'); -require PUN_ROOT.'include/common.php'; +//define('PUN_ROOT', './'); +//require PUN_ROOT.'include/common.php'; + +global $pun_db, $pun_user, $pun_config, $lang_common; + require PUN_ROOT.'include/common_admin.php'; -if ($pun_user['g_id'] > PUN_ADMIN) +if ($pun_user['g_id'] < PUN_ADMIN) message($lang_common['No permission']); @@ -42,8 +45,8 @@ { $base_group = intval($_POST['base_group']); - $result = $db->query('SELECT * FROM '.$db->prefix.'groups WHERE g_id='.$base_group) or error('Unable to fetch user group info', __FILE__, __LINE__, $db->error()); - $group = $db->fetch_assoc($result); + $result = $pun_db->query('SELECT * FROM '.$pun_db->prefix.'groups WHERE g_id='.$base_group) or error('Unable to fetch user group info', __FILE__, __LINE__, $pun_db->error()); + $group = $pun_db->fetch_assoc($result); $mode = 'add'; } @@ -53,11 +56,11 @@ if ($group_id < 1) message($lang_common['Bad request']); - $result = $db->query('SELECT * FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch user group info', __FILE__, __LINE__, $db->error()); - if (!$db->num_rows($result)) + $result = $pun_db->query('SELECT * FROM '.$pun_db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch user group info', __FILE__, __LINE__, $pun_db->error()); + if (!$pun_db->num_rows($result)) message($lang_common['Bad request']); - $group = $db->fetch_assoc($result); + $group = $pun_db->fetch_assoc($result); $mode = 'edit'; } @@ -225,36 +228,36 @@ if ($title == '') message('You must enter a group title.'); - $user_title = ($user_title != '') ? '\''.$db->escape($user_title).'\'' : 'NULL'; + $user_title = ($user_title != '') ? '\''.$pun_db->escape($user_title).'\'' : 'NULL'; if ($_POST['mode'] == 'add') { - $result = $db->query('SELECT 1 FROM '.$db->prefix.'groups WHERE g_title=\''.$db->escape($title).'\'') or error('Unable to check group title collision', __FILE__, __LINE__, $db->error()); - if ($db->num_rows($result)) + $result = $pun_db->query('SELECT 1 FROM '.$pun_db->prefix.'groups WHERE g_title=\''.$pun_db->escape($title).'\'') or error('Unable to check group title collision', __FILE__, __LINE__, $pun_db->error()); + if ($pun_db->num_rows($result)) message('There is already a group with the title \''.pun_htmlspecialchars($title).'\'.'); - $db->query('INSERT INTO '.$db->prefix.'groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES(\''.$db->escape($title).'\', '.$user_title.', '.$read_board.', '.$post_replies.', '.$post_topics.', '.$edit_posts.', '.$delete_posts.', '.$delete_topics.', '.$set_title.', '.$search.', '.$search_users.', '.$edit_subjects_interval.', '.$post_flood.', '.$search_flood.')') or error('Unable to add group', __FILE__, __LINE__, $db->error()); - $new_group_id = $db->insert_id(); + $pun_db->query('INSERT INTO '.$pun_db->prefix.'groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES(\''.$pun_db->escape($title).'\', '.$user_title.', '.$read_board.', '.$post_replies.', '.$post_topics.', '.$edit_posts.', '.$delete_posts.', '.$delete_topics.', '.$set_title.', '.$search.', '.$search_users.', '.$edit_subjects_interval.', '.$post_flood.', '.$search_flood.')') or error('Unable to add group', __FILE__, __LINE__, $pun_db->error()); + $new_group_id = $pun_db->insert_id(); // Now lets copy the forum specific permissions from the group which this group is based on - $result = $db->query('SELECT forum_id, read_forum, post_replies, post_topics FROM '.$db->prefix.'forum_perms WHERE group_id='.intval($_POST['base_group'])) or error('Unable to fetch group forum permission list', __FILE__, __LINE__, $db->error()); - while ($cur_forum_perm = $db->fetch_assoc($result)) - $db->query('INSERT INTO '.$db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$new_group_id.', '.$cur_forum_perm['forum_id'].', '.$cur_forum_perm['read_forum'].', '.$cur_forum_perm['post_replies'].', '.$cur_forum_perm['post_topics'].')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error()); + $result = $pun_db->query('SELECT forum_id, read_forum, post_replies, post_topics FROM '.$pun_db->prefix.'forum_perms WHERE group_id='.intval($_POST['base_group'])) or error('Unable to fetch group forum permission list', __FILE__, __LINE__, $pun_db->error()); + while ($cur_forum_perm = $pun_db->fetch_assoc($result)) + $pun_db->query('INSERT INTO '.$pun_db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$new_group_id.', '.$cur_forum_perm['forum_id'].', '.$cur_forum_perm['read_forum'].', '.$cur_forum_perm['post_replies'].', '.$cur_forum_perm['post_topics'].')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $pun_db->error()); } else { - $result = $db->query('SELECT 1 FROM '.$db->prefix.'groups WHERE g_title=\''.$db->escape($title).'\' AND g_id!='.intval($_POST['group_id'])) or error('Unable to check group title collision', __FILE__, __LINE__, $db->error()); - if ($db->num_rows($result)) + $result = $pun_db->query('SELECT 1 FROM '.$pun_db->prefix.'groups WHERE g_title=\''.$pun_db->escape($title).'\' AND g_id!='.intval($_POST['group_id'])) or error('Unable to check group title collision', __FILE__, __LINE__, $pun_db->error()); + if ($pun_db->num_rows($result)) message('There is already a group with the title \''.pun_htmlspecialchars($title).'\'.'); - $db->query('UPDATE '.$db->prefix.'groups SET g_title=\''.$db->escape($title).'\', g_user_title='.$user_title.', g_read_board='.$read_board.', g_post_replies='.$post_replies.', g_post_topics='.$post_topics.', g_edit_posts='.$edit_posts.', g_delete_posts='.$delete_posts.', g_delete_topics='.$delete_topics.', g_set_title='.$set_title.', g_search='.$search.', g_search_users='.$search_users.', g_edit_subjects_interval='.$edit_subjects_interval.', g_post_flood='.$post_flood.', g_search_flood='.$search_flood.' WHERE g_id='.intval($_POST['group_id'])) or error('Unable to update group', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'groups SET g_title=\''.$pun_db->escape($title).'\', g_user_title='.$user_title.', g_read_board='.$read_board.', g_post_replies='.$post_replies.', g_post_topics='.$post_topics.', g_edit_posts='.$edit_posts.', g_delete_posts='.$delete_posts.', g_delete_topics='.$delete_topics.', g_set_title='.$set_title.', g_search='.$search.', g_search_users='.$search_users.', g_edit_subjects_interval='.$edit_subjects_interval.', g_post_flood='.$post_flood.', g_search_flood='.$search_flood.' WHERE g_id='.intval($_POST['group_id'])) or error('Unable to update group', __FILE__, __LINE__, $pun_db->error()); } // Regenerate the quickjump cache require_once PUN_ROOT.'include/cache.php'; generate_quickjump_cache(); - redirect('admin_groups.php', 'Group '.(($_POST['mode'] == 'edit') ? 'edited' : 'added').'. Redirecting …'); + pun_redirect('admin_groups.php', 'Group '.(($_POST['mode'] == 'edit') ? 'edited' : 'added').'. Redirecting …'); } @@ -267,13 +270,13 @@ if ($group_id < 4) message($lang_common['Bad request']); - $db->query('UPDATE '.$db->prefix.'config SET conf_value='.$group_id.' WHERE conf_name=\'o_default_user_group\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'config SET conf_value='.$group_id.' WHERE conf_name=\'o_default_user_group\'') or error('Unable to update board config', __FILE__, __LINE__, $pun_db->error()); // Regenerate the config cache require_once PUN_ROOT.'include/cache.php'; generate_config_cache(); - redirect('admin_groups.php', 'Default group set. Redirecting …'); + pun_redirect('admin_groups.php', 'Default group set. Redirecting …'); } @@ -292,30 +295,30 @@ // Check if this group has any members - $result = $db->query('SELECT g.g_title, COUNT(u.id) FROM '.$db->prefix.'groups AS g INNER JOIN '.$db->prefix.'users AS u ON g.g_id=u.group_id WHERE g.g_id='.$group_id.' GROUP BY g.g_id, g_title') or error('Unable to fetch group info', __FILE__, __LINE__, $db->error()); + $result = $pun_db->query('SELECT g.g_title, COUNT(u.id) FROM '.$pun_db->prefix.'groups AS g INNER JOIN '.$pun_db->prefix.'users AS u ON g.g_id=u.group_id WHERE g.g_id='.$group_id.' GROUP BY g.g_id, g_title') or error('Unable to fetch group info', __FILE__, __LINE__, $pun_db->error()); // If the group doesn't have any members or if we've already selected a group to move the members to - if (!$db->num_rows($result) || isset($_POST['del_group'])) + if (!$pun_db->num_rows($result) || isset($_POST['del_group'])) { if (isset($_POST['del_group'])) { $move_to_group = intval($_POST['move_to_group']); - $db->query('UPDATE '.$db->prefix.'users SET group_id='.$move_to_group.' WHERE group_id='.$group_id) or error('Unable to move users into group', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'users SET group_id='.$move_to_group.' WHERE group_id='.$group_id) or error('Unable to move users into group', __FILE__, __LINE__, $pun_db->error()); } // Delete the group and any forum specific permissions - $db->query('DELETE FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to delete group', __FILE__, __LINE__, $db->error()); - $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$group_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to delete group', __FILE__, __LINE__, $pun_db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'forum_perms WHERE group_id='.$group_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $pun_db->error()); // Regenerate the quickjump cache require_once PUN_ROOT.'include/cache.php'; generate_quickjump_cache(); - redirect('admin_groups.php', 'Group removed. Redirecting …'); + pun_redirect('admin_groups.php', 'Group removed. Redirecting …'); } - list($group_title, $group_members) = $db->fetch_row($result); + list($group_title, $group_members) = $pun_db->fetch_row($result); $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / User groups'; require PUN_ROOT.'header.php'; @@ -336,9 +339,9 @@ query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id>'.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); +$result = $pun_db->query('SELECT g_id, g_title FROM '.$pun_db->prefix.'groups WHERE g_id>'.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $pun_db->error()); -while ($cur_group = $db->fetch_assoc($result)) +while ($cur_group = $pun_db->fetch_assoc($result)) { if ($cur_group['g_id'] == $pun_config['o_default_user_group']) echo "\t\t\t\t\t\t\t\t\t\t\t".''."\n"; @@ -415,9 +418,9 @@  '."\n"; ?> diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/admin_reports.php --- a/punbb/admin_reports.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/admin_reports.php Thu Jul 12 01:04:01 2007 -0400 @@ -26,12 +26,15 @@ // Tell header.php to use the admin template define('PUN_ADMIN_CONSOLE', 1); -define('PUN_ROOT', './'); -require PUN_ROOT.'include/common.php'; +//define('PUN_ROOT', './'); +//require PUN_ROOT.'include/common.php'; + +global $pun_db, $pun_user, $pun_config, $lang_common; + require PUN_ROOT.'include/common_admin.php'; -if ($pun_user['g_id'] > PUN_MOD) +if ($pun_user['g_id'] < PUN_MOD) message($lang_common['No permission']); @@ -42,13 +45,13 @@ $zap_id = intval(key($_POST['zap_id'])); - $result = $db->query('SELECT zapped FROM '.$db->prefix.'reports WHERE id='.$zap_id) or error('Unable to fetch report info', __FILE__, __LINE__, $db->error()); - $zapped = $db->result($result); + $result = $pun_db->query('SELECT zapped FROM '.$pun_db->prefix.'reports WHERE id='.$zap_id) or error('Unable to fetch report info', __FILE__, __LINE__, $pun_db->error()); + $zapped = $pun_db->result($result); if ($zapped == '') - $db->query('UPDATE '.$db->prefix.'reports SET zapped='.time().', zapped_by='.$pun_user['id'].' WHERE id='.$zap_id) or error('Unable to zap report', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'reports SET zapped='.time().', zapped_by='.$pun_user['id'].' WHERE id='.$zap_id) or error('Unable to zap report', __FILE__, __LINE__, $pun_db->error()); - redirect('admin_reports.php', 'Report zapped. Redirecting …'); + pun_redirect('admin_reports.php', 'Report zapped. Redirecting …'); } @@ -64,11 +67,11 @@
query('SELECT r.id, r.post_id, r.topic_id, r.forum_id, r.reported_by, r.created, r.message, t.subject, f.forum_name, u.username AS reporter FROM '.$db->prefix.'reports AS r LEFT JOIN '.$db->prefix.'topics AS t ON r.topic_id=t.id LEFT JOIN '.$db->prefix.'forums AS f ON r.forum_id=f.id LEFT JOIN '.$db->prefix.'users AS u ON r.reported_by=u.id WHERE r.zapped IS NULL ORDER BY created DESC') or error('Unable to fetch report list', __FILE__, __LINE__, $db->error()); +$result = $pun_db->query('SELECT r.id, r.post_id, r.topic_id, r.forum_id, r.reported_by, r.created, r.message, t.subject, f.forum_name, u.username AS reporter FROM '.$pun_db->prefix.'reports AS r LEFT JOIN '.$pun_db->prefix.'topics AS t ON r.topic_id=t.id LEFT JOIN '.$pun_db->prefix.'forums AS f ON r.forum_id=f.id LEFT JOIN '.$pun_db->prefix.'users AS u ON r.reported_by=u.id WHERE r.zapped IS NULL ORDER BY created DESC') or error('Unable to fetch report list', __FILE__, __LINE__, $pun_db->error()); -if ($db->num_rows($result)) +if ($pun_db->num_rows($result)) { - while ($cur_report = $db->fetch_assoc($result)) + while ($cur_report = $pun_db->fetch_assoc($result)) { $reporter = ($cur_report['reporter'] != '') ? ''.pun_htmlspecialchars($cur_report['reporter']).'' : 'Deleted user'; $forum = ($cur_report['forum_name'] != '') ? ''.pun_htmlspecialchars($cur_report['forum_name']).'' : 'Deleted'; @@ -112,11 +115,11 @@
query('SELECT r.id, r.post_id, r.topic_id, r.forum_id, r.reported_by, r.message, r.zapped, r.zapped_by AS zapped_by_id, t.subject, f.forum_name, u.username AS reporter, u2.username AS zapped_by FROM '.$db->prefix.'reports AS r LEFT JOIN '.$db->prefix.'topics AS t ON r.topic_id=t.id LEFT JOIN '.$db->prefix.'forums AS f ON r.forum_id=f.id LEFT JOIN '.$db->prefix.'users AS u ON r.reported_by=u.id LEFT JOIN '.$db->prefix.'users AS u2 ON r.zapped_by=u2.id WHERE r.zapped IS NOT NULL ORDER BY zapped DESC LIMIT 10') or error('Unable to fetch report list', __FILE__, __LINE__, $db->error()); +$result = $pun_db->query('SELECT r.id, r.post_id, r.topic_id, r.forum_id, r.reported_by, r.message, r.zapped, r.zapped_by AS zapped_by_id, t.subject, f.forum_name, u.username AS reporter, u2.username AS zapped_by FROM '.$pun_db->prefix.'reports AS r LEFT JOIN '.$pun_db->prefix.'topics AS t ON r.topic_id=t.id LEFT JOIN '.$pun_db->prefix.'forums AS f ON r.forum_id=f.id LEFT JOIN '.$pun_db->prefix.'users AS u ON r.reported_by=u.id LEFT JOIN '.$pun_db->prefix.'users AS u2 ON r.zapped_by=u2.id WHERE r.zapped IS NOT NULL ORDER BY zapped DESC LIMIT 10') or error('Unable to fetch report list', __FILE__, __LINE__, $pun_db->error()); -if ($db->num_rows($result)) +if ($pun_db->num_rows($result)) { - while ($cur_report = $db->fetch_assoc($result)) + while ($cur_report = $pun_db->fetch_assoc($result)) { $reporter = ($cur_report['reporter'] != '') ? ''.pun_htmlspecialchars($cur_report['reporter']).'' : 'Deleted user'; $forum = ($cur_report['forum_name'] != '') ? ''.pun_htmlspecialchars($cur_report['forum_name']).'' : 'Deleted'; diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/admin_users.php --- a/punbb/admin_users.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/admin_users.php Thu Jul 12 01:04:01 2007 -0400 @@ -26,12 +26,15 @@ // Tell header.php to use the admin template define('PUN_ADMIN_CONSOLE', 1); -define('PUN_ROOT', './'); -require PUN_ROOT.'include/common.php'; +//define('PUN_ROOT', './'); +//require PUN_ROOT.'include/common.php'; + +global $pun_db, $pun_user, $pun_config, $lang_common; + require PUN_ROOT.'include/common_admin.php'; -if ($pun_user['g_id'] > PUN_MOD) +if ($pun_user['g_id'] < PUN_MOD) message($lang_common['No permission']); @@ -69,10 +72,10 @@ query('SELECT poster_ip, MAX(posted) AS last_used, COUNT(id) AS used_times FROM '.$db->prefix.'posts WHERE poster_id='.$ip_stats.' GROUP BY poster_ip ORDER BY last_used DESC') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); - if ($db->num_rows($result)) + $result = $pun_db->query('SELECT poster_ip, MAX(posted) AS last_used, COUNT(id) AS used_times FROM '.$pun_db->prefix.'posts WHERE poster_id='.$ip_stats.' GROUP BY poster_ip ORDER BY last_used DESC') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); + if ($pun_db->num_rows($result)) { - while ($cur_ip = $db->fetch_assoc($result)) + while ($cur_ip = $pun_db->fetch_assoc($result)) { ?> @@ -143,19 +146,19 @@ query('SELECT DISTINCT poster_id, poster FROM '.$db->prefix.'posts WHERE poster_ip=\''.$db->escape($ip).'\' ORDER BY poster DESC') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); - $num_posts = $db->num_rows($result); + $result = $pun_db->query('SELECT DISTINCT poster_id, poster FROM '.$pun_db->prefix.'posts WHERE poster_ip=\''.$pun_db->escape($ip).'\' ORDER BY poster DESC') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); + $num_posts = $pun_db->num_rows($result); if ($num_posts) { // Loop through users and print out some info for ($i = 0; $i < $num_posts; ++$i) { - list($poster_id, $poster) = $db->fetch_row($result); + list($poster_id, $poster) = $pun_db->fetch_row($result); - $result2 = $db->query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1 AND u.id='.$poster_id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); + $result2 = $pun_db->query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$pun_db->prefix.'users AS u INNER JOIN '.$pun_db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1 AND u.id='.$poster_id) or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error()); - if (($user_data = $db->fetch_assoc($result2))) + if (($user_data = $pun_db->fetch_assoc($result2))) { $user_title = get_title($user_data); @@ -258,7 +261,7 @@ while (list($key, $input) = @each($form)) { if ($input != '' && in_array($key, array('username', 'email', 'title', 'realname', 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location', 'signature', 'admin_note'))) - $conditions[] = 'u.'.$db->escape($key).' '.$like_command.' \''.$db->escape(str_replace('*', '%', $input)).'\''; + $conditions[] = 'u.'.$pun_db->escape($key).' '.$like_command.' \''.$pun_db->escape(str_replace('*', '%', $input)).'\''; } if ($posts_greater != '') @@ -301,10 +304,10 @@ query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1 AND '.implode(' AND ', $conditions).' ORDER BY '.$db->escape($order_by).' '.$db->escape($direction)) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); - if ($db->num_rows($result)) + $result = $pun_db->query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$pun_db->prefix.'users AS u LEFT JOIN '.$pun_db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1 AND '.implode(' AND ', $conditions).' ORDER BY '.$pun_db->escape($order_by).' '.$pun_db->escape($direction)) or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error()); + if ($pun_db->num_rows($result)) { - while ($user_data = $db->fetch_assoc($result)) + while ($user_data = $pun_db->fetch_assoc($result)) { $user_title = get_title($user_data); @@ -466,9 +469,9 @@ query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); + $result = $pun_db->query('SELECT g_id, g_title FROM '.$pun_db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $pun_db->error()); - while ($cur_group = $db->fetch_assoc($result)) + while ($cur_group = $pun_db->fetch_assoc($result)) echo "\t\t\t\t\t\t\t\t\t\t\t".''."\n"; ?> diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/delete.php --- a/punbb/delete.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/delete.php Thu Jul 12 01:04:01 2007 -0400 @@ -23,8 +23,11 @@ ************************************************************************/ -define('PUN_ROOT', './'); -require PUN_ROOT.'include/common.php'; +//define('PUN_ROOT', './'); +//require PUN_ROOT.'include/common.php'; + +global $pun_db, $pun_user, $pun_config, $lang_common; + if ($pun_user['g_read_board'] == '0') @@ -36,19 +39,19 @@ message($lang_common['Bad request']); // Fetch some info about the post, the topic and the forum -$result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); -if (!$db->num_rows($result)) +$result = $pun_db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); +if (!$pun_db->num_rows($result)) message($lang_common['Bad request']); -$cur_post = $db->fetch_assoc($result); +$cur_post = $pun_db->fetch_assoc($result); // Sort out who the moderators are and if we are currently a moderator (or an admin) $mods_array = ($cur_post['moderators'] != '') ? unserialize($cur_post['moderators']) : array(); $is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array))) ? true : false; // Determine whether this post is the "topic post" or not -$result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$cur_post['tid'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); -$topic_post_id = $db->result($result); +$result = $pun_db->query('SELECT id FROM '.$pun_db->prefix.'posts WHERE topic_id='.$cur_post['tid'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); +$topic_post_id = $pun_db->result($result); $is_topic_post = ($id == $topic_post_id) ? true : false; @@ -77,7 +80,7 @@ delete_topic($cur_post['tid']); update_forum($cur_post['fid']); - redirect('viewforum.php?id='.$cur_post['fid'], $lang_delete['Topic del redirect']); + pun_redirect('viewforum.php?id='.$cur_post['fid'], $lang_delete['Topic del redirect']); } else { @@ -85,7 +88,7 @@ delete_post($id, $cur_post['tid']); update_forum($cur_post['fid']); - redirect('viewtopic.php?id='.$cur_post['tid'], $lang_delete['Post del redirect']); + pun_redirect('viewtopic.php?id='.$cur_post['tid'], $lang_delete['Post del redirect']); } } diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/edit.php --- a/punbb/edit.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/edit.php Thu Jul 12 01:04:01 2007 -0400 @@ -23,8 +23,11 @@ ************************************************************************/ -define('PUN_ROOT', './'); -require PUN_ROOT.'include/common.php'; +//define('PUN_ROOT', './'); +//require PUN_ROOT.'include/common.php'; + +global $pun_db, $pun_user, $pun_config, $lang_common; + if ($pun_user['g_read_board'] == '0') @@ -36,19 +39,19 @@ message($lang_common['Bad request']); // Fetch some info about the post, the topic and the forum -$result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); -if (!$db->num_rows($result)) +$result = $pun_db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); +if (!$pun_db->num_rows($result)) message($lang_common['Bad request']); -$cur_post = $db->fetch_assoc($result); +$cur_post = $pun_db->fetch_assoc($result); // Sort out who the moderators are and if we are currently a moderator (or an admin) $mods_array = ($cur_post['moderators'] != '') ? unserialize($cur_post['moderators']) : array(); $is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array))) ? true : false; // Determine whether this post is the "topic post" or not -$result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$cur_post['tid'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); -$topic_post_id = $db->result($result); +$result = $pun_db->query('SELECT id FROM '.$pun_db->prefix.'posts WHERE topic_id='.$cur_post['tid'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); +$topic_post_id = $pun_db->result($result); $can_edit_subject = ($id == $topic_post_id && (($pun_user['g_edit_subjects_interval'] == '0' || (time() - $cur_post['posted']) < $pun_user['g_edit_subjects_interval']) || $is_admmod)) ? true : false; @@ -80,7 +83,7 @@ $errors[] = $lang_post['No subject']; else if (pun_strlen($subject) > 70) $errors[] = $lang_post['Too long subject']; - else if ($pun_config['p_subject_all_caps'] == '0' && strtoupper($subject) == $subject && $pun_user['g_id'] > PUN_MOD) + else if ($pun_config['p_subject_all_caps'] == '0' && strtoupper($subject) == $subject && $pun_user['g_id'] < PUN_MOD) $subject = ucwords(strtolower($subject)); } @@ -91,7 +94,7 @@ $errors[] = $lang_post['No message']; else if (strlen($message) > 65535) $errors[] = $lang_post['Too long message']; - else if ($pun_config['p_message_all_caps'] == '0' && strtoupper($message) == $message && $pun_user['g_id'] > PUN_MOD) + else if ($pun_config['p_message_all_caps'] == '0' && strtoupper($message) == $message && $pun_user['g_id'] < PUN_MOD) $message = ucwords(strtolower($message)); // Validate BBCode syntax @@ -108,14 +111,14 @@ // Did everything go according to plan? if (empty($errors) && !isset($_POST['preview'])) { - $edited_sql = (!isset($_POST['silent']) || !$is_admmod) ? $edited_sql = ', edited='.time().', edited_by=\''.$db->escape($pun_user['username']).'\'' : ''; + $edited_sql = (!isset($_POST['silent']) || !$is_admmod) ? $edited_sql = ', edited='.time().', edited_by=\''.$pun_db->escape($pun_user['username']).'\'' : ''; require PUN_ROOT.'include/search_idx.php'; if ($can_edit_subject) { // Update the topic and any redirect topics - $db->query('UPDATE '.$db->prefix.'topics SET subject=\''.$db->escape($subject).'\' WHERE id='.$cur_post['tid'].' OR moved_to='.$cur_post['tid']) or error('Unable to update topic', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'topics SET subject=\''.$pun_db->escape($subject).'\' WHERE id='.$cur_post['tid'].' OR moved_to='.$cur_post['tid']) or error('Unable to update topic', __FILE__, __LINE__, $pun_db->error()); // We changed the subject, so we need to take that into account when we update the search words update_search_index('edit', $id, $message, $subject); @@ -124,9 +127,9 @@ update_search_index('edit', $id, $message); // Update the post - $db->query('UPDATE '.$db->prefix.'posts SET message=\''.$db->escape($message).'\', hide_smilies=\''.$hide_smilies.'\''.$edited_sql.' WHERE id='.$id) or error('Unable to update post', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'posts SET message=\''.$pun_db->escape($message).'\', hide_smilies=\''.$hide_smilies.'\''.$edited_sql.' WHERE id='.$id) or error('Unable to update post', __FILE__, __LINE__, $pun_db->error()); - redirect('viewtopic.php?pid='.$id.'#p'.$id, $lang_post['Edit redirect']); + pun_redirect('viewtopic.php?pid='.$id.'#p'.$id, $lang_post['Edit redirect']); } } diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/extern.php --- a/punbb/extern.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/extern.php Thu Jul 12 01:04:01 2007 -0400 @@ -129,18 +129,18 @@ // Load DB abstraction layer and try to connect require PUN_ROOT.'include/dblayer/common_db.php'; -// Load cached config -@include PUN_ROOT.'cache/cache_config.php'; -if (!defined('PUN_CONFIG_LOADED')) -{ - require PUN_ROOT.'include/cache.php'; - generate_config_cache(); - require PUN_ROOT.'cache/cache_config.php'; +// Load cached config +@include PUN_ROOT.'cache/cache_config.php'; +if (!defined('PUN_CONFIG_LOADED')) +{ + require PUN_ROOT.'include/cache.php'; + generate_config_cache(); + require PUN_ROOT.'cache/cache_config.php'; } // Make sure we (guests) have permission to read the forums -$result = $db->query('SELECT g_read_board FROM '.$db->prefix.'groups WHERE g_id=3') or error('Unable to fetch group info', __FILE__, __LINE__, $db->error()); -if ($db->result($result) == '0') +$result = $pun_db->query('SELECT g_read_board FROM '.$pun_db->prefix.'groups WHERE g_id=3') or error('Unable to fetch group info', __FILE__, __LINE__, $pun_db->error()); +if ($pun_db->result($result) == '0') exit('No permission'); @@ -217,9 +217,9 @@ echo "\t".'en-us'."\r\n"; // Fetch 15 topics - $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, f.id AS fid, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT 15') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error()); + $result = $pun_db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, f.id AS fid, f.forum_name FROM '.$pun_db->prefix.'topics AS t INNER JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT 15') or error('Unable to fetch topic list', __FILE__, __LINE__, $pun_db->error()); - while ($cur_topic = $db->fetch_assoc($result)) + while ($cur_topic = $pun_db->fetch_assoc($result)) { if ($pun_config['o_censoring'] == '1') $cur_topic['subject'] = censor_words($cur_topic['subject']); @@ -244,9 +244,9 @@ $show = 15; // Fetch $show topics - $result = $db->query('SELECT t.id, t.subject FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error()); + $result = $pun_db->query('SELECT t.id, t.subject FROM '.$pun_db->prefix.'topics AS t INNER JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $pun_db->error()); - while ($cur_topic = $db->fetch_assoc($result)) + while ($cur_topic = $pun_db->fetch_assoc($result)) { if ($pun_config['o_censoring'] == '1') $cur_topic['subject'] = censor_words($cur_topic['subject']); @@ -275,9 +275,9 @@ // Fetch users online info and generate strings for output $num_guests = $num_users = 0; $users = array(); - $result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error()); + $result = $pun_db->query('SELECT user_id, ident FROM '.$pun_db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $pun_db->error()); - while ($pun_user_online = $db->fetch_assoc($result)) + while ($pun_user_online = $pun_db->fetch_assoc($result)) { if ($pun_user_online['user_id'] > 1) { @@ -308,14 +308,14 @@ require PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/index.php'; // Collect some statistics from the database - $result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error()); - $stats['total_users'] = $db->result($result); + $result = $pun_db->query('SELECT COUNT(id)-1 FROM '.$pun_db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $pun_db->error()); + $stats['total_users'] = $pun_db->result($result); - $result = $db->query('SELECT id, username FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error()); - $stats['last_user'] = $db->fetch_assoc($result); + $result = $pun_db->query('SELECT id, username FROM '.$pun_db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $pun_db->error()); + $stats['last_user'] = $pun_db->fetch_assoc($result); - $result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error()); - list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result); + $result = $pun_db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$pun_db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $pun_db->error()); + list($stats['total_topics'], $stats['total_posts']) = $pun_db->fetch_row($result); echo $lang_index['No of users'].': '.$stats['total_users'].'
'; echo $lang_index['Newest user'].': '.pun_htmlspecialchars($stats['last_user']['username']).'
'; diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/footer.php --- a/punbb/footer.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/footer.php Thu Jul 12 01:04:01 2007 -0400 @@ -115,7 +115,7 @@ // Calculate script generation time list($usec, $sec) = explode(' ', microtime()); $time_diff = sprintf('%.3f', ((float)$usec + (float)$sec) - $pun_start); - echo "\t\t\t".'

[ Generated in '.$time_diff.' seconds, '.$db->get_num_queries().' queries executed ]

'."\n"; + echo "\t\t\t".'

[ Generated in '.$time_diff.' seconds, '.$pun_db->get_num_queries().' queries executed ]

'."\n"; } ?> @@ -127,7 +127,7 @@ // End the transaction -$db->end_transaction(); +$pun_db->end_transaction(); // Display executed queries (if enabled) if (defined('PUN_SHOW_QUERIES')) @@ -140,7 +140,7 @@ // Close the db connection (and free up any result data) -$db->close(); +$pun_db->close(); // Spit out the page exit($tpl_main); diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/header.php --- a/punbb/header.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/header.php Thu Jul 12 01:04:01 2007 -0400 @@ -22,25 +22,77 @@ ************************************************************************/ +// Import the Enano API +global $db, $session, $paths, $template, $plugins; // Common objects // Make sure no one attempts to run this script "directly" if (!defined('PUN')) exit; +$template->tpl_strings['PAGE_NAME'] = $page_title; +$template->add_header(''); + +// Special case - many Enano themes have indented paragraphs +$template->add_header(''); + // Send no-cache headers header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :) header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); // For HTTP/1.0 compability - // Load the template if (defined('PUN_ADMIN_CONSOLE')) +{ $tpl_main = file_get_contents(PUN_ROOT.'include/template/admin.tpl'); +} else if (defined('PUN_HELP')) +{ $tpl_main = file_get_contents(PUN_ROOT.'include/template/help.tpl'); +} else - $tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl'); +{ + // $tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl'); + $inner = '
+
+ +
+
+
+ + +
+ + +
+
+ + + + + + + +
+
'; + + $tpl_main = $template->getHeader() . $inner . $template->getFooter(); + +} // START SUBST - @@ -57,7 +109,6 @@ } // END SUBST - - // START SUBST - $tpl_main = str_replace('', $lang_common['lang_direction'], $tpl_main); // END SUBST - @@ -67,7 +118,6 @@ $tpl_main = str_replace('', $lang_common['lang_encoding'], $tpl_main); // END SUBST - - // START SUBST - ob_start(); @@ -76,8 +126,7 @@ echo ''."\n"; ?> -<?php echo $page_title ?> - + $tpl_main = str_replace('', htmlspecialchars(basename($_SERVER['PHP_SELF'], '.php')), $tpl_main); -// END SUBST - +// END SUBST - // START SUBST - @@ -172,11 +221,11 @@ { $tpl_temp = '
'."\n\t\t\t".'
    '."\n\t\t\t\t".'
  • '.$lang_common['Logged in as'].' '.pun_htmlspecialchars($pun_user['username']).'
  • '."\n\t\t\t\t".'
  • '.$lang_common['Last visit'].': '.format_time($pun_user['last_visit']).'
  • '; - if ($pun_user['g_id'] < PUN_GUEST) + if ($pun_user['g_id'] >= USER_LEVEL_MEMBER) { - $result_header = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'reports WHERE zapped IS NULL') or error('Unable to fetch reports info', __FILE__, __LINE__, $db->error()); + $result_header = $pun_db->query('SELECT COUNT(id) FROM '.$pun_db->prefix.'reports WHERE zapped IS NULL') or error('Unable to fetch reports info', __FILE__, __LINE__, $pun_db->error()); - if ($db->result($result_header)) + if ($pun_db->result($result_header)) $tpl_temp .= "\n\t\t\t\t".''; if ($pun_config['o_maintenance'] == '1') @@ -192,7 +241,6 @@ $tpl_main = str_replace('', $tpl_temp, $tpl_main); // END SUBST - - // START SUBST - if ($pun_config['o_announcement'] == '1') { @@ -217,7 +265,6 @@ $tpl_main = str_replace('', '', $tpl_main); // END SUBST - - // START SUBST - ob_start(); diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/help.php --- a/punbb/help.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/help.php Thu Jul 12 01:04:01 2007 -0400 @@ -26,8 +26,11 @@ // Tell header.php to use the help template define('PUN_HELP', 1); -define('PUN_ROOT', './'); -require PUN_ROOT.'include/common.php'; +//define('PUN_ROOT', './'); +//require PUN_ROOT.'include/common.php'; + +global $pun_db, $pun_user, $pun_config, $lang_common; + if ($pun_user['g_read_board'] == '0') diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/include/cache.php --- a/punbb/include/cache.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/include/cache.php Thu Jul 12 01:04:01 2007 -0400 @@ -78,11 +78,11 @@ // function generate_config_cache() { - global $db; + global $pun_db; // Get the forum config from the DB - $result = $db->query('SELECT * FROM '.$db->prefix.'config', true) or error('Unable to fetch forum config', __FILE__, __LINE__, $db->error()); - while ($cur_config_item = $db->fetch_row($result)) + $result = $pun_db->query('SELECT * FROM '.$pun_db->prefix.'config', true) or error('Unable to fetch forum config', __FILE__, __LINE__, $pun_db->error()); + while ($cur_config_item = $pun_db->fetch_row($result)) $output[$cur_config_item[0]] = $cur_config_item[1]; // Output config as PHP code @@ -101,13 +101,13 @@ // function generate_bans_cache() { - global $db; + global $pun_db; // Get the ban list from the DB - $result = $db->query('SELECT * FROM '.$db->prefix.'bans', true) or error('Unable to fetch ban list', __FILE__, __LINE__, $db->error()); + $result = $pun_db->query('SELECT * FROM '.$pun_db->prefix.'bans', true) or error('Unable to fetch ban list', __FILE__, __LINE__, $pun_db->error()); $output = array(); - while ($cur_ban = $db->fetch_assoc($result)) + while ($cur_ban = $pun_db->fetch_assoc($result)) $output[] = $cur_ban; // Output ban list as PHP code @@ -126,13 +126,13 @@ // function generate_ranks_cache() { - global $db; + global $pun_db; // Get the rank list from the DB - $result = $db->query('SELECT * FROM '.$db->prefix.'ranks ORDER BY min_posts', true) or error('Unable to fetch rank list', __FILE__, __LINE__, $db->error()); + $result = $pun_db->query('SELECT * FROM '.$pun_db->prefix.'ranks ORDER BY min_posts', true) or error('Unable to fetch rank list', __FILE__, __LINE__, $pun_db->error()); $output = array(); - while ($cur_rank = $db->fetch_assoc($result)) + while ($cur_rank = $pun_db->fetch_assoc($result)) $output[] = $cur_rank; // Output ranks list as PHP code @@ -151,7 +151,7 @@ // function generate_quickjump_cache($group_id = false) { - global $db, $lang_common, $pun_user; + global $pun_db, $lang_common, $pun_user; // If a group_id was supplied, we generate the quickjump cache for that group only if ($group_id !== false) @@ -159,11 +159,11 @@ else { // A group_id was now supplied, so we generate the quickjump cache for all groups - $result = $db->query('SELECT g_id FROM '.$db->prefix.'groups') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); - $num_groups = $db->num_rows($result); + $result = $pun_db->query('SELECT g_id FROM '.$pun_db->prefix.'groups') or error('Unable to fetch user group list', __FILE__, __LINE__, $pun_db->error()); + $num_groups = $pun_db->num_rows($result); for ($i = 0; $i < $num_groups; ++$i) - $groups[] = $db->result($result, $i); + $groups[] = $pun_db->result($result, $i); } // Loop through the groups in $groups and output the cache for each of them @@ -178,10 +178,10 @@ $output .= "\t\t\t\t".''."\n\t\t\t\t\t".'