<?php

@( (bool)FALSE === strpos( $_SERVER['REQUEST_URI'], basename( __FILE__ ) ) ) OR exit( '!! ACCESS DENIED !!' );
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: myyp.php,v 1.14.2.10 2004/08/15 12:58:20 kirilt Exp $



/************************************************************************/
/*  My Yellow Pages v1.0 (MPN Addon)                                    */
/*  Kazumi Ono AKA onokazu                                              */
/*  2001-7-3                                                            */
/*  http://www.myweb.ne.jp                                              */
/*  http://mpn.phpwebhosting.com                                        */
/************************************************************************/
/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)            */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
//2001-03-08 hombergs: Added missing translate calls
//2001-03-03 hombergs: Added missing translate calls

include_once("class.myfunctions.$phpEx");
include_once("module.errorhandler.$phpEx");

$eh = new ErrorHandler;
$mf = new MyFunctions;
$mf->table = $mpnTables['yp_categories'];
$mf->id = "cid";
$mf->itemtable = $mpnTables['yp_business'];
$mf->itemid = "bid";
$mf->ratingtable = $mpnTables['yp_votedata'];

function businesses() {
        global $hlpfile, $admin, $mpnTables, $phpEx, $eh, $mf;
        OpenTable();
        echo "<center><font size=3><b>".translate("My Yellow Pages Configuration")."</b></font><br><br>";
        $result=mysql_query("select count(*) from ".$mpnTables['yp_business']." where status>0");
        list($numrows) = mysql_fetch_row($result);
        echo "<font size=2>".translate("There are")." <b>$numrows</b> ".translate("businesses in the database")."";
    // Temporarily 'homeless' businesses (to be revised in admin.php breakup)
        $result = mysql_query("select count(*) from ".$mpnTables['yp_brokenlink']."");
        list($totalbrokenlinks) = mysql_fetch_row($result);
    if($totalbrokenlinks>0){
        $totalbrokenlinks = "<font color=\"#ff0000\"><b>$totalbrokenlinks</b></font>";
    }
        $result2 = mysql_query("select count(*) from ".$mpnTables['yp_modrequest']."");
        list($totalmodrequests) = mysql_fetch_row($result2);
    if($totalmodrequests>0){
        $totalmodrequests = "<font color=\"#ff0000\"><b>$totalmodrequests</b></font>";
    }
    echo "<br>[&nbsp;<a href=admin.$phpEx?fct=myyp&op=listBrokenLinks>".translate("Broken Link Reports")." ($totalbrokenlinks)</a>&nbsp;|&nbsp;<a href=admin.$phpEx?fct=myyp&op=listModReq>".translate("Business Modification Requests")." ($totalmodrequests)</a>&nbsp;]</b><br></center>";
        CloseTable();
        echo "<br>";
// List businesses waiting for validation
        $result = mysql_query("select bid, cid, title, url, email, phone, fax, summary, address, city, state, zipcode, country, logourl, submitter from ".$mpnTables['yp_business']." where status=0 order by date DESC");
        $numrows = mysql_num_rows($result);
        if ($numrows>0) {
            OpenTable();
            echo "
            </center><font size=3><b>".translate("Businesses Waiting for Validation")."</b></font><br><br>";
            while(list($bid, $cid, $title, $url, $email, $phone, $fax, $summary, $address, $city, $state, $zipcode, $country, $logourl, $submitter) = mysql_fetch_row($result)) {
        $result2 = mysql_query("select description from ".$mpnTables['yp_businesstxt']." where bid=$bid");
        list($description) = mysql_fetch_row($result2);

        // Kiril: New Sanitizer

        $sanity_ary = compact( 'title', 'url', 'email', 'phone', 'fax', 'summary', 'address', 'city', 'state', 'zipcode', 'country', 'logourl', 'submitter', 'description' );
        $_SERVER['SAN'] -> slashIT( $sanity_ary );
        extract( $sanity_ary );
        unset( $sanity_ary );

        $prev_desc = $description;

        $_SERVER['SAN'] -> adjustFormat( $prev_desc, 3, 10 );

        // End New Saintizer

        $url = urldecode($url);
        $logourl = urldecode($logourl);

        /*
        $title = $myts->makeTboxData4Show($title);
        $url = $myts->makeTboxData4Show($url);
        $url = urldecode($url);
        $email = $myts->makeTboxData4Show($email);
        $phone = $myts->makeTboxData4Show($phone);
        $fax = $myts->makeTboxData4Show($fax);
        $summary = $myts->makeTboxData4Show($summary);
        $address = $myts->makeTboxData4Show($address);
        $city = $myts->makeTboxData4Show($city);
        $state = $myts->makeTboxData4Show($state);
        $zipcode = $myts->makeTboxData4Show($zipcode);
        $country = $myts->makeTboxData4Show($country);
        $logourl = $myts->makeTboxData4Show($logourl);
        $logourl = urldecode($logourl);
        $description = $myts->makeTareaData4Show($description);
        $submitter = $myts->makeTboxData4Show($submitter);*/


        echo "<b>" .translate("Submitter: ")."</b>$submitter<br>";
        echo "<b>".translate("Business Title: ")."</b>$title<br>";
        echo "<b>".translate("Category: ")."</b>";
        $category=$mf->getPathFromId($cid);
        echo "".$category."<br>";
                echo "<b>".translate("URL: ")."</b>$url<br>";
        echo "<b>".translate("Email: ")."</b>$email<br>";
        echo "<b>".translate("Phone: ")."</b>$phone<br>";
        echo "<b>".translate("Fax: ")."</b>$fax<br>";
        echo "<b>".translate("Summary: ")."</b>$summary<br>";
        echo "<b>".translate("Address: ")."</b>$address<br>";
        echo "<b>".translate("City: ")."</b>$city<br>";
        echo "<b>".translate("State/Province: ")."</b>$state<br>";
        echo "<b>".translate("Zip Code: ")."</b>$zipcode<br>";
        echo "<b>".translate("Country: ")."</b>$country<br>";
        echo "<b>".translate("Logo URL: ")."</b>$logourl<br>";
        echo "<b>".translate("Description: ")."</b><br>$prev_desc";

            echo "<br><br><input type=button value=".translate("Approve")." onclick=\"location='admin.$phpEx?fct=myyp&op=approve&bid=$bid'\">&nbsp;<input type=button value=".translate("Delete")." onclick=\"location='admin.$phpEx?fct=myyp&op=delNewBiz&bid=$bid'\"><br><hr noshade><br>";
        }
    CloseTable();
        echo "<br>";
        }
// Add a New Main Category
        OpenTable();
    echo "<br><form method=post action=admin.$phpEx?fct=myyp>\n";
        echo "<font size=3><b>".translate("Add a MAIN Category")."</b></font><br><br>".translate("Name: ")."<input type=text name=title size=30 maxlength=50><br>";
    echo "".translate("Image URL (OPTIONAL Image height will be resized to 50): ")."<br><input type=\"text\" name=\"imgurl\" size=\"100\" maxlength=\"150\"><br><br>";
    echo "<input type=hidden name=cid value=0>\n";
    echo "<input type=hidden name=op value=addCat>";
    echo "<input class='button' type=submit value=".translate("Add")."><br></form>";
        CloseTable();
        echo "<br>";
// Add a New Sub-Category
        $result = mysql_query("select * from ".$mpnTables['yp_categories']." order by title");
        $numrows = mysql_num_rows($result);
        if ($numrows>0) {
        OpenTable();
            echo "</center><form method=post action=admin.".$phpEx."?fct=myyp>";
        echo "<font size=3><b>".translate("Add a SUB-Category")."</b></font><br /><br />".translate("Name: ")."<input type=text name=title size=30 maxlength=50>&nbsp;".translate("in")."&nbsp;";
    $mf->makeMySelBox();
#   echo "<br>".translate("Image URL (OPTIONAL Image height will be resized to 50): ")."<br><input type=\"text\" name=\"imgurl\" size=\"100\" maxlength=\"150\">\n";
        echo "<input type=hidden name=op value=addCat><br><br>";
    echo "<input class='button' type=submit value=".translate("Add")."><br></form>";
    CloseTable();
    echo "<br>";
// If there is a subcategory, add a New Business
    $result2=mysql_query("select count(*) from ".$mpnTables['yp_categories']."");
    list($num_rows)=mysql_fetch_row($result2);
    if($num_rows>0){
        OpenTable();
        echo "
        </center><form method=post action=admin.".$phpEx."?fct=myyp>
        <font size=3><b>".translate("Add a New Business")."</b></font><br><br>
        <table width=\"80%\"><tr><td align=\"right\">
        ".translate("Business Name: ")."</td><td>";
        echo "<input type=text name=title size=50 maxlength=100>";
        echo "</td></tr><tr><td align=\"right\">".translate("URL: ")."</td><td>";
        echo "<input type=text name=url size=50 maxlength=100 value=\"http://\">";
        echo "</td></tr>";
        echo "<tr><td align=\"right\">".translate("Category: ")."</td><td>";
        $mf->makeMySelBox();
        echo "</td></tr><tr><td></td><td></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Email: ")."</td><td>\n";
        echo "<input type=text name=email size=50 maxlength=60></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Phone: ")."</td><td>\n";
        echo "<input type=text name=phone size=25 maxlength=20></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Fax: ")."</td><td>\n";
        echo "<input type=text name=fax size=25 maxlength=20></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Summary:  (150 characters max)")."</td><td>\n";
        echo "<input type=text name=summary size=60 maxlength=150></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Address: ")."</td><td>\n";
        echo "<input type=text name=address size=60 maxlength=100></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("City: ")."</td><td>\n";
        echo "<input type=text name=city size=\"50\" maxlength=\"50\"></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("State/Province: ")."</td><td>\n";
        echo "<input type=text name=\"state\" size=\"25\" maxlength=\"25\"></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Zip Code: ")."</td><td>\n";
        echo "<input type=text name=zipcode size=\"15\" maxlength=\"10\"></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Country: ")."</td><td>\n";
        makeCountrySelBox();
        echo "</td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Logo URL: ")."</td><td>\n";
        echo "<input type=\"text\" name=\"logourl\" size=\"50\" maxlength=\"150\" value=\"http://\"></td></tr>\n";
        echo "<tr><td align=\"right\" valign=\"top\">".translate("Description:")."</td><td>\n";
        echo "<textarea name=description cols=60 rows=5></textarea>\n";
        echo "</td></tr>\n";
        echo "</td></tr></table>\n";

        // Kiril: New Sanitizer

        addFormatOption();

        echo "<input type='hidden' name='clickit_form' value='description' />\n";
        echo "<input type='hidden' name='stripit_form' value='title|url|email|phone|fax|summary|address|city|state|zipcode|logourl' />\n";
        echo "<input type='hidden' name='mpn_sectype' value='2' />\n";

        // End Sanitizer

        echo "<br><input type=\"hidden\" name=\"op\" value=\"addBiz\"></input><center><input type=\"submit\" class=\"button\" value=\"".translate("Submit")."\"></input></center>\n";
        echo "</form></td></tr></table></td></tr></table><br>";
    }
// Modify Category
        OpenTable();
        echo "
        </center><form method=post action=admin.".$phpEx."?fct=myyp>
        <font size=3><b>".translate("Modify Category")."</b></font><br><br>";
        $result=mysql_query("select cid, title from ".$mpnTables['yp_categories']." order by title");
        echo "".translate("Category: ")."";
        $mf->makeMySelBox();
        echo "<br><br>\n";
        echo "<input type=hidden name=op value=modCat>\n";
        echo "<input class='button' type=submit value=".translate("Modify").">\n";
    echo "</form>";
    CloseTable();
    echo "<br>";
    }
// Modify Business
    $result = mysql_query("select count(*) from ".$mpnTables['yp_business']."");
    list($numrows) = mysql_fetch_row($result);
    if ($numrows>0) {
        OpenTable();
// 2004-03-07 - AvW - Changed method from post to get because all functions in this script use http_get_vars to retrieve the given bid.
        echo "<form method='get' action=\"admin.$phpEx\">\n";
        echo "<font size=3><b>".translate("Modify Business")."</b></font><br><br>\n";
        echo "".translate("Business ID: ")."<input type='text' name='bid' size=12 maxlength=11>\n";
        echo "<input type='hidden' name='fct' value='myyp'>\n";
        echo "<input type='hidden' name='op' value='modBiz'><br><br>\n";
        echo "<input class='button' type='submit' value=".translate("Modify")."></form>\n";
        echo "</td></tr></table></td></tr></table><br>";
    }
    OpenTable();
    echo "<center>Script from Kazumi Ono, <a href=mailto:webmaster@myweb.ne.jp>webmaster@myweb.ne.jp</a><br>";
    echo "For the latest version of this script, please go to <a href=\"http://www.myphpnuke.com\">www.myphpnuke.com.</a></center>";
    CloseTable();
}

function modBiz() {
    global $mpnTables, $phpEx, $_REQUEST, $eh, $mf;
        $bid = $_REQUEST['bid'];
        global $anonymous;
        OpenTable();
        $result = mysql_query("select cid, title, url, email, phone, fax, summary, address, city, state, zipcode, country, logourl from ".$mpnTables['yp_business']." where bid=$bid") or $eh->show("0013");
        echo "<font size=3><b>Modify Business</b></FONT><br><br>";

        list($cid, $title, $url, $email, $phone, $fax, $summary, $address, $city, $state, $zipcode, $country, $logourl) = mysql_fetch_row($result);

        $result = mysql_query("select description from ".$mpnTables['yp_businesstxt']." where bid=$bid");
        list($description)=mysql_fetch_row($result);

        // Kiril: New Sanitizer

        $sanity_ary = compact( 'title', 'url', 'email', 'phone', 'fax', 'summary', 'address', 'city', 'state', 'zipcode', 'country', 'logourl', 'description' );
        $_SERVER['SAN'] -> slashIT( $sanity_ary );
        extract( $sanity_ary );
        unset( $sanity_ary );

        // End New Saintizer

        $url = urldecode($url);
        $logourl = urldecode($logourl);

       /*
        $title = $myts->makeTboxData4Edit($title);
        $url = $myts->makeTboxData4Edit($url);
        $url = urldecode($url);
        $email = $myts->makeTboxData4Edit($email);
        $phone = $myts->makeTboxData4Edit($phone);
        $fax = $myts->makeTboxData4Edit($fax);
        $summary = $myts->makeTboxData4Edit($summary);
        $address = $myts->makeTboxData4Edit($address);
        $city = $myts->makeTboxData4Edit($city);
        $state = $myts->makeTboxData4Edit($state);
        $zipcode = $myts->makeTboxData4Edit($zipcode);
        $country = $myts->makeTboxData4Edit($country);
        $logourl = $myts->makeTboxData4Edit($logourl);
        $logourl = urldecode($logourl);
        */

        echo "<form method=post action=admin.".$phpEx."?fct=myyp>\n";
        echo "<table width=\"80%\"><tr><td align=\"right\">";
        echo "<font color=Blue>".translate("Business ID: ")."</td><td><font color=Black><b>$bid</b></td></tr>";
        echo "<tr><td align=\"right\">".translate("Business Title: ")."</td><td><input type=text name=title value=\"$title\" size=50 maxlength=100></input></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("URL: ")."</td><td><input type=text name=url value=\"$url\" size=50 maxlength=100></input></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Email: ")."</td><td><input type=text name=email value=\"$email\" size=50 maxlength=60></input></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Phone: ")."</td><td><input type=text name=phone value=\"$phone\" size=25 maxlength=20></input></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Fax: ")."</td><td><input type=text name=fax value=\"$fax\" size=25 maxlength=20></input></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Summary: ")."</td><td><input type=text name=summary value=\"$summary\" size=50 maxlength=150></input></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Address: ")."</td><td><input type=text name=address value=\"$address\" size=50 maxlength=100></input></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("City: ")."</td><td><input type=text name=city value=\"$city\" size=50 maxlength=50></input></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("State/Province: ")."</td><td><input type=text name=state value=\"$state\" size=30 maxlength=25></input></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Zip Code: ")."</td><td><input type=text name=zipcode value=\"$zipcode\" size=20 maxlength=10></input></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Country: ")."</td><td>";
    makeCountrySelBox($country);
        echo "</td></tr>\n";
		echo "<tr><td align=\"right\">".translate("Logo URL: ")."</td><td><input type=text name=logourl value=\"$logourl\" size=50 maxlength=150></input></td></tr>\n";
        echo "<tr><td align=\"right\">".translate("Description: ")."</td><td><textarea name=description cols=60 rows=5>$description</textarea><br>";
        echo "<tr><td align=\"right\">".translate("Category: ")."</td><td>";
        $mf->makeMySelBox($cid);
        echo "</td></tr></table>\n";

        // Kiril: New Sanitizer

        addFormatOption();

        echo "<input type='hidden' name='clickit_form' value='description' />\n";
        echo "<input type='hidden' name='stripit_form' value='title|url|email|phone|fax|summary|address|city|state|zipcode|logourl' />\n";
        echo "<input type='hidden' name='mpn_sectype' value='2' />\n";

        // End Sanitizer

        echo "<input type=hidden name=bid value=$bid></input>\n";
        echo "<input type=hidden name=op value=modBizS><input class='button' type=submit value=".translate("Modify")."> [ <a href=admin.$phpEx?fct=myyp&op=delBiz&bid=$bid>".translate("Delete")."</a> ]</form>\n";
        echo "<hr>";

        $result5=mysql_query("SELECT count(*) FROM ".$mpnTables['yp_votedata']."");
        list($totalvotes) = mysql_num_rows($result5);
        echo "<table valign=top width=100%>\n";
        echo "<tr><td colspan=7><b>" .translate("Business Votes (total votes:")." $totalvotes)</b><br><br></td></tr>\n";
        // Show Registered Users Votes
        $result5=mysql_query("SELECT ratingid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ".$mpnTables['yp_votedata']." WHERE bid = $bid AND ratinguser != '$anonymous' ORDER BY ratingtimestamp DESC");
        $votes = mysql_num_rows($result5);
        echo "<tr><td colspan=7><br><br><b>" .translate("Registered User Votes (total votes:")." $votes)</b><br><br></td></tr>\n";
        echo "<tr><td><b>" .translate("User")."  </b></td><td><b>" .translate("IP Address")."  </b></td><td><b>" .translate("Rating")."  </b></td><td><b>" .translate("User AVG Rating")."  </b></td><td><b>" .translate("Total Ratings")."  </b></td><td><b>" .translate("Date")."  </b></td></font></b><td align=\"center\"><b>" .translate("Delete")."</b></td></tr>\n";
        if ($votes == 0){
        echo "<tr><td align=\"center\" colspan=\"7\"><font color=cccccc>" .translate("No Registered User Votes")."<br></font></td></tr>\n";
        }
        $x=0;
        $colorswitch="dddddd";
        while(list($ratingid, $ratinguser, $rating, $ratinghostname, $ratingtimestamp)=mysql_fetch_row($result5)) {
            $formatted_date = strftime(translate("datestring4"),strtotime($ratingtimestamp));
        //Individual user information
            $result2=mysql_query("SELECT rating FROM ".$mpnTables['yp_votedata']." WHERE ratinguser = '$ratinguser'");
            $uservotes = mysql_num_rows($result2);
            $useravgrating = 0;
            while(list($rating2) = mysql_fetch_row($result2)){
            $useravgrating = $useravgrating + $rating2;
        }
            $useravgrating = $useravgrating / $uservotes;
            $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\">$uservotes</td><td bgcolor=\"$colorswitch\">$formatted_date</font></b></td><td bgcolor=\"$colorswitch\" align=\"center\"><b><a href=admin.$phpEx?fct=myyp&op=delVote&bid=$bid&rid=$ratingid>X</a></b></td></tr>\n";
            $x++;
            if ($colorswitch=="dddddd"){
            $colorswitch="ffffff";
            } else {
            $colorswitch="dddddd";
        }
        }
    // Show Unregistered Users Votes
        $result5=mysql_query("SELECT ratingid, rating, ratinghostname, ratingtimestamp FROM ".$mpnTables['yp_votedata']." WHERE bid = $bid AND ratinguser = '$anonymous' ORDER BY ratingtimestamp DESC");
        $votes = mysql_num_rows($result5);
        echo "<tr><td colspan=7><b><br><br>" .translate("Unregistered User Votes (total votes:")." $votes)</b><br><br></td></tr>\n";
        echo "<tr><td colspan=2><b>" .translate("IP Address")."  </b></td><td colspan=3><b>" .translate("Rating")."  </b></td><td><b>" .translate("Date")."  </b></font></td><td align=\"center\"><b>" .translate("Delete")."</b></td><br></tr>";
        if ($votes == 0) {
        echo "<tr><td colspan=\"7\" align=\"center\"><font color=cccccc>" .translate("No Unregistered User Votes")."<br></font></td></tr>";
        }
        $x=0;
        $colorswitch="dddddd";
        while(list($ratingid, $rating, $ratinghostname, $ratingtimestamp)=mysql_fetch_row($result5)) {
            $formatted_date = strftime(translate("datestring4"),strtotime($ratingtimestamp));
            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\" aling=\"center\"><b><a href=admin.$phpEx?fct=myyp&op=delVote&bid=$bid&rid=$ratingid>X</a></b></td></tr>";
            $x++;
            if ($colorswitch=="dddddd") {
            $colorswitch="ffffff";
            } else {
            $colorswitch="dddddd";
        }
        }
        echo "<tr><td colspan=\"6\">&nbsp;<br></td></tr>\n";
        echo "</table>\n";
        echo "</td></tr></table></td></tr></table><br>";

        include ("footer.$phpEx");
}

function delVote() {
        global $mpnTables, $phpEx, $_REQUEST, $eh, $mf;
        $rid = $_REQUEST['rid'];
        $bid = $_REQUEST['bid'];
        $query = "delete from ".$mpnTables['yp_votedata']." where ratingid=$rid";
        mysql_query($query) or $eh->show("0013");
        $mf->updaterating($bid);
        echo "".translate("Vote data deleted.")."";
        echo "<br><br><a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";
}
function listBrokenLinks() {
        global $mpnTables, $phpEx, $eh;
        $result = mysql_query("select * from ".$mpnTables['yp_brokenlink']." order by reportid");
        $totalbrokenlinks = mysql_num_rows($result);
        echo "<table align=\"center\" width=\"90%\">";
        if ($totalbrokenlinks==0) {
            echo "<center><font size=3>".translate("No reported broken links.")."</font></center><br><br><br>";
        } else {
        echo "<center><font size=3><b>".translate("User Reported Broken Links")." ($totalbrokenlinks)</b></font></center><br><br><center>
    ".translate("Ignore (Ignores the report and only deletes the <b><i>broken link report</i></b>)")."<br>
    ".translate("Delete (Deletes <b><i>the reported business information</i></b> and <b><i>broken link reports</i></b> for the business.)")."</center><br><br><br>";
            $colorswitch="dddddd";
            echo "
            <tr>
            <td><b>Biz Name</b></td>
            <td><b>" .translate("Sender")."</b></td>
            <td><b>" .translate("Business Submitter")."</b></td>
            <td><b>" .translate("Ignore")."</b></td>
            <td><b>" .translate("Delete")."</b></td>
            </tr>";
            while(list($reportid, $bid, $sender, $ip)=mysql_fetch_row($result)){
                $result2 = mysql_query("select title, url, submitter from ".$mpnTables['yp_business']." where bid=$bid");
            if ($sender != '$anonymous') {
                $result3 = mysql_query("select email from mpn_users where uname='$sender'");
                list($email)=mysql_fetch_row($result3);
            }
                list($title, $url, $owner)=mysql_fetch_row($result2);
            $url=urldecode($url);
                $result4 = mysql_query("select email from mpn_users where uname='$owner'");
                list($owneremail)=mysql_fetch_row($result4);
                echo "<tr><td bgcolor=$colorswitch><a href=$url>$title</a></td>";
                if ($email=='') { echo "<td bgcolor=$colorswitch>$sender ($ip)";
            } else {
                echo "<td bgcolor=$colorswitch><a href=mailto:$email>$sender</a> ($ip)";
            }
                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.$phpEx?fct=myyp&op=ignoreBrokenLinks&bid=$bid>X</a></center></td>
                    <td bgcolor=$colorswitch><center><a href=admin.$phpEx?fct=myyp&op=delBrokenLinks&bid=$bid>X</a></center>
                    </td>
                    </tr>";
                if ($colorswitch=="dddddd") {
                $colorswitch="ffffff";
            } else {
                $colorswitch="dddddd";
            }
            }
        }
        echo "</table>";
}
function delBrokenLinks() {
        global $mpnTables, $phpEx, $_REQUEST, $eh;
        $bid = $_REQUEST['bid'];
        $query = "delete from ".$mpnTables['yp_brokenlink']." where bid=$bid";
        mysql_query($query) or $eh->show("0013");
        $query = "delete from ".$mpnTables['yp_business']." where bid=$bid";
        mysql_query($query) or $eh->show("0013");
        echo "".translate("Business deleted.")."";
        echo "<br><br><a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";
}
function ignoreBrokenLinks() {
        global $mpnTables, $phpEx, $_REQUEST, $eh, $mf;
        $query = "delete from ".$mpnTables['yp_brokenlink']." where bid=".$_REQUEST['bid']."";
        mysql_query($query) or $eh->show("0013");
        echo "".translate("Broken link report deleted.")."";
        echo "<br><br><a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";
}
function listModReq() {
        global $mpnTables, $phpEx, $eh, $mf;
        $result = mysql_query("select * from ".$mpnTables['yp_modrequest']." order by requestid");
        $totalmodrequests = mysql_num_rows($result);
        echo "<center><font size=3><b>".translate("User Business Modification Requests")." ($totalmodrequests)</b></font></center><br><br><br>";
        echo "<table width=95%><tr><td>";

        while(list($requestid, $bid, $cid, $title, $url, $email, $phone, $fax, $summary, $address, $city, $state, $zipcode, $country, $logourl, $description, $modifysubmitter)=mysql_fetch_row($result))
        {
            // Kiril: New Sanitizer

            $sanity_ary = compact( 'title', 'url', 'email', 'phone', 'fax', 'summary', 'address', 'city', 'state', 'zipcode', 'country', 'logourl', 'description' );
            $_SERVER['SAN'] -> slashIT( $sanity_ary );
            extract( $sanity_ary );
            unset( $sanity_ary );

            // End New Saintizer

            $url = urldecode($url);
            $logourl = urldecode($logourl);

            $_SERVER['SAN'] -> adjustFormat( $description, 3, 10 );


        $result2 = mysql_query("select cid, title, url, email, phone, fax, summary, address, city, state, zipcode, country, logourl, submitter from ".$mpnTables['yp_business']." where bid=$bid");
        list($origcid, $origtitle, $origurl, $origemail, $origphone, $origfax, $origsummary, $origaddress, $origcity, $origstate, $origzipcode, $origcountry, $origlogourl, $owner)=mysql_fetch_row($result2);
        $result2 = mysql_query("select description from ".$mpnTables['yp_businesstxt']." where bid=$bid");
        list($origdescription) = mysql_fetch_row($result2);

        // Kiril: New Sanitizer

        $sanity_ary = compact( 'origtitle', 'origurl', 'origemail', 'origphone', 'origfax', 'origsummary', 'origaddress', 'origcity', 'origstate', 'origzipcode', 'origcountry', 'origlogourl', 'origdescription' );
        $_SERVER['SAN'] -> slashIT( $sanity_ary );
        extract( $sanity_ary );
        unset( $sanity_ary );

        $_SERVER['SAN'] -> adjustFormat( $origdescription, 3, 10 );

        // End New Saintizer

        $origurl = urldecode($origurl);
        $origlogourl = urldecode($origlogourl);


        $result7 = mysql_query("select email from mpn_users where uname='$modifysubmitter'");
        $result8 = mysql_query("select email from mpn_users where uname='$owner'");
        $cidtitle=$mf->getPathFromId($cid);
        $origcidtitle=$mf->getPathFromId($origcid);
        list($modifysubmitteremail)=mysql_fetch_row($result7);
        list($owneremail)=mysql_fetch_row($result8);


        /*$title = $myts->makeTboxData4Show($title);
            $url = $myts->makeTboxData4Show($url);
        $url = urldecode($url);
            $email = $myts->makeTboxData4Show($email);
            $phone = $myts->makeTboxData4Show($phone);
            $fax = $myts->makeTboxData4Show($fax);
            $summary = $myts->makeTboxData4Show($summary);
            $address = $myts->makeTboxData4Show($address);
            $city = $myts->makeTboxData4Show($city);
            $state = $myts->makeTboxData4Show($state);
            $zipcode = $myts->makeTboxData4Show($zipcode);
            $country = $myts->makeTboxData4Show($country);
            $logourl = $myts->makeTboxData4Show($logourl);
        $logourl = urldecode($logourl);
            $description = $myts->makeTareaData4Show($description);

            $origurl = $myts->makeTboxData4Show($origurl);
        $origurl = urldecode($origurl);
            $origemail = $myts->makeTboxData4Show($origemail);
            $origphone = $myts->makeTboxData4Show($origphone);
            $origfax = $myts->makeTboxData4Show($origfax);
            $origsummary = $myts->makeTboxData4Show($origsummary);
            $origaddress = $myts->makeTboxData4Show($origaddress);
            $origcity = $myts->makeTboxData4Show($origcity);
            $origstate = $myts->makeTboxData4Show($origstate);
            $origzipcode = $myts->makeTboxData4Show($origzipcode);
            $origcountry = $myts->makeTboxData4Show($origcountry);
            $origlogourl = $myts->makeTboxData4Show($origlogourl);
        $origlogourl = urldecode($origlogourl);
            $origdescription = $myts->makeTareaData4Show($origdescription);*/


            if ($owner=="") {
            $owner="administration";
        }
            echo "<table border=1 bordercolor=black cellpadding=5 cellspacing=0 align=center width=450><tr><td>
            <table width=100% bgcolor=dddddd>
                <tr>
                <td valign=top width=45%><b>".translate("Original")."</b></td>
            <td rowspan=14 valign=top align=left><font size=1><br>".translate("Summary:")."<br>$origsummary
                <br><br>".translate("Description:")."<br>$origdescription</font></td>
                </tr>
                <tr><td valign=top width=45%><font size=1>".translate("Title:")." $origtitle</td></tr>
                <tr><td valign=top width=45%><font size=1>".translate("URL:")." <a href=$origurl>$origurl</a></td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Cat:")." $origcidtitle</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Email:")." $origemail</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Phone:")." $origphone</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Fax:")." $origfax</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Address:")." $origaddress</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("City:")." $origcity</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("State/Province:")." $origstate</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Zip Code:")." $origzipcode</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Country:")." $origcountry</td></tr>\n";

            if ( ! empty( $image ) && $image != '' )
            {
                echo "<tr><td valign=top width=45%><font size=1>".translate("Logo:")." <img src=\"$origlogourl\"></td></tr>\n";
            }

            echo "</table></td></tr><tr><td>
            <table width=100%>
                <tr>
                <td valign=top width=45%><b>".translate("Proposed")."</b></td>
                <td rowspan=14 valign=top align=left><font size=1><br>".translate("Summary:")."<br>$summary
                <br><br>".translate("Description:")."<br>$description</font></td>
                </tr>
                <tr><td valign=top width=45%><font size=1>".translate("Title:")." $title</td></tr>
                <tr><td valign=top width=45%><font size=1>".translate("URL:")." <a href=$url>$url</a></td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Cat:")." $cidtitle</td></tr>
        <tr><td valign=top width=45%><font size=1>".translate("Email:")." $email</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Phone:")." $phone</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Fax:")." $fax</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Address:")." $address</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("City:")." $city</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("State/Province:")." $state</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Zip Code:")." $zipcode</td></tr>
            <tr><td valign=top width=45%><font size=1>".translate("Country:")." $country</td></tr>\n";

            if ( ! empty( $image ) && $image != '' )
            {
                echo "<tr><td valign=top width=45%><font size=1>".translate("Logo:")." <img src=\"$logourl\"></td></tr>\n";
            }

            echo "</table></td></tr></table>
            <table align=center width=450>
            <tr>";
            if ($modifysubmitteremail=="") {
            echo "<td align=left><font size=1>".translate("Submitter").":  $modifysubmitter</font></td>";
        } else {
            echo "<td align=left><font size=1>".translate("Submitter").":  <a href=mailto:$modifysubmitteremail>$modifysubmitter</a></font></td>";
        }
            if ($owneremail=="") {
            echo "<td align=center><font size=1>".translate("Owner").":  $owner</font></td>";
        } else {
            echo "<td align=center><font size=1>".translate("Owner").": <a href=mailto:$owneremail>$owner</a></font></td>";
        }
            echo "
                <td align=right><font size=1>( <a href=admin.$phpEx?fct=myyp&op=changeModReq&requestid=$requestid>".translate("Accept")."</a> / <a href=admin.$phpEx?fct=myyp&op=ignoreModReq&requestid=$requestid>".translate("Ignore")."</a> )</font></td>
            </tr>
            </table><br><br>";
        }
        echo "</td></tr></table>";
}
function changeModReq() {
        global $mpnTables, $phpEx, $_REQUEST, $eh;
        $requestid = $_REQUEST['requestid'];
        $query = "select bid, cid, title, url, email, phone, fax, summary, address, city, state, zipcode, country, logourl, description from ".$mpnTables['yp_modrequest']." where requestid='$requestid'";
        $result = mysql_query($query);
        while(list($bid, $cid, $title, $url, $email, $phone, $fax, $summary, $address, $city, $state, $zipcode, $country, $logourl, $description)=mysql_fetch_row($result)) {

/*        $title = stripslashes($title);
        $url = stripslashes($url);
        $email = stripslashes($email);
        $phone = stripslashes($phone);
        $fax = stripslashes($fax);
        $summary = stripslashes($summary);
        $address = stripslashes($address);
        $city = stripslashes($city);
        $state = stripslashes($state);
        $zipcode = stripslashes($zipcode);
        $country = stripslashes($country);
        $logourl = stripslashes($logourl);
        $description = stripslashes($description);

        $title = addslashes($title);
        $url = addslashes($url);
        $email = addslashes($email);
        $phone = addslashes($phone);
        $fax = addslashes($fax);
        $summary = addslashes($summary);
        $address = addslashes($address);
        $city = addslashes($city);
        $state = addslashes($state);
        $zipcode = addslashes($zipcode);
        $country = addslashes($country);
        $logourl = addslashes($logourl);
        $description = addslashes($description);*/

        mysql_query("UPDATE ".$mpnTables['yp_business']." SET cid='$cid',title='$title',url='$url',email='$email',phone='$phone',fax='$fax',summary='$summary',address='$address',city='$city',state='$state',zipcode='$zipcode',country='$country',logourl='$logourl', status=2, date=now() WHERE bid='$bid'")
      or $eh->show("0013");
    mysql_query("UPDATE ".$mpnTables['yp_businesstxt']." SET description='$description' WHERE bid='$bid'")
      or $eh->show("0013");
        mysql_query("delete from ".$mpnTables['yp_modrequest']." where requestid='$requestid'") or $eh->show("0013");
        }
        echo "".translate("Database Updated Successfully!")."";
        echo "<br><br><a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";
}
function ignoreModReq() {
        global $mpnTables, $phpEx, $_REQUEST, $eh;
        $query= "delete from ".$mpnTables['yp_modrequest']." where requestid=".$_REQUEST['requestid']."";
        mysql_query($query) or $eh->show("0013");
        echo "".translate("Modification Request Deleted.")."";
        echo "<br><br><a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";
}

function modBizS() {
        global $mpnTables, $phpEx, $HTTP_POST_VARS, $eh;
        $cid = $HTTP_POST_VARS["cid"];
        $url = $HTTP_POST_VARS["url"];
    if (($url) || ($url!="")) {
        $url = trim($url);
        if ($url == "http://") {
            $url = "";
        } else {
            if (!stristr($url, "http://")) {
                $url = "http://" . $url;
            }
        $url = urlencode($url);
        //$url = $myts->makeTboxData4Save($url);
        }
    }
    $logourl = $HTTP_POST_VARS["logourl"];
    if (($logourl) || ($logourl!="")) {
        $logourl = trim($logourl);
        if ($logourl == "http://" || $logourl == "" ) {
            $logourl = "";
        } else {
            if (!stristr($logourl, "http://")) {
                $logourl = "http://" . $logourl;
            }
        $logourl = urlencode($logourl);
        //$logourl =  $myts->makeTboxData4Save($logourl);
        }
        }
        $title = $HTTP_POST_VARS["title"];
        $email = $HTTP_POST_VARS["email"];
        $phone =  $HTTP_POST_VARS["phone"];
        $fax =  $HTTP_POST_VARS["fax"];
        $summary = $HTTP_POST_VARS["summary"];
        $address =  $HTTP_POST_VARS["address"];
        $city =  $HTTP_POST_VARS["city"];
        $state =  $HTTP_POST_VARS["state"];
        $zipcode =  $HTTP_POST_VARS["zipcode"];
        $country = $HTTP_POST_VARS["country"];

        $description = $HTTP_POST_VARS["description"];

            // Kiril: New Sanitizer

            $sanity_ary = compact( 'title', 'url', 'email', 'phone', 'fax', 'summary', 'address', 'city', 'state', 'zipcode', 'country', 'logourl', 'description' );
            $_SERVER['SAN'] -> slashIT( $sanity_ary );
            extract( $sanity_ary );
            unset( $sanity_ary );

            // End New Saintizer


        mysql_query("update ".$mpnTables['yp_business']." set cid='$cid', title='$title', url='$url', email='$email', phone='$phone', fax='$fax', summary='$summary', address='$address', city='$city', state='$state', zipcode='$zipcode', country='$country', logourl='$logourl', status=2, date=now() where bid=".$HTTP_POST_VARS['bid']."")  or $eh->show("0013");
        mysql_query("update ".$mpnTables['yp_businesstxt']." set description='$description' where bid=".$HTTP_POST_VARS['bid']."")  or $eh->show("0013");
        echo "".translate("Database Updated Successfully!")."";
        echo "<br><br><a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";
}
function delBiz() {
        global $mpnTables, $phpEx, $_REQUEST, $eh;
        $query = "delete from ".$mpnTables['yp_business']." where bid=".$_REQUEST['bid']."";
        mysql_query($query) or $eh->show("0013");
    $query = "delete from ".$mpnTables['yp_businesstxt']." where bid=".$_REQUEST['bid']."";
    mysql_query($query) or $eh->show("0013");
    $query = "delete from ".$mpnTables['yp_votedata']." where bid=".$_REQUEST['bid']."";
    mysql_query($query) or $eh->show("0013");
        echo "".translate("Business Deleted.")."";
        echo "<br><br><a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";
}
function modCat() {
        global $mpnTables, $phpEx, $HTTP_POST_VARS, $eh;
        $cid = $HTTP_POST_VARS["cid"];
        OpenTable();
        echo "<font size=3><b>".translate("Modify Category")."</b></font><br><br>";
    $result=mysql_query("select pid, title, imgurl from ".$mpnTables['yp_categories']." where cid=$cid");
    list($pid,$title,$imgurl) = mysql_fetch_row($result);


    $title = stripslashes($title);
    $imgurl = stripslashes($imgurl);


    $imgurl = urldecode($imgurl);

    echo "<form action=admin.".$phpEx."?fct=myyp method=post>".translate("Name: ")."<input type=text name=title value=\"$title\" size=51 maxlength=50><br><br>".translate("Image URL (OPTIONAL and Only valid for main categories. Image height will be resized to 50): ")."<br><input type=text name=imgurl value=\"$imgurl\" size=100 maxlength=150><br>
    <input type=hidden name=pid value=\"$pid\">
    <input type=hidden name=cid value=$cid>
    <input type=hidden name=op value=modCatS><br>
    <input class='button' type=submit value=".translate("Save Changes").">
    <input class='button' type=button value=".translate("Delete")." onClick=\"location='admin.".$phpEx."?fct=myyp&pid=$pid&cid=$cid&op=delCat'\">
    </form>";
        echo "</td></tr></table></td></tr></table><br>";
}
function modCatS() {
        global $mpnTables, $phpEx, $HTTP_POST_VARS, $eh;
        $cid =  $HTTP_POST_VARS['cid'];
        $sid =  $HTTP_POST_VARS['pid'];
        $title =  addslashes($HTTP_POST_VARS['title']);

        if (($HTTP_POST_VARS["imgurl"]) || ($HTTP_POST_VARS["imgurl"]!="")) {
            $imgurl = trim($HTTP_POST_VARS["imgurl"]);
            if ($imgurl == "http://") {
            $imgurl = "";
            } else {
                if (!stristr($imgurl, "http://")) {
                    $imgurl = "http://" . $imgurl;
                }
            $imgurl = urlencode($imgurl);
            $imgurl = addslashes($imgurl);
            }
        }
        mysql_query("update ".$mpnTables['yp_categories']." set title='$title', imgurl='$imgurl' where cid=$cid") or $eh->show("0013");

        echo "Category modified successfully.";
        echo "<br><br><a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";
}
function delCat() {
        global $mpnTables, $phpEx, $_REQUEST, $eh, $mf;
        $cid =  $_REQUEST['cid'];
        if(isset( $_REQUEST['ok'] )){
            $ok =  $_REQUEST['ok'];
        }
        else
        {
            $ok = null;
        }

        if($ok==1) {
        //get all subcategories under the specified category
        $arr=$mf->getAllChildId($cid);
        for($i=0;$i<sizeof($arr);$i++){
            //get all businesses in each subcategory
            $result=mysql_query("select bid from ".$mpnTables['yp_business']." where cid=".$arr[$i]."") or $eh->show("0013");
            //now for each business, delete the text data and vote ata associated with the business
            while(list($bid)=mysql_fetch_row($result)){
                mysql_query("delete from ".$mpnTables['yp_businesstxt']." where bid=".$bid."") or $eh->show("0013");
                mysql_query("delete from ".$mpnTables['yp_votedata']." where bid=".$bid."") or $eh->show("0013");
                mysql_query("delete from ".$mpnTables['yp_business']." where bid=".$bid."") or $eh->show("0013");
            }

            //all businesses for each subcategory is deleted, now delete the subcategory data
                    mysql_query("delete from ".$mpnTables['yp_categories']." where cid=".$arr[$i]."") or $eh->show("0013");
        }
        //all subcategory and associated data are deleted, now delete category data and its associated data
        $result=mysql_query("select bid from ".$mpnTables['yp_business']." where cid=".$cid."") or $eh->show("0013");
        while(list($bid)=mysql_fetch_row($result)){
            mysql_query("delete from ".$mpnTables['yp_business']." where bid=$bid") or $eh->show("0013");
            mysql_query("delete from ".$mpnTables['yp_businesstxt']." where bid=$bid") or $eh->show("0013");
            mysql_query("delete from ".$mpnTables['yp_votedata']." where bid=".$bid."") or $eh->show("0013");
        }
            mysql_query("delete from ".$mpnTables['yp_categories']." where cid=$cid") or $eh->show("0013");

        echo "Category deleted successfully.";
            echo "<br><br><a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";
        } else {
        OpenTable();
        echo "<center>";
        echo "<font size=3 color=Red>";
        echo "<b>".translate("WARNING: Are you sure you want to delete this Category and ALL its Businesses and Comments?")."</b></font><br><br>";
        echo "[ <a href=admin.$phpEx?fct=myyp&op=delCat&cid=$cid&ok=1>".translate("Yes")."</a> | <a href=admin.$phpEx?fct=myyp>".translate("No")."</a> ]<br><br>";
        CloseTable();
        }
}
function delNewBiz() {
        global $mpnTables, $phpEx, $_REQUEST, $eh;
        $query = "delete from ".$mpnTables['yp_business']." where bid=".$_REQUEST['bid']."";
        mysql_query($query) or $eh->show("0013");
        $query = "delete from ".$mpnTables['yp_businesstxt']." where bid=".$_REQUEST['bid']."";
        mysql_query($query) or $eh->show("0013");
        echo "".translate("Business deleted.")."";
        echo "<br><br><a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";
}
function addCat() {
        global $mpnTables, $phpEx, $HTTP_POST_VARS, $eh;
        $pid = $HTTP_POST_VARS["cid"];
        $title = $HTTP_POST_VARS["title"];
        if (isset($HTTP_POST_VARS["imgurl"]) && ($HTTP_POST_VARS["imgurl"]!="")) {
        $imgurl = trim($HTTP_POST_VARS["imgurl"]);
        if ($imgurl == "http://") {
            $imgurl = "";
        } else {
            if (!stristr($imgurl, "http://")) {
                $imgurl = "http://" . $imgurl;
            }
        $imgurl = urlencode($imgurl);
        $imgurl = addslashes($imgurl);
        }
    }
    else
    {
        $imgurl = '';
    }
        $title = addslashes($title);
        mysql_query("insert into ".$mpnTables['yp_categories']." values (NULL, '$pid', '$title', '$imgurl')") or $eh->show("0013");
    echo "".translate("New Category Added Successfully!")."";
    echo "<br><br><a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";

}

function addBiz() {
        global $sitename, $adminmail, $mpnTables, $phpEx, $HTTP_POST_VARS, $eh;
    if (($HTTP_POST_VARS["url"]) || ($HTTP_POST_VARS["url"]!="")) {
        $url = trim($HTTP_POST_VARS["url"]);
        if ($url == "http://") {
            $url = "";
        } else {
            if (!stristr($url, "http://")) {
                $url = "http://" . $url;
            }
        $url = urlencode($url);
        //$url = $myts->makeTboxData4Save($url);
        }
    }
    if (($HTTP_POST_VARS["logourl"]) || ($HTTP_POST_VARS["logourl"]!="")) {
        $logourl = trim($HTTP_POST_VARS["logourl"]);
        if ($logourl == "http://") {
            $logourl = "";
        } else {
            if (!stristr($logourl, "http://")) {
                $logourl = "http://" . $logourl;
            }
        $logourl = urlencode($logourl);
        //$logourl = $myts->makeTboxData4Save($logourl);
        }
    }
        /*$title = $myts->makeTboxData4Save($HTTP_POST_VARS["title"]);
        $email = $myts->makeTboxData4Save($HTTP_POST_VARS["email"]);
        $phone =  $myts->makeTboxData4Save($HTTP_POST_VARS["phone"]);
        $fax =  $myts->makeTboxData4Save($HTTP_POST_VARS["fax"]);
        $summary = $myts->makeTboxData4Save($HTTP_POST_VARS["summary"]);
        $address =  $myts->makeTboxData4Save($HTTP_POST_VARS["address"]);
        $city =  $myts->makeTboxData4Save($HTTP_POST_VARS["city"]);
        $state =  $myts->makeTboxData4Save($HTTP_POST_VARS["state"]);
        $zipcode =  $myts->makeTboxData4Save($HTTP_POST_VARS["zipcode"]);
        $country = $myts->makeTboxData4Save($HTTP_POST_VARS["country"]);
        $description = $myts->makeTareaData4Save($HTTP_POST_VARS["description"]);
        $submitter = $myts->makeTareaData4Save($HTTP_POST_VARS["submitter"]);*/

        $title=$HTTP_POST_VARS['title'];
        $result = mysql_query("select count(*) from ".$mpnTables['yp_business']." where title='$title'");
        list($numrows) = mysql_fetch_row($result);
        if ($numrows>0) {
        echo "<font size=3 color=Red>";
        echo "<b>".translate("ERROR: The Business you provided is already in the database!")."</b></font><br><br>";
        $error = 1;
        }
// Check if Title exist
        if ($HTTP_POST_VARS['title'] == "") {
        echo "<font size=3 color=Red>";
        echo "<b>".translate("ERROR: You need to enter Name!")."</b></font><br><br>";
            $error =1;
        }

// Check if Description exist
        if ($HTTP_POST_VARS['description'] == "") {
        echo "<font size=3 color=Red>";
        echo "<b>".translate("ERROR: You need to enter DESCRIPTION!")."</b></font><br><br>";
            $error =1;
        }
        if($error == 1) {
            include("footer.$phpEx");
            exit();
        }
        if (isset( $HTTP_POST_VARS['cid'] ))
        {
            $cid = $HTTP_POST_VARS['cid'];
        }
        else
        {
            $cid = null;
        }

        extract( $HTTP_POST_VARS );

        mysql_query("insert into ".$mpnTables['yp_business']." values (NULL, '$cid', '$title', '$url', '$email', '$phone', '$fax', '$summary', '$address', '$city', '$state', '$zipcode', '$country', '$logourl', '$submitter', 1, now(), 0, 0, 0, 0)") or $eh->show("0013");
        $newid = mysql_insert_id();
        mysql_query("insert into ".$mpnTables['yp_businesstxt']." values (NULL, '$newid', '$description')") or $eh->show("0013");
    echo "".translate("New Business added to the Database")."<br>";
        echo "<br><a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";
}
function approve(){
    global $sitename, $adminmail, $mpnTables, $phpEx, $_REQUEST, $eh;
    global $smtp, $mailmethod;

    require_once('class.phpmailer.php');
    $mail = new phpmailer();

    /* SET MAIL DELIVERY OPTIONS */
    $mail->IsHTML(true);
    if ($mailmethod == "0") {
        $mail->IsMail();
    } else {
        $mail->IsSMTP();
        $mail->Host = $smtp;
    }

    $bid = $_REQUEST['bid'];
    $query = "update ".$mpnTables['yp_business']." set status=1, date=now() where bid=".$bid."";
    mysql_query($query) or $eh->show("0013");
    $result = mysql_query("select u.email,b.submitter from ".$mpnTables['users']." u, ".$mpnTables['yp_business']." b where b.bid=$bid and u.uname=b.submitter && u.uid > 1");
    list($email, $submitter)=mysql_fetch_row($result);

    $email = stripslashes($email);
    $submitter = stripslashes($submitter);

    $subject = "".translate("Your Business Info at")." $sitename";
    $message = "".translate("Hello")." $submitter:\n\n".translate("We approved your business info submission for our yellow pages.")."\n\n".translate("You can browse our yellow pages at:") . " " . _MPN_ROOT_URI . "myyp.$phpEx\n\n".translate("Thanks for your submission!")."\n\n$sitename";
        $from = "$adminmail";
//        mail($email, $subject, $message, "From: \"$adminmail\" <$from>\nX-Mailer: PHP/" . phpversion());

    $mail->From = $adminmail;
    $mail->FromName = $sitename . translate(' Mailer');
    $mail->AddAddress($email);
    $mail->Subject = stripslashes($subject);
    $mail->Body = nl2br( stripslashes($message) );
    $mail->AltBody = strip_tags( stripslashes($message) );
    $mail->Send();

        echo "".translate("New Business added to the Database")."<br><br>";
        echo "<a href=\"admin.php?fct=myyp\">".translate("Back to Configuration Menu")."</a>";
}

function makeCountrySelBox($country=""){
    $countries = array("United States","Afghanistan","Albania","Algeria","American Samoa","Andorra","Angola","Anguilla","Antigua and Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain"
,"Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia and Herzegovina","Botswana","Brazil","British Virgin Islands","Brunei Darussalam","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Cayman Islands","Central African Republic","Chad","Chile","China","Colombia","Comoros","Congo","Cook Islands","Costa Rica","Croatia","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Guiana","French Polynesia","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guadeloupe","Guatemala","Guinea","Guinea Bissau","Guyana","Haiti","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Israel","Italy","Ivory Coast","Jamaica","Japan","Jordan","Kazakhstan","Kenya","Kiribati","Kuwait","Kyrgyzstan","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macau","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Martinique","Mauritania","Mauritius","Mexico","Micronesia","Moldova","Monaco","Mongolia","Montserrat","Morocco","Mozambique","Myanmar","Namibia","Nepal","Netherlands","Netherlands Antilles","New Caledonia","New Zealand","Nicaragua","Niger","Nigeria","Norfolk Island","North Korea","Northern Mariana Islands","Norway","Oman","Pakistan","Palau","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Puerto Rico","Qatar","Reunion","Romania","Russia","Rwanda","Saint Helena","Saint Kitts and Nevis","Saint Lucia","Saint Pierre and Miquelon","Saint Vincent/Grenadines","Samoa","San Marino","Saotome and Principe","Saudi Arabia","Senegal","Seychelles","Sierra Leone","Singapore","Slovak Republic","Slovenia","Solomon Islands","Somalia","South Africa","South Korea","Spain","Sri Lanka","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Togo","Tokelau","Tonga","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan","Turks and Caicos Islands","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","Virgin Islands","Uruguay","Uzbekistan","Vanuatu","Vatican","Venezuela","Vietnam","Western Sahara","Yemen","Yugoslavia","Zambia","Zimbabwe");

   $countrycodes =array("USA","AFG","ALB","DZA","ASM","AND","AGO","AIA","ATG","ARG","ARM","ABW","AUS","AUT","AZE","BHS","BHR","BGD","BRB","BLR","BEL","BLZ","BEN","BMU","BTN","BOL","BIH","BWA","BRA","VGB","BRN","BGR","BFA","BDI","KHM","CMR","CAN","CPV","CYM","CAF","TCD","CHL","CHN","COL","COM","COG","COK","CRI","HRV","CUB","CYP","CZE","DNK","DJI","DMA","DOM","ECU","EGY","SLV","GNQ","ERI","EST","ETH","FLK","FRO","FJI","FIN","FRA","GUF","PYF","GAB","GMB","GEO","DEU","GHA","GIB","GRC","GRL","GRD","GLP","GTM","GIN","GNB","GUY","HTI","HND","HKG","HUN","ISL","IND","IDN","IRN","IRQ","IRL","ISR","ITA","CIV","JAM","JPN","JOR","KAZ","KEN","KIR","KWT","KGZ","LAO","LVA","LBN","LSO","LBR","LBY","LIE","LTU","LUX","MAC","MKD","MDG","MWI","MYS","MDV","MLI","MLT","MHL","MTQ","MRT","MUS","MEX","FSM","MDA","MCO","MNG","MSR","MAR","MOZ","MMR","NAM","NPL","NLD","ANT","NCL","NZL","NIC","NER","NGA","NFK","PRK","MNP","NOR","OMN","PAK","PLW","PAN","PNG","PRY","PER","PHL","POL","PRT","PRI","QAT","REU","ROM","RUS","RWA","SHN","KNA","LCA","SPM","VCT","WSM","SMR","STP","SAU","SEN","SYC","SLE","SGP","SVK","SVN","SLB","SOM","ZAF","KOR","ESP","LKA","SDN","SUR","SWZ","SWE","CHE","SYR","TWN","TJK","TZA","THA","TGO","TKL","TON","TTO","TUN","TUR","TKM","TCA","UGA","UKR","ARE","GBR","USA","VIR","URY","UZB","VUT","VAT","VEN","VNM","ESH","YEM","YUG","ZMB","ZWE");
    echo "<select name=country>";
    for($i=0;$i<sizeof($countries);$i++){
        if($country==$countrycodes[$i]){
            echo "<option value=\"$countrycodes[$i]\" selected>$countries[$i]</option>";
        } else {
            echo "<option value=\"$countrycodes[$i]\">$countries[$i]</option>";
        }
    }
    echo "</select>";
}

?>
