The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
77777
By Guest on 2nd January 2019 01:33:20 AM | Syntax: PHP | Views: 18



New paste | Download | Show/Hide line no. | Copy text to clipboard
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2.  
  3. class Core_Controller extends CI_Controller
  4. {
  5.     public function __construct()
  6.     {
  7.         parent::__construct();
  8.         //settings
  9.         $global_data['general_settings'] = $this->settings_model->get_general_settings();
  10.         $this->general_settings = $global_data['general_settings'];
  11.         //set timezone
  12.         date_default_timezone_set($this->general_settings->timezone);
  13.         //lang base url
  14.         $global_data['lang_base_url'] = base_url();
  15.         //languages
  16.         $global_data['languages'] = $this->language_model->get_active_languages();
  17.         //site lang
  18.         $global_data['site_lang'] = $this->language_model->get_language($this->general_settings->site_lang);
  19.         if (empty($global_data['site_lang'])) {
  20.             $global_data['site_lang'] = $this->language_model->get_language('1');
  21.         }
  22.         $global_data['selected_lang'] = $global_data['site_lang'];
  23.  
  24.         //set language
  25.         $lang_segment = $this->uri->segment(1);
  26.         foreach ($global_data['languages'] as $lang) {
  27.             if ($lang_segment == $lang->short_form) {
  28.                 if ($this->general_settings->multilingual_system == 1):
  29.                     $global_data['selected_lang'] = $lang;
  30.                     $global_data['lang_base_url'] = base_url() . $lang->short_form . "/";
  31.                 else:
  32.                     redirect(base_url());
  33.                 endif;
  34.             }
  35.         }
  36.         $this->selected_lang = $global_data['selected_lang'];
  37.         $this->lang_base_url = $global_data['lang_base_url'];
  38.         if (!file_exists(APPPATH . "language/" . $this->selected_lang->folder_name)) {
  39.             echo "Language folder doesn't exists!";
  40.             exit();
  41.         }
  42.         $this->config->set_item('language', $global_data['selected_lang']->folder_name);
  43.         $this->lang->load("site_lang", $global_data['selected_lang']->folder_name);
  44.  
  45.         $global_data['rtl'] = false;
  46.         if ($global_data['selected_lang']->text_direction == "rtl") {
  47.             $global_data['rtl'] = true;
  48.         }
  49.         $this->rtl = $global_data['rtl'];
  50.         $this->language_id = $global_data['selected_lang']->id;
  51.  
  52.         //set lang base url
  53.         if ($this->general_settings->site_lang == $this->language_id) {
  54.             $global_data['lang_base_url'] = base_url();
  55.         } else {
  56.             $global_data['lang_base_url'] = base_url() . $global_data['selected_lang']->short_form . "/";
  57.         }
  58.         $this->lang_base_url = $global_data['lang_base_url'];
  59.  
  60.         //check remember
  61.         $this->auth_model->check_remember();
  62.  
  63.         //check auth
  64.         $this->auth_check = auth_check();
  65.         if ($this->auth_check) {
  66.             $this->auth_user = user();
  67.         }
  68.  
  69.         $global_data['vsettings'] = $this->visual_settings_model->get_settings();
  70.         $global_data['settings'] = $this->settings_model->get_settings($global_data['selected_lang']->id);
  71.         $this->settings = $global_data['settings'];
  72.  
  73.         //get site primary font
  74.         $this->config->load('fonts');
  75.         $global_data['primary_font'] = $this->general_settings->primary_font;
  76.         $global_data['primary_font_family'] = $this->config->item($global_data['primary_font'] . '_font_family');
  77.         $global_data['primary_font_url'] = $this->config->item($global_data['primary_font'] . '_font_url');
  78.  
  79.         //get site secondary font
  80.         $global_data['secondary_font'] = $this->general_settings->secondary_font;
  81.         $global_data['secondary_font_family'] = $this->config->item($global_data['secondary_font'] . '_font_family');
  82.         $global_data['secondary_font_url'] = $this->config->item($global_data['secondary_font'] . '_font_url');
  83.  
  84.         //get site tertiary font
  85.         $global_data['tertiary_font'] = $this->general_settings->tertiary_font;
  86.         $global_data['tertiary_font_family'] = $this->config->item($global_data['tertiary_font'] . '_font_family');
  87.         $global_data['tertiary_font_url'] = $this->config->item($global_data['tertiary_font'] . '_font_url');
  88.  
  89.         //bg images
  90.         $global_data["img_bg_mid"] = base_url() . "assets/img/img_bg_mid.jpg";
  91.         $global_data["img_bg_sm"] = base_url() . "assets/img/img_bg_sm.jpg";
  92.         $global_data["img_bg_sl"] = base_url() . "assets/img/img_bg_sl.jpg";
  93.         $global_data["img_bg_lg"] = base_url() . "assets/img/img_bg_lg.jpg";
  94.         $global_data["img_bg_sm_footer"] = base_url() . "assets/img/img_bg_sm_footer.jpg";
  95.  
  96.         //update last seen
  97.         $this->auth_model->update_last_seen();
  98.  
  99.         $this->load->vars($global_data);
  100.     }
  101.  
  102. }
  103.  
  104. class Home_Core_Controller extends Core_Controller
  105. {
  106.     public function __construct()
  107.     {
  108.         parent::__construct();
  109.  
  110.         //categories
  111.         $this->categories = get_cached_data('categories');
  112.         if (empty($this->categories)) {
  113.             $this->categories = $this->category_model->get_categories();
  114.             set_cache_data('categories', $this->categories);
  115.         }
  116.         //pages
  117.         $this->pages = get_cached_data('pages');
  118.         if (empty($this->pages)) {
  119.             $this->pages = $this->page_model->get_pages();
  120.             set_cache_data('pages', $this->pages);
  121.         }
  122.         //menu links
  123.         $this->menu_links = get_cached_data('menu_links');
  124.         if (empty($this->menu_links)) {
  125.             $this->menu_links = $this->navigation_model->get_menu_links();
  126.             set_cache_data('menu_links', $this->menu_links);
  127.         }
  128.         //total post count
  129.         $this->total_posts_count = get_cached_data('total_posts_count');
  130.         if (empty($this->total_posts_count)) {
  131.             $this->total_posts_count = $this->post_model->get_post_count_by_lang($this->selected_lang->id);
  132.             set_cache_data('total_posts_count', $this->total_posts_count);
  133.         }
  134.         //random posts
  135.         $this->random_posts = get_cached_data('random_posts');
  136.         if (empty($this->random_posts)) {
  137.             $this->random_posts = $this->post_model->get_random_posts(15);
  138.             set_cache_data('random_posts', $this->random_posts);
  139.         }
  140.         //popular posts
  141.         $this->popular_posts_week = get_cached_data('popular_posts_week');
  142.         if (empty($this->popular_posts_week)) {
  143.             $this->popular_posts_week = $this->post_model->get_popular_posts(7);
  144.             set_cache_data('popular_posts_week', $this->popular_posts_week);
  145.         }
  146.         $this->popular_posts_month = get_cached_data('popular_posts_month');
  147.         if (empty($this->popular_posts_month)) {
  148.             $this->popular_posts_month = $this->post_model->get_popular_posts(30);
  149.             set_cache_data('popular_posts_month', $this->popular_posts_month);
  150.         }
  151.         $this->popular_posts_year = get_cached_data('popular_posts_year');
  152.         if (empty($this->popular_posts_year)) {
  153.             $this->popular_posts_year = $this->post_model->get_popular_posts(365);
  154.             set_cache_data('popular_posts_year', $this->popular_posts_year);
  155.         }
  156.         //recommended posts
  157.         $this->recommended_posts = get_cached_data('recommended_posts');
  158.         if (empty($this->recommended_posts)) {
  159.             $this->recommended_posts = $this->post_model->get_recommended_posts();
  160.             set_cache_data('recommended_posts', $this->recommended_posts);
  161.         }
  162.         //category posts
  163.         $this->category_posts = get_cached_data('category_posts');
  164.         if (empty($this->category_posts)) {
  165.             $this->category_posts = $this->generate_posts_array_by_category();
  166.             set_cache_data('category_posts', $this->category_posts);
  167.         }
  168.         //widgets
  169.         $this->widgets = get_cached_data('widgets');
  170.         if (empty($this->widgets)) {
  171.             $this->widgets = $this->widget_model->get_widgets();
  172.             set_cache_data('widgets', $this->widgets);
  173.         }
  174.         //random tags
  175.         $this->random_tags = get_cached_data('random_tags');
  176.         if (empty($this->random_tags)) {
  177.             $this->random_tags = $this->tag_model->get_random_tags();
  178.             set_cache_data('random_tags', $this->random_tags);
  179.         }
  180.         $global_data['polls'] = $this->poll_model->get_polls();
  181.  
  182.         //Social Login
  183.         $global_data['fb_login_state'] = 0;
  184.         $global_data['google_login_state'] = 0;
  185.  
  186.         if (!empty($this->general_settings->facebook_app_id)) {
  187.             $global_data['fb_login_state'] = 1;
  188.         }
  189.         if (!empty($this->general_settings->google_client_id)) {
  190.             $global_data['google_login_state'] = 1;
  191.         }
  192.         //recaptcha status
  193.         $global_data['recaptcha_status'] = true;
  194.         if (empty($this->general_settings->recaptcha_site_key) || empty($this->general_settings->recaptcha_secret_key)) {
  195.             $global_data['recaptcha_status'] = false;
  196.         }
  197.         $this->recaptcha_status = $global_data['recaptcha_status'];
  198.         $this->load->vars($global_data);
  199.     }
  200.  
  201.     //generate posts array by category
  202.     public function generate_posts_array_by_category()
  203.     {
  204.         $array_posts = array();
  205.         if (!empty($this->categories)) {
  206.             foreach ($this->categories as $category) {
  207.                 $array_posts['category_' . $category->id] = get_latest_posts_by_category($category, 8);
  208.             }
  209.         }
  210.         return $array_posts;
  211.     }
  212.  
  213.     //verify recaptcha
  214.     public function recaptcha_verify_request()
  215.     {
  216.         if (!$this->recaptcha_status) {
  217.             return true;
  218.         }
  219.  
  220.         $this->load->library('recaptcha');
  221.         $recaptcha = $this->input->post('g-recaptcha-response');
  222.         if (!empty($recaptcha)) {
  223.             $response = $this->recaptcha->verifyResponse($recaptcha);
  224.             if (isset($response['success']) && $response['success'] === true) {
  225.                 return true;
  226.             }
  227.         }
  228.         return false;
  229.     }
  230.  
  231.     public function paginate($url, $total_rows)
  232.     {
  233.         $per_page = $this->general_settings->pagination_per_page;
  234.         //initialize pagination
  235.         $page = $this->security->xss_clean($this->input->get('page'));
  236.         if (empty($page)) {
  237.             $page = 0;
  238.         }
  239.         if ($page != 0) {
  240.             $page = $page - 1;
  241.         }
  242.         $config['num_links'] = 4;
  243.         $config['base_url'] = $url;
  244.         $config['total_rows'] = $total_rows;
  245.         $config['per_page'] = $per_page;
  246.         $config['reuse_query_string'] = true;
  247.         $this->pagination->initialize($config);
  248.         return array('per_page' => $per_page, 'offset' => $page * $per_page, 'current_page' => $page + 1);
  249.     }
  250.  
  251. }
  252.  
  253. class Admin_Core_Controller extends Core_Controller
  254. {
  255.  
  256.     public function __construct()
  257.     {
  258.         parent::__construct();
  259.  
  260.         if (!auth_check()) {
  261.             redirect(admin_url() . "login");
  262.         }
  263.         $global_data['images'] = $this->file_model->get_images(48);
  264.         $global_data['audios'] = $this->file_model->get_audios(48);
  265.         $global_data['videos'] = $this->file_model->get_videos(48);
  266.         $this->load->vars($global_data);
  267.     }
  268.  
  269.     public function paginate($url, $total_rows)
  270.     {
  271.         //initialize pagination
  272.         $page = $this->security->xss_clean($this->input->get('page'));
  273.         $per_page = $this->input->get('show', true);
  274.         if (empty($page)) {
  275.             $page = 0;
  276.         }
  277.  
  278.         if ($page != 0) {
  279.             $page = $page - 1;
  280.         }
  281.  
  282.         if (empty($per_page)) {
  283.             $per_page = 15;
  284.         }
  285.  
  286.         $config['num_links'] = 4;
  287.         $config['base_url'] = $url;
  288.         $config['total_rows'] = $total_rows;
  289.         $config['per_page'] = $per_page;
  290.         $config['reuse_query_string'] = true;
  291.         $this->pagination->initialize($config);
  292.  
  293.         return array('per_page' => $per_page, 'offset' => $page * $per_page);
  294.     }
  295. }



  • Recent Pastes
  • Admin Style CSS
    16 hours 58 mins 23 secs ago
  • Asdasdad
    1 week 3 days 2 hours 7 mins and 8 secs ago
  • Testing
    2 weeks 16 hours 58 mins and 31 secs ago
  • 77777
    2 weeks 1 day 21 hours 33 mins and 9 secs ago
  • Test paste
    2 weeks 3 days 8 hours 42 mins and 43 secs ago