function search($kw) { global $channels; $channel = $channels[$kw]; if ($channel) { return search_channel($channel); } else { return search_query($kw); } }
/** * Search template for the Now Reading plugin. * * @package Suffusion * @subpackage NowReading */ get_header(); ?> <div id="main-col"> <?php suffusion_before_begin_content(); ?> <div id="content"> <?php suffusion_after_begin_content(); ?> <div class="post fix nr-post"> <h1 class="posttitle">Search Results for <?php search_query(); ?></h1> <div class="bookdata fix"> <?php if( can_now_reading_admin() ) { ?> <div class="manage"> <span class="icon"> </span> <a href="<?php manage_library_url(); ?>"><?php _e('Manage Books', 'suffusion');?></a> </div> <?php } ?> </div> <div class="booklisting"> <?php
echo ' </div><div class="clear"></div></dd>'; } echo ' </dl> <p class="c">' . show_sbutton("Utfør søk") . '</p> </div> </form> </div>'; // søke? if (isset($_GET['qs'])) { $title_search = requestval("qs"); $text_search = requestval("qt"); // finn ut delene av spørringen $title_parts = search_query($title_search); $text_parts = search_query($text_search); // sett opp søkespørringen $search_title = false; $search_text_topic = false; $search_text_reply = false; if (count($title_parts[0]) > 0) { $search_title = " AND ft_title" . implode(" AND ft_title", $title_parts[0]); } if (count($text_parts[0]) > 0) { $search_text_topic = " AND ft_text" . implode(" AND ft_text", $text_parts[0]); $search_text_reply = " AND fr.fr_text" . implode(" AND fr.fr_text", $text_parts[0]); } if ($search_title === false && $search_text_topic === false && $search_text_reply === false) { $search_text_topic = ""; $search_text_reply = ""; }
/** * Nodesøk */ protected function node_search($cid, $dest, $search) { $search = utf8_decode($search); // hent all informasjon $result = \Kofradia\DB::get()->query("SELECT node_id, node_parent_node_id, node_title, node_type, node_params, node_show_menu, node_expand_menu, node_enabled, node_priority, node_change FROM nodes"); $nodes = array(); while ($row = $result->fetch()) { $row['params'] = new params($row['node_params']); $row['enheter'] = array(); $row['plain'] = ""; $nodes[$row['node_id']] = $row; } if (count($nodes) == 0) { $this->msg($cid, $dest, "Ingen siden eksisterer."); return; } // sett opp søkekriteriene $search_list = search_query($search); $search_list = $search_list[1]; $search_list2 = $search_list; // for delvise treff foreach ($search_list as &$q) { $q = '/(\\P{L}|^)' . preg_replace(array('/([\\/\\\\\\[\\]()$.+?|{}])/', '/\\*\\*+/', '/\\*/'), array('\\\\$1', '*', '\\S*'), $q) . '(\\P{L}|$)/i'; } // sett opp søkeliste hvor vi søker med * på slutten av ordene foreach ($search_list2 as &$q) { $q = '/' . preg_replace(array('/([\\/\\\\\\[\\]()$.+?|{}])/', '/\\*\\*+/', '/\\*/'), array('\\\\$1', '*', '\\S*'), $q) . '/i'; } // hent alle enhetene $result = \Kofradia\DB::get()->query("SELECT ni_id, ni_node_id, ni_type, nir_content, nir_params, nir_time FROM nodes_items LEFT JOIN nodes_items_rev ON nir_id = ni_nir_id WHERE ni_enabled != 0 AND ni_deleted = 0 ORDER BY ni_priority"); while ($row = $result->fetch()) { if (!isset($nodes[$row['ni_node_id']])) { continue; } $data = nodes::content_build($row); $nodes[$row['ni_node_id']]['enheter'][] = $data; // bygg opp plain tekst $plain = preg_replace("/<br[^\\/>]*\\/?>/", "\n", $data); $plain = preg_replace("/(<\\/?(h[1-6]|p)[^>]*>)/", "\n\\1", $plain); $plain = html_entity_decode(strip_tags($plain)); $plain = preg_replace("/(^ +| +\$|\\r)/m", "", $plain); #$plain = preg_replace("/(?<![!,.\\n ])\\n/", " ", $plain); $plain = preg_replace("/\\n/", " ", $plain); $plain = preg_replace("/ +/", " ", $plain); $plain = trim($plain); $nodes[$row['ni_node_id']]['plain'] .= $plain . " "; } // sett opp riktige referanser og lag tree $sub = array(); foreach (nodes::$nodes as $row) { if ($row['node_enabled'] != 0) { $sub[$row['node_parent_node_id']][] = $row['node_id']; } } $tree = new tree($sub); $data = $tree->generate(0, NULL, $nodes); // sett opp paths $paths = array(); $path = array(); $number = 1; foreach ($data as $row) { for (; $row['number'] <= $number; $number--) { // fjern fra path array_pop($path); } if ($row['number'] >= $number) { // legg til i path $path[] = $row['data']['node_title']; } $paths[$row['data']['node_id']] = $path; $number = $row['number']; } // sett opp søkeresultater $result = array(); $points = array(); $points2 = array(); foreach ($data as $row) { if ($row['data']['node_type'] != "container") { continue; } // utfør søk $found = true; $p = 0; $p2 = 0; foreach ($search_list as $key => $regex) { $ok = false; $matches = null; // søk i teksten if (preg_match_all($regex, $row['data']['plain'], $matches)) { $ok = true; $p += count($matches[0]); } if (preg_match_all($search_list2[$key], $row['data']['plain'], $matches)) { $ok = true; $p2 += count($matches[0]); } // søk i tittelen if (preg_match_all($regex, $row['data']['node_title'], $matches)) { $ok = true; $p += count($matches[0]); } if (preg_match_all($search_list2[$key], $row['data']['node_title'], $matches)) { $ok = true; $p2 += count($matches[0]); } if ($ok) { continue; } $found = false; break; } // fant? if ($found) { $result[] = $row; $points[] = $p; $points2[] = $p2; } } // vis søkeresultater if (count($result) == 0) { $this->msg($cid, $dest, "Ingen treff ble funnet."); } // sorter søkeresultatene array_multisort($points, SORT_DESC, SORT_NUMERIC, $points2, SORT_DESC, SORT_NUMERIC, $result); $this->msg($cid, $dest, count($result) . " treff ble funnet - " . ess::$s['path'] . '/node/search?q=' . urlencode($search)); $i = 0; foreach ($result as $key => $row) { if ($i++ == 3) { break; } $partial = $points2[$key] - $points[$key]; if ($row['data']['node_id'] == nodes::$default_node) { $url = ess::$s['path'] . '/node'; } else { $url = ess::$s['path'] . '/node/' . $row['data']['node_id']; } $m = array(); if ($points[$key] > 0) { $m[] = $points[$key] . ' treff'; } if ($partial > 0) { $m[] = fwords("%d delvis treff", "%d delvise treff", $partial); } $this->msg($cid, $dest, implode(", ", $m) . ": " . implode(" -> ", $paths[$row['data']['node_id']]) . " {$url}"); } }
<div id="main-col"> <?php suffusion_before_begin_content(); ?> <div id="content"> <?php suffusion_after_begin_content(); ?> <article <?php post_class('post nr-post'); ?> > <header class="post-header"> <h1 class="posttitle">Search Results for <?php search_query(); ?> </h1> </header> <div class="bookdata fix"> <?php if (can_now_reading_admin()) { ?> <div class="manage"> <span class="icon"> </span> <a href="<?php manage_library_url(); ?> "><?php _e('Manage Books', 'suffusion'); ?>
<div id="content" class="narrowcolumn primary now-reading"> <div class="post"> <?php if( can_now_reading_admin() ) : ?> <p>Admin: » <a href="<?php manage_library_url() ?>">Manage Books</a></p> <?php endif; ?> <p><a href="<?php library_url() ?>">← Back to library</a></p> <?php library_search_form() ?> <p>Search results for <?php search_query(); ?>:</p> <?php if( have_books("status=all&num=-1&search={$GLOBALS['query']}") ) : ?> <ul> <?php while( have_books("status=all&num=-1&search={$GLOBALS['query']}") ) : the_book(); ?> <li><a href="<?php book_permalink() ?>"><?php book_title() ?></a> by <a href="<?php book_author_permalink() ?>"><?php book_author() ?></a></li> <?php endwhile; ?> </ul> <?php else : ?>
/** Søkefunksjon */ public static function action_search() { access::need("crewet"); ess::$b->page->add_title("Søk"); // hvem som skal ha kunnet skrevet det man søker på $search_from = array(1 => array("Alle", ""), array("Meg selv", " AND sum_up_id = up_ref.up_id"), array("Andre", " AND sum_up_id != up_ref.up_id"), array('Spesifiser', NULL, array())); $id = requestval("f"); $search_from_id = isset($search_from[$id]) ? $id : 1; // sjekk etter spillere? if ($search_from_id == 4) { $name = trim(postval("up")); // sett opp brukernavnene $names = explode(",", $name); foreach ($names as $name) { $name = trim($name); if (empty($name)) { continue; } if (preg_match('/^[0-9a-zA-Z\\-_ ]+$/Du', $name)) { $search_from[4][2][] = $name; } else { ess::$b->page->add_message('Ugyldig spillernavn: <b>' . htmlspecialchars($name) . '</b>.', "error"); } } if (count($search_from[4][2]) == 0) { $search_from_id = 1; } else { $search_from[4][1] = " AND up_sum.up_name IN (" . implode(",", array_map(array(ess::$b->db, "quote"), $search_from[4][2])) . ")"; } } // søke kun blant den som sendte inn henvendelsen eller de som svarte? // MERK: tar ikke høyde for at brukere skifter spiller $search_by = array(1 => array("Alle", ""), array("Innsender", " AND sum_up_id = su_up_id"), array("Crewet", " AND sum_up_id != su_up_id")); $id = requestval("fb"); $search_by_id = isset($search_by[$id]) ? $id : 1; // kategorier $search_kat = array(); foreach (self::$kategorier as $info) { $search_kat[$info['id']] = array($info['name'], "su_category = {$info['id']}"); } $search_kat_active = array(); $search_kat_query = array(); foreach ($_REQUEST as $key => $dummy) { $match = false; if (preg_match("/^k(\\d+)\$/Du", $key, $match)) { if (isset($search_kat[$match[1]])) { $search_kat_active[] = $match[1]; $search_kat_query[] = $search_kat[$match[1]][1]; } } } if (count($search_kat_query) > 0 && count($search_kat_query) != count($search_kat)) { $search_kat_query = " AND (" . implode(" OR ", $search_kat_query) . ")"; $more = true; } else { if (count($search_kat_active) == 0) { $search_kat_active = array_keys($search_kat); } $search_kat_query = ""; } // sortering $sort = new sorts("sort"); $sort->append("asc", "Avsender", "up_name, sum_time DESC"); $sort->append("desc", "Avsender", "up_name DESC, sum_time DESC"); $sort->append("asc", "Tittel", "su_title, sum_time DESC"); $sort->append("desc", "Tittel", "su_title DESC, sum_time DESC"); #$sort->append("asc", "Innhold", "id_text"); #$sort->append("desc", "Innhold", "id_text DESC"); $sort->append("asc", "Tid", "sum_time"); $sort->append("desc", "Tid", "sum_time DESC"); $sort->set_active(postval("sort"), 5); // søkeskjema echo ' <h1>Søk i support</h1> <p class="h_right"><a href="./">Tilbake</a></p> <form action="" method="post"> <div class="section" style="width: 410px; margin-left: auto; margin-right: auto"> <h2>Søk</h2> <dl class="dl_20 dl_2x"> <dt>Tittel</dt> <dd><input type="text" name="title" value="' . htmlspecialchars(postval("title")) . '" class="styled w150" /></dd> <dt>Innhold</dt> <dd><input type="text" name="text" value="' . htmlspecialchars(postval("text")) . '" class="styled w300" /></dd> <dt>Av?</dt> <dd>'; $i = 0; foreach ($search_from as $key => $item) { if (++$i == count($search_from)) { break; } echo ' <input type="radio" id="f_' . $key . '" name="f" value="' . $key . '"' . ($search_from_id == $key ? ' checked="checked"' : '') . ' /><label for="f_' . $key . '"> ' . htmlspecialchars($item[0]) . '</label>'; } echo ' </dd> <dt> </dt> <dd><input type="radio" id="f_' . $key . '" name="f" value="' . $key . '"' . ($search_from_id == $key ? ' checked="checked"' : '') . ' onclick="$(\'u_name\').focus()" /><label for="f_' . $key . '"> Spesifiser: </label><input type="text" name="up" value="' . htmlspecialchars(postval("up")) . '" class="styled w100" id="u_name" onfocus="$(\'f_' . $key . '\').checked=true" /></dd> <dt>Hvilke meldinger?</dt> <dd>'; foreach ($search_by as $key => $item) { echo ' <input type="radio" id="fb_' . $key . '" name="fb" value="' . $key . '"' . ($search_by_id == $key ? ' checked="checked"' : '') . ' /><label for="fb_' . $key . '"> ' . htmlspecialchars($item[0]) . '</label>'; } echo ' </dd> <dt>Kategorier</dt> <dd>'; $i = 0; foreach ($search_kat as $key => $item) { if ($i++ > 0) { echo '<br />'; } echo ' <input type="checkbox" id="kat?' . $key . '" name="k' . $key . '" value="1"' . (in_array($key, $search_kat_active) ? ' checked="checked"' : '') . ' /><label for="kat_' . $key . '"> ' . htmlspecialchars($item[0]) . '</label>'; } echo ' </dd> </dl> <h3 class="c"> ' . show_sbutton("Utfør søk", 'name="search"') . ' </h3> </div> </form>'; // søke? if (isset($_POST['search'])) { $title_search = postval("title"); $text_search = postval("text"); // finn ut delene av spørringen $title_parts = search_query($title_search); $text_parts = search_query($text_search); if (count($title_parts[0]) == 0 && count($text_parts[0]) == 0 && $search_from_id != 4 && $search_kat_query == "") { echo ' <h2>Søkeresultater</h2> <p>Ingen søkekriterier.</p>'; } else { // sett opp søkespørringen $search = ""; if (count($title_parts[0]) > 0) { $search .= " AND su_title" . implode(" AND su_title", $title_parts[0]); } if (count($text_parts[0]) > 0) { $search .= " AND sum_text" . implode(" AND sum_text", $text_parts[0]); } // sortering $sort_info = $sort->active(); // sidetall - hent henvendelsene på denne siden $pagei = new pagei(pagei::ACTIVE_POST, "side", pagei::PER_PAGE, 50); $result = $pagei->query("\n\t\t\t\t\tSELECT su_id, su_up_id, su_category, su_title, su_time, su_solved, sum_id, sum_up_id, sum_time, sum_text, up_sum.up_name, up_sum.up_access_level\n\t\t\t\t\tFROM support\n\t\t\t\t\t\tJOIN support_messages ON sum_su_id = su_id\n\t\t\t\t\t\tJOIN users_players up_sum ON up_sum.up_id = sum_up_id,\n\t\t\t\t\t\tusers_players up_ref\n\t\t\t\t\tWHERE up_ref.up_u_id = " . login::$user->id . "{$search_from[$search_from_id][1]}{$search_by[$search_by_id][1]}{$search_kat_query}{$search}\n\t\t\t\t\tGROUP BY sum_id" . (count($text_parts[0]) == 0 && $search_from_id == 1 ? ", su_id" : "") . "\n\t\t\t\t\tORDER BY {$sort_info['params']}", array_merge($title_parts[2], $text_parts[2])); $info = array(); foreach ($title_parts[1] as $part) { $info[] = '<b>Tittel:</b> ' . htmlspecialchars($part); } foreach ($text_parts[1] as $part) { $info[] = '<b>Innhold:</b> ' . htmlspecialchars($part); } if ($search_from_id == 4) { if (count($search_from[4][2]) == 1) { $info[] = '<b>Spiller:</b> <user="******" />'; } else { $u = array(); foreach ($search_from[4][2] as $name) { $u[] = '<user="******" />'; } $info[] = '<b>Spiller:</b> ' . implode(" eller ", $u); } } $info = implode(" ", $info); echo ' <h2>Søkeresultater</h2> <p>Søkekriterier: ' . $info . '</p>'; // fant vi noe? if ($pagei->total == 0) { echo ' <p>Fant ingen treff.</p>'; } else { echo ' <p>Antall treff: <b>' . $pagei->total . '</b></p> <form action="" method="post">'; foreach ($_POST as $key => $value) { if ($key == "side" || $key == "sort") { continue; } echo ' <input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />'; } echo ' <input type="hidden" name="sort" id="sort_sort" value="' . $sort->active . '" /> <table class="table' . ($pagei->pages == 1 ? ' tablemb' : '') . '" width="100%"> <thead> <tr> <th><span class="tools_r">' . $sort->show_button(0, 1) . '</span> Spiller</th> <th><span class="tools_r">' . $sort->show_button(2, 3) . '</span> Henvendelse</th> <th><span class="tools_r">Tekst</th> <th><span class="tools_r">' . $sort->show_button(4, 5) . '</span> Tid</th> </tr> </thead> <tbody>'; ess::$b->page->add_css(' .su_not_solved { color: #FF0000; font-weight: bold } .sum_up { white-space: nowrap; width: 100px } .su_time { text-align: center; white-space: nowrap; color: #888888; width: 100px }'); $i = 0; while ($row = $result->fetch()) { $content = trim(strip_tags(game::bb_to_html($row['sum_text']))); $length = mb_strlen($content); $max = 60; if (mb_strlen($content) > $max) { $content = mb_substr($content, 0, $max - 4) . " ..."; } echo ' <tr' . (++$i % 2 == 0 ? ' class="color"' : '') . '> <td class="sum_up">' . game::profile_link($row['sum_up_id'], $row['up_name'], $row['up_access_level']) . '</td> <td><a href="./?a=show&su_id=' . $row['su_id'] . '">' . htmlspecialchars($row['su_title']) . '</a>' . ($row['su_solved'] == 0 ? ' <span class="su_not_solved">(Uløst)</span>' : '') . '</td> <td class="dark">' . htmlspecialchars($content) . ' (' . $length . ' tegn)</td> <td class="su_time">' . ess::$b->date->get($row['sum_time'])->format() . '</td> </tr>'; } echo ' </tbody> </table>'; // flere sider? if ($pagei->pages > 1) { echo ' <div class="hr"></div> <p class="c"> ' . $pagei->pagenumbers("input") . ' </p>'; } echo ' </form>'; } } } }
/** * Søke i alle nodene */ protected static function search() { ess::$b->page->add_title("Søk"); nodes::add_node(0, "Søk", ess::$s['relative_path'] . "/node/search"); // hindre søkemotorer i å indeksere denne siden om man har søkt etter noe if (isset($_GET['q'])) { ess::$b->page->add_head('<meta name="robots" content="noindex" />'); } echo ' <h1>Søk</h1> <p>Denne siden lar deg søke gjennom alt innholdet som er synlig i hjelpesidene.</p>'; // hent all informasjon $result = \Kofradia\DB::get()->query("SELECT node_id, node_parent_node_id, node_title, node_type, node_params, node_show_menu, node_expand_menu, node_enabled, node_priority, node_change FROM nodes"); $nodes = array(); while ($row = $result->fetch()) { $row['params'] = new params($row['node_params']); $row['enheter'] = array(); $row['plain'] = ""; $nodes[$row['node_id']] = $row; } if (count($nodes) == 0) { echo ' <p>Ingen sider er opprettet som det er mulig å søke gjennom.</p>'; } else { // skal vi søke? $search = null; if (isset($_GET['q'])) { $search = trim($_GET['q']); if ($search == "") { $search = false; } } // vise søkeboks ess::$b->page->add_js_domready('$("searchq").focus();'); echo ' <div style="background-color: #222; padding: 1px 10px; margin: 1em 0"> <form action="" method="get"> <p class="c"> <strong>Søkestreng</strong>: <input type="text" class="styled w200" name="q" id="searchq" value="' . htmlspecialchars(getval("q")) . '" /> ' . show_sbutton("Utfør søk") . ' <a href="&rpath;/node/61">Hjelp</a> </p>' . ($search === false ? ' <p class="c">Du må fylle ut et søkekriterie.</p>' : '') . ' </form> </div>'; // søke? if (is_string($search)) { // sett opp søkekriteriene $search_list = search_query($search); $search_list = $search_list[1]; $search_list2 = $search_list; // for delvise treff foreach ($search_list as &$q) { $q = '/(\\P{L}|^)' . preg_replace(array('/([\\/\\\\\\[\\]()$.+?|{}])/u', '/\\*\\*+/u', '/\\*/u'), array('\\\\$1', '*', '\\S*'), $q) . '(\\P{L}|$)/i'; } // sett opp søkeliste hvor vi søker med * på slutten av ordene foreach ($search_list2 as &$q) { $q = '/' . preg_replace(array('/([\\/\\\\\\[\\]()$.+?|{}])/u', '/\\*\\*+/u', '/\\*/u'), array('\\\\$1', '*', '\\S*'), $q) . '/i'; } // gå over alle sidene og finn treff self::search_handle($search_list, $search_list2, $nodes); } } self::load_page(); }
<input type="submit" name="sub" value="Submit" /> </div> </form> <?php //search jobs by filling various fields if ($_REQUEST['sub']) { extract($_POST); if (empty($keyword) and empty($loc) and empty($cat) and empty($salary)) { $error = "please fill something"; } else { echo "<hr /><br>"; $search_query = search_query($loc, $salary, $keyword, $cat); view_filtered_jobs($search_query); } } elseif ($cat_id = $_REQUEST['cat_id']) { $search_query = search_query('', '', '', $cat_id); $error = view_filtered_jobs($search_query); } //error if (!empty($error)) { echo "<span class=error>{$error}</span>"; } if ($con = $_REQUEST['con']) { include $con . ".php"; } ?> </div> <div id=blocks> <div class=block> <h2>Premium Jobs</h2>