本文整理汇总了PHP中trim_slashes函数的典型用法代码示例。如果您正苦于以下问题:PHP trim_slashes函数的具体用法?PHP trim_slashes怎么用?PHP trim_slashes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trim_slashes函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_trim_slashes
public function test_trim_slashes()
{
$strs = array('//Slashes//\\/' => 'Slashes//\\', '/var/www/html/' => 'var/www/html');
foreach ($strs as $str => $expect) {
$this->assertEquals($expect, trim_slashes($str));
}
}
开发者ID:saiful1105020,项目名称:Under-Construction-Bracathon-Project-,代码行数:7,代码来源:string_helper_test.php
示例2: catalogov
function catalogov()
{
parent::Controller();
$this->load->helper('string');
$protocolo = explode('/', $_SERVER['SERVER_PROTOCOL']);
$this->_direccion = $protocolo[0] . '://' . $_SERVER['SERVER_NAME'] . '/' . trim_slashes($this->config->item('base_url'));
}
开发者ID:enderochoa,项目名称:tortuga,代码行数:7,代码来源:catalogov.php
示例3: ver2
function ver2()
{
$parametros = func_get_args();
$this->_direccion = 'http://localhost/' . trim_slashes($this->config->item('base_url'));
if (count($parametros) > 0) {
$_arch_nombre = implode('-', $parametros);
$_fnombre = array_shift($parametros);
$this->load->library('dompdf/cidompdf');
$query = $this->db->query("SELECT proteo FROM formatos WHERE nombre='{$_fnombre}'");
if ($query->num_rows() > 0) {
$row = $query->row();
ob_start();
echo eval('?>' . preg_replace("/;*\\s*\\?>/", "; ?>", str_replace('<?=', '<?php echo ', $row->proteo)) . '<?php ');
$_html = ob_get_contents();
@ob_end_clean();
if (strlen($_html) > 0) {
$this->cidompdf->html2pdf($_html, $_arch_nombre);
} else {
echo 'Formato no definido';
}
} else {
echo 'Formato no existe';
}
} else {
echo 'Faltan parametros';
}
}
开发者ID:enderochoa,项目名称:tortuga,代码行数:27,代码来源:formatos.php
示例4: parse_n
/**
* Parse N Indicator
*/
function parse_n($qstring, $uristr, $dynamic = TRUE)
{
$uristr = FALSE;
if (preg_match("#^N(\\d+)|/N(\\d+)#", $qstring, $match)) {
$uristr = $this->EE->functions->remove_double_slashes(str_replace($match[0], '', $uristr));
$qstring = trim_slashes(str_replace($match[0], '', $qstring));
}
return array('uristr' => $uristr, 'qstring' => $qstring);
}
开发者ID:thomasvandoren,项目名称:teentix-site,代码行数:12,代码来源:segment_helper.php
示例5: Formatos
function Formatos()
{
parent::Controller();
$this->load->library("rapyd");
//$this->load->library("numletra");
$this->load->plugin('numletra');
$this->load->helper('string');
$protocolo = explode('/', $_SERVER['SERVER_PROTOCOL']);
$this->_direccion = $protocolo[0] . '://' . $_SERVER['SERVER_NAME'] . '/' . trim_slashes($this->config->item('base_url'));
}
开发者ID:codethics,项目名称:proteoerp,代码行数:10,代码来源:formatos.php
示例6: parse_year_month
/**
* Parse Year and Month
*/
function parse_year_month($qstring, $dynamic = TRUE)
{
// added (^|\/) to make sure this doesn't trigger with url titles like big_party_2006
if ($dynamic && preg_match("#(^|\\/)(\\d{4}/\\d{2})(\\/|\$)#", $qstring, $match)) {
$ex = explode('/', $match[2]);
$year = $ex[0];
$month = $ex[1];
$qstring = trim_slashes(str_replace($match[2], '', $qstring));
}
return array('year' => $year, 'month' => $month, 'qstring' => $qstring);
}
开发者ID:vigm,项目名称:advancedMD,代码行数:14,代码来源:segment_helper.php
示例7: _create_links
private function _create_links()
{
$CI =& get_instance();
$this->cur_page = trim_slashes($CI->uri->ruri_string());
$li = NULL;
foreach ($this->_data() as $line) {
if ($this->cur_display == TRUE) {
$this->cur_page == $line['slug'] ? $line['class'] = $line['class'] . ' ' . $this->cur_class : $line['class'];
}
$li .= $this->item_tag_open . anchor($line['slug'], $line['name'], array('class' => $line['class'])) . $this->item_tag_close;
}
$this->output = $this->full_tag_open . $li . $this->full_tag_close;
return $this->output;
}
开发者ID:avinaszh,项目名称:CRM,代码行数:14,代码来源:menu.php
示例8: reason_get_merged_fileset
/**
* Finds files in both the core and local directories and merges them into one listing
* @author Matt Ryan
* @date 2006-05-18
* @param string $dir_path
* @param string $section
* @return array $files
*/
function reason_get_merged_fileset($dir_path, $section = 'lib')
{
$areas = array('core', 'local');
$files = array();
foreach ($areas as $area) {
$directory = REASON_INC . $section . '/' . $area . '/' . trim_slashes($dir_path) . '/';
if (is_dir($directory)) {
$handle = opendir($directory);
while ($entry = readdir($handle)) {
if (is_file($directory . $entry)) {
$files[$entry] = $entry;
}
}
}
}
ksort($files);
return $files;
}
开发者ID:hunter2814,项目名称:reason_package,代码行数:26,代码来源:file_finders.php
示例9: get_canonical_url
/**
* @return string|NULL Canonical url, NULL if current page is canonical
*/
public function get_canonical_url()
{
foreach ($this->modules as $key => $module) {
$this->data[$key]['non_canonical'] = $module->get_noncanonical_request_keys();
$this->data[$key]['all'] = array_keys($module->get_cleanup_rules());
$this->data[$key]['canonical'] = array_diff($this->data[$key]['non_canonical'], $this->data[$key]['all']);
}
$canonicalized_url = NULL;
$non_cans_array = $this->get_non_canonical_url_params();
$curr_url = get_current_url();
$parsed_url = parse_url($curr_url);
$non_cans_array = array_flip($non_cans_array);
$canonicalized_url = $this->strip_non_canonical_url_params($non_cans_array, $parsed_url);
if ($canonicalized_url == get_current_url()) {
return;
} else {
return trim_slashes($canonicalized_url);
}
}
开发者ID:hunter2814,项目名称:reason_package,代码行数:22,代码来源:canonicalizer.php
示例10: save_settings
function save_settings()
{
$this->EE->load->helper('string');
unset($_POST['file'], $_POST['submit']);
if ($_POST['old_url'] && $_POST['new_url']) {
$original_url = trim_slashes(trim($_POST['old_url']));
$data = array('original_url' => xss_clean($original_url), 'new_url' => xss_clean($_POST['new_url']), 'detour_method' => xss_clean($_POST['new_detour_method']));
if ($original_url != $_POST['new_url']) {
$this->EE->db->insert('exp_detours', $data);
} else {
$this->EE->session->set_flashdata('message_failure', $this->EE->lang->line('original_equals_redirect'));
}
}
if (!empty($_POST['detour_delete'])) {
$delete_sql = "DELETE \n\t\t\tFROM exp_detours \n\t\t\tWHERE detour_id IN (" . implode(',', $_POST['detour_delete']) . ")";
$this->EE->db->query($delete_sql);
}
if (!empty($_POST['hits_delete'])) {
$delete_sql = "UPDATE \n\t\t\texp_detours SET hitcounter=0\n\t\t\tWHERE detour_id IN (" . implode(',', $_POST['hits_delete']) . ")";
$this->EE->db->query($delete_sql);
}
$this->EE->functions->redirect(BASE . AMP . 'C=addons_extensions' . AMP . 'M=extension_settings' . AMP . 'file=detour');
}
开发者ID:GDmac,项目名称:Detour,代码行数:23,代码来源:ext.detour.php
示例11: ver
function ver($numero = '00042617')
{
$this->load->helper('string');
$protocolo = explode('/', $_SERVER['SERVER_PROTOCOL']);
$_direccion = $protocolo[0] . '://' . $_SERVER['SERVER_NAME'] . '/' . trim_slashes($this->config->item('base_url'));
$mSQL_1 = $this->db->query("SELECT fecha,numero,cod_cli,nombre,impuesto,gtotal,stotal FROM pmay WHERE numero={$numero}");
$mSQL_2 = $this->db->query("SELECT codigo,descrip,cantidad,fraccion,precio,importe from itpmay WHERE numero={$numero}");
$row = $mSQL_1->row();
$data['fecha'] = $row->fecha;
$data['numero'] = $row->numero;
$data['cod_cli'] = $row->cod_cli;
$data['nombre'] = $row->nombre;
$data['stotal'] = $row->stotal;
$data['gtotal'] = $row->gtotal;
$data['impuesto'] = $row->impuesto;
$data['detalle'] = $mSQL_2->result();
$data['_direccion'] = $_direccion;
$this->load->plugin('html2pdf');
$html = $this->load->view('view_vpresupuesto', $data, true);
pdf_create($html, 'nombrepdf');
//echo $html;
//http://192.168.0.99/proteoerp/ventas/vpresupuesto/ver/00042617
//$this->load->view('view_vpresupuesto', $data);
}
开发者ID:codethics,项目名称:proteoerp,代码行数:24,代码来源:vpresupuesto.php
示例12: search_results
/** ----------------------------------------
/** Show search results
/** ----------------------------------------*/
function search_results()
{
// Fetch the search language file
$this->EE->lang->loadfile('search');
// Load Pagination Object
$this->EE->load->library('pagination');
$pagination = new Pagination_object(__CLASS__);
// Capture Pagination Template
$pagination->get_template();
// Check to see if we're using old style pagination
// TODO: Remove once old pagination is phased out
$old_pagination = strpos($this->EE->TMPL->template, LD . 'if paginate' . RD) !== FALSE ? TRUE : FALSE;
// If we are using old pagination, log it as deprecated
// TODO: Remove once old pagination is phased out
if ($old_pagination) {
$this->EE->load->library('logger');
$this->EE->logger->developer('Deprecated template tag {if paginate}. Old style pagination in the Search Module has been deprecated in 2.4 and will be removed soon. Switch to the new Channel style pagination.', TRUE);
}
// Check search ID number
// If the QSTR variable is less than 32 characters long we
// don't have a valid search ID number
if (strlen($this->EE->uri->query_string) < 32) {
return $this->EE->output->show_user_error('off', array(lang('search_no_result')), lang('search_result_heading'));
}
// Clear old search results
$this->EE->db->delete('search', array('site_id' => $this->EE->config->item('site_id'), 'search_date <' => $this->EE->localize->now - $this->cache_expire * 3600));
// Fetch ID number and page number
$pagination->offset = 0;
$qstring = $this->EE->uri->query_string;
// Parse page number
if (preg_match("#^P(\\d+)|/P(\\d+)#", $qstring, $match)) {
$pagination->offset = isset($match[2]) ? $match[2] : $match[1];
$search_id = trim_slashes(str_replace($match[0], '', $qstring));
} else {
$pagination->offset = 0;
$search_id = $qstring;
}
// If there is a slash in the search ID we'll kill everything after it.
$search_id = trim($search_id);
$search_id = preg_replace("#/.+#", "", $search_id);
// Fetch the cached search query
$query = $this->EE->db->get_where('search', array('search_id' => $search_id));
if ($query->num_rows() == 0 or $query->row('total_results') == 0) {
return $this->EE->output->show_user_error('off', array(lang('search_no_result')), lang('search_result_heading'));
}
$fields = $query->row('custom_fields') == '' ? array() : unserialize(stripslashes($query->row('custom_fields')));
$sql = unserialize(stripslashes($query->row('query')));
$sql = str_replace('MDBMPREFIX', 'exp_', $sql);
$pagination->per_page = (int) $query->row('per_page');
$res_page = $query->row('result_page');
// Run the search query
$query = $this->EE->db->query(preg_replace("/SELECT(.*?)\\s+FROM\\s+/is", 'SELECT COUNT(*) AS count FROM ', $sql));
if ($query->row('count') == 0) {
return $this->EE->output->show_user_error('off', array(lang('search_no_result')), lang('search_result_heading'));
}
// Calculate total number of pages and add total rows
$pagination->current_page = $pagination->offset / $pagination->per_page + 1;
$pagination->total_rows = $query->row('count');
// Figure out total number of pages for old style pagination
// TODO: Remove once old pagination is phased out
if ($old_pagination) {
$total_pages = intval($pagination->total_rows / $pagination->per_page);
if ($pagination->total_rows % $pagination->per_page) {
$total_pages++;
}
$page_count = lang('page') . ' ' . $pagination->current_page . ' ' . lang('of') . ' ' . $total_pages;
$pager = '';
if ($pagination->total_rows > $pagination->per_page) {
$this->EE->load->library('pagination');
$config = array('base_url' => $this->EE->functions->create_url($res_page . '/' . $search_id, 0, 0), 'prefix' => 'P', 'total_rows' => $pagination->total_rows, 'per_page' => $pagination->per_page, 'cur_page' => $pagination->offset, 'first_link' => lang('pag_first_link'), 'last_link' => lang('pag_last_link'), 'uri_segment' => 0);
$this->EE->pagination->initialize($config);
$pager = $this->EE->pagination->create_links();
}
}
// Build pagination if enabled
if ($pagination->paginate === TRUE) {
$pagination->build($pagination->total_rows);
}
// If we're paginating, old or new, limit the query and do it again
if ($pagination->paginate === TRUE or $old_pagination) {
$sql .= " LIMIT " . $pagination->offset . ", " . $pagination->per_page;
} else {
if ($pagination->per_page > 0) {
$sql .= " LIMIT 0, " . $pagination->per_page;
} else {
$sql .= " LIMIT 0, 100";
}
}
$query = $this->EE->db->query($sql);
$output = '';
if (!class_exists('Channel')) {
require PATH_MOD . 'channel/mod.channel.php';
}
unset($this->EE->TMPL->var_single['auto_path']);
unset($this->EE->TMPL->var_single['excerpt']);
unset($this->EE->TMPL->var_single['id_auto_path']);
unset($this->EE->TMPL->var_single['full_text']);
//.........这里部分代码省略.........
开发者ID:thomasvandoren,项目名称:teentix-site,代码行数:101,代码来源:mod.search.php
示例13: cms_widgets
/**
* @author go frendi
*
* @param slug
* @param widget_name
*
* @return mixed
* @desc return widgets
*/
public function cms_widgets($slug = null, $widget_name = null)
{
// get user_name, user_id, etc
$user_name = $this->cms_user_name();
$user_id = $this->cms_user_id();
$user_id = $user_id == '' ? 0 : $user_id;
$not_login = !$user_name ? '(1=1)' : '(1=2)';
$login = $user_name ? '(1=1)' : '(1=2)';
$super_user = $this->cms_user_is_super_admin() ? '(1=1)' : '(1=2)';
/*
$slug_where = isset($slug)?
"(((slug LIKE '".addslashes($slug)."') OR (slug LIKE '%".addslashes($slug)."%')) AND active=1)" :
"1=1";
$widget_name_where = isset($widget_name)? "widget_name LIKE '".addslashes($widget_name)."'" : "1=1";
*/
if (!self::$__cms_model_properties['is_widget_cached']) {
$SQL = 'SELECT
widget_id, widget_name, is_static, title,
description, url, slug, static_content, active
FROM ' . cms_table_name('main_widget') . " AS w WHERE\n (\n (authorization_id = 1) OR\n (authorization_id = 2 AND {$not_login}) OR\n (authorization_id = 3 AND {$login}) OR\n (\n (authorization_id = 4 AND {$login}) AND\n (\n {$super_user} OR\n (SELECT COUNT(*) FROM " . cms_table_name('main_group_widget') . ' AS gw
WHERE
gw.widget_id=w.widget_id AND
gw.group_id IN
(SELECT group_id FROM ' . cms_table_name('main_group_user') . ' WHERE user_id = ' . addslashes($user_id) . ")\n )>0\n )\n ) OR\n (\n (authorization_id = 5 AND {$login}) AND\n (\n (SELECT COUNT(*) FROM " . cms_table_name('main_group_widget') . ' AS gw
WHERE
gw.widget_id=w.widget_id AND
gw.group_id IN
(SELECT group_id FROM ' . cms_table_name('main_group_user') . ' WHERE user_id = ' . addslashes($user_id) . ')
)>0
)
)
) ORDER BY ' . $this->db->protect_identifiers('index');
$query = $this->db->query($SQL);
self::$__cms_model_properties['widget'] = $query->result();
self::$__cms_model_properties['is_widget_cached'] = true;
}
$result = array();
foreach (self::$__cms_model_properties['widget'] as $row) {
if (isset($slug) && $slug != '') {
if ($row->active != 1 || stripos($row->slug === null ? '' : $row->slug, $slug) === false) {
continue;
}
}
if (isset($widget_name)) {
if (strtolower($row->widget_name) != strtolower($widget_name)) {
continue;
}
}
// generate widget content
$content = '';
if ($row->is_static == 1) {
$content = $row->static_content;
if (substr($row->widget_name, 0, 8) != 'section_' && $content != '' && $this->cms_editing_mode() && $this->cms_allow_navigate('main_widget_management')) {
$content = '<div class="row" style="padding-top:10px; padding-bottom:10px;"><a class="btn btn-primary pull-right" href="{{ SITE_URL }}main/widget/edit/' . $row->widget_id . '">' . '<i class="glyphicon glyphicon-pencil"></i>' . '</a></div>' . $content;
}
} else {
// url
$url = $row->url;
// content
if ($slug) {
$content .= '<div id="__cms_widget_' . $row->widget_id . '">';
} else {
$content .= '<span id="__cms_widget_' . $row->widget_id . '" style="padding:0px; margin:0px;">';
}
if (strpos(strtoupper($url), 'HTTP://') !== false || strpos(strtoupper($url), 'HTTPS://') !== false) {
$response = null;
// use CURL
if (in_array('curl', get_loaded_extensions())) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, '');
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = @curl_exec($ch);
curl_close($ch);
}
// use file get content
if (!isset($response)) {
$response = @file_get_contents($url);
}
// add the content
if (isset($response)) {
$response = preg_replace('#(href|src|action)="([^:"]*)(?:")#', '$1="' . $url . '/$2"', $response);
$content .= $response;
}
} else {
$url = trim_slashes($url);
$url_segment = explode('/', $url);
$module_path = $url_segment[0];
$response = '';
//.........这里部分代码省略.........
开发者ID:engirocha,项目名称:No-CMS,代码行数:101,代码来源:CMS_Model.php
示例14: force_ssl
/**
* Force the request to be redirected to HTTPS, or optionally show 404.
* A strong security policy does not allow for redirection.
*/
protected function force_ssl()
{
// Force SSL if available
if (USE_SSL !== 0 && $this->protocol == 'http') {
// Allow redirect to the HTTPS page
if (REDIRECT_TO_HTTPS !== 0) {
// Load string helper for trim_slashes function
$this->load->helper('string');
// 301 Redirect to the secure page
header("Location: " . secure_site_url(trim_slashes($this->uri->uri_string())), TRUE, 301);
} else {
show_404();
}
exit;
}
}
开发者ID:Osub,项目名称:Community-Auth-For-CodeIgniter-3,代码行数:20,代码来源:MY_Controller.php
示例15: cms_widgets
/**
* @author goFrendiAsgard
* @param slug
* @param widget_name
* @return mixed
* @desc return widgets
*/
public function cms_widgets($slug = NULL, $widget_name = NULL)
{
$user_name = $this->cms_user_name();
$user_id = $this->cms_user_id();
$user_id = !isset($user_id) || is_null($user_id) ? 0 : $user_id;
$not_login = !$user_name ? "TRUE" : "FALSE";
$login = $user_name ? "TRUE" : "FALSE";
$super_user = $user_id == 1 ? "TRUE" : "FALSE";
$slug_where = isset($slug) ? "(((slug LIKE '" . addslashes($slug) . "') OR (slug LIKE '%" . addslashes($slug) . "%')) AND active=1)" : "1=1";
$widget_name_where = isset($widget_name) ? "widget_name LIKE '" . addslashes($widget_name) . "'" : "1=1";
$SQL = "SELECT\n widget_id, widget_name, is_static, title,\n description, url, slug, static_content\n FROM " . cms_table_name('main_widget') . " AS w WHERE\n (\n (authorization_id = 1) OR\n (authorization_id = 2 AND {$not_login}) OR\n (authorization_id = 3 AND {$login}) OR\n (\n (authorization_id = 4 AND {$login}) AND\n (\n (SELECT COUNT(*) FROM " . cms_table_name('main_group_user') . " AS gu WHERE gu.group_id=1 AND gu.user_id ='" . addslashes($user_id) . "')>0\n OR {$super_user} OR\n (SELECT COUNT(*) FROM " . cms_table_name('main_group_widget') . " AS gw\n WHERE\n gw.widget_id=w.widget_id AND\n gw.group_id IN\n (SELECT group_id FROM " . cms_table_name('main_group_user') . " WHERE user_id = " . addslashes($user_id) . ")\n )>0\n )\n )\n ) AND {$slug_where} AND {$widget_name_where} ORDER BY " . $this->db->protect_identifiers('index');
$query = $this->db->query($SQL);
$result = array();
foreach ($query->result() as $row) {
// generate widget content
$content = '';
if ($row->is_static == 1) {
$content = $row->static_content;
} else {
// url
$url = $row->url;
// content
if ($slug) {
$content .= '<div id="_cms_widget_' . $row->widget_id . '">';
} else {
$content .= '<span id="_cms_widget_' . $row->widget_id . '">';
}
if (strpos(strtoupper($url), 'HTTP://') !== FALSE || strpos(strtoupper($url), 'HTTPS://') !== FALSE) {
$response = NULL;
// use CURL
if (in_array('curl', get_loaded_extensions())) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = @curl_exec($ch);
curl_close($ch);
}
// use file get content
if (!isset($response)) {
$response = @file_get_contents($url);
}
// add the content
if (isset($response)) {
$response = preg_replace('#(href|src|action)="([^:"]*)(?:")#', '$1="' . $url . '/$2"', $response);
$content .= $response;
}
} else {
// TODO: something wrong with this
$url = trim_slashes($url);
$url_partial = explode('/', $url);
$this->cms_ci_session('cms_dynamic_widget', TRUE);
$response = @Modules::run($url);
if (strlen($response) == 0) {
$response = @Modules::run($url . '/index');
}
$content .= $response;
$this->cms_unset_ci_session('cms_dynamic_widget');
}
if ($slug) {
$content .= '</div>';
} else {
$content .= '</span>';
}
}
// make widget based on slug
$slugs = explode(',', $row->slug);
foreach ($slugs as $slug) {
$slug = trim($slug);
if (!isset($result[$slug])) {
$result[$slug] = array();
}
$result[$slug][] = array("widget_id" => $row->widget_id, "widget_name" => $row->widget_name, "title" => $this->cms_lang($row->title), "description" => $row->description, "content" => $this->cms_parse_keyword($content));
}
}
return $result;
}
开发者ID:heruprambadi,项目名称:simpeg,代码行数:84,代码来源:MY_Model.php
示例16: process_image
public function process_image()
{
$raw_str = trim_slashes($this->input->post("image"));
$raw_arr = explode("/", $raw_str);
$filename = end($raw_arr);
return $filename;
}
开发者ID:nguyenanhtu,项目名称:fit_website,代码行数:7,代码来源:articles_admin.php
示例17: set_cache_dir
/**
* @param dir string absolute path to cache directory (must be writable by web server, include trailing slash)
*/
public function set_cache_dir($dir)
{
$this->dir = '/' . trim_slashes($dir) . '/';
}
开发者ID:hunter2814,项目名称:reason_package,代码行数:7,代码来源:cache.php
示例18: build
//.........这里部分代码省略.........
// Check to see if we can actually deal with cat_limit. Has
// to have dynamic != 'no' and channel set with a category
// in the uri_string somewhere
$cat_limit = FALSE;
if ((in_array($this->EE->config->item("reserved_category_word"), explode("/", $this->EE->uri->uri_string)) or preg_match("#(^|\\/)C(\\d+)#", $this->EE->uri->uri_string, $match)) and $this->EE->TMPL->fetch_param('dynamic') != 'no' and $this->EE->TMPL->fetch_param('channel')) {
$cat_limit = TRUE;
}
if ($cat_limit and is_numeric($this->EE->TMPL->fetch_param('cat_limit'))) {
$this->per_page = $this->EE->TMPL->fetch_param('cat_limit');
} else {
$this->per_page = !is_numeric($this->EE->TMPL->fetch_param('limit')) ? '100' : $this->EE->TMPL->fetch_param('limit');
}
}
$this->offset = ($this->offset == '' or $this->per_page > 1 and $this->offset == 1) ? 0 : $this->offset;
// If we're far beyond where we should be, reset us back to
// the first page
if ($this->offset > $this->total_rows) {
$this->offset = 0;
}
$this->current_page = floor($this->offset / $this->per_page + 1);
$this->total_pages = intval(floor($this->total_rows / $this->per_page));
} else {
// Field pagination - base values
// If we're doing field pagination and there's not even one
// entry, then clear out the sql and get out of here
if ($count == 0) {
$main_query = '';
return;
}
$m_fields = array();
foreach ($this->multi_fields as $val) {
foreach ($this->cfields as $site_id => $cfields) {
if (isset($cfields[$val])) {
if (isset($row['field_id_' . $cfields[$val]]) and $row['field_id_' . $cfields[$val]] != '') {
$m_fields[] = $val;
}
}
}
}
$this->per_page = 1;
$this->total_rows = count($m_fields);
$this->total_pages = $this->total_rows;
if ($this->total_pages == 0) {
$this->total_pages = 1;
}
$this->offset = $this->offset == '' ? 0 : $this->offset;
if ($this->offset > $this->total_rows) {
$this->offset = 0;
}
$this->current_page = floor($this->offset / $this->per_page + 1);
if (isset($m_fields[$this->offset])) {
$this->EE->TMPL->tagdata = preg_replace("/" . LD . "multi_field\\=[\"'].+?[\"']" . RD . "/s", LD . $m_fields[$this->offset] . RD, $this->EE->TMPL->tagdata);
$this->EE->TMPL->var_single[$m_fields[$this->offset]] = $m_fields[$this->offset];
}
}
// Create the pagination
if ($this->total_rows > 0 && $this->per_page > 0) {
if ($this->total_rows % $this->per_page) {
$this->total_pages++;
}
}
// Last check to make sure we actually need to paginate
if ($this->total_rows > $this->per_page) {
if (strpos($this->basepath, SELF) === FALSE && $this->EE->config->item('site_index') != '') {
$this->basepath .= SELF;
}
// Check to see if a paginate_base was provided
if ($this->EE->TMPL->fetch_param('paginate_base')) {
$this->EE->load->helper('string');
$this->basepath = $this->EE->functions->create_url(trim_slashes($this->EE->TMPL->fetch_param('paginate_base')));
}
$config['first_url'] = rtrim($this->basepath, '/');
$config['base_url'] = $this->basepath;
$config['prefix'] = 'P';
$config['total_rows'] = $this->total_rows;
$config['per_page'] = $this->per_page;
// cur_page uses the offset because P45 (or similar) is a page
$config['cur_page'] = $this->offset;
$config['first_link'] = lang('pag_first_link');
$config['last_link'] = lang('pag_last_link');
$config['uri_segment'] = 0;
// Allows $config['cur_page'] to override
$this->EE->pagination->initialize($config);
$this->page_links = $this->EE->pagination->create_links();
$this->EE->pagination->initialize($config);
// Re-initialize to reset config
$this->page_array = $this->EE->pagination->create_link_array();
// If a page_next should exist, create it
if ($this->total_pages * $this->per_page - $this->per_page > $this->offset) {
$this->page_next = reduce_double_slashes($this->basepath . '/P' . ($this->offset + $this->per_page));
}
// If a page_previous should exist, create it
if ($this->offset - $this->per_page >= 0) {
$this->page_previous = reduce_double_slashes($this->basepath . '/P' . ($this->offset - $this->per_page));
}
} else {
$this->offset = 0;
}
}
}
开发者ID:thomasvandoren,项目名称:teentix-site,代码行数:101,代码来源:EE_Pagination.php
示例19: Stats
/**
* Constructor
*/
public function Stats()
{
$this->EE =& get_instance();
$this->EE->stats->load_stats();
// Limit stats by channel
// You can limit the stats by any combination of channels
if ($channel_name = $this->EE->TMPL->fetch_param('channel')) {
$sql = "SELECT\ttotal_entries, \n\t\t\t\t\t\t\ttotal_comments,\n\t\t\t\t\t\t\tlast_entry_date,\n\t\t\t\t\t\t\tlast_comment_date\n\t\t\t\t\tFROM exp_channels \n\t\t\t\t\tWHERE site_id IN ('" . implode("','", $this->EE->TMPL->site_ids) . "') ";
$sql .= $this->EE->functions->sql_andor_string($channel_name, 'exp_channels.channel_name');
$cache_sql = md5($sql);
if (!isset($this->EE->stats->stats_cache[$cache_sql])) {
$query = $this->EE->db->query($sql);
$sdata = array('total_entries' => 0, 'total_comments' => 0, 'last_entry_date' => 0, 'last_comment_date' => 0);
if ($query->num_rows() > 0) {
foreach ($query->result_array() as $row) {
foreach ($sdata as $key => $val) {
if (substr($key, 0, 5) == 'last_') {
if ($row[$key] > $val) {
$sdata[$key] = $row[$key];
}
} else {
$sdata[$key] = $sdata[$key] + $row[$key];
}
}
}
foreach ($sdata as $key => $val) {
$this->EE->stats->set_statdata($key, $val);
$this->EE->stats->stats_cache[$cache_sql][$key] = $val;
}
}
} else {
foreach ($this->EE->stats->stats_cache[$cache_sql] as $key => $val) {
$this->EE->stats->set_statdata($key, $val);
}
}
}
// Parse stat fields
$fields = array('total_members', 'total_entries', 'total_forum_topics', 'total_forum_replies', 'total_forum_posts', 'total_comments', 'most_visitors', 'total_logged_in', 'total_guests', 'total_anon');
$cond = array();
foreach ($fields as $field) {
if (isset($this->EE->TMPL->var_single[$field])) {
$cond[$field] = $this->EE->stats->statdata($field);
$this->EE->TMPL->tagdata = $this->EE->TMPL->swap_var_single($field, $this->EE->stats->statdata($field), $this->EE->TMPL->tagdata);
}
}
if (count($cond) > 0) {
$this->EE->TMPL->tagdata = $this->EE->functions->prep_conditionals($this->EE->TMPL->tagdata, $cond);
}
// Parse dates
$dates = array('last_entry_date', 'last_forum_post_date', 'last_comment_date', 'last_visitor_date', 'most_visitor_date');
foreach ($this->EE->TMPL->var_single as $key => $val) {
foreach ($dates as $date) {
if (strncmp($key, $date, strlen($date)) == 0) {
$this->EE->TMPL->tagdata = $this->EE->TMPL->swap_var_single($key, (!$this->EE->stats->statdata($date) or $this->EE->stats->statdata($date) == 0) ? '--' : $this->EE->localize->decode_date($val, $this->EE->stats->statdata($date)), $this->EE->TMPL->tagdata);
}
}
}
// Online user list
$names = '';
if ($this->EE->stats->statdata('current_names')) {
$chunk = $this->EE->TMPL->fetch_data_between_var_pairs($this->EE->TMPL->tagdata, 'member_names');
$backspace = '';
if (!preg_match("/" . LD . "member_names.*?backspace=[\"|'](.+?)[\"|']/", $this->EE->TMPL->tagdata, $match)) {
if (preg_match("/" . LD . "name.*?backspace=[\"|'](.+?)[\"|']/", $this->EE->TMPL->tagdata, $match)) {
$backspace = $match['1'];
}
} else {
$backspace = $match['1'];
}
// Load the string helper
$this->EE->load->helper('string');
$member_path = preg_match("/" . LD . "member_path=(.+?)" . RD . "/", $this->EE->TMPL->tagdata, $match) ? $match['1'] : '';
$member_path = str_replace("\"", "", $member_path);
$member_path = str_replace("'", "", $member_path);
$member_path = trim_slashes($member_path);
foreach ($this->EE->stats->statdata('current_names') as $k => $v) {
$temp = $chunk;
if ($v['1'] == 'y') {
if ($this->EE->session->userdata('group_id') == 1) {
$temp = preg_replace("/" . LD . "name.*?" . RD . "/", $v['0'] . '*', $temp);
} elseif ($this->EE->session->userdata('member_id') == $k) {
$temp = preg_replace("/" . LD . "name.*?" . RD . "/", $v['0'] . '*', $temp);
} else {
continue;
}
} else {
$temp = preg_replace("/" . LD . "name.*?" . RD . "/", $v['0'], $temp);
}
$path = $this->EE->functions->create_url($memb
|
请发表评论