function translate($lang_from, $lang_to, $msg) { $html = wget_ssl("translate.google.com", "/?sl=" . urlencode($lang_from) . "&tl=" . urlencode($lang_to) . "&js=n&ie=UTF-8&text=" . urlencode($msg)); $html = strip_headers($html); if ($html === False) { return ""; } strip_all_tag($html, "head"); strip_all_tag($html, "style"); strip_all_tag($html, "a"); $html = strip_tags($html, "<div>"); $delim1 = "TRANSLATED_TEXT='"; $delim2 = "';"; $i = strpos($html, $delim1) + strlen($delim1); if ($i === False) { return ""; } $html = substr($html, $i); $i = strpos($html, $delim2); if ($i === False) { return ""; } $result = trim(substr($html, 0, $i)); $result = str_replace("\\x26", "&", $result); $result = html_decode($result); $result = html_decode($result); return $result; }
function get_time($location) { $location = trim($location); term_echo("*** TIME: http://www.google.com/search?gbv=1&q=time+" . urlencode($location)); $html = wget_ssl("www.google.com.au", "/search?gbv=1&q=time+" . urlencode($location), ICEWEASEL_UA, "", 60); $html = strip_headers($html); $result = ""; $delim1 = "<div id=\"ires\">"; $delim2 = "</li>"; $i = strpos($html, $delim1); if ($i !== False) { $html = substr($html, $i); $i = strpos($html, $delim2); if ($i !== False) { $html = trim(substr($html, 0, $i)); $html = strip_tags($html); while (strpos($html, " ") !== False) { $html = str_replace(" ", " ", $html); } if ($html != "" and strpos($html, "Time in") !== False) { $result = substr($html, 0, 300); } } else { term_echo("*** TIME: delim2 not found"); } } else { term_echo("*** TIME: delim1 not found"); } return $result; }
function google_search($query) { $response = wget_ssl("www.google.com.au", "/search?source=hp&q=" . urlencode($query)); $html = strip_headers($response); strip_all_tag($html, "head"); strip_all_tag($html, "script"); strip_all_tag($html, "style"); $results = explode("<cite class=\"_Rm\">", $html); array_shift($results); if (count($results) == 0) { return False; } for ($i = 0; $i < count($results); $i++) { $results[$i] = explode("</cite>", $results[$i])[0]; $results[$i] = strip_tags($results[$i]); } return $results; }
function quick_wget($trailing) { $parts = explode(" ", $trailing); delete_empty_elements($parts); if (count($parts) < 2) { return False; } $url = $parts[0]; array_shift($parts); $trailing = implode(" ", $parts); $parts = explode("<>", $trailing); delete_empty_elements($parts); if (count($parts) < 2) { return False; } $delim1 = trim($parts[0]); $delim2 = trim($parts[1]); $host = ""; $uri = ""; $port = ""; if (get_host_and_uri($url, $host, $uri, $port) == False) { return False; } $response = wget_ssl($host, $uri, $port); $result = extract_text($response, $delim1, $delim2); if ($result === False) { return False; } $result = strip_tags($result); $result = html_decode($result); $result = html_decode($result); $result = trim($result); if ($result == "") { return False; } return $result; }