has('locations', ['osmid' => $osmid])) { $database->insert('locations', ['osmid' => $osmid, 'teamid' => 0]); } $gameinfo = $database->select('locations', ["[>]players" => ["owneruuid" => "uuid"]], ['locations.locationid', 'players.nickname', 'locations.teamid', 'locations.currentlife', 'locations.maxlife'], ['osmid' => $osmid])[0]; //$gameinfo = $database->select('locations', ['locationid', 'teamid', 'currentlife', 'maxlife'], ['osmid' => $osmid])[0]; // Reset owner info for dead places if ($gameinfo['currentlife'] <= 0) { $database->update('locations', ['teamid' => 0, 'owneruuid' => null, 'maxlife' => 0], ['locationid' => $gameinfo['locationid']]); $gameinfo = $database->select('locations', ['locationid', 'teamid', 'currentlife', 'maxlife'], ['osmid' => $osmid])[0]; $gameinfo['nickname'] = ""; } $geo['features'][] = array("type" => "Feature", "geometry" => [ "type" => "Point", "coordinates" => [ floatval($plong), floatval($plat) ] ], "properties" => [ "osm_id" => intval($osmid), "name" => $name, "gameinfo" => $gameinfo//['teamid' => $gameinfo['teamid'], 'owneruuid' => $gameinfo['owneruuid']] ] ); } if ($VARS['debug']) { echo "got all the way to the encode "; } function utf8ize($d) { if (is_array($d)) { foreach ($d as $k => $v) { $d[$k] = utf8ize($v); } } else if (is_object($d)) { foreach ($d as $k => $v) { $d->$k = utf8ize($v); } } else { return utf8_encode($d); } return $d; } echo json_encode(utf8ize($geo)); if ($VARS['debug']) { switch (json_last_error()) { case JSON_ERROR_NONE: echo ' - No errors'; break; case JSON_ERROR_DEPTH: echo ' - Maximum stack depth exceeded'; break; case JSON_ERROR_STATE_MISMATCH: echo ' - Underflow or the modes mismatch'; break; case JSON_ERROR_CTRL_CHAR: echo ' - Unexpected control character found'; break; case JSON_ERROR_SYNTAX: echo ' - Syntax error, malformed JSON'; break; case JSON_ERROR_UTF8: echo ' - Malformed UTF-8 characters, possibly incorrectly encoded'; break; default: echo ' - Unknown error'; break; } }