本文整理汇总了PHP中trim_slashes函数的典型用法代码示例。如果您正苦于以下问题:PHP trim_slashes函数的具体用法?PHP trim_slashes怎么用?PHP trim_slashes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trim_slashes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
}
示例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'));
}
示例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';
}
}
示例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);
}
示例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'));
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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');
}
示例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);
}
示例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']);
//.........这里部分代码省略.........
示例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 = '';
//.........这里部分代码省略.........
示例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;
}
}
示例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;
}