sql_query($sql)) { message_die(GENERAL_ERROR, "Could not insert theme data!", "Error", __LINE__, __FILE__, $sql); } message_die(GENERAL_MESSAGE, $lang['Theme_installed'], $lang['Success']); } else { $installable_themes = array(); if($dir = opendir($phpbb_root_dir . "templates/")) { while($sub_dir = readdir($dir)) { if($sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS") { if(file_exists($phpbb_root_dir . "templates/" . $sub_dir . "/theme_info.cfg")) { include($phpbb_root_dir . "templates/" . $sub_dir . "/theme_info.cfg"); for($i = 0; $i < count($$sub_dir); $i++) { $working_data = $$sub_dir; $style_name = $working_data[$i]['style_name']; $sql = "SELECT themes_id FROM " . THEMES_TABLE . " WHERE style_name = '$style_name'"; if(!$result = $db->sql_query($sql)) { message_die(GENREAL_ERROR, "Could not query themes table!", "Error", __LINE__, __FILE__, $sql); } if(!$db->sql_numrows($result)) { $installable_themes[] = $working_data[$i]; } } } } } $template->set_filenames(array( "body" => "admin/styles_addnew_body.tpl") ); $template->assign_vars(array( "L_STYLES_TITLE" => $lang['Styles_admin'], "L_STYLES_ADD_TEXT" => $lang['Styles_addnew_explain'], "L_STYLE" => $lang['Style'], "L_TEMPLATE" => $lang['Template'], "L_INSTALL" => $lang['Install'], "L_ACTION" => $lang['Action']) ); for($i = 0; $i < count($installable_themes); $i++) { $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars("styles", array( "STYLE_NAME" => $installable_themes[$i]['style_name'], "TEMPLATE_NAME" => $installable_themes[$i]['template_name'], "ROW_CLASS" => $row_class, "ROW_COLOR" => $row_color, "U_STYLES_INSTALL" => append_sid("admin_styles.$phpEx?mode=addnew&style=" . urlencode($installable_themes[$i]['style_name']) . "&install_to=" . urlencode($installable_themes[$i]['template_name']))) ); } $template->pparse("body"); } closedir($dir); } break; case "create": case "edit": break; case "export"; if($HTTP_POST_VARS['export_template']) { $template_name = $HTTP_POST_VARS['export_template']; $sql = "SELECT * FROM " . THEMES_TABLE . " WHERE template_name = '$template_name'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, "Could not get theme data for selected template", "Error", __LINE__, __FILE__, $sql); } $theme_rowset = $db->sql_fetchrowset($result); if(count($theme_rowset) == 0) { message_die(GENERAL_MESSAGE, $lang['No_themes'], $lang['Export_themes']); } $theme_data = ''; // Done this to prevent highlighting editors getting confused! @umask(0111); $fp = @fopen($phpbb_root_path . 'templates/' . $template_name . '/theme_info.cfg', 'w'); if( !$fp ) { // // Unable to open the file writeable do something here as an attempt // to get around that... // $s_hidden_fields = ''; $s_hidden_fields .= ''; $download_form = '
' . $s_hidden_fields; $template->set_filenames(array( "body" => "message_body.tpl") ); $template->assign_vars(array( "MESSAGE_TITLE" => $lang['Export_themes'], "MESSAGE_TEXT" => $lang['Download_theme_cfg'] . "
" . $download_form) ); $template->pparse('body'); exit(); } $result = @fputs($fp, $theme_data, strlen($theme_data)); fclose($fp); message_die(GENERAL_MESSAGE, $lang['Theme_info_saved'], $lang['Success']); } else if($HTTP_POST_VARS['send_file']) { header("Content-Type: text/x-delimtext; name=\"theme_info.cfg\""); header("Content-disposition: attachment; filename=theme_info.cfg"); if( get_magic_quotes_gpc() ) { $HTTP_POST_VARS['theme_info'] = stripslashes($HTTP_POST_VARS['theme_info']); } echo $HTTP_POST_VARS['theme_info']; } else { $template->set_filenames(array( "body" => "admin/styles_exporter.tpl") ); if($dir = opendir($phpbb_root_path . 'templates/')) { $s_template_select = ''; // // Set template files // $template->set_filenames(array( "confirm" => "confirm_body.tpl") ); $template->assign_vars(array( "MESSAGE_TITLE" => $lang['Confirm'], "MESSAGE_TEXT" => $lang['Confirm_delete_style'], "L_YES" => $lang['Yes'], "L_NO" => $lang['No'], "S_CONFIRM_ACTION" => append_sid("admin_styles.$phpEx"), "S_HIDDEN_FIELDS" => $hidden_fields) ); $template->pparse("confirm"); } else { // // The user has confirmed the delete. Remove the style, the style element names and update any users // who might be using this style // $sql = "DELETE FROM " . THEMES_TABLE . " WHERE themes_id = $style_id"; if(!$result = $db->sql_query($sql, BEGIN_TRANSACTION)) { message_die(GENERAL_ERROR, "Could not remove style data!", "Error", __LINE__, __FILE__, $sql); } $sql = "DELETE FROM " . THEMES_NAME_TABLE . " WHERE themes_id = $style_id"; // There may not be any theme name data so don't throw an error if the SQL dosan't work $db->sql_query($sql); $sql = "UPDATE " . USERS_TABLE . " SET user_style = " . $board_config['default_style'] . " WHERE user_style = $style_id"; if(!$result = $db->sql_query($sql, END_TRANSACTION)) { message_die(GENERAL_ERROR, "Could not update user style information", "Error", __LINE__, __FILE__, $sql); } message_die(GENERAL_MESSAGE, $lang['Style_removed'], $lang['Success']); } break; default: $sql = "SELECT themes_id, template_name, style_name FROM phpbb_themes ORDER BY template_name"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, "Could not get style information!", "Error", __LINE__, __FILE__, $sql); } $style_rowset = $db->sql_fetchrowset($result); $template->set_filenames(array( "body" => "admin/styles_list_body.tpl") ); $template->assign_vars(array("L_STYLES_TITLE" => $lang['Styles_admin'], "L_STYLES_TEXT" => $lang['Styles_explain'], "L_STYLE" => $lang['Style'], "L_TEMPLATE" => $lang['Template'], "L_EDIT" => $lang['Edit'], "L_DELETE" => $lang['Delete'])); for($i = 0; $i < count($style_rowset); $i++) { $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars("styles", array("ROW_CLASS" => $row_class, "ROW_COLOR" => $row_color, "STYLE_NAME" => $style_rowset[$i]['style_name'], "TEMPLATE_NAME" => $style_rowset[$i]['template_name'], "U_STYLES_EDIT" => append_sid("$PHP_SELF?mode=edit&style_id=" . $style_rowset[$i]['themes_id']), "U_STYLES_DELETE" => append_sid("$PHP_SELF?mode=delete&style_id=" . $style_rowset[$i]['themes_id']))); } $template->pparse("body"); break; } if(!$HTTP_POST_VARS['send_file']) { include('page_footer_admin.'.$phpEx); } ?>