Пример #1
0
 /**
  * Read data from the session dirver
  *
  * @param string		$id		The session id key.
  * @return array
  */
 public function read($id)
 {
     if ($this->has($id)) {
         return unserialize(\CCFile::read($this->file_path($id)));
     }
     return array();
 }
Пример #2
0
 /**
  * Compile the view
  *
  * @param string 		$builder
  * @param string 		$view_file
  */
 public static function compile($builder, $view_file)
 {
     if (!isset(static::$_view_builders[$builder])) {
         throw new CCException("CCView_Builder - view builder '" . $builder . "' is not registerd.");
     }
     $builder = static::$_view_builders[$builder];
     if (!class_exists($builder)) {
         throw new CCException("CCView_Builder - invalid view builder '" . $builder . "'.");
     }
     $builder = new $builder(CCFile::read($view_file));
     return $builder->compile();
 }
Пример #3
0
 /**
  * Try to generate a security key in the main config file
  *
  * @param array 		$params 
  */
 public function action_security_key($params)
 {
     $path = \CCPath::config('main.config' . EXT);
     // Check if the file exists
     if (!file_exists($path)) {
         $this->error('Could not find main configuration file.');
         return;
     }
     // Now try to replace the placeholder with
     // an new generated key
     $data = \CCFile::read($path);
     if (strpos($data, '{{security salt here}}') === false) {
         $this->error('The key has already been generated or set.');
         return;
     }
     $data = str_replace('{{security salt here}}', \CCStr::random(32, 'password'), $data);
     // write the data back down
     \CCFile::write($path, $data);
     $this->success('The key has been generated.');
 }
Пример #4
0
 /**
  * read a json file
  *
  * @param string			$path
  * @param bool			$as_array
  * @return array|object
  */
 public static function read($path, $as_array = true)
 {
     return static::decode(CCFile::read($path), $as_array);
 }