function configSettings()
{
    global $cfg;
    include_once "AliasFile.php";
    include_once "RunningTorrent.php";
    DisplayHead("Administration - Settings");
    // Admin Menu
    displayMenu();
    // Main Settings Section
    echo "<div align=\"center\">";
    echo "<table width=\"100%\" border=1 bordercolor=\"" . $cfg["table_admin_border"] . "\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"" . $cfg["table_data_bg"] . "\">";
    echo "<tr><td bgcolor=\"" . $cfg["table_header_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\">";
    echo "<img src=\"images/properties.png\" width=18 height=13 border=0>&nbsp;&nbsp;<font class=\"title\">TorrentFlux Settings</font>";
    echo "</td></tr><tr><td align=\"center\">";
    ?>

	<script language="JavaScript">
	function validateSettings()
	{
		var rtnValue = true;
		var msg = "";
		if (isNumber(document.theForm.max_upload_rate.value) == false)
		{
			msg = msg + "* Max Upload Rate must be a valid number.\n";
			document.theForm.max_upload_rate.focus();
		}
		if (isNumber(document.theForm.max_download_rate.value) == false)
		{
			msg = msg + "* Max Download Rate must be a valid number.\n";
			document.theForm.max_download_rate.focus();
		}
		if (isNumber(document.theForm.max_uploads.value) == false)
		{
			msg = msg + "* Max # Uploads must be a valid number.\n";
			document.theForm.max_uploads.focus();
		}
		if ((isNumber(document.theForm.minport.value) == false) || (isNumber(document.theForm.maxport.value) == false))
		{
			msg = msg + "* Port Range must have valid numbers.\n";
			document.theForm.minport.focus();
		}
		if (isNumber(document.theForm.rerequest_interval.value) == false)
		{
			msg = msg + "* Rerequest Interval must have a valid number.\n";
			document.theForm.rerequest_interval.focus();
		}
		if (document.theForm.rerequest_interval.value < 10)
		{
			msg = msg + "* Rerequest Interval must 10 or greater.\n";
			document.theForm.rerequest_interval.focus();
		}
		if (isNumber(document.theForm.days_to_keep.value) == false)
		{
			msg = msg + "* Days to keep Audit Actions must be a valid number.\n";
			document.theForm.days_to_keep.focus();
		}
		if (isNumber(document.theForm.minutes_to_keep.value) == false)
		{
			msg = msg + "* Minutes to keep user online must be a valid number.\n";
			document.theForm.minutes_to_keep.focus();
		}
		if (isNumber(document.theForm.rss_cache_min.value) == false)
		{
			msg = msg + "* Minutes to Cache RSS Feeds must be a valid number.\n";
			document.theForm.rss_cache_min.focus();
		}
		if (isNumber(document.theForm.page_refresh.value) == false)
		{
			msg = msg + "* Page Refresh must be a valid number.\n";
			document.theForm.page_refresh.focus();
		}
		if (isNumber(document.theForm.sharekill.value) == false)
		{
			msg = msg + "* Keep seeding until Sharing % must be a valid number.\n";
			document.theForm.sharekill.focus();
		}
		if ((document.theForm.maxport.value > 65535) || (document.theForm.minport.value > 65535))
		{
			msg = msg + "* Port can not be higher than 65535.\n";
			document.theForm.minport.focus();
		}
		if ((document.theForm.maxport.value < 0) || (document.theForm.minport.value < 0))
		{
			msg = msg + "* Can not have a negative number for port value.\n";
			document.theForm.minport.focus();
		}
		if (document.theForm.maxport.value < document.theForm.minport.value)
		{
			msg = msg + "* Port Range is not valid.\n";
			document.theForm.minport.focus();
		}
		// maxcons
		if (isNumber(document.theForm.maxcons.value) == false)
		{
					msg = msg + "* Max Cons must be a valid number.\n" ;
		}
		// Specific save path
		if (isNumber(document.theForm.maxdepth.value) == false)
		{
					msg = msg + "* Max Depth must be a valid number.\n" ;
		}
		if (msg != "")
		{
			rtnValue = false;
			alert("Please check the following:\n\n" + msg);
		}

		return rtnValue;
	}

	function isNumber(sText)
	{
		var ValidChars = "0123456789";
		var IsNumber = true;
		var Char;

		for (i = 0; i < sText.length && IsNumber == true; i++)
		{
			Char = sText.charAt(i);
			if (ValidChars.indexOf(Char) == -1)
			{
				IsNumber = false;
			}
		}

		return IsNumber;
	}
	</script>

	<div align="center">

		<table cellpadding="5" cellspacing="0" border="0" width="100%">
		<form name="theForm" action="admin.php?op=updateConfigSettings" method="post" onsubmit="return validateSettings()">
		<input type="Hidden" name="continue" value="configSettings">
		<tr>
			<td align="left" width="350" valign="top"><strong>Path</strong><br>
			Define the PATH where the downloads will go <br>(make sure it ends with a / [slash]).
			It must be chmod'd to 777:
			</td>
			<td valign="top">
				<input name="path" type="Text" maxlength="254" value="<?php 
    echo $cfg["path"];
    ?>
" size="55"><?php 
    echo validatePath($cfg["path"]);
    ?>
			</td>
		</tr>

		<tr><td colspan="2" align="center" bgcolor="<?php 
    echo $cfg["table_header_bg"];
    ?>
"><strong>Authentication</strong></td></tr>

		<tr>
			<td align="left" width="350" valign="top"><strong>Select Auth-Type</strong><br>
			<u>Form-Auth</u> : Standard TF 2.1 Form-Based Auth<br>
			<u>Form-Auth + Cookie</u> : Form-Based Auth with "Remember Me"-Cookie<br>
			<u>Basic-Auth</u> : Basic-Auth with Realm "<?php 
    echo _AUTH_BASIC_REALM;
    ?>
"<br>
			<u>Basic-Passthru</u> : gets credentials of already authenticated user and passes them to flux<br>
			</td>
			<td valign="top">
				<?php 
    echo '<select name="auth_type">';
    echo '<option value="0"';
    if ($cfg["auth_type"] == "0") {
        echo " selected";
    }
    echo '>Form-Auth</option>';
    echo '<option value="1"';
    if ($cfg["auth_type"] == "1") {
        echo " selected";
    }
    echo '>Form-Auth + Cookie</option>';
    echo '<option value="2"';
    if ($cfg["auth_type"] == "2") {
        echo " selected";
    }
    echo '>Basic-Auth</option>';
    echo '<option value="3"';
    if ($cfg["auth_type"] == "3") {
        echo " selected";
    }
    echo '>Basic-Passthru</option>';
    echo '</select>';
    ?>
			</td>
		</tr>

		<tr><td colspan="2" align="center" bgcolor="<?php 
    echo $cfg["table_header_bg"];
    ?>
"><strong>BitTorrent</strong></td></tr>

		<tr>
			<td align="left" width="350" valign="top"><strong>default BitTorrent-Client</strong><br>
			Choose the default BitTorrent-Client.
			</td>
			<td valign="top">
				<?php 
    printBTClientSelect($cfg["btclient"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Select torrent-metainfo-client</strong><br>
			The client that is used to decode torrent-meta-data.
			</td>
			<td valign="top">
				<?php 
    echo '<select name="metainfoclient">';
    echo '<option value="btshowmetainfo.py"';
    if ($cfg["metainfoclient"] == "btshowmetainfo.py") {
        echo " selected";
    }
    echo '>btshowmetainfo.py</option>';
    echo '<option value="transmissioncli"';
    if ($cfg["metainfoclient"] == "transmissioncli") {
        echo " selected";
    }
    echo '>transmissioncli</option>';
    echo '</select>';
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>tornado : btphptornado.py Path</strong><br>
			Specify the path to the btphptornado.py python script:
			</td>
			<td valign="top">
				<input name="btclient_tornado_bin" type="Text" maxlength="254" value="<?php 
    echo $cfg["btclient_tornado_bin"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["btclient_tornado_bin"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>tornado : Extra Commandline Options</strong><br>
			DO NOT include --max_upload_rate, --minport, --maxport, --max_uploads and --max_connections here.
			</td>
			<td valign="top">
				<input name="btclient_tornado_options" type="Text" maxlength="254" value="<?php 
    echo $cfg["btclient_tornado_options"];
    ?>
" size="55">
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>transmission : transmissioncli Path</strong><br>
			Specify the path to the transmission binary (transmissioncli):
			</td>
			<td valign="top">
				<input name="btclient_transmission_bin" type="Text" maxlength="254" value="<?php 
    echo $cfg["btclient_transmission_bin"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["btclient_transmission_bin"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>transmission : Extra Commandline Options</strong><br>
			</td>
			<td valign="top">
				<input name="btclient_transmission_options" type="Text" maxlength="254" value="<?php 
    echo $cfg["btclient_transmission_options"];
    ?>
" size="55">
			</td>
		</tr>


		<tr>
			<td align="left" width="350" valign="top"><strong>btshowmetainfo.py Path</strong><br>
			Specify the path to the btshowmetainfo.py python script:
			</td>
			<td valign="top">
				<input name="btshowmetainfo" type="Text" maxlength="254" value="<?php 
    echo $cfg["btshowmetainfo"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["btshowmetainfo"]);
    ?>
			</td>
		</tr>

		<tr><td colspan="2"><hr noshade></td></tr>

		<tr>
			<td align="left" width="350" valign="top"><strong>Max Upload Rate (B+T)</strong><br>
			Set the default value for the max upload rate per torrent:
			</td>
			<td valign="top">
				<input name="max_upload_rate" type="Text" maxlength="5" value="<?php 
    echo $cfg["max_upload_rate"];
    ?>
" size="5"> KB/second
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Max Download Rate (B+T)</strong><br>
			Set the default value for the max download rate per torrent (0 for no limit):
			</td>
			<td valign="top">
				<input name="max_download_rate" type="Text" maxlength="5" value="<?php 
    echo $cfg["max_download_rate"];
    ?>
" size="5"> KB/second
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Max Upload Connections (B)</strong><br>
			Set the default value for the max number of upload connections per torrent:
			</td>
			<td valign="top">
				<input name="max_uploads" type="Text" maxlength="5" value="<?php 
    echo $cfg["max_uploads"];
    ?>
" size="5">
			</td>
		</tr>
		<tr>
		   <td align="left" width="350" valign="top"><strong>Max Cons (B)</strong><br>
		   Set default-value for maxcons.
		   </td>
		   <td valign="top">
			   <input name="maxcons" type="Text" maxlength="4" value="<?php 
    echo $cfg["maxcons"];
    ?>
" size="4">
		   </td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Port Range (B+T)</strong><br>
			Set the default values for the for port range (Min - Max):
			</td>
			<td valign="top">
				<input name="minport" type="Text" maxlength="5" value="<?php 
    echo $cfg["minport"];
    ?>
" size="5"> -
				<input name="maxport" type="Text" maxlength="5" value="<?php 
    echo $cfg["maxport"];
    ?>
" size="5">
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Rerequest Interval (B)</strong><br>
			Set the default value for the rerequest interval to the tracker (default 1800 seconds):
			</td>
			<td valign="top">
				<input name="rerequest_interval" type="Text" maxlength="5" value="<?php 
    echo $cfg["rerequest_interval"];
    ?>
" size="5">
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Default Torrent Completion Activity (B)</strong><br>
			Select whether or not a torrent should keep seeding when download is complete
			(please seed your torrents):
			</td>
			<td valign="top">
				<select name="torrent_dies_when_done">
						<option value="True">Die When Done</option>
						<option value="False" <?php 
    if ($cfg["torrent_dies_when_done"] == "False") {
        echo "selected";
    }
    ?>
>Keep Seeding</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Default Percentage When Seeding should Stop (B+T)</strong><br>
			Set the default share pecentage where torrents will shutoff
			when running torrents that do not die when done.
			Value '0' will seed forever.
			</td>
			<td valign="top">
				<input name="sharekill" type="Text" maxlength="3" value="<?php 
    echo $cfg["sharekill"];
    ?>
" size="3">%
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable File Priority (B)</strong><br>
			When enabled, users will be allowed to select particular files from the torrent to download.:
			</td>
			<td valign="top">
				<select name="enable_file_priority">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_file_priority"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>

		<tr>
			<td align="left" width="350" valign="top"><strong>Skip HashCheck (B)</strong><br>
			Set the default	 for skip hash-checks on torrent-start:
			</td>
			<td valign="top">
				<select name="skiphashcheck">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["skiphashcheck"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>

		<tr><td colspan="2" align="center" bgcolor="<?php 
    echo $cfg["table_header_bg"];
    ?>
"><strong>misc</strong></td></tr>

		<tr>
			<td align="left" width="350" valign="top"><strong>Enable umask</strong><br>
			Enable/Disable setting umask to 0000 when starting a torrent-client. :
			</td>
			<td valign="top">
				<select name="enable_umask">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_umask"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>

		<tr>
			<td align="left" width="350" valign="top"><strong>nice</strong><br>
			nice clients and increment priority by given adjustment first:
			</td>
			<td valign="bottom">
				<select name="nice_adjust">
				<?php 
    for ($i = 0; $i < 20; $i++) {
        if ($i != 0) {
            echo '<option value="' . $i . '"';
            if ($cfg["nice_adjust"] == $i) {
                echo " selected";
            }
            echo '>' . $i . '</option>';
        } else {
            echo '<option value="' . $i . '"';
            if ($cfg["nice_adjust"] == $i) {
                echo " selected";
            }
            echo '>Dont use nice</option>';
        }
    }
    ?>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Use Advanced Start Dialog</strong><br>
			When enabled, users will be given the advanced start dialog popup when starting a torrent:
			</td>
			<td valign="top">
				<select name="advanced_start">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["advanced_start"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable multi-operations</strong><br>
			Enable/Disable torrent-multi-operations. (Start/Stop/Delete/...) :
			</td>
			<td valign="top">
				<select name="enable_multiops">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_multiops"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable bulk-operations</strong><br>
			Enable/Disable bulk-operations. (Stop/Resume/Start) :
			</td>
			<td valign="top">
				<select name="enable_bulkops">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_bulkops"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable dereferrer</strong><br>
			When enabled, links will be proxied over the dereferrer-page.
			</td>
			<td valign="top">
				<select name="enable_dereferrer">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_dereferrer"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>

		<tr>
			<td align="left" width="350" valign="top"><strong>Enable Torrent Search</strong><br>
			When enabled, users will be allowed to perform torrent searches from the home page:
			</td>
			<td valign="top">
				<select name="enable_search">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_search"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Default Torrent Search Engine</strong><br>
			Select the default search engine for torrent searches:
			</td>
			<td valign="top">
				<?php 
    echo buildSearchEngineDDL($cfg["searchEngine"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable Make Torrent</strong><br>
			When enabled, users will be allowed to make torrent files from the directory view:
			</td>
			<td valign="top">
				<select name="enable_maketorrent">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_maketorrent"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>btmakemetafile.py Path</strong><br>
			Specify the path to the btmakemetafile.py python script (used for making torrents):
			</td>
			<td valign="top">
				<input name="btmakemetafile" type="Text" maxlength="254" value="<?php 
    echo $cfg["btmakemetafile"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["btmakemetafile"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable Torrent File Download</strong><br>
			When enabled, users will be allowed to download the torrent meta file from the torrent list view:
			</td>
			<td valign="top">
				<select name="enable_torrent_download">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_torrent_download"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable File Download</strong><br>
			When enabled, users will be allowed to download from the directory view:
			</td>
			<td valign="top">
				<select name="enable_file_download">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_file_download"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable Text/NFO Viewer</strong><br>
			When enabled, users will be allowed to view Text/NFO files from the directory listing:
			</td>
			<td valign="top">
				<select name="enable_view_nfo">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_view_nfo"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Download Package Type</strong><br>
			When File Download is enabled, users will be allowed download from the directory view using
			a packaging system.	 Make sure your server supports the package type you select:
			</td>
			<td valign="top">
				<select name="package_type">
						<option value="tar" selected>tar</option>
						<option value="zip" <?php 
    if ($cfg["package_type"] == "zip") {
        echo "selected";
    }
    ?>
>zip</option>
				</select>
			</td>
		</tr>

		<tr>
			<td align="left" width="350" valign="top"><strong>Days to keep Audit Actions in the Log</strong><br>
			Number of days that audit actions will be held in the database:
			</td>
			<td valign="top">
				<input name="days_to_keep" type="Text" maxlength="3" value="<?php 
    echo $cfg["days_to_keep"];
    ?>
" size="3">
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Minutes to Keep User Online Status</strong><br>
			Number of minutes before a user status changes to offline after leaving TorrentFlux:
			</td>
			<td valign="top">
				<input name="minutes_to_keep" type="Text" maxlength="2" value="<?php 
    echo $cfg["minutes_to_keep"];
    ?>
" size="2">
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Minutes to Cache RSS Feeds</strong><br>
			Number of minutes to cache the RSS XML feed on server (speeds up reload):
			</td>
			<td valign="top">
				<input name="rss_cache_min" type="Text" maxlength="3" value="<?php 
    echo $cfg["rss_cache_min"];
    ?>
" size="3">
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Default Theme</strong><br>
			Select the default theme that users will have (including login screen):
			</td>
			<td valign="top">
				<select name="default_theme">
<?php 
    $arThemes = GetThemes();
    for ($inx = 0; $inx < sizeof($arThemes); $inx++) {
        $selected = "";
        if ($cfg["default_theme"] == $arThemes[$inx]) {
            $selected = "selected";
        }
        echo "<option value=\"" . $arThemes[$inx] . "\" " . $selected . ">" . $arThemes[$inx] . "</option>";
    }
    ?>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Default Language</strong><br>
			Select the default language that users will have:
			</td>
			<td valign="top">
				<select name="default_language">
<?php 
    $arLanguage = GetLanguages();
    for ($inx = 0; $inx < sizeof($arLanguage); $inx++) {
        $selected = "";
        if ($cfg["default_language"] == $arLanguage[$inx]) {
            $selected = "selected";
        }
        echo "<option value=\"" . $arLanguage[$inx] . "\" " . $selected . ">" . GetLanguageFromFile($arLanguage[$inx]) . "</option>";
    }
    ?>
			</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Show SQL Debug Statements</strong><br>
			SQL Errors will always be displayed but when this feature is enabled the SQL Statement
			that caused the error will be displayed as well:
			</td>
			<td valign="top">
				<select name="debug_sql">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["debug_sql"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>

		<tr><td colspan="2" align="center" bgcolor="<?php 
    echo $cfg["table_header_bg"];
    ?>
"><strong>Hacks</strong></td></tr>

		<tr>
			<td align="left" width="350" valign="top"><strong>Enable MRTG-Integration</strong><br>
			Enable/Disable MRTG-Graphs-Integration. :
			</td>
			<td valign="top">
				<select name="enable_mrtg">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_mrtg"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>

		<tr>
			<td align="left" width="350" valign="top"><strong>Enable xfer</strong><br>
			Enable/Disable xfer-hack :
			</td>
			<td valign="top">
				<select name="enable_xfer">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_xfer"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable xfer realtime</strong><br>
			Enable/Disable xfer-realtime-stats updated on every index-reload :
			</td>
			<td valign="top">
				<select name="xfer_realtime">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["xfer_realtime"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable public xfer</strong><br>
			Enable/Disable public xfer of xfer-hack :
			</td>
			<td valign="top">
				<select name="enable_public_xfer">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_public_xfer"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>xfer - total</strong><br>
			Specify xfer_total. (default is "0"; 1TB is "1048576"):
			</td>
			<td valign="bottom">
				<input name="xfer_total" type="Text" maxlength="20" value="<?php 
    echo $cfg["xfer_total"];
    ?>
" size="20">
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>xfer - month</strong><br>
			Specify xfer_month. (default is "0"; 1GB is "1024"):
			</td>
			<td valign="bottom">
				<input name="xfer_month" type="Text" maxlength="20" value="<?php 
    echo $cfg["xfer_month"];
    ?>
" size="20">
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>xfer - week</strong><br>
			Specify xfer_week. (default is "0"):
			</td>
			<td valign="bottom">
				<input name="xfer_week" type="Text" maxlength="20" value="<?php 
    echo $cfg["xfer_week"];
    ?>
" size="20">
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>xfer - day</strong><br>
			Specify xfer_day. (default is "0"):
			</td>
			<td valign="bottom">
				<input name="xfer_day" type="Text" maxlength="20" value="<?php 
    echo $cfg["xfer_day"];
    ?>
" size="20">
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>xfer - week start</strong><br>
			Specify week_start. (default is "Monday"):
			</td>
			<td valign="bottom">
				<select name="week_start">
				<?php 
    echo '<option value="Monday"';
    if ($cfg["week_start"] == 'Monday') {
        echo " selected";
    }
    echo '>Monday</option>';
    echo '<option value="Tuesday"';
    if ($cfg["week_start"] == 'Tuesday') {
        echo " selected";
    }
    echo '>Tuesday</option>';
    echo '<option value="Wednesday"';
    if ($cfg["week_start"] == 'Wednesday') {
        echo " selected";
    }
    echo '>Wednesday</option>';
    echo '<option value="Thursday"';
    if ($cfg["week_start"] == 'Thursday') {
        echo " selected";
    }
    echo '>Thursday</option>';
    echo '<option value="Friday"';
    if ($cfg["week_start"] == 'Friday') {
        echo " selected";
    }
    echo '>Friday</option>';
    echo '<option value="Saturday"';
    if ($cfg["week_start"] == 'Saturday') {
        echo " selected";
    }
    echo '>Saturday</option>';
    echo '<option value="Sunday"';
    if ($cfg["week_start"] == 'Sunday') {
        echo " selected";
    }
    echo '>Sunday</option>';
    ?>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>xfer - month start</strong><br>
			Specify month_start. (default is "1"):
			</td>
			<td valign="bottom">
				<select name="month_start">
				<?php 
    for ($i = 1; $i <= 31; $i++) {
        echo '<option value="' . $i . '"';
        if ($cfg["month_start"] == $i) {
            echo " selected";
        }
        echo '>' . $i . '</option>';
    }
    ?>
				</select>
			</td>
		</tr>

		<tr>
			<td align="left" width="350" valign="top"><strong>Enable multi-upload</strong><br>
			Enable/Disable multi-upload-hack :
			</td>
			<td valign="top">
				<select name="enable_multiupload">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_multiupload"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>multi-upload - rows</strong><br>
			Specify rows on multi-upload page. (default is "6"):
			</td>
			<td valign="bottom">
				<input name="hack_multiupload_rows" type="Text" maxlength="2" value="<?php 
    echo $cfg["hack_multiupload_rows"];
    ?>
" size="2">
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable dir-stats</strong><br>
			Enable/Disable dir-stats-hack :
			</td>
			<td valign="top">
				<select name="enable_dirstats">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_dirstats"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable unrar</strong><br>
			Enable/Disable unrar-hack :
			</td>
			<td valign="top">
				<select name="enable_rar">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_rar"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable sfv-check</strong><br>
			Enable/Disable SFV Check-hack :
			</td>
			<td valign="top">
				<select name="enable_sfvcheck">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_sfvcheck"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable wget</strong><br>
			Enable/Disable wget-hack :
			</td>
			<td valign="top">
				<select name="enable_wget">
						<option value="1">true</option>
						<option value="0" <?php 
    if (!$cfg["enable_wget"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
			</td>
		</tr>

		<!-- Specific save path -->
		<tr>
		   <td align="left" width="350" valign="top"><strong>Enable Specific save path</strong><br>
		   Show Directory Tree when you are going to start a torrent,
		   allowing you to select the path where you want
		   to download the file(s).
		   </td>
		   <td valign="top">
			   <select name="showdirtree">
					   <option value="1">true</option>
					   <option value="0" <?php 
    if (!$cfg["showdirtree"]) {
        echo "selected";
    }
    ?>
>false</option>
			   </select>
		   </td>
		</tr>
		<tr>
		   <td align="left" width="350" valign="top"><strong>Max Depth in Directory Tree</strong><br>
		   Set the max depth of subfolders in your user directory when
		   displaying directory tree. Set it to 0 if you want to
		   display all subfolders.
		   </td>
		   <td valign="top">
			   <input name="maxdepth" type="Text" maxlength="1" value="<?php 
    echo $cfg["maxdepth"];
    ?>
" size="1">
		   </td>
		</tr>

		<!-- "Only Admin can see other user torrents" -->
		<tr>
		   <td align="left" width="350" valign="top"><strong>Enable Only Admin can see other user torrents</strong><br>
		   Enable/Disable "Only Admin can see other user torrents"-hack :
		   </td>
		   <td valign="top">
			   <select name="enable_restrictivetview">
					   <option value="1">true</option>
					   <option value="0" <?php 
    if (!$cfg["enable_restrictivetview"]) {
        echo "selected";
    }
    ?>
>false</option>
			   </select>
		   </td>
		</tr>

		<!-- Rename Hack -->
		<tr>
			<td align="left" width="350" valign="top"><strong>Enable Rename Files</strong><br>
				Enable/Disable Rename Files or Folders:
			</td>
		  <td valign="top"><select name="enable_rename">
						  <option value="1">true</option>
						  <option value="0" <?php 
    if (!$cfg["enable_rename"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
		  </td>
		</tr>

		<!-- Move Hack -->
		<tr>
		  <td align="left" width="350" valign="top"><strong>Move Settings</strong><br>
			Enable/Disable Moving Files into a specified dir:
		  </td>
		  <td valign="top"><select name="enable_move">
						  <option value="1">true</option>
						  <option value="0" <?php 
    if (!$cfg["enable_move"]) {
        echo "selected";
    }
    ?>
>false</option>
				</select>
		  </td>
		</tr>

		<!-- Move Hack settings -->
		<script src="move_extensionSettings.js" type="text/javascript"></script>
		<tr>
			<td align="left" width="350" valign="top"><strong>Move Settings</strong><br>
			  <u>Note :</u> You must specify absolute paths here. relative paths are not valid.<br>
			  <u>Note :</u> The created dirs will not be deleted after removing a entry from the List.
			</td>
			<td valign="top">
			 <?php 
    printMoveSettingsForm();
    ?>
			  </td>
		</tr>

		<!-- bins -->

		<tr><td colspan="2" align="center" bgcolor="<?php 
    echo $cfg["table_header_bg"];
    ?>
"><strong>Bins</strong></td></tr>

		<tr>
			<td align="left" width="350" valign="top"><strong>Path : grep</strong><br>
			Specify the path to the grep binary (/bin/grep):
			</td>
			<td valign="top">
				<input name="bin_grep" type="Text" maxlength="254" value="<?php 
    echo $cfg["bin_grep"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["bin_grep"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : cat</strong><br>
			Specify the path to the cat binary (/bin/cat):
			</td>
			<td valign="top">
				<input name="bin_cat" type="Text" maxlength="254" value="<?php 
    echo $cfg["bin_cat"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["bin_cat"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : php</strong><br>
			Specify the path to the php binary (/usr/bin/php):
			</td>
			<td valign="top">
				<input name="bin_php" type="Text" maxlength="254" value="<?php 
    echo $cfg["bin_php"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["bin_php"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : python</strong><br>
			Specify the path to the python binary (/usr/bin/python):
			</td>
			<td valign="top">
				<input name="pythonCmd" type="Text" maxlength="254" value="<?php 
    echo $cfg["pythonCmd"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["pythonCmd"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : awk</strong><br>
			Specify the path to the awk binary (/usr/bin/awk):
			</td>
			<td valign="top">
				<input name="bin_awk" type="Text" maxlength="254" value="<?php 
    echo $cfg["bin_awk"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["bin_awk"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : du</strong><br>
			Specify the path to the du binary (/usr/bin/du):
			</td>
			<td valign="top">
				<input name="bin_du" type="Text" maxlength="254" value="<?php 
    echo $cfg["bin_du"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["bin_du"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : wget</strong><br>
			Specify the path to the wget binary (/usr/bin/wget):
			</td>
			<td valign="top">
				<input name="bin_wget" type="Text" maxlength="254" value="<?php 
    echo $cfg["bin_wget"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["bin_wget"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : unzip</strong><br>
			Specify the path to the unzip binary (/usr/bin/unzip):
			</td>
			<td valign="top">
				<input name="bin_unzip" type="Text" maxlength="254" value="<?php 
    echo $cfg["bin_unzip"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["bin_unzip"]);
    ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : cksfv</strong><br>
			Specify the path to the cksfv binary (/usr/bin/cksfv):
			</td>
			<td valign="top">
				<input name="bin_cksfv" type="Text" maxlength="254" value="<?php 
    echo $cfg["bin_cksfv"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["bin_cksfv"]);
    ?>
			</td>
		</tr>

		<tr><td colspan="2" align="center" bgcolor="<?php 
    echo $cfg["table_header_bg"];
    ?>
"><strong>OS-specific</strong> <em>(<?php 
    echo php_uname('s');
    echo " ";
    echo php_uname('r');
    ?>
)</em></td></tr>
<?php 
    switch (_OS) {
        case 1:
            // linux
            ?>
		<tr>
			<td align="left" width="350" valign="top"><strong>loadavg Path</strong><br>
			Path to the loadavg file (/proc/loadavg):
			</td>
			<td valign="top">
				<input name="loadavg_path" type="Text" maxlength="254" value="<?php 
            echo $cfg["loadavg_path"];
            ?>
" size="55"><?php 
            echo validateFile($cfg["loadavg_path"]);
            ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : netstat</strong><br>
			Specify the path to the netstat binary (/bin/netstat):
			</td>
			<td valign="top">
				<input name="bin_netstat" type="Text" maxlength="254" value="<?php 
            echo $cfg["bin_netstat"];
            ?>
" size="55"><?php 
            echo validateFile($cfg["bin_netstat"]);
            ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : unrar</strong><br>
			Specify the path to the unrar binary (/usr/bin/unrar):
			</td>
			<td valign="top">
				<input name="bin_unrar" type="Text" maxlength="254" value="<?php 
            echo $cfg["bin_unrar"];
            ?>
" size="55"><?php 
            echo validateFile($cfg["bin_unrar"]);
            ?>
			</td>
		</tr>
<?php 
            break;
        case 2:
            // bsd
            ?>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : fstat</strong><br>
			Specify the path to the fstat binary (/usr/bin/fstat):
			</td>
			<td valign="top">
				<input name="bin_fstat" type="Text" maxlength="254" value="<?php 
            echo $cfg["bin_fstat"];
            ?>
" size="55"><?php 
            echo validateFile($cfg["bin_fstat"]);
            ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : sockstat</strong><br>
			Specify the path to the sockstat binary (/usr/bin/sockstat):
			</td>
			<td valign="top">
				<input name="bin_sockstat" type="Text" maxlength="254" value="<?php 
            echo $cfg["bin_sockstat"];
            ?>
" size="55"><?php 
            echo validateFile($cfg["bin_sockstat"]);
            ?>
			</td>
		</tr>
		<tr>
			<td align="left" width="350" valign="top"><strong>Path : rarbsd</strong><br>
			Specify the path to the rarbsd binary:
			</td>
			<td valign="top">
				<input name="bin_unrar" type="Text" maxlength="254" value="<?php 
            echo $cfg["bin_unrar"];
            ?>
" size="55"><?php 
            echo validateFile($cfg["bin_unrar"]);
            ?>
			</td>
		</tr>

<?php 
            break;
    }
    ?>

		</table>
		<br>
		<input type="Submit" value="Update Settings">
		</form>
	</div>
	<br>
<?php 
    echo "</td></tr>";
    echo "</table></div>";
    DisplayFoot(true, true);
}
$tmpl->setvar('enable_personal_settings', $cfg["enable_personal_settings"]);
$tmpl->setvar('enable_dereferrer', $cfg["enable_dereferrer"]);
$tmpl->setvar('days_to_keep', $cfg["days_to_keep"]);
$tmpl->setvar('minutes_to_keep', $cfg["minutes_to_keep"]);
$tmpl->setvar('rss_cache_min', $cfg["rss_cache_min"]);
$tmpl->setvar('debug_sql', $cfg["debug_sql"]);
$tmpl->setvar('debuglevel', $cfg["debuglevel"]);
//
$tmpl->setvar('drivespacebar', $cfg["drivespacebar"]);
$tmpl->setvar('servermon_update', $cfg["servermon_update"]);
$tmpl->setvar('transferHosts', $cfg["transferHosts"]);
$tmpl->setvar('transferStatsType', $cfg["transferStatsType"]);
$tmpl->setvar('transferStatsUpdate', $cfg["transferStatsUpdate"]);
// themes
$theme_list = array();
$arThemes = GetThemes();
for ($inx = 0; $inx < sizeof($arThemes); $inx++) {
    array_push($theme_list, array('arThemes' => preg_replace('/_beta$/', ' (beta)', $arThemes[$inx]), 'arThemes2' => $arThemes[$inx], 'selected' => $cfg["default_theme"] == $arThemes[$inx] ? "selected=\"selected\"" : ""));
}
$tmpl->setloop('theme_list', $theme_list);
// tf standard themes
$tfstandard_theme_list = array();
$arThemes = GetThemesStandard();
for ($inx = 0; $inx < sizeof($arThemes); $inx++) {
    $arThemes2[$inx] = "tf_standard_themes/" . $arThemes[$inx];
    array_push($tfstandard_theme_list, array('arThemes' => $arThemes[$inx], 'arThemes2' => $arThemes2[$inx], 'selected' => $cfg["default_theme"] == $arThemes2[$inx] ? "selected=\"selected\"" : ""));
}
$tmpl->setloop('tfstandard_theme_list', $tfstandard_theme_list);
// languages
$lang_list = array();
$arLanguage = GetLanguages();
$aus['global1'].='</table></fieldset>';
$aus['global1'].=print_save_button();
$aus['global1'].='</div>';

//Interface -->
$aus['global3']='<div id="global3"><fieldset><legend>' . $lang['L_CONFIG_INTERFACE'] . '</legend><table>';
$aus['global3'].='<tr><td>' . Help($lang['L_HELP_LANG'],"conf11") . $lang['L_LANGUAGE'] . ':&nbsp;</td>';
$aus['global3'].='<td><select name="language">' . GetLanguageCombo("op");
$aus['global3'].='</select><input type="hidden" name="lang_old" value="' . $config['language'] . '"><input type="hidden" name="scaption_old" value="' . $config['interface_server_caption'] . '"></td></tr>';

$aus['global3'].='<tr><td>' . Help($lang['L_HELP_SERVERCAPTION'],"") . $lang['L_SERVERCAPTION'] . ':</td>';
$aus['global3'].='<td><input type="checkbox" class="checkbox" value="1" name="server_caption" ' . ( ( $config['interface_server_caption'] == 1 ) ? " checked" : "" ) . '>&nbsp;' . $lang['L_ACTIVATED'] . '&nbsp;&nbsp;&nbsp;';
$aus['global3'].='<input type="radio" class="radio" name="server_caption_position" value="1" ' . ( ( $config['interface_server_caption_position'] == 1 ) ? "checked" : "" ) . '>&nbsp;' . $lang['L_IN_MAINFRAME'] . '&nbsp;&nbsp;<input type="radio" class="radio" name="server_caption_position" value="0" ' . ( ( $config['interface_server_caption_position'] == 0 ) ? "checked" : "" ) . '>&nbsp;' . $lang['L_IN_LEFTFRAME'] . '';
$aus['global3'].='</td></tr>';
$aus['global3'].='<tr><td>' . Help("","") . 'Theme:</td><td><select name="theme">' . GetThemes() . '</select></td></tr>';

$aus['global3'].='</table></fieldset><fieldset><legend>' . $lang['L_SQL_BROWSER'] . '</legend><table>';
$aus['global3'].='<tr><td>' . Help("","") . $lang['L_SQLBOXHEIGHT'] . ':&nbsp;</td>';
$aus['global3'].='<td><input type="text" class="text" name="sqlboxsize" value="' . $config['interface_sqlboxsize'] . '" size="3" maxlength="3">&nbsp;Pixel</td></tr>';
$aus['global3'].='<tr><td>' . Help("","") . $lang['L_SQLLIMIT'] . ':&nbsp;</td>';
$aus['global3'].='<td><input type="text" class="text" name="sql_limit" value="' . $config['sql_limit'] . '" size="3" maxlength="6">&nbsp;</td></tr>';
$aus['global3'].='<tr><td>' . Help("","") . $lang['L_BBPARAMS'] . ':&nbsp;</td>';
$aus['global3'].='<td>';
$aus['global3'].='<table><tr><td>' . $lang['L_WIDTH'] . ':</td><td><input type="text" class="text" name="bb_width" value="' . $config['bb_width'] . '" size="3" maxlength="3">&nbsp;pixel</td></tr>';
$aus['global3'].='<tr><td>' . $lang['L_BBTEXTCOLOR'] . ':&nbsp;</td>';
$aus['global3'].='<td><select name="bb_textcolor">
<option value="#000000" style="color :#000000;" ' . ( ( $config['bb_textcolor'] == "#000000" ? "selected" : "" ) ) . '>&nbsp;Textcolor&nbsp;</option>
<option value="#000066" style="color :#000066;" ' . ( ( $config['bb_textcolor'] == "#000066" ? "selected" : "" ) ) . '>&nbsp;Textcolor&nbsp;</option>
<option value="#800000" style="color :#800000;" ' . ( ( $config['bb_textcolor'] == "#800000" ? "selected" : "" ) ) . '>&nbsp;Textcolor&nbsp;</option>
<option value="#990000" style="color :#990000;" ' . ( ( $config['bb_textcolor'] == "#990000" ? "selected" : "" ) ) . '>&nbsp;Textcolor&nbsp;</option>
function showIndex()
{
    global $cfg, $db;
    $hideChecked = "";
    if ($cfg["hide_offline"] == 1) {
        $hideChecked = "checked";
    }
    DisplayHead($cfg["user"] . "'s " . _PROFILE);
    echo "<div align=\"center\">";
    echo "<table border=1 bordercolor=\"" . $cfg["table_admin_border"] . "\" cellpadding=\"2\" cellspacing=\"0\" width=\"760\">";
    echo "<tr><td colspan=6 bgcolor=\"" . $cfg["table_data_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\">";
    echo "<img src=\"images/properties.png\" width=18 height=13 border=0>&nbsp;&nbsp;<font class=\"title\">" . $cfg["user"] . "'s " . _PROFILE . "</font>";
    echo "</td></tr><tr><td align=\"center\">";
    $total_activity = GetActivityCount();
    $sql = "SELECT user_id, hits, last_visit, time_created, user_level FROM tf_users WHERE user_id=" . $db->qstr($cfg["user"]);
    list($user_id, $hits, $last_visit, $time_created, $user_level) = $db->GetRow($sql);
    $user_type = _NORMALUSER;
    if (IsAdmin()) {
        $user_type = _ADMINISTRATOR;
    }
    if (IsSuperAdmin()) {
        $user_type = _SUPERADMIN;
    }
    $user_activity = GetActivityCount($cfg["user"]);
    if ($user_activity == 0) {
        $user_percent = 0;
    } else {
        $user_percent = number_format($user_activity / $total_activity * 100);
    }
    ?>

    <table width="100%" border="0" cellpadding="3" cellspacing="0">
    <tr>

        <!-- left column -->
        <td width="50%" bgcolor="<?php 
    echo $cfg["table_data_bg"];
    ?>
" valign="top">
        <div align="center">
        <table border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td align="right"><?php 
    echo _JOINED;
    ?>
:&nbsp;</td>
            <td><strong><?php 
    echo date(_DATETIMEFORMAT, $time_created);
    ?>
</strong></td>
        </tr>
        <tr>
            <td colspan="2" align="center">&nbsp;</td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _UPLOADPARTICIPATION;
    ?>
:&nbsp;</td>
            <td>
                <table width="200" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td background="themes/<?php 
    echo $cfg["theme"];
    ?>
/images/proglass.gif" width="<?php 
    echo $user_percent * 2;
    ?>
"><img src="images/blank.gif" width="1" height="12" border="0"></td>
                    <td background="themes/<?php 
    echo $cfg["theme"];
    ?>
/images/noglass.gif" width="<?php 
    echo 200 - $user_percent * 2;
    ?>
"><img src="images/blank.gif" width="1" height="12" border="0"></td>
                </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _UPLOADS;
    ?>
:&nbsp;</td>
            <td><strong><?php 
    echo $user_activity;
    ?>
</strong></td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _PERCENTPARTICIPATION;
    ?>
:&nbsp;</td>
            <td><strong><?php 
    echo $user_percent;
    ?>
%</strong></td>
        </tr>
        <tr>
            <td colspan="2" align="center"><div align="center" class="tiny">(<?php 
    echo _PARTICIPATIONSTATEMENT . " " . $cfg['days_to_keep'] . " " . _DAYS;
    ?>
)</div><br></td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _TOTALPAGEVIEWS;
    ?>
:&nbsp;</td>
            <td><strong><?php 
    echo $hits;
    ?>
</strong></td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _USERTYPE;
    ?>
:&nbsp;</td>
            <td><strong><?php 
    echo $user_type;
    ?>
</strong></td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <table>
                    <tr>
                        <td align="center">
                            <BR />[ <a href="?op=showCookies">Cookie Management</a> ]
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        </table>
        </div>
        </td>

        <!-- right column -->
        <td valign="top">
        <div align="center">
        <table cellpadding="5" cellspacing="0" border="0">
        <form name="theForm" action="profile.php?op=updateProfile" method="post" onsubmit="return validateProfile()">
        <tr>
            <td align="right"><?php 
    echo _USER;
    ?>
:</td>
            <td>
            <input readonly="true" type="Text" value="<?php 
    echo $cfg["user"];
    ?>
" size="15">
            </td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _NEWPASSWORD;
    ?>
:</td>
            <td>
            <input name="pass1" type="Password" value="" size="15">
            </td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _CONFIRMPASSWORD;
    ?>
:</td>
            <td>
            <input name="pass2" type="Password" value="" size="15">
            </td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _THEME;
    ?>
:</td>
            <td>
            <select name="theme">
<?php 
    $arThemes = GetThemes();
    for ($inx = 0; $inx < sizeof($arThemes); $inx++) {
        $selected = "";
        if ($cfg["theme"] == $arThemes[$inx]) {
            $selected = "selected";
        }
        echo "<option value=\"" . $arThemes[$inx] . "\" " . $selected . ">" . $arThemes[$inx] . "</option>";
    }
    ?>
            </select>
            </td>
        </tr>
                <tr>
            <td align="right"><?php 
    echo _LANGUAGE;
    ?>
:</td>
            <td>
            <select name="language">
<?php 
    $arLanguage = GetLanguages();
    for ($inx = 0; $inx < sizeof($arLanguage); $inx++) {
        $selected = "";
        if ($cfg["language_file"] == $arLanguage[$inx]) {
            $selected = "selected";
        }
        echo "<option value=\"" . $arLanguage[$inx] . "\" " . $selected . ">" . GetLanguageFromFile($arLanguage[$inx]) . "</option>";
    }
    ?>
            </select>
            </td>
        </tr>
        <tr>
            <td colspan="2">
            <input name="hideOffline" type="Checkbox" value="1" <?php 
    echo $hideChecked;
    ?>
> <?php 
    echo _HIDEOFFLINEUSERS;
    ?>
<br>
            </td>
        </tr>
        <tr>
            <td align="center" colspan="2">
            <input type="Submit" value="<?php 
    echo _UPDATE;
    ?>
">
            </td>
        </tr>
        </form>

        </table>

        </div>
        </td>
    </tr>

    <!-- user-settings -->
    <tr><td colspan="2" align="center" bgcolor="<?php 
    echo $cfg["table_border_dk"];
    ?>
"><strong><?php 
    echo $cfg["user"];
    ?>
's Settings</strong></td></tr>
    <tr><td colspan="2"><br></td></tr>
    <tr><td colspan="2">

    <form name="settingsForm" action="profile.php?op=updateSettingsUser" method="post">
    <table border="0" cellpadding="3" cellspacing="0" width="100%">

        <tr><td colspan="2" align="center" bgcolor="<?php 
    echo $cfg["table_header_bg"];
    ?>
"><strong>Index-Page</strong></td></tr>

        <tr>
            <td align="left" width="350" valign="top"><strong>Select index-page</strong><br>
            Select the index-Page.
            </td>
            <td valign="top">
                <?php 
    printIndexPageSelectForm();
    ?>
            </td>
        </tr>

        <tr>
            <td align="left" width="350" valign="top"><strong>index-page settings</strong><br>
            Select the columns in transfer-list on index-Page.<br>(only for b4rt-index-page)
            </td>
            <td valign="top">
                <?php 
    printIndexPageSettingsForm();
    ?>
            </td>
        </tr>

        <tr>
            <td align="left" width="350" valign="top"><strong>Width</strong><br>
            Specify the width of the index-page. (780):
            </td>
            <td valign="bottom">
                <input name="ui_dim_main_w" type="Text" maxlength="5" value="<?php 
    echo $cfg["ui_dim_main_w"];
    ?>
" size="5">
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Display Links</strong><br>
            Display Links on the index-page. (true):
            </td>
            <td valign="bottom">
                <select name="ui_displaylinks">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["ui_displaylinks"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Display Users</strong><br>
            Display Users on the index-page. (true):
            </td>
            <td valign="bottom">
                <select name="ui_displayusers">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["ui_displayusers"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Select Drivespace-Bar</strong><br>
            Select Style of Drivespace-Bar on index-Page.
            </td>
            <td valign="top">
                <?php 
    printDrivespacebarSelectForm();
    ?>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Show Server Stats</strong><br>
            Enable showing the server stats at the bottom:
            </td>
            <td valign="top">
                <select name="index_page_stats">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["index_page_stats"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>

        <tr>
            <td align="left" width="350" valign="top"><strong>Show Server Load</strong><br>
            Enable showing the average server load over the last 15 minutes:
            </td>
            <td valign="top">
                <select name="show_server_load">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["show_server_load"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>

        <tr>
            <td align="left" width="350" valign="top"><strong>Show Connections</strong><br>
            Enable showing the Sum of TCP-Connections:
            </td>
            <td valign="top">
                <select name="index_page_connections">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["index_page_connections"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>

        <tr>
            <td align="left" width="350" valign="top"><strong>Use Refresh</strong><br>
            Use meta-refresh on index-page. (true):
            </td>
            <td valign="bottom">
                <select name="ui_indexrefresh">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["ui_indexrefresh"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Page Refresh (in seconds)</strong><br>
            Number of seconds before the torrent list page refreshes:
            </td>
            <td valign="top">
                <input name="page_refresh" type="Text" maxlength="3" value="<?php 
    echo $cfg["page_refresh"];
    ?>
" size="3">
            </td>
        </tr>

        <tr>
            <td align="left" width="350" valign="top"><strong>Select Sort-Order</strong><br>
            Select default Sort-Order of transfers on index-Page.
            </td>
            <td valign="top">
                <?php 
    printSortOrderSettingsForm();
    ?>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Enable sorttable</strong><br>
            Enable Client-Side sorting of Transfer-Table:
            </td>
            <td valign="top">
                <select name="enable_sorttable">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["enable_sorttable"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>

        <tr>
           <td align="left" width="350" valign="top"><strong>Enable Good looking statistics</strong><br>
           Enable/Disable "Good looking statistics" :
           </td>
           <td valign="top">
               <select name="enable_goodlookstats">
                       <option value="1">true</option>
                       <option value="0" <?php 
    if (!$cfg["enable_goodlookstats"]) {
        echo "selected";
    }
    ?>
>false</option>
               </select>
           </td>
        </tr>

        <tr>
           <td align="left" width="350" valign="top"><strong>Good looking statistics settings</strong><br>
           Configure Settings of "Good looking statistics" :
           </td>
           <td valign="top">
            <?php 
    printGoodLookingStatsForm();
    ?>
           </td>
        </tr>

        <tr>
           <td align="left" width="350" valign="top"><strong>Enable Big bold drivespace warning</strong><br>
           Enable/Disable "Big bold drivespace warning" :
           </td>
           <td valign="top">
               <select name="enable_bigboldwarning">
                       <option value="1">true</option>
                       <option value="0" <?php 
    if (!$cfg["enable_bigboldwarning"]) {
        echo "selected";
    }
    ?>
>false</option>
               </select>
           </td>
        </tr>

        <tr><td colspan="2" align="center" bgcolor="<?php 
    echo $cfg["table_header_bg"];
    ?>
"><strong>Download-Details</strong></td></tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Width</strong><br>
            Specify the width of the details-popup. (450):
            </td>
            <td valign="bottom">
                <input name="ui_dim_details_w" type="Text" maxlength="5" value="<?php 
    echo $cfg["ui_dim_details_w"];
    ?>
" size="5">
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Height</strong><br>
            Specify the height of the details-popup. (290):
            </td>
            <td valign="bottom">
                <input name="ui_dim_details_h" type="Text" maxlength="5" value="<?php 
    echo $cfg["ui_dim_details_h"];
    ?>
" size="5">
            </td>
        </tr>

        <tr><td colspan="2" align="center" bgcolor="<?php 
    echo $cfg["table_header_bg"];
    ?>
"><strong>Misc</strong></td></tr>

        <tr>
            <td align="left" width="350" valign="top"><strong>Default Torrent Search Engine</strong><br>
            Select the default search engine for torrent searches:
            </td>
            <td valign="top">
                <?php 
    echo buildSearchEngineDDL($cfg["searchEngine"]);
    ?>
            </td>
        </tr>

        <!-- move hack settings -->
        <?php 
    if ($cfg["enable_move"] != 0) {
        ?>
            <script src="move_extensionSettings.js" type="text/javascript"></script>
    		<tr>
            	<td align="left" width="350" valign="top"><strong>Move Settings</strong><br>
            	<u>Note :</u> You must specify absolute paths here. relative paths are not valid.<br>
            	<u>Note :</u> The created dirs will not be deleted after removing a entry from the List.
            	</td>
        		<td valign="top">
                 <?php 
        printMoveSettingsForm();
        ?>
    		    </td>
    		</tr>
        <?php 
    }
    ?>

        <tr>
            <td align="left" width="350" valign="top"><strong>Display TorrentFlux Link</strong><br>
            Display TorrentFlux Link at bottom of pages. (true):
            </td>
            <td valign="bottom">
                <select name="ui_displayfluxlink">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["ui_displayfluxlink"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>

        <tr><td colspan="2"><hr noshade></td></tr>
        <tr>
            <td align="center" colspan="2">
                <input type="Submit" value="Update Settings">
            </td>
        </tr>
    </table>
    </form>

    </td></tr>
    <!-- user-settings -->

    </table>

    <script language="JavaScript">
    function validateProfile()
    {
        var msg = ""
        if (theForm.pass1.value != "" || theForm.pass2.value != "")
        {
            if (theForm.pass1.value.length <= 5 || theForm.pass2.value.length <= 5)
            {
                msg = msg + "* <?php 
    echo _PASSWORDLENGTH;
    ?>
\n";
                theForm.pass1.focus();
            }
            if (theForm.pass1.value != theForm.pass2.value)
            {
                msg = msg + "* <?php 
    echo _PASSWORDNOTMATCH;
    ?>
\n";
                theForm.pass1.value = "";
                theForm.pass2.value = "";
                theForm.pass1.focus();
            }
        }

        if (msg != "")
        {
            alert("<?php 
    echo _PLEASECHECKFOLLOWING;
    ?>
:\n\n" + msg);
            return false;
        }
        else
        {
            return true;
        }
    }
    </script>

<?php 
    echo "</td></tr>";
    echo "</table></div><br><br>";
    DisplayFoot();
}
function showIndex()
{
    global $cfg, $db;
    $hideChecked = "";
    if ($cfg["hide_offline"] == 1) {
        $hideChecked = "checked";
    }
    DisplayHead($cfg["user"] . "'s " . _PROFILE);
    echo "<div align=\"center\">";
    echo "<table border=1 bordercolor=\"" . $cfg["table_admin_border"] . "\" cellpadding=\"2\" cellspacing=\"0\" width=\"760\">";
    echo "<tr><td colspan=6 bgcolor=\"" . $cfg["table_data_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\">";
    echo "<img src=\"images/properties.png\" width=18 height=13 border=0>&nbsp;&nbsp;<font class=\"title\">" . $cfg["user"] . "'s " . _PROFILE . "</font>";
    echo "</td></tr><tr><td align=\"center\">";
    $total_activity = GetActivityCount();
    $sql = "SELECT user_id, hits, last_visit, time_created, user_level FROM tf_users WHERE user_id=" . $db->qstr($cfg["user"]);
    list($user_id, $hits, $last_visit, $time_created, $user_level) = $db->GetRow($sql);
    $user_type = _NORMALUSER;
    if (IsAdmin()) {
        $user_type = _ADMINISTRATOR;
    }
    if (IsSuperAdmin()) {
        $user_type = _SUPERADMIN;
    }
    $user_activity = GetActivityCount($cfg["user"]);
    if ($user_activity == 0) {
        $user_percent = 0;
    } else {
        $user_percent = number_format($user_activity / $total_activity * 100);
    }
    ?>

    <table width="100%" border="0" cellpadding="3" cellspacing="0">
    <tr>
        <td width="50%" bgcolor="<?php 
    echo $cfg["table_data_bg"];
    ?>
" valign="top">

        <div align="center">
        <table border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td align="right"><?php 
    echo _JOINED;
    ?>
:&nbsp;</td>
            <td><strong><?php 
    echo date(_DATETIMEFORMAT, $time_created);
    ?>
</strong></td>
        </tr>
        <tr>
            <td colspan="2" align="center">&nbsp;</td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _UPLOADPARTICIPATION;
    ?>
:&nbsp;</td>
            <td>
                <table width="200" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td background="themes/<?php 
    echo $cfg["theme"];
    ?>
/images/proglass.gif" width="<?php 
    echo $user_percent * 2;
    ?>
"><img src="images/blank.gif" width="1" height="12" border="0"></td>
                    <td background="themes/<?php 
    echo $cfg["theme"];
    ?>
/images/noglass.gif" width="<?php 
    echo 200 - $user_percent * 2;
    ?>
"><img src="images/blank.gif" width="1" height="12" border="0"></td>
                </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _UPLOADS;
    ?>
:&nbsp;</td>
            <td><strong><?php 
    echo $user_activity;
    ?>
</strong></td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _PERCENTPARTICIPATION;
    ?>
:&nbsp;</td>
            <td><strong><?php 
    echo $user_percent;
    ?>
%</strong></td>
        </tr>
        <tr>
            <td colspan="2" align="center"><div align="center" class="tiny">(<?php 
    echo _PARTICIPATIONSTATEMENT . " " . $cfg['days_to_keep'] . " " . _DAYS;
    ?>
)</div><br></td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _TOTALPAGEVIEWS;
    ?>
:&nbsp;</td>
            <td><strong><?php 
    echo $hits;
    ?>
</strong></td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _USERTYPE;
    ?>
:&nbsp;</td>
            <td><strong><?php 
    echo $user_type;
    ?>
</strong></td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <table>
                    <tr>
                        <td align="center">
                            <BR />[ <a href="?op=showCookies">Cookie Management</a> ]
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        </table>
        </div>

        </td>
        <td valign="top">
        <div align="center">
        <table cellpadding="5" cellspacing="0" border="0">
        <form name="theForm" action="profile.php?op=updateProfile" method="post" onsubmit="return validateProfile()">
        <tr>
            <td align="right"><?php 
    echo _USER;
    ?>
:</td>
            <td>
            <input readonly="true" type="Text" value="<?php 
    echo $cfg["user"];
    ?>
" size="15">
            </td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _NEWPASSWORD;
    ?>
:</td>
            <td>
            <input name="pass1" type="Password" value="" size="15">
            </td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _CONFIRMPASSWORD;
    ?>
:</td>
            <td>
            <input name="pass2" type="Password" value="" size="15">
            </td>
        </tr>
        <tr>
            <td align="right"><?php 
    echo _THEME;
    ?>
:</td>
            <td>
            <select name="theme">
<?php 
    $arThemes = GetThemes();
    for ($inx = 0; $inx < sizeof($arThemes); $inx++) {
        $selected = "";
        if ($cfg["theme"] == $arThemes[$inx]) {
            $selected = "selected";
        }
        echo "<option value=\"" . $arThemes[$inx] . "\" " . $selected . ">" . $arThemes[$inx] . "</option>";
    }
    ?>
            </select>
            </td>
        </tr>
                <tr>
            <td align="right"><?php 
    echo _LANGUAGE;
    ?>
:</td>
            <td>
            <select name="language">
<?php 
    $arLanguage = GetLanguages();
    for ($inx = 0; $inx < sizeof($arLanguage); $inx++) {
        $selected = "";
        if ($cfg["language_file"] == $arLanguage[$inx]) {
            $selected = "selected";
        }
        echo "<option value=\"" . $arLanguage[$inx] . "\" " . $selected . ">" . GetLanguageFromFile($arLanguage[$inx]) . "</option>";
    }
    ?>
            </select>
            </td>
        </tr>
        <tr>
            <td colspan="2">
            <input name="hideOffline" type="Checkbox" value="1" <?php 
    echo $hideChecked;
    ?>
> <?php 
    echo _HIDEOFFLINEUSERS;
    ?>
<br>
            </td>
        </tr>
        <tr>
            <td align="center" colspan="2">
            <input type="Submit" value="<?php 
    echo _UPDATE;
    ?>
">
            </td>
        </tr>
        </form>
        </table>
        </div>
        </td>
    </tr>
    </table>


    <script language="JavaScript">
    function validateProfile()
    {
        var msg = ""
        if (theForm.pass1.value != "" || theForm.pass2.value != "")
        {
            if (theForm.pass1.value.length <= 5 || theForm.pass2.value.length <= 5)
            {
                msg = msg + "* <?php 
    echo _PASSWORDLENGTH;
    ?>
\n";
                theForm.pass1.focus();
            }
            if (theForm.pass1.value != theForm.pass2.value)
            {
                msg = msg + "* <?php 
    echo _PASSWORDNOTMATCH;
    ?>
\n";
                theForm.pass1.value = "";
                theForm.pass2.value = "";
                theForm.pass1.focus();
            }
        }

        if (msg != "")
        {
            alert("<?php 
    echo _PLEASECHECKFOLLOWING;
    ?>
:\n\n" + msg);
            return false;
        }
        else
        {
            return true;
        }
    }
    </script>

<?php 
    echo "</td></tr>";
    echo "</table></div><br><br>";
    DisplayFoot();
}
$aus['global1'] .= '<tr><td>' . Help("", "") . $lang['L_ERRORHANDLING_RESTORE'] . '</td><td>';
$aus['global1'] .= '<input type="radio" class="radio" name="stop_with_error" value="0" ' . ($config['stop_with_error'] == 0 ? " checked" : "") . '>&nbsp;' . $lang['L_EHRESTORE_CONTINUE'] . '<br>';
$aus['global1'] .= '<input type="radio" class="radio" name="stop_with_error" value="1" ' . ($config['stop_with_error'] == 1 ? " checked" : "") . '>&nbsp;' . $lang['L_EHRESTORE_STOP'];
$aus['global1'] .= '</td></tr></table></fieldset>';
$aus['global1'] .= print_save_button();
$aus['global1'] .= '</div>';
//Interface -->
$aus['global3'] = '<div id="global3"><fieldset><legend>' . $lang['L_CONFIG_INTERFACE'] . '</legend><table>';
$aus['global3'] .= '<tr><td>' . Help($lang['L_HELP_LANG'], "conf11") . $lang['L_LANGUAGE'] . ':&nbsp;</td>';
$aus['global3'] .= '<td><select name="language">' . GetLanguageCombo("op");
$aus['global3'] .= '</select>&nbsp;&nbsp;<a href="' . $languagepacks_ref . '" target="_blank">' . $lang['L_DOWNLOAD_LANGUAGES'] . '</a><input type="hidden" name="lang_old" value="' . $config['language'] . '"><input type="hidden" name="scaption_old" value="' . $config['interface_server_caption'] . '"></td></tr>';
$aus['global3'] .= '<tr><td>' . Help($lang['L_HELP_SERVERCAPTION'], "") . $lang['L_SERVERCAPTION'] . ':</td>';
$aus['global3'] .= '<td><input type="checkbox" class="checkbox" value="1" name="server_caption" ' . ($config['interface_server_caption'] == 1 ? " checked" : "") . '>&nbsp;' . $lang['L_ACTIVATED'] . '&nbsp;&nbsp;&nbsp;';
$aus['global3'] .= '<input type="radio" class="radio" name="server_caption_position" value="1" ' . ($config['interface_server_caption_position'] == 1 ? "checked" : "") . '>&nbsp;' . $lang['L_IN_MAINFRAME'] . '&nbsp;&nbsp;<input type="radio" class="radio" name="server_caption_position" value="0" ' . ($config['interface_server_caption_position'] == 0 ? "checked" : "") . '>&nbsp;' . $lang['L_IN_LEFTFRAME'] . '';
$aus['global3'] .= '</td></tr>';
$aus['global3'] .= '<tr><td>' . Help("", "") . 'Theme</td><td><select name="theme">' . GetThemes() . '</select>&nbsp;&nbsp;<a href="' . $stylepacks_ref . '" target="_blank">' . $lang['L_DOWNLOAD_STYLES'] . '</a></td></tr>';
$aus['global3'] .= '</table></fieldset><fieldset><legend>' . $lang['L_SQL_BROWSER'] . '</legend><table>';
$aus['global3'] .= '<tr><td>' . Help("", "") . $lang['L_SQLBOXHEIGHT'] . ':&nbsp;</td>';
$aus['global3'] .= '<td><input type="text" class="text" name="sqlboxsize" value="' . $config['interface_sqlboxsize'] . '" size="3" maxlength="3">&nbsp;Pixel</td></tr>';
$aus['global3'] .= '<tr><td>' . Help("", "") . $lang['L_SQLLIMIT'] . ':&nbsp;</td>';
$aus['global3'] .= '<td><input type="text" class="text" name="sql_limit" value="' . $config['sql_limit'] . '" size="3" maxlength="6">&nbsp;</td></tr>';
$aus['global3'] .= '<tr><td>' . Help("", "") . $lang['L_BBPARAMS'] . ':&nbsp;</td>';
$aus['global3'] .= '<td>';
$aus['global3'] .= '<table><tr><td>' . $lang['L_WIDTH'] . ':</td><td><input type="text" class="text" name="bb_width" value="' . $config['bb_width'] . '" size="3" maxlength="3">&nbsp;pixel</td></tr>';
$aus['global3'] .= '<tr><td>' . $lang['L_BBTEXTCOLOR'] . ':&nbsp;</td>';
$aus['global3'] .= '<td><select name="bb_textcolor">
<option value="#000000" style="color :#000000;" ' . ($config['bb_textcolor'] == "#000000" ? "selected" : "") . '>&nbsp;Textcolor&nbsp;</option>
<option value="#000066" style="color :#000066;" ' . ($config['bb_textcolor'] == "#000066" ? "selected" : "") . '>&nbsp;Textcolor&nbsp;</option>
<option value="#800000" style="color :#800000;" ' . ($config['bb_textcolor'] == "#800000" ? "selected" : "") . '>&nbsp;Textcolor&nbsp;</option>
<option value="#990000" style="color :#990000;" ' . ($config['bb_textcolor'] == "#990000" ? "selected" : "") . '>&nbsp;Textcolor&nbsp;</option>
<option value="#006600" style="color :#006600;" ' . ($config['bb_textcolor'] == "#006600" ? "selected" : "") . '>&nbsp;Textcolor&nbsp;</option>
function configSettings()
{
    global $cfg;
    include_once "AliasFile.php";
    include_once "RunningTorrent.php";
    DisplayHead("Administration - Settings");
    // Admin Menu
    displayMenu();
    // Main Settings Section
    echo "<div align=\"center\">";
    echo "<table width=\"100%\" border=1 bordercolor=\"" . $cfg["table_admin_border"] . "\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"" . $cfg["table_data_bg"] . "\">";
    echo "<tr><td bgcolor=\"" . $cfg["table_header_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\">";
    echo "<img src=\"images/properties.png\" width=18 height=13 border=0>&nbsp;&nbsp;<font class=\"title\">TorrentFlux Settings</font>";
    echo "</td></tr><tr><td align=\"center\">";
    ?>

    <script language="JavaScript">
    function validateSettings()
    {
        var rtnValue = true;
        var msg = "";
        if (isNumber(document.theForm.max_upload_rate.value) == false)
        {
            msg = msg + "* Max Upload Rate must be a valid number.\n";
            document.theForm.max_upload_rate.focus();
        }
        if (isNumber(document.theForm.max_download_rate.value) == false)
        {
            msg = msg + "* Max Download Rate must be a valid number.\n";
            document.theForm.max_download_rate.focus();
        }
        if (isNumber(document.theForm.max_uploads.value) == false)
        {
            msg = msg + "* Max # Uploads must be a valid number.\n";
            document.theForm.max_uploads.focus();
        }
        if ((isNumber(document.theForm.minport.value) == false) || (isNumber(document.theForm.maxport.value) == false))
        {
            msg = msg + "* Port Range must have valid numbers.\n";
            document.theForm.minport.focus();
        }
        if (isNumber(document.theForm.rerequest_interval.value) == false)
        {
            msg = msg + "* Rerequest Interval must have a valid number.\n";
            document.theForm.rerequest_interval.focus();
        }
        if (document.theForm.rerequest_interval.value < 10)
        {
            msg = msg + "* Rerequest Interval must 10 or greater.\n";
            document.theForm.rerequest_interval.focus();
        }
        if (isNumber(document.theForm.days_to_keep.value) == false)
        {
            msg = msg + "* Days to keep Audit Actions must be a valid number.\n";
            document.theForm.days_to_keep.focus();
        }
        if (isNumber(document.theForm.minutes_to_keep.value) == false)
        {
            msg = msg + "* Minutes to keep user online must be a valid number.\n";
            document.theForm.minutes_to_keep.focus();
        }
        if (isNumber(document.theForm.rss_cache_min.value) == false)
        {
            msg = msg + "* Minutes to Cache RSS Feeds must be a valid number.\n";
            document.theForm.rss_cache_min.focus();
        }
        if (isNumber(document.theForm.page_refresh.value) == false)
        {
            msg = msg + "* Page Refresh must be a valid number.\n";
            document.theForm.page_refresh.focus();
        }
        if (isNumber(document.theForm.sharekill.value) == false)
        {
            msg = msg + "* Keep seeding until Sharing % must be a valid number.\n";
            document.theForm.sharekill.focus();
        }
        if ((document.theForm.maxport.value > 65535) || (document.theForm.minport.value > 65535))
        {
            msg = msg + "* Port can not be higher than 65535.\n";
            document.theForm.minport.focus();
        }
        if ((document.theForm.maxport.value < 0) || (document.theForm.minport.value < 0))
        {
            msg = msg + "* Can not have a negative number for port value.\n";
            document.theForm.minport.focus();
        }
        if (document.theForm.maxport.value < document.theForm.minport.value)
        {
            msg = msg + "* Port Range is not valid.\n";
            document.theForm.minport.focus();
        }

        if (msg != "")
        {
            rtnValue = false;
            alert("Please check the following:\n\n" + msg);
        }

        return rtnValue;
    }

    function isNumber(sText)
    {
        var ValidChars = "0123456789";
        var IsNumber = true;
        var Char;

        for (i = 0; i < sText.length && IsNumber == true; i++)
        {
            Char = sText.charAt(i);
            if (ValidChars.indexOf(Char) == -1)
            {
                IsNumber = false;
            }
        }

        return IsNumber;
    }
    </script>

    <div align="center">

        <table cellpadding="5" cellspacing="0" border="0" width="100%">
        <form name="theForm" action="admin.php?op=updateConfigSettings" method="post" onsubmit="return validateSettings()">
        <input type="Hidden" name="continue" value="configSettings">
        <tr>
            <td align="left" width="350" valign="top"><strong>Path</strong><br>
            Define the PATH where the downloads will go <br>(make sure it ends with a / [slash]).
            It must be chmod'd to 777:
            </td>
            <td valign="top">
                <input name="path" type="Text" maxlength="254" value="<?php 
    echo $cfg["path"];
    ?>
" size="55"><?php 
    echo validatePath($cfg["path"]);
    ?>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Python Path</strong><br>
            Specify the path to the Python binary (usually /usr/bin/python or /usr/local/bin/python):
            </td>
            <td valign="top">
                <input name="pythonCmd" type="Text" maxlength="254" value="<?php 
    echo $cfg["pythonCmd"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["pythonCmd"]);
    ?>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>btphptornado Path</strong><br>
            Specify the path to the btphptornado python script:
            </td>
            <td valign="top">
                <input name="btphpbin" type="Text" maxlength="254" value="<?php 
    echo $cfg["btphpbin"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["btphpbin"]);
    ?>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>btshowmetainfo Path</strong><br>
            Specify the path to the btshowmetainfo python script:
            </td>
            <td valign="top">
                <input name="btshowmetainfo" type="Text" maxlength="254" value="<?php 
    echo $cfg["btshowmetainfo"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["btshowmetainfo"]);
    ?>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Use Advanced Start Dialog</strong><br>
            When enabled, users will be given the advanced start dialog popup when starting a torrent:
            </td>
            <td valign="top">
                <select name="advanced_start">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["advanced_start"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Enable File Priority</strong><br>
            When enabled, users will be allowed to select particular files from the torrent to download:
            </td>
            <td valign="top">
                <select name="enable_file_priority">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["enable_file_priority"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Max Upload Rate</strong><br>
            Set the default value for the max upload rate per torrent:
            </td>
            <td valign="top">
                <input name="max_upload_rate" type="Text" maxlength="5" value="<?php 
    echo $cfg["max_upload_rate"];
    ?>
" size="5"> KB/second
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Max Download Rate</strong><br>
            Set the default value for the max download rate per torrent (0 for no limit):
            </td>
            <td valign="top">
                <input name="max_download_rate" type="Text" maxlength="5" value="<?php 
    echo $cfg["max_download_rate"];
    ?>
" size="5"> KB/second
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Max Upload Connections</strong><br>
            Set the default value for the max number of upload connections per torrent:
            </td>
            <td valign="top">
                <input name="max_uploads" type="Text" maxlength="5" value="<?php 
    echo $cfg["max_uploads"];
    ?>
" size="5">
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Port Range</strong><br>
            Set the default values for the for port range (Min - Max):
            </td>
            <td valign="top">
                <input name="minport" type="Text" maxlength="5" value="<?php 
    echo $cfg["minport"];
    ?>
" size="5"> -
                <input name="maxport" type="Text" maxlength="5" value="<?php 
    echo $cfg["maxport"];
    ?>
" size="5">
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Rerequest Interval</strong><br>
            Set the default value for the rerequest interval to the tracker (default 1800 seconds):
            </td>
            <td valign="top">
                <input name="rerequest_interval" type="Text" maxlength="5" value="<?php 
    echo $cfg["rerequest_interval"];
    ?>
" size="5">
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Allow encrypted connections</strong><br>
            Check to allow the client to accept encrypted connections.
            </td>
            <td valign="top">
                <select name="crypto_allowed">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["crypto_allowed"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Only allow encrypted connections</strong><br>
            Check to force the client to only create and accept encrypted connections.
            </td>
            <td valign="top">
                <select name="crypto_only">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["crypto_only"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Stealth crypto</strong><br>
	    Prevent all non-encrypted connection attempts.  (Note: will result in an effectively firewalled state on older trackers.)
            <td valign="top">
                <select name="crypto_stealth">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["crypto_stealth"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Extra BitTornado Commandline Options</strong><br>
            DO NOT include --max_upload_rate, --minport, --maxport, --max_uploads, --crypto_allowed, --crypto_only, --crypto_stealth here as they are included by TorrentFlux settings above:
            </td>
            <td valign="top">
                <input name="cmd_options" type="Text" maxlength="254" value="<?php 
    echo $cfg["cmd_options"];
    ?>
" size="55">
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Enable Torrent Search</strong><br>
            When enabled, users will be allowed to perform torrent searches from the home page:
            </td>
            <td valign="top">
                <select name="enable_search">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["enable_search"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Default Torrent Search Engine</strong><br>
            Select the default search engine for torrent searches:
            </td>
            <td valign="top">
<?php 
    echo buildSearchEngineDDL($cfg["searchEngine"]);
    ?>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Enable Make Torrent</strong><br>
            When enabled, users will be allowed make torrent files from the directory view:
            </td>
            <td valign="top">
                <select name="enable_maketorrent">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["enable_maketorrent"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>btmakemetafile.py Path</strong><br>
            Specify the path to the btmakemetafile.py python script (used for making torrents):
            </td>
            <td valign="top">
                <input name="btmakemetafile" type="Text" maxlength="254" value="<?php 
    echo $cfg["btmakemetafile"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["btmakemetafile"]);
    ?>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Enable Torrent File Download</strong><br>
            When enabled, users will be allowed download the torrent meta file from the torrent list view:
            </td>
            <td valign="top">
                <select name="enable_torrent_download">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["enable_torrent_download"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Enable File Download</strong><br>
            When enabled, users will be allowed download from the directory view:
            </td>
            <td valign="top">
                <select name="enable_file_download">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["enable_file_download"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Enable Text/NFO Viewer</strong><br>
            When enabled, users will be allowed to view Text/NFO files from the directory listing:
            </td>
            <td valign="top">
                <select name="enable_view_nfo">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["enable_view_nfo"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Download Package Type</strong><br>
            When File Download is enabled, users will be allowed download from the directory view using
            a packaging system.  Make sure your server supports the package type you select:
            </td>
            <td valign="top">
                <select name="package_type">
                        <option value="tar" selected>tar</option>
                        <option value="zip" <?php 
    if ($cfg["package_type"] == "zip") {
        echo "selected";
    }
    ?>
>zip</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Show Server Load</strong><br>
            Enable showing the average server load over the last 15 minutes from <? echo $cfg["loadavg_path"] ?> file:
            </td>
            <td valign="top">
                <select name="show_server_load">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["show_server_load"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>loadavg Path</strong><br>
            Path to the loadavg file:
            </td>
            <td valign="top">
                <input name="loadavg_path" type="Text" maxlength="254" value="<?php 
    echo $cfg["loadavg_path"];
    ?>
" size="55"><?php 
    echo validateFile($cfg["loadavg_path"]);
    ?>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Days to keep Audit Actions in the Log</strong><br>
            Number of days that audit actions will be held in the database:
            </td>
            <td valign="top">
                <input name="days_to_keep" type="Text" maxlength="3" value="<?php 
    echo $cfg["days_to_keep"];
    ?>
" size="3">
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Minutes to Keep User Online Status</strong><br>
            Number of minutes before a user status changes to offline after leaving TorrentFlux:
            </td>
            <td valign="top">
                <input name="minutes_to_keep" type="Text" maxlength="2" value="<?php 
    echo $cfg["minutes_to_keep"];
    ?>
" size="2">
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Minutes to Cache RSS Feeds</strong><br>
            Number of minutes to cache the RSS XML feed on server (speeds up reload):
            </td>
            <td valign="top">
                <input name="rss_cache_min" type="Text" maxlength="3" value="<?php 
    echo $cfg["rss_cache_min"];
    ?>
" size="3">
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Page Refresh (in seconds)</strong><br>
            Number of seconds before the torrent list page refreshes:
            </td>
            <td valign="top">
                <input name="page_refresh" type="Text" maxlength="3" value="<?php 
    echo $cfg["page_refresh"];
    ?>
" size="3">
            </td>
        </tr>
<?php 
    if (!defined("IMG_JPG")) {
        define("IMG_JPG", 2);
    }
    // Check gd is loaded AND that jpeg image type is supported:
    if (extension_loaded('gd') && imagetypes() & IMG_JPG) {
        ?>
        <tr>
            <td align="left" width="350" valign="top"><strong>Enable Security Code Login</strong><br>
            Requires users to enter a security code from a generated graphic to login (if enabled automated logins will NOT work):
            </td>
            <td valign="top">
                <select name="security_code">
                        <option value="1">true</option>
                        <option value="0" <?php 
        if (!$cfg["security_code"]) {
            echo "selected";
        }
        ?>
>false</option>
                </select>
            </td>
        </tr>
<?php 
    }
    ?>
        <tr>
            <td align="left" width="350" valign="top"><strong>Default Theme</strong><br>
            Select the default theme that users will have (including login screen):
            </td>
            <td valign="top">
                <select name="default_theme">
<?php 
    $arThemes = GetThemes();
    for ($inx = 0; $inx < sizeof($arThemes); $inx++) {
        $selected = "";
        if ($cfg["default_theme"] == $arThemes[$inx]) {
            $selected = "selected";
        }
        echo "<option value=\"" . $arThemes[$inx] . "\" " . $selected . ">" . $arThemes[$inx] . "</option>";
    }
    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Default Language</strong><br>
            Select the default language that users will have:
            </td>
            <td valign="top">
                <select name="default_language">
<?php 
    $arLanguage = GetLanguages();
    for ($inx = 0; $inx < sizeof($arLanguage); $inx++) {
        $selected = "";
        if ($cfg["default_language"] == $arLanguage[$inx]) {
            $selected = "selected";
        }
        echo "<option value=\"" . $arLanguage[$inx] . "\" " . $selected . ">" . GetLanguageFromFile($arLanguage[$inx]) . "</option>";
    }
    ?>
            </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Show SQL Debug Statements</strong><br>
            SQL Errors will always be displayed but when this feature is enabled the SQL Statement
            that caused the error will be displayed as well:
            </td>
            <td valign="top">
                <select name="debug_sql">
                        <option value="1">true</option>
                        <option value="0" <?php 
    if (!$cfg["debug_sql"]) {
        echo "selected";
    }
    ?>
>false</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Default Torrent Completion Activity</strong><br>
            Select whether or not a torrent should keep seeding when download is complete
            (please seed your torrents):
            </td>
            <td valign="top">
                <select name="torrent_dies_when_done">
                        <option value="True">Die When Done</option>
                        <option value="False" <?php 
    if ($cfg["torrent_dies_when_done"] == "False") {
        echo "selected";
    }
    ?>
>Keep Seeding</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="left" width="350" valign="top"><strong>Default Percentage When Seeding should Stop</strong><br>
            Set the default share pecentage where torrents will shutoff
            when running torrents that do not die when done.
            Value '0' will seed forever.
            </td>
            <td valign="top">
                <input name="sharekill" type="Text" maxlength="3" value="<?php 
    echo $cfg["sharekill"];
    ?>
" size="3">%
            </td>
        </tr>
        </table>
        <br>
        <input type="Submit" value="Update Settings">
        </form>
    </div>
    <br>
<?php 
    echo "</td></tr>";
    echo "</table></div>";
    DisplayFoot();
}