// phphoo3 - a yahoo-like link directory written for PHP3/4
// Copyright (C) 1999/2001 Rolf V. Ostergaard http://www.cable-modems.org/phpHoo/
//
// 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, 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.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Refer to http://www.webreference.com/perl/xhoo/php1/ for phphoo, the
// first cut done by CDI.
include("config.php"); // Configuration information
require("mysql.php"); // Access to all the database functions
require("smtp.php"); // Access to mail class
// Open the database
$db = new MySQL;
if(!$db->init()) {
echo "Cannot open database \n";
exit;
}
// Prepare SMTP class
$smtp = new smtp_class;
$smtp->host_name = "smtp.rhodesia.com";
$smtp->localhost = "localhost";
// Send mail function
function smtp_mail($from, $to, $subject, $body, $replyto = "", $bcc = "")
{
global $smtp;
$hdr = array(
"From: $from",
"To: $to",
"Subject: $subject"
);
if ($replyto) { $hdr[] = "Reply-to: $replyto"; }
if ($bcc) { $hdr[] = "Bcc: $bcc"; }
if (!$smtp->SendMessage($from, array($to), $hdr, $body)) {
echo "
Could not send the message to $to.\nError: ".$smtp->error."
\n";
}
}
// Expand CatID to whole trail
function breadcrumbs($CatID="")
{
global $db;
global $PHP_SELF;
if(empty($CatID)) { return; }
$db->get_ParentsInt($CatID);
$path = $db->TRAIL;
if(!empty($path))
{
while ( list ( $key,$val ) = each ($path))
{
$CatID = stripslashes($val["CatID"]);
$CatName = stripslashes($val["CatName"]);
$trail = " > $CatName$trail";
}
} else {
$trail = "";
}
return $trail;
}
function breadcrumbs_txt($CatID="")
{
global $db;
global $PHP_SELF;
if(empty($CatID)) { return; }
$db->get_ParentsInt($CatID);
$path = $db->TRAIL;
if(!empty($path))
{
while ( list ( $key,$val ) = each ($path))
{
$CatID = stripslashes($val["CatID"]);
$CatName = stripslashes($val["CatName"]);
if ($trail) {
$trail = "$CatName: $trail";
} else {
$trail = $CatName;
}
}
} else {
$trail = "-";
}
return $trail;
}
// Print page header based on template file
function print_header($CatID="",$title="")
{
global $TEMPLATE_FILE;
$trail = breadcrumbs($CatID);
$filename = $TEMPLATE_FILE;
$fd = fopen ($filename, "r");
$c = fread ($fd, filesize ($filename));
fclose ($fd);
$c = eregi_replace("@PHPHOO_BODY@.*", "", $c);
$c = str_replace("@TRAIL@", $trail, $c);
$c = str_replace("@TITLE@", $title, $c);
print ($c);
}
// Print page footer based on template file
function print_footer()
{
global $db;
global $TEMPLATE_FILE;
$lnk_cnt = $db->get_approved_cnt();
$new_cnt = $db->get_not_approved_cnt();
$filename = $TEMPLATE_FILE;
$fd = fopen ($filename, "r");
$c = fread ($fd, filesize ($filename));
fclose ($fd);
$c = eregi_replace(".*@PHPHOO_BODY@", "", $c);
$c = str_replace("@LNK_CNT@", $lnk_cnt, $c);
$c = str_replace("@NEW_CNT@", $new_cnt, $c);
print ($c);
}
function show_submissions_list($CatID)
{
global $PHP_SELF;
global $db;
global $SEE_ALL_SUBMISSIONS;
global $TOP_CAT_NAME;
if ($SEE_ALL_SUBMISSIONS) {
$sub = $db->get_Submissions();
} else {
// Need to replace with function to show only for this CatID
$sub = $db->get_Submissions();
};
print "
";
print "$LinkName - $Desc \n";
print "URL: $Url \n";
// Print submitter name and email
print "Name: $Name - $Email Date: $SDate \n";
// Print category
print "Category: $LinkCatName \n";
print "[";
// Link to approve a sumbission
print "Approve ";
// Link to delete a sumbission
print "Delete ";
// Link to edit a sumbission
print "Edit";
print "]";
print "
";
}
}
print "
\n";
return;
}
function start_page($CatID="",$title="",$msg="")
{
global $PHP_SELF;
global $SITE_URL;
print_header($CatID,$title);
if(!empty($msg))
{
print "\n
$msg
\n";
}
print "
';
return;
}
function start_browse($CatID="")
{
global $PHP_SELF;
global $db;
global $ADMIN_MODE;
global $TOP_CAT_NAME;
$data = $db->get_Cats($CatID);
$links = $db->get_Links($CatID);
$OurCatID = $CatID;
if(empty($CatID) || ($CatID == "0"))
{
$currentID = "top";
$currentName = "$TOP_CAT_NAME";
} else {
$currentID = $CatID;
$currentName = $db->get_CatNames($CatID);
}
// Print list of sub categories
if(!empty($data))
{
$data_cnt = count ($data);
$data_left = $data_cnt >> 1;
print '
';
print "
\n";
while ( list ( $key,$val ) = each ($data))
{
$CatID = stripslashes($val["CatID"]);
$CatName = stripslashes($val["CatName"]);
$LinksInCat = $db->get_TotalLinksInCat_cnt($CatID);
print "
\n";
show_submissions_list($CatID);
$CatID = $OurCatID; // restore CatID
// Show form to add a subcategory
print "\n\n";
print "
\n";
}
// Print the footer
print_footer();
return;
}
// Print drop-down box for available categories
function show_cat_selection($SelName = "CatID", $IncludeTop = true, $SecSel = 0, $IncludeNone = false)
{
global $PHP_SELF;
global $db;
global $ADMIN_MODE;
global $TOP_CAT_NAME;
print "\n";
return;
}
function show_edit_link($LinkID="",$title="",$msg="")
{
global $PHP_SELF;
global $db;
global $TOP_CAT_NAME;
global $FULL_ADMIN_ACCESS;
print_header($CatID,$title,$msg);
$thislink = $db->get_OneLink($LinkID);
if (empty($thislink)) {
print "