diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-01-11 15:49:17 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-01-11 15:49:17 +0100 |
commit | 1062c782ebec95041c5cee289cf59d6ea1bdbe54 (patch) | |
tree | 4ae17cf2d6a325b5dccb42c04172a02042cf538d /prog/sear.php | |
parent | in v odejo se zavijem (diff) | |
download | r-1062c782ebec95041c5cee289cf59d6ea1bdbe54.tar r-1062c782ebec95041c5cee289cf59d6ea1bdbe54.tar.gz r-1062c782ebec95041c5cee289cf59d6ea1bdbe54.tar.bz2 r-1062c782ebec95041c5cee289cf59d6ea1bdbe54.tar.lz r-1062c782ebec95041c5cee289cf59d6ea1bdbe54.tar.xz r-1062c782ebec95041c5cee289cf59d6ea1bdbe54.tar.zst r-1062c782ebec95041c5cee289cf59d6ea1bdbe54.zip |
Diffstat (limited to 'prog/sear.php')
-rw-r--r-- | prog/sear.php/index.php | 21 | ||||
-rw-r--r-- | prog/sear.php/osdd.xml | 4 |
2 files changed, 14 insertions, 11 deletions
diff --git a/prog/sear.php/index.php b/prog/sear.php/index.php index 58d5600..4324fba 100644 --- a/prog/sear.php/index.php +++ b/prog/sear.php/index.php @@ -50,12 +50,12 @@ function query_google ($s, $image = false, $noredirect = false, $bindstring = fa if ($image) { $imageclass = find_class($txtdoc, "{font-family:Roboto,Helvetica,Arial,sans-serif}"); if (!$imageclass) - return ["status" => false, "code" => "noimgclass"]; + return ["status" => false, "code" => "noimgclass", "url" => $url]; } else { $titleclass = find_class($txtdoc, "{color:#1967D2;font-size:14px;line-height:16px}"); $descclass = find_class($txtdoc, "{word-break:break-word}"); if (!$titleclass || !$descclass) - return ["status" => false, "code" => "noclass"]; + return ["status" => false, "code" => "noclass", "url" => $url]; } $results = []; $x = new DOMDocument(); @@ -92,9 +92,12 @@ function query_google ($s, $image = false, $noredirect = false, $bindstring = fa if ($span->getAttribute("class") == $descclass) $breadcrumbs = $span->nodeValue; } - foreach ($a->parentNode->parentNode->getElementsByTagName("table")[0]->getElementsByTagName("span") as $span) - if ($span->getAttribute("class") == $descclass) - $description = $span->nodeValue; + $table = $a->parentNode->parentNode->getElementsByTagName("table")[0]; + $description = "nisem uspel izluščiti opisa."; + if ($table) + foreach ($table->getElementsByTagName("span") as $span) + if ($span->getAttribute("class") == $descclass) + $description = $span->nodeValue; $results[] = ["url" => $hreflink, "title" => $firstspan->nodeValue, "breadcrumbs" => $breadcrumbs, "description" => $description]; } $suggested = []; @@ -108,7 +111,7 @@ function query_google ($s, $image = false, $noredirect = false, $bindstring = fa $suggestion = false; if (sizeof($suggested) == 1 || ($noredirect && sizeof($suggested) > 0)) $suggestion = $suggested[0]; - return ["status" => true, "query" => $s, "suggestion" => $suggestion, "results" => $results]; + return ["status" => true, "query" => $s, "suggestion" => $suggestion, "results" => $results, "url" => $url]; } function template ($title, $queryinfo, $body, $query = "", $additionalform = "", $imgfirst = false) { $query = htmlspecialchars($query); @@ -130,11 +133,11 @@ function template ($title, $queryinfo, $body, $query = "", $additionalform = "", <html lang=sl> <head> <meta charset=UTF-8> - <title>$title :: sear.c</title> + <title>$title :: sear.php</title> <meta name=viewport content='width=device-width, initial-scale=1'> <link rel=stylesheet href=/css.css> <link rel=icon type=image/x-icon href=favicon.ico> - <link title=sear.c rel=search type=application/opensearchdescription+xml href=/osdd.xml> + <link title=sear.php rel=search type=application/opensearchdescription+xml href=/osdd.xml> </head> <body> <form class=container action=.> @@ -289,7 +292,7 @@ if (!empty($_REQUEST["f"])) { $add_form .= "<input type=hidden name=f value=f />"; } if ($q == null) { - die(template("", "iskalnik sear.php", "dobrodošli v iskalniku sear.php, naslednjiku programa sear.c. za iskanje po spletu nekaj vnesite v iskalno vrstico zgoraj in pritisnite na gumb.")); + die(template("", "iskalnik sear.php", "dobrodošli v iskalniku sear.php, nasledniku programa sear.c. za iskanje po spletu nekaj vnesite v iskalno vrstico zgoraj in pritisnite na gumb.")); } $response = try_query_google($q, $image, $exact); if ($response["status"] != true) { diff --git a/prog/sear.php/osdd.xml b/prog/sear.php/osdd.xml index 8ef499d..03b698c 100644 --- a/prog/sear.php/osdd.xml +++ b/prog/sear.php/osdd.xml @@ -1,7 +1,7 @@ <?xml version="1.0"?> <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" > - <ShortName>sear.c @ REPLACEME</ShortName> - <Description>sear.c @ REPLACEME</Description> + <ShortName>sear.php @ REPLACEME</ShortName> + <Description>sear.php @ REPLACEME</Description> <Url type="text/html" method="get" template="http://REPLACEME/?q={searchTerms}" /> <Image height="16" width="16">data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAA////////////AAAA/wAAAP////////////////8AAAD/AAAA////////////////////////////////////////////AAAA/////////////////////////////////wAAAP8AAAD//////////////////////////////////////wAAAP//////////////////////////////////////AAAA/wAAAP//////////////////////////////////////AAAA/wAAAP////////////////////////////////8AAAD/AAAA/////////////////////////////////////////////////////////////////////////////////wAAAP8AAAD//////wAAAP8AAAD/AAAA////////////////////////////////////////////////////////////AAAA/wAAAP////////////////8AAAD//////////////////////////////////////////////////////wAAAP///////////////////////////wAAAP///////////////////////////////////////////wAAAP//////////////////////AAAA////////////AAAA/////////////////wAAAP8AAAD///////////8AAAD///////////////////////////8AAAD//////wAAAP///////////wAAAP///////////wAAAP//////AAAA//////////////////////8AAAD///////////8AAAD//////////////////////wAAAP////////////////8AAAD///////////////////////////8AAAD//////////////////////wAAAP///////////wAAAP///////////wAAAP////////////////8AAAD/////////////////////////////////AAAA/wAAAP//////////////////////AAAA/wAAAP8AAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</Image> </OpenSearchDescription> |