Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 18th, 2010 | Syntax: PHP | Size: 8.13 KB | Hits: 84 | Expires: Never
Copy text to clipboard
  1. <?php
  2.  
  3.  
  4. // OUBLIE PAS DE DECOMMENTER LE UPDATE !!!
  5. print "working<br /><br />";
  6.  
  7. parse_str("$QUERY_STRING");
  8.  
  9. $db = mysql_connect("internal-db.s269.gridserver.com", "isopharmacy", "Zaq12wsx") or die("Could not connect.");
  10. if(!$db)
  11.         die("no db");
  12. if(!mysql_select_db("db269_ao",$db))
  13.         die("No database selected.");
  14. if(!get_magic_quotes_gpc())
  15. {
  16.   $_GET = array_map('mysql_real_escape_string', $_GET);
  17.   $_POST = array_map('mysql_real_escape_string', $_POST);
  18.   $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);
  19. }
  20. else
  21. {  
  22.    $_GET = array_map('stripslashes', $_GET);
  23.    $_POST = array_map('stripslashes', $_POST);
  24.    $_COOKIE = array_map('stripslashes', $_COOKIE);
  25.    $_GET = array_map('mysql_real_escape_string', $_GET);
  26.    $_POST = array_map('mysql_real_escape_string', $_POST);
  27.    $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);
  28. }
  29.  
  30. $playerx = $_GET['x'];
  31. $playery = $_GET['y'];
  32. $playern = $_GET['n'];
  33.  
  34. $request="SELECT * from xiv_merveilles where mv_name='$playern'";
  35. $request2=mysql_query($request) or die("Could not get user stats");$u=mysql_fetch_array($request2);
  36.  
  37. $playerf = $u[floor];
  38.  
  39.  
  40.  
  41. // SECURITY
  42.  
  43. $playerx = preg_replace("/</","&lt;",$playerx);  
  44. $playerx = preg_replace("/>/","&gt;",$playerx);  
  45. $playerx = nl2br($playerx);  
  46. $playerx = substr($playerx, 0, 3);
  47.  
  48. $playery = preg_replace("/</","&lt;",$playery);  
  49. $playery = preg_replace("/>/","&gt;",$playery);  
  50. $playery = nl2br($playery);  
  51. $playery = substr($playery, 0, 3);
  52.  
  53.  
  54.  
  55. $update = mysql_query("UPDATE  `db269_ao`.`xiv_merveilles` SET `x`  =  $playerx,`y`  =  $playery WHERE mv_name='$playern'");
  56.  
  57. $result = mysql_query("SELECT * from xiv_merveilles");
  58. while($row = mysql_fetch_array($result))
  59. {echo $row['mv_name']; print " ("; echo $row['x']; print ","; echo $row['y']; echo ") floor: ";echo $row['floor']; echo "<br />"; }
  60.  
  61.  
  62. $mo_ri = $playerx -1;
  63. $mo_le = $playerx +1;
  64. $mo_up = $playery +1;
  65. $mo_do = $playery -1;
  66.  
  67. $groundx = ($playerx * 16);
  68. $groundy = ($playery * 16);
  69.  
  70. srand(5); // Level 5
  71. $square = 128;
  72. $y = 0;
  73. $map = array();
  74. $entities = array();
  75.  
  76. while($y < $square)
  77. {
  78.         $m = array();
  79.         $e = array();
  80.         $x = 0;
  81.         while($x < $square)
  82.         {
  83.                 $tile = rand(0,9) > 7 ? false : true;
  84.                 $e[] = !$tile && rand(0,9) > 7 ? true : false;
  85.                 $m[] = $tile;
  86.                 $x++;
  87.         }
  88.         $entities[] = $e;
  89.         $map[] = $m;
  90.         $y++;
  91. }
  92.  
  93.  
  94. $visibility = 17;
  95. $visibBase = floor($visibility / 2);
  96. $y = 0;
  97.  
  98. $mapVisib = array();
  99. $entVisib = array();
  100.  
  101. while($y < $visibility)
  102. {
  103.         $x = 0;
  104.         $m = array();
  105.         $e = array();
  106.         $currentY = $playery + $y - $visibBase;
  107.        
  108.         while($x < $visibility)
  109.         {
  110.                 $currentX = $playerx + $x - $visibBase;
  111.                 $m[$currentX] = (isset($map[$currentY]) && isset($map[$currentY][$currentX])) ? $map[$currentY][$currentX] : false;
  112.                 $e[$currentX] = (isset($entities[$currentY]) && isset($entities[$currentY][$currentX])) ? $entities[$currentY][$currentX] : false;
  113.                 $x++;
  114.         }
  115.         $mapVisib[$currentY] = $m;
  116.         $entVisib[$currentY] = $e;
  117.         $y++;
  118. }
  119.  
  120.  
  121.  
  122. ?>
  123.  
  124. <html>
  125. <head>
  126. <style>
  127.  
  128. body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,table,
  129. th,td                           { margin: 0; padding: 0;}
  130. ul, li, ol                      { list-style: none; }
  131. fieldset,img,abbr               { border: 0; }
  132. address,caption,cite,code,dfn,em,h1,h2,h3,h4,h5,h6,th,var    {  }
  133. caption,th                      { text-align: left; }
  134. q:before,q:after                { content: ''; }
  135. a                               { text-decoration: none; }
  136. body                            {font-size:12px; font-family:Georgia; color:#fff; background-color:#111; text-align: justify}
  137. table                           {margin:0px; padding:0px; border:0px; }
  138. pre                             {font-family: VT100,Lucida Console, Monaco, monospace; font-size:9px;}
  139. hr                              {border:0px; border-top:1px dashed #333; height:0px;}
  140. h1                              {font-size:45px; font-style: italic; font-family:Georgia; font-weight:normal;}
  141. h2                              {font-size:45px; font-family:Georgia; font-weight:bold; }
  142.  
  143. #nav { width: 660px; margin: 40px auto;}
  144.  
  145. #nav div {
  146.         list-style-type:none;
  147.         font-size:2em;
  148. }
  149.  
  150. #nav div a {
  151.         background-image:url('sprites.gif');
  152.         background-repeat:no-repeat;
  153.         padding: 0 0 0 0px;
  154.         display: block;
  155.         height: 16px;
  156.         width:16px;
  157.         float:left;
  158. }
  159.  
  160. #nav div a.player       {background-position:0px 0px;position:absolute; top:128px; left:128px; width:16px; height:16px;}
  161. #nav div a:hover.player {background-position:0px -16px; position:absolute; top:128px; left:128px; width:16px; height:16px;}
  162.  
  163. #nav div a.arr_right    {background-position:-64px 0px; position:absolute; top:128px; left:144px; width:16px; height:16px;}
  164. #nav div a:hover.arr_right {background-position:-64px -16px; position:absolute; top:128px; left:144px; width:16px; height:16px;}
  165.  
  166. #nav div a.arr_left     {background-position:-48px 0px; position:absolute; top:128px; left:112px; width:16px; height:16px;}
  167. #nav div a:hover.arr_left {background-position:-48px -16px; position:absolute; top:128px; left:112px; width:16px; height:16px;}
  168.  
  169. #nav div a.arr_up       {background-position:-16px 0px; position:absolute; top:112px; left:128px; width:16px; height:16px;}
  170. #nav div a:hover.arr_up {background-position:-16px -16px; position:absolute; top:112px; left:128px; width:16px; height:16px;}
  171.  
  172. #nav div a.arr_down     {background-position:-32px 0px; position:absolute; top:144px; left:128px; width:16px; height:16px;}
  173. #nav div a:hover.arr_down {background-position:-32px -16px; position:absolute; top:144px; left:128px; width:16px; height:16px;}
  174.  
  175. .wall         {background-position:-16px -32px; position:absolute; width:16px; height:16px;background-image:url('sprites.gif');
  176. background-repeat:no-repeat;}
  177.  
  178. </style>
  179. </head>
  180. <body style='background-color:#111; width:620px'>
  181.        
  182.         <?     
  183.         print "
  184.         <div style='background-color:#777; width:360; height:360px; margin:50px auto; '>
  185.                
  186.                 <div style='width:272px; height:272; margin:40px; background-color:#666; position:absolute;
  187.                 background-image:url(ground.gif); background-position: $groundx $groundy;
  188.                 '>
  189.  
  190. <div id='nav'>
  191. <div><a class='player' href='#'></a>   </div>
  192. <div><a class='arr_right' href='move.php?x=$mo_ri&y=$playery&n=$playern'></a></div>
  193. <div><a class='arr_left' href='move.php?x=$mo_le&y=$playery&n=$playern'></a> </div>
  194. <div><a class='arr_up' href='move.php?x=$playerx&y=$mo_up&n=$playern'></a>   </div>
  195. <div><a class='arr_down' href='move.php?x=$playerx&y=$mo_do&n=$playern'></a> </div>";
  196.  
  197.  
  198.  
  199.  
  200. foreach($mapVisib as $y => $ligne)
  201. {
  202.         foreach($ligne as $x => $tile)
  203.         {
  204.                 $newx = ($playerx * 16)-($x * 16)+(8*16);
  205.                 $newy = ($playery * 16)-($y * 16)+(8*16);
  206.                 echo $tile ? '' : '<div style="top:'.$newy.'px;left:'.$newx.'px" class="wall"></div>
  207.                 ';
  208.                
  209.         }
  210.         echo "\r\n";
  211. }
  212.  
  213. foreach($entVisib as $y => $ligne)
  214. {
  215.         foreach($ligne as $x => $tile)
  216.         {
  217.                 $newx = ($playerx * 16)-($x * 16)+(8*16);
  218.                 $newy = ($playery * 16)-($y * 16)+(8*16);
  219.                 echo $tile ? '' : '<div style="top:'.$newy.'px;left:'.$newx.'px;opacity:.5;" class="wall"></div>
  220.                 ';
  221.                
  222.         }
  223.         echo "\r\n";
  224. }
  225.  
  226.  
  227. $limitx = $playerx + 9;
  228. $minimx = $playerx - 9;
  229. $limity = $playery + 9;
  230. $minimy = $playery - 9;
  231.  
  232. $result = mysql_query("SELECT * from xiv_merveilles WHERE floor = '$u[floor]' and x < '$limitx' and x > '$minimx' and y < '$limity' and y > '$minimy'");
  233. while($row = mysql_fetch_array($result))
  234. {/*echo $row['mv_name']; print " ("; echo $row['x']; print ","; echo $row['y']; echo ")<br />";*/
  235. $playersx = $row['x']; $playersy = $row['y']; $playersn = $row['mv_name'];
  236. $playersy = ($playery * 16)-($playersy * 16)+(16*8);
  237. $playersx = ($playerx * 16)-($playersx * 16)+(16*8);
  238.  
  239. if($row['mv_name']=="$playern"){print "";}
  240. else {print "<div style='width:16px; height:16px; position:absolute; top:$playersy; left:$playersx; background-position:0px 0px;background-image:url(sprites.gif);'></div>
  241. <div style='width:16px; height:16px; position:absolute; top:$playersy; left:$playersx; background-position:0px 0px; font-size:8px; padding-top:15px'>$playersn<br />5hp</div>
  242.  
  243. ";}
  244.  
  245.  
  246. }
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253. print "
  254.  
  255. </div>
  256. ";
  257.  
  258.  
  259.  
  260.  
  261. ?>     
  262.                 </div>
  263.                
  264.         </div>
  265.        
  266.        
  267.        
  268.        
  269.        
  270.  
  271.        
  272. <?php
  273.  
  274.  
  275.  
  276.  
  277. /*
  278. echo '<pre>';
  279. foreach($mapVisib as $y => $ligne)
  280. {
  281.         foreach($ligne as $x => $tile)
  282.         {
  283.                 echo $tile ? '.' : '#';
  284.         }
  285.         echo "\r\n";
  286. }
  287. echo '</pre>';
  288.  
  289. */
  290. ?>
  291.  
  292.  
  293. </body>
  294. </html>