<?php
// OUBLIE PAS DE DECOMMENTER LE UPDATE !!!
print "working<br /><br />";
parse_str("$QUERY_STRING");
$db = mysql_connect("internal-db.s269.gridserver.com", "isopharmacy", "Zaq12wsx") or die("Could not connect.");
if(!$db)
die("no db");
if(!mysql_select_db("db269_ao",$db))
die("No database selected.");
if(!get_magic_quotes_gpc())
{
$_GET = array_map('mysql_real_escape_string', $_GET);
$_POST = array_map('mysql_real_escape_string', $_POST);
$_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);
}
else
{
$_GET = array_map('stripslashes', $_GET);
$_POST = array_map('stripslashes', $_POST);
$_COOKIE = array_map('stripslashes', $_COOKIE);
$_GET = array_map('mysql_real_escape_string', $_GET);
$_POST = array_map('mysql_real_escape_string', $_POST);
$_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);
}
$playerx = $_GET['x'];
$playery = $_GET['y'];
$playern = $_GET['n'];
$request="SELECT * from xiv_merveilles where mv_name='$playern'";
$request2=mysql_query($request) or die("Could not get user stats");$u=mysql_fetch_array($request2);
$playerf = $u[floor];
// SECURITY
$playerx = preg_replace("/</","<",$playerx);
$playerx = preg_replace("/>/",">",$playerx);
$playerx = nl2br($playerx);
$playerx = substr($playerx, 0, 3);
$playery = preg_replace("/</","<",$playery);
$playery = preg_replace("/>/",">",$playery);
$playery = nl2br($playery);
$playery = substr($playery, 0, 3);
$update = mysql_query("UPDATE `db269_ao`.`xiv_merveilles` SET `x` = $playerx,`y` = $playery WHERE mv_name='$playern'");
$result = mysql_query("SELECT * from xiv_merveilles");
while($row = mysql_fetch_array($result))
{echo $row['mv_name']; print " ("; echo $row['x']; print ","; echo $row['y']; echo ") floor: ";echo $row['floor']; echo "<br />"; }
$mo_ri = $playerx -1;
$mo_le = $playerx +1;
$mo_up = $playery +1;
$mo_do = $playery -1;
$groundx = ($playerx * 16);
$groundy = ($playery * 16);
srand(5); // Level 5
$square = 128;
$y = 0;
$map = array();
$entities = array();
while($y < $square)
{
$m = array();
$e = array();
$x = 0;
while($x < $square)
{
$tile = rand(0,9) > 7 ? false : true;
$e[] = !$tile && rand(0,9) > 7 ? true : false;
$m[] = $tile;
$x++;
}
$entities[] = $e;
$map[] = $m;
$y++;
}
$visibility = 17;
$visibBase = floor($visibility / 2);
$y = 0;
$mapVisib = array();
$entVisib = array();
while($y < $visibility)
{
$x = 0;
$m = array();
$e = array();
$currentY = $playery + $y - $visibBase;
while($x < $visibility)
{
$currentX = $playerx + $x - $visibBase;
$m[$currentX] = (isset($map[$currentY]) && isset($map[$currentY][$currentX])) ? $map[$currentY][$currentX] : false;
$e[$currentX] = (isset($entities[$currentY]) && isset($entities[$currentY][$currentX])) ? $entities[$currentY][$currentX] : false;
$x++;
}
$mapVisib[$currentY] = $m;
$entVisib[$currentY] = $e;
$y++;
}
?>
<html>
<head>
<style>
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,table,
th,td { margin: 0; padding: 0;}
ul, li, ol { list-style: none; }
fieldset,img,abbr { border: 0; }
address,caption,cite,code,dfn,em,h1,h2,h3,h4,h5,h6,th,var { }
caption,th { text-align: left; }
q:before,q:after { content: ''; }
a { text-decoration: none; }
body {font-size:12px; font-family:Georgia; color:#fff; background-color:#111; text-align: justify}
table {margin:0px; padding:0px; border:0px; }
pre {font-family: VT100,Lucida Console, Monaco, monospace; font-size:9px;}
hr {border:0px; border-top:1px dashed #333; height:0px;}
h1 {font-size:45px; font-style: italic; font-family:Georgia; font-weight:normal;}
h2 {font-size:45px; font-family:Georgia; font-weight:bold; }
#nav { width: 660px; margin: 40px auto;}
#nav div {
list-style-type:none;
font-size:2em;
}
#nav div a {
background-image:url('sprites.gif');
background-repeat:no-repeat;
padding: 0 0 0 0px;
display: block;
height: 16px;
width:16px;
float:left;
}
#nav div a.player {background-position:0px 0px;position:absolute; top:128px; left:128px; width:16px; height:16px;}
#nav div a:hover.player {background-position:0px -16px; position:absolute; top:128px; left:128px; width:16px; height:16px;}
#nav div a.arr_right {background-position:-64px 0px; position:absolute; top:128px; left:144px; width:16px; height:16px;}
#nav div a:hover.arr_right {background-position:-64px -16px; position:absolute; top:128px; left:144px; width:16px; height:16px;}
#nav div a.arr_left {background-position:-48px 0px; position:absolute; top:128px; left:112px; width:16px; height:16px;}
#nav div a:hover.arr_left {background-position:-48px -16px; position:absolute; top:128px; left:112px; width:16px; height:16px;}
#nav div a.arr_up {background-position:-16px 0px; position:absolute; top:112px; left:128px; width:16px; height:16px;}
#nav div a:hover.arr_up {background-position:-16px -16px; position:absolute; top:112px; left:128px; width:16px; height:16px;}
#nav div a.arr_down {background-position:-32px 0px; position:absolute; top:144px; left:128px; width:16px; height:16px;}
#nav div a:hover.arr_down {background-position:-32px -16px; position:absolute; top:144px; left:128px; width:16px; height:16px;}
.wall {background-position:-16px -32px; position:absolute; width:16px; height:16px;background-image:url('sprites.gif');
background-repeat:no-repeat;}
</style>
</head>
<body style='background-color:#111; width:620px'>
<?
print "
<div style='background-color:#777; width:360; height:360px; margin:50px auto; '>
<div style='width:272px; height:272; margin:40px; background-color:#666; position:absolute;
background-image:url(ground.gif); background-position: $groundx $groundy;
'>
<div id='nav'>
<div><a class='player' href='#'></a> </div>
<div><a class='arr_right' href='move.php?x=$mo_ri&y=$playery&n=$playern'></a></div>
<div><a class='arr_left' href='move.php?x=$mo_le&y=$playery&n=$playern'></a> </div>
<div><a class='arr_up' href='move.php?x=$playerx&y=$mo_up&n=$playern'></a> </div>
<div><a class='arr_down' href='move.php?x=$playerx&y=$mo_do&n=$playern'></a> </div>";
foreach($mapVisib as $y => $ligne)
{
foreach($ligne as $x => $tile)
{
$newx = ($playerx * 16)-($x * 16)+(8*16);
$newy = ($playery * 16)-($y * 16)+(8*16);
echo $tile ? '' : '<div style="top:'.$newy.'px;left:'.$newx.'px" class="wall"></div>
';
}
echo "\r\n";
}
foreach($entVisib as $y => $ligne)
{
foreach($ligne as $x => $tile)
{
$newx = ($playerx * 16)-($x * 16)+(8*16);
$newy = ($playery * 16)-($y * 16)+(8*16);
echo $tile ? '' : '<div style="top:'.$newy.'px;left:'.$newx.'px;opacity:.5;" class="wall"></div>
';
}
echo "\r\n";
}
$limitx = $playerx + 9;
$minimx = $playerx - 9;
$limity = $playery + 9;
$minimy = $playery - 9;
$result = mysql_query("SELECT * from xiv_merveilles WHERE floor = '$u[floor]' and x < '$limitx' and x > '$minimx' and y < '$limity' and y > '$minimy'");
while($row = mysql_fetch_array($result))
{/*echo $row['mv_name']; print " ("; echo $row['x']; print ","; echo $row['y']; echo ")<br />";*/
$playersx = $row['x']; $playersy = $row['y']; $playersn = $row['mv_name'];
$playersy = ($playery * 16)-($playersy * 16)+(16*8);
$playersx = ($playerx * 16)-($playersx * 16)+(16*8);
if($row['mv_name']=="$playern"){print "";}
else {print "<div style='width:16px; height:16px; position:absolute; top:$playersy; left:$playersx; background-position:0px 0px;background-image:url(sprites.gif);'></div>
<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>
";}
}
print "
</div>
";
?>
</div>
</div>
<?php
/*
echo '<pre>';
foreach($mapVisib as $y => $ligne)
{
foreach($ligne as $x => $tile)
{
echo $tile ? '.' : '#';
}
echo "\r\n";
}
echo '</pre>';
*/
?>
</body>
</html>