Example #1
0
function editUser($user_id)
{
    global $cfg, $db;
    DisplayHead(_USERADMIN);
    $editUserImage = "images/user.gif";
    $selected_n = "selected";
    $selected_a = "";
    $hide_checked = "";
    // Admin Menu
    displayMenu();
    $total_activity = GetActivityCount();
    $sql = "SELECT user_id, hits, last_visit, time_created, user_level, hide_offline, theme, language_file FROM tf_users WHERE user_id=" . $db->qstr($user_id);
    list($user_id, $hits, $last_visit, $time_created, $user_level, $hide_offline, $theme, $language_file) = $db->GetRow($sql);
    $user_type = _NORMALUSER;
    if ($user_level == 1) {
        $user_type = _ADMINISTRATOR;
        $selected_n = "";
        $selected_a = "selected";
        $editUserImage = "images/admin_user.gif";
    }
    if ($user_level >= 2) {
        $user_type = _SUPERADMIN;
        $editUserImage = "images/superadmin.gif";
    }
    if ($hide_offline == 1) {
        $hide_checked = "checked";
    }
    $user_activity = GetActivityCount($user_id);
    if ($user_activity == 0) {
        $user_percent = 0;
    } else {
        $user_percent = number_format($user_activity / $total_activity * 100);
    }
    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 colspan=6 bgcolor=\"" . $cfg["table_header_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\">";
    echo "<img src=\"" . $editUserImage . "\" width=17 height=14 border=0>&nbsp;&nbsp;&nbsp;<font class=\"title\">" . _EDITUSER . ": " . $user_id . "</font>";
    echo "</td></tr><tr><td align=\"center\">";
    ?>

	<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 $user_id . " " . _JOINED;
    ?>
:&nbsp;</td>
			<td><strong><?php 
    echo date(_DATETIMEFORMAT, $time_created);
    ?>
</strong></td>
		</tr>
		<tr>
			<td align="right"><?php 
    echo _LASTVISIT;
    ?>
:&nbsp;</td>
			<td><strong><?php 
    echo date(_DATETIMEFORMAT, $last_visit);
    ?>
</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" valign="top"><?php 
    echo _THEME;
    ?>
:&nbsp;</td>
			<td valign="top"><strong><?php 
    echo $theme;
    ?>
</strong><br></td>
		</tr>
		<tr>
			<td align="right" valign="top"><?php 
    echo _LANGUAGE;
    ?>
:&nbsp;</td>
			<td valign="top"><strong><?php 
    echo GetLanguageFromFile($language_file);
    ?>
</strong><br><br></td>
		</tr>
		<tr>
			<td align="right" valign="top"><?php 
    echo _USERTYPE;
    ?>
:&nbsp;</td>
			<td valign="top"><strong><?php 
    echo $user_type;
    ?>
</strong><br></td>
		</tr>
		<tr>
			<td colspan="2" align="center"><div align="center">[<a href="admin.php?op=showUserActivity&user_id=<?php 
    echo $user_id;
    ?>
"><?php 
    echo _USERSACTIVITY;
    ?>
</a>]</div></td>
		</tr>
		</table>
		</div>

		</td>
		<td valign="top" bgcolor="<?php 
    echo $cfg["body_data_bg"];
    ?>
">
		<div align="center">
		<table cellpadding="5" cellspacing="0" border="0">
		<form name="theForm" action="admin.php?op=updateUser" method="post" onsubmit="return validateUser()">
		<tr>
			<td align="right"><?php 
    echo _USER;
    ?>
:</td>
			<td>
			<input name="user_id" type="Text" value="<?php 
    echo $user_id;
    ?>
" size="15">
			<input name="org_user_id" type="Hidden" value="<?php 
    echo $user_id;
    ?>
">
			</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 _USERTYPE;
    ?>
:</td>
			<td>
<?php 
    if ($user_level <= 1) {
        ?>
			<select name="userType">
				<option value="0" <?php 
        echo $selected_n;
        ?>
><?php 
        echo _NORMALUSER;
        ?>
</option>
				<option value="1" <?php 
        echo $selected_a;
        ?>
><?php 
        echo _ADMINISTRATOR;
        ?>
</option>
			</select>
<?php 
    } else {
        ?>
			<strong><?php 
        echo _SUPERADMIN;
        ?>
</strong>
			<input type="Hidden" name="userType" value="2">
<?php 
    }
    ?>
			</td>
		</tr>
		<tr>
			<td colspan="2">
			<input name="hideOffline" type="Checkbox" value="1" <?php 
    echo $hide_checked;
    ?>
> <?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 validateUser()
	{
		var msg = ""
		if (theForm.user_id.value == "")
		{
			msg = msg + "* <?php 
    echo _USERIDREQUIRED;
    ?>
\n";
			theForm.user_id.focus();
		}

		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>";
    echo "<br><br>";
    // Show User Section
    displayUserSection();
    echo "<br><br>";
    DisplayFoot(true, true);
}
Example #2
0
 $tmpl->setvar('showIndex', 1);
 $hideChecked = "";
 if ($cfg["hide_offline"] == 1) {
     $hideChecked = "checked=\"checked\"";
 }
 $total_activity = GetActivityCount();
 $sql = "SELECT user_id, email_address, hits, last_visit, time_created, user_level FROM tf_users WHERE user_id=" . $db->qstr($cfg["user"]);
 list($user_id, $email_address, $hits, $last_visit, $time_created, $user_level) = $db->GetRow($sql);
 $user_type = $cfg['_NORMALUSER'];
 if ($cfg['isAdmin']) {
     $user_type = $cfg['_ADMINISTRATOR'];
 }
 if (IsSuperAdmin()) {
     $user_type = $cfg['_SUPERADMIN'];
 }
 $user_activity = GetActivityCount($cfg["user"]);
 if ($user_activity == 0) {
     $user_percent = 0;
 } else {
     $user_percent = number_format($user_activity / $total_activity * 100);
 }
 $tmpl->setvar('time_created1', date($cfg['_DATETIMEFORMAT'], $time_created));
 $tmpl->setvar('width1', $user_percent * 2);
 $tmpl->setvar('width2', 200 - $user_percent * 2);
 $tmpl->setvar('user_activity', $user_activity);
 $tmpl->setvar('user_percent', $user_percent);
 $tmpl->setvar('days_to_keep', $cfg["days_to_keep"]);
 $tmpl->setvar('hits', $hits);
 $tmpl->setvar('email_address', $email_address);
 $tmpl->setvar('user_type', $user_type);
 $tmpl->setvar('_UPLOADS', $cfg['_UPLOADS']);
Example #3
0
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();
}
/**
 * sets vars for the user section
 */
function tmplSetUserSection()
{
    global $cfg, $db, $tmpl;
    // xfer-prepare
    $tmpl->setvar('enable_xfer', $cfg["enable_xfer"]);
    if ($cfg['enable_xfer'] == 1) {
        $tmpl->setvar('userSection_colspan', 8);
        // getTransferListArray to update xfer-stats
        // xfer-init
        if ($cfg['xfer_realtime'] == 0) {
            $cfg['xfer_realtime'] = 1;
            // set xfer-newday
            Xfer::setNewday();
        }
        @getTransferListArray();
    } else {
        $tmpl->setvar('userSection_colspan', 7);
    }
    // activity-prepare
    $total_activity = GetActivityCount();
    $sql = "SELECT user_id, hits, last_visit, time_created, user_level, state FROM tf_users ORDER BY user_id";
    $result = $db->Execute($sql);
    if ($db->ErrorNo() != 0) {
        dbError($sql);
    }
    // user-details
    $user_details_list = array();
    while (list($user_id, $hits, $last_visit, $time_created, $user_level, $user_state) = $result->FetchRow()) {
        // disk-usage
        $disk_usage = "0";
        $tDir = $cfg["path"] . $user_id . "/";
        if (is_dir($tDir)) {
            switch ($cfg["_OS"]) {
                case 1:
                    //Linux
                    $dudir = shell_exec($cfg['bin_du'] . " -sk -h -D " . tfb_shellencode($tDir));
                    break;
                case 2:
                    //BSD
                    $dudir = shell_exec($cfg['bin_du'] . " -sk -h -L " . tfb_shellencode($tDir));
                    break;
            }
            $dusize = explode("\t", $dudir);
            $disk_usage = array_shift($dusize);
        }
        // xfer-usage
        $xfer_usage = $cfg['enable_xfer'] == 1 ? Xfer::getUsage($user_id) : 0;
        // activity
        $user_activity = GetActivityCount($user_id);
        $user_percent = $user_activity == 0 ? 0 : number_format($user_activity / $total_activity * 100);
        // online
        $user_icon = "themes/" . $cfg['theme'] . "/images/user_offline.gif";
        if (IsOnline($user_id)) {
            $user_icon = "themes/" . $cfg['theme'] . "/images/user.gif";
        }
        // level
        $user_image = "themes/" . $cfg['theme'] . "/images/user.gif";
        $type_user = $cfg['_NORMALUSER'];
        if ($user_level == 1) {
            $user_image = "themes/" . $cfg['theme'] . "/images/admin_user.gif";
            $type_user = $cfg['_ADMINISTRATOR'];
        }
        if ($user_level == 2) {
            $user_image = "themes/" . $cfg['theme'] . "/images/superadmin.gif";
            $type_user = $cfg['_SUPERADMIN'];
        }
        $is_superadmin = $user_level <= 1 || IsSuperAdmin() ? 1 : 0;
        // add to list
        array_push($user_details_list, array('is_user' => IsUser($user_id), 'user_id' => $user_id, 'user_icon' => $user_icon, 'hits' => $hits, 'disk_usage' => $disk_usage, 'xfer_usage' => $xfer_usage, 'user_percent' => $user_percent, 'user_percent2' => $user_percent * 2, 'user_percent3' => 200 - $user_percent * 2, 'time_created' => date($cfg['_DATEFORMAT'], $time_created), 'last_visit' => date($cfg['_DATETIMEFORMAT'], $last_visit), 'user_image' => $user_image, 'type_user' => $type_user, 'user_level' => $user_level, 'user_state' => $user_state, 'is_superadmin' => $is_superadmin));
    }
    // set vars
    $tmpl->setvar('_USERDETAILS', $cfg['_USERDETAILS']);
    $tmpl->setvar('_USER', $cfg['_USER']);
    $tmpl->setvar('_HITS', $cfg['_HITS']);
    $tmpl->setvar('_UPLOADACTIVITY', $cfg['_UPLOADACTIVITY']);
    $tmpl->setvar('_JOINED', $cfg['_JOINED']);
    $tmpl->setvar('_LASTVISIT', $cfg['_LASTVISIT']);
    $tmpl->setvar('_ADMIN', $cfg['_ADMIN']);
    $tmpl->setvar('_DAYS', $cfg['_DAYS']);
    $tmpl->setvar('_SENDMESSAGETO', $cfg['_SENDMESSAGETO']);
    $tmpl->setvar('_WARNING', $cfg['_WARNING']);
    $tmpl->setvar('_ABOUTTODELETE', $cfg['_ABOUTTODELETE']);
    $tmpl->setvar('_USERSACTIVITY', $cfg['_USERSACTIVITY']);
    $tmpl->setvar('_EDIT', $cfg['_EDIT']);
    $tmpl->setvar('_DELETE', $cfg['_DELETE']);
    $tmpl->setvar('table_admin_border', $cfg["table_admin_border"]);
    $tmpl->setvar('days_to_keep', $cfg["days_to_keep"]);
    $tmpl->setloop('user_details_list', $user_details_list);
}
list($user_id, $hits, $last_visit, $time_created, $user_level, $hide_offline, $theme, $language_file) = $db->GetRow($sql);
$user_type = $cfg['_NORMALUSER'];
if ($user_level == 1) {
    $user_type = $cfg['_ADMINISTRATOR'];
    $selected_n = "";
    $selected_a = "selected";
    $editUserImage = "themes/" . $cfg['theme'] . "/images/admin_user.gif";
}
if ($user_level >= 2) {
    $user_type = $cfg['_SUPERADMIN'];
    $editUserImage = "themes/" . $cfg['theme'] . "/images/superadmin.gif";
}
if ($hide_offline == 1) {
    $hide_checked = "checked";
}
$user_activity = GetActivityCount($user_id);
$user_percent = $user_activity != 0 ? number_format($user_activity / $total_activity * 100) : 0;
$tmpl->setvar('editUserImage', $editUserImage);
$tmpl->setvar('user_id', $user_id);
$tmpl->setvar('time_created', date($cfg['_DATETIMEFORMAT'], $time_created));
$tmpl->setvar('last_visit', date($cfg['_DATETIMEFORMAT'], $last_visit));
$tmpl->setvar('percent1', $user_percent * 2);
$tmpl->setvar('percent2', 200 - $user_percent * 2);
$tmpl->setvar('user_activity', $user_activity);
$tmpl->setvar('user_percent', $user_percent);
$tmpl->setvar('days_to_keep', $cfg["days_to_keep"]);
$tmpl->setvar('hits', $hits);
$tmpl->setvar('language_file', GetLanguageFromFile($language_file));
$tmpl->setvar('user_type', $user_type);
$tmpl->setvar('user_level', $user_level);
$tmpl->setvar('selected_n', $selected_n);
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();
}