Esempio n. 1
0
 public function testSecure()
 {
     $secret = sha1(self::TEST_URL);
     $url = new \Curry_URL(self::TEST_URL);
     $secureUrl = $url->getAbsolute('&', $secret);
     $url = new \Curry_URL($secureUrl);
     $this->assertNotEmpty($url->getVar('hash'));
     $this->assertTrue($url->isValid($secret));
     \Curry_URL::setDefaultSecret(sha1($secret));
     $url = new \Curry_URL(self::TEST_URL);
     $secureUrl = $url->getAbsolute('&', true);
     $url = new \Curry_URL($secureUrl);
     $this->assertNotEmpty($url->getVar('hash'));
     $this->assertTrue($url->isValid());
 }
Esempio n. 2
0
 /**
  * Initializes CurryCms using the specified configuration.
  * 
  * @param string|array|null $config Path to configuration file, array with configuration options or null for no configuration.
  * @param float|null $startTime Time when initialization was started (use microtime(true)), if not specified the current time will be used.
  * @param bool|null $initAutoloader Attempt to initialize vendor/autoload.php
  */
 public static function init($config, $startTime = null, $initAutoloader = null)
 {
     self::$startTime = $startTime === null ? microtime(true) : $startTime;
     if (get_magic_quotes_gpc()) {
         throw new Exception('magic quotes gpc is enabled, please disable!');
     }
     // Initialize autoloader?
     if ($initAutoloader === null) {
         $initAutoloader = spl_autoload_functions();
         $initAutoloader = $initAutoloader === false || !count($initAutoloader);
     }
     if ($initAutoloader) {
         $autoload = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
         if (!file_exists($autoload)) {
             throw new Exception('curry/vendor/autoload.php not found, make sure composer dependencies have been installed.');
         }
         self::$autoloader = (require_once $autoload);
     }
     // load configuration
     self::$config = new Zend_Config(self::getConfig($config));
     // add project path to autoloader
     if ($initAutoloader) {
         $projectInclude = Curry_Util::path(self::$config->curry->projectPath, 'include');
         self::$autoloader->add('', $projectInclude);
         set_include_path($projectInclude . PATH_SEPARATOR . get_include_path());
     }
     // trigger hook
     self::triggerHook('Curry_Core::preInit');
     // try to use utf-8 locale
     setlocale(LC_ALL, 'en_US.UTF-8', 'en_US.UTF8', 'UTF-8', 'UTF8');
     // umask
     if (self::$config->curry->umask) {
         umask(self::$config->curry->umask);
     }
     // init
     self::initErrorHandling();
     self::initLogging();
     self::initPropel();
     self::initCache();
     self::initEncoding();
     Curry_URL::setDefaultBaseUrl(self::$config->curry->baseUrl);
     Curry_URL::setDefaultSecret(self::$config->curry->secret);
     self::triggerHook('Curry_Core::postInit');
     register_shutdown_function(array(__CLASS__, 'shutdown'));
 }