Location: PHPKode > projects > DDL CMS > Upload these files to your webspace/admin/edit.php
<?php

/**********************************************************
*  ______   ______   ___      _______  ___ ___  _______   *
* |   _  \ |   _  \ |   |    |   _   ||   Y   ||   _   |  *
* |.  |   \|.  |   \|.  |    |.  1___||.      ||   1___|  *
* |.  |    |.  |    |.  |___ |.  |___ |. \_/  ||____   |  *
* |:  1    |:  1    |:  1   ||:  1   ||:  |   ||:  1   |  *
* |::.. . /|::.. . /|::.. . ||::.. . ||::.|:. ||::.. . |  *
* `------' `------' `-------'`-------'`--- ---'`-------'  *
*                                _______        _______   *
*                    .--.--.    |   _   |      |       |  *
*                    |  |  |    |___|   |  __  |___|   |  *
*                     \___/      _(__   | |__|  /  ___/   *
*                               |:  1   |      |:  1  \   *
*                               |::.. . |      |::.. . |  *
*                               `-------'      `-------'  *
*                                                         *
*                                   Script: DDLCMS v3.2   *
*                                 Author: Little Dragon   *
*                              Email: hide@address.com   *
*                        Website: http://www.ddlcms.com   *
*                                                         *
*    Please direct bug reports, suggestions or feedback   *
*                                 to the DDLCMS forums:   *
*                                                         *
*                          http://www.ddlcms.com/forums   *
*                                                         *
*    DDLCMS is a commercial grade content management      *
*    system for DDL site owners. It is provided free      *
*    of charge, provided:                                 *
*                                                         *
*    1. You keep the linkback to http://www.ddlcms.com    *
*       in the footer.                                    *
*                                                         *
*    2. You keep the sponsored links to Sharingzone.net   *
*       on your site.                                     *
*                                                         *
*    By using this script, you agree that you will not    *
*    modify, remove, or replace any encoded parts of      *
*    this script. All encoded parts MUST remain intact    *
*    for your site to remain in good standing.            *
*                                                         *
**********************************************************/

	# Kill any security threats:
	#include(WWWROOT . 'killthreat.php');
	class edit extends config
	{
		function form($location)
		{
			echo '
				<h2>Add Downloads</h2>
					<table border="0" cellspacing="2" cellpadding="2" border="0">
						<form name="add" action="submit.php" method="post">
							<tr>
								<td colspan="4" align="right">Change All:</td>
								<td>
									<select class="form" style="margin: 0; font-size: 10px;" id="lstChangeAll">' . "\n";
			echo $this->option_list();
			echo '
									</select>
								</td>
							</tr>';
			for($i = 1; $i <= 10; $i++)
			{
				echo '
							<tr>
								<td class="form">Download Name ' . $i . '*: </td>
								<td><input type="text" name="title[]" class="form" size="30" /></td>
								<td class="form">&nbsp;&nbsp;&nbsp;&nbsp; Download Url ' . $i . '*:</td>
								<td><input type="text" name="url[]" class="form" size="30" /></td>
								<td>
									<select name="type[]" class="form">' . "\n";
				echo $this->option_list();
				echo '
									</select>
								</td>
							</tr>';
			}
			echo '
							<tr>
								<td class="form2"><br />Site Name*: </td>
								<td><br /><input type="text" name="sname" class="form" size="30" /></td>
								<td class="form2"><br />&nbsp;&nbsp;&nbsp;&nbsp; Site Url*: </td>
								<td><br /><input type="text" name="surl" class="form" size="30" /></td>
							</tr>
							<tr>
								<td class="form2">E-mail: </td>
								<td colspan="4"><input type="text" name="email" class="form" size="30" /></td>
							</tr>
							<tr>
								<td></td>
								<td colspan="4" class="form2"><br /><input type="Submit" value="Submit Download" class="formbuttonwide" /></td>
							</tr>
						</form>
					</table>' . "\n";
		}
		function leftmenu()
		{
			global $site_url;
			$g_total = dbcom('SELECT COUNT(id) AS TOTAL FROM downloads;');
			$total = mysql_result($g_total, 0);
			if($total <= 0)
			{
				$total = 0;
			}
			$g_total = dbcom('SELECT COUNT(id) AS TOTAL FROM que;');
			$submitted = mysql_result($g_total, 0);
			$get = dbcom('SELECT * FROM downloads ORDER BY views DESC;');
			$i = 1;
			while($row = mysql_fetch_array($get))
			{
				if($i == 1)
				{
					$p['v'] = $row['views'];
				}
				if($row['reports'] != 0)
				{
					$t['rep']++;
				}
				$t['dl'] += $row['views'];
				$i = 0;
			}
			if(!$t['rep'])
			{
				$t['rep'] = 0;
			}
			# Get total blacklisted sites
			$countbanned = dbcom('SELECT COUNT(id) AS banned FROM blacklist;');
			$rows = mysql_fetch_object($countbanned); 
			$blacklisted = $rows->banned;
			# Get total whitelisted sites
			$countclean = dbcom('SELECT COUNT(id) AS clean FROM whitelist;');
			$rows = mysql_fetch_object($countclean); 
			$whitelisted = $rows->clean;
			# Get total banned words
			$countbanned = dbcom('SELECT COUNT(id) AS banned FROM bannedwords;');
			$rows = mysql_fetch_object($countbanned); 
			$numbannedwords = $rows->banned;
			# Get total spam keywords 
			$countbanned = dbcom('SELECT COUNT(id) AS banned FROM spamwords;');
			$rows = mysql_fetch_object($countbanned); 
			$numspamwords = $rows->banned;
			$countbanned = dbcom('SELECT count(ip) as banned FROM submitter_bannedips WHERE ip <> "0";');
			$rows = mysql_fetch_object($countbanned);
			$numbannedips = $rows->banned;
			echo "
			<div class='sidebartitle'>
				Maintenance Functions
			</div>
			<a href=\"$site_url/admin/ddl.php?go=added\"> &#149; Queue</a> ($submitted)<br>
			<a href=\"$site_url/admin/ddl.php?go=report\"> &#149; Reported</a> ($t[rep])<br>
			<a href=\"$site_url/admin/ddl.php?go=stats\"> &#149; Downloads</a> ($total)<br>
			<a href=\"$site_url/admin/ddl.php?go=blacklist\"> &#149; Blacklist</a> ($blacklisted)<br>
			<a href=\"$site_url/admin/ddl.php?go=bannedips\"> &#149; Banned IPs</a> ($numbannedips)<br>
			<a href=\"$site_url/admin/ddl.php?go=whitelist\"> &#149; Whitelist</a> ($whitelisted)<br>
			<a href=\"$site_url/admin/ddl.php?go=bannedwords\"> &#149; Banned Keywords</a> ($numbannedwords)<br>
			<a href=\"$site_url/admin/ddl.php?go=spamwords\"> &#149; Spam Blocker</a> ($numspamwords)<br />
			<a href=\"$site_url/admin/ddl.php?go=add\"> &#149; Add Download</a><br />
			<a href=\"$site_url/admin/ddl.php?go=editpages\"> &#149; Edit Pages</a><br />
			<a href=\"$site_url/admin/ddl.php?go=editplinks\"> &#149; View/Edit Partner Links</a><br />
			<a href=\"$site_url/admin/ddl.php?go=editsuff\"> &#149; View/Edit Suffixes</a><br />
			<a href=\"$site_url/admin/ddl.php?go=editrecents\"> &#149; View/Delete Recents</a><br />
			<a href=\"$site_url/admin/ddl.php?go=editsearches\"> &#149; View/Delete Searches</a><br />";
			if(function_exists('pspell_new') === TRUE)
			{
				echo "<a href=\"$site_url/admin/ddl.php?go=updatedic\"> &#149; Update Dictionary</a>";
			}
			echo "
			<br />
			<br />
			<div class='sidebartitle'>
				Mailing List
			</div>
			<a href=\"$site_url/admin/ddl.php?go=mailinglist\"> &#149; View Outgoing List</a><br>
			<a href=\"$site_url/admin/ddl.php?go=email\"> &#149; Send Newsletter</a>
			<br />
			<br />
			<div class='sidebartitle'>
				DDL Setup
			</div>
			<a href=\"$site_url/admin/ddl.php\"> &#149; Edit Options</a>
			<br />
			<a href=\"$site_url/admin/ddl.php?go=optimtables\"> &#149; Optimize Tables</a>
			<br />
			<a href=\"$site_url/admin/ddl.php?go=backupdb\"> &#149; Backup Database</a>
			<br />
			<a href=\"$site_url/admin/ddl.php?go=restoredb\"> &#149; Restore Database</a>
			<br />
			<a href=\"http://www.ddlcms.com/latest/\" target=_blank> &#149; Upgrade</a>
			<br />
			<br />
			<div class='sidebartitle'>
				Admin Functions
			</div>
			<a href=\"$site_url/admin/ddl.php?go=adminpass\"> &#149; Change User/Password</a>
			<br />
			<a href=\"$site_url/admin/ddl.php?go=accesslog\"> &#149; Access Log</a>
			<br />
			<a href=\"$site_url/admin/ddl.php?go=adminbannedips\"> &#149; Banned IPs</a><br />
			<br />
			";
		}
		function main()
		{
			global $siteID, $site_url, $site_name, $admin_email, $keywords, $description, $votelink, $cbusername, $camsusername, $videoszusername, $skin, $hovercolor, $menualign, $showTop5, $showInstantLE, $showTopSearches, $topsearches, $showRecentSearches, $recentsearches, $showRecentDownloads, $recentdownloads, $showSponsoredLinks, $topdownloads, $sponsoredSearchResults, $pagelimit, $pagenumbers, $max_dl, $max_que, $date_format, $siteNameLength, $whitelist_threshold, $deadlink_threshold, $auto_allow, $maximumsubmissions, $arrowsForProvider, $enableAutoResponder;
			echo '<h2>DDL Settings</h2>' . "\n";

			if(isset($_POST) && count($_POST) > 0)
			{
				if(isset($_POST) && count($_POST) > 0 && checkPostForm('editOptions', $_POST) === TRUE)
				{
					echo '<p>DDL Settings update was successful.</p>' . "\n";
					if($_POST['sponsoredSearchResults'] < 1)
					{
						$_POST['sponsoredSearchResults'] = 1;
					}
					if($admin_email != $_POST['email'])
					{
						$headers = "FROM: ".$admin_email."\n";
						$headers .= "X-Sender: ".$admin_email."\n";
						$headers .= "Return-Path: ".$admin_email."\n";
						$message = $site_name . ' Admin email has been changed to ' . $_POST['email'] . ' from IP ' . $_SERVER['REMOTE_ADDR'] . '.  If you did not perform this change, please login and change your email right away.';
						@mail($admin_email, $site_name . ' Admin Email Changed', $message, $headers);
					}
					$currentSkinQuery = dbcom("SELECT skin FROM config WHERE siteID = '{$_POST['siteID']}' LIMIT 1;");
					$currentSkinArray = mysql_fetch_assoc($currentSkinQuery);
					$tsCache = file_get_contents(WWWROOT . 'topsites/cache/default');
					$tsCache = str_replace($currentSkinArray['skin'], $_POST['skin'], $tsCache);
					file_put_contents(WWWROOT . 'topsites/cache/default', $tsCache);
					dbcom("UPDATE config SET 
						site_url = '{$_POST['surl']}',
						site_name = '{$_POST['sname']}',
						admin_email = '{$_POST['email']}',
						keywords = '{$_POST['keywords']}',
						description = '{$_POST['description']}',
						votelink = '{$_POST['votelink']}',
						cbusername = '{$_POST['cbUserName']}',
						camsusername = '{$_POST['camsUserName']}',
						videoszusername = '{$_POST['videosZuserName']}',
						skin = '{$_POST['skin']}',
						hovercolor = '{$_POST['hoverColor']}',
						menualign = '{$_POST['menuAlign']}',
						pagelimit = '{$_POST['pageLimit']}',
						pagenumbers = '{$_POST['pageNumbers']}', 
						max_dl = '{$_POST['maximumDownloads']}',
						max_que = '{$_POST['maximumQueue']}',
						date_format = '{$_POST['dateFormat']}',
						siteNameLength = '{$_POST['siteNameLength']}',
						showTop5 = '{$_POST['showTop5']}',
						topdownloads = '{$_POST['topdownloads']}',
						sponsoredSearchResults = '{$_POST['sponsoredSearchResults']}',
						showInstantLE = '{$_POST['showInstantLE']}',
						showTopSearches = '{$_POST['showTopSearches']}',
						showRecentSearches = '{$_POST['showRecentSearches']}',
						showRecentDownloads = '{$_POST['showRecentDownloads']}',
						showSponsoredLinks = '{$_POST['showSponsoredLinks']}',
						recentdownloads = '{$_POST['recentDownloads']}',
						recentsearches = '{$_POST['recentSearches']}',
						topsearches = '{$_POST['topSearches']}',
						whitelist_threshold = '{$_POST['whitelistThreshold']}',
						deadlink_threshold = '{$_POST['deadlinkThreshold']}',
						auto_allow = '{$_POST['autoAllow']}',
						arrowsForProvider = '{$_POST['arrowsForProvider']}',
						enableAutoResponder = '{$_POST['enableAutoResponder']}',
						maximumsubmissions = '{$_POST['maximumSubmissions']}' 
					 	WHERE siteID = '{$_POST['siteID']}';");
					$commaCategories = implode(',', $_POST['categories']);
					dbcom("UPDATE category SET active = 1 WHERE id IN ($commaCategories);");
					dbcom("UPDATE category SET active = 0 WHERE id NOT IN ($commaCategories);");
				}
				else
				{
					echo '<p>DDL Settings update failed. Please, check the lengths and contents of form fields. <a href="javascript:history.go(-1)">Go back</a> and try again.</p>' . "\n";
				}
			}
			else
			{

				echo '<script type="text/javascript">
				function expand(id)
				{
				    var item  = document.getElementById(id);
				
				    if( item.style.visibility == \'hidden\' )
				    {
				        item.style.position   = \'relative\';
				        item.style.visibility = \'visible\';
				        
				    }
				    else
				    {
				        item.style.visibility = \'hidden\';
				        item.style.position   = \'absolute\';
				    }
				
				    return false;
				}
				</script>';

				echo '<p>DDL Options. All fields are required!</p>' . "\n";
				echo '<form action="ddl.php" method="post">' . "\n";
				echo '<input type="hidden" name="siteID" value="' . $siteID . '" />' . "\n";
				echo '<table border=0 cellpadding=10 cellspacing=0>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtSiteURL"><b>Site URL:</b></label></td>' . "\n";
				echo '<td><input type="text" name="surl" value="' . $site_url . '" id="txtSiteURL" maxlength="255" size="30" />
				<a href="" onClick="return expand(\'Site_URL_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Site_URL_Help">
				The full URL to your website, without trailing slash.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtSiteName"><b>Site Name:</b></label></td>' . "\n";
				echo '<td><input type="text" name="sname" value="' . $site_name . '" id="txtSiteName" maxlength="100" size="30" />
				<a href="" onClick="return expand(\'Site_Name_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Site_Name_Help">
				The name of your site. Keep it simple.<br>Example: CoolDDL.net
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtAdminEmail"><b>Admin E-mail:</b></label></td>' . "\n";
				echo '<td><input type="text" name="email" value="' . $admin_email . '" id="txtAdminEmail" maxlength="255" size="30" />
				<a href="" onClick="return expand(\'Site_E-mail_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Site_E-mail_Help">
				Your email address.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtKeywords"><b>Keywords:</b></label></td>' . "\n";
				echo '<td><input type="text" name="keywords" value="' . $keywords . '" id="txtKeywords" maxlength="255" size="30" />
				<a href="" onClick="return expand(\'Keywords_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Keywords_Help">
				Keywords, each separated by a comma. These will be used in your Meta tags and image Alt tags for SEO optimization.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtDescription"><b>Description:</b></label></td>' . "\n";
				echo '<td><input type="text" name="description" value="' . $description . '" id="txtDescription" maxlength="255" size="30" />
				<a href="" onClick="return expand(\'Description_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Description_Help">
				Your site\'s description. Keep it simple. Displayed below main site title.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtVoteLink"><b>Vote Link:</b></label></td>' . "\n";
				echo '<td><input type="text" name="votelink" value="' . $votelink . '" id="txtVoteLink" maxlength="255" size="30" />
				<a href="" onClick="return expand(\'Vote_Link_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Vote_Link_Help">
				The URL you want to forward surfers to, when they click on your Vote link (Xxx category pages only).
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtCBuserName"><b><a href="http://www.sharingzone.net/webmasters.php?r=9" target=_blank>Sharingzone.net</a> Username:</b></label></td>' . "\n";
				echo '<td><input type="text" name="cbUserName" value="' . $cbusername . '" id="txtCBuserName" maxlength="20" size="15" />
				<a href="" onClick="return expand(\'Sharingzone_Username_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Sharingzone_Username_Help">
				Your Sharingzone username.  You need this to earn money from sponsored links and sponsored searches.  If you don\'t have one, <a href="http://www.sharingzone.net/webmasters.php?r=9" target=_blank>click here to get one</a>.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtCamsUserName"><b><a href="http://cams.com/go/g656263-brk" target=_blank>Cams.com</a> Username:</b></label></td>' . "\n";
				echo '<td><input type="text" name="camsUserName" value="' . $camsusername . '" id="txtCamsUserName" maxlength="20" size="15" />
				<a href="" onClick="return expand(\'Cams_Username_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Cams_Username_Help">
				Your Cams.com username.  You need this to earn money from sponsored ads on Xxx category pages.  If you don\'t have one, <a href="http://cams.com/go/g656263-brk" target=_blank>click here to get one</a>.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtVideosZuserName"><b><a href="http://webmasters.videosz.com/index.php?webmaster_id=8006" target=_blank>Videosz.com</a> Username:</b></label></td>' . "\n";
				echo '<td><input type="text" name="videosZuserName" value="' . $videoszusername . '" id="txtVideosZuserName" maxlength="20" size="15" />
				<a href="" onClick="return expand(\'Videosz_Username_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Videosz_Username_Help">
				Your Videosz.com username.  You need this to earn money from sponsored ads on Xxx category pages.  If you don\'t have one, <a href="http://webmasters.videosz.com/index.php?webmaster_id=8006" target=_blank>click here to get one</a>.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="lstCategories">Categories:</label></td>' . "\n";
				echo '<td><select name="categories[]" id="lstCategories" multiple="multiple" style="width:125px">' . "\n";
				$categoriesQuery = dbcom('SELECT * FROM category;');
				while($categoriesArray = mysql_fetch_assoc($categoriesQuery))
				{
					if($categoriesArray['active'] == 1)
					{
						echo '<option value="' . $categoriesArray['id'] . '" selected="selected"> ' . $categoriesArray['category'] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>' . "\n";
					}
					else
					{
						echo '<option value="' . $categoriesArray['id'] . '"> ' . $categoriesArray['category'] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>' . "\n";
					}
				}
				echo '</select>
				<a href="" onClick="return expand(\'Categories_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Categories_Help">
				The categories you want to use on your site.  To select more than one, hold down the shift key.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="lstSkin"><b>Skin:</b></label></td>' . "\n";
				echo '<td><select name="skin" id="lstSkin" style="width:125px">' . "\n";
				$skins = scandir(WWWROOT . 'skins');
				for($i = 2; $i < count($skins); $i++)
				{
					if($skins[$i] == $skin)
					{
						echo '<option value="' . $skins[$i] . '" selected="selected"> ' . $skins[$i] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>' . "\n";
					}
					else
					{
						echo '<option value="' . $skins[$i] . '"> ' . $skins[$i] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>' . "\n";
					}
				}
				echo '</select>
				<a href="" onClick="return expand(\'Skin_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Skin_Help">
				Select the skin you want to your on your site. <a href="http://www.ddlcms.com/download.php" target=_blank>Get more skins for your site here</a>.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtHoverColor"><span style="background-color: ' . $hovercolor . '"><b>Hover Color:</b></span></label></td>' . "\n";
				echo '<td><input type="text" name="hoverColor" value="' . $hovercolor  . '" id="txtHoverColor" maxlength="7" size="15" />
				<a href="" onClick="return expand(\'Hover_Color_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Hover_Color_Help">
				The color of the background when you hover your mouse cursor over a link. Used for the main downloads list, and some admin lists.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="lstMenuAlign"><b>Floating Menu Alignment:</b></label></td>' . "\n";
				echo '<td><select name="menuAlign" id="lstMenuAlign" style="width:125px">' . "\n";
				if($menualign == 'left')
				{
					echo '<option value="left" selected="selected"> Left</option>' . "\n";
					}
				else
				{
					echo '<option value="left"> Left&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>' . "\n";
				}
				if($menualign == 'center')
				{
					echo '<option value="center" selected="selected"> Center&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>' . "\n";
				}
				else
				{
					echo '<option value="center"> Center&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>' . "\n";
				}
				if($menualign == 'right')
				{
					echo '<option value="right" selected="selected"> Right&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>' . "\n";
				}
				else
				{
					echo '<option value="right"> Right&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>' . "\n";
				}
				echo '</select>
				<a href="" onClick="return expand(\'Floating_Menu_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Floating_Menu_Help">
				The position you want your main menu buttons displayed.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><span><b>Show Top 5:</b></span></td>' . "\n";
				if($showTop5 == 1)
				{
					echo '<td><input type="radio" name="showTop5" id="optShowTop5Yes" value="1" checked="checked" /><label for="optShowTop5Yes">Yes</label>' . "\n";
					echo '<input type="radio" name="showTop5" id="optShowTop5No" value="0" /><label for="optShowTop5No">No</label>
					<a href="" onClick="return expand(\'Top_5_Help\');">[?]</a><br />
					<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Top_5_Help">
					Whether to display the "Top 5 Downloads This Week" panel.
					</div></td>' . "\n";
				}
				else
				{
					echo '<td><input type="radio" name="showTop5" id="optShowTop5Yes" value="1" /><label for="optShowTop5Yes">Yes</label>' . "\n";
					echo '<input type="radio" name="showTop5" id="optShowTop5No" value="0" checked="checked" /><label for="optShowTop5No">No</label>
					<a href="" onClick="return expand(\'Top_5_Help\');">[?]</a><br />
					<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Top_5_Help">
					Whether to display the "Top 5 Downloads This Week" panel.
					</div></td>' . "\n";
				}
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtTopDownloads"><b>Top Downloads:</b></label></td>' . "\n";
				echo '<td><input type="text" name="topdownloads" id="txtTopDownloads" maxlength="3" size="15" value="' . $topdownloads . '" />
				<a href="" onClick="return expand(\'Top_Downloads_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Top_Downloads_Help">
				The number of "Top Downloads" to list. It\'s ideal to keep this number the same as the "Page Limit."
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtSponsoredSearchResults"><b>Sponsored Search Results:</b></label></td>' . "\n";
				echo '<td><input type="text" name="sponsoredSearchResults" id="txtSponsoredSearchResults" value="' . $sponsoredSearchResults . '" maxlength="2" size="15" />
				<a href="" onClick="return expand(\'Sponsored_Search_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Sponsored_Search_Help">
				The number of sponsored search results to show after a surfer performs a search on your site. Cannot be less than "1".
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><span><b>Show Instant Link Exchange:</b></span></td>' . "\n";
				if($showInstantLE == 1)
				{
					echo '<td><input type="radio" name="showInstantLE" id="optShowInstantLEyes" value="1" checked="checked" /><label for="optShowInstantLEyes">Yes</label>' . "\n";
					echo '<input type="radio" name="showInstantLE" id="optShowInstantLEno" value="0" /><label for="optShowInstantLEno">No</label>' . "\n";

				}
				else
				{
					echo '<td><input type="radio" name="showInstantLE" id="optShowInstantLEyes" value="1" /><label for="optShowInstantLEyes">Yes</label>' . "\n";
					echo '<input type="radio" name="showInstantLE" id="optShowInstantLEno" value="0" checked="checked" /><label for="optShowInstantLEno">No</label>' . "\n";
				}
				echo '<a href="" onClick="return expand(\'Show_InstantLE_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Show_InstantLE_Help">
				Whether to show the Instant Link Exchange (including the links to sign up).
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><span><b>Show Top Searches:</b></span></td>' . "\n";
				if($showTopSearches == 1)
				{
					echo '<td><input type="radio" name="showTopSearches" id="optShowTopSearchesYes" value="1" checked="checked" /><label for="optShowTopSearchesYes">Yes</label>' . "\n";
					echo '<input type="radio" name="showTopSearches" id="optShowTopSearchesNo" value="0" /><label for="optShowTopSearchesNo">No</label>' . "\n";
				}
				else
				{
					echo '<td><input type="radio" name="showTopSearches" id="optShowTopSearchesYes" value="1" /><label for="optShowTopSearchesYes">Yes</label>' . "\n";
					echo '<input type="radio" name="showTopSearches" id="optShowTopSearchesNo" value="0" checked="checked" /><label for="optShowTopSearchesNo">No</label>' . "\n";
				}
				echo '<a href="" onClick="return expand(\'Show_Top_Searches_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Show_Top_Searches_Help">
				Whether to show the Top Searches link list at the bottom of pages (Good for SEO).
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtTopSearches"><b>Top Searches:</b></label>' . "\n";
				echo '<td><input type="text" name="topSearches" id="txtTopSearches" value="' . $topsearches . '" maxlength="3" size="15" />
				<a href="" onClick="return expand(\'Top_Searches_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Top_Searches_Help">
				The number of Top Searches links to display at the bottom of pages (Good for SEO).
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><span><b>Show Recent Searches:</b></span></td>' . "\n";
				if($showRecentSearches == 1)
				{
					echo '<td><input type="radio" name="showRecentSearches" id="optShowRecentSearchesYes" value="1" checked="checked" /><label for="optShowRecentSearchesYes">Yes</label>' . "\n";
					echo '<input type="radio" name="showRecentSearches" id="optShowRecentSearchesNo" value="0" /><label for="optShowRecentSearchesNo">No</label>' . "\n";
				}
				else
				{
					echo '<td><input type="radio" name="showRecentSearches" id="optShowRecentSearchesYes" value="1" /><label for="optShowRecentSearchesYes">Yes</label>' . "\n";
					echo '<input type="radio" name="showRecentSearches" id="optShowRecentSearchesNo" value="0" checked="checked" /><label for="optShowRecentSearchesNo">No</label>' . "\n";
				}
				echo '<a href="" onClick="return expand(\'Show_Recent_Searches_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Show_Recent_Searches_Help">
				Whether to show the Recent Searches link list at the bottom of pages (Good for SEO).
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtRecentSearches"><b>Recent Searches:</b></label></td>' . "\n";
				echo '<td><input type="text" name="recentSearches" id="txtRecentSearches" value="' . $recentsearches . '" maxlength="3" size="15" />
				<a href="" onClick="return expand(\'Recent_Searches_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Recent_Searches_Help">
				The number of Recent Searches links to display at the bottom of pages (Good for SEO).
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><span><b>Show Recent Downloads:</b></span></td>' . "\n";
				if($showRecentDownloads == 1)
				{
					echo '<td><input type="radio" name="showRecentDownloads" id="optShowRecentDownloadsYes" value="1" checked="checked" /><label for="optShowRecentDownloadsYes">Yes</label>' . "\n";
					echo '<input type="radio" name="showRecentDownloads" id="optShowRecentDownloadsNo" value="0" /><label for="optShowRecentDownloadsNo">No</label>' . "\n";
				}
				else
				{
					echo '<td><input type="radio" name="showRecentDownloads" id="optShowRecentDownloadsYes" value="1" /><label for="optShowRecentDownloadsYes">Yes</label>' . "\n";
					echo '<input type="radio" name="showRecentDownloads" id="optShowRecentDownloadsNo" value="0" checked="checked" /><label for="optShowRecentDownloadsNo">No</label>' . "\n";
				}
				echo '<a href="" onClick="return expand(\'Show_Recent_Downloads_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Show_Recent_Downloads_Help">
				Whether to show the Recent Downloads link list at the bottom of pages (Good for SEO).
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtRecentDownloads"><b>Recent Downloads:</b></label></td>' . "\n";
				echo '<td><input type="text" name="recentDownloads" id="txtRecentDownloads" value="' . $recentdownloads . '" maxlength="3" size="15" />
				<a href="" onClick="return expand(\'Recent_Downloads_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Recent_Downloads_Help">
				The number of Recent Downloads links to display at the bottom of pages (Good for SEO).
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><span><b>Show Sponsored Links:</b></span></td>' . "\n";
				if($showSponsoredLinks == 1)
				{
					echo '<td><input type="radio" name="showSponsoredLinks" id="optShowSponsoredLinksYes" value="1" checked="checked" /><label for="optShowSponsoredLinksYes">Yes</label>' . "\n";
					echo '<input type="radio" name="showSponsoredLinks" id="optShowSponsoredLinksNo" value="0" /><label for="optShowSponsoredLinksNo">No</label>' . "\n";
				}
				else
				{
					echo '<td><input type="radio" name="showSponsoredLinks" id="optShowSponsoredLinksYes" value="1" /><label for="optShowSponsoredLinksYes">Yes</label>' . "\n";
					echo '<input type="radio" name="showSponsoredLinks" id="optShowSponsoredLinksNo" value="0" checked="checked" /><label for="optShowSponsoredLinksNo">No</label>' . "\n";
				}
				echo '<a href="" onClick="return expand(\'Show_Sponsored_Links_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Show_Sponsored_Links_Help">
				Whether to show the Sponsored Links list at the bottom of pages (Good for SEO).
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<a name=\"autoallow\"></a><td width=200 align=right><p><b>Auto Allow:</b></td>' . "\n";
				if($auto_allow == 1)
				{
					echo '<td><input type="radio" name="autoAllow" id="optAutoAllowYes" value="1" checked="checked" /><label for="optAutoAllowYes">Yes</label>' . "\n";
					echo '<input type="radio" name="autoAllow" id="optAutoAllowNo" value="0" /><label for="optAutoAllowNo">No</label>' . "\n";
				}
				else
				{
					echo '<td><input type="radio" name="autoAllow" id="optAutoAllowYes" value="1" /><label for="optAutoAllowYes">Yes</label>' . "\n";
					echo '<input type="radio" name="autoAllow" id="optAutoAllowNo" value="0" checked="checked" /><label for="optAutoAllowNo">No</label>' . "\n";
				}
				echo '<a href="" onClick="return expand(\'Auto_Allow_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Auto_Allow_Help">
				Whether to automatically allow whitelisted site submissions to the main database.  If you turn this on, any whitelisted downloads <b>currently</b> in the submitted Queue will still require manual addition.  Warning: If you turn this on, be sure the sites in your whitelist are <b>fully trusted sites</b>!
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign="top">' . "\n";
				echo '<td width="200" align="right" ><p><b>Toggle Site/Provider (Display Arrows):</b></td>' . "\n";
				echo '<td>' . "\n";
				if($arrowsForProvider == 1)
				{
					echo '<input type="radio" name="arrowsForProvider" id="optArrowsForProviderYes" value="1" checked="checked" /><label for="optArrowsForProviderYes">Yes</label>' . "\n";
					echo '<input type="radio" name="arrowsForProvider" id="optArrowsForProviderNo" value="0" /><label for="optArrowsForProviderNo">No</label>' . "\n";
				}
				else
				{
					echo '<input type="radio" name="arrowsForProvider" id="optArrowsForProviderYes" value="1" /><label for="optArrowsForProviderYes">Yes</label>' . "\n";
					echo '<input type="radio" name="arrowsForProvider" id="optArrowsForProviderNo" value="0" checked="checked" /><label for="optArrowsForProviderNo">No</label>' . "\n";
				}
				echo '<a href="" onClick="return expand(\'ArrowsForProvider_Help\');">[?]</a><br />' . "\n";
				echo '<div style="visibility: hidden; position: absolute; font-size: 10px; padding: 10px" id="ArrowsForProvider_Help">
				This option enables or disables arrows (^) and site toggling in the Provider column of the main DDL page.' . "\n";
				echo '</div>' . "\n";
				echo '</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign="top">' . "\n";
				echo '<td width="200" align="right" ><p><b>Enable AutoResponder:</b></td>' . "\n";
				echo '<td>' . "\n";
				if($enableAutoResponder == 1)
				{
					echo '<input type="radio" name="enableAutoResponder" id="optEnableAutoResponderYes" value="1" checked="checked" /><label for="optEnableAutoResponderYes">Yes</label>' . "\n";
					echo '<input type="radio" name="enableAutoResponder" id="optEnableAutoResponderNo" value="0" /><label for="optEnableAutoResponderNo">No</label>' . "\n";
				}
				else
				{
					echo '<input type="radio" name="enableAutoResponder" id="optEnableAutoResponderYes" value="1" /><label for="optEnableAutoResponderYes">Yes</label>' . "\n";
					echo '<input type="radio" name="enableAutoResponder" id="optEnableAutoResponderNo" value="0" checked="checked" /><label for="optEnableAutoResponderNo">No</label>' . "\n";
				}
				echo '<a href="" onClick="return expand(\'AutoResponder_Help\');">[?]</a><br />' . "\n";
				echo '<div style="visibility: hidden; position: absolute; font-size: 10px; padding: 10px" id="AutoResponder_Help">
				This option enables or disables the script\'s autoresponder email system. Turn off if you don\'t want your submitters to receive autoresponse emails.' . "\n";
				echo '</div>' . "\n";
				echo '</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtPageLimit"><b>Page Limit:</b></label></td>' . "\n";
				echo '<td><input type="text" name="pageLimit" id="txtPageLimit" value="' . $pagelimit . '" maxlength="3" size="15" />
				<a href="" onClick="return expand(\'Page_Limit_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Page_Limit_Help">
				The number of download links to display per page.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtPageNumbers"><b>Page Numbers:</b></label></td>' . "\n";
				echo '<td><input type="text" name="pageNumbers" id="txtPageNumbers" value="' . $pagenumbers . '" maxlength="3" size="15" />
				<a href="" onClick="return expand(\'Page_Numbers_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Page_Numbers_Help">
				The number of page numbers to display on paginated pages.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtMaximumDownloads"><b>Maximum Downloads:</b></label></td>' . "\n";
				echo '<td><input type="text" name="maximumDownloads" id="txtMaximumDownloads" value="' . $max_dl . '" maxlength="6" size="15" />
				<a href="" onClick="return expand(\'Max_Downloads_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Max_Downloads_Help">
				The maximum number of downloads you want to keep in your main downloads database.  When this limit is reached, older entires are bumped off the list.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtMaximumQueue"><b>Maximum Queue:</b></label></td>' . "\n";
				echo '<td><input type="text" name="maximumQueue" id="txtMaximumQueue" value="' . $max_que . '" maxlength="6" size="15" />
				<a href="" onClick="return expand(\'Max_Queue_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Max_Queue_Help">
				The maximum number of submitted downloads to keep in your submitted Queue.  When this limit is reached, older entires are bumped off the list.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtDateFormat"><b>Date Format:</b></label></td>' . "\n";
				echo '<td><input type="text" name="dateFormat" id="txtDateFormat" value="' . $date_format . '" maxlength="5" size="15" />
				<a href="" onClick="return expand(\'Date_Format_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Date_Format_Help">
				The format you want the date displayed.<br>Example: "d-m-Y"
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign="top">' . "\n";
				echo '<td width="200"align="right"><label for="txtSiteNameLength"><b>Site Name Length:</b></label></td>' . "\n";
				echo '<td><input type="text" name="siteNameLength" id="txtSiteNameLength" value="' . $siteNameLength . '" maxlength="3" size="15" />
				<a href="" onClick="return expand(\'SiteNameLength_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="SiteNameLength_Help">
				Maximum length of site names.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtWhitelistThreshold"><b>Whitelist Threshold:</b></label></td>' . "\n";
				echo '<td><input type="text" name="whitelistThreshold" id="txtWhitelistThreshold" value="' . $whitelist_threshold . '" maxlength="3" size="15" />
				<a href="" onClick="return expand(\'Whitelist_Threshold_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Whitelist_Threshold_Help">
				The number of submissions that are accepted from a site, before that site automatically gets added to your whitelist.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtDeadlinkThreshold"><b>Deadlink Threshold:</b></label></td>' . "\n";
				echo '<td><input type="text" name="deadlinkThreshold" id="txtDeadlinkThreshold" value="' . $deadlink_threshold . '" maxlength="3" size="15" />
				<a href="" onClick="return expand(\'Deadlink_Threshold_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Deadlink_Threshold_Help">
				The number of Dead Link reports that must be submitted, before that link is automatically deleted from the database.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><label for="txtMaximumSubmissions"><b>Maximum Submissions Per Day Per Site:</b></label></td>' . "\n";
				echo '<td><input type="text" name="maximumSubmissions" id="txtMaximumSubmissions" value="' . $maximumsubmissions . '" maxlength="3" size="15" />
				<a href="" onClick="return expand(\'Max_Subs_Help\');">[?]</a><br />
				<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Max_Subs_Help">
				The maximum number of submissions allowed per day, by any site.
				</div>
				</td>' . "\n";
				echo '</tr>' . "\n";
				echo '<tr valign=top>' . "\n";
				echo '<td width=200 align=right><br><input type="reset" /></td>' . "\n";
				echo '<td><br><input type="submit" value="Save Options" style="width:125px"/></td>' . "\n";
				echo '</tr>' . "\n";
				echo '</table>' . "\n";
				echo '</form>' . "\n";
			}
		}
		function stats($id = '')
		{
			global $categories, $hovercolor, $pagelimit, $date_format, $site_url, $skin, $siteNameLength;
			if($id == '')
			{
				if($_POST['bsub'] == 'Delete')
				{
					$idTest = FALSE;
					if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && array_key_exists('list', $_POST) === TRUE && is_array($_POST['list']) && count($_POST['list']) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
					{
						$idTest = TRUE;
						$idList = implode(',', $_POST['list']);
						$numberOfIDs = count($_POST['list']);
					}
					if($idTest === TRUE)
					{
						dbcom('DELETE FROM downloads WHERE id IN(' .  $idList . ');');
						dbcom('DELETE FROM downloads_ratings WHERE id IN(' . $idList . ');');
						echo '<b>' . $numberOfIDs . ' download(s) deleted from main database!</b><br /><br /><a href="ddl.php?go=stats">Back to download list</a>';
						die();
					}
					else
					{
						echo 'You didn\'t select any download(s).<br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
					}
				}
				elseif($_POST['bsub'] == 'Blacklist Site')
				{ 
					#echo '<h2>Main Downloads</h2>' . "\n";
					if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && checkPostForm('blconfirm', $_POST) === TRUE)
					{
						if($_POST['blyesno'] == 'Blacklist')
						{
							# Blacklist site URL and delete array of downloads from downloads and que tables
							$idList = implode(',', $_POST['list']);
							$downloadURLquery = dbcom("SELECT DISTINCT surl FROM downloads WHERE id IN($idList);");
							$numberBanned = mysql_num_rows($downloadURLquery);
							while($downloadURLarray = mysql_fetch_assoc($downloadURLquery))
							{
								# get URL to ban
								$bannedDomain = $this->getdomain($downloadURLarray['surl']);
								$existingBanQuery = dbcom('SELECT url FROM blacklist WHERE url = "' . $bannedDomain . '" LIMIT 1;');
								if(mysql_num_rows($existingBanQuery) == 0)
								{
									dbcom("INSERT INTO blacklist (id, url) VALUES (NULL, '{$bannedDomain}');");
								}
								dbcom('DELETE FROM downloads_ratings WHERE id IN(SELECT id FROM downloads WHERE surl LIKE "%' . $bannedDomain . '%");');
								dbcom("DELETE FROM downloads WHERE surl LIKE '%{$bannedDomain}%';");
								dbcom("DELETE FROM que WHERE surl LIKE '%{$bannedDomain}%';");
								dbcom("DELETE FROM whitelist WHERE url LIKE '%{$bannedDomain}%';");
							}
							echo '&#149; ' . $numberBanned . ' URLs added to the Blacklist.<br />';
							echo '&#149; Related downloads deleted from main Database and Queue.<br /><br />';
							echo '<a href="ddl.php?go=stats">Back to main downloads</a>.';
							die();
						}
						else
						{
							echo '<p>An error occurred. This is not supposed to happen.</p>' . "\n";
						}
					}
					else
					{
						if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
						{
							$idList = implode(',', $_POST['list']);
							$downloadURLquery = dbcom("SELECT DISTINCT surl FROM downloads WHERE id IN($idList) ORDER BY surl;");
							while($downloadURLarray = mysql_fetch_assoc($downloadURLquery))
							{
								# get URL to ban
								$bannedURLs[] = $downloadURLarray['surl'];
								$bannedDomains[] = strtolower($this->getdomain($downloadURLarray['surl']));
							}
							$urlList = implode('","', $bannedDomains);
							$urlList = '"' . $urlList . '"';
							$whiteListQuery = dbcom("SELECT DISTINCT url FROM whitelist WHERE url IN($urlList) ORDER BY url;");
							if(mysql_num_rows($whiteListQuery) > 0)
							{
								while($whiteListArray = mysql_fetch_assoc($whiteListQuery))
								{
									$whiteListedDomains[] = strtolower($whiteListArray['url']);
								}
								echo '<form action="' . $site_url . '/admin/ddl.php?go=stats" method="post">' . "\n";
								echo '<div>' . "\n";
								echo '<p>Are you sure you want to blacklist? Your selection includes one or more whitelisted sites!</p>' . "\n";
								echo '<ol>' . "\n";
								for($i = 0; $i < count($bannedDomains); $i++)
								{
									if(isset($whiteListedDomains) && is_array($whiteListedDomains) && in_array($bannedDomains[$i], $whiteListedDomains) === TRUE)
									{
										echo '<li><a href="' . $bannedURLs[$i] . '" style="color: #008000;" target="_blank">' . $bannedURLs[$i] . '</a></li>';
									}
									else
									{
										echo '<li><a href="' . $bannedURLs[$i] . '" target="_blank">' . $bannedURLs[$i] . '</a></li>';
									}
								}
								echo '</ol>' . "\n";
								echo '<br />';
								echo '<input type="submit" name="blyesno" class="formbutton" value="Blacklist" />' . "\n";
								echo '<input type="button" class="formbutton" value="Cancel" onclick="javascript:window.location.href = \'' . $site_url . '/admin/ddl.php?go=stats' . '\';" />' . "\n";
								for($i = 0; $i < count($_POST['list']); $i++)
								{
									echo '<input type="hidden" name="list[]" value="' . $_POST['list'][$i] . '" />' . "\n";
								}
								echo '<input type="hidden" name="bsub" value="Blacklist Site" />' . "\n";
								echo '</div>' . "\n";
								echo '</form>' . "\n";
								die();
							}
							else
							{
								for($i = 0; $i < count($bannedDomains); $i++)
								{
									$existingBanQuery = dbcom('SELECT url FROM blacklist WHERE url = "' . $bannedDomains[$i] . '" LIMIT 1;');
									if(mysql_num_rows($existingBanQuery) == 0)
									{
										dbcom("INSERT INTO blacklist (id, url) VALUES (NULL, '{$bannedDomains[$i]}');");
									}
									dbcom('DELETE FROM downloads_ratings WHERE id IN(SELECT id FROM downloads WHERE surl LIKE "%' . $bannedDomains[$i] . '%");');
									dbcom("DELETE FROM downloads WHERE surl LIKE '%{$bannedDomains[$i]}%';");
									dbcom("DELETE FROM que WHERE surl LIKE '%{$bannedDomains[$i]}%';");
									dbcom("DELETE FROM whitelist WHERE url LIKE '%{$bannedDomains[$i]}%';");
								}
								echo '&#149; ' . count($bannedDomains) . ' URLs added to the Blacklist.<br />';
								echo '&#149; Related downloads deleted from main Database and Queue.<br /><br />';
								echo '<a href="ddl.php?go=stats">Back to main downloads</a>.';
								die();
							}
						}
						else
						{
							echo 'You didn\'t select any downloads. <br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
						}
					}
					/*
					if($_POST['list'])
					{
						# Blacklist site URL and delete array of downloads from downloads and que tables
						foreach($_POST['list'] as $banned)
						{
							$d++;
							$get = dbcom("SELECT surl FROM downloads WHERE id = '$banned';");
							$bannedrow = mysql_fetch_array($get);
							# get URL to ban
							$bannedurl = $this->getdomain($bannedrow[surl]);
							$uniqueurl[$d] = $bannedurl;
						}
						$uniqueurl = array_unique($uniqueurl);
						$urls = count($uniqueurl);
						for($i = 1; $i < ($urls + 1); $i++)
						{
							dbcom("INSERT INTO blacklist (id, url) VALUES (NULL, '{$uniqueurl[$i]}');");
							dbcom("DELETE FROM downloads WHERE surl LIKE '%{$uniqueurl[$i]}%';");
							dbcom("DELETE FROM que WHERE surl LIKE '%{$uniqueurl[$i]}%';");
						}
						# Remove any duplicate entries in blacklist table:
						dbcom('CREATE TABLE blacklist_temp AS SELECT * FROM blacklist WHERE 1 GROUP BY url;');
						dbcom('DROP TABLE blacklist;');
						dbcom('RENAME TABLE blacklist_temp TO blacklist;');
						dbcom('ALTER TABLE blacklist ADD PRIMARY KEY (url);');
						//echo "&#149; $d downloads deleted from main Database.<br>";
						echo "&#149; $urls URLs added to the Blacklist.<br>";
						echo '&#149; Related downloads deleted from main Database and Queue.<br><br>';
						echo '<a href="ddl.php?go=stats">Back to download list</a>';
						die();
					}
					*/
				}
				elseif($_POST['bsub'] == 'Ban By IP')
				{
					#echo '<h2>Main Downloads</h2>' . "\n";
					if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && checkPostForm('blconfirm', $_POST) === TRUE)
					{
						if($_POST['blyesno'] == 'Ban By IP')
						{
							$idList = implode(',', $_POST['list']);
							$downloadURLquery = dbcom("SELECT DISTINCT surl, ip FROM downloads WHERE id IN($idList);");
							echo '<p>The following IPs have been banned from using your Submitter and Autosubmitter:</p>' . "\n";
							echo '<ul>' . "\n";
							while($downloadURLarray = mysql_fetch_assoc($downloadURLquery))
							{
								# get URL to ban
								dbcom("DELETE FROM que WHERE ip = '{$downloadURLarray['ip']}';");
								dbcom('DELETE FROM downloads_ratings WHERE id IN(SELECT id FROM downloads WHERE ip = "' . $downloadURLarray['ip'] . '");');
								dbcom("DELETE FROM downloads WHERE ip = '{$downloadURLarray['ip']}';");
								dbcom("INSERT INTO submitter_bannedips VALUES (NULL, '{$downloadURLarray['ip']}');");
								echo "<li>{$downloadURLarray['ip']} ({$downloadURLarray['surl']})</li>\n";
							}
							echo '</ul>' . "\n";
							echo '<p><a href="ddl.php?go=stats">Back to main downloads</a>.</p>' . "\n";
							die();
						}
						else
						{
							echo '<p>An error occurred. This is not supposed to happen.</p>' . "\n";
						}
					}
					else
					{
						echo '<h2>Main Downloads</h2>' . "\n";
						if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
						{
							$idList = implode(',', $_POST['list']);
							$downloadURLquery = dbcom("SELECT DISTINCT surl, ip FROM downloads WHERE id IN($idList) ORDER BY surl;");
							while($downloadURLarray = mysql_fetch_assoc($downloadURLquery))
							{
								# get URL to ban
								$bannedURLs[] = $downloadURLarray['surl'];
								$bannedDomains[] = strtolower($this->getdomain($downloadURLarray['surl']));
								$bannedIPs[] = $downloadURLarray['ip'];
							}
							$urlList = implode('","', $bannedDomains);
							$urlList = '"' . $urlList . '"';
							$whiteListQuery = dbcom("SELECT DISTINCT url FROM whitelist WHERE url IN($urlList) ORDER BY url;");
							if(mysql_num_rows($whiteListQuery) > 0)
							{
								while($whiteListArray = mysql_fetch_assoc($whiteListQuery))
								{
									$whiteListedDomains[] = strtolower($whiteListArray['url']);
								}
							}
								echo '<form action="' . $site_url . '/admin/ddl.php?go=stats" method="post">' . "\n";
								echo '<div>' . "\n";
								echo '<p>Are you sure you want to ban by IP? ';
								if(isset($whiteListedDomains) && is_array($whiteListedDomains) && count($whiteListedDomains) > 0)
								{
									echo 'Your selection includes one or more whitelisted sites! ';
								}
								echo 'The selected IP(s) may be from a popular autosubmitter.</p>' . "\n";
								echo '<ol>' . "\n";
								for($i = 0; $i < count($bannedDomains); $i++)
								{
									if(isset($whiteListedDomains) && is_array($whiteListedDomains) && in_array($bannedDomains[$i], $whiteListedDomains) === TRUE)
									{
										echo '<li><a href="' . $bannedURLs[$i] . '" style="color: #008000;" target="_blank">' . $bannedURLs[$i] . '</a> (<a href="http://ip-lookup.net/index.php?ip=' . $bannedIPs[$i] . '" target="_blank">' . $bannedIPs[$i] . '</a>)</li>';
									}
									else
									{
										echo '<li><a href="' . $bannedURLs[$i] . '" target="_blank">' . $bannedURLs[$i] . '</a> (<a href="http://ip-lookup.net/index.php?ip=' . $bannedIPs[$i] . '" target="_blank">' . $bannedIPs[$i] . '</a>)</li>';
									}
								}
								echo '</ol>' . "\n";
								echo '<br />';
								echo '<input type="submit" name="blyesno" class="formbutton" value="Ban By IP" />' . "\n";
								echo '<input type="button" class="formbutton" value="Cancel" onclick="javascript:window.location.href = \'' . $site_url . '/admin/ddl.php?go=stats' . '\';" />' . "\n";
								for($i = 0; $i < count($_POST['list']); $i++)
								{
									echo '<input type="hidden" name="list[]" value="' . $_POST['list'][$i] . '" />' . "\n";
								}
								echo '<input type="hidden" name="bsub" value="Ban By IP" />' . "\n";
								echo '</div>' . "\n";
								echo '</form>' . "\n";
								die();
							/*}
							else
							{
								echo '<p>The following IPs have been banned from using your Submitter and Autosubmitter:<br />';
								for($i = 0; $i < count($bannedIPs); $i++)
								{
									dbcom("DELETE FROM que WHERE ip = '{$bannedIPs[$i]}';");
									dbcom("DELETE FROM downloads WHERE ip = '{$bannedIPs[$i]}';");
									dbcom("INSERT INTO submitter_bannedips VALUES (NULL, '{$bannedIPs[$i]}');");
									echo "{$bannedIPs[$i]} ({$bannedURLs[$i]})<br />";
								}
								echo '<a href="ddl.php?go=stats">Back to main downloads</a>.';
								echo '</p>';
								die();
							}*/
						}
						else
						{
							echo 'You didn\'t select any IPs. <br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
						}
					}
					/*
					if(array_key_exists('list', $_POST))
					{
						foreach($_POST['list'] as $banned)
						{
							$get = dbcom("SELECT surl, ip FROM downloads WHERE id = $banned AND ip != NULL;");
							if(mysql_num_rows($get) > 0)
							{
								$bannedrows[] = mysql_fetch_array($get);
							}
						}
						if(count($bannedrows) > 0)
						{
							$bannedrows = array_unique($bannedrows);
							echo '<p>The following IPs have been banned from using your Submitter and Autosubmitter:<br>';
							for($i = 0; $i < count($bannedrows); $i++)
							{
								dbcom("DELETE FROM que WHERE ip = '{$bannedrows[$i]['ip']}';");
								dbcom("DELETE FROM downloads WHERE ip = '{$bannedrows[$i]['ip']}';");
								dbcom("INSERT INTO submitter_bannedips VALUES (NULL, '{$bannedrows[$i]['ip']}');");
								echo "{$bannedrows[$i]['ip']} ({$bannedrows[$i]['surl']})<br>";
							}
							echo '</p>';
						}
						else
						{
							echo '<p>No IPs have been banned!</p>';
						}
					}
					else
					{
						echo "You didn't select any IPs. <br><br><a href=\"javascript:history.go(-1)\">Go Back</a>.";
					}
					*/
				}
				if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
				{
					$page = $_GET['page'];
				}
				else
				{
					$page = 1;
				}
				$this->page = $page;
				$this->page *= $pagelimit;
				$this->page -= $pagelimit;
				if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('filterURL', $_GET) && strlen(testURL($_GET['filterURL'])) > 0)
				{
					$filterURL = mysql_escape_string($_GET['filterURL']);
					$g_total = dbcom('SELECT COUNT(id) AS TOTAL FROM downloads WHERE surl = "' . $filterURL . '";');
				}
				else
				{
					$g_total = dbcom('SELECT COUNT(id) AS TOTAL FROM downloads;');
				}
				$this->total = mysql_result($g_total, 0);
				if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('filterURL', $_GET) && strlen(testURL($_GET['filterURL'])) > 0)
				{
					$filterURL = mysql_escape_string($_GET['filterURL']);
					$get = dbcom("SELECT id, type, title, url, sname, surl, UNIX_TIMESTAMP(date) AS theDate, email, views, reports, rating, ip FROM downloads WHERE surl = '$filterURL' ORDER BY id DESC LIMIT $this->page, $pagelimit;");
				}
				else
				{
					$get = dbcom("SELECT id, type, title, url, sname, surl, UNIX_TIMESTAMP(date) AS theDate, email, views, reports, rating, ip FROM downloads ORDER BY id DESC LIMIT $this->page, $pagelimit;");
				}
				echo "<h2>Main Downloads</h2><P>There are $this->total downloads in the database.<br><br>
				<form name=\"f1\" action=\"ddl.php?go=stats\" method=\"post\">
				<table border=0 cellspacing=0 cellpadding=0 width=\"100%\"><tr height=25><td width=10></td>
				<td width=50><b>Edit</b></td><td width=50><b>Type</b></td><td width=*><b>Title</b></td><td width=100><b>Date</b></td><td width=100><b>Submitter/IP <img src=\"" . $site_url . "/admin/images/toggle.gif\" alt=\"Toggle Site\" border=\"0\" /></b></td><td width=30>Views</td></tr>";
				while($row = mysql_fetch_array($get))
				{
					$row['title'] = stripslashes($row['title']);
					echo "<tr onmouseover=\"this.style.backgroundColor='$hovercolor'; return true;\" onmouseout=\"this.style.backgroundColor=''\">
					<td><input type=\"checkbox\" id=\"list\" name=\"list[]\" value=\"".$row[id]."\" "; if ($this->whitelisted($row[surl]) && $this->whitelisted($row[url])) echo 'checked="checked"'; echo " class=\"box\"></td>
					<td><a href=\"ddl.php?go=stats&id=$row[id]\">Edit</a></td>
					<td>$row[type]</td>
					<td><a href=\"$row[url]\" "; if ($this->whitelisted($row[surl]) && $this->whitelisted($row[url]) && $auto_allow==0) echo "style=\"color: #008000\""; echo " target=\"_blank\">" . substr($row['title'], 0, $siteNameLength) . "</a> ";
					$unrating = 5;
					for($i = 0; $i < $row['rating'] && $i < 5; $i++)
					{
						echo '<img src="' . $site_url . '/admin/images/star.gif" height="10" width="10" border="0" alt="Download Rating" align="middle" />';
						$unrating--;
					}
					for($i = 0; $i < $unrating && $i < 5; $i++)
					{
						echo '<img src="' . $site_url . '/admin/images/unstar.gif" height="10" width="10" border="0" alt="Download Rating" align="middle" />';
					}
					echo "</td>
					<td>" . date($date_format, $row['theDate']) . "</td>
					<td><a href=\"$row[surl]\" "; if ($this->whitelisted($row[surl]) && $this->whitelisted($row[url]) && $auto_allow==0) echo "style=\"color: #008000\""; echo " target=\"_blank\" onMouseover=\"ddrivetip('IP: ".$row[ip]."')\"; onMouseout=\"hideddrivetip()\">$row[sname]</a>"; if($this->vip($row['surl'])){ echo ' <img src="' . $site_url . '/admin/images/vip.gif" alt="VIP Site" />'; } echo " <a href=\"ddl.php?go=stats&filterURL=$row[surl]\"><img src=\"" . $site_url . "/admin/images/toggle.gif\" alt=\"Toggle Site\" border=\"0\" /></a></td>
					<td align=\"center\">$row[views]</td></tr>\n";
				}
				echo '</table><p>';
				if(isset($filterURL))
				{
					$this->paginate('ddl.php?go=stats&filterURL=' . $filterURL . '&page=');
				}
				else
				{
					$this->paginate('ddl.php?go=stats&page=');
				}
            	echo '<P><input type=button value="Check All" class="form" onClick="this.value=check(this.form.list)">
				<p>
            <table border=0 cellspacing=0 cellpadding=0 width="100%"><tr>
            <td><input type="Submit" name="bsub" value="Delete" class="formbutton"></td>
				<td align=right><input type="Submit" name="bsub" value="Blacklist Site" class="formbutton"> <input type="Submit" name="bsub" value="Ban By IP" class="formbutton"><br><small>WARNING: Blacklist/Ban By IP will delete all related downloads from Queue and main Downloads!<br><I>Ban by IP: Be extra careful, many IPs are those of AUTOSUBMITTERS!</I></small></td>
            </tr></table></form>';
			}
			else
			{
				if(isset($_POST) && is_array($_POST) && count($_POST) > 0)
				{
					if(array_key_exists('delete', $_POST) === TRUE && $_POST['delete'] == 1)
					{
						dbcom('DELETE FROM downloads_ratings WHERE id = ' . $id . ';');
						dbcom('DELETE FROM downloads WHERE id = ' . $id . ';');
						echo '<p>The file "' . $_POST['title'] . '" has been deleted!<br><br><a href="ddl.php?go=stats">Back to download list</a></p>';
					}
					else
					{
						dbcom('UPDATE downloads SET type="' . $_POST['type'] . '", title="' . $_POST['title'] . '", url="' . $_POST['url'] . '", sname="' . $_POST['sname'] . '", surl="' . $_POST['surl'] . '", email="' . $_POST['email'] . '" WHERE id = ' . $id . ';');
						echo '<p><b>' . $_POST['title'] . ' updated!</b><br /><br /><a href="ddl.php?go=stats&id=' . $id . '">Back to Edit Screen</a>.</p>' . "\n";
					}
				}
				else
				{
					$downloadQuery = dbcom('SELECT * FROM downloads WHERE id = ' . $id . ' LIMIT 1;');
					$downloadArray = mysql_fetch_assoc($downloadQuery);
					echo '<h2>Edit Download</h2>
						<p>
							<table border="0" cellspacing="2" cellpadding="1">
								<form name="editid" action="ddl.php?go=stats&id=' . $id . '" method="post">
									<tr>
										<td class="form2">Id: </td><td class="form">' . $id . '</td>
									</tr>
									<tr>
										<td class="form2">Type: </td>
										<td>
											<select name="type" class="form">' . "\n";
					$type = capitalize($downloadArray['type']);
					if($type == 'Ebook' || $type == 'EBook')
					{
						$type = 'eBook';
					}
					if($type == 'XXX')
					{
						$type = 'Xxx';
					}
					if(!in_array($type, $categories))
					{
						# It's not a part of our allowed types
						$type = 'Other';
					}
					for($i = 0; $i < count($categories); $i++)
					{
						if($type != $categories[$i])
						{
							echo '<option value="' . $categories[$i] . '">' . $categories[$i] . "</option>\n";
						}
						else
						{
							echo '<option value="' . $categories[$i] . '" selected>' . $categories[$i] . "</option>\n";
						}
					}
					echo '</select>
								</td>
							</tr>
							<tr>
								<td class="form2">Title: </td>
								<td>
									<input type="text" name="title" size="60" class="form" value="' . $downloadArray['title'] . '" />
								</td>
							</tr>
							<tr>
								<td class="form2">Url: </td>
								<td>
									<input type="text" name="url" size="60" class="form" value="' . $downloadArray['url'] . '" />
								</td>
							</tr>
							<tr>
								<td class="form2">Submitter: </td>
								<td>
									<input type="text" name="sname" size="60" class="form" value="' . $downloadArray['sname'] . '" />
								</td>
							</tr>
							<tr>
								<td class="form2">Url: </td>
								<td>
									<input type="text" name="surl" size="60" class="form" value="' . $downloadArray['surl'] . '" />
								</td>
							</tr>
							<tr>
								<td class="form2">E-mail: </td>
								<td>
									<input type="text" name="email" size="60" class="form" value="' . $downloadArray['email'] . '" />
								</td>
							</tr>
							<tr>
								<td class="form2">Delete? </td>
								<td class="form">
									<input type="checkbox" name="delete" value="1" /> Check to Delete
								</td>
							</tr>
							<tr>
								<td></td>
								<td>
									<input type="Submit" value="Update!" class="formbutton" />
								</td>
							</tr>
						</form>
					</table>' . "\n";
				}
			}
		}
		function add($location, $insert)
		{
			global $max_dl, $max_que, $date_format;
			if(!(isset($_POST) && is_array($_POST) && count($_POST) > 0))
			{
				$this->form($location);
			}
			elseif(isset($_POST) && is_array($_POST) && count($_POST) > 0 && (strlen($_POST['title'][0]) == 0 || strlen($_POST['url'][0]) == 0 || strlen($_POST['sname']) == 0 || strlen(testURL($_POST['surl'])) == 0))
			{
				echo '<h2>Add Downloads</h2>' . "\n";
				echo '<p>Not all required fields were filled out correctly.<br><br><a href="javascript:history.go(-1)">Go back</a> and try again.</p>' . "\n";
			}
			else
			{
				echo '<h2>Add Downloads</h2>' . "\n";
				if($insert == 1)
				{
					$tabellen = 'downloads';
				}
				else
				{
					$tabellen = 'que';
				}
				$i = $banned = 0;
				$dato = date($date_format);
				while($i < count($_POST['title']))
				{
					if($_POST['title'][$i] != '' && $_POST['url'][$i] != '' && $_POST['type'][$i] != '')
					{
						# Kill any security threats with $HTTP_POST_VARS manually because foreach($HTTP_POST_VARS as $key=>val) doesn't work
						#include(WWWROOT . 'killthreat.php');
						$disallowedtags = array
						(
							'script',
							'object',
							'iframe',
							'image',
							'applet',
							'meta',
							'form',
							'onmouseover',
							'onmouseout'
						);
						foreach($disallowedtags as $tag)
						{
							if(preg_match('/<[^>]*' . $tag . '/i', $_POST['title'][$i]) !== 0)
							{
							    echo 'You are not allowed to do that.';
								include(ADMINDIR . 'adminfooter.php');
							    die();
							}
							if(preg_match('/<[^>]*' . $tag . '/i', $_POST['url'][$i]) !== 0)
							{
							    echo 'You are not allowed to do that.';
								include(ADMINDIR . 'adminfooter.php');
							    die();
							}
							if(preg_match('/<[^>]*' . $tag . '/i', $_POST['type'][$i]) !== 0)
							{
							    echo 'You are not allowed to do that.';
								include(ADMINDIR . 'adminfooter.php');
							    die();
							}
						}
						$sql_title = $_POST['title'][$i];
						$sql_url = $_POST['url'][$i];
						$sql_type = $_POST['type'][$i];
						if(!$this->blacklist($_POST['surl']))
						{
							dbcom("INSERT INTO $tabellen (type, title, url, sname, surl, date, email, ip)
								VALUES ('$sql_type', '$sql_title', '$sql_url', '{$_POST['sname']}', '{$_POST['surl']}', '$dato', '{$_POST['email']}', '{$_SERVER['REMOTE_ADDR']}');");
							$g_antall = dbcom('SELECT COUNT(id) AS TOTAL FROM downloads;');
							$antall = mysql_result($g_antall, 0);
							$antallet = $antall + count($title);
							if($antallet > $max_dl && $max_dl > 0)
							{
								$max_limit = $antallet - $max_dl;
								$max_get = dbcom("SELECT * FROM downloads ORDER BY id LIMIT 0, $max_limit");
								while($max_row = mysql_fetch_row($max_get))
								{
									$max_id[] = $max_row[0];
								}
								$idList = implode(',', $max_id);
								dbcom('DELETE FROM downloads_ratings WHERE id IN(' . $idList . ');');
								dbcom('DELETE FROM downloads WHERE id IN(' . $idList . ');');
							}
							$queQuery = dbcom('SELECT COUNT(id) AS TOTAL FROM que;');
							$antall = mysql_result($queQuery, 0);
							$antallet = $antall + count($title);
							if($antallet > $max_que && $max_que > 0)
							{
								$max_limit = $antallet - $max_que;
								$max_get = dbcom("SELECT * FROM que ORDER BY id LIMIT 0, $max_limit;");
								while($max_row = mysql_fetch_row($max_get))
								{
									$max_id[] = $max_row[0];
								}
								$idList = implode(',', $max_id);
								dbcom("DELETE FROM que WHERE id IN ($idList);");
							}
							$banned = FALSE;
						}
						else
						{
							$banned = TRUE;
						}
					}
					else
					{
						break;
					}
					$i++;
				}
				if($insert == 1 && $banned === FALSE)
				{
					echo '<p><b>Data added to database</b><br /><br /></p>' . "\n";
				}
				elseif($banned === FALSE)
				{
					echo '<p><b>The downloads have been submitted into the Queue.</b><br /><br /></p>' . "\n";
				}
				else
				{
					echo '<p><span style="color: #ff0000;"><b>That site has been blacklisted!</b></span><br /><br /></p>' . "\n";
				}
			}
		}
		function itembanned($haystack)
		{
			$bannedwords = dbcom('SELECT word FROM bannedwords;');
			while($banned = mysql_fetch_array($bannedwords))
			{
				if(stristr($haystack, $banned['word']))
				{
					return TRUE;
					break;
				}
			}
		}
		function whitelisted($url)
		{
			$whitelisted = dbcom('SELECT url FROM whitelist;');
			while($clean = mysql_fetch_array($whitelisted))
			{
				if(stristr($url, $clean['url']))
				{
					return TRUE;
					break;
				}
			}
		}
		function que($go = NULL)
		{
			global $auto_allow, $whitelist_threshold, $hovercolor, $max_dl, $date_format, $pagelimit, $siteNameLength, $max_que, $site_url, $skin, $categories;
			$site_urls = array();
			if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
			{
				$page = $_GET['page'];
			}
			else
			{
				$page = 1;
			}
			$this->page = $page;
			$this->page *= $pagelimit;
			$this->page -= $pagelimit;
			if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('filterURL', $_GET) && strlen(testURL($_GET['filterURL'])) > 0)
			{
				$filterURL = mysql_escape_string($_GET['filterURL']);
				$g_total = dbcom('SELECT COUNT(id) AS TOTAL FROM que WHERE surl = "' . $filterURL . '";');
			}
			elseif(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('filterIP', $_GET) && ip2long($_GET['filterIP']) !== FALSE)
			{
				$filterIP = mysql_escape_string($_GET['filterIP']);
				$g_total = dbcom('SELECT COUNT(id) AS TOTAL FROM que WHERE ip = "' . $filterIP . '";');
			}
			else
			{
				$g_total = dbcom('SELECT COUNT(id) AS TOTAL FROM que;');
			}
			$this->total = mysql_result($g_total, 0);
			$check_first = 1;
			$idTest = FALSE;
			if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && array_key_exists('list', $_POST) === TRUE && is_array($_POST['list']) && count($_POST['list']) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
			{
				$idTest = TRUE;
				$idList = implode(',', $_POST['list']);
				$numberOfIDs = count($_POST['list']);
			}
			if($go == 'Insert')
			{
				echo '<h2>Submitted Queue</h2>' . "\n";
				$tabellen = 'downloads';
				if($idTest === TRUE)
				{
					$hvahvor = $this->run($_POST['list']);
					$dato = date($date_format);
					$get = dbcom("SELECT * FROM que WHERE $hvahvor;");
					dbcom("DELETE FROM que WHERE $hvahvor");
					while($row = mysql_fetch_array($get))
					{
						$type = mysql_escape_string($row['type']);
						$title = mysql_escape_string($row['title']);
						$url = mysql_escape_string($row['url']);
						$sname = mysql_escape_string($row['sname']);
						$surl = mysql_escape_string($row['surl']);
						$email = mysql_escape_string($row['email']);
						$IP = mysql_escape_string($row['ip']);
						dbcom("INSERT INTO downloads (type, title, url, sname, surl, date, email, ip)
						VALUES ('$type','$title','$url','$sname','$surl', CURRENT_DATE(), '$email', '$IP')");
						# Count the total number of site urls
						$site_urls[] = $row['surl'];
					}
					# Get the unique number of site urls submitted:
					$site_urls = array_unique($site_urls);
					foreach($site_urls as $site_url)
					{
						# Count total downloads in main database from this site
						$countdls = dbcom("SELECT surl FROM downloads WHERE surl = '$site_url';");
						while ($rows = mysql_fetch_array($countdls))
						{ 
							$totalsubs++;
						}
						if($totalsubs > $whitelist_threshold)
						{
							# Add the site url to the whitelist automatically
							$whitelistedurl = $this->getdomain($site_url);
							# Delete from blacklist if exists
							dbcom("DELETE FROM blacklist WHERE url = '$whitelistedurl';");
							# Check if already in the whitelist
							$whitelistQuery = dbcom("SELECT url FROM whitelist WHERE url = '$whitelistedurl' LIMIT 1;");
							# Add url to whitelist if not already there:
							if(mysql_num_rows($whitelistQuery) == 0)
							{
								dbcom("INSERT INTO whitelist (id, url) VALUES (NULL, '$whitelistedurl');");
								echo "<span style=color:green>Site: $whitelistedurl reached the whitelist threshold ($whitelist_threshold) and was added to whitelist!</span><br /><br />";
							}
						}
					}
					echo "<b>".count($_POST['list'])." downloads inserted into main database!</b>";
					echo "<br><br><a href=\"javascript:history.go(-1)\">Back</a>";
				}
				else
				{
					echo 'You didn\'t select any downloads. <br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
				}
				$g_antall = dbcom("SELECT COUNT(id) AS TOTAL FROM $tabellen;");
				$antall = mysql_result($g_antall,0);
				$antallet = $antall + count($title);
				if ($antallet > $max_dl && $max_dl > 0) {
					$max_limit = $antallet-$max_dl;
					$max_get = dbcom("SELECT * FROM $tabellen ORDER BY id LIMIT 0, $max_limit;");
					while ($max_row = mysql_fetch_row($max_get)) {
						$max_id[] = $max_row[0];
					}
					for ($i=0; $i<count($max_id); $i++) {
						if ($i == 0)
							$max_query = "WHERE id = '".$max_id[$i]."'";
						else
							$max_query .= " || id = '".$max_id[$i]."'";
					}
					dbcom('DELETE FROM downloads_ratings WHERE id ' . $max_query . ';');
					dbcom("DELETE FROM $tabellen $max_query;");
				}
				$queQuery = dbcom('SELECT COUNT(id) AS TOTAL FROM que;');
				$antall = mysql_result($queQuery, 0);
				$antallet = $antall + count($title);
				if($antallet > $max_que && $max_que > 0)
				{
					$max_limit = $antallet - $max_que;
					$max_get = dbcom("SELECT * FROM que ORDER BY id LIMIT 0, $max_limit;");
					while($max_row = mysql_fetch_row($max_get))
					{
						$max_id[] = $max_row[0];
					}
					for($i = 0; $i < count($max_id); $i++)
					{
						if($i == 0)
						{
							$max_query = "WHERE id = '".$max_id[$i]."'";
						}
						else
						{
							$max_query .= " || id = '".$max_id[$i]."'";
						}
					}
					$idList = implode(',', $max_id);
					#echo "DELETE FROM que WHERE id IN ('$idList');";
					#dbcom("DELETE FROM que $max_query;");
				}
			}
			elseif($go == 'Delete')
			{
				echo '<h2>Submitted Queue</h2>' . "\n";
				if($idTest === TRUE)
				{
					$hvahvor = $this->run($_POST['list']);
					dbcom("DELETE FROM que WHERE $hvahvor;");
					echo '<b>' . count($_POST['list']) . ' downloads in queue deleted!</b><br /><br /><a href="javascript:history.go(-1)">Back</a>.';
				}
				else
				{
					echo 'You didn\'t select any downloads. <br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
				}
			}
			elseif($go == 'Blacklist Site')
			{
				echo '<h2>Submitted Queue</h2>' . "\n";
				if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && checkPostForm('blconfirm', $_POST) === TRUE)
				{
					if($_POST['blyesno'] == 'Blacklist')
					{
						# Blacklist site URL and delete array of downloads from downloads and que tables
						$idList = implode(',', $_POST['list']);
						$queURLquery = dbcom("SELECT DISTINCT surl FROM que WHERE id IN($idList);");
						$numberBanned = mysql_num_rows($queURLquery);
						while($queURLarray = mysql_fetch_assoc($queURLquery))
						{
							# get URL to ban
							$bannedDomain = $this->getdomain($queURLarray['surl']);
							$existingBanQuery = dbcom('SELECT url FROM blacklist WHERE url = "' . $bannedDomain . '" LIMIT 1;');
							if(mysql_num_rows($existingBanQuery) == 0)
							{
								dbcom("INSERT INTO blacklist (id, url) VALUES (NULL, '{$bannedDomain}');");
							}
							dbcom('DELETE FROM downloads_ratings WHERE id IN(SELECT id FROM downloads WHERE surl LIKE "%' . $bannedDomain . '%");');
							dbcom("DELETE FROM downloads WHERE surl LIKE '%{$bannedDomain}%';");
							dbcom("DELETE FROM que WHERE surl LIKE '%{$bannedDomain}%';");
							dbcom("DELETE FROM whitelist WHERE url LIKE '%{$bannedDomain}%';");
						}
						echo '&#149; ' . $numberBanned . ' URLs added to the Blacklist.<br />';
						echo '&#149; Related downloads deleted from main Database and Queue.<br /><br />';
						echo '<a href="ddl.php?go=added">Back to submitted queue</a>.';
						die();
					}
					else
					{
						echo '<p>An error occurred. This is not supposed to happen.</p>' . "\n";
					}
				}
				else
				{
					if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
					{
						$queURLquery = dbcom("SELECT DISTINCT surl FROM que WHERE id IN($idList) ORDER BY surl;");
						while($queURLarray = mysql_fetch_assoc($queURLquery))
						{
							# get URL to ban
							$bannedURLs[] = $queURLarray['surl'];
							$bannedDomains[] = strtolower($this->getdomain($queURLarray['surl']));
						}
						$urlList = implode('","', $bannedDomains);
						$urlList = '"' . $urlList . '"';
						$whiteListQuery = dbcom("SELECT DISTINCT url FROM whitelist WHERE url IN($urlList) ORDER BY url;");
						if(mysql_num_rows($whiteListQuery) > 0)
						{
							while($whiteListArray = mysql_fetch_assoc($whiteListQuery))
							{
								$whiteListedDomains[] = strtolower($whiteListArray['url']);
							}
							echo '<form action="' . $site_url . '/admin/ddl.php?go=added" method="post">' . "\n";
							echo '<div>' . "\n";
							echo '<p>Are you sure you want to blacklist? Your selection includes one or more whitelisted sites!</p>' . "\n";
							echo '<ol>' . "\n";
							for($i = 0; $i < count($bannedDomains); $i++)
							{
								if(isset($whiteListedDomains) && is_array($whiteListedDomains) && in_array($bannedDomains[$i], $whiteListedDomains) === TRUE)
								{
									echo '<li><a href="' . $bannedURLs[$i] . '" style="color: #008000;" target="_blank">' . $bannedURLs[$i] . '</a></li>';
								}
								else
								{
									echo '<li><a href="' . $bannedURLs[$i] . '" target="_blank">' . $bannedURLs[$i] . '</a></li>';
								}
							}
							echo '</ol>' . "\n";
							echo '<br />';
							echo '<input type="submit" name="blyesno" class="formbutton" value="Blacklist" />' . "\n";
							echo '<input type="button" class="formbutton" value="Cancel" onclick="javascript:window.location.href = \'' . $site_url . '/admin/ddl.php?go=added' . '\';" />' . "\n";
							for($i = 0; $i < count($_POST['list']); $i++)
							{
								echo '<input type="hidden" name="list[]" value="' . $_POST['list'][$i] . '" />' . "\n";
							}
							echo '<input type="hidden" name="bsub" value="Blacklist Site" />' . "\n";
							echo '</div>' . "\n";
							echo '</form>' . "\n";
						}
						else
						{
							for($i = 0; $i < count($bannedDomains); $i++)
							{
								$existingBanQuery = dbcom('SELECT url FROM blacklist WHERE url = "' . $bannedDomains[$i] . '" LIMIT 1;');
								if(mysql_num_rows($existingBanQuery) == 0)
								{
									dbcom("INSERT INTO blacklist (id, url) VALUES (NULL, '{$bannedDomains[$i]}');");
								}
								dbcom('DELETE FROM downloads_ratings WHERE id IN(SELECT id FROM downloads WHERE surl LIKE "%' . $bannedDomains[$i]. '%");');
								dbcom("DELETE FROM downloads WHERE surl LIKE '%{$bannedDomains[$i]}%';");
								dbcom("DELETE FROM que WHERE surl LIKE '%{$bannedDomains[$i]}%';");
								dbcom("DELETE FROM whitelist WHERE url LIKE '%{$bannedDomains[$i]}%';");
							}
							echo '&#149; ' . count($bannedDomains) . ' URLs added to the Blacklist.<br />';
							echo '&#149; Related downloads deleted from main Database and Queue.<br /><br />';
							echo '<a href="ddl.php?go=added">Back to submitted queue</a>.';
							die();
						}
					}
					else
					{
						echo 'You didn\'t select any downloads. <br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
					}
				}
			}
			elseif($go == 'Ban By IP')
			{
				echo '<h2>Submitted Queue</h2>' . "\n";
				if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && checkPostForm('blconfirm', $_POST) === TRUE)
				{
					if($_POST['blyesno'] == 'Ban By IP')
					{
						$idList = implode(',', $_POST['list']);
						$queURLquery = dbcom("SELECT DISTINCT surl, ip FROM que WHERE id IN($idList);");
						echo '<p>The following IPs have been banned from using your Submitter and Autosubmitter:</p>' . "\n";
						echo '<ul>' . "\n";
						while($queURLarray = mysql_fetch_assoc($queURLquery))
						{
							# get URL to ban
							dbcom("DELETE FROM que WHERE ip = '{$queURLarray['ip']}';");
							dbcom('DELETE FROM downloads_ratings WHERE id IN(SELECT id FROM downloads WHERE ip = "' . $queURLarray['ip'] . '");');
							dbcom("DELETE FROM downloads WHERE ip = '{$queURLarray['ip']}';");
							dbcom("INSERT INTO submitter_bannedips VALUES (NULL, '{$queURLarray['ip']}');");
							echo "<li>{$queURLarray['ip']} ({$queURLarray['surl']})</li>\n";
						}
						echo '</ul>' . "\n";
						echo '<p><a href="ddl.php?go=added">Back to submitted queue</a>.</p>' . "\n";
						die();
					}
					else
					{
						echo '<p>An error occurred. This is not supposed to happen.</p>' . "\n";
					}
				}
				else
				{
					if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
					{
						$queURLquery = dbcom("SELECT DISTINCT surl, ip FROM que WHERE id IN($idList) ORDER BY surl;");
						while($queURLarray = mysql_fetch_assoc($queURLquery))
						{
							# get URL to ban
							$bannedURLs[] = $queURLarray['surl'];
							$bannedDomains[] = strtolower($this->getdomain($queURLarray['surl']));
							$bannedIPs[] = $queURLarray['ip'];
						}
						$urlList = implode('","', $bannedDomains);
						$urlList = '"' . $urlList . '"';
						$whiteListQuery = dbcom("SELECT DISTINCT url FROM whitelist WHERE url IN($urlList) ORDER BY url;");
						if(mysql_num_rows($whiteListQuery) > 0)
						{
							while($whiteListArray = mysql_fetch_assoc($whiteListQuery))
							{
								$whiteListedDomains[] = strtolower($whiteListArray['url']);
							}
						}
							echo '<form action="' . $site_url . '/admin/ddl.php?go=added" method="post">' . "\n";
							echo '<div>' . "\n";
							echo '<p>Warning! Are you sure you want to ban by IP? ';
							if(isset($whiteListedDomains) && is_array($whiteListedDomains) && count($whiteListedDomains) > 0)
							{
								echo 'Your selection includes one or more whitelisted sites! ';
							}
							echo 'Make sure it\'s not an autosubmitter IP. Do you want to continue?.</p>' . "\n";
							echo '<ol>' . "\n";
							for($i = 0; $i < count($bannedDomains); $i++)
							{
								if(isset($whiteListedDomains) && is_array($whiteListedDomains) && in_array($bannedDomains[$i], $whiteListedDomains) === TRUE)
								{
									echo '<li><a href="' . $bannedURLs[$i] . '" style="color: #008000;" target="_blank">' . $bannedURLs[$i] . '</a> (<a href="http://ip-lookup.net/index.php?ip=' . $bannedIPs[$i] . '" target="_blank">' . $bannedIPs[$i] . '</a>)</li>';
								}
								else
								{
									echo '<li><a href="' . $bannedURLs[$i] . '" target="_blank">' . $bannedURLs[$i] . '</a> (<a href="http://ip-lookup.net/index.php?ip=' . $bannedIPs[$i] . '" target="_blank">' . $bannedIPs[$i] . '</a>)</li>';
								}
							}
							echo '</ol>' . "\n";
							echo '<br />';
							echo '<input type="submit" name="blyesno" class="formbutton" value="Ban By IP" />' . "\n";
							echo '<input type="button" class="formbutton" value="Cancel" onclick="javascript:window.location.href = \'' . $site_url . '/admin/ddl.php?go=added' . '\';" />' . "\n";
							for($i = 0; $i < count($_POST['list']); $i++)
							{
								echo '<input type="hidden" name="list[]" value="' . $_POST['list'][$i] . '" />' . "\n";
							}
							echo '<input type="hidden" name="bsub" value="Ban By IP" />' . "\n";
							echo '</div>' . "\n";
							echo '</form>' . "\n";
						/*}
						else
						{
							echo '<p>The following IPs have been banned from using your Submitter and Autosubmitter:<br />';
							for($i = 0; $i < count($bannedIPs); $i++)
							{
								dbcom("DELETE FROM que WHERE ip = '{$bannedIPs[$i]}';");
								dbcom("DELETE FROM downloads WHERE ip = '{$bannedIPs[$i]}';");
								dbcom("INSERT INTO submitter_bannedips VALUES (NULL, '{$bannedIPs[$i]}');");
								echo "{$bannedIPs[$i]} ({$bannedURLs[$i]})<br />";
							}
							echo '<a href="ddl.php?go=added">Back to submitted queue</a>.';
							echo '</p>';
							die();
						}*/
					}
					else
					{
						echo 'You didn\'t select any IPs. <br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
					}
				}
/*
				if(array_key_exists('list', $_POST))
				{
					foreach($_POST['list'] as $banned)
					{
						$get = dbcom("SELECT surl, ip FROM que WHERE id = $banned;");
						if(mysql_num_rows($get) > 0)
						{
							$bannedrows[] = mysql_fetch_array($get);
						}
					}
					if(count($bannedrows) > 0)
					{
						$bannedrows = array_unique($bannedrows);
						echo '<p>The following IPs have been banned from using your Submitter and Autosubmitter:<br>';
						for($i = 0; $i < count($bannedrows); $i++)
						{
							dbcom("DELETE FROM que WHERE ip = '{$bannedrows[$i]['ip']}';");
							dbcom("DELETE FROM downloads WHERE ip = '{$bannedrows[$i]['ip']}';");
							dbcom("INSERT INTO submitter_bannedips VALUES (NULL, '{$bannedrows[$i]['ip']}');");
							echo "{$bannedrows[$i]['ip']} ({$bannedrows[$i]['surl']})<br>";
						}
						echo '</p>';
					}
					else
					{
						echo '<p>No IPs have been banned!</p>';
					}
				}
				else
				{
					echo "You didn't select any IPs. <br><br><a href=\"javascript:history.go(-1)\">Go Back</a>.";
				}
			*/
			}
			else
			{
				if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('filterURL', $_GET) && strlen(testURL($_GET['filterURL'])) > 0)
				{
					$filterURL = mysql_escape_string($_GET['filterURL']);
					$get = dbcom("SELECT * FROM que WHERE surl = '$filterURL' ORDER BY id DESC LIMIT $this->page, $pagelimit;");
				}
				elseif(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('filterIP', $_GET) && ip2long($_GET['filterIP']) !== FALSE)
				{
					$filterIP = mysql_escape_string($_GET['filterIP']);
					$get = dbcom("SELECT * FROM que WHERE ip = '$filterIP' ORDER BY id DESC LIMIT $this->page, $pagelimit;");
				}
				elseif(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('sortBy', $_GET) && in_array($_GET['sortBy'], $categories) !== FALSE)
				{
					$sortBy = $_GET['sortBy'];
					$get = dbcom("SELECT * FROM ((SELECT * FROM que WHERE type = '$sortBy' ORDER BY id DESC) UNION (SELECT * FROM que WHERE type != '$sortBy' ORDER BY id DESC)) AS sortedCategories LIMIT $this->page, $pagelimit;");
				}
				else
				{
					$get = dbcom("SELECT * FROM que ORDER BY id DESC LIMIT $this->page, $pagelimit;");
				}
				echo "<h2>Submitted Queue</h2><P>&#149; ".$this->total." downloads submitted for review.<br> &#149; <a href=\"ddl.php?go=bannedwords\">Banned keywords</a> <span style=\"color:red\">are flagged in red</span>.";
				if($auto_allow == 0)
				{
					echo "<br>&#149; <a href=\"ddl.php?go=whitelist\">Whitelisted sites</a> <span style=\"color:green\">appear in green</span> and are checked (\"Auto Allow\" is off).  <a href=\"ddl.php#autoallow\">You can turn \"Auto Allow\" on here</a>.";
				}
				echo"<br>&#149; Hover over the \"IP\" icon (<img src=\"" . $site_url . "/admin/images/toggleip.gif\" alt=\"Toggle IP\" border=\"0\" />) to view the submitter's IP address (via tooltip).";
				echo "<br />&#149; Any VIP sites go straight to the main downloads database.";
				echo "<br />&#149; Toggle all of a site's submissions by clicking the blue arrow <img src=\"" . $site_url . "/admin/images/toggle.gif\" alt=\"Toggle Site\" border=\"0\" /> next to the site name.";
				echo "<br />&#149; Toggle all submissions from an IP address by clicking the \"IP\" icon (<img src=\"" . $site_url . "/admin/images/toggleip.gif\" alt=\"Toggle IP\" border=\"0\" />) next to the site name.";
				echo"<br /><br />\n\n";
				$categoryLinks = array();
				for($i = 0; $i < count($categories); $i++)
				{
					$categoryLinks[] = '<a href="' . $site_url . '/admin/ddl.php?go=added&sortBy=' . $categories[$i] . '">' . $categories[$i] . '</a>';
				}
				echo 'Sort by: ' . implode($categoryLinks, ' | ') . "\n";
				if(mysql_num_rows($get) > 0)
				{
					echo "<form name=\"f1\" action=\"ddl.php?go=added\" method=\"post\"><table border=0 cellpadding=0 cellspacing=0 width=\"100%\">";
					echo "<tr height=25><td width=10></td><td width=45><b>Type</b></td><td width=\"*\"><b>Download Name</b></td><td width=100><b>Submitter <img src=\"" . $site_url . "/admin/images/toggle.gif\" alt=\"Toggle Site\" border=\"0\" /> <img src=\"" . $site_url . "/admin/images/toggleip.gif\" alt=\"Toggle IP\" border=\"0\" /></b></td><td width=100><b>Email</b></td></tr>";

					while($row = mysql_fetch_array($get))
					{
						# WC vulnerability patch #1:
						$row['url'] = strip_tags($row['url']);
						$row['title'] = stripslashes(strip_tags($row['title']));
						$row['sname'] = strip_tags($row['sname']);
						$row['email'] = strip_tags($row['email']);
						$row['type'] = strip_tags($row['type']);
						$row['surl'] = strip_tags($row['surl']);
						if(!$row['email'])
							$row['email'] = 'no email';

						echo "<tr onmouseover=\"this.style.backgroundColor='$hovercolor'; return true;\" onmouseout=\"this.style.backgroundColor=''\">
						<td><input type=\"checkbox\" id=\"list\" name=\"list[]\" value=\"".$row['id']."\" class=\"box\" "; 
                    if ($this->whitelisted($row['surl']) && $this->whitelisted($row['url'])) echo "checked";
                    echo "></td>
						<td>{$row['type']}</td>
						<td><a href=\"".$row['url']."\" target=\"_blank\""; 
                    if ($this->itembanned($row['title'])) echo "style=\"color:red\""; 
                    if ($this->whitelisted($row['surl']) && $this->whitelisted($row['url']) && $auto_allow==0) echo "style=\"color:green\""; 
                    echo ">" . substr($row['title'], 0 , $siteNameLength) . "</a> </td>
						<td><a href=\"".$row['surl']."\" target=\"_blank\"";
                    if ($this->whitelisted($row['surl']) && $this->whitelisted($row['url']) && $auto_allow==0) echo "style=\"color:green\"";
                    echo ">{$row['sname']}</a> <a href=\"ddl.php?go=added&filterURL={$row['surl']}\"><img src=\"" . $site_url . "/admin/images/toggle.gif\" alt=\"Toggle Site\" border=\"0\" /></a> <a href=\"ddl.php?go=added&filterIP={$row['ip']}\" onMouseover=\"ddrivetip('IP: ".$row['ip']."')\"; onMouseout=\"hideddrivetip()\"><img src=\"" . $site_url . "/admin/images/toggleip.gif\" border=\"0\" /></a></td>
						<td> {$row['email']} </td>
						</tr>
						\n";
					}
					echo "</table><P>";
					if(isset($filterURL))
					{
						$this->paginate('ddl.php?go=added&filterURL=' . $filterURL . '&page=');
					}
					elseif(isset($filterIP))
					{
						$this->paginate('ddl.php?go=added&filterIP=' . $filterIP . '&page=');
					}
					elseif(isset($sortBy))
					{
						$this->paginate('ddl.php?go=added&sortBy=' . $sortBy . '&page=');
					}
					else
					{
						$this->paginate('ddl.php?go=added&page=');
					}
                echo "<P><input type=button value=\"Check All\" class=\"form\" onClick=\"this.value=check(this.form.list)\">
					<p>
                <table border=0 cellspacing=0 cellpadding=0 width=\"100%\"><tr>
                <td><input type=\"Submit\" name=\"bsub\" value=\"Insert\" class=\"formbutton\"> <input type=\"Submit\" name=\"bsub\" value=\"Delete\" class=\"formbutton\"></td>
    				<td align=right><input type=\"Submit\" name=\"bsub\" value=\"Blacklist Site\" class=\"formbutton\"> <input type=\"Submit\" name=\"bsub\" value=\"Ban By IP\" class=\"formbutton\"><br><small>WARNING: Blacklist/Ban by IP will delete all related downloads from Queue and main Downloads!<br><I>Ban by IP: Be extra careful, many IPs are those of AUTOSUBMITTERS!</I></small></td>
                </tr></table></form>";

				}
			}
		}
		function reported($go = NULL)
		{
			global $pagelimit, $siteNameLength;
			if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
            {
                $page = $_GET['page'];
            }
            else
            {
                $page = 1;
            }
			$this->page = $page;
			$this->page *= $pagelimit;
			$this->page -= $pagelimit;
			$g_total = dbcom('SELECT COUNT(id) AS TOTAL FROM downloads WHERE reports > 0;');
			$this->total = mysql_result($g_total, 0);
			$idTest = FALSE;
            if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && array_key_exists('list', $_POST) === TRUE && is_array($_POST['list']) && count($_POST['list']) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
			{
				$idTest = TRUE;
				$idList = implode(',', $_POST['list']);
				$numberOfIDs = count($_POST['list']);
			}
			echo '<h2>Links Reported Dead</h2>' . "\n";
			if($go == 'Remove From Report List' && $idTest === TRUE)
			{
				echo '<b>' . $numberOfIDs . '</b> links removed from report list<br /><br />';
				$hvahvor = $this->run($_POST['list']);
				dbcom("UPDATE downloads SET reports=0 WHERE $hvahvor;");
				echo "<a href=\"javascript:history.go(-1)\">Back</a>";
			}
			elseif($go == 'Delete' && $idTest === TRUE)
			{
				echo '<b>' . $numberOfIDs . '</b> links deleted from database<br /><br />';
				$hvahvor = $this->run($_POST['list']);
				dbcom('DELETE FROM downloads_ratings WHERE id IN(' . $idList . ');');
				dbcom("DELETE FROM downloads WHERE $hvahvor;");
				echo '<a href="javascript:history.go(-1)">Back</a>' . "\n";
			}
			elseif($go == 'Delete All From Selected Domains' && $idTest === TRUE)
			{
				echo '<b>Downloads related to the following domains were deleted from database:</b><br /><br />' . "\n";
				dbcom('DELETE FROM downloads_ratings WHERE id IN(SELECT id FROM downloads WHERE surl IN(SELECT DISTINCT surl FROM downloads WHERE id IN(' . $idList . ')));');
				$surlQuery = dbcom('SELECT DISTINCT surl FROM downloads AS tmpDownloads WHERE id IN(' . $idList . ');');
				$surlArray = array();
				while($surlQueryArray = mysql_fetch_array($surlQuery))
				{
					echo $surlQueryArray['surl'] . '<br />' . "\n";
					$surlArray[] = $surlQueryArray['surl'];
				}
				$surlList = implode('","', $surlArray);
				$surlList = '"' . $surlList . '"';
				dbcom('DELETE FROM downloads WHERE surl IN(' . $surlList . ');');
				echo '<br /><a href="javascript:history.go(-1)">Back</a>' . "\n";
			}
			else
			{
				$get = dbcom("SELECT * FROM downloads WHERE reports > 0 ORDER BY reports DESC LIMIT $this->page, $pagelimit;");
				if(mysql_num_rows($get) > 0)
				{
					echo "<br /><form name=\"f1\" action=\"ddl.php?go=report\" method=\"post\">".mysql_num_rows($get)." links reported as dead<br /><br />\n\n";
					while($row = mysql_fetch_array($get))
					{
						echo "<input type=\"checkbox\" name=\"list[]\" value=\"".$row['id']."\" id=\"list\" /> 
						<a href=\"ddl.php?go=stats&id=$row[id]\">Edit</a> | <a href=\"".$row['url']."\" target=\"_blank\">" . substr($row['title'], 0, $siteNameLength) . "</a> ($row[reports] ";
						if ($row['reports'] > 1)
							echo "reports";
						else
							echo "report";
						echo ")<br />\n";
					}
					echo "<br />\n";
					$this->paginate('ddl.php?go=report&page=');
					echo "<br /><br /><input type=button value=\"Check All\" class=\"form\" onClick=\"this.value=check(this.form.list)\" /><br />
					<br /><input type=\"Submit\" name=\"bsub\" value=\"Delete\" class=\"formbutton\">
					<input type=\"Submit\" name=\"bsub\" value=\"Remove From Report List\" class=\"formbuttonwide\">
					<p align=\"right\">
					<input type=\"submit\" name=\"bsub\" value=\"Delete All From Selected Domains\" class=\"formbuttonwide\" /><br /><small>WARNING: Only click this button if the selected download's domain names are dead. This will wipe out all downloads from the selected domains from the entire database.</small></p></form>";
				}
				else
				{
					echo '<p>No links reported dead!</p>';
				}
			}
		}
		function viewips()
		{
			global $pagelimit, $date_format;
			if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
            {
                $page = $_GET['page'];
            }
            else
            {
                $page = 1;
            }
			$this->page = $page;
			$this->page *= $pagelimit;
			$this->page -= $pagelimit;
			$g_total = dbcom("SELECT COUNT(ip) AS TOTAL FROM iplog");
			$this->total = mysql_result($g_total,0);
			echo '<h2>Autosubmitter IP Address Log</h2><P>Raw IP address log of people using your Autosubmitter:<P>' . "\n";
			if($_POST['bsub'] == 'Ban IP')
			{
				# Add IPs to banned list
				if(count($_POST['list']) > 0)
				{
					$ipcount = 0;
					foreach(array_unique($_POST['list']) as $badip)
					{
						# Check if already in there
						$bannedQuery = dbcom("SELECT bannedip FROM iplog WHERE bannedip = '$badip' LIMIT 1;");
						if(mysql_num_rows($bannedQuery) != 1)
						{
							dbcom("UPDATE iplog SET bannedip = '$badip' WHERE ip = '$badip' LIMIT 1;");
							$ipcount++;
						}
					}
					echo "<span style=color:red>$ipcount IPs were banned from using your Autosubmitter and Submitter.</span><br><br>";
				}
			}
			$get = dbcom("SELECT id, url, UNIX_TIMESTAMP(date) AS theDate, ip, bannedip FROM iplog ORDER BY date LIMIT $this->page, $pagelimit;");
			if(mysql_num_rows($get) > 0)
			{
				echo "<P><form name=\"f1\" action=\"autosubmitter.php?go=viewips\" method=\"post\">\n";
				echo "<table border=0 cellpadding=0 cellspacing=0 width=\"100%\">\n";
				echo "<tr height=30><td width=\"170\"><b>IP Address</b></td><td width=\"200\"><b>Date</b></td><td width=\"*\"><b>Site</b></td></tr>\n";
				while($row = mysql_fetch_array($get))
				{
					if($row['ip'] != '0')
					{
						echo "<tr><td><input type=\"checkbox\" name=\"list[]\" value=\"".$row[ip]."\" id=\"list\"> ".$row[ip]."</td><td>" . date($date_format, $row['theDate']) . "</td><td>".$row[url]."</td></tr>";

					}
				}
				echo '</table><P>' . "\n";
				$this->paginate('autosubmitter.php?go=viewips&page=');
				echo "<P><input type=button value=\"Check All\" class=\"form\" onClick=\"this.value=check(this.form.list)\">
				<p><input type=\"Submit\" name=\"bsub\" value=\"Ban IP\" class=\"formbutton\"><br>Ban an IP from using your Autosubmitter.</form>";
			}
			else
			{
				echo 'No IPs logged!' . "\n";
			}
		}
	function viewSubmitterBannedIPs()
	{
		global $pagelimit;
		if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
		{
			$page = $_GET['page'];
		}
		else
		{
			$page = 1;
		}
		$this->page = $page;
		$this->page*=$pagelimit;
		$this->page-=$pagelimit;
		$g_total = dbcom('SELECT COUNT(ip) AS total FROM submitter_bannedips;');
		$this->total = mysql_result($g_total,0);
		echo '<h2>Banned IPs</h2>';
		echo '<p>IP addresses banned from submitting downloads (regular submit):</p>';
		echo "<form name=\"f1\" action=\"ddl.php?go=bannedips\" method=\"post\">\n";
		echo "<P><span style=color:red>Manually ban an IP address:</span><br>";
		echo "<input type=\"text\" name=\"ip\" size=\"50\" /> <input type=\"submit\" name=\"bsub\" value=\"Ban IP\" class=\"formbutton\"><small><br>Examples: 255.255.255.255</small></form><P>";
		if($_POST['bsub'] == 'Unban IP')
		{
			# Remove IPs from banned list
			if(count($_POST['list']) > 0)
			{
				$ipcount = 0;
				foreach(array_unique($_POST['list']) as $badid)
				{
					# Check if already in there
					if(ctype_digit($badid) === TRUE)
					{
						$bannedQuery = dbcom("SELECT id FROM submitter_bannedips WHERE id = $badid LIMIT 1;");
						if(mysql_num_rows($bannedQuery) == 1)
						{
							dbcom("DELETE FROM submitter_bannedips WHERE id = $badid;");
							$ipcount++;
						}
					}
				}
				echo "<span style=color:red>$ipcount IPs were unbanned from using your Submitter.</span><br><br>";
			}
		}
		if($_POST['bsub'] == 'Ban IP')
		{
			# Add IP to banned list
			
			if(array_key_exists('ip', $_POST) === TRUE && preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $_POST['ip']) === 1)
			{
				# Check if already in there
				$bannedQuery = dbcom("SELECT ip FROM submitter_bannedips WHERE ip = '{$_POST['ip']}' LIMIT 1;");
				if(mysql_num_rows($bannedQuery) == 0)
				{
					# Add ip to banned ip field:
					dbcom("INSERT INTO submitter_bannedips VALUES (NULL, '{$_POST['ip']}');"); 
					echo "IP (<span style=color:red>{$_POST['ip']}</span>) has been banned from using your Submitter.";
				}
			}
		}
		$get = dbcom("SELECT * FROM submitter_bannedips ORDER BY id LIMIT $this->page, $pagelimit;");
		if(mysql_num_rows($get) > 0)
		{
			echo "<P><form name=\"f1\" action=\"ddl.php?go=bannedips\" method=\"post\">\n";
			echo "<table border=0 cellpadding=0 cellspacing=0 width=\"100%\">\n";
			echo "<tr>\n";
			while($row = mysql_fetch_array($get))
			{
				if($row[ip] != '0')
				{
					$column++;
					echo "<td><input type=\"checkbox\" name=\"list[]\" value=\"".$row[id]."\" id=\"list\"> ".$row[ip]."</td>";
					if(is_int($column/4))
					{
						echo "</tr><tr>\n";
					}
				}
			}
			echo "</table><P>";
			$this->paginate('ddl.php?go=bannedips&page=');
			echo "<P><input type=button value=\"Check All\" class=\"form\" onClick=\"this.value=check(this.form.list)\">
			<p><input type=\"Submit\" name=\"bsub\" value=\"Unban IP\" class=\"formbutton\"><br>Unban an IP from using your Submitter.</form>";
		}
		else
		{
			echo '<p>No IPs banned!</p>';
		}
	}
		function edit_blacklist()
		{
			global $pagelimit;
			if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
            {
                $page = $_GET['page'];
            }
            else
            {
                $page = 1;
            }
			$this->page = $page;
			$this->page *= $pagelimit;
			$this->page -= $pagelimit;
			$g_total = dbcom('SELECT COUNT(url) AS TOTAL FROM blacklist;');
			$this->total = mysql_result($g_total, 0);
			echo "<h2>View/Edit Blacklist</h2><P>Blacklisted sites are blocked from submitting downloads to this site.<P>";
			echo "<form name=\"f1\" action=\"ddl.php?go=blacklist\" method=\"post\">\n";
			echo "<P><span style=color:red>Manually blacklist a URL &amp; Delete All Related:</span><br>";
			echo "<input type=\"text\" name=\"url\" size=\"50\" /> <input type=\"submit\" name=\"bsub\" value=\"Blacklist\" class=\"formbutton\"><small><br>(Enter hostname only! Example: \"domain.com\")</small></form><P>";
			$idTest = FALSE;
			if($_POST['bsub'] == 'Remove From Blacklist')
			{
				if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && array_key_exists('list', $_POST) === TRUE && is_array($_POST['list']) && count($_POST['list']) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
				{
					$idTest = TRUE;
					$idList = implode(',', $_POST['list']);
					$numberOfIDs = count($_POST['list']);
				}
				if($idTest === TRUE)
				{
					echo '<b>' . $numberOfIDs . '</b> URL';
					if($numberOfIDs <> 1)
					{
						echo 's';
					}
					echo ' removed from Blacklist.<br /><br />';
					dbcom('DELETE FROM blacklist WHERE id IN(' . $idList . ');');
				}
				else
				{
					echo 'You didn\'t select any URLs.<br /><br /><a href="javascript:history.go(-1)">Go Back</a>.' . "\n";
				}
			}
			else
			{
				if($_POST['bsub'] == 'Blacklist' && $_POST['url'] != '')
				{
					# Delete from whitelist if exists
					dbcom('DELETE FROM whitelist WHERE url = "' . $_POST['url'] . '";');
					$existingBlacklistQuery = dbcom('SELECT id FROM blacklist WHERE url = "' . $_POST['url'] . '" LIMIT 1;');
					if(mysql_num_rows($existingBlacklistQuery) == 0)
					{
						# Add url to blacklist:
						dbcom('INSERT INTO blacklist (id, url) VALUES (NULL, "' . $_POST['url'] . '");');
					}
					# Remove all related from que and downloads tables:
					dbcom('DELETE FROM que WHERE surl LIKE "%' . $_POST['url'] . '%";');
					dbcom('DELETE FROM downloads_ratings WHERE id IN(SELECT id FROM downloads WHERE surl LIKE "%' . $_POST['url'] . '%");');
					dbcom('DELETE FROM downloads WHERE surl LIKE "%' . $_POST['url'] . '%";');
					echo 'URL (<span style="color: #ff0000;">' . $_POST['url'] . '</span>) has been blacklisted and all related downloads deleted (if any).';
				}
			}
			$get = dbcom("SELECT * FROM blacklist ORDER BY url LIMIT $this->page, $pagelimit;");
			if(mysql_num_rows($get) > 0)
			{
				echo "<P><form name=\"f1\" action=\"ddl.php?go=blacklist\" method=\"post\"><table border=0 cellpadding=0 cellspacing=0 width=\"100%\"><tr>\n";
				while($row = mysql_fetch_array($get))
				{
					$column++;
					echo '<td width="33%"><input type="checkbox" name="list[]" value="' . $row['id'] . '" id="list"> ' . $row['url'] . '</td>' . "\n";
					if(is_int($column / 3))
					{
						echo "</tr><tr>\n";
					}
				}
				echo '</tr></table><p>';
				$this->paginate('ddl.php?go=blacklist&page=');
				echo "<P><input type=button value=\"Check All\" class=\"form\" onClick=\"this.value=check(this.form.list)\">
				<p><input type=\"Submit\" name=\"bsub\" value=\"Remove From Blacklist\" class=\"formbuttonwide\"></form>";
			}
			else
			{
				echo 'No sites in the blacklist!';
			}
		}
		function bannedips() {
			global $pagelimit;
			if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
            {
                $page = $_GET['page'];
            }
            else
            {
                $page = 1;
            }
			$this->page = $page;
			$this->page *= $pagelimit;
			$this->page -= $pagelimit;
			$g_total = dbcom('SELECT COUNT(bannedip) AS TOTAL FROM iplog WHERE bannedip = ip;');
			$this->total = mysql_result($g_total, 0);
			$IPtest = FALSE;
			if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && array_key_exists('list', $_POST) === TRUE && is_array($_POST['list']) && count($_POST['list']) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
			{
				$IPtest = TRUE;
			}
			echo "<h2>Banned IPs</h2><P>IP addresses blocked from using your Autosubmitter.<P>";
			echo "<form name=\"f1\" action=\"autosubmitter.php?go=bannedips\" method=\"post\">\n";
			echo "<P><span style=color:red>Manually ban an IP address:</span><br>";
			echo "<input type=\"text\" name=\"ip\" size=\"50\" /> <input type=\"submit\" name=\"bsub\" value=\"Ban IP\" class=\"formbutton\"><small><br>Examples: 255.255.255.255 &nbsp; or &nbsp; 255.255.255.*</small></form><P>";
			if($_POST['bsub'] == 'Unban IP')
			{
				if($IPtest === TRUE)
				{
					$numberOfIPs = count($_POST['list']);
					echo '<b>' . $numberOfIPs . '</b> IP address';
					if($numberOfIPs <> 1)
					{
						echo 'es';
					}
					echo ' removed from Autosubmitter Banned List.<br /><br />';
					$IPlist = implode('","', $_POST['list']);
					$IPlist = '"' . $IPlist . '"';
					dbcom('UPDATE iplog SET bannedip = NULL WHERE bannedip IN(' . $IPlist . ');');
				}
				else
				{
					echo 'You didn\'t select any IP(s).<br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
				}
			}
			else
			{
				if($_POST['bsub'] == 'Ban IP' && $_POST['ip'] !='')
				{
					# Add ip to banned ip field:
					# Check if already in there
					$bannedQuery = dbcom("SELECT bannedip FROM iplog WHERE bannedip = '{$_POST['ip']}' LIMIT 1;");
					if(mysql_num_rows($bannedQuery) == 0)
					{
						dbcom("UPDATE iplog SET bannedip = '{$_POST['ip']}' WHERE ip = '{$_POST['ip']}' LIMIT 1;");
						$bannedIPquery = dbcom("SELECT bannedip FROM iplog where bannedip = '{$_POST['ip']}' LIMIT 1;");
						if(mysql_num_rows($bannedIPquery) == 0)
						{
							dbcom("INSERT INTO iplog VALUES (NULL, 'http://{$_SERVER['SERVER_NAME']}/{$_SERVER['REQUEST_URI']}', NOW(), '{$_POST['ip']}', '{$_POST['ip']}');");
						}
						echo 'IP (<span style="color: #ff0000;">' . $_POST['ip'] . '</span>) has been banned from using your Autosubmitter.';
					}
				}
			}
			$get = dbcom("SELECT DISTINCT bannedip FROM iplog WHERE bannedip = ip ORDER BY ip LIMIT $this->page, $pagelimit;");
			if(mysql_num_rows($get) > 0)
			{
				echo "<P><form name=\"f1\" action=\"autosubmitter.php?go=bannedips\" method=\"post\"><table border=0 cellpadding=0 cellspacing=0 width=\"100%\"><tr>\n";
				while($row = mysql_fetch_array($get))
				{
					if($row['bannedip'] != '0')
					{
						$column++;
						echo '<td width="25%"><input type="checkbox" name="list[]" value="' . $row['id'] . '" id="list"> ' . $row['bannedip'] . '</td>' . "\n";
						if(is_int($column / 4))
						{
							echo "</tr><tr>\n";
						}
					}
				}
				echo "</tr></table><P>";
				$this->paginate('autosubmitter.php?go=bannedips&page=');
				echo "<P><input type=button value=\"Check All\" class=\"form\" onClick=\"this.value=check(this.form.list)\">
				<p><input type=\"Submit\" name=\"bsub\" value=\"Unban IP\" class=\"formbutton\"><br>Unban an IP from using your Autosubmitter.</form>";
			}
			elseif(!isset($_POST) && !is_array($_POST) && count($_POST) > 1)
			{
				echo 'No IP addresses are banned!';
			}
		}
		function edit_whitelist()
		{
			global $pagelimit, $auto_allow, $skin;
			if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
            {
                $page = $_GET['page'];
            }
            else
            {
                $page = 1;
            }
			$this->page = $page;
			$this->page *= $pagelimit;
			$this->page -= $pagelimit;
			$g_total = dbcom('SELECT COUNT(id) AS TOTAL FROM whitelist;');
			$this->total = mysql_result($g_total, 0);
			echo '<h2>View/Edit Whitelist</h2><P>Whitelisted sites are ';
			if($auto_allow == 0)
			{
				echo 'not';
			}
			echo ' added to the downloads database automatically';
			if($auto_allow == 0)
			{
				echo ' ("Auto Allow" is off).  <a href="ddl.php#autoallow">You can turn "Auto Allow" on here</a>.<br />';
			}
			$idTest = FALSE;
			if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && array_key_exists('list', $_POST) === TRUE && is_array($_POST['list']) && count($_POST['list']) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
			{
				$idTest = TRUE;
				$idList = implode(',', $_POST['list']);
				$numberOfIDs = count($_POST['list']);
			}
			echo '<br /><img src="' . $site_url . '/admin/images/vip.gif" alt="VIP Site" /> VIP sites are <b>always automatically accepted</b> to the DDL list.';
			echo ".<P>";
			echo "<form name=\"f1\" action=\"ddl.php?go=whitelist\" method=\"post\">\n";
			echo "<P><span style=color:green>Manually whitelist a URL:</span><br>";
			echo "<input type=\"text\" name=\"url\" size=\"50\" /> <input type=\"submit\" name=\"bsub\" value=\"Whitelist\" class=\"formbutton\"><small><br>(Enter hostname only! Example: \"domain.com\")</small></form><P>";
			if($_POST['bsub'] == 'Remove From Whitelist')
			{
				if($idTest === TRUE)
				{
					echo '<b>' . $numberOfIDs . '</b> URL';
					if($numberOfIDs <> 1)
					{
						echo 's';
					}
					echo ' removed from Whitelist.<br /><br />';
					dbcom('DELETE FROM whitelist WHERE id IN(' . $idList . ');');
				}
				else
				{
					echo 'You didn\'t select any URL(s).<br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
				}
			}
			elseif($_POST['bsub'] == 'Promote to VIP (Auto Allow)')
			{
				if($idTest === TRUE)
				{
					echo '<b>' . $numberOfIDs . '</b> URL';
					if($numberOfIDs <> 1)
					{
						echo 's';
					}
					echo ' promoted to VIP!<br /><br />';
					dbcom('UPDATE whitelist SET vip = 1 WHERE id IN(' . $idList . ');');
				}
				else
				{
					echo 'You didn\'t select any URL(s).<br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
				}
			}
			elseif($_POST['bsub'] == 'Remove VIP Status')
			{
				if($idTest === TRUE)
				{
					echo '<b>' . $numberOfIDs . '</b> URL';
					if($numberOfIDs <> 1)
					{
						echo 's';
					}
					echo ' removed from VIP status.<br /><br />';
					dbcom('UPDATE whitelist SET vip = 0 WHERE id IN(' . $idList . ');');
				}
				else
				{
					echo 'You didn\'t select any URL(s).<br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
				}
			}
			else
			{
				if($_POST['bsub'] == 'Whitelist' && $_POST['url'] != '')
				{
					$blacklistQuery = dbcom("SELECT * FROM blacklist WHERE url = '{$_POST['url']}' LIMIT 1;");
					if(mysql_num_rows($blacklistQuery) > 0)
					{
						# Delete from blacklist if exists
						dbcom('DELETE FROM blacklist WHERE url = "' . $_POST['url'] . '";');
						echo '<span style="color: #ff0000;">Warning! </span>This URL (' . $_POST['url'] . ') was blacklisted! Removing from blacklist now.<br /><br />';
					}
					$existingWhitelistQuery = dbcom('SELECT id FROM whitelist WHERE url = "' . $_POST['url'] . '" LIMIT 1;');
					if(mysql_num_rows($existingWhitelistQuery) == 0)
					{
						# Add url to whitelist:
						dbcom('INSERT INTO whitelist (id, url, vip) VALUES (NULL, "' . $_POST['url'] . '", 0);');
						echo 'URL (<span style="color: #008000;">' . $_POST['url'] . '</span>) has been added to the Allowed Sites list (whitelist).';
					}
					else
					{
						echo '<span>URL was already whitelisted.</span>' . "\n";
					}
				}
			}
			$get = dbcom("SELECT * FROM whitelist ORDER BY url LIMIT $this->page, $pagelimit;");
			if(mysql_num_rows($get) > 0)
			{
				echo "<P><form name=\"f1\" action=\"ddl.php?go=whitelist\" method=\"post\"><table border=0 cellpadding=0 cellspacing=0 width=\"100%\"><tr>\n";
				while($row = mysql_fetch_array($get))
				{
					$column++;
					echo '<td width="33%"><input type="checkbox" name="list[]" value="' . $row['id'] . '" id="list"> ' . $row['url'];
					if($row['vip'] == 1)
					{
						echo ' <img src="' . $site_url . '/admin/images/vip.gif" alt="VIP Site" />';
					}
					echo '</td>' . "\n";
					if(is_int($column / 3))
					{
						echo "</tr><tr>\n";
					}
				}
				echo '</tr></table><br />';
				$this->paginate('ddl.php?go=whitelist&page=');
				echo "<br /><br /><input type=button value=\"Check All\" class=\"form\" onClick=\"this.value=check(this.form.list)\">
				<br /><br /><input type=\"Submit\" name=\"bsub\" value=\"Remove From Whitelist\" class=\"formbuttonwide\">
				<input type=\"submit\" name=\"bsub\" value=\"Promote to VIP (Auto Allow)\" class=\"formbuttonwide\">
				<input type=\"submit\" name=\"bsub\" value=\"Remove VIP Status\" class=\"formbuttonwide\"></form>";
			}
			else
			{
				echo 'No sites in the whitelist!';
			}
		}
		function edit_bannedwords()
		{
			global $pagelimit;
			if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
            {
                $page = $_GET['page'];
            }
            else
            {
                $page = 1;
            }
			$this->page = $page;
			$this->page *= $pagelimit;
			$this->page -= $pagelimit;
			$g_total = dbcom('SELECT COUNT(id) AS TOTAL FROM bannedwords;');
			$this->total = mysql_result($g_total, 0);
			$idTest = FALSE;
			if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && array_key_exists('list', $_POST) === TRUE && is_array($_POST['list']) && count($_POST['list']) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
			{
				$idTest = TRUE;
				$idList = implode(',', $_POST['list']);
				$numberOfIDs = count($_POST['list']);
			}
			echo '<h2>View/Edit Banned Keywords</h2>
				<p>Banned keywords are <span style="color: #ff0000;">flagged in in red</span> in the Submitted Queue.  The purpose of banned keywords is to alert you of downloads you "may" not wish to add to the database (ie. your webhost got a complaint regaring links to "windows vista", but you still want to allow links like "Windows Vista eBook for Dummies").</p>
				<p>If you want to completely block a keyword, use the <a href="ddl.php?go=spamwords">Spam Blocker</a> instead.</p>';
			if($_POST['bsub'] == 'Unban Keyword')
			{
				if($idTest === TRUE)
				{
					echo '<b>' . $numberOfIDs . '</b> keyword';
					if($numberOfIDs <> 1)
					{
						echo 's';
					}
					echo ' removed from banned list.<br /><br />';
					dbcom('DELETE FROM bannedwords WHERE id IN(' . $idList . ');');
				}
				else
				{
					echo 'You didn\'t select any banned words.<br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
				}
			}
			else
			{
				if($_POST['bsub'] == 'Ban Keyword' && $_POST['word'] != '')
				{
					# Add keyword to banned list:
					$bannedword = strtolower($_POST['word']);
					# Test to see if banned word already exists in table
					$existingBanWordQuery = dbcom('SELECT word FROM bannedwords WHERE word = "' . $bannedword . '" LIMIT 1;');
					if(mysql_num_rows($existingBanWordQuery) == 0)
					{
						dbcom("INSERT INTO bannedwords (id, word) VALUES (NULL, '$bannedword');");
					}
					echo "\"<span style=color:red>$_POST[word]</span>\" has been added to the banned keywords list.";
				}
			}
			echo '<form name="f1" action="ddl.php?go=bannedwords" method="post">' . "\n";
			echo "<P><span style=color:red>Enter a keyword to flag:</span><br>";
			echo "<input type=\"text\" name=\"word\" size=\"50\" /> <input type=\"submit\" name=\"bsub\" value=\"Ban Keyword\" class=\"formbutton\"></form><P>";
			$get = dbcom("SELECT * FROM bannedwords ORDER BY word LIMIT $this->page, $pagelimit;");
			if(mysql_num_rows($get) > 0)
			{
				echo "<P><form name=\"f1\" action=\"ddl.php?go=bannedwords\" method=\"post\"><table border=0 cellpadding=0 cellspacing=0 width=\"100%\"><tr>\n";
				while($row = mysql_fetch_array($get))
				{
					$column++;
					echo '<td width="25%"><input type="checkbox" name="list[]" value="' . $row['id'] . '" id="list"> ' . $row['word'] . '</td>' . "\n";
					if(is_int($column / 4))
					{
						echo "</tr><tr>\n";
					}
				}
				echo "</tr></table><P>";
				$this->paginate('ddl.php?go=bannedwords&page=');
				echo "<P><input type=button value=\"Check All\" class=\"form\" onClick=\"this.value=check(this.form.list)\">
				<p><input type=\"Submit\" name=\"bsub\" value=\"Unban Keyword\" class=\"formbuttonwide\"></form>";
			}
			else
			{
				echo 'No banned keywords.';
			}
		}
		function edit_spamwords()
		{
			global $pagelimit;
			if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
            {
                $page = $_GET['page'];
            }
            else
            {
                $page = 1;
            }
			$this->page = $page;
			$this->page *= $pagelimit;
			$this->page -= $pagelimit;
			$g_total = dbcom('SELECT COUNT(spamword) AS TOTAL FROM spamwords;');
			$this->total = mysql_result($g_total, 0);
			$idTest = FALSE;
			if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && array_key_exists('list', $_POST) === TRUE && is_array($_POST['list']) && count($_POST['list']) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
			{
				$idTest = TRUE;
				$idList = implode(',', $_POST['list']);
				$numberOfIDs = count($_POST['list']);
			}
			echo "<h2>View/Edit Spam Keywords</h2><p>Spam keywords are blocked from being submitted (by both, the regular Submit form, and the Autosubmitter).<br />Note: Spam words are also blocked from site searches, to prevent SEO sabotage.</p><p>";
			if($_POST['bsub'] == 'Remove From Spam List')
			{
				if($idTest === TRUE)
				{
					echo '<b>' . $numberOfIDs . '</b> spam word';
					if($numberOfIDs <> 1)
					{
						echo 's';
					}
					echo ' removed from spam keywords list.<br /><br />';
					dbcom('DELETE FROM spamwords WHERE id IN(' . $idList . ');');
				}
				else
				{
					echo 'You didn\'t select any spam words.<br /><br /><a href="javascript:history.go(-1)">Go Back</a>.';
				}
			}
			else
			{
				if($_POST['bsub'] == 'Block Keyword' && $_POST['word'] != '')
				{
					$bannedword = strtolower($_POST['word']);
					# See if word already exists in spamwords table
					$spamWordsQuery = dbcom("SELECT id FROM spamwords WHERE spamword = '$bannedword' LIMIT 1;");
					if(mysql_num_rows($spamWordsQuery) == 0)
					{
						# Add keyword to spam list if not already there
						dbcom("INSERT INTO spamwords (id, spamword) VALUES (NULL, '$bannedword');");
						echo 'The keyword "<span style="color: #ff0000;">' . $bannedword . '</span>" has been added to the spam keywords list.';
					}
					else
					{
						echo 'The keyword "<span style="color: #ff0000;">' . $bannedword . '</span> already exists in the spam keywords list.';
					}
				}
			}
			echo "<form name=\"f1\" action=\"ddl.php?go=spamwords\" method=\"post\">\n";
			echo "<P><span style=color:red>Enter a keyword to block:</span><br>";
			echo "<input type=\"text\" name=\"word\" size=\"50\" /> <input type=\"submit\" name=\"bsub\" value=\"Block Keyword\" class=\"formbutton\"></form><P>";
			$get = dbcom("SELECT * FROM spamwords ORDER BY spamword LIMIT $this->page, $pagelimit;");
			if(mysql_num_rows($get) > 0)
			{
				echo "<P><form name=\"f1\" action=\"ddl.php?go=spamwords\" method=\"post\"><table border=0 cellpadding=0 cellspacing=0 width=\"100%\"><tr>\n";
				while($row = mysql_fetch_array($get))
				{
					$column++;
					echo '<td width="25%"><input type="checkbox" name="list[]" value="' . $row['id'] . '" id="list"> ' . $row['spamword'] . '</td>' . "\n";
					if(is_int($column / 4))
					{
						echo "</tr><tr>\n";
					}
				}
				echo "</tr></table><P>";
				$this->paginate('ddl.php?go=spamwords&page=');
				echo "<P><input type=button value=\"Check All\" class=\"form\" onClick=\"this.value=check(this.form.list)\">
				<p><input type=\"Submit\" name=\"bsub\" value=\"Remove From Spam List\" class=\"formbuttonwide\"></form>";
			}
			else
			{
				echo 'No spam keywords.';
			}
		}
		function edit_urls()
		{
			global $hovercolor, $pagelimit, $failedSubmitURLtries, $siteID;
			if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
            {
                $page = $_GET['page'];
            }
            else
            {
                $page = 1;
            }
			if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('sortby', $_GET) && ctype_lower($_GET['sortby']))
			{
				$sortOptions = array('url', 'fails');
				if(in_array($_GET['sortby'], $sortOptions) === TRUE)
				{
					$sortBy = $_GET['sortby'];
					$otherSortArray = array_slice($sortOptions, array_search($sortBy, $sortOptions) - 1, 1);
					$otherSort = $otherSortArray[0];
				}
				else
				{
					$sortBy = 'fails';
					$otherSort = 'url';
				}
			}
			else
			{
				$sortBy = 'fails';
				$otherSort = 'url';
			}
			if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('sortorder', $_GET) && ctype_upper($_GET['sortorder']))
			{
				$sortOrders = array('ASC', 'DESC');
				if(in_array($_GET['sortorder'], $sortOrders) === TRUE)
				{
					$sortOrder = $_GET['sortorder'];
				}
				else
				{
					$sortOrder = 'DESC';
				}
			}
			else
			{
				$sortOrder = 'DESC';
			}
			$this->page = $page;
			$this->page *= $pagelimit;
			$this->page -= $pagelimit;
			$g_total = dbcom('SELECT COUNT(url) AS TOTAL FROM urls;');
			$this->total = mysql_result($g_total, 0);
			$idTest = FALSE;
			if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && array_key_exists('list', $_POST) === TRUE && is_array($_POST['list']) && count($_POST['list']) > 0 && checkPostForm('adminIDlists', $_POST) === TRUE)
			{
				$idTest = TRUE;
				$idList = implode(',', $_POST['list']);
				$numberOfIDs = count($_POST['list']);
			}
			echo "<h2>View or Delete Submit-To URLs</h2>(The Autosubmitter submits to all these URLs)<P>";
			if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && array_key_exists('bsub', $_POST) && $_POST['bsub'] == 'Remove From URL List' && $idTest === TRUE)
			{
				echo '<span style="color: #ff0000;"><b>' . $numberOfIDs . '</b> URL';
				if($numberOfIDs <> 1)
				{
					echo 's';
				}
				echo ' removed from URL submit-to list.</span><br /><br />' . "\n";
				dbcom('DELETE FROM urls WHERE id IN(' . $idList . ');');
			}
			if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && array_key_exists('sub', $_POST) && checkPostForm('editFailedURLthreshold', $_POST) === TRUE)
			{
				dbcom("UPDATE config SET failedSubmitURLtries = {$_POST['failedSubmitURLtries']} WHERE siteID = {$_POST['siteID']};"); 
				echo '<p>Failed Submit URL Delete Threshold was updated successfully</p>' . "\n";
			}
			echo '<script type="text/javascript">
			function expand(id)
			{
			    var item  = document.getElementById(id);
			
			    if( item.style.visibility == \'hidden\' )
			    {
			        item.style.position   = \'relative\';
			        item.style.visibility = \'visible\';
			        
			    }
			    else
			    {
			        item.style.visibility = \'hidden\';
			        item.style.position   = \'absolute\';
			    }
			
			    return false;
			}
			</script>';
			echo '<form action="autosubmitter.php?go=urls" method="post">' . "\n";
			echo '<input type="hidden" name="siteID" value="' . $siteID . '">' . "\n";
			echo '<label for="txtFailedSubmitURLtries">Failed Submit URL Delete Threshold:</label>' . "\n";
			echo '<input type="text" name="failedSubmitURLtries" id="txtFailedSubmitURLtries" maxlength="3" size="3" value="' . $failedSubmitURLtries . '">' . "\n";
			echo '<input type="submit" name="sub" value="Change"> ';

			echo '<a href="" onClick="return expand(\'Failed_Threshold\');">[?]</a><br />
			<div style="visibility:hidden;position:absolute;font-size:10px;padding:10px" id="Failed_Threshold">
			If this many failed submits get logged for a particular URL, it will be automatically deleted from your URLs list (the site has probably gone down).
			Note: Each time your Autosubmitter is used, failed submits are logged -- even from other webmasters who may use your Autosubmitter.</div>';

			echo '</form>' . "\n";
			$get = dbcom("SELECT * FROM urls ORDER BY $sortBy $sortOrder, $otherSort LIMIT $this->page, $pagelimit;");
			if(mysql_num_rows($get) > 0)
			{
				echo "<P><form name=\"f1\" action=\"autosubmitter.php?go=urls\" method=\"post\"><table border=0 cellpadding=0 cellspacing=0 width=\"100%\">\n";
				if($sortBy == 'url')
				{
					if($sortOrder == 'ASC')
					{
						echo '<tr><td width="10"></td><td height="25" width="550"><b><a href="autosubmitter.php?go=urls&sortby=url&sortorder=DESC&page=' . $page . '">Submit Page URL</a></b></td><td align="center"> <b><a href="autosubmitter.php?go=urls&sortby=fails&sortorder=DESC&page=' . $page . '">Failed Submits</a></b></td></tr>' . "\n";
					}
					else
					{
						echo '<tr><td width="10"></td><td height="25" width="550"><b><a href="autosubmitter.php?go=urls&sortby=url&sortorder=ASC&page=' . $page . '">Submit Page URL</a></b></td><td align="center"> <b><a href="autosubmitter.php?go=urls&sortby=fails&sortorder=DESC&page=' . $page . '">Failed Submits</a></b></td></tr>' . "\n";
					}
				}
				else
				{
					if($sortOrder == 'ASC')
					{
						echo '<tr><td width="10"></td><td height="25" width="550"><b><a href="autosubmitter.php?go=urls&sortby=url&sortorder=DESC&page=' . $page . '">Submit Page URL</a></b></td><td align="center"> <b><a href="autosubmitter.php?go=urls&sortby=fails&sortorder=DESC&page=' . $page . '">Failed Submits</a></b></td></tr>' . "\n";
					}
					else
					{
						echo '<tr><td width="10"></td><td height="25" width="550"><b><a href="autosubmitter.php?go=urls&sortby=url&sortorder=DESC&page=' . $page . '">Submit Page URL</a></b></td><td align="center"> <b><a href="autosubmitter.php?go=urls&sortby=fails&sortorder=ASC&page=' . $page . '">Failed Submits</a></b></td></tr>' . "\n";
					}
				}
				while($row = mysql_fetch_array($get))
				{
					$column++;
					echo "<tr onmouseover=\"this.style.backgroundColor='$hovercolor'; return true;\" onmouseout=\"this.style.backgroundColor=''\">";
					echo '<td><input type="checkbox" name="list[]" value="' . $row['id'] . '" id="list"></td><td> <a href="' . $row['url'] . '" target="_blank">' . $row['url'] . '</a></td><td align="center">' . $row['fails'] . '</td></tr>' . "\n";
				}
				echo '</table><p>';
				$this->paginate('autosubmitter.php?go=urls&sortby=' . $sortBy . '&sortorder=' . $sortOrder . '&page=');
				echo "<P><input type=button value=\"Check All\" class=\"form\" onClick=\"this.value=check(this.form.list)\">
				<p><input type=\"Submit\" name=\"bsub\" value=\"Remove From URL List\" class=\"formbuttonwide\"></form>";
			}
			else
			{
				echo 'No URLs in list.';
			}
		}
		function add_urls()
		{
			echo '<h2>Add One or More Submit-To URLs</h2><p>';
			if ($_POST['bsub']=="Add URLS" && trim($_POST['url']) != "")
			{
				$urlarray = array_unique(preg_split('/[\r\n]+/', trim($_POST['url']), -1, PREG_SPLIT_NO_EMPTY));
				foreach($urlarray as $newurl)
				{
					$newurl = trim($newurl);
					$newurl = strtolower($newurl);
					$newurl = str_replace ('www.', '', $newurl);
					if(strlen(testURL($newurl)) > 0 && strpos($newurl, 'submit.php') !== FALSE)
					{
						# Check if already in there
						$URLquery = dbcom("SELECT url FROM urls WHERE url = '$newurl' LIMIT 1;");
						# Add it, if it's not already there
						if(mysql_num_rows($URLquery) == 1)
						{
							echo "Duplicate URL: $newurl (not added).<br>";
						}
						else
						{
							dbcom("INSERT INTO urls (id, url) VALUES (NULL, '$newurl')");
							echo '<span style="color: green">' . $newurl . '</span> added to <a href="autosubmitter.php?go=urls">URLs list</a>.<br />';
						}
					}
					else
					{
						echo '<span style="color: #ff0000;">' . $newurl . '</span> was not in the proper format (http://domain.tld/submit.php) and not added to <a href="autosubmitter.php?go=urls">URLs list</a>.<br />';
					}
				}
			}
			echo "<form name=\"f1\" action=\"autosubmitter.php?go=addurls\" method=\"post\">\n";
			echo "<P>";
			echo "<textarea cols=\"80\" rows=\"30\" class=\"form\" name=\"url\">";
			echo "</textarea><br>Enter one or more URLs to add, one per line.<br>";
			echo "Example: http://navnetwork.com/submit.php<br>";
			echo "Duplicates will be removed automatically!<br>";
			echo "<br><input type=\"submit\" name=\"bsub\" value=\"Add URLS\" class=\"formbuttonwide\"></form><P>";
		}
		function getdomain($url)
		{
			if(version_compare(PHP_VERSION, '5.1.2', '>=') === TRUE)
			{
				$hostname = trim(strtolower(parse_url($url, PHP_URL_HOST)));
			}
			else
			{
				$URLparts = parse_url($url);
				$hostname = trim(strtolower($URLparts['host']));
			}
			return str_replace('www.', '', $hostname);
			/*$url = trim(strtolower($url));
			$url = str_replace (array('http://', 'www.'), '', $url);
 			$slashparts = explode('/', $url);
			$slashparts = $slashparts[0];
			if(stristr($slashparts, '?'))
			{
				$slashparts = explode('?', $slashparts);
				$slashparts = $slashparts[0];
			}
			return $slashparts;
			*/
		}
	}
	function dot($url)
	{
		return str_replace(array('-', '_', ' '), '.', $url);
	}
?>
Return current item: DDL CMS