PHP Classes
elePHPant
Icontem

File: test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Pashkov Denis Igorevich  >  Google helper  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Example
Class: Google helper
Perform searches using Google search API
Author: By
Last change: Some stuff
Date: 4 years ago
Size: 4,039 bytes
 

Contents

Class file image Download
<?php
include_once "goog_class.php";
$search=new googlehelper();
// Set error reporting to null ///
error_reporting(0);
if(!
session_id()) session_start();
if (isset(
$_GET["search"])){
unset(
$_SESSION["request"]);
$_SESSION["request"] = $_GET["search"] ;
}
?>

<html>
    <head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js" type="text/javascript"></script>
<script src="jquery.googleSuggest.js" type="text/javascript"></script>

<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/ui-lightness/jquery-ui.css" type="text/css" rel="stylesheet"/>
<style>
input{font-size:1.3em;}
#log{position: absolute; top: 10px; right: 10px;}
span{color:blue; text-decoration: underline; cursor: pointer;}
</style>
    <style type="text/css">
   
        a{
        text-decoration:none;
        }
   
        div{
        -moz-border-radius: 15px;
border-radius: 15px;
       
        }
   
        #result{
       
        margin-top:50px;
       
        }
       
       
        #more{
       
            background-color:yellow;
            border:2px solid white;
            height:50px;
            padding:5px;
            width:60px;
          position: fixed;
    bottom: 30px;
       
        }
       
            #more a{
           
        
            }
       
        #top a{
       
            padding-left:50px;
              font-weight:bold ;
       
        }
       
       
       
        .result{
       
            display:block;
            background-color:#fffadc;
            width:50%;
            height:90px;
            margin-top:70px;
            margin-left:300px;
       
       
        }
   
    </style>
   
   
    <title> Google Wrapper by Me </title> </head>


    <body>
   
    <div id="top" style='height:20px;'>
    <a href="test.php?type=images&search=<?=$_SESSION["request"];?>"> Images </a>
    <a href="test.php?type=web&search=<?=$_SESSION["request"];?>"> Web </a>
    <hr/>
    </div>
   
        <center>
       
            <form style='margin-top:50px;' autocomplete="off">
                <a href="test.php"><img src='gogy.png' width="400px" /></a> </br>
                <input type='text' id='searcher' name='search' style='width:400px;' /> <input type='submit' value='Поиск' />
        
            </form>
           
                <script src="http://www.gmodules.com/ig/ifr?url=http://hosting.gmodules.com/ig/gadgets/file/112771201556372182373/Pub-Google-Adsense.xml&amp;synd=open&amp;w=510&amp;h=130&amp;title=&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script>
            <div id="content">
           
            </div>
           
        </center>
   
 <script>
function log(msg){
  $("#log").append(msg+"\n");
}
function select(event, ui){
  log(ui.item.label);
}

$("#searcher").googleSuggest({
  select: select
}).focus();


 
</script>
   
   
   
    <div id='result'>
   
    <?php
 
/*
             Some Like Controller Section
       

*/
/////

if (isset($_GET["type"])){
$search->setType($_GET["type"]);
$_SESSION["type"]=$_GET["type"];
}else{

    if (isset(
$_SESSION["type"]))
       
$search->setType($_SESSION["type"]);

}


if (isset(
$_GET["next"]))
   
$search->setNext($_GET["next"]);
   


    if (isset(
$_GET["search"])){

   
$results=$search->searcgogole(iconv("CP1251","UTF-8",$_GET["search"]),true);
   
    if (
count($results)>=2){
   
//REsult count
           
$c= (count($results)+$search->getNext()) ;
           
           
    echo
"<h3 style='color:#05790b;'> Результаты поиска : $c </h3>";
        foreach(
$results as $result){
       
        echo
"<div class='result'>".$result."<hr/></div>";
       
       
        }
       
        }else{
       
$search->setNext(1);
        echo
"<h3 style='color:#05790b;'> Нет результатов! </h3> ";
        }
       
       
       
}

/*

    end of contr


*/

 
?>

   
   
    </div>

    <div id="footer">
   
    <?php
        
               
// step by 2
               
$request = $search->reqs;
                
               
    if (isset(
$request))
    {
        echo
"
        <div id='more'>
        <a href='test.php?search="
.$request."&next=".$search->getNext()."' > <h2>ЕЩЕ</h2> </a></div>
        "
;
    }
   
?>
   
   
   
    </div>
   
   
    </body>
   

</html>