<?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) {


    $stop = "";
    if ($chng_uname != $old_uname) { ya_userCheck($chng_uname); }
    if ($chng_email != $old_email) { ya_mailCheck($chng_email); }
    if ($chng_pass != "" OR $chng_pass2 != "") { ya_passCheck($chng_pass, $chng_pass2); }
    if ($stop == "") {
        if ($chng_pass != "") {
            $cpass = md5($chng_pass);
            $db->sql_query("UPDATE ".TABLE_USERS." SET username='$chng_uname', name='$chng_name', user_email='$chng_email', femail='$chng_femail', user_website='$chng_url', user_icq='$chng_user_icq', user_aim='$chng_user_aim', user_yim='$chng_user_yim', user_msnm='$chng_user_msnm', user_from='$chng_user_from', user_occ='$chng_user_occ', user_interests='$chng_user_intrest', user_viewemail='$chng_user_viewemail', user_avatar='$chng_avatar', user_sig='$chng_user_sig', user_password='$cpass', newsletter='$chng_newsletter' WHERE user_id='$chng_uid'");
        } else {
            $db->sql_query("UPDATE ".TABLE_USERS." SET username='$chng_uname', name='$chng_name', user_email='$chng_email', femail='$chng_femail', user_website='$chng_url', user_icq='$chng_user_icq', user_aim='$chng_user_aim', user_yim='$chng_user_yim', user_msnm='$chng_user_msnm', user_from='$chng_user_from', user_occ='$chng_user_occ', user_interests='$chng_user_intrest', user_viewemail='$chng_user_viewemail', user_avatar='$chng_avatar', user_sig='$chng_user_sig', newsletter='$chng_newsletter' WHERE user_id='$chng_uid'");
        }

        $subnum = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_subscriptions WHERE userid='$chng_uid'"));
        $row = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_subscriptions WHERE userid='$chng_uid'"));
        $row2 = $db->sql_fetchrow($db->sql_query("SELECT username, user_email FROM ".TABLE_USERS." WHERE user_id='$chng_uid'"));
        if ($reason == "") {
            $reason = 0;
        }
        if ($subnum == 1) {
            if ($subscription == 0) {
                $from = "$sitename <$adminmail>";
                $subject = "$sitename "._SUBCANCELLED."";
                if ($reason == "0") {
                    if ($subscription_url != "") {
                        $body = _HELLO." ".$row2['username']."!\r\n\r\n"._SUBCANCEL."\r\n\r\n"._SUBNEEDTOAPPLY." $subscription_url\r\n\r\n"._SUBTHANKSATT."\r\n\r\n$sitename "._TEAM."\r\n$nukeurl";
                    } else {
                        $body = _HELLO." ".$row2['username']."!\r\n\r\n"._SUBCANCEL."\r\n\r\n"._SUBTHANKSATT."\r\n\r\n$sitename "._TEAM."\r\n$nukeurl";
                    }
                } else {
                    if ($subscription_url != "") {
                        $body = _HELLO." ".$row2['username']."!\r\n\r\n"._SUBCANCELREASON."\r\n\r\n$reason\r\n\r\n"._SUBNEEDTOAPPLY." $subscription_url\r\n\r\n"._SUBTHANKSATT."\r\n\r\n$sitename "._TEAM."\r\n$nukeurl";
                    } else {
                        $body = _HELLO." ".$row2['username']."!\r\n\r\n"._SUBCANCELREASON."\r\n\r\n$reason\r\n\r\n"._SUBTHANKSATT."\r\n\r\n$sitename "._TEAM."\r\n$nukeurl";
                    }
                }
                $db->sql_query("DELETE FROM ".$prefix."_subscriptions WHERE userid='$chng_uid'");
                mail($row2[user_email], $subject, $body, "From: $from\nX-Mailer: PHP/" . phpversion());
            } elseif ($subscription == 1) {
                if ($subscription_expire != 0) {
                    $from = "$sitename <$adminmail>";
                    $subject = "$sitename "._SUBUPDATEDSUB."";
                    $body = _HELLO." ".$row2['username']."!\r\n\r\n"._SUBUPDATED." $subscription_expire "._SUBYEARSTOACCOUNT."\r\n\r\n"._SUBTHANKSSUPP."\r\n\r\n$sitename "._TEAM."\r\n$nukeurl";
                    $expire = $subscription_expire*31536000;
                    if ($subnum == 0) {
                        $expire = $expire+time();
                    }
                    $expire = $expire+$row['subscription_expire'];
                    $db->sql_query("UPDATE ".$prefix."_subscriptions SET subscription_expire='$expire' WHERE userid='$chng_uid'");
                    mail($row2['user_email'], $subject, $body, "From: $from\nX-Mailer: PHP/" . phpversion());
                }
            }
        } elseif ($subnum == 0 AND $subscription == 1) {
            if ($subscription_expire != 0) {
                $expire = $subscription_expire*31536000;
                $expire = $expire+time();
                $db->sql_query("INSERT INTO ".$prefix."_subscriptions VALUES (NULL, '$chng_uid', '$expire')");
                $from = "$sitename <$adminmail>";
                $subject = "$sitename "._SUBACTIVATED."";
                $body = _HELLO." ".$row2['username']."!\r\n\r\n"._SUBOPENED." $subscription_expire "._SUBOPENED2."\r\n\r\n"._SUBHOPELIKE."\r\n"._SUBTHANKSSUPP2."\r\n\r\n$sitename "._TEAM."\r\n$nukeurl";
                mail($row2['user_email'], $subject, $body, "From: $from\nX-Mailer: PHP/" . phpversion());
            }
        }

        $pagetitle = ": "._USERADMIN." - "._ACCTMODIFY;
        incoh();
        amain();
        br('1');
        Max_OpenTable();
        echo "<center><table align='center' border='0' cellpadding='2' cellspacing='2'>\n";
        echo "<form action='".$admin_file.".php?op=members' 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'><b>"._ACCTMODIFY."</b></td></tr>\n";
        echo "<tr><td align='center'><input type='submit' value='"._RETURN2."'></td></tr>\n";
        echo "</form>\n";
        echo "</table></center>\n";
        Max_CloseTable();
        incof();
    } else {
        $pagetitle = ": "._USERADMIN;
        incoh();
        title(_USERADMIN);
        amain();
        br('1');
        Max_OpenTable();
        echo "<b>$stop</b>\n";
        Max_CloseTable();
        incof();
        return;
    }
}