static function get_current_page_url() { $page_url = AT_Router::get_instance()->server('HTTPS') == 'on' ? 'https://' : 'http://'; if (AT_Router::get_instance()->server('SERVER_PORT') != '80') { $page_url .= AT_Router::get_instance()->server('SERVER_NAME') . ':' . AT_Router::get_instance()->server('SERVER_PORT') . AT_Router::get_instance()->server('REQUEST_URI'); } else { $page_url .= AT_Router::get_instance()->server('SERVER_NAME') . AT_Router::get_instance()->server('REQUEST_URI'); } return $page_url; }
public static function current_class($classes, $item) { if (AT_Router::get_instance()->segments(0) == 'catalog' && $item->title == "Catalog") { $classes[] = "current-menu-item"; } else { if (AT_Router::get_instance()->segments(0) == 'blog' && $item->title == "Blog") { $classes[] = "current-menu-item"; } } return $classes; }
public static function show_underconstruction() { if (!is_super_admin()) { include_once AT_DIR . '/controllers/errors.php'; AT_Router::get_instance()->set_controller('AT_Errors'); AT_Router::get_instance()->set_method('show_underconstruction'); $controllerObj = new AT_Errors(); call_user_func(array($controllerObj, 'show_underconstruction')); unset($controllerObj); } }
public function __construct() { $this->core = AT_Core::get_instance(); if (!$this->core->get_option('theme_is_activated', false) && isset($_GET['page']) && $_GET['page'] != 'at_theme_install') { wp_redirect('admin.php?page=at_theme_install'); } $this->load = AT_Loader::get_instance(); if (is_null($this->view)) { $this->view = $this->core->view; $this->uri = AT_Router::get_instance(); } }
public function __construct() { $this->core = AT_Core::get_instance(); // if ( !$this->core->get_option( 'theme_is_activated', false ) && is_user_logged_in() ) { // AT_Notices::set_frontend_notice( // '<h3>'.__( 'New to AutoDealer?' , AT_TEXTDOMAIN ) . '</h3>' . // __( 'You almost ready to use full theme features. Please complete two last steps before move your website to production mode.' , AT_TEXTDOMAIN ) . // '<br />' . // sprintf(__( '<a href="%1$s">Click here to continue →</a>' , AT_TEXTDOMAIN ), get_admin_url() . 'admin.php?page=at_site_options_general'), // $class = 'notice' // ); // Header('Location: ' . get_admin_url() . 'admin.php?page=at_site_options_general'); // die(); // // exit( __( 'Theme is not activated' , AT_TEXTDOMAIN ) ); // } // SSL and ajax tricks // if ( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] != rtrim( home_url(), '/' ) ) { // AT_Common::redirect( AT_Router::get_instance()->server('REQUEST_URI'), '301' ); // } $this->uri = AT_Router::get_instance(); if ($this->uri->get_method() != 'show_underconstruction' && $this->core->get_option('status_site', 'production') == 'underconstruction') { AT_Core::show_underconstruction(); } $this->view = $this->core->view; $this->load = AT_Loader::get_instance(); $this->session = AT_Session::get_instance(); $this->registry = AT_Registry::get_instance(); $this->load->library('breadcrumbs'); $this->breadcrumbs = AT_Breadcrumbs::get_instance(); $validation_rules = $this->load->helper('validation_rules', true); $this->validation = $this->load->library('form_validation', true, $validation_rules->rules); //$this->validation->set_rules(); if (AT_Common::is_user_logged() && $this->core->get_option('theme_is_activated', false)) { $user_model = $this->load->model('user_model'); $user_info = $user_model->get_user_by_id(AT_Common::get_logged_user_id()); $this->registry->set('user_info', $user_info); if ($this->core->get_option('confirm_email_enable', true) && !in_array($this->uri->segments(1), array('confirm_email', 'unlogged')) && (is_null($user_info['date_active']) || empty($user_info['date_active']))) { AT_Common::redirect('auth/confirm_email'); } } }
/** * Run the Validator * * This function does all the work. * * @access public * @return bool */ public function run($group = '') { // Do we even have any data to process? Mm? if (count($_POST) == 0) { return FALSE; } // Does the _field_data array containing the validation rules exist? // If not, we look to see if they were assigned via a config file if (count($this->_field_data) == 0) { // No validation rules? We're done... if (count($this->_config_rules) == 0) { return FALSE; } // Is there a validation rule for the particular URI being accessed? $uri = $group == '' ? trim(AT_Router::get_instance()->ruri_string(), '/') : $group; if ($uri != '' and isset($this->_config_rules[$uri])) { $this->set_rules($this->_config_rules[$uri]); } else { $this->set_rules($this->_config_rules); } // We're we able to set the rules correctly? if (count($this->_field_data) == 0) { //log_message('debug', "Unable to find validation rules"); return FALSE; } } // Cycle through the rules for each field, match the // corresponding $_POST item and test for errors foreach ($this->_field_data as $field => $row) { // Fetch the data from the corresponding $_POST array and cache it in the _field_data array. // Depending on whether the field name is an array or a string will determine where we get it from. if ($row['is_array'] == TRUE) { $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']); } else { if (isset($_POST[$field]) and $_POST[$field] != "") { $this->_field_data[$field]['postdata'] = $_POST[$field]; } } $this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']); } // Did we end up with any errors? $total_errors = count($this->_error_array); if ($total_errors > 0) { $this->_safe_form_data = TRUE; } // Now we need to re-set the POST data with the new, processed data $this->_reset_post_array(); // No errors, validation passes! if ($total_errors == 0) { return TRUE; } // Validation fails return FALSE; }
public static function route() { $coreProfile = AT_Core::get_instance(); try { if (is_admin()) { // init admin panel if (isset($_GET['page'])) { if ($segments = AT_Route::admin($_GET['page'])) { // if (isset($_GET['tab'])) // $segments[2] = $_GET['tab']; throw new Exception(serialize($segments)); } } else { if (isset($_GET['activated'])) { global $pagenow; if ($pagenow === 'themes.php') { throw new Exception(serialize(array('admin', 'install', 'redirect'))); } } } } else { //////////////////////////////////////////////////// // view inited URI //////////////////////////////////////////////////// //$segments = explode( '/', ltrim( trim($_SERVER['REQUEST_URI'], '/' ), 'index.php' ) ); $host = explode(rtrim($_SERVER['HTTP_HOST'], '/'), rtrim(home_url(), '/')); $request_uri = trim($_SERVER['REQUEST_URI'], '/'); if (!empty($host[1])) { $request_uri = substr_replace($request_uri, '', 0, strlen($host[1])); $request_uri = trim($request_uri, '/'); } $request_uri = explode('?', $request_uri); $segments = explode('/', trim($request_uri[0], '/')); if (!empty($segments[0]) && array_key_exists($segments[0], AT_Route::fronted())) { $param_segment = AT_Route::fronted($segments[0]); array_splice($segments, 0, $param_segment['segment_start']); if (!isset($segments[0])) { $segments[0] = 'vehicles'; } if ($param_segment['without_index']) { self::$without_index = $param_segment['without_index']; } throw new Exception(serialize($segments)); } //////////////////////////////////////////////////// // view inited single post type //////////////////////////////////////////////////// if (is_single() && in_array(get_post_type(), AT_Posttypes::get_post_types())) { $segments = array(get_post_type(), 'single'); throw new Exception(serialize($segments)); } if (is_archive() && (is_category() || is_tag() || is_day() || is_month() || is_year() || is_author() || is_tax())) { throw new Exception(serialize(array('post', 'archive'))); } //////////////////////////////////////////////////// // view inited archive custom post type // news, reviews //////////////////////////////////////////////////// if (is_archive() && in_array(get_post_type(), AT_Posttypes::get_post_types())) { if (isset($segments[1]) && $segments[1] == 'page' && isset($segments[2]) && is_numeric($segments[2])) { throw new Exception(serialize(array(get_post_type(), 'archive', $segments[2]))); } else { throw new Exception(serialize(array(get_post_type(), 'archive'))); } //$segments = array(get_post_type(), 'archive' ); throw new Exception(serialize($segments)); } //////////////////////////////////////////////////// // page view //////////////////////////////////////////////////// if (is_page()) { $segments = array('page', 'index'); throw new Exception(serialize($segments)); } //////////////////////////////////////////////////// // category view //////////////////////////////////////////////////// if (is_category()) { throw new Exception(serialize(array('post', 'archive'))); } //////////////////////////////////////////////////// // front page view //////////////////////////////////////////////////// if (is_front_page()) { throw new Exception(serialize(array('blog', 'index'))); } //////////////////////////////////////////////////// // blog view //////////////////////////////////////////////////// if (is_home()) { if (isset($segments[1]) && $segments[1] == 'page' && isset($segments[2]) && is_numeric($segments[2])) { throw new Exception(serialize(array('blog', 'index', $segments[2]))); } else { throw new Exception(serialize(array('blog', 'index'))); } } //////////////////////////////////////////////////// // search view //////////////////////////////////////////////////// if (is_search()) { throw new Exception(serialize(array('search', 'index'))); } //////////////////////////////////////////////////// // 404 view //////////////////////////////////////////////////// if (is_404()) { throw new Exception(serialize(array('errors', 'show_404'))); } if (is_attachment()) { throw new Exception(serialize(array('post', 'single'))); } if (is_single()) { throw new Exception(serialize(array('post', 'single'))); } if (is_feed()) { throw new Exception(''); } // other pages && post types throw new Exception(serialize(array('errors', 'show_404'))); //echo "don't find"; die; } } catch (Exception $e) { if ($e->getMessage() != '') { $route = AT_Router::get_instance(unserialize($e->getMessage())); $route->run(); } } }
private function _AT_Dealer_data($method, $params) { switch ($method) { case 'info': $user_model = $this->load->model('user_model'); $dealer = AT_Router::get_instance()->segments(2); if (is_numeric($dealer)) { $dealer_id = $dealer; } else { $segment = explode('-', $dealer); $dealer_id = $segment[count($segment) - 1]; } $dealer_info = $user_model->get_user_by_id($dealer_id); $page_title = $dealer_info['name'] . ' | '; break; default: $page_title = __('Dealer | ', AT_TEXTDOMAIN); break; } $page_title = $page_title . get_bloginfo('name'); return array('page_title' => $page_title); }
public function __construct() { $this->uri = AT_Router::get_instance(); }
public static function filter_add_theme_admin_body_class($classes) { if (implode('_', AT_Router::get_instance()->segments()) != 'welcome_index') { $classes .= 'at_theme_options_styled'; } return $classes; }
public function sess_create($data) { $this->_userdata = array('session_id' => $this->_generate_session_id(), 'ip_address' => AT_Router::get_instance()->server("REMOTE_ADDR"), 'user_agent' => substr(AT_Router::get_instance()->server("HTTP_USER_AGENT"), 0, 120), 'last_activity' => time()); $this->_userdata = array_merge($this->_userdata, $data); $this->_set_cookie(); }