コード例 #1
0
function decrease_misc($item, $count)
{
    //$item = preg_replace ('/[^a-z0-9_\.]/i', '', $item);
    $count = preg_replace('/[^0-9]/', '', $count);
    // vozmem nachalqnoe kolichestvo
    $sc = do_mysql("SELECT on_take FROM items WHERE fullname = '" . $item . "';");
    $sc = mysql_result($sc, 0);
    // esli count menqshe nulja, tupaja oshibka
    if ($count <= 0) {
        //put_error ('уменьшить на минусовое число нелзя, надо использовать увеличить');
        return 0;
    }
    // esli otnjav poluchitsja menqshe 0 tozhe nelzja, ob etom pozabotitsja nado v skriptah
    if ($sc - $count < 0) {
        //put_error ('как ты считал балбес, ведь меньше 0 получается');
        return 0;
    }
    // esli vse prodolzhaetsja, uvelichim i obnovim
    $nc = $sc - $count;
    if ($nc < 1) {
        include_once 'modules/f_delete.php';
        delete_item($item);
    }
    do_mysql("UPDATE items SET on_take = '" . $nc . "' WHERE fullname = '" . $item . "';");
    return 1;
}
コード例 #2
0
function decr_abstr_misc($prot, $who, $count, $other = 0)
{
    //$prot = preg_replace ('/[^a-z0-9_\.]/i', '', $prot);
    $count = preg_replace('/[^0-9]/', '', $count);
    //$who = preg_replace ('/[^a-z0-9_]/i', '', $who);
    if (!is_player($who)) {
        return 0;
    }
    if ($count < 1) {
        return 0;
    }
    $q = do_mysql("SELECT on_take FROM items WHERE belongs = '" . $who . "' AND is_in = 'inv' AND realname = '" . $prot . "' AND type = 'm';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $ci = mysql_result($q, 0);
    if ($ci < $count) {
        return 0;
    }
    $ci -= $count;
    if ($ci) {
        do_mysql("UPDATE items SET on_take = '" . $ci . "' WHERE  belongs = '" . $who . "' AND is_in = 'inv' AND realname = '" . $prot . "';");
    } else {
        include_once 'modules/f_delete_item.php';
        $q = do_mysql("SELECT fullname FROM items WHERE belongs = '" . $who . "' AND is_in = 'inv' AND realname = '" . $prot . "' AND type = 'm';");
        $item = mysql_result($q, 0);
        delete_item($item);
    }
    return 1;
}
コード例 #3
0
function teach_magic_from_sc($scroll, $npc, $login)
{
    //$scroll = preg_replace ('/[^a-z0-9_\.]/i', '', $scroll);
    //$npc = preg_replace ('/[^a-z0-9_\.]/i', '', $npc);
    //$login = preg_replace ('/[^a-z0-9_]/i', '', $login);
    $nid = is_npc($npc);
    $id = is_player($login);
    // v odnoj li lokacii
    $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . $nid . "';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $loc1 = mysql_result($q, 0);
    $q = do_mysql("SELECT location FROM players WHERE id_player = '" . $id . "';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $loc2 = mysql_result($q, 0);
    if ($loc1 != $loc2) {
        return 0;
    }
    include_once 'modules/f_has_item.php';
    if (!has_item($scroll, $login)) {
        put_g_error('у вас нету свитка!');
    }
    $q = do_mysql("SELECT on_take, price FROM items WHERE fullname = '" . $scroll . "' AND type = 's';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $spell = mysql_fetch_assoc($q);
    // neumeet li on uzhe
    include_once 'modules/f_has_magic.php';
    if (has_magic($spell['on_take'], $login)) {
        put_g_error('вы уже умеете это заклинание!');
    }
    // cenu vyschitaem:
    $q = do_mysql("SELECT money FROM players WHERE id_player = '" . $id . "';");
    $money = mysql_result($q, 0);
    $cost = $spell['price'] * 10;
    if ($money < $cost) {
        put_g_error('нехватает серебра, нужно ' . $cost . ' серебреных!');
    }
    $money -= $cost;
    // dobavljaem zakl:
    $q = do_mysql("SELECT magic FROM players WHERE id_player = '" . $id . "';");
    $magic = mysql_result($q, 0);
    if (!$magic) {
        $magic = $spell['on_take'];
    } else {
        $magic .= '|' . $spell['on_take'];
    }
    // obnovim dannye:
    do_mysql("UPDATE players SET magic = '" . $magic . "', money = '" . $money . "' WHERE id_player = '" . $id . "';");
    // udaljaem svitok
    include_once 'modules/f_delete_item.php';
    delete_item($scroll);
    $q = do_mysql("SELECT name FROM magic WHERE fullname = '" . $spell['on_take'] . "';");
    $name = mysql_result($q, 0);
    exit_msg('магия', 'вы выучили заклинание ' . $name . ' за ' . $cost . ' серебреных!');
}
コード例 #4
0
ファイル: parse.php プロジェクト: phpsmith/IS4C
function deleteitem($plu)
{
    global $FANNIE_ROOT, $FANNIE_SCALES;
    $CSV_dir = $FANNIE_ROOT . 'item/hobartcsv/csvfiles';
    $DGW_dir = $FANNIE_ROOT . 'item/hobartcsv/csv_output';
    if (!function_exists('writeitem')) {
        include 'writecsv.php';
    }
    $session_key = '';
    for ($i = 0; $i < 20; $i++) {
        $num = rand(97, 122);
        $session_key = $session_key . chr($num);
    }
    $i = 0;
    foreach ($FANNIE_SCALES as $f) {
        delete_item("{$CSV_dir}/{$session_key}_di_scale_{$i}.csv", $f['type'], $f['host'], $f['dept'], $plu);
        delete_text("{$CSV_dir}/{$session_key}_dt_scale_{$i}.csv", $f['type'], $f['host'], $f['dept'], $plu);
        $i++;
    }
    for ($i = 0; $i < count($FANNIE_SCALES); $i++) {
        copy($CSV_dir . "/" . $session_key . "_di_scale_" . $i . ".csv", $DGW_dir . "/" . $session_key . "_di_scale_" . $i . ".csv");
        unlink($CSV_dir . "/" . $session_key . "_di_scale_" . $i . ".csv");
        copy($CSV_dir . "/" . $session_key . "_dt_scale_" . $i . ".csv", $DGW_dir . "/" . $session_key . "_dt_scale_" . $i . ".csv");
        unlink($CSV_dir . "/" . $session_key . "_dt_scale_" . $i . ".csv");
    }
}
function hunterslodge_customtitle_run()
{
    require_once "lib/sanitize.php";
    require_once "lib/names.php";
    global $session;
    $op = httpget("op");
    $free = httpget("free");
    page_header("Choose your Custom Title");
    switch ($op) {
        case "change":
            output("Ready to change your Title?  No problem.  Enter your desired Title in the box below.  You've got 25 characters to play with, including colour codes.`n`n");
            titlechange_form();
            addnav("Cancel");
            addnav("Don't change colours, just go back to the Lodge", "runmodule.php?module=iitems_hunterslodge&op=start");
            break;
        case "confirm":
            $ntitle = rawurldecode(httppost('newname'));
            $ntitle = newline_sanitize($ntitle);
            if ($ntitle == "") {
                $ntitle = "`0";
            }
            $ntitle = preg_replace("/[`][cHw]/", "", $ntitle);
            $ntitle = sanitize_html($ntitle);
            $nname = get_player_basename();
            output("`0Your new title will look like this: %s`0`n", $ntitle);
            output("`0Your entire name will look like: %s %s`0`n`n", $ntitle, $nname);
            output("Do you want to set the new title now?`n`n");
            output("`0Try a different title below, if you like.`n`n");
            titlechange_form();
            addnav("Confirm");
            addnav("Set the new Title", "runmodule.php?module=hunterslodge_customtitle&op=set&free={$free}&newname=" . rawurlencode($ntitle));
            addnav("Cancel");
            addnav("Don't change your Title, just go back to the Lodge", "runmodule.php?module=iitems_hunterslodge&op=start");
            break;
        case "set":
            $ntitle = rawurldecode(httpget('newname'));
            $fromname = $session['user']['name'];
            $newname = change_player_ctitle($ntitle);
            $session['user']['ctitle'] = $ntitle;
            $session['user']['name'] = $newname;
            output("You are now known as %s!`0`n`n", $session['user']['name']);
            if (!$free) {
                $id = has_item("hunterslodge_customtitle");
                delete_item($id);
            }
            addnav("Return");
            addnav("Return to the Lodge", "runmodule.php?module=iitems_hunterslodge&op=start");
            break;
    }
    page_footer();
}
function hunterslodge_customrace_run()
{
    require_once "lib/sanitize.php";
    require_once "lib/names.php";
    global $session;
    $op = httpget("op");
    $free = httpget("free");
    page_header("Choose your Custom Race");
    switch ($op) {
        case "change":
            output("Want to change your Custom Race?  No problem.  Enter your desired race in the box below.  You've got 25 characters to play around with.`n(leave this blank to disable custom race naming and return to default, game-supplied race names)`n`n");
            rawoutput("<form action='runmodule.php?module=hunterslodge_customrace&op=confirm&free=" . $free . "' method='POST'>");
            $race = get_module_pref("customrace");
            rawoutput("<input id='input' name='newrace' width='25' maxlength='25' value='" . htmlentities($race, ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "'>");
            rawoutput("<input type='submit' class='button' value='Preview'>");
            rawoutput("</form>");
            addnav("", "runmodule.php?module=hunterslodge_customrace&op=confirm&free=" . $free);
            addnav("Cancel");
            addnav("Don't set a custom race, just go back to the Lodge", "runmodule.php?module=iitems_hunterslodge&op=start");
            break;
        case "confirm":
            $newrace = httppost("newrace");
            $sub = httpget("sub");
            $newrace = str_replace("`", "", $newrace);
            $newrace = comment_sanitize($newrace);
            $newrace = substr($newrace, 0, 25);
            if ($newrace) {
                output("Your new custom race is:`n%s`nWould you like to set your new Race now?`n`n", $newrace);
            } else {
                output("You've chosen to go back to the default, game-supplied races.  Are you sure that's what you want?`n`n");
            }
            addnav("Confirm");
            addnav("Set custom race", "runmodule.php?module=hunterslodge_customrace&op=set&free={$free}&newrace=" . rawurlencode($newrace));
            addnav("Cancel");
            addnav("Don't set a custom race, just go back to the Lodge", "runmodule.php?module=iitems_hunterslodge&op=start");
            break;
        case "set":
            $newrace = rawurldecode(httpget("newrace"));
            output("Your custom race has been set to %s!`n`n", $newrace);
            set_module_pref("customrace", $newrace);
            if (!$free) {
                $id = has_item("hunterslodge_customrace");
                delete_item($id);
            }
            addnav("Return");
            addnav("Return to the Lodge", "runmodule.php?module=iitems_hunterslodge&op=start");
            break;
    }
    page_footer();
}
function cratesniffer_use($args)
{
    output("`0You thumb the switch on your Crate Sniffer.  It buzzes and hisses for a moment, exhausting its primitive battery sending out a radio ping to nearby Crates.`n`n");
    $ploc = get_module_pref("worldXYZ", "worldmapen");
    list($px, $py, $pz) = explode(",", $ploc);
    $pxlow = $px - 3;
    $pxhigh = $px + 3;
    $pylow = $py - 3;
    $pyhigh = $py + 3;
    $potentialowners = array();
    $x = -3;
    $y = -3;
    $cont = true;
    while ($cont) {
        $ox = $px + $x;
        $oy = $py + $y;
        $owner = "worldmap_{$ox},{$oy},1";
        //debug($owner);
        $potentialowners[] = $owner;
        if ($x == 3 && $y == 3) {
            $cont = false;
            break;
        }
        if ($y == 3) {
            $x++;
            $y = -3;
        } else {
            $y++;
        }
    }
    //debug($potentialowners);
    $sql = "SELECT count(item) AS c FROM " . db_prefix("items_player") . " WHERE item='supplycrate' AND owner IN (";
    foreach ($potentialowners as $owner) {
        $sql .= "'" . $owner . "',";
    }
    $sql = substr_replace($sql, "", -1);
    $sql .= ")";
    //debug($sql);
    $result = db_query($sql);
    $row = db_fetch_assoc($result);
    $count = $row['c'];
    output("It displays, weakly, the number `\$`b%s`b`0 in dull red LED's before its radio module catches fire.`n`n", $count);
    delete_item($args['id']);
    return $args;
}
コード例 #8
0
function add_sc_to_book($scroll, $book, $login)
{
    // v has_item proveritsja
    //$scroll = preg_replace ('/[^a-z0-9_\.]/i', '', $scroll);
    //$book = preg_replace ('/[^a-z0-9_\.]/i', '', $book);
    //$login = preg_replace ('/[^a-z0-9_]/i', '', $login);
    include_once 'modules/f_has_item.php';
    if (!has_item($scroll, $login)) {
        put_g_error('у вас нету свитка');
    }
    if (!has_item($book, $login)) {
        put_g_error('у вас нету книги');
    }
    // tolqko esli estq navyk:
    $q = do_mysql("SELECT skills FROM players WHERE login = '******';");
    $skills = mysql_result($q, 0);
    $skills = explode('|', $skills);
    if (!$skills[30]) {
        put_g_error('у вас нету навыка');
    }
    // dobavim:
    $q = do_mysql("SELECT on_take FROM items WHERE fullname = '" . $book . "' AND type = 'b';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $mlist = mysql_result($q, 0);
    $q = do_mysql("SELECT on_take FROM items WHERE type = 's' AND fullname = '" . $scroll . "';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $spell = mysql_result($q, 0);
    if (strpos($mlist, $spell) !== false) {
        put_g_error('в этой книге уже есть это заклинание!');
    }
    if ($mlist) {
        $mlist .= '~' . $spell;
    } else {
        $mlist = $spell;
    }
    do_mysql("UPDATE items SET on_take = '" . $mlist . "' WHERE fullname = '" . $book . "';");
    // udalim svitok:
    include_once 'modules/f_delete_item.php';
    delete_item($scroll);
    return 1;
}
コード例 #9
0
ファイル: parse.php プロジェクト: phpsmith/IS4C
function deleteitem($plu, $scalenum)
{
    include 'ini.php';
    $session_key = '';
    for ($i = 0; $i < 20; $i++) {
        $num = rand(97, 122);
        $session_key = $session_key . chr($num);
    }
    for ($i = 0; $i < $num_scales; $i++) {
        delete_item("{$CSV_dir}/{$session_key}_di_scale_{$i}.csv", $scale_types[$i], $scale_ips[$i], $department, $plu);
        delete_text("{$CSV_dir}/{$session_key}_dt_scale_{$i}.csv", $scale_types[$i], $scale_ips[$i], $department, $plu);
    }
    for ($i = 0; $i < $num_scales; $i++) {
        exec("cp {$CSV_dir}/{$session_key}_di_scale_{$i}.csv {$DGW_dir}");
        exec("rm -f {$CSV_dir}/{$session_key}_di_scale_{$i}.csv");
        exec("cp {$CSV_dir}/{$session_key}_dt_scale_{$i}.csv {$DGW_dir}");
        exec("rm -f {$CSV_dir}/{$session_key}_dt_scale_{$i}.csv");
    }
}
function hunterslodge_healthinsurance_use($args)
{
    global $session;
    $id = $args['id'];
    $expirationtime = get_item_pref("expiration_timestamp", $id);
    if (!$expirationtime) {
        $expires = time() + 604800;
        set_item_pref("expiration_timestamp", $expires, $id);
        output("`0This is the first time you've used this certificate.  It will expire exactly one week from now.`n`n");
    } else {
        if (time() > $expirationtime) {
            output("This certificate has now expired!`n`n");
            delete_item($id);
        } else {
            require_once "lib/datetime.php";
            $expirein = reltime($expirationtime, false);
            output("This certificate will expire in %s.`n`n", $expirein);
        }
    }
    $args['destroyafteruse'] = false;
    return $args;
}
コード例 #11
0
ファイル: class.citem.php プロジェクト: phedders/zabbix
 /**
  * Delete items
  *
  * {@source}
  * @access public
  * @static
  * @since 1.8
  * @version 1
  *
  * @static
  * @param array $itemids
  * @return array|boolean
  */
 public static function delete($itemids)
 {
     $result = delete_item($itemids);
     if ($result) {
         return $itemids;
     } else {
         self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Internal zabbix error');
         return false;
     }
 }
function meatsystem_run()
{
    global $session;
    require_once "modules/staminasystem/lib/lib.php";
    page_header("Meat!");
    addnav("Meat Skills");
    $from = httpget('from');
    switch (httpget('op')) {
        case "devour":
            //special ability for Zombies only - Zombies can eat raw meat, so we're giving them the ability to simply devour the carcass where it lies.
            $carcasses = unserialize(get_module_pref("carcasses"));
            if (!is_array($carcasses)) {
                $carcasses = array();
            }
            debug($carcasses);
            foreach ($carcasses as $carcassnum => $creatureid) {
                $sql = "SELECT creaturename FROM " . db_prefix("creatures") . " WHERE creatureid = " . $creatureid . " ";
                $result = db_query_cached($sql, "creaturename-" . $creatureid, 86400);
                $creature = db_fetch_assoc($result);
                output("Giving in to your primal urges, you lean down and begin ripping meat from the still-twitching %s with your teeth.`n`n", $creature['creaturename']);
                $meat1 = get_module_objpref("creatures", $creatureid, "meat1");
                $meat2 = get_module_objpref("creatures", $creatureid, "meat2");
                $meat3 = get_module_objpref("creatures", $creatureid, "meat3");
                for ($i = 0; $i < $meat1; $i++) {
                    increment_module_pref("nutrition", 1, "staminafood");
                    increment_module_pref("fat", 3, "staminafood");
                    increment_module_pref("fullness", 1, "staminafood");
                    addstamina(1000);
                }
                for ($i = 0; $i < $meat2; $i++) {
                    increment_module_pref("nutrition", 2, "staminafood");
                    increment_module_pref("fat", 2, "staminafood");
                    increment_module_pref("fullness", 1, "staminafood");
                    addstamina(2000);
                }
                for ($i = 0; $i < $meat3; $i++) {
                    increment_module_pref("nutrition", 3, "staminafood");
                    increment_module_pref("fat", 1, "staminafood");
                    increment_module_pref("fullness", 1, "staminafood");
                    addstamina(5000);
                }
                output("For the record, and since it's nice to know these things even if you're too busy tearing cartilage and muscle from the bone to really pay attention to them, in this meal you have eaten %s bite's-worth of Crap Meat, %s bite's-worth of Half-Decent Meat, and %s bite's-worth of Tasty Meat.`n", $meat1, $meat2, $meat3);
                $full = get_module_pref("fullness", "staminafood");
                if ($full < 0) {
                    output("You still feel as though you haven't eaten in days.`n`n");
                }
                if ($full >= 0 && $full < 50) {
                    output("You feel a little less hungry.`n`n");
                }
                if ($full >= 50 && $full < 100) {
                    output("You still feel as though you've got room for more!`n`n");
                }
                if ($full >= 100) {
                    output("You're stuffed!  You feel as though you can't possibly eat anything more today.`n`n");
                }
                unset($carcasses[$carcassnum]);
                set_module_pref("carcasses", serialize($carcasses));
            }
            break;
        case "clean":
            $creatureid = httpget('creatureid');
            $carcass = httpget('carcass');
            $meat1 = get_module_objpref("creatures", $creatureid, "meat1");
            $meat2 = get_module_objpref("creatures", $creatureid, "meat2");
            $meat3 = get_module_objpref("creatures", $creatureid, "meat3");
            $amber = get_stamina();
            $return = process_action("Cleaning the Carcass");
            if ($return['lvlinfo']['levelledup'] == true) {
                output("`n`c`b`0You gained a level in Cleaning Carcasses!  You are now level %s!  This action will cost fewer Stamina points now, so you can butcher more creatures each day!`b`c`n", $return['lvlinfo']['newlvl']);
            }
            $failchance = e_rand(0, 100);
            if ($failchance > $amber) {
                //failure - the nice meat gets turned into Crap Meat
                $meat1 += $meat2;
                $meat1 += $meat3;
                output("`4You sit down to clean the carcass.  Your exhausted, clumsy incisions make a mockery of the choicest cuts - what is left over can only be described as Crap Meat.  %s bite's-worth, to be precise.  It looks like it was hacked into chunks by a blind woodsman.", $meat1);
                //todo
                for ($i = 0; $i < $meat1; $i++) {
                    give_item("meat_low", false, false, true);
                }
                load_inventory();
                $carcasses = unserialize(get_module_pref("carcasses"));
                unset($carcasses[$carcass]);
                $carcasses = array_values($carcasses);
                set_module_pref("carcasses", serialize($carcasses));
            } else {
                //success - all meat is sorted
                output("You spend a few minutes up to your elbows in gore, and getting rather hungry.`n");
                if ($meat1 > 0) {
                    output("You tear off enough to make %s rough bite's-worth of what the locals affectionately call Crap Meat.  It's mostly wobbling chunks of stinking yellow fat, intermingled with the occasional squirmy tendon.`n", $meat1);
                }
                if ($meat2 > 0) {
                    output("You make swift work of the fattier muscle, and before too long you have %s rough bite's-worth of Half-Decent Meat.`n", $meat2);
                }
                if ($meat3 > 0) {
                    output("The red, tender slivers of muscle slide easily from the bone, and you wind up with %s rough bite's-worth of Tasty Meat.`n", $meat3);
                }
                //todo
                for ($i = 0; $i < $meat1; $i++) {
                    give_item("meat_low", false, false, true);
                }
                for ($i = 0; $i < $meat2; $i++) {
                    give_item("meat_medium", false, false, true);
                }
                for ($i = 0; $i < $meat3; $i++) {
                    give_item("meat_high", false, false, true);
                }
                load_inventory();
                $carcasses = unserialize(get_module_pref("carcasses"));
                unset($carcasses[$carcass]);
                $carcasses = array_values($carcasses);
                set_module_pref("carcasses", serialize($carcasses));
                $pmeat1 = has_item("meat_low");
                $pmeat2 = has_item("meat_medium");
                $pmeat3 = has_item("meat_high");
                if (($pmeat1 || $pmeat2 || $pmeat3) && $session['user']['race'] != "Robot") {
                    if (get_module_pref("fullness", "staminafood") < 100) {
                        $cookcost = stamina_getdisplaycost("Cooking");
                        addnav(array("Cook up some meat (`Q%s%%`0)", $cookcost), "runmodule.php?module=meatsystem&op=cook&from=" . $from);
                    } else {
                        addnav("You're too full to cook, let alone eat", "");
                    }
                }
            }
            break;
        case "cook":
            $pmeat1qty = has_item_quantity("meat_low");
            $pmeat2qty = has_item_quantity("meat_medium");
            $pmeat3qty = has_item_quantity("meat_high");
            output("You whip out your camping stove.  It's time to cook!`n`nWhat will you put in the pan?  You can fit up to 20 bite's-worth of meat in there.  Right now you have %s bite's-worth of Crap Meat, %s bite's-worth of Half-Decent Meat, and %s bite's-worth of Tasty Meat.`n`n", $pmeat1qty, $pmeat2qty, $pmeat3qty);
            rawoutput("<form action='runmodule.php?module=meatsystem&op=cookfinal&from=" . $from . "' method='POST'>");
            rawoutput("Put in <input name='meat1' width='2' value='0'> bite's-worth of Crap Meat.<br />");
            rawoutput("Put in <input name='meat2' width='2' value='0'> bite's-worth of Half-Decent Meat.<br />");
            rawoutput("Put in <input name='meat3' width='2' value='0'> bite's-worth of Tasty Meat.<br />");
            rawoutput("<input type='submit' class='button' value='" . translate_inline("Cook!") . "'>");
            rawoutput("</form>");
            addnav("", "runmodule.php?module=meatsystem&op=cookfinal&from=" . $from);
            break;
        case "cookfinal":
            $pmeat1qty = has_item_quantity("meat_low");
            $pmeat2qty = has_item_quantity("meat_medium");
            $pmeat3qty = has_item_quantity("meat_high");
            $meat1 = httppost("meat1");
            $meat2 = httppost("meat2");
            $meat3 = httppost("meat3");
            //check for the dumbass player cooking meat that they don't have
            if ($meat1 > $pmeat1qty || $meat2 > $pmeat2qty || $meat3 > $pmeat3qty) {
                output("You don't `ihave`i that much meat!`n`n");
                addnav("Whoops");
                addnav("Sorry, I forgot how to count for a second there.  Let's try this again.", "runmodule.php?module=meatsystem&op=cook&from=" . $from);
                break;
            }
            //check for the dumbass player inputting a negative number
            if ($meat1 < 0 || $meat2 < 0 || $meat3 < 0) {
                page_header("Either taking vegetarianism to whole new levels, or trying to grow meat from an empty pan");
                output("You want to cook `inegative`i meat?  How very Zen of you.`n`n");
                addnav("You sneaky bugger");
                addnav("Abandon your efforts to produce the opposite of meat and try again, pretending that you weren't just trying to cheat.", "runmodule.php?module=meatsystem&op=cook&from=" . $from);
                break;
            }
            //check for the dumbass player trying to put too much meat in the pan
            $totalmeat = $meat1 + $meat2 + $meat3;
            if ($totalmeat > 20) {
                output("Your pan can't hold that much meat, pal.`n`n");
                addnav("Whoops");
                addnav("Try again, without filling the pan up so much", "runmodule.php?module=meatsystem&op=cook&from=" . $from);
                break;
            }
            //check for the dumbass player trying to cook no meat at all
            $totalmeat = $meat1 + $meat2 + $meat3;
            if ($totalmeat == 0) {
                output("You start the process of cooking up your tasty meat.  After a few minutes of poking around in your pan, growing hungrier by the second, you realise that you've forgotten something.`n`n");
                addnav("Whoops");
                addnav("Try again, with meat this time", "runmodule.php?module=meatsystem&op=cook&from=" . $from);
                break;
            }
            //Stamina interaction, including consequences and level-up details.
            $amber = get_stamina();
            $return = process_action("Cooking");
            if ($return['lvlinfo']['levelledup'] == true) {
                output("`n`c`b`0You gained a level in Cooking!  You are now level %s!  This action will cost fewer Stamina points now, so you can cook more tasty meals each day!`b`c`n", $return['lvlinfo']['newlvl']);
            }
            $failchance = e_rand(0, 100);
            if ($failchance > $amber) {
                output("`4You put your meat into the pan, and sit down to stir-fry it.  The hypnotic motion and white-noise sizzling, combined with your tiredness, sends you staring into space.  While your concentration is impaired, the meat bursts into flames.  You jerk back into awareness, and look down sadly at the flaming chunks.  Bummer.");
                for ($i = 0; $i < $meat1; $i++) {
                    delete_item(has_item("meat_low"));
                }
                for ($i = 0; $i < $meat2; $i++) {
                    delete_item(has_item("meat_medium"));
                }
                for ($i = 0; $i < $meat3; $i++) {
                    delete_item(has_item("meat_high"));
                }
                break;
            }
            //we can now assume that the player is not some sort of cheating reprobate, or trying to cook while dog-tired, and do some cooking!
            for ($i = 0; $i < $meat1; $i++) {
                increment_module_pref("nutrition", 1, "staminafood");
                increment_module_pref("fat", 3, "staminafood");
                increment_module_pref("fullness", 1, "staminafood");
                delete_item(has_item("meat_low"));
                addstamina(1000);
            }
            for ($i = 0; $i < $meat2; $i++) {
                increment_module_pref("nutrition", 2, "staminafood");
                increment_module_pref("fat", 2, "staminafood");
                increment_module_pref("fullness", 1, "staminafood");
                delete_item(has_item("meat_medium"));
                addstamina(2000);
            }
            for ($i = 0; $i < $meat3; $i++) {
                increment_module_pref("nutrition", 3, "staminafood");
                increment_module_pref("fat", 1, "staminafood");
                increment_module_pref("fullness", 1, "staminafood");
                delete_item(has_item("meat_high"));
                addstamina(5000);
            }
            output("You fry up your lovely meaty loveliness, and sit down to eat.  You gain some Stamina!`n`n");
            $full = get_module_pref("fullness", "staminafood");
            if ($full < 0) {
                output("You still feel as though you haven't eaten in days.`n`n");
            }
            if ($full >= 0 && $full < 50) {
                output("You feel a little less hungry.`n`n");
            }
            if ($full >= 50 && $full < 100) {
                output("You still feel as though you've got room for more!`n`n");
            }
            if ($full >= 100) {
                output("You're stuffed!  You feel as though you can't possibly eat anything more today.`n`n");
            }
            break;
    }
    $carcasses = unserialize(get_module_pref("carcasses"));
    if (!is_array($carcasses)) {
        $carcasses = array();
    }
    if (count($carcasses) > 0) {
        output("You look at the spoils of your most recent battle.  They lie bloodied and broken on the ground.  What will you do with them?");
        foreach ($carcasses as $carcassnum => $creatureid) {
            $sql = "SELECT creaturename FROM " . db_prefix("creatures") . " WHERE creatureid = " . $creatureid . " ";
            $result = db_query_cached($sql, "creaturename-" . $creatureid, 86400);
            $creature = db_fetch_assoc($result);
            $cleancost = stamina_getdisplaycost("Cleaning the Carcass");
            addnav(array("Clean the carcass of %s (`Q%s%%`0)", $creature['creaturename'], $cleancost), "runmodule.php?module=meatsystem&op=clean&creatureid=" . $creatureid . "&carcass=" . $carcassnum . "&from=" . $from);
        }
    } else {
        if (httpget('op') != "cook" && httpget('op') != "cookfinal") {
            output("Now only bloody bones lie strewn around the area.`n`n");
        }
    }
    addnav("Ah, screw it.");
    if ($from == "forest") {
        addnav("Return to the Jungle", "forest.php");
    } else {
        if ($from == "world") {
            addnav("Return to the World Map", "runmodule.php?module=worldmapen&op=continue");
        }
    }
    page_footer();
    return true;
}
function oneshotteleporter_use($args)
{
    delete_item($args['id']);
    redirect("runmodule.php?module=oneshotteleporter");
}
コード例 #14
0
ファイル: items.php プロジェクト: ravenii/guardocs
        return false;
    }
    $sql = "SELECT COUNT(*) FROM purch_order_details " . "WHERE item_code='{$stock_id}'";
    $result = db_query($sql, "could not query purchase orders");
    $myrow = db_fetch_row($result);
    if ($myrow[0] > 0) {
        display_error(tr('Cannot delete this item because there are existing ' . 'purchase order items for it.'));
        return false;
    }
    return true;
}
//------------------------------------------------------------------------------------
if (isset($_POST['delete']) && strlen($_POST['delete']) > 1) {
    if (can_delete($_POST['NewStockID'])) {
        $stock_id = $_POST['NewStockID'];
        delete_item($stock_id);
        meta_forward($_SERVER['PHP_SELF']);
    }
}
//------------------------------------------------------------------------------------
start_form(true);
if (db_has_stock_items()) {
    start_table("class='tablestyle_noborder'");
    start_row();
    stock_items_list_cells(tr("Select an item:"), 'stock_id', null, null, null, null, 1);
    submit_cells('SelectStockItem', tr("Edit Item"));
    end_row();
    end_table();
}
hyperlink_params($_SERVER['PHP_SELF'], tr("Enter a new item"), "New=1");
echo "<br>";
function hunterslodge_customarmour_run()
{
    require_once "lib/sanitize.php";
    require_once "lib/names.php";
    global $session;
    $op = httpget("op");
    $free = httpget("free");
    $context = httpget("context");
    switch ($context) {
        case "village":
            $backlink = "village.php";
            break;
        case "forest":
            $backlink = "forest.php";
            break;
        case "worldmap":
            $backlink = "runmodule.php?module=worldmapen&op=continue";
            break;
        case "lodge":
            $backlink = "runmodule.php?module=iitems_hunterslodge&op=start";
            break;
    }
    page_header("Choose your Custom Armour");
    switch ($op) {
        case "change":
            output("Want to change your Custom Armour?  No problem.  Enter your desired armour in the box below.  You've got 25 characters to play around with.`n(leave this blank to disable custom armour naming and return to default, game-supplied armour names)`n`n");
            rawoutput("<form action='runmodule.php?module=hunterslodge_customarmour&op=confirm&free={$free}&context={$context}' method='POST'>");
            $armour = get_module_pref("customarmour");
            rawoutput("<input id='input' name='newarmour' width='25' maxlength='25' value='" . htmlentities($armour, ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "'>");
            rawoutput("<input type='submit' class='button' value='Preview'>");
            rawoutput("</form>");
            addnav("", "runmodule.php?module=hunterslodge_customarmour&op=confirm&free={$free}&context={$context}");
            addnav("Cancel");
            addnav("Don't set custom armour, just go back to where I came from", $backlink);
            break;
        case "confirm":
            $newarmour = httppost("newarmour");
            $sub = httpget("sub");
            $newarmour = str_replace("`", "", $newarmour);
            $newarmour = comment_sanitize($newarmour);
            $newarmour = substr($newarmour, 0, 25);
            if ($newarmour) {
                output("Your new custom armour is:`n%s`nWould you like to set your new armour now?`n`n", $newarmour);
            } else {
                output("You've chosen to go back to the default, game-supplied armours.  Are you sure that's what you want?`n`n");
            }
            addnav("Confirm");
            addnav("Set custom armour", "runmodule.php?module=hunterslodge_customarmour&op=set&free={$free}&context={$context}&newarmour=" . rawurlencode($newarmour));
            addnav("Cancel");
            addnav("Don't set custom armour, just go back to where I came from", $backlink);
            break;
        case "set":
            $newarmour = rawurldecode(httpget("newarmour"));
            if ($newarmour == "") {
                output("Your custom armour name has been removed.  The next time you change your armour, you'll return to game-supplied armour names.`n`n");
            } else {
                output("Your custom armour has been set to %s!`n`n", $newarmour);
                $session['user']['armor'] = $newarmour;
            }
            set_module_pref("customarmour", $newarmour);
            if (!$free) {
                require_once "modules/iitems/lib/lib.php";
                $id = has_item("hunterslodge_customarmour");
                delete_item($id);
            }
            addnav("Return");
            addnav("Return to where I came from", $backlink);
            break;
    }
    page_footer();
}
コード例 #16
0
ファイル: index3.php プロジェクト: sealucky7/lesson_7
        case 'Сохранить':
            $id = $_POST['hidden_id'];
            $_POST['date'] = $ads_db['db'][$id]['date'];
            $ads_db['db'][$id] = $_POST;
            break;
    }
    save_all($ads_db);
    file_put_serialize_contents(ADS_DB, $ads_db);
    // запись массива в файл
    header("Location: index3.php");
    exit;
}
// Обработка команд на удаление
if (isset($_GET['delete'])) {
    $del = $_GET['delete'];
    delete_item($del, $ads_db);
    header("Location: index3.php");
    exit;
}
// Вывод объявления
if (isset($_GET['show'])) {
    $change_id = $_GET['show'];
    $changeAd = $ads_db['db'][$change_id];
    //unset($_SESSION['show']);
}
?>


<?php 
require_once 'table.php';
// Вывод списка
コード例 #17
0
if (!$usersmenus->AsDansGuardianAdministrator) {
    $tpl = new templates();
    $alert = $tpl->_ENGINE_parse_body('{ERROR_NO_PRIVS}');
    echo "alert('{$alert}');";
    die;
}
if (isset($_GET["popup"])) {
    popup();
    exit;
}
if (isset($_GET["search"])) {
    search();
    exit;
}
if (isset($_POST["delete-item"])) {
    delete_item();
    exit;
}
if (isset($_GET["params"])) {
    params();
    exit;
}
if (isset($_POST["SquidDBBackupCatzMaxDay"])) {
    params_save();
    exit;
}
if (isset($_GET["f"])) {
    downloadfile();
    exit;
}
js();
コード例 #18
0
             $sql = "DELETE FROM " . PRUNE_TABLE . " WHERE forum_id = " . intval($item['id']);
             $db->sql_query($sql);
         } else {
             $sql = "SELECT * FROM " . PRUNE_TABLE . " WHERE forum_id = " . intval($item['id']);
             $result = $db->sql_query($sql);
             if ($db->sql_numrows($result) > 0) {
                 $sql = "UPDATE " . PRUNE_TABLE . "\n\t\t\t\t\t\t\t\tSET prune_days = " . intval($item['prune_days']) . ",\n\t\t\t\t\t\t\t\t\tprune_freq = " . intval($item['prune_freq']) . "\n\t\t\t\t\t\t\t\tWHERE forum_id = " . intval($item['id']);
             } else {
                 $sql = "INSERT INTO " . PRUNE_TABLE . "\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\tforum_id,\n\t\t\t\t\t\t\t\t\tprune_days,\n\t\t\t\t\t\t\t\t\tprune_freq\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tVALUES(\n\t\t\t\t\t\t\t\t\t" . intval($item['id']) . ",\n\t\t\t\t\t\t\t\t\t" . intval($item['prune_days']) . ",\n\t\t\t\t\t\t\t\t\t" . intval($item['prune_freq']) . "\n\t\t\t\t\t\t\t\t)";
             }
             $db->sql_query($sql);
         }
     }
     // clean previous if new created
     if ($new_item || $delete_forum) {
         delete_item($fid, $item['type'] . $item['id'], $item['move']);
     }
     // reorder
     reorder_tree();
     // end message
     $selected_id = $item['main'];
     $message = $lang['Forums_updated'] . $return_msg;
     message_die(GENERAL_MESSAGE, $message);
     exit;
 } else {
     // template
     $template->set_filenames(array('body' => ADM_TPL . 'forum_extend_edit_body.tpl'));
     // header
     $template->assign_vars(array('L_TITLE' => $lang['Edit_forum'], 'L_TITLE_EXPLAIN' => $lang['Forum_edit_delete_explain'], 'L_TYPE' => $lang['Forum_type'], 'L_NAME' => $lang['Forum_name'], 'L_NAME_CLEAN' => $lang['CLEAN_NAME'], 'L_DESC' => $lang['Forum_desc'], 'L_MAIN' => $lang['Category_attachment'], 'L_POSITION' => $lang['Position_after'], 'L_STATUS' => $lang['Forum_status'], 'L_MOVE' => $lang['Move_contents'], 'L_ICON' => $lang['icon'], 'L_ICON_EXPLAIN' => $lang['icon_explain'], 'L_PRUNE_ENABLE' => $lang['Forum_pruning'], 'L_ENABLED' => $lang['Enabled'], 'L_PRUNE_DAYS' => $lang['prune_days'], 'L_PRUNE_FREQ' => $lang['prune_freq'], 'L_FORUM_NOTIFY' => $lang['Forum_notify'], 'L_POSTCOUNT' => $lang['Forum_postcount'], 'L_MOD_OS_FORUMRULES' => $lang['MOD_OS_ForumRules'], 'L_FORUM_RULES' => $lang['Forum_rules'], 'L_RULES_DISPLAY_TITLE' => $lang['Rules_display_title'], 'L_RULES_CUSTOM_TITLE' => $lang['Rules_custom_title'], 'L_RULES_APPEAR_IN' => $lang['Rules_appear_in'], 'L_RULES_IN_VIEWFORUM' => $lang['Rules_in_viewforum'], 'L_RULES_IN_VIEWTOPIC' => $lang['Rules_in_viewtopic'], 'L_RULES_IN_POSTING' => $lang['Rules_in_posting'], 'L_LINK' => $lang['Forum_link'], 'L_FORUM_LINK' => $lang['Forum_link_url'], 'L_FORUM_LINK_EXPLAIN' => $lang['Forum_link_url_explain'], 'L_FORUM_LINK_INTERNAL' => $lang['Forum_link_internal'], 'L_FORUM_LINK_INTERNAL_EXPLAIN' => $lang['Forum_link_internal_explain'], 'L_FORUM_LINK_HIT_COUNT' => $lang['Forum_link_hit_count'], 'L_FORUM_LINK_HIT_COUNT_EXPLAIN' => $lang['Forum_link_hit_count_explain'], 'L_AUTH' => $lang['Auth_Control_Forum'], 'L_PRESET' => $lang['Presets'], 'L_SUBMIT' => $delete_forum ? $lang['Delete'] : $lang['Submit'], 'L_CANCEL' => $lang['Cancel'], 'L_REFRESH' => $lang['Refresh'], 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_DAYS' => $lang['Days']));
     // type select list
     $s_type_opt = '';
コード例 #19
0
ファイル: watchlist.php プロジェクト: oanav/closetshare
<?php

$i_userId = osc_logged_user_id();
if (Params::getParam('delete') != '' && osc_is_web_user_logged_in()) {
    delete_item(Params::getParam('delete'), $i_userId);
}
$itemsPerPage = Params::getParam('itemsPerPage') != '' ? Params::getParam('itemsPerPage') : 5;
$iPage = Params::getParam('iPage') != '' ? Params::getParam('iPage') : 0;
Search::newInstance()->addConditions(sprintf("%st_item_watchlist.fk_i_user_id = %d", DB_TABLE_PREFIX, $i_userId));
Search::newInstance()->addConditions(sprintf("%st_item_watchlist.fk_i_item_id = %st_item.pk_i_id", DB_TABLE_PREFIX, DB_TABLE_PREFIX));
Search::newInstance()->addTable(sprintf("%st_item_watchlist", DB_TABLE_PREFIX));
Search::newInstance()->page($iPage, $itemsPerPage);
$aItems = Search::newInstance()->doSearch();
$iTotalItems = Search::newInstance()->count();
$iNumPages = ceil($iTotalItems / $itemsPerPage);
View::newInstance()->_exportVariableToView('items', $aItems);
View::newInstance()->_exportVariableToView('search_total_pages', $iNumPages);
View::newInstance()->_exportVariableToView('search_page', $iPage);
// delete item from watchlist
function delete_item($item, $uid)
{
    $conn = getConnection();
    $conn->osc_dbExec("DELETE FROM %st_item_watchlist WHERE fk_i_item_id = %d AND fk_i_user_id = %d LIMIT 1", DB_TABLE_PREFIX, $item, $uid);
}
?>
<div class="row">
    <?php 
osc_current_web_theme_path('user-sidebar.php');
?>
    <div class="col-sm-8 col-md-9">
        <h1 class="title">
コード例 #20
0
ファイル: styles.php プロジェクト: acohn/grinnellplans-php
             $custom_style_form->append($item);
             $item = new HiddenInput('part', '1');
             $custom_style_form->append($item);
             $item = new SubmitInput('Submit');
             $custom_style_form->append($item);
         } else {
             if (get_item($dbh, "stylesheet", "stylesheet", "userid", $idcookie)) {
                 set_item($dbh, "stylesheet", "stylesheet", $urcss, "userid", $idcookie);
             } else {
                 add_row($dbh, "stylesheet", array($idcookie, $urcss));
             }
             $message = new InfoText('Style Set', 'Success');
             $thispage->append($message);
         }
     } else {
         delete_item($dbh, "stylesheet", "userid", $idcookie);
         $style = $_POST['style'];
         set_item($dbh, "display", "style", $style, "userid", $idcookie);
         //set the style that they selected
         $message = new InfoText('Style Set', 'Success');
         $thispage->append($message);
     }
     //if $style=custome, else
 }
 populate_page($thispage, $dbh, $idcookie);
 $my_result = mysql_query("Select style,descr From \n\t\t\t\t  style");
 //get currently available styles and their descriptions
 while ($new_row = mysql_fetch_row($my_result)) {
     $mystyles[] = $new_row;
 }
 $css = get_item($dbh, "stylesheet", "stylesheet", "userid", $idcookie);
コード例 #21
0
    case 'payment':
        $id = get_isset($_GET['id']);
        payment($id);
        header('Location: purchase.php?page=list&did=4');
        break;
    case 'add_menu':
        $item_id = get_isset($_GET['item_id']);
        $data = "'',\n\t\t\t\t\t'0',\n\t\t\t\t\t'{$item_id}',\n\t\t\t\t\t'0', \n\t\t\t\t\t'0',\n\t\t\t\t\t'" . $_SESSION['user_id'] . "'\n\t\t\t\t\t\n\t\t\t";
        create_config("purchase_details", $data);
        header("Location: purchase.php?page=form");
        break;
    case 'edit_price':
        $id = get_isset($_GET['id']);
        $qty = get_isset($_GET['qty']);
        $price = get_isset($_GET['price']);
        $data = "purchase_detail_qty = '{$qty}',\n\t\t\t\tpurchase_detail_price = '{$price}'\n\t\t\t\t\n\t\t";
        update_config("purchase_details", $data, "purchase_detail_id", $id);
        break;
    case 'edit_qty':
        $id = get_isset($_GET['id']);
        $qty = get_isset($_GET['qty']);
        $price = get_isset($_GET['price']);
        $data = "purchase_detail_qty = '{$qty}',\n\t\t\t\tpurchase_detail_price = '{$price}'\n\t\t\t\t\n\t\t";
        update_config("purchase_details", $data, "purchase_detail_id", $id);
        break;
    case 'delete_item':
        $id = get_isset($_GET['id']);
        delete_item($id);
        header("Location: purchase.php?page=form");
        break;
}
コード例 #22
0
ファイル: claimed.php プロジェクト: kkoves/limbo
                    <li><a href="lost.php">Lost Items</a></li>
                    <li><a href="found.php">Found Items</a></li>
                    <li><a href="claimed.php">Claimed Items</a></li>
                    <li><a href="compare.php">Compare Records</a></li>
					<li><a href="logout.php">Log Out</a></li>
                </ul>
                <a href="#" data-activates="slide-out" class="button-collapse show-on-large"><i class="mdi-navigation-menu"></i></a>
            </div>
        </header>
		<main>
            <div class="container">
				<?php 
require '../includes/connect_db.php';
require '../includes/helpers.php';
if (isset($_POST['deleteID'])) {
    delete_item($_POST['deleteID']);
}
?>
			    <!-- Modal dialog for "Lost & Found Item Detail" -->
				<div id="modal1" class="modal modal-fixed-footer">
					<div class="modal-content">
						<h4>Lost/Found Item Detail</h4>
						<p>
							<?php 
if (isset($_GET['id'])) {
    show_record($_GET['id']);
}
?>
						</p>
					</div>
					<div class="modal-footer">
コード例 #23
0
$nid = is_npc($npc);
$tr = do_mysql("SELECT drop2 FROM npc WHERE id_npc = '" . $nid . "';");
$tr = mysql_result($tr, 0);
$tr = explode('|', $tr);
if (strpos($tr[0], substr($item, 2, 1)) === false && $tr[0] != '*') {
    put_error('торговец не покупает эти виды вещей');
}
if ($count > $iin['on_take']) {
    $count = $iin['on_take'];
}
// cena
$cost = round($iin['price'] * $count * $tr[2]);
$p['money'] += $cost;
do_mysql("UPDATE players SET money = '" . $p['money'] . "' WHERE id_player = '" . $p['id_player'] . "';");
if ($count == $iin['on_take']) {
    // beretsja vsja veshq
    // udaljaem veshq von
    include_once 'modules/f_delete_item.php';
    delete_item($item);
} else {
    include_once 'modules/f_decrease_misc.php';
    decrease_misc($item, $count);
}
// vse, veshq prodali, teperq vyvodim stranicu
$f = gen_header('торг');
$f .= '<div class="y" id="oaidy"><b>продажа:</b></div><p>';
$f .= 'вы продали ' . $count . ' ' . $iin['name'] . ' за ' . $cost . ' серебра!<br/>';
$f .= '<a class="blue" href="game.php?sid=' . $sid . '&action=trade&npc=' . $npc . '&start=' . $_GET['start'] . '&start2=' . $_GET['start2'] . '">торг</a><br/>';
$f .= '<a class="blue" href="game.php?sid=' . $sid . '">в игру</a></p>';
$f .= gen_footer();
exit($f);
function eboy_run()
{
    global $session, $inventory;
    if (!isset($inventory)) {
        load_inventory();
    }
    page_header("eBoy's Trading Station");
    addnav("Buy Items");
    addnav("Sell Items");
    require_once "modules/cityprefs/lib.php";
    $cid = get_cityprefs_cityid("location", $session['user']['location']);
    $item = httpget('item');
    if ($item) {
        $curstock = get_item_setting("eboy_stock_" . $cid, $item);
        $curprice = get_item_setting("eboy_price_" . $cid, $item);
    }
    eboy_updateprices();
    $eboy_info = get_items_with_settings("eboy");
    if (httpget('op') == "start") {
        output("Already fearing the worst, you head into eBoy's Trading Station.`n`nYour fears are well-founded.  The place is packed with the heaving, sweaty bodies of the hardcore capitalist, shouting \"`iBuy, buy!`i\" and \"`iSell, sell!`i\" and \"`iPut down the chainsaw and let's talk about this!`i\"`n`neBoy himself - although you suspect that this place, like Mike's Chop Shop, is a franchise of which you'll find one in every outpost, so is his name really eBoy?  Whoever he is, he stands on an elevated section of floor behind a tall mahogany counter, grabbing money with one hand and tossing grenades and ration packs over his shoulder with the other.  His arms are a blur.  His speech is the unintelligible, rapid-fire gabble of a professional auctioneer.  His eyes bulge and swivel.  You know he's loving this.`n`n");
    }
    if (httpget('op') == "buy") {
        $pprice = httpget('price');
        if ($pprice == $curprice) {
            if ($curstock > 0) {
                give_item($item);
                $session['user']['gold'] -= $curprice;
                increment_item_setting("eboy_stock_" . $cid, -1, $item);
                output("You fight your way to the front of the crowd and shout your order up to eBoy, slapping your Requisition tokens down on the counter.  Before you can blink, your money is gone and the item you desired sits in its place.  You grab it hastily and stuff it into your backpack as eBoy turns to deal with the next customer.`n`n");
            } else {
                output("eBoy turns to you and gibbers.`n`n\"Sorrymatejustsoldthelastoneyougottabefasteritsthequickandthedeadaroundherepal.\"  He turns to the next customer in line, leaving you trying to piece together whatever it is that he just said.`n`n");
            }
        } else {
            output("You fight your way to the front of the crowd and shout your order up to eBoy, slapping your Requisition tokens down on the counter.  eBoy turns to you and gibbers.`n`n\"Idontmeantobefunnymatebutlookattheboardthepricehasjustbloodychangedagainyousureyoustillwannabuy?\"  After giving you exactly one microsecond to consider what the hell he just asked, he rolls his eyes and turns to the next customer in line.`n`n");
        }
    }
    if (httpget('op') == "sell") {
        $pprice = httpget('price');
        $requiredprefs = array("inventorylocation" => "main");
        $itemid = has_item($item, $requiredprefs);
        if ($pprice == $curprice) {
            delete_item($itemid);
            if ($curstock < 3) {
                $buy = round($curprice * 0.5);
            } else {
                $buy = round($curprice * 0.7);
            }
            $session['user']['gold'] += $buy;
            increment_item_setting("eboy_stock_" . $cid, 1, $item);
            output("You barge your way through the crowd like a battleship through an ice floe, and toss your item up to eBoy.  eBoy snatches the item out of the air with his left hand while tossing your Requisition tokens back at you with his right, and goes on to serve the next customer.`n`n");
        } else {
            output("You fight your way to the front of the crowd and shout your order up to eBoy, slapping your Requisition tokens down on the counter.  eBoy turns to you and gibbers.`n`n\"Idontmeatobefunnymatebutlookattheboardthepricehasjustbloodychangedagainyousureyoustillwannasell?\"  After giving you exactly one microsecond to consider what the hell he just asked, he rolls his eyes and turns to the next customer in line.`n`n");
        }
    }
    output("You look up above eBoy's head at the trading board, the values of each commodity displayed on a mechanical readout which clatters and changes constantly.`n`n");
    $sellable_inventory = array();
    foreach ($inventory as $itemid => $prefs) {
        if (!$prefs['carrieritem'] && $prefs['eboy'] && $prefs['inventorylocation'] == "main") {
            $sellable_inventory[$prefs['item']]['quantity'] += 1;
            $sellable_inventory[$prefs['item']]['itemids'][] = $itemid;
        }
    }
    eboy_updateprices();
    $eboy_info = get_items_with_settings("eboy");
    //inventory-type display routine
    rawoutput("<table width=100% style='border: dotted 1px #000000;'>");
    $classcount = 1;
    foreach ($eboy_info as $item => $settings) {
        if ($settings['eboy_stock_' . $cid] > 0) {
            $stock = number_format($settings['eboy_stock_' . $cid]) . " available";
        } else {
            $stock = "`4Sold Out`0";
        }
        $classcount++;
        $class = $classcount % 2 ? "trdark" : "trlight";
        rawoutput("<tr class='{$class}'><td>");
        if ($settings['image']) {
            rawoutput("<table width=100% cellpadding=0 cellspacing=0><tr><td width=100px align=center><img src=\"images/items/" . $settings['image'] . "\"></td><td>");
        }
        output("`b%s`b`n", stripslashes($settings['verbosename']));
        output("%s`n", stripslashes($settings['description']));
        if ($settings['weight']) {
            output("Weight: %s kg`n", $settings['weight']);
        }
        rawoutput("<table width=100%><tr><td width=50%>");
        output("`bStock:`b %s", $stock);
        if ($settings['eboy_stock_' . $cid] < 3) {
            $buy = round($settings['eboy_price_' . $cid] * 0.5);
        } else {
            $buy = round($settings['eboy_price_' . $cid] * 0.7);
        }
        if ($settings['eboy_price_' . $cid] > 0) {
            output("`n`7Buying at: %s Requisition", number_format($buy));
        } else {
            output("`nNot Buying");
        }
        if ($settings['eboy_stock_' . $cid] > 0) {
            output("`n`2Selling at: %s Requisition`n`n", number_format($settings['eboy_price_' . $cid]));
        } else {
            output("`n`n");
        }
        rawoutput("</td><td width=50%>");
        $requiredprefs = array("inventorylocation" => "main");
        if ($sellable_inventory[$item]) {
            addnav("Sell Items");
            if ($settings['eboy_stock_' . $cid] < 3) {
                $buy = round($settings['eboy_price_' . $cid] * 0.5);
            } else {
                $buy = round($settings['eboy_price_' . $cid] * 0.7);
            }
            if ($sellable_inventory[$item]['quantity'] > 0 && $settings['eboy_price_' . $cid] > 0) {
                addnav(array("%s (%s available)", $settings['verbosename'], $sellable_inventory[$item]['quantity']), "runmodule.php?module=eboy&op=sell&item=" . $item . "&price=" . $settings['eboy_price_' . $cid], true);
                addnav("", "runmodule.php?module=eboy&op=sell&item=" . $item . "&price=" . $settings['eboy_price_' . $cid]);
                rawoutput("<a href=\"runmodule.php?module=eboy&op=sell&item=" . $item . "&price=" . $settings['eboy_price_' . $cid] . "\">Sell for <strong>" . number_format($buy) . " </strong> Requisition (" . $sellable_inventory[$item]['quantity'] . " available to sell)</a><br />");
            }
        } else {
            output("`&You don't have any of this item to sell.`0`n");
        }
        if ($session['user']['gold'] >= $settings['eboy_price_' . $cid] && $settings['eboy_stock_' . $cid]) {
            addnav("Buy Items");
            addnav(array("%s (%s Req)", $settings['verbosename'], $settings['eboy_price_' . $cid]), "runmodule.php?module=eboy&op=buy&item=" . $item . "&price=" . $settings['eboy_price_' . $cid], true);
            addnav("", "runmodule.php?module=eboy&op=buy&item=" . $item . "&price=" . $settings['eboy_price_' . $cid]);
            rawoutput("<a href=\"runmodule.php?module=eboy&op=buy&item=" . $item . "&price=" . $settings['eboy_price_' . $cid] . "\">Buy for <strong>" . number_format($settings['eboy_price_' . $cid]) . "</strong> Requisition</a><br />");
        } else {
            if (!$settings['eboy_stock_' . $cid]) {
                output("`&There are no items of this type available.`0`n");
            } else {
                $difference = $settings['eboy_price_' . $cid] - $session['user']['gold'];
                output("`&You need another %s Requisition to buy this item.`0`n", number_format($difference));
            }
        }
        rawoutput("</td></tr></table>");
        if ($settings['image']) {
            rawoutput("</td></tr></table>");
        }
        rawoutput("</td></tr>");
    }
    rawoutput("</td></tr></table>");
    addnav("Leave");
    addnav("Return to the Outpost", "village.php");
    addnav("Inventory");
    addnav("View your Inventory", "inventory.php?items_context=eboy");
    //set_module_objpref("city",$cid,"eboytrades-intelligent",serialize($info));
    page_footer();
    return true;
}
function hunterslodge_customcolours_run()
{
    require_once "lib/sanitize.php";
    require_once "lib/names.php";
    global $session;
    $op = httpget("op");
    $free = httpget("free");
    $context = httpget("context");
    switch ($context) {
        case "village":
            $backlink = "village.php";
            break;
        case "forest":
            $backlink = "forest.php";
            break;
        case "worldmap":
            $backlink = "runmodule.php?module=worldmapen&op=continue";
            break;
        case "lodge":
            $backlink = "runmodule.php?module=iitems_hunterslodge&op=start";
            break;
    }
    page_header("Choose your Custom Colours");
    switch ($op) {
        case "change":
            output("Want to change your name colours?  No problem.  Enter your desired name, using colour codes, in the box below.  You've got 30 characters to play around with, including colour codes.`n`n");
            namecolour_form();
            addnav("Cancel");
            addnav("Don't change colours, just go back to where I came from", $backlink);
            break;
        case "confirm":
            $newname = httppost("newname");
            $newname = str_replace("`0", "", httppost("newname"));
            $newname = str_replace("`b", "", $newname);
            $newname = str_replace("`i", "", $newname);
            $newname = str_replace("`n", "", $newname);
            $newname = preg_replace("/[`][cHw]/", "", $newname);
            $regname = get_player_basename();
            $comp1 = strtolower(sanitize($regname));
            $comp2 = strtolower(sanitize($newname));
            $err = 0;
            if ($comp1 != $comp2) {
                if (!$err) {
                    output("`4`bInvalid name`b`0`n");
                }
                $err = 1;
                output("Your new name must contain only the same characters as your current name; you can add or remove colors, and you can change the capitalization, but you may not add or remove anything else. You chose %s.`0`n`n", $newname);
            }
            if (strlen($newname) > 30) {
                if (!$err) {
                    output("`4`bInvalid name`b`0`n");
                }
                $err = 1;
                output("Your new name is too long.  Including the color markups, you are not allowed to exceed 30 characters in length.`n`n");
            }
            if (!$err) {
                output("`0Your name will look this this: %s`n`n`0Do you want to set your new name colours now?`n`n", $newname);
                addnav("Confirm");
                addnav("Set the new name colours", "runmodule.php?module=hunterslodge_customcolours&op=set&free={$free}&context={$context}&newname=" . rawurlencode($newname));
                addnav("Cancel");
                addnav("Don't change colours, just go back to where I came from", $backlink);
            } else {
                addnav("Cancel");
                addnav("Don't change colours, just go back to where I came from", $backlink);
            }
            output("`0Change your name again below, if you like.`n`n");
            namecolour_form();
            break;
        case "set":
            $fromname = $session['user']['name'];
            $newname = change_player_name(rawurldecode(httpget('newname')));
            $session['user']['name'] = $newname;
            output("You are now known as %s!`0`n`n", $session['user']['name']);
            if (!$free) {
                $id = has_item("hunterslodge_customcolours");
                delete_item($id);
            }
            addnav("Return");
            addnav("Go back to where I came from", $backlink);
            break;
    }
    page_footer();
}
function staminafood_run()
{
    global $session;
    $pmeat1 = has_item_quantity("meat_low");
    $pmeat2 = has_item_quantity("meat_medium");
    $pmeat3 = has_item_quantity("meat_high");
    addnav("Eat");
    switch (httpget("op")) {
        case "sellmeat":
            switch ($session['user']['location']) {
                case "NewHome":
                    page_header("Joe's Diner");
                    if (httpget('q') == 1) {
                        delete_item(has_item("meat_medium"));
                        $session['user']['gold'] += 5;
                        output("With a surly grunt, Joe grabs your meat and slaps down five Requisition tokens.`n`n");
                    } else {
                        for ($i = 1; $i <= $pmeat2; $i++) {
                            delete_item(has_item("meat_medium"));
                            $session['user']['gold'] += 5;
                        }
                        output("With a surly grunt, Joe grabs your meat and slaps down %s Requisition tokens.`n`n", $pmeat2 * 5);
                    }
                    break;
                case "New Pittsburgh":
                    page_header("BRAAAAAINS");
                    if (httpget('q') == 1) {
                        delete_item(has_item("meat_medium"));
                        $session['user']['gold'] += 6;
                        output("With a nod, the waiter takes your meat and hands back six Requisition tokens.`n`n");
                    } else {
                        for ($i = 1; $i <= $pmeat2; $i++) {
                            delete_item(has_item("meat_medium"));
                            $session['user']['gold'] += 6;
                        }
                        output("With a nod, the waiter takes your meat and hands back %s Requisition tokens.`n`n", $pmeat2 * 6);
                    }
                    break;
                case "Kittania":
                    page_header("Cool Springs Cafe");
                    if (httpget('q') == 1) {
                        delete_item(has_item("meat_high"));
                        $session['user']['gold'] += 12;
                        output("With a warm smile, the waitress takes your meat and hands back twelve Requisition tokens.`n`n");
                    } else {
                        for ($i = 1; $i <= $pmeat3; $i++) {
                            delete_item(has_item("meat_high"));
                            $session['user']['gold'] += 12;
                        }
                        output("With a warm smile, the waitress takes your meat and hands back %s Requisition tokens.`n`n", $pmeat3 * 12);
                    }
                    break;
                case "Squat Hole":
                    page_header("Kebabs 'N' S***e");
                    if (httpget('q') == 1) {
                        delete_item(has_item("meat_low"));
                        $session['user']['gold'] += 2;
                        output("With a squeaky \"Ta mate,\" the Midget behind the counter relieves you of the stinking yellow meat and hands back two Requisition tokens.`n`n");
                    } else {
                        for ($i = 1; $i <= $pmeat1; $i++) {
                            delete_item(has_item("meat_low"));
                            $session['user']['gold'] += 2;
                        }
                        output("With a squeaky \"Ta mate,\" the Midget behind the counter relieves you of the stinking yellow meat and hands back %s Requisition tokens.`n`n", $pmeat1 * 2);
                    }
                    break;
            }
            break;
        case "start":
            switch (httpget("location")) {
                case "nh":
                    page_header("Joe's Diner");
                    output("`0You head into what presents itself as a 1950's-style diner.  Plastic red and white gingham patterns cover every available surface.  Tomato-shaped ketchup bottles are dotted on tables here and there, dried gunge crusting their nozzles.  Behind the bar can be seen Joe, the owner, who is keeping himself busy wiping down the counter tops with a rag, redistributing the half-inch-thick layer of grease into a more uniform level.  A sign above the counter reads \"`2WE BUY MEAT.  WE PAY 5 REQ PER 120 GRAM'S.`0\"`n`n");
                    if ($session['user']['race'] != "Robot") {
                        output("The smell of fried onions does its wicked work, and you glance up at the menu.`n`n");
                        if (get_module_pref("fullness") <= 100) {
                            if ($session['user']['gold'] >= 10) {
                                addnav("Crisps (10 Req)", "runmodule.php?module=staminafood&op=buy&bought=1");
                            } else {
                                output("After a careful read of the menu, you realise that you can't afford a single thing on it.  Bah.");
                            }
                            if ($session['user']['gold'] >= 40) {
                                addnav("Garden Salad (40 Req)", "runmodule.php?module=staminafood&op=buy&bought=2");
                            }
                            if ($session['user']['gold'] >= 50) {
                                addnav("Plate of Chips (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=3");
                                addnav("Coffee (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=4");
                            }
                            if ($session['user']['gold'] >= 150) {
                                addnav("Bangers & Mash (150 Req)", "runmodule.php?module=staminafood&op=buy&bought=5");
                            }
                            if ($session['user']['gold'] >= 300) {
                                addnav("Cheeseburger (300 Req)", "runmodule.php?module=staminafood&op=buy&bought=6");
                            }
                        } else {
                            output("You are far too full to eat any more today.`n`n");
                        }
                    }
                    if ($pmeat2) {
                        output("You remember that Maiko told you that the NewHome diner will only buy middling-quality meat.  You have %s pieces of average-quality meat to sell.  All of them, quite conveniently - perhaps a little TOO conveniently - weigh exactly a hundred and twenty grams each.`n`n", $pmeat2);
                        addnav("Sell Meat");
                        addnav("Sell one piece", "runmodule.php?module=staminafood&op=sellmeat&q=1");
                        if ($pmeat2 > 1) {
                            addnav("Sell all Meat", "runmodule.php?module=staminafood&op=sellmeat&q=all");
                        }
                    }
                    break;
                case "ki":
                    page_header("Cool Springs Cafe");
                    output("You head into what at first appears to be a little hut.  As you work down the stairs into the rock underneath Kittania, you realise that this place is so much more.`n`nStrings of fairy lights illuminate the cavern, and soft trickling sounds can be heard against the laughter and conversation of KittyMorphs around you.`n`nYou take a seat and a white-furred KittyMorph approaches, a menu in her hand.  \"Welcome to the Cool Springs Cafe,\" she says with a smile.  \"We try to tread on Mother Earth as lightly as we can, in here; all of our produce is locally-grown, you'll find a wonderful selection of vegetarian and vegan meals, and the various waters come from the three springs that run through this very cavern.  Now, what can I get you?\"`n`nYou peruse the menu, your eyes lingering on the last entry, detailing a rare, dripping, bloody steak.  The KittyMorph follows your gaze, and laughs sheepishly.  \"Like I said, we `itry`i,\" she giggles, elongated canines peeking out.  \"We `iare`i carnivores, you know.  Oh, on that note, I should mention that we also buy meat, if you've got any of the good stuff to sell.  We pay twelve Requisition per slice.\"`n`n");
                    if ($session['user']['race'] != "Robot") {
                        if (get_module_pref("fullness") <= 100) {
                            if ($session['user']['gold'] >= 50) {
                                addnav("Hot Chocolate (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=7");
                                addnav("White Spring Water (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=8");
                            } else {
                                output("After a careful read of the menu, you realise that you can't afford a single thing on it.  Bah.");
                            }
                            if ($session['user']['gold'] >= 100) {
                                addnav("Nut and Berry Salad (100 Req)", "runmodule.php?module=staminafood&op=buy&bought=9");
                            }
                            if ($session['user']['gold'] >= 175) {
                                addnav("Turquoise Spring Water (175 Req)", "runmodule.php?module=staminafood&op=buy&bought=10");
                            }
                            if ($session['user']['gold'] >= 250) {
                                addnav("Red Spring Water (250 Req)", "runmodule.php?module=staminafood&op=buy&bought=11");
                            }
                            if ($session['user']['gold'] >= 500) {
                                addnav("Still-Twitching Steak (500 Req)", "runmodule.php?module=staminafood&op=buy&bought=12");
                            }
                        } else {
                            output("You are far too full to eat any more today.`n`n");
                        }
                    }
                    if ($pmeat3) {
                        output("You remember that Maiko told you that the Kittania cafe will only buy the best-quality meat.  You have %s pieces of high-quality meat to sell.`n`n", $pmeat3);
                        addnav("Sell Meat");
                        addnav("Sell one piece", "runmodule.php?module=staminafood&op=sellmeat&q=1");
                        if ($pmeat3 > 1) {
                            addnav("Sell all Meat", "runmodule.php?module=staminafood&op=sellmeat&q=all");
                        }
                    }
                    break;
                case "np":
                    page_header("BRAAAAAINS");
                    output("You head into the local cafe, imaginatively titled \"BRAAAAAINS\".  A waiter comes shuffling over to you, green skin peeling from his face.  \"BRAAAAAINS?\" he asks, holding out a menu.`n`nA sign above the counter says \"We are only too happy to buy your surplus meat.  We pay 6 Requisition tokens per 120 grams.\"`n`n");
                    if ($session['user']['race'] != "Robot") {
                        if (get_module_pref("fullness") <= 100) {
                            if ($session['user']['gold'] >= 50) {
                                addnav("Egg and Brains (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=13");
                            } else {
                                output("After a careful read of the menu, you realise that you can't afford a single thing on it.  Bah.");
                            }
                            if ($session['user']['gold'] >= 100) {
                                addnav("Sausage and Brains (100 Req)", "runmodule.php?module=staminafood&op=buy&bought=14");
                            }
                            if ($session['user']['gold'] >= 150) {
                                addnav("Spam and Brains (150 Req)", "runmodule.php?module=staminafood&op=buy&bought=15");
                            }
                            if ($session['user']['gold'] >= 200) {
                                addnav("Egg, Brains, Sausage and Brains (200 Req)", "runmodule.php?module=staminafood&op=buy&bought=16");
                            }
                            if ($session['user']['gold'] >= 250) {
                                addnav("Brains, Spam, Brains, Sausage and Brains (250 Req)", "runmodule.php?module=staminafood&op=buy&bought=17");
                            }
                            if ($session['user']['gold'] >= 300) {
                                addnav("Brains, Brains, Brains, Brains and Spam (300 Req)", "runmodule.php?module=staminafood&op=buy&bought=18");
                            }
                        } else {
                            output("You are far too full to eat any more today.`n`n");
                        }
                    }
                    if ($pmeat2) {
                        output("You remember that Maiko told you that the New Pittsburgh diner will only buy middling-quality meat.  You have %s pieces of average-quality meat to sell.  All of them, quite conveniently - perhaps a little TOO conveniently - weigh a hundred and twenty grams each.`n`n", $pmeat2);
                        addnav("Sell Meat");
                        addnav("Sell one piece", "runmodule.php?module=staminafood&op=sellmeat&q=1");
                        if ($pmeat2 > 1) {
                            addnav("Sell all Meat", "runmodule.php?module=staminafood&op=sellmeat&q=all");
                        }
                    }
                    break;
                case "sq":
                    page_header("Kebabs 'N' S***e");
                    output("You head into the local kebab house.  As you're studying the menu, a Midget brushes past you, dragging a six-foot blue plastic bag with the words \"INCINERATE ONLY\" stencilled on the side.  He stops, glares up at you, and mutters \"Yer din't see `inuffink.`i\"  Then he resumes his journey, dragging the bag into the back of the shop.  You're sure you saw a bit of steering wheel poking out.`n`nA sign above the counter reads \"WE BY MEET 2 REK PER BIT\"`n`n");
                    if ($session['user']['race'] != "Robot") {
                        if (get_module_pref("fullness") <= 100) {
                            if ($session['user']['gold'] >= 20) {
                                addnav("Crisps (20 Req)", "runmodule.php?module=staminafood&op=buy&bought=25");
                            } else {
                                output("After a careful read of the menu, you realise that you can't afford a single thing on it.  Bah.");
                            }
                            if ($session['user']['gold'] >= 50) {
                                addnav("Skinheads on a Raft (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=26");
                            }
                            if ($session['user']['gold'] >= 75) {
                                addnav("Doner Kebab (75 Req)", "runmodule.php?module=staminafood&op=buy&bought=27");
                                addnav("Crimson Pitbull (75 Req)", "runmodule.php?module=staminafood&op=buy&bought=28");
                            }
                            if ($session['user']['gold'] >= 150) {
                                addnav("C**k Nuggets (150 Req)", "runmodule.php?module=staminafood&op=buy&bought=29");
                            }
                            if ($session['user']['gold'] >= 200) {
                                addnav("Sausage Feast Pizza (200 Req)", "runmodule.php?module=staminafood&op=buy&bought=30");
                            }
                        } else {
                            output("You are far too full to eat any more today.`n`n");
                        }
                    }
                    if ($pmeat1) {
                        output("You remember that Maiko told you that the Squat Hole kebab shop only buys the sort of meat that the dog food factory would throw away.  You have %s wobbling chunks of Crap Meat to sell.`n`n", $pmeat1);
                        addnav("Sell Meat");
                        addnav("Sell one piece", "runmodule.php?module=staminafood&op=sellmeat&q=1");
                        if ($pmeat1 > 1) {
                            addnav("Sell all Meat", "runmodule.php?module=staminafood&op=sellmeat&q=all");
                        }
                    }
                    break;
                case "pl":
                    page_header("Mutated Munchies");
                    if ($session['user']['race'] != "Robot") {
                        output("You head into the local cafe.  The stench of vomit and disinfectant hangs in the air.  Bravely, you sit down at a table and peruse the menu.`n`n");
                        if (get_module_pref("fullness") <= 100) {
                            if ($session['user']['gold'] >= 100) {
                                addnav("Wriggly Biscuits (100 Req)", "runmodule.php?module=staminafood&op=buy&bought=19");
                            } else {
                                output("After a careful read of the menu, you realise that you can't afford a single thing on it.  Bah.");
                            }
                            if ($session['user']['gold'] >= 200) {
                                addnav("Phallic Nuts (200 Req)", "runmodule.php?module=staminafood&op=buy&bought=20");
                            }
                            if ($session['user']['gold'] >= 300) {
                                addnav("Noodly Noodles (300 Req)", "runmodule.php?module=staminafood&op=buy&bought=21");
                            }
                            if ($session['user']['gold'] >= 400) {
                                addnav("Three-Eyed Fish (400 Req)", "runmodule.php?module=staminafood&op=buy&bought=22");
                            }
                            if ($session['user']['gold'] >= 500) {
                                addnav("Magical Mystery Meatloaf (500 Req)", "runmodule.php?module=staminafood&op=buy&bought=23");
                            }
                            if ($session['user']['gold'] >= 750) {
                                addnav("Mutant Steak (750 Req)", "runmodule.php?module=staminafood&op=buy&bought=24");
                            }
                        } else {
                            output("You are far too full to eat any more today.`n`n");
                        }
                    } else {
                        output("You are a robot, and this place doesn't buy meat.  You have no business here.  Out with you!`n`n");
                    }
                    break;
            }
            break;
        case "buy":
            page_header("Om nom nom");
            require_once "modules/staminasystem/lib/lib.php";
            switch (httpget("bought")) {
                case 1:
                    output("You munch happily on your crisps, reflecting that they're probably not too good for you - but hell, at least they're cheap.`n`nYou gain some Stamina!");
                    $st = 5000;
                    $nu = 5;
                    $fa = 10;
                    $fu = 5;
                    $co = 10;
                    break;
                case 2:
                    output("You pick the snails out of your Garden Salad, and tuck in.`n`nYou gain some Stamina!");
                    $st = 18000;
                    $nu = 15;
                    $fa = 0;
                    $fu = 10;
                    $co = 40;
                    break;
                case 3:
                    output("You wolf down your plate of chips.  They're like little brown paper bags filled with pus, but damn it, you paid good money for these and you're going to eat them come Hell or high water.`n`nYou gain some Stamina!");
                    $st = 25000;
                    $nu = 20;
                    $fa = 30;
                    $fu = 25;
                    $co = 50;
                    break;
                case 4:
                    output("The coffee swirls grittily down your throat.  You feel like you have more energy!");
                    apply_stamina_buff('newhomedinercoffee', array("name" => "Caffeine Rush", "action" => "Global", "costmod" => 0.8, "expmod" => 1, "rounds" => 20, "roundmsg" => "Your Caffeine Rush makes everything a little bit easier!", "wearoffmsg" => "The effects of the caffeine seem to have worn off."));
                    $co = 50;
                    break;
                case 5:
                    output("It's not so much Bangers and Mash as Mingers and Mush, but you get stuck in anyway.`n`nYou gain some Stamina!");
                    $st = 105000;
                    $nu = 40;
                    $fa = 30;
                    $fu = 40;
                    $co = 150;
                    break;
                case 6:
                    output("You can has cheeseburger!  Well, it's not so much \"cheese\" as \"unidentifiable bright orange goo\", but I'm sure you'll live.`n`nYou gain some Stamina!");
                    $st = 225000;
                    $nu = 60;
                    $fa = 40;
                    $fu = 25;
                    $co = 300;
                    break;
                case 7:
                    output("You sip your hot chocolate, listening to the babbling brooks.  Life ain't so bad.`n`nYou gain some Stamina!");
                    $st = 25000;
                    $nu = 10;
                    $fa = 10;
                    $fu = 15;
                    $co = 50;
                    break;
                case 8:
                    output("There's something very odd about the water from the White Spring.  You feel light on your feet.  It seems to make everything easier, somehow.");
                    apply_stamina_buff('whitespringwater', array("name" => "White Spring Lightness", "action" => "Global", "costmod" => 0.8, "expmod" => 1, "rounds" => 20, "roundmsg" => "The waters of the White Spring seem to be making everything a little easier.", "wearoffmsg" => "The White Spring effects seem to have worn off."));
                    $co = 50;
                    break;
                case 9:
                    output("You scarf down your salad of nuts and berries, secretly wishing for a nice juicy steak.`n`nYou gain some Stamina!");
                    $st = 65000;
                    $nu = 25;
                    $fa = 5;
                    $fu = 10;
                    $co = 100;
                    break;
                case 10:
                    output("The water from the Turquoise Spring is served at room temperature, but somehow tastes very cold.  After a few moments, your eyesight improves; you can make out individual facets of a crystal buried in the far wall of the cavern.  This should make it a bit easier to hunt down monsters!");
                    apply_stamina_buff('turquoisespringwater', array("name" => "Turquoise Sight", "class" => "Hunting", "costmod" => 0.5, "expmod" => 1, "rounds" => 3, "roundmsg" => "Thanks to your heightened senses granted by the waters of the Turquoise Spring, hunting for monsters seems a lot easier now.", "wearoffmsg" => "The effects of the Turquoise Spring water have worn off, and your senses return to their usual state."));
                    $co = 175;
                    break;
                case 11:
                    output("You down the water from the Red Spring.  There's a distinct taste of iron in there.  After a few moments, you become anxious - surely there must be something around here that you can engage in combat...");
                    apply_stamina_buff('redspringwater', array("name" => "Red Haze", "class" => "Combat", "costmod" => 0.5, "expmod" => 1, "rounds" => 20, "roundmsg" => "The waters of the Red Spring make fighting seem more natural and fluid.  You're not expending nearly as much Stamina as usual.", "wearoffmsg" => "The effects of the Red Spring water have worn off, and your senses return to their natural state."));
                    $co = 250;
                    break;
                case 12:
                    output("The menu described a still-twitching steak, and boy, it delivered.  Steam rises from the plate of raw muscle in front of you.  The meat jerks and spasms as it reacts to the sudden flood of oxygen, slapping gently against the plate.  Your mouth waters, and you can see some nearby KittyMorphs glancing jealously in your direction.  You wolf it down before they get any ideas.`n`nYou gain some Stamina!");
                    $st = 385000;
                    $nu = 100;
                    $fa = 10;
                    $fu = 80;
                    $co = 500;
                    break;
                case 13:
                    output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!");
                    $st = 25000;
                    $nu = 10;
                    $fa = 10;
                    $fu = 10;
                    $co = 50;
                    break;
                case 14:
                    output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!");
                    $st = 65000;
                    $nu = 20;
                    $fa = 20;
                    $fu = 20;
                    $co = 100;
                    break;
                case 15:
                    output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!");
                    $st = 105000;
                    $nu = 30;
                    $fa = 30;
                    $fu = 30;
                    $co = 150;
                    break;
                case 16:
                    output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!");
                    $st = 145000;
                    $nu = 40;
                    $fa = 40;
                    $fu = 40;
                    $co = 200;
                    break;
                case 17:
                    output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!");
                    $st = 185000;
                    $nu = 50;
                    $fa = 50;
                    $fu = 50;
                    $co = 250;
                    break;
                case 18:
                    output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!");
                    $st = 225000;
                    $nu = 60;
                    $fa = 60;
                    $fu = 60;
                    $co = 300;
                    break;
                case 19:
                    output("You chew thoughtfully on your Wriggly Biscuits.  They live up to their name quite adequately.`n`nYou gain some Stamina!");
                    $st = 65000;
                    $nu = 20;
                    $fa = 10;
                    $fu = 10;
                    $co = 100;
                    break;
                case 20:
                    output("You run your tongue lovingly up, down and around the extremely phallic nuts, savouring their delightfully salty flavour.`n`nYou gain some Stamina!");
                    $st = 145000;
                    $nu = 40;
                    $fa = 10;
                    $fu = 20;
                    $co = 200;
                    break;
                case 21:
                    output("The Noodly Noodles jerk and spasm, each bite releasing a sticky yellow goo.  Tasty!`n`nYou gain some Stamina!");
                    $st = 225000;
                    $nu = 40;
                    $fa = 10;
                    $fu = 20;
                    $co = 300;
                    break;
                case 22:
                    output("You stare down at your three-eyed fish.  It stares back up at you, in ways that you can only imagine.  After a few moments of depressed contemplation, you tuck in - and hey, it's actually not that bad.`n`nYou gain some Stamina!");
                    $st = 305000;
                    $nu = 50;
                    $fa = 25;
                    $fu = 40;
                    $co = 400;
                    break;
                case 23:
                    output("As your fork sinks into your Magical Mystery Meatloaf, a hundred pairs of eyes open on its crispy skin.  They close again almost instantly, and you try your hardest to persuade yourself that you were hallucinating from the disinfectant fumes - it beats reality, that's for damn sure.`n`nYou gain some Stamina!");
                    $st = 385000;
                    $nu = 50;
                    $fa = 25;
                    $fu = 50;
                    $co = 500;
                    break;
                case 24:
                    output("The Mutant Steak is lean, delicious, nutritious and as big as your head!  What a pleasant surprise!`n`nYou gain some Stamina!");
                    $st = 585000;
                    $nu = 150;
                    $fa = 10;
                    $fu = 80;
                    $co = 750;
                    break;
                case 25:
                    output("You grimace, and call over to the midget behind the counter.  \"These taste like someone tried to make bacon flavour crisps and failed, badly.\"`n`n\"Read the fookin' packet, dick'ead!\"`n`nYou do as he says.  Ah.  Tumour flavour.  Nice.`n`nYou gain some Stamina!");
                    $st = 10000;
                    $nu = 5;
                    $fa = 10;
                    $fu = 5;
                    $co = 20;
                    break;
                case 26:
                    output("Skinheads on a Raft turned out to be beans on toast.  You're not sure whether to be relieved.`n`nYou gain some Stamina!");
                    $st = 25000;
                    $nu = 20;
                    $fa = 20;
                    $fu = 15;
                    $co = 50;
                    break;
                case 27:
                    //Potential for expansion: have the kebab taste better if the player's drunk, have the player find a wedding ring that he can sell for Req, etc.
                    output("You scarf down your doner kebab, stopping occasionally to pick out the occasional toenail or piece of car dashboard.  It's pretty fatty, and would taste a lot better if you were drunk, but you make do.`n`nYou gain some Stamina!");
                    $st = 65000;
                    $nu = 20;
                    $fa = 40;
                    $fu = 20;
                    $co = 75;
                    break;
                case 28:
                    output("You knock back your Crimson Pitbull, which turned out to be some sort of energy drink.`n`nYou feel aggressive!");
                    apply_stamina_buff('crimsonpitbull', array("name" => "Bark of the Crimson Pitbull", "class" => "Combat", "costmod" => 0.5, "expmod" => 1, "rounds" => 20, "roundmsg" => "The harsh, chemically-sweet taste of the Crimson Pitbull lurks in the back of your throat.  You're not expending nearly as much Stamina as usual.", "wearoffmsg" => "The effects of the Crimson Pitbull have worn off, and your senses return to their natural state."));
                    $co = 75;
                    break;
                case 29:
                    output("C**k Nuggets turned out to be chicken nuggets, only with a little more fowl language.`n`n...`n`n...sorry.`n`nYou gain some Stamina!");
                    $st = 145000;
                    $nu = 30;
                    $fa = 60;
                    $fu = 25;
                    $co = 150;
                    break;
                case 30:
                    output("The Sausage Feast turned out to be less sausage, and more fat, but hey, it's cheap and it tastes halfway decent.`n`nYou gain some Stamina!");
                    $st = 185000;
                    $nu = 40;
                    $fa = 80;
                    $fu = 50;
                    $co = 200;
                    break;
            }
            addstamina($st);
            increment_module_pref("nutrition", $nu);
            increment_module_pref("fat", $fa);
            increment_module_pref("fullness", $fu);
            $full = get_module_pref("fullness");
            if ($full < 0) {
                output("`n`nYou still feel as though you haven't eaten in days.");
            }
            if ($full >= 0 && $full < 50) {
                output("`n`nYou feel a little less hungry.");
            }
            if ($full >= 50 && $full < 100) {
                output("`n`nYou still feel as though you've got room for more!");
            }
            if ($full >= 100) {
                output("`n`nYou're stuffed!  You feel as though you can't possibly eat anything more today.");
            }
            $session['user']['gold'] -= $co;
            break;
    }
    debug(get_module_pref("fat"));
    debug(get_module_pref("nutrition"));
    addnav("Exit");
    addnav("Return to the Outpost", "village.php");
    page_footer();
}
コード例 #27
0
function delete_host($hostids, $unlink_mode = false)
{
    zbx_value2array($hostids);
    if (empty($hostids)) {
        return true;
    }
    $ret = false;
    // unlink child hosts
    $db_childs = get_hosts_by_templateid($hostids);
    while ($db_child = DBfetch($db_childs)) {
        unlink_template($db_child['hostid'], $hostids, $unlink_mode);
    }
    // delete web tests
    $del_httptests = array();
    $db_httptests = get_httptests_by_hostid($hostids);
    while ($db_httptest = DBfetch($db_httptests)) {
        $del_httptests[$db_httptest['httptestid']] = $db_httptest['httptestid'];
    }
    if (!empty($del_httptests)) {
        delete_httptest($del_httptests);
    }
    // delete items -> triggers -> graphs
    $del_items = array();
    $db_items = get_items_by_hostid($hostids);
    while ($db_item = DBfetch($db_items)) {
        $del_items[$db_item['itemid']] = $db_item['itemid'];
    }
    delete_item($del_items);
    // delete screen items
    DBexecute('DELETE FROM screens_items WHERE ' . DBcondition('resourceid', $hostids)) . ' AND resourcetype=' . SCREEN_RESOURCE_HOST_TRIGGERS;
    // delete host from maps
    delete_sysmaps_elements_with_hostid($hostids);
    // delete host from maintenances
    DBexecute('DELETE FROM maintenances_hosts WHERE ' . DBcondition('hostid', $hostids));
    // delete host from group
    DBexecute('DELETE FROM hosts_groups WHERE ' . DBcondition('hostid', $hostids));
    // delete host from template linkages
    DBexecute('DELETE FROM hosts_templates WHERE ' . DBcondition('hostid', $hostids));
    // disable actions
    $actionids = array();
    // conditions
    $sql = 'SELECT DISTINCT actionid ' . ' FROM conditions ' . ' WHERE conditiontype=' . CONDITION_TYPE_HOST . ' AND ' . DBcondition('value', $hostids, false, true);
    // FIXED[POSIBLE value type violation]!!!
    $db_actions = DBselect($sql);
    while ($db_action = DBfetch($db_actions)) {
        $actionids[$db_action['actionid']] = $db_action['actionid'];
    }
    DBexecute('UPDATE actions ' . ' SET status=' . ACTION_STATUS_DISABLED . ' WHERE ' . DBcondition('actionid', $actionids));
    // operations
    $sql = 'SELECT DISTINCT o.actionid ' . ' FROM operations o ' . ' WHERE o.operationtype IN (' . OPERATION_TYPE_GROUP_ADD . ',' . OPERATION_TYPE_GROUP_REMOVE . ') ' . ' AND ' . DBcondition('o.objectid', $hostids);
    $db_actions = DBselect($sql);
    while ($db_action = DBfetch($db_actions)) {
        $actionids[$db_action['actionid']] = $db_action['actionid'];
    }
    if (!empty($actionids)) {
        DBexecute('UPDATE actions ' . ' SET status=' . ACTION_STATUS_DISABLED . ' WHERE ' . DBcondition('actionid', $actionids));
    }
    // delete action conditions
    DBexecute('DELETE FROM conditions ' . ' WHERE conditiontype=' . CONDITION_TYPE_HOST . ' AND ' . DBcondition('value', $hostids, false, true));
    // FIXED[POSIBLE value type violation]!!!
    // delete action operations
    DBexecute('DELETE FROM operations ' . ' WHERE operationtype IN (' . OPERATION_TYPE_TEMPLATE_ADD . ',' . OPERATION_TYPE_TEMPLATE_REMOVE . ') ' . ' AND ' . DBcondition('objectid', $hostids));
    // delete host profile
    delete_host_profile($hostids);
    delete_host_profile_ext($hostids);
    $applicationids = array();
    $query = 'SELECT a.applicationid' . ' FROM applications a' . ' WHERE	' . DBcondition('a.hostid', $hostids);
    $db_applications = DBselect($query);
    while ($app = DBfetch($db_applications)) {
        $applicationids[] = $app['applicationid'];
    }
    $result = delete_application($applicationids);
    if (!$result) {
        return false;
    }
    // delete host
    foreach ($hostids as $id) {
        /* The section should be improved */
        $host_old = get_host_by_hostid($id);
        $result = DBexecute('DELETE FROM hosts WHERE hostid=' . $id);
        if ($result) {
            if ($host_old['status'] == HOST_STATUS_TEMPLATE) {
                info(S_TEMPLATE . SPACE . $host_old['host'] . SPACE . S_HOST_HAS_BEEN_DELETED_MSG_PART2);
                add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_TEMPLATE, $id, $host_old['host'], 'hosts', NULL, NULL);
            } else {
                info(S_HOST_HAS_BEEN_DELETED_MSG_PART1 . SPACE . $host_old['host'] . SPACE . S_HOST_HAS_BEEN_DELETED_MSG_PART2);
                add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_HOST, $id, $host_old['host'], 'hosts', NULL, NULL);
            }
        } else {
            break;
        }
    }
    return $result;
}
function luggagehut_run()
{
    global $session;
    page_header("The Luggage Hut");
    $backpackprefs = array("carrieritem" => "main");
    $backpack = get_items_with_prefs($backpackprefs, true);
    // debug($backpack);
    foreach ($backpack as $key => $prefs) {
        $currentbackpack = $prefs;
        $currentbackpackid = $key;
    }
    $bandolierprefs = array("carrieritem" => "fight");
    $bandolier = get_items_with_prefs($bandolierprefs, true);
    // debug($bandolier);
    foreach ($bandolier as $key => $prefs) {
        $currentbandolier = $prefs;
        $currentbandolierid = $key;
    }
    global $inventory;
    // debug($inventory);
    $tradein_main = round($currentbackpack['invshop_price'] * 0.6);
    $tradein_fight = round($currentbandolier['invshop_price'] * 0.6);
    switch (httpget('op')) {
        case "start":
            output("`0You head into the Luggage Hut.  A tall woman in her mid-twenties greets you.  From the dimensions of her mullet, you suspect she may be related to Sheila.`n`n\"`2Well, hey there!  Name's Sharon, nice to meet you.  Here for some new luggage?  We've got three different types of Backpacks and Bandoliers available.  Here, take a look around.  I can give you a trade-in value of %s cigarettes on your old backpack, and %s on your old bandolier.`0\"`n`nYou look around the shop a little, finding three different types of Bandoliers and Backpacks on sale:`n`n`bStandard Backpack`b`nA bog-standard backpack made from reasonably good materials.  Comfortably holds up to twenty kilos, and costs ten cigarettes.`n`n`bImproved Backpack`b`nA more well-designed backpack with extra pockets and good balance.  Holds up to forty kilos, and costs fifty cigarettes.`n`n`bAdvanced Backpack`b`nA superior-quality backpack designed by the famous B. P. BackPack, who changed his name by deed poll after working in the backpack design business for sixty years.  The man's completely bonkers, but he knows how to design a damned good backpack.  Comfortably holds up to eighty kilos, and costs one hundred cigarettes.`n`n`n`bStandard Bandolier`b`nA slightly more advanced version of the Basic bandolier given to new recruits.  Holds up to five kilos and costs ten cigarettes.`n`n`bImproved Bandolier`b`nThis leather bandolier looks cool, and has more pockets to store more things to use in fights.  Holds up to seven kilos and costs fifty cigarettes.`n`n`bAdvanced Bandolier`b`nThe Rolls-Royce of bandoliers, these things only tend to get purchased by the serious combat nut.  Holds up to ten kilos, and costs one hundred cigarettes.", $tradein_main, $tradein_fight);
            break;
        case "buy":
            $item = httpget('buy');
            if ($item == "backpack2" || $item == "backpack3" || $item == "backpack4") {
                $invloc = "main";
                $tradein = $tradein_main;
            } else {
                $invloc = "fight";
                $tradein = $tradein_fight;
            }
            $price = get_item_setting("invshop_price", $item);
            //debug($price);
            if ($price > $session['user']['gems'] + $tradein) {
                //todo
                output("Sharon shakes her head, her mullet swaying back and forth.  \"`2Sorry love - even with the trade-in, that's just not going to be enough.`0\"`n`nYou don't actually `ihave`i that many cigarettes.  Shame.");
            } else {
                $has = has_item($item);
                if ($has) {
                    output("Sharon smiles as she takes your cigarettes.  She pauses when she sees your old equipment.`n`n\"`2Uh, mate...  That's `iexactly`i the same as the one you're buying.  I'm not gonna take your cigs and then give you something that's no different to what you've already got - I'm not Sheila, you know?`0\"`n`nEmbarrassed, you nod, and take back your cigarettes.");
                } else {
                    output("Sharon smiles as you hand over your cigarettes and your old equipment.  \"`2Great stuff.  Here you go, one lovely new shiny piece of luggage!  Treat it well, now!`0\"");
                    $session['user']['gems'] += $tradein;
                    $session['user']['gems'] -= $price;
                    $price = $price - $tradein;
                    if ($invloc == "main") {
                        delete_item($currentbackpackid);
                    } else {
                        if ($invloc == "fight") {
                            delete_item($currentbandolierid);
                        }
                    }
                    give_item($item);
                    debuglog("spent " . $price . " cigarettes on " . $item . " at the Luggage Hut.");
                }
            }
            break;
    }
    addnav("Backpacks");
    addnav("Buy Standard Backpack", "runmodule.php?module=luggagehut&op=buy&buy=backpack2");
    addnav("Buy Improved Backpack", "runmodule.php?module=luggagehut&op=buy&buy=backpack3");
    addnav("Buy Advanced Backpack", "runmodule.php?module=luggagehut&op=buy&buy=backpack4");
    addnav("Bandoliers");
    addnav("Buy Standard bandolier", "runmodule.php?module=luggagehut&op=buy&buy=bandolier2");
    addnav("Buy Improved bandolier", "runmodule.php?module=luggagehut&op=buy&buy=bandolier3");
    addnav("Buy Advanced bandolier", "runmodule.php?module=luggagehut&op=buy&buy=bandolier4");
    addnav("Other");
    addnav("Back to the Outpost", "village.php");
    page_footer();
    return true;
}
page_header("Inventory");
//$op = httpget("op");
$items_useitem = httpget("items_useitem");
$items_discarditem = httpget("items_discarditem");
$items_transferitem = httpget("items_transferitem");
$items_transferto = httpget("items_transferto");
$context = httpget("items_context");
//handle moving, using, discarding, and contexts
if ($items_transferitem && $items_transferto) {
    move_item($items_transferitem, $items_transferto);
}
if ($items_useitem) {
    use_item($items_useitem, $context);
}
if ($items_discarditem) {
    delete_item($items_discarditem);
}
load_inventory();
//debug($inventory);
$hook = array('inventory' => $inventory, 'context' => $context);
$hook = modulehook("inventory-predisplay", $hook);
addnav("Sort by...");
addnav("Recently Acquired", "inventory.php?items_sort=key&items_context={$context}");
addnav("Alphabetical", "inventory.php?items_sort=alpha&items_context={$context}");
addnav("Quantity", "inventory.php?items_sort=qty&items_context={$context}");
$sort = httpget("items_sort");
$gr = group_items($inventory, $sort);
//debug($gr);
// switch ($sort){
// case "key":
// arsort($gr);
コード例 #30
0
ファイル: dz_6_2.php プロジェクト: Anatoliy-Bezhenaru/wdc
    // уникальный номер объявления в базе
    foreach ($_POST as $key => $value) {
        if ($key == 'main_form_submit') {
            continue;
        }
        $_SESSION['bd'][$id_ad][$key] = trim(htmlspecialchars($value));
    }
    $_SESSION['bd'][$id_ad]['date'] = date('d.m.Y H:i:s');
    header("Location: dz_6_2.php");
    exit;
}
//print_r($_SESSION);
// Обработка команды на удаление
if (isset($_GET['delete'])) {
    $get_value = $_GET['delete'];
    delete_item($get_value);
    header("Location: dz_6_2.php");
    exit;
}
// Обработка команды на просмотр
if (isset($_GET['view'])) {
    $_SESSION['view'] = $_GET['view'];
    header("Location: dz_6_2.php");
    exit;
}
// Функция удаления объявления
function delete_item($get_value)
{
    unset($_SESSION['bd'][$get_value]);
}
// Функция просмотра объявления