[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

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

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @subpackage Config
   5  * @author Mambo Foundation Inc see README.php
   6  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   7  * See COPYRIGHT.php for copyright notices and details.
   8  * @license GNU/GPL Version 2, see LICENSE.php
   9  *
  10  * Redistributions of files must retain the above copyright notice.
  11  *
  12  * Mambo is free software; you can redistribute it and/or
  13  * modify it under the terms of the GNU General Public License
  14  * as published by the Free Software Foundation; version 2 of the License.
  15  */
  16  
  17  /** ensure this file is being included by a parent file */
  18  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  19  
  20  if (!$acl->acl_check( 'administration', 'config', 'users', $my->usertype )) {
  21      mosRedirect( 'index2.php', T_('You are not authorized to view this resource.') );
  22  }
  23  
  24  class mosConfig extends mosDBTable {
  25      /** @var int */
  26      var $config_offline=null;
  27      /** @var string */
  28      var $config_host=null;
  29      /** @var string */
  30      var $config_user=null;
  31      /** @var string */
  32      var $config_password=null;
  33      /** @var string */
  34      var $config_db=null;
  35      /** @var string */
  36      var $config_dbprefix=null;
  37      /** @var string */
  38      var $config_path=null;
  39      /** @var string */
  40      var $config_live_site=null;
  41      /** @var string */
  42      var $config_sitename=null;
  43      /** @var int */
  44      var $config_auth=null;
  45      /** @var int */
  46      var $config_lifetime=null;
  47      /** @var string */
  48      var $config_offline_message=null;
  49      /** @var string */
  50      var $config_error_message=null;
  51      /** @var int */
  52      var $config_useractivation=null;
  53      /** @var string */
  54      var $config_use_captcha=0;
  55      /** @var int */
  56      var $config_uniquemail=null;
  57      /** @var string */
  58      var $config_metadesc=null;
  59      /** @var string */
  60      var $config_metakeys=null;
  61      /** @var int */
  62      var $config_metaauthor=null;
  63      /** @var int */
  64      var $config_metatitle=null;
  65      /** @var int */
  66      var $config_debug=0;
  67      /** @var string */
  68      var $config_lang=null;
  69      /** @var string */
  70      var $config_locale_debug=0;
  71      /** @var string */
  72      var $config_locale_use_gettext=0;
  73      /** @var string */
  74      var $config_locale=null;
  75      /** @var string */
  76      var $config_charset=null;
  77      /** @var int */
  78      var $config_offset=null;
  79      /** @var int */
  80      var $config_hideauthor=null;
  81      /** @var int */
  82      var $config_hidecreate=null;
  83      /** @var int */
  84      var $config_hidemodify=null;
  85      /** @var int */
  86      var $config_hidepdf=null;
  87      /** @var int */
  88      var $config_hideprint=null;
  89      /** @var int */
  90      var $config_hideemail=null;
  91      /** @var int */
  92      var $config_enable_log_items=null;
  93      /** @var int */
  94      var $config_enable_log_searches=null;
  95      /** @var int */
  96      var $config_enable_stats=null;
  97      /** @var int */
  98      var $config_sef=0;
  99      /** @var int */
 100      var $config_vote=0;
 101      /** @var int */
 102      var $config_gzip=0;
 103      /** @var int */
 104      var $config_multipage_toc=0;
 105      /** @var int */
 106      var $config_allowUserRegistration=0;
 107      /** @var int */
 108      var $config_error_reporting=0;
 109      /** @var int */
 110      var $config_register_globals=0;
 111      /** @var int */
 112      var $config_link_titles=0;
 113      /** @var int */
 114      var $config_list_limit=0;
 115      /** @var int */
 116      var $config_caching=0;
 117      /** @var string */
 118      var $config_cachepath=null;
 119      /** @var string */
 120      var $config_cachetime=null;
 121      /** @var string */
 122      var $config_mailer=null;
 123      /** @var string */
 124      var $config_mailfrom=null;
 125      /** @var string */
 126      var $config_fromname=null;
 127      /** @var string */
 128      var $config_sendmail='/usr/sbin/sendmail';
 129      /** @var string */
 130      var $config_smtpauth=0;
 131      /** @var string */
 132      var $config_smtpuser=null;
 133      /** @var string */
 134      var $config_smtppass=null;
 135      /** @var string */
 136      var $config_smtphost=null;
 137      /** @var string */
 138      var $_alias=null;
 139      /** @var int */
 140      var $config_back_button=0;
 141      /** @var int */
 142      var $config_item_navigation=0;
 143      /** @var int */
 144      var $config_ml_support=0;
 145      /** @var string */
 146      var $config_secret=null;
 147      /** @var int */
 148      var $config_pagetitles=1;
 149      /** @var int */
 150      var $config_readmore=1;
 151      /** @var int */
 152      var $config_hits=1;
 153      /** @var int */
 154      var $config_icons=1;
 155      /** @var string */
 156      var $config_favicon=null;
 157      /** @var string */
 158      var $config_fileperms='0644';
 159      /** @var string */
 160      var $config_dirperms='0755';
 161      /** @var string */
 162      var $config_helpurl='';
 163  
 164  	function mosConfig() {
 165          $this->_alias = array(
 166          'config_offline'                =>'mosConfig_offline',
 167          'config_host'                    =>'mosConfig_host',
 168          'config_user'                    =>'mosConfig_user',
 169          'config_password'                =>'mosConfig_password',
 170          'config_db'                        =>'mosConfig_db',
 171          'config_dbprefix'                =>'mosConfig_dbprefix',
 172          'config_path'                    =>'mosConfig_absolute_path',
 173          'config_live_site'                =>'mosConfig_live_site',
 174          'config_sitename'                =>'mosConfig_sitename',
 175          'config_auth'                    =>'mosConfig_shownoauth',
 176          'config_useractivation'            =>'mosConfig_useractivation',
 177          'config_uniquemail'                =>'mosConfig_uniquemail',
 178          'config_use_captcha'            =>'mosConfig_usecaptcha',
 179          'config_offline_message'        =>'mosConfig_offline_message',
 180          'config_error_message'            =>'mosConfig_error_message',
 181          'config_debug'                     =>'mosConfig_debug',
 182          'config_lifetime'                =>'mosConfig_lifetime',
 183          'config_metadesc'                =>'mosConfig_MetaDesc',
 184          'config_metakeys'                =>'mosConfig_MetaKeys',
 185          'config_metaauthor'                =>'mosConfig_MetaAuthor',
 186          'config_metatitle'                =>'mosConfig_MetaTitle',
 187          'config_lang'                    =>'mosConfig_lang',
 188          'config_locale'                    =>'mosConfig_locale',
 189          'config_charset'                =>'mosConfig_charset',
 190          'config_locale_debug'            =>'mosConfig_locale_debug',
 191          'config_locale_use_gettext'        =>'mosConfig_locale_use_gettext',
 192          'config_offset'                    =>'mosConfig_offset',
 193          'config_hideauthor'                =>'mosConfig_hideAuthor',
 194          'config_hidecreate'                =>'mosConfig_hideCreateDate',
 195          'config_hidemodify'                =>'mosConfig_hideModifyDate',
 196          'config_hidepdf'                =>'mosConfig_hidePdf',
 197          'config_hideprint'                =>'mosConfig_hidePrint',
 198          'config_hideemail'                =>'mosConfig_hideEmail',
 199          'config_enable_log_items'        =>'mosConfig_enable_log_items',
 200          'config_enable_log_searches'    =>'mosConfig_enable_log_searches',
 201          'config_enable_stats'             =>'mosConfig_enable_stats',
 202          'config_sef'                    =>'mosConfig_sef',
 203          'config_vote'                    =>'mosConfig_vote',
 204          'config_gzip'                    =>'mosConfig_gzip',
 205          'config_multipage_toc'            =>'mosConfig_multipage_toc',
 206          'config_allowUserRegistration'    =>'mosConfig_allowUserRegistration',
 207          'config_link_titles'            =>'mosConfig_link_titles',
 208          'config_error_reporting'        =>'mosConfig_error_reporting',
 209          'config_register_globals'        =>'mosConfig_register_globals',
 210          'config_list_limit'                =>'mosConfig_list_limit',
 211          'config_caching'                =>'mosConfig_caching',
 212          'config_cachepath'                =>'mosConfig_cachepath',
 213          'config_cachetime'                =>'mosConfig_cachetime',
 214          'config_mailer'                 =>'mosConfig_mailer',
 215          'config_mailfrom'                 =>'mosConfig_mailfrom',
 216          'config_fromname'                 =>'mosConfig_fromname',
 217          'config_sendmail'                 =>'mosConfig_sendmail',
 218          'config_smtpauth'                 =>'mosConfig_smtpauth',
 219          'config_smtpuser'                 =>'mosConfig_smtpuser',
 220          'config_smtppass'                 =>'mosConfig_smtppass',
 221          'config_smtphost'                 =>'mosConfig_smtphost',
 222          'config_back_button'             =>'mosConfig_back_button',
 223          'config_item_navigation'         =>'mosConfig_item_navigation',
 224          'config_secret'                 =>'mosConfig_secret',
 225          'config_pagetitles'             =>'mosConfig_pagetitles',
 226          'config_readmore'                 =>'mosConfig_readmore',
 227          'config_hits'                     =>'mosConfig_hits',
 228          'config_icons'                     =>'mosConfig_icons',
 229          'config_favicon'                 =>'mosConfig_favicon',
 230          'config_fileperms'                 =>'mosConfig_fileperms',
 231          'config_dirperms'                 =>'mosConfig_dirperms',
 232          'config_ml_support'                =>'mosConfig_mbf_content',
 233          'config_helpurl'                 =>'mosConfig_helpurl'
 234          );
 235      }
 236  
 237  	function getVarText() {
 238          $txt = '';
 239          foreach ($this->_alias as $k=>$v) {
 240              $txt .= "\$$v = '".addslashes( str_replace(array("\r\n", "\n", "\r"), '', $this->$k) )."';\n";
 241          }
 242          return $txt;
 243      }
 244  
 245  	function bindGlobals() {
 246          foreach ($this->_alias as $k=>$v) {
 247              if(isset($GLOBALS[$v]))
 248                  $this->$k = $GLOBALS[$v];
 249          }
 250      }
 251  }
 252  
 253  require_once( str_replace('\\','/',dirname(__FILE__)) . '/admin.config.html.php' );
 254  $confightml = new HTML_config();
 255  
 256  
 257  switch ( $task ) {
 258      case 'apply':
 259      case 'save':
 260          saveconfig( $task );
 261          break;
 262  
 263      case 'cancel':
 264          mosRedirect( 'index2.php' );
 265          break;
 266  
 267      default:
 268          showconfig($confightml, $database, $option);
 269          break;
 270  }
 271  
 272  
 273  function showconfig($confightml, &$database, $option) {
 274      global $database, $mosConfig_absolute_path, $mosConfig_locale;
 275      $row = new mosConfig();
 276      $row->bindGlobals();
 277  
 278      // compile list of the languages
 279      $langs = array();
 280      // menuitems appears never to be used - so commented out by Martin Brampton 15 Dec 2005
 281  //    $menuitems = array();
 282      $language =& new mamboLanguage($mosConfig_locale);
 283      $files = $language->getLanguages();
 284      foreach ($files as $file){
 285          $langs[] = mosHTML::makeOption( $file->name );
 286      }
 287      // sort list of languages
 288      sort($langs);
 289      reset($langs);
 290  
 291      // compile list of the editors
 292      $query = "SELECT id AS value, name AS text"
 293      . "\n FROM #__mambots"
 294      . "\n WHERE folder='editors' AND published >= 0"
 295      . "\n ORDER BY ordering, name"
 296      ;
 297      $database->setQuery( $query );
 298      $edits = $database->loadObjectList();
 299  
 300      // @RawSQLUse, trivial_implementation, SELECT
 301      $query = "SELECT id"
 302      . "\n FROM #__mambots"
 303      . "\n WHERE folder='editors' AND published = 1"
 304      . "\n LIMIT 1"
 305      ;
 306      $database->setQuery( $query );
 307      $editor = $database->loadResult();
 308  
 309      $lists = array();
 310      // build the html select list
 311      $lists['editor'] = mosHTML::selectList( $edits, 'editor', 'class="inputbox" size="1"', 'value', 'text', $editor );
 312  
 313      // build the html select list
 314      $lists['lang'] = mosHTML::selectList( $langs, 'config_locale', 'class="inputbox" size="1"', 'value', 'text', $row->config_locale );
 315      // make a generic -24 - 24 list
 316      for ($i=-12;$i<=12;$i++) {
 317          $timeoffset[] = mosHTML::makeOption( $i, $i );
 318      }
 319  
 320      // menuitems appears not to be used anywhere - so commented out Martin Brampton 15 Dec 2005
 321      // get list of menuitems
 322  //    $query = "SELECT id AS value, name AS text FROM #__menu"
 323  //    . "\n WHERE (type='content_section' OR type='components' OR type='content_typed')"
 324  //    . "\n AND published=1"
 325  //    . "\n AND access=0"
 326  //    . "\n ORDER BY name"
 327  //    ;
 328  //    $database->setQuery( $query );
 329  //    $menuitems = array_merge( $menuitems, $database->loadObjectList() );
 330  
 331      $show_hide = array(
 332          mosHTML::makeOption( 1, T_('Hide') ),
 333          mosHTML::makeOption( 0, T_('Show') ),
 334      );
 335  
 336      $show_hide_r = array(
 337          mosHTML::makeOption( 0, T_('Hide') ),
 338          mosHTML::makeOption( 1, T_('Show') ),
 339      );
 340  
 341      $list_length = array(
 342          mosHTML::makeOption( 5, 5 ),
 343          mosHTML::makeOption( 10, 10 ),
 344          mosHTML::makeOption( 15, 15 ),
 345          mosHTML::makeOption( 20, 20 ),
 346          mosHTML::makeOption( 25, 25 ),
 347          mosHTML::makeOption( 30, 30 ),
 348          mosHTML::makeOption( 50, 50 ),
 349      );
 350  
 351      $errors = array(
 352          mosHTML::makeOption( -1, T_('System Default') ),
 353          mosHTML::makeOption( 0, T_('None') ),
 354          mosHTML::makeOption( E_ERROR|E_WARNING|E_PARSE, T_('Simple') ),
 355          mosHTML::makeOption( E_ALL , T_('Maximum') )
 356      );
 357  
 358      $register_globals = array(
 359          mosHTML::makeOption( 1, T_('On') ),
 360          mosHTML::makeOption( 0, T_('Off') ),
 361      );
 362      $locale_debug = array(
 363          mosHTML::makeOption( 1, T_('On') ),
 364          mosHTML::makeOption( 0, T_('Off') ),
 365      );
 366      $locale_use_gettext = array(
 367          mosHTML::makeOption( 1, T_('Yes') ),
 368          mosHTML::makeOption( 0, T_('No') ),
 369      );
 370  
 371      $mailer = array(
 372          mosHTML::makeOption( 'mail', T_('PHP mail function'), true ),
 373          mosHTML::makeOption( 'sendmail', T_('Sendmail'), true ),
 374          mosHTML::makeOption( 'smtp', T_('SMTP Server'), true )
 375      );
 376      
 377      // build the html select lists
 378      $lists['offline']                 = mosHTML::yesnoRadioList( 'config_offline', 'class="inputbox"', $row->config_offline );
 379  
 380      $lists['auth']                     = mosHTML::yesnoRadioList( 'config_auth', 'class="inputbox"', $row->config_auth );
 381  
 382      $lists['metaauthor']            = mosHTML::yesnoRadioList( 'config_metaauthor', 'class="inputbox"', $row->config_metaauthor );
 383  
 384      $lists['metatitle']             = mosHTML::yesnoRadioList( 'config_metatitle', 'class="inputbox"', $row->config_metatitle );
 385  
 386      $lists['useractivation']         = mosHTML::yesnoRadioList( 'config_useractivation', 'class="inputbox"',    $row->config_useractivation );
 387  
 388      $lists['uniquemail']             = mosHTML::yesnoRadioList( 'config_uniquemail', 'class="inputbox"',    $row->config_uniquemail );
 389  
 390      $lists['usecaptcha']             = mosHTML::yesnoRadioList( 'config_use_captcha', 'class="inputbox"',    $row->config_use_captcha );
 391  
 392      $lists['allowuserregistration'] = mosHTML::yesnoRadioList( 'config_allowUserRegistration', 'class="inputbox"',    $row->config_allowUserRegistration );
 393  
 394      $lists['debug']                 = mosHTML::yesnoRadioList( 'config_debug', 'class="inputbox"', $row->config_debug );
 395  
 396      $lists['offset']                 = mosHTML::selectList( $timeoffset, 'config_offset', 'class="inputbox" size="1"',    'value', 'text', $row->config_offset );
 397  
 398      $lists['hideauthor']             = mosHTML::RadioList( $show_hide, 'config_hideauthor', 'class="inputbox"', $row->config_hideauthor, 'value', 'text' );
 399  
 400      $lists['hidecreate']             = mosHTML::RadioList( $show_hide, 'config_hidecreate', 'class="inputbox"', $row->config_hidecreate, 'value', 'text' );
 401  
 402      $lists['hidemodify']             = mosHTML::RadioList( $show_hide, 'config_hidemodify', 'class="inputbox"', $row->config_hidemodify, 'value', 'text' );
 403  
 404      if (is_writable( "$mosConfig_absolute_path/media/" )) {
 405          $lists['hidepdf']             = mosHTML::RadioList( $show_hide, 'config_hidepdf', 'class="inputbox"', $row->config_hidepdf, 'value', 'text' );
 406      } else {
 407          $lists['hidepdf']             = '<input type="hidden" name="config_hidepdf" value="1" /><strong>'.T_('Yes').'</strong>';
 408      }
 409  
 410      $lists['hideprint']             = mosHTML::RadioList( $show_hide, 'config_hideprint', 'class="inputbox"', $row->config_hideprint, 'value', 'text' );
 411  
 412      $lists['hideemail']             = mosHTML::RadioList( $show_hide, 'config_hideemail', 'class="inputbox"', $row->config_hideemail, 'value', 'text' );
 413  
 414      $lists['log_items']                 = mosHTML::yesnoRadioList( 'config_enable_log_items', 'class="inputbox"', $row->config_enable_log_items );
 415  
 416      $lists['log_searches']             = mosHTML::yesnoRadioList( 'config_enable_log_searches', 'class="inputbox"', $row->config_enable_log_searches );
 417  
 418      $lists['enable_stats']             = mosHTML::yesnoRadioList( 'config_enable_stats', 'class="inputbox"', $row->config_enable_stats );
 419  
 420      $lists['sef']                     = mosHTML::yesnoRadioList( 'config_sef', 'class="inputbox" onclick="javascript: if (document.adminForm.config_sef[1].checked) { alert(\''.T_('Remember to rename htaccess.txt to .htaccess').'\') }"', $row->config_sef );
 421  
 422      $lists['vote']                     = mosHTML::RadioList( $show_hide_r, 'config_vote', 'class="inputbox"', $row->config_vote, 'value', 'text' );
 423  
 424      $lists['gzip']                     = mosHTML::yesnoRadioList( 'config_gzip', 'class="inputbox"', $row->config_gzip );
 425  
 426      $lists['multipage_toc']         = mosHTML::RadioList( $show_hide_r, 'config_multipage_toc', 'class="inputbox"', $row->config_multipage_toc, 'value', 'text' );
 427  
 428      $lists['pagetitles']             = mosHTML::yesnoRadioList( 'config_pagetitles', 'class="inputbox"', $row->config_pagetitles );
 429  
 430      $lists['error_reporting']         = mosHTML::selectList( $errors, 'config_error_reporting', 'class="inputbox" size="1"', 'value', 'text', $row->config_error_reporting );
 431  
 432      $lists['register_globals']         = mosHTML::RadioList( $register_globals, 'config_register_globals', 'class="inputbox" size="1"', $row->config_register_globals, 'value', 'text' );
 433  
 434      $lists['locale_debug']             = mosHTML::RadioList( $locale_debug, 'config_locale_debug', 'class="inputbox" size="1"', $row->config_locale_debug, 'value', 'text' );
 435  
 436      $disabled = (extension_loaded('gettext')) ? '' : 'disabled="disabled" ';
 437      $lists['locale_use_gettext']     = mosHTML::RadioList( $locale_use_gettext, 'config_locale_use_gettext', $disabled.'class="inputbox" size="1"', $row->config_locale_use_gettext, 'value', 'text' );
 438  
 439      $lists['link_titles']             = mosHTML::yesnoRadioList( 'config_link_titles', 'class="inputbox"', $row->config_link_titles );
 440  
 441      $lists['caching']                 = mosHTML::yesnoRadioList( 'config_caching', 'class="inputbox"', $row->config_caching );
 442  
 443      $lists['mailer']                 = mosHTML::selectList( $mailer, 'config_mailer', 'class="inputbox" size="1"', 'value', 'text', $row->config_mailer );
 444  
 445      $lists['smtpauth']                 = mosHTML::yesnoRadioList( 'config_smtpauth', 'class="inputbox"', $row->config_smtpauth );
 446  
 447      $lists['list_length']             = mosHTML::selectList( $list_length, 'config_list_limit', 'class="inputbox" size="1"', 'value', 'text', ( $row->config_list_limit ? $row->config_list_limit : 50 ) );
 448  
 449      $lists['back_button']             = mosHTML::RadioList( $show_hide_r, 'config_back_button', 'class="inputbox"', $row->config_back_button, 'value', 'text' );
 450  
 451      $lists['item_navigation']         = mosHTML::RadioList( $show_hide_r, 'config_item_navigation', 'class="inputbox"', $row->config_item_navigation, 'value', 'text' );
 452  
 453      $lists['ml_support']             = mosHTML::yesnoRadioList( 'config_ml_support', 'class="inputbox" onclick="javascript: if (document.adminForm.config_ml_support[1].checked) { alert(\''.T_('Remember to install the MambelFish component.').'\') }"', $row->config_ml_support );
 454  
 455      $lists['readmore']                 = mosHTML::RadioList( $show_hide_r, 'config_readmore', 'class="inputbox"', $row->config_readmore, 'value', 'text' );
 456  
 457      $lists['hits']                     = mosHTML::RadioList( $show_hide_r, 'config_hits', 'class="inputbox"', $row->config_hits, 'value', 'text' );
 458  
 459      $lists['icons']                 = mosHTML::RadioList( $show_hide_r, 'config_icons', 'class="inputbox"', $row->config_icons, 'value', 'text' );
 460  
 461  //    $lists['favicon']                 = mosHTML::RadioList( $show_hide_r, 'config_icons', 'class="inputbox"', $row->config_icons, 'value', 'text' );
 462  
 463      $confightml->showconfig( $row, $lists, $option );
 464  }
 465  
 466  function saveconfig( $task ) {
 467      global $database, $mosConfig_absolute_path;
 468  
 469      $row = new mosConfig();
 470      if (!$row->bind( $_POST )) {
 471          mosRedirect( "index2.php", $row->getError() );
 472      }
 473  
 474      $editor = intval( mosGetParam( $_POST, 'editor', 0 ) );
 475      if ($editor > 0) {
 476          $query = "UPDATE #__mambots"
 477          . "\n SET published = 0"
 478          . "\n WHERE published >= 0 AND folder='editors'"
 479          ;
 480          $database->setQuery( $query );
 481          $database->query() or die( $database->getErrorMsg() );
 482  
 483          // @RawSQLUse, trivial_implementation, UPDATE
 484          $query = "UPDATE #__mambots"
 485          . "\n SET published = 1"
 486          . "\n WHERE id = $editor"
 487          ;
 488          $database->setQuery( $query );
 489          $database->query() or die( $database->getErrorMsg() );
 490      }
 491      
 492      $language =& new mamboLanguage($row->config_locale);
 493      $row->config_lang = $language->get('lang');
 494      $row->config_charset = $language->get('charset');
 495      
 496      $config = "<?php \n";
 497      $config .= $row->getVarText();
 498      //$config .= "setlocale (LC_TIME, \$mosConfig_locale);\n";
 499      $config .= '?>';
 500  
 501      $fname = '../configuration.php';
 502      $enable_write = mosGetParam($_POST,'enable_write',0);
 503      $oldperms = fileperms($fname);
 504      if ($enable_write) @chmod($fname, $oldperms | 0222);
 505      if ( $fp = fopen($fname, 'w') ) {
 506          fputs($fp, $config, strlen($config));
 507          fclose($fp);
 508          if ($enable_write) {
 509              @chmod($fname, $oldperms);
 510          } else {
 511              if (mosGetParam($_POST,'disable_write',0))
 512                  @chmod($fname, $oldperms & 0777555);
 513          } // if
 514  
 515          $msg = T_('The Configuration Details have been updated');
 516  
 517          // apply file and directory permissions if requested by user
 518          $applyFilePerms = mosGetParam($_POST,'applyFilePerms',0) && $row->config_fileperms!='';
 519          $applyDirPerms = mosGetParam($_POST,'applyDirPerms',0) && $row->config_dirperms!='';
 520          if ($applyFilePerms || $applyDirPerms) {
 521              $mosrootfiles = array(
 522                  'administrator',
 523                  'cache',
 524                  'components',
 525                  'editor',
 526                  'help',
 527                  'images',
 528                  'includes',
 529                  'parameters',
 530                  'installation',
 531                  'language',
 532                  'mambots',
 533                  'media',
 534                  'modules',
 535                  'templates',
 536                  'CHANGELOG',
 537                  'configuration.php',
 538                  'htaccess.txt',
 539                  'index.php',
 540                  'index2.php',
 541                  'index3.php',
 542                  'INSTALL',
 543                  'LICENSE',
 544                  'mainbody.php',
 545                  'offline.php',
 546                  'page404.php',
 547                  'pathway.php',
 548                  'README',
 549                  'robots.txt'
 550              );
 551              $filemode = NULL;
 552              if ($applyFilePerms) $filemode = octdec($row->config_fileperms);
 553              $dirmode = NULL;
 554              if ($applyDirPerms) $dirmode = octdec($row->config_dirperms);
 555              foreach ($mosrootfiles as $file)
 556                  mosChmodRecursive($mosConfig_absolute_path.'/'.$file, $filemode, $dirmode);
 557          } // if
 558  
 559          switch ( $task ) {
 560              case 'apply':
 561                  mosRedirect( 'index2.php?option=com_config&hidemainmenu=1', $msg );
 562                  break;
 563  
 564              case 'save':
 565              default:
 566                  mosRedirect( 'index2.php', $msg );
 567                  break;
 568          }
 569      } else {
 570          if ($enable_write) @chmod($fname, $oldperms);
 571          mosRedirect( 'index2.php', T_('An Error Has Occurred! Unable to open config file to write!') );
 572      }
 573  }
 574  ?>