Guest
Public paste!

Untitled

By: a guest | Mar 18th, 2010 | Syntax: PHP | Size: 8.38 KB | Hits: 34 | Expires: Never
This paste has a previous version, view the difference. 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", "defegejiki") 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($playerf); // Level 5
  71. $square = 128;
  72. $length = $square * $square;
  73. $count = 0;
  74. $map = array();
  75.  
  76. while($count < $length)
  77. {
  78.         $map[] = rand(0,9) > 7 ? '#' : '.';
  79.         $count++;
  80. }
  81.  
  82. $location = $playery*$playerx;
  83.  
  84. $p01 = $location-($square*1);
  85.  
  86.  
  87.  
  88. srand(5); // Level 5
  89. $square = 128;
  90. $y = 0;
  91. $map = array();
  92. $entities = array();
  93.  
  94. while($y < $square)
  95. {
  96.         $m = array();
  97.         $e = array();
  98.         $x = 0;
  99.         while($x < $square)
  100.         {
  101.                 $tile = rand(0,9) > 7 ? false : true;
  102.                 $e[] = !$tile && rand(0,9) > 7 ? true : false;
  103.                 $m[] = $tile;
  104.                 $x++;
  105.         }
  106.         $entities = $e;
  107.         $map[] = $m;
  108.         $y++;
  109. }
  110.  
  111.  
  112. $visibility = 17;
  113. $visibBase = floor($visibility / 2);
  114. $y = 0;
  115.  
  116. $mapVisib = array();
  117. $entVisib = array();
  118.  
  119. while($y < $visibility)
  120. {
  121.         $x = 0;
  122.         $m = array();
  123.         $e = array();
  124.         $currentY = $playery + $y - $visibBase;
  125.        
  126.         while($x < $visibility)
  127.         {
  128.                 $currentX = $playerx + $x - $visibBase;
  129.                 $m[$currentX] = (isset($map[$currentY]) && isset($map[$currentY][$currentX])) ? $map[$currentY][$currentX] : false;
  130.                 $e[$currentX] = (isset($entities[$currentY]) && isset($entities[$currentY][$currentX])) ? $entities[$currentY][$currentX] : false;
  131.                 $x++;
  132.         }
  133.         $mapVisib[$currentY] = $m;
  134.         $entVisib[$currentY] = $m;
  135.         $y++;
  136. }
  137.  
  138.  
  139.  
  140. ?>
  141.  
  142. <html>
  143. <head>
  144. <style>
  145.  
  146. body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,table,
  147. th,td                           { margin: 0; padding: 0;}
  148. ul, li, ol                      { list-style: none; }
  149. fieldset,img,abbr               { border: 0; }
  150. address,caption,cite,code,dfn,em,h1,h2,h3,h4,h5,h6,th,var    {  }
  151. caption,th                      { text-align: left; }
  152. q:before,q:after                { content: ''; }
  153. a                               { text-decoration: none; }
  154. body                            {font-size:12px; font-family:Georgia; color:#fff; background-color:#111; text-align: justify}
  155. table                           {margin:0px; padding:0px; border:0px; }
  156. pre                             {font-family: VT100,Lucida Console, Monaco, monospace; font-size:9px;}
  157. hr                              {border:0px; border-top:1px dashed #333; height:0px;}
  158. h1                              {font-size:45px; font-style: italic; font-family:Georgia; font-weight:normal;}
  159. h2                              {font-size:45px; font-family:Georgia; font-weight:bold; }
  160.  
  161. #nav { width: 660px; margin: 40px auto;}
  162.  
  163. #nav div {
  164.         list-style-type:none;
  165.         font-size:2em;
  166. }
  167.  
  168. #nav div a {
  169.         background-image:url('sprites.gif');
  170.         background-repeat:no-repeat;
  171.         padding: 0 0 0 0px;
  172.         display: block;
  173.         height: 16px;
  174.         width:16px;
  175.         float:left;
  176. }
  177.  
  178. #nav div a.player       {background-position:0px 0px;position:absolute; top:128px; left:128px; width:16px; height:16px;}
  179. #nav div a:hover.player {background-position:0px -16px; position:absolute; top:128px; left:128px; width:16px; height:16px;}
  180.  
  181. #nav div a.arr_right    {background-position:-64px 0px; position:absolute; top:128px; left:144px; width:16px; height:16px;}
  182. #nav div a:hover.arr_right {background-position:-64px -16px; position:absolute; top:128px; left:144px; width:16px; height:16px;}
  183.  
  184. #nav div a.arr_left     {background-position:-48px 0px; position:absolute; top:128px; left:112px; width:16px; height:16px;}
  185. #nav div a:hover.arr_left {background-position:-48px -16px; position:absolute; top:128px; left:112px; width:16px; height:16px;}
  186.  
  187. #nav div a.arr_up       {background-position:-16px 0px; position:absolute; top:112px; left:128px; width:16px; height:16px;}
  188. #nav div a:hover.arr_up {background-position:-16px -16px; position:absolute; top:112px; left:128px; width:16px; height:16px;}
  189.  
  190. #nav div a.arr_down     {background-position:-32px 0px; position:absolute; top:144px; left:128px; width:16px; height:16px;}
  191. #nav div a:hover.arr_down {background-position:-32px -16px; position:absolute; top:144px; left:128px; width:16px; height:16px;}
  192.  
  193. .wall         {background-position:-16px -32px; position:absolute; width:16px; height:16px;background-image:url('sprites.gif');
  194. background-repeat:no-repeat;}
  195.  
  196. </style>
  197. </head>
  198. <body style='background-color:#111; width:620px'>
  199.        
  200.         <?     
  201.         print "
  202.         <div style='background-color:#777; width:360; height:360px; margin:50px auto; '>
  203.                
  204.                 <div style='width:272px; height:272; margin:40px; background-color:#666; position:absolute;
  205.                 background-image:url(ground.gif); background-position: $groundx $groundy;
  206.                 '>
  207.  
  208. <div id='nav'>
  209. <div><a class='player' href='#'></a>   </div>
  210. <div><a class='arr_right' href='move.php?x=$mo_ri&y=$playery&n=$playern'></a></div>
  211. <div><a class='arr_left' href='move.php?x=$mo_le&y=$playery&n=$playern'></a> </div>
  212. <div><a class='arr_up' href='move.php?x=$playerx&y=$mo_up&n=$playern'></a>   </div>
  213. <div><a class='arr_down' href='move.php?x=$playerx&y=$mo_do&n=$playern'></a> </div>";
  214.  
  215.  
  216.  
  217.  
  218. foreach($mapVisib as $y => $ligne)
  219. {
  220.         foreach($ligne as $x => $tile)
  221.         {
  222.                 $newx = ($playerx * 16)-($x * 16)+(8*16);
  223.                 $newy = ($playery * 16)-($y * 16)+(8*16);
  224.                 echo $tile ? '' : '<div style="top:'.$newy.'px;left:'.$newx.'px" class="wall"></div>
  225.                 ';
  226.                
  227.         }
  228.         echo "\r\n";
  229. }
  230.  
  231. foreach($entVisib as $y => $ligne)
  232. {
  233.         foreach($ligne as $x => $tile)
  234.         {
  235.                 $newx = ($playerx * 16)-($x * 16)+(8*16);
  236.                 $newy = ($playery * 16)-($y * 16)+(8*16);
  237.                 echo $tile ? '' : '<div style="top:'.$newy.'px;left:'.$newx.'px;opacity:.5;" class="wall"></div>
  238.                 ';
  239.                
  240.         }
  241.         echo "\r\n";
  242. }
  243.  
  244.  
  245. $limitx = $playerx + 9;
  246. $minimx = $playerx - 9;
  247. $limity = $playery + 9;
  248. $minimy = $playery - 9;
  249.  
  250. $result = mysql_query("SELECT * from xiv_merveilles WHERE floor = '$u[floor]' and x < '$limitx' and x > '$minimx' and y < '$limity' and y > '$minimy'");
  251. while($row = mysql_fetch_array($result))
  252. {/*echo $row['mv_name']; print " ("; echo $row['x']; print ","; echo $row['y']; echo ")<br />";*/
  253. $playersx = $row['x']; $playersy = $row['y']; $playersn = $row['mv_name'];
  254. $playersy = ($playery * 16)-($playersy * 16)+(16*8);
  255. $playersx = ($playerx * 16)-($playersx * 16)+(16*8);
  256.  
  257. if($row['mv_name']=="$playern"){print "";}
  258. else {print "<div style='width:16px; height:16px; position:absolute; top:$playersy; left:$playersx; background-position:0px 0px;background-image:url(sprites.gif);'></div>
  259. <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>
  260.  
  261. ";}
  262.  
  263.  
  264. }
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271. print "
  272.  
  273. </div>
  274. ";
  275.  
  276.  
  277.  
  278.  
  279. ?>     
  280.                 </div>
  281.                
  282.         </div>
  283.        
  284.        
  285.        
  286.        
  287.        
  288.  
  289.        
  290. <?php
  291.  
  292.  
  293.  
  294.  
  295. /*
  296. echo '<pre>';
  297. foreach($mapVisib as $y => $ligne)
  298. {
  299.         foreach($ligne as $x => $tile)
  300.         {
  301.                 echo $tile ? '.' : '#';
  302.         }
  303.         echo "\r\n";
  304. }
  305. echo '</pre>';
  306.  
  307. */
  308. ?>
  309.  
  310.  
  311. </body>
  312. </html>