[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/components/com_config/controllers/ -> application.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: application.php 15097 2010-02-27 14:19:54Z ian $
   4   * @package        Joomla
   5   * @subpackage    Config
   6   * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7   * @license        GNU/GPL, see LICENSE.php
   8   * Joomla! is free software. This version may have been modified pursuant to the
   9   * GNU General Public License, and as distributed it includes or is derivative
  10   * of works licensed under the GNU General Public License or other free or open
  11   * source software licenses. See COPYRIGHT.php for copyright notices and
  12   * details.
  13   */
  14  
  15  // no direct access
  16  defined( '_JEXEC' ) or die( 'Restricted access' );
  17  
  18  require_once( JPATH_COMPONENT.DS.'views'.DS.'application'.DS.'view.php' );
  19  
  20  /**
  21   * @package        Joomla
  22   * @subpackage    Config
  23   */
  24  class ConfigControllerApplication extends ConfigController
  25  {
  26      /**
  27       * Custom Constructor
  28       */
  29  	function __construct( $default = array() )
  30      {
  31          $default['default_task'] = 'showConfig';
  32          parent::__construct( $default );
  33  
  34          $this->registerTask( 'apply', 'save' );
  35      }
  36  
  37      /**
  38       * Show the configuration edit form
  39       * @param string The URL option
  40       */
  41  	function showConfig()
  42      {
  43          // Initialize some variables
  44          $db =& JFactory::getDBO();
  45          $row = new JConfig();
  46  
  47          // compile list of the languages
  48          $langs         = array ();
  49          $menuitems     = array ();
  50          $lists         = array ();
  51  
  52          // PRE-PROCESS SOME LIST
  53  
  54          // -- Editors --
  55  
  56          // compile list of the editors
  57          $query = 'SELECT element AS value, name AS text'
  58                  .' FROM #__plugins'
  59                  .' WHERE folder = "editors"'
  60                  .' AND published = 1'
  61                  .' ORDER BY ordering, name'
  62                  ;
  63          $db->setQuery($query);
  64          $edits = $db->loadObjectList();
  65  
  66          // -- Show/Hide --
  67  
  68          $show_hide        = array (JHTML::_('select.option', 1, JText::_('Hide')), JHTML::_('select.option', 0, JText::_('Show')),);
  69  
  70          $show_hide_r     = array (JHTML::_('select.option', 0, JText::_('Hide')), JHTML::_('select.option', 1, JText::_('Show')),);
  71  
  72          // -- menu items --
  73  
  74          $query = 'SELECT id AS value, name AS text FROM #__menu'
  75                  .' WHERE ( type="content_section" OR type="components" OR type="content_typed" )'
  76                  .' AND published = 1'
  77                  .' AND access = 0'
  78                  .' ORDER BY name'
  79                  ;
  80          $db->setQuery($query);
  81          $menuitems = array_merge($menuitems, $db->loadObjectList());
  82  
  83          // SITE SETTINGS
  84          $lists['offline'] = JHTML::_('select.booleanlist', 'offline', 'class="inputbox"', $row->offline);
  85          if (!$row->editor) {
  86              $row->editor = '';
  87          }
  88          // build the html select list
  89          $lists['editor']         = JHTML::_('select.genericlist',  $edits, 'editor', 'class="inputbox" size="1"', 'value', 'text', $row->editor);
  90          $listLimit                 = array (JHTML::_('select.option', 5, 5), JHTML::_('select.option', 10, 10), JHTML::_('select.option', 15, 15), JHTML::_('select.option', 20, 20), JHTML::_('select.option', 25, 25), JHTML::_('select.option', 30, 30), JHTML::_('select.option', 50, 50), JHTML::_('select.option', 100, 100),);
  91          $lists['list_limit']     = JHTML::_('select.genericlist',  $listLimit, 'list_limit', 'class="inputbox" size="1"', 'value', 'text', ($row->list_limit ? $row->list_limit : 50));
  92  
  93          jimport('joomla.language.help');
  94          $helpsites                 = array ();
  95          $helpsites                 = JHelp::createSiteList(JPATH_BASE.DS.'help'.DS.'helpsites-15.xml', $row->helpurl);
  96          array_unshift($helpsites, JHTML::_('select.option', '', JText::_('local')));
  97          $lists['helpsites']     = JHTML::_('select.genericlist',  $helpsites, 'helpurl', ' class="inputbox"', 'value', 'text', $row->helpurl);
  98  
  99          // DEBUG
 100          $lists['debug']         = JHTML::_('select.booleanlist', 'debug', 'class="inputbox"', $row->debug);
 101          $lists['debug_lang']     = JHTML::_('select.booleanlist', 'debug_lang', 'class="inputbox"', $row->debug_lang);
 102  
 103          // DATABASE SETTINGS
 104  
 105          // SERVER SETTINGS
 106          $lists['gzip']             = JHTML::_('select.booleanlist', 'gzip', 'class="inputbox"', $row->gzip);
 107          $errors                 = array (JHTML::_('select.option', -1, JText::_('System Default')), JHTML::_('select.option', 0, JText::_('None')), JHTML::_('select.option', E_ERROR | E_WARNING | E_PARSE, JText::_('Simple')), JHTML::_('select.option', E_ALL, JText::_('Maximum')));
 108          $lists['xmlrpc_server'] = JHTML::_('select.booleanlist', 'xmlrpc_server', 'class="inputbox"', $row->xmlrpc_server);
 109          $lists['error_reporting'] = JHTML::_('select.genericlist',  $errors, 'error_reporting', 'class="inputbox" size="1"', 'value', 'text', $row->error_reporting);
 110          $lists['enable_ftp']     = JHTML::_('select.booleanlist', 'ftp_enable', 'class="inputbox"', intval($row->ftp_enable));
 111  
 112          $forceSSL = array(
 113                                  JHTML::_('select.option', 0, JText::_('None')),
 114                                  JHTML::_('select.option', 1, JText::_('Administrator Only')),
 115                                  JHTML::_('select.option', 2, JText::_('Entire Site')),
 116                          );
 117          $lists['force_ssl'] = JHTML::_('select.genericlist', $forceSSL, 'force_ssl', 'class="inputbox" size="1"', 'value', 'text', @$row->force_ssl);
 118  
 119          // LOCALE SETTINGS
 120          $timeoffset = array (
 121              JHTML::_('select.option', -12, JText::_('(UTC -12:00) International Date Line West')),
 122              JHTML::_('select.option', -11, JText::_('(UTC -11:00) Midway Island, Samoa')),
 123              JHTML::_('select.option', -10, JText::_('(UTC -10:00) Hawaii')),
 124              JHTML::_('select.option', -9.5, JText::_('(UTC -09:30) Taiohae, Marquesas Islands')),
 125              JHTML::_('select.option', -9, JText::_('(UTC -09:00) Alaska')),
 126              JHTML::_('select.option', -8, JText::_('(UTC -08:00) Pacific Time (US &amp; Canada)')),
 127              JHTML::_('select.option', -7, JText::_('(UTC -07:00) Mountain Time (US &amp; Canada)')),
 128              JHTML::_('select.option', -6, JText::_('(UTC -06:00) Central Time (US &amp; Canada), Mexico City')),
 129              JHTML::_('select.option', -5, JText::_('(UTC -05:00) Eastern Time (US &amp; Canada), Bogota, Lima')),
 130              JHTML::_('select.option', -4.5, JText::_('(UTC -04:30) Venezuela')),
 131              JHTML::_('select.option', -4, JText::_('(UTC -04:00) Atlantic Time (Canada), Caracas, La Paz')),
 132              JHTML::_('select.option', -3.5, JText::_('(UTC -03:30) St. John\'s, Newfoundland, Labrador')),
 133              JHTML::_('select.option', -3, JText::_('(UTC -03:00) Brazil, Buenos Aires, Georgetown')),
 134              JHTML::_('select.option', -2, JText::_('(UTC -02:00) Mid-Atlantic')),
 135              JHTML::_('select.option', -1, JText::_('(UTC -01:00) Azores, Cape Verde Islands')),
 136              JHTML::_('select.option', 0, JText::_('(UTC 00:00) Western Europe Time, London, Lisbon, Casablanca')),
 137              JHTML::_('select.option', 1, JText::_('(UTC +01:00) Amsterdam, Berlin, Brussels, Copenhagen, Madrid, Paris')),
 138              JHTML::_('select.option', 2, JText::_('(UTC +02:00) Istanbul, Jerusalem, Kaliningrad, South Africa')),
 139              JHTML::_('select.option', 3, JText::_('(UTC +03:00) Baghdad, Riyadh, Moscow, St. Petersburg')),
 140              JHTML::_('select.option', 3.5, JText::_('(UTC +03:30) Tehran')),
 141              JHTML::_('select.option', 4, JText::_('(UTC +04:00) Abu Dhabi, Muscat, Baku, Tbilisi')),
 142              JHTML::_('select.option', 4.5, JText::_('(UTC +04:30) Kabul')),
 143              JHTML::_('select.option', 5, JText::_('(UTC +05:00) Ekaterinburg, Islamabad, Karachi, Tashkent')),
 144              JHTML::_('select.option', 5.5, JText::_('(UTC +05:30) Bombay, Calcutta, Madras, New Delhi, Colombo')),
 145              JHTML::_('select.option', 5.75, JText::_('(UTC +05:45) Kathmandu')),
 146              JHTML::_('select.option', 6, JText::_('(UTC +06:00) Almaty, Dhaka')),
 147              JHTML::_('select.option', 6.5, JText::_('(UTC +06:30) Yagoon')),
 148              JHTML::_('select.option', 7, JText::_('(UTC +07:00) Bangkok, Hanoi, Jakarta')),
 149              JHTML::_('select.option', 8, JText::_('(UTC +08:00) Beijing, Perth, Singapore, Hong Kong')),
 150              JHTML::_('select.option', 8.75, JText::_('(UTC +08:00) Ulaanbaatar, Western Australia')),
 151              JHTML::_('select.option', 9, JText::_('(UTC +09:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk')),
 152              JHTML::_('select.option', 9.5, JText::_('(UTC +09:30) Adelaide, Darwin, Yakutsk')),
 153              JHTML::_('select.option', 10, JText::_('(UTC +10:00) Eastern Australia, Guam, Vladivostok')),
 154              JHTML::_('select.option', 10.5, JText::_('(UTC +10:30) Lord Howe Island (Australia)')),
 155              JHTML::_('select.option', 11, JText::_('(UTC +11:00) Magadan, Solomon Islands, New Caledonia')),
 156              JHTML::_('select.option', 11.5, JText::_('(UTC +11:30) Norfolk Island')),
 157              JHTML::_('select.option', 12, JText::_('(UTC +12:00) Auckland, Wellington, Fiji, Kamchatka')),
 158              JHTML::_('select.option', 12.75, JText::_('(UTC +12:45) Chatham Island')),
 159              JHTML::_('select.option', 13, JText::_('(UTC +13:00) Tonga')),
 160              JHTML::_('select.option', 14, JText::_('(UTC +14:00) Kiribati')),);
 161          $lists['offset'] = JHTML::_('select.genericlist',  $timeoffset, 'offset', 'class="inputbox" size="1"', 'value', 'text', $row->offset);
 162  
 163          // MAIL SETTINGS
 164          $mailer = array (
 165              JHTML::_('select.option', 'mail', JText::_('PHP mail function')),
 166              JHTML::_('select.option', 'sendmail', JText::_('Sendmail')),
 167              JHTML::_('select.option', 'smtp', JText::_('SMTP Server')));
 168          $lists['mailer'] = JHTML::_('select.genericlist',  $mailer, 'mailer', 'class="inputbox" size="1"', 'value', 'text', $row->mailer);
 169          $smtpsecure = array (
 170              JHTML::_('select.option', 'none', JText::_('None')),
 171              JHTML::_('select.option', 'ssl', 'SSL'),
 172              JHTML::_('select.option', 'tls', 'TLS'));
 173          $lists['smtpsecure'] = JHTML::_('select.genericlist',  $smtpsecure, 'smtpsecure', 'class="inputbox" size="1"', 'value', 'text', (isset($row->smtpsecure) ? $row->smtpsecure : ''));
 174          $lists['smtpauth'] = JHTML::_('select.booleanlist', 'smtpauth', 'class="inputbox"', $row->smtpauth);
 175  
 176          // CACHE SETTINGS
 177          $lists['caching'] = JHTML::_('select.booleanlist', 'caching', 'class="inputbox"', $row->caching);
 178          jimport('joomla.cache.cache');
 179          $stores = JCache::getStores();
 180          $options = array();
 181          foreach($stores as $store) {
 182              $options[] = JHTML::_('select.option', $store, JText::_(ucfirst($store)) );
 183          }
 184          $lists['cache_handlers'] = JHTML::_('select.genericlist',  $options, 'cache_handler', 'class="inputbox" size="1"', 'value', 'text', $row->cache_handler);
 185  
 186          // MEMCACHE SETTINGS
 187          if (!empty($row->memcache_settings) && !is_array($row->memcache_settings)) {
 188              $row->memcache_settings = unserialize(stripslashes($row->memcache_settings));
 189          }
 190          $lists['memcache_persist'] = JHTML::_('select.booleanlist', 'memcache_settings[persistent]', 'class="inputbox"', @$row->memcache_settings['persistent']);
 191          $lists['memcache_compress'] = JHTML::_('select.booleanlist', 'memcache_settings[compression]', 'class="inputbox"', @$row->memcache_settings['compression']);
 192  
 193          // META SETTINGS
 194          $lists['MetaAuthor']     = JHTML::_('select.booleanlist', 'MetaAuthor', 'class="inputbox"', $row->MetaAuthor);
 195          $lists['MetaTitle']     = JHTML::_('select.booleanlist', 'MetaTitle', 'class="inputbox"', $row->MetaTitle);
 196  
 197          // SEO SETTINGS
 198          $lists['sef']         = JHTML::_('select.booleanlist', 'sef', 'class="inputbox"', $row->sef);
 199          $lists['sef_rewrite']     = JHTML::_('select.booleanlist', 'sef_rewrite', 'class="inputbox"', $row->sef_rewrite);
 200          $lists['sef_suffix']     = JHTML::_('select.booleanlist', 'sef_suffix', 'class="inputbox"', $row->sef_suffix);
 201  
 202          // FEED SETTINGS
 203          $formats    = array (JHTML::_('select.option', 'RSS2.0', JText::_('RSS')), JHTML::_('select.option', 'Atom', JText::_('Atom')));
 204          $summary    = array (JHTML::_('select.option', 1, JText::_('Full Text')), JHTML::_('select.option', 0, JText::_('Intro Text')),);
 205          $lists['feed_limit']    = JHTML::_('select.genericlist',  $listLimit, 'feed_limit', 'class="inputbox" size="1"', 'value', 'text', ($row->feed_limit ? $row->feed_limit : 10));
 206          $emailOptions = array (    JHTML::_('select.option', 'author', JText::_('Author Email')),
 207                                  JHTML::_('select.option', 'site', JText::_('Site Email')));
 208          $lists['feed_email'] = JHTML::_('select.genericlist', $emailOptions, 'feed_email', 'class="inputbox" size="1"', 'value', 'text', (@$row->feed_email) ? $row->feed_email : 'author');
 209  
 210          // SESSION SETTINGS
 211          $stores = JSession::getStores();
 212          $options = array();
 213          foreach($stores as $store) {
 214              $options[] = JHTML::_('select.option', $store, JText::_(ucfirst($store)) );
 215          }
 216          $lists['session_handlers'] = JHTML::_('select.genericlist',  $options, 'session_handler', 'class="inputbox" size="1"', 'value', 'text', $row->session_handler);
 217  
 218          // SHOW EDIT FORM
 219          ConfigApplicationView::showConfig($row, $lists);
 220      }
 221  
 222      /**
 223       * Save the configuration
 224       */
 225  	function save()
 226      {
 227          global $mainframe;
 228  
 229          // Check for request forgeries
 230          JRequest::checkToken() or jexit( 'Invalid Token' );
 231  
 232          // Set FTP credentials, if given
 233          jimport('joomla.client.helper');
 234          JClientHelper::setCredentialsFromRequest('ftp');
 235          $ftp = JClientHelper::getCredentials('ftp');
 236  
 237          //Save user and media manager settings
 238          $table =& JTable::getInstance('component');
 239  
 240          $userpost['params'] = JRequest::getVar('userparams', array(), 'post', 'array');
 241          $userpost['option'] = 'com_users';
 242          $table->loadByOption( 'com_users' );
 243          $table->bind( $userpost );
 244  
 245          // pre-save checks
 246          if (!$table->check()) {
 247              JError::raiseWarning( 500, $table->getError() );
 248              return false;
 249          }
 250  
 251          // save the changes
 252          if (!$table->store()) {
 253              JError::raiseWarning( 500, $table->getError() );
 254              return false;
 255          }
 256  
 257          $mediapost['params'] = JRequest::getVar('mediaparams', array(), 'post', 'array');
 258          $mediapost['option'] = 'com_media';
 259          //Sanitize $file_path and $image_path
 260          $file_path = $mediapost['params']['file_path'];
 261          $image_path = $mediapost['params']['image_path'];
 262          if(strpos($file_path, '/') === 0 || strpos($file_path, '\\') === 0) {
 263              //Leading slash.  Kill it and default to /media
 264              $file_path = 'images';
 265          }
 266          if(strpos($image_path, '/') === 0 || strpos($image_path, '\\') === 0) {
 267              //Leading slash.  Kill it and default to /media
 268              $image_path = 'images/stories';
 269          }
 270          if(strpos($file_path, '..') !== false) {
 271              //downward directories.  Kill it and default to images/
 272              $file_path = 'images';
 273          }
 274          if(strpos($image_path, '..') !== false) {
 275              //downward directories  Kill it and default to images/stories
 276              $image_path = 'images/stories';
 277          }
 278          $mediapost['params']['file_path'] = $file_path;
 279          $mediapost['params']['image_path'] = $image_path;
 280  
 281          $table->loadByOption( 'com_media' );
 282          $table->bind( $mediapost );
 283  
 284          // pre-save checks
 285          if (!$table->check()) {
 286              JError::raiseWarning( 500, $table->getError() );
 287              return false;
 288          }
 289  
 290          // save the changes
 291          if (!$table->store()) {
 292              JError::raiseWarning( 500, $table->getError() );
 293              return false;
 294          }
 295  
 296          $config = new JRegistry('config');
 297          $config_array = array();
 298  
 299          // SITE SETTINGS
 300          $config_array['offline']    = JRequest::getVar('offline', 0, 'post', 'int');
 301          $config_array['editor']        = JRequest::getVar('editor', 'tinymce', 'post', 'cmd');
 302          $config_array['list_limit']    = JRequest::getVar('list_limit', 20, 'post', 'int');
 303          $config_array['helpurl']    = JRequest::getVar('helpurl', 'http://help.joomla.org', 'post', 'string');
 304  
 305          // DEBUG
 306          $config_array['debug']        = JRequest::getVar('debug', 0, 'post', 'int');
 307          $config_array['debug_lang']    = JRequest::getVar('debug_lang', 0, 'post', 'int');
 308  
 309          // SEO SETTINGS
 310          $config_array['sef']            = JRequest::getVar('sef', 0, 'post', 'int');
 311          $config_array['sef_rewrite']    = JRequest::getVar('sef_rewrite', 0, 'post', 'int');
 312          $config_array['sef_suffix']        = JRequest::getVar('sef_suffix', 0, 'post', 'int');
 313  
 314          // FEED SETTINGS
 315          $config_array['feed_limit']        = JRequest::getVar('feed_limit', 10, 'post', 'int');
 316          $config_array['feed_email']        = JRequest::getVar('feed_email', 'author', 'post', 'word');
 317  
 318          // SERVER SETTINGS
 319          $config_array['secret']                = JRequest::getVar('secret', 0, 'post', 'string');
 320          $config_array['gzip']                = JRequest::getVar('gzip', 0, 'post', 'int');
 321          $config_array['error_reporting']    = JRequest::getVar('error_reporting', -1, 'post', 'int');
 322          $config_array['xmlrpc_server']        = JRequest::getVar('xmlrpc_server', 0, 'post', 'int');
 323          $config_array['log_path']            = JRequest::getVar('log_path', JPATH_ROOT.DS.'logs', 'post', 'string');
 324          $config_array['tmp_path']            = JRequest::getVar('tmp_path', JPATH_ROOT.DS.'tmp', 'post', 'string');
 325          $config_array['live_site']             = rtrim(JRequest::getVar('live_site','','post','string'), '/\\');
 326          $config_array['force_ssl']             = JRequest::getVar('force_ssl', 0, 'post', 'int');
 327  
 328          // LOCALE SETTINGS
 329          $config_array['offset']                = JRequest::getVar('offset', 0, 'post', 'float');
 330  
 331          // CACHE SETTINGS
 332          $config_array['caching']            = JRequest::getVar('caching', 0, 'post', 'int');
 333          $config_array['cachetime']            = JRequest::getVar('cachetime', 900, 'post', 'int');
 334          $config_array['cache_handler']        = JRequest::getVar('cache_handler', 'file', 'post', 'word');
 335          $config_array['memcache_settings']    = JRequest::getVar('memcache_settings', array(), 'post');
 336  
 337          // FTP SETTINGS
 338          $config_array['ftp_enable']    = JRequest::getVar('ftp_enable', 0, 'post', 'int');
 339          $config_array['ftp_host']    = JRequest::getVar('ftp_host', '', 'post', 'string');
 340          $config_array['ftp_port']    = JRequest::getVar('ftp_port', '', 'post', 'int');
 341          $config_array['ftp_user']    = JRequest::getVar('ftp_user', '', 'post', 'string');
 342          $config_array['ftp_pass']    = JRequest::getVar('ftp_pass', '', 'post', 'string', JREQUEST_ALLOWRAW);
 343          $config_array['ftp_root']    = JRequest::getVar('ftp_root', '', 'post', 'string');
 344  
 345          // DATABASE SETTINGS
 346          $config_array['dbtype']        = JRequest::getVar('dbtype', 'mysql', 'post', 'word');
 347          $config_array['host']        = JRequest::getVar('host', 'localhost', 'post', 'string');
 348          $config_array['user']        = JRequest::getVar('user', '', 'post', 'string');
 349          $config_array['db']        = JRequest::getVar('db', '', 'post', 'string');
 350          $config_array['dbprefix']    = JRequest::getVar('dbprefix', 'jos_', 'post', 'string');
 351  
 352          // MAIL SETTINGS
 353          $config_array['mailer']        = JRequest::getVar('mailer', 'mail', 'post', 'word');
 354          $config_array['mailfrom']    = JRequest::getVar('mailfrom', '', 'post', 'string');
 355          $config_array['fromname']    = JRequest::getVar('fromname', 'Joomla 1.5', 'post', 'string');
 356          $config_array['sendmail']    = JRequest::getVar('sendmail', '/usr/sbin/sendmail', 'post', 'string');
 357          $config_array['smtpauth']    = JRequest::getVar('smtpauth', 0, 'post', 'int');
 358          $config_array['smtpsecure']    = JRequest::getVar('smtpsecure', 'none', 'post', 'word');
 359          $smtpport                = JRequest::getVar('smtpport', '', 'post', 'int');
 360          $config_array['smtpport']    = $smtpport ? $smtpport : '25';
 361          $config_array['smtpuser']    = JRequest::getVar('smtpuser', '', 'post', 'string');
 362          $config_array['smtppass']    = JRequest::getVar('smtppass', '', 'post', 'string', JREQUEST_ALLOWRAW);
 363          $config_array['smtphost']    = JRequest::getVar('smtphost', '', 'post', 'string');
 364  
 365          // META SETTINGS
 366          $config_array['MetaAuthor']    = JRequest::getVar('MetaAuthor', 1, 'post', 'int');
 367          $config_array['MetaTitle']    = JRequest::getVar('MetaTitle', 1, 'post', 'int');
 368  
 369          // SESSION SETTINGS
 370          $config_array['lifetime']            = JRequest::getVar('lifetime', 0, 'post', 'int');
 371          $config_array['session_handler']    = JRequest::getVar('session_handler', 'none', 'post', 'word');
 372  
 373          //LANGUAGE SETTINGS
 374          //$config_array['lang']                = JRequest::getVar('lang', 'none', 'english', 'cmd');
 375          //$config_array['language']            = JRequest::getVar('language', 'en-GB', 'post', 'cmd');
 376  
 377          $config->loadArray($config_array);
 378  
 379          //override any possible database password change
 380          $config->setValue('config.password', $mainframe->getCfg('password'));
 381  
 382          // handling of special characters
 383          $sitename            = htmlspecialchars( JRequest::getVar( 'sitename', '', 'post', 'string' ), ENT_COMPAT, 'UTF-8' );
 384          $config->setValue('config.sitename', $sitename);
 385  
 386          $MetaDesc            = htmlspecialchars( JRequest::getVar( 'MetaDesc', '', 'post', 'string' ),  ENT_COMPAT, 'UTF-8' );
 387          $config->setValue('config.MetaDesc', $MetaDesc);
 388  
 389          $MetaKeys            = htmlspecialchars( JRequest::getVar( 'MetaKeys', '', 'post', 'string' ),  ENT_COMPAT, 'UTF-8' );
 390          $config->setValue('config.MetaKeys', $MetaKeys);
 391  
 392          // handling of quotes (double and single) and amp characters
 393          // htmlspecialchars not used to preserve ability to insert other html characters
 394          $offline_message    = JRequest::getVar( 'offline_message', '', 'post', 'string' );
 395          $offline_message    = JFilterOutput::ampReplace( $offline_message );
 396          $offline_message    = str_replace( '"', '&quot;', $offline_message );
 397          $offline_message    = str_replace( "'", '&#039;', $offline_message );
 398          $config->setValue('config.offline_message', $offline_message);
 399  
 400          //purge the database session table (only if we are changing to a db session store)
 401          if($mainframe->getCfg('session_handler') != 'database' && $config->getValue('session_handler') == 'database')
 402          {
 403              $table =& JTable::getInstance('session');
 404              $table->purge(-1);
 405          }
 406  
 407          // Get the path of the configuration file
 408          $fname = JPATH_CONFIGURATION.DS.'configuration.php';
 409  
 410          // Update the credentials with the new settings
 411          $oldconfig =& JFactory::getConfig();
 412          $oldconfig->setValue('config.ftp_enable', $config_array['ftp_enable']);
 413          $oldconfig->setValue('config.ftp_host', $config_array['ftp_host']);
 414          $oldconfig->setValue('config.ftp_port', $config_array['ftp_port']);
 415          $oldconfig->setValue('config.ftp_user', $config_array['ftp_user']);
 416          $oldconfig->setValue('config.ftp_pass', $config_array['ftp_pass']);
 417          $oldconfig->setValue('config.ftp_root', $config_array['ftp_root']);
 418          JClientHelper::getCredentials('ftp', true);
 419  
 420          if(!$config->get('caching') && $oldconfig->get('caching')) {
 421              $cache = JFactory::getCache();
 422              $cache->clean();
 423          }
 424  
 425          // Try to make configuration.php writeable
 426          jimport('joomla.filesystem.path');
 427          if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0644')) {
 428              JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php writable');
 429          }
 430  
 431          // Get the config registry in PHP class format and write it to configuation.php
 432          jimport('joomla.filesystem.file');
 433          if (JFile::write($fname, $config->toString('PHP', 'config', array('class' => 'JConfig')))) {
 434              $msg = JText::_('The Configuration Details have been updated');
 435          } else {
 436              $msg = JText::_('ERRORCONFIGFILE');
 437          }
 438  
 439          // Redirect appropriately
 440          $task = $this->getTask();
 441          switch ($task) {
 442              case 'apply' :
 443                  $this->setRedirect('index.php?option=com_config', $msg);
 444                  break;
 445  
 446              case 'save' :
 447              default :
 448                  $this->setRedirect('index.php', $msg);
 449                  break;
 450          }
 451  
 452          // Try to make configuration.php unwriteable
 453          //if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0444')) {
 454          if ($config_array['ftp_enable']==0 && !$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0444')) {
 455              JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php unwritable');
 456          }
 457      }
 458  
 459      /**
 460       * Cancel operation
 461       */
 462  	function cancel()
 463      {
 464          // Set FTP credentials, if given
 465          jimport('joomla.client.helper');
 466          JClientHelper::setCredentialsFromRequest('ftp');
 467  
 468          $this->setRedirect( 'index.php' );
 469      }
 470  
 471  	function refreshHelp()
 472      {
 473          jimport('joomla.filesystem.file');
 474  
 475          // Set FTP credentials, if given
 476          jimport('joomla.client.helper');
 477          JClientHelper::setCredentialsFromRequest('ftp');
 478  
 479          if (($data = file_get_contents('http://help.joomla.org/helpsites-15.xml')) === false ) {
 480              $this->setRedirect('index.php?option=com_config', JText::_('HELPREFRESH ERROR FETCH'), 'error');
 481          } else if (!JFile::write(JPATH_BASE.DS.'help'.DS.'helpsites-15.xml', $data)) {
 482              $this->setRedirect('index.php?option=com_config', JText::_('HELPREFRESH ERROR STORE'), 'error');
 483          } else {
 484              $this->setRedirect('index.php?option=com_config', JText::_('HELPREFRESH SUCCESS'));
 485          }
 486      }
 487  }


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1