protected function mute()
 {
     if (!$this->isAdmin()) {
         return;
     }
     if (empty($_POST['player']) || empty($_POST['mute-server']) || empty($_POST['mute-expiration']) || !isset($_POST['mute-reason'])) {
         $answer = new AJAXAnswer("One or many parameters are missing !", false);
         echo $answer->getJSON();
         return;
     }
     $uuid = $this->model->getPlayerUUID($_POST['player']);
     if ($uuid == null) {
         $answer = new AJAXAnswer("Error : " . $_POST['player'] . "'s UUID can't be found.", false);
         echo $answer->getJSON();
         return;
     }
     $muteExpiration;
     if ($_POST['mute-expiration'] == "definitive") {
         $muteExpiration = null;
     } else {
         $muteExpiration = DateTime::createFromFormat("m/d/Y h:i A", $_POST['mute-expiration']);
         $muteExpiration = $muteExpiration->format("Y-m-d H:i:s");
     }
     $result = $this->model->mute($uuid, $_POST['mute-server'], $muteExpiration, $this->getUsername(), $_POST['mute-reason']);
     echo $result;
 }
Exemplo n.º 2
0
 public function toogleSU($user)
 {
     $query = $this->database->prepare("UPDATE BAT_web SET superuser = !superuser WHERE user = :user;");
     $query->execute(array("user" => $user));
     if ($query->rowCount() > 0) {
         $answer = new AJAXAnswer($user . "'s SuperUser rights have been updated!", true);
         return $answer->getJSON();
     } else {
         $answer = new AJAXAnswer("Error: there is no account with that name!", true);
         return $answer->getJSON();
     }
 }
Exemplo n.º 3
0
 public function ban($uuid, $banServer, $banExpiration, $banStaff, $banReason)
 {
     $query = $this->database->prepare("INSERT INTO `BAT_ban`(UUID, ban_staff, ban_server, ban_end, ban_reason) \r\n\t\t\t\tVALUES (:uuid, :staff, :server, :expiration, :reason)");
     if ($banExpiration == null) {
         $query->bindParam(":expiration", $banExpiration, PDO::PARAM_NULL);
     } else {
         $query->bindParam(":expiration", $banExpiration);
     }
     $query->bindParam(":uuid", $uuid);
     $query->bindParam(":staff", $banStaff);
     $query->bindParam(":server", $banServer);
     $query->bindParam(":reason", $banReason);
     $query->execute();
     if ($query->rowCount() > 0) {
         $answer = new AJAXAnswer("Banned successfully!", true);
         return $answer->getJSON();
     } else {
         $answer = new AJAXAnswer("Error : the ban process has failed for unknown reason.", false);
         return $answer->getJSON();
     }
 }
 protected function toggleSU()
 {
     if (!$this->isSU()) {
         $this->index();
         return;
     }
     if (empty($_POST['user'])) {
         $answer = new AJAXAnswer("User parameter is missing !", false);
         echo $answer->getJSON();
         return;
     }
     if ($this->getUsername() == $_POST['user']) {
         $answer = new AJAXAnswer("You can't remove yourself your SU rights !", false);
         echo $answer->getJSON();
         return;
     }
     echo $this->model->toogleSU($_POST['user']);
 }