root/server/announce.php

Revision 1, 0.5 kB (checked in by swizec, 3 years ago)

initial import of working example app

Line 
1<?php
2
3include( "wolf.php" );
4include( "wolves.php" );
5
6// fetch and sanitise variables
7$id = ( isset( $_POST[ "id" ] ) ) ? intval( $_POST[ "id" ] ) : -1;
8$x = ( isset( $_POST[ "x" ] ) ) ? abs( intval( $_POST[ "x" ] ) ) : 0;
9$y = ( isset( $_POST[ "y" ] ) ) ? abs( intval( $_POST[ "y" ] ) ) : 0;
10
11if ( $id < 0 )
12{
13        $id = count( $wolves );
14}
15
16if ( $x > 37 )
17{
18        $x = 37;
19}
20if ( $y > 37 )
21{
22        $y = 37;
23}
24
25$wolves[ $id ] = new Wolf( $x, $y, time() );
26
27file_put_contents( "wolves.php", '<?php $wolves = ' . var_export( $wolves, TRUE ) . ' ?>' );
28
29echo $id;
30
31?>
Note: See TracBrowser for help on using the browser.