Пример #1
0
 /**
  * @param self[] $sessions
  * @param MysqlConnection $conn
  */
 public static function saveData($sessions, MysqlConnection $conn)
 {
     $query = "INSERT INTO players(uid,names,hash,coins,lastonline,registry,lastip,histip,ipconfig,ignoring,primaryname,rank,notag,tid,teamrank,teamjointime,lastgrind,warnpts,tmpdelta,ontime,timesince)VALUES";
     $query .= implode(",", array_fill(0, count($sessions), "(%d,%s,%s,%g,%d,%d,%s,%s,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%g,%d,%d)"));
     $query .= "ON DUPLICATE KEY UPDATE names=VALUES(names),coins=coins+VALUES(tmpdelta),lastonline=VALUES(lastonline),lastip=VALUES(lastip),histip=VALUES(histip),ipconfig=VALUES(ipconfig),ignoring=VALUES(ignoring),notag=VALUES(notag),tid=VALUES(tid),teamrank=VALUES(teamrank),teamjointime=VALUES(teamjointime),lastgrind=VALUES(lastgrind),warnpts=VALUES(warnpts),ontime=ontime+VALUES(ontime)";
     $args = [];
     foreach ($sessions as $ses) {
         $data = $ses->data;
         $args[] = (int) $data["uid"];
         $args[] = $data["names"];
         $args[] = $data["hash"];
         $args[] = $data["coins"];
         $args[] = $data["lastonline"];
         $args[] = $data["registry"];
         $args[] = $data["lastip"];
         $args[] = $data["histip"];
         $args[] = $data["ipconfig"];
         $args[] = $data["ignoring"];
         $args[] = $data["primaryname"];
         $args[] = $data["rank"];
         $args[] = $data["notag"];
         $args[] = $data["tid"];
         $args[] = $data["teamrank"];
         $args[] = $data["teamjointime"];
         $args[] = $data["lastgrind"];
         $args[] = $data["warnpts"];
         $args[] = $data["coins"] - $ses->lastCoins;
         $ses->lastCoins = $data["coins"];
         $args[] = time() - $ses->onSince;
         $args[] = $ses->onSince;
         $ses->onSince = time();
     }
     $conn->query($query, MysqlConnection::RAW, ...$args);
 }
Пример #2
0
 public function onDisable()
 {
     foreach ($this->getServer()->getOnlinePlayers() as $player) {
         $this->sessions->onPlayerDisconnect(new PlayerQuitEvent($player, "Server stop"));
     }
     $this->teamMgr->saveTeams();
     $this->mysqli->close();
     $url = $this->pasteTimings();
     $mem = memory_get_usage(true) / 1048576 . "MB";
     $msg = $this->getDescription()->getFullName() . " has been disabled at " . Utils::getIP() . ":{$this->getServer()->getPort()} with peak memory reaching {$mem}. ";
     $msg .= "The process ID is " . getmypid() . ". ";
     $dateTime = (new \DateTime())->setTimestamp($this->timestamp);
     $msg .= "The plugin was built on " . $dateTime->format("jS F, Y \\a\\t H:i:s (T, \\G\\M\\T P). ");
     $msg .= "Timings has been pasted to {$url}.";
     if (!IS_TEST) {
         Utils::getURL(self::IRC_WEBHOOK . urlencode($msg), 2);
     }
     $this->getLogger()->info($msg);
 }
Пример #3
0
 public static function fetchById(MysqlConnection $mysql, $id)
 {
     return self::fromAssoc($mysql->query("SELECT uid,class,pts,msg,issuer,unix_timestamp(creation)AS creation,id FROM warnings_logs WHERE id={$id}", MysqlConnection::ASSOC));
 }
Пример #4
0
 public function updateToMysql(MysqlConnection $con)
 {
     if ($this->updated) {
         $con->query($this->insert ? "INSERT INTO kitpvp_kits(uid,kitid,name,helmet,chestplate,leggings,boots,weapon,food,arrows)VALUES(%d,%d,%s,%d,%d,%d,%d,%d,%d,%d);" : "UPDATE kitpvp_kits SET name=%3\$s,helmet=%4\$d,chestplate=%5\$d,leggings=%6\$d,boots=%7\$d,weapon=%8\$d,food=%9\$d,arrows=%10\$d WHERE uid=%1\$d AND kitid=%2\$d;", MysqlConnection::RAW, $this->uid, $this->kitid, $this->name, $this->helmet, $this->chestplate, $this->leggings, $this->boots, $this->weapon, $this->food, $this->arrows);
         $this->insert = false;
     }
 }