Exemple #1
0
function perfom_mail()
{
    global $txt, $x7c, $x7s, $print, $db, $prefix, $x7p;
    $sys_msg = "";
    $body = "";
    include_once "./lib/message.php";
    if (isset($_GET['ok'])) {
        $body = "<div id=\"sysmsg\">Messaggio inviato</div>";
    } elseif (isset($_POST['to']) && isset($_POST['subject']) && isset($_POST['body'])) {
        // Make sure the subject isn't null
        if ($_POST['subject'] == "") {
            $_POST['subject'] = $txt[173];
        }
        // Send the msg
        $_POST['body'] = eregi_replace("\n", "<Br>", $_POST['body']);
        if (!isset($_POST['group'])) {
            $query = $db->DoQuery("SELECT * FROM {$prefix}users WHERE username='******'to']}'");
            $row = $db->Do_Fetch_Row($query);
            if ($row[0] == "") {
                $person_error = true;
            } else {
                $person_error = false;
            }
        } else {
            $person_error = false;
        }
        //Group send
        if (isset($_POST['group'])) {
            if (!checkIfMaster() && !in_array($_POST['to'], $x7p->profile['usergroup'])) {
                $body = "<div id=\"sysmsg\">Non sei autorizzato a inviare a questo gruppo</div>";
                $_POST['msg'] = $_POST['body'];
            } else {
                if (!checkIfMaster() && $_POST['to'] == "all") {
                    $body = "<div id=\"sysmsg\">Non sei autorizzato a inviare a questo gruppo</div>";
                    $_POST['msg'] = $_POST['body'];
                } else {
                    if ($_POST['to'] == "all") {
                        $query = "SELECT username FROM {$prefix}users WHERE sheet_ok = 1";
                    } else {
                        $query = "SELECT username FROM {$prefix}groups WHERE usergroup = '{$_POST['to']}'";
                    }
                    $result = $db->DoQuery($query);
                    //Do the real send
                    while ($row = $db->Do_Fetch_Assoc($result)) {
                        send_offline_msg($row['username'], $_POST['subject'], $_POST['body']);
                    }
                    // Reset values
                    $_POST['subject'] = "";
                    $_POST['to'] = "";
                    $_GET['ok'] = 1;
                    header("Location: index.php?act=mail&ok=1");
                }
            }
        } elseif (count_offline($_POST['to']) >= $x7c->settings['max_offline_msgs'] && $x7c->settings['max_offline_msgs'] != 0) {
            $body = "<div id=\"sysmsg\">" . $txt[184] . "</div>";
            $_POST['msg'] = $_POST['body'];
        } elseif ($person_error) {
            // Person doesn't exist
            $body = "<div id=\"sysmsg\">" . $txt[610] . "</div>";
            $_POST['msg'] = $_POST['body'];
        } else {
            send_offline_msg($_POST['to'], $_POST['subject'], $_POST['body']);
            // Reset values
            $_POST['subject'] = "";
            $_POST['to'] = "";
            $_GET['ok'] = 1;
            header("Location: index.php?act=mail&ok=1");
        }
        if (isset($_POST['msg'])) {
            $_POST['msg'] = eregi_replace("<Br>", "\n", $_POST['msg']);
        }
    } elseif (isset($_POST['delete_group'])) {
        $body = "<div id=\"sysmsg\">Messaggio cancellato</div>";
        foreach ($_POST['delete_group'] as $delete) {
            offline_delete($delete);
        }
    } elseif (isset($_GET['delete'])) {
        $body = "<div id=\"sysmsg\">Messaggio cancellato</div>";
        offline_delete($_GET['delete']);
    } else {
        $body = "";
    }
    $msgs = get_offline_msgs();
    if (isset($_GET['read'])) {
        // Print an individual message
        offline_markasread($_GET['read']);
        $mid = $_GET['read'];
        $author = @$msgs[$mid][1];
        $nb = offline_msg_split(@$msgs[$mid][2]);
        $msgbody = $nb[0];
        $subject = $nb[1];
        $time = $nb[2];
        // Set default values for reply form
        $_POST['to'] = $author;
        $_POST['subject'] = $subject;
        $replybody = $msgbody;
        $replybody = eregi_replace("<br>", "\n", $replybody);
        $_POST['msg'] = " \n\n{$txt['174']}\n\n" . $replybody;
        $fwd = "Fwd: ";
        $rply = "Re: ";
        if (preg_match("/^Re:/", $subject)) {
            $rply = "";
        } elseif (preg_match("/^Fwd: /", $subject)) {
            $fwd = "";
        }
        $body .= "\n\t\t\t\t\t\t<div> \n\t\t\t\t\t\t<table class=\"inside_table\" width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n\t\t\t\t\t\t<Tr>\n\t\t\t\t\t\t\t<td class=\"dark_row\"><B>Mittente:</b> {$author}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<Tr>\n\t\t\t\t\t\t\t<td class=\"dark_row\"><b>Oggetto:</b> {$subject}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<Tr>\n\t\t\t\t\t\t\t<td class=\"dark_row\"><b>Data ricezione:</b> {$time}<hr></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t<div id=\"msg_body\">\n\t\t\t\t\t\t<table class=\"inside_table\" width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n\t\t\t\t\t\t<Tr>\n\t\t\t\t\t\t\t<td class=\"msg_txt\">{$msgbody}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\n\t\t\t\t\t\t<br>\n\t\t\t\t\t\t<div id=\"menu\">\n\t\t\t\t\t\t<a href=\"./index.php?act=mail&delete={$mid}\">[{$txt['175']}]</a>\n\t\t\t\t\t\t<a href=\"index.php?act=mail&write&back={$_GET['read']}&subject={$rply}{$_POST['subject']}&to={$_POST['to']}\">[Rispondi]</a>\n\t\t\t\t\t\t<a href=\"index.php?act=mail&write&back={$_GET['read']}&subject={$fwd}{$_POST['subject']}\">[Inoltra]</a>\n\t\t\t\t\t\n\t\t\t\t\t<Br><Br><div align=\"center\">\n\t\t\t\t\t<div align=\"left\">\n\t\t\t\t\t<a href=\"index.php?act=mail\">[Elenco]</a>\n\t\t\t\t\t</div>\n\t\t\t\t\t\n\t\t\t\t\t</div>";
    } else {
        if (!isset($_GET['write'])) {
            // Display a table of all messages
            //jingjing add here
            $body .= "\n\t\t\t\t\t<script>\n\t\t\t\t\tfunction do_delete_all(){\n\t\t\t\t\t\turl = './index.php?act=mail&delete=_all_';\n\t\t\t\t\t\tif(!confirm('vuoi davvero cancellare tutti i messaggi?'))\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\twindow.location.href=url;\n\t\t\t\t\t}\n\t\t\t\t\tfunction do_delete(){\n\t\t\t\t\t\tdocument.forms['message_form'].submit();\n\t\t\t\t\t}\n\t\t\t\t</script>";
            $body .= "<form action='index.php?act=mail' method='POST' name='message_form'>\n                                        <div id=\"message_tbl\">\n\t\t\t\t\t\t<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"inside_table\">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>&nbsp;</th>\n\t\t\t\t\t\t\t<th>&nbsp;</th>\n\t\t\t\t\t\t\t<th>{$txt['178']}</th>\n\t\t\t\t\t\t\t<th>{$txt['179']}</th>\n\t\t\t\t\t\t\t<th>Data</th>\n\t\t\t\t\t\t</tr>\n\n\t\t\t\t\t\t";
            foreach ($msgs as $id => $val) {
                $mid = $id;
                $author = $val[1];
                $nb = offline_msg_split($val[2]);
                $msgbody = $nb[0];
                $subject = $nb[1];
                $time = $nb[2];
                if ($val[3] == 0) {
                    $img = "<img src=\"{$print->image_path}new_mail.gif\">";
                } else {
                    $img = "<img src=\"{$print->image_path}old_mail.gif\">";
                }
                $body .= "<tr>\n\t\t\t\t\t\t    <td class=\"dark_row\"><input type=\"checkbox\" \n\t\t\t\t\t\t\t\tname=\"delete_group[]\" value=\"{$mid}\"></td>\n\t\t\t\t\t\t\t\t<td class=\"dark_row\">{$img}</td>\n\t\t\t\t\t\t\t\t<td class=\"dark_row\"><a href=\"./index.php?act=mail&read={$mid}\">{$subject}</a></td>\n\t\t\t\t\t\t\t\t<td class=\"dark_row\">{$author}</td>\n\t\t\t\t\t\t\t\t<td class=\"dark_row\">{$time}</td>\n\t\t\t\t\t\t\t\t</tr>";
            }
            $body .= "</table>\n\t\t\t\t\t</div>";
            // Display Inbox totals
            if ($x7c->settings['max_offline_msgs'] != 0) {
                $number = count_offline($x7s->username);
                $percentage = $number / $x7c->settings['max_offline_msgs'] * 100;
                $percentage .= "%";
                $number = $x7c->settings['max_offline_msgs'] - $number;
                $txt[185] = eregi_replace("_p", $percentage, $txt[185]);
                $txt[185] = eregi_replace("_n", "{$number}", $txt[185]);
                $body .= "<Br><br>{$txt['185']}";
            }
            $body .= '<div id="menu"><a href="./index.php?act=mail&write">[Scrivi]</a>';
            if (checkIfMaster() || $x7s->user_group != $x7c->settings['usergroup_default']) {
                $body .= '<a href="./index.php?act=mail&write&group">[Mail di gruppo]</a>';
            } else {
                $body .= '[Mail di gruppo]';
            }
            $body .= "<a href='#' onClick=\"do_delete()\">[Cancella]</a>";
            $body .= '<a href="#" onClick="do_delete_all()">[Cancella tutti]</a>';
            $body .= "\n</div>";
            $body .= "</form>";
        }
    }
    // DO send form
    if (isset($_GET['write'])) {
        // These three isset() things are checking for default field values
        if (!isset($_GET['subject'])) {
            $_GET['subject'] = "";
        }
        if (!isset($_GET['to'])) {
            $_GET['to'] = "";
        }
        if (!isset($_POST['msg'])) {
            $_POST['msg'] = "";
        }
        $back = '';
        $replybody = '';
        if (isset($_GET['back'])) {
            $back = "&read=" . $_GET['back'];
            $nb = offline_msg_split(@$msgs[$_GET['back']][2]);
            $msgbody = $nb[0];
            $subject = $nb[1];
            $replybody = $msgbody;
            $replybody = eregi_replace("<br>", "\n", $replybody);
            $replybody = " \n\n{$txt['174']}\n\n" . $replybody;
        }
        $to = "<p style=\"text-align: center\">\n\t\t\t\t\t<input type=\"hidden\" name=\"act\" value=\"mail\">\n\t\t\t\t\t{$txt['182']}: \n\t\t\t\t\t<br><input class=\"wickEnabled\" type=\"text\" name=\"to\" autocomplete=\"off\" value=\"{$_GET['to']}\">\n\t\t\t\t\t<br>";
        if (isset($_GET['group'])) {
            $elenco = '';
            if (checkIfMaster()) {
                $elenco = '<option value="all">Tutti</option>';
                $query = "SELECT DISTINCT usergroup FROM {$prefix}groups";
                $result = $db->DoQuery($query);
                while ($row = $db->Do_Fetch_Assoc($result)) {
                    $elenco .= "<option value=\"{$row['usergroup']}\"> {$row['usergroup']} </option>\n";
                }
            } else {
                if ($x7s->user_group != '' && $x7s->user_group != $x7c->settings['usergroup_default']) {
                    $elenco .= "<option value=\"{$x7s->user_group}\"> {$x7s->user_group} </option>\n";
                }
            }
            $to = "<p style=\"text-align: center\">\n\t\t\t\t\t<input type=\"hidden\" name=\"act\" value=\"mail\">\n\t\t\t\t\t<input type=\"hidden\" name=\"group\">\n\t\t\t\t\t{$txt['182']}: \n\t\t\t\t\t<br><select class=\"text_input\" name=\"to\" style=\"background: white;\">\n\t\t\t\t\t\t{$elenco}\t\n\t\t\t\t\t</select>\n\t\t\t\t\t<br>";
        }
        $accounts = '';
        $query = "SELECT username FROM {$prefix}users WHERE sheet_ok = 1";
        $result = $db->DoQuery($query);
        while ($row = $db->Do_Fetch_Assoc($result)) {
            $accounts .= "'{$row['username']}',";
        }
        $accounts .= "''";
        $body .= "\n\t\t\t\t\t<script type=\"text/javascript\" language=\"JavaScript\">\n\t\t\t\t\tcollection =\n\t\t\t\t\t[" . $accounts . "\n\t\t\t\t\t];\n\t\t\t\t\t</script>\n\t\t\t\t\t<script type=\"text/javascript\" language=\"JavaScript\" src=\"./lib/wick.js\"></script>\n\t\t\t\t\t\n\t\t\t\t\t<div align=\"center\">\n\t\t\t\t\t<form action=\"./index.php?act=mail\" method=\"post\">\n\t\t\t\t\t\n\t\t\t\t\t{$to}\n\t\t\t\t\t\n\t\t\t\t\t{$txt['183']}: \n\t\t\t\t\t<br><input class=\"text_input\" type=\"text\" name=\"subject\" value=\"{$_GET['subject']}\">\n\t\t\t\t\t</p>\n\t\t\t\t\t\n\t\t\t\t\t<textarea htmlconv=yes name=\"body\" class=\"text_input\" cols=\"40\" rows=\"15\">{$replybody}</textarea><Br>\n\t\t\t\t\t<input type=\"submit\" value=\"{$txt['181']}\" class=\"button\">\n\t\t\t\t\t</form></div>\n\t\t\t\t\t<p style=\"text-align: center\">\n\t\t\t\t\t<a href=\"./index.php?act=mail\">[Elenco]</a>\n\t\t\t\t\t</p>\n\t\t\t\t\t";
    }
    return $body;
}
Exemple #2
0
function udpate_unread()
{
    global $print, $x7s, $x7c, $db, $prefix, $x7p;
    $query = $db->DoQuery("SELECT last_board_id FROM {$prefix}users WHERE username='******'");
    $row = $db->Do_Fetch_Assoc($query);
    $last_read = $row['last_board_id'];
    //We create the list of new messages
    $query = $db->DoQuery("SELECT msg.id, user_group FROM {$prefix}boardmsg msg, {$prefix}boards brd\n \t\t\t\t\tWHERE msg.board=brd.id\n \t\t\t\t\tAND msg.id>'{$last_read}' AND user<>'{$x7s->username}'");
    $lastid = 0;
    while ($new_msg = $db->Do_Fetch_Assoc($query)) {
        //We consider only groups which we belong to and the default user group
        //Master must be updated on alle messages
        if (in_array($new_msg['user_group'], $x7p->profile['usergroup']) || $new_msg['user_group'] == $x7p->profile['base_group'] || $new_msg['user_group'] == '_all_' || checkIfMaster()) {
            if ($lastid < $new_msg['id']) {
                $lastid = $new_msg['id'];
            }
            $db->DoQuery("INSERT INTO {$prefix}boardunread (id, user)\n\t\t\t\t\t\tVALUES('{$new_msg['id']}','{$x7s->username}')\n\t\t\t\t\t\tON DUPLICATE KEY UPDATE user=user");
        }
    }
    $db->DoQuery("UPDATE {$prefix}users SET last_board_id=(SELECT MAX(id) FROM {$prefix}boardmsg) WHERE username='******'");
}
Exemple #3
0
function build_ability_javascript($max_ab)
{
    $body = '';
    if (!checkIfMaster()) {
        $body .= '	<script language="javascript" type="text/javascript">
								
								' . ability_script($max_ab) . '
								
								function do_form_refresh(ab_name){
									document.sheet_form[ab_name+"_display"].value = document.sheet_form[ab_name].value;
									document.sheet_form["xp_display"].value = document.sheet_form["xp"].value;
								}';
    } else {
        $body .= '	<script language="javascript" type="text/javascript">
								function add(ab_name){
									var value = parseInt(document.sheet_form[ab_name].value);
									
									document.sheet_form[ab_name].value = value + 1;
										
									do_form_refresh(ab_name);
								}								
								
								
								function sub(ab_name){
									var value = parseInt(document.sheet_form[ab_name].value);
									
									document.sheet_form[ab_name].value = value - 1;
									
									do_form_refresh(ab_name);
									
									
								}
								
								function do_form_refresh(ab_name){
									document.sheet_form[ab_name+"_display"].value = document.sheet_form[ab_name].value;
								}';
    }
    $body .= '
								function modify(){
								        if(document.getElementById("visual"))
									       document.getElementById("visual").style.visibility="hidden";
                                                                        if(document.getElementById("visual2"))
                                                                              document.getElementById("visual2").style.visibility="hidden";
									if(document.getElementById("modifiable"))
									       document.getElementById("modifiable").style.visibility="visible";
									if(document.getElementById("modifiable2"))
									       document.getElementById("modifiable2").style.visibility="visible";
									if(document.getElementById("modifiable3"))
									       document.getElementById("modifiable3").style.visibility="visible";
                                    if(document.getElementById("modify"))
									       document.getElementById("modify").style.visibility="hidden";
									if(document.getElementById("modify2"))
									       document.getElementById("modify2").style.visibility="hidden";
                                                                        if(document.getElementById("modify3"))
									       document.getElementById("modify3").style.visibility="hidden";
									if(document.getElementById("aggiorna"))
									       document.getElementById("aggiorna").style.visibility="visible";
								}
	
						</script>';
    return $body;
}
Exemple #4
0
function sheet_page_main()
{
    global $db, $x7c, $prefix, $x7s, $print, $auth_pcookie, $X7CHAT_CONFIG;
    $pg = $_GET['pg'];
    $head = "Scheda del personaggio";
    $body = "";
    $errore = "";
    $ok = true;
    $reload = false;
    $char;
    $query_usr = $db->DoQuery("SELECT * FROM {$prefix}users WHERE username='******'");
    $row_user = $db->Do_Fetch_Assoc($query_usr);
    if (!$row_user) {
        die("User not in Database");
    }
    if (isset($_GET['daily_px']) && checkIfMaster()) {
        $time = time();
        $day = date("j/n/Y", $row_user['daily_px']);
        if ($row_user['daily_px'] < $time && $day != date("j/n/Y", $time)) {
            $db->DoQuery("UPDATE {$prefix}users SET xp=xp+1, daily_px='{$time}' WHERE username='******'");
            $errore = "PX Giornaliero assegnato correttamente";
            $reload = true;
        } else {
            $errore = "PX gironaliero gia' assegnato";
        }
    }
    if (isset($_GET['toggle_death']) && isset($_GET['pg']) && checkIfMaster()) {
        $pg = $_GET['pg'];
        include_once './lib/sheet_lib.php';
        $resurgo = true;
        if (isset($_GET['permanent_death'])) {
            $resurgo = false;
        }
        $errore = toggle_death($pg, $_GET['toggle_death'], $resurgo);
        $reload = true;
    }
    if (isset($_GET['toggle_heal']) && isset($_GET['pg']) && checkIfMaster()) {
        $pg = $_GET['pg'];
        include_once './lib/sheet_lib.php';
        $errore = toggle_heal($pg, $_GET['toggle_heal']);
        $reload = true;
    }
    if (isset($_GET['settings_change']) && checkIfMaster()) {
        //We are modifiyng character sheet
        if (isset($_POST['name']) && isset($_POST['age']) && isset($_POST['hobbies']) && isset($_POST['nat']) && isset($_POST['marr']) && isset($_POST['gender']) && isset($_POST['avatar_in']) && isset($_POST['spazio']) && isset($_POST['lvl'])) {
            if ($_POST['name'] == '') {
                $ok = false;
                $errore .= "Non hai specificato il nome<br>";
            }
            if (($_POST['age'] == '' || $_POST['age'] < 16) && !checkIfMaster()) {
                $ok = false;
                $errore .= "Et&agrave; non valida<br>";
            }
            if ($_POST['nat'] == '') {
                $ok = false;
                $errore .= "Non hai specificato la nazionalit&agrave;<br>";
            }
        } else {
            $ok = false;
            $errore .= "Parametri mancanti<br>";
        }
        $query = $db->DoQuery("SELECT * FROM {$prefix}characteristic ORDER BY name");
        $char = '';
        while ($row = $db->Do_Fetch_Assoc($query)) {
            $char[$row['id']] = $row;
        }
        if ($ok) {
            $reload = true;
            //Ora posso aggiornare
            if ($pg != $x7s->username) {
                include_once './lib/alarms.php';
                sheet_modification($pg, $_GET['page']);
            }
            $db->DoQuery("UPDATE {$prefix}users SET\n\t\t\t\t\tname='{$_POST['name']}',\n\t\t\t\t\tage='{$_POST['age']}',\n\t\t\t\t\tnat='{$_POST['nat']}',\n\t\t\t\t\tmarr='{$_POST['marr']}',\n\t\t\t\t\thobbies='{$_POST['hobbies']}',\n\t\t\t\t\tgender='{$_POST['gender']}',\n\t\t\t\t\tavatar='{$_POST['avatar_in']}',\n\t\t\t\t\tlvl='{$_POST['lvl']}'\n\t\t\t\t\tWHERE username='******'");
            if (isset($_POST['pwd1']) && isset($_POST['pwd2']) && $_POST['pwd1'] != '' && $_POST['pwd2'] != '') {
                if ($_POST['pwd1'] != $_POST['pwd2']) {
                    $errore .= "Non hai digitato correttamente la password";
                } else {
                    $errore .= "Password cambiata";
                    $newpwd = md5($_POST['pwd1']);
                    if ($pg == $x7s->username) {
                        setcookie($auth_pcookie, $newpwd, time() + $x7c->settings['cookie_time'], $X7CHAT_CONFIG['COOKIE_PATH']);
                    }
                    $db->DoQuery("UPDATE {$prefix}users SET\n\t\t\t\t\t\t\tpassword='******'\n\t\t\t\t\t\t\tWHERE username='******'");
                }
            }
            if (isset($_POST['info'])) {
                if (is_numeric($_POST['info'])) {
                    if ($_POST['info'] != $row_user['info']) {
                        $time = time();
                        $db->DoQuery("UPDATE {$prefix}users\n\t\t\t\t\t\t\t\tSET info='{$_POST['info']}',\n\t\t\t\t\t\t\t\theal_time='{$time}'\n\t\t\t\t\t\t\t\tWHERE username='******'");
                    }
                } else {
                    $errore .= "Il campo \"Status\" puo' contenere solo numeri";
                }
            }
            if (isset($_POST['xp'])) {
                $db->DoQuery("UPDATE {$prefix}users SET\txp='{$_POST['xp']}'\tWHERE username='******'");
            }
            $spazio_query = $db->DoQuery("SELECT spazio FROM {$prefix}users\n\t\t\t\t\tWHERE username='******'");
            if ($row = $db->Do_Fetch_Assoc($spazio_query)) {
                if ($row['spazio'] != $_POST['spazio']) {
                    $db->DoQuery("UPDATE {$prefix}users\n\t\t\t\t\t\t\t\t\tSET sheet_ok='1', spazio = '{$_POST['spazio']}'\n\t\t\t\t\t\t\t\t\tWHERE username='******'");
                    $db->DoQuery("UPDATE {$prefix}objects \n\t\t\t\t\t\t\tSET equipped='0'\n\t\t\t\t\t\t\tWHERE owner='{$pg}'");
                }
            }
            foreach ($char as $cur) {
                if (!isset($_POST[$cur['id']])) {
                    $ok = false;
                    break;
                }
                $db->DoQuery("UPDATE {$prefix}usercharact\n\t\t\t\t\t\tSET value='{$_POST[$cur['id']]}'\n\t\t\t\t\t\tWHERE username='******'\n\t\t\t\t\t\tAND charact_id='{$cur['id']}'");
            }
        }
    } else {
        if (isset($_GET['settings_change']) && !checkIfMaster() && $x7s->username == $pg) {
            if (isset($_POST['avatar_in'])) {
                $db->DoQuery("UPDATE {$prefix}users SET\n\t\t\t\t\tavatar='{$_POST['avatar_in']}'\n\t\t\t\t\tWHERE username='******'");
                $reload = true;
            }
            if (isset($_POST['pwd1']) && isset($_POST['pwd2']) && $_POST['pwd1'] != '' && $_POST['pwd2'] != '') {
                if ($_POST['pwd1'] != $_POST['pwd2']) {
                    $errore .= "Non hai digitato correttamente la password";
                } else {
                    $errore .= "Password cambiata";
                    $newpwd = md5($_POST['pwd1']);
                    setcookie($auth_pcookie, $newpwd, time() + $x7c->settings['cookie_time'], $X7CHAT_CONFIG['COOKIE_PATH']);
                    $db->DoQuery("UPDATE {$prefix}users SET\n\t\t\t\t\t\tpassword='******'\n\t\t\t\t\t\tWHERE username='******'");
                    $reload = true;
                }
            }
        }
    }
    if ($reload) {
        $query_usr = $db->DoQuery("SELECT * FROM {$prefix}users WHERE username='******'");
        $row_user = $db->Do_Fetch_Assoc($query_usr);
        if (!$row_user) {
            die("User not in Database");
        }
    }
    $gender = $row_user['gender'] == 0 ? "M" : "F";
    $group = $row_user['base_group'];
    $date = date("j/n/Y", $row_user['iscr']);
    if (checkIfMaster()) {
        $body .= '		<script language="javascript" type="text/javascript">
			mod=false;

		function modify(){
			if(!mod){
				mod=true;
				document.forms[0].elements["name"].style.color="blue";
				document.forms[0].elements["age"].style.color="blue";
				document.forms[0].elements["nat"].style.color="blue";
				document.forms[0].elements["marr"].style.color="blue";
				document.forms[0].elements["gender"].style.color="blue";
				document.forms[0].elements["avatar_in"].style.color="blue";
				document.forms[0].elements["spazio"].style.color="blue";

				document.forms[0].elements["name"].style.border="1px solid";
				document.forms[0].elements["age"].style.border="1px solid";
				document.forms[0].elements["nat"].style.border="1px solid";
				document.forms[0].elements["marr"].style.border="1px solid";
				document.forms[0].elements["gender"].style.border="1px solid";
				document.forms[0].elements["avatar_in"].style.border="1px solid";
				document.forms[0].elements["spazio"].style.border="1px solid";

				document.forms[0].elements["name"].style.background="white";
				document.forms[0].elements["age"].style.background="white";
				document.forms[0].elements["nat"].style.background="white";
				document.forms[0].elements["marr"].style.background="white";
				document.forms[0].elements["gender"].style.background="white";
				document.forms[0].elements["avatar_in"].style.background="white";
				document.forms[0].elements["spazio"].style.background="white";

				document.forms[0].elements["name"].disabled=false;
				document.forms[0].elements["age"].disabled=false;
				document.forms[0].elements["nat"].disabled=false;
				document.forms[0].elements["marr"].disabled=false;
				document.forms[0].elements["avatar_in"].disabled=false;
				document.forms[0].elements["gender"].disabled=false;
				document.forms[0].elements["marr"].disabled=false;

				document.forms[0].elements["avatar_in"].style.visibility="visible";
				document.forms[0].elements["spazio"].style.visibility="visible";
				document.forms[0].elements["aggiorna"].style.visibility="visible";
				document.forms[0].elements["mod_button"].style.visibility="hidden";

				document.forms[0].elements["pwd1"].style.color="blue";
				document.forms[0].elements["pwd1"].style.border="1px solid";
				document.forms[0].elements["pwd1"].style.background="white";
				document.forms[0].elements["pwd1"].disabled=false;
				document.forms[0].elements["pwd1"].style.visibility="visible";

				document.forms[0].elements["pwd2"].style.color="blue";
				document.forms[0].elements["pwd2"].style.border="1px solid";
				document.forms[0].elements["pwd2"].style.background="white";
				document.forms[0].elements["pwd2"].disabled=false;
				document.forms[0].elements["pwd2"].style.visibility="visible";

				document.getElementById("visual_modify").style.visibility="visible";
				document.getElementById("pwd1").style.visibility="visible";
				document.getElementById("pwd2").style.visibility="visible";


				document.getElementById("avatar").innerHTML="<br><br><br>Specifica l\'URL del tuo avatar nel campo qui sopra";

				document.forms[0].elements["info"].style.color="blue";
				document.forms[0].elements["info"].style.border="1px solid";
				document.forms[0].elements["info"].style.background="white";
				document.forms[0].elements["info"].disabled=false;

				document.forms[0].elements["hobbies"].style.color="blue";
				document.forms[0].elements["hobbies"].style.border="1px solid";
				document.forms[0].elements["hobbies"].style.background="white";
				document.forms[0].elements["hobbies"].disabled=false;

				document.forms[0].elements["xp"].style.color="blue";
				document.forms[0].elements["xp"].style.background="white";
				document.forms[0].elements["xp"].disabled=false;
				
				document.forms[0].elements["lvl"].style.color="blue";
				document.forms[0].elements["lvl"].style.background="white";
				document.forms[0].elements["lvl"].disabled=false;
			}
		}

		</script>';
    }
    $body .= "\n\t\t<div class=\"indiv\" id=\"login\"><a class=\"dark_link\" onClick=\"javascript: hndl = window.open('index.php?act=mail&write&to={$row_user['username']}','MsgCenter','location=no,menubar=no,resizable=no,status=no,toolbar=no,scrollbars=yes,width=488,height=650'); hndl.focus();\">{$row_user['username']}</a></div>\n\t\t<div class=\"indiv\" id=\"group\">{$group}</div>\n\t\t<div class=\"indiv\" id=\"date\">{$date}</div>\n\t\t<div class=\"indiv\" id=\"lvl\">{$row_user['lvl']}</div>\n\t\t<div class=\"indiv\" id=\"avatar\"><a class=\"dark_link\" onClick=\"javascript: hndl = window.open('index.php?act=mail&write&to={$row_user['username']}','MsgCenter','location=no,menubar=no,resizable=no,status=no,toolbar=no,scrollbars=yes,width=488,height=650'); hndl.focus();\">\n\t\t";
    // Check if the user is in hunt mode.
    $query = $db->DoQuery("SELECT r.hunt AS hunt FROM {$prefix}rooms r,\n\t\t\t{$prefix}online o\n\t\t\tWHERE r.name = o.room AND o.name = '{$pg}'");
    $is_hunt = 0;
    if ($row_hunt = $db->Do_Fetch_Assoc($query)) {
        $is_hunt = $row_hunt['hunt'];
    }
    if ($is_hunt) {
        $body .= "<img src=\"{$row_user['hunt_avatar']}\" width=200 height=200 />";
    } elseif ($row_user['avatar'] != '') {
        $body .= "<img src=\"{$row_user['avatar']}\" width=200 height=200 />";
    } else {
        $body .= "<img src=\"{$x7c->settings['default_avatar']}\" width=200 height=200 />";
    }
    $body .= '</a></div>';
    $body .= "\n\t\t<div class=\"indiv\" id=\"status\">{$row_user['info']}</div>\n\t\t<div class=\"indiv\" id=\"real_status\">{$row_user['hobbies']}</div>\n\t\t<div class=\"indiv\" id=\"xp_point\">{$row_user['xp']}</div>\n\t\t";
    $query_char = $db->DoQuery("SELECT uc.value AS value, c.name AS name, c.id AS id\n\t\t\tFROM \t{$prefix}usercharact uc,\n\t\t\t{$prefix}characteristic c\n\t\t\tWHERE\tc.id=uc.charact_id\n\t\t\tAND \tuc.username='******'");
    while ($row_ch = $db->Do_Fetch_Assoc($query_char)) {
        $charact[$row_ch['id']] = $row_ch;
    }
    //Auto heal_button
    $rob = $charact['rob']['value'];
    if ($row_user['autoheal'] && $row_user['info'] != "Morto" && $row_user['info'] < $rob * 2) {
        $time = time();
        $elapsed = $time - $row_user['heal_time'];
        $rec_rate = (13 - $rob) * 3600 * 24;
        $rec_value = floor($elapsed / $rec_rate);
        if ($rec_value > 0) {
            $new_status = $row_user['info'] + $rec_value;
            $new_status = $new_status > $rob * 2 ? $rob * 2 : $new_status;
            $db->DoQuery("UPDATE {$prefix}users SET heal_time='{$time}', info='{$new_status}' WHERE username='******'");
            $row_user['info'] = $new_status;
        }
    }
    $ability = '';
    $body .= "<div class=\"indiv\" id=\"name\">{$row_user['name']}</div>\n\t\t<div class=\"indiv\" id=\"age\">{$row_user['age']}</div>\n\t\t<div class=\"indiv\" id=\"nat\">{$row_user['nat']}</div>\n\t\t<div class=\"indiv\" id=\"marr\">{$row_user['marr']}</div>\n\t\t<div class=\"indiv\" id=\"gender\">{$gender}</div>\n\t\t";
    foreach ($charact as $cur_ch) {
        $body .= "<div id=\"" . $cur_ch['name'] . "\">" . $cur_ch['value'] . "</div>\n";
    }
    if (checkIfMaster()) {
        foreach ($charact as $cur_ch) {
            $body .= "<div id=\"" . $cur_ch['name'] . "\">" . $cur_ch['value'] . "</div>\n";
        }
        //Modified script for master modification that can everything
        $body .= '
			<script language="javascript" type="text/javascript">
			function add_ch(ch_name){
				var value = parseInt(document.sheet_form[ch_name].value) + 1;
				document.sheet_form[ch_name].value = value;

				do_ch_form_refresh(ch_name);

				if(ch_name == "for") {
					document.sheet_form["spazio"].value = (value - 3) * 2;
				}
			}

		function sub_ch(ch_name){
			var value = parseInt(document.sheet_form[ch_name].value) - 1;
			document.sheet_form[ch_name].value = value;

			do_ch_form_refresh(ch_name);

			if(ch_name == "for") {
				document.sheet_form["spazio"].value = (value - 3) * 2;
			}
		}

		function do_ch_form_refresh(ch_name){
			document.sheet_form[ch_name+"_display"].value = document.sheet_form[ch_name].value;
			modify();
		}

		</script>';
        $body .= '<form action="index.php?act=sheet&settings_change=1&pg=' . $pg . '" method="post" name="sheet_form">
			<div id="visual_modify">';
        $ch = $x7c->settings['starting_ch'] - $x7c->settings['min_ch'] * sizeof($charact);
        foreach ($charact as $cur_ch) {
            $ch -= $cur_ch['value'] - $x7c->settings['min_ch'];
            $body .= "\n\t\t\t\t<div id=\"{$cur_ch['name']}\">\n\t\t\t\t<input class=\"button\" type=\"button\" value=\"-\" onMouseDown=\"return sub_ch('{$cur_ch['id']}');\">\n\t\t\t\t<input type=\"text\" name=\"{$cur_ch['id']}_display\" value=\"{$cur_ch['value']}\" size=\"2\" style=\"text-align: right; color: blue;\" disabled/>\n\t\t\t\t<input type=\"hidden\" name=\"{$cur_ch['id']}\" value=\"{$cur_ch['value']}\"/>\n\t\t\t\t<input class=\"button\" type=\"button\" value=\"+\" onMouseDown=\"return add_ch('{$cur_ch['id']}');\"></div>\n";
        }
        if ($gender == "M") {
            $male = "selected";
            $female = "";
            if ($row_user['marr'] == "Libero") {
                $marr_opt = "<option value=\"Libero\" selected>Libero</option>\n\t\t\t\t\t<option value=\"Sposato\">Sposato</option>";
            } else {
                $marr_opt = "<option value=\"Libero\">Libero</option>\n\t\t\t\t\t<option value=\"Sposato\" selected>Sposato</option>";
            }
        } else {
            $male = "";
            $female = "selected";
            if ($row_user['marr'] == "Libera") {
                $marr_opt = "<option value=\"Libera\" selected>Libera</option>\n\t\t\t\t\t<option value=\"Sposata\">Sposata</option>";
            } else {
                $marr_opt = "<option value=\"Libera\">Libera</option>\n\t\t\t\t\t<option value=\"Sposata\" selected>Sposata</option>";
            }
        }
        $body .= "<div class=\"indiv\" id=\"pwd1\" style=\"visibility: hidden;\">Nuova password:<br><input class=\"sheet_input\" type=\"password\" name=\"pwd1\" size=\"10\" style=\"visibility: hidden; font-size:10pt;\" disabled /></div>\n";
        $body .= "<div class=\"indiv\" id=\"pwd2\" style=\"visibility: hidden;\">Ripeti nuova password:<br><input class=\"sheet_input\" type=\"password\" name=\"pwd2\" size=\"10\" style=\"visibility: hidden; font-size:10pt;\" disabled /></div>\n";
        $body .= "\n\t\t\t<div class=\"indiv\" id=\"name\"><input class=\"sheet_input\" type=\"text\" name=\"name\" value=\"{$row_user['name']}\" size=\"16\" disabled /></div>\n\t\t\t<div class=\"indiv\" id=\"age\"><input class=\"sheet_input\" type=\"text\" name=\"age\" value=\"{$row_user['age']}\" size=\"2\" style=\"text-align: right;\" disabled /></div>\n\t\t\t<div class=\"indiv\" id=\"nat\"><input class=\"sheet_input\" type=\"text\" name=\"nat\" value=\"{$row_user['nat']}\" size=\"16\" disabled /></div>\n\t\t\t<div class=\"indiv\" id=\"marr\">\n\t\t\t<select class=\"button\" name=\"marr\" disabled>\n\t\t\t{$marr_opt}\n\t\t\t</select>\n\t\t\t</div>\n\t\t\t<div class=\"indiv\" id=\"gender\">\n\t\t\t<select class=\"button\" name=\"gender\" disabled>\n\t\t\t<option value=\"0\" {$male}>M</option>\n\t\t\t<option value=\"1\" {$female}>F</option>\n\t\t\t</select>\n\t\t\t</div>\n\t\t\t<div class=\"indiv\" id=\"avatar\"><input class=\"sheet_input\" type=\"text\" name=\"avatar_in\" value=\"{$row_user['avatar']}\" size=\"10\" style=\"visibility: hidden; font-size:10pt;\" disabled /></div>\n\t\t\t<div class=\"indiv\" id=\"spazio_main\">Spazio:<input class=\"sheet_input\" type=\"text\" name=\"spazio\" value=\"{$row_user['spazio']}\" size=\"2\" style=\"visibility: hidden; font-size:10pt;\" /></div>\n\t\t\t";
        $time = time();
        $day = date("j/n/Y", $row_user['daily_px']);
        $extra = '';
        if (checkIfMaster() && $row_user['daily_px'] < $time && $day != date("j/n/Y", $time)) {
            $extra = "<INPUT name=\"daily_px\" class=\"button\" type=\"button\" value=\"PX Giornaliero\" onClick=\"javascript: window.location.href='index.php?act=sheet&page=main&daily_px=1&pg={$pg}';\" style=\"visibility: visible;\">";
        }
        $body .= "\n\t\t\t<div class=\"indiv\" id=\"status\"><input class=\"sheet_input\" type=\"text\" name=\"info\" value=\"{$row_user['info']}\" size=\"5\" disabled /></div>\n\t\t\t<div class=\"indiv\" id=\"real_status\"><input class=\"sheet_input\" type=\"text\" name=\"hobbies\" value=\"{$row_user['hobbies']}\" size=\"10\" disabled /></div>\n\t\t\t<div class=\"indiv\" id=\"xp_point\"><input class=\"sheet_input\" type=\"text\" id=\"xp\" name=\"xp\" size=\"5\" value=\"{$row_user['xp']}\" disabled />{$extra}</div>\n\t\t\t<div class=\"indiv\" id=\"lvl\"><input class=\"sheet_input\" type=\"text\" id=\"lvl\" name=\"lvl\" size=\"5\" value=\"{$row_user['lvl']}\" disabled/></div>\n\t\t\t";
        $body .= "<script language=\"javascript\" type=\"text/javascript\">\n\n\t\t\tfunction master_action(sel){\n\t\t\t\tswitch(sel.options[sel.selectedIndex].value) {\n\t\t\t\t\tcase 'kill':\n\t\t\t\t\t\tdo_kill();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'real_kill':\n\t\t\t\t\t\tdo_permanent_kill();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'respawn':\n\t\t\t\t\t\twindow.location.href='index.php?act=sheet&page=main&toggle_death=0&pg={$pg}';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'heal_off':\n\t\t\t\t\t\twindow.location.href='index.php?act=sheet&page=main&toggle_heal=0&pg={$pg}';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'heal_on':\n\t\t\t\t\t\twindow.location.href='index.php?act=sheet&page=main&toggle_heal=1&pg={$pg}';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\tfunction do_kill(){\n\t\t\tif(!confirm('vuoi davvero uccidere il personaggio?'))\n\t\t\t\treturn;\n\t\t\twindow.location.href='index.php?act=sheet&page=main&toggle_death=1&pg={$pg}';\n\t\t}\n\t\tfunction do_permanent_kill(){\n\t\t\tif(!confirm('vuoi davvero uccidere il personaggio?'))\n\t\t\t\treturn;\n\t\t\twindow.location.href='index.php?act=sheet&page=main&toggle_death=1&permanent_death=1&pg={$pg}';\n\t\t}\n\t\t</script>\n\t\t\t\n\t\t</div>";
        $body .= "<div id=\"modify\"><INPUT name=\"mod_button\" class=\"button\" type=\"button\" value=\"Modifica\" onClick=\"javascript: modify();\" style=\"visibility: visible;\">\n\t\t\t<INPUT name=\"aggiorna\" class=\"button\" type=\"SUBMIT\" value=\"Invia modifiche\" style=\"visibility: hidden;\">";
        $body .= "<br>\n\t\t\t<select class=\"button\" onChange=\"javascript: master_action(this);\">\n\t\t\t<option>Azioni Master</option>\n\t\t\t<option>------------</option>";
        if ($row_user['info'] != "Morto" && $row_user['info'] >= -10) {
            $body .= "<option value=\"kill\">Uccidi</option>";
            $body .= "<option value=\"real_kill\">EXTERMINATE!</option>";
        } else {
            $body .= "<option value=\"respawn\">Resuscita</option>";
        }
        if ($row_user['autoheal']) {
            $body .= "<option value=\"heal_off\">Disattiva Auto-Heal</option>";
        } else {
            $body .= "<option value=\"heal_on\">Attiva auto-heal</option>";
        }
        $body .= "</select>";
        if ($row_user['autoheal']) {
            $body .= "  Autoheal: ON";
        } else {
            $body .= "  Autoheal: OFF";
        }
        $body .= "</div></form>";
    }
    //Just for the avatar and password modification
    if (!checkIfMaster() && $x7s->username == $pg) {
        $body .= '		<script language="javascript" type="text/javascript">
			mod=false;

		function modify(){
			if(!mod){
				mod=true;
				document.forms[0].elements["avatar_in"].style.color="blue";
				document.forms[0].elements["avatar_in"].style.border="1px solid";
				document.forms[0].elements["avatar_in"].style.background="white";
				document.forms[0].elements["avatar_in"].disabled=false;
				document.forms[0].elements["avatar_in"].style.visibility="visible";

				document.forms[0].elements["pwd1"].style.color="blue";
				document.forms[0].elements["pwd1"].style.border="1px solid";
				document.forms[0].elements["pwd1"].style.background="white";
				document.forms[0].elements["pwd1"].disabled=false;
				document.forms[0].elements["pwd1"].style.visibility="visible";

				document.forms[0].elements["pwd2"].style.color="blue";
				document.forms[0].elements["pwd2"].style.border="1px solid";
				document.forms[0].elements["pwd2"].style.background="white";
				document.forms[0].elements["pwd2"].disabled=false;
				document.forms[0].elements["pwd2"].style.visibility="visible";

				document.getElementById("pwd1").style.visibility="visible";
				document.getElementById("pwd2").style.visibility="visible";

				document.getElementById("avatar").innerHTML="<br><br><br>Specifica l\'URL del tuo avatar nel campo qui sopra";
				document.forms[0].elements["aggiorna"].style.visibility="visible";
				document.forms[0].elements["mod_button"].style.visibility="hidden";
			}
		}
		</script>';
        $body .= '<form action="index.php?act=sheet&settings_change=1&pg=' . $pg . '" method="post" name="sheet_form">';
        $body .= "<div class=\"indiv\" id=\"avatar\"><input class=\"sheet_input\" type=\"text\" name=\"avatar_in\" value=\"{$row_user['avatar']}\" size=\"10\" style=\"visibility: hidden; font-size:10pt;\" disabled /></div>\n";
        $body .= "<div class=\"indiv\" id=\"pwd1\" style=\"visibility: hidden;\">Nuova password:<br><input class=\"sheet_input\" type=\"password\" name=\"pwd1\" size=\"10\" style=\"visibility: hidden; font-size:10pt;\" disabled /></div>\n";
        $body .= "<div class=\"indiv\" id=\"pwd2\" style=\"visibility: hidden;\">Ripeti nuova password:<br><input class=\"sheet_input\" type=\"password\" name=\"pwd2\" size=\"10\" style=\"visibility: hidden; font-size:10pt;\" disabled /></div>\n";
        $body .= "<div id=\"modify\">\n\t\t\t<INPUT name=\"mod_button\" class=\"button\" type=\"button\" value=\"Modifica\" onClick=\"javascript: modify();\" style=\"visibility: visible;\">\n\t\t\t<INPUT name=\"aggiorna\" class=\"button\" type=\"SUBMIT\" value=\"Invia modifiche\" style=\"visibility: hidden;\">\n\t\t\t</div></form>";
    }
    $body .= "<div id=\"descr\"> </div>";
    if ($errore != '') {
        $body .= '<script language="javascript" type="text/javascript">
			function close_err(){
				document.getElementById("errore").style.visibility="hidden";
			}
		</script>
			<div id="errore" class="errore">' . $errore . '
			<br><input name="ok" type="button" class="button" value="OK" onClick="javascript: close_err();">
			</div>';
    }
    return $body;
}