summaryrefslogtreecommitdiffstats
path: root/prog/sear.php/index.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--prog/sear.php/index.php21
1 files changed, 12 insertions, 9 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) {