<?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");
}
global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT title, admins FROM ".TABLE_MODULES." WHERE title='Your_Account'"));
$row2 = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM ".TABLE_AUTHORS." WHERE aid='$aid'"));
$admins = explode(",", $row['admins']);
$auth_user = 0;
for ($i=0; $i < sizeof($admins); $i++) {
    if ($row2['name'] == "$admins[$i]" AND $row['admins'] != "") {
        $auth_user = 1;
    }
}
if ($row2['radminsuper'] == 1 || $auth_user == 1) {

    $pagetitle = ": "._USERADMIN." - "._USERUPDATE;
    incoh();
    title(_USERADMIN." - "._USERUPDATE);
    amain();
    br('1');
    $result = $db->sql_query("select * from ".TABLE_USERS." where user_id='$chng_uid' or username='$chng_uid'");
    if($db->sql_numrows($result) > 0) {
        $chnginfo = $db->sql_fetchrow($result);
        Max_OpenTable();
        echo "<center><table border='0'>\n";
        echo "<form action='".$admin_file.".php' method='post'>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._USERID.":</td><td><b>".$chnginfo['user_id']."</b></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._NICKNAME.":</td><td><input type='text' name='chng_uname' value='".$chnginfo['username']."'><br /><b>"._YA_CHNGRISK."</b></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._NAME.":</td><td><input type='text' name='chng_name' value='".$chnginfo['name']."'></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._URL.":</td><td><input type='text' name='chng_url' value='".$chnginfo['user_website']."' size='30' maxlength='60'></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._EMAIL.":</td><td><input type='text' name='chng_email' value='".$chnginfo['user_email']."' size='30' maxlength='60'> <font class='tiny'>"._REQUIRED."</font></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._FAKEEMAIL.":</td><td><input type='text' name='chng_femail' value='".$chnginfo['femial']."' size='30' maxlength='60'></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._ICQ.":</td><td><input type='text' name='chng_user_icq' value='".$chnginfo['user_icq']."' size='20' maxlength='20'></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._AIM.":</td><td><input type='text' name='chng_user_aim' value='".$chnginfo['user_aim']."' size='20' maxlength='20'></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._YIM.":</td><td><input type='text' name='chng_user_yim' value='".$chnginfo['user_yim']."' size='20' maxlength='20'></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._MSNM.":</td><td><input type='text' name='chng_user_msnm' value='".$chnginfo['user_msnm']."' size='20' maxlength='20'></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._LOCATION.":</td><td><input type='text' name='chng_user_from' value='".$chnginfo['user_from']."' size='25' maxlength='60'></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._OCCUPATION.":</td><td><input type='text' name='chng_user_occ' value='".$chnginfo['user_occ']."' size='25' maxlength='60'></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._INTERESTS.":</td><td><input type='text' name='chng_user_intrest' value='".$chnginfo['user_intrests']."' size='25' maxlength='255'></td></tr>\n";
        if ($chnginfo['user_viewemail'] ==1) { $cuv = "checked"; } else { $cuv = ""; }
        echo "<tr><td bgcolor='$bgcolor2'>"._OPTION.":</td><td><input type='checkbox' name='chng_user_viewemail' value='1' $cuv> "._ALLOWUSERS."</td></tr>\n";
        if ($chnginfo['newsletter'] == 1) { $cnl = "checked"; } else { $cnl = ""; }
        echo "<tr><td bgcolor='$bgcolor2'>"._NEWSLETTER.":</td><td><input type='checkbox' name='chng_newsletter' value='1' $cnl> "._YES."</td></tr>\n";
        $yacontent = "";
        $subnum = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_subscriptions WHERE userid='$chng_uid'"));
        if ($subnum == 0) {
            $yacontent .= "<tr><td bgcolor='$bgcolor2'>"._SUBUSERASK.":</td><td><input type='radio' name='subscription' value='1'> "._YES."&nbsp;&nbsp;&nbsp;<input type='radio' name='subscription' value='0' checked> "._NO."</td></tr>";
            $yacontent .= "<tr><td bgcolor='$bgcolor2'>"._SUBPERIOD.":</td><td><select name='subscription_expire'>";
            $yacontent .= "<option value='0' selected>"._NONE."</option>";
            $yacontent .= "<option value='1'>1 "._YEAR."</option>";
            $yacontent .= "<option value='2'>2 "._YEARS."</option>";
            $yacontent .= "<option value='3'>3 "._YEARS."</option>";
            $yacontent .= "<option value='4'>4 "._YEARS."</option>";
            $yacontent .= "<option value='5'>5 "._YEARS."</option>";
            $yacontent .= "<option value='6'>6 "._YEARS."</option>";
            $yacontent .= "<option value='7'>7 "._YEARS."</option>";
            $yacontent .= "<option value='8'>8 "._YEARS."</option>";
            $yacontent .= "<option value='9'>9 "._YEARS."</option>";
            $yacontent .= "<option value='10'>10 "._YEARS."</option>";
            $yacontent .= "</select><input type='hidden' name='reason' value='0'></td></tr>";
        } elseif ($subnum == 1) {
            $yacontent .= "<tr><td bgcolor='$bgcolor2'>"._UNSUBUSER.":</td><td><input type='radio' name='subscription' value='0'> "._YES."&nbsp;&nbsp;&nbsp;<input type='radio' name='subscription' value='1' checked> "._NO."</td></tr>";
            $yacontent .= "<tr><td bgcolor='$bgcolor2'>"._ADDSUBPERIOD.":</td><td><select name='subscription_expire'>";
            $yacontent .= "<option value='0' selected>"._NONE."</option>";
            $yacontent .= "<option value='1'>1 "._YEAR."</option>";
            $yacontent .= "<option value='2'>2 "._YEARS."</option>";
            $yacontent .= "<option value='3'>3 "._YEARS."</option>";
            $yacontent .= "<option value='4'>4 "._YEARS."</option>";
            $yacontent .= "<option value='5'>5 "._YEARS."</option>";
            $yacontent .= "<option value='6'>6 "._YEARS."</option>";
            $yacontent .= "<option value='7'>7 "._YEARS."</option>";
            $yacontent .= "<option value='8'>8 "._YEARS."</option>";
            $yacontent .= "<option value='9'>9 "._YEARS."</option>";
            $yacontent .= "<option value='10'>10 "._YEARS."</option>";
            $yacontent .= "</select></td></tr>";
            $yacontent .= "<tr><td bgcolor='$bgcolor2'>"._ADMSUBEXPIREIN."</td><td>";
            $row = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_subscriptions WHERE userid='$chng_uid'"));
            $diff = $row['subscription_expire']-time();
            $yearDiff = floor($diff/60/60/24/365);
            $diff -= $yearDiff*60*60*24*365;
            if ($yearDiff < 1) {
                $diff = $row['subscription_expire']-time();
            }
            $daysDiff = floor($diff/60/60/24);
            $diff -= $daysDiff*60*60*24;
            $hrsDiff = floor($diff/60/60);
            $diff -= $hrsDiff*60*60;
            $minsDiff = floor($diff/60);
            $diff -= $minsDiff*60;
            $secsDiff = $diff;
            if ($yearDiff < 1) {
                $rest = "$daysDiff "._SBDAYS.", $hrsDiff "._SBHOURS.", $minsDiff "._SBMINUTES.", $secsDiff "._SBSECONDS."";
            } elseif ($yearDiff == 1) {
                $rest = "$yearDiff "._SBYEAR.", $daysDiff "._SBDAYS.", $hrsDiff "._SBHOURS.", $minsDiff "._SBMINUTES.", $secsDiff "._SBSECONDS."";
            } elseif ($yearDiff > 1) {
                $rest = "$yearDiff "._SBYEARS.", $daysDiff "._SBDAYS.", $hrsDiff "._SBHOURS.", $minsDiff "._SBMINUTES.", $secsDiff "._SBSECONDS."";
            }
            $yacontent .= "<font color='#FF0000'>$rest</font></td></tr>";
            $yacontent .= "<tr><td bgcolor='$bgcolor2' valign='top'>"._SUBREASON."</td><td><textarea name='reason' cols='60' rows='10'></textarea></td></tr>";
        }
        echo "$yacontent";
        echo "<tr><td bgcolor='$bgcolor2' valign='top'>"._SIGNATURE.":</td><td><textarea name='chng_user_sig' rows='6' cols='45'>".$chnginfo['user_sig']."</textarea></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._PASSWORD.":</td><td><input type='password' name='chng_pass' size='12' maxlength='12'></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._RETYPEPASSWD.":</td><td><input type='password' name='chng_pass2' size='12' maxlength='12'> <font class='tiny'>"._FORCHANGES."</font></td></tr>\n";
        echo "<input type='hidden' name='chng_avatar' value='".$chnginfo['chng_avatar']."'>\n";
        echo "<input type='hidden' name='chng_uid' value='$chng_uid'>\n";
        echo "<input type='hidden' name='old_uname' value='".$chnginfo['username']."'>\n";
        echo "<input type='hidden' name='old_email' value='".$chnginfo['user_email']."'>\n";
        echo "<input type='hidden' name='op' value='modifyUserConf'>\n";
        if (isset($query)) { echo "<input type='hidden' name='query' value='$query'>\n"; }
        if (isset($min)) { echo "<input type='hidden' name='min' value='$min'>\n"; }
        if (isset($xop)) { echo "<input type='hidden' name='xop' value='$xop'>\n"; }
        echo "<tr><td align='center' colspan='2'><input type='submit' value='"._SAVECHANGES."'></td></tr>\n";
        echo "</form>\n";
        echo "<form action='".$admin_file.".php' method='post'>\n";
        if (isset($query)) { echo "<input type='hidden' name='query' value='$query'>\n"; }
        if (isset($min)) { echo "<input type='hidden' name='min' value='$min'>\n"; }
        if (isset($xop)) { echo "<input type='hidden' name='op' value='$xop'>\n"; }
        echo "<tr><td align='center' colspan='2'><input type='submit' value='"._CANCEL."'></td></tr>\n";
        echo "</form>\n";
        echo "</table></center>\n";
        Max_CloseTable();
    } else {
        Max_OpenTable();
        echo "<center><b>"._USERNOEXIST."</b></center>\n";
        Max_CloseTable();
    }
    incof();
}