";
echo "";
echo "";
echo "";
echo "";
}
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
require_once "google.php";
require_once "tools.php";
$query = $_SESSION["q"];
$page = (int) htmlspecialchars($_SESSION["p"]);
$type = (int) $_SESSION["type"];
$start_time = microtime(true);
$results = get_google_results($query, $page, $type);
$end_time = number_format(microtime(true) - $start_time, 2, '.', '');
echo "Fetched the results in $end_time seconds
";
if ($type == 0) // text search
{
check_for_special_search($query);
foreach($results as $result)
{
$title = $result["title"];
$url = $result["url"];
$base_url = $result["base_url"];
$description = $result["description"];
echo "";
}
echo "";
if ($page != 0)
{
print_next_pages(0, "<<", $query);
print_next_pages($page - 10, "<", $query);
}
for ($i=$page / 10; $page / 10 + 10 > $i; $i++)
{
$page_input = $i * 10;
$page_button = $i + 1;
print_next_pages($page_input, $page_button, $query);
}
print_next_pages($page + 10, ">", $query);
echo "
";
}
else if ($type == 1) // image search
{
foreach($results as $result)
{
$src = $result["base64"];
$alt = $result["alt"];
echo "";
echo "";
echo "";
}
}
better_session_destroy();
?>