blob: 3075ac3e09d090cbd73eb6daf08e4139d1cb1d51 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
<?php /* Copyright (c) 2024 Freya Murphy */
class Bucket_model extends Model {
private $bucket_json;
private $bucket_map;
function __construct()
{
$this->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;
}
}
|