예제 #1
0
 public function default()
 {
     $default = ['limit' => 1, 'level' => 0];
     $this->merge_defaults($default);
     ci()->load->model('c_page_model');
     /* get the page model table prefix so this will be cleared when the model is flushed */
     $model_cache_prefix = ci()->c_page_model->get_cache_prefix();
     /* create our cache key using that prefix */
     $cache_key = $model_cache_prefix . '.menu.special.catalog';
     /* do we have this cached? */
     if (!($data = ci()->cache->get($cache_key))) {
         $records = ci()->c_page_model->get_menus($this->option('level'), $this->option('limit'));
         $data = '<ul class="nav navbar-nav">';
         foreach ($records as $idx => $rec) {
             $record->idx = $idx;
             if ($rec->in_menu) {
                 $url = $rec->url == '/' . setting('cms-page.Home Page', 'home-page') ? '/' : $rec->url;
                 $data .= '<li><a href="' . str_replace('*', '', $url) . '">' . $rec->title . '</a></li>';
             }
         }
         $data .= '</ul>';
         ci()->cache->save($cache_key, $data);
     }
     return $data;
 }
 public function indexPostAction()
 {
     $honey_pot = 'team_name';
     /* did they fill in the honey pot? */
     if (!empty($this->input->post($honey_pot))) {
         show_error('Form Submission Error 101');
     }
     $everything = $this->input->post();
     unset($everything['team_name']);
     /* honey pot */
     unset($everything['_success_goto']);
     unset($everything['_fail_goto']);
     unset($everything['_form_name']);
     $form_name = $this->input->post('_form_name');
     $success_goto = $this->input->post('_success_goto');
     $fail_goto = $this->input->post('_fail_goto');
     /* did the hmac unhash properly? if not something fishy going on */
     if (!ci()->validate->filter_hmac($form_name)) {
         show_error('Form Submission Error 102');
     }
     /* did the hmac unhash properly? if not something fishy going on */
     if (!ci()->validate->filter_hmac($success_goto)) {
         show_error('Form Submission Error 103');
     }
     /* did the hmac unhash properly? if not something fishy going on */
     if (!ci()->validate->filter_hmac($fail_goto)) {
         show_error('Form Submission Error 104');
     }
     $data = ['created_on' => date('Y-m-d H:i:s'), 'ip_address' => $this->input->ip_address(), 'user_agent' => $this->input->user_agent(), 'form_name' => $form_name, 'url' => $this->input->server('HTTP_REFERER'), 'capture' => json_encode($everything, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE)];
     $this->load->model('capture_model');
     $redirect = $this->capture_model->insert($data) ? $success_goto : $fail_goto;
     redirect($redirect);
 }
예제 #3
0
 public function is_valid($rules = '', $input = null, $human_die = true)
 {
     $human = 'field';
     $die = true;
     if (is_bool($human_die)) {
         $die = $human_die;
     } elseif (is_string($human_die)) {
         $human = $human_die;
         /* don't die because they sent in a Human readable field name */
         $die = false;
     }
     /* post variable? */
     if ($input[0] == '@') {
         $input = $this->_fetch_from_array($_POST, substr($input, 1));
     }
     /* either get a reply or die here */
     $reply = ci()->validate->die_on_fail($die)->single($rules, $input, $human);
     /*
     if we havn't died yet then what should we return?
     
     if die is true then we are just testing multiple inputs so allow chaining
     if die is false then they sent in a human field name so return the reply (false)
     this will also populate the validate error string (which is why the human is needed)
     */
     return $die ? $this : $reply;
 }
 public function __construct()
 {
     parent::__construct();
     //var_dump($this->ion_auth->logged_in());die;
     if (!$this->ion_auth->logged_in()) {
         redirect('auth/login', 'refresh');
     }
     $this->load->helper('dropdowns');
     $this->load->model('user_model', 'user_m');
     $this->load->model('company_model', 'company_m');
     $this->current_user = $this->user_m->get_user_profile($this->session->userdata('user_id'));
     $this->current_user->gmt_offset = $this->cfg->gmt_offset;
     if (!$this->current_user) {
         redirect('auth/login', 'refresh');
     }
     $company_settings = $this->current_user->group_id == 1 ? FALSE : $this->company_m->company_settings($this->current_user->company_id);
     //$custom_field = $this->company_m->company_custom_fields($this->current_user->company_id);
     //$this->form_validation->CI =& $this;
     $this->template->current_user = ci()->current_user = $this->current_user;
     $this->template->current_user->company_settings = ci()->current_user->company_settings = $company_settings;
     //$this->template->custom_field = ci()->custom_field = $custom_field;
     $gmt_options = $this->session->userdata('gmt_options');
     $this->template->gmt_options = ci()->gmt_options = array('recheck' => true);
     if (!empty($gmt_options)) {
         $gmt_options = unserialize_object($gmt_options);
         $this->template->gmt_options = ci()->gmt_options = $gmt_options;
     }
 }
예제 #5
0
 /**
  * @todo Document this please.
  */
 public function __construct()
 {
     parent::__construct();
     // Not logged in or not an admin and don't have permission to see files
     if (!$this->current_user or $this->current_user->group !== 'admin' and (!isset($this->permissions['files']) or !isset($this->permissions['files']['wysiwyg']))) {
         $this->load->language('files/files');
         show_error(lang('files:no_permissions'));
     }
     ci()->admin_theme = $this->theme_m->get_admin();
     // Using a bad slug? Weak
     if (empty($this->admin_theme->slug)) {
         show_error('This site has been set to use an admin theme that does not exist.');
     }
     // Make a constant as this is used in a lot of places
     defined('ADMIN_THEME') or define('ADMIN_THEME', $this->admin_theme->slug);
     // Set the location of assets
     Asset::add_path('module', APPPATH . 'modules/wysiwyg/');
     Asset::add_path('theme', $this->admin_theme->web_path . '/');
     Asset::set_path('theme');
     $this->load->library('files/files');
     $this->lang->load('files/files');
     $this->lang->load('wysiwyg');
     $this->lang->load('buttons');
     $this->template->set_theme(ADMIN_THEME)->set_layout('wysiwyg', 'admin')->enable_parser(false)->append_css('module::wysiwyg.css')->append_css('jquery/ui-lightness/jquery-ui.css')->append_js('jquery/jquery.js')->append_js('jquery/jquery-ui.min.js')->append_js('plugins.js')->append_js('module::wysiwyg.js');
 }
예제 #6
0
 public function __construct()
 {
     parent::__construct();
     //load base libraries, helpers and models
     $this->load->database();
     // load the migrations class & settings model
     $this->load->library('migration');
     if (!($schema_version = $this->migration->current())) {
         show_error($this->migration->error_string());
     }
     //load the default libraries
     $this->load->library(array('session', 'login/login_lib'));
     $this->load->helper(array('language', 'system'));
     // load lang from session
     $lang = ci()->curlang = get_lang_session();
     if (!$lang) {
         set_lang_session();
         $lang = ci()->curlang = get_lang_session();
     }
     $this->config->set_item('language', $lang);
     // Work out module, controller and method and make them accessable throught the CI instance
     ci()->module = $this->router->fetch_module();
     ci()->controller = ci()->class = $this->router->fetch_class();
     ci()->method = $this->router->fetch_method();
 }
예제 #7
0
 function my_img_resize($config)
 {
     ci()->load->library('image_lib');
     $config['image_library'] = 'gd2';
     $config['create_thumb'] = TRUE;
     $config['quality'] = '100%';
     $marker = "_thumb" . @$config['width'] . @$config['height'];
     $thumb = preg_replace("!\\.([^/]+?)\$!", $marker . ".\$1", $config['source_image']);
     if (!file_exists($thumb)) {
         $config['thumb_marker'] = $marker;
         $list = getimagesize($config['source_image']);
         $width = $list[0];
         $height = $list[1];
         if (!isset($config['width']) or !isset($config['height'])) {
             $ratio = $width / $height;
             if (!isset($config['width'])) {
                 $config['width'] = $config['height'] * $ratio;
             } else {
                 $config['height'] = $config['width'] * $ratio;
             }
         }
         ci()->image_lib->clear();
         ci()->image_lib->initialize($config);
         if (!ci()->image_lib->resize()) {
             echo ci()->image_lib->display_errors();
         }
     }
     return substr($thumb, strlen(DOCUMENT_ROOT) - 1);
 }
예제 #8
0
 public function default()
 {
     $default = ['categories' => '', 'category' => '', 'not_categories' => '', 'not_category' => '', 'is_visible' => 1, 'start_on' => date('Y-m-d H:i:s'), 'end_on' => date('Y-m-d H:i:s'), 'sort' => 'start_on', 'is_deleted' => '0000-00-00 00:00:00', 'dir' => 'asc', 'limit' => 500, 'title' => '', 'internal' => ''];
     $this->merge_defaults($default);
     $records = ci()->c_content_model->show($this->options);
     return $this->loop($records);
 }
예제 #9
0
 public function route($uri)
 {
     $uri = '/' . uri_string();
     /* if it's the home page then change url to /home-page */
     if ($uri == '/') {
         $uri = '/' . setting('cms-page.Home Page', 'home-page');
     }
     ci()->load->model('c_page_model');
     /* catalog caches the data */
     $catalog = ci()->c_page_model->active_urls();
     $record = null;
     $routes = array_keys($catalog);
     foreach ($routes as $route) {
         $pattern = '#^' . str_replace('*', '(.*)', $route) . '$#';
         if (preg_match($pattern, $uri)) {
             $record = $catalog[$route];
             break;
         }
     }
     if (!$record) {
         show_404($uri, true);
     }
     /* load the template model so we can find the templates html */
     ci()->load->model('c_templates_model');
     ci()->load->library('lex_plugin');
     ci()->load->helper('cms');
     /* we send it into the lex parser */
     $parser = new Lex\Parser();
     /* final output */
     ci()->output->set_output($parser->parse(ci()->c_templates_model->get_by_id($record->template_id), ci()->load->get_vars(), 'lex_plugin::_callback'));
 }
 public function __construct()
 {
     ci()->load->library('data_uri');
     ci()->event->register('page.prep', function (&$page) {
         $page->js('/plugins/attach_file/attach_file.min.js')->css('/plugins/attach_file/attach_file.min.css');
     });
 }
예제 #11
0
 public function start($lifespan)
 {
     if ($this->fragment_name != '') {
         die('Nested fragment cache not supported.');
     }
     $bt = debug_backtrace();
     $this->fragment_name = md5(ci()->uri->uri_string() . ':' . $bt[0]['line']) . '.view.fragment';
     /* if file does not exist, make preparations to cache and return true, so segment is executed */
     if (!file_exists($this->fragment_path . $this->fragment_name)) {
         $this->newly_cached = true;
         ob_start();
         return true;
     } else {
         /* cache exists, let's see if it is still valid by checking it's age against the $lifespan variable */
         $fmodify = filemtime($this->fragment_path . $this->fragment_name);
         $fage = time() - $fmodify;
         if ($fage > $lifespan * 60) {
             /* file is old, let's re-cache */
             $this->newly_cached = true;
             ob_start();
             return true;
         }
         /* no need to redo */
         return false;
     }
 }
 public function __construct()
 {
     parent::__construct();
     // Not an admin and not allowed to see files
     if ($this->current_user->group !== 'admin' and !array_key_exists('files', $this->permissions)) {
         $this->load->language('files/files');
         show_error(lang('files.no_permissions'));
     }
     ci()->admin_theme = $this->theme_m->get_admin();
     // Using a bad slug? Weak
     if (empty($this->admin_theme->slug)) {
         show_error('This site has been set to use an admin theme that does not exist.');
     }
     // make a constant as this is used in a lot of places
     defined('ADMIN_THEME') or define('ADMIN_THEME', $this->admin_theme->slug);
     // Prepare Asset library
     $this->asset->set_theme(ADMIN_THEME);
     // Set the location of assets
     $this->config->set_item('asset_dir', dirname($this->admin_theme->web_path) . '/');
     $this->config->set_item('asset_url', BASE_URL . dirname($this->admin_theme->web_path) . '/');
     $this->config->set_item('theme_asset_dir', dirname($this->admin_theme->web_path) . '/');
     $this->config->set_item('theme_asset_url', BASE_URL . dirname($this->admin_theme->web_path) . '/');
     $this->load->model('files/file_folders_m');
     $this->load->model('files/file_m');
     $this->lang->load('files/files');
     $this->lang->load('wysiwyg');
     $this->lang->load('buttons');
     $this->template->set_theme(ADMIN_THEME)->set_layout('wysiwyg', 'admin')->enable_parser(FALSE)->set('editor_path', config_item('asset_dir') . 'js/ckeditor/')->append_metadata(css('wysiwyg.css', 'wysiwyg'))->append_metadata(css('jquery/ui-lightness/jquery-ui.css'))->append_metadata(js('jquery/jquery.min.js'))->append_metadata(js('plugins.js'))->append_metadata(js('jquery/jquery-ui.min.js'))->append_metadata(js('wysiwyg.js', 'wysiwyg'));
 }
 public static function items($module, $parent_id, $uid = 0)
 {
     if ($uid) {
         $items = static::where('uid', $uid)->get()->toArray();
     } else {
         $items = static::where('module', $module)->where('parent_id', $parent_id)->get()->toArray();
     }
     $unique_keys = array();
     foreach ($items as $i) {
         if (!in_array($i['key'], $unique_keys)) {
             $unique_keys[] = $i['key'];
         }
     }
     $array = array();
     // we foreach on lang, in case new language was added, and we don't want undefined notices...
     $langs = ci()->translate->languages_admin();
     foreach ($langs as $lang_slug => $lang) {
         $array[$lang_slug] = array();
         foreach ($unique_keys as $k) {
             $array[$lang_slug][$k] = '';
             // $array[$lang_slug][$k] = array_get($items)
             foreach ($items as $i) {
                 if ($i['key'] == $k and $i['lang'] == $lang_slug) {
                     $array[$lang_slug][$k] = $i['val'];
                 }
             }
         }
     }
     return $array;
 }
 public function get_variables($extra = [])
 {
     ci()->load->model('c_snippet_model');
     $variables_set_b = setting('paths');
     $variables_set_a = $this->c_snippet_model->catalog('name', 'value');
     return array_merge($variables_set_b, $variables_set_a, ['base_url' => trim(base_url(), '/'), 'year' => date('Y')], (array) $extra);
 }
예제 #15
0
/**
 * Return a users display name based on settings
 *
 * @param int $user the users id
 * @return  string
 */
function user_displayname($user)
{
	if (is_numeric($user))
	{
		$user = ci()->ion_auth->get_user($user);
	}

	$user = (array) $user;

	// Static var used for cache
	if ( ! isset($_users))
	{
		static $_users = array();
	}

	// check it exists
	if (isset($_users[$user['id']]))
	{
		return $_users[$user['id']];
	}

	$user_name = empty($user['display_name']) ? $user['username'] : $user['display_name'];

	if (ci()->settings->enable_profiles)
	{
		$user_name = anchor('user/' . $user['id'], $user_name);
	}

	$_users[$user['id']] = $user_name;

	return $user_name;
}
예제 #16
0
 function load_cfg_settings()
 {
     $ci =& get_instance();
     $ci->load->model('setting_model', 'setting_m');
     $cfg = $ci->setting_m->core_settings();
     $ci->template->cfg = ci()->cfg = $cfg;
     $default_theme = FALSE;
     switch ($ci->cp_theme_type) {
         case 'cp_theme':
             $default_theme = $cfg->cp_theme;
             break;
         case 'frontend_theme':
             $default_theme = $cfg->frontend_theme;
             break;
         default:
             break;
     }
     $cfg->{'default_theme'} = $default_theme;
     $ci->config->load('theme_' . $cfg->default_theme, FALSE);
     $ci->load->helper('theme_' . $cfg->default_theme, FALSE);
     /*
     $_is_tablet = ( isset($ci->agent) && $ci->agent->is_tablet() ) ? TRUE : FALSE;
     $_is_mobile = ( isset($ci->agent) && $ci->agent->is_mobile() && !$_is_tablet ) ? TRUE : FALSE;
     
     if( (ENVIRONMENT=='development' || ENVIRONMENT=='testing') && $_is_mobile == FALSE) {
     	if(!$ci->input->is_ajax_request()) $ci->output->enable_profiler(TRUE);
     }
     */
 }
예제 #17
0
 private function _build_tree_select($params)
 {
     $params = array_merge(array('tree' => array(), 'parent_id' => 0, 'current_parent' => 0, 'current_id' => 0, 'level' => 0), $params);
     extract($params);
     if (!$tree) {
         if ($pages = ci()->db->select('pages.id, pages.parent_id, pages.title')->get('pages')->result()) {
             foreach ($pages as $page) {
                 $tree[$page->parent_id][] = $page;
             }
         }
     }
     if (!isset($tree[$parent_id])) {
         return;
     }
     $html = '';
     foreach ($tree[$parent_id] as $item) {
         if ($current_id == $item->id) {
             continue;
         }
         $html .= '<option value="' . $item->id . '"';
         $html .= $current_parent == $item->id ? ' selected="selected">' : '>';
         if ($level > 0) {
             for ($i = 0; $i < $level * 2; $i++) {
                 $html .= '&nbsp;';
             }
             $html .= '-&nbsp;';
         }
         $html .= $item->title . '</option>';
         $html .= $this->_build_tree_select(array('tree' => $tree, 'parent_id' => (int) $item->id, 'current_parent' => $current_parent, 'current_id' => $current_id, 'level' => $level + 1));
     }
     return $html;
 }
예제 #18
0
function cmpr()
{
    $s = array("", "123", "123q", "q123", "-456", "-456.7", "7.80", "9000000000", "9e10");
    $i = array(0, 123, -456, 7.8, 90000000000);
    for ($ji = 0; $ji < 5; ++$ji) {
        cs($i[$ji]);
    }
    for ($js = 0; $js < 9; ++$js) {
        ci($s[$js]);
    }
    for ($ji = 0; $ji < 5; ++$ji) {
        for ($js = 0; $js < 9; ++$js) {
            is($i[$ji], $s[$js]);
        }
    }
    print "----------\n0 == 'q123'\n";
    var_dump(0 == "q123");
    print "----------\n123 == '123q'\n";
    var_dump(123 == "123q");
    print "----------\n123 == '123.0'\n";
    var_dump(123 == "123.0");
    print "----------\n90000000000 == '9e10'\n";
    var_dump(9000000000 == "9e10");
    print "----------\n0 == '-456'\n";
    var_dump(0 == "-456");
}
 public function up()
 {
     $this->remove_access();
     $this->remove_menu();
     $this->add_menu(['url' => '/admin/utilities/orange-ei', 'text' => 'Export & Import Settings', 'parent_id' => 'Utilities']);
     $this->add_access(['name' => 'Access Export & Import Settings', 'description' => 'Export & Import Orange Package settings']);
     $this->add_access(['name' => 'Export Settings']);
     $this->add_access(['name' => 'Import Settings']);
     $this->add_access(['name' => 'Export Menubar']);
     $this->add_access(['name' => 'Import Menubar']);
     $this->add_access(['name' => 'Export Users']);
     $this->add_access(['name' => 'Import Users']);
     $this->add_access(['name' => 'Export Roles']);
     $this->add_access(['name' => 'Import Roles']);
     $this->add_access(['name' => 'Export Access']);
     $this->add_access(['name' => 'Import Access']);
     $this->add_access(['name' => 'Export Role/Access']);
     $this->add_access(['name' => 'Import Role/Access']);
     $this->add_access(['name' => 'Lock & Unlock Records']);
     $this->add_symlink('plugins/orange-export-import');
     /* add the is locked column if it's not there already */
     foreach ($this->tables as $t) {
         if (!in_array('is_locked', ci()->db->list_fields($t))) {
             $this->dbforge->add_column($t, $this->is_locked_field);
         }
     }
     return true;
 }
예제 #20
0
 /**
  * Get all folders and files within a folder
  *
  * @param   int     $parent The id of this folder
  * @return  array
  *
  **/
 public static function folder_contents($parent = 0, $type = null)
 {
     // they can also pass a url hash such as #foo/bar/some-other-folder-slug
     if (!is_numeric($parent)) {
         $segment = explode('/', trim($parent, '/#'));
         $result = ci()->file_folders_m->get_by('slug', array_pop($segment));
         $parent = $result ? $result->id : 0;
     }
     $folders = ci()->file_folders_m->where('parent_id', $parent)->where('hidden', 0)->order_by('sort')->get_all();
     // $files = ci()->file_m->where(array('folder_id' => $parent))
     //     ->order_by('sort')
     //     ->get_all();
     $files = ci()->file_m->where(array('folder_id' => $parent, 'type' => $type))->order_by('sort')->get_all();
     // let's be nice and add a date in that's formatted like the rest of the CMS
     if ($folders) {
         foreach ($folders as &$folder) {
             $folder->formatted_date = format_date($folder->date_added);
             $folder->file_count = ci()->file_m->count_by('folder_id', $folder->id);
         }
     }
     if ($files) {
         ci()->load->library('keywords/keywords');
         foreach ($files as &$file) {
             $file->keywords_hash = $file->keywords;
             $file->keywords = ci()->keywords->get_string($file->keywords);
             $file->formatted_date = format_date($file->date_added);
         }
     }
     return Files::result(true, null, null, array('folder' => $folders, 'file' => $files, 'parent_id' => $parent));
 }
예제 #21
0
 public function if_empty_group_id(&$field, $options = null)
 {
     $err_msg = 'Group id validation failure.';
     $this->set_message('if_empty_group_id', $err_msg);
     /* is group_id currently empty? */
     if (empty($field)) {
         /* Yes! Did the the current_group_id hidden get set? */
         $current_group_id = ci()->input->post('current_group_id');
         if ($current_group_id) {
             /* Yes! ok then let's decode that and use it */
             ci()->load->library('encrypt');
             $group_id = ci()->encrypt->decode($current_group_id);
             if (!is_numeric($group_id)) {
                 if (ci()->input->is_ajax_request()) {
                     /* die hard */
                     echo '{"err":true,"errors":"<p>' . $err_msg . '<\\/p>\\n","errors_array":["' . $err_msg . '"]}';
                     exit;
                 } else {
                     show_error($err_msg);
                 }
             }
             $field = $group_id;
         }
     }
     /*
     always true either it found it and set
     the field (by ref) or not in which case
     the next rule will run
     usually ifempty set it to the users new record group id
     */
     return TRUE;
 }
예제 #22
0
function showmsg($message, $url = '')
{
    $CI = ci();
    $CI->load->model('url_model');
    $CI->url_model->message($message);
    $CI->url_model->url($url);
    $CI->url_model->dump_and_exit();
}
 public function __construct()
 {
     parent::__construct();
     /* where to save images */
     $this->data_uri->public_folder('/images/content/');
     /* load the categories */
     $this->page->data(['category_options' => ci()->cms_category_model->catalog('id', 'name')]);
 }
 public function infoCliAction()
 {
     $this->output('<blue>Default: <yellow>' . ci()->config->item('cache_default'));
     $this->output('<blue>Backup: <yellow>' . ci()->config->item('cache_backup'));
     $this->output('<blue>Cache TTL: <yellow>' . ci()->config->item('cache_ttl'));
     $this->output('<yellow>CI Cache');
     var_dump($this->cache->cache_info());
 }
예제 #25
0
 public function __construct()
 {
     parent::__construct();
     ci()->validate->attach('must_be_1', function ($field_data, $field, $param, $validate_obj) {
         $validate_obj->set_message('must_be_1', 'The Trigger time format is not valid.');
         return (int) $field_data['trigger_valid'] == 1;
     });
 }
예제 #26
0
 public function down()
 {
     ci()->load->model('o_email_template_model');
     $this->remove_setting();
     ci()->o_email_template_model->remove('Forgot Password Email Template');
     $this->drop_table('addon_forgot_password');
     return true;
 }
예제 #27
0
 public function __construct(&$auth)
 {
     $this->CI = ci();
     $this->count_attempts = (bool) setting('Lockout.Count Attempts');
     $this->max_attempts = (int) setting('Lockout.Max Attempts');
     $this->attempt_expire = (int) setting('Lockout.Attempt Expire');
     $this->CI->load->model('a_lockout_model');
 }
예제 #28
0
 public static function close_form($extra = '')
 {
     $page_end = '<script src="//cdnjs.cloudflare.com/ajax/libs/parsley.js/2.1.2/parsley.min.js"></script>';
     $page_end .= '<link href="/plugins/o-capture/o-capture.css" rel="stylesheet">';
     $page_end .= '<script src="/plugins/o-capture/o-capture.js"></script>';
     ci()->page->data('page_end', $page_end);
     return $extra . '</form>';
 }
예제 #29
0
    public function __construct()
    {
        parent::__construct();
        $this->benchmark->mark('public_controller_start');
        //check for a redirect
        $this->load->model('redirects/redirect_m');
        $uri = trim(uri_string(), '/');
        if ($redirect = $this->redirect_m->get_from($uri)) {
            redirect($redirect->to);
        }
        Events::trigger('public_controller');
        // Check the frontend hasnt been disabled by an admin
        if (!$this->settings->frontend_enabled && (empty($this->current_user) or $this->current_user->group != 'admin')) {
            header('Retry-After: 600');
            $error = $this->settings->unavailable_message ? $this->settings->unavailable_message : lang('cms_fatal_error');
            show_error($error, 503);
        }
        // -- Navigation menu -----------------------------------
        $this->load->model('pages/page_m');
        // Load the current theme so we can set the assets right away
        ci()->theme = $this->theme_m->get();
        if (empty($this->theme->slug)) {
            show_error('This site has been set to use a theme that does not exist. If you are an administrator please ' . anchor('admin/themes', 'change the theme') . '.');
        }
        // Prepare Asset library
        $this->asset->set_theme($this->theme->slug);
        // Set the front-end theme directory
        $this->config->set_item('theme_asset_dir', dirname($this->theme->path) . '/');
        $this->config->set_item('theme_asset_url', BASE_URL . dirname($this->theme->web_path) . '/');
        // Set the theme view folder
        $this->template->set_theme($this->theme->slug)->append_metadata('
				<script type="text/javascript">
					var APPPATH_URI = "' . APPPATH_URI . '";
					var BASE_URI = "' . BASE_URI . '";
				</script>');
        // Is there a layout file for this module?
        if ($this->template->layout_exists($this->module . '.html')) {
            $this->template->set_layout($this->module . '.html');
        } elseif ($this->template->layout_exists('default.html')) {
            $this->template->set_layout('default.html');
        }
        // Make sure whatever page the user loads it by, its telling search robots the correct formatted URL
        $this->template->set_metadata('canonical', site_url($this->uri->uri_string()), 'link');
        // If there is a blog module, link to its RSS feed in the head
        if (module_exists('blog')) {
            $this->template->append_metadata('<link rel="alternate" type="application/rss+xml" title="' . $this->settings->site_name . '" href="' . site_url('blog/rss/all.rss') . '" />');
        }
        // Frontend data
        $this->load->library('variables/variables');
        // grab the theme options if there are any
        $this->theme->options = $this->pyrocache->model('theme_m', 'get_values_by', array(array('theme' => $this->theme->slug)));
        // Assign segments to the template the new way
        $this->template->variables = $this->variables->get_all();
        $this->template->settings = $this->settings->get_all();
        $this->template->server = $_SERVER;
        $this->template->theme = $this->theme;
        $this->benchmark->mark('public_controller_end');
    }
예제 #30
0
 public function get_user_allergies($member_id)
 {
     $ret = array();
     $res = $this->get(array('member_id' => ci()->user_session_data['member_id']));
     foreach ($res as $allergy) {
         $ret[] = $allergy['allergy'];
     }
     return $ret;
 }