X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=mud.php;h=4309fef193f0526c178e9d83337317922d36570d;hb=HEAD;hp=629f48edd076a48e79768baa558e6d399b6ef236;hpb=a1f3f9145f24d26020a16e95ea1baa21e5f53b59;p=mudd.git diff --git a/mud.php b/mud.php index 629f48e..4309fef 100644 --- a/mud.php +++ b/mud.php @@ -22,7 +22,8 @@ abstract class model { public function query() { $args = func_get_args(); $statement = $this->db->prepare(array_shift($args)); - if ($args) call_user_func_array(array($statement, 'bind_param'), &$args); + #if ($args) call_user_func_array(array($statement, 'bind_param'), &$args); + if ($args) call_user_func_array(array($statement, 'bind_param'), $args); $statement->execute(); $statement->store_result(); $statement->store_result(); @@ -44,7 +45,7 @@ abstract class model { public function insert() { $args = func_get_args(); $statement = $this->db->prepare(array_shift($args)); - call_user_func_array(array($statement, 'bind_param'), &$args); + call_user_func_array(array($statement, 'bind_param'), $args); $statement->execute(); return $this->db->insert_id; } @@ -52,7 +53,7 @@ abstract class model { public function update() { $args = func_get_args(); $statement = $this->db->prepare(array_shift($args)); - call_user_func_array(array($statement, 'bind_param'), &$args); + call_user_func_array(array($statement, 'bind_param'), $args); $statement->execute(); return $this->db->insert_id; } @@ -164,7 +165,7 @@ class mud extends model { if (!$dest || !$msg) $this->error('400', 'expected `dest` and `msg` fields'); $player = $this->query('SELECT id FROM players where name = ?', 's', $dest); if (!($player && $player['id'])) - $this->error('400', "could not find a player with `name` == $dest"); + $this->error(400, "could not find a player with `name` == $dest"); $this->insert( 'INSERT INTO messages (message,type,destination,source) VALUES(?,?,?,?)', 'ssii', $msg, 'say', $player['id'], $this->player->id); @@ -220,7 +221,8 @@ class mud extends model { public function command($cmd) { if (!$_GET['cmd']) $this->error(400, 'Missing command: expected `cmd` field'); - if ($_GET['cmd'] != 'join' && $_GET['cmd'] != 'start' && !isset($_SESSION['id'])) + if (($_GET['cmd'] != 'join' && $_GET['cmd'] != 'kick') + && $_GET['cmd'] != 'start' && !isset($_SESSION['id'])) $this->error(401, 'Missing user ID: please join first'); if (isset($_SESSION['id'])) $this->player = new player($this); switch ($cmd) { @@ -240,16 +242,19 @@ class mud extends model { $this->yell($_GET['msg']); break; case 'say': - $this->say($_GET['dest'], $_GET['msg']); + $this->say($_GET['msg']); break; case 'tell': - $this->tell(); + $this->tell($_GET['dest'], $_GET['msg']); break; case 'poll': - echo json_encode($this->poll()); + $this->response($this->poll()); + break; + case 'kick': + $this->update('DELETE FROM players'); break; default: - $this->error(400, 'Unknown command'); + $this->error(400, 'unknown command'); } }