newClanId; } public function __construct() { if (!isset($_POST['newclanname'], $_POST['newclanalign'], $_FILES['newclanlogo'])) { return; } $this->setName($_POST['newclanname']); $this->setLogo(); $this->setAlign(intval($_POST['newclanalign'])); $this->new(); } private function hasGoodName(): bool { return Db::getValue('select count(id) from clan where name = ?', [$this->name]) === 0; } public function new() { if (!$this->hasGoodName()) { return; } $imageId = $this->logo->saveToDb(); if (!$imageId) { echo $this->logo::$error; return; } Db::sql('insert into clan (name, align, logo) values (?,?,?)', [$this->name, $this->align, $imageId]); $this->newClanId = Db::lastInsertId(); } public static function approve(int $clanId) { Db::sql('update clan set status = 1, time_reg = unix_timestamp() where id = ?', [$clanId]); } public static function reject(int $clanId) { Db::sql('delete from clan where id = ?', [$clanId]); } public static function printForm(): string { $img = Config::img() . '/i/align'; return << div.regclangrid [type=radio] { position: absolute; opacity: 0; width: 0; height: 0; } /* IMAGE STYLES */ div.regclangrid [type=radio] + img { cursor: pointer; } /* CHECKED STYLES */ div.regclangrid [type=radio]:checked + img { outline: 1px solid brown; padding: 2px; } div.regclangrid { display: grid; grid-template-columns: 100px auto; }
размер: 24×15, формат: png или gif, до 30Кб
Склонность:
REGISTERFORM; } private function setName(string $name) { $this->name = $name; } private function setAlign(int $align) { if (!in_array($align, [0, 1, 3, 7])) { $align = 0; } $this->align = $align; } private function setLogo() { $this->logo = new Uploader('newclanlogo'); $this->logo->setMaxFileSize(.03); $this->logo->setDimensions(24, 15); $this->logo->setExtentions(['gif', 'png']); } }