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 "\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 "

\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 "
  • $CatName"; print " ($LinksInCat)"; print "
  • \n"; $data_cnt--; if ($data_cnt == $data_left) { print "
\n"; print '
'; } } print "\n"; print "
\n"; } $CatID = $OurCatID; // restore CatID print "

$currentName:

\n"; // Print list of links print "\n"; print "

"; print " Suggest new link "; print "

\n"; 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 "

New Category:

\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 "

Bad LinkID, nothing returned


\n"; return; } while ( list ( $key,$val ) = each ($thislink)) { $CatID = stripslashes($val["CatID"]); $Url = stripslashes($val["Url"]); $LinkName = stripslashes($val["LinkName"]); $Desc = stripslashes($val["Description"]); $Name = stripslashes($val["SubmitName"]); $Email = stripslashes($val["SubmitEmail"]); $SDate = stripslashes($val["SubmitDate"]); } if(!empty($CatID)) { $LinkCatName = $db->get_CatNames($CatID); } else { $LinkCatName = "$TOP_CAT_NAME"; } print "

Edit a Resource in: $LinkCatName


show_cat_selection("CatID", True, $CatID); print "
URL:
Title:
Description:
Your Name:
Your Email:
CatID:"; //
CatID:
\n"; print_footer(); return; } function show_add_link($add = "NULL", $CatName = "Unknown") { global $PHP_SELF; global $db; global $TOP_CAT_NAME; global $FULL_ADMIN_ACCESS; global $UserName; // Cookie global $UserEmail; // Cookie print "

Add a link in: $CatName


URL:
Title:
Description:
Your Name:
Your Email:

\n"; return; } // Mail the admin anytime a new link is submitted function mail_new_link($postData = "") { global $PHP_SELF; global $db; global $ADMIN_EMAIL; if( (empty($postData)) or (!is_array($postData)) ) { return false; } if ($ADMIN_EMAIL == "") { return false; } $CatID = $postData["CatID"]; $Url = addslashes($postData["Url"]); $Description = addslashes($postData["Description"]); $LinkName = addslashes($postData["LinkName"]); $SubmitName = addslashes($postData["SubmitName"]); $SubmitEmail = addslashes($postData["SubmitEmail"]); $SubmitDate = time(); // Get category information $secs = $db->get_CatNames($CatID); $CatName = "Unknown"; if (!empty($secs)) { $CatName = $secs; } $Subject = "New Link: "; $Subject .= substr($LinkName, 0, 60); if ($LinkName != substr($LinkName, 0, 60)) { $LinkName .= "..."; } $Subject = trim($Subject); $Body = "User \"$SubmitName\" <".$SubmitEmail."> submitted this link in category $CatName:\n\n"; $Body .= "$LinkName at <$Url>\n\n"; $Body .= "$Description\n\n"; if ($AUTOAPPROVEQUE) { $Body .= "This link was auto-approved.\n"; } else { $Body .= "This link needs approval.\n"; $Body .= "(Use $PHP_SELF? for admin rights!)\n"; } $From = "$SubmitName<".$SubmitEmail.">"; // Send the email notice if email defined if ($ADMIN_EMAIL) { // function smtp_mail($from, $to, $subject, $body, $replyto = "", $bcc = "") smtp_mail($ADMIN_EMAIL, $ADMIN_EMAIL, $Subject, $Body, $From); } return; } // ***************************************************************** // Check cookie to see if we are in admin mode if($HooPass == $ADMIN_PASS) { $ADMIN_MODE = true; } $query = getenv("QUERY_STRING"); if( ($viewCat) or ( (!$HTTP_POST_VARS) and (!$query) ) ) { start_page($viewCat); start_browse($viewCat); exit; } elseif($pass) { if ($pass == $ADMIN_PASS) { setcookie("HooPass", $ADMIN_PASS); $ADMIN_MODE = true; start_page(); start_browse(); exit; } } elseif($add) { if (("$add" == "top") || empty($add)) { $add = 0; $CatName = "$TOP_CAT_NAME"; } else { $CatName = stripslashes($db->get_CatNames($add)); if (empty($CatName)) { $CatName = "$TOP_CAT_NAME"; } } $junk = ""; print_header($add,$title,$junk); show_add_link($add, $CatName); print_footer(); exit; } elseif($add_cat) { $junk = ""; $err_msg = ""; if ($ADMIN_MODE && $FULL_ADMIN_ACCESS) { if(!$db->add_cat($HTTP_POST_VARS,$err_msg)) { $title = "Error Creating Category"; $msg = "Category not created. ".$err_msg; } else { $title = "Category Created"; $msg = "New subcategory created"; } } else { $title = "Error Creating Category"; $msg = "Not authorized for creating categories"; } start_page($CatID,$title,$msg); start_browse($CatID); exit; } elseif ($suggest) { $junk = ""; $err_msg = ""; if(!$db->suggest($HTTP_POST_VARS,$err_msg)) { $title = "Suggestion Error"; $msg = "Sugestion not accepted: ".$err_msg; } else { $title = "Suggestion Submitted"; $msg = "Suggestion submitted for approval"; // Also tell the admin about it mail_new_link($HTTP_POST_VARS); } start_page($CatID,$title,$msg); start_browse($CatID); exit; } elseif ($update) { $junk = ""; $err_msg = ""; if ($ADMIN_MODE) { if(!$db->update($HTTP_POST_VARS,$err_msg)) { $title = "Update Error"; $msg = "Update failed: ".$err_msg; } else { $title = "Updated"; $msg = "Updated entry submitted for approval"; } } else { $title = "Update Error"; $msg = "Not authorized"; } start_page($CatID,$title,$msg); start_browse($CatID); exit; } elseif ($approve) { if ($ADMIN_MODE) { if(!$db->approve($approve,$err_msg)) { $title = "Approval Error"; $msg = $err_msg; } else { $title = "Approved"; $msg = "Suggestion approved"; } } else { $title = "Approval Error"; $msg = "Not authorized"; } start_page($CatID,$title,$msg); start_browse($CatID); exit; } elseif ($disapprove) { if ($ADMIN_MODE) { if(!$db->disapprove($disapprove,$err_msg)) { $title = "Disapproval Error"; $msg = $err_msg; } else { $title = "Disapproved"; $msg = "Link disapproved"; } } else { $title = "Disapproval Error"; $msg = "Not authorized"; } start_page($CatID,$title,$msg); start_browse($CatID); exit; } elseif ($delete_link) { if ($ADMIN_MODE) { if(!$db->delete_link($delete_link,$err_msg)) { $title = "Error deleting submission"; $msg = $err_msg; } else { $title = "Deleted"; $msg = "Suggestion deleted"; } } else { $title = "Error deleting submission"; $msg = "Not authorized"; } start_page($CatID,$title,$msg); start_browse($CatID); exit; } elseif ($edit_link) { show_edit_link($edit_link,$title,$msg); exit; } elseif ($KeyWords) { //start_page(); $hits = $db->search($KeyWords); if( (!$hits) or (empty($hits)) ) { $junk = ""; $title = "Search Results"; $msg = "No Matches"; start_page($junk,$title,$msg); } else { $total = count($hits); $title = "Search Results"; $msg = "Search returned $total matches"; $junk = ""; start_page($junk,$title,$msg); while ( list ($key,$hit) = each ($hits)) { if(!empty($hit)) { $LinkID = $hit["LinkID"]; $LinkName = stripslashes($hit["LinkName"]); $LinkDesc = stripslashes($hit["Description"]); $LinkURL = stripslashes($hit["Url"]); $CatID = $hit["CatID"]; $CatName = stripslashes($db->get_CatNames($CatID)); print "
\n"; print "
$LinkName\n"; print "
$LinkDesc\n"; print "
Found In: $CatName\n"; print "
\n"; } } } print "


\n"; start_browse($CatID); exit; } else { // Something terribly bad happened - start fresh start_page("$viewCat","Error","Unknown error"); start_browse(""); phpinfo(); exit; } ?>