Esempio n. 1
0
    /**
     * Vis fengsel
     */
    protected function show()
    {
        // er vi i fengsel nå?
        if ($wait = $this->up->fengsel_wait()) {
            ess::$b->page->add_js_domready('$("fengsel_dusor").focus();');
            echo '
<div class="bg1_c xsmall">
	<h1 class="bg1">Du er i fengsel<span class="left"></span><span class="right"></span></h1>
	<p class="h_right"><a href="node/16">Hjelp</a></p>
	<div class="bg1">
		<p>Du befinner deg for øyeblikket i fengsel og slipper ut om ' . game::counter($wait, true) . '.</p>' . (!$this->up->is_nostat() ? '
		<form action="" method="post">
			<input type="hidden" name="sid" value="' . login::$info['ses_id'] . '" />
			<input type="hidden" name="expire" value="' . $this->up->data['up_fengsel_time'] . '" />
			<dl class="dd_right">
				<dt>Dusør for å bryte deg ut</dt>
				<dd><input type="text" class="styled w80" name="amount" id="fengsel_dusor" value="' . game::format_cash($this->up->data['up_fengsel_dusor']) . '" /></dd>
			</dl>
			<p class="c">' . show_sbutton($this->up->data['up_fengsel_dusor'] > 0 ? "Endre dusør" : "Sett dusør", 'name="dusor"') . '</p>
			<p class="c">Spilleren som bryter ut mottar kun ' . self::DUSOR_PROFIT * 100 . ' % av dusøren.</p>
		</form>' : '') . '
	</div>
</div>';
        }
        // sortering
        $sort = new sorts("sort");
        $sort->append("asc", "Spiller", "up_name");
        $sort->append("desc", "Spiller", "up_name DESC");
        $sort->append("asc", "Wanted nivå", "up_wanted_level, up_fengsel_time DESC");
        $sort->append("desc", "Wanted nivå", "up_wanted_level DESC, up_fengsel_time DESC");
        $sort->append("asc", "Tid igjen", "up_fengsel_time");
        $sort->append("desc", "Tid igjen", "up_fengsel_time DESC");
        $sort->set_active(requestval("sort"), 5);
        // hent folk i fengsel
        $sort_info = $sort->active();
        $pagei = new pagei(pagei::ACTIVE_GET, "side", pagei::PER_PAGE, 15);
        $result = $pagei->query("\n\t\t\tSELECT up_id, up_name, up_access_level, up_fengsel_time, up_fengsel_num, up_fengsel_dusor, ROUND(up_fengsel_dusor * " . self::DUSOR_PROFIT . ") up_fengsel_dusor_get, up_wanted_level\n\t\t\tFROM users_players\n\t\t\tWHERE up_fengsel_time > " . time() . " AND up_access_level != 0\n\t\t\tORDER BY {$sort_info['params']}");
        $num = $result->rowCount();
        echo '
<div class="bg1_c ' . ($num == 0 ? 'xsmall' : 'xlarge') . '">
	<h1 class="bg1">Fengsel<span class="left"></span><span class="right"></span></h1>
	<p class="h_right"><a href="node/16">Hjelp</a></p>
	<div class="bg1">
		<form action="" method="post">
			<p class="c dark">Ditt wanted nivå er på ' . game::format_number($this->up->data['up_wanted_level'] / 10, 1) . ' %.</p>';
        if ($num == 0) {
            echo '
			<p class="c dark">Ingen er i fengselet for øyeblikket.</p>
			<p class="c"><a href="' . htmlspecialchars(game::address("fengsel", $_GET)) . '" class="button">Oppdater</a></p>';
        } else {
            echo '
			<table class="table center" width="100%">
				<thead>
					<tr>
						<th>Spiller ' . $sort->show_link(0, 1) . '</th>
						<th>Wanted<br />nivå ' . $sort->show_link(2, 3) . '</th>
						<th>Utbrytning<br />sannsynlighet</th>
						<th>Ca. poeng</th>
						<th>Dusør</th>
						<th>Tid igjen ' . $sort->show_link(4, 5) . '</th>
					</tr>
				</thead>
				<tbody>';
            $i = 0;
            while ($row = $result->fetch()) {
                $prefix = "";
                $attr = new attr("class");
                if (++$i % 2 == 0) {
                    $attr->add("color");
                }
                if (!$this->up->fengsel_check()) {
                    $attr->add("box_handle");
                    $prefix = '<input type="radio" name="up_id" value="' . $row['up_id'] . '_' . $row['up_fengsel_time'] . '_' . $row['up_fengsel_dusor'] . '" /> ';
                }
                $time = $row['up_fengsel_time'] - time();
                $prob = self::calc_prob($time, $row['up_wanted_level'] / 10);
                $points = self::calc_points($prob);
                echo '
					<tr' . $attr->build() . '>
						<td>' . $prefix . game::profile_link($row['up_id'], $row['up_name'], $row['up_access_level']) . '</td>
						<td class="c">' . game::format_number($row['up_wanted_level'] / 10, 1) . ' %</td>
						<td class="c">' . game::format_number($prob, 1) . ' %</td>
						<td class="c">' . game::format_num($points) . '</td>
						<td class="r nowrap">' . game::format_cash($row['up_fengsel_dusor_get']) . '</td>
						<td class="r">' . game::counter($time) . '</td>
					</tr>';
            }
            echo '
				</tbody>
			</table>
			<p class="c">' . (($wait = $this->up->fengsel_wait()) == 0 ? '
				' . show_sbutton("Bryt ut", 'name="brytut"') : '
				Du er i fengsel og slipper ut om ' . game::counter($wait, true) . '.
			</p>
			<p class="c">') . '
				<a href="' . htmlspecialchars(game::address("fengsel", $_GET)) . '" class="button">Oppdater</a>
			</p>';
            // flere sider?
            if ($pagei->pages > 1) {
                echo '
			<div class="hr"></div>
			<p class="c">
				' . $pagei->pagenumbers() . '
			</p>';
            }
        }
        echo '
		</form>
	</div>
</div>';
        // testing
        if (!MAIN_SERVER || access::is_nostat() && access::has("mod")) {
            echo '
<div class="bg1_c xxsmall bg1_padding">
	<h1 class="bg1">' . (MAIN_SERVER ? 'No-stat' : 'Testing') . '<span class="left"></span><span class="right"></span></h1>
	<div class="bg1">
		<form action="" method="post">' . ($this->up->fengsel_check() ? '
			<p class="c">' . show_sbutton("Gå ut av fengsel", 'name="remove"') . '</p>' : '
			<dl class="dd_right dl_2x">
				<dt>Tid</dt>
				<dd><input type="text" name="time" value="' . htmlspecialchars(postval("time", 20)) . '" class="styled w40" /> sekunder</dd>
			</dl>
			<p class="c">' . show_sbutton("Gå inn i fensgel") . '</p>') . '
		</form>
	</div>
</div>';
        }
    }