Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/modules/Web_Links/admin.php
<?php
// File: $Id
// ----------------------------------------------------------------------
// 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:
// Purpose of file:
// ----------------------------------------------------------------------
// 07-07-2001:Wandrer - changed mysql_num_rows to count(*) clause
// 08-24-2001:JM      - fix sfb 438273 LinksAddLink()
//                      add LinksAddLinkError($errstr)
//                      fixed sfb 452097 Confirmation mail define at LinksAddLink()
// 09-04-2001:Insert /font in some section
// 09-25-2001:Karateka - Added unlimited subcategories
//                       (Credits go to Christoph Fischer)
// 12-04-2001:voll     - New admin schema
// ----------------------------------------------------------------------

if (!eregi("admin.php", $PHP_SELF)) { die ("Access Denied"); }
$hlpfile = "manual/weblinks.html";
$ModName = $module;
modules_get_language();

/*********************************************************/
/* Links Modified Web Links                              */
/*********************************************************/

function CatPath($cid, $start, $links, $linkmyself) {
    global $pntable, $dbconn, $ModName;
    global $modurl;
    $column = &$pntable['links_categories_column'];
    $result=$dbconn->Execute("SELECT $column[parent_id], $column[title] FROM $pntable[links_categories] WHERE $column[cat_id]=$cid");
//ADODBtag list+row
    list($pid, $title)=$result->fields;
    if ($linkmyself) {
      $cpath = "<a href=\"${modurl}&amp;req=viewlink&amp;cid=$cid\">$title</a>";
    } else {
        $cpath = $title;
    }
    while ($pid!=0) {
        $column = &$pntable['links_categories_column'];
        $result=$dbconn->Execute("SELECT $column[cat_id], $column[parent_id], $column[title] FROM $pntable[links_categories] WHERE $column[cat_id]=$pid");
//ADODBtag list+row
        list($cid, $pid, $title)=$result->fields;
        if ($links) {
            $cpath = "<a href=\"${modurl}&amp;req=viewlink&amp;cid=$cid\">".$title.'</a> / '.$cpath;
        } else {
            $cpath = $title.' / '.$cpath;
        }
    }
    if ($start) {
        $cpath="<a href=\"${modurl}\">Start</a> / ".$cpath;
    }
    return $cpath;
}

function CatList($scat, $sel, $pfx) {
    global $pntable, $dbconn;

    $s="";

    if ($scat==0) {
        $pfx="";
    }
    $column = &$pntable['links_categories_column'];
    $result=$dbconn->Execute("SELECT $column[cat_id], $column[title] FROM $pntable[links_categories] WHERE $column[parent_id]=$scat");
//ADODBtag MoveNext while+list+row

//FTO : Test database error and eof
    if (!$result) {
          PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
          die();
    }
    while(!$result->EOF) {
        list($cid, $title)=$result->fields;

        $result->MoveNext();
        if ($sel==$cid) {
            $selstr=" selected";
        } else {
            $selstr='';
        }
        if ($pfx=='') {
            $ctitle=$title;
            $opfx=$pfx;
            $pfx=$title;
        } else {
            $ctitle=$pfx.' / '.$title;
            $opfx=$pfx;
            $pfx.=' / '.$title;
        }
        $s.="<option value=\"$cid\"$selstr>$ctitle</option>";
        $s.=CatList($cid, $sel, $pfx);
        $pfx=$opfx;
    }
    return $s;
}



function links() {
    global $hlpfile, $pntable, $dbconn, $user;
    include ("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font class=\"pn-logo\">"._LINKSMAINCAT."</font><br><br>";
    $result=$dbconn->Execute("SELECT count(*) FROM $pntable[links_links]");
//ADODBtag list+row
    list($numrows) = $result->fields;
    echo "<font class=\"pn-normal\">"._THEREARE." <b>$numrows</b> "._LINKSINDB."</font></center>";
    CloseTable();
    echo "<br>";

    $cl=CatList(0,0,'');

    if ((!authorised(0, 'Web links::Category', '::', ACCESS_EDIT)) &&
        (!authorised(0, 'Web links::Link', '::', ACCESS_EDIT))) {
        echo _WEBLINKSNOAUTH;
        include 'footer.php';
        exit;
    }



    // Status
    if (authorised(0, 'Web links::Link', '::', ACCESS_EDIT)) {
        $column = &$pntable['links_modrequest_column'];
        $result = $dbconn->Execute("SELECT COUNT(*) FROM $pntable[links_modrequest] WHERE $column[brokenlink]=1");
//ADODBtag list+row
        list($totalbrokenlinks) = $result->fields;
        $result = $dbconn->Execute("SELECT COUNT(*) FROM $pntable[links_modrequest] WHERE $column[brokenlink]=0");
//ADODBtag list+row
        list($totalmodrequests) = $result->fields;
        OpenTable();
        echo "<center><font class=\"pn-normal\">[ <a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksCleanVotes\">"._CLEANLINKSDB."</a> | "
            ."<a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksListBrokenLinks\">"._BROKENLINKSREP." ($totalbrokenlinks)</a> | "
            ."<a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksListModRequests\">"._LINKMODREQUEST." ($totalmodrequests)</a> | "
            ."<a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksLinkCheck\">"._VALIDATELINKS."</a> ]</font></center>";
        CloseTable();
        echo "<br>";
    }

    // Add category
    if (authorised(0, 'Web links::Category', '::', ACCESS_ADD)) {
       OpenTable();
       echo "<form method=\"post\" action=\"admin.php\">"
            ."<font class=\"pn-title\"><b>"._ADDCATEGORY."</b></font><br><br>"
            .""._NAME.": <input type=\"text\" name=\"title\" size=\"30\" maxlength=\"100\">&nbsp;"._INCAT
            ."<select name=\"cid\">"
            ."<option value=\"0\">"._NONE
            ."$cl</select><br><br>"
            .""._DESCRIPTION.":<br><textarea name=\"cdescription\" cols=\"60\" rows=\"10\"></textarea><br>"
            ."<input type=\"hidden\" name=\"module\" value=\"".$GLOBALS['module']."\">"
            ."<input type=\"hidden\" name=\"op\" value=\"LinksAddCat\">"
            ."<input type=\"submit\" value=\""._ADD."\"><br>"
            ."</form>";
       CloseTable();
       echo "<br>";
    }

    // Modify category
    if (authorised(0, 'Web links::Category', '::', ACCESS_EDIT)) {
        $result = $dbconn->Execute("SELECT count(*) FROM $pntable[links_categories]");
//ADODBtag list+row
        list($numrows) = $result->fields;
        if ($numrows>0) {
            OpenTable();
            echo "<form method=\"post\" action=\"admin.php\">"
                ."<font class=\"pn-title\"><b>"._MODCATEGORY."</b></font><br><br>";
            echo ""._CATEGORY.": <select name=\"cat\">$cl";
            echo "</select>"
                ."<input type=\"hidden\" name=\"module\" value=\"".$GLOBALS['module']."\">"
                ."<input type=\"hidden\" name=\"op\" value=\"LinksModCat\">"
                ."<input type=\"submit\" value=\""._MODIFY."\">"
                ."</form>";
            CloseTable();
            echo "<br>";
        }
    }

    // Add link
    if (authorised(0, 'Web links::Link', '::', ACCESS_ADD)) {
        $result = $dbconn->Execute("SELECT COUNT(*) FROM $pntable[links_categories]");
//ADODBtag list+row
        list($numrows) = $result->fields;
        if ($numrows>0) {
            OpenTable();
            if(is_user($user)) {
               $user2 = base64_decode($user);
               $cookie = explode(":", $user2);
               cookiedecode($user);
               $submitter = $cookie[1];
            }
            echo "<form method=\"post\" action=\"admin.php\">"
                ."<font class=\"pn-title\"><b>"._ADDNEWLINK."</b></font><br><br>"
                .""._PAGETITLE.": <input type=\"text\" name=\"title\" size=\"50\" maxlength=\"100\"><br>"
                .""._PAGEURL.": <input type=\"text\" name=\"url\" size=\"50\" maxlength=\"100\" value=\"http://\"><br>";
            echo ""._CATEGORY.": <select name=\"cat\">$cl</select><br><br><br>"
                .""._DESCRIPTION255."<br><textarea name=\"description\" cols=\"60\" rows=\"5\"></textarea><br><br><br>"
                .""._NAME.": <input type=\"text\" name=\"name\" size=\"30\" maxlength=\"60\"><br>"
                .""._EMAIL.": <input type=\"text\" name=\"email\" size=\"30\" maxlength=\"60\"><br><br>"
                ."<input type=\"hidden\" name=\"submitter\" value=\"$submitter\">"
                ."<input type=\"hidden\" name=\"module\" value=\"".$GLOBALS['module']."\">"
                ."<input type=\"hidden\" name=\"op\" value=\"LinksAddLink\">"
                ."<input type=\"hidden\" name=\"new\" value=\"0\">"
                ."<input type=\"hidden\" name=\"lid\" value=\"0\">"
                ."<center><input type=\"submit\" value=\""._ADDURL."\"><br>"
                ."</form>";
            CloseTable();
            echo "<br>";
        }
    }

    // Modify link
    if (authorised(0, 'Web links::Link', '::', ACCESS_MODERATE)) {
        $result = $dbconn->Execute("SELECT COUNT(*) FROM $pntable[links_links]");
//ADODBtag list+row
        list($numrows) = $result->fields;
        if ($numrows>0) {
            OpenTable();
            echo "<form method=\"post\" action=\"admin.php\">"
                ."<font class=\"pn-title\"><b>"._MODLINK."</b></font><br><br>"
                .""._LINKID.": <input type=\"text\" name=\"lid\" size=\"12\" maxlength=\"11\">&nbsp;&nbsp;"
                ."<input type=\"hidden\" name=\"module\" value=\"".$GLOBALS['module']."\">"
                ."<input type=\"hidden\" name=\"op\" value=\"LinksModLink\">"
                ."<input type=\"submit\" value=\""._MODIFY."\">"
                ."</form>";
            CloseTable();
            echo "<br>";
        }
    }

    // Validate links
    if (authorised(0, 'Web links::Link', '::', ACCESS_ADD)) {
        $column = &$pntable['links_newlink_column'];
        $result = $dbconn->Execute("SELECT $column[lid], $column[cat_id], $column[title], $column[url], $column[description], $column[name], $column[email], $column[submitter] FROM $pntable[links_newlink] ORDER BY $column[lid]");

//FTO Check database error
        if (!$result) {
           PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
           die();
        }

        if (!$result->EOF) {
            OpenTable();
            echo "<center><font class=\"pn-title\"><b>"._LINKSWAITINGVAL."</b></font></center><br><br>";
//ADODBtag MoveNext while+list+row

//FTO Test EOF
            while(!$result->EOF) {
                list($lid, $cid, $title, $url, $description, $name, $email, $submitter) = $result->fields;
                $result->MoveNext();
                if ($submitter == "") {
                    $submitter = _NONE;
                }
                echo "<form action=\"admin.php\" method=\"post\">"
                    ."<b>"._LINKID.": $lid</b><br><br>"
                    .""._SUBMITTER.":  $submitter<br>"
                    .""._PAGETITLE.": <input type=\"text\" name=\"title\" value=\"$title\" size=\"50\" maxlength=\"100\"><br>"
                    .""._PAGEURL.": <input type=\"text\" name=\"url\" value=\"$url\" size=\"50\" maxlength=\"100\">&nbsp;[ <a target=\"_blank\" href=\"$url\">"._VISIT."</a> ]<br>"
                    .""._DESCRIPTION.": <br><textarea name=\"description\" cols=\"60\" rows=\"10\">$description</textarea><br>"
                    .""._NAME.": <input type=\"text\" name=\"name\" size=\"20\" maxlength=\"100\" value=\"$name\">&nbsp;&nbsp;"
                    .""._EMAIL.": <input type=\"text\" name=\"email\" size=\"20\" maxlength=\"100\" value=\"$email\"><br>"
                    ."<input type=\"hidden\" name=\"new\" value=\"1\">"
                    ."<input type=\"hidden\" name=\"lid\" value=\"$lid\">"
                    ."<input type=\"hidden\" name=\"submitter\" value=\"$submitter\">"
                    .""._CATEGORY.": <select name=\"cat\">".CatList(0,$cid,"")."</select>"
                    ."<input type=\"hidden\" name=\"module\" value=\"".$GLOBALS['module']."\">"
                    ."<input type=\"hidden\" name=\"op\" value=\"LinksAddLink\"><input type=\"submit\" value="
                    ._ADD."> [ <a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksDelNew&amp;lid=$lid\">"
                    ._DELETE."</a> ]</form><br><hr noshade><br>";
            }
            CloseTable();
            echo "<br>";
        }
    }

    include ("footer.php");
}

function LinksModLink($lid) {
    global $pntable, $dbconn, $hlpfile, $anonymous;
    include ("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._WEBLINKSADMIN."</b></font></center>";
    CloseTable();
    echo "<br>";

    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._MODLINK."</b></font></center><br><br>";
    $column = &$pntable['links_links_column'];
    $catcolumn = &$pntable['links_categories_column'];
    $result = $dbconn->Execute("SELECT $column[cat_id],
                                     $catcolumn[title],
                                     $column[title],
                                     $column[url],
                                     $column[description],
                                     $column[name],
                                     $column[email],
                                     $column[hits]
                              FROM $pntable[links_links], $pntable[links_categories]
                              WHERE $column[lid]=$lid
                              AND $column[cat_id] = $catcolumn[cat_id]");
    if (!$result->EOF) {
//ADODBtag list+row
        list($cid, $cattitle, $title, $url, $description, $name, $email, $hits) = $result->fields;


        if (!authorised(0, 'Web links::Link', "$cattitle:$title:$lid", ACCESS_MODERATE)) {
            echo _WEBLINKSMODERATENOAUTH;
            CloseTable();
            include 'footer.php';
            return;
        }

        $title = stripslashes($title);
        $description = stripslashes($description);
        if (authorised(0, 'Web links::Link', "$cattitle:$title:$lid", ACCESS_EDIT)) {
            echo "<form action=admin.php method=post>"
                .""._LINKID.": <b>$lid</b><br>"
                .""._PAGETITLE.": <input type=\"text\" name=\"title\" value=\"$title\" size=\"50\" maxlength=\"100\"><br>"
                .""._PAGEURL.": <input type=\"text\" name=\"url\" value=\"$url\" size=\"50\" maxlength=\"100\">&nbsp;"
                ."[ <a href=\"$url\">Visit</a> ]<br>"
                .""._DESCRIPTION.":<br><textarea name=\"description\" cols=\"60\" rows=\"10\">$description</textarea><br>"
                .""._NAME.": <input type=\"text\" name=\"name\" size=\"50\" maxlength=\"100\" value=\"$name\"><br>"
                .""._EMAIL.": <input type=\"text\" name=\"email\" size=\"50\" maxlength=\"100\" value=\"$email\"><br>"
                .""._HITS.": <input type=\"text\" name=\"hits\" value=\"$hits\" size=\"12\" maxlength=\"11\"><br>"
                ."<input type=\"hidden\" name=\"lid\" value=\"$lid\">"
                .""._CATEGORY.": <select name=\"cat\">".CatList(0,$cid,"")
                ."</select>"
                ."<input type=\"hidden\" name=\"module\" value=\"".$GLOBALS['module']."\">"
                ."<input type=\"hidden\" name=\"op\" value=\"LinksModLinkS\">"
                ."<input type=\"submit\" value=\""._MODIFY."\"> [ <a href=\"admin.php?module="
                .$GLOBALS['module']."&op=LinksDelLink&amp;lid=$lid\">"._DELETE."</a> ]</form><br>";
            CloseTable();
            echo "<br>";
        }

        if (authorised(0, 'Web links::Link', "$cattitle:$title:$lid", ACCESS_EDIT)) {
            /* Modify or Add Editorial */
            $column = &$pntable['links_editorials_column'];
            $resulted2 = $dbconn->Execute("SELECT $column[adminid], $column[editorialtimestamp], $column[editorialtext], $column[editorialtitle] FROM $pntable[links_editorials] WHERE $column[linkid]=$lid");
            $recordexist = $resulted2->PO_RecordCount();
            OpenTable();
            /* if returns 'bad query' status 0 (add editorial) */
            if ($recordexist == 0) {
                echo "<center><font class=\"pn-title\"><b>"._ADDEDITORIAL."</b></font></center><br><br>"
                    ."<form action=\"admin.php\" method=\"post\">"
                    ."<input type=\"hidden\" name=\"linkid\" value=\"$lid\">"
                    .""._EDITORIALTITLE.":<br><input type=\"text\" name=\"editorialtitle\" "
                    ."value=\"$editorialtitle\" size=\"50\" maxlength=\"100\"><br>"
                    .""._EDITORIALTEXT.":<br><textarea name=\"editorialtext\" cols=\"60\" rows=\"10\">$editorialtext</textarea><br>"
                    ."<input type=\"hidden\" name=\"module\" value=\"".$GLOBALS['module']."\">"
                    ."<input type=\"hidden\" name=\"op\" value=\"LinksAddEditorial\"><input type=\"submit\" value=\"Add\">"
                    ."</form>";
            } else {
                /* if returns 'cool' then status 1 (modify editorial) */
//ADODBtag MoveNext while+list+row

//FTO Test EOF
                while(!$resulted2->EOF) {
                    list($adminid, $editorialtimestamp, $editorialtext, $editorialtitle) = $resulted2->fields;
                    $resulted2->MoveNext();
                    $editorialtitle = stripslashes($editorialtitle); $editorialtext = stripslashes($editorialtext);
                    ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $editorialtimestamp, $editorialtime);
                    $editorialtime = strftime("%F",mktime($editorialtime[4],$editorialtime[5],$editorialtime[6],$editorialtime[2],$editorialtime[3],$editorialtime[1]));
                    $date_array = explode("-", $editorialtime);
                    $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]);
                    $formatted_date = date("F j, Y", $timestamp);
                    echo "<center><font class=\"pn-title\"><b>Modify Editorial</b></font></center><br><br>"
                        ."<form action=\"admin.php\" method=\"post\">"
                        .""._AUTHOR.": $adminid<br>"
                        .""._DATEWRITTEN.": $formatted_date<br><br>"
                        ."<input type=\"hidden\" name=\"linkid\" value=\"$lid\">"
                        .""._EDITORIALTITLE.":<br><input type=\"text\" name=\"editorialtitle\" "
                        ."value=\"$editorialtitle\" size=\"50\" maxlength=\"100\"><br>"
                        .""._EDITORIALTEXT.":<br><textarea name=\"editorialtext\" cols=\"60\" "
                        ."rows=\"10\">$editorialtext</textarea><br>"
                        ."<input type=\"hidden\" name=\"module\" value=\"".$GLOBALS['module']."\">"
                        ."<input type=\"hidden\" name=\"op\" value=\"LinksModEditorial\"><input type=\"submit\" value=\""
                        ._MODIFY."\"> [ <a href=\"admin.php?module=".$GLOBALS['module']
                        ."&op=LinksDelEditorial&amp;linkid=$lid\">"._DELETE."</a> ]"
                        ."</form>";
                }
            }
            CloseTable();
            echo "<br>";
        }

        OpenTable();
        /* Show Comments */
        $column = &$pntable['links_votedata_column'];
        $result5=$dbconn->Execute("SELECT $column[ratingdbid], $column[ratinguser], $column[ratingcomments], $column[ratingtimestamp] FROM $pntable[links_votedata] WHERE $column[ratinglid]=$lid AND $column[ratingcomments] != '' ORDER BY $column[ratingtimestamp] DESC");

//FTO Test database error
        if (!$result5) {
            PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
            die();
        }

        $totalcomments = $result5->PO_RecordCount();
        echo "<table valign=top width=100%>";
        echo "<tr><td colspan=7><b>Link Comments (total comments: $totalcomments)</b><br><br></td></tr>";
        echo "<tr><td width=20 colspan=1><b>User  </b></td><td colspan=5><b>Comment  </b></td><td><b><center>Delete</center></b></td><br></tr>";
        if ($totalcomments == 0) echo "<tr><td colspan=7><center><font color=cccccc>No Comments<br></font></center></td></tr>";
        $x=0;
        $colorswitch="dddddd";
//ADODBtag MoveNext while+list+row
//FTO Test EOF
        while(!$result5->EOF) {
            list($ratingdbid, $ratinguser, $ratingcomments, $ratingtimestamp)=$result5->fields;
            $result5->MoveNext();
            $ratingcomments = stripslashes($ratingcomments);
            ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $ratingtimestamp, $ratingtime);
            $ratingtime = strftime("%F",mktime($ratingtime[4],$ratingtime[5],$ratingtime[6],$ratingtime[2],$ratingtime[3],$ratingtime[1]));
            $date_array = explode("-", $ratingtime);
            $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]);
            $formatted_date = date("F j, Y", $timestamp);
            echo "<tr><td valign=top bgcolor=$colorswitch>$ratinguser</td>"
            ."<td valign=top colspan=5 bgcolor=$colorswitch>$ratingcomments</td>"
            ."<td bgcolor=$colorswitch><center><b><a href=admin.php?module="
            .$GLOBALS['module']."&op=LinksDelComment&lid=$lid&rid=$ratingdbid>X</a></b></center></td><br></tr>";
            $x++;
            if ($colorswitch=="dddddd") $colorswitch="ffffff";
            else $colorswitch="dddddd";
        }


        // Show Registered Users Votes
        $column = &$pntable['links_votedata_column'];
        $result5=$dbconn->Execute("SELECT $column[ratingdbid], $column[ratinguser],
        $column[rating], $column[ratinghostname], $column[ratingtimestamp]
        FROM $pntable[links_votedata] WHERE $column[ratinglid] = $lid
        AND $column[ratinguser] != 'outside' AND $column[ratinguser] !=
        '$anonymous' ORDER BY $column[ratingtimestamp] DESC");

        // FTO Check Database errors
        if (!$result5) {
            PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
            die();
        }

        $totalvotes = $result5->PO_RecordCount();
        echo "<tr><td colspan=7><br><br><b>Registered User Votes (total votes: $totalvotes)</b><br><br></td></tr>"
             ."<tr><td><b>User  </b></td><td><b>IP Address  </b></td><td><b>Rating  </b></td><td><b>"
             ."User AVG Rating  </b></td><td><b>Total Ratings  </b></td><td><b>Date  </b></td></font>"
             ."</b><td><b><center>Delete</center></b></td><br></tr>";
        if ($totalvotes == 0) echo "<tr><td colspan=7><center><font color=cccccc>No Registered User Votes<br></font></center></td></tr>";
        $x=0;
        $colorswitch="dddddd";

//ADODBtag MoveNext while+list+row
//FTO Test EOF

        while(!$result5->EOF) {
            list($ratingdbid, $ratinguser, $rating, $ratinghostname, $ratingtimestamp)=$result5->fields;
            $result5->MoveNext();
            ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $ratingtimestamp, $ratingtime);
            $ratingtime = strftime("%F",mktime($ratingtime[4],$ratingtime[5],$ratingtime[6],$ratingtime[2],$ratingtime[3],$ratingtime[1]));
            $date_array = explode("-", $ratingtime);
            $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]);
            $formatted_date = date("F j, Y", $timestamp);

            //Individual user information
            $column = &$pntable['links_votedata_column'];
            $result2=$dbconn->Execute("SELECT $column[rating] FROM $pntable[links_votedata] WHERE $column[ratinguser]='$ratinguser'");
            $usertotalcomments = $result2->PO_RecordCount();
            $useravgrating = 0;
//ADODBtag MoveNext while+list+row

//FTO Correction of while position (was after brace) + Test EOF
            while(!$result2->EOF)
              {
                list($rating2)=$result2->fields;
                $useravgrating = $useravgrating + $rating2;
                $result2->MoveNext();
              }
            $useravgrating = $useravgrating / $usertotalcomments;
            $useravgrating = number_format($useravgrating, 1);
            echo "<tr><td bgcolor=$colorswitch>$ratinguser</td><td bgcolor=$colorswitch>"
            .$ratinghostname."</td><td bgcolor=$colorswitch>$rating</td><td bgcolor=$colorswitch>"
            .$useravgrating."</td><td bgcolor=$colorswitch>$usertotalcomments</td><td bgcolor="
            .$colorswitch.">$formatted_date  </font></b></td><td bgcolor=$colorswitch><center>"
            ."<b><a href=admin.php?module=".$GLOBALS['module']."&op=LinksDelVote&lid=$lid&rid=$ratingdbid>X</a></b></center></td></tr><br>";
            $x++;
            if ($colorswitch=="dddddd") $colorswitch="ffffff";
            else $colorswitch="dddddd";
        }

        // Show Unregistered Users Votes
        $column = &$pntable['links_votedata_column'];
        $result5=$dbconn->Execute("SELECT $column[ratingdbid], $column[rating],
        $column[ratinghostname], $column[ratingtimestamp] FROM $pntable[links_votedata]
        WHERE $column[ratinglid] = $lid AND $column[ratinguser] = '$anonymous'
        ORDER BY $column[ratingtimestamp] DESC");

        // FTO Check Database errors
        if (!$result5) {
            PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
            die();
        }


        $totalvotes = $result5->PO_RecordCount();
        echo "<tr><td colspan=7><b><br><br>Unregistered User Votes (total votes: $totalvotes)</b><br><br></td></tr>"
        ."<tr><td colspan=2><b>IP Address  </b></td><td colspan=3><b>Rating  </b></td><td><b>Date  </b>"
        ."</font></td><td><b><center>Delete</center></b></td><br></tr>";
        if ($totalvotes == 0) echo "<tr><td colspan=7><center><font color=cccccc>No Unregistered User Votes<br></font></center></td></tr>";
        $x=0;
        $colorswitch="dddddd";
//ADODBtag MoveNext while+list+row

//FTO Test EOF

        while(!$result5->EOF) {
            list($ratingdbid, $rating, $ratinghostname, $ratingtimestamp)=$result5->fields;
            $result5->MoveNext();
            ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $ratingtimestamp, $ratingtime);
            $ratingtime = strftime("%F",mktime($ratingtime[4],$ratingtime[5],$ratingtime[6],$ratingtime[2],$ratingtime[3],$ratingtime[1]));
            $date_array = explode("-", $ratingtime);
            $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]);
            $formatted_date = date("F j, Y", $timestamp);
            echo "<td colspan=2 bgcolor=$colorswitch>$ratinghostname</td><td colspan=3 bgcolor=$colorswitch>$rating</td><td bgcolor=$colorswitch>$formatted_date  </font></b></td><td bgcolor=$colorswitch><center><b><a href=admin.php?module=".$GLOBALS['module']."&op=LinksDelVote&lid=$lid&rid=$ratingdbid>X</a></b></center></td></tr><br>";
            $x++;
            if ($colorswitch=="dddddd") {
                $colorswitch="ffffff";
            } else {
                $colorswitch="dddddd";
            }
        }
        // Show Outside Users Votes
        $column = &$pntable['links_votedata_column'];
        $result5=$dbconn->Execute("SELECT $column[ratingdbid], $column[rating], $column[ratinghostname], $column[ratingtimestamp] FROM $pntable[links_votedata] WHERE $column[ratinglid] = $lid AND $column[ratinguser] = 'outside' ORDER BY $column[ratingtimestamp] DESC");

        // FTO Check Database errors
        if (!$result5) {
            PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
            die();
        }

        $totalvotes = $result5->PO_RecordCount();
        echo "<tr><td colspan=7><b><br><br>Outside User Votes (total votes: $totalvotes)</b><br><br></td></tr>";
        echo "<tr><td colspan=2><b>IP Address  </b></td><td colspan=3><b>Rating  </b></td><td><b>Date  </b></td></font></b><td><b><center>Delete</center></b></td><br></tr>";
        if ($totalvotes == 0) echo "<tr><td colspan=7><center><font color=cccccc>No Votes from Outside $sitename<br></font></center></td></tr>";
        $x=0;
        $colorswitch="dddddd";
//ADODBtag MoveNext while+list+row

//FTO Test EOF

        while(!$result5->EOF) {
            list($ratingdbid, $rating, $ratinghostname, $ratingtimestamp)=$result5->fields;
            $result5->MoveNext();
            ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $ratingtimestamp, $ratingtime);
            $ratingtime = strftime("%F",mktime($ratingtime[4],$ratingtime[5],$ratingtime[6],$ratingtime[2],$ratingtime[3],$ratingtime[1]));
            $date_array = explode("-", $ratingtime);
            $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]);
            $formatted_date = date("F j, Y", $timestamp);
            echo "<tr><td colspan=2 bgcolor=$colorswitch>$ratinghostname</td><td colspan=3 bgcolor=$colorswitch>$rating</td><td bgcolor=$colorswitch>$formatted_date  </font></b></td><td bgcolor=$colorswitch><center><b><a href=admin.php?module=".$GLOBALS['module']."&op=LinksDelVote&lid=$lid&rid=$ratingdbid>X</a></b></center></td></tr><br>";
            $x++;
            if ($colorswitch=="dddddd") $colorswitch="ffffff";
                else $colorswitch="dddddd";
            }

            echo "<tr><td colspan=6><br></td></tr>";
            echo "</table>";
            echo "</form>";
        } else {
            echo _NOSUCHLINK;
        }
        CloseTable();
        echo "<br>";
        include ("footer.php");
}

function LinksDelComment($lid, $rid) {
    global $pntable, $dbconn;

    csrfcheck();

    $linkcolumn = &$pntable['links_links_column'];
    $linktable = $pntable['links_links'];
    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $linkcolumn[title],
                                     $catcolumn[title]
                              FROM $linktable, $cattable
                              WHERE $linkcolumn[lid] = $lid
                              AND $linkcolumn[cat_id] = $catcolumn[cat_id]");
//ADODBtag list+row
    list($title, $cattitle) = $result->fields;
    if (!authorised(0, 'Web links::Link', "$title:$cattitle:$lid", ACCESS_MODERATE)) {
        include 'header.php';
        echo _WEBLINKSMODERATENOAUTH;
        include 'footer.php';
        return;
    }

    $column = &$pntable['links_votedata_column'];
    $dbconn->Execute("UPDATE $pntable[links_votedata] SET $column[ratingcomments]='' WHERE $column[ratingdbid] = $rid");
    $column = &$pntable['links_links_column'];
    $dbconn->Execute("UPDATE $pntable[links_links] SET $column[totalcomments] = ($column[totalcomments] - 1) WHERE $column[lid] = $lid");
    pnRedirect('admin.php?module='.$GLOBALS['module'].'&op=LinksModLink&lid='.$lid);
}

function LinksDelVote($lid, $rid) {
    global $pntable, $dbconn;

    csrfcheck();

    $linkcolumn = &$pntable['links_links_column'];
    $linktable = $pntable['links_links'];
    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $linkcolumn[title],
                                     $catcolumn[title]
                              FROM $linktable, $cattable
                              WHERE $linkcolumn[lid] = $lid
                              AND $linkcolumn[cat_id] = $catcolumn[cat_id]");
//ADODBtag list+row
    list($title, $cattitle) = $result->fields;
    if (!authorised(0, 'Web links::Link', "$title:$cattitle:$lid", ACCESS_MODERATE)) {
        include 'header.php';
        echo _WEBLINKSMODERATENOAUTH;
        include 'footer.php';
        return;
    }

    $column = &$pntable['links_votedata_column'];
    $dbconn->Execute("DELETE FROM $pntable[links_votedata] WHERe $column[ratingdbid]=$rid");
    $voteresult = $dbconn->Execute("SELECT $column[rating], $column[ratinguser], $column[ratingcomments] FROM $pntable[links_votedata] WHERE $column[ratinglid] = $lid");
    $totalvotesDB = $voteresult->PO_RecordCount();
    include ("voteinclude.php");
    $dbconn->Execute("UPDATE $pntable[links_links] SET $column[linkratingsummary]=$finalrating, $column[totalvotes]=$totalvotesDB, $column[totalcomments]=$truecomments WHERE $column[lid] = $lid");
    pnRedirect('admin.php?module='.$GLOBALS['module'].'&op=LinksModLink&lid='.$lid);
}

function LinksListBrokenLinks() {
    global $bgcolor1, $bgcolor2, $pntable, $dbconn, $hlpfile;
    include ("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._WEBLINKSADMIN."</b></font></center>";
    CloseTable();
    echo "<br>";

    if (!authorised(0, 'Web links::Link', '::', ACCESS_EDIT)) {
        echo _WEBLINKSEDITNOAUTH;
        include 'footer.php';
        return;
    }
    OpenTable();
    $column = &$pntable['links_modrequest_column'];
    $result = $dbconn->Execute("SELECT $column[requestid], $column[lid], $column[modifysubmitter] FROM $pntable[links_modrequest] WHERE $column[brokenlink]=1 ORDER BY $column[requestid]");
    // FTO Check Database errors
    if (!$result) {
        PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
        die();
    }


    $totalbrokenlinks = $result->PO_RecordCount();
    echo "<center><font class=\"pn-title\"><b>"._USERREPBROKEN." ($totalbrokenlinks)</b></font></center><br><br><center>"
    .""._IGNOREINFO."<br>"
    .""._DELETEINFO."</center><br><br><br>"
    ."<table align=\"center\" width=\"450\">";
    if ($totalbrokenlinks==0) {
    echo "<center><font class=\"pn-title\">"._NOREPORTEDBROKEN."</font></center><br><br><br>";
    } else {
        $colorswitch = $bgcolor2;
        echo "<tr>"
            ."<td><b>"._LINK."</b></td>"
            ."<td><b>"._SUBMITTER."</b></td>"
            ."<td><b>"._LINKOWNER."</b></td>"
            ."<td><b>"._IGNORE."</b></td>"
            ."<td><b>"._DELETE."</b></td>"
            ."</tr>";
//ADODBtag MoveNext while+list+row
      // FTO Check EOF
        while($result->EOF) {
            list($requestid, $lid, $modifysubmitter)=$result->fields ;
            $result->MoveNext();
            $column = &$pntable['links_links_column'];
            $result2 = $dbconn->Execute("SELECT $column[title], $column[url], $column[submitter] FROM $pntable[links_links] WHERE $column[lid]=$lid");
            if ($modifysubmitter != '$anonymous') {
                $column = &$pntable['users_column'];
                $result3 = $dbconn->Execute("select $column[email] from $pntable[users] where $column[uname]='$modifysubmitter'");
//ADODBtag list+row
                list($email)=$result3->fields;
            }
//ADODBtag list+row
            list($title, $url, $owner)=$result2->fields;

            $column = &$pntable['users_column'];
            $result4 = $dbconn->Execute("SELECT $column[email] FROM $pntable[users] WHERE $column[uname]='$owner'");
//ADODBtag list+row
            list($owneremail)=$result4->fields;
            echo "<tr>"
                ."<td bgcolor=\"$colorswitch\"><a href=\"$url\">$title</a>"
                ."</td>";
            if ($email=='') {
                echo "<td bgcolor=\"$colorswitch\">$modifysubmitter";
            } else {
                echo "<td bgcolor=\"$colorswitch\"><a href=\"mailto:$email\">$modifysubmitter</a>";
            }
            echo "</td>";
            if ($owneremail=='') {
            echo "<td bgcolor=\"$colorswitch\">$owner";
        } else {
            echo "<td bgcolor=\"$colorswitch\"><a href=\"mailto:$owneremail\">$owner</a>";
        }
        echo "</td>"
            ."<td bgcolor=\"$colorswitch\"><center><a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksIgnoreBrokenLinks&amp;lid=$lid\">X</a></center>"
            ."</td>"
            ."<td bgcolor=\"$colorswitch\"><center><a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksDelBrokenLinks&amp;lid=$lid\">X</a></center>"
            ."</td>"
            ."</tr>";
        if ($colorswitch == $bgcolor2) {
            $colorswitch = $bgcolor1;
        } else {
            $colorswitch = $bgcolor2;
        }
        }
    }
    echo "</table>";
    CloseTable();
    include ("footer.php");
}

function LinksDelBrokenLinks($lid) {
    global $pntable, $dbconn;

    csrfcheck();

    $linkcolumn = &$pntable['links_links_column'];
    $linktable = $pntable['links_links'];
    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $linkcolumn[title],
                                     $catcolumn[title]
                              FROM $linktable, $cattable
                              WHERE $linkcolumn[lid] = $lid
                              AND $linkcolumn[cat_id] = $catcolumn[cat_id]");
//ADODBtag list+row
    list($title, $cattitle) = $result->fields;
    if (!authorised(0, 'Web links::Link', "$title:$cattitle:$lid", ACCESS_DELETE)) {
        include 'header.php';
        echo _WEBLINKSDELNOAUTH;
        include 'footer.php';
        return;
    }

    $column = &$pntable['links_modrequest_column'];
    $dbconn->Execute("DELETE FROM $pntable[links_modrequest] WHERE $column[lid]=$lid");
    $column = &$pntable['links_links_column'];
    $dbconn->Execute("DELETE FROM $pntable[links_links] WHERE $column[lid]=$lid");
    pnRedirect('admin.php?module='.$GLOBALS['module'].'&op=LinksListBrokenLinks');
}

function LinksIgnoreBrokenLinks($lid) {
    global $pntable, $dbconn;

    csrfcheck();

    $linkcolumn = &$pntable['links_links_column'];
    $linktable = $pntable['links_links'];
    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $linkcolumn[title],
                                     $catcolumn[title]
                              FROM $linktable, $cattable
                              WHERE $linkcolumn[lid] = $lid
                              AND $linkcolumn[cat_id] = $catcolumn[cat_id]");
//ADODBtag list+row
    list($title, $cattitle) = $result->fields;
    if (!authorised(0, 'Web links::Link', "$title:$cattitle:$lid", ACCESS_MODERATE)) {
        include 'header.php';
        echo _WEBLINKSMODERATENOAUTH;
        include 'footer.php';
        return;
    }
    $column = &$pntable['links_modrequest_column'];
    $dbconn->Execute("DELETE FROM $pntable[links_modrequest] WHERE $column[lid]=$lid AND $column[brokenlink]=1");
    pnRedirect('admin.php?module='.$GLOBALS['module'].'&op=LinksListBrokenLinks');
}

//jgm
function LinksListModRequests() {
    global $bgcolor2, $pntable, $dbconn, $hlpfile;
    include ("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._WEBLINKSADMIN."</b></font></center>";
    CloseTable();
    echo "<br>";

    if (!authorised(0, 'Web links::Link', '::', ACCESS_EDIT)) {
        echo _WEBLINKSEDITNOAUTH;
        include 'footer.php';
        return;
    }

    OpenTable();
    $column = &$pntable['links_modrequest_column'];
    $result = $dbconn->Execute("SELECT $column[requestid], $column[lid], $column[cat_id], $column[title], $column[url], $column[description], $column[modifysubmitter] FROM $pntable[links_modrequest] WHERE $column[brokenlink]=0 ORDER BY $column[requestid]");
    // FTO Check Database errors
    if (!$result) {
        PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
        die();
    }

    $totalmodrequests = $result->PO_RecordCount();
    echo "<center><font class=\"pn-title\"><b>"._USERMODREQUEST." ($totalmodrequests)</b></font></center><br><br><br>";
    echo "<table width=\"95%\"><tr><td>";
//ADODBtag MoveNext while+list+row

//FTO test EOF
    while(!$result->EOF) {
        list($requestid, $lid, $cid, $title, $url, $description, $modifysubmitter)=$result->fields ;
        $result->MoveNext();
        $column = &$pntable['links_links_column'];
        $result2 = $dbconn->Execute("SELECT $column[cat_id], $column[title], $column[url], $column[description], $column[submitter] FROM $pntable[links_links] WHERE $column[lid]=$lid");
//ADODBtag list+row
        list($origcid, $origtitle, $origurl, $origdescription, $owner)=$result2->fields;
        $column = &$pntable['users_column'];
        $result7 = $dbconn->Execute("SELECT $column[email] FROM $pntable[users] WHERE $column[uname]='$modifysubmitter'");
//ADODBtag list+row
        list($modifysubmitteremail)=$result7->fields;
        $result8 = $dbconn->Execute("SELECT $column[email] FROM $pntable[users] WHERE $column[uname]='$owner'");
        $cidtitle=CatPath($cid,0,0,0);
        $origcidtitle=CatPath($origcid,0,0,0);
//ADODBtag list+row
        list($owneremail)=$result8->fields;
        $title = stripslashes($title);
        $description = stripslashes($description);
        if ($owner=="") {
        $owner="administration";
    }
        echo "<table border=\"1\" bordercolor=\"black\" cellpadding=\"5\" cellspacing=\"0\" align=\"center\" width=\"450\">"
            ."<tr>"
            ."<td>"
            ."<table width=\"100%\" bgcolor=\"$bgcolor2\">"
            ."<tr>"
            ."<td valign=\"top\" width=\"45%\"><b>"._ORIGINAL."</b></td>"
            ."<td rowspan=\"5\" valign=\"top\" align=\"left\"><font class=\"pn-sub\"><br>"._DESCRIPTION.":<br>$origdescription</font></td>"
            ."</tr>"
            ."<tr><td valign=\"top\" width=\"45%\"><font class=\"pn-sub\">"._TITLE.": $origtitle</td></tr>"
            ."<tr><td valign=\"top\" width=\"45%\"><font class=\"pn-sub\">"._URL.": <a href=\"$origurl\">$origurl</a></td></tr>"
        ."<tr><td valign=\"top\" width=\"45%\"><font class=\"pn-sub\">"._CATEGORY.": $origcidtitle</td></tr>"
            ."</table>"
            ."</td>"
            ."</tr>"
            ."<tr>"
            ."<td>"
            ."<table width=\"100%\">"
            ."<tr>"
            ."<td valign=\"top\" width=\"45%\"><b>"._PROPOSED."</b></td>"
            ."<td rowspan=\"5\" valign=\"top\" align=\"left\"><font class=\"pn-sub\"><br>"._DESCRIPTION.":<br>$description</font></td>"
            ."</tr>"
            ."<tr><td valign=\"top\" width=\"45%\"><font class=\"pn-sub\">"._TITLE.": $title</td></tr>"
            ."<tr><td valign=\"top\" width=\"45%\"><font class=\"pn-sub\">"._URL.": <a href=\"$url\">$url</a></td></tr>"
        ."<tr><td valign=\"top\" width=\"45%\"><font class=\"pn-sub\">"._CATEGORY.": $cidtitle</td></tr>"
            ."</table>"
            ."</td>"
            ."</tr>"
            ."</table>"
            ."<table align=\"center\" width=\"450\">"
            ."<tr>";
        if ($modifysubmitteremail=="") {
        echo "<td align=\"left\"><font class=\"pn-sub\">"._SUBMITTER.":  $modifysubmitter</font></td>";
    } else {
        echo "<td align=\"left\"><font class=\"pn-sub\">"._SUBMITTER.":  <a href=\"mailto:$modifysubmitteremail\">$modifysubmitter</a></font></td>";
    }
        if ($owneremail=="") {
        echo "<td align=\"center\"><font class=\"pn-sub\">"._OWNER.":  $owner</font></td>";
    } else {
        echo "<td align=\"center\"><font class=\"pn-sub\">"._OWNER.": <a href=\"mailto:$owneremail\">$owner</a></font></td>";
    }
        echo "<td align=\"right\"><font class=\"pn-sub\">( <a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksChangeModRequests&amp;requestid=$requestid\">"._ACCEPT."</a> / <a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksChangeIgnoreRequests&amp;requestid=$requestid\">"._IGNORE."</a> )</font></td></tr></table>";
    }
    if ($totalmodrequests == 0) {
    echo "<center>"._NOMODREQUESTS."</center><br><br>";
    }
    echo "</td></tr></table>";
    CloseTable();
    include ("footer.php");
}

function LinksChangeModRequests($requestid) {
    global $pntable, $dbconn;

    csrfcheck();

    $column = &$pntable['links_modrequest_column'];
    $result = $dbconn->Execute("SELECT $column[requestid], $column[lid], $column[cat_id], $column[title], $column[url], $column[description] FROM $pntable[links_modrequest] WHERE $column[requestid]=$requestid");
    // FTO Check Database errors
    if (!$result) {
        PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
        die();
    }


//ADODBtag MoveNext while+list+row

//FTO test EOF
    while(!$result->EOF) {
        list($requestid, $lid, $cid, $title, $url, $description)=$result->fields;
        $result->MoveNext();

        $linkcolumn = &$pntable['links_links_column'];
        $linktable = $pntable['links_links'];
        $catcolumn = &$pntable['links_categories_column'];
        $cattable = $pntable['links_categories'];
        $result = $dbconn->Execute("SELECT $linkcolumn[title],
                                         $catcolumn[title]
                                  FROM $linktable, $cattable
                                  WHERE $linkcolumn[lid] = $lid
                                  AND $linkcolumn[cat_id] = $catcolumn[cat_id]");
//ADODBtag list+row
        list($title, $cattitle) = $result->fields;
        if (!authorised(0, 'Web links::Link', "$title:$cattitle:$lid", ACCESS_EDIT)) {
            include 'header.php';
            echo _WEBLINKSEDITNOAUTH;
            include 'footer.php';
            return;
        }

        $title = stripslashes($title);
        $description = stripslashes($description);
        $column = &$pntable['links_links_column'];
        $dbconn->Execute("UPDATE $pntable[links_links] SET $column[cat_id]=$cid, $column[title]='$title', $column[url]='$url', $column[description]='$description' WHERE $column[lid] = $lid");
        $column = &$pntable['links_modrequest_column'];
        $dbconn->Execute("DELETE FROM $pntable[links_modrequest] WHERE $column[requestid]=$requestid");
    }
    pnRedirect('admin.php?module='.$GLOBALS['module'].'&op=LinksListModRequests');
}

function LinksChangeIgnoreRequests($requestid) {
    global $pntable, $dbconn;

    csrfcheck();

    $column = &$pntable['links_modrequest_column'];
    $result = $dbconn->Execute("SELECT $column[lid] FROM $pntable[links_modrequest] WHERE $column[requestid]=$requestid");
//ADODBtag list+row
    list($lid) = $result->fields;
    $result->Close();
    $linkcolumn = &$pntable['links_links_column'];
    $linktable = $pntable['links_links'];
    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $linkcolumn[title],
                                     $catcolumn[title]
                              FROM $linktable, $cattable
                              WHERE $linkcolumn[lid] = $lid
                              AND $linkcolumn[cat_id] = $catcolumn[cat_id]");
//ADODBtag list+row
    list($title, $cattitle) = $result->fields;
    $result->Close();
    if (!authorised(0, 'Web links::Link', "$title:$cattitle:$lid", ACCESS_EDIT)) {
        include 'header.php';
        echo _WEBLINKSEDITNOAUTH;
        include 'footer.php';
        return;
    }

    $column = &$pntable['links_modrequest_column'];
    $dbconn->Execute("DELETE FROM $pntable[links_modrequest] WHERE $column[requestid]=$requestid");
    pnRedirect('admin.php?module='.$GLOBALS['module'].'&op=LinksListModRequests');
}

function LinksCleanVotes() {
    global $pntable, $dbconn;

    if (!authorised(0, 'Web links::Link', '::', ACCESS_EDIT)) {
        include 'header.php';
        echo _WEBLINKSEDITNOAUTH;
        include 'footer.php';
        return;
    }
    $column = &$pntable['links_votedata_column'];
    $totalvoteresult = $dbconn->Execute("SELECT DISTINCT $column[ratinglid] FROM $pntable[links_votedata]");
    // FTO Check Database errors
    if (!$totalvoteresult) {
        PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
        die();
    }

//ADODBtag MoveNext while+list+row
//FTO Test EOF
    while(!$totalvoteresult->EOF) {
        list($lid)=$totalvoteresult->fields;
        $totalvoteresult->MoveNext();
        $column = &$pntable['links_votedata_column'];
        $voteresult = $dbconn->Execute("SELECT $column[rating], $column[ratinguser], $column[ratingcomments] FROM $pntable[links_votedata] WHERE $column[ratinglid] = $lid");
        $totalvotesDB = $voteresult->PO_RecordCount();
        include ("voteinclude.php");
        $column = &$pntable['links_links_column'];
        $dbconn->Execute("UPDATE $pntable[links_links] SET $column[linkratingsummary]=$finalrating,$column[totalvotes]=$totalvotesDB,$column[totalcomments]=$truecomments WHERE $column[lid] = $lid");
    }
    pnRedirect('admin.php?module='.$GLOBALS['module'].'&op=links');
}

function LinksModLinkS($lid, $title, $url, $description, $name, $email, $hits, $cat) {
    global $pntable, $dbconn;

    csrfcheck();

    $linkcolumn = &$pntable['links_links_column'];
    $linktable = $pntable['links_links'];
    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $linkcolumn[title],
                                     $catcolumn[title]
                              FROM $linktable, $cattable
                              WHERE $linkcolumn[lid] = $lid
                              AND $linkcolumn[cat_id] = $catcolumn[cat_id]");
//ADODBtag list+row
    list($oldtitle, $cattitle) = $result->fields;
    $result->Close();
    if (!authorised(0, 'Web links::Link', "$oldtitle:$cattitle:$lid", ACCESS_EDIT)) {
        include 'header.php';
        echo _WEBLINKSEDITNOAUTH;
        include 'footer.php';
        return;
    }

    $title = stripslashes(FixQuotes($title));
    $url = stripslashes(FixQuotes($url));
    $description = stripslashes(FixQuotes($description));
    $name = stripslashes(FixQuotes($name));
    $email = stripslashes(FixQuotes($email));
    $column = &$pntable['links_links_column'];
    $dbconn->Execute("UPDATE $pntable[links_links] SET $column[cat_id]='$cat', $column[title]='$title', $column[url]='$url', $column[description]='$description', $column[name]='$name', $column[email]='$email', $column[hits]='$hits' WHERE $column[lid]=$lid");
    pnRedirect('admin.php?module='.$GLOBALS['module'].'&op=links');
}

function LinksDelLink($lid) {
    global $pntable, $dbconn;

    csrfcheck();

    $linkcolumn = &$pntable['links_links_column'];
    $linktable = $pntable['links_links'];
    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $linkcolumn[title],
                                     $catcolumn[title]
                              FROM $linktable, $cattable
                              WHERE $linkcolumn[lid] = $lid
                              AND $linkcolumn[cat_id] = $catcolumn[cat_id]");
//ADODBtag list+row
    list($oldtitle, $cattitle) = $result->fields;
    $result->Close();
    if (!authorised(0, 'Web links::Link', "$oldtitle:$cattitle:$lid", ACCESS_DELETE)) {
        include 'header.php';
        echo _WEBLINKSDELNOAUTH;
        include 'footer.php';
        return;
    }
    $column = &$pntable['links_links_column'];
    $dbconn->Execute("DELETE FROM $pntable[links_links] WHERE $column[lid]=$lid");
    pnRedirect('admin.php?module='.$GLOBALS['module'].'&op=links');
}

function LinksModCat($cid) {
    global $pntable, $dbconn, $hlpfile;
    include ("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._WEBLINKSADMIN."</b></font></center>";
    CloseTable();
    echo "<br>";
    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._MODCATEGORY."</b></font></center><br><br>";
    $column = &$pntable['links_categories_column'];
    $result=$dbconn->Execute("SELECT $column[title], $column[cdescription] FROM $pntable[links_categories] WHERE $column[cat_id]=$cid");
//ADODBtag list+row
    list($title,$cdescription) = $result->fields;

    if (!authorised(0, 'Web links::Category', "$title::$cid", ACCESS_EDIT)) {
        echo _WEBLINKSCATEDITNOAUTH;
        CloseTable();
        include 'footer.php';
        return;
    }

    $cdescription = stripslashes($cdescription);
    echo "<form action=\"admin.php\" method=\"post\">"
        .""._NAME.": <input type=\"text\" name=\"title\" value=\"$title\" size=\"51\" maxlength=\"50\"><br>"
        .""._DESCRIPTION.":<br><textarea name=\"cdescription\" cols=\"60\" rows=\"10\">$cdescription</textarea><br>"
        ."<input type=\"hidden\" name=\"sub\" value=\"0\">"
        ."<input type=\"hidden\" name=\"cid\" value=\"$cid\">"
        ."<input type=\"hidden\" name=\"module\" value=\"".$GLOBALS['module']."\">"
        ."<input type=\"hidden\" name=\"op\" value=\"LinksModCatS\">"
        ."<table border=\"0\"><tr><td>"
        ."<input type=\"submit\" value=\""._SAVECHANGES."\"></form></td><td>"
        ."<form action=\"admin.php\" method=\"post\">"
        ."<input type=\"hidden\" name=\"sub\" value=\"0\">"
        ."<input type=\"hidden\" name=\"ok\" value=\"0\">"
        ."<input type=\"hidden\" name=\"cid\" value=\"$cid\">"
        ."<input type=\"hidden\" name=\"module\" value=\"".$GLOBALS['module']."\">"
        ."<input type=\"hidden\" name=\"op\" value=\"LinksDelCat\">"
        ."<input type=\"submit\" value=\""._DELETE."\"></form></td></tr></table>";
    CloseTable();
    include("footer.php");
}

function LinksModCatS($cid, $sub, $title, $cdescription) {
    global $pntable, $dbconn;

    csrfcheck();

    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $catcolumn[title]
                              FROM $cattable
                              WHERE $catcolumn[cat_id] = $cid");
//ADODBtag list+row
    list($oldtitle) = $result->fields;
    $result->Close();
    if (!authorised(0, 'Web links::Category', "$oldtitle::$cid", ACCESS_EDIT)) {
        echo _WEBLINKSCATEDITNOAUTH;
        CloseTable();
        include 'footer.php';
        return;
    }

    $column = &$pntable['links_categories_column'];
    $dbconn->Execute("UPDATE $pntable[links_categories] SET $column[title]='$title',
    $column[cdescription]='$cdescription' WHERE $column[cat_id]=$cid");
    pnRedirect('admin.php?module='.$GLOBALS['module'].'&op=links');
}

function LinksDelCat($cid, $sub, $ok=0) {
    global $pntable, $dbconn, $hlpfile;

    csrfcheck();

    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $catcolumn[title]
                              FROM $cattable
                              WHERE $catcolumn[cat_id] = $cid");
//ADODBtag list+row
    list($oldtitle) = $result->fields;
    $result->Close();
    if (!authorised(0, 'Web links::Category', "$oldtitle::$cid", ACCESS_DELETE)) {
        echo _WEBLINKSCATDELNOAUTH;
        CloseTable();
        include 'footer.php';
        return;
    }

    if($ok==1) {
        $column = &$pntable['links_categories_column'];
        $dbconn->Execute("DELETE FROM $pntable[links_categories] WHERE $column[cat_id]=$cid");
        $column = &$pntable['links_links_column'];
        $dbconn->Execute("DELETE FROM $pntable[links_links] WHERE $column[cat_id]=$cid");
        pnRedirect('admin.php?module='.$GLOBALS['module'].'&&op=links');
    } else {
        include("header.php");
        GraphicAdmin($hlpfile);
        OpenTable();
        echo "<br><center><font class=\"pn-title\">";
        echo "<b>"._DELCATWARNING."</b><br><br>";
    }
    // need GET to POST
    echo "[ <a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksDelCat&amp;cid=$cid&amp;sub=$sub&amp;ok=1\">"._YES."</a> | <a href=\"admin.php?module=".$GLOBALS['module']."&op=links\">"._NO."</a> ]<br><br>";
    CloseTable();
    include("footer.php");
}

function LinksDelNew($lid) {
    global $pntable, $dbconn;

    csrfcheck();

    if (!authorised(0, 'Web links::Link', '::$lid', ACCESS_DELETE)) {
        include 'header.php';
        echo _WEBLINKSDELNOAUTH;
        CloseTable();
        include 'footer.php';
        return;
    }

    $column = &$pntable['links_newlink_column'];
    $dbconn->Execute("DELETE FROM $pntable[links_newlink] WHERE $column[lid]=$lid");

    pnRedirect('admin.php?module='.$GLOBALS['module'].'&op=links');
}

function LinksAddCat($pid, $title, $cdescription) {
    global $pntable, $dbconn, $hlpfile;

    csrfcheck();

    if (!authorised(0, 'Web links::Category', "$title::", ACCESS_ADD)) {
        echo _WEBLINKSCATADDNOAUTH;
        CloseTable();
        include 'footer.php';
        return;
    }

    $column = &$pntable['links_categories_column'];

    $result = $dbconn->Execute("SELECT $column[cat_id] FROM $pntable[links_categories] WHERE $column[title]='$title' AND $column[parent_id]=$pid");

    if (!$result->EOF) {
        include("header.php");
        GraphicAdmin($hlpfile);
        OpenTable();
        echo "<br><center><font class=\"pn-title\">"
            ."<b>"._ERRORTHECATEGORY." $title "._ALREADYEXIST."</b><br><br>"
            .""._GOBACK."<br><br>";
        CloseTable();
        include("footer.php");
        return;
    }
    $column = &$pntable['links_categories_column'];

// FTO : Add SEQ suffix to avoid conflict name with ORACLE
    $nextid = $dbconn->GenId("{$pntable['links_categories']}_SEQ");

    $dbconn->Execute("INSERT INTO $pntable[links_categories] ($column[cat_id],
    $column[parent_id], $column[title], $column[cdescription]) VALUES ($nextid, $pid, '$title', '$cdescription')");

    pnRedirect('admin.php?module='.$GLOBALS['module'].'&op=links');
}

function LinksAddEditorial($linkid, $editorialtitle, $editorialtext) {
    global $aid, $pntable, $dbconn, $hlpfile;

    csrfcheck();

    $linkcolumn = &$pntable['links_links_column'];
    $linktable = $pntable['links_links'];
    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $linkcolumn[title],
                                     $catcolumn[title]
                              FROM $linktable, $cattable
                              WHERE $linkcolumn[lid] = $linkid
                              AND $linkcolumn[cat_id] = $catcolumn[cat_id]");
//ADODBtag list+row
    list($title, $cattitle) = $result->fields;
    if (!authorised(0, 'Web links::Link', "$title:$cattitle:$linkid", ACCESS_EDIT)) {
        include 'header.php';
        echo _WEBLINKSEDITNOAUTH;
        include 'footer.php';
        return;
    }

    $editorialtext = stripslashes(FixQuotes($editorialtext));
    $column = &$pntable['links_editorials_column'];

    //FTO Use a php date time to stay compatible with
    //    all databases.
    $now=$dbconn->DBTimeStamp(mktime());
    $dbconn->Execute("INSERT INTO $pntable[links_editorials] ($column[linkid], $column[adminid], $column[editorialtimestamp], $column[editorialtext], $column[editorialtitle]) VALUES ($linkid, '$aid', $now, '$editorialtext', '$editorialtitle')");

    include("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><br>"
        ."<font size=3>"
        .""._EDITORIALADDED."<br><br>"
        ."[ <a href=\"admin.php?module=".$GLOBALS['module']."&op=links\">"._WEBLINKSADMIN."</a> ]<br><br>";
    echo "$linkid  $adminid, $editorialtitle, $editorialtext";
    CloseTable();
    include("footer.php");
}

function LinksModEditorial($linkid, $editorialtitle, $editorialtext) {
    global $pntable, $dbconn, $hlpfile;

    csrfcheck();

    $linkcolumn = &$pntable['links_links_column'];
    $linktable = $pntable['links_links'];
    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $linkcolumn[title],
                                     $catcolumn[title]
                              FROM $linktable, $cattable
                              WHERE $linkcolumn[lid] = $linkid
                              AND $linkcolumn[cat_id] = $catcolumn[cat_id]");
//ADODBtag list+row
    list($title, $cattitle) = $result->fields;
    if (!authorised(0, 'Web links::Link', "$title:$cattitle:$linkid", ACCESS_EDIT)) {
        include 'header.php';
        echo _WEBLINKSEDITNOAUTH;
        include 'footer.php';
        return;
    }

    $editorialtext = stripslashes(FixQuotes($editorialtext));
    $column = &$pntable['links_editorials_column'];
    $dbconn->Execute("UPDATE $pntable[links_editorials] SET $column[editorialtext]='$editorialtext', $column[editorialtitle]='$editorialtitle' WHERE $column[linkid]=$linkid");
    include("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<br><center>"
    ."<font class=\"pn-title\">"
    .""._EDITORIALMODIFIED."<br><br>"
    ."[ <a href=\"admin.php?module=".$GLOBALS['module']."&op=links\">"._WEBLINKSADMIN."</a> ]<br><br>";
    CloseTable();
    include("footer.php");
}

function LinksDelEditorial($linkid) {
    global $pntable, $dbconn, $hlpfile;

    csrfcheck();

    $linkcolumn = &$pntable['links_links_column'];
    $linktable = $pntable['links_links'];
    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $linkcolumn[title],
                                     $catcolumn[title]
                              FROM $linktable, $cattable
                              WHERE $linkcolumn[lid] = $linkid
                              AND $linkcolumn[cat_id] = $catcolumn[cat_id]");
//ADODBtag list+row
    list($title, $cattitle) = $result->fields;
    if (!authorised(0, 'Web links::Link', "$title:$cattitle:$linkid", ACCESS_DELETE)) {
        include 'header.php';
        echo _WEBLINKSDELNOAUTH;
        include 'footer.php';
        return;
    }

    $column = &$pntable['links_editorials_column'];
    $dbconn->Execute("DELETE FROM $pntable[links_editorials] WHERE $column[linkid]=$linkid");
    include("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<br><center>"
    ."<font class=\"pn-title\">"
    .""._EDITORIALREMOVED."<br><br>"
    ."[ <a href=\"admin.php?module=".$GLOBALS['module']."&op=links\">"._WEBLINKSADMIN."</a> ]<br><br>";
    CloseTable();
    include("footer.php");
}

function LinksLinkCheck() {
    global $pntable, $dbconn, $hlpfile;
    include ("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._WEBLINKSADMIN."</b></font></center>";
    CloseTable();
    echo "<br>";

    if (!authorised(0, 'Web links::Link', '::', ACCESS_EDIT)) {
        echo _WEBLINKSEDITNOAUTH;
        include 'footer.php';
        return;
    }

    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._LINKVALIDATION."</b></font><br>"
    ."<a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksValidate&amp;cid=0\">"._CHECKALLLINKS."</a><br><br>"
    ."<b>"._CHECKCATEGORIES."</b><br><br><font class=\"pn-sub\">";
    $column = &$pntable['links_categories_column'];
    $result = $dbconn->Execute("SELECT $column[cat_id], $column[title] FROM $pntable[links_categories] ORDER BY $column[title]");
    echo "<form method=\"post\" action=\"admin.php\">"
         ."<input type=\"hidden\" name=\"module\" value=\"".$GLOBALS['module']."\">"
         ."<input type=\"hidden\" name=\"op\" value=\"LinksValidate\">"
         ."<select name=\"cid\">".CatList(0,0,"")."</select>"
         ."&nbsp;<input type=\"submit\" name=\"Ok\" value=\""._CHECKCATEGORIES."\"></form>"
         ."</font></center>";
    CloseTable();
    include ("footer.php");
}

function LinksValidate($cid) {
    global $bgcolor2, $pntable, $dbconn, $hlpfile;
    
    csrfcheck();

    include ("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._WEBLINKSADMIN."</b></font></center>";
    CloseTable();
    echo "<br>";

    $catcolumn = &$pntable['links_categories_column'];
    $cattable = $pntable['links_categories'];
    $result = $dbconn->Execute("SELECT $catcolumn[title]
                              FROM $cattable
                              WHERE $catcolumn[cat_id] = $cid");
//ADODBtag list+row
    list($cattitle) = $result->fields;
    $result->Close();
    if (!authorised(0, 'Web links::Link', ":$cattitle:$lid", ACCESS_EDIT)) {
        echo _WEBLINKSEDITNOAUTH;
        CloseTable();
        include 'footer.php';
        return;
    }

    OpenTable();
    $transfertitle = str_replace ("_", "", $ttitle);
    /* Check ALL Links */
    echo "<table width=100% border=0>";
    if ($cid==0) {
    echo "<tr><td colspan=\"3\"><center><b>"._CHECKALLLINKS."</b><br>"._BEPATIENT."</center><br><br></td></tr>";
    $column = &$pntable['links_links_column'];
    $result = $dbconn->Execute("SELECT $column[lid], $column[title], $column[url], $column[name], $column[email], $column[submitter] FROM $pntable[links_links] ORDER BY $column[title]");
    }
    /* Check Categories */
    if ($cid!=0) {
    $column = &$pntable['links_categories_column'];
    $result = $dbconn->Execute("SELECT $column[title] FROM $pntable[links_categories] WHERE $column[cat_id]=$cid");
//ADODBtag list+row
    list($transfertitle) = $result->fields;
    echo "<tr><td colspan=\"3\"><center><b>"._CHECKCATEGORIES.": $transfertitle</b><br>"._BEPATIENT."</center><br><br></td></tr>";
    $column = &$pntable['links_links_column'];
    $result = $dbconn->Execute("SELECT $column[lid], $column[title], $column[url], $column[name], $column[email], $column[submitter] FROM $pntable[links_links] WHERE $column[cat_id]=$cid");
    }
    echo "<tr><td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._STATUS."</b></td><td bgcolor=\"$bgcolor2\" width=\"100%\"><b>"._LINKTITLE."</b></td><td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._FUNCTIONS."</b></td></tr>";
//ADODBtag MoveNext while+list+row

    // FTO Check Database errors
    if (!$result) {
        PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
        die();
    }
    // FTO test EOF
    while(!$result->EOF) {
        list($lid, $title, $url, $name, $email, $submitter) = $result->fields ;
        $result->MoveNext();
        if ($url == 'http://' OR $url == '' )
        {
          $fp = false;
        }
        else    {
          $vurl = parse_url($url);
          $fp = fsockopen($vurl['host'], 80, $errno, $errstr, 15);
        }
        if (!$fp){
          echo "<tr><td align=\"center\"><b>&nbsp;&nbsp;"._FAILED."&nbsp;&nbsp;</b></td>"
          ."<td>&nbsp;&nbsp;<a href=\"$url\" target=\"new\">$title</a>&nbsp;&nbsp;</td>"
          ."<td align=\"center\"><font class=\"pn-normal\">&nbsp;&nbsp;[ <a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksModLink&amp;lid=$lid\">"._EDIT."</a> | <a href=\"admin.php?module=".$GLOBALS['module']."&op=LinksDelLink&amp;lid=$lid\">"._DELETE."</a> ]&nbsp;&nbsp;</font>"
          ."</td></tr>";
        }

        if ($fp){
          echo "<tr><td align=\"center\">&nbsp;&nbsp;"._OK."&nbsp;&nbsp;</td>"
          ."<td>&nbsp;&nbsp;<a href=\"$url\" target=\"new\">$title</a>&nbsp;&nbsp;</td>"
          ."<td align=\"center\"><font class=\"pn-normal\">&nbsp;&nbsp;"._NONE."&nbsp;&nbsp;</font>"
          ."</td></tr>";
        }
    }
    echo "</table>";
    CloseTable();
    include ("footer.php");
}

function LinksAddLink($new, $lid, $title, $url, $cat, $description, $name, $email, $submitter) {
    global $pntable, $dbconn, $hlpfile;
    global $nukeurl, $sitename;
    if (!authorised(0, 'Web links::Link', '$title::', ACCESS_ADD)) {
        include 'header.php';
        echo _WEBLINKSADDNOAUTH;
        include 'footer.php';
        return;
    }

    /* Get a quick count - Wandrer */
    $column = &$pntable['links_links_column'];
    $result = $dbconn->Execute("SELECT COUNT(*) FROM $pntable[links_links] WHERE $column[url]='$url'");
//ADODBtag list+row
    list($numrows) = $result->fields;
    if ($numrows>0) {
    include("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._WEBLINKSADMIN."</b></font></center>";
    CloseTable();
    echo "<br>";
    OpenTable();
    echo "<br><center>"
        ."<font class=\"pn-title\">"
        ."<b>"._ERRORURLEXIST."</b><br><br>"
        .""._GOBACK."<br><br>";
    CloseTable();
    include("footer.php");
    } else {
/* Check if Title exist */
    if ($title=="") {
    include("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._WEBLINKSADMIN."</b></font></center>";
    CloseTable();
    echo "<br>";
    OpenTable();
    echo "<br><center>"
        ."<font class=\"pn-title\">"
        ."<b>"._ERRORNOTITLE."</b><br><br>"
        .""._GOBACK."<br><br>";
    CloseTable();
    include("footer.php");
    }
/* Check if URL exist */
    if ($url=="") {
    include("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._WEBLINKSADMIN."</b></font></center>";
    CloseTable();
    echo "<br>";
    OpenTable();
    echo "<br><center>"
        ."<font class=\"pn-title\">"
        ."<b>"._ERRORNOURL."</b><br><br>"
        .""._GOBACK."<br><br>";
    CloseTable();
    include("footer.php");
    }
// Check if Description exist
    if ($description=="") {
    include("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<center><font class=\"pn-title\"><b>"._WEBLINKSADMIN."</b></font></center>";
    CloseTable();
    echo "<br>";
    OpenTable();
    echo "<br><center>"
        ."<font class=\"pn-title\">"
        ."<b>"._ERRORNODESCRIPTION."</b><br><br>"
        .""._GOBACK."<br><br>";
    CloseTable();
    include("footer.php");
    }
    $title = stripslashes(FixQuotes($title));
    $url = stripslashes(FixQuotes($url));
    $description = stripslashes(FixQuotes($description));
    $name = stripslashes(FixQuotes($name));
    $email = stripslashes(FixQuotes($email));
    $column = &$pntable['links_links_column'];
// FTO : Add SEQ suffix to avoid conflict name with ORACLE
    $nextid = $dbconn->GenId("{$pntable['links_links']}_SEQ");

    //FTO Use a php date time to stay compatible with
    //    all databases.
    $now=$dbconn->DBTimeStamp(mktime());

    $dbconn->Execute("INSERT INTO $pntable[links_links] ($column[lid], $column[cat_id],
    $column[title], $column[url], $column[description], $column[date], $column[name],
    $column[email], $column[hits], $column[submitter], $column[linkratingsummary],
    $column[totalvotes], $column[totalcomments]) VALUES ($nextid, '$cat', '$title',
    '$url', '$description', $now, '$name', '$email', '0','$submitter',0,0,0)");

    include("header.php");
    GraphicAdmin($hlpfile);
    OpenTable();
    echo "<br><center>";
    echo "<font class=\"pn-title\">";
    echo ""._NEWLINKADDED."<br><br>";
    echo "[ <a href=\"admin.php?module=".$GLOBALS['module']."&op=links\">"._WEBLINKSADMIN."</a> ]</center><br><br>";
    CloseTable();
    if ($new==1) {
    $column = &$pntable['links_newlink_column'];
    $dbconn->Execute("DELETE FROM $pntable[links_newlink] WHERE $column[lid]=$lid");
    if ($email=="") {
    } else {
        $subject = ""._YOURLINKAT." $sitename";
        $message = ""._HELLO." $name:\n\n"._WEAPPROVED."\n\n"._LINKTITLE
        .": $title\n"._URL.": $url\n"._DESCRIPTION.": $description\n\n\n"
        ._YOUCANBROWSEUS." $nukeurl/modules.php?op=modload&name=Web_Links&file=index\n\n"
        ._THANKS4YOURSUBMISSION."\n\n$sitename "._TEAM."";
        $from = "$sitename";
//        mail($email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion(), "-f$from");
        mail($email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion());
    }
    }
    include("footer.php");
    }
}

function web_links_admin_main($var)
{
global $op;
extract($var);

if ((!authorised(0, 'Web links::Category', '::', ACCESS_EDIT)) && (!authorised(0, 'Web links::Link', '::', ACCESS_MODERATE))) {
    include 'header.php';
    echo _WEBLINKSNOAUTH;
    include 'footer.php';
} else {
    switch ($op) {

        case "links":
            links();
            break;

        case "LinksDelNew":
            LinksDelNew($var['lid']);
            break;

        case "LinksAddCat":
            LinksAddCat($var['cid'], $var['title'], $var['cdescription']);
            break;

        case "LinksAddLink":
            LinksAddLink($var['new'], $var['lid'], $var['title'], $var['url'], $var['cat'], $var['description'], $var['name'], $var['email'], $var['submitter']);
            break;

        case "LinksAddEditorial":
            LinksAddEditorial($var['linkid'], $var['editorialtitle'], $var['editorialtext']);
            break;

        case "LinksModEditorial":
            LinksModEditorial($var['linkid'], $var['editorialtitle'], $var['editorialtext']);
            break;

        case "LinksLinkCheck":
            LinksLinkCheck();
            break;

        case "LinksValidate":
            LinksValidate($var['cid']);
            break;

        case "LinksDelEditorial":
            LinksDelEditorial($var['linkid']);
            break;

        case "LinksCleanVotes":
            LinksCleanVotes();
            break;

        case "LinksListBrokenLinks":
            LinksListBrokenLinks();
            break;

        case "LinksDelBrokenLinks":
            LinksDelBrokenLinks($var['lid']);
            break;

        case "LinksIgnoreBrokenLinks":
            LinksIgnoreBrokenLinks($var['lid']);
            break;

        case "LinksListModRequests":
            LinksListModRequests();
            break;

        case "LinksChangeModRequests":
            LinksChangeModRequests($var['requestid']);
            break;

        case "LinksChangeIgnoreRequests":
            LinksChangeIgnoreRequests($var['requestid']);
            break;

        case "LinksDelCat":
            LinksDelCat($var['cid'], $var['sub'], $var['ok']);
            break;

        case "LinksModCat":
            LinksModCat($var['cat']);
            break;

        case "LinksModCatS":
            LinksModCatS($var['cid'], $var['sub'], $var['title'], $var['cdescription']);
            break;

        case "LinksModLink":
            LinksModLink($var['lid']);
            break;

        case "LinksModLinkS":
            LinksModLinkS($var['lid'], $var['title'], $var['url'], $var['description'], $var['name'], $var['email'], $var['hits'], $var['cat']);
            break;

        case "LinksDelLink":
            LinksDelLink($var['lid']);
            break;

        case "LinksDelVote":
            LinksDelVote($var['lid'], $var['rid']);
            break;

        case "LinksDelComment":
            LinksDelComment($var['lid'], $var['rid']);
            break;

        default: 
            links();
            break;
    }
}

}
?>
Return current item: ProNuke. Postnuke To Oracle