Location: PHPKode > projects > H-tracker > advertisers.php
<?
//
//  H-Tracker v0.2
//    http://h-tracker.org
//    Based on TorrentTrader (http://www.torrenttrader.org)
//
//
require_once("backend/functions.php");
dbconn();
loggedinonly();
$site_config['RIGHTNAV'] = false;

if (get_user_class() < 7)
show_error_msg("Error", "Permission denied.");

$action = $_GET["action"];

if ($action == "approve") {

$id = 0 + $_GET["id"];

if (!is_valid_id($id))
show_error_msg("Error", "It appears you have entered an invalid id.");

$res = mysql_query("SELECT name, email FROM ads WHERE id = $id") or die(mysql_error());
$arr = mysql_fetch_assoc($res);

mysql_query("UPDATE ads SET approved = 'yes' WHERE id = $id") or die(mysql_error());

$body = "Hello $arr[name],\n\nRecently you have requested to become advertiser at our site (".$site_config['SITEURL']."). This request has been approved, and your advertisement will be added to the site as soon as possible.\n\n Come visit back soon at ".$site_config['SITEURL']." to view your advertisement.";
ini_set("sendmail_from", ""); 
mail($arr["email"], "Advertisement at ".$site_config['SITEURL']."", $body, "From: ".$site_config['SITENAME']." <".$site_config['SITEEMAIL'].">"); 

header("Location: ".$site_config['SITEURL']."/advertisers.php");


} elseif ($action == "reject") {

$id = 0 + $_GET["id"];

if (!is_valid_id($id))
show_error_msg("Error", "It appears you have entered an invalid id.");

$res = mysql_query("SELECT name, email FROM ads WHERE id = $id") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_assoc($res);

mysql_query("UPDATE ads SET approved = 'no' WHERE id = $id") or sqlerr(__FILE__, __LINE__);

$body = "Hello $arr[name],\n\nRecently you have requested to become advertiser at our site (".$site_config['SITEURL']."). This request has been rejected, and your advertisement will not be added to the site.";

ini_set("sendmail_from", ""); 
mail($arr["email"], "Advertisement at ".$site_config['SITEURL']."", $body, "From: ".$site_config['SITENAME']." <".$site_config['SITEEMAIL'].">"); 

header("Location: ".$site_config['SITEURL']."/advertisers.php");


} elseif ($action == "delete") {

$res = mysql_query("SELECT id FROM ads WHERE id IN (".implode(", ", $_POST["delad"]).")");
while ($arr = mysql_fetch_assoc($res))
mysql_query("DELETE FROM ads WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__);

header("Location: ".$site_config['SITEURL']."/advertisers.php");


} elseif ($action == "view") {

$id = 0 + $_GET["id"];

if (!is_valid_id($id))
show_error_msg("Error", "It appears you have entered an invalid id.");

$res = mysql_query("SELECT * FROM ads WHERE id = $id") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_assoc($res);

stdhead("Advertisement of ".htmlspecialchars($arr["name"]));
begin_frame("Advertisement of ".htmlspecialchars($arr["name"])."");
print("<table width=650 border=1 cellspacing=0 cellpadding=5>");
print("<tr><td class=rowhead>Name:</td><td colspan=2>".htmlspecialchars($arr["name"])."</td></tr>");
print("<tr><td class=rowhead>Email address:</td><td colspan=2><a href='mailto:".htmlspecialchars($arr["email"])."'>".htmlspecialchars($arr["email"])."</a></td></tr>");
print("<tr><td class=rowhead>Site URL:</td><td colspan=2><a href='".htmlspecialchars($arr["site_url"])."'>".htmlspecialchars($arr["site_url"])."</a></td></tr>");
print("<tr><td class=rowhead>Months:</td><td colspan=2>$arr[months]</td></tr>");
print("<tr><td class=rowhead>Banner URL(s):</td><td colspan=2><img src=".htmlspecialchars($arr["banners"])."><br></td></tr>");
print("<tr><td class=rowhead>Notes:</td><td colspan=2>".htmlspecialchars($arr["notes"])."</td></tr>");
print("<tr><td></td><td align=center><a href=?action=approve&id=$arr[id]><b>Approve</b></a></td><td align=center><a href=?action=reject&id=$arr[id]><b>Reject</b></a></td></tr>");
print("</td></tr></table>");
end_frame();
stdfoot();


} else {

$res = mysql_query("SELECT COUNT(*) FROM ads") or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_array($res);
$count = $row[0];
$perpage = 25;
list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, "?");
   
stdhead("Advertisers");
begin_frame("Advertisers");
echo $pagertop;
print("<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>\n");
print("<table width=100% class=tablebg cellspacing=0 cellpadding=5 align=center>\n");
print("<tr>");
print("<td class=rowTabHead align=center>ID</td>");
print("<td class=rowTabHead align=center>Added</td>");
print("<td class=rowTabHead align=center>Name</td>");
print("<td class=rowTabHead align=center>Email</td>");
print("<td class=rowTabHead align=center>Website</td>");
print("<td class=rowTabHead align=center>Months</td>");
print("<td class=rowTabHead align=center>Approved</td>");
print("<td class=rowTabHead align=center>Delete</td>");
print("</tr>");   
print("<form method=post action=?action=delete>");

$res1 = mysql_query("SELECT * FROM ads $limit") or sqlerr(__FILE__, __LINE__);
while ($arr = mysql_fetch_assoc($res1)) {

$elapsed = get_elapsed_time(sql_timestamp_to_unix_timestamp($arr["added"]));

print("<tr>");
print("<td class=ttable_col1 align=center><a href=?action=view&id=$arr[id]>$arr[id]</a></td>");  
print("<td class=ttable_col2 align=center>".str_replace(" ", "&nbsp;", $arr["added"])."<br>($elapsed ago)</td>"); 
print("<td class=ttable_col1 align=center><a href=?action=view&id=$arr[id]>".htmlspecialchars($arr["name"])."</a></td>");
print("<td class=ttable_col2 align=center><a href='mailto:".htmlspecialchars($arr["email"])."'>".htmlspecialchars($arr["email"])."</a></td>");
print("<td class=ttable_col1 align=center><a href='".htmlspecialchars($arr["site_url"])."'>".htmlspecialchars($arr["site_url"])."</a></td>"); 
print("<td class=ttable_col2 align=center><b>$arr[months]</b></td>");
print("<td class=ttable_col1 align=center><b>".($arr["approved"] == "yes" ? "<font color=green>Yes</font>" : ($arr["approved"] == "no" ? "<font color=red>No</font>" : "<font color=blue>Pending</font>"))."</b></td>");
print("<td class=ttable_col2 align=center><input type=checkbox name=delad[] value=$arr[id]></td>");
print("</tr>");
}
print("</table>");
print("<p align=right><input type=submit value=Delete></p>\n");
print("</form>\n");
print("</td></tr></table>");
echo $pagerbottom;
end_frame();
stdfoot();
}
?>
Return current item: H-tracker