function search() { global $vars; if (isset($vars['searchstring'])) { return search_results(); } return search_form(); }
function report_results(&$docs) { echo "<table cellspacing=\"2\">\n"; echo " <tr>\n"; echo " <td colspan=\"2\"><h2>" . search_results() . "</h2></td>\n"; echo " </tr>\n"; $numDocs = sizeof($docs); if ($numDocs == 0) { echo " <tr>\n"; echo " <td colspan=\"2\">" . matches_text(0) . "</td>\n"; echo " </tr>\n"; } else { echo " <tr>\n"; echo " <td colspan=\"2\">" . matches_text($numDocs); echo "\n"; echo " </td>\n"; echo " </tr>\n"; $num = 1; foreach ($docs as $doc) { echo " <tr>\n"; echo " <td align=\"right\">{$num}.</td>"; echo "<td><a class=\"el\" href=\"" . $doc["url"] . "\">" . $doc["name"] . "</a></td>\n"; echo " <tr>\n"; echo " <td></td><td class=\"tiny\">" . report_matches() . " "; foreach ($doc["words"] as $wordInfo) { $word = $wordInfo["word"]; $matchRight = substr($wordInfo["match"], strlen($word)); echo "<b>{$word}</b>{$matchRight}(" . $wordInfo["freq"] . ") "; } echo " </td>\n"; echo " </tr>\n"; $num++; } } echo "</table>\n"; }
<?php theme_include('header'); ?> <h1 class="no-margin-top">You searched for “<?php echo search_term(); ?> ”.</h1> <?php if (has_search_results()) { ?> <ul class="items"> <?php while (search_results()) { ?> <li> <article class="wrap"> <h2> <a href="<?php echo article_url(); ?> " title="<?php echo article_title(); ?> "><?php echo article_title(); ?> </a> </h2> </article>
function blogsfera_widget_search_results() { $title = __('Resultados de la búsqueda'); ?> <li id="search-results" class="clearfix"> <h2><?php echo $title; ?> </h2> <p class="query">Estos son los resultados de su búsqueda de "<?php current_search(); ?> ":</p> <ul> <?php if ($result = search_results()) { $list = ""; $last = count($result) - 1; $i = 0; reset($result); // Display blog info if (search_type() == 'blog') { foreach ($result as $blog_result) { $blog = get_blog_details($blog_result); $users = get_users_of_blog_by_rol($blog_result, 'edit_posts'); $list .= "<li"; // Display last element class if ($i == $last) { $list .= " class='last clearfix'"; } $list .= "><h3><a href='{$blog->siteurl}'>{$blog->blogname}</a></h3><ul>"; foreach ($users as $user) { $list .= "<li><a class='avatar' href='{$blog->siteurl}'>"; $list .= "<img src='" . author_image_path($user->user_id, $display = false) . "' alt='avatar' width='48px' height='48px'/></a>"; $list .= "<p style='font-size:15px;'>{$user->display_name}</p></li>"; } $list .= "</ul></li>"; $i++; } // Display user info } else { global $wpdb; $current_blog_id = $wpdb->blogid; foreach ($result as $user) { $blogs = get_blogs_of_user($user['ID'], true); foreach ($blogs as $blog_id => $blog) { //$blog = get_active_blog_for_user($user['ID']); switch_to_blog($blog_id); $user_o = new WP_User($user['ID']); if ($user_o->has_cap('edit_posts')) { $list .= "<li"; // Display last element class if ($i == $last) { $list .= " class='last clearfix'"; } $list .= "><a class='avatar' href='{$blog->siteurl}'>"; $list .= "<img src='" . author_image_path($user['ID'], $display = false) . "' alt='avatar' width='48px' height='48px'/>"; $list .= "</a><h3><a href='{$blog->siteurl}'>{$blog->blogname}</a></h3>"; $list .= "<p>by " . $user['display_name'] . "</p></li>"; } } $i++; } switch_to_blog($current_blog_id); } echo $list; } else { echo "<li>No se hallaron resultados</li>"; } ?> </ul> </li> <?php }
function do_update() { $query = $this->EE->db->query("SELECT COUNT(*) AS count FROM exp_template_groups"); $num = $query->row('count') + 1; $this->EE->db->query("insert into exp_template_groups(group_name, group_order) values ('search', '$num')"); $id = $DB->insert_id; $Q[] = "insert into exp_templates(group_id, template_name, template_data) values ('$id', 'index', '".addslashes(search_index())."')"; $Q[] = "insert into exp_templates(group_id, template_name, template_data) values ('$id', 'results', '".addslashes(search_results())."')"; $Q[] = "insert into exp_templates(group_id, template_name, template_type, template_data) values ('$id', 'search_css', 'css', '".addslashes(search_css())."')"; // Define the table changes $Q[] = "ALTER TABLE exp_member_groups ADD COLUMN can_search char(1) NOT NULL default 'n'"; $Q[] = "ALTER TABLE exp_member_groups ADD COLUMN search_flood_control mediumint(5) unsigned NOT NULL"; $Q[] = "ALTER TABLE exp_member_groups ADD COLUMN can_moderate_comments char(1) NOT NULL default 'n'"; $Q[] = "ALTER TABLE exp_weblogs ADD COLUMN search_excerpt int(4) unsigned NOT NULL"; $Q[] = "ALTER TABLE exp_weblogs ADD COLUMN comment_moderate char(1) NOT NULL default 'n'"; $Q[] = "ALTER TABLE exp_comments ADD COLUMN status char(1) NOT NULL default 'o'"; $Q[] = "ALTER TABLE exp_referrers ADD COLUMN ref_ip varchar(16) default '0' NOT NULL"; $Q[] = "ALTER TABLE exp_referrers ADD COLUMN ref_date int(10) unsigned default '0' NOT NULL"; $Q[] = "ALTER TABLE exp_referrers ADD COLUMN ref_agent varchar(100) NOT NULL"; $Q[] = "ALTER TABLE exp_templates ADD COLUMN php_parse_location char(1) NOT NULL default 'o'"; // Fix DB typos $Q[] = "ALTER TABLE exp_member_homepage CHANGE COLUMN memeber_search_form member_search_form char(1) NOT NULL default 'n'"; $Q[] = "ALTER TABLE exp_member_homepage CHANGE COLUMN memeber_search_form_order member_search_form_order int(3) unsigned NOT NULL default '0'"; $Q[] = "UPDATE exp_actions SET method = 'retrieve_password' WHERE class = 'Member' AND method = 'retreive_password'"; // Add keys to some tables $Q[] = "ALTER TABLE exp_weblog_titles ADD INDEX(weblog_id)"; $Q[] = "ALTER TABLE exp_weblog_titles ADD INDEX(author_id)"; $Q[] = "ALTER TABLE exp_category_posts ADD INDEX(entry_id)"; $Q[] = "ALTER TABLE exp_category_posts ADD INDEX(cat_id)"; $Q[] = "ALTER TABLE exp_weblogs ADD INDEX(cat_group)"; $Q[] = "ALTER TABLE exp_weblogs ADD INDEX(status_group)"; $Q[] = "ALTER TABLE exp_weblogs ADD INDEX(field_group)"; // Search module $Q[] = "INSERT INTO exp_modules (module_name, module_version, has_cp_backend) VALUES ('Search', '1.0', 'n')"; $Q[] = "INSERT INTO exp_actions (class, method) VALUES ('Search', 'do_search')"; // Email module $Q[] = "INSERT INTO exp_modules (module_name, module_version, has_cp_backend) VALUES ('Email', '1.0', 'n')"; $Q[] = "INSERT INTO exp_actions (class, method) VALUES ('Email', 'send_email')"; $Q[] = "CREATE TABLE IF NOT EXISTS exp_search ( search_id varchar(32) NOT NULL, search_date int(10) NOT NULL, member_id int(10) unsigned NOT NULL, ip_address varchar(16) NOT NULL, total_results int(6) NOT NULL, per_page tinyint(3) unsigned NOT NULL, query text NOT NULL, result_page varchar(70) NOT NULL, PRIMARY KEY `search_id` (`search_id`) )"; $Q[] = "CREATE TABLE IF NOT EXISTS exp_blacklisted ( blacklisted_type VARCHAR(20) NOT NULL, blacklisted_value TEXT NOT NULL )"; $Q[] = "CREATE TABLE IF NOT EXISTS exp_email_tracker ( email_id int(10) unsigned NOT NULL auto_increment, email_date int(10) unsigned default '0' NOT NULL, sender_ip varchar(16) NOT NULL, sender_email varchar(75) NOT NULL , sender_username varchar(50) NOT NULL , number_recipients int(4) unsigned default '1' NOT NULL, PRIMARY KEY `email_id` (`email_id`) )"; // Run the queries foreach ($Q as $sql) { $this->EE->db->query($sql); } /** ----------------------------------------- /** Update Member Groups with search prefs /** -----------------------------------------*/ $query = $this->EE->db->query("SELECT group_id FROM exp_member_groups ORDER BY group_id"); foreach ($query->result_array() as $row) { $flood = ($row['group_id'] == 1) ? '0' : '30'; $this->EE->db->query("UPDATE exp_member_groups SET can_search = 'y', search_flood_control = '$flood' WHERE group_id = '".$row['group_id']."'"); $st = ($row['group_id'] == 1) ? 'y' : 'n'; $this->EE->db->query("UPDATE exp_member_groups SET can_moderate_comments = '$st' WHERE group_id = '".$row['group_id']."'"); } /** ----------------------------------------- /** Fix pm member import problem /** -----------------------------------------*/ // Do we have custom fields? $query = $this->EE->db->query("SELECT COUNT(*) AS count FROM exp_member_data"); $md_exists = ($query->row('count') > 0) ? TRUE : FALSE; // We need to run through the member table and add two fields if they are missing $query = $this->EE->db->query("SELECT member_id FROM exp_members"); foreach ($query->result_array() as $row) { $member_id = $row['member_id']; $res = $this->EE->db->query("SELECT member_id FROM exp_member_homepage WHERE member_id = '$member_id'"); if ($res->num_rows() == 0) $this->EE->db->query("INSERT INTO exp_member_homepage (member_id) VALUES ('$member_id')"); if ($md_exists == TRUE) { $res = $this->EE->db->query("SELECT member_id FROM exp_member_data WHERE member_id = '$member_id'"); if ($resnum_rows() == 0) { $this->EE->db->query("INSERT INTO exp_member_data (member_id) VALUES ('$member_id')"); } } } /** ----------------------------------------- /** Update config file with new prefs /** -----------------------------------------*/ $data = array( 'word_separator' => '_', 'license_number' => '' ); $this->EE->config->_append_config_1x($data); return TRUE; }
echo "<br><br>A few suggestions : <br><br>\r\n\t\t\t<ul>\r\n\t\t\t\t<li>Check your spelling.</li>\r\n\t\t\t\t<li>Try more general words.</li>\r\n\t\t\t\t<li>Try different words that mean the same thing.</li>\r\n\t\t\t</ul>\t\r\n\t\t\t"; } ?> </table> <?php } else { // Searching Photos... ?> <table style="position:relative;top:20px"> <?php //get images liked by user $getlikes = mysql_query("SELECT image_id FROM likes WHERE user_id = '{$user_id}'"); while ($b = mysql_fetch_array($getlikes)) { $likes[] = $b['image_id']; } $results = search_results($keyword); $results_num = count($results); $i = 1; $limit = 2; $counter = 1; if ($results_num > 0) { echo "Your search for <b>" . $keyword . "</b> returned " . $results_num . " results.<br><br>"; echo "\r\n\t\t\tSort : "; if ($sort == "") { echo "<span id='sort1' style='color:#777;font-weight:bold'>Relevence</span>"; } else { echo "<span id='sort1'><a href='../search/index.php?q=" . $keyword . "&stype=1'>Relevence</a></span>"; } echo "<span class='divider' style='border-left:2px solid #d8d8d8;margin-left:10px'></span>"; if ($sort == "pop") { echo "<span id='sort2' style='position:absolute;margin-left:15px;color:#777;font-weight:bold'>Popularity</span>";
function search() { global $vars; try { if (isset($vars['searchstring'])) { return search_results(); } } catch (Exception $e) { message($e->getMessage()); } return search_form(); }
$ul = urlencode($l); $s = isset($_GET['start']) && is_numeric($_GET['start']) ? (int) $_GET['start'] : 0; $profile = isset($_GET['p']) && is_string($_GET['p']) ? $_GET['p'] : 'all'; $per_page = 10; $valid_profiles = array('all', 'local', 'manual', 'news', 'bugs', 'pear', 'pecl', 'talks'); $scope = in_array($profile, $valid_profiles) ? $profile : 'all'; $srch_host = "www.php.net"; $srch_rqst = "/ws.php?profile={$scope}&q={$uq}&lang={$ul}&results={$per_page}&start={$s}&mirror=" . trim(substr($MYSITE, 7), '/'); $url = "http://" . $srch_host . $srch_rqst; $data = fetch_contents($url); if (is_array($data)) { // FIXME: if (is_authenticated()) ... $comment = '<!-- ' . print_r($data, true) . '-->'; exit_with_pretty_error("Search error", "Internal error", "This mirror does not support searches, please report this error to <a href='/contact'>our webmasters</a>" . $comment); } $res = unserialize($data); // HTTP status line is passed on, signifies an error site_header('Search results', array("noindex", "current" => "FIXME")); if (!is_array($res)) { exit_with_pretty_error(null, 'Internal error', 'Please try again later'); } // No results for query if ($res['ResultSet']['totalResultsAvailable'] == 0) { echo '<h1>Perform an alternative search instead</h1>'; // TODO Research possible encoding issues google_cse($q); exit_with_pretty_error(null, 'No matches', 'No pages matched your query'); exit; } search_results($res, $q, $scope, $per_page, $s, $l); site_footer();
<br clear="left"/> <?php // Don't do a web search if the search term contains: // tp:// since we are seeing a lot of proxy attempts through the 404 handler // admin/ since these tend to be script-kiddie hack attempts if (strlen($notfound) > 2 && !strstr($notfound, 'tp://') && !strstr($notfound, 'admin/')) { $srch_rqst = "/ws.php?profile={$scope}&q=" . urlencode($notfound) . "&lang={$LANG}&results=10&start=0&mirror=" . trim(substr($MYSITE, 7), '/'); $url = "http://www.php.net" . $srch_rqst; $data = fetch_contents($url); if (!is_array($data)) { $res = unserialize($data); if (is_array($res) && $res['ResultSet']['totalResultsAvailable'] > 0) { // Ok, we got some results from the search backend echo "<br /><h1>Site Search Results</h1>\n"; search_results($res, $notfound, 'local', 10, 0, $LANG, false, false, true); echo '<br clear="left"/>'; } } } ?> <h1>Other forms of search</h1> <p> To search the string "<b><?php echo $notfound; ?> </b>" using other options, try searching: </p> <ul id="quickref_other">
</fieldset> </div> <div id="tab_search"> <?php echo TEXT_KEYWORD; ?> <br /> <?php echo html_form('search_form', FILENAME_DEFAULT, 'module=phreehelp&page=main&fID=left'); ?> <?php echo html_input_field('search_text', $search_text); ?> <?php echo html_icon('actions/system-search.png', TEXT_SEARCH, 'small', 'style="cursor:pointer;" onclick="javascript:document.search_form.submit()"') . "\n"; ?> </form> <br /> <?php if ($search_text) { echo TEXT_SEARCH_RESULTS . '<br />' . chr(10); echo '<fieldset>' . chr(10); echo search_results($search_text) . chr(10); echo '</fieldset>' . chr(10); } ?> </div> </div> </body> </html>
<?php if (isset($_POST['keywords'])) { $keywords = mysql_real_escape_string(htmlentities(trim($_POST['keywords']))); $word = strtoupper($_POST['keywords']); if (empty($keywords)) { $errors[] = 'Please Enter a search term'; } elseif (strlen($keywords) < 3) { $errors[] = 'Your search term must be three or more characters'; } elseif (search_results($keywords) === false) { $errors[] = 'Your search for ' . $keywords . ' returned no results'; } /*********************************************Main Logic ******************/ if (empty($errors)) { $where = ""; $wheres = ""; $keywords = preg_split('/[\\s]+/', $keywords); $total_keywords = count($keywords); foreach ($keywords as $key => $keyword) { $where .= "`pname` LIKE '%{$keyword}%'"; if ($key != $total_keywords - 1) { $where .= " AND "; } } foreach ($keywords as $keyw => $keywordw) { $wheres .= " `cat_title` LIKE '%{$keywordw}%'"; if ($keyw != $total_keywords - 1) { $wheres .= " AND "; } } $results = "SELECT `p_id`,`pname`,`pprice`,`pimage` FROM `products` WHERE {$where}";
get_header(); if ($_GET[id]) { include 'single.php'; } else { ?> <div id="content"> <h2>Todos los usuarios:</h2> <?php global $wpdb; $url = get_option('home'); if ($_GET['area']) { $users = $wpdb->get_col("SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key='area' and meta_value='" . $_GET['area'] . "' ORDER BY meta_value ASC"); } elseif ($_GET['unidad']) { $users = $wpdb->get_col("SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key='unidad' and meta_value='" . $_GET['unidad'] . "' ORDER BY meta_value ASC"); } elseif ($result = search_results()) { $list = ""; $last = count($result) - 1; $i = 0; reset($result); $users = array(); foreach ($result as $user) { array_push($users, $user['ID']); } } else { $inc = 30; if (!$_GET['pag']) { $i = 0; } else { $i = $inc * (int) $_GET['pag']; }
echo TEXT_KEYWORD; ?> <br /> <form name="search_form" method="post" action="leftframe.php"> <input type="text" name="search_field" value="<?php echo $search_field; ?> "> <input type="image" src="css/<?php echo DEFAULT_STYLE; ?> /images/system-search.png" border="0" alt="Search"> </form> <?php echo TEXT_SEARCH_RESULTS; ?> <br /> <fieldset> <?php echo search_results($search_field); ?> </fieldset> </div> <?php // Post-processing ?> </body> </html>
function search_alerts() { global $dbtable_prefix, $tplvars; $skin = get_default_skin_dir(); require_once _BASEPATH_ . '/includes/search_functions.inc.php'; require_once _BASEPATH_ . '/includes/access_levels.inc.php'; // require_once _BASEPATH_.'/includes/user_functions.inc.php'; $tplvars['tplrelpath'] = _BASEPATH_ . '/skins_site/' . $skin; $config['limit_results'] = 5; $query_strlen = 20000; $query = "SELECT a.`search_id`,a.`fk_user_id`,a.`title`,a.`search`,a.`search_qs`,a.`alert_last_id`,UNIX_TIMESTAMP(a.`alert_last_sent`) as `alert_last_sent`,b.`membership`,c.`_user` as `user`,b.`email` FROM `{$dbtable_prefix}user_searches` a,`" . USER_ACCOUNTS_TABLE . "` b,`{$dbtable_prefix}user_profiles` c WHERE a.`fk_user_id`=b.`" . USER_ACCOUNT_ID . "` AND a.`fk_user_id`=c.`fk_user_id` AND a.`alert`=1"; if (!($res = @mysql_query($query))) { trigger_error(mysql_error(), E_USER_ERROR); } if (mysql_num_rows($res)) { $tpl = new phemplate(_BASEPATH_ . '/skins_site/' . $skin . '/emails/', 'remove_nonjs'); $tpl->set_file('temp', 'search_alert.html'); $tpl->set_var('tplvars', $tplvars); $subject = sprintf($GLOBALS['_lang'][217], _SITENAME_); $subject = sanitize_and_format($subject, TYPE_STRING, $GLOBALS['__field2format'][FIELD_TEXTFIELD]); require_once _BASEPATH_ . '/includes/classes/user_cache.class.php'; $user_cache = new user_cache($skin); $insert = "INSERT INTO `{$dbtable_prefix}queue_email` (`to`,`subject`,`message_body`) VALUES "; $iquery = $insert; $alert_intervals = array(); $now = time(); while ($rsrow = mysql_fetch_assoc($res)) { if (!isset($alert_intervals[$rsrow['fk_user_id']])) { $alert_intervals[$rsrow['fk_user_id']] = get_user_settings($rsrow['fk_user_id'], 'def_user_prefs', 'send_alert_interval') * 86400; } if ((int) $now - (int) $rsrow['alert_last_sent'] >= (int) $alert_intervals[$rsrow['fk_user_id']]) { $output = array(); $rsrow['search'] = unserialize($rsrow['search']); $rsrow['search']['min_user_id'] = $rsrow['alert_last_id']; $user_ids = search_results($rsrow['search'], $rsrow['membership']); if (!empty($user_ids)) { $GLOBALS['_list_of_online_members'] = get_online_ids(); $last_user_id = 0; for ($i = 0; isset($user_ids[$i]); ++$i) { if ($user_ids[$i] > $last_user_id) { $last_user_id = $user_ids[$i]; } } $user_ids = array_slice($user_ids, 0, $config['limit_results']); // last activity only for not online members $temp = array(); $inject_by_uid = array(); for ($i = 0; isset($user_ids[$i]); ++$i) { if (!isset($GLOBALS['_list_of_online_members'][$user_ids[$i]])) { $temp[] = $user_ids[$i]; } else { $inject_by_uid[$user_ids[$i]] = array('last_online' => $GLOBALS['_lang'][153]); } } if (!empty($temp)) { $time = mktime(gmdate('H'), gmdate('i'), gmdate('s'), gmdate('m'), gmdate('d'), gmdate('Y')); $query = "SELECT `" . USER_ACCOUNT_ID . "` as `uid`,UNIX_TIMESTAMP(`last_activity`) as `last_activity` FROM `" . USER_ACCOUNTS_TABLE . "` WHERE `" . USER_ACCOUNT_ID . "` IN ('" . join("','", $temp) . "')"; if (!($res2 = @mysql_query($query))) { trigger_error(mysql_error(), E_USER_ERROR); } while ($rsrow2 = mysql_fetch_assoc($res2)) { $rsrow2['last_activity'] = $time - $rsrow2['last_activity']; if ($rsrow2['last_activity'] < 86400) { $inject_by_uid[$rsrow2['uid']] = array('last_online' => $GLOBALS['_lang'][154]); } elseif ($rsrow2['last_activity'] < 172800) { $inject_by_uid[$rsrow2['uid']] = array('last_online' => $GLOBALS['_lang'][155]); } elseif ($rsrow2['last_activity'] < 604800) { $inject_by_uid[$rsrow2['uid']] = array('last_online' => $GLOBALS['_lang'][156]); } elseif ($rsrow2['last_activity'] < 2419200) { $inject_by_uid[$rsrow2['uid']] = array('last_online' => $GLOBALS['_lang'][157]); } else { $inject_by_uid[$rsrow2['uid']] = array('last_online' => $GLOBALS['_lang'][158]); } } } $cell_css_classes = array(); for ($i = 0; isset($user_ids[$i]); ++$i) { if (isset($GLOBALS['_list_of_online_members'][$user_ids[$i]])) { $cell_css_classes[$i] = 'is_online'; } } $output['results'] = smart_table($user_cache->get_cache_array($user_ids, 'result_user', $inject_by_uid), 5, 'list_view', $cell_css_classes); $output['title'] = sanitize_and_format($rsrow['title'], TYPE_STRING, $GLOBALS['__field2format'][TEXT_DB2DISPLAY]); $output['search_qs'] = $rsrow['search_qs']; $output['user'] = $rsrow['user']; $tpl->set_var('output', $output); $message_body = $tpl->process('', 'temp', TPL_LOOP | TPL_OPTLOOP | TPL_OPTIONAL | TPL_FINISH); $message_body = sanitize_and_format($message_body, TYPE_STRING, $GLOBALS['__field2format'][FIELD_TEXTAREA]); if (strlen($iquery) > $query_strlen) { $iquery = substr($iquery, 0, -1); if (!($res2 = @mysql_query($iquery))) { trigger_error(mysql_error(), E_USER_ERROR); } $iquery = $insert; } $iquery .= "('" . $rsrow['email'] . "','{$subject}','{$message_body}'),"; $query = "UPDATE `{$dbtable_prefix}user_searches` SET `alert_last_id`={$last_user_id},`alert_last_sent`=now() WHERE `search_id`=" . $rsrow['search_id']; @mysql_query($query); } } } if ($iquery != $insert) { $iquery = substr($iquery, 0, -1); if (!($res2 = @mysql_query($iquery))) { trigger_error(mysql_error(), E_USER_ERROR); } } } return true; }