Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/modules/Web_Links/wl-search.php
<?php
// File: $Id: wl-search.php,v 1.2 2001/12/04 00:50:30 gregorrothfuss Exp $ $Name:  $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Francisco Burzi
// Purpose of file:
// ----------------------------------------------------------------------
// 11-30-2001:ahumphr - created file as part of modularistation

/**
 * search
 */
function search($query, $min, $orderby, $show) {
    include(WHERE_IS_PERSO."config.php");
    global $admin, $bgcolor2, $ModName, $pntable, $dbconn;
    global $modurl;

    global $web_links_show_star;
    if (!isset($min)) $min=0;
    if (!isset($max)) $max=$min+$linksresults;
    if(isset($orderby)) {
    $orderby = convertorderbyin($orderby);
    } else {
        $orderby = "title ASC";
    }
    if ($show!="") {
        $linksresults = $show;
    } else {
        $show=$linksresults;
    }
    $query = stripslashes($query);

    $column = &$pntable['links_links_column'];
    $fullcountresult=$dbconn->Execute("SELECT COUNT(*) FROM $pntable[links_links] WHERE $column[title] LIKE '%$query%' OR $column[description] LIKE '%$query%' ");
    list($totalselectedlinks) = $fullcountresult->fields;
    $column = &$pntable['links_categories_column'];
    $resultx = $dbconn->Execute("SELECT count(*) FROM $pntable[links_categories] WHERE $column[title] LIKE '%$query%'");
    list($nrowsx)=$resultx->fields;
    $column = &$pntable['links_links_column'];
    $mysearch = buildSimpleQuery ('links_links', array ('lid', 'cat_id', 'title', 'url', 'description', 'date', 'hits', 'linkratingsummary', 'totalvotes', 'totalcomments'), "$column[title] LIKE '%$query%' OR $column[description] LIKE '%$query%'", $orderby, $linkresults, $min);
    $result = $dbconn->Execute($mysearch);
    $nrows  = $result->PO_RecordCount();
    $x=0;
    include("header.php");
    menu(1);
    echo "<br>";
    OpenTable();
    if ($query != "") {
        if ($nrows>0 OR $nrowsx>0) {
            echo "<font class=\"pn-normal\">"._SEARCHRESULTS4.": <b>$query</b></font><br><br>"
                ."<table width=\"100%\" bgcolor=\"$bgcolor2\"><tr><td><font class=\"pn-normal\"><b>"._USUBCATEGORIES."</b></font></td></tr></table>";
            $column = &$pntable['links_categories_column'];
            $result2 = $dbconn->Execute("SELECT $column[cat_id] FROM $pntable[links_categories] WHERE $column[title] LIKE '%$query%' ORDER BY $column[title] DESC");
            // FTO Check EOF and databse error
            if (!$result2) {
                PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
                die();
            }
            while(!$result2->EOF) {

                list($cid) = $result2->fields;

                $result2->MoveNext();
                $stitle = ereg_replace($query, "<b>$query</b>", CatPath($cid,1,1,1));
                echo "<strong><big>&middot;</big></strong>&nbsp;<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$cid\">$stitle</a> (".CountSubLinks($cid).")<br>";
            }
            echo "<br><table width=\"100%\" bgcolor=\"$bgcolor2\"><tr><td><font class=\"pn-normal\"><b>"._LINKS."</b></font></td></tr></table>";
            $orderbyTrans = convertorderbytrans($orderby);
            echo "<br><font class=\"pn-normal\">"._SORTLINKSBY.": "
                .""._TITLE." (<a class=\"pn-normal\" href=\"${modurl}&amp;req=search&amp;query=$query&amp;orderby=titleA\">A</a>/<a class=\"pn-normal\" href=\"${modurl}&amp;req=search&amp;query=$query&amp;orderby=titleD\">D</a>)"
                .""._DATE." (<a class=\"pn-normal\" href=\"${modurl}&amp;req=search&amp;query=$query&amp;orderby=dateA\">A</a>/<a class=\"pn-normal\" href=\"${modurl}&amp;req=search&amp;query=$query&amp;orderby=dateD\">D</a>)"
                .""._RATING." (<a class=\"pn-normal\" href=\"${modurl}&amp;req=search&amp;query=$query&amp;orderby=ratingA\">A</a>/<a class=\"pn-normal\" href=\"${modurl}&amp;req=search&amp;query=$query&amp;orderby=ratingD\">D</a>)"
                .""._POPULARITY." (<a class=\"pn-normal\" href=\"${modurl}&amp;req=search&amp;query=$query&amp;orderby=hitsA\">A</a>/<a class=\"pn-normal\" href=\"${modurl}&amp;req=search&amp;query=$query&amp;orderby=hitsD\">D</a>)"
                ."<br>"._SITESSORTED.": $orderbyTrans<br><br>";
// FTO Check EOF and databse error
            if (!$result) {
               PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
               die();
            }
            while(!$result->EOF) {

                list($lid, $cid, $title, $url, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments) = $result->fields;

                $result->MoveNext();
                $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
                $title = stripslashes($title); $description = stripslashes($description);
                $transfertitle = str_replace (" ", "_", $title);
                $title = ereg_replace($query, "<b>$query</b>", $title);
                echo "<a class=\"pn-title\" href=\"${modurl}&amp;req=visit&amp;lid=$lid\" target=\"new\">$title</a>";
                newlinkgraphic($datetime, $time);
                popgraphic($hits);
                echo "<br>";
                $description = ereg_replace($query, "<b>$query</b>", $description);
                echo ""._DESCRIPTION.": $description<br>";
                setlocale ("LC_TIME", "$locale");
                ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
                $datetime = ml_ftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
                $datetime = ucfirst($datetime);
                echo ""._ADDEDON.": $datetime <br>"._HITS.": $hits";
                /* voting & comments stats */
                if ($totalvotes == 1) {
                    $votestring = _VOTE;
                } else {
                    $votestring = _VOTES;
                }
                if ($linkratingsummary!="0" || $linkratingsummary!="0.0") {
                    echo " "._RATING.": $linkratingsummary ($totalvotes $votestring)";
                    if ($web_links_show_star) {
                        echo " ".web_links_rateMakeStar($linkratingsummary, 10);
                    }
                }
                LinksBottomMenu($lid, $transfertitle, $totalvotes, $totalcomments);
                detecteditorial($lid, $transfertitle);
                echo "<br>";
                echo ""._CATEGORY.": ".CatPath($cid,1,1,1)."<br><br>";
                $x++;
            }
            echo "</font>";
            $orderby = convertorderbyout($orderby);
        } else {
            echo "<br><br><center><font class=\"pn-normal\"><b>"._NOMATCHES."</b></font><br><br>"._GOBACK."<br></center>";
        }
        /* Calculates how many pages exist.  Which page one should be on, etc... */
        $linkpagesint = ($totalselectedlinks / $linksresults);
        $linkpageremainder = ($totalselectedlinks % $linksresults);
        if ($linkpageremainder != 0) {
            $linkpages = ceil($linkpagesint);
            if ($totalselectedlinks < $linksresults) {
                $linkpageremainder = 0;
            }
        } else {
            $linkpages = $linkpagesint;
        }
        /* Page Numbering */
        if ($linkpages!=1 && $linkpages!=0) {
            echo "<br><br>"
                .""._SELECTPAGE.": ";
            $prev=$min-$linksresults;
            if ($prev>=0) {
                echo "&nbsp;&nbsp;<b>[ <a class=\"pn-normal\" href=\"${modurl}&amp;req=search&amp;query=$query&amp;min=$prev&amp;orderby=$orderby&amp;show=$show\">"
                    ." &lt;&lt; "._PREVIOUS."</a> ]</b> ";
            }
            $counter = 1;
            $currentpage = ($max / $linksresults);
            while ($counter<=$linkpages ) {
                $cpage = $counter;
                $mintemp = ($perpage * $counter) - $linksresults;
                if ($counter == $currentpage) {
                    echo "<b>$counter</b> ";
                } else {
                    echo "<a class=\"pn-normal\" href=\"${modurl}&amp;req=search&amp;query=$query&amp;min=$mintemp&amp;orderby=$orderby&amp;show=$show\">$counter</a> ";
                }
                $counter++;
            }
            $next=$min+$linksresults;
            if ($x>=$perpage) {
                echo "&nbsp;&nbsp;<b>[ <a class=\"pn-normal\" href=\"${modurl}&amp;req=search&amp;query=$query&amp;min=$max&amp;orderby=$orderby&amp;show=$show\">"
                    ." "._NEXT." &gt;&gt;</a> ]</b>";
            }
        }
        echo "<br><br><center><font class=\"pn-normal\">"
            .""._TRY2SEARCH." \"$query\" "._INOTHERSENGINES."<br>"
            ."<a class=\"pn-normal\" target=\"_blank\" href=\"http://www.altavista.com/cgi-bin/query?pg=q&amp;sc=on&amp;hl=on&amp;act=2006&amp;par=0&amp;q=$query&amp;kl=XX&amp;stype=stext\">Alta Vista</a> - "
            ."<a class=\"pn-normal\" target=\"_blank\" href=\"http://www.hotbot.com/?MT=$query&amp;DU=days&amp;SW=web\">HotBot</a> - "
            ."<a class=\"pn-normal\" target=\"_blank\" href=\"http://www.infoseek.com/Titles?qt=$query\">Infoseek</a> - "
            ."<a class=\"pn-normal\" target=\"_blank\" href=\"http://www.dejanews.com/dnquery.xp?QRY=$query\">Deja News</a> - "
            ."<a class=\"pn-normal\" target=\"_blank\" href=\"http://www.lycos.com/cgi-bin/pursuit?query=$query&amp;maxhits=20\">Lycos</a> - "
            ."<a class=\"pn-normal\" target=\"_blank\" href=\"http://search.yahoo.com/bin/search?p=$query\">Yahoo</a>"
            ."<br>"
            ."<a class=\"pn-normal\" target=\"_blank\" href=\"http://es.linuxstart.com/cgi-bin/sqlsearch.cgi?pos=1&amp;query=$query&amp;language=&amp;advanced=&amp;urlonly=&amp;withid=\">LinuxStart</a> - "
            ."<a class=\"pn-normal\" target=\"_blank\" href=\"http://search.1stlinuxsearch.com/compass?scope=$query&amp;ui=sr\">1stLinuxSearch</a> - "
            ."<a class=\"pn-normal\" target=\"_blank\" href=\"http://www.google.com/search?q=$query\">Google</a> - "
            ."<a class=\"pn-normal\" target=\"_blank\" href=\"http://www.linuxlinks.com/cgi-bin/search.cgi?query=$query&amp;engine=Links\">LinuxLinks</a> - "
            ."<a class=\"pn-normal\" target=\"_blank\" href=\"http://www.freshmeat.net/search.php?query=$query\">Freshmeat</a> - "
            ."<a class=\"pn-normal\" target=\"_blank\" href=\"http://www.justlinux.com/bin/search.pl?key=$query\">JustLinux</a>"
            ."</font>";
    } else {
        echo "<center><font class=\"pn-normal\"><b>"._NOMATCHES."</b></font></center><br><br>";
    }
    CloseTable();
    include("footer.php");
}

?>
Return current item: ProNuke. Postnuke To Oracle