Ska koda ett platsbokningssystem till ett lan,
och hittade ett på nätet som verkar funka för mina ändamål.
Har dock fått ett litet problem.
Finns en fil som heter gdTickets.php med följande kod:
Kod:
Ett stycke php-kod:
<?PHP
include('../_inc/config.php');
include('../_inc/tickets.php');
$img = imagecreatefromgif( '../_gfx/struct-skeer.gif' );
$red = imagecolorallocate( $img, 255, 0, 0 );
$green = imagecolorallocate( $img, 0, 255, 0 );
$yellow= imagecolorallocate( $img, 255, 255, 0 );
$black = imagecolorallocate( $img, 0, 0, 0 );
$white = imagecolorallocate( $img, 255, 255, 255 );
$conf = $cnf['seatmap'];
//$s = $db->query("SELECT seat FROM ".MYSQL_TABLE_PREFIX."user_lan WHERE seat > 0 AND lanID = ".$tpl->lan['id']);
$seats = Array();
if (is_array($s))
foreach($s as $v)
$seats[$v['seat']] = 1;
if (isset($_GET['chosen']))
$seats[$_GET['chosen']] = 1;
unset($s);
$seatSize=$conf['seatsize'];
if (isset($_GET['sel']))
$sel = $_GET['sel'];
else
$sel = 0;
if (strstr($sel, ','))
$sel = explode(',', $sel);
for ( $i = 0; $i < $conf['tables']; $i++ )
{
for ( $j = 0; $j < 2; $j++ )
{
for ( $k = 0; $k < 14; $k++ )
{
if ($conf['direction'] == 'x') {
$x = $conf['leftoffset'] + ($seatSize+2)*$k;
$y = $conf['topoffset'] + $conf['tablespace']*$i + ($seatSize+2)*$j;
} else {
$x = $conf['leftoffset'] + $conf['tablespace']*$i + ($seatSize+2)*$j;
$y = $conf['topoffset'] + ($seatSize+2)*$k;
}
$plats = ($i * 2 * $conf['seats']) + ($j * $conf['seats']) + $k + 1; // +1 för att motsvara 1 ist. för 0
$col = (isset($seats[$plats]) ? $red : ( checkAvailableTicket($plats) ? $green : $white ) );
$col = (is_array($sel) ? (in_array($plats, $sel)?$yellow:$col) : ($plats==$sel?$yellow:$col) );
imagerectangle( $img, $x-1, $y-1, $x+$seatSize+1, $y+$seatSize+1, $black );
imagefilledrectangle( $img, $x, $y, $x+$seatSize, $y+$seatSize, $col );
}
}
}
foreach($conf['special'] as $name => $c) {
for ( $i = 0; $i < $c['seats']; $i++ )
{
$plats = $c['startseat']+$i;
if ($c['direction'] == 'x') {
$x = $c['leftoffset'] + ($seatSize+2)*$i;
$y = $c['topoffset'];
} else {
$x = $c['leftoffset'];
$y = $c['topoffset'] + ($seatSize+2)*$i;
}
$col = (isset($seats[$plats]) ? $red : $white );
$col = (is_array($sel) ? (in_array($plats, $sel)?$yellow:$col) : ($plats==$sel?$yellow:$col) );
imagerectangle( $img, $x-1, $y-1, $x+($seatSize+1), $y+($seatSize+1), $black );
imagefilledrectangle( $img, $x, $y, $x+$seatSize, $y+$seatSize, $col );
}
}
imagerectangle( $img, 40, 300, 50, 310, $black );
imagefilledrectangle( $img, 41, 301, 49, 309, $red );
imagestring( $img, 2, 55, 298, "= bokad", $black );
imagerectangle( $img, 40, 315, 50, 325, $black );
imagefilledrectangle( $img, 41, 316, 49, 324, $green );
imagestring( $img, 2, 55, 313, "= ledig", $black );
imagerectangle( $img, 40, 330, 50, 340, $black );
imagestring( $img, 2, 55, 328, "= reserverad", $black );
Header('Content-type: image/gif');
imagegif($img);
?>
Och som man ser här
http://valhack.com/lan_tickets.php
Så är det bilden i mitten som har med koden att göra.
Varför funkar det inte som det ska?
Möjligtvis någon som kan hjälpa mig att få det att funka.
Kan komplettera med fler uppgifter om något är oklart.
Tack på förhand!