setName($_POST['newclanname']); $this->setLogo(); $this->setAlign(intval($_POST['newclanalign'])); $this->new(); } private function setName(string $name) { $this->name = $name; } private function setLogo() { $this->logo = new Uploader('newclanlogo'); $this->logo->setMaxFileSize(.03); $this->logo->setDimensions(24, 15); $this->logo->setExtentions(['gif', 'png']); } private function setAlign(int $align) { if (!in_array($align, [0, 1, 3, 7])) { $align = 0; } $this->align = $align; } 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(); } private function hasGoodName(): bool { return Db::getValue('select count(id) from clan where name = ?', [$this->name]) === 0; } 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; } /** * @return int */ public function getNewClanId(): int { return $this->newClanId; } }