<?php
/********************************************************/
/* NSN Your Account                                     */
/* By: NukeScripts Network (webmaster@nukescripts.fr)   */
/* http://www.nukescripts.fr                            */
/* Copyright  2000-2004 by NukeScripts Network         */
/* ==================================================== */
/* Based from:                                          */
/* NSN YAT 320 from www.nukescripts.net                 */
/* Based from:                                          */
/* PHP-NUKE: Web Portal System                          */
/********************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}

function amain() {
    global $module_name, $bgcolor2, $bgcolor1, $textcolor1, $find, $what, $match, $query, $admin_file;
    Max_OpenTable();
    $act = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_USERS."` WHERE `user_level`>'0' AND `user_id`>'1'"));
    $sus = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_USERS."` WHERE `user_level`='0' AND `user_id`>'1'"));
    $del = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_USERS."` WHERE `user_level`='-1' AND `user_id`>'1'"));
    $nor = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_USERS."` WHERE `user_id`>'1'"));
    $pen = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_USERS_TEMP."`"));
    echo "<table align='center' cellpadding='2' cellspacing='2' border='0' width='100%'>\n";
    echo "<tr bgcolor='$bgcolor1'>\n";
    echo "<td align='center' colspan='3'><a href='".$admin_file.".php'><i>Administration</i></a></td>\n";
    echo "</tr>\n";
    echo "<tr bgcolor='$bgcolor1'>\n";
    echo "<td align='center' width='33%'><a href='".$admin_file.".php?op=addUser'>"._ADDUSER."</a></td>\n";
    echo "<td align='center' width='33%'><a href='".$admin_file.".php?op=UsersConfig'>"._USERSCONFIG."</a></td>\n";
    echo "<td align='center' width='33%'><a href='".$admin_file.".php?op=UsersChamps'>"._CHAMPSCONFIG."</a></td>\n";
    echo "</tr>\n";
    echo "<tr bgcolor='$bgcolor1'>";
    echo "<td align='center'><a href='".$admin_file.".php?op=listnormal&amp;query=1'>"._ACTIVEUSERS."</a> ($act)</td>\n";
    echo "<td align='center'><a href='".$admin_file.".php?op=listnormal&amp;query=0'>"._SUSPENDUSERS."</a> ($sus)</td>\n";
    echo "<td align='center'><a href='".$admin_file.".php?op=listnormal&amp;query=-1'>"._DELETEUSERS."</a> ($del)</td>\n";
    echo "</tr>\n";
    echo "<tr bgcolor='$bgcolor1'>\n";
    echo "<td align='center'><a href='".$admin_file.".php?op=listnormal&amp;query=a'>"._NORMALUSERS."</a> ($nor)</td>\n";
    echo "<td align='center'><a href='".$admin_file.".php?op=searchUser'>"._SEARCHUSERS."</a></td>\n";
    echo "<td align='center'><a href='".$admin_file.".php?op=listpending'>"._WAITINGUSERS."</a> ($pen)</td>\n";
    echo "</tr>\n";
    echo "</table>\n";
    Max_CloseTable();
}

function asearch() {
    global $module_name, $bgcolor2, $bgcolor1, $textcolor1, $find, $what, $match, $query, $admin_file;
    Max_OpenTable();
    echo "<table align='center' cellpadding='2' cellspacing='2' border='0' bgcolor='$bgcolor1'>\n";
    echo "<form method='post' action='".$admin_file.".php'>\n";
    echo "<input type='hidden' name='op' value='listresults'>\n";
    echo "<tr>\n";
    echo "<td align='center'><b>"._YA_FIND.":</b></td>\n";
    echo "<td align='center'><b>"._YA_BY.":</b></td>\n";
    echo "<td align='center'><b>"._YA_MATCH.":</b></td>\n";
    echo "<td align='center'><b>"._YA_QUERY.":</b></td>\n";
    echo "</tr>\n<tr>\n";
    if ($find == "tempUser") { $sel1 = ""; $sel2 = " selected"; } else { $sel1 = " selected"; $sel2 = ""; }
    echo "<td align='center'><select name='find'>\n";
    echo "<option value='findUser'$sel1>"._YA_REGLUSER."</option>\n";
    echo "<option value='tempUser'$sel2>"._YA_TEMPUSER."</option>\n";
    echo "</select></td>\n";
    if ($what == "user_email") {
        $sel1 = ""; $sel2 = ""; $sel3 = " selected";
    } elseif ($what == "user_id") {
        $sel1 = ""; $sel2 = " selected"; $sel3 = "";
    } else {
        $sel1 = " selected"; $sel2 = ""; $sel3 = "";
    }
    echo "<td align='center'><select name='what'>\n";
    echo "<option value='username'$sel1>"._USERNAME."</option>\n";
    echo "<option value='user_id'$sel2>"._USERID."</option>\n";
    echo "<option value='user_email'$sel3>"._EMAIL."</option>\n";
    echo "</select></td>\n";
    if ($match == "like") { $sel1 = ""; $sel2 = " selected"; } else { $sel1 = " selected"; $sel2 = ""; }
    echo "<td align='center'><select name='match'>\n";
    echo "<option value='equal'$sel1>"._YA_EQUAL."</option>\n";
    echo "<option value='like'$sel2>"._YA_LIKE."</option>\n";
    echo "</select></td>\n";
    echo "<td align='center'><input type='text' name='query' value='$query' size='30' maxlength='60'></td>\n";
    echo "<td align='center'><input type='submit' value='"._YA_SEARCH."'></td>\n";
    echo "</tr>\n";
    echo "</form>\n";
    echo "</table>\n";
    Max_CloseTable();
}


function yapagenums($op, $totalselected, $perpage, $max, $find, $what, $match, $query) {
    global $module_name, $admin_file;
    $pagesint = ($totalselected / $perpage);
    $pageremainder = ($totalselected % $perpage);
    if ($pageremainder != 0) {
        $pages = ceil($pagesint);
        if ($totalselected < $perpage) { $pageremainder = 0; }
    } else {
        $pages = $pagesint;
    }
    if ($pages != 1 && $pages != 0) {
        $counter = 1;
        $currentpage = ($max / $perpage);
        echo "<table align=\"center\" border=\"0\" cellpadding=\"2\" cellspacing=\"2'\">\n";
        echo "<tr><form action=\"".$admin_file.".php\" method=\"post\">\n";
        echo "<input type='hidden' name='op' value='$op'>\n";
        if ($what > "") { echo "<input type='hidden' name='what' value='$what'>\n"; }
        if ($find > "") { echo "<input type='hidden' name='find' value='$find'>\n"; }
        if ($match > "") { echo "<input type='hidden' name='match' value='$match'>\n"; }
        if ($query > "") { echo "<input type='hidden' name='query' value='$query'>\n"; }
        echo "<td align='center'><b>"._YA_SELECTPAGE.": </b><select name='min'>\n";
        while ($counter <= $pages ) {
            $cpage = $counter;
            $mintemp = ($perpage * $counter) - $perpage;
            echo "<option value='$mintemp'>$counter</option>\n";
            $counter++;
        }
        echo "</select><b> "._YA_OF." $pages "._YA_PAGES."</b> <input type='submit' value='"._YA_GO."'></td>\n</form>\n</tr>\n";
        echo "</table>\n";
    }
}