Example #1
0
 public function SaveProfile(Button $button)
 {
     $form = $button->getForm();
     $values = $form->getValues();
     try {
         if ($this->mode == 'superadmin') {
             if (isset($values['password_new'])) {
                 if ($values['password'] == $this->profile_data['password']) {
                     if ($values['password_new'] == $values['password_new_confirm']) {
                         $values['password'] = $values['password_new'];
                     } else {
                         throw new AuthenticationException('New password does not match.');
                     }
                 } else {
                     throw new AuthenticationException('Old password does not match with provided password.');
                 }
             } else {
                 unset($values['password']);
             }
             unset($values['password_new']);
             unset($values['password_new_confirm']);
             $this->config_data['admin'] = array_merge($this->config_data['admin'], $values);
             $config = new Config();
             $config->import($this->config_data);
             $config->save(APP_DIR . '/config/admin.ini', 'admin');
             $this->flash('Super admin profile updated');
         }
     } catch (Exception $e) {
         $this->flash($e->getMessage(), 'error');
     }
     $this->end();
 }
Example #2
0
 public function saveMetaData($form)
 {
     $values = $form->getValues();
     $data = ConfigAdapterIni::load(APP_DIR . '/config/site.ini', 'site');
     try {
         foreach ($values as $key => $value) {
             $data['key'] = $value;
         }
         $metaConfig = new Config();
         $metaConfig->import($data);
         $metaConfig->save(APP_DIR . '/config/site.ini', 'site');
         $this->flash('Metadata saved');
     } catch (InvalidArgumentException $e) {
         $this->flash($e->getMessage);
     }
 }
 /**
  * Import config action
  *
  * @return void
  */
 function w3tc_config_import()
 {
     $error = '';
     $config = new Config();
     if (!isset($_FILES['config_file']['error']) || $_FILES['config_file']['error'] == UPLOAD_ERR_NO_FILE) {
         $error = 'config_import_no_file';
     } elseif ($_FILES['config_file']['error'] != UPLOAD_ERR_OK) {
         $error = 'config_import_upload';
     } else {
         $imported = $config->import($_FILES['config_file']['tmp_name']);
         if (!$imported) {
             $error = 'config_import_import';
         }
     }
     if ($error) {
         Util_Admin::redirect(array('w3tc_error' => $error), true);
         return;
     }
     Util_Admin::config_save($this->_config, $config);
     Util_Admin::redirect(array('w3tc_note' => 'config_import'), true);
 }
Example #4
0
/**
 * 框架配置管理
 *
 * @copyright   Copyright © 2014 Vipshen
 * @author      Vipshen <*****@*****.**>
 * @version     $Id: Config.php 406 2014-09-01 06:28:04Z Vipshen $
 * @package     system
*/
namespace hyena;

class Config
{
    private static $_config = array();
    public static function import(array $config)
    {
        self::$_config = array_merge(self::$_config, $config);
    }
    public static function get($name = null, $default = null)
    {
        $name = (string) $name;
        return array_key_exists($name, self::$_config) ? self::$_config[$name] : $default;
    }
    public static function set($name, $value)
    {
    }
}
// 载入框架默认配置
if (file_exists(__DIR__ . '/_config/default.php')) {
    Config::import(require __DIR__ . '/_config/default.php');
}
Example #5
0
 public function testNonExistsFile()
 {
     Config::import('test', '/tmp/' . uniqid());
     $this->setExpectedException('InvalidArgumentException');
     Config::export('test');
 }
Example #6
0
 public function handleActivateSiteTheme($theme)
 {
     $data = ConfigAdapterIni::load(APP_DIR . '/config/site.ini', 'site');
     $data['theme'] = $theme;
     $themeConfig = new Config();
     $themeConfig->import($data);
     $themeConfig->save(APP_DIR . '/config/site.ini', 'site');
     $this->flash('Site theme ' . $theme . ' activated');
 }