public function __construct() { parent::__construct(); $this->_configs['base_url'] = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); $this->_configs['request_url'] = $_SERVER['REQUEST_URI'] != $this->_configs['base_url'] ? substr($_SERVER['REQUEST_URI'], strlen($this->_configs['base_url'])) : 'index.html'; $this->_configs['extension_url'] = extension($this->_configs['request_url'], $this->_configs['request_url']); $this->_configs['ajax_header'] = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'; $ext = extension($url = !empty($_GET['request_url']) ? $_GET['request_url'] : $this->_configs['request_url'], $url); $this->_configs['segments_url'] = explode('/', rtrim(substr($url, 0, -strlen($ext)), '.')); if ($this->_configs['segments_url'][0] == 'admin') { $this->_configs['admin_url'] = TRUE; } if (empty($this->_configs['admin_url']) && $this->_configs['segments_url'][0] == 'ajax' || !empty($this->_configs['admin_url']) && isset($this->_configs['segments_url'][1]) && $this->_configs['segments_url'][1] == 'ajax') { $this->_configs['ajax_url'] = TRUE; } if (is_null($configs = NeoFrag::loader()->db->select('site, lang, name, value, type')->from('nf_settings')->get())) { exit('Database is empty'); } foreach ($configs as $setting) { if ($setting['type'] == 'array') { $value = unserialize(utf8_html_entity_decode($setting['value'])); } else { if ($setting['type'] == 'list') { $value = explode('|', $setting['value']); } else { if ($setting['type'] == 'bool') { $value = (bool) $setting['value']; } else { if ($setting['type'] == 'int') { $value = (int) $setting['value']; } else { $value = $setting['value']; } } } } $this->_settings[$setting['site']][$setting['lang']][$setting['name']] = $value; if (empty($site) && $setting['name'] == 'nf_domains' && in_string($_SERVER['HTTP_HOST'], $setting['value'])) { $site = $value; } } $this->update(''); $this->update('default'); if (!empty($site)) { $this->update('default'); } }
function str_shortener($string, $max_length, $end = '…') { if (strlen($string) <= $max_length) { return $string; } else { if (utf8_html_entity_decode($end) === $end) { $max_length -= strlen($end); } for ($i = $max_length; $i > 1; $i--) { if (in_array(substr($string, $i, 1), str_split(' .,;:!?-_"')) && in_array(substr(url_title($string), $i - 1, 1), array_merge(range('a', 'z'), range('A', 'Z'), range(0, 9)))) { return substr($string, 0, $i) . $end; } } return substr($string, 0, $max_length) . $end; } }
public function get_sessions($user_id = NULL) { $sessions = $this->db->from('nf_sessions')->where('user_id', $user_id ?: $this('user_id'))->order_by('last_activity DESC')->get(); //On ajoute des infos de session (time_zone ....) foreach ($sessions as &$session) { $user_data = unserialize(utf8_html_entity_decode($session['user_data'])); unset($session['user_data']); if (isset($user_data['session'])) { foreach ($user_data['session'] as $key => $value) { $session[$key] = $value; } } } return $sessions; }
/** * utf8_html_entity_decode */ function utf8_html_entity_decode($content) { if (!$this->_set_include_path) { set_include_path(YF_PATH . 'libs/yf_utf8_funcs/' . PATH_SEPARATOR . get_include_path()); } $this->_set_include_path = true; include_once 'utf8_html_entity_decode.php'; return utf8_html_entity_decode($content, true); }
private function _check_cookie($cookie_data, &$last_activity) { $session = $this->db->select('host_name', 'ip_address', 'UNIX_TIMESTAMP(last_activity) as last_activity', 'user_data', 'user_id')->from('nf_sessions')->where('session_id', $cookie_data)->row(); if (!empty($session)) { $last_activity = $session['last_activity']; if ($session['ip_address'] != $this->_ip_address && levenshtein($session['host_name'], $this->_host_name) > levenshtein($session['ip_address'], $this->_ip_address) + 0.5 * strlen($session['host_name'])) { return FALSE; } if (!is_null($session['user_id'])) { $this->_user_id = (int) $session['user_id']; } if ($session['user_data']) { $this->_user_data = array_merge(unserialize(utf8_html_entity_decode($session['user_data'])), $this->_user_data); } return TRUE; } return FALSE; }
public function __construct() { parent::__construct(); if (method_exists($this->load->theme, 'load')) { $this->load->theme->load(); } $this->data = $this->load->data; $this->data['page_title'] = $this->config->nf_name . ' :: ' . $this->config->nf_description; $this->data['lang'] = $this->config->lang; if (isset($this->load->module->table) && $this->load->module->table->is_ajax()) { $output = $this->load->module->table->get_output(ob_get_clean(), $this->data); } else { if ($this->config->ajax_url) { $output = $this->load->module->get_output(); } else { if (NeoFrag::live_editor()) { $this->load->css('neofrag.live-editor'); } $this->data['module_actions'] = $this->load->module->get_actions(); $this->data = array_merge($this->data, $this->load->module->load->data); $this->template->parse_data($this->data, $this->load->module->load); $this->data['module'] = ob_get_clean() . $this->template->parse($this->load->module->get_output(), $this->data, $this->load->module->load); if ($this->config->admin_url) { $this->data['module'] = '<div class="module module-admin module-' . $this->load->module->name . '">' . $this->data['module'] . $this->profiler->output() . '</div>'; } if ($this->config->segments_url[0] != 'index' && !empty($this->data['module_title'])) { $this->data['page_title'] = $this->data['module_title'] . ' :: ' . $this->config->nf_name; } if (!empty($this->load->module->icon) || !empty($this->data['module_icon'])) { $this->data['module_title'] = icon(!empty($this->data['module_icon']) ? $this->data['module_icon'] : $this->load->module->icon) . ' ' . $this->data['module_title']; } $this->data['body'] = $this->load->theme->load->view('body', $this->data); if (isset($this->load->css)) { $this->data['css'] = array(); foreach ($this->load->css as $css) { $this->data['css'][] = '<link rel="stylesheet" href="' . path($css[0] . '.css', 'css', $css[2]->paths['assets']) . '" type="text/css" media="' . $css[1] . '" />' . "\r\n"; } $this->data['css'] = implode(array_unique($this->data['css'])); } if (isset($this->load->js)) { $this->data['js'] = array(); foreach ($this->load->js as $js) { $this->data['js'][] = '<script type="text/javascript" src="' . path($js[0] . '.js', 'js', $js[1]->paths['assets']) . '"></script>' . "\r\n"; } $this->data['js'] = implode(array_unique($this->data['js'])); } if (isset($this->load->js_load)) { $this->data['js_load'] = ''; foreach (array_unique($this->load->js_load) as $js) { $this->data['js_load'] .= $js; } } $output = $this->load->theme->load->view('default', $this->data); } } if ($this->config->extension_url == 'json') { header('Content-Type: application/json; charset=UTF-8'); } else { if ($this->config->extension_url == 'xml') { header('Content-Type: application/xml; charset=UTF-8'); $output = '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . $output; } else { if ($this->config->extension_url == 'txt') { header('Content-Type: text/plain; charset=UTF-8'); $output = utf8_html_entity_decode($output); } else { header('Content-Type: text/html; charset=UTF-8'); } } } echo $output; }