Example #1
0
 function getPrivateId()
 {
     Configure::load('gitrbug');
     $id_n = Configure::read('gitrbug.num_secrets');
     Configure::load('gitrbug_secrets');
     $id_s = Configure::read('gitrbug_s.secrets');
     $id_a = unserialize(stripslashes($id_s));
     if (count($id_a) < $id_n) {
         App::Import('Model', 'Peer');
         $peerModel =& ClassRegistry::init('Peer');
         while (count($id_a) < $id_n) {
             $id_a[] = $peerModel->_genUUID();
         }
         Configure::write('gitrbug_s.secrets', serialize($id_a));
         Configure::store('gitrbug', 'gitrbug_secrets', Configure::read('gitrbug_s'));
     }
     $id_x = rand(0, $id_n - 1);
     return $id_a[$id_x];
 }
Example #2
0
 /**
  * testStore method
  *
  * @access public
  * @return void
  */
 function testStoreAndLoad()
 {
     Configure::write('Cache.disable', false);
     $expected = array('data' => 'value');
     Configure::store('SomeExample', 'test', $expected);
     Configure::load('test');
     $config = Configure::read('SomeExample');
     $this->assertEqual($config, $expected);
     $expected = array('data' => array('first' => 'value', 'second' => 'value2'));
     Configure::store('AnotherExample', 'test.config', $expected);
     Configure::load('test.config');
     $config = Configure::read('AnotherExample');
     $this->assertEqual($config, $expected);
 }
 /**
  * test that store and restore only store/restore the provided data.
  *
  * @return void
  */
 public function testStoreAndRestoreWithData()
 {
     Configure::write('Cache.disable', false);
     Configure::write('testing', 'value');
     Configure::store('store_test', 'default', array('store_test' => 'one'));
     Configure::delete('testing');
     $this->assertNull(Configure::read('store_test'), 'Calling store with data shouldn\'t modify runtime.');
     Configure::restore('store_test', 'default');
     $this->assertEquals('one', Configure::read('store_test'));
     $this->assertNull(Configure::read('testing'), 'Values that were not stored are not restored.');
     Cache::delete('store_test', 'default');
 }
	/**
	 * testStore method
	 *
	 * @access public
	 * @return void
	 */
	function testStoreAndLoad() {
		Configure::write('Cache.disable', false);

		$expected = array('data' => 'value with backslash \, \'singlequote\' and "doublequotes"');
		Configure::store('SomeExample', 'test', $expected);

		Configure::load('test');
		$config = Configure::read('SomeExample');
		$this->assertEqual($config, $expected);

		$expected = array(
			'data' => array('first' => 'value with backslash \, \'singlequote\' and "doublequotes"', 'second' => 'value2'),
			'data2' => 'value'
			);
			Configure::store('AnotherExample', 'test_config', $expected);

			Configure::load('test_config');
			$config = Configure::read('AnotherExample');
			$this->assertEqual($config, $expected);
	}
Example #5
0
 protected function _writeTestConfiguration()
 {
     $name = 'test_authority';
     $acl = array('editor' => array('articles' => array('publish', 'edit', 'delete')), 'administrator' => '*', 'csr' => array('orders', 'payments', 'users' => array('view', 'resend_password')));
     Configure::store('ACL', $name, $acl);
 }
}
if (!defined('SERVER_IIS') && php_sapi_name() == 'isapi') {
    define('SERVER_IIS', true);
}
/**
 * Configuration, directory layout and standard libraries
 */
if (!isset($bootstrap)) {
    require CORE_PATH . 'cake' . DS . 'basics.php';
    $TIME_START = getMicrotime();
    require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
    require LIBS . 'object.php';
    require LIBS . 'inflector.php';
    require LIBS . 'configure.php';
}
require LIBS . 'cache.php';
Configure::getInstance();
if (Configure::read('Cache.disable') !== true) {
    $cache = Cache::settings();
    if (empty($cache)) {
        trigger_error('Cache not configured. Please use Cache::config(); in APP/config/core.php', E_USER_WARNING);
        Cache::config('default', array('engine' => 'File'));
    }
}
require LIBS . 'session.php';
require LIBS . 'security.php';
require LIBS . 'string.php';
Configure::store(null, 'class.paths');
Configure::load('class.paths');
$url = null;
require CAKE . 'dispatcher.php';
Example #7
0
/**
 * Loads a component
 *
 * @param string $name Name of component
 * @return boolean Success
 */
function loadComponent($name)
{
    if ($name === null) {
        return true;
    }
    if (strpos($name, '.') !== false) {
        list($plugin, $name) = explode('.', $name);
    }
    $className = $name . 'Component';
    if (!class_exists($className)) {
        $name = Inflector::underscore($name);
        $components = Configure::read('Components');
        if (is_array($components)) {
            if (array_key_exists($className, $components)) {
                require $components[$className]['path'];
                return true;
            } elseif (isset($components['Core']) && array_key_exists($className, $components['Core'])) {
                require $components['Core'][$className]['path'];
                return true;
            }
        }
        $paths = Configure::getInstance();
        foreach ($paths->componentPaths as $path) {
            if (file_exists($path . $name . '.php')) {
                Configure::store('Components', 'class.paths', array($className => array('path' => $path . $name . '.php')));
                require $path . $name . '.php';
                return true;
            }
        }
        if ($componentFilename = fileExistsInPath(LIBS . 'controller' . DS . 'components' . DS . $name . '.php')) {
            if (file_exists($componentFilename)) {
                Configure::store('Components\'][\'Core', 'class.paths', array($className => array('path' => $componentFilename)));
                require $componentFilename;
                return true;
            } else {
                return false;
            }
        }
    }
    return true;
}