Ejemplo n.º 1
0
/**
 * @author Dominik Ryńko <http://www.rynko.pl/>
 * @version 1.0
 * @license http://creativecommons.org/licenses/by-sa/3.0/pl/
 */
// Set default charset and document type
header('Content-Type: text/html; charset=UTF-8');
// Check PHP version
if (version_compare(PHP_VERSION, '5.4.0') <= 0) {
    exit('Script requires 5.4.0 or higher version of PHP. My version is: ' . PHP_VERSION);
}
$className = 'security.class.php';
if (file_exists($className) && filesize($className) !== 0) {
    require $className;
    $config = ['error_reporting' => ['E_ALL', 1], 'path' => '/'];
    $security = new Security\Security($config);
    echo $security->init();
    /**
     isAjax() method demo
    */
    if ($security->isAjax() == true) {
        echo 'Request comes from AJAX';
    } else {
        echo 'Request does not comes from AJAX';
    }
    $xss = '<img src="http://url.to.file.which/not.exist" onerror=alert(document.cookie);>';
    echo 'Code after cleaning<br>';
    echo $security->clean($xss);
    echo '<br><br>';
    echo 'Code after xssClean method sanitizing';
    var_dump($security->xssClean($xss));
Ejemplo n.º 2
0
 public function run()
 {
     $this->timer = new Util\Timer();
     $this->timer->start();
     $this->plugins = array();
     $this->appAspectKernel = \App\AppAspectKernel::getInstance();
     if (!file_exists(Core\Location::get(Core\Location::CACHE))) {
         @mkdir(Core\Location::get(Core\Location::CACHE));
     }
     $this->appAspectKernel->init(array('debug' => $this->config('debug'), 'appDir' => Core\Location::get(Core\Location::SRC), 'cacheDir' => Core\Location::get(Core\Location::CACHE) . '/AOP'));
     $this->ruleContainer = new Bundle\Route\RuleContainer();
     $this->configuration = new Configuration\ConfigurationLoader();
     /**
      * Verify if the framework was moved of location
      */
     $locations = \Raptor\Raptor::getInstance()->getConfigurationLoader()->getOptions();
     $bundles = $locations['location'];
     $counting = 0;
     $onefile = NULL;
     foreach ($bundles as $value) {
         if (!file_exists($value)) {
             $counting++;
             $onefile = $value;
         } else {
             break;
         }
     }
     if ($counting == count($bundles) and $counting > 0) {
         $this->configuration->forceLoad();
     }
     $secret = $this->configuration->getConfOption();
     if (isset($secret['raptor']['secret'])) {
         $this->config('cookies.secret_key', $secret['raptor']['secret']);
     }
     Security\Security::directives();
     $this->add(new Core\Routing());
     $this->add(new \App\Main());
     $this->add(new Language\Language());
     $this->add(new Security\Security());
     $this->add(new Persister\Store());
     $this->add(new Exception\Listener\RaptorExceptions());
     $this->inyector = new Core\Inyector\Container();
     parent::run();
 }