From ab928d8f5f2668da1354077a94e9326307ac3de4 Mon Sep 17 00:00:00 2001 From: Ludovic Arnaud Date: Mon, 13 Jan 2003 05:11:11 +0000 Subject: [PATCH] Minor fixes git-svn-id: file:///svn/phpbb/trunk@3316 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/admin/admin_board.php | 9 ++------- phpBB/admin/admin_forums.php | 21 +++++++++++---------- phpBB/admin/admin_search.php | 17 +++-------------- phpBB/includes/functions.php | 29 +++++++++++++++++++++++------ 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/phpBB/admin/admin_board.php b/phpBB/admin/admin_board.php index 099514f680..5cb3ad51f9 100644 --- a/phpBB/admin/admin_board.php +++ b/phpBB/admin/admin_board.php @@ -98,10 +98,7 @@ while ($row = $db->sql_fetchrow($result)) if (isset($_POST['submit'])) { - $sql = "UPDATE " . CONFIG_TABLE . " SET - config_value = '" . str_replace("\'", "''", $new[$config_name]) . "' - WHERE config_name = '$config_name'"; - $db->sql_query($sql); + set_config($config_name, stripslashes($new[$config_name])); } } @@ -549,9 +546,7 @@ switch ($mode) { if (!isset($config[$field])) { - $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name, config_value) - VALUES ('$field', '')"; - $db->sql_query($sql); + set_config($field, ''); } } } diff --git a/phpBB/admin/admin_forums.php b/phpBB/admin/admin_forums.php index 9491624db1..66c792d1e4 100644 --- a/phpBB/admin/admin_forums.php +++ b/phpBB/admin/admin_forums.php @@ -72,7 +72,7 @@ switch ($mode) $result = $db->sql_query('SELECT parent_id, left_id, right_id FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id"); if (!$row = $db->sql_fetchrow($result)) { - message_die(ERROR, 'Forum does not exist'); + trigger_error('Forum does not exist'); } extract($row); $forum_info = array($forum_id => $row); @@ -192,8 +192,8 @@ switch ($mode) 'parent_id' => $parent_id, 'left_id' => $left_id, 'right_id' => $right_id, - 'forum_status' => (!empty($_POST['is_category'])) ? ITEM_CATEGORY : intval($_POST['forum_status']), - 'forum_postable' => (!empty($_POST['is_category'])) ? 0 : 1, + 'forum_status' => ITEM_UNLOCKED, + 'forum_postable' => (!empty($_POST['forum_postable'])) ? 1 : 0, 'forum_name' => sql_quote($_POST['forum_name']), 'forum_desc' => sql_quote($_POST['forum_desc']), 'forum_style' => (!empty($_POST['forum_style'])) ? intval($_POST['forum_style']) : 'NULL', @@ -210,14 +210,14 @@ switch ($mode) $forum_id = $db->sql_nextid(); // Redirect to permissions - redirect('admin_permissions.' . $phpEx . $SID . '&mode=forums&f=' . $forum_id); + redirect('admin/admin_permissions.' . $phpEx . $SID . '&mode=forums&f=' . $forum_id); break; case 'modify': if (!$forum_id = intval($_POST['f'])) { - message_die(ERROR, 'No forum specified'); + trigger_error('No forum specified'); } $row = get_forum_info($forum_id); @@ -271,7 +271,8 @@ switch ($mode) $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql) . " WHERE forum_id = $forum_id"); $message = $user->lang['Forums_updated'] . "

" . sprintf($user->lang['Click_return_forumadmin'], '', '') . '

' . sprintf($user->lang['Click_return_admin_index'], '', ''); - message_die(MESSAGE, $message); + + trigger_error($message); break; @@ -300,7 +301,7 @@ switch ($mode) { $message = $user->lang['No_destination_forum'] . '

' . sprintf($user->lang['Click_return_forumadmin'], '', ''); - message_die(ERROR, $message); + trigger_error($message); } move_forum_content($forum_id, $_POST['posts_to_id']); @@ -325,7 +326,7 @@ switch ($mode) { $message = $user->lang['No_destination_forum'] . '

' . sprintf($user->lang['Click_return_forumadmin'], '', ''); - message_die(ERROR, $message); + trigger_error($message); } $result = $db->sql_query('SELECT forum_id FROM ' . FORUMS_TABLE . " WHERE parent_id = $forum_id"); @@ -360,7 +361,7 @@ switch ($mode) $return_id = (!empty($_POST['subforums_to_id'])) ? $_POST['subforums_to_id'] : $parent_id; $message = $user->lang['Forum_deleted'] . '

' . sprintf($user->lang['Click_return_forumadmin'], '', ''); - message_die(MESSAGE, $message); + trigger_error($message); break; case 'sync': @@ -745,7 +746,7 @@ while ($row = $db->sql_fetchrow($result)) lang['Move_up'] ?>
lang['Move_down'] ?>
-  lang['Edit'] ?> | lang['Delete'] ?> | lang['Resync'] ?>  +  lang['Edit'] ?> | lang['DELETE'] ?> | lang['Resync'] ?>  sql_query($sql); + set_config('board_disable', 1); // // Empty existing tables @@ -279,11 +276,7 @@ if (isset($_POST['start']) || isset($_GET['batchstart'])) } else { - $sql = "UPDATE " . CONFIG_TABLE . " - SET config_value = '0' - WHERE config_name = 'board_disable'"; - $db->sql_query($sql); - + set_config('board_disable', 0); page_header($user->lang['Search_indexing']); ?> @@ -303,11 +296,7 @@ if (isset($_POST['start']) || isset($_GET['batchstart'])) } else if (isset($_POST['cancel'])) { - $sql = "UPDATE " . CONFIG_TABLE . " - SET config_value = '0' - WHERE config_name = 'board_disable'"; - $db->sql_query($sql); - + set_config('board_disable', 0); page_header($user->lang['Search_indexing']); ?> diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8689ca7b2a..aa1af28270 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -32,13 +32,26 @@ function sql_quote($msg) function set_config($config_name, $config_value) { global $db, $cache, $config; + + if (isset($config[$config_name])) + { + $sql = 'UPDATE ' . CONFIG_TABLE . " + SET config_value = '" . sql_escape($config_value) . "' + WHERE config_name = '$config_name'"; + $db->sql_query($sql); + } + else + { + $db->sql_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE config_name = "' . $config_name . '"'); + + $sql = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) + VALUES ('$config_name', '" . sql_escape($config_value) . "'"; + $db->sql_query($sql); + } + $config[$config_name] = $config_value; $cache->save('config', $config); - $sql = 'UPDATE ' . CONFIG_TABLE . " - SET config_value = '" . sql_escape($config_value) . "' - WHERE config_name = '$config_name'"; - $db->sql_query($sql); } function get_userdata($user) @@ -689,18 +702,22 @@ function obtain_word_list(&$orig_word, &$replacement_word) // Redirects the user to another page then exits the script nicely function redirect($url) { - global $db, $config; + global $db, $cache, $config; if (isset($db)) { $db->sql_close(); } + if (isset($cache)) + { + $cache->save_cache(); + } $server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://'; $server_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($config['server_name'])); $server_port = ($config['server_port'] <> 80) ? ':' . trim($config['server_port']) . '/' : '/'; $script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($config['script_path'])); - $url = preg_replace('/^\/?(.*?)\/?$/', '/\1', trim($url)); + $url = (($script_name == '') ? '' : '/') . preg_replace('/^\/?(.*?)\/?$/', '\1', trim($url)); // Redirect via an HTML form for PITA webservers if (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')))