Exemple #1
0
function remove_ban($id, $room)
{
    global $db, $prefix, $txt;
    // Alert the room that this user has been unbanned if it isn't a server ban and isn't an IP or email
    if ($room != "*") {
        $query = $db->DoQuery("SELECT user_ip_email FROM {$prefix}banned WHERE id='{$id}'");
        $row = $db->Do_Fetch_Row($query);
        if (!eregi("\\.", $row[0])) {
            $txt[513] = eregi_replace("_u", "{$row['0']}", $txt[513]);
            include_once "./lib/message.php";
            alert_room(@$_GET['room'], $txt[513]);
        }
    }
    $db->DoQuery("DELETE FROM {$prefix}banned WHERE id='{$id}' AND room='{$room}'");
}
Exemple #2
0
 function unvoice()
 {
     global $db, $prefix, $x7c, $txt;
     $voiced = $x7c->room_data['voiced'];
     $their_id = $this->user_info->profile['id'];
     $room_id = $x7c->room_data['id'];
     $voiced = explode(";", $voiced);
     $key = array_search("{$their_id}", $voiced);
     unset($voiced[$key]);
     $voiced = implode(";", $voiced);
     $db->DoQuery("UPDATE {$prefix}rooms SET voiced='{$voiced}' WHERE id='{$room_id}'");
     // Alert the room that they have a new voiced user
     include_once "./lib/message.php";
     alert_room($x7c->room_name, $txt[130], $this->user);
 }
Exemple #3
0
function sheet_page_equip()
{
    global $db, $x7c, $prefix, $x7s, $print;
    $pg = $_GET['pg'];
    $body = '';
    $errore = '';
    include_once './lib/sheet_lib.php';
    include_once './lib/shop_lib.php';
    global $money_name;
    if (isset($_GET['moduse']) && checkIfMaster()) {
        if (!isset($_POST['use']) || !isset($_POST['id'])) {
            die("Bad form 3");
        }
        $db->DoQuery("UPDATE {$prefix}objects SET uses='{$_POST['use']}'\n\t\t\t\tWHERE id='{$_POST['id']}'");
        include_once './lib/alarms.php';
        object_uses($pg, $_POST['id'], $_POST['use']);
    }
    if (isset($_GET['delete']) && ($x7s->username == $pg || checkIfMaster())) {
        $db->DoQuery("DELETE FROM {$prefix}objects WHERE id='{$_GET['delete']}'");
    }
    if (isset($_GET['equiptgl']) && ($x7s->username == $pg || checkIfMaster())) {
        $query = $db->DoQuery("SELECT equipped,name,size \n\t\t\t\tFROM {$prefix}objects WHERE id='{$_GET['equiptgl']}'");
        $row = $db->Do_Fetch_Assoc($query);
        if (!$row) {
            $errore = "Oggetto non esistente";
        } else {
            $equip_value = 0;
            $azione = "";
            $action_ok = true;
            if (!$row['equipped']) {
                $equip_value = 1;
                $azione = "equipaggiato";
                if (get_user_space($pg) - $row['size'] < 0) {
                    $errore = "Spazio insufficiente per equipaggiare l'oggetto";
                    $action_ok = false;
                }
            } else {
                $equip_value = 0;
                $azione = "depositato";
                if (get_user_space($pg) + $row['size'] < 0) {
                    $errore = "Impossibile depositare l'oggetto";
                    $action_ok = false;
                }
            }
            if ($action_ok) {
                $db->DoQuery("UPDATE {$prefix}objects \n\t\t\t\t\t\tSET equipped='{$equip_value}' WHERE id='{$_GET['equiptgl']}'");
                include './lib/alarms.php';
                toggle_equip_log($row['name'], $azione);
                $query = $db->DoQuery("SELECT position\t\t\n\t\t\t\t\t\tFROM {$prefix}users WHERE username='******'");
                $row_msg = $db->Do_Fetch_Assoc($query);
                if ($row_msg && $row_msg['position'] != "Mappa" && $row_msg['position'] != "") {
                    include_once "./lib/message.php";
                    $txt = "L\\'utente {$pg} ha {$azione} l\\'oggetto {$row['name']}";
                    alert_room($row_msg['position'], $txt);
                }
                header("location: index.php?act=sheet&page=equip&pg={$pg}&refreshparent");
            }
        }
    }
    if (isset($_GET['pay']) && ($x7s->username == $pg || checkIfMaster())) {
        global $shopper;
        if (!isset($_POST['owner']) || !isset($_POST['amount']) || !$_POST['owner'] || !$_POST['amount']) {
            $errore = "Non hai specificato il destinatario o l'ammontare";
        } else {
            $query = $db->DoQuery("SELECT count(*) AS cnt\n\t\t\t\t\tFROM {$prefix}users WHERE username='******'owner']}'");
            $row = $db->Do_Fetch_Assoc($query);
            if ((!$row || $row['cnt'] == 0) && $_POST['owner'] != $shopper) {
                $errore = "Utente non esistente";
            } else {
                $errore = pay($_POST['amount'], $pg, $_POST['owner']);
            }
        }
    }
    if (isset($_GET['split']) && ($x7s->username == $pg || checkIfMaster())) {
        if (!isset($_POST['amount']) || !isset($_POST['group'])) {
            die("Bad form 2");
        }
        $errore = split_money($_POST['amount'], $pg, $_POST['group']);
    }
    if (isset($_GET['group_money']) && ($x7s->username == $pg || checkIfMaster())) {
        group_money($pg);
    }
    if (isset($_GET['assign']) && ($x7s->username == $pg || checkIfMaster())) {
        if (!isset($_POST['owner']) || !isset($_POST['id'])) {
            die("Bad form owner: {$_POST['owner']} id: {$_POST['id']}");
        }
        $dummy = '';
        get_obj_name_and_uses($_POST['id'], $obj, $dummy);
        //keys duplicates, and does not disappera from my sheet
        if (preg_match("/^masterkey/", $obj)) {
            list($pre, $name) = split("masterkey_", $obj);
            $obj = "key_{$name}";
            if (!isset($_POST['grants']) || $_POST['grants'] <= 0 || $_POST['grants'] == '') {
                $_POST['grants'] = -1;
            }
            $errore .= assign_object($_POST['id'], $_POST['owner'], true, $pg, $_POST['grants'], $obj);
        } else {
            $errore .= assign_object($_POST['id'], $_POST['owner'], false, $pg);
        }
    }
    $body .= "<script language=\"javascript\" type=\"text/javascript\">\n\t\t\t\tfunction confirmDrop(id){\n\t\t\t\t\tif(confirm(\"Vuoi davvero buttare l'oggetto?\")){\n\t\t\t\t\t\tlocation.href='index.php?act=sheet&page=equip&pg={$pg}&delete='+id;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\n\t\t\tfunction requestReady_channel1(){\n\t\t\t\tif(httpReq2){\n\t\t\t\t\tif(httpReq2.readyState == 4){\n\t\t\t\t\t\tif(httpReq2.status == 200){\n\t\t\t\t\t\t\tvar dataArray = httpReq2.responseText;\n\t\t\t\t\t\t\tdocument.getElementById('objects').innerHTML = dataArray;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction do_refresh(search){\n\t\t\t\tjd=new Date();\n\t\t\t\tnocache = jd.getTime();\n\t\t\t\ttext = search.value;\n\t\t\t\turl = './index.php?act=sheet&page=equip&pg={$pg}&search=' + text + '&nc=' + nocache;\n\t\t\t\tif(window.XMLHttpRequest){\n\t\t\t\t\ttry {\n\t\t\t\t\t\thttpReq2 = new XMLHttpRequest();\n\t\t\t\t\t} catch(e) {\n\t\t\t\t\t\thttpReq2 = false;\n\t\t\t\t\t}\n\t\t\t\t}else if(window.ActiveXObject){\n\t\t\t\t\ttry{\n\t\t\t\t\t\thttpReq2 = new ActiveXObject('Msxml2.XMLHTTP');\n\t\t\t\t\t}catch(e){\n\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\thttpReq2 = new ActiveXObject('Microsoft.XMLHTTP');\n\t\t\t\t\t\t}catch(e){\n\t\t\t\t\t\t\thttpReq2 = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\thttpReq2.onreadystatechange = requestReady_channel1;\n\t\t\t\thttpReq2.open('GET', url, true);\n\t\t\t\thttpReq2.send('');\n\t\t\t}\n\t\t\t</script>";
    $body .= "<div id=\"search_box\">\n\t<input type=\"text\" size=20 onkeyup=\"javascript:do_refresh(this)\"\n\tonclick=\"this.value=''\" \n\tonblur=\"this.value=!this.value?'cerca oggetto':this.value;\"\n\tvalue=\"cerca oggetto\">\n\t</div>\n";
    $body .= "<div id=\"objects\">\n";
    $obj_div = "";
    $refine_query = "";
    if (isset($_GET['search']) && $_GET['search']) {
        $refine_query = " AND name like '%{$_GET['search']}%'";
    }
    $query = $db->DoQuery("SELECT * FROM {$prefix}objects\n\t\t\tWHERE owner='{$pg}' {$refine_query} ORDER BY equipped DESC, name");
    $room = '';
    while ($row = $db->Do_Fetch_Assoc($query)) {
        if ($pg != $x7s->username && $row['equipped'] || $pg == $x7s->username || checkIfMaster()) {
            $more_form = '';
            $obj_name = $row['name'];
            $description = $row['description'];
            $dimensione = "";
            $disabled = "";
            if (!$row['equipped']) {
                $disabled = "style=\"color: #aeaeae;\"";
            }
            switch ($row['size']) {
                case 0:
                    $dimensione = "Minuscolo";
                    break;
                case 1:
                    $dimensione = "Piccolo";
                    break;
                case 2:
                    $dimensione = "Medio";
                    break;
                case 5:
                    $dimensione = "Grande";
                    break;
                case -1:
                    $dimensione = "Capienza piccola";
                    break;
                case -2:
                    $dimensione = "Capienza media";
                    break;
                case -5:
                    $dimensione = "Capienza grande";
                    break;
            }
            if ($row['uses'] == 0) {
                $obj_name .= " [inutilizzabile]";
            }
            if (preg_match("/^key_/", $row['name']) || preg_match("/^masterkey_/", $row['name'])) {
                $master_key = 0;
                $master_string = '';
                if (preg_match("/^key_/", $row['name'])) {
                    list($pre, $name) = split("key_", $row['name']);
                } elseif (preg_match("/^masterkey_/", $row['name'])) {
                    list($pre, $name) = split("masterkey_", $row['name']);
                    $master_key = 1;
                    $master_string = " (chiave master)";
                }
                if (strcasecmp($_GET['pg'], $x7s->username) == 0 || checkIfMaster()) {
                    //we make clickable only key of my sheet
                    if ($master_key) {
                        //This a master key
                        $more_form = ' <tr>
							<td>Usi concessi (vuoto per illimitati):</td>
							<td><input type="text" name="grants" class="text_input" size=2>
							</td>
              </tr>';
                    }
                    $obj_name = '<a onClick="javascript: hdl=window.open(\'\',\'main\'); hdl.location.href=\'index.php?act=frame&room=' . $name . '&key_used=' . $row['id'] . '\'; window.location.reload(); hdl.focus(); "> Stanza di ' . $name . $master_string . '</a>';
                } else {
                    $obj_name = "Stanza di {$name}";
                }
            }
            if ($row['name'] == $money_name) {
                $obj_name .= ": {$row['uses']}";
            }
            $visible_uses = '';
            if ($row['visible_uses']) {
                if ($row['uses'] >= 0) {
                    $visible_uses = "<br>Usi rimasti: {$row['uses']}";
                } else {
                    $visible_uses = "<br>Usi rimasti: illimitati";
                }
            }
            $expire_string = '';
            if ($row['expire_span'] > 0) {
                $query_expire = $db->DoQuery("SELECT expire_time \n\t\t\t\t\t\tFROM {$prefix}temp_obj\n\t\t\t\t\t\tWHERE id = '{$row['id']}'");
                $row_expire = $db->Do_Fetch_Assoc($query_expire);
                if ($row_expire) {
                    $expire_string = "<br>(Nullificazione: " . date("d/m/Y H:i", $row_expire['expire_time']) . ")";
                }
            }
            $obj_div .= "<table width=100%> <tr> <td class=\"obj\">\n\t\t\t\t<img width=100 height=100 src=\"{$row['image_url']}\" align=\"left\">\n        <div {$disabled}>\n        <b>{$obj_name}</b>\n        <br>Dimensione: {$dimensione}\n\t\t\t\t{$visible_uses}\n\t\t\t\t{$expire_string}\n        <p>{$description}</p>\n        </div> </td> </tr> </table>";
            if ($pg == $x7s->username || checkIfMaster()) {
                $money_qty = "";
                $money_form = "";
                if ($row['name'] == $money_name) {
                    if ($row['equipped']) {
                        $money_form = "\n\t\t\t\t\t\t\t<form action=\"index.php?act=sheet&page=equip&pg={$pg}&split=1\"\n\t\t\t\t\t\t\tmethod=\"post\" name=\"split\">\n\t\t\t\t\t\t\t<input type=\"hidden\" name=\"id\" value=\"{$row['id']}\">\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<input type=\"button\" class=\"button\" value=\"Raggruppa tutti\"\n\t\t\t\t\t\t\tonClick=\"javascript: location.href='index.php?act=sheet&page=equip&pg={$pg}&group_money'\">\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<input type=\"submit\" class=\"button\" value=\"Dividi\">" . "<input type=\"text\" name=\"amount\" class=\"text_input\" size=5>\n\t\t\t\t\t\t\t<input type=\"hidden\" name=\"group\" value=\"{$row['id']}\">\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t<form action=\"index.php?act=sheet&page=equip&pg={$pg}&pay=1\"\n\t\t\t\t\t\t\tmethod=\"post\" name=\"payment\">\n\t\t\t\t\t\t\t<input type=\"hidden\" name=\"id\" value=\"{$row['id']}\">\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Paga a:</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"owner\" class=\"text_input\" size=10>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\tAmmontare:</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"amount\" class=\"text_input\" size=5>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td><input type=\"submit\" class=\"button\" value=\"Paga\"></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</form>";
                    }
                }
                $equip_text = "Deposita";
                if (!$row['equipped']) {
                    $equip_text = "Equipaggia";
                }
                $obj_div .= "\n          <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n\t\t\t\t\t<form action=\"index.php?act=sheet&page=equip&pg={$pg}&assign=1\"\n\t\t\t\t\tmethod=\"post\" name=\"object_assign\">\n          <input type=\"hidden\" name=\"id\" value=\"{$row['id']}\">\n          <tr>\n          <td>Dai a:</td>\n          <td><input type=\"text\" name=\"owner\" class=\"text_input\"></td>\n          <td><input type=\"submit\" class=\"button\" value=\"Dai\"></td>\n          </tr>\n          {$more_form}\n          </form>\n          <tr>\n          <td><input type=\"button\" class=\"button\" value=\"Butta\"\n\t\t\t\t\tonClick=\"javascript: confirmDrop({$row['id']})\">\n          <input type=\"button\" class=\"button\" value=\"{$equip_text}\"\n\t\t\t\t\tonClick=\"javascript: location.href='index.php?act=sheet&page=equip&pg={$pg}&equiptgl={$row['id']}'\"></td>\n          </tr>\n\t\t\t\t\t{$money_form}\n          </table>";
            }
            if (checkIfMaster() && $row['name'] != $money_name) {
                $obj_div .= "<form action=\"index.php?act=sheet&page=equip&pg={$pg}&moduse=1\"" . " method=\"post\" name=\"object_moduse\">\n          <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n          <input type=\"hidden\" name=\"id\" value=\"{$row['id']}\">\n          <tr>\n          <td>Usi:</td>\n          <td><input type=\"text\" name=\"use\" class=\"text_input\" size=2 value=\"{$row['uses']}\"></td>\n          <td><input type=\"submit\" class=\"button\" value=\"Cambia\"></div></td>\n          </tr>\n          </table>\n          ";
                $obj_div .= "</form>\n";
            }
            $obj_div .= "<br><br>\n";
        }
    }
    if (isset($_GET['search'])) {
        echo $obj_div;
        return "";
    }
    $body .= $obj_div;
    $body .= "</div>\n";
    $body .= '<div class="counter" id="spazio">' . get_user_space($pg) . '</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><br><input name="ok" type="button" class="button" value="OK" onClick="javascript: close_err(); window.location.href=\'index.php?act=sheet&page=equip&pg=' . $_GET['pg'] . '\';">
				</div>';
    }
    return $body;
}