【php开源代码栏目提醒】:网学会员为广大网友收集整理了,admin_styles.php,希望对大家有所帮助!
<?php
/***************************************************************************
* admin_styles.php
* -------------------
* begin : Thursday, Jul 12, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: admin_styles.php,v 1.27.2.17 2006/04/20 13:34:15 grahamje Exp $
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', 1);
if( !empty($setmodules) )
{
$file = basename(__FILE__);
$module['Styles']['Add_new'] = "$file?mode=addnew";
$module['Styles']['Create_new'] = "$file?mode=create";
$module['Styles']['Manage'] = $file;
$module['Styles']['Export'] = "$file?mode=export";
return;
}
//
// Load default header
//
//
// Check if the user has cancled a confirmation message.
//
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
$confirm = ( isset($HTTP_POST_VARS['confirm']) ) ? TRUE : FALSE;
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? TRUE : FALSE;
$no_page_header = (!empty($HTTP_POST_VARS['send_file']) || $cancel) ? TRUE : FALSE;
require('./pagestart.' . $phpEx);
$confirm = ( isset($HTTP_POST_VARS['confirm']) ) ? TRUE : FALSE;
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? TRUE : FALSE;
if ($cancel)
{
redirect('admin/' . append_sid("admin_styles.$phpEx", true));
}
if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
{
$mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
$mode = htmlspecialchars($mode);
}
else
{
$mode = "";
}
switch( $mode )
{
case "addnew":
$install_to = ( isset($HTTP_GET_VARS['install_to']) ) ? urldecode($HTTP_GET_VARS['install_to']) : $HTTP_POST_VARS['install_to'];
$style_name = ( isset($HTTP_GET_VARS['style']) ) ? urldecode($HTTP_GET_VARS['style']) : $HTTP_POST_VARS['style'];
if( isset($install_to) )
{
include($phpbb_root_path. "templates/" . basename($install_to) . "/theme_info.cfg");
$template_name = $$install_to;
$found = FALSE;
for($i = 0; $i < count($template_name) && !$found; $i++)
{
if( $template_name[$i]['style_name'] == $style_name )
{
while(list($key, $val) = each($template_name[$i]))
{
$db_fields[] = $key;
$db_values[] = str_replace("\'", "''" , $val);
}
}
}
$sql = "INSERT INTO " . THEMES_TABLE . " (";
for($i = 0; $i < count($db_fields); $i++)
{
$sql .= $db_fields[$i];
if($i != (count($db_fields) - 1))
{
$sql .= ", ";
}
}
$sql .= ") VALUES (";
for($i = 0; $i < count($db_values); $i++)
{
$sql .= "'" . $db_values[$i] . "'";
if($i != (count($db_values) - 1))
{
$sql .= ", ";
}
}
$sql .= ")";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not insert theme data!", "", __LINE__, __FILE__, $sql);
}
$message = $lang['Theme_installed'] . "<br /><br />" . sprintf($lang['Click_return_styleadmin'], "<a href=\"" . append_sid("admin_styles.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");
message_die(GENERAL_MESSAGE, $message);
}
else
{
$installable_themes = array();
if( $dir = @opendir($phpbb_root_path. "templates/") )
{
while( $sub_dir = @readdir($dir) )
{
if( !is_file(phpbb_realpath($phpbb_root_path . 'templates/' .$sub_dir)) && !is_link(phpbb_realpath($phpbb_root_path . 'templates/' .$sub_dir)) && $sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS" )
{
if( @file_exists(@phpbb_realpath($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg")) )
{
include($phpbb_root_path. "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 = '" . str_replace("\'", "''", $style_name) . "'";
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Could not query themes table!", "", __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(
"ROW_CLASS" => $row_class,
"ROW_COLOR" => "#" . $row_color,
"STYLE_NAME" => $installable_themes[$i]['style_name'],
"TEMPLATE_NAME" => $installable_themes[$i]['template_name'],
"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":
$submit = ( isset($HTTP_POST_VARS['submit']) ) ? TRUE : 0;
if( $submit )
{
//
// DAMN! Thats alot of data to validate...
//
$updated['style_name'] = $HTTP_POST_VARS['style_name'];
$updated['template_name'] = $HTTP_POST_VARS['template_name'];
$updated['head_stylesheet'] = $HTTP_POST_VARS['head_stylesheet'];
$updated['body_background'] = $HTTP_POST_VARS['body_background'];
$updated['body_bgcolor'] = $HTTP_POST_VARS['body_bgcolor'];
$updated['body_text'] = $HTTP_POST_VARS['body_text'];
$updated['body_link'] = $HTTP_POST_VARS['body_link'];
$updated['body_vlink'] = $HTTP_POST_VARS['body_vlink'];
$updated['body_alink'] = $HTTP_POST_VARS['body_alink'];
$updated['body_hlink'] = $HTTP_POST_VARS['body_hlink'];
$updated['tr_color1'] = $HTTP_POST_VARS['tr_color1'];
$updated_name['tr_color1_name'] = $HTTP_POST_VARS['tr_color1_name'];
$updated['tr_color2'] = $HTTP_POST_VARS['tr_color2'];
$updated_name['t
上一篇:
admin_smilies.php
下一篇:
陕西师范大学远程教育学院毕业论文