|
Revision 1, 0.5 kB
(checked in by swizec, 3 years ago)
|
|
initial import of working example app
|
| Line | |
|---|
| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | include( "wolf.php" ); |
|---|
| 4 | include( "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 | |
|---|
| 11 | if ( $id < 0 ) |
|---|
| 12 | { |
|---|
| 13 | $id = count( $wolves ); |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | if ( $x > 37 ) |
|---|
| 17 | { |
|---|
| 18 | $x = 37; |
|---|
| 19 | } |
|---|
| 20 | if ( $y > 37 ) |
|---|
| 21 | { |
|---|
| 22 | $y = 37; |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | $wolves[ $id ] = new Wolf( $x, $y, time() ); |
|---|
| 26 | |
|---|
| 27 | file_put_contents( "wolves.php", '<?php $wolves = ' . var_export( $wolves, TRUE ) . ' ?>' ); |
|---|
| 28 | |
|---|
| 29 | echo $id; |
|---|
| 30 | |
|---|
| 31 | ?> |
|---|