openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

ConfigurationAction.class.php (4290B)


      1 <?php
      2 
      3 namespace cms\action;
      4 
      5 // OpenRat Content Management System
      6 // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
      7 //
      8 // This program is free software; you can redistribute it and/or
      9 // modify it under the terms of the GNU General Public License
     10 // as published by the Free Software Foundation; version 2.
     11 //
     12 // This program is distributed in the hope that it will be useful,
     13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 // GNU General Public License for more details.
     16 //
     17 // You should have received a copy of the GNU General Public License
     18 // along with this program; if not, write to the Free Software
     19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     20 
     21 use Session;
     22 /**
     23  * Action-Klasse fuer die Bearbeitung eines Template-Elementes.
     24  * 
     25  * @author Jan Dankert
     26  * @package openrat.actions
     27  */
     28 class ConfigurationAction extends BaseAction
     29 {
     30 	public $security = Action::SECURITY_ADMIN;
     31 	
     32 	/**
     33 	 * Konstruktor
     34 	 */
     35 	function __construct()
     36 	{
     37         parent::__construct();
     38 	}
     39 
     40 
     41 	public function editView()
     42 	{
     43 		$this->nextSubAction('show');
     44 
     45 	}
     46 	
     47 	
     48 	/**
     49 	 * Anzeigen des Elementes
     50 	 */
     51 	public function showView()
     52 	{
     53         require_once( OR_MODULES_DIR.'/util/config-default.php');
     54         $conf = createDefaultConfig();
     55         $conf_default = $conf;
     56 		
     57 		$conf_cms = Session::getConfig();
     58 
     59         // Language are to much entries
     60         unset($conf_cms['language']);
     61 
     62 
     63 		$conf_cms['system'] = $this->getSystemConfiguration();
     64 
     65 		//$split = "\xC2\xA0"."\xC2\xA0"."\xC2\xBB"."\xC2\xA0"."\xC2\xA0";
     66 		//$flatDefaultConfig = \ArrayUtils::flattenArray('', $conf_default       , $split );
     67 		//$flatCMSConfig     = \ArrayUtils::flattenArray('', Session::getConfig(), $split );
     68 		//$flatConfig        = \ArrayUtils::flattenArray('', $conf_cms           , $split );
     69 
     70 		$pad = str_repeat("\xC2\xA0",10); // Hard spaces
     71 
     72 		$flatDefaultConfig = \ArrayUtils::dryFlattenArray( $conf_default       , $pad );
     73 		$flatCMSConfig     = \ArrayUtils::dryFlattenArray( Session::getConfig(), $pad );
     74 		$flatConfig        = \ArrayUtils::dryFlattenArray( $conf_cms           , $pad );
     75 
     76 		$config = array();
     77 		foreach( $flatConfig as $key=>$val )
     78 			$config[] = array( 'key'=>$key,'value'=>substr($key,-8)=='password'?'*******************':$val,'class'=>(empty($flatCMSConfig[$key])?'readonly':(isset($flatDefaultConfig[$key]) && $flatDefaultConfig[$key]==$flatConfig[$key]?'default':'changed')));
     79 
     80 		$this->setTemplateVar('config',$config );
     81 	}
     82 
     83 
     84     /**
     85      * Die Konfiguration als YAML-String anzeigen.
     86      */
     87 	public function srcView()
     88     {
     89         $conf = Session::getConfig();
     90         unset( $conf['language']);
     91 
     92         // Mask passwords.
     93         array_walk_recursive($conf,function(&$item,$key)
     94         {
     95             if($key=='password'){
     96                 $item='*************';
     97             }
     98         });
     99 
    100         $this->setTemplateVar('source',\YAML::dump($conf,4,0,true));
    101     }
    102 
    103 
    104 
    105     /**
    106      * Reads system configuration.
    107      * @return array
    108      */
    109     private function getSystemConfiguration()
    110     {
    111         $conf['server'] = array('time' => date('r'),
    112             'name' => php_uname(),
    113             'os' => php_uname('s'),
    114             'host' => php_uname('n'),
    115             'release' => php_uname('r'),
    116             'machine' => php_uname('m'),
    117             'owner' => get_current_user(),
    118             'pid' => getmypid());
    119 
    120 
    121         $conf['interpreter'] = array('version' => phpversion(),
    122             'SAPI' => php_sapi_name(),
    123             'session-name' => session_name(),
    124             'magic_quotes_gpc' => get_magic_quotes_gpc(),
    125             'loaded_ini_file' => php_ini_loaded_file(),
    126             'magic_quotes_runtime' => get_magic_quotes_runtime());
    127 
    128         $conf['interpreter']['server'] = $_SERVER;
    129         $conf['interpreter']['environment'] = $_ENV;
    130         $conf['interpreter']['temp_dir'] = sys_get_temp_dir();
    131 
    132         $conf['interpreter']['configuration'] = ini_get_all();
    133         $conf['resources'] = getrusage();
    134 
    135         $extensions = get_loaded_extensions();
    136         asort($extensions);
    137 
    138         foreach ($extensions as $id => $extensionName)
    139             $conf['interpreter']['extension'][$extensionName] = 'loaded';
    140 
    141         return $conf;
    142     }
    143 
    144 }
    145 
    146 
    147 
    148 
    149 ?>