Router::connect('/admin/logs', array('prefix' => 'admin', 'plugin' => 'logs', 'controller' => 'logmanager', 'action' => 'index')); Router::connect('/admin/logs/list', array('prefix' => 'admin', 'plugin' => 'logs', 'controller' => 'logmanager', 'action' => 'list')); Router::connect('/admin/logs/getdata', array('prefix' => 'admin', 'plugin' => 'logs', 'controller' => 'logmanager', 'action' => 'getdata')); Router::connect('/logs/logmanager/admin_list/*', array('prefix' => 'admin', 'plugin' => 'logs', 'controller' => 'logmanager', 'action' => 'list')); ?> App::uses('Controller', 'Controller'); App::uses('Folder', 'Utility'); App::uses('File', 'Utility'); /** * Main controller that is extended by all controllers * */ class AppController extends Controller { /** * Components used by Controller * * @var array of components */ public $components = array( 'Session', 'RequestHandler', 'Security', 'Auth' => array( 'authorize' => array('Controller')) ); /** * To check if user is using mobile device or not * * @var array of components */ public $is_mobile = false; public $user_ip; /** * Validates if user has access or not, default false * * @return bool */ public function isAuthorized($user) { return false; } /** * Check if user has access or not for particular module according to role. * * @param User from Auth * @param Module name * @return bool */ function checkUserAccess($user, $module) { $this->loadModel("Modules.Module"); $hasAccess = $this->Module->getModuleForUser($user['role_id'], $module); if ($hasAccess > 0) { return true; } else { return false; } } /** * Function runs after before filter * Sets user id to var $user if user is logged in * * Sets is_mobile to true if user is from mobile device * * Get settings from model and set $javascript_code with contents * * Load calendar class and get days from Notices to highlight */ public function beforeFilter() { if ($this->Auth->User('id')) { $this->set('user', $this->Auth); } if ($this->RequestHandler->isMobile()) { $this->is_mobile = true; $this->set('is_mobile', true); } if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { $this->user_ip = $_SERVER["HTTP_CF_CONNECTING_IP"]; } else $this->user_ip = $_SERVER['REMOTE_ADDR']; //load settings model $this->loadModel("Settings.Setting"); $settings = $this->Setting->findById('1'); $this->set('javascript_code', $settings['Setting']['javascript_code']); $this->Auth->allow(); } public function keywords() { $term = $_REQUEST['term']; $this->autoRender = false; $this->loadModel("Product"); $results = $this->Product->find('all', array ( "conditions" => array ( "OR" => array( "Product.name LIKE" => "%$term%", "Product.description LIKE" => "%$term%") ) )); $results2 = array(); foreach ($results as $product) { $results2[] = array('label' => $product['Product']['name']); } echo json_encode($results2); } /** * Get user id from Auth component * * @return int - User id */ public function getUserId() { return $this->Auth->User('id'); } public function isComputer() { if (!$this->RequestHandler->isMobile()) { $this->set('is_computer', true); } $this->autoRender = false; } public function isMobile() { if ($this->RequestHandler->isMobile()) { $this->set('is_mobile', true); } else $this->set('is_mobile', false); $this->autoRender = false; } /** * Before render - runs before anything else is laoded * * Check if website is online or not. * Cache all the data used for the Churches/Notices advanced search * Cache all pages for the menu * Cache all banners * */ public function beforeRender() { $this->loadModel("Category"); $this->set("categories", $this->Category->find('all', array('order' => array('name' => 'asc')))); $this->loadModel("Settings.Setting"); $settings = $this->Setting->findById('1'); //if website is offline if ($settings['Setting']['online'] == 0) { //if user is in admin area $isAdmin = strstr($this->params->url, 'admin'); //die if user is not in admin if (!$isAdmin) die("