コード例 #1
0
ファイル: banken.php プロジェクト: Kuzat/kofradia
    /**
     * Kontroller at vi er logget inn i banken
     */
    protected function auth_verify()
    {
        // alltid logget inn i banken når man er logget inn som crew
        if (isset(login::$extended_access['authed'])) {
            return;
        }
        // sjekk om vi er logget inn i banken
        $last = login::data_get("banken_last_view", 0);
        $idle = 1800;
        // hvor lenge vi kan være inaktiv
        $exceed = max(0, time() - $last - $idle);
        // allerede logget inn?
        if ($last != 0 && $exceed == 0) {
            login::data_set("banken_last_view", time());
            return;
        }
        // logge inn?
        if (isset($_POST['passord'])) {
            if (!password::verify_hash($_POST['passord'], login::$user->player->user->data['u_bank_auth'], "bank_auth")) {
                ess::$b->page->add_message("Passordet var ikke riktig. Husk at dette er bank passordet og ikke passordet til brukerkontoen.", "error");
                putlog("ABUSE", "%c4%bUGYLDIG PASSORD I BANKEN (FF):%b%c %u" . login::$user->player->data['up_name'] . "%u ({$_SERVER['REMOTE_ADDR']}) brukte feil passord for å logge inn i banken");
            } else {
                // logget inn
                login::data_set("banken_last_view", time());
                ess::$b->page->add_message("Du er nå logget inn i banken. Du blir logget ut etter " . game::timespan($idle, game::TIME_FULL) . " uten å besøke banken.");
            }
            redirect::handle();
        }
        echo '
<div class="bg1_c xsmall">
	<h1 class="bg1">
		Banken
		<span class="left"></span><span class="right"></span>
	</h1>
	<div class="bg1">
		<boxes />';
        if ($exceed > 0 && $last != 0) {
            login::data_set("banken_last_view", 0);
            echo '
		<p>Det gikk for lang tid siden du viste banken og du må logge inn på nytt. Du var ' . game::timespan($exceed, game::TIME_FULL) . ' over tiden.</p>';
        }
        // javascript for fokus til passord feltet
        ess::$b->page->add_body_post('<script type="text/javascript">
document.getElementById("b_pass").focus();
</script>');
        echo '
		<p>Du må logge inn for å få tilgang til banken for ' . $this->ff->type['refobj'] . '.</p>
		<form action="" method="post">
			<dl class="dd_right dl_2x">
				<dt>Bankpassord</dt>
				<dd><input type="password" class="styled w100" name="passord" id="b_pass" /></dd>
			</dl>
			<p class="c">' . show_sbutton("Logg inn") . '</p>
			<p class="c"><a href="' . ess::$s['relative_path'] . '/banken?rp">Nullstill bankpassord</a></p>
		</form>
	</div>
</div>';
        $this->ff->load_page();
    }
コード例 #2
0
ファイル: innboks_sok.php プロジェクト: Kuzat/kofradia
	Skal du ikke søke etter noe?!
</p>';
    } else {
        // sett opp søkespørringen
        $search = "";
        if (count($title_parts[0]) > 0) {
            $search .= " AND it_title" . implode(" AND it_title", $title_parts[0]);
        }
        if (count($text_parts[0]) > 0) {
            $search .= " AND id_text" . implode(" AND id_text", $text_parts[0]);
        }
        // søke i slettede meldinger?
        $deleted = $show_deleted ? " AND im_deleted = 0" : " AND ir_deleted = 0";
        // sortering
        $sort_info = $sort->active();
        $per_page = login::data_get("innboks_per_side", 15);
        $pagei = new pagei(pagei::ACTIVE_POST, "side", pagei::PER_PAGE, $per_page);
        //  AND it_id = im_it_id{$search_where[$search_where_id][1]}
        $result = $pagei->query("\n\t\t\tSELECT it_id, it_title, ir_up_id, ir_unread, ir_unread, ir_deleted, ir_marked, im_id, im_up_id, im_time, id_text, up.up_name, up.up_access_level\n\t\t\tFROM inbox_threads, inbox_rel, users_players up_ref, inbox_data, inbox_messages LEFT JOIN users_players up ON up.up_id = im_up_id\n\t\t\tWHERE\n\t\t\t\tup_ref.up_u_id = {$user->id}\n\t\t\t\tAND ir_up_id = up_ref.up_id{$deleted}\n\t\t\t\tAND it_id = ir_it_id\n\t\t\t\tAND im_it_id= it_id{$search_from[$search_from_id][1]}\n\t\t\t\tAND im_time <= ir_restrict_im_time\n\t\t\t\tAND im_id = id_im_id{$search}\n\t\t\tORDER BY {$sort_info['params']}", array_merge($title_parts[2], $text_parts[2]));
        $info = array();
        foreach ($title_parts[1] as $part) {
            $info[] = '<b>Tittel:</b> ' . htmlspecialchars($part);
        }
        foreach ($text_parts[1] as $part) {
            $info[] = '<b>Innhold:</b> ' . htmlspecialchars($part);
        }
        if ($search_from_id == 4) {
            if (count($search_from[4][2]) == 1) {
                $info[] = '<b>Avsender:</b> <user="******" />';
            } else {
                $u = array();
コード例 #3
0
ファイル: banken.php プロジェクト: Kuzat/kofradia
    /**
     * Kontroller at vi er logget inn i banken
     */
    protected function auth_verify()
    {
        // alltid logget inn i banken når man er logget inn som crew
        if (isset(login::$extended_access['authed'])) {
            return;
        }
        // sjekk om vi er logget inn i banken
        $last = login::data_get("banken_last_view", 0);
        $idle = 1800;
        // hvor lenge vi kan være inaktiv
        $exceed = max(0, time() - $last - $idle);
        // allerede logget inn?
        if ($last != 0 && $exceed == 0) {
            login::data_set("banken_last_view", time());
            return;
        }
        // logge inn?
        if (isset($_POST['passord'])) {
            // sjekk passord
            if (!password::verify_hash($_POST['passord'], $this->up->user->data['u_bank_auth'], "bank_auth")) {
                ess::$b->page->add_message("Passordet var ikke riktig. Husk at dette er bank passordet og ikke passordet til brukerkontoen.", "error");
                putlog("ABUSE", "%c4%bUGYLDIG PASSORD I BANKEN:%b%c %u" . $this->up->data['up_name'] . "%u ({$_SERVER['REMOTE_ADDR']}) brukte feil passord for å logge inn i banken");
            } else {
                // logget inn
                login::data_set("banken_last_view", time());
                ess::$b->page->add_message("Du er nå logget inn i banken. Du blir logget ut etter " . game::timespan($idle, game::TIME_FULL) . " uten å besøke banken.");
            }
            redirect::handle();
        }
        // glemt passord?
        if (isset($_GET['rp'])) {
            // validere?
            if (!empty($_GET['rp'])) {
                $this->auth_reset($_GET['rp']);
            }
            // be om e-post?
            if (isset($_POST['send']) && validate_sid()) {
                $this->auth_send_link();
            }
            ess::$b->page->add_title("Nullstill bankpassord");
            $requested = $this->up->user->params->get("bankauth_change_rtime");
            $expire = $this->up->user->params->get("bankauth_change_expire");
            echo '
<div class="bg1_c xsmall">
	<h1 class="bg1">Nullstill bankpassord<span class="left"></span><span class="right"></span></h1>
	<div class="bg1">
		<boxes />
		<p>For å nullstille passordet til banken må du bekrefte din identitet via e-posten din.</p>';
            // allerede sendt e-post?
            if ($expire > time()) {
                echo '
		<p>Du ba om e-post ' . ess::$b->date->get($requested)->format() . ' for å nullstille ditt passord. Forespørselen er gyldig til ' . ess::$b->date->get($expire)->format() . '.</p>
		<p>Du må vente til dette klokkeslettet for å be om ny e-post.</p>';
            } else {
                echo '
		<form action="" method="post">
			<input type="hidden" name="rp" />
			<input type="hidden" name="sid" value="' . login::$info['ses_id'] . '" />
			<p class="c">' . show_sbutton("Send e-post", 'name="send"') . '</p>
		</form>';
            }
            echo '
		<p class="c"><a href="banken">Tilbake</a></p>
	</div>
</div>';
            ess::$b->page->load();
        }
        echo '
<div class="bg1_c xsmall">
	<h1 class="bg1">
		Banken
		<span class="left"></span><span class="right"></span>
	</h1>
	<div class="bg1">
		<boxes />';
        if ($exceed > 0 && $last != 0) {
            login::data_set("banken_last_view", 0);
            echo '
		<p>Det gikk for lang tid siden du viste banken og du må logge inn på nytt. Du var ' . game::timespan($exceed, game::TIME_FULL) . ' over tiden.</p>';
        }
        // javascript for fokus til passord feltet
        ess::$b->page->add_body_post('<script type="text/javascript">
document.getElementById("b_pass").focus();
</script>');
        echo '
		<p>Du må logge inn for å få tilgang til bankkontoen din.</p>
		<p>Denne sikkerheten er her for å hindre uvedkommende i å kvitte seg med pengene dine, selv om de kommer inn på spilleren din.</p>
		<form action="" method="post">
			<dl class="dd_right dl_2x">
				<dt>Bankpassord</dt>
				<dd><input type="password" class="styled w100" name="passord" id="b_pass" /></dd>
			</dl>
			<p class="c">' . show_sbutton("Logg inn") . '</p>
			<p class="c"><a href="banken?rp">Nullstill bankpassord</a></p>
		</form>
	</div>
</div>';
        ess::$b->page->load();
    }
コード例 #4
0
ファイル: innboks.php プロジェクト: Kuzat/kofradia
    /**
     * Vis meldinger
     */
    protected function show_messages()
    {
        // hent meldinger
        $pagei = new pagei(pagei::ACTIVE_GET, "side", pagei::PER_PAGE, login::data_get("innboks_per_side", 15));
        $meldinger = $this->inbox->get_messages($pagei, $this->show_deleted);
        $this->css();
        echo '
<div style="margin-top: 1em; font-size: 15px">
	<h1' . ($pagei->active > 1 && ($show_deleted = false ? ' id="scroll_here"' : '')) . ' style="float: left; margin-top: 0">Meldinger</h1>
	<p class="h_right" style="margin: 10px 0 0 0 !important">
		<a href="innboks_ny">Opprett ny melding</a>' . ($pagei->total > 0 ? '
		<a href="' . htmlspecialchars($this->addr(null, null, "innboks_sok")) . '">Søk</a>' : '') . '
	</p>
</div>';
        // ingen meldinger å vise?
        if (!$meldinger) {
            echo '
<p class="clear">Du har ingen meldinger i din innboks eller utboks.</p>
<p>Så fort du sender eller mottar en melding vil den komme opp på denne siden.</p>';
        } else {
            $this->js();
            // flere sider?
            if ($pagei->pages > 1) {
                echo '
<p class="c" style="margin: 25px auto 10px; width: 250px">' . $pagei->pagenumbers() . '</p>';
            }
            echo '
<form action="" method="post">
	<table class="table clear" width="100%" id="meldinger">
		<thead>
			<tr>
				<th>Emne (<a href="#" class="box_handle_toggle" rel="it_id[]">Merk alle</a>)</th>
				<th><abbr title="Antall meldinger i meldingstråden">Ant.</abbr></th>
				<th><abbr title="Antall deltakere utenom deg selv">De.</abbr></th>
				<th>Siste</th>
				<th class="nowrap" colspan="1">Tid siste (<a id="skift_tid">veksle</a>)</th>
			</tr>
		</thead>
		<tbody>';
            $i = 0;
            $c = access::has("crewet");
            foreach ($meldinger as $row) {
                $o = $row['up_prev_other'] ? '<user id="' . $row['up_prev_other']['im_up_id'] . '" /> <span class="im_utg">(utgående)</span>' : ($row['up_prev'] && !$row['up_prev'][0] ? '<user id="' . $row['up_prev'][1] . '" />' : (count($row['receivers']) > 1 ? '<user id="' . $row['receivers'][0]['ir_up_id'] . '" /> <span class="im_utg">(utgående)</span>' : '<span class="dark">Ingen</span>'));
                // låst?
                // TODO: Skal ikke tråden se ut som den er låst når man er i crewet? Man har uansett mulighet til å svare når man går inn i tråden
                $locked = false;
                if (!$row['receivers_ok']) {
                    $locked = true;
                } elseif ($row['ir_up_id'] != $this->inbox->u->player->id || !$this->inbox->u->player->active && !$row['receivers_crew']) {
                    $locked = true;
                }
                echo '
			<tr class="box_handle' . ($row['ir_unread'] > 0 ? ' not_viewed' : (++$i % 2 == 0 ? ' color' : '')) . '">
				<td class="it_e">
					<input type="checkbox" name="it_id[]" value="' . $row['it_id'] . '" />
					<a href="innboks_les?id=' . $row['it_id'] . '" class="it_a">
						<span class="it_t_w">
							<span class="it_t">' . htmlspecialchars($row['it_title']) . '</span>' . ($row['ir_unread'] == 1 ? ' <span class="ny">(Ny!)</span>' : ($row['ir_unread'] > 1 ? ' <span class="ny">(' . $row['ir_unread'] . ' nye!)</span>' : '')) . ($row['ir_deleted'] != 0 ? ' <span class="slettet">(Slettet)</span>' : '') . ($locked ? ' <span class="it_locked">(Låst)</span>' : '') . ($row['ir_marked'] != 0 ? '<span class="ir_marked"> (Til oppfølging)</span>' : '') . '
						</span>' . ($row['id_text'] != "" ? '<br />
						<span class="id_text_w"><span class="id_text">' . $row['id_text'] . '</span> <span class="id_up">(' . ($row['up_prev'][0] ? 'meg' : '<user id="' . $row['up_prev'][1] . '" nolink />') . ')</span></span>' : '') . '
					</a>
				</td>
				<td class="c">' . game::format_number($row['num_messages']) . '</td>
				<td class="c">' . (count($row['receivers']) - 1) . '</td>
				<td class="it_u">
					' . $o . '
					<div class="im_deltakere_det hide" rel="' . $row['it_id'] . ',' . $row['ir_marked'] . '">
						<table class="table">
							<thead>
								<tr>
									<th>Spiller</th>
									<th>Antall</th>
									<th>Uleste</th>' . (access::has("mod") ? '
									<th>Vis</th>' : '') . '
									<th>Status</th>
								</tr>
							</thead>
							<tbody>';
                foreach ($row['receivers'] as $r) {
                    echo '
								<tr>
									<td><user id="' . $r['ir_up_id'] . '" /></td>
									<td class="r">' . $r['num_messages'] . '</td>
									<td class="r">' . ($r['ir_unread'] > 0 ? '<b>' . $r['ir_unread'] . '</b>' : $r['ir_unread']) . '</td>' . (access::has("mod") ? '
									<td>' . $r['ir_views'] . '</td>' : '') . '
									<td>' . ($r['up_access_level'] == 0 ? '<span class="dark">Død' . ($c && $r['u_access_level'] != 0 && $r['u_active_up_id'] == $r['ir_up_id'] ? ', men bruker aktiv' : '') . '</span>' : ($r['ir_deleted'] != 0 ? '<span class="dark">Slettet meldingen</span>' : 'Mottar nye meldinger')) . '</td>
								</tr>';
                }
                echo '
							</tbody>
						</table>
					</div>
				</td>
				<td class="it_dato_w">
					<span class="it_dato_f it_dato_hide">' . ess::$b->date->get($row['ir_restrict_im_time'])->format(date::FORMAT_SEC) . '</span>
					<span class="it_dato_f">' . game::timespan($row['ir_restrict_im_time'], game::TIME_ABS) . '</span>
				</td>
			</tr>';
            }
            echo '
		</tbody>
	</table>
	<p style="float: right; line-height: 25px" class="r red">
		' . show_sbutton("Slett merkede meldinger", 'name="slett" onclick="return confirm(\'Er du sikker på at du vil slette de merkede meldingene?\')"') . '<br />
		' . show_sbutton("Slett alle meldingene", 'name="slettalle"') . '
	</p>
</form>
<form action="" method="post">
	<p style="float: left">
		<select name="ps">';
            $list = array(10, 15, 20, 25, 30, 40, 50, 75, 100);
            if (!in_array($pagei->per_page, $list)) {
                $list[] = $pagei->per_page;
                sort($list);
            }
            foreach ($list as $a) {
                echo ' 
			<option value="' . $a . '"' . ($a == $pagei->per_page ? ' selected="selected"' : '') . '>Vis ' . $a . ' meldinger</option>';
            }
            echo '
		</select>
	</p>
</form>';
            // flere sider?
            if ($pagei->pages > 1) {
                echo '
	<p class="c" style="margin: 13px auto 10px; width: 250px">' . $pagei->pagenumbers() . '</p>';
            }
        }
        $this->load_page();
    }
コード例 #5
0
ファイル: poker.php プロジェクト: Kuzat/kofradia
    protected function show_create()
    {
        if ($this->is_starter) {
            return;
        }
        $innsats = login::data_get("poker_siste_innsats", 10000);
        if (bccomp($innsats, $this->up->data['up_cash']) == 1) {
            $innsats = $this->up->data['up_cash'];
        }
        ess::$b->page->add_js_domready('
	var player_cash = ' . js_encode(game::format_cash($this->up->data['up_cash'])) . ';
	var elm = $("poker_amount_set");
	var elm_t = $("poker_amount");
	
	elm
		.appendText(" (")
		.grab(new Element("a", {"text":"velg alt"}).addEvent("click", function()
		{
			elm_t.set("value", player_cash);
		}))
		.appendText(")");');
        echo '
<div class="bg1_c xsmall">
	<h1 class="bg1">Nytt pokerspill<span class="left"></span><span class="right"></span></h1>
	<p class="h_right"><a href="' . ess::$s['relative_path'] . '/node/28">Hjelp</a></p>
	<div class="bg1">
		<form action="" method="post">
			<dl class="dd_right">
				<dt id="poker_amount_set">Beløp</dt>
				<dd><input type="text" id="poker_amount" name="amount" value="' . game::format_cash($innsats) . '" class="styled w120" /> ' . show_sbutton("Start") . '</dd>
			</dl>
		</form>
	</div>
</div>';
    }
コード例 #6
0
ファイル: gta.php プロジェクト: Kuzat/kofradia
    /**
     * Vis biltyveri
     */
    protected function biltyveri_show()
    {
        ess::$b->page->add_title("Biltyveri");
        // kontroller ranken vi må ha for å utføre biltyveri
        $this->check_rank();
        // kontroller energi
        $this->gta->up->energy_require(gta::ENERGY_BILTYVERI * 1.3);
        // legg til 30 % på kravet
        // anti-bot
        $this->antibot = antibot::get("biltyveri", 10);
        $this->antibot->check_required(ess::$s['rpath'] . '/gta');
        // skjema
        $this->form = \Kofradia\Form::getByDomain("biltyveri", login::$user);
        // hent inn alternativene
        $this->gta->load_options();
        // ønsker vi å utføre biltyveri?
        if (isset($_POST['option_id'])) {
            $this->biltyveri_utfor();
        }
        // kontroller ventetid
        $wait = $this->gta->calc_wait();
        $wait = $wait[0];
        echo '
<div class="col2_w" style="margin: 35px 0">
	<div class="col_w left" style="width: 64%">
		<div class="col">
<div class="bg1_c center" style="width: 350px">
	<h1 class="bg1">Biltyveri<span class="left2"></span><span class="right2"></span></h1>
	<p class="h_right"><a href="&rpath;/node/20">Hjelp</a></p>
	<div class="bg1">
		';
        // har vi ikke garasje i denne bydelen?
        $bydeler = $this->gta->get_bydeler_info();
        if (!$bydeler[$this->gta->up->data['up_b_id']]['ff_id']) {
            echo '
		<p>Du må ha en garasje i denne bydelen før du kan forsøke å utføre biltyveri.</p>';
        } elseif ($bydeler[$this->gta->up->data['up_b_id']]['garage_free'] == 0) {
            $msg = ess::$b->page->messages->getMessageByName("gta_result");
            if ($msg) {
                echo '
		<div class="p c">' . $msg->content . '</div>';
            }
            echo '
		<p>Det er ikke plass til flere kjøretøy i garasjen din. Oppgrader garasje, selg eller flytt biler for å kunne utføre biltyveri.</p>';
        } elseif (count($this->gta->options) == 0) {
            echo '
		<p>Det er ingen mulighet for å stjele biler i denne bydelen.</p>';
        } else {
            $id = reset($this->gta->options);
            $id = $id['id'];
            $rank = $this->gta->up->rank['need_points'] == 0 ? game::format_number(round(gta::RANK_BILTYVERI / $this->gta->up->rank['points'], 5) * 100, 4) : game::format_number(round(gta::RANK_BILTYVERI / $this->gta->up->rank['need_points'], 5) * 100, 3);
            echo '
		<form action="" method="post" onsubmit="noSubmit(this)">
			' . $this->form->getHTMLInput() . '
			<table class="table game center tablemt" style="width: 100%">
				<thead>
					<tr>
						<th>Navn</th>
						<th>Sjanse</th>
						<th>Forsøk</th>
						<th>Vellykkede</th>
					</tr>
				</thead>
				<tbody>';
            // vis alternativene
            $valgt = login::data_get("biltyveri_alternativ_" . login::$user->player->data['up_b_id']);
            $i = 0;
            foreach ($this->gta->options as $option) {
                echo '
					<tr class="box_handle' . (++$i % 2 == 0 ? ' color' : '') . '">
						<td><input type="radio" name="option_id" value="' . $option['id'] . '"' . ($option['id'] == $valgt ? ' checked="checked"' : '') . ' />' . htmlspecialchars($option['name']) . '</td>
						<td class="r">' . game::format_number($option['percent']) . ' %</td>
						<td class="r">' . game::format_number($option['count']) . '</td>
						<td class="r">' . game::format_number($option['success']) . ' (' . ($option['count'] == 0 ? '0,0' : game::format_number($option['success'] / $option['count'] * 100, 1)) . ' %)</td>
					</tr>';
            }
            echo '
				</tbody>
			</table>';
            $msg = ess::$b->page->messages->getMessageByName("gta_result");
            if ($msg) {
                echo '
			<div class="p c">' . $msg->content . '</div>';
            }
            echo $wait > 0 ? '
			<p class="c">Du må vente ' . game::counter($wait, true) . ' før du kan utføre biltyveri igjen.</p>' : '
			<p class="c">' . show_sbutton("Utfør handling") . '</p>';
            echo '
		</form>';
        }
        echo '
	</div>
</div>
		</div>
	</div>
	<div class="col_w right" style="width: 36%">
		<div class="col">
			<p class="c" style="margin-top: 0"><img src="&staticlink;/gta/biltyveri.jpg" alt="Biltyveri" style="border: 3px solid #1F1F1F" /></p>
		</div>
	</div>
</div>';
    }