Пример #1
0
 public function __construct(SignShop $SignShop)
 {
     if (file_exists($SignShop->getDataFolder() . "/resources/player.db")) {
         $this->plr = new \SQLite3($SignShop->getDataFolder() . "/resources/player.db", SQLITE3_OPEN_READWRITE);
     } else {
         $this->plr = new \SQLite3($SignShop->getDataFolder() . "/resources/player.db", SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
     }
     if (file_exists($SignShop->getDataFolder() . "/resources/sign.db")) {
         $this->sign = new \SQLite3($SignShop->getDataFolder() . "/resources/sign.db", SQLITE3_OPEN_READWRITE);
     } else {
         $this->sign = new \SQLite3($SignShop->getDataFolder() . "/resources/sign.db", SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
     }
     $this->sign->exec('CREATE TABLE IF NOT EXISTS sign (var varchar(255), id int(5), damage int(5), amount int(2), available varchar(15), cost int(15), maker varchar(255), sold int(50), earned int(50), direction int(2), type VARCHAR(4) DEFAULT "buy", need INT(15))');
     $this->plr->exec('CREATE TABLE IF NOT EXISTS plr (player varchar(255), authorized varchar(10), changed int(15), echo varchar(6))');
     if ($SignShop->getSetup()->get("version") != "oneone") {
         $this->sign->exec("ALTER TABLE sign ADD type VARCHAR(4) DEFAULT 'buy', need INT(15)");
         $SignShop->getSetup()->set("version", "oneone");
         foreach ($this->getAllPlayers() as $var => $c) {
             if ($c["authorized"] == "super") {
                 $c["authorized"] = "root";
             } elseif ($c["authorized"] == "auth") {
                 $c["authorized"] = "allow";
             } elseif ($c["authorized"] == "unauth") {
                 $c["authorized"] = "denied";
             }
             $this->setPlayer($var, $c);
         }
         foreach ($this->getAllSigns() as $var => $c) {
             $pos = explode(":", $var);
             $pos[3] = str_replace("%", " ", $pos[3]);
             $this->removeSign($var);
             $this->setSign($pos, $c);
         }
     }
 }
Пример #2
0
 public function __construct(SignShop $SignShop)
 {
     $dataResources = $SignShop->getDataFolder() . "/resources/";
     if (file_exists($dataResources . "player_authorized.yml")) {
         rename($dataResources . "player_authorized.yml", $dataResources . "player.yml");
     }
     $this->sign = new Config($dataResources . "sign.yml", Config::YAML);
     $this->plr = new Config($dataResources . "player.yml", Config::YAML);
     if ($SignShop->getSetup()->get("version") != "oneone") {
         foreach ($this->plr->getAll() as $var => $c) {
             if (!isset($c["earned"])) {
                 $c["earned"] = 0;
             }
             if (!isset($c["totEarned"])) {
                 $c["totEarned"] = 0;
             }
             if (!isset($c["totSpent"])) {
                 $c["totSpent"] = 0;
             }
             if (!isset($c["echo"])) {
                 $c["echo"] = true;
             }
             if ($c["authorized"] == "super") {
                 $c["authorized"] = "root";
             }
             if ($c["authorized"] == "auth") {
                 $c["authorized"] = "allowed";
             }
             if ($c["authorized"] == "unauth") {
                 $c["authorized"] = "denied";
             }
             $this->plr->set($var, $c);
             $this->plr->save();
         }
         foreach ($this->sign->getAll() as $var => $c) {
             if (!isset($c["type"])) {
                 $c["type"] = "buy";
             }
             if (!isset($c["need"])) {
                 $c["need"] = 0;
             }
             if (!isset($c["sold"])) {
                 $c["sold"] = 0;
             }
             if (!isset($c["earned"])) {
                 $c["earned"] = 0;
             }
             if (!isset($c["direction"])) {
                 $c["direction"] = 0;
             }
             if (!isset($c["damage"])) {
                 $c["damage"] = $c["meta"];
                 unset($c["meta"]);
             }
             $pos = explode(":", $var);
             $pos[3] = str_replace("%", " ", $pos[3]);
             $this->sign->remove($var);
             $this->sign->set(implode(":", $pos), $c);
             $this->sign->save();
         }
         $SignShop->getSetup()->set("version", "oneone");
         $SignShop->getSetup()->save();
     }
 }