This commit is contained in:
Gnieark 2016-06-19 20:41:47 +02:00
parent be44f53eed
commit 4ac9cd769b

View File

@ -1,4 +1,9 @@
<?php <?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
function is_it_possible_to_place_ships_on_grid($gridWidth,$gridHeight,$nbShipsSize1,$nbShipsSize2,$nbShipsSize3,$nbShipsSize4,$nbShipsSize5,$nbShipsSize6){ function is_it_possible_to_place_ships_on_grid($gridWidth,$gridHeight,$nbShipsSize1,$nbShipsSize2,$nbShipsSize3,$nbShipsSize4,$nbShipsSize5,$nbShipsSize6){
//return false or true //return false or true
//not a perfect solution //not a perfect solution
@ -67,9 +72,11 @@ function place_ship_on_map($x1,$y1,$x2,$y2,$map){
} }
} }
switch($_POST['act']){ $message=json_decode(file_get_contents('php://input'), TRUE);
switch($message['action']){
case "init": case "init":
file_put_contents(__DIR__."/log.txt",print_r($_POST,true)); //file_put_contents(__DIR__."/log.txt",print_r($_POST,true));
$wantedVars=array( $wantedVars=array(
'match_id' => false, //false-> string ; true -> integer 'match_id' => false, //false-> string ; true -> integer
'opponent' => false, 'opponent' => false,