// phphoo2 - a yahoo-like link directory written in PHP3
// Copyright (C) 1999/2000 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.
require("/home/cothrun/mysql.php"); // Access to all the database functions
require("smtp.php"); // Access to mail class
include("myheadfoot.php"); // The header and footer files
// Password protection:
// Use "phpHoo2?pass=secret" to enter admin mode
// This will set a cookie that gives you admin mode till you exit the browser
// ////////////////////////////////////////////////////////////////////////////
// Need to set these constant variables:
$ADMIN_MODE = false; // Set true for admin version
$ADMIN_PASS = "9THnine"; // Use ?pass=secret to enter admin mode
$SEE_ALL_SUBMISSIONS = true; // Set false to show submissions in this category only
$SITE_URL = "http://www.cothrun.com/";
// Set real URL of site (needed when multiple domains
// are parked on top of each other)
$FULL_ADMIN_ACCESS = true; // True to allow admin to create categories
$TOP_CAT_NAME = ""; // Name of the top "category"
$ADMIN_EMAIL = ""; // Admin email address used for new links
// That's all!
// ////////////////////////////////////////////////////////////////////////////
// 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 = "mail2.imagineis.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";
}
}
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) \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,$msg);
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 "
Feel free to add your own links. You must select a category, ";
print "it won't accept top level links. Your entry stands a much better chance of getting ";
print "added if your description is exceptionally short and clear, is in the right category,";
print "isn't spammy, and your site intrigues me. I reserve the right to edit, deny or delete ";
print "your link at any time. Follow links at your own risk.
\n";
if ($ADMIN_MODE) {
print "\n\n";
print "
Submissions
\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 = "NULL")
{
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 "