Esempio n. 1
0
 /**
  * Generic function for updating the configuration.php file
  *
  * @param $param string
  * @param $value string|int
  */
 private function _setConfigParam($param, $value, $type = 'int')
 {
     // Require more complex methods for dealing with files
     require 'bfFilesystem.php';
     if ($type == 'int') {
         if ($value == "true") {
             $value = 1;
         } else {
             if ($value == "false") {
                 $value = 0;
             } else {
                 $value = 0;
             }
         }
     }
     $config = JFactory::getConfig();
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $config->set($param, $value);
     } else {
         $config->setValue('config.' . $param, $value);
     }
     $newConfig = $config->toString('PHP', 'config', array('class' => 'JConfig'));
     /**
      * On some occasions, Joomla! 1.6+ ignores the configuration and
      * produces "class c". Let's fix this!
      */
     $newConfig = str_replace('class c {', 'class JConfig {', $newConfig);
     $newConfig = str_replace('namespace c;', '', $newConfig);
     // Set the correct location of the file
     $filename = JPATH_ROOT . DIRECTORY_SEPARATOR . 'configuration.php';
     // Try to write out the configuration.php
     $result = Bf_Filesystem::_write($filename, $newConfig);
     if ($result !== FALSE) {
         bfEncrypt::reply('success', array($param => $value));
     } else {
         bfEncrypt::reply(bfReply::ERROR, array('msg' => 'Could Not Save Config value for ' . $param));
     }
 }