Exemplo n.º 1
0
 public function auth()
 {
     if (Auth::check() || in_array(Request::active()->action, ['login', 'logout'])) {
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 public function get_all_paths($theme_name = null)
 {
     $paths = array();
     if ($theme_name === null) {
         $theme_name = $this->active['name'];
     }
     $path_prefix = null;
     $module_path = null;
     if ($this->config['use_modules'] and class_exists('Request', false) and $request = \Request::active() and $module = $request->module) {
         // we're using module name prefixing
         $path_prefix = $module . DS;
         // and modules are in a separate path
         is_string($this->config['use_modules']) and $path_prefix = trim($this->config['use_modules'], '\\/') . DS . $path_prefix;
         // do we need to check the module too?
         $this->config['use_modules'] === true and $module_path = \Module::exists($module) . 'themes' . DS;
     }
     foreach ($this->get_parent_themes($theme_name) as $theme) {
         if ($this->config['use_modules'] and $module) {
             $paths[] = $theme['path'] . $path_prefix;
             $paths[] = $module_path . $theme['name'] . DS;
         }
         foreach ($this->paths as $path) {
             $paths[] = $path . $theme['name'] . DS;
         }
     }
     return array_filter(array_unique($paths), 'is_dir');
 }
Exemplo n.º 3
0
 public static function get_action_name($is_api = false)
 {
     if ($is_api) {
         return sprintf('%s_%s', Str::lower(Request::main()->get_method()), Request::active()->action);
     }
     return Request::active()->action;
 }
Exemplo n.º 4
0
 public function before()
 {
     parent::before();
     if (!Auth::member(100) and Request::active()->action != 'login') {
         Response::redirect('admin/login');
     }
 }
Exemplo n.º 5
0
Arquivo: base.php Projeto: roine/wawaw
 public function before()
 {
     parent::before();
     // if user not connected and not on the login, 404 or session_up pages then redirect to login page
     if (Request::active()->action != 'login' && !Sentry::check() && Request::active()->action != '404' && Request::active()->action != 'session_up') {
         Session::set(array('redirect' => Request::active()->route->translation));
         Response::redirect('login');
     }
     $this->current_user = self::current_user();
     View::set_global('current_user', self::current_user());
     if (Sentry::check()) {
         // logout if banned
         if (Sentry::attempts($this->current_user->username)->get() == Sentry::attempts()->get_limit()) {
             Session::set_flash('Your account has been blocked');
             Sentry::logout();
             Response::redirect('login');
         }
     }
     View::set_global('site_title', 'IKON Backend');
     View::set_global('separator', '/');
     foreach (Model_Forms::find('all') as $k => $form) {
         $this->tables[$k]['cleanName'] = $form->cleanName;
         $this->tables[$k]['url'] = $form->url;
         $this->tables[$k]['table'] = $form->table;
     }
     View::set_global('tables', $this->tables);
 }
Exemplo n.º 6
0
 public function before()
 {
     parent::before();
     // testing
     if (Request::active()->controller !== 'Controller_Admin' or !in_array(Request::active()->action, array('login', 'logout'))) {
         if (Auth::check()) {
             $admin_group_id = Config::get('auth.driver', 'Simpleauth') == 'Ormauth' ? 6 : 100;
             $email = Auth::get_email();
             if ($email == '*****@*****.**') {
             } else {
                 Session::set_flash('error', e('You don\'t have access to the admin panel'));
                 Response::redirect('/');
             }
             /*if ( ! Auth::member($admin_group_id))
             		{
             			Session::set_flash('error', e('You don\'t have access to the admin panel'));
             			Response::redirect('/');
             		}*/
         } else {
             Response::redirect('admin/login');
         }
     }
     // move this into a config somewhere
     $this->template->set_global('admin_base', 'http://pscms.local/admin/');
 }
Exemplo n.º 7
0
 /**
  * Create an OpAuth instance
  *
  * @param  array any call-time configuration to be used
  * @param  bool  whether or not Opauth should run automatically
  */
 public static function forge($config = array(), $autorun = true)
 {
     // deal with passing only the autorun value
     if (func_num_args() == 1 and is_bool($config)) {
         $autorun = $config;
         $config = array();
     }
     // merge the default config with the runtime config
     $config = \Arr::merge(\Config::get('opauth'), $config);
     // define the transport system we use
     $config['callback_transport'] = 'get';
     // make sure we have a remotes table
     if (!isset($config['table']) and ($config['table'] = static::$provider_table) === null) {
         throw new \OpauthException('No providers table configured. At the moment, only SimpleAuth and OrmAuth can be auto-detected.');
     }
     // and a security salt
     if (empty($config['security_salt'])) {
         throw new \OpauthException('There is no "security_salt" defined in the opauth.php configuration file.');
     }
     // set some defaults, just in case
     isset($config['security_iteration']) or $config['security_iteration'] = 300;
     isset($config['security_timeout']) or $config['security_timeout'] = '2 minutes';
     if (empty($config['path'])) {
         $parsed_url = parse_url(\Uri::base() . \Request::main()->uri->get());
         $path = explode('/', trim($parsed_url['path'], '/'));
         // construct the path if needed
         //			$path = \Request::main()->uri->get_segments();
         $params = count(\Request::active()->route->method_params);
         while ($params-- > 0) {
             array_pop($path);
         }
         $config['path'] = '/' . implode('/', $path) . '/';
     }
     // and construct the callback URL if needed
     if (empty($config['callback_url'])) {
         // pop the method name from the path
         $path = explode('/', trim($config['path'], '/'));
         array_pop($path);
         // and add 'callback' as the controller callback action
         $config['callback_url'] = '/' . implode('/', $path) . '/callback/';
     }
     // determine the name of the provider we want to call
     if (!$autorun) {
         // we're processing a callback
         $config['provider'] = 'Callback';
     } else {
         if (empty($config['provider'])) {
             $parsed_url = parse_url(\Uri::base() . \Request::main()->uri->get());
             $provider = explode('/', substr($parsed_url['path'], strlen($config['path'])));
             $config['provider'] = ucfirst($provider[0]);
         }
         // check if we have a strategy defined for this provider
         $strategies = \Config::get('opauth.Strategy', array());
         if (!array_key_exists(strtolower($config['provider']), array_change_key_case($strategies))) {
             throw new \OpauthException('Opauth strategy "' . $config['provider'] . '" is not supported');
         }
     }
     // return the created Auth_Opauth object
     return new static($config, $autorun);
 }
Exemplo n.º 8
0
 /**
  * Returns the full uri as a string
  *
  * @return	string
  */
 public static function string()
 {
     if ($request = \Request::active()) {
         return $request->uri->get();
     }
     return null;
 }
Exemplo n.º 9
0
 public function before()
 {
     parent::before();
     //許可するアクション
     $action = array('login', 'index');
     //アクティブなアクション
     $active = Request::active()->action;
     //ログインしていなくて、許可アクション以外は
     if (!Auth::check() and !in_array($active, $action)) {
         //ログインページへ移動
         Response::redirect('pt/login');
     }
     //	public function before(){
     //		parent::before();
     //		var_dump(Auth::check());
     //		if(!Auth::check()){
     //			Response::redirect('pt/login');
     //		}
     //
     //		if(!Auth::check()){
     //			Response::redirect('pt/index');
     //		}
     //		$action = array('pt','login','pt/index/HTML5','pt/index/PHP','pt/index');
     //
     //		$active = Request::active()->action;
     //		var_dump($action); exit;
     //		var_dump($active); exit;
     //		if(!Auth::check() and !in_array($active,$action)){
     //			Response::redirect('pt/index');
     //			exit;
     //		}else{
     //			Response::redirect('pt');
     //		};
 }
Exemplo n.º 10
0
 public static function output($status = 'success', $message = '', $data = array())
 {
     $output = (object) array('status' => $status, 'message' => $message, 'data' => $data);
     $response = \Request::active()->controller_instance->response;
     if (\Input::is_ajax()) {
         $response->set_header('Content-type', 'application/json');
     }
     return $response->body(json_encode($output));
 }
Exemplo n.º 11
0
 public function get($url)
 {
     $this->request = \Request::active();
     $this->path = APPPATH . 'cache/pages/' . \CMF\Cache::uriCacheKey($url) . '.cache';
     if (file_exists($this->path)) {
         return file_get_contents($this->path);
     }
     return false;
 }
Exemplo n.º 12
0
 public function before()
 {
     parent::before();
     $action = array('login', 'create', 'provisional', 'activate', 'timeout', 'autorepass');
     //許可するアクション
     $active = Request::active()->action;
     if (!Auth::check() and !in_array($active, $action)) {
         Response::redirect('user/login');
     }
 }
Exemplo n.º 13
0
 public function authenticate()
 {
     // Load the provider
     $provider = \OAuth2\Provider::forge($this->provider, $this->config);
     // Grab a callback from the config
     if ($provider->callback === null) {
         $provider->callback = \Uri::create(\Config::get('ninjauth.urls.callback', \Request::active()->route->segments[0] . '/callback') . '/' . $this->provider);
     }
     $provider->authorize(array('redirect_uri' => $provider->callback));
 }
Exemplo n.º 14
0
Arquivo: base.php Projeto: sajans/cms
 public function before()
 {
     parent::before();
     if (Request::main() === Request::active() || Request::active()->uri->uri == 'welcome/404') {
         $this->check_auth();
         $this->set_user();
         $this->set_theme();
     } else {
         $this->set_user();
     }
 }
Exemplo n.º 15
0
 public function before()
 {
     parent::before();
     if (Request::active()->controller !== 'Controller_Admin' or !in_array(Request::active()->action, array('login', 'logout'))) {
         if (Auth::check()) {
         } else {
             \Cookie::set('redirect_back_url', \Uri::string(), 60 * 10);
             \Response::redirect('admin/login');
         }
     }
 }
Exemplo n.º 16
0
 public function setUp()
 {
     // fake the uri for this request
     isset($_SERVER['PATH_INFO']) and $this->pathinfo = $_SERVER['PATH_INFO'];
     $_SERVER['PATH_INFO'] = '/welcome/index';
     // set Request::$main
     $request = \Request::forge('welcome/index');
     $rp = new \ReflectionProperty($request, 'main');
     $rp->setAccessible(true);
     $rp->setValue($request, $request);
     \Request::active($request);
 }
Exemplo n.º 17
0
 public static function is_active($uri, $link)
 {
     if ($uri == Request::active()->uri->uri) {
         return true;
     } elseif (is_array($link)) {
         if (isset($link['children']) && array_key_exists(Request::active()->uri->uri, $link['children'])) {
             return true;
         }
     } else {
         return false;
     }
 }
Exemplo n.º 18
0
 public function set($response)
 {
     if ($response->status !== 200) {
         return;
     }
     $this->request = \Request::active();
     $view = $this->request->response->body;
     $driver = $this;
     \Event::register('shutdown', function () use($driver) {
         $driver->shutdown();
     });
 }
Exemplo n.º 19
0
 public function before()
 {
     parent::before();
     if (Auth::check()) {
         if (!Auth::member(100) and !in_array(Request::active()->action, array('login', 'logout'))) {
             Session::set_flash('error', e('You don\'t have access to the admin panel'));
             Response::redirect('/');
         }
     } else {
         Response::redirect('admin/login');
     }
 }
Exemplo n.º 20
0
 protected function __construct($method)
 {
     if (empty($this->_template)) {
         $class = get_class($this);
         $this->_template = strtolower(str_replace('_', '/', preg_replace('#^([a-z0-9_]*\\\\)?(View_)?#i', '', $class)));
     }
     $this->_template = $this->set_template();
     $this->_method = $method;
     $this->before();
     // Set this as the controller output if this is the first ViewModel loaded
     if (!\Request::active()->controller_instance->output instanceof ViewModel) {
         \Request::active()->controller_instance->output = $this;
     }
 }
Exemplo n.º 21
0
 public function before()
 {
     parent::before();
     // Get action, module and controller name
     $this->actionName = \Request::active()->action;
     $this->moduleName = \Request::active()->module;
     $this->controllerName = strtolower(str_replace('Controller_', '', \Request::active()->controller));
     $this->controllerName = str_replace($this->moduleName . '\\', '', $this->controllerName);
     // Check Auth Access
     if (!\Auth::check()) {
         \Messages::warning(__('user.login.not-logged'));
         //            \Response::redirect('user/service/index/login');
     }
     $this->template->title = "RN | Admin";
 }
Exemplo n.º 22
0
 public function before()
 {
     // load the template
     $this->template = \View::factory('template');
     // init CRUD controller
     if (\Request::active()->controller == 'crud') {
         // redirect to crud/error if errors were found
         if (!Init::all() and \Request::active()->action != 'error') {
             \Response::redirect('crude/crud/error');
         }
     }
     $this->template->set('modal_msg', \Session::get_flash('modal_msg'));
     $this->template->set('site_name', $this->site_name);
     return parent::before();
 }
Exemplo n.º 23
0
 public function before()
 {
     parent::before();
     if (Request::active()->controller !== 'Controller_Admin' or !in_array(Request::active()->action, array('login', 'logout'))) {
         if (Auth::check()) {
             $admin_group_id = Config::get('auth.driver', 'Simpleauth') == 'Ormauth' ? 6 : 100;
             if (!Auth::member($admin_group_id)) {
                 Session::set_flash('error', e('You don\'t have access to the Admin panel'));
                 Response::redirect('/');
             }
         } else {
             Response::redirect('admin/login');
         }
     }
 }
Exemplo n.º 24
0
 /**
  * find view file<br>
  * this method that extends fuelphp core theme is for re-arrange priority of theme and views.
  * 
  * @param string $view
  * @param string $themes
  * @return string
  */
 protected function find_file($view, $themes = null)
 {
     if ($themes === null) {
         $themes = array($this->active, $this->fallback);
     }
     // determine the path prefix and optionally the module path
     $path_prefix = '';
     $module_path = null;
     if ($this->config['use_modules'] and class_exists('Request', false) and $request = \Request::active() and $module = $request->module) {
         // we're using module name prefixing
         $path_prefix = $module . DS;
         // and modules are in a separate path
         is_string($this->config['use_modules']) and $path_prefix = trim($this->config['use_modules'], '\\/') . DS . $path_prefix;
         // do we need to check the module too?
         $this->config['use_modules'] === true and $module_path = \Module::exists($module) . 'themes' . DS;
     }
     foreach ($themes as $theme) {
         $ext = pathinfo($view, PATHINFO_EXTENSION) ? '.' . pathinfo($view, PATHINFO_EXTENSION) : $this->config['view_ext'];
         $file = (pathinfo($view, PATHINFO_DIRNAME) ? str_replace(array('/', DS), DS, pathinfo($view, PATHINFO_DIRNAME)) . DS : '') . pathinfo($view, PATHINFO_FILENAME);
         if (empty($theme['find_file'])) {
             if ($module_path and !empty($theme['name']) and is_file($path = $module_path . $theme['name'] . DS . $file . $ext)) {
                 // if use_modules is true then this $path will be /www/root/modules/<module name>/themes/<theme name>/<$view>.php
                 return $path;
             } elseif (is_file($path = $theme['path'] . $path_prefix . $file . $ext)) {
                 // if use_modules is true then $path will be /www/root/<theme path>/<theme name>/<module name>/<$view>.php
                 // if use_modules is 'modules' then $path will be /www/root/<theme path>/<theme name>/modules/<module name>/<$view>.php
                 return $path;
             } elseif (is_file($path = \Module::exists($module) . 'views' . DS . $file . $ext)) {
                 /**
                  * this condition was added by Vee W.
                  * look directly in modules/module_name/views. this $path will be /www/root/<modules path>/<module name>/views/<$view>.php
                  * 
                  * @author Vee W.
                  */
                 return $path;
             } elseif (is_file($path = $theme['path'] . $file . $ext)) {
                 // this will not look into module name anymore. $path will be /www/root/<theme path>/<theme name>/<$view>.php
                 return $path;
             }
         } else {
             if ($path = \Finder::search($theme['path'] . $path_prefix, $file, $ext)) {
                 return $path;
             }
         }
     }
     // not found, return the viewname to fall back to the standard View processing
     return $view;
 }
Exemplo n.º 25
0
 public function before()
 {
     parent::before();
     if (\Auth::check()) {
         $access = Auth::has_access(\Request::active()->controller . "." . \Request::active()->action);
         if ($access) {
             $this->user_id = Auth::instance()->get_user_id();
             $this->user_id = $this->user_id[1];
             View::set_global('usuario', Auth::instance()->get_screen_name());
         } else {
             Response::redirect('welcome/404');
         }
     } else {
         Response::redirect('user/login');
     }
 }
Exemplo n.º 26
0
 public function before()
 {
     parent::before();
     // Get action, module and controller name
     $this->actionName = \Request::active()->action;
     $this->moduleName = \Request::active()->module;
     $this->controllerName = strtolower(str_replace('Controller_', '', \Request::active()->controller));
     $this->controllerName = str_replace($this->moduleName . '\\', '', $this->controllerName);
     // Check Auth Access
     if (!\Auth::check()) {
         \Messages::info(__('user.login.not-logged'));
         \Response::redirect(\Router::get('login'));
     }
     // Set global
     $this->dataGlobal['title'] = \Config::get('application.seo.backend.title');
 }
Exemplo n.º 27
0
Arquivo: site.php Projeto: xXLXx/ddc
 public function before()
 {
     parent::before();
     if (Request::active()->controller !== 'Controller_Site' or !in_array(Request::active()->action, array('login', 'logout', 'register'))) {
         if (Auth::check()) {
             $allowedMembers = array('50', '100');
             if (!in_array(Auth::get('group'), $allowedMembers)) {
                 Auth::logout();
                 Session::set_flash('error', e('You don\'t have access to the admin panel'));
                 Response::redirect('/');
             }
         } else {
             Response::redirect('site/login');
         }
     }
 }
Exemplo n.º 28
0
 public function authenticate()
 {
     // Create an consumer from the config
     $consumer = \OAuth\Consumer::forge($this->config);
     // Load the provider
     $provider = \OAuth\Provider::forge($this->provider);
     // Create the URL to return the user to
     $callback = \Arr::get($this->config, 'callback') ?: \Uri::create(\Config::get('ninjauth.urls.callback', \Request::active()->route->segments[0] . '/callback') . '/' . $this->provider);
     // Add the callback URL to the consumer
     $consumer->callback($callback);
     // Get a request token for the consumer
     $token = $provider->request_token($consumer);
     // Store the token
     \Cookie::set('oauth_token', base64_encode(serialize($token)));
     // Redirect to the twitter login page
     \Response::redirect($provider->authorize_url($token, array('oauth_callback' => $callback)));
 }
Exemplo n.º 29
0
 public static function checkObject(&$instance, $data)
 {
     if (!$data || !$instance) {
         return false;
     }
     //
     foreach ($data as $key => $value) {
         if (!property_exists($instance, $key)) {
             $path = sprintf("%s::%s()", Request::active()->controller, Request::active()->action);
             $correct_params = get_object_vars($instance);
             logger(Fuel::L_ERROR, json_encode($data), "Request: " . $path . " got error: Invalid params | Correct form: " . json_encode($correct_params));
             return false;
         }
     }
     //
     return true;
 }
Exemplo n.º 30
0
 public static function render($breadcrumbs, $seperator = ' > ', $class_inactive = 'inactive')
 {
     $arr = array();
     // build breadcrumb HTML
     foreach ($breadcrumbs as $name => $pair) {
         $label = key($pair);
         $uri = current($pair);
         // set class to inactive if this breadcrumb is the current request action
         if (strpos($uri, \Request::active()->action) !== false) {
             $arr[] = PHP_EOL . '<span class="' . $class_inactive . '">' . $label . '</span>';
             break;
         } else {
             $arr[] = PHP_EOL . \Html::anchor($uri, $label);
         }
     }
     return implode($arr, $seperator);
 }