[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/administrator/components/com_config/ -> admin.config.php (source)

   1  <?php
   2  /**
   3  * @version $Id: admin.config.php 7424 2007-05-17 15:56:10Z robs $
   4  * @package Joomla
   5  * @subpackage Config
   6  * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
   7  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
   8  * Joomla! is free software. This version may have been modified pursuant
   9  * to the GNU General Public License, and as distributed it includes or
  10  * is derivative of works licensed under the GNU General Public License or
  11  * other free or open source software licenses.
  12  * See COPYRIGHT.php for copyright notices and details.
  13  */
  14  
  15  // no direct access
  16  defined( '_VALID_MOS' ) or die( 'Restricted access' );
  17  
  18  if (!$acl->acl_check( 'administration', 'config', 'users', $my->usertype )) {
  19      mosRedirect( 'index2.php?', _NOT_AUTH );
  20  }
  21  
  22  require_once( $mainframe->getPath( 'class' ) );
  23  require_once( $mainframe->getPath( 'admin_html' ) );
  24  
  25  switch ( $task ) {
  26      case 'apply':
  27      case 'save':
  28          saveconfig( $task );
  29          break;
  30  
  31      case 'cancel':
  32          mosRedirect( 'index2.php' );
  33          break;
  34  
  35      default:
  36          showconfig( $option );
  37          break;
  38  }
  39  
  40  /**
  41   * Show the configuration edit form
  42   * @param string The URL option
  43   */
  44  function showconfig( $option) {
  45      global $database, $mosConfig_absolute_path, $mosConfig_editor;
  46  
  47      $row = new mosConfig();
  48      $row->bindGlobals();
  49  
  50      // compile list of the languages
  51      $langs         = array();
  52      $menuitems     = array();
  53      $lists         = array();
  54  
  55  // PRE-PROCESS SOME LISTS
  56  
  57      // -- Languages --
  58  
  59      if ($handle = opendir( $mosConfig_absolute_path . '/language/' )) {
  60          $i=0;
  61          while (false !== ($file = readdir( $handle ))) {
  62              if (!strcasecmp(substr($file,-4),".php") && $file != "." && $file != ".." && strcasecmp(substr($file,-11),".ignore.php")) {
  63                  $langs[] = mosHTML::makeOption( substr($file,0,-4) );
  64              }
  65          }
  66      }
  67  
  68      // sort list of languages
  69      sort( $langs );
  70      reset( $langs );
  71  
  72      // -- Editors --
  73  
  74      // compile list of the editors
  75      $query = "SELECT element AS value, name AS text"
  76      . "\n FROM #__mambots"
  77      . "\n WHERE folder = 'editors'"
  78      . "\n AND published = 1"
  79      . "\n ORDER BY ordering, name"
  80      ;
  81      $database->setQuery( $query );
  82      $edits = $database->loadObjectList();
  83  
  84      // -- Show/Hide --
  85  
  86      $show_hide = array(
  87          mosHTML::makeOption( 1, 'Hide' ),
  88          mosHTML::makeOption( 0, 'Show' ),
  89      );
  90  
  91      $show_hide_r = array(
  92          mosHTML::makeOption( 0, 'Hide' ),
  93          mosHTML::makeOption( 1, 'Show' ),
  94      );
  95  
  96      // -- menu items --
  97  
  98      $query = "SELECT id AS value, name AS text FROM #__menu"
  99      . "\n WHERE ( type='content_section' OR type='components' OR type='content_typed' )"
 100      . "\n AND published = 1"
 101      . "\n AND access = 0"
 102      . "\n ORDER BY name"
 103      ;
 104      $database->setQuery( $query );
 105      $menuitems = array_merge( $menuitems, $database->loadObjectList() );
 106  
 107  
 108  // SITE SETTINGS
 109  
 110      $lists['offline'] = mosHTML::yesnoRadioList( 'config_offline', 'class="inputbox"', $row->config_offline );
 111  
 112      if ( !$row->config_editor ) {
 113          $row->config_editor = '';
 114      }
 115      // build the html select list
 116      $lists['editor'] = mosHTML::selectList( $edits, 'config_editor', 'class="inputbox" size="1"', 'value', 'text', $row->config_editor );
 117  
 118      $listLimit = array(
 119          mosHTML::makeOption( 5, 5 ),
 120          mosHTML::makeOption( 10, 10 ),
 121          mosHTML::makeOption( 15, 15 ),
 122          mosHTML::makeOption( 20, 20 ),
 123          mosHTML::makeOption( 25, 25 ),
 124          mosHTML::makeOption( 30, 30 ),
 125          mosHTML::makeOption( 50, 50 ),
 126      );
 127  
 128      $lists['list_limit'] = mosHTML::selectList( $listLimit, 'config_list_limit', 'class="inputbox" size="1"', 'value', 'text', ( $row->config_list_limit ? $row->config_list_limit : 50 ) );
 129  
 130      $lists['frontend_login'] = mosHTML::yesnoRadioList( 'config_frontend_login', 'class="inputbox"', $row->config_frontend_login );
 131  
 132  // DEBUG
 133  
 134      $lists['debug'] = mosHTML::yesnoRadioList( 'config_debug', 'class="inputbox"', $row->config_debug );
 135  
 136  // DATABASE SETTINGS
 137  
 138  
 139  // SERVER SETTINGS
 140      $lists['gzip'] = mosHTML::yesnoRadioList( 'config_gzip', 'class="inputbox"', $row->config_gzip );
 141  
 142      $session = array(
 143          mosHTML::makeOption( 0, 'Level 3 Security- Default & Highest' ),
 144          mosHTML::makeOption( 1, 'Level 2 Security - Allow for proxy IPs' ),
 145          mosHTML::makeOption( 2, 'Level 1 Security - Backward Compatibility' )
 146      );
 147  
 148      $lists['session_type'] = mosHTML::selectList( $session, 'config_session_type', 'class="inputbox" size="1"', 'value', 'text', $row->config_session_type );
 149  
 150      $errors = array(
 151          mosHTML::makeOption( -1, 'System Default' ),
 152          mosHTML::makeOption( 0, 'None' ),
 153          mosHTML::makeOption( E_ERROR|E_WARNING|E_PARSE, 'Simple' ),
 154          mosHTML::makeOption( E_ALL , 'Maximum' )
 155      );
 156  
 157      $lists['error_reporting'] = mosHTML::selectList( $errors, 'config_error_reporting', 'class="inputbox" size="1"', 'value', 'text', $row->config_error_reporting );
 158  
 159      $lists['admin_expired'] = mosHTML::yesnoRadioList( 'config_admin_expired', 'class="inputbox"', $row->config_admin_expired );
 160  
 161  // LOCALE SETTINGS
 162  
 163      $lists['lang'] = mosHTML::selectList( $langs, 'config_lang', 'class="inputbox" size="1"', 'value', 'text', $row->config_lang );
 164  
 165      $timeoffset = array(
 166          mosHTML::makeOption( -12, '(UTC -12:00) International Date Line West'),
 167          mosHTML::makeOption( -11, '(UTC -11:00) Midway Island, Samoa'),
 168          mosHTML::makeOption( -10, '(UTC -10:00) Hawaii'),
 169          mosHTML::makeOption( -9.5, '(UTC -09:30) Taiohae, Marquesas Islands'),
 170          mosHTML::makeOption( -9, '(UTC -09:00) Alaska'),
 171          mosHTML::makeOption( -8, '(UTC -08:00) Pacific Time (US &amp; Canada)'),
 172          mosHTML::makeOption( -7, '(UTC -07:00) Mountain Time (US &amp; Canada)'),
 173          mosHTML::makeOption( -6, '(UTC -06:00) Central Time (US &amp; Canada), Mexico City'),
 174          mosHTML::makeOption( -5, '(UTC -05:00) Eastern Time (US &amp; Canada), Bogota, Lima'),
 175          mosHTML::makeOption( -4, '(UTC -04:00) Atlantic Time (Canada), Caracas, La Paz'),
 176          mosHTML::makeOption( -3.5, '(UTC -03:30) St. John`s, Newfoundland and Labrador'),
 177          mosHTML::makeOption( -3, '(UTC -03:00) Brazil, Buenos Aires, Georgetown'),
 178          mosHTML::makeOption( -2, '(UTC -02:00) Mid-Atlantic'),
 179          mosHTML::makeOption( -1, '(UTC -01:00 hour) Azores, Cape Verde Islands'),
 180          mosHTML::makeOption( 0, '(UTC 00:00) Western Europe Time, London, Lisbon, Casablanca'),
 181          mosHTML::makeOption( 1 , '(UTC +01:00 hour) Berlin, Brussels, Copenhagen, Madrid, Paris'),
 182          mosHTML::makeOption( 2, '(UTC +02:00) Kaliningrad, South Africa'),
 183          mosHTML::makeOption( 3, '(UTC +03:00) Baghdad, Riyadh, Moscow, St. Petersburg'),
 184          mosHTML::makeOption( 3.5, '(UTC +03:30) Tehran'),
 185          mosHTML::makeOption( 4, '(UTC +04:00) Abu Dhabi, Muscat, Baku, Tbilisi'),
 186          mosHTML::makeOption( 4.5, '(UTC +04:30) Kabul'),
 187          mosHTML::makeOption( 5, '(UTC +05:00) Ekaterinburg, Islamabad, Karachi, Tashkent'),
 188          mosHTML::makeOption( 5.5, '(UTC +05:30) Bombay, Calcutta, Madras, New Delhi'),
 189          mosHTML::makeOption( 5.75, '(UTC +05:45) Kathmandu'),
 190          mosHTML::makeOption( 6, '(UTC +06:00) Almaty, Dhaka, Colombo'),
 191          mosHTML::makeOption( 6.5, '(UTC +06:30) Yagoon'),
 192          mosHTML::makeOption( 7, '(UTC +07:00) Bangkok, Hanoi, Jakarta'),
 193          mosHTML::makeOption( 8, '(UTC +08:00) Beijing, Perth, Singapore, Hong Kong'),
 194          mosHTML::makeOption( 8.75, '(UTC +08:45) Western Australia'),
 195          mosHTML::makeOption( 9, '(UTC +09:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk'),
 196          mosHTML::makeOption( 9.5, '(UTC +09:30) Adelaide, Darwin, Yakutsk'),
 197          mosHTML::makeOption( 10, '(UTC +10:00) Eastern Australia, Guam, Vladivostok'),
 198          mosHTML::makeOption( 10.5, '(UTC +10:30) Lord Howe Island (Australia)'),
 199          mosHTML::makeOption( 11, '(UTC +11:00) Magadan, Solomon Islands, New Caledonia'),
 200          mosHTML::makeOption( 11.5, '(UTC +11:30) Norfolk Island'),
 201          mosHTML::makeOption( 12, '(UTC +12:00) Auckland, Wellington, Fiji, Kamchatka'),
 202          mosHTML::makeOption( 12.75, '(UTC +12:45) Chatham Island'),
 203          mosHTML::makeOption( 13, '(UTC +13:00) Tonga'),
 204          mosHTML::makeOption( 14, '(UTC +14:00) Kiribati'),
 205      );
 206  
 207      $lists['offset'] = mosHTML::selectList( $timeoffset, 'config_offset_user', 'class="inputbox" size="1"', 'value', 'text', $row->config_offset_user );
 208  
 209  // MAIL SETTINGS
 210  
 211      $mailer = array(
 212          mosHTML::makeOption( 'mail', 'PHP mail function' ),
 213          mosHTML::makeOption( 'sendmail', 'Sendmail' ),
 214          mosHTML::makeOption( 'smtp', 'SMTP Server' )
 215      );
 216      $lists['mailer']     = mosHTML::selectList( $mailer, 'config_mailer', 'class="inputbox" size="1"', 'value', 'text', $row->config_mailer );
 217  
 218      $lists['smtpauth']     = mosHTML::yesnoRadioList( 'config_smtpauth', 'class="inputbox"', $row->config_smtpauth );
 219  
 220  
 221  // CACHE SETTINGS
 222  
 223      $lists['caching']     = mosHTML::yesnoRadioList( 'config_caching', 'class="inputbox"', $row->config_caching );
 224  
 225  
 226  // USER SETTINGS
 227  
 228      $lists['allowUserRegistration'] = mosHTML::yesnoRadioList( 'config_allowUserRegistration', 'class="inputbox"',    $row->config_allowUserRegistration );
 229  
 230      $lists['useractivation']         = mosHTML::yesnoRadioList( 'config_useractivation', 'class="inputbox"',    $row->config_useractivation );
 231  
 232      $lists['uniquemail']             = mosHTML::yesnoRadioList( 'config_uniquemail', 'class="inputbox"',    $row->config_uniquemail );
 233  
 234      $lists['shownoauth']             = mosHTML::yesnoRadioList( 'config_shownoauth', 'class="inputbox"', $row->config_shownoauth );
 235  
 236      $lists['frontend_userparams']    = mosHTML::yesnoRadioList( 'config_frontend_userparams', 'class="inputbox"', $row->config_frontend_userparams );
 237  
 238  // META SETTINGS
 239  
 240      $lists['MetaAuthor']            = mosHTML::yesnoRadioList( 'config_MetaAuthor', 'class="inputbox"', $row->config_MetaAuthor );
 241  
 242      $lists['MetaTitle']             = mosHTML::yesnoRadioList( 'config_MetaTitle', 'class="inputbox"', $row->config_MetaTitle );
 243  
 244  
 245  // STATISTICS SETTINGS
 246  
 247      $lists['log_searches']             = mosHTML::yesnoRadioList( 'config_enable_log_searches', 'class="inputbox"', $row->config_enable_log_searches );
 248  
 249      $lists['enable_stats']             = mosHTML::yesnoRadioList( 'config_enable_stats', 'class="inputbox"', $row->config_enable_stats );
 250  
 251      $lists['log_items']                 = mosHTML::yesnoRadioList( 'config_enable_log_items', 'class="inputbox"', $row->config_enable_log_items );
 252  
 253  
 254  // SEO SETTINGS
 255  
 256      $lists['sef']                     = mosHTML::yesnoRadioList( 'config_sef', 'class="inputbox" onclick="javascript: if (document.adminForm.config_sef[1].checked) { alert(\'Remember to rename htaccess.txt to .htaccess\') }"', $row->config_sef );
 257  
 258      $lists['pagetitles']             = mosHTML::yesnoRadioList( 'config_pagetitles', 'class="inputbox"', $row->config_pagetitles );
 259  
 260  
 261  // CONTENT SETTINGS
 262  
 263      $lists['link_titles']             = mosHTML::yesnoRadioList( 'config_link_titles', 'class="inputbox"', $row->config_link_titles );
 264  
 265      $lists['readmore']                 = mosHTML::RadioList( $show_hide_r, 'config_readmore', 'class="inputbox"', $row->config_readmore, 'value', 'text' );
 266  
 267      $lists['vote']                     = mosHTML::RadioList( $show_hide_r, 'config_vote', 'class="inputbox"', $row->config_vote, 'value', 'text' );
 268  
 269  
 270  
 271      $lists['hideAuthor']             = mosHTML::RadioList( $show_hide, 'config_hideAuthor', 'class="inputbox"', $row->config_hideAuthor, 'value', 'text' );
 272  
 273      $lists['hideCreateDate']         = mosHTML::RadioList( $show_hide, 'config_hideCreateDate', 'class="inputbox"', $row->config_hideCreateDate, 'value', 'text' );
 274  
 275      $lists['hideModifyDate']         = mosHTML::RadioList( $show_hide, 'config_hideModifyDate', 'class="inputbox"', $row->config_hideModifyDate, 'value', 'text' );
 276  
 277      $lists['hits']                     = mosHTML::RadioList( $show_hide_r, 'config_hits', 'class="inputbox"', $row->config_hits, 'value', 'text' );
 278  
 279      if (is_writable( "$mosConfig_absolute_path/media/" )) {
 280          $lists['hidePdf']             = mosHTML::RadioList( $show_hide, 'config_hidePdf', 'class="inputbox"', $row->config_hidePdf, 'value', 'text' );
 281      } else {
 282          $lists['hidePdf']             = '<input type="hidden" name="config_hidePdf" value="1" /><strong>Hide</strong>';
 283      }
 284  
 285      $lists['hidePrint']             = mosHTML::RadioList( $show_hide, 'config_hidePrint', 'class="inputbox"', $row->config_hidePrint, 'value', 'text' );
 286  
 287      $lists['hideEmail']             = mosHTML::RadioList( $show_hide, 'config_hideEmail', 'class="inputbox"', $row->config_hideEmail, 'value', 'text' );
 288  
 289      $lists['icons']                 = mosHTML::RadioList( $show_hide_r, 'config_icons', 'class="inputbox"', $row->config_icons, 'value', 'text' );
 290  
 291      $lists['back_button']             = mosHTML::RadioList( $show_hide_r, 'config_back_button', 'class="inputbox"', $row->config_back_button, 'value', 'text' );
 292  
 293      $lists['item_navigation']         = mosHTML::RadioList( $show_hide_r, 'config_item_navigation', 'class="inputbox"', $row->config_item_navigation, 'value', 'text' );
 294  
 295      $lists['multipage_toc']         = mosHTML::RadioList( $show_hide_r, 'config_multipage_toc', 'class="inputbox"', $row->config_multipage_toc, 'value', 'text' );
 296  
 297      $itemid_compat = array(
 298          mosHTML::makeOption( '11', 'Joomla! 1.0.11 and before' ),
 299          mosHTML::makeOption( '0', 'Joomla! 1.0.12 and after' ),
 300      );
 301      $lists['itemid_compat']         = mosHTML::selectList( $itemid_compat, 'config_itemid_compat', 'class="inputbox" size="1"', 'value', 'text', $row->config_itemid_compat );
 302  
 303  // SHOW EDIT FORM
 304  
 305      HTML_config::showconfig( $row, $lists, $option );
 306  }
 307  
 308  /**
 309   * Save the configuration
 310   */
 311  function saveconfig( $task ) {
 312      global $database, $mosConfig_absolute_path, $mosConfig_password, $mosConfig_session_type;
 313  
 314      $row = new mosConfig();
 315      if (!$row->bind( $_POST )) {
 316          mosRedirect( 'index2.php', $row->getError() );
 317      }
 318  
 319      // if Session Authentication Type changed, delete all old Frontend sessions only - which used old Authentication Type
 320      if ( $mosConfig_session_type != $row->config_session_type ) {
 321          $past = time();
 322          $query = "DELETE FROM #__session"
 323          . "\n WHERE time < " . $database->Quote( $past )
 324          . "\n AND ("
 325          . "\n ( guest = 1 AND userid = 0 ) OR ( guest = 0 AND gid > 0 )"
 326          . "\n )"
 327          ;
 328          $database->setQuery( $query );
 329          $database->query();
 330      }
 331  
 332      $server_time             = date( 'O' ) / 100;
 333      $offset                 = $_POST['config_offset_user'] - $server_time;
 334      $row->config_offset     = $offset;
 335  
 336      //override any possible database password change
 337      $row->config_password     = $mosConfig_password;
 338  
 339      // handling of special characters
 340      $row->config_sitename            = htmlspecialchars( $row->config_sitename, ENT_QUOTES );
 341  
 342      // handling of quotes (double and single) and amp characters
 343      // htmlspecialchars not used to preserve ability to insert other html characters
 344      $row->config_offline_message    = ampReplace( $row->config_offline_message );
 345      $row->config_offline_message    = str_replace( '"', '&quot;', $row->config_offline_message );
 346      $row->config_offline_message    = str_replace( "'", '&#039;', $row->config_offline_message );
 347  
 348      // handling of quotes (double and single) and amp characters
 349      // htmlspecialchars not used to preserve ability to insert other html characters
 350      $row->config_error_message        = ampReplace( $row->config_error_message );
 351      $row->config_error_message        = str_replace( '"', '&quot;', $row->config_error_message );
 352      $row->config_error_message        = str_replace( "'", '&#039;', $row->config_error_message );
 353  
 354      $config = "<?php \n";
 355  
 356      $RGEmulation = intval( mosGetParam( $_POST, 'rgemulation', 0 ) );
 357      $config .= "if(!defined('RG_EMULATION')) { define( 'RG_EMULATION', $RGEmulation ); }\n";
 358  
 359  
 360      $config .= $row->getVarText();
 361      $config .= "setlocale (LC_TIME, \$mosConfig_locale);\n";
 362      $config .= '?>';
 363  
 364      $fname = $mosConfig_absolute_path . '/configuration.php';
 365  
 366      $enable_write     = intval( mosGetParam( $_POST, 'enable_write', 0 ) );
 367      $oldperms         = fileperms($fname);
 368      if ( $enable_write ) {
 369          @chmod( $fname, $oldperms | 0222);
 370      }
 371  
 372      if ( $fp = fopen($fname, 'w') ) {
 373          fputs($fp, $config, strlen($config));
 374          fclose($fp);
 375          if ($enable_write) {
 376              @chmod($fname, $oldperms);
 377          } else {
 378              if (mosGetParam($_POST,'disable_write',0))
 379                  @chmod($fname, $oldperms & 0777555);
 380          } // if
 381  
 382          $msg = 'The Configuration Details have been updated';
 383  
 384          // apply file and directory permissions if requested by user
 385          $applyFilePerms = mosGetParam($_POST,'applyFilePerms',0) && $row->config_fileperms!='';
 386          $applyDirPerms = mosGetParam($_POST,'applyDirPerms',0) && $row->config_dirperms!='';
 387          if ($applyFilePerms || $applyDirPerms) {
 388              $mosrootfiles = array(
 389                  'administrator',
 390                  'cache',
 391                  'components',
 392                  'images',
 393                  'language',
 394                  'mambots',
 395                  'media',
 396                  'modules',
 397                  'templates',
 398                  'configuration.php'
 399              );
 400              $filemode = NULL;
 401  
 402              if ( $applyFilePerms ) {
 403                  $filemode = octdec( $row->config_fileperms );
 404              }
 405  
 406              $dirmode = NULL;
 407  
 408              if ( $applyDirPerms ) {
 409                  $dirmode = octdec( $row->config_dirperms );
 410              }
 411  
 412              foreach ($mosrootfiles as $file) {
 413                  mosChmodRecursive( $mosConfig_absolute_path.'/'.$file, $filemode, $dirmode );
 414              }
 415          } // if
 416  
 417          switch ( $task ) {
 418              case 'apply':
 419                  mosRedirect( 'index2.php?option=com_config&hidemainmenu=1', $msg );
 420                  break;
 421  
 422              case 'save':
 423              default:
 424                  mosRedirect( 'index2.php', $msg );
 425                  break;
 426          }
 427      } else {
 428          if ($enable_write) {
 429              @chmod( $fname, $oldperms );
 430          }
 431          mosRedirect( 'index2.php', 'An Error Has Occurred! Unable to open config file to write!' );
 432      }
 433  }
 434  ?>


Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics