/** * @param null $where * @param null $identification * @return string * @throws InvalidArgumentException */ protected function getLink($where = null, $identification = null) { if (in_array($where, ['index', 'edit'])) { switch ($where) { case 'index': return route('admin.' . $this->getPackage() . '.index'); break; case 'edit': if (!isset($identification)) { throw new InvalidArgumentException('Id should be set when $where is edit'); } return route('admin.' . $this->getPackage() . '.index', [$identification]); break; default: return resources($this->getResource()); break; } } else { return resources($this->getResource()); } }
connectMysql('dyn'); $DB->query("INSERT INTO actions (session_id, player_id, dateaction, actiondata) VALUES (" . $session_id . ", " . $player_id . ", NOW(), '" . addslashes(json_encode($data)) . "')"); $action_id = $DB->lastInsertId(); // "Réveiller" les autres joueurs pour leur indiquer qu'il y a une nouvelle action à lire $socket = getSocket(); stream_set_timeout($socket, 10); // Timeout de 10 secondes. fwrite($socket, $player_id . ",1\n"); // 1 = On débloque tout le monde immédiatement ! @fclose($socket); echo json_encode(array('id' => $action_id)); } switch ($call) { case 'gameinfo': gameinfo(); break; case 'gamemode': gamemode(); break; case 'resources': resources(); break; case 'subscribe': subscribe(); break; case 'postaction': postaction(); break; default: die('API ready 2'); }