[ Index ] |
|
Code source de PHP NUKE 7.9 |
1 <?php 2 /*************************************************************************** 3 * admin_styles.php 4 * ------------------- 5 * begin : Thursday, Jul 12, 2001 6 * copyright : (C) 2001 The phpBB Group 7 * email : support@phpbb.com 8 * 9 * $Id: admin_styles.php,v 1.27.2.14 2005/03/17 17:33:30 acydburn Exp $ 10 * 11 * 12 ***************************************************************************/ 13 14 /*************************************************************************** 15 * 16 * This program is free software; you can redistribute it and/or modify 17 * it under the terms of the GNU General Public License as published by 18 * the Free Software Foundation; either version 2 of the License, or 19 * (at your option) any later version. 20 * 21 ***************************************************************************/ 22 23 define('IN_PHPBB', 1); 24 25 if( !empty($setmodules) ) 26 { 27 $file = basename(__FILE__); 28 $module['Styles']['Add_new'] = "$file?mode=addnew"; 29 $module['Styles']['Create_new'] = "$file?mode=create"; 30 $module['Styles']['Manage'] = "$file"; 31 $module['Styles']['Export'] = "$file?mode=export"; 32 return; 33 } 34 35 // 36 // Load default header 37 // 38 // 39 // Check if the user has cancled a confirmation message. 40 // 41 $phpbb_root_path = "./../"; 42 require ($phpbb_root_path . 'extension.inc'); 43 44 $confirm = ( isset($HTTP_POST_VARS['confirm']) ) ? TRUE : FALSE; 45 $cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? TRUE : FALSE; 46 47 $no_page_header = (!empty($HTTP_POST_VARS['send_file']) || $cancel) ? TRUE : FALSE; 48 49 require('./pagestart.' . $phpEx); 50 51 $confirm = ( isset($HTTP_POST_VARS['confirm']) ) ? TRUE : FALSE; 52 $cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? TRUE : FALSE; 53 54 if ($cancel) 55 { 56 $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', $_SERVER['SERVER_SOFTWARE']) ) ? 'Refresh: 0; URL=' : 'Location: '; 57 header($header_location . append_sid("admin_styles.$phpEx")); 58 exit; 59 } 60 61 if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) 62 { 63 $mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; 64 $mode = htmlspecialchars($mode); 65 } 66 else 67 { 68 $mode = ""; 69 } 70 71 switch( $mode ) 72 { 73 case "addnew": 74 $install_to = ( isset($HTTP_GET_VARS['install_to']) ) ? urldecode($HTTP_GET_VARS['install_to']) : $HTTP_POST_VARS['install_to']; 75 $style_name = ( isset($HTTP_GET_VARS['style']) ) ? urldecode($HTTP_GET_VARS['style']) : $HTTP_POST_VARS['style']; 76 77 if( isset($install_to) ) 78 { 79 80 include($phpbb_root_path. "templates/" . basename($install_to) . "/theme_info.cfg"); 81 82 $template_name = $$install_to; 83 $found = FALSE; 84 85 for($i = 0; $i < count($template_name) && !$found; $i++) 86 { 87 if( $template_name[$i]['style_name'] == $style_name ) 88 { 89 while(list($key, $val) = each($template_name[$i])) 90 { 91 $db_fields[] = $key; 92 $db_values[] = str_replace("\'", "''" , $val); 93 } 94 } 95 } 96 97 $sql = "INSERT INTO " . THEMES_TABLE . " ("; 98 99 for($i = 0; $i < count($db_fields); $i++) 100 { 101 $sql .= $db_fields[$i]; 102 if($i != (count($db_fields) - 1)) 103 { 104 $sql .= ", "; 105 } 106 107 } 108 109 $sql .= ") VALUES ("; 110 111 for($i = 0; $i < count($db_values); $i++) 112 { 113 $sql .= "'" . $db_values[$i] . "'"; 114 if($i != (count($db_values) - 1)) 115 { 116 $sql .= ", "; 117 } 118 } 119 $sql .= ")"; 120 121 if( !$result = $db->sql_query($sql) ) 122 { 123 message_die(GENERAL_ERROR, "Could not insert theme data!", "", __LINE__, __FILE__, $sql); 124 } 125 126 $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>"); 127 128 message_die(GENERAL_MESSAGE, $message); 129 } 130 else 131 { 132 133 $installable_themes = array(); 134 135 if( $dir = @opendir($phpbb_root_path. "templates/") ) 136 { 137 while( $sub_dir = @readdir($dir) ) 138 { 139 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" ) 140 { 141 if( @file_exists(@phpbb_realpath($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg")) ) 142 { 143 include($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg"); 144 145 for($i = 0; $i < count($$sub_dir); $i++) 146 { 147 $working_data = $$sub_dir; 148 149 $style_name = $working_data[$i]['style_name']; 150 151 $sql = "SELECT themes_id 152 FROM " . THEMES_TABLE . " 153 WHERE style_name = '" . str_replace("\'", "''", $style_name) . "'"; 154 if(!$result = $db->sql_query($sql)) 155 { 156 message_die(GENERAL_ERROR, "Could not query themes table!", "", __LINE__, __FILE__, $sql); 157 } 158 159 if(!$db->sql_numrows($result)) 160 { 161 $installable_themes[] = $working_data[$i]; 162 } 163 } 164 } 165 } 166 } 167 168 $template->set_filenames(array( 169 "body" => "admin/styles_addnew_body.tpl") 170 ); 171 172 $template->assign_vars(array( 173 "L_STYLES_TITLE" => $lang['Styles_admin'], 174 "L_STYLES_ADD_TEXT" => $lang['Styles_addnew_explain'], 175 "L_STYLE" => $lang['Style'], 176 "L_TEMPLATE" => $lang['Template'], 177 "L_INSTALL" => $lang['Install'], 178 "L_ACTION" => $lang['Action']) 179 ); 180 181 for($i = 0; $i < count($installable_themes); $i++) 182 { 183 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; 184 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; 185 186 $template->assign_block_vars("styles", array( 187 "ROW_CLASS" => $row_class, 188 "ROW_COLOR" => "#" . $row_color, 189 "STYLE_NAME" => $installable_themes[$i]['style_name'], 190 "TEMPLATE_NAME" => $installable_themes[$i]['template_name'], 191 192 "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']))) 193 ); 194 195 } 196 $template->pparse("body"); 197 198 } 199 closedir($dir); 200 } 201 break; 202 203 case "create": 204 case "edit": 205 $submit = ( isset($HTTP_POST_VARS['submit']) ) ? TRUE : 0; 206 207 if( $submit ) 208 { 209 // 210 // DAMN! Thats alot of data to validate... 211 // 212 $updated['style_name'] = $HTTP_POST_VARS['style_name']; 213 $updated['template_name'] = $HTTP_POST_VARS['template_name']; 214 $updated['head_stylesheet'] = $HTTP_POST_VARS['head_stylesheet']; 215 $updated['body_background'] = $HTTP_POST_VARS['body_background']; 216 $updated['body_bgcolor'] = $HTTP_POST_VARS['body_bgcolor']; 217 $updated['body_text'] = $HTTP_POST_VARS['body_text']; 218 $updated['body_link'] = $HTTP_POST_VARS['body_link']; 219 $updated['body_vlink'] = $HTTP_POST_VARS['body_vlink']; 220 $updated['body_alink'] = $HTTP_POST_VARS['body_alink']; 221 $updated['body_hlink'] = $HTTP_POST_VARS['body_hlink']; 222 $updated['tr_color1'] = $HTTP_POST_VARS['tr_color1']; 223 $updated_name['tr_color1_name'] = $HTTP_POST_VARS['tr_color1_name']; 224 $updated['tr_color2'] = $HTTP_POST_VARS['tr_color2']; 225 $updated_name['tr_color2_name'] = $HTTP_POST_VARS['tr_color2_name']; 226 $updated['tr_color3'] = $HTTP_POST_VARS['tr_color3']; 227 $updated_name['tr_color3_name'] = $HTTP_POST_VARS['tr_color3_name']; 228 $updated['tr_class1'] = $HTTP_POST_VARS['tr_class1']; 229 $updated_name['tr_class1_name'] = $HTTP_POST_VARS['tr_class1_name']; 230 $updated['tr_class2'] = $HTTP_POST_VARS['tr_class2']; 231 $updated_name['tr_class2_name'] = $HTTP_POST_VARS['tr_class2_name']; 232 $updated['tr_class3'] = $HTTP_POST_VARS['tr_class3']; 233 $updated_name['tr_class3_name'] = $HTTP_POST_VARS['tr_class3_name']; 234 $updated['th_color1'] = $HTTP_POST_VARS['th_color1']; 235 $updated_name['th_color1_name'] = $HTTP_POST_VARS['th_color1_name']; 236 $updated['th_color2'] = $HTTP_POST_VARS['th_color2']; 237 $updated_name['th_color2_name'] = $HTTP_POST_VARS['th_color2_name']; 238 $updated['th_color3'] = $HTTP_POST_VARS['th_color3']; 239 $updated_name['th_color3_name'] = $HTTP_POST_VARS['th_color3_name']; 240 $updated['th_class1'] = $HTTP_POST_VARS['th_class1']; 241 $updated_name['th_class1_name'] = $HTTP_POST_VARS['th_class1_name']; 242 $updated['th_class2'] = $HTTP_POST_VARS['th_class2']; 243 $updated_name['th_class2_name'] = $HTTP_POST_VARS['th_class2_name']; 244 $updated['th_class3'] = $HTTP_POST_VARS['th_class3']; 245 $updated_name['th_class3_name'] = $HTTP_POST_VARS['th_class3_name']; 246 $updated['td_color1'] = $HTTP_POST_VARS['td_color1']; 247 $updated_name['td_color1_name'] = $HTTP_POST_VARS['td_color1_name']; 248 $updated['td_color2'] = $HTTP_POST_VARS['td_color2']; 249 $updated_name['td_color2_name'] = $HTTP_POST_VARS['td_color2_name']; 250 $updated['td_color3'] = $HTTP_POST_VARS['td_color3']; 251 $updated_name['td_color3_name'] = $HTTP_POST_VARS['td_color3_name']; 252 $updated['td_class1'] = $HTTP_POST_VARS['td_class1']; 253 $updated_name['td_class1_name'] = $HTTP_POST_VARS['td_class1_name']; 254 $updated['td_class2'] = $HTTP_POST_VARS['td_class2']; 255 $updated_name['td_class2_name'] = $HTTP_POST_VARS['td_class2_name']; 256 $updated['td_class3'] = $HTTP_POST_VARS['td_class3']; 257 $updated_name['td_class3_name'] = $HTTP_POST_VARS['td_class3_name']; 258 $updated['fontface1'] = $HTTP_POST_VARS['fontface1']; 259 $updated_name['fontface1_name'] = $HTTP_POST_VARS['fontface1_name']; 260 $updated['fontface2'] = $HTTP_POST_VARS['fontface2']; 261 $updated_name['fontface2_name'] = $HTTP_POST_VARS['fontface2_name']; 262 $updated['fontface3'] = $HTTP_POST_VARS['fontface3']; 263 $updated_name['fontface3_name'] = $HTTP_POST_VARS['fontface3_name']; 264 $updated['fontsize1'] = intval($HTTP_POST_VARS['fontsize1']); 265 $updated_name['fontsize1_name'] = $HTTP_POST_VARS['fontsize1_name']; 266 $updated['fontsize2'] = intval($HTTP_POST_VARS['fontsize2']); 267 $updated_name['fontsize2_name'] = $HTTP_POST_VARS['fontsize2_name']; 268 $updated['fontsize3'] = intval($HTTP_POST_VARS['fontsize3']); 269 $updated_name['fontsize3_name'] = $HTTP_POST_VARS['fontsize3_name']; 270 $updated['fontcolor1'] = $HTTP_POST_VARS['fontcolor1']; 271 $updated_name['fontcolor1_name'] = $HTTP_POST_VARS['fontcolor1_name']; 272 $updated['fontcolor2'] = $HTTP_POST_VARS['fontcolor2']; 273 $updated_name['fontcolor2_name'] = $HTTP_POST_VARS['fontcolor2_name']; 274 $updated['fontcolor3'] = $HTTP_POST_VARS['fontcolor3']; 275 $updated_name['fontcolor3_name'] = $HTTP_POST_VARS['fontcolor3_name']; 276 $updated['span_class1'] = $HTTP_POST_VARS['span_class1']; 277 $updated_name['span_class1_name'] = $HTTP_POST_VARS['span_class1_name']; 278 $updated['span_class2'] = $HTTP_POST_VARS['span_class2']; 279 $updated_name['span_class2_name'] = $HTTP_POST_VARS['span_class2_name']; 280 $updated['span_class3'] = $HTTP_POST_VARS['span_class3']; 281 $updated_name['span_class3_name'] = $HTTP_POST_VARS['span_class3_name']; 282 $style_id = intval($HTTP_POST_VARS['style_id']); 283 // 284 // Wheeeew! Thank heavens for copy and paste and search and replace :D 285 // 286 287 if($mode == "edit") 288 { 289 $sql = "UPDATE " . THEMES_TABLE . " SET "; 290 $count = 0; 291 292 while(list($key, $val) = each($updated)) 293 { 294 if($count != 0) 295 { 296 $sql .= ", "; 297 } 298 299 // 300 // I don't like this but it'll keep MSSQL from throwing 301 // an error and save me alot of typing 302 // 303 $sql .= ( stristr($key, "fontsize") ) ? "$key = $val" : "$key = '" . str_replace("\'", "''", $val) . "'"; 304 305 $count++; 306 } 307 308 $sql .= " WHERE themes_id = '$style_id'"; 309 310 if(!$result = $db->sql_query($sql)) 311 { 312 message_die(GENERAL_ERROR, "Could not update themes table!", "", __LINE__, __FILE__, $sql); 313 } 314 315 // 316 // Check if there's a names table entry for this style 317 // 318 $sql = "SELECT themes_id 319 FROM " . THEMES_NAME_TABLE . " 320 WHERE themes_id = '$style_id'"; 321 if(!$result = $db->sql_query($sql)) 322 { 323 message_die(GENERAL_ERROR, "Could not get data from themes_name table", "", __LINE__, __FILE__, $sql); 324 } 325 326 if($db->sql_numrows($result) > 0) 327 { 328 $sql = "UPDATE " . THEMES_NAME_TABLE . " 329 SET "; 330 $count = 0; 331 while(list($key, $val) = each($updated_name)) 332 { 333 if($count != 0) 334 { 335 $sql .= ", "; 336 } 337 338 $sql .= "$key = '$val'"; 339 340 $count++; 341 } 342 343 $sql .= " WHERE themes_id = '$style_id'"; 344 } 345 else 346 { 347 // 348 // Nope, no names entry so we create a new one. 349 // 350 $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (themes_id, "; 351 while(list($key, $val) = each($updated_name)) 352 { 353 $fields[] = $key; 354 $vals[] = str_replace("\'", "''", $val); 355 } 356 357 for($i = 0; $i < count($fields); $i++) 358 { 359 if($i > 0) 360 { 361 $sql .= ", "; 362 } 363 $sql .= $fields[$i]; 364 } 365 366 $sql .= ") VALUES ($style_id, "; 367 for($i = 0; $i < count($vals); $i++) 368 { 369 if($i > 0) 370 { 371 $sql .= ", "; 372 } 373 $sql .= "'" . $vals[$i] . "'"; 374 } 375 376 $sql .= ")"; 377 } 378 379 if(!$result = $db->sql_query($sql)) 380 { 381 message_die(GENERAL_ERROR, "Could not update themes name table!", "", __LINE__, __FILE__, $sql); 382 } 383 384 $message = $lang['Theme_updated'] . "<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>"); 385 386 message_die(GENERAL_MESSAGE, $message); 387 } 388 else 389 { 390 // 391 // First, check if we already have a style by this name 392 // 393 $sql = "SELECT themes_id 394 FROM " . THEMES_TABLE . " 395 WHERE style_name = '" . str_replace("\'", "''", $updated['style_name']) . "'"; 396 if(!$result = $db->sql_query($sql)) 397 { 398 message_die(GENERAL_ERROR, "Could not query themes table", "", __LINE__, __FILE__, $sql); 399 } 400 401 if($db->sql_numrows($result)) 402 { 403 message_die(GENERAL_ERROR, $lang['Style_exists'], $lang['Error']); 404 } 405 406 while(list($key, $val) = each($updated)) 407 { 408 $field_names[] = $key; 409 410 if(stristr($key, "fontsize")) 411 { 412 $values[] = "$val"; 413 } 414 else 415 { 416 $values[] = "'" . str_replace("\'", "''", $val) . "'"; 417 } 418 } 419 420 $sql = "INSERT 421 INTO " . THEMES_TABLE . " ("; 422 for($i = 0; $i < count($field_names); $i++) 423 { 424 if($i != 0) 425 { 426 $sql .= ", "; 427 } 428 $sql .= $field_names[$i]; 429 } 430 431 $sql .= ") VALUES ("; 432 for($i = 0; $i < count($values); $i++) 433 { 434 if($i != 0) 435 { 436 $sql .= ", "; 437 } 438 $sql .= $values[$i]; 439 } 440 $sql .= ")"; 441 442 if(!$result = $db->sql_query($sql)) 443 { 444 message_die(GENERAL_ERROR, "Could not update themes table!", "", __LINE__, __FILE__, $sql); 445 } 446 447 $style_id = $db->sql_nextid(); 448 449 // 450 // Insert names data 451 // 452 $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (themes_id, "; 453 while(list($key, $val) = each($updated_name)) 454 { 455 $fields[] = $key; 456 $vals[] = $val; 457 } 458 459 for($i = 0; $i < count($fields); $i++) 460 { 461 if($i > 0) 462 { 463 $sql .= ", "; 464 } 465 $sql .= $fields[$i]; 466 } 467 468 $sql .= ") VALUES ($style_id, "; 469 for($i = 0; $i < count($vals); $i++) 470 { 471 if($i > 0) 472 { 473 $sql .= ", "; 474 } 475 $sql .= "'" . $vals[$i] . "'"; 476 } 477 478 $sql .= ")"; 479 480 if(!$result = $db->sql_query($sql)) 481 { 482 message_die(GENERAL_ERROR, "Could not insert themes name table!", "", __LINE__, __FILE__, $sql); 483 } 484 485 $message = $lang['Theme_created'] . "<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>"); 486 487 message_die(GENERAL_MESSAGE, $message); 488 } 489 } 490 else 491 { 492 if($mode == "edit") 493 { 494 $themes_title = $lang['Edit_theme']; 495 $themes_explain = $lang['Edit_theme_explain']; 496 497 $style_id = intval($HTTP_GET_VARS['style_id']); 498 499 $selected_names = array(); 500 $selected_values = array(); 501 // 502 // Fetch the Theme Info from the db 503 // 504 $sql = "SELECT * 505 FROM " . THEMES_TABLE . " 506 WHERE themes_id = $style_id"; 507 if(!$result = $db->sql_query($sql)) 508 { 509 message_die(GENERAL_ERROR, "Could not get data from themes table", "", __LINE__, __FILE__, $sql); 510 } 511 512 if ( $selected_values = $db->sql_fetchrow($result) ) 513 { 514 while(list($key, $val) = @each($selected_values)) 515 { 516 $selected[$key] = $val; 517 } 518 } 519 520 // 521 // Fetch the Themes Name data 522 // 523 $sql = "SELECT * 524 FROM " . THEMES_NAME_TABLE . " 525 WHERE themes_id = '$style_id'"; 526 if(!$result = $db->sql_query($sql)) 527 { 528 message_die(GENERAL_ERROR, "Could not get data from themes name table", "", __LINE__, __FILE__, $sql); 529 } 530 531 if ( $selected_names = $db->sql_fetchrow($result) ) 532 { 533 while(list($key, $val) = @each($selected_names)) 534 { 535 $selected[$key] = $val; 536 } 537 } 538 539 $s_hidden_fields = '<input type="hidden" name="style_id" value="' . $style_id . '" />'; 540 } 541 else 542 { 543 $themes_title = $lang['Create_theme']; 544 $themes_explain = $lang['Create_theme_explain']; 545 } 546 547 $template->set_filenames(array( 548 "body" => "admin/styles_edit_body.tpl") 549 ); 550 551 if( $dir = @opendir($phpbb_root_path . 'templates/') ) 552 { 553 $s_template_select = '<select name="template_name">'; 554 while( $file = @readdir($dir) ) 555 { 556 if( !is_file(phpbb_realpath($phpbb_root_path . 'templates/' . $file)) && !is_link(phpbb_realpath($phpbb_root_path . 'templates/' . $file)) && $file != "." && $file != ".." && $file != "CVS" ) 557 { 558 if($file == $selected['template_name']) 559 { 560 $s_template_select .= '<option value="' . $file . '" selected="selected">' . $file . "</option>\n"; 561 } 562 else 563 { 564 $s_template_select .= '<option value="' . $file . '">' . $file . "</option>\n"; 565 } 566 } 567 } 568 $s_template_select .= '</select>'; 569 } 570 else 571 { 572 message_die(GENERAL_MESSAGE, $lang['No_template_dir']); 573 } 574 575 $s_hidden_fields .= '<input type="hidden" name="mode" value="' . $mode . '" />'; 576 577 $template->assign_vars(array( 578 "L_THEMES_TITLE" => $themes_title, 579 "L_THEMES_EXPLAIN" => $themes_explain, 580 "L_THEME_NAME" => $lang['Theme_name'], 581 "L_TEMPLATE" => $lang['Template'], 582 "L_THEME_SETTINGS" => $lang['Theme_settings'], 583 "L_THEME_ELEMENT" => $lang['Theme_element'], 584 "L_SIMPLE_NAME" => $lang['Simple_name'], 585 "L_VALUE" => $lang['Value'], 586 "L_STYLESHEET" => $lang['Stylesheet'], 587 "L_BACKGROUND_IMAGE" => $lang['Background_image'], 588 "L_BACKGROUND_COLOR" => $lang['Background_color'], 589 "L_BODY_TEXT_COLOR" => $lang['Text_color'], 590 "L_BODY_LINK_COLOR" => $lang['Link_color'], 591 "L_BODY_VLINK_COLOR" => $lang['VLink_color'], 592 "L_BODY_ALINK_COLOR" => $lang['ALink_color'], 593 "L_BODY_HLINK_COLOR" => $lang['HLink_color'], 594 "L_TR_COLOR1" => $lang['Tr_color1'], 595 "L_TR_COLOR2" => $lang['Tr_color2'], 596 "L_TR_COLOR3" => $lang['Tr_color3'], 597 "L_TR_CLASS1" => $lang['Tr_class1'], 598 "L_TR_CLASS2" => $lang['Tr_class2'], 599 "L_TR_CLASS3" => $lang['Tr_class3'], 600 "L_TH_COLOR1" => $lang['Th_color1'], 601 "L_TH_COLOR2" => $lang['Th_color2'], 602 "L_TH_COLOR3" => $lang['Th_color3'], 603 "L_TH_CLASS1" => $lang['Th_class1'], 604 "L_TH_CLASS2" => $lang['Th_class2'], 605 "L_TH_CLASS3" => $lang['Th_class3'], 606 "L_TD_COLOR1" => $lang['Td_color1'], 607 "L_TD_COLOR2" => $lang['Td_color2'], 608 "L_TD_COLOR3" => $lang['Td_color3'], 609 "L_TD_CLASS1" => $lang['Td_class1'], 610 "L_TD_CLASS2" => $lang['Td_class2'], 611 "L_TD_CLASS3" => $lang['Td_class3'], 612 "L_FONTFACE_1" => $lang['fontface1'], 613 "L_FONTFACE_2" => $lang['fontface2'], 614 "L_FONTFACE_3" => $lang['fontface3'], 615 "L_FONTSIZE_1" => $lang['fontsize1'], 616 "L_FONTSIZE_2" => $lang['fontsize2'], 617 "L_FONTSIZE_3" => $lang['fontsize3'], 618 "L_FONTCOLOR_1" => $lang['fontcolor1'], 619 "L_FONTCOLOR_2" => $lang['fontcolor2'], 620 "L_FONTCOLOR_3" => $lang['fontcolor3'], 621 "L_SPAN_CLASS_1" => $lang['span_class1'], 622 "L_SPAN_CLASS_2" => $lang['span_class2'], 623 "L_SPAN_CLASS_3" => $lang['span_class3'], 624 "L_SAVE_SETTINGS" => $lang['Save_Settings'], 625 "THEME_NAME" => $selected['style_name'], 626 "HEAD_STYLESHEET" => $selected['head_stylesheet'], 627 "BODY_BACKGROUND" => $selected['body_background'], 628 "BODY_BGCOLOR" => $selected['body_bgcolor'], 629 "BODY_TEXT_COLOR" => $selected['body_text'], 630 "BODY_LINK_COLOR" => $selected['body_link'], 631 "BODY_VLINK_COLOR" => $selected['body_vlink'], 632 "BODY_ALINK_COLOR" => $selected['body_alink'], 633 "BODY_HLINK_COLOR" => $selected['body_hlink'], 634 "TR_COLOR1" => $selected['tr_color1'], 635 "TR_COLOR2" => $selected['tr_color2'], 636 "TR_COLOR3" => $selected['tr_color3'], 637 "TR_CLASS1" => $selected['tr_class1'], 638 "TR_CLASS2" => $selected['tr_class2'], 639 "TR_CLASS3" => $selected['tr_class3'], 640 "TH_COLOR1" => $selected['th_color1'], 641 "TH_COLOR2" => $selected['th_color2'], 642 "TH_COLOR3" => $selected['th_color3'], 643 "TH_CLASS1" => $selected['th_class1'], 644 "TH_CLASS2" => $selected['th_class2'], 645 "TH_CLASS3" => $selected['th_class3'], 646 "TD_COLOR1" => $selected['td_color1'], 647 "TD_COLOR2" => $selected['td_color2'], 648 "TD_COLOR3" => $selected['td_color3'], 649 "TD_CLASS1" => $selected['td_class1'], 650 "TD_CLASS2" => $selected['td_class2'], 651 "TD_CLASS3" => $selected['td_class3'], 652 "FONTFACE1" => $selected['fontface1'], 653 "FONTFACE2" => $selected['fontface2'], 654 "FONTFACE3" => $selected['fontface3'], 655 "FONTSIZE1" => $selected['fontsize1'], 656 "FONTSIZE2" => $selected['fontsize2'], 657 "FONTSIZE3" => $selected['fontsize3'], 658 "FONTCOLOR1" => $selected['fontcolor1'], 659 "FONTCOLOR2" => $selected['fontcolor2'], 660 "FONTCOLOR3" => $selected['fontcolor3'], 661 "SPAN_CLASS1" => $selected['span_class1'], 662 "SPAN_CLASS2" => $selected['span_class2'], 663 "SPAN_CLASS3" => $selected['span_class3'], 664 665 "TR_COLOR1_NAME" => $selected['tr_color1_name'], 666 "TR_COLOR2_NAME" => $selected['tr_color2_name'], 667 "TR_COLOR3_NAME" => $selected['tr_color3_name'], 668 "TR_CLASS1_NAME" => $selected['tr_class1_name'], 669 "TR_CLASS2_NAME" => $selected['tr_class2_name'], 670 "TR_CLASS3_NAME" => $selected['tr_class3_name'], 671 "TH_COLOR1_NAME" => $selected['th_color1_name'], 672 "TH_COLOR2_NAME" => $selected['th_color2_name'], 673 "TH_COLOR3_NAME" => $selected['th_color3_name'], 674 "TH_CLASS1_NAME" => $selected['th_class1_name'], 675 "TH_CLASS2_NAME" => $selected['th_class2_name'], 676 "TH_CLASS3_NAME" => $selected['th_class3_name'], 677 "TD_COLOR1_NAME" => $selected['td_color1_name'], 678 "TD_COLOR2_NAME" => $selected['td_color2_name'], 679 "TD_COLOR3_NAME" => $selected['td_color3_name'], 680 "TD_CLASS1_NAME" => $selected['td_class1_name'], 681 "TD_CLASS2_NAME" => $selected['td_class2_name'], 682 "TD_CLASS3_NAME" => $selected['td_class3_name'], 683 "FONTFACE1_NAME" => $selected['fontface1_name'], 684 "FONTFACE2_NAME" => $selected['fontface2_name'], 685 "FONTFACE3_NAME" => $selected['fontface3_name'], 686 "FONTSIZE1_NAME" => $selected['fontsize1_name'], 687 "FONTSIZE2_NAME" => $selected['fontsize2_name'], 688 "FONTSIZE3_NAME" => $selected['fontsize3_name'], 689 "FONTCOLOR1_NAME" => $selected['fontcolor1_name'], 690 "FONTCOLOR2_NAME" => $selected['fontcolor2_name'], 691 "FONTCOLOR3_NAME" => $selected['fontcolor3_name'], 692 "SPAN_CLASS1_NAME" => $selected['span_class1_name'], 693 "SPAN_CLASS2_NAME" => $selected['span_class2_name'], 694 "SPAN_CLASS3_NAME" => $selected['span_class3_name'], 695 696 "S_THEME_ACTION" => append_sid("admin_styles.$phpEx"), 697 "S_TEMPLATE_SELECT" => $s_template_select, 698 "S_HIDDEN_FIELDS" => $s_hidden_fields) 699 ); 700 701 $template->pparse("body"); 702 } 703 break; 704 705 case "export"; 706 if($HTTP_POST_VARS['export_template']) 707 { 708 $template_name = $HTTP_POST_VARS['export_template']; 709 710 $sql = "SELECT * 711 FROM " . THEMES_TABLE . " 712 WHERE template_name = '" . str_replace("\'", "''", $template_name) . "'"; 713 if(!$result = $db->sql_query($sql)) 714 { 715 message_die(GENERAL_ERROR, "Could not get theme data for selected template", "", __LINE__, __FILE__, $sql); 716 } 717 718 $theme_rowset = $db->sql_fetchrowset($result); 719 720 if( count($theme_rowset) == 0 ) 721 { 722 message_die(GENERAL_MESSAGE, $lang['No_themes']); 723 } 724 725 $theme_data = '<?php'."\n\n"; 726 $theme_data .= "//\n// phpBB 2.x auto-generated theme config file for $template_name\n// Do not change anything in this file!\n//\n\n"; 727 728 for($i = 0; $i < count($theme_rowset); $i++) 729 { 730 while(list($key, $val) = each($theme_rowset[$i])) 731 { 732 if(!intval($key) && $key != "0" && $key != "themes_id") 733 { 734 $theme_data .= '$' . $template_name . "[$i]['$key'] = \"" . addslashes($val) . "\";\n"; 735 } 736 } 737 $theme_data .= "\n"; 738 } 739 740 $theme_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused! 741 742 @umask(0111); 743 744 $fp = @fopen($phpbb_root_path . 'templates/' . basename($template_name) . '/theme_info.cfg', 'w'); 745 746 if( !$fp ) 747 { 748 // 749 // Unable to open the file writeable do something here as an attempt 750 // to get around that... 751 // 752 $s_hidden_fields = '<input type="hidden" name="theme_info" value="' . htmlspecialchars($theme_data) . '" />'; 753 $s_hidden_fields .= '<input type="hidden" name="send_file" value="1" /><input type="hidden" name="mode" value="export" />'; 754 755 $download_form = '<form action="' . append_sid("admin_styles.$phpEx") . '" method="post"><input class="mainoption" type="submit" name="submit" value="' . $lang['Download'] . '" />' . $s_hidden_fields; 756 757 $template->set_filenames(array( 758 "body" => "message_body.tpl") 759 ); 760 761 $template->assign_vars(array( 762 "MESSAGE_TITLE" => $lang['Export_themes'], 763 "MESSAGE_TEXT" => $lang['Download_theme_cfg'] . "<br /><br />" . $download_form) 764 ); 765 766 $template->pparse('body'); 767 exit(); 768 } 769 770 $result = @fputs($fp, $theme_data, strlen($theme_data)); 771 fclose($fp); 772 773 $message = $lang['Theme_info_saved'] . "<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>"); 774 775 message_die(GENERAL_MESSAGE, $message); 776 777 } 778 else if($HTTP_POST_VARS['send_file']) 779 { 780 781 header("Content-Type: text/x-delimtext; name=\"theme_info.cfg\""); 782 header("Content-disposition: attachment; filename=theme_info.cfg"); 783 784 echo stripslashes($HTTP_POST_VARS['theme_info']); 785 } 786 else 787 { 788 $template->set_filenames(array( 789 "body" => "admin/styles_exporter.tpl") 790 ); 791 792 if( $dir = @opendir($phpbb_root_path . 'templates/') ) 793 { 794 $s_template_select = '<select name="export_template">'; 795 while( $file = @readdir($dir) ) 796 { 797 if( !is_file(phpbb_realpath($phpbb_root_path . 'templates/' . $file)) && !is_link(phpbb_realpath($phpbb_root_path . 'templates/' .$file)) && $file != "." && $file != ".." && $file != "CVS" ) 798 { 799 $s_template_select .= '<option value="' . $file . '">' . $file . "</option>\n"; 800 } 801 } 802 $s_template_select .= '</select>'; 803 } 804 else 805 { 806 message_die(GENERAL_MESSAGE, $lang['No_template_dir']); 807 } 808 809 $template->assign_vars(array( 810 "L_STYLE_EXPORTER" => $lang['Export_themes'], 811 "L_EXPORTER_EXPLAIN" => $lang['Export_explain'], 812 "L_TEMPLATE_SELECT" => $lang['Select_template'], 813 "L_SUBMIT" => $lang['Submit'], 814 815 "S_EXPORTER_ACTION" => append_sid("admin_styles.$phpEx?mode=export"), 816 "S_TEMPLATE_SELECT" => $s_template_select) 817 ); 818 819 $template->pparse("body"); 820 821 } 822 break; 823 824 case "delete": 825 $style_id = ( isset($HTTP_GET_VARS['style_id']) ) ? intval($HTTP_GET_VARS['style_id']) : intval($HTTP_POST_VARS['style_id']); 826 827 if( !$confirm ) 828 { 829 if($style_id == $board_config['default_style']) 830 { 831 message_die(GENERAL_MESSAGE, $lang['Cannot_remove_style']); 832 } 833 834 $hidden_fields = '<input type="hidden" name="mode" value="'.$mode.'" /><input type="hidden" name="style_id" value="'.$style_id.'" />'; 835 836 // 837 // Set template files 838 // 839 $template->set_filenames(array( 840 "confirm" => "confirm_body.tpl") 841 ); 842 843 $template->assign_vars(array( 844 "MESSAGE_TITLE" => $lang['Confirm'], 845 "MESSAGE_TEXT" => $lang['Confirm_delete_style'], 846 847 "L_YES" => $lang['Yes'], 848 "L_NO" => $lang['No'], 849 850 "S_CONFIRM_ACTION" => append_sid("admin_styles.$phpEx"), 851 "S_HIDDEN_FIELDS" => $hidden_fields) 852 ); 853 854 $template->pparse("confirm"); 855 856 } 857 else 858 { 859 // 860 // The user has confirmed the delete. Remove the style, the style element 861 // names and update any users who might be using this style 862 // 863 $sql = "DELETE FROM " . THEMES_TABLE . " 864 WHERE themes_id = '$style_id'"; 865 if(!$result = $db->sql_query($sql, BEGIN_TRANSACTION)) 866 { 867 message_die(GENERAL_ERROR, "Could not remove style data!", "", __LINE__, __FILE__, $sql); 868 } 869 870 // 871 // There may not be any theme name data so don't throw an error 872 // if the SQL dosan't work 873 // 874 $sql = "DELETE FROM " . THEMES_NAME_TABLE . " 875 WHERE themes_id = '$style_id'"; 876 $db->sql_query($sql); 877 878 $sql = "UPDATE " . USERS_TABLE . " 879 SET user_style = " . $board_config['default_style'] . " 880 WHERE user_style = '$style_id'"; 881 if(!$result = $db->sql_query($sql, END_TRANSACTION)) 882 { 883 message_die(GENERAL_ERROR, "Could not update user style information", "", __LINE__, __FILE__, $sql); 884 } 885 886 $message = $lang['Style_removed'] . "<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>"); 887 888 message_die(GENERAL_MESSAGE, $message); 889 } 890 break; 891 892 default: 893 894 $sql = "SELECT themes_id, template_name, style_name 895 FROM " . THEMES_TABLE . " 896 ORDER BY template_name"; 897 if(!$result = $db->sql_query($sql)) 898 { 899 message_die(GENERAL_ERROR, "Could not get style information!", "", __LINE__, __FILE__, $sql); 900 } 901 902 $style_rowset = $db->sql_fetchrowset($result); 903 904 $template->set_filenames(array( 905 "body" => "admin/styles_list_body.tpl") 906 ); 907 908 $template->assign_vars(array( 909 "L_STYLES_TITLE" => $lang['Styles_admin'], 910 "L_STYLES_TEXT" => $lang['Styles_explain'], 911 "L_STYLE" => $lang['Style'], 912 "L_TEMPLATE" => $lang['Template'], 913 "L_EDIT" => $lang['Edit'], 914 "L_DELETE" => $lang['Delete']) 915 ); 916 917 for($i = 0; $i < count($style_rowset); $i++) 918 { 919 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; 920 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; 921 922 $template->assign_block_vars("styles", array( 923 "ROW_CLASS" => $row_class, 924 "ROW_COLOR" => $row_color, 925 "STYLE_NAME" => $style_rowset[$i]['style_name'], 926 "TEMPLATE_NAME" => $style_rowset[$i]['template_name'], 927 928 "U_STYLES_EDIT" => append_sid("admin_styles.$phpEx?mode=edit&style_id=" . $style_rowset[$i]['themes_id']), 929 "U_STYLES_DELETE" => append_sid("admin_styles.$phpEx?mode=delete&style_id=" . $style_rowset[$i]['themes_id'])) 930 ); 931 } 932 933 $template->pparse("body"); 934 break; 935 } 936 937 if (empty($HTTP_POST_VARS['send_file'])) 938 { 939 include('./page_footer_admin.'.$phpEx); 940 } 941 942 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 11:11:59 2007 | par Balluche grâce à PHPXref 0.7 |