Webmaster общности: Predpriemach.com | SearchEngines.bg

    google images търсачка

    Автор: djvato

    Привет на всички Smile

    от отдавна не бях писал уроци но ето , че дойде времето да ви покажа един много добър урок за вашия портал сайт и т.н. Winking това е една проста търсачка която търси само картинки в google лесно можете да намерите исканата от вас картинка от вашия сайт Smile и така нека започнем с самата търсачка само да кажа , че търсачката може да търси и снимки в вашия сайт в смисъл имате хостинг а снимки можете да сложите търсачката да търси и в вашия хостинг :

    като за начало направете config.inc

    в него сложете :

    <?
    
    // Name of your site
    $sitename = "Image Search";
    
    //Your www.domain.com address *Do not use http://
    $domain = " google.bg ";
    
    // папката от вашия сайт дет са картинките
    $pathtoscript = "/images";
    
    // Body Tag Attributes * Any of these can be left blank
    $bgcolor =""; // Background Color
    $text =""; // Text Color
    $link =""; // Link Color
    $alink =""; // Active Link Color
    $vlink =""; // Visited Link Color
    $backgroundimage = "http://www.domain.com/images/background.jpg"; // Background Image
    
    // Header and Footer files
    // If they are located somehere else then show full path ex: /home/user/www/header.txt
    $headerfile = "header.txt";
    $footerfile = "footer.txt";
    
    
    // Result text that shows after an image is clicked
    $displaytext = "Your Image From $sitename";
    
    
    
    
    
    // No need to edit below here
    // #######################################################
    
    // 0 represents "showing no errors"
    // Replacing with E_ALL will "show all errors"
    error_reporting(0);
    
    
    // Image Variables - imgurl=(image location) imgrefurl=(webpage image was found) h=(height) w=(width) sz=(size)
    $imgurl = 'imgurl';
    $imgrefurl = 'imgrefurl';
    $h = 'h';
    $w = 'w';
    $sz = 'sz';
    
    // imagetype - you cannot add more than the 3 filetypes used here
    $jpg = 'jpg';
    $gif = 'gif';
    $png = 'png';
    
    // image size - you cannot add more than the 3 types used here
    $icon = 'icon';
    $meduim = 'small|medium|large|xlarge';
    $xxlarge = 'xxlarge';
    // image colors - you cannot add more than the 3 types used here
    $mono = 'mono';
    $gray = 'gray';
    $color = 'color';
    
    
    $lang = "en";
    $start = $_GET['start'];
    $q1 = $_GET['q'];
    $q = str_replace(" ", "+", $q1);
    $turl = "/imgres?";
    $nurl = "http://images.google.com/imgres?";
    $therecolor = "#e7eefc";
    $ourcolor = "#99CCFF";
    $thumnew = "http://images.google.com/images?q";
    $thumold = "/images?q";
    $didyoumeanold = "/images?svnum";
    $didyoumeannew = "$pathtoscript/isearch.php?svnum";
    $imagesizeold = "/images?imgsz";
    $imagesizenew = "$pathtoscript/isearch.php?imgsz";
    $imagecolorold = "/images?imgc";
    $imagecolornew = "$pathtoscript/isearch.php?imgc";
    $url = "http://images.google.com/images?q=$q&hl=$lang&as_filetype=$imagetype&imgsz=$imgsz&imgc=$imgc&start=$start";
    // $url = "http://images.google.com/images?q=$q&hl=$lang&start=$start";
    $lines_array = file($url);
    $lines_string = implode('', $lines_array);
    
    ?>

    следващия файл :

    index.php

    <? include("config.inc");
    echo "
    <html><head>
    <style type=\"text/css\">
    
    
    td {
    background-color: transparent;
    }
    </style>
    <title>$sitename</title></head>
    <BODY BACKGROUND=\"$backgroundimage\" TEXT=\"$text\" LINK=\"$link\" ALINK=\"$alink\" VLINK=\"$vlink\">
    ";
    include("$headerfile");
    ?>
    
    
    
    
    
    
    
    <?
    echo "
    <table width=100% border=0 cellspacing=0 cellpadding=0>
    <td>
    <br><br><br><br>
    </td>
    </table>
    
    <table width=100% border=0 cellspacing=0 cellpadding=0>
    <td align=center width=100%><form action=\"isearch.php?q=\" method=\"get\">
    <input type=\"text\" size=\"40\" name=\"q\" value=\"$q1\"title=\"Enter Search String\">
    <input type=\"submit\" value=\"Search\">
    <br>
    <SELECT size=1 name='imagetype' value='$imagetype'>
    <OPTION selected value=''>any filetype
    <OPTION value='$jpg'>jpg
    <OPTION value='$gif'>gif
    <OPTION value='$png'>png
    </SELECT>
    <SELECT size=1 name='imgsz' value='$imgsz'>
    <OPTION selected value=''>any size
    <OPTION value='$icon'>small
    <OPTION value='$medium'>medium
    <OPTION value='$xxlarge'>large
    </SELECT>
    <SELECT size=1 name='imgc' value='$imgc'>
    <OPTION selected value=''>any colors
    <OPTION value='$mono'>black & white
    <OPTION value='$gray'>grayscale
    <OPTION value='$color'>full color
    </SELECT><p>
    </form>
    </td></table>";
    ?>
    
    <? include("$footerfile"); ?>

    isearch.php

    <?php
    include("config.inc");
    $keyword = "Image Search";
    echo "
    <html><head>
    <style type=\"text/css\">
    
    
    td {
    background-color: transparent;
    }
    </style>
    <title>$sitename - $q1</title>
    <META NAME=\"description\" CONTENT=\"$q1\">
    <META NAME=\"keywords\" CONTENT=\"$q1\">
    
    </head>
    <BODY BACKGROUND=\"$backgroundimage\" TEXT=\"$text\" LINK=\"$link\" ALINK=\"$alink\" VLINK=\"$vlink\">
    ";
    
    include("$headerfile");
    
    
    echo "
    <table width=100% border=0 cellspacing=0 cellpadding=0>
    <td>
    <br><br>
    </td>
    </table>
    <table width=100% border=0 cellspacing=0 cellpadding=0>
    <td align=center width=100%><form action=\"isearch.php?q=\" method=\"get\">
    <input type=\"text\" size=\"40\" name=\"q\" value=\"$q1\"title=\"Enter Search String\">
    <input type=\"submit\" value=\"Search\">
    <br>
    <SELECT size=1 name='imagetype' value='$imagetype'>
    <OPTION selected value=''>any filetype
    <OPTION value='$jpg'>jpg
    <OPTION value='$gif'>gif
    <OPTION value='$png'>png
    </SELECT>
    <SELECT size=1 name='imgsz' value='$imgsz'>
    <OPTION selected value=''>any size
    <OPTION value='$icon'>small
    <OPTION value='$medium'>medium
    <OPTION value='$xxlarge'>large
    </SELECT>
    <SELECT size=1 name='imgc' value='$imgc'>
    <OPTION selected value=''>any colors
    <OPTION value='$mono'>black & white
    <OPTION value='$gray'>grayscale
    <OPTION value='$color'>full color
    </SELECT><p>
    </form>
    </td></table>";
    
    
    
    ereg("Small(.*)Next", $lines_string, $mydata);
    $tenew = str_replace("$therecolor", "$ourcolor", $mydata); // change our color
    
    
    
    
    // THE ESSENTIAL STUFF
    $tenew2 = str_replace("$turl", "$nurl", $tenew); // change some url
    $tenew3 = str_replace("$thumold", "$thumnew", $tenew2); // change thumbnail paths
    $tenew4 = str_replace("http://images.google.com/images?q=$q", "http://$domain$pathtoscript/isearch.php?q=$q", $tenew3);
    $tenew5 = str_replace("http://images.google.com/imgres?imgurl=", "http://$domain$pathtoscript/simage.php?n=", $tenew4);
    $tenew6 = str_replace("/images?hl=", "http://$domain$pathtoscript/isearch.php?", $tenew5);
    
    
    // THE HTML GARBAGE TO TAKE OUT AND REPLACE
    
    
    $html = str_replace("<img src=/nav_previous.gif width=68 height=26 alt=\"\" border=0><br>", "", $tenew6); // Navigational images
    $html1 = str_replace("<img src=/nav_page.gif width=16 height=26 alt=\"\" border=0><br>", "", $html); // Navigational images
    $html2 = str_replace("<img src=/nav_first.gif width=18 height=26 alt=\"\"><br>", "", $html1); // Navigational images
    $html3 = str_replace("<img src=/nav_current.gif width=16 height=26 alt=\"\"><br>", "", $html2); // Navigational images
    $html4 = str_replace("<img src=/nav_next.gif width=100 height=26 alt=\"\" border=0><br>", "", $html3); // Navigational images
    
    
    $html5 = str_replace("<td nowrap nowrap>", "<td nowrap>", $html4); // DELETING HTML
    $html6 = str_replace("<span class=b>Previous</span>", "Previous ", $html5); // DELETING HTML
    $html7 = str_replace("<span class=b>Next", "Next", $html6); // DELETING HTML
    $html8 = str_replace("Small</a></font></td></tr></table><font size=-1><br></font>", "", $html7); // DELETING HTML
    $html9 = str_replace("<td nowrap>", "</td><td nowrap>", $html8); // FIXING HTML
    $html10 = str_replace("<tr align=center valign=top><td valign=bottom nowrap><font size=-1>Result Page: </font></td>", "", $html9); // FIXING HTML
    $html11 = str_replace("<tr align=center valign=top><td valign=bottom nowrap><font size=-1>Result Page: </font>", "", $html10); // same type FIXING HTML
    $html12 = str_replace("<td nowrap>", "<td nowrap> ", $html11); // DELETING HTML
    
    $html13 = str_replace("$didyoumeanold", "$didyoumeannew", $html12); // Did you mean FIX
    $html14 = str_replace("Small</a></font></td></tr></table><p>", "", $html13);
    $html15 = str_replace("Small</b></font></td></tr></table><font size=-1><br></font>", "", $html14);
    
    $html16 = str_replace("$imagesizeold", "$imagesizenew", $html15); // DROPDOWN IMAGESIZE FIX
    $html17 = str_replace("$imagecolorold", "$imagecolornew", $html16); // DROPDOWN IMAGECOLOR FIX
    
    echo "$html17[0]";
    
    echo "</table>
    <table width=100% border=0 cellspacing=0 cellpadding=0>
    <td align=center width=100%>
    <br>
    <form action=\"isearch.php?q=\" method=\"get\">
    <input type=\"text\" size=\"40\" name=\"q\" value=\"$q1\"title=\"Enter Search String\">
    <input type=\"submit\" value=\"Search\">
    </form></td>
    </table>";
    
    include("$footerfile");
    ?>

    и последния фаил simage.php

    <html>
    <head>
    <?php
    include("config.inc");
    echo "<title>$sitename</title>
    </head>
    <BODY BACKGROUND=\"$backgroundimage\" TEXT=\"$text\" LINK=\"$link\" ALINK=\"$alink\" VLINK=\"$vlink\">";
    
    
    
    $picture = $_GET['n'];
    
    echo "
    <table width=100% border=0 cellspacing=5 cellpadding=5>
    <tr><td align=center width=100%>
    $displaytext
    </td></tr>
    
    <tr><td align=center width=100%>
    <a href=\"#\" onClick=\"javascript:window.history.back(-1)\">Back To $sitename
    </td></tr>
    
    <tr><td align=center width=100%>
    <img src=\"$n\">
    </td></tr>
    </table>";
    ?>
    
    </body>
    </html>

    Оставете коментар