rendered paste body<?
//version: 1195772503
$db['hostname'] = 'localhost';
$db['username'] = 'user';
$db['password'] = 'password';
$db['database'] = 'opensim';
mysql_connect($db['hostname'],$db['username'],$db['password']);
@mysql_select_db($db['database']) or die( "Unable to select database");
$query = "SELECT regionName, locX, locY FROM regions ORDER BY locX ASC, locY DESC, regionName DESC;";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$regions[$row['regionName']] = array('locX' => $row['locX'], 'locY' => $row['locY']);
}
mysql_close();
//Width and height of each region
$regionSize = 85;
//Center on a coordinate
$centerX = 19996;
$centerY = 20001;
//set X, Y upper bounds
$maxX = 20004;
$maxY = 20003;
//set X, Y lower bounds
$minX = 19995;
$minY = 19996;
//Create an image, properly sized
$imageWidth = (($maxX-$minX)*$regionSize);
$imageHeight = (($maxY-$minY)*$regionSize);
$heading = '<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.0" width="'.$imageWidth.'" height="'.$imageHeight.'" id="svg2">';
//foreach region, plot square at position in image multiplied by region width
foreach($regions as $regionName => $coords)
{
if($coords['locX'] > $minX AND $coords['locX'] < $maxX)
{
if($coords['locY'] > $minY AND $coords['locY'] < $maxY)
{
$rectangles .= '<rect width="'.$regionSize.'" height="'.$regionSize.'" x="'.($coords['locX']-$centerX)*$regionSize.'" y="'.(($coords['locY']-$centerY)*$regionSize*(-1)).'" style="opacity:1;fill:#00ff00;fill-opacity:1;stroke:#000000;stroke-width:1.00430417;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" id="'.$regionName.'_rectangle" />';
$text .= '<text x="'.((($coords['locX']-$centerX)*$regionSize)).'" y="'.(((($coords['locY']-$centerY)*$regionSize*(-1)))+($regionSize/2)).'" style="font-size:12px;font-family:Times-Roman" id="'.$regionName.'_text"><tspan dy="1em" dx="5">'.$regionName.'</tspan><tspan x="'.((($coords['locX']-$centerX)*$regionSize)).'" dx="5" dy="1em">X='.$coords['locX'].'</tspan><tspan x="'.((($coords['locX']-$centerX)*$regionSize)).'" dx="5" dy="1em">Y='.$coords['locY'].'</tspan></text>';
}
}
}
$ending = '</svg>';
$stringData = $heading.$rectangles.$text.$ending;
$fh = fopen('map.svg', 'w');
fwrite($fh, $stringData);
fclose($fh);
exec('convert map.svg map.png');
echo '<body bgcolor="#000000"><center><br><IMG SRC="map.png"></img>'
?>