gc-fallout - updates
[anomen-overlay.git] / www-apps / gc-fallout / dev / index.php
blobdd2c310323273c5e895b0e08f11d5f8cc7d47f67
1 <?php
3 header("Cache-Control: no-cache, must-revalidate");
4 header("Expires: Fri, 01 Jan 2010 05:00:00 GMT");
5 header("Pragma: no-cache");
7 require_once('toolbox.php');
9 $U = array();
10 $params = array('login'=>'x', 'klice'=>'', 'penize'=>'i', 'jidlo'=>'i', 'karma'=>'i');
12 foreach ($params as $p=>$op) {
13 if (isset($_REQUEST[$p])) {
14 $v = $_REQUEST[$p];
15 if (strpos($op, 'x') !== FALSE) {
16 $v = strtr($v, '!', '_');
18 if (strpos($op, 'i') !== FALSE) {
19 $v = intval($v);
21 $U[$p] = $v;
22 $U["${p}_safe"] = htmlentities($U[$p], ENT_QUOTES);
26 $valid = true;
29 <html>
30 <head>
31 <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
32 <link rel='stylesheet' type='text/css' href='styles.css' />
33 </head>
34 <body>
36 <?php if ($valid && empty($_REQUEST['form_submit'])) { ?>
38 <form method="post">
39 <div id="input_div">
41 <div id="form_login">
42 <label for="login" title="Login na geocaching.com:">Jméno</label><br />
43 <input type="text" name="login" id="login" value="<?php echo $U['login_safe']; ?>" />
44 </div>
46 <div id="form_karma">
47 <label for="karma">Karma:</label>
48 <br />
49 <input type="text" name="karma" id="karma" value="<?php echo $U['karma_safe']; ?>" />
50 </div>
52 <div id="form_penize">
53 <label for="penize">Zbylé zátky:</label>
54 <br />
55 <input type="text" name="penize" id="penize" value="<?php echo $U['penize_safe']; ?>" />
56 </div>
58 <div id="form_jidlo">
59 <label for="jidlo">Jídlo:</label>
60 <br />
61 <input type="text" name="jidlo" id="jidlo" value="<?php echo $U['jidlo_safe']; ?>" />
62 </div>
64 <div id="form_klice">
65 <label for="klice">Nalezené klíče, micro, perky i předměty oddělené čárkou (na pořadí klíčů a micro záleží!):</label>
66 <br />
67 <textarea cols="30" rows=8" name="klice" id="klice"><?php echo $U['klice_safe']; ?></textarea>
68 </div>
70 <div>
71 <input type="submit" name="form_submit" id="form_submit" />
72 </div>
74 </div>
75 </form>
77 <?php } else {
79 dbstats_access($U);
81 // TODO: check integers
82 // dbstats_update($U, '', 'invalid values');
84 echo "<div id=\"result\">\n";
86 if (!ip_check()) {
87 echo "<p><span style=\"color:red;font-weight:bold\">OPAKOVANY POKUS</span></p>\n";
88 dbstats_update($U, '', 'retry_limit_reached');
89 if (LIMIT_TRIES_PER_DAY) {
90 echo "</div></body></html>\n";
91 die;
95 // echo "volam ohodnot_hrace(${U['klice']})"; // DEBUG
96 ohodnot_hrace($U);
98 echo '<div id="perky_preview">';
99 foreach($U['perky'] as $perk) {
100 echo "<img src='perky/$perk.jpg'/>\n";
102 echo '</div>';
104 echo "<hr /> odkaz pro zalogovani:<br />\n";
106 //echo "<pre>U=";print_r($U);echo "</pre>";
108 $token_b64 = getToken($U);
110 dbstats_update($U, $token_b64, '');
112 $script="http://${_SERVER['SERVER_NAME']}:${_SERVER['SERVER_PORT']}"
113 . str_replace('index.php','cert.php', $_SERVER['SCRIPT_NAME'])
114 . "?$token_b64";
117 if (HAVE_DEBUG) {
118 echo "<pre>";
119 print_r($U);
120 echo "</pre>";
122 // $script="http://${_SERVER['SERVER_NAME']}:${_SERVER['SERVER_PORT']}/~guppy/fallout/cert.php?$token_b64";
124 //TEST
125 // $script = 'http://guppy.zemeplocha.info:10080/~guppy/fallout/cert.php?' . implode('/', array_keys($perky));
127 // echo "<a href=\"$script\">[url=$script][/url] </a><br />\n";
128 echo "<a href=\"$script\">CERTIFIKÁT</a><br />\n";
130 echo "</div>\n";
132 // print_r(decodeToken($token_b64));
138 </body>
139 </html>