diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index 600d3c986c..6f1c967e53 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -47,8 +47,8 @@ if (!$auth->acl_get('a_styles')) // Get some vars -$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; $update = (isset($_POST['update'])) ? true : false; +$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; if (isset($_REQUEST['action'])) { @@ -69,19 +69,21 @@ else // Set some basic vars $error = $cfg = $stylecfg = array(); -$archive_types = $archive_preg = $tmp_path = ''; +$tmp_path = ''; $safe_mode = (@ini_get('safe_mode') && @strtolower(ini_get('safe_mode')) == 'on') ? true : false; // Generate list of archive types inc. regexp | match -foreach (array('zip' => 'zlib', 'tar' => '', 'tar.gz' => 'zlib', 'tar.bz2' => 'bz2') as $type => $module) +$archive_types = '.tar'; +$archive_preg = '\.tar'; +foreach (array('tar.gz' => 'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib') as $type => $module) { - if ($module && !@extension_loaded($module)) + if (!@extension_loaded($module)) { break; } - $archive_types .= (($archive_types != '') ? ', ' : '') . ".$type"; - $archive_preg .= (($archive_preg != '') ? '|' : '') . '\.' . preg_quote($type); + $archive_types .= ", .$type"; + $archive_preg .= '|\.' . preg_quote($type); } @@ -436,13 +438,13 @@ switch ($mode) lang['ARCHIVE_FORMAT']; ?>: - .tar   'zlib', 'tar' => '', 'tar.gz' => 'zlib', 'tar.bz2' => 'bz2'); + $compress_types = array('tar.gz' => 'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib'); foreach ($compress_types as $type => $module) { - if ($module && !extension_loaded($module)) + if (!extension_loaded($module)) { break; } @@ -622,7 +624,7 @@ switch ($mode) // Common params $style_active = (isset($_POST['style_active'])) ? ((!empty($_POST['style_active'])) ? 1 : 0) : 1; - $style_default = (isset($_POST['style_default'])) ? ((!empty($_POST['style_active'])) ? 1 : 0) : (($config['default_style'] == $style_id) ? 1 : 0); + $style_default = (isset($_POST['style_default'])) ? ((!empty($_POST['style_default'])) ? 1 : 0) : (($config['default_style'] == $style_id) ? 1 : 0); // User has submitted form and no errors have occured @@ -1026,7 +1028,7 @@ switch ($mode) ?> lang['STYLE_DEFAULT']; ?>: - /> lang['YES']; ?>   /> lang['NO']; ?> + /> lang['YES']; ?>   /> lang['NO']; ?> array( - 'btn_post', 'btn_post_pm', 'btn_reply', 'btn_reply_pm', 'btn_locked', 'btn_profile', 'btn_pm', 'btn_delete', 'btn_ip', 'btn_quote', 'btn_search', 'btn_edit', 'btn_report', 'btn_email', 'btn_www', 'btn_icq', 'btn_aim', 'btn_yim', 'btn_msnm', 'btn_jabber', 'btn_online', 'btn_offline', 'btn_topic_watch', 'btn_topic_unwatch', - ), - 'icons' => array( - 'icon_unapproved', 'icon_reported', 'icon_attach', 'icon_post', 'icon_post_new', 'icon_post_latest', 'icon_post_newest',), - 'forums' => array( - 'forum', 'forum_new', 'forum_locked', 'forum_link', 'sub_forum', 'sub_forum_new',), - 'folders' => array( - 'folder', 'folder_posted', 'folder_new', 'folder_new_posted', 'folder_hot', 'folder_hot_posted', 'folder_hot_new', 'folder_hot_new_posted', 'folder_locked', 'folder_locked_posted', 'folder_locked_new', 'folder_locked_new_posted', 'folder_sticky', 'folder_sticky_posted', 'folder_sticky_new', 'folder_sticky_new_posted', 'folder_announce', 'folder_announce_posted', 'folder_announce_new', 'folder_announce_new_posted',), - 'polls' => array( - 'poll_left', 'poll_center', 'poll_right',), - 'custom' => array(), - ); - - switch ($action) - { - case 'export': - if ($imageset_id) - { - $sql = 'SELECT * - FROM ' . STYLES_IMAGE_TABLE . " - WHERE imageset_id = $imageset_id"; - $result = $db->sql_query($sql); - - if (!($row = ($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_IMAGESET']); - } - $db->sql_freeresult($result); - - $imageset_name = $row['imageset_name']; - $imageset_path = $row['imageset_path']; - $imageset_copyright = $row['imageset_copyright']; - unset($row['imageset_name']); - unset($row['imageset_path']); - unset($row['imageset_copyright']); - unset($row['imageset_id']); - - $cfg = addslashes($imageset_name) . "\n"; - $cfg .= addslashes($imageset_copyright) . "\n"; - $cfg .= addslashes($config['version']); - - foreach (array_keys($row) as $key) - { - $cfg.= $key . '||' . str_replace("styles/$imageset_path/imageset/", '{PATH}', $row[$key]) . "\n"; - unset($row[$key]); - } - - $files = array(array('src' => "styles/$imageset_path/imageset/", 'prefix-' => "styles/$imageset_path/", 'prefix+' => false, 'exclude' => 'imageset.cfg')); - $data = array(array('src' => trim($cfg), 'prefix' => "imageset/imageset.cfg")); - - export('imageset', $imageset_id, $imageset_name, $imageset_path, $files, $data); - } - break; - - case 'delete': - if ($imageset_id) - { - $sql = 'SELECT imageset_id, imageset_name, imageset_path - FROM ' . STYLES_IMAGE_TABLE . " - WHERE imageset_id = $imageset_id"; - $result = $db->sql_query($sql); - - if (!(extract($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_IMAGESET']); - } - $db->sql_freeresult($result); - - remove('imageset', $imageset_id, $imageset_name, $imageset_path); - } - break; - - case 'add': - case 'details': - case 'install': - details('imageset', $mode, $action, $imageset_id); - exit; - break; - - case 'edit': - $imgname = (!empty($_POST['imgname'])) ? htmlspecialchars($imgname) : ''; - - if ($imageset_id) - { - $sql = 'SELECT * - FROM ' . STYLES_IMAGE_TABLE . " - WHERE imageset_id = $imageset_id"; - $result = $db->sql_query($sql); - - if (!extract($db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_IMAGESET']); - } - $db->sql_freeresult($result); - - $test_ary = array(); - foreach ($imglist as $category => $img_ary) - { - foreach ($img_ary as $img) - { - if (!empty($$img)) - { - $test_ary[] = preg_replace('#^"styles/' . $imageset_path . '/imageset/(\{LANG\}/)?(.*?)".*$#', '\2', $$img); - } - } - } - - $dp = @opendir("{$phpbb_root_path}styles/$imageset_path/imageset/"); - while ($file = readdir($dp)) - { - if (is_file("{$phpbb_root_path}styles/$imageset_path/imageset/$file")) - { - if (!in_array($file, $test_ary)) - { - $imglist['custom'][] = $file; - } - } - } - closedir($dp); - unset($matches); - unset($test_ary); - - $imgwidth = (preg_match('#width="([0-9]+?)"#i', $$imgname, $matches)) ? $matches[1] : 0; - $imgheight = (preg_match('#height="([0-9]+?)"#i', $$imgname, $matches)) ? $matches[1] : 0; - } - - - // Generate list of image options - $img_options = ''; - foreach ($imglist as $category => $img_ary) - { - $img_options .= ''; - foreach ($img_ary as $img) - { - $selected = ($img == $imgname) ? ' selected="selected"' : ''; - $img_options .= ''; - } - } - - // Grab list of potential images - $imagesetlist = filelist("{$phpbb_root_path}styles/$imageset_path/imageset"); - - $imagesetlist_options = ''; - foreach ($imagesetlist as $path => $img_ary) - { - foreach ($img_ary as $img) - { - $img = substr($path, 1) . (($path != '') ? '/' : '') . $img; - - $selected = (preg_match('#' . preg_quote($img) . '$#', $background_image)) ? ' selected="selected"' : ''; - $imagesetlist_options .= ''; - } - } - $imagesetlist_options = '' . $imagesetlist_options; - unset($imagesetlist); - - - adm_page_header($user->lang['EDIT_IMAGESET']); - -?> - -

lang['EDIT_IMAGESET']; ?>

- -

lang['EDIT_IMAGESET_EXPLAIN']; ?>

- -
"> - - - - - - -
lang['SELECT_CLASS']; ?>:  
- - - - - - - - - - - - - - - - - - - - - -
lang['EDIT_IMAGESET']; ?>
img_lang, $$imgname)) . ' vspace="5" />' : ''; ?>
lang['IMAGE_PARAMETER']; ?>lang['IMAGE_VALUE']; ?>
lang['IMAGE']; ?>:
lang['DIMENSIONS']; ?>:
lang['DIMENSIONS_EXPLAIN']; ?>
X
  
- -sql_query($sql); - - if (!extract($db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_TEMPLATE']); - } - $db->sql_freeresult($result); - - if ($template_storedb && file_exists("{$phpbb_root_path}styles/$template_path/template/")) - { - $filelist = array('/' => array()); - - $sql = 'SELECT template_filename, template_mtime - FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $template_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (@filemtime("{$phpbb_root_path}styles/$template_path/template/" . $row['template_filename']) > $row['template_mtime']) - { - $filelist['/'][] = $row['template_filename']; - } - } - $db->sql_freeresult($result); - - store_templates('update', $template_id, $template_path, $filelist); - unset($filelist); - } - } - break; - - case 'delete': - if ($template_id) - { - $sql = 'SELECT template_id, template_name, template_path, template_storedb - FROM ' . STYLES_TPL_TABLE . " - WHERE template_id = $template_id"; - $result = $db->sql_query($sql); - - if (!(extract($db->sql_fetchrow($result)))) - { - trigger_error($user->lang['NO_TEMPLATE']); - } - $db->sql_freeresult($result); - - if ($template_storedb) - { - $sql = 'DELETE FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $template_id"; - $db->sql_query($sql); - } - - remove('template', $template_id, $template_name, $template_path, $template_storedb); - } - break; - - case 'export': - if ($template_id) - { - $files = $data = array(); - $sql = 'SELECT * FROM ' . STYLES_TPL_TABLE . " WHERE template_id = $template_id"; @@ -1515,39 +1230,178 @@ switch ($mode) } $db->sql_freeresult($result); + // User wants to submit data ... if ($update) { - $cfg = addslashes($template_name) . "\n"; - $cfg .= addslashes($template_copyright) . "\n"; - $cfg .= addslashes($config['version']) . "\n"; - $cfg .= addslashes($bbcode_bitfield); - - if ($template_storedb) + // Where is the template stored? + if (!$template_storedb && is_writeable("{$phpbb_root_path}styles/$template_path/template/$tplname")) { - $sql = 'SELECT template_filename, template_data - FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $template_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) + if (!($fp = fopen("{$phpbb_root_path}styles/$template_path/template/$tplname", 'wb'))) { - $data[] = array( - 'src' => $row['template_data'], - 'prefix' => 'template/' . $row['template_filename'] - ); + trigger_error($user->lang['NO_TEMPLATE']); } - $db->sql_freeresult($result); + $stylesheet = fwrite($fp, $tpldata); + fclose($fp); } else { - $files = array(array('src' => "styles/$template_path/template/", 'prefix-' => "styles/$template_path/", 'prefix+' => false, 'exclude' => 'template.cfg')); + $db->sql_transaction('begin'); + + if (!$template_storedb) + { + // We change the path to one relative to the root rather than the theme folder + $sql = 'UPDATE ' . STYLES_TPL_TABLE . ' + SET template_storedb = 1 + WHERE template_id = ' . $template_id; + $db->sql_query($sql); + + $filelist = filelist("{$phpbb_root_path}styles/$template_path/template"); + $filelist = array('/template' => $filelist['']); + store_templates('insert', $template_id, $template_path, $filelist); + } + + $sql = 'UPDATE ' . STYLES_TPLDATA_TABLE . " + SET template_data = '" . $db->sql_escape($tpldata) . "', template_mtime = " . time() . " + WHERE template_id = $template_id + AND template_filename = '" . $db->sql_escape($tplname) . "'"; + $db->sql_query($sql); + + $db->sql_transaction('commit'); } - $data[] = array('src' => trim($cfg), 'prefix' => 'template/template.cfg'); + @unlink("{$phpbb_root_path}cache/tpl_{$template_name}_$tplname.$phpEx"); + + $error[] = $user->lang['TEMPLATE_UPDATED']; + add_log('admin', 'LOG_EDIT_TEMPLATE', $template_name, $tplname); } - export('template', $template_id, $template_name, $template_path, $files, $data); + $test_ary = array(); + foreach ($tpllist as $category => $tpl_ary) + { + $test_ary = array_merge($test_ary, $tpl_ary); + } + + if (!$template_storedb) + { + $dp = @opendir("{$phpbb_root_path}styles/$template_path/template"); + while ($file = readdir($dp)) + { + if (!strstr($file, 'bbcode.') && strstr($file, '.html') && !in_array($file, $test_ary) && is_file("{$phpbb_root_path}styles/$template_path/template/$file")) + { + $tpllist['custom'][] = $file; + } + } + closedir($dp); + unset($matches); + unset($test_ary); + + if ($tplname && !$tpldata) + { + if (!($fp = fopen("{$phpbb_root_path}styles/$template_path/template/$tplname", 'r'))) + { + trigger_error($user->lang['NO_TEMPLATE']); + } + $tpldata = fread($fp, filesize("{$phpbb_root_path}styles/$template_path/template/$tplname")); + fclose($fp); + } + + } + else + { + $sql = 'SELECT * + FROM ' . STYLES_TPLDATA_TABLE . " + WHERE template_id = $template_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if (!strstr($row['template_filename'], 'bbcode.') && !in_array($row['template_filename'], $test_ary)) + { + $tpllist['custom'][] = $row['template_filename']; + } + + if ($row['template_filename'] == $tplname && !$tpldata) + { + $tpldata = $row['template_data']; + } + } + $db->sql_freeresult($result); + } + + // List of included templates + if ($tplname) + { + preg_match_all('##', $tpldata, $included_tpls); + $included_tpls = $included_tpls[1]; + } } + unset($test_ary); + + // Generate list of template options + $tpl_options = ''; + ksort($tpllist); + foreach ($tpllist as $category => $tpl_ary) + { + sort($tpl_ary); + $tpl_options .= ''; + + foreach ($tpl_ary as $tpl_file) + { + $selected = ($tpl_file == $tplname) ? ' selected="selected"' : ''; + $tpl_options .= ''; + } + } + + + // Output page + adm_page_header($user->lang['EDIT_TEMPLATE']); + +?> + +

lang['EDIT_TEMPLATE']; ?>

+ +

lang['EDIT_TEMPLATE_EXPLAIN']; ?>

+ +
"> + + + + + + +
lang['SELECT_TEMPLATE']; ?>:  
+ + + + + + + + + + + + + + + + + +
lang['TEXT_COLUMNS']; ?>:  lang['TEXT_ROWS']; ?>:  
lang['RAW_HTML']; ?>
', $error); ?>
  
+ +sql_query($sql); + + if (!extract($db->sql_fetchrow($result))) + { + trigger_error($user->lang['NO_TEMPLATE']); + } + $db->sql_freeresult($result); + + if ($template_storedb && file_exists("{$phpbb_root_path}styles/$template_path/template/")) + { + $filelist = array('/' => array()); + + $sql = 'SELECT template_filename, template_mtime + FROM ' . STYLES_TPLDATA_TABLE . " + WHERE template_id = $template_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if (@filemtime("{$phpbb_root_path}styles/$template_path/template/" . $row['template_filename']) > $row['template_mtime']) + { + $filelist['/'][] = $row['template_filename']; + } + } + $db->sql_freeresult($result); + + store_templates('update', $template_id, $template_path, $filelist); + unset($filelist); + } + } + break; + + case 'delete': + if ($template_id) + { + $sql = 'SELECT template_id, template_name, template_path, template_storedb + FROM ' . STYLES_TPL_TABLE . " + WHERE template_id = $template_id"; + $result = $db->sql_query($sql); + + if (!(extract($db->sql_fetchrow($result)))) + { + trigger_error($user->lang['NO_TEMPLATE']); + } + $db->sql_freeresult($result); + + if ($template_storedb) + { + $sql = 'DELETE FROM ' . STYLES_TPLDATA_TABLE . " + WHERE template_id = $template_id"; + $db->sql_query($sql); + } + + remove('template', $template_id, $template_name, $template_path, $template_storedb); + } + break; + + case 'export': + if ($template_id) + { + $files = $data = array(); + $sql = 'SELECT * FROM ' . STYLES_TPL_TABLE . " WHERE template_id = $template_id"; @@ -1817,178 +1728,46 @@ function viewsource(url) } $db->sql_freeresult($result); - // User wants to submit data ... if ($update) { - // Where is the template stored? - if (!$template_storedb && is_writeable("{$phpbb_root_path}styles/$template_path/template/$tplname")) + $cfg = addslashes($template_name) . "\n"; + $cfg .= addslashes($template_copyright) . "\n"; + $cfg .= addslashes($config['version']) . "\n"; + $cfg .= addslashes($bbcode_bitfield); + + if ($template_storedb) { - if (!($fp = fopen("{$phpbb_root_path}styles/$template_path/template/$tplname", 'wb'))) + $sql = 'SELECT template_filename, template_data + FROM ' . STYLES_TPLDATA_TABLE . " + WHERE template_id = $template_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) { - trigger_error($user->lang['NO_TEMPLATE']); + $data[] = array( + 'src' => $row['template_data'], + 'prefix' => 'template/' . $row['template_filename'] + ); } - $stylesheet = fwrite($fp, $tpldata); - fclose($fp); + $db->sql_freeresult($result); } else { - $db->sql_transaction('begin'); - - if (!$template_storedb) - { - // We change the path to one relative to the root rather than the theme folder - $sql = 'UPDATE ' . STYLES_TPL_TABLE . ' - SET template_storedb = 1 - WHERE template_id = ' . $template_id; - $db->sql_query($sql); - - $filelist = filelist("{$phpbb_root_path}styles/$template_path/template"); - $filelist = array('/template' => $filelist['']); - store_templates('insert', $template_id, $template_path, $filelist); - } - - $sql = 'UPDATE ' . STYLES_TPLDATA_TABLE . " - SET template_data = '" . $db->sql_escape($tpldata) . "', template_mtime = " . time() . " - WHERE template_id = $template_id - AND template_filename = '" . $db->sql_escape($tplname) . "'"; - $db->sql_query($sql); - - $db->sql_transaction('commit'); + $files = array(array('src' => "styles/$template_path/template/", 'prefix-' => "styles/$template_path/", 'prefix+' => false, 'exclude' => 'template.cfg')); } - @unlink("{$phpbb_root_path}cache/tpl_{$template_name}_$tplname.$phpEx"); - - $error[] = $user->lang['TEMPLATE_UPDATED']; - add_log('admin', 'LOG_EDIT_TEMPLATE', $template_name, $tplname); + $data[] = array('src' => trim($cfg), 'prefix' => 'template/template.cfg'); } - $test_ary = array(); - foreach ($tpllist as $category => $tpl_ary) - { - $test_ary = array_merge($test_ary, $tpl_ary); - } - - if (!$template_storedb) - { - $dp = @opendir("{$phpbb_root_path}styles/$template_path/template"); - while ($file = readdir($dp)) - { - if (!strstr($file, 'bbcode.') && strstr($file, '.html') && !in_array($file, $test_ary) && is_file("{$phpbb_root_path}styles/$template_path/template/$file")) - { - $tpllist['custom'][] = $file; - } - } - closedir($dp); - unset($matches); - unset($test_ary); - - if ($tplname && !$tpldata) - { - if (!($fp = fopen("{$phpbb_root_path}styles/$template_path/template/$tplname", 'r'))) - { - trigger_error($user->lang['NO_TEMPLATE']); - } - $tpldata = fread($fp, filesize("{$phpbb_root_path}styles/$template_path/template/$tplname")); - fclose($fp); - } - - } - else - { - $sql = 'SELECT * - FROM ' . STYLES_TPLDATA_TABLE . " - WHERE template_id = $template_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!strstr($row['template_filename'], 'bbcode.') && !in_array($row['template_filename'], $test_ary)) - { - $tpllist['custom'][] = $row['template_filename']; - } - - if ($row['template_filename'] == $tplname && !$tpldata) - { - $tpldata = $row['template_data']; - } - } - $db->sql_freeresult($result); - } - - // List of included templates - if ($tplname) - { - preg_match_all('##', $tpldata, $included_tpls); - $included_tpls = $included_tpls[1]; - } + export('template', $template_id, $template_name, $template_path, $files, $data); } - unset($test_ary); + break; - // Generate list of template options - $tpl_options = ''; - ksort($tpllist); - foreach ($tpllist as $category => $tpl_ary) - { - sort($tpl_ary); - $tpl_options .= ''; - - foreach ($tpl_ary as $tpl_file) - { - $selected = ($tpl_file == $tplname) ? ' selected="selected"' : ''; - $tpl_options .= ''; - } - } - - - // Output page - adm_page_header($user->lang['EDIT_TEMPLATE']); - -?> - -

lang['EDIT_TEMPLATE']; ?>

- -

lang['EDIT_TEMPLATE_EXPLAIN']; ?>

- -
"> - - - - - - -
lang['SELECT_TEMPLATE']; ?>:  
- - - - - - - - - - - - - - - - - -
lang['TEXT_COLUMNS']; ?>:  lang['TEXT_ROWS']; ?>:  
lang['RAW_HTML']; ?>
', $error); ?>
  
- - '%s', ); - $s_hidden_fields = ''; // Do we want to edit an existing theme? @@ -2114,7 +1882,6 @@ function viewsource(url) } } - // Do we have a class set? If so, we need to extract and set the relevant data if (!empty($class)) { @@ -2505,6 +2272,17 @@ function csspreview() adm_page_footer(); break; + + case 'preview': + break; + + case 'add': + case 'details': + case 'install': + details('theme', $mode, $action, $theme_id); + exit; + break; + case 'delete': if ($theme_id) { @@ -2564,6 +2342,223 @@ function csspreview() // Front page front('theme', array('details', 'refresh', 'export', 'delete', 'preview')); break; + + + // IMAGESETS + case 'imagesets': + $imageset_id = (isset($_REQUEST['id'])) ? intval($_REQUEST['id']) : 0; + + $imglist = array( + 'buttons' => array( + 'btn_post', 'btn_post_pm', 'btn_reply', 'btn_reply_pm', 'btn_locked', 'btn_profile', 'btn_pm', 'btn_delete', 'btn_ip', 'btn_quote', 'btn_search', 'btn_edit', 'btn_report', 'btn_email', 'btn_www', 'btn_icq', 'btn_aim', 'btn_yim', 'btn_msnm', 'btn_jabber', 'btn_online', 'btn_offline', 'btn_topic_watch', 'btn_topic_unwatch', + ), + 'icons' => array( + 'icon_unapproved', 'icon_reported', 'icon_attach', 'icon_post', 'icon_post_new', 'icon_post_latest', 'icon_post_newest',), + 'forums' => array( + 'forum', 'forum_new', 'forum_locked', 'forum_link', 'sub_forum', 'sub_forum_new',), + 'folders' => array( + 'folder', 'folder_posted', 'folder_new', 'folder_new_posted', 'folder_hot', 'folder_hot_posted', 'folder_hot_new', 'folder_hot_new_posted', 'folder_locked', 'folder_locked_posted', 'folder_locked_new', 'folder_locked_new_posted', 'folder_sticky', 'folder_sticky_posted', 'folder_sticky_new', 'folder_sticky_new_posted', 'folder_announce', 'folder_announce_posted', 'folder_announce_new', 'folder_announce_new_posted',), + 'polls' => array( + 'poll_left', 'poll_center', 'poll_right',), + 'custom' => array(), + ); + + switch ($action) + { + case 'edit': + $imgname = (!empty($_POST['imgname'])) ? htmlspecialchars($_POST['imgname']) : ''; + + if ($imageset_id) + { + $sql = 'SELECT * + FROM ' . STYLES_IMAGE_TABLE . " + WHERE imageset_id = $imageset_id"; + $result = $db->sql_query($sql); + + if (!extract($db->sql_fetchrow($result))) + { + trigger_error($user->lang['NO_IMAGESET']); + } + $db->sql_freeresult($result); + + $test_ary = array(); + foreach ($imglist as $category => $img_ary) + { + foreach ($img_ary as $img) + { + if (!empty($$img)) + { + $test_ary[] = preg_replace('#^"styles/' . $imageset_path . '/imageset/(\{LANG\}/)?(.*?)".*$#', '\2', $$img); + } + } + } + + $dp = @opendir("{$phpbb_root_path}styles/$imageset_path/imageset/"); + while ($file = readdir($dp)) + { + if (is_file("{$phpbb_root_path}styles/$imageset_path/imageset/$file")) + { + if (!in_array($file, $test_ary)) + { + $imglist['custom'][] = $file; + } + } + } + closedir($dp); + unset($matches); + unset($test_ary); + + $imgwidth = (preg_match('#width="([0-9]+?)"#i', $$imgname, $matches)) ? $matches[1] : 0; + $imgheight = (preg_match('#height="([0-9]+?)"#i', $$imgname, $matches)) ? $matches[1] : 0; + } + + + // Generate list of image options + $img_options = ''; + foreach ($imglist as $category => $img_ary) + { + $img_options .= ''; + foreach ($img_ary as $img) + { + $selected = ($img == $imgname) ? ' selected="selected"' : ''; + $img_options .= ''; + } + } + + // Grab list of potential images + $imagesetlist = filelist("{$phpbb_root_path}styles/$imageset_path/imageset"); + + $imagesetlist_options = ''; + foreach ($imagesetlist as $path => $img_ary) + { + foreach ($img_ary as $img) + { + $img = substr($path, 1) . (($path != '') ? '/' : '') . $img; + + $selected = (preg_match('#' . preg_quote($img) . '$#', $background_image)) ? ' selected="selected"' : ''; + $imagesetlist_options .= ''; + } + } + $imagesetlist_options = '' . $imagesetlist_options; + unset($imagesetlist); + + + adm_page_header($user->lang['EDIT_IMAGESET']); + +?> + +

lang['EDIT_IMAGESET']; ?>

+ +

lang['EDIT_IMAGESET_EXPLAIN']; ?>

+ +
"> + + + + + + +
lang['SELECT_CLASS']; ?>:  
+ + + + + + + + + + + + + + + + + + + + + +
lang['EDIT_IMAGESET']; ?>
img_lang, $$imgname)) . ' vspace="5" />' : ''; ?>
lang['IMAGE_PARAMETER']; ?>lang['IMAGE_VALUE']; ?>
lang['IMAGE']; ?>:
lang['DIMENSIONS']; ?>:
lang['DIMENSIONS_EXPLAIN']; ?>
X
  
+ +sql_query($sql); + + if (!($row = ($db->sql_fetchrow($result)))) + { + trigger_error($user->lang['NO_IMAGESET']); + } + $db->sql_freeresult($result); + + $imageset_name = $row['imageset_name']; + $imageset_path = $row['imageset_path']; + $imageset_copyright = $row['imageset_copyright']; + unset($row['imageset_name']); + unset($row['imageset_path']); + unset($row['imageset_copyright']); + unset($row['imageset_id']); + + $cfg = addslashes($imageset_name) . "\n"; + $cfg .= addslashes($imageset_copyright) . "\n"; + $cfg .= addslashes($config['version']); + + foreach (array_keys($row) as $key) + { + $cfg.= $key . '||' . str_replace("styles/$imageset_path/imageset/", '{PATH}', $row[$key]) . "\n"; + unset($row[$key]); + } + + $files = array(array('src' => "styles/$imageset_path/imageset/", 'prefix-' => "styles/$imageset_path/", 'prefix+' => false, 'exclude' => 'imageset.cfg')); + $data = array(array('src' => trim($cfg), 'prefix' => "imageset/imageset.cfg")); + + export('imageset', $imageset_id, $imageset_name, $imageset_path, $files, $data); + } + break; + + case 'delete': + if ($imageset_id) + { + $sql = 'SELECT imageset_id, imageset_name, imageset_path + FROM ' . STYLES_IMAGE_TABLE . " + WHERE imageset_id = $imageset_id"; + $result = $db->sql_query($sql); + + if (!(extract($db->sql_fetchrow($result)))) + { + trigger_error($user->lang['NO_IMAGESET']); + } + $db->sql_freeresult($result); + + remove('imageset', $imageset_id, $imageset_name, $imageset_path); + } + break; + + case 'add': + case 'details': + case 'install': + details('imageset', $mode, $action, $imageset_id); + exit; + break; + } + + + // Front page + front('imageset', array('details', 'delete', 'export')); + break; }