echo " -u Cache update only, do not do the analysis" . PHP_EOL; echo " -f Do the analysis and run only fast analyzers" . PHP_EOL; echo " -d Enable debug features" . PHP_EOL; exit; } $passcode = isset($options['passcode']) ? $options['passcode'] : (isset($options['p']) ? $options['p'] : null); $runAnalysis = !isset($options['update']) && !isset($options['u']); $fastOnly = isset($options['fast']) || isset($options['f']); $debug = isset($options['debug']) || isset($options['d']); $correctPasscode = Config::get("passcode"); if ($correctPasscode) { if ($passcode == null) { echo "Passcode non specificato..."; exit(1); } if (md5($passcode) != $correctPasscode) { echo "Passcode non valido..."; exit(2); } } $locked = Atomic::isLocked(); if ($locked) { echo "Analysis is locked... waiting up to 60 seconds" . PHP_EOL; } Atomic::waitForLock(60.0); if ($debug) { Controller::init(); Config::override("debug", true); } Controller::run($runAnalysis, $fastOnly); Atomic::unlock();
/** * Main loader, loads defaults, main config and virtualhost config if it exists * * @param string $virtualhost the name of a particular virtualhost to load * * @throws ConfigFileMissingException * @throws ConfigBadParameterException */ private static function load($virtualhost = null) { if (!is_null(self::$parameters) && !$virtualhost) { return; } // Do not load twice, except if switching virtualhost // Load default configuration self::$parameters = array(); // Load defaults if needed if (is_null(self::$defaults)) { self::$defaults = array(); $defaults_file = APPLICATION_BASE . '/includes/core/ConfigDefaults.php'; $default = array(); if (file_exists($defaults_file)) { include_once $defaults_file; } //include: if file doesn't exists, execution will not stop, only gives a warning. if() not needed self::$defaults = $default; foreach ($default as $key => $value) { self::$parameters[$key] = $value; } } // Check if main config exists $main_config_file = APPLICATION_BASE . '/config/config.php'; if (!file_exists($main_config_file)) { throw new ConfigFileMissingException($main_config_file); } $config = array(); // Load base config include_once $main_config_file; if ($virtualhost != null) { $config['virtualhost'] = $virtualhost; } foreach ($config as $key => $value) { self::$parameters[$key] = $value; } // Merge // Load virtualhost config if used if ($virtualhost === null) { $virtualhost = self::get('virtualhost'); } if ($virtualhost) { if (!is_string($virtualhost)) { throw new ConfigBadParameterException('virtualhost'); } $config_file = APPLICATION_BASE . '/config/' . $virtualhost . '/config.php'; if (!file_exists($config_file)) { throw new ConfigFileMissingException($config_file); } // Should exist even if empty $config = array(); include_once $config_file; foreach ($config as $key => $value) { self::$parameters[$key] = $value; } // Merge } // Load config overrides if any $overrides_cfg = self::get('config_overrides'); if ($overrides_cfg) { $overrides_file = APPLICATION_BASE . '/config/' . ($virtualhost ? $virtualhost . '/' : '') . 'config_overrides.json'; $overrides = file_exists($overrides_file) ? json_decode(trim(file_get_contents($overrides_file))) : new StdClass(); self::$override = array('file' => $overrides_file, 'parameters' => array()); foreach ($overrides_cfg as $key => $dfn) { // Casting if (is_string($dfn)) { $dfn = array('type' => $dfn); } else { if (is_array($dfn) && !array_key_exists('type', $dfn)) { $dfn = array('type' => 'enum', 'values' => $dfn); } else { if (!is_array($dfn)) { throw new ConfigBadParameterException('config_overrides'); } } } $dfn['value'] = property_exists($overrides, $key) ? $overrides->{$key} : null; self::$override['parameters'][$key] = $dfn; } } }
/** * Override the values from one array with values from another array * * @param array $arr1 Base config * @param array $arr2 Overriding config * @return array */ public static function override(array $arr1, array $arr2) { foreach ($arr2 as $key => $value) { if (array_key_exists($key, $arr1) and is_array($value) and !array_key_exists(0, $value)) { $arr1[$key] = Config::override($arr1[$key], $arr2[$key]); } else { $arr1[$key] = $value; } } return $arr1; }
<?php // user signup data $first_name = "jacopo"; $last_name = "beschi"; $email = "*****@*****.**"; $password = $password_confirmation = "password"; Config::override('laravel-authentication-acl::captcha_signup', false); Config::override('mail.pretend', true); $I = new AcceptanceTester($scenario); $I->wantTo('signup a new user'); $I->amOnPage('/user/signup'); $I->see('Please sign up for Authenticator'); $I->fillField('first_name', $first_name); $I->fillField('last_name', $last_name); $I->fillField('email', $email); $I->fillField('password', $password); $I->fillField('password_confirmation', $password_confirmation); $I->click('Register'); $I->see('Request received'); //@todo assert mail data //@todo make it work with captcha