just a quick uncomment cause some just run and wonder why it dose nothing
[travianx.git] / cropfinder.php
blob0bc46b26743e379bed8d7da7ad14143e19093531
1 <?php
2 include ("GameEngine/Village.php");
4 if($session->plus == 0) {
5 header("Location: plus.php?id=3");
8 if($_POST['type'] == 15) {
9 header("Location: ".$_SERVER['PHP_SELF']."?s=1");
10 } else
11 if($_POST['type'] == 9) {
12 header("Location: ".$_SERVER['PHP_SELF']."?s=2");
16 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
17 <html>
18 <head>
19 <title><?php
21 echo SERVER_NAME
23 ?> - Crop Finder</title>
24 <link REL="shortcut icon" HREF="favicon.ico"/>
25 <meta http-equiv="cache-control" content="max-age=0" />
26 <meta http-equiv="pragma" content="no-cache" />
27 <meta http-equiv="expires" content="0" />
28 <meta http-equiv="imagetoolbar" content="no" />
29 <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
30 <script src="mt-full.js?0faaa" type="text/javascript"></script>
31 <script src="unx.js?0faaa" type="text/javascript"></script>
32 <script src="new.js?0faaa" type="text/javascript"></script>
33 <link href="<?php
35 echo GP_LOCATE;
37 ?>lang/en/lang.css?f4b7c" rel="stylesheet" type="text/css" />
38 <link href="<?php
40 echo GP_LOCATE;
42 ?>lang/en/compact.css?f4b7c" rel="stylesheet" type="text/css" />
43 <?php
45 if($session->gpack == null || GP_ENABLE == false) {
46 echo "
47 <link href='".GP_LOCATE."travian.css?e21d2' rel='stylesheet' type='text/css' />
48 <link href='".GP_LOCATE."lang/en/lang.css?e21d2' rel='stylesheet' type='text/css' />";
50 else {
51 echo "
52 <link href='".$session->gpack."travian.css?e21d2' rel='stylesheet' type='text/css' />
53 <link href='".$session->gpack."lang/en/lang.css?e21d2' rel='stylesheet' type='text/css' />";
57 <script type="text/javascript">
59 window.addEvent('domready', start);
60 </script>
61 </head>
64 <body class="v35 ie ie8">
65 <div class="wrapper">
66 <img style="filter:chroma();" src="img/x.gif" id="msfilter" alt="" />
67 <div id="dynamic_header">
68 </div>
69 <?php
71 include ("Templates/header.tpl");
74 <div id="mid">
75 <?php
77 include ("Templates/menu.tpl");
80 <div id="content" class="player">
82 <h1>Crop Finder</h1>
83 <center>
84 <img width="200" src="gpack/travian_default/img/g/f6.jpg" />
85 <img width="200" src="gpack/travian_default/img/g/f1.jpg" />
86 </center>
87 <br /><br />
88 <form action="<?php
90 echo $_SERVER['PHP_SELF'];
92 ?>?s" method="post">
93 <span>Search for:</span><br />
94 <input type="radio" class="radio" name="type" value="15" /> 15 crop
95 <input type="radio" class="radio" name="type" value="9" /> 9 crop <br />
96 <input type="submit" name="submit" value="Search">
97 </form>
99 <?php
101 define('PREFIX', TB_PREFIX);
102 $type15 = mysql_query("SELECT id,x,y,occupied FROM ".PREFIX."wdata WHERE fieldtype = 6");
103 $type9 = mysql_query("SELECT id,x,y,occupied FROM ".PREFIX."wdata WHERE fieldtype = 1");
104 $wref = $village->wid;
105 $coor = $database->getCoor($wref);
107 function getDistance($coorx1, $coory1, $coorx2, $coory2) {
108 $max = WORLD_MAX * WORLD_MAX;
109 $x1 = intval($coorx1);
110 $y1 = intval($coory1);
111 $x2 = intval($coorx2);
112 $y2 = intval($coory2);
113 $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1)));
114 $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1)));
115 $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2));
116 return round($dist, 1);
119 if($_GET['s'] == 1) {
122 <table id="member">
123 <thead>
124 <tr>
125 <th colspan='5'>Crop Finder - 15c</th>
126 </tr>
127 <tr>
128 <td>Type</td>
129 <td>Coordinates</td>
130 <td>Owner</td>
131 <td>Occupied</td>
132 <td>Distance</td>
133 </tr>
134 </thead><tbody>
137 </td></tr><br>
139 <?php
141 while($row = mysql_fetch_array($type15)) {
142 $dist = getDistance($coor['x'], $coor['y'], $row['x'], $row['y']);
144 $rows[$dist] = $row;
147 ksort($rows);
148 foreach($rows as $dist => $row) {
150 echo "<tr>";
151 echo "<td>15c</td>";
152 if($row['occupied'] == 0) {
153 echo "<td>(".$row['x']."|".$row['y'].")</td>";
154 echo "<td>-</td>";
155 echo "<td><b><font color=\"green\">Unoccupied</b></font></td>";
156 } else {
157 echo "<td><a href=\"karte.php?d=".$row['id']."&c=".$generator->getMapCheck($row['id'])."\">".$database->getVillageField($row['id'], "name")." (".$row['x']."|".$row['y'].")</a></td>";
158 echo "<td><a href=\"spieler.php?uid=".$database->getVillageField($row['id'], "owner")."\">".$database->getUserField($database->getVillageField($row['id'], "owner"), "username", 0)."</a></td>";
159 echo "<td><b><font color=\"red\">Occupied</b></font></td>";
161 echo "<td><center>".getDistance($coor['x'], $coor['y'], $row['x'], $row['y'])."</center></td>";
166 </tbody></table>
168 <?php
171 else if($_GET['s'] == 2) {
174 <table id="member">
175 <thead>
176 <tr>
177 <th colspan='5'>Crop Finder - 9c</th>
178 </tr>
179 <tr>
180 <td>Type</td>
181 <td>Coordinates</td>
182 <td>Owner</td>
183 <td>Occupied</td>
184 <td>Distance</td>
185 </tr>
186 </thead><tbody>
189 </td></tr><br>
190 <?php
192 unset($rows);
193 while($row = mysql_fetch_array($type9)) {
194 $dist = getDistance($coor['x'], $coor['y'], $row['x'], $row['y']);
196 $rows[$dist] = $row;
199 ksort($rows);
200 foreach($rows as $dist => $row) {
203 echo "<tr>";
204 echo "<td>9c</td>";
205 if($row['occupied'] == 0) {
206 echo "<td>(".$row['x']."|".$row['y'].")</td>";
207 echo "<td>-</td>";
208 echo "<td><b><font color=\"green\">Unoccupied</b></font></td>";
209 } else {
210 echo "<td><a href=\"karte.php?d=".$row['id']."&c=".$generator->getMapCheck($row['id'])."\">".$database->getVillageField($row['id'], "name")." (".$row['x']."|".$row['y'].")</a></td>";
211 echo "<td><a href=\"spieler.php?uid=".$database->getVillageField($row['id'], "owner")."\">".$database->getUserField($database->getVillageField($row['id'], "owner"), "username", 0)."</a></td>";
212 echo "<td><b><font color=\"red\">Occupied</b></font></td>";
214 echo "<td><center>".getDistance($coor['x'], $coor['y'], $row['x'], $row['y'])."</center></td>";
219 </tbody></table>
221 <?php
226 </div>
227 <div id="side_info">
228 <?php
230 include ("Templates/quest.tpl");
231 include ("Templates/news.tpl");
232 include ("Templates/multivillage.tpl");
233 include ("Templates/links.tpl");
236 </div>
237 <div class="clear"></div>
238 </div>
239 <div class="footer-stopper"></div>
240 <div class="clear"></div>
242 <?php
244 include ("Templates/footer.tpl");
245 include ("Templates/res.tpl");
248 <div id="stime">
249 <div id="ltime">
250 <div id="ltimeWrap">
251 Calculated in <b><?php
253 echo round(($generator->pageLoadTimeEnd() - $start) * 1000);
255 ?></b> ms
257 <br />Server time: <span id="tp1" class="b"><?php
259 echo date('H:i:s');
261 ?></span>
262 </div>
263 </div>
264 </div>
266 <div id="ce"></div>
267 </body>
268 </html>
269 </html>