diff --git a/phpBB/adm/admin_icons.php b/phpBB/adm/admin_icons.php index b81c4ccd57..5a0d610940 100644 --- a/phpBB/adm/admin_icons.php +++ b/phpBB/adm/admin_icons.php @@ -1,23 +1,15 @@ acl_get('a_icons')) } // Grab some basic parameters -$mode = (!empty($_REQUEST['mode'])) ? $_REQUEST['mode'] : ''; -$action = (!empty($_REQUEST['action'])) ? $_REQUEST['action'] : ((isset($_POST['add'])) ? 'add' : ''); -$id = (isset($_GET['id'])) ? intval($_GET['id']) : false; +$mode = request_var('mode', ''); +$action = request_var('action', ''); +$action = (isset($_POST['add'])) ? 'add' : $action; +$action = (isset($_POST['edit'])) ? 'edit' : $action; +$id = request_var('id', 0); // What are we working on? switch ($mode) @@ -70,27 +64,33 @@ switch ($mode) // Clear some arrays $_images = $_paks = array(); - +$notice = ''; // Grab file list of paks and images if ($action == 'edit' || $action == 'add' || $action == 'import') { + $imglist = filelist($phpbb_root_path . $img_path, ''); + + foreach ($imglist as $path => $img_ary) + { + foreach ($img_ary as $img) + { + $img_size = @getimagesize($phpbb_root_path . $img_path . '/' . $path . $img); + + $_images[$path.$img]['file'] = $path.$img; + $_images[$path.$img]['width'] = $img_size[0]; + $_images[$path.$img]['height'] = $img_size[1]; + } + } + unset($imglist); + $dir = @opendir($phpbb_root_path . $img_path); while ($file = @readdir($dir)) { - if (is_file($phpbb_root_path . $img_path . '/' . $file)) + if (is_file($phpbb_root_path . $img_path . '/' . $file) && preg_match('#\.pak$#i', $file)) { - $img_size = @getimagesize($phpbb_root_path . $img_path . '/' . $file); - - if (preg_match('#\.(gif|png|jpg)$#i', $file) || (!empty($img_size[0]) && !empty($img_size[1]))) - { - $_images[] = $file; - } - elseif (preg_match('#\.pak$#i', $file)) - { - $_paks[] = $file; - } + $_paks[] = $file; } } @closedir($dir); @@ -100,51 +100,40 @@ if ($action == 'edit' || $action == 'add' || $action == 'import') // What shall we do today? Oops, I believe that's trademarked ... switch ($action) { - case 'delete': - - $db->sql_query('DELETE FROM ' . $table . ' - WHERE ' . $fields . '_id = ' . intval($_GET['id'])); - - switch ($mode) - { - case 'emoticons': - break; - - case 'icons': - // Reset appropriate icon_ids - $db->sql_query('UPDATE ' . TOPICS_TABLE . ' - SET icon_id = 0 - WHERE icon_id = ' . intval($_GET['id'])); - $db->sql_query('UPDATE ' . POSTS_TABLE . ' - SET icon_id = 0 - WHERE icon_id = ' . intval($_GET['id'])); - break; - } - - trigger_error($user->lang[$lang . '_DELETED']); - break; - case 'edit': + unset($_images); + $_images = array(); + case 'add': $order_list = ''; - $existing_imgs = array(); - $result = $db->sql_query('SELECT * - FROM ' . $table . ' - ORDER BY ' . $fields . '_order DESC'); + + $sql = "SELECT * + FROM $table + ORDER BY {$fields}_order " . (($id || $action == 'add') ? 'DESC' : 'ASC'); + $result = $db->sql_query($sql); + if ($row = $db->sql_fetchrow($result)) { do { - $existing_imgs[] = $row[$fields . '_url']; + if ($action == 'add') + { + unset($_images[$row[$fields . '_url']]); + } if ($row[$fields . '_id'] == $id) { $after = TRUE; - $data = $row; + $data[$row[$fields . '_url']] = $row; } else { + if ($action == 'edit' && !$id) + { + $data[$row[$fields . '_url']] = $row; + } + $selected = ''; if (!empty($after)) { @@ -161,36 +150,16 @@ switch ($action) $db->sql_freeresult($result); $order_list = '' . $order_list; - - $imglist = filelist($phpbb_root_path . $img_path, ''); - $filename_list = ''; - foreach ($imglist as $path => $img_ary) + if ($action == 'add') { - foreach ($img_ary as $img) - { - $img = "$path$img"; - - if (!in_array($img, $existing_imgs) || $action == 'edit') - { - if ((isset($data) && $img == $data[$fields . '_url']) || - (!isset($data) && !isset($edit_img))) - { - $selected = ' selected="selected"'; - $edit_img = $img; - } - else - { - $selected = ''; - } - - $filename_list .= ''; - } - } + $data = $_images; } - unset($existing_imgs); - unset($imglist); - + + $colspan = (($mode == 'emoticons') ? '7' : '5'); + $colspan += ($id) ? 1 : 0; + $colspan += ($action == 'add') ? 2 : 0; + adm_page_header($user->lang[$lang]); ?> @@ -199,78 +168,97 @@ switch ($action)
lang[$lang .'_EXPLAIN']; ?>
- - -