Hallo zusammen,
ich habe mir folgende Datei geschrieben:
Alles anzeigen
Das funktioniert auch ohne Probleme, allerdings nur wenn keine Sonderzeichen vorkommen. Ich habe das nun so versucht zu lösen:
und
Brachte aber beides keinen Erfolg. Kann jemand weiterhelfen?
ich habe mir folgende Datei geschrieben:
Quellcode
- <?php
- /*
- ____ _
- / __ \ | |
- | | | |_ __ ___ _ __ ___ ___ __ _ _ __ ___| |__
- | | | | '_ \ / _ \ '_ \/ __|/ _ \/ _` | '__/ __| '_ \
- | |__| | |_) | __/ | | \__ \ __/ (_| | | | (__| | | |
- \____/| .__/ \___|_| |_|___/\___|\__,_|_| \___|_| |_|
- | | v0.2
- |_|
- Copyright : Sumale.nin
- Kontakt : ben88b@googlemail.com
- Credits : V@no
- */
- $main_template = 0;
- $nozip = 1;
- $nocache = 1;
- define('GET_CACHES', (isset($_GET['s'])));
- define('ROOT_PATH', '../');
- include(ROOT_PATH.'global.php');
- $url = "http://".$_SERVER['HTTP_HOST'].str_replace("//", "/", "/".dirname($PHP_SELF)."/")."";
- $favicon = ROOT_PATH."favicon.ico";
- function get_opensearch_favicon($favicon) {
- global $config;
- if (file_exists($favicon)) {
- return $favicon;
- }
- else {
- return ROOT_PATH."/opensearch/img/opensearch_favicon.png";
- }
- }
- /*
- Einstellungen > Start
- */
- $url_suggestions = $url."opensearch.php?s=";
- $num = 10;
- $show_num_results = 1;
- /*
- Einstellungen > Ende
- */
- if (isset($HTTP_GET_VARS['s']))
- {
- require(ROOT_PATH.'includes/sessions.php');
- $user_access = get_permission();
- include(ROOT_PATH.'includes/search_utils.php');
- $r = "";
- $n = "";
- if (strlen($HTTP_GET_VARS['s']))
- {
- $cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
- $cat_id_sql = $cat_id_sql !== 0 ? "AND i.cat_id NOT IN (".$cat_id_sql.")" : "";
- $sql = "SELECT DISTINCT w.word_text".($show_num_results ? ", COUNT(w.word_text) as num" : "")."
- FROM (".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m)
- LEFT JOIN ".IMAGES_TABLE." i ON (i.image_id = m.image_id)
- WHERE w.word_text LIKE '".addslashes(str_replace("*", "%", $HTTP_GET_VARS['s']))."%'
- AND m.word_id = w.word_id $cat_id_sql
- GROUP BY w.word_text
- ".($show_num_results ? "ORDER BY num DESC" : "")."
- LIMIT $num";
- $result = $site_db->query($sql);
- while($row = $site_db->fetch_array($result))
- {
- $r .= ($r?',':'').'"'.str_replace('"', """, stripslashes($row['word_text'])).'"';
- if ($show_num_results)
- $n .= ($n?',':'').'"'.number_format($row['num']).' '.$lang['opensearch_results'].'"';
- }
- }
- echo '["'.str_replace('"', """, stripslashes($HTTP_GET_VARS['s'])).'",['.$r.'], ['.$n.']]';
- }
- elseif (isset($HTTP_GET_VARS['xml']))
- {
- header ("content-type: text/xml");
- $array = array("x-ico", "gif", "jpg", "png");
- echo ' <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">\n';
- echo ' <ShortName>'.htmlspecialchars($config['site_name'], ENT_QUOTES).'</ShortName>\n';
- echo ' <Description>'.$lang['search'].'</Description>\n';
- echo ' <InputEncoding>'.$lang['charset'].'</InputEncoding>\n';
- $favicon_info = getimagesize(get_opensearch_favicon($favicon));
- if (!isset($favicon_info[2]) || !isset($array[$favicon_info[2]]))
- $favicon_info[2] = 0;
- echo ' <Image width="16" height="16" type="image/'.$array[$favicon_info[2]].'">'.$url.get_opensearch_favicon($favicon).'</Image>\n';
- echo ' <Url type="text/html" method="get" template="'.$url.'search.php?search_keywords={searchTerms}"/>\n';
- if (isset($url_suggestions) && $url_suggestions)
- {
- echo ' <Url type="application/x-suggestions+json" template="'.$url_suggestions.'{searchTerms}"/>\n';
- }
- echo ' </OpenSearchDescription>';
- }
- elseif (isset($HTTP_GET_VARS['js']))
- {
- echo '
- function addEngine()
- {
- if (window.external && ("AddSearchProvider" in window.external))
- {
- window.external.AddSearchProvider("'.$url.'opensearch.php?xml" );
- }
- else if (window.sidebar && ("addSearchEngine" in window.sidebar))
- {
- window.sidebar.addSearchEngine("'.$url.'opensearch.php?xml",
- "'.$url.get_opensearch_favicon($favicon).'",
- "opensearch.xml",
- "(c) by Sumale.nin"
- );
- }
- else
- {
- alert("'.$lang['opensearch_support'].'");
- }
- }
- ';
- }
- ?>
Das funktioniert auch ohne Probleme, allerdings nur wenn keine Sonderzeichen vorkommen. Ich habe das nun so versucht zu lösen:
und
Brachte aber beides keinen Erfolg. Kann jemand weiterhelfen?