示例#1
0
 /**
  * 
  * 
  */
 public function handleAuthenticationRequest(&$message, $conf)
 {
     if ($this->app->request()->isFormData() and !$this->app->request()->isXhr()) {
         if ($this->app->request()->post('username') and $this->app->request()->post('password')) {
             $username = $this->app->request()->post('username');
             $pass = $this->app->request()->post('password');
             $passCompare = $conf['raptor']['adminpass'];
             $obj = \Raptor\Configuration\ConfigurationLoader::getHash($passCompare);
             if ($obj->valid) {
                 $passCompare = \Raptor\Security\SecureHash::verify($pass, $obj->password);
             } else {
                 $passCompare = $pass === $conf['raptor']['adminpass'];
             }
             if ($conf['raptor']['admin'] == $username and $passCompare) {
                 $this->app->getSession()->set('admin_auth', true);
                 $this->app->getSession()->set('admin_auth_user', $username);
                 $this->app->redirect('');
             } else {
                 $message = "Wrong password or username";
             }
         } else {
             $message = "Wrong password or username";
         }
     }
 }
示例#2
0
 public function call(\Raptor\Raptor $app)
 {
     $app->setViewPlugin('raptor_bundle', $app->render("@exampleBundle/plugin.html.twig"));
     /**
      * Return false to continue the flow of routing
      */
     return false;
 }
示例#3
0
 public function call(\Raptor\Raptor $app)
 {
     $this->interactive = $app->getInyector()->get('InteractiveManager');
     $this->interactive->add(array('name' => 'raptor.panel.welcome', 'seconds' => 40, 'style' => array('background' => 'darkblue'), 'next' => 'raptor.panel.start', 'author' => 'amed', 'position' => 'right top'), 'systemBundle');
     $this->interactive->add(array('name' => 'raptor.panel.start', 'seconds' => 20, 'style' => array('background' => 'darkblue'), 'pointer' => '.navbar-nav li:first', 'author' => 'amed', 'position' => 'right top'), 'systemBundle');
     $this->interactive->add(array('name' => 'raptor.configuration.conf', 'seconds' => 60, 'style' => array('background' => 'darkblue'), 'author' => 'amed', 'next' => 'raptor.tools.toolpresent', 'position' => 'right bottom'), 'systemBundle');
     $this->interactive->add(array('name' => 'raptor.start.startopen', 'seconds' => 60, 'style' => array('background' => 'darkblue'), 'pointer' => '.navbar-nav li:eq(1)', 'author' => 'amed', 'position' => 'right top'), 'systemBundle');
     $this->interactive->add(array('name' => 'raptor.tools.toolpresent', 'seconds' => 60, 'waitSeconds' => 45, 'style' => array('background' => 'darkblue'), 'pointer' => '.navbar-nav li:eq(2)', 'author' => 'amed', 'next' => 'raptor.bundle.bundle', 'position' => 'right top'), 'systemBundle');
     $this->interactive->add(array('name' => 'raptor.bundle.bundle', 'seconds' => 45, 'waitSeconds' => 30, 'style' => array('background' => 'darkblue'), 'pointer' => '.navbar-nav>li:eq(3)', 'author' => 'amed', 'next' => 'raptor.account.admin', 'position' => 'right top'), 'systemBundle');
     $this->interactive->add(array('name' => 'raptor.account.admin', 'seconds' => 45, 'waitSeconds' => 30, 'style' => array('background' => 'darkblue'), 'pointer' => '.navbar-nav.navbar-right li:first', 'author' => 'amed', 'position' => 'left top'), 'systemBundle');
     return false;
 }
示例#4
0
 public function init(\Raptor\Raptor $app)
 {
     //        Place your init code here
     /**
      * This make Raptor load the control panel from the root path
      * if the config mode is debug wich is taken by Raptor like
      * DEV mode
      * 
      * PROBABLY YOU NEED TO REMOVE THIS IN PRODUCTION MODE
      */
     if ($app->config('debug')) {
         $app->any('/', function () use($app) {
             $app->redirect($app->request()->getScriptName() . '/raptor');
         });
     }
 }
示例#5
0
 function __construct()
 {
     $this->app = \Raptor\Raptor::getInstance();
     session_set_save_handler($this, false);
     register_shutdown_function('session_write_close');
     if (!$this->app->getStore()->getManager()->getConnection()->getSchemaManager()->tablesExist(array('raptor_session'))) {
         $this->app->getStore()->generateSchema('systemBundle', array('RaptorSession'));
     }
 }
示例#6
0
 /**
  * 
  * Retorna una instancia de los servicios privados en el bundle especificado o FALSE sino se encontro ninguno
  * @param string $bundle The name of the Bundle where is the PrivateService
  * @return PrivateService
  */
 public function getPrivate($bundle)
 {
     $bundles = \Raptor\Raptor::getInstance()->getConfigurationLoader()->getOptions();
     if (isset($bundles['specifications'][$bundle])) {
         if (file_exists($bundles['specifications'][$bundle]['location'] . DIRECTORY_SEPARATOR . 'Services' . DIRECTORY_SEPARATOR . 'PrivateService.php')) {
             $class = $bundles['specifications'][$bundle]['namespace'] . '\\Services\\PrivateService';
             return new $class();
         } else {
             return FALSE;
         }
     } else {
         return FALSE;
     }
 }
示例#7
0
 public function createScript()
 {
     $app = \Raptor\Raptor::getInstance();
     if (strpos($app->response()->headers->get('Content-Type'), 'text/html') === false) {
         return;
     }
     $user = '******';
     if ($app->getSecurity()->isAuthenticated()) {
         $array = $app->getSecurity()->getUser();
         $user = $array['username'];
     }
     $data = array('token' => $app->getSecurity()->getToken(), 'front' => $app->request()->getRootUri(), 'bundle' => dirname($_SERVER['SCRIPT_NAME']) . '/bundles', 'file' => $app->getLanguage()->getBundleFile(), 'lang' => $app->getLanguage()->getUserCurrentLanguage(), 'user' => $user);
     $core = $app->render('@systemBundle/client/client.core.html.twig', $data);
     $app->response()->write($core . $app->response()->getBody(), true);
 }
示例#8
0
 /**
  * Pobla los atributos de la clase o objeto especificado con los parametros provenientes en el request actual
  * 
  * Si el primer parametro es una clase el colector crea un instancia de esta.
  * Si el primer paremtro es un objeto lo usa para poblar segun los parametros del request.
  * 
  * @param string/object $class clase u objeto a poblar
  * @param array $matcher un array con el macheo de parametros que no conciden con los atributos de la clase. ejemplo array('nombre'=>'nombre_c') en el ejemplo nombre es el parametro que viene en el request y nombre_c el que esta en la clase, el colector pone el valor de nombre en nombre_c
  * @return mixed
  */
 public function collector($class, $matcher = array())
 {
     $classTo = $class;
     if (!is_object($classTo)) {
         $alias = new ItemList(explode(':', $classTo));
         if ($alias->size() > 1) {
             $classTo = $alias->get(0);
             $namespace = $this->getStore()->getManager()->getConfiguration()->getEntityNamespace($classTo);
             $namespace .= '\\' . $alias->get(1);
             $classTo = $namespace;
         }
         $classTo = new $classTo();
     }
     return Collector::run($classTo, new ItemList($this->app->request()->params()), $matcher);
 }
示例#9
0
 /**
  * [USO DEL SISTEMA]
  * @return boolean
  */
 public function call()
 {
     $cmp_str = $this->bundle;
     $cmp = new $cmp_str();
     if (\Raptor\Raptor::getInstance()->config('debug')) {
         Publisher\Publisher::run($cmp, true);
     }
     call_user_func_array(array($cmp, 'entrance'), array(\Raptor\Raptor::getInstance()));
     $app = \Raptor\Raptor::getInstance();
     $app->getLanguage()->setCurrentBundle($cmp);
     $return = call_user_func_array(array(new $this->instance(), $this->action), array($app->request(), $app->response(), $app->router()->getCurrentRoute()));
     if ($return != false || $return != null || !$return instanceof \Slim\Http\Response) {
         $app->response()->write($return);
     }
     return true;
 }
示例#10
0
 public function registerLastPerformance()
 {
     $app = \Raptor\Raptor::getInstance();
     $time = round($app->getTimer()->getExecutionTime(), 2);
     $cache = new \Raptor\Cache\Cache('performance');
     if (!$cache->hasCache()) {
         $performance = new \Raptor\Util\ItemList();
     } else {
         $performance = $cache->getData();
     }
     if ($performance->size() < 20) {
         $performance->add($time);
     } else {
         $performance->shift();
         $performance->add($time);
     }
     $cache->setData($performance);
     $cache->save();
 }
示例#11
0
 public static function serverAsset($dev)
 {
     $headers = Raptor::getRequest()->header;
     $route = $headers->get('PATH_INFO');
     $web_location = Location::get('web_bundles');
     $file = $web_location . $route;
     $js = new AssetCollection(array(new GlobAsset($file)));
     // the code is merged when the asset is dumped
     $response = new Response($js->dump());
     if (preg_match("/(\\.css)\$/", $route)) {
         $response->addHeader('Content-Type', 'text/css');
     } else {
         $response->addHeader('Content-Type', 'application/javascript');
     }
     if ($dev == FALSE) {
         $response->setCache(true, 3, true);
     }
     $response->sendResponse();
     exit;
 }
示例#12
0
 /**
  * 
  * [USADA POR EL SISTEMA]
  */
 public function register()
 {
     $asset = new Twig_SimpleFunction('asset', function ($val) {
         if (dirname($_SERVER['SCRIPT_NAME']) == '/' or dirname($_SERVER['SCRIPT_NAME']) == '\\') {
             return '/bundles/' . $val;
         } else {
             return dirname($_SERVER['SCRIPT_NAME']) . '/bundles/' . $val;
         }
     });
     $this->twig->addFunction($asset);
     $path = new Twig_SimpleFunction('path', function ($val) {
         $route = \Raptor\Raptor::getInstance()->router()->getNamedRoute($val);
         if ($route == NULL) {
             return "";
         }
         $pattern = $route->getPattern();
         return \Raptor\Raptor::getInstance()->request()->getRootUri() . $pattern;
     });
     $this->twig->addFunction($path);
     $plugin = new Twig_SimpleFunction('plugin', function ($key) {
         $app = \Raptor\Raptor::getInstance();
         $result = $app->getViewPlugin($key);
         if ($result == false) {
             return "";
         }
         return join("", $result);
     });
     $this->twig->addFunction($plugin);
     $locale = new Twig_SimpleFunction('locale', function () {
         $params = \Raptor\Raptor::getInstance()->getConfigurationLoader()->getConfOption();
         if (isset($params['raptor']['language'])) {
             return $params['raptor']['language'];
         } else {
             return false;
         }
     });
     $this->twig->addFunction($locale);
     $langFilter = new Twig_SimpleFilter('lang', function ($val) {
         return \Raptor\Raptor::getInstance()->getLanguage()->getBundleLanguage($val);
     });
     $enviroment = new \Twig_SimpleFunction('conf', function ($val) {
         return \Raptor\Raptor::getInstance()->config($val);
     });
     $this->twig->addFunction($enviroment);
     $this->twig->addFilter($langFilter);
     $lang = new \Twig_SimpleFunction('lang', function ($val) {
         return \Raptor\Raptor::getInstance()->getLanguage()->getBundleLanguage($val);
     });
     $this->twig->addFunction($lang);
 }
示例#13
0
 /**
  * Devuelve la logica de validacion para el formulario
  * @return string
  */
 function render()
 {
     return \Raptor\Raptor::getInstance()->render('@systemBundle/form/validation.html.twig', array('fields' => json_encode($this->fields), 'formId' => $this->formId));
 }
示例#14
0
 public function call(\Raptor\Raptor $app)
 {
     /**
      * Add to the inyector container the Interactive Instance
      * 
      */
     $app->getInyector()->add(new \Raptor2\InteractiveBundle\Manager\InteractiveManager());
     $user = '******';
     if ($app->getSecurity()->isAuthenticated()) {
         $array = $app->getSecurity()->getUser();
         $user = $array['username'];
     }
     $store = json_encode(array('reject' => false, 'tutoriales' => array('interactive' => 'This is interactive')));
     if ($app->getCookie('Interactive_' . $user, true) == NULL) {
         $app->setCookie('Interactive_' . $user, $store, strtotime('+1 year'));
     } else {
         $store = $app->getCookie('Interactive_' . $user, true);
     }
     $app->setViewPlugin('core_library_outside', $app->render("@InteractiveBundle/core/core.js.twig", array('url' => $app->request()->getUrl() . $app->request()->getScriptName() . '/interactive/core', 'perfil' => $store)));
     /**
      * Return false to continue the flow of routing
      */
     return false;
 }
示例#15
0
 /**
  * 
  * Setea para el usuario en la sesion actual, el lenguaje del agente de usuario
  * @return string
  */
 public function setUserPreferedLanguage()
 {
     $prefer = $this->getPreferedLanguage();
     \Raptor\Raptor::getInstance()->getSession()->set('rpt_lang', $prefer);
     return $prefer;
 }
示例#16
0
 /**
  * Retorna la Sesion para este SessionStore
  * @return \Raptor\Security\Sessions\NativeSession
  */
 public function getSession()
 {
     return \Raptor\Raptor::getInstance()->getSession();
 }
示例#17
0
 private static function getRemoteManifiest($url)
 {
     $array = array();
     try {
         $bufer = file_get_contents($url);
     } catch (\Exception $exc) {
         \Raptor\Raptor::getInstance()->response()->write("<h3 style='text-align:center;background: #ff9999;padding:5px;'>Cannot connect with remote repository</h3>");
         return array();
     }
     $array = json_decode(utf8_encode($bufer), true);
     if ($array === NULL) {
         \Raptor\Raptor::getInstance()->response()->write("<h3 style='text-align:center;background: #ff9999;padding:5px;'>The repository metadata has some errors</h3>");
     }
     if (!$array) {
         return array();
     }
     return $array;
 }
示例#18
0
 * Raptor - Integration PHP 5 framework
 *
 * @author      William Amed <*****@*****.**>, Otto Haus <*****@*****.**>
 * @copyright   2014 
 * @link        http://dinobyte.net
 * @version     2.0.1
 * @package     Raptor
 *
 * MIT LICENSE
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
$data = new \Raptor\Util\ItemList(\Raptor\Raptor::getInstance()->getStore()->getManager()->getRepository('exampleBundle:Persona')->findAll());
file_put_contents(__DIR__ . '/mas', $data->toJson());
 public function getTutorial($name)
 {
     $route = str_replace('.', '/', $name);
     $lang = \Raptor\Raptor::getInstance()->getLanguage()->getUserCurrentLanguage();
     if (isset($this->tags[$name])) {
         $tutorial = new \Raptor\Util\ItemList($this->tags[$name]);
         if (!file_exists($this->tags[$name]['bundle'] . "/Tutorials/{$lang}")) {
             $default = $this->getDefault();
             $default['found'] = FALSE;
             return $default;
         }
         if (file_exists($this->tags[$name]['bundle'] . "/Tutorials/{$lang}/docs/{$route}.html")) {
             $tutorial->set('text', file_get_contents($this->tags[$name]['bundle'] . "/Tutorials/{$lang}/docs/{$route}.html"));
             $tutorial->set('bundle', '');
         }
         if ($this->tags[$name]['author'] == NULL) {
             $tutorial->set('author', array('img' => 'Raptor/img/logo.png'));
         } else {
             $author = str_replace('.', '/', $this->tags[$name]['author']);
             $obj = json_decode(file_get_contents($this->tags[$name]['bundle'] . "/Tutorials/{$lang}/authors/{$author}.json"));
             $result = array();
             if ($obj->img == '') {
                 $obj->img = 'Raptor/img/accountblue.png';
             }
             foreach ($obj as $key => $value) {
                 $result[$key] = $value;
             }
             $tutorial->set('author', $result);
         }
         if ($tutorial->get('next') == NULL) {
             $tutorial->set('next', $this->getConditionalTutorial($name));
         }
         if ($tutorial->has('pointer')) {
             $pointerOrig = $tutorial->get('pointer');
             $pointer = array();
             if (preg_match('/^arrow:((up)|(down)|(left)|(right)) /', $pointerOrig)) {
                 if (count(explode('arrow:up', $pointerOrig)) > 1) {
                     $pointer['arrow'] = 'up';
                     $pointer['selector'] = str_replace('arrow:up', '', $pointerOrig);
                 }
                 if (count(explode('arrow:down', $pointerOrig)) > 1) {
                     $pointer['arrow'] = 'down';
                     $pointer['selector'] = str_replace('arrow:down', '', $pointerOrig);
                 }
                 if (count(explode('arrow:left', $pointerOrig)) > 1) {
                     $pointer['arrow'] = 'left';
                     $pointer['selector'] = str_replace('arrow:left', '', $pointerOrig);
                 }
                 if (count(explode('arrow:right', $pointerOrig)) > 1) {
                     $pointer['arrow'] = 'right';
                     $pointer['selector'] = str_replace('arrow:right', '', $pointerOrig);
                 }
             } else {
                 $pointer = array('selector' => $pointerOrig, 'arrow' => 'up');
             }
             $tutorial->set('pointer', $pointer);
         }
         return $tutorial;
     }
     $default = $this->getDefault();
     $default['next'] = $this->getConditionalTutorial($name);
     return new \Raptor\Util\ItemList($default);
 }
示例#20
0
 private function read()
 {
     if (!$this->cacheautoinstaller->isDirty()) {
         $this->autoinstaller = $this->cacheautoinstaller->getData();
     }
     if ($this->cache->isDirty()) {
         $this->monitor->execute();
         $this->checkForGhosts();
         $app = Location::get(Location::APP);
         $this->options['options'] = \Raptor\Yaml\Yaml::parse($app . '/conf/options.yml');
         $this->options['bundles'] = \Raptor\Yaml\Yaml::parse($app . '/conf/bundles.yml');
         /**
          * Add the system routes and the bundles
          * check fot enviroment
          * if(development)
          */
         $this->options['bundles'] = array_merge(\Raptor\Yaml\Yaml::parse(__DIR__ . '/../Component/bundles.yml'), $this->options['bundles']);
         /**
          * Must call this before the Reader
          */
         //           \Raptor\Raptor::getInstance()->getAppAspectKernel()->resetContainer();
         foreach ($this->options['bundles'] as $bundle) {
             $cmp_str = $bundle;
             $cmp = new $cmp_str();
             call_user_func_array(array($cmp, 'init'), array());
             $container = \Raptor\Raptor::getInstance()->getAppAspectKernel()->getContainer();
             $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
             $refClass = new \ReflectionObject($cmp);
             $container->addResource($trace[1]['file']);
             $container->addResource($refClass->getFileName());
         }
         $this->reader->setBundles($this->options['bundles']);
         $this->reader->load();
         $this->options['routes'] = $this->reader->getDefinitions();
         $this->options['location'] = $this->reader->getLocation();
         $this->options['specifications'] = $this->reader->getSpecifications();
         $this->options['description'] = $this->reader->getDescriptions();
         $this->cache->setData($this->options);
         $this->cache->save();
         /**
          * Save the API to access in the main Raptor class
          */
         $api = new \Raptor\Cache\Cache('api');
         $api->setData($this->reader->getApi());
         $api->save();
         /**
          * Save the Auto Install Cache to know the trace of installed bundled
          */
         $this->cacheautoinstaller->setData($this->autoinstaller);
         $this->cacheautoinstaller->save();
     } else {
         $this->options = $this->cache->getData();
         foreach ($this->options['bundles'] as $bundle) {
             $cmp_str = $bundle;
             $cmp = new $cmp_str();
             call_user_func_array(array($cmp, 'init'), array());
             $container = \Raptor\Raptor::getInstance()->getAppAspectKernel()->getContainer();
             $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
             $refClass = new \ReflectionObject($cmp);
             $container->addResource($trace[1]['file']);
             $container->addResource($refClass->getFileName());
         }
     }
 }
示例#21
0
 public function init()
 {
     $container = \Raptor\Raptor::getInstance()->getAppAspectKernel()->getContainer();
     $this->registerBundleAspect($container);
 }
示例#22
0
 /**
  * Establece directivas y rutinas de proteccion contra ataques
  * [USADA POR EL SISTEMA]
  */
 public static function directives()
 {
     $options = \Raptor\Raptor::getInstance()->getConfigurationLoader()->getConfOption();
     if (isset($options['raptor']['session_expire'])) {
         ini_set('session.cookie_lifetime', intval($options['raptor']['session_expire']));
     } else {
         ini_set('session.cookie_lifetime', 0);
     }
     ini_set('session.cookie_httponly', true);
     ini_set('session.use_only_cookies', true);
     $savePath = \Raptor\Core\Location::get(\Raptor\Core\Location::APP) . '/Sessions';
     if (!file_exists($savePath)) {
         @mkdir($savePath);
     }
     session_save_path($savePath);
     if (isset($options['raptor']['proxy'])) {
         $parts = explode('@', $options['raptor']['proxy']);
         $header = array();
         $proxy = '';
         if (count($parts) == 2) {
             $auth = base64_encode($parts[0]);
             $header[] = "Proxy-Authorization: Basic {$auth}";
             $proxy = $parts[1];
         } else {
             $proxy = $parts[0];
         }
         stream_context_set_default(array('http' => array('proxy' => "tcp://{$proxy}", 'request_fulluri' => true, 'method' => "GET", 'user_agent' => 'Mozilla/5.0', 'header' => $header)));
     }
 }
示例#23
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();
 }