protected function _configTestFile($path = null, $baseKey = null)
 {
     if ($path === null) {
         $path = CakePlugin::path('YamlReader') . 'Test' . DS . 'files' . DS;
     }
     Configure::config('YamlTestConfig', new YamlReader($path, $baseKey));
 }
Example #2
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     Configure::config('configini', new IniReader());
     Configure::load('config.ini', 'configini');
     /*
      * "Auth" logic
      * Generate and test the security key
      */
     $api = json_decode($this->Setting->getOption('api'));
     if (empty($api) || empty($api->enabled) || !$api->enabled) {
         return $this->api401(__('API is disabled'));
     }
     // No key, refuse connexion
     if (empty($this->request->params['named']) || empty($this->request->params['named']['key'])) {
         return $this->api401(__('Security key is missing'));
     }
     // Get the key and remote it from the params
     $theirSecurityKey = $this->request->params['named']['key'];
     unset($this->request->params['named']['key']);
     // generate the security key
     $paramsUrl = '/' . $this->request->params['controller'] . '/' . $this->request->params['action'];
     $paramsUrl .= $this->Tools->paramsToUrl($this->request->params['named']);
     $securityKey = hash_hmac('sha1', $paramsUrl, $api->privateKey);
     if ($theirSecurityKey != $securityKey) {
         return $this->api401(__('Wrong security key'));
     }
 }
 protected function _configTestFile($domain = null, $path = null, $baseKey = null)
 {
     if ($path === null) {
         $path = App::pluginPath('YamlReader') . 'Test' . DS . 'files' . DS;
     }
     Configure::config('I18nYamlTestConfig', new I18nYamlReader($domain, $path, $baseKey));
 }
 public function beforeFilter()
 {
     parent::beforeFilter();
     App::uses('CloggyModuleConfigReader', 'CustomConfigure');
     Configure::config('cloggy', new CloggyModuleConfigReader('CloggySearch'));
     //disable auto render
     $this->autoRender = false;
 }
Example #5
0
 public function setupSettings($appDir)
 {
     if (!$this->setupSettings) {
         return;
     }
     $Setting = ClassRegistry::init('Settings.Setting');
     $Setting->settingsPath = $appDir . 'Config' . DS . 'settings.json';
     Configure::drop('settings');
     Configure::config('settings', new CroogoJsonReader(dirname($Setting->settingsPath) . DS));
     $Setting->writeConfiguration();
 }
Example #6
0
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     App::build(array('Plugin' => array(TESTS . 'test_app' . DS . 'Plugin' . DS), 'View' => array(TESTS . 'test_app' . DS . 'View' . DS)), App::PREPEND);
     CakePlugin::unload('Install');
     CakePlugin::load('Example');
     Configure::write('Acl.database', 'test');
     $Setting = ClassRegistry::init('Settings.Setting');
     $Setting->settingsPath = TESTS . 'test_app' . DS . 'Config' . DS . 'settings.json';
     Configure::drop('settings');
     Configure::config('settings', new CroogoJsonReader(dirname($Setting->settingsPath) . DS));
     $Setting->writeConfiguration();
 }
Example #7
0
 function __construct()
 {
     Configure::config('configini', new IniReader());
     Configure::load('config.ini', 'configini');
     if ($databaseConf = Configure::read('Database')) {
         $this->default['datasource'] = $databaseConf['datasource'];
         $this->default['host'] = $databaseConf['host'];
         $this->default['login'] = $databaseConf['login'];
         $this->default['password'] = $databaseConf['password'];
         $this->default['database'] = $databaseConf['database'];
         $this->default['prefix'] = $databaseConf['prefix'];
         $this->default['port'] = $databaseConf['port'];
     }
 }
Example #8
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     // Check conf file
     if (!file_exists('../Config/config.ini')) {
         file_put_contents('../Config/config.ini', '');
     }
     Configure::config('configini', new IniReader());
     Configure::load('config.ini', 'configini');
     // If config isn't set, redirect to install process to create one
     if (!Configure::read('Settings.installed') && strtolower($this->plugin) != 'install') {
         $this->Session->setFlash(__('MushRaider is ready for install, what about you ?'), 'flash_info');
         $this->redirect('/install/step/1');
     }
     // Language
     $language = Configure::read('Settings.language');
     $language = $this->Cookie->check('Lang') ? $this->Cookie->read('Lang') : $language;
     $language = !empty($language) ? $language : 'eng';
     Configure::write('Config.language', $language);
     // Some usefull infos
     Configure::write('Config.maxFileSize', ini_get('upload_max_filesize'));
     Configure::write('Config.maxPostSize', ini_get('post_max_size'));
     Configure::write('Config.appUrl', rtrim('http://' . $_SERVER['HTTP_HOST'] . $this->webroot, '/'));
     // Timezone
     date_default_timezone_set($this->Setting->getOption('timezone'));
     // Log in user
     if ($this->Session->check('User.id')) {
         $userID = $this->Session->read('User.id');
         if (!empty($userID)) {
             $params = array();
             $params['recursive'] = 1;
             $params['contain']['Role'] = array();
             $params['contain']['Character'] = array();
             $params['conditions']['User.id'] = $userID;
             if ($this->user = $this->User->find('first', $params)) {
                 $this->user['User']['can'] = $this->Role->getPermissions($this->user['User']['role_id']);
             }
         } else {
             $this->Session->delete('User.id');
         }
     }
     // Is a patch needed ?
     if (strtolower($this->name) != 'patcher' && strtolower($this->name) != 'auth') {
         $this->Patcher->patchNeeded();
     }
     $this->pageTitle = $this->Setting->getOption('title');
     Configure::write('Config.email', json_decode($this->Setting->getOption('email')));
     Configure::write('Config.notifications', json_decode($this->Setting->getOption('notifications')));
 }
Example #9
0
 /**
  * Constructor
  *
  * @param mixed $id The id to start the model on.
  * @param string $table The table to use for this model.
  * @param string $ds The connection name this model is connected to.
  */
 public function __construct($id = false, $table = null, $ds = null)
 {
     parent::__construct($id, $table, $ds);
     Configure::config('default', new PhpReader(ROOT . '/plugins/Tools/Config/'));
     Configure::load('google', 'default');
     set_include_path(ROOT . '/plugins/Tools/Lib/' . PATH_SEPARATOR . get_include_path());
     require_once 'Google/Client.php';
     require_once 'Google/Service/Calendar.php';
     $this->__client = new Google_Client();
     $this->__client->setClientId(Configure::read('google_client_id'));
     $this->__client->setClientSecret(Configure::read('google_client_secret'));
     $this->__client->setRedirectUri(Configure::read('google_redirect_url'));
     $this->__client->setAccessType('offline');
     $this->__client->addScope("https://www.googleapis.com/auth/calendar");
     $this->__service = new Google_Service_Calendar($this->__client);
 }
Example #10
0
 /**
  * Constructor
  *
  * @param mixed $id The id to start the model on.
  * @param string $table The table to use for this model.
  * @param string $ds The connection name this model is connected to.
  */
 public function __construct($id = false, $table = null, $ds = null)
 {
     parent::__construct($id, $table, $ds);
     Configure::config('default', new PhpReader());
     Configure::load('mailchimp', 'default');
     // Set-up mailchimp
     $this->apikey = Configure::read('mailchimp_apiKey');
     $this->__api = new MCAPI($this->apikey, true);
     // Bit hacky, we need to tell the MCAPI class
     // which dbConfig to use, but we can't add a method on
     // to the production MCAPI class, so we have to check if
     // it exists first.
     if (method_exists($this->__api, 'setConfig')) {
         $this->__api->setConfig($this->useDbConfig);
     }
 }
Example #11
0
 /**
  * __construct
  * @param array $config
  * @param string $path
  */
 public function __construct($config = array(), $path = null)
 {
     if (!$path) {
         $path = APP . 'Config' . DS;
     }
     Configure::delete('Oven');
     if (empty($config)) {
         $try = array($path . 'oven.json', $path . 'oven.php');
         foreach ($try as $cfg) {
             if (file_exists($cfg)) {
                 $this->path = $cfg;
                 $ext = strrchr($cfg, '.');
                 switch ($ext) {
                     case '.json':
                         App::uses('File', 'Utility');
                         $cfg = new File($cfg);
                         $this->config = json_decode($cfg->read(), true);
                         break;
                     case '.yaml':
                         App::import('Vendor', 'Oven.spyc/spyc');
                         $this->config = Spyc::YAMLLoad($cfg);
                         break;
                     default:
                         App::uses('PhpReader', 'Configure');
                         Configure::config('oven', new PhpReader(dirname($cfg) . DS));
                         Configure::load('oven', 'oven');
                         $this->config = Configure::read('Oven');
                         break;
                 }
                 break;
             }
         }
         // IF NO CONFIG COPY OVER SAMPLE
         if (empty($this->config)) {
             if (copy(CakePlugin::path('Oven') . 'Config' . DS . 'config.json', $path . 'oven.json')) {
                 $this->__construct();
             }
         }
     } else {
         $this->config = $config;
     }
     $this->config = $this->_default($this->config);
     Configure::write('Oven', $this->config);
 }
 public function beforeFilter()
 {
     parent::beforeFilter();
     if (!file_exists('../Config/config.ini')) {
         file_put_contents('../Config/config.ini', '');
     }
     Configure::config('configini', new IniReader());
     Configure::load('config.ini', 'configini');
     // If config already set, redirect to root
     if (file_exists('../Config/config.ini')) {
         if (Configure::read('Settings.installed')) {
             $this->Session->setFlash(__('MushRaider can see the database config, why do you want to install ?'), 'flash_warning');
             $this->redirect('/');
         }
     }
     $this->set('title_for_layout', __('MushRaider Installer'));
     $languages = array('eng' => 'English', 'fra' => 'Français', 'deu' => 'Deutsch');
     $this->set('languages', $languages);
 }
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     App::build(array('Plugin' => array(TESTS . 'test_app' . DS . 'Plugin' . DS), 'View' => array(TESTS . 'test_app' . DS . 'View' . DS)), App::PREPEND);
     if (!isset($_SERVER['REMOTE_ADDR'])) {
         $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     }
     CakePlugin::unload('Install');
     CakePlugin::load(array('Users'), array('bootstrap' => true));
     CakePlugin::load('Example');
     Configure::write('Acl.database', 'test');
     $Setting = ClassRegistry::init('Settings.Setting');
     $Setting->settingsPath = TESTS . 'test_app' . DS . 'Config' . DS . 'settings.json';
     Configure::drop('settings');
     Configure::config('settings', new CroogoJsonReader(dirname($Setting->settingsPath) . DS));
     CakeLog::drop('stdout');
     CakeLog::drop('stderr');
     $Setting->writeConfiguration();
 }
Example #14
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     Configure::config('default', new PhpReader());
     Configure::load('automation', 'default');
     //Configure::load('routes', 'default');
     $phpSelf = $_SERVER['PHP_SELF'];
     $selfParts = explode('/', $phpSelf);
     $this->__rootUrl = '';
     $partIndex = 0;
     $firstPart = true;
     $numParts = count($selfParts);
     while ($selfParts[$partIndex] != 'app' && $partIndex < $numParts) {
         if ($selfParts[$partIndex] != '') {
             if (!$firstPart) {
                 $this->__rootUrl .= '/';
             }
             $firstPart = false;
             $this->__rootUrl .= $selfParts[$partIndex];
         }
         $partIndex++;
     }
     $this->__webDriver = new PHPWebDriver_WebDriver(Configure::read('automation_driver_selenium_url'));
     new CakeRequest();
 }
 /**
  * test reader() throwing exceptions on missing interface.
  *
  * @expectedException PHPUnit_Framework_Error
  * @return void
  */
 public function testReaderExceptionOnIncorrectClass()
 {
     $reader = new StdClass();
     Configure::config('test', $reader);
 }
Example #16
0
 /**
  * Find the related code folding values for $char
  *
  * @param int $char decimal value of character
  * @param string $type Type 'lower' or 'upper'. Defaults to 'lower'.
  * @return array|null
  */
 protected static function _find($char, $type = 'lower')
 {
     $found = array();
     if (!isset(self::$_codeRange[$char])) {
         $range = self::_codepoint($char);
         if ($range === false) {
             return null;
         }
         if (!Configure::configured('_cake_core_')) {
             App::uses('PhpReader', 'Configure');
             Configure::config('_cake_core_', new PhpReader(CAKE . 'Config' . DS));
         }
         Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_');
         self::$_caseFold[$range] = Configure::read($range);
         Configure::delete($range);
     }
     if (!self::$_codeRange[$char]) {
         return null;
     }
     self::$_table = self::$_codeRange[$char];
     $count = count(self::$_caseFold[self::$_table]);
     for ($i = 0; $i < $count; $i++) {
         if ($type === 'lower' && self::$_caseFold[self::$_table][$i][$type][0] === $char) {
             $found[] = self::$_caseFold[self::$_table][$i];
         } elseif ($type === 'upper' && self::$_caseFold[self::$_table][$i][$type] === $char) {
             $found[] = self::$_caseFold[self::$_table][$i];
         }
     }
     return $found;
 }
 /**
  * Load module config menus
  * @param string $moduleName
  * @param string $key
  * @return null|array
  */
 public function loadConfigModuleMenus($moduleName, $key)
 {
     App::uses('CloggyModuleConfigReader', 'CustomConfigure');
     Configure::config('cloggy', new CloggyModuleConfigReader($moduleName));
     Configure::load($key, 'cloggy');
     $configs = Configure::read('Cloggy');
     if (array_key_exists($moduleName, $configs) && array_key_exists($key, $configs[$moduleName])) {
         return $configs[$moduleName][$key];
     } else {
         return null;
     }
 }
 /**
  * Load info.ini for requested module
  * @access private
  * @param string $moduleName
  */
 private function __configureModuleInfo($moduleName)
 {
     App::uses('IniReader', 'Configure');
     Configure::config('ini', new IniReader(CLOGGY_PATH_MODULE . $moduleName . DS));
     Configure::load('info.ini', 'ini');
 }
Example #19
0
Cache::config('nodes_index', $cacheConfig);
Cache::config('contacts_view', $cacheConfig);
/**
 * Failed login attempts
 *
 * Default is 5 failed login attempts in every 5 minutes
 */
$failedLoginDuration = 300;
Configure::write('User.failed_login_limit', 5);
Configure::write('User.failed_login_duration', $failedLoginDuration);
Cache::config('users_login', array_merge($cacheConfig, array('duration' => '+' . $failedLoginDuration . ' seconds')));
/**
 * Settings
 */
App::uses('CroogoJsonReader', 'Configure');
Configure::config('settings', new CroogoJsonReader());
if (file_exists(APP . 'Config' . DS . 'settings.json')) {
    Configure::load('settings', 'settings');
}
/**
 * Locale
 */
Configure::write('Config.language', Configure::read('Site.locale'));
/**
 * Setup custom paths
 */
if ($theme = Configure::read('Site.theme')) {
    App::build(array('View/Helper' => array(App::themePath($theme) . 'Helper' . DS)));
}
/**
 * List of core plugins
Example #20
0
 /**
  * Perform initial setup.
  * 
  * @param Model $model The model we're being attached to.
  * @param array $settings Any settings passed from the model.
  * @link http://book.cakephp.org/2.0/en/models/behaviors.html#creating-a-behavior-callback
  */
 public function setup(Model $model, $settings = array())
 {
     Configure::config('default', new PhpReader());
     Configure::load('krb', 'default');
     $this->__krbObj = new Krb5Auth(Configure::read('krb_username'), Configure::read('krb_tab'), Configure::read('krb_relm'));
 }
 public function startup(Controller $controller)
 {
     parent::startup($controller);
     //configure config
     Configure::config('cloggy', new CloggyModuleConfigReader('CloggySearch'));
 }
Example #22
0
 /**
  * The credits page.  Pulls from the config files, which plugins can contribute to
  */
 public function credits()
 {
     Configure::config('default', new PhpReader());
     Configure::load('credits', 'default');
     $media = Configure::read('hms_media');
     $this->set('media', $media);
 }
 /**
  * Test dumping only some of the data.
  *
  * @return void
  */
 public function testDumpPartial()
 {
     Configure::config('test_reader', new PhpReader(TMP));
     $result = Configure::dump('config_test.php', 'test_reader', array('Error'));
     $this->assertTrue($result > 0);
     $result = file_get_contents(TMP . 'config_test.php');
     $this->assertContains('<?php', $result);
     $this->assertContains('$config = ', $result);
     $this->assertContains('Error', $result);
     $this->assertNotContains('debug', $result);
     if (file_exists(TMP . 'config_test.php')) {
         unlink(TMP . 'config_test.php');
     }
 }
 public function beforeFilter()
 {
     parent::beforeFilter();
     App::uses('CloggyModuleConfigReader', 'CustomConfigure');
     Configure::config('cloggy', new CloggyModuleConfigReader('CloggySearch'));
 }
Example #25
0
 *
 * This file should load/create any application wide configuration settings, such as 
 * Caching, Logging, loading additional configuration files.
 *
 * You should also use this file to include any files that provide global functions/constants
 * that your application uses.
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Config
 * @since         CakePHP(tm) v 0.10.8.2117
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
# Setup a 'default' cache configuration for use in the application.
Cache::config('default', array('engine' => 'File'));
App::uses('IniReader', 'Configure', 'Security');
Configure::config('default', new IniReader(APP . 'Config' . DS));
# Load additional config files.
Configure::load('arcs');
Configure::load('assets');
define("TWIG_VIEW_CACHE", APP . 'tmp');
define("LIB", CORE_PATH);
CakePlugin::load('TwigView');
Example #26
0
 *
 * Production Mode:
 * 	0: No error messages, errors, or warnings shown. Flash messages redirect.
 *
 * Development Mode:
 * 	1: Errors and warnings shown, model caches refreshed, flash messages halted.
 * 	2: As in 1, but also with full debug messages and SQL output.
 *
 * In production mode, flash messages redirect after a time interval.
 * In development mode, you need to click the flash message to continue.
 */
Configure::write('debug', 2);
// Carrega arquivos do projeto
if (file_exists(APP . 'Config' . DS . 'config.php')) {
    App::uses('PhpReader', 'Configure');
    Configure::config('PhpReader', new PhpReader());
    Configure::load('config', 'PhpReader');
}
/**
 * Configure the Error handler used to handle errors for your application. By default
 * ErrorHandler::handleError() is used. It will display errors using Debugger, when debug > 0
 * and log errors with CakeLog when debug = 0.
 *
 * Options:
 *
 * - `handler` - callback - The callback to handle errors. You can set this to any callable type,
 *   including anonymous functions.
 *   Make sure you add App::uses('MyHandler', 'Error'); when using a custom handler class
 * - `level` - int - The level of errors you are interested in capturing.
 * - `trace` - boolean - Include stack traces for errors in log files.
 *
Example #27
0
<?php

App::uses('PhpReader', 'Configure');
Configure::config('default', new PhpReader());
Configure::load('Jcamp.jcamp', 'default');
// TODO: The config files are not loading correctly...
class JcampAppController extends AppController
{
}
Example #28
0
 /**
  * Setup configuration reader.
  *
  * @param mixed $config Optional. Reader configuration options as array or just name (i.e. ini)
  * @param boolean $default Optional. If true, make this configuration the default one.
  * @return array Full configuration settings.
  */
 public static function reader($config = null, $default = false)
 {
     if (empty($config)) {
         $config = array('id' => 'json', 'className' => 'JsonReader', 'location' => 'Common.Configure');
     }
     if (!is_array($config)) {
         $config = array('id' => $config, 'className' => ucfirst($config) . 'Reader', 'location' => 'Configure');
     }
     extract($config);
     if (Configure::configured($id)) {
         throw new ConfigureException(__d('_common_', "A reader with the '%s' name already exists.", $id));
     }
     foreach (array('id', 'className', 'location') as $var) {
         if (!isset(${$var}) || empty(${$var})) {
             throw new ConfigureException(__d('_common_', "Reader configuration missing the '%s' key.", $key));
         }
     }
     App::uses($className, $location);
     Configure::config($default ? 'default' : $id, new $className());
     return $config;
 }
Example #29
0
App::uses('BcControllerEventListener', 'Event');
App::uses('BcModelEventListener', 'Event');
App::uses('BcViewEventListener', 'Event');
App::uses('BcHelperEventListener', 'Event');
App::uses('BcPluginAppController', 'Controller');
App::uses('BcPluginAppModel', 'Model');
App::uses('BcManagerShell', 'Console/Command');
App::uses('CakeRequest', 'Network');
/**
 * 設定ファイル読み込み
 * install.php で設定している為、一旦読み込んで再設定
 */
$baserSettings = array();
$baserSettings['BcEnv'] = Configure::read('BcEnv');
$baserSettings['BcApp'] = Configure::read('BcApp');
Configure::config('baser', new PhpReader(BASER_CONFIGS));
if (Configure::load('setting', 'baser') === false) {
    $config = array();
    include BASER_CONFIGS . 'setting.php';
    Configure::write($config);
}
if (BC_INSTALLED && $baserSettings) {
    foreach ($baserSettings as $key1 => $settings) {
        if ($settings) {
            foreach ($settings as $key2 => $setting) {
                Configure::write($key1 . '.' . $key2, $setting);
            }
        }
    }
}
/**
Example #30
0
 /**
  * Get the ip address of the request.
  *
  * @return string The IP address of the request.
  */
 public function getRequestIpAddress()
 {
     // We might have a debug config here to force requests to be local
     App::uses('PhpReader', 'Configure');
     Configure::config('default', new PhpReader());
     try {
         Configure::load('debug', 'default');
         $configIp = Configure::read('forceRequestIp');
         if (isset($configIp)) {
             return $configIp;
         }
     } catch (ConfigureException $ex) {
         // We don't care.
     }
     return $_SERVER["REMOTE_ADDR"];
 }