bucket_json = array(); if (file_exists('/var/run/crimson/bucket.json')) { $this->bucket_json = file_get_contents('/var/run/crimson/bucket.json'); $this->bucket_json = json_decode($this->bucket_json) ?? array(); } $this->bucket_map = array(); foreach ($this->bucket_json as $idx => $entry) { $this->bucket_map[$entry->name ?? ''] = $idx; } } public function get_before(string $name): string { $default = "https://webring.bucketfish.me/redirect.html?to=prev&name={$name}"; $idx = $this->bucket_map[$name ?? ''] ?? null; if (!$idx) return $default; if ($idx) $idx--; else $idx = count($this->bucket_json) - 1; return $this->bucket_json[$idx]->url ?? $default; } public function get_after(string $name): string { $default = "https://webring.bucketfish.me/redirect.html?to=next&name={$name}"; $idx = $this->bucket_map[$name ?? ''] ?? null; if (!$idx) return $default; $idx++; if ($idx == count($this->bucket_json)) $idx = 0; return $this->bucket_json[$idx]->url ?? $default; } public function get_data(): ?array { $data = parent::get_data(); $data['title'] = lang('first_name'); $data['desc'] = lang('default_short_desc'); if (array_key_exists('name', $_GET)) $data['name'] = $_GET['name']; else return NULL; if (array_key_exists('lightmode', $_GET)) $data['lightmode'] = $_GET['lightmode']; else $data['lightmode'] = 'false'; return $data; } }