/** * * @param string $shortname * @param string $longname * @param bool $worksafe * @param int $pages * @param int $per_page * @param int $privilege * @param bool $swf_board * @param int $group * @param bool $hidden */ function addBoard(string $shortname, string $longname, int $worksafe, int $pages, int $per_page, int $privilege, int $swf_board, int $group, int $hidden, int $archive_time, int $is_archive) { $stmt = $this->conn_rw->prepare("INSERT INTO `boards` " . "(`shortname`, `longname`, `worksafe`, `pages`, `perpage`, `privilege`, `swf_board`," . " `is_archive`, `first_crawl`, `last_crawl`, `group`, `hidden`,`archive_time`) VALUES " . "(:short, :long, :ws, :pages, :per, :priv, :swf, :is_archive, UNIX_TIMESTAMP(), 0, :group, :hidden,:archivetime)"); $stmt->execute([':short' => $shortname, ':long' => $longname, ':ws' => $worksafe, ':pages' => $pages, ':per' => $per_page, ':priv' => $privilege, ':swf' => $swf_board, ':group' => $group, ':hidden' => $hidden, ':archivetime' => $archive_time, ':is_archive' => $is_archive]); $sn = alphanum($shortname); // Set up board tables $this->conn_rw->exec(str_replace(['%BOARD%'], [$sn], file_get_contents(Site::getPath() . "/sql/newboard.sql"))); }
public function display() : string { $img = imagecreatetruecolor(96, 48); $image_text = empty($_SESSION['captcha']) ? 'error' : $_SESSION['captcha']; srand(time() / 60); $red = rand(0, 100); $green = rand(0, 100); $blue = rand(0, 100); $text_color = imagecolorallocate($img, 255 - $red, 255 - $green, 255 - $blue); $strlen = strlen($image_text); $char_array = str_split($image_text); for ($i = 0; $i < $strlen; $i++) { imagettftext($img, rand(13, 16), rand(-20, 20), 5 + 15 * $i, rand(15, 40), $text_color, Site::getPath() . "/cfg/DroidSansMono.ttf", $char_array[$i]); } header("Content-type:image/jpeg"); header("Content-Disposition:inline ; filename=secure.jpg"); imagejpeg($img, null, 5); exit; }
/** * Get the named config file. * If not found, throws exception. * @param string $name * @return array * @throws NotFoundException; */ static function getCfg($name) { if (isset(self::$json_cache[$name])) { return self::$json_cache[$name]; } if (file_exists(Site::getPath() . "/cfg/{$name}.json")) { self::$json_cache[$name] = json_decode(file_get_contents(Site::getPath() . "/cfg/{$name}.json"), true); return self::$json_cache[$name]; } throw new NotFoundException("Couldn't find config: {$name} (did you run the setup script?)"); }
static function stop($board) { if (self::getStatus($board) == self::RUNNING) { touch(Site::getPath() . "/backend/{$board}.kill"); } }