本文整理汇总了PHP中sanitize_search_terms函数的典型用法代码示例。如果您正苦于以下问题:PHP sanitize_search_terms函数的具体用法?PHP sanitize_search_terms怎么用?PHP sanitize_search_terms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sanitize_search_terms函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Index function
*
* @access public
* @return void
*/
function index($message = '')
{
$this->load->helper('html');
$this->load->helper('search');
$vars['cp_page_title'] = $this->lang->line('search_results');
$this->cp->set_variable('cp_page_title', $vars['cp_page_title']);
// Saved search
if ($search = $this->input->get('saved')) {
$search = base64_decode(rawurldecode($search));
} else {
$search = $this->input->get_post('cp_search_keywords', TRUE);
}
if (!$this->cp_search->_check_index()) {
// Save the search
$search = rawurlencode(base64_encode($search));
if ($this->input->get('ajax')) {
// Force a js redirect
$url = str_replace('&', '&', BASE) . '&C=search&M=build_index&saved=' . $search;
echo '<script type="text/javascript">window.location="' . $url . '";</script>';
exit;
}
// Degrade 'nicely'
$this->functions->redirect(BASE . AMP . 'C=search' . AMP . 'M=build_index' . AMP . 'saved=' . $search);
}
$vars['keywords'] = sanitize_search_terms($search);
$vars['can_rebuild'] = $this->cp->allowed_group('can_access_utilities');
$vars['search_data'] = $this->cp_search->generate_results($search);
$vars['num_rows'] = count($vars['search_data']);
if ($this->input->get('ajax')) {
echo $this->load->view('search/sidebar', $vars, TRUE);
exit;
}
$this->javascript->compile();
$this->load->view('search/results', $vars);
}
示例2: index
/**
* Index function
*
* @access public
* @return void
*/
function index()
{
ee()->load->helper('html');
ee()->load->helper('search');
$vars['cp_page_title'] = lang('search_results');
ee()->view->cp_page_title = $vars['cp_page_title'];
// Saved search
if ($search = ee()->input->get('saved')) {
$search = base64_decode(rawurldecode($search));
} else {
$search = ee()->input->get_post('cp_search_keywords', TRUE);
}
if (!ee()->cp_search->_check_index()) {
// Save the search
$search = rawurlencode(base64_encode($search));
if (AJAX_REQUEST) {
// Force a js redirect
$url = cp_url('search/build_index', array('saved' => $search));
$url = str_replace('&', '&', $url);
echo '<script type="text/javascript">window.location="' . $url . '";</script>';
exit;
}
// Degrade 'nicely'
ee()->functions->redirect(cp_url('search/build_index', array('saved' => $search)));
}
$vars['keywords'] = sanitize_search_terms($search);
$vars['can_rebuild'] = ee()->cp->allowed_group('can_access_utilities');
$vars['search_data'] = ee()->cp_search->generate_results($search);
$vars['num_rows'] = count($vars['search_data']);
if (AJAX_REQUEST) {
echo ee()->load->view('search/sidebar', $vars, TRUE);
exit;
}
ee()->cp->render('search/results', $vars);
}
示例3: add_items
//.........这里部分代码省略.........
$vars['status_select_options']['closed'] = lang('closed');
}
// Date range pull-down menu
$vars['date_selected'] = $date_range;
$vars['date_select_options'][''] = lang('date_range');
$vars['date_select_options']['1'] = lang('today');
$vars['date_select_options']['7'] = lang('past_week');
$vars['date_select_options']['31'] = lang('past_month');
$vars['date_select_options']['182'] = lang('past_six_months');
$vars['date_select_options']['365'] = lang('past_year');
$vars['date_select_options']['custom_date'] = lang('any_date');
// Display order pull-down menu
$vars['order_selected'] = $order;
$vars['order_select_options'][''] = lang('order');
$vars['order_select_options']['asc'] = lang('ascending');
$vars['order_select_options']['desc'] = lang('descending');
$vars['order_select_options']['alpha'] = lang('alpha');
// Results per page pull-down menu
if (!($perpage = ee()->input->get_post('perpage'))) {
$perpage = ee()->input->cookie('perpage');
}
if ($perpage == '') {
$perpage = 50;
}
ee()->functions->set_cookie('perpage', $perpage, 60 * 60 * 24 * 182);
$vars['perpage_selected'] = $perpage;
$vars['perpage_select_options']['10'] = '10 ' . lang('results');
$vars['perpage_select_options']['25'] = '25 ' . lang('results');
$vars['perpage_select_options']['50'] = '50 ' . lang('results');
$vars['perpage_select_options']['75'] = '75 ' . lang('results');
$vars['perpage_select_options']['100'] = '100 ' . lang('results');
$vars['perpage_select_options']['150'] = '150 ' . lang('results');
if (isset($_POST['keywords'])) {
$keywords = sanitize_search_terms($_POST['keywords']);
} elseif (isset($_GET['keywords'])) {
$keywords = sanitize_search_terms(base64_decode($_GET['keywords']));
} else {
$keywords = '';
}
if (substr(strtolower($keywords), 0, 3) == 'ip:') {
$keywords = str_replace('_', '.', $keywords);
}
// Because of the auto convert we prepare a specific variable with the converted ascii
// characters while leaving the $keywords variable intact for display and URL purposes
$search_keywords = ee()->config->item('auto_convert_high_ascii') == 'y' ? ascii_to_entities($keywords) : $keywords;
$vars['exact_match'] = ee()->input->get_post('exact_match');
$vars['keywords'] = array('name' => 'keywords', 'value' => stripslashes($keywords), 'id' => 'keywords', 'maxlength' => 200);
$search_in = ee()->input->get_post('search_in') != '' ? ee()->input->get_post('search_in') : 'title';
$vars['search_in_selected'] = $search_in;
$vars['search_in_options']['title'] = lang('title_only');
$vars['search_in_options']['body'] = lang('title_and_body');
if (isset(ee()->installed_modules['comment'])) {
$vars['search_in_options']['everywhere'] = lang('title_body_comments');
$vars['search_in_options']['comments'] = $this->lang->line('comments');
}
// Build the main query
if ($search_url != '') {
$pageurl = BASE . AMP . $search_url;
} else {
$pageurl = BASE . AMP . 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=simple_commerce' . AMP . 'method=add_items';
}
$sql_a = "SELECT ";
if ($search_in == 'comments') {
$sql_b = "DISTINCT(exp_comments.comment_id) ";
} else {
$sql_b = ($cat_id == 'none' or $cat_id != "") ? "DISTINCT(exp_channel_titles.entry_id) " : "exp_channel_titles.entry_id ";
示例4: search_products
/**
* search_products function.
*
* @access public
* @param string $term
* @param string $type
* @return JSON product array
*/
public function search_products($term, $type = '')
{
$this->EE->load->helper('search');
$products = array();
$term = "%" . sanitize_search_terms($term) . "%";
if (strlen($term) < 2) {
return $products;
}
$site_id = $this->config->item('site_id');
$sql = " SELECT \n \t\t * \n \t\t FROM \n \t\t " . $this->EE->db->dbprefix . "br_product \n \t\t WHERE \n \t\t enabled >= 0 \n \t\t AND \n \t\t site_id = " . $site_id . " \n \t\t AND \n \t\t (\n \t\t title LIKE '" . $term . "'\n \t\t OR \n \t\t detail LIKE '" . $term . "'\n \t\t OR \n \t\t sku LIKE '" . $term . "'\n \t\t ) ";
// restrict the product types allowed
// in a bundle search
if ($type == 'bundle') {
$types = array(1, 4, 5, 7);
$sql .= " AND type_id IN (" . join(",", $types) . ")";
}
$sql .= " order by title desc";
$query = $this->EE->db->query($sql);
foreach ($query->result_array() as $row) {
$products[] = $row;
}
return $products;
}
示例5: sanitize_search_terms
/**
* Sanitize Search Terms
*
* Filters a search string for security
*
* @access public
* @param string
* @return string
*/
public function sanitize_search_terms($str)
{
if (APP_VER < 2.0) {
return $GLOBALS['REGX']->keyword_clean($str);
} else {
ee()->load->helper('search');
return sanitize_search_terms($str);
}
}
示例6: filter_settings
function filter_settings($ajax = FALSE)
{
// Load the search helper so we can filter the keywords
$this->EE->load->helper('search');
$keywords = '';
if ($this->EE->input->post('keywords')) {
$keywords = $this->EE->input->get_post('keywords');
} elseif ($this->EE->input->get('keywords')) {
$keywords = base64_decode($this->EE->input->get('keywords'));
}
$channel_id = $this->EE->input->get_post('channel_id') && $this->EE->input->get_post('channel_id') != 'null' ? $this->EE->input->get_post('channel_id') : '';
$filter_on['status'] = $this->EE->input->get_post('status');
$filter_on['order'] = $this->EE->input->get_post('order');
$filter_on['date_range'] = $this->EE->input->get_post('date_range');
$filter_on['name'] = $this->EE->input->get('name') ? sanitize_search_terms(base64_decode($this->EE->input->get('name'))) : $this->EE->input->post('name');
$filter_on['keywords'] = $keywords;
$filter_on['search_in'] = $this->EE->input->get_post('search_in');
$filter_on['channel_id'] = $this->EE->input->get_post('channel_id');
$filter_on['date_range'] = $this->EE->input->get_post('date_range');
$filter_on['ip_address'] = $this->EE->input->get('ip_address') ? sanitize_search_terms(base64_decode($this->EE->input->post('ip_address'))) : $this->EE->input->post('ip_address');
$filter_on['email'] = $this->EE->input->get('email') ? base64_decode($this->EE->input->post('email')) : $this->EE->input->post('email');
$filter_on['entry_id'] = $this->EE->input->get_post('entry_id');
$filter_on['comment_id'] = $this->EE->input->get_post('comment_id');
$filter_on['limit'] = $this->perpage;
// Because you can specify some extra gets- let's translate that back to search_in/keywords
if ($this->EE->input->get('entry_id')) {
$filter_on['search_in'] = 'entry_title';
$this->EE->db->select('title');
$this->EE->db->where('entry_id', $this->EE->input->get('entry_id'));
$query = $this->EE->db->get('channel_titles');
$row = $query->row();
$filter_on['keywords'] = $row->title;
} elseif ($this->EE->input->get('name')) {
$filter_on['search_in'] = 'name';
$filter_on['keywords'] = base64_decode($this->EE->input->get('name'));
} elseif ($this->EE->input->get('email')) {
$filter_on['search_in'] = 'email';
$filter_on['keywords'] = base64_decode($this->EE->input->get('email'));
} elseif ($this->EE->input->get('ip_address')) {
$filter_on['search_in'] = 'ip_address';
$filter_on['keywords'] = base64_decode($this->EE->input->get('ip_address'));
}
// Create the get variables for non-js pagination
// Post variables: search_in, keywords*, channel_id, status, date_range
// Get variables: entry_id, channel_id, name, email*, ip_address* and status
$url = array('search_in' => $filter_on['search_in']);
$filter_on['search_form_hidden'] = array();
foreach ($filter_on as $name => $value) {
if ($this->EE->input->post($name) && $this->EE->input->post($name) != '') {
$v = $name == 'keywords' ? base64_encode($this->EE->input->post($name)) : $this->EE->input->post($name);
$url[$name] = $name . '=' . $v;
} elseif ($this->EE->input->get($name)) {
$url[$name] = $name . '=' . $this->EE->input->get($name);
}
}
if (!isset($url['keywords'])) {
unset($url['search_in']);
}
$this->search_url = implode(AMP, $url);
return $filter_on;
}
示例7: view
/**
* View Referrers
*/
function view()
{
ee()->load->library('pagination');
ee()->load->library('javascript');
ee()->load->library('table');
ee()->load->helper('form');
ee()->cp->set_breadcrumb(BASE . AMP . 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=referrer', ee()->lang->line('referrers'));
$vars['cp_page_title'] = ee()->lang->line('view_referrers');
ee()->jquery->tablesorter('.mainTable', '{
headers: {5: {sorter: false}},
widgets: ["zebra"]
}');
ee()->javascript->output(array('$(".toggle_all").toggle(
function(){
$("input.toggle").each(function() {
this.checked = true;
});
}, function (){
var checked_status = this.checked;
$("input.toggle").each(function() {
this.checked = false;
});
}
);'));
ee()->cp->add_to_foot('<script type="text/javascript">function showHide(entryID, htmlObj, linkType) {
extTextDivID = ("extText" + (entryID));
extLinkDivID = ("extLink" + (entryID));
if (linkType == "close")
{
document.getElementById(extTextDivID).style.display = "none";
document.getElementById(extLinkDivID).style.display = "block";
htmlObj.blur();
}
else
{
document.getElementById(extTextDivID).style.display = "block";
document.getElementById(extLinkDivID).style.display = "none";
htmlObj.blur();
}
}
</script>');
$vars['referrers'] = array();
// used to pass referrer info into view, but initialized here in case there are no results.
$rownum = ee()->input->get_post('rownum') != '' ? ee()->input->get_post('rownum') : 0;
$perpage = 10;
$search_str = '';
$search_sql = '';
$vars['search']['name'] = 'search';
if (isset($_GET['search']) or isset($_POST['search'])) {
$search_str = isset($_POST['search']) ? stripslashes($_POST['search']) : base64_decode($_GET['search']);
}
if ($search_str != '') {
// Load the search helper so we can filter the keywords
ee()->load->helper('search');
$s = preg_split("/\\s+/", sanitize_search_terms($search_str));
foreach ($s as $part) {
if (substr($part, 0, 1) == '-') {
$search_sql .= "CONCAT_WS(' ', ref_from, ref_to, ref_ip, ref_agent) NOT LIKE '%" . ee()->db->escape_like_str(substr($part, 1)) . "%' AND ";
} else {
$search_sql .= "CONCAT_WS(' ', ref_from, ref_to, ref_ip, ref_agent) LIKE '%" . ee()->db->escape_like_str($part) . "%' AND ";
}
}
$sql = "WHERE (" . substr($search_sql, 0, -4) . ")";
$vars['search']['value'] = sanitize_search_terms($search_str);
} else {
$sql = "";
}
$query = ee()->db->query("SELECT COUNT(*) AS count FROM exp_referrers " . $sql);
$vars['num_referrers'] = $query->row('count');
if ($query->row('count') == 0) {
$vars['message'] = isset($vars['search']['value']) ? ee()->lang->line('referrer_no_results') : ee()->lang->line('no_referrers');
return ee()->load->view('view', $vars, TRUE);
exit;
}
$sites_query = ee()->db->query("SELECT site_id, site_label FROM exp_sites");
$sites = array();
foreach ($sites_query->result_array() as $row) {
$sites[$row['site_id']] = $row['site_label'];
}
$query = ee()->db->query("SELECT * FROM exp_referrers " . $sql . " ORDER BY ref_id desc LIMIT {$rownum}, {$perpage}");
$site_url = ee()->config->item('site_url');
foreach ($query->result_array() as $row) {
// From
$row['ref_from'] = str_replace('http://', '', $row['ref_from']);
if (strlen($row['ref_from']) > 40) {
$from_pieces = explode('/', $row['ref_from']);
$new_from = $from_pieces['0'] . '/';
for ($p = 1; $p < count($from_pieces); $p++) {
if (strlen($from_pieces[$p]) + strlen($new_from) <= 40) {
$new_from .= $p == count($from_pieces) - 1 ? $from_pieces[$p] : $from_pieces[$p] . '/';
} else {
$new_from .= '…';
break;
}
//.........这里部分代码省略.........
示例8: do_search
/**
* Do Search
*/
function do_search()
{
$this->EE->lang->loadfile('search');
// Get hidden meta vars
if (isset($_POST['meta'])) {
$this->_get_meta_vars();
}
/** ----------------------------------------
/** Profile Exception
/** ----------------------------------------*/
// This is an exception to the normal search routine.
// It permits us to search for all posts by a particular user's screen name
// We look for the "mbr" $_GET variable. If it exsists it will
// trigger our exception
if ($this->EE->input->get_post('mbr')) {
$this->_meta['result_page'] = $this->EE->input->get_post('result_path') != '' ? $this->EE->input->get_post('result_path') : 'search/results';
$_POST['keywords'] = '';
$_POST['exact_match'] = 'y';
$_POST['exact_keyword'] = 'n';
}
// RP can be used in a query string,
// so we need to clean it a bit
$this->_meta['result_page'] = str_replace(array('=', '&'), '', $this->_meta['result_page']);
/** ----------------------------------------
/** Pulldown Addition - Any, All, Exact
/** ----------------------------------------*/
if (isset($this->_meta['where']) && $this->_meta['where'] == 'exact') {
$_POST['exact_keyword'] = 'y';
}
/** ----------------------------------------
/** Do we have a search results page?
/** ----------------------------------------*/
// The search results template is specified as a parameter in the search form tag.
// If the parameter is missing we'll issue an error since we don't know where to
// show the results
if (!isset($this->_meta['result_page']) or $this->_meta['result_page'] == '') {
return $this->EE->output->show_user_error('general', array(lang('search_path_error')));
}
/** ----------------------------------------
/** Is the current user allowed to search?
/** ----------------------------------------*/
if ($this->EE->session->userdata('can_search') == 'n' and $this->EE->session->userdata('group_id') != 1) {
return $this->EE->output->show_user_error('general', array(lang('search_not_allowed')));
}
/** ----------------------------------------
/** Flood control
/** ----------------------------------------*/
if ($this->EE->session->userdata['search_flood_control'] > 0 and $this->EE->session->userdata['group_id'] != 1) {
$cutoff = time() - $this->EE->session->userdata['search_flood_control'];
$sql = "SELECT search_id FROM exp_search WHERE site_id = '" . $this->EE->db->escape_str($this->EE->config->item('site_id')) . "' AND search_date > '{$cutoff}' AND ";
if ($this->EE->session->userdata['member_id'] != 0) {
$sql .= "(member_id='" . $this->EE->db->escape_str($this->EE->session->userdata('member_id')) . "' OR ip_address='" . $this->EE->db->escape_str($this->EE->input->ip_address()) . "')";
} else {
$sql .= "ip_address='" . $this->EE->db->escape_str($this->EE->input->ip_address()) . "'";
}
$query = $this->EE->db->query($sql);
$text = str_replace("%x", $this->EE->session->userdata['search_flood_control'], lang('search_time_not_expired'));
if ($query->num_rows() > 0) {
return $this->EE->output->show_user_error('general', array($text));
}
}
/** ----------------------------------------
/** Did the user submit any keywords?
/** ----------------------------------------*/
// We only require a keyword if the member name field is blank
if (!isset($_GET['mbr']) or !is_numeric($_GET['mbr'])) {
if (!isset($_POST['member_name']) or $_POST['member_name'] == '') {
if (!isset($_POST['keywords']) or $_POST['keywords'] == "") {
return $this->EE->output->show_user_error('general', array(lang('search_no_keywords')));
}
}
}
/** ----------------------------------------
/** Strip extraneous junk from keywords
/** ----------------------------------------*/
if ($_POST['keywords'] != "") {
// Load the search helper so we can filter the keywords
$this->EE->load->helper('search');
$this->keywords = sanitize_search_terms($_POST['keywords']);
/** ----------------------------------------
/** Is the search term long enough?
/** ----------------------------------------*/
if (strlen($this->keywords) < $this->min_length) {
$text = lang('search_min_length');
$text = str_replace("%x", $this->min_length, $text);
return $this->EE->output->show_user_error('general', array($text));
}
// Load the text helper
$this->EE->load->helper('text');
$this->keywords = $this->EE->config->item('auto_convert_high_ascii') == 'y' ? ascii_to_entities($this->keywords) : $this->keywords;
/** ----------------------------------------
/** Remove "ignored" words
/** ----------------------------------------*/
if ((!isset($_POST['exact_keyword']) or $_POST['exact_keyword'] != 'y') && @(include_once APPPATH . 'config/stopwords.php')) {
$parts = explode('"', $this->keywords);
$this->keywords = '';
foreach ($parts as $num => $part) {
//.........这里部分代码省略.........
示例9: search_results
/**
* Render the search results
* @param string $keywords (Optional) Search keyword from elsewhere
* @return string Parsed search results
*/
public function search_results($keywords = '')
{
// Check for pagination
if (ee()->input->get_post('keywords') === FALSE && $keywords == '') {
if (!isset($this->seg_parts['1']) or strlen($this->seg_parts['1']) < 20) {
return $this->return_data = '';
}
ee()->db->where('wiki_search_id', $this->seg_parts['1']);
$query = ee()->db->get('wiki_search');
if ($query->num_rows() > 0) {
// Retrieve information about the search
$paginate_sql = $query->row('wiki_search_query');
$paginate_hash = $query->row('wiki_search_id');
$keywords = $query->row('wiki_search_keywords');
}
}
/** ----------------------------------------
/** Work Up the Keywords A Bit, Know What I'm Saying?
/** ----------------------------------------*/
$keywords = ee()->input->get_post('keywords') !== FALSE ? ee()->input->get_post('keywords') : $keywords;
// Load the search helper so we can filter the keywords
ee()->load->helper('search');
$keywords = ee()->functions->encode_ee_tags(sanitize_search_terms($keywords), TRUE);
if ($keywords == '') {
$this->redirect('', 'index');
} elseif (strlen($keywords) < $this->min_length_keywords) {
return ee()->output->show_user_error('general', array(str_replace("%x", $this->min_length_keywords, lang('search_min_length'))));
}
$this->return_data = str_replace(array('{wiki:page}', '{keywords}'), array($this->_fetch_template('wiki_special_search_results.html'), stripslashes($keywords)), $this->return_data);
// Start work on pagination
ee()->load->library('pagination');
$pagination = ee()->pagination->create();
$this->return_data = $pagination->prepare($this->return_data);
/** ----------------------------------------
/** Parse Results Tag Pair
/** ----------------------------------------*/
if (!preg_match("/\\{wiki:search_results(.*?)\\}(.*?)\\{\\/wiki:search_results\\}/s", $this->return_data, $match)) {
return $this->return_data = '';
}
/** ----------------------------------------
/** Parameters
/** ----------------------------------------*/
$parameters = ee()->functions->assign_parameters($match[1], array('limit' => 20, 'paginate' => 'bottom', 'switch' => ''));
/* ----------------------------------------
/* Date Formats
/* - Those GMT dates are not typical for results, but I thought it might
/* be the case that there will be dynamic RSS/Atom searches in the
/* future so I added them just in case.
/* ----------------------------------------*/
$dates = $this->parse_dates($this->return_data);
/** ----------------------------------------
/** Our Query
/** ----------------------------------------*/
if ($pagination->paginate === TRUE && isset($paginate_sql)) {
$sql = $paginate_sql;
} else {
$sql = "FROM exp_wiki_revisions r, exp_members m, exp_wiki_page p\n\t\t\t\tWHERE p.page_id = r.page_id\n\t\t\t\t\tAND p.last_updated = r.revision_date\n\t\t\t\t\tAND p.wiki_id = '" . ee()->db->escape_str($this->wiki_id) . "'\n\t\t\t\t\tAND (";
/** -------------------------------------
/** Get our keywords into search terms
/** -------------------------------------*/
$terms = array();
$keywords = stripslashes($keywords);
$nsql = '';
if (stristr(strtolower($keywords), 'namespace:')) {
$namespaces = array('Category' => 'category');
$nquery = ee()->db->query("SELECT namespace_label, namespace_name FROM exp_wiki_namespaces");
if ($nquery->num_rows() > 0) {
foreach ($nquery->result_array() as $row) {
$namespaces[$row['namespace_label']] = $row['namespace_name'];
}
}
foreach ($namespaces as $key => $val) {
if (preg_match("/namespace:\\s*(\\-)*\\s*[\\'\"]?(" . preg_quote($key, '/') . ")[\\'\"]?/", $keywords, $nmatch)) {
$keywords = str_replace($nmatch['0'], '', $keywords);
$compare = $nmatch['1'] == "-" ? '!=' : '=';
$nsql = "AND p.page_namespace {$compare} '" . $namespaces[$nmatch['2']] . "' \n";
}
}
}
// in case they searched with only "namespace:namespace_label" and no keywords
if (trim($keywords) == '') {
return ee()->output->show_user_error('general', array(lang('no_search_terms')));
}
if (preg_match_all("/\\-*\"(.*?)\"/", $keywords, $matches)) {
for ($m = 0; $m < count($matches['1']); $m++) {
$terms[] = trim(str_replace('"', '', $matches['0'][$m]));
$keywords = str_replace($matches['0'][$m], '', $keywords);
}
}
if (trim($keywords) != '') {
$terms = array_merge($terms, preg_split("/\\s+/", trim($keywords)));
}
$not_and = count($terms) > 2 ? ') AND (' : 'AND';
rsort($terms);
/** -------------------------------------
//.........这里部分代码省略.........
示例10: search
function search()
{
// Load native EE helper to sanitize search term
$this->EE->load->helper('search');
// Set the return location
$return = $this->EE->TMPL->fetch_param('return') ? $this->EE->TMPL->fetch_param('return') : 'catalog/result';
// Get the product search collection
$term = $this->EE->TMPL->fetch_param('term') ? $this->EE->TMPL->fetch_param('term') : $this->EE->input->post('search', TRUE);
$term = sanitize_search_terms($term);
$hits = $this->_search_index($term);
$hash = sha1(time() . $term);
$i = 0;
$product = array();
foreach ($hits as $hit) {
$tmp = $this->EE->product_model->get_products($hit["product_id"]);
// Check to make sure that a product is returned
if (isset($tmp[0])) {
if ($tmp[0]["site_id"] == $this->site_id) {
$product[$i] = $tmp[0];
$product[$i]["score"] = round(100 * $hit["score"], 2);
$product[$i]["row_count"] = $i + 1;
$i++;
}
}
}
// Count the products but set
// a reasonable search result
// limit
$count = count($product);
if ($count > $this->_config["result_limit"]) {
$lim = $count - 1;
for ($i = $this->_config["result_limit"]; $i <= $count; $i++) {
unset($product[$i]);
}
$count = $this->_config["result_limit"];
}
$vars[0] = array('search_hash' => $hash, 'search_term' => $term, 'total_results' => count($product), 'results' => $product, 'no_results' => array(), 'result_filter_set' => '');
save_to_cache('search_' . $hash, serialize($vars));
$this->EE->product_model->log_search($term, $hash, count($product), $this->EE->session->userdata["member_id"]);
$this->EE->functions->redirect($this->EE->functions->create_url($return . '/id/' . $hash));
}
示例11: sanitize_search_terms
/**
* Sanitize Search Terms
*
* Filters a search string for security
*
* @access public
* @param string
* @return string
*/
public function sanitize_search_terms($str)
{
ee()->load->helper('search');
return sanitize_search_terms($str);
}
示例12: search_results
/** -------------------------------------
/** Search Some Content!
/** -------------------------------------*/
function search_results($keywords='')
{
/** ----------------------------------------
/** Check for Pagination
/** ----------------------------------------*/
$search_paginate = FALSE;
if ($this->EE->input->get_post('keywords') === FALSE && $keywords == '')
{
if ( ! isset($this->seg_parts['1']) OR strlen($this->seg_parts['1']) < 20)
{
return $this->return_data = '';
}
$this->EE->db->where('wiki_search_id', $this->seg_parts['1']);
$query = $this->EE->db->get('wiki_search');
if ($query->num_rows() > 0)
{
$search_paginate = TRUE;
$paginate_sql = $query->row('wiki_search_query') ;
$paginate_hash = $query->row('wiki_search_id') ;
$keywords = $query->row('wiki_search_keywords') ;
}
}
/** ----------------------------------------
/** Work Up the Keywords A Bit, Know What I'm Saying?
/** ----------------------------------------*/
$keywords = ($this->EE->input->get_post('keywords') !== FALSE) ? $this->EE->input->get_post('keywords') : $keywords;
// Load the search helper so we can filter the keywords
$this->EE->load->helper('search');
$keywords = $this->EE->functions->encode_ee_tags(sanitize_search_terms($keywords), TRUE);
if ($keywords == '')
{
$this->redirect('', 'index');
}
elseif(strlen($keywords) < $this->min_length_keywords)
{
return $this->EE->output->show_user_error('general', array(str_replace("%x", $this->min_length_keywords, $this->EE->lang->line('search_min_length'))));
}
$this->return_data = str_replace(array('{wiki:page}', '{keywords}'),
array($this->_fetch_template('wiki_special_search_results.html'), stripslashes($keywords)),
$this->return_data);
/** ----------------------------------------
/** Parse Results Tag Pair
/** ----------------------------------------*/
if ( ! preg_match("/\{wiki:search_results(.*?)\}(.*?)\{\/wiki:search_results\}/s", $this->return_data, $match))
{
return $this->return_data = '';
}
/** ----------------------------------------
/** Parameters
/** ----------------------------------------*/
$parameters['limit'] = 20;
$parameters['switch1'] = '';
$parameters['switch2'] = '';
$parameters['paginate'] = 'bottom';
if (trim($match['1']) != '' && ($params = $this->EE->functions->assign_parameters($match['1'])) !== FALSE)
{
$parameters['limit'] = (isset($params['limit']) && is_numeric($params['limit'])) ? $params['limit'] : $parameters['limit'];
$parameters['paginate'] = (isset($params['paginate'])) ? $params['paginate'] : $parameters['paginate'];
if (isset($params['switch']))
{
if (strpos($params['switch'], '|') !== FALSE)
{
$x = explode("|", $params['switch']);
$parameters['switch1'] = $x['0'];
$parameters['switch2'] = $x['1'];
}
else
{
$parameters['switch1'] = $params['switch'];
}
}
}
/* ----------------------------------------
/* Date Formats
/* - Those GMT dates are not typical for results, but I thought it might
/* be the case that there will be dynamic RSS/Atom searches in the
/* future so I added them just in case.
/* ----------------------------------------*/
//.........这里部分代码省略.........
示例13: _fetch_get_post_vars
/**
* Fetch Get/Post variables
*
* GET/POST variables are just a wee bit different when a jquery datatables
* request is made. In order to keep stupid IE from caching the ajax request,
* we add a time= variable to the request. So here, we can safely assume that
* a request from datatables will have $_['GET']['time'] in it.
* There are just a coupla differences, so we construct our array of get/post
* vars and return 'er/
*
* @return array
*/
private function _fetch_get_post_vars()
{
$this->load->helper('search');
$ret = array('author_id' => $this->input->get_post('author_id'), 'cat_id' => $this->input->get_post('cat_id'), 'dir_id' => $this->input->get_post('dir_id') != 'all' && $this->input->get_post('dir_id') != 'null' ? $this->input->get_post('dir_id') : FALSE, 'date_range' => $this->input->get_post('date_range'), 'file_type' => $this->input->get_post('file_type'), 'keywords' => NULL, 'offset' => ($offset = $this->input->get('offset')) ? $offset : 0, 'order' => ($order = $this->input->get('offset')) ? $order : 0, 'per_page' => ($per_page = $this->input->get('per_page')) ? $per_page : $this->per_page, 'status' => $this->input->get_post('status') != 'all' ? $this->input->get_post('status') : '', 'search_in' => $this->input->get_post('search_in'), 'search_type' => $this->input->get_post('search_type'), 'type' => ($type = $this->input->get_post('type')) ? $type : 'all', 'date_range' => $this->input->get_post('date_range'), 'date_start' => (($date_start = $this->input->get_post('custom_date_start')) != 'yyyy-mm-dd' and $date_start !== FALSE) ? $date_start : FALSE, 'date_end' => (($date_end = $this->input->get_post('custom_date_end')) != 'yyyy-mm-dd' and $date_end !== FALSE) ? $date_end : FALSE);
if ($this->input->post('keywords')) {
$ret['keywords'] = sanitize_search_terms($this->input->post('keywords'));
} elseif ($this->input->get('keywords')) {
$ret['keywords'] = sanitize_search_terms(base64_decode($this->input->get('keywords')));
}
return $ret;
}
示例14: _table_datasource
/**
* Edit table datasource
*
* Must remain public so that it can be called from the
* table library!
*
* @access public
*/
public function _table_datasource($tbl_settings, $defaults)
{
// Get filter information
// ----------------------------------------------------------------
$keywords = (string) $this->input->post('keywords');
$channel_id = (string) $this->input->get_post('channel_id');
if ($channel_id == 'null') {
$channel_id = NULL;
}
if (!$keywords) {
$keywords = (string) $this->input->get('keywords');
if ($keywords) {
$keywords = base64_decode($keywords);
}
}
if ($keywords) {
$this->load->helper('search');
$keywords = sanitize_search_terms($keywords);
if (substr(strtolower($keywords), 0, 3) == 'ip:') {
$keywords = str_replace('_', '.', $keywords);
}
}
// Because of the auto convert we prepare a specific variable with the converted ascii
// characters while leaving the $keywords variable intact for display and URL purposes
$this->load->helper('text');
$search_keywords = $this->config->item('auto_convert_high_ascii') == 'y' ? ascii_to_entities($keywords) : $keywords;
$perpage = $this->input->get_post('perpage');
$perpage = $perpage ? $perpage : $defaults['perpage'];
$rownum = $tbl_settings['offset'];
// We want the filter to work based on both get and post
$filter_data = array('channel_id' => $channel_id, 'keywords' => $keywords, 'cat_id' => $this->input->get_post('cat_id'), 'status' => $this->input->get_post('status'), 'order' => $this->input->get_post('order'), 'date_range' => $this->input->get_post('date_range'), 'author_id' => $this->input->get_post('author_id'), 'exact_match' => $this->input->get_post('exact_match'), 'cat_id' => $this->input->get_post('cat_id') != 'all' ? $this->input->get_post('cat_id') : '', 'search_in' => $this->input->get_post('search_in') ? $this->input->get_post('search_in') : 'title', 'rownum' => $rownum, 'perpage' => $perpage, 'search_keywords' => $search_keywords);
$channels = $defaults['channels'];
$order = $tbl_settings['sort'];
$columns = $tbl_settings['columns'];
// -------------------------------------------
// 'edit_entries_additional_where' hook.
// - Add additional where, where_in, where_not_in
//
$_hook_wheres = $this->extensions->call('edit_entries_additional_where', $filter_data);
if ($this->extensions->end_script === TRUE) {
return;
}
//
// -------------------------------------------
$filter_data['_hook_wheres'] = is_array($_hook_wheres) ? $_hook_wheres : array();
$this->load->model('search_model');
$filter_result = $this->search_model->get_filtered_entries($filter_data, $order);
$rows = $filter_result['results'];
$total = $filter_result['total_count'];
unset($filter_result);
$filter_url = $this->_create_return_filter($filter_data);
// Gather up ids for a single quick query down the line
$entry_ids = array();
foreach ($rows as $row) {
$entry_ids[] = $row['entry_id'];
}
// Load the site's templates
// ----------------------------------------------------------------
$templates = array();
$tquery = $this->db->query("SELECT exp_template_groups.group_name, exp_templates.template_name, exp_templates.template_id\n\t\t\t\t\t\t\tFROM exp_template_groups, exp_templates\n\t\t\t\t\t\t\tWHERE exp_template_groups.group_id = exp_templates.group_id\n\t\t\t\t\t\t\tAND exp_templates.site_id = '" . $this->db->escape_str($this->config->item('site_id')) . "'");
foreach ($tquery->result_array() as $row) {
$templates[$row['template_id']] = $row['group_name'] . '/' . $row['template_name'];
}
// Comment count
// ----------------------------------------------------------------
$show_link = TRUE;
$comment_counts = array();
if (count($entry_ids) and $this->db->table_exists('comments')) {
$comment_qry = $this->db->select('entry_id, COUNT(*) as count')->where_in('entry_id', $entry_ids)->group_by('entry_id')->get('comments');
foreach ($comment_qry->result() as $row) {
$comment_counts[$row->entry_id] = $row->count;
}
}
// Date formatting
$date_fmt = $this->session->userdata('time_format') != '' ? $this->session->userdata('time_format') : $this->config->item('time_format');
$datestr = '%m/%d/%y %h:%i %a';
if ($date_fmt != 'us') {
$datestr = '%Y-%m-%d %H:%i';
}
// Autosave - Grab all autosaved entries
// ----------------------------------------------------------------
$this->prune_autosave();
$this->db->select('entry_id, original_entry_id, channel_id, title, author_id, status, entry_date, dst_enabled, comment_total');
$autosave = $this->db->get('channel_entries_autosave');
$autosave_array = array();
$autosave_show = FALSE;
if ($autosave->num_rows()) {
$this->load->helper('snippets');
$autosave_show = TRUE;
}
foreach ($autosave->result() as $entry) {
if ($entry->original_entry_id) {
//.........这里部分代码省略.........
示例15: index
/**
* Index function
*
* @return void
*/
public function index($channel_id = '', $message = '', $extra_sql = '', $search_url = '', $form_url = '', $action = '', $extra_fields_search = '', $extra_fields_entries = '', $heading = '')
{
if (!$this->cp->allowed_group('can_access_content')) {
show_error($this->lang->line('unauthorized_access'));
}
$channel_id = '';
$extra_sql = '';
// $action, $extra_fields_*, and $heading are used by move_comments
$vars['message'] = $message;
$action = $action != '' ? $action : $this->input->get_post('action');
$this->load->library('pagination');
$this->load->library('table');
$this->load->helper(array('form', 'text', 'url', 'snippets'));
$this->api->instantiate('channel_categories');
// Load the search helper so we can filter the keywords
$this->load->helper('search');
$this->cp->set_variable('cp_page_title', $this->lang->line('edit'));
$this->cp->add_js_script(array('plugin' => 'dataTables', 'ui' => 'datepicker'));
// Need perpage for js
// Results per page pull-down menu
if (!($perpage = $this->input->get_post('perpage'))) {
$perpage = $this->input->cookie('perpage');
}
if ($perpage == '') {
$perpage = 50;
}
$this->cp->add_js_script(array('file' => 'cp/content_edit'));
$this->javascript->set_global('lang.selection_required', $this->lang->line('selection_required'));
$cp_theme = !$this->session->userdata('cp_theme') ? $this->config->item('cp_theme') : $this->session->userdata('cp_theme');
if ($this->config->item('kill_all_humans') !== 'disable' && (mt_rand(0, 5000) == 42 && $this->session->userdata['group_id'] == 1 or $this->config->item('kill_all_humans'))) {
$this->load->helper('html');
$image_properties = array('src' => base_url() . "themes/cp_themes/default/images/" . strrev('tobor_rellik') . ".png", 'alt' => '', 'id' => 'extra', 'width' => '228', 'height' => '157', 'style' => 'z-index: 1000; position: absolute; top: 49px; left: 790px');
$this->javascript->output(array('$("#mainMenu").append(\'' . img($image_properties) . '\')', $this->javascript->animate("#extra", array("left" => 0), 4000, 'function(){$(\'#extra\').fadeOut(3000)}')));
}
// Fetch channel ID numbers assigned to the current user
$allowed_channels = $this->functions->fetch_assigned_channels();
if (empty($allowed_channels)) {
show_error($this->lang->line('no_channels'));
}
// Fetch Color Library - We use this to assist with our status colors
if (file_exists(APPPATH . 'config/colors' . EXT)) {
include APPPATH . 'config/colors' . EXT;
} else {
$colors = '';
}
// We need to determine which channel to show entries from
// if the channel_id combined
if ($channel_id == '') {
$channel_id = $this->input->get_post('channel_id');
}
if ($channel_id == 'null' or $channel_id === FALSE or !is_numeric($channel_id)) {
$channel_id = '';
}
$cat_group = '';
// We want the filter to work based on both get and post
$filter_data['channel_id'] = $channel_id;
$filter_data['cat_id'] = $this->input->get_post('cat_id');
$filter_data['status'] = $this->input->get_post('status');
$filter_data['order'] = $this->input->get_post('order');
$filter_data['date_range'] = $this->input->get_post('date_range');
$total_channels = count($allowed_channels);
$vars['status'] = $filter_data['status'];
if (isset($_POST['keywords'])) {
$keywords = sanitize_search_terms($_POST['keywords']);
} elseif (isset($_GET['keywords'])) {
$keywords = sanitize_search_terms(base64_decode($_GET['keywords']));
} else {
$keywords = '';
}
if (substr(strtolower($keywords), 0, 3) == 'ip:') {
$keywords = str_replace('_', '.', $keywords);
}
$filter_data['keywords'] = $keywords;
// We need this for the filter, so grab it now
$cat_form_array = $this->api_channel_categories->category_form_tree($this->nest_categories);
// If we have channels we'll write the JavaScript menu switching code
if ($total_channels > 0) {
$this->filtering_menus($cat_form_array);
}
// If we're filtering using ajax, we redirect comment only searches
// So- pass along the filter in the url
if (isset($this->installed_modules['comment'])) {
$comment_url = '&ajax=true';
$comment_url .= $filter_data['channel_id'] != '' ? '&channel_id=' . $filter_data['channel_id'] : '';
$comment_url .= $filter_data['keywords'] != '' ? '&keywords=' . base64_encode($filter_data['keywords']) : '';
}
if (isset($this->installed_modules['comment'])) {
$table_columns = 9;
} else {
$table_columns = 8;
}
$this->javascript->set_global(array('edit.pipe' => $this->pipe_length, 'edit.perPage' => $perpage, 'edit.themeUrl' => $this->cp->cp_theme_url, 'edit.tableColumns' => $table_columns, 'lang.noEntries' => $this->lang->line('no_entries_matching_that_criteria')));
// Do we have a message to show?
// Note: a message is displayed on this page after editing or submitting a new entry
if ($this->input->get_post("U") == 'mu') {
//.........这里部分代码省略.........