function deleteAction() { $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = FALSE; foreach ($modelsID as $id) { $model = new IpAccess(); if ($model->findByPk($id)) { $model->delete($id); } else { $errors = TRUE; } if ($model->getErrors()) { $errors = TRUE; } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('access_no_deleted')); } else { $countE = AF::get($_POST, 'countE', 100000); if (count($modelsID) >= $countE) { $link = AF::link(array('access' => 'view')); Message::echoJsonRedirect($link); } else { Message::echoJsonSuccess(__('access_deleted')); } } } $this->redirect(); }
/** * @return mixed */ public function onBeforeInit() { $access = new IpAccess($this->owner->getRequest()->getIP()); if (!$access->hasAccess()) { $access->respondNoAccess($this->owner); } }
function onBeforeInit() { if (Config::inst()->get('IpAccess', 'enabled')) { $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), Config::inst()->get('IpAccess', 'allowed_ips')); if (!$ipAccess->hasAccess()) { if (class_exists('ErrorPage', true)) { $response = ErrorPage::response_for(403); } $response = $response ? $response : 'The requested page could not be found.'; return $this->owner->httpError(403, $response); } } }
/** * @return void */ public function init() { parent::init(); $access = new IpAccess($this->getRequest()->getIP()); if (!$access->hasAccess()) { $access->respondNoAccess($this); } if (Config::inst()->get('AdminLogin', 'UseTheme') !== true) { // this prevents loading frontend css and javscript files Object::useCustomClass('Page_Controller', 'AdminLoginPage_Controller'); Requirements::css('adminlogin/css/style.css'); } Object::useCustomClass('MemberLoginForm', 'AdminLoginForm'); }
public function init() { parent::init(); if (Config::inst()->get('IpAccess', 'enabled')) { $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), Config::inst()->get('IpAccess', 'allowed_ips')); if (!$ipAccess->hasAccess()) { $reponse = ''; if (class_exists('ErrorPage', true)) { $response = ErrorPage::response_for(404); } return $this->owner->httpError(404, $response ? $response : 'The requested page could not be found.'); } } // this prevents loading frontend css and javscript files Requirements::clear(); Requirements::css('adminlogin/css/style.css'); }
function testMatchWildCard() { $obj = new IpAccess('192.168.1.101'); $obj->allowedIps = array('192.168.1.*'); $this->assertEquals($obj->matchWildCard(), '192.168.1.*'); $obj->setIp('192.168.2.101'); $this->assertEmpty($obj->matchWildCard()); $obj->setIp('190.168.1.101'); $this->assertEmpty($obj->matchWildCard()); $obj = new IpAccess('192.168.2.2'); $obj->allowedIps = array('192.168.*'); $this->assertEquals($obj->matchWildCard(), '192.168.*'); $obj->allowedIps = array('192.167.*'); $this->assertNull($obj->matchWildCard()); $obj->allowedIps = array('192.*'); $this->assertEquals($obj->matchWildCard(), '192.*'); $obj->allowedIps = array('10.*'); $this->assertNull($obj->matchWildCard()); }
public function init() { parent::init(); if (Config::inst()->get('IpAccess', 'enabled')) { $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), Config::inst()->get('IpAccess', 'allowed_ips')); if (!$ipAccess->hasAccess()) { $reponse = ''; if (class_exists('ErrorPage', true)) { $response = ErrorPage::response_for(404); } return $this->owner->httpError(404, $response ? $response : 'The requested page could not be found.'); } } if (Config::inst()->get('AdminLogin', 'UseTheme') !== true) { // this prevents loading frontend css and javscript files Object::useCustomClass('Page_Controller', 'AdminLoginPage_Controller'); Requirements::css('adminlogin/css/style.css'); } Object::useCustomClass('MemberLoginForm', 'AdminLoginForm'); }
private function configuration() { Assets::$test = TRUE; // Delete in real $this->fc = FrontController::getInstance(); $this->controller = strtolower(str_replace('Controller', '', $this->fc->getController())); $this->action = strtolower(str_replace('Action', '', $this->fc->getAction())); $this->view = new View(); $this->params = $this->fc->getParams(); if ($this->controller == 'error') { return; } // Users and Access $this->mu = M_Users::Instance(); $this->user = $this->mu->GetUser(); $accessByIp = IpAccess::isAccess($_SERVER['REMOTE_ADDR']); if ((!$accessByIp || $this->user->locked) && $this->controller != 'authorization') { $expire = time() + 3600 * 24 * 100; setcookie('rUrl', $_SERVER['REQUEST_URI'], $expire, "/"); $this->redirect(array('authorization', 'login')); exit; } $access = new Access(); $access->fillFromUser($this->user); $access->setAccessParams($this->controller, $this->action); $sectionAccess = $access->sectionAccess(); $actionAccess = $access->actionAccess(); if (!$sectionAccess || !$actionAccess) { if ($this->user->isGuest) { $expire = time() + 3600 * 24 * 100; setcookie('rUrl', $_SERVER['REQUEST_URI'], $expire, "/"); $this->redirect(array('authorization', 'login')); } $pageArr = $access->UserAccessPage; $redirectArray = $pageArr ? $pageArr : array('error', ''); $this->redirect($redirectArray); } $this->access = $access; $sInfo = $access->actionAccess(array('service', 'info')) ? true : false; $this->fc->setSInfo($sInfo); unset($access); $this->pageTitle = __('pageTitle'); $array = array('access' => $this->access, 'controller' => $this->controller, 'action' => $this->action, 'user' => $this->user); $this->setMainVars($array); if (!empty($_POST)) { $_POST = AF::clearDataArray($_POST); } // Set user AF::setUser($this->user); AF::setUserAccess($this->access); //$sectionID = ( isset($this->params['id']) && is_numeric($this->params['id']) ) ? $this->params['id'] : ''; //Log::createLog($this->user->user_id, $this->action."Action", $this->controller, $sectionID); }