just a quick uncomment cause some just run and wonder why it dose nothing
[travianx.git] / crop_finder.php
blob53ef8542e7ff86c63cab47ead239e71e58630d46
1 <?php
3 #################################################################################
4 ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
5 ## --------------------------------------------------------------------------- ##
6 ## Filename crop_finder.php ##
7 ## Made by: Dzoki ##
8 ## License: TravianX Project ##
9 ## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
10 ## ##
11 #################################################################################
13 include ("GameEngine/Village.php");
15 if($session->plus == 0) {
16 header("Location: plus.php?id=3");
19 if($_POST['type'] == 15) {
20 header("Location: ".$_SERVER['PHP_SELF']."?s=1");
21 } else
22 if($_POST['type'] == 9) {
23 header("Location: ".$_SERVER['PHP_SELF']."?s=2");
27 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
28 <html>
29 <head>
30 <title><?php
32 echo SERVER_NAME
34 ?> - Crop Finder</title>
35 <link REL="shortcut icon" HREF="favicon.ico"/>
36 <meta http-equiv="cache-control" content="max-age=0" />
37 <meta http-equiv="pragma" content="no-cache" />
38 <meta http-equiv="expires" content="0" />
39 <meta http-equiv="imagetoolbar" content="no" />
40 <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
41 <script src="mt-full.js?0faaa" type="text/javascript"></script>
42 <script src="unx.js?0faaa" type="text/javascript"></script>
43 <script src="new.js?0faaa" type="text/javascript"></script>
44 <link href="<?php
46 echo GP_LOCATE;
48 ?>lang/en/lang.css?f4b7c" rel="stylesheet" type="text/css" />
49 <link href="<?php
51 echo GP_LOCATE;
53 ?>lang/en/compact.css?f4b7c" rel="stylesheet" type="text/css" />
54 <?php
56 if($session->gpack == null || GP_ENABLE == false) {
57 echo "
58 <link href='".GP_LOCATE."travian.css?e21d2' rel='stylesheet' type='text/css' />
59 <link href='".GP_LOCATE."lang/en/lang.css?e21d2' rel='stylesheet' type='text/css' />";
61 else {
62 echo "
63 <link href='".$session->gpack."travian.css?e21d2' rel='stylesheet' type='text/css' />
64 <link href='".$session->gpack."lang/en/lang.css?e21d2' rel='stylesheet' type='text/css' />";
68 <script type="text/javascript">
70 window.addEvent('domready', start);
71 </script>
72 </head>
75 <body class="v35 ie ie8">
76 <div class="wrapper">
77 <img style="filter:chroma();" src="img/x.gif" id="msfilter" alt="" />
78 <div id="dynamic_header">
79 </div>
80 <?php
82 include ("Templates/header.tpl");
85 <div id="mid">
86 <?php
88 include ("Templates/menu.tpl");
91 <div id="content" class="player">
93 <h1>Crop Finder</h1>
94 <center>
95 <img width="200" src="gpack/travian_default/img/g/f6.jpg" />
96 <img width="200" src="gpack/travian_default/img/g/f1.jpg" />
97 </center>
98 <br /><br />
99 <form action="<?php
101 echo $_SERVER['PHP_SELF'];
103 ?>?s" method="post">
104 <span>Search for:</span><br />
105 <input type="radio" class="radio" name="type" value="15" /> 15 crop
106 <input type="radio" class="radio" name="type" value="9" /> 9 crop <br />
107 <input type="submit" name="submit" value="Search">
108 </form>
110 <?php
112 define('PREFIX', TB_PREFIX);
113 $type15 = mysql_query("SELECT id,x,y,occupied FROM ".PREFIX."wdata WHERE fieldtype = 6");
114 $type9 = mysql_query("SELECT id,x,y,occupied FROM ".PREFIX."wdata WHERE fieldtype = 1");
115 $wref = $village->wid;
116 $coor = $database->getCoor($wref);
118 function getDistance($coorx1, $coory1, $coorx2, $coory2) {
119 $max = 2 * WORLD_MAX + 1;
120 $x1 = intval($coorx1);
121 $y1 = intval($coory1);
122 $x2 = intval($coorx2);
123 $y2 = intval($coory2);
124 $distanceX = min(abs($x2 - $x1), $max - abs($x2 - $x1));
125 $distanceY = min(abs($y2 - $y1), $max - abs($y2 - $y1));
126 $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2));
127 return round($dist, 1);
130 if($_GET['s'] == 1) {
133 <table id="member">
134 <thead>
135 <tr>
136 <th colspan='5'>Crop Finder - 15c</th>
137 </tr>
138 <tr>
139 <td>Type</td>
140 <td>Coordinates</td>
141 <td>Owner</td>
142 <td>Occupied</td>
143 <td>Distance</td>
144 </tr>
145 </thead><tbody>
148 </td></tr><br>
150 <?php
152 while($row = mysql_fetch_array($type15)) {
153 $dist = getDistance($coor['x'], $coor['y'], $row['x'], $row['y']);
155 $rows[$dist] = $row;
158 ksort($rows);
159 foreach($rows as $dist => $row) {
161 echo "<tr>";
162 echo "<td>15c</td>";
163 if($row['occupied'] == 0) {
164 echo "<td>(".$row['x']."|".$row['y'].")</td>";
165 echo "<td>-</td>";
166 echo "<td><b><font color=\"green\">Unoccupied</b></font></td>";
167 } else {
168 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>";
169 echo "<td><a href=\"spieler.php?uid=".$database->getVillageField($row['id'], "owner")."\">".$database->getUserField($database->getVillageField($row['id'], "owner"), "username", 0)."</a></td>";
170 echo "<td><b><font color=\"red\">Occupied</b></font></td>";
172 echo "<td><center>".getDistance($coor['x'], $coor['y'], $row['x'], $row['y'])."</center></td>";
177 </tbody></table>
179 <?php
182 else if($_GET['s'] == 2) {
185 <table id="member">
186 <thead>
187 <tr>
188 <th colspan='5'>Crop Finder - 9c</th>
189 </tr>
190 <tr>
191 <td>Type</td>
192 <td>Coordinates</td>
193 <td>Owner</td>
194 <td>Occupied</td>
195 <td>Distance</td>
196 </tr>
197 </thead><tbody>
200 </td></tr><br>
201 <?php
203 unset($rows);
204 while($row = mysql_fetch_array($type9)) {
205 $dist = getDistance($coor['x'], $coor['y'], $row['x'], $row['y']);
207 $rows[$dist] = $row;
210 ksort($rows);
211 foreach($rows as $dist => $row) {
214 echo "<tr>";
215 echo "<td>9c</td>";
216 if($row['occupied'] == 0) {
217 echo "<td>(".$row['x']."|".$row['y'].")</td>";
218 echo "<td>-</td>";
219 echo "<td><b><font color=\"green\">Unoccupied</b></font></td>";
220 } else {
221 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>";
222 echo "<td><a href=\"spieler.php?uid=".$database->getVillageField($row['id'], "owner")."\">".$database->getUserField($database->getVillageField($row['id'], "owner"), "username", 0)."</a></td>";
223 echo "<td><b><font color=\"red\">Occupied</b></font></td>";
225 echo "<td><center>".getDistance($coor['x'], $coor['y'], $row['x'], $row['y'])."</center></td>";
230 </tbody></table>
232 <?php
237 </div>
238 <div id="side_info">
239 <?php
241 include ("Templates/quest.tpl");
242 include ("Templates/news.tpl");
243 include ("Templates/multivillage.tpl");
244 include ("Templates/links.tpl");
247 </div>
248 <div class="clear"></div>
249 </div>
250 <div class="footer-stopper"></div>
251 <div class="clear"></div>
253 <?php
255 include ("Templates/footer.tpl");
256 include ("Templates/res.tpl");
259 <div id="stime">
260 <div id="ltime">
261 <div id="ltimeWrap">
262 Calculated in <b><?php
264 echo round(($generator->pageLoadTimeEnd() - $start) * 1000);
266 ?></b> ms
268 <br />Server time: <span id="tp1" class="b"><?php
270 echo date('H:i:s');
272 ?></span>
273 </div>
274 </div>
275 </div>
277 <div id="ce"></div>
278 </body>
279 </html>
280 </html>