From 0a4f369681c7bf28c49fe9e9435b2c6ea0fd4915 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Wed, 30 Oct 2002 18:59:09 +0000 Subject: Dumped sql_query_array, replaced with build_array, posting updates, fixed quoting in mysql layers, fulltext enabled ... speed/problem feedback welcome git-svn-id: file:///svn/phpbb/trunk@2986 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/admin/admin_forums.php | 176 +++++++++++++++++++++----------------- phpBB/admin/admin_smilies.php | 194 +++++++++++++++++++++++++++--------------- 2 files changed, 223 insertions(+), 147 deletions(-) (limited to 'phpBB/admin') diff --git a/phpBB/admin/admin_forums.php b/phpBB/admin/admin_forums.php index 915a63a56f..25e6ced71c 100644 --- a/phpBB/admin/admin_forums.php +++ b/phpBB/admin/admin_forums.php @@ -168,6 +168,7 @@ switch ($mode) $forum_style = (!empty($_POST['forum_style'])) ? intval($_POST['forum_style']) : 'NULL'; $post_count_inc = (!empty($_POST['disable_post_count'])) ? 0 : 1; + $moderated = (!empty($_POST['moderated'])) ? 1 : 0; $prune_enable = (!empty($_POST['prune_enable'])) ? 1 : 0; $prune_days = intval($_POST['prune_days']); @@ -198,8 +199,8 @@ switch ($mode) $right_id = $left_id + 1; } - $sql = 'INSERT INTO ' . FORUMS_TABLE . " (forum_id, forum_name, forum_desc, parent_id, left_id, right_id, forum_status, forum_style, post_count_inc, prune_enable, prune_days, prune_freq) - VALUES ($forum_id, '$forum_name', '$forum_desc', $parent_id, $left_id, $right_id, $forum_status, $forum_style, $post_count_inc, $prune_enable, $prune_days, $prune_freq)"; + $sql = 'INSERT INTO ' . FORUMS_TABLE . " (forum_id, forum_name, forum_desc, parent_id, left_id, right_id, forum_status, forum_style, post_count_inc, moderate, prune_enable, prune_days, prune_freq) + VALUES ($forum_id, '$forum_name', '$forum_desc', $parent_id, $left_id, $right_id, $forum_status, $forum_style, $post_count_inc, $moderated, $prune_enable, $prune_days, $prune_freq)"; $db->sql_query($sql); $message = $user->lang['Forums_updated'] . "

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

' . sprintf($user->lang['Click_return_admin_index'], '', ''); @@ -231,8 +232,9 @@ switch ($mode) 'prune_enable' => (!empty($_POST['prune_enable'])) ? 1 : 0, 'prune_days' => intval($_POST['prune_days']), 'prune_freq' => intval($_POST['prune_freq']), - 'display_on_index' => (!isset($_POST['display_on_index']) || !empty($_POST['display_on_index'])) ? 1 : 0, - 'post_count_inc' => (!empty($_POST['disable_post_count'])) ? 0 : 1 + 'display_on_index' => (!empty($_POST['display_on_index'])) ? 1 : 0, + 'post_count_inc' => (!empty($_POST['disable_post_count'])) ? 0 : 1, + 'moderated' => (!empty($_POST['moderated'])) ? 1 : 0, ); if (!empty($_POST['set_category']) && $action) @@ -249,8 +251,8 @@ switch ($mode) $sql['forum_posts'] = 0; $sql['forum_topics'] = 0; } - - $db->sql_query_array('UPDATE ' . FORUMS_TABLE . " SET WHERE forum_id = $forum_id", $sql); +echo 'UPDATE ' . FORUMS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql) . " WHERE forum_id = $forum_id"; + $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); @@ -400,6 +402,7 @@ switch ($mode) $forum_name = (!empty($_POST['forum_name'][$parent_id])) ? htmlspecialchars($_POST['forum_name'][$parent_id]) : ''; $post_count_inc = TRUE; + $moderated = FALSE; $prune_enabled = ''; $prune_days = 7; @@ -424,117 +427,136 @@ switch ($mode)

lang['Forum_edit_delete_explain'] ?>

-
" method="post"> - - - - - - - - - - - +" method="post">
lang['General_settings'] ?>
lang['Forum_name'] : $user->lang['Category_name'] ?>
lang['Forum_desc'] ?>
+ + + + + + + + + + - - - - + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - + + + + - - - - + + + + - - - -
lang['General_settings'] ?>
lang['Forum_name'] : $user->lang['Category_name'] ?>
lang['Forum_desc'] ?>
lang['Forum_type'] ?>/>lang['Forum'] ?>   />lang['Category'] ?>
lang['Forum_type'] ?>/>lang['Forum'] ?>   />lang['Category'] ?>
lang['Parent'] ?>
lang['Style'] ?>
lang['Parent'] ?>
lang['Style'] ?>
lang['Forum_settings'] ?>
lang['Forum_status'] ?>
lang['Options'] ?> - />lang['Disable_post_count'] ?> +
lang['Forum_settings'] ?>
lang['Forum_status'] ?>
lang['Options'] ?> + + + + + + 0) { - // // if this forum is a subforum put the "display on index" checkbox - // if ($parent_info = get_forum_info($parent_id)) { if ($parent_info['parent_id'] > 0 || $parent_info['forum_status'] != ITEM_CATEGORY) { + ?> -
- />lang['Display_on_index'] ?> + + + - +
/> lang['Disable_post_count'] ?>
/> lang['Forum_is_moderated']; ?>
/> lang['Display_on_index'] ?>
+
lang['Forum_type'] ?>lang['Set_as_category'] ?>
-      lang['Delete_all_posts'] ?>
-      lang['Move_posts_to'] ?> -
lang['Forum_type'] ?> + + + + + + + + + +
lang['Set_as_category'] ?>
      lang['Delete_all_posts'] ?>
      lang['Move_posts_to'] ?>
lang['Forum_pruning'] ?> - - - - - - - - - - - - -
lang['Enabled'] ?>/>
lang['prune_days'] ?>  lang['Days'] ?>
lang['prune_freq'] ?>  lang['Days'] ?>
lang['Forum_pruning'] ?> + + + + + + + + + + + + +
lang['Enabled'] ?>/>
lang['prune_days'] ?>  lang['Days'] ?>
lang['prune_freq'] ?>  lang['Days'] ?>
-
+ + + +
acl_get('a_general')) // // Check to see what mode we should operate in. // +if (isset($_POST['type']) || isset($_GET['type'])) +{ + $type = (!empty($_POST['type'])) ? $_POST['type'] : $_GET['type']; +} +else +{ + $type = ''; +} + if (isset($_POST['mode']) || isset($_GET['mode'])) { $mode = (!empty($_POST['mode'])) ? $_POST['mode'] : $_GET['mode']; @@ -60,25 +70,40 @@ else $mode = ''; } +switch ($type) +{ + case 'emoticons': + $table = SMILIES_TABLE; + $lang = 'smilies'; + $path = $config['smilies_path']; + break; + + case 'icons': + $table = ICONS_TABLE; + $lang = 'icons'; + $path = $config['icons_path']; + break; +} + $delimiter = '=+:'; -$smilies_images = $smilies_paks = array(); +$_images = $_paks = array(); if ($mode == 'edit' || !empty($_POST['add']) || !empty($_POST['import_pak'])) { - $dir = @opendir($phpbb_root_path . $board_config['smilies_path']); + $dir = @opendir($phpbb_root_path . $path); while ($file = @readdir($dir)) { - if (is_file($phpbb_root_path . $board_config['smilies_path'] . '/' . $file)) + if (is_file($phpbb_root_path . $path . '/' . $file)) { - $img_size = @getimagesize($phpbb_root_path . $board_config['smilies_path'] . '/' . $file); + $img_size = @getimagesize($phpbb_root_path . $path . '/' . $file); if (preg_match('/\.(gif|png|jpg)$/i', $file) || (!empty($img_size[0]) && !empty($img_size[1]))) { - $smilies_images[] = $file; + $_images[] = $file; } elseif (preg_match('/\.pak$/i', $file)) { - $smilies_paks[] = $file; + $_paks[] = $file; } } } @@ -90,7 +115,7 @@ if ($mode == 'edit' || !empty($_POST['add']) || !empty($_POST['import_pak'])) // if (isset($_POST['import_pak'])) { - if (!empty($_POST['smilies_pak'])) + if (!empty($_POST['_pak'])) { $smile_order = 0; // @@ -98,11 +123,11 @@ if (isset($_POST['import_pak'])) // if (!empty($_POST['clear_current'])) { - $db->sql_query('DELETE FROM ' . SMILIES_TABLE); + $db->sql_query('DELETE FROM ' . $table); } else { - $result = $db->sql_query('SELECT code FROM ' . SMILIES_TABLE); + $result = $db->sql_query('SELECT code FROM ' . $table); $smilies = array(); while ($row = $db->sql_fetchrow($result)) @@ -112,35 +137,35 @@ if (isset($_POST['import_pak'])) } } - $fcontents = @file($phpbb_root_path . $board_config['smilies_path'] . '/'. $smilies_pak); + $fcontents = @file($phpbb_root_path . $path . '/'. $_pak); if (empty($fcontents)) { - message_die(ERROR, 'Could not read smiley pak file'); + trigger_error('Could not read smiley pak file', E_USER_ERROR); } foreach ($fcontents as $line) { - $smile_data = explode($delimiter, trim($line)); + $_data = explode($delimiter, trim($line)); - $smile_url = $smile_data[0]; - $emotion = $smile_data[1]; - $code = htmlentities($smile_data[2]); + $_url = $_data[0]; + $emotion = $_data[1]; + $code = htmlentities($_data[2]); - if (!isset($smile_data[4])) + if (!isset($_data[4])) { // // The size isn't specified, try to get it from the file and if it fails // arbitrary set it to 15 and let the user correct it later. // - $size = @getimagesize($phpbb_root_path . $board_config['smilies_path'] . '/' . $smile_url); - $smile_width = (!empty($size[0])) ? $size[0] : 15; - $smile_height = (!empty($size[1])) ? $size[1] : 15; + $size = @getimagesize($phpbb_root_path . $path . '/' . $smile_url); + $_width = (!empty($size[0])) ? $size[0] : 15; + $_height = (!empty($size[1])) ? $size[1] : 15; } else { - $smile_width = $smile_data[3]; - $smile_height = $smile_data[4]; + $_width = $_data[3]; + $_height = $_data[4]; } if (!empty($smilies[$code])) @@ -149,12 +174,12 @@ if (isset($_POST['import_pak'])) { $code_sql = str_replace("'", "''", str_replace('\\', '\\\\', $code)); $sql = array( - 'smile_url' => $smile_url, - 'smile_height' => $smile_height, - 'smile_width' => $smile_width, + 'smile_url' => $_url, + 'smile_height' => $_height, + 'smile_width' => $_width, 'emoticon' => $emotion ); - $db->sql_query_array('UPDATE ' . SMILIES_TABLE . " SET WHERE code = '$code_sql'", $sql); + $db->sql_query("UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql) . "WHERE code = '$code_sql'"); } } else @@ -163,33 +188,33 @@ if (isset($_POST['import_pak'])) $sql = array( 'code' => $code, - 'smile_url' => $smile_url, - 'smile_height' => $smile_height, - 'smile_width' => $smile_width, - 'smile_order' => $smile_order, + 'smile_url' => $_url, + 'smile_height' => $_height, + 'smile_width' => $_width, + 'smile_order' => $_order, 'emoticon' => $emotion ); - $db->sql_query_array('INSERT INTO ' . SMILIES_TABLE, $sql); + $db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql)); } } - message_die(MESSAGE, $user->lang['Smilies_import_success']); + message_die(MESSAGE, $user->lang[$lang . '_import_success']); } else { - if (!count($smilies_paks)) + if (!count($_paks)) { - $smilies_paks_select = $user->lang['No_smilies_pak']; + $_paks_select = $user->lang['No_smilies_pak']; } else { - $smilies_paks_select = ''; - foreach ($smilies_paks as $pak) + foreach ($_paks as $pak) { - $smilies_paks_select .= ''; + $_paks_select .= ''; } - $smilies_paks_select .= ''; + $_paks_select .= ''; } page_header($user->lang['Import_smilies']); @@ -198,13 +223,13 @@ if (isset($_POST['import_pak']))

lang['Import_smilies_explain'] ?>

-
+
- + @@ -230,7 +255,7 @@ elseif (isset($_GET['export_pak'])) { $smilies_pak = ''; - $result = $db->sql_query('SELECT * FROM ' . SMILIES_TABLE); + $result = $db->sql_query('SELECT * FROM ' . $table); while ($row = $db->sql_fetchrow($result)) { $smilies_pak .= $row['smile_url'] . $delimiter; @@ -256,7 +281,7 @@ elseif (isset($_POST['export_pak'])) elseif (isset($_POST['add'])) { $filename_list = ''; - foreach ($smilies_images as $smile_url) + foreach ($_images as $smile_url) { if (!isset($default_image)) { @@ -273,7 +298,7 @@ elseif (isset($_POST['add'])) -
lang['Smilies_import'] ?>
lang['Select_package'] ?>
lang['Delete_existing_smilies'] ?>
+>
@@ -296,7 +321,7 @@ function update_smile_dimensions() - + @@ -352,7 +377,7 @@ switch ($mode) $order_list = '' . $order_list; $filename_list = ''; - foreach ($smilies_images as $smile_url) + foreach ($_images as $smile_url) { if ($smile_url == $smile_data['smile_url']) { @@ -375,7 +400,7 @@ switch ($mode)
lang['smile_config'] ?>
lang['Smile_url'] ?>        
lang['Smile_width'] ?>