예제 #1
0
파일: frame.php 프로젝트: EZDM/omeyocan
                $_GET['key_used'] = $row['id'];
            }
            $remain = -1;
            if (!isset($_GET['frame']) || $_GET['frame'] != "update" && $_GET['frame'] != "send") {
                if ($row['uses'] > 0) {
                    //If we have a limited access to the room whe must update the use
                    // of the keyCode
                    $remain = $row['uses'] - 1;
                    $db->DoQuery("UPDATE {$prefix}objects\r\n\t\t\t\t\t\t\t\tSET uses={$remain}\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\towner = '{$x7s->username}' AND\r\n\t\t\t\t\t\t\t\tname = 'key_{$_GET['room']}' AND\r\n\t\t\t\t\t\t\t\tid = '{$_GET['key_used']}'\r\n\t\t\t\t\t\t\t\t");
                } else {
                    if ($row['uses'] == 0) {
                        $db->DoQuery("DELETE FROM {$prefix}objects\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\towner = '{$x7s->username}' AND\r\n\t\t\t\t\t\t\t\tname = 'key_{$_GET['room']}' AND\r\n\t\t\t\t\t\t\t\tid = '{$_GET['key_used']}'\r\n\t\t\t\t\t\t\t\t");
                    }
                }
                include_once './lib/alarms.php';
                object_usage($x7s->username, $_GET['key_used'], $remain);
            }
        }
        if (!$ok) {
            if (!isset($_GET['frame']) || $_GET['frame'] != "update" && $_GET['frame'] != "send") {
                //We do not own a valid key
                header("Location: index.php?errore=nokey");
                return;
            } else {
                echo "9;Non hai la chiave per questa stanza;index.php";
                return;
            }
        }
    }
}
switch ($_GET['frame']) {
예제 #2
0
파일: message.php 프로젝트: EZDM/omeyocan
function parse_message($message, $sysmsg = 0, $allow_user_img = 0)
{
    global $x7s, $x7c, $db, $prefix;
    // We look for the following tags:
    // Do Auto-URL linking
    if ($x7c->settings['disable_autolinking'] != 1) {
        $message = preg_replace("/(http:\\/\\/(.+?)\\.[^ \\[\"<]*)(.)/ie", "autoparse_url(\"2\",\"\$1\",\"\$3\");", $message);
        $message = preg_replace("/(www\\.(.+?)\\.[^ \\[\"<]*)(.)/ie", "autoparse_url(\"1\",\"\$1\",\"\$3\");", $message);
        $message = preg_replace("/([^@\\]\\s]*)@(.+?)\\.(.+?)([\\s\\[])/i", "<a href=\"mailto: \$1@\$2.\$3\">\$1@\$2.\$3</a>\$4", $message);
    }
    // See if Styles are off
    $styles_off = $x7c->settings['disable_styles'];
    if ($sysmsg == 1) {
        $styles_off = 1;
    }
    //Action parse
    $pos = stripos($message, "&lt;");
    $open = 0;
    while ($pos) {
        if (!$open) {
            $first = substr($message, 0, $pos);
            $last = substr($message, $pos + 4);
            $message = $first . "<span class=\"action\">\"" . $last;
            $open++;
            $pos = stripos($message, "&gt;", $pos);
        } else {
            $first = substr($message, 0, $pos);
            $last = substr($message, $pos + 4);
            $message = $first . "\"</span>" . $last;
            $open--;
            $pos = stripos($message, "&lt;", $pos);
        }
    }
    if ($open) {
        $message .= "\"</span>";
    }
    $message = preg_replace("/&gt;/i", "", $message);
    $message = preg_replace("/&lt;/i", "", $message);
    //Delete sussurro dest
    $message = preg_replace("/^@.*@/i", "", $message);
    //Perform ability
    $action_regexp = "/&sect;([^;]+);/i";
    srand(time() + microtime());
    while (preg_match($action_regexp, $message, $action)) {
        $action_msg = "";
        $query = $db->DoQuery("SELECT a.name AS ab_name, ua.value AS ab_value, uc.value AS char_value\r\n\t\t\t\t\t\t\tFROM {$prefix}userability ua, {$prefix}usercharact uc , {$prefix}ability a\r\n\t\t\t\t\t\t\tWHERE ua.ability_id=a.id\r\n\t\t\t\t\t\t\t AND a.char=uc.charact_id\r\n\t\t\t\t\t\t\t AND uc.username=ua.username\r\n\t\t\t\t\t\t\t AND ua.username='******' \r\n\t\t\t\t\t\t\t AND ua.ability_id='{$action['1']}'");
        if ($row = $db->Do_Fetch_Assoc($query)) {
            $roll = rand(1, 6);
            $roll += rand(1, 6);
            $roll += rand(1, 6);
            $result = floor($row['ab_value'] * 2 + $row['char_value'] / 2 - $roll) + 16;
            if ($result < 11) {
                $action_msg = "<span class=\"roll_neg\">{" . $row['ab_name'] . " " . $result . "}</span>";
            } else {
                if ($result < 21) {
                    $action_msg = "<span class=\"roll_avg\">{" . $row['ab_name'] . " " . $result . "}</span>";
                } else {
                    $action_msg = "<span class=\"roll_pos\">{" . $row['ab_name'] . " " . $result . "}</span>";
                }
            }
        }
        $message = preg_replace($action_regexp, $action_msg, $message, 1);
    }
    //Perform characteristic
    $charact_regexp = "/%([^;]+);/i";
    while (preg_match($charact_regexp, $message, $charact)) {
        $charact_msg = "";
        $query = $db->DoQuery("SELECT c.name AS ch_name, uc.value AS ch_value\r\n\t\t\t\t\t\t\tFROM {$prefix}usercharact uc , {$prefix}characteristic c\r\n\t\t\t\t\t\t\tWHERE uc.charact_id=c.id\r\n\t\t\t\t\t\t\t AND uc.username='******' \r\n\t\t\t\t\t\t\t AND uc.charact_id='{$charact['1']}'");
        if ($row = $db->Do_Fetch_Assoc($query)) {
            $roll = rand(1, 14);
            $result = floor($row['ch_value'] - $roll) + 10;
            if ($result < 7) {
                $charact_msg = "<span class=\"roll_neg\">{" . $row['ch_name'] . " " . $result . "}</span>";
            } else {
                if ($result < 14) {
                    $charact_msg = "<span class=\"roll_avg\">{" . $row['ch_name'] . " " . $result . "}</span>";
                } else {
                    $charact_msg = "<span class=\"roll_pos\">{" . $row['ch_name'] . " " . $result . "}</span>";
                }
            }
        }
        $message = preg_replace($charact_regexp, $charact_msg, $message, 1);
    }
    //Perform objects
    $obj_regexp = "/&deg;([0-9]+);/i";
    while (preg_match($obj_regexp, $message, $obj)) {
        $obj_msg = "";
        $query = $db->DoQuery("SELECT name, uses, equipped, visible_uses,\r\n\t\t\t\t\t\trandom_img\r\n\t\t\t\t\t\tFROM {$prefix}objects\r\n\t\t\t\t\t\tWHERE id='{$obj['1']}'\r\n\t\t\t\t\t\tAND owner='{$x7s->username}'");
        if ($row = $db->Do_Fetch_Assoc($query)) {
            if (!$row['equipped']) {
                $obj_msg = "<span class=\"break\">{L\\'oggetto " . $row['name'] . " non &egrave; equipaggiato}</span>";
            } else {
                $newusage = -1;
                if ($row['uses'] > 0) {
                    $newusage = $row['uses'] - 1;
                    $db->DoQuery("UPDATE {$prefix}objects SET uses='{$newusage}' \r\n\t\t\t\t\t\t\t\t\tWHERE id='{$obj[1]}'");
                }
                $left_usage = '';
                if ($row['visible_uses'] && $newusage >= 0) {
                    $left_usage = " (usi rimasti: {$newusage})";
                }
                if ($row['uses'] > 1 || $row['uses'] == -1) {
                    $obj_msg = "<span class=\"roll_pos\">{Usa l\\'oggetto " . $row['name'] . $left_usage . "}</span>";
                } else {
                    if ($row['uses'] == 1) {
                        $obj_msg = "<span class=\"break\">{Usa l\\'oggetto " . $row['name'] . " che diventa inutilizzabile subito dopo " . "l\\'azione}</span>";
                    } else {
                        $obj_msg = "<span class=\"roll_neg\">{Tenta di utilizzare un" . " oggetto inutilizzabile: " . $row['name'] . "}</span>";
                    }
                }
                include_once './lib/alarms.php';
                object_usage($x7s->username, $obj[1], $row['uses']);
            }
        }
        if ($row['random_img']) {
            $obj_msg .= pick_random_img($row['random_img']);
        }
        $message = preg_replace($obj_regexp, $obj_msg, $message, 1);
    }
    //Perform image
    $img_regexp = "/&pound;([^;]+);/i";
    while (preg_match($img_regexp, $message, $img_url)) {
        if ($x7c->permissions['write_master'] || $allow_user_img) {
            if (preg_match("/swf\$/i", $img_url[1])) {
                //This is specific for the server! (works only if the URL root and the DOCUMENT_ROOT point to the same place)
                $file = $_SERVER['DOCUMENT_ROOT'] . $img_url[1];
                $size = getimagesize($file);
                $width = $size[0];
                $img_msg = "<br><br>\r\n\t\t\t\t\t\t\t\t\t<object>\r\n\t\t\t\t\t\t\t\t\t<param name=\"movie\" width=\"{$size['0']}\" height=\"{$size['1']}\" value=\"" . $img_url[1] . "\">\r\n\t\t\t\t\t\t\t\t\t<param name=\"quality\" value=\"high\">\r\n\t\t\t\t\t\t\t\t\t<param name=\"allowScriptAccess\" value=\"sameDomain\" />\r\n\t\t\t\t\t\t\t\t\t<embed src=\"" . $img_url[1] . "\" width=\"{$size['0']}\" height=\"{$size['1']}\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" allowScriptAccess=\"sameDomain\">\r\n\t\t\t\t\t\t\t\t\t</embed>\r\n\t\t\t\t\t\t\t\t\t</object>\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<br><br>";
            } else {
                $img_msg = "<br><br><img src=\"" . $img_url[1] . "\" ><br><br>";
            }
        }
        $message = preg_replace($img_regexp, $img_msg, $message, 1);
    }
    //Perform generic dice
    $dice_regexp = "/\\~([^;]+);/i";
    while (preg_match($dice_regexp, $message, $dice_value)) {
        $dice_msg = "";
        if (is_numeric($dice_value[1])) {
            $result = rand(1, $dice_value[1]);
            $dice_msg = "<span class=\"roll_avg\">{Tira un d{$dice_value['1']}:</span><span style=\"color: white; font-weight: bold;\"> {$result} </span><span class=\"roll_avg\">}</span>";
        }
        $message = preg_replace($dice_regexp, $dice_msg, $message, 1);
    }
    if (eregi("^\\*", $message)) {
        $message = preg_replace("/^\\*/", "", $message);
        if ($x7c->permissions['admin_panic'] || $allow_user_img) {
            $message = "<div class=\"mastering\">" . $message . "</div>";
        } else {
            if ($x7c->permissions['write_master']) {
                $message = "<div class=\"ambient\">" . $message . "</div>";
            }
        }
    } else {
        $message = "<span class=\"chatmsg\">" . $message . "</span>";
    }
    // Put new lines in
    $message = eregi_replace("\n", "<Br>", $message);
    $message = eregi_replace("\\\\n", "<Br>", $message);
    return $message;
}