public static function get_instance() { if (is_null(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
public function __construct() { parent::__construct(); if ($this->core->get_option('site_type', 'mode_soletrader') != 'mode_partnership' && $this->uri->segments(1) != 'unlogged') { AT_Core::show_404(); } }
public function show_underconstruction() { if (is_admin()) { return; } $protocol = "HTTP/1.0"; if ("HTTP/1.1" == $_SERVER["SERVER_PROTOCOL"]) { $protocol = "HTTP/1.1"; } // header( $protocol . ' 503 Service Temporarily Unavailable'); // header('Status: 503 Service Temporarily Unavailable'); $datetime_retry_after = $this->core->get_option('datetime_retry_after'); if (!empty($datetime_retry_after) && strlen($datetime_retry_after) == 16) { $date = new DateTime($datetime_retry_after); $now = new DateTime('now'); header('Retry-After: ' . $datetime_retry_after); // header('Retry-After: ' . $date->getTimestamp() - $now->getTimestamp() ); $diff = $date->diff($now); $counter_options = array('months' => $diff->format("%m"), 'days' => $diff->format("%d"), 'hours' => $diff->format("%H"), 'minutes' => $diff->format("%i"), 'seconds' => $diff->format("%S")); } else { header('Retry-After: 300'); //300 seconds $counter_options = array(); } AT_Core::$is_404 = true; $this->view->use_layout('header_content_footer'); $this->view->add_block('content', 'errors/underconstruction', array('counter_options' => $counter_options)); $this->view->render()->display(); die; }
public function registration() { if ($this->core->get_option('site_type', 'mode_soletrader') == 'mode_soletrader' || !$this->core->get_option('registration_enable', true)) { AT_Core::show_404(); } if ($this->uri->is_ajax_request() && !empty($_POST) && !AT_Common::is_user_logged()) { try { if (!$this->validation->run('registration')) { throw new Exception(serialize($this->validation->get_errors())); } $user_model = $this->load->model('user_model'); $data = array('name' => $_POST['name'], 'email' => $_POST['email'], 'password' => $_POST['pass'], 'is_dealer' => 0); $user_id = $user_model->create($data); $data = array('logged' => true, 'user_id' => $user_id); $this->session->sess_create($data); $user_model = $this->load->model('user_model'); $mail_model = $this->load->model('mail_model'); $user_info = $user_model->get_user_by_id($user_id); $code = $user_model->get_confirm_email_code($user_info['id'], $user_info['email']); $data = array('username' => $user_info['name'], 'confirm_url' => AT_Common::site_url('auth/confirm_email/' . $code . '/'), 'confirm_code' => $code); $mail_model->send('template_mail_confirm_email', $user_info['email'], $data); $response = array('status' => 'OK', 'redirect_url' => AT_Common::site_url('/profile/')); } catch (Exception $e) { $response = array('status' => 'ERROR', 'message' => unserialize($e->getMessage())); } $this->view->add_json($response)->display(); exit; } if (!AT_Common::is_user_logged()) { $this->view->use_layout('header_content2_footer'); $this->view->add_block('content', 'auth/registration', array('background' => $this->_get_rand_bg())); } else { AT_Common::redirect('profile/'); } }
public function info($dealer = '') { try { if (empty($dealer)) { throw new Exception(); } if (is_numeric($dealer)) { $dealer_id = $dealer; } else { $segment = explode('-', $dealer); if (count($segment) == 1) { throw new Exception(); } $dealer_id = $segment[count($segment) - 1]; if (!is_numeric($dealer_id)) { throw new Exception(); } } $user_model = $this->load->model('user_model'); if (!($dealer_info = $user_model->get_user_by_id($dealer_id)) || !$dealer_info['is_dealer'] || $dealer_info['is_block']) { throw new Exception(); } if (is_numeric($dealer) && !empty($dealer_info['alias'])) { wp_redirect(AT_Common::site_url('dealer/info/' . trim($dealer_info['alias'] . '-' . $dealer_info['id'], '-') . '/'), 301); exit; } } catch (Exception $e) { AT_Core::show_404(); } switch ($dealer_info['layout']) { case 'layout_2': $layout = 'content'; $right_side = 'content/right_side'; break; default: $layout = 'content_right'; $right_side = 'right_side'; break; } $car_model = $this->load->model('car_model'); $reference_model = $this->load->model('reference_model'); $dealer_contact = array(); $affiliate = $user_model->get_dealer_main_affiliate($dealer_info['id']); if ($affiliate) { $phones = array(); if (trim($affiliate['phone']) != '') { $phones[] = trim($affiliate['phone']); } if (trim($affiliate['phone_2']) != '') { $phones[] = trim($affiliate['phone_2']); } $dealer_contact = array('phones' => implode('<br/>', $phones), 'email' => $affiliate['email'], 'adress' => (!empty($affiliate['region']) ? $affiliate['region'] . ', ' : '') . $affiliate['adress'], 'url' => AT_Common::site_url('dealer/info/' . trim($dealer_info['alias'] . '-' . $dealer_info['id'], '-') . '/')); } $affiliates = $user_model->get_dealer_affiliates($dealer_info['id']); $paginator = $this->load->library('paginator'); $paginator = $paginator->get(3, $car_model->get_cars_count_by_user_id($dealer_info['id']), $dealer_info['per_page']); $this->breadcrumbs->add_item(__('Catalog', AT_TEXTDOMAIN), 'catalog'); $this->breadcrumbs->add_item($dealer_info['name'], 'dealer/info/' . trim($dealer_info['alias'] . '-' . $dealer_info['id'], '-') . '/'); $this->view->use_layout('header_' . $layout . '_footer')->add_block('page_title', 'general/page_title', array('page_title' => $dealer_info['name']))->add_block($right_side, 'dealer/right_side', array('dealer_info' => $dealer_info, 'dealer_contact' => $dealer_contact, 'affiliate' => $affiliate, 'affiliates' => $user_model->get_dealer_affiliates($dealer_info['id'])))->add_block('content', 'dealer/info', array('layout' => $layout, 'best_offers' => $car_model->get_best_offers($dealer_info['id']), 'cars' => $car_model->get_cars_by_user_id($dealer_info['id'], $paginator['offset'], $paginator['per_page'])))->add_block('content/pagination', 'general/pagination', $paginator); }
public function __construct() { global $wpdb; $this->wpdb =& $wpdb; $this->_users_table = $wpdb->prefix . $this->_users_table; $this->_dealers_affiliates_table = $wpdb->prefix . $this->_dealers_affiliates_table; $this->_manufacturers_table = $wpdb->prefix . $this->_manufacturers_table; $this->_models_table = $wpdb->prefix . $this->_models_table; $this->_body_types_table = $wpdb->prefix . $this->_body_types_table; $this->_transmissions_table = $wpdb->prefix . $this->_transmissions_table; $this->_equipments_table = $wpdb->prefix . $this->_equipments_table; $this->_doors_table = $wpdb->prefix . $this->_doors_table; $this->_fuels_table = $wpdb->prefix . $this->_fuels_table; $this->_technical_conditions_table = $wpdb->prefix . $this->_technical_conditions_table; $this->_currencies_table = $wpdb->prefix . $this->_currencies_table; $this->_transport_types_table = $wpdb->prefix . $this->_transport_types_table; $this->_regions_table = $wpdb->prefix . $this->_regions_table; $this->_cities_table = $wpdb->prefix . $this->_cities_table; $this->_region_types_table = $wpdb->prefix . $this->_region_types_table; $this->_states_table = $wpdb->prefix . $this->_states_table; $this->_drive_table = $wpdb->prefix . $this->_drive_table; $this->_colors_table = $wpdb->prefix . $this->_colors_table; $this->_photos_table = $wpdb->prefix . $this->_photos_table; $this->_recovery_password_table = $wpdb->prefix . $this->_recovery_password_table; $this->_transactions_table = $wpdb->prefix . $this->_transactions_table; $this->load = AT_Loader::get_instance(); $this->core = AT_Core::get_instance(); $this->registry = AT_Registry::get_instance(); }
public static function get_custom_sidebars() { $data = AT_Core::get_instance()->get_option('custom_sidebars', array()); $sidebars = array(); foreach ($data as $key => $value) { $sidebars['at_custom_sidebar_' . $key] = $value['name']; } return $sidebars; }
public static function init_actions() { add_action('wp_enqueue_scripts', array(AT_Core::get_instance()->view, 'render_styles')); add_action('wp_enqueue_scripts', array(AT_Core::get_instance()->view, 'render_scripts')); add_action('template_redirect', array(AT_Core::get_instance()->view, 'render')); add_action('template_redirect', array(AT_Core::get_instance()->view, 'display')); add_action('after_setup_theme', array('AT_Core', 'locale')); // MOVE TO after_setup_theme IN RELEASE 2.0 }
private function _additional_data() { $data = array(); if ($this->core->get_option('footer_logo_src', '') != '') { $data['logo'] = '<img src="' . $this->core->get_option('footer_logo_src') . '">'; } $data['sociable_view'] = $this->core->get_option('footer_sociable_view', true); $data['sociable'] = AT_Core::get_instance()->get_option('sociable', array()); return $data; }
private function __construct() { //session_settings $session_settings = AT_Core::get_instance()->get_option('session_settings', array()); if (count($session_settings) > 0) { if (isset($session_settings['sess_expiration'])) { $this->_sess_expiration = (int) $session_settings['sess_expiration']; } if (isset($session_settings['sess_time_to_update']) && (int) $session_settings['sess_time_to_update'] > 0) { $this->_sess_time_to_update = (int) $session_settings['sess_time_to_update']; } if (isset($session_settings['sess_expire_on_close'])) { $this->_sess_expire_on_close = $session_settings['sess_expire_on_close']; } if (isset($session_settings['sess_match_ip'])) { $this->_sess_match_ip = $session_settings['sess_match_ip']; } if (isset($session_settings['sess_match_useragent'])) { $this->_sess_match_useragent = $session_settings['sess_match_useragent']; } if (!empty($session_settings['sess_cookie_name'])) { $this->_sess_cookie_name = $session_settings['sess_cookie_name']; } if (!isset($session_settings['cookie_prefix'])) { $this->_cookie_prefix = $session_settings['cookie_prefix']; } if (!empty($session_settings['cookie_path'])) { $this->_cookie_path = $session_settings['cookie_path']; } if (!isset($session_settings['cookie_domain'])) { $this->_cookie_domain = $session_settings['cookie_domain']; } if (!isset($session_settings['cookie_secure'])) { $this->_cookie_secure = $session_settings['cookie_secure']; } if (!empty($session_settings['encryption_key'])) { $this->_encryption_key = $session_settings['encryption_key']; } } if ($this->_sess_expiration == 0) { $this->_sess_expiration = 60 * 60 * 24 * 365 * 2; } $this->_sess_cookie_name = $this->_cookie_prefix . $this->_sess_cookie_name; if ($this->sess_read()) { $this->_sess_update(); } else { if (is_user_logged_in() && AT_Core::get_instance()->get_option('site_type', 'mode_soletrader') == 'mode_soletrader') { $data = array('logged' => true, 'user_id' => 1); $this->sess_create($data); } } }
private function _controller($view, $params) { $content = ''; if (empty($params['name'])) { if (!empty(AT_Core::get_instance()->view->global_sidebar)) { $params['name'] = AT_Core::get_instance()->view->global_sidebar; } else { if (is_category() || is_tag() || is_day() || is_month() || is_year() || is_author() || is_tax() || is_search()) { $params['name'] = 'primary'; } else { if (is_home()) { $post_id = get_option('page_for_posts'); } else { $post_id = get_queried_object_id(); } $layout = get_post_meta($post_id, '_layout', true); } } if (isset($params['layout'])) { $layout = $params['layout']; } } if (empty($layout) || !$view->check_layout($layout)) { $layout = $this->core->get_option('default_page_layout', 'content_right'); } if ($layout != 'content' || !empty($params['name'])) { if (!empty($params['name'])) { $sidebar_name = $params['name']; } else { if (($custom_sidebar = get_post_meta($post_id, '_custom_sidebar', true)) != '') { $sidebar_name = $custom_sidebar; } else { $sidebar_name = 'primary'; } } ob_start(); dynamic_sidebar($sidebar_name); $content = ob_get_clean(); } return array('content' => $content); }
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'); } } }
public function single() { $car_model = $this->load->model('car_model'); $user_model = $this->load->model('user_model'); if (!($car_info = $car_model->get_car_info(get_the_ID()))) { AT_Core::show_404(); } $car_model->set_car_views(get_the_ID()); $reference_model = $this->load->model('reference_model'); $photo_model = $this->load->model('photo_model'); $owner_info = $user_model->get_user_by_id($car_info['options']['_owner_id']); $contacts_owner = array(); if ($owner_info['is_dealer']) { if ($car_info['options']['_affiliate_id'] > 0) { $affiliate = $user_model->get_dealer_affiliate_by_id($car_info['options']['_affiliate_id']); } if (empty($affiliate)) { $affiliate = $user_model->get_dealer_main_affiliate($car_info['options']['_owner_id']); } if ($affiliate) { $phones = array(); if (!empty($affiliate['phone'])) { $phones[] = $affiliate['phone']; } if (!empty($affiliate['phone_2'])) { $phones[] = $affiliate['phone_2']; } $contacts_owner = array('phones' => implode(', ', $phones), 'email' => $affiliate['email'], 'adress' => (!empty($affiliate['region']) ? $affiliate['region'] . ', ' : '') . $affiliate['adress'], 'url' => AT_Common::site_url('dealer/info/' . trim($owner_info['alias'] . '-' . $car_info['options']['_owner_id'], '-') . '/'), 'add_offer' => true, 'is_dealer' => true, 'name' => $owner_info['name'], 'photo' => $owner_info['photo']); } else { $phones = array(); if (!empty($owner_info['phone'])) { $phones[] = $owner_info['phone']; } if (!empty($owner_info['phone_2'])) { $phones[] = $owner_info['phone_2']; } $contacts_owner = array('phones' => implode(', ', $phones), 'email' => '', 'adress' => '', 'url' => AT_Common::site_url('dealer/info/' . trim($owner_info['alias'] . '-' . $car_info['options']['_owner_id'], '-') . '/'), 'add_offer' => true, 'is_dealer' => true, 'name' => $owner_info['name'], 'photo' => $owner_info['photo']); } } else { $phones = array(); if (!empty($owner_info['phone'])) { $phones[] = $owner_info['phone']; } if (!empty($owner_info['phone_2'])) { $phones[] = $owner_info['phone_2']; } if (isset($owner_info['region_id'])) { $region = $reference_model->get_region_by_id($owner_info['region_id']); } $contacts_owner = array('phones' => implode(', ', $phones), 'email' => $owner_info['email'], 'adress' => !empty($region['name']) ? $region['name'] : '', 'url' => '', 'add_offer' => false, 'is_dealer' => false, 'name' => $owner_info['name'], 'photo' => $owner_info['photo']); } $this->breadcrumbs->add_item(__('Catalog', AT_TEXTDOMAIN), 'catalog/'); if ($manufacturer_data = $reference_model->get_manufacturer_by_id($car_info['options']['_manufacturer_id'])) { $this->breadcrumbs->add_item($manufacturer_data['name'], 'catalog/' . $manufacturer_data['alias']); if ($model_data = $reference_model->get_model_by_id($car_info['options']['_model_id'])) { $this->breadcrumbs->add_item($model_data['name'], 'catalog/' . $manufacturer_data['alias'] . '/' . $model_data['alias']); } } $this->breadcrumbs->add_item($car_info['post_title'], ''); $this->view->use_layout('header_content_footer')->add_block('content', 'car/view', array('car_info' => $car_info, 'contacts_owner' => $contacts_owner, 'car_photos' => $photo_model->get_photos_by_post(get_the_ID(), 'car'), 'equipments' => $reference_model->get_equipments(), 'car_views' => $car_model->get_car_views(get_the_ID()), 'is_dealer' => $owner_info['is_dealer']))->add_block('content/recent_cars', 'car/recent_cars', array('cars' => $car_model->get_similar_car(get_the_ID()))); //->add_block('content/loan_calculator', 'additions/loan_calculator'); }
public function want_be_dealer() { if (!$this->uri->is_ajax_request() || empty($_POST) || !isset($_POST['comment'])) { AT_Core::show_404(); } try { $comment = trim($_POST['comment']); if (empty($comment)) { throw new Exception(__('Comment is empty!', AT_TEXTDOMAIN)); } $mail_model = $this->load->model('mail_model'); $user_info = $this->registry->get('user_info'); $data = array('username' => $user_info['name'], 'comment' => $comment); $adm_email = get_option('admin_email'); if (!$mail_model->send('template_mail_notify_want_be_dealer', $adm_email, $data, $user_info['email'], $user_info['name'])) { throw new Exception(__('Error send email! Try later.', AT_TEXTDOMAIN)); } $response = array('status' => 'OK', 'message' => __('The request was sent.', AT_TEXTDOMAIN)); } catch (Exception $e) { $response = array('status' => 'ERROR', 'message' => $e->getMessage()); } $this->view->add_json($response)->display(); exit; }
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(); } } }
public function widget($args, $instance) { extract($args); $defaults = array('title' => '', 'description' => ''); $instance = wp_parse_args((array) $instance, $defaults); $title = ''; if (isset($instance['title'])) { $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); } if (!empty($title)) { $title_array = explode(" ", $title); $title = ""; foreach ($title_array as $tcount => $word) { if ($tcount == 0) { $word = "<strong>" . $word . "</strong>"; } $title .= $word . " "; } $title = "<h3>" . $title . "</h3>"; } $description = $instance['description']; $loans = AT_Core::get_instance()->get_option('loans'); $html = '<form name="loan_calculator" class="loan calculator form">'; $annual_rate = array(); $downpay = array(); $period_min = array(); $period_max = array(); $name = array(); $total = count($loans) - 1; foreach ($loans as $key => $loan) { $period_min[] = $loan['period_min']; $period_max[] = $loan['period_max']; $annual_rate[] = str_replace('%', '', $loan['annual_rate']); $downpay[] = str_replace('%', '', $loan['downpay']); $names[] = $loan['name']; } $cn = 0; $html .= '<div class="loan calculator-wrapper">'; $html .= $title; // Loan amount $html .= '<label><strong>' . __('Loan Amount', AT_TEXTDOMAIN) . ':</strong></label>'; $html .= '<input name="amount" class="text loan amount" value="" />'; // Down pay $html .= '<div class="select_wrapper">'; $html .= '<label><strong>' . __('Down Payment', AT_TEXTDOMAIN) . ':</strong></label>'; $html .= '<select name="downpay" class="custom-select loan down pay">'; // $html .= '<option value="-1" selected>' . __( 'Please select...', AT_TEXTDOMAIN ) . '</option>'; foreach ($names as $name) { $html .= '<option value="' . $cn . '">' . $downpay[$cn] . '%</option>'; $cn++; } $html .= '</select>'; $html .= '</div>'; // Annual rate $html .= '<div class="select_wrapper">'; $html .= '<label><strong>' . __('Annual Rate', AT_TEXTDOMAIN) . ':</strong></label>'; $html .= '<select name="rate" class="custom-select loan annual rate">'; $html .= '<option value="">' . __('Please select...', AT_TEXTDOMAIN) . '</option>'; $html .= '</select>'; $html .= '</div>'; // period_max $html .= '<div class="select_wrapper">'; $html .= '<label><strong>' . __('Loan Period', AT_TEXTDOMAIN) . ':</strong></label>'; $html .= '<select name="period" class="custom-select loan period">'; $html .= '<option value="">' . __('Please select...', AT_TEXTDOMAIN) . '</option>'; $html .= '</select>'; $html .= '</div>'; $html .= '<input type="submit" value="' . __('Calculate', AT_TEXTDOMAIN) . '" class="btn_calc">'; $html .= '</div>'; $script = ' <noscript> ' . __('Loan Calculator requires enable Javascript support. Please enable Javascript in your browser settings to continue, and reload page.', AT_TEXTDOMAIN) . ' </noscript> <script> jQuery(document).ready(function(){ var $j = jQuery; var period = ' . json_encode($period_max) . '; var downpay = ' . json_encode($downpay) . '; var rate = ' . json_encode($annual_rate) . '; var settings = []; var downpay_html = []; var meta = $j(".car_characteristics .price"); var dropdown_period = $j(".loan.calculator .loan.period"); var amount = $j(".loan.calculator .loan.amount"); var annual_rate = $j(".loan.calculator .loan.annual.rate"); var selector = $j(".loan.calculator-wrapper .loan.down.pay"); var initLoanCalculator = function(el) { var val = el.val(); if ( val.length > 0 ) { settings["period"]=period[val]*1; settings["downpay"]=downpay[val]; settings["rate"]=rate[val]*1; dropdown_period.html(""); annual_rate.html(""); // Period for (var p = 1; p < (period[val]*1+1); p++) { $j("<option/>", {value: p, text: p + " year"}).appendTo(dropdown_period); } // Rate $j("<option/>", {value: rate[val], text: rate[val] + "%"}).appendTo(annual_rate); } } $j(".loan.calculator-wrapper .loan.down.pay option").each(function(e) { if ( meta.length > 0) { settings["price"] = meta.data("price")*1; settings["currency"] = meta.data("currency"); // downpay_html[e] = downpay[e] * (((meta.data("price"))*1) / 100); // downpay_html[e] += " " + meta.data("currency"); amount.val(meta.data("price")); amount.attr("readonly","true"); $j(this).html(downpay_html[e]); } }); initLoanCalculator(selector); selector.change( function(){ var el = $j(this); initLoanCalculator(el); } ); $j("form.loan.calculator.form").bind("submit", function() { var html = ""; settings["period"]=(dropdown_period.val())*1; var total_rate = settings["period"] * settings["rate"]; var total_fee_amount = 0; var paid = ( amount.val()*1 ) - (settings["downpay"] * ( amount.val()*1 / 100 )); for ( var v=0; v < settings["period"]; v++ ) { total_fee_amount += (( settings["rate"]*1 ) * paid / 100 ); paid = ( ( settings["rate"]*1 ) * paid / 100 ) + paid; } var monthly_payment = paid/( settings["period"]*1*12 ); var html = ""; var total_month = 1; for ( var v=1; v < (settings["period"]*1*12+1); v++ ) { html += "<tr><td>Month " + v + "</td><td>" + monthly_payment.toFixed(2) + " " + settings["currency"] + "</td></tr>"; } html = "<table width=100% cellpadding=5 cellspacing=0 border=1><tbody>" + html + "</tbody></table>"; html += "<h3>Fee amount: " + total_fee_amount.toFixed(2) + "</h3>"; html += "<h3>Total price: " + (total_fee_amount + ( amount.val()*1 )).toFixed(2) + "</h3>"; AT_Application.ModalBox({"width": 940, "handler": "prepend"},html); return false; }); }); </script> '; if (!empty($description)) { $description = '<p>' . $description . '</p>'; } if (isset($instance['type']) && $instance['type'] == 'page_content') { echo '<div class="wj_loan_calculators">'; // echo '<h3>' . $title . '</h3>'; echo $html; echo $script; echo '</div>'; } else { echo $before_widget; // echo "<h3>" . $title . "</h3>"; echo $html; echo $script; echo $description; echo $after_widget; } }
private function _frontend_header($params) { $data = array(); switch ($this->core->get_option('logo_settings')) { case 'logo_image': $width = $this->core->get_option('header_logo_width') != '' ? ' style="max-width:' . $this->core->get_option('header_logo_width') . ';"' : ''; if ($this->core->get_option('header_logo_src') != '') { $data['logo'] = '<img src="' . $this->core->get_option('header_logo_src') . '"' . $width . '>'; } else { $data['logo'] = '<img src="' . AT_Common::static_url('/assets/images/pics/logo_auto_dealer.png') . '"' . $width . '>'; } break; case 'logo_text': $data['logo'] = $this->core->get_option('header_logo_text'); break; default: $data['logo'] = get_bloginfo('name'); break; } $data['header_style'] = $this->core->get_option('header_content_style', 'info'); $data['add_car_button'] = $this->core->get_option('header_add_car_button', true); $data['add_car_button'] = $this->core->get_option('header_add_car_button', true); $data['sociable_view'] = $this->core->get_option('header_sociable_view', true); $data['sociable'] = AT_Core::get_instance()->get_option('sociable', array()); $data['site_type'] = $this->core->get_option('site_type', 'mode_soletrader'); $data['phone'] = $this->core->get_option('header_phone', ''); $data['adress'] = $this->core->get_option('header_adress', ''); $data['header_custom_html'] = $this->core->get_option('header_custom_html', ''); $data['searchbox'] = $this->core->get_option('header_searchbox', true); return $data; }
private function _field_backup($args) { $defaults = array('title' => '', 'description' => '', 'name' => '', 'value' => ''); $args = wp_parse_args($args, $defaults); $args['value'] = base64_encode(serialize(AT_Core::get_instance()->get_options())); $this->view->add_block($this->_get_block_id(), 'admin/fields/textarea', $args); }
public function ajax_add_offer($car_id = '') { $car_id = (int) $car_id; if (!$this->uri->is_ajax_request() || $car_id == 0) { AT_Core::show_404(); } $car_model = $this->load->model('car_model'); if (!($car_info = $car_model->get_car_info($car_id))) { AT_Core::show_404(); } try { if (!$this->validation->run('add_offer')) { throw new Exception(serialize($this->validation->get_errors())); } $mail_model = $this->load->model('mail_model'); $user_model = $this->load->model('user_model'); $owner_info = $user_model->get_user_by_id($car_info['options']['_owner_id']); $dealer_email = ''; if ($owner_info['is_dealer']) { if ($car_info['options']['_affiliate_id'] > 0) { $affiliate = $user_model->get_dealer_affiliate_by_id($car_info['options']['_affiliate_id']); } if (empty($affiliate)) { $affiliate = $user_model->get_dealer_main_affiliate($car_info['options']['_owner_id']); } if ($affiliate) { $dealer_email = $affiliate['email']; } } if (!$owner_info['is_dealer'] || $dealer_email == '') { $dealer_email = $owner_info['email']; } $cost = AT_Common::show_full_price($value = $car_info['options']['_price'], $currency = $car_info['options']['_currency_id']); $data = array('dealer_name' => $owner_info['name'], 'username' => $_POST['fullname'], 'user_email' => $_POST['email'], 'car_name' => trim($car_info['options']['_manufacturer_id']['name'] . ' ' . $car_info['options']['_model_id']['name'] . ' ' . $car_info['options']['_version']), 'cost' => $cost, 'offer_details' => $_POST['offer_details'], 'link_car' => get_permalink($car_id)); if (!$mail_model->send('template_mail_add_offer', $dealer_email, $data, $_POST['email'], $_POST['fullname'])) { throw new Exception(serialize(array('email' => __('Error send email! Try later.', AT_TEXTDOMAIN)))); } $response = array('status' => 'OK', 'message' => __('The offer was sent.', AT_TEXTDOMAIN)); } catch (Exception $e) { $response = array('status' => 'ERROR', 'message' => unserialize($e->getMessage())); } $this->view->add_json($response)->display(); }
public static function options() { if (isset($_GET['page'])) { AT_Core::get_instance()->view->display(); } }
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?> " /> <meta property="og:title" content="<?php echo $page_title; ?> " /> <meta property="og:url" content="<?php if (is_home()) { print site_url(); } else { print get_permalink(); } ?> " /> <?php if (AT_Core::get_instance()->get_option('favicon')) { echo '<link href="' . AT_Core::get_instance()->get_option('favicon') . '" rel="icon" type="image/x-icon" />'; } ?> <?php wp_head(); ?> </head> <body <?php body_class(); ?> > <?php AT_Notices::get_frontend_notice();
public function form($instance) { $defaults = array('title' => 'Social networks', 'color' => '#0000FF', 'description' => 'Website powered by WinterJuice theme'); $instance = wp_parse_args((array) $instance, $defaults); if (!isset($instance['skin'])) { $instance['skin'] = 'default'; } echo ' <p> <label for="' . $this->get_field_id('title') . '">Widget Title:</label> <input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" value="' . $instance['title'] . '" /> </p> <p> <label for="' . $this->get_field_id('title') . '">Custom Text:</label> <input class="widefat" id="' . $this->get_field_id('description') . '" name="' . $this->get_field_name('description') . '" value="' . $instance['description'] . '" /> </p>'; $skin = $instance['skin']; $sociable = AT_Core::get_instance()->get_option('sociable'); $sociables = ""; $total = count($sociable) - 1; $width = 100 / $total; $size = $width / 2; echo '<h3>Icons Preview:</h3>'; $sociables .= '<div class="custom-socials">'; foreach ($sociable as $key => $item) { $sociable_link = !empty($item['link']) ? $item['link'] : '#'; $sociables .= ' <a href="' . esc_url($sociable_link) . '"> <i class="' . $item['icon'] . '"></i> </a> '; } $sociables .= '</div>'; echo $sociables; echo '<hr />'; }
public static function car_mileage($view = 1) { $car_mileage = AT_Core::get_instance()->get_option('car_mileage', 'miles'); $types = array('miles' => array(__('Miles', AT_ADMIN_TEXTDOMAIN), __('miles', AT_ADMIN_TEXTDOMAIN), __('miles', AT_ADMIN_TEXTDOMAIN)), 'kilometers' => array(__('Kilometers', AT_ADMIN_TEXTDOMAIN), __('kilometers', AT_ADMIN_TEXTDOMAIN), __('km', AT_ADMIN_TEXTDOMAIN))); return $types[$car_mileage][$view]; }
public function get_option($item, $default = null) { if ($default != null) { $value = AT_Core::get_instance()->get_option($item, $default); } else { $value = AT_Core::get_instance()->get_option($item); } return !is_null($value) ? $value : ''; }
public function upload() { if (empty($_POST) || empty($_FILES) || !isset($_FILES["file"])) { AT_Core::show_404(); } $_file_a = explode('.', $_FILES["file"]["name"]); if (count($_file_a) <= 1) { //AT_Core::show_404(); $file_name = uniqid("car_") . '.jpg'; } else { $file_name = uniqid("car_") . '.' . $_file_a[count($_file_a) - 1]; } //$file_name = uniqid("car_") . '.' . $_file_a[count($_file_a)-1]; $targetDir = AT_DIR_THEME . '/uploads'; $cleanupTargetDir = false; // Remove old files $maxFileAge = 5 * 3600; // Temp file age in seconds $filePath = $targetDir . DIRECTORY_SEPARATOR . $file_name; // Chunking might be enabled $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0; $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0; try { // Open temp file if (!($out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb"))) { throw new Exception('{"status" : "ERROR", "code": 102, "message": "Failed to open output stream."}'); } if (!empty($_FILES)) { if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) { throw new Exception('{"status" : "ERROR", "code": 103, "message": "Failed to move uploaded file."}'); } // Read binary input stream and append it to temp file if (!($in = @fopen($_FILES["file"]["tmp_name"], "rb"))) { throw new Exception('{"status" : "ERROR", "code": 101, "message": "Failed to open input stream."}'); } } else { if (!($in = @fopen("php://input", "rb"))) { throw new Exception('{"status" : "ERROR", "code": 101, "message": "Failed to open input stream."}'); } } while ($buff = fread($in, 4096)) { fwrite($out, $buff); } @fclose($out); @fclose($in); // Check if file has been uploaded if (!$chunks || $chunk == $chunks - 1) { // Strip the temp .part suffix off rename("{$filePath}.part", $filePath); } // Return Success JSON-RPC response $response = '{"status" : "OK", "file_name" : "' . $file_name . '", "file_name_url" : "' . AT_Common::static_url('uploads/' . $file_name) . '"}'; throw new Exception($response); } catch (Exception $e) { $this->view->add_json(json_decode($e->getMessage()))->display(); } }