-<!DOCTYPE html>
-
-<!--
+<?php
+/*
consearch
Copyright (C) 2015 Felix Kästner, consearch @ f p u n k t k . de
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/.
--->
+*/
-<?php
$dse = "";
if ( isset($_GET['dse']) and preg_match('/^[0-9a-z]{1,5}$/', $_GET['dse']) === 1 ) { // TODO: prevent injection, check whether dse is a valid searchengine
$dse = $_GET['dse'];
}
-?>
+if ( isset($_GET['get']) and $_GET['get'] === "opensearchdescription" ) {
+ echo '<?xml version="1.0" encoding="UTF-8"?>
+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+<ShortName>consearch';
+ if ( $dse ) { echo " ($dse)"; }
+ echo '</ShortName>
+<Description>conveniently use different searchengines</Description>
+<Tags>consearch</Tags>
+<Contact>consearch @ f p u n k t k . de</Contact>
+<Url type="text/html" template="https://www.fpunktk.de/consearch/index.php';
+ if ( $dse ) { echo "?dse=$dse"; }
+ echo '#{searchTerms}" />
+<Image height="16" width="16" type="image/png">https://www.fpunktk.de/consearch/consearch.png</Image>
+</OpenSearchDescription>';
+
+ exit;
+}
+
+?>
+<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>consearch</title>
<link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAACMuuz63rNKAAAAK0lEQVQI12P4/58BiM4cZ9gdDUVnboNE/n8Hoc6JDLvLGLrLGF4DyWlAcQBYKBgvsgbJOAAAAABJRU5ErkJggg==" type="image/png">
-<link rel="search" type="application/opensearchdescription+xml" href="opensearchdescription-consearch.xml.php<?php if ( $dse ) { echo "?dse=$dse"; } ?>" title="consearch<?php if ( $dse ) { echo " ($dse)"; } ?>">
+<link rel="search" type="application/opensearchdescription+xml" href="index.php?get=opensearchdescription<?php if ( $dse ) { echo "&dse=$dse"; } ?>" title="consearch<?php if ( $dse ) { echo " ($dse)"; } ?>">
<style type="text/css">
* {
}
button {
margin: 0px -5px 3mm 0px; /* trbl */
- padding: -4px;
+ padding: 3px;
+ background: none;
+ border: 1px solid black;
width: 13ex; /* 13ex 11ch */
width: 11ch; /* used twice because some browsers don't understand it */
height: 13mm;
se["imdb"] = ["imdb", "http://www.imdb.com/find?s=all&q=", "imdb.png"];
se["az"] = ["amazon", "https://www.amazon.de/s/?url=search-alias%3Daps&field-keywords=", "az.png"];
se["php"] = ["php.net", "http://de2.php.net/manual-lookup.php?lang=de&pattern=", "php.png"];
-se["sh"] = ["slfhtml", "http://de.selfhtml.org/navigation/suche/index.htm?Suchanfrage=", "sh.png"];
+se["sh"] = ["slfhtml", "https://wiki.selfhtml.org/index.php?search=", "sh.png"];
se["down"] = ["down", "http://www.downforeveryoneorjustme.com/", "down.png"];
+se["fefe"] = ["fefe", "https://blog.fefe.de/?q=", ""];
+se["wtr"] = ["wtr.com", "http://www.wetter.com/suche/?o=location&q=", ""];
function display_searchbuttons() {
document.getElementById("searchbuttons").innerHTML = "";
document.getElementById("querystring").focus();
} else {
fragmentarr = fragmentstring.replace("%20", "+").split("+");
- if ( se[fragmentarr[0]] ) {
- // first word in query is a keyword
- kw = fragmentarr[0];
+ kw = fragmentarr[0];
+ if ( se[kw] ) {
+ // first word in query is a search engine keyword
fragmentarr.shift();
location.href = se[kw][1] + fragmentarr.join(" ");
} else {
- // there is no keyword
<?php
if ( $dse ) {
// use a default searchengine
- echo ' location.href = se["' . $dse . '"][1] + fragmentarr.join(" ");
+ echo ' if ( kw != "nd" ) {
+ location.href = se["' . $dse . '"][1] + fragmentarr.join(" ");
+ } else {
+ fragmentarr.shift();
+ document.getElementById("querystring").value = fragmentarr.join(" ");
+ display_searchbuttons();
+ }
';
} else {
// display all buttons and write the fragmentstring into the querystring input