about summary refs log tree commit diff stats
path: root/pages/blog.php
blob: 009326cfa6a273ae1188f3a7d08ca8a14b7a9360 (plain) (blame)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
/*
       444444444  
      4::::::::4  
     4:::::::::4  
    4::::44::::4  
   4::::4 4::::4   Four Island
  4::::4  4::::4  
 4::::4   4::::4   Written and maintained by Starla Insigna
4::::444444::::444
4::::::::::::::::4  pages/blog.php
4444444444:::::444
          4::::4   Please do not use, reproduce or steal the
          4::::4   contents of this file without explicit
          4::::4   permission from Hatkirby.
        44::::::44
        4::::::::4
        4444444444
*/

if (!defined('S_INCLUDE_FILE')) {define('S_INCLUDE_FILE',1);}

require('headerproc.php');

if ((strpos($_SERVER['REQUEST_URI'],'index.php')) && (isset($_GET['post'])))
{
	header('Location: /blog/' . $_GET['post'] . '/');
}

$pageCategory = 'home';
$pageAID = 'archive';

if (isset($_GET['post']))
{
	$template = new FITemplate('post');
	$template->adds_block('INTERNAL',array('exi'=>1));

	$getpost = "SELECT * FROM updates WHERE slug = \"" . urldecode($_GET['post']) . "\"";
	$getpost2 = mysql_query($getpost);
	$getpost3 = mysql_fetch_array($getpost2);

	if ($getpost3['slug'] == urldecode($_GET['post']))
	{
		updatePop($getpost3['id'],'views');

		$title = stripslashes($getpost3['title']) . ' - Blog Archive';

		$getback = "SELECT * FROM updates WHERE id = " . ($getpost3['id']-1);
		$getback2 = mysql_query($getback);
		$getback3 = mysql_fetch_array($getback2);
		if (isset($getback3['title']))
		{
			$template->adds_block('BACK', array(	'CODED' => $getback3['slug'],
								'TITLE' => $getback3['title']));
		}

		$getnext = "SELECT * FROM updates WHERE id = " . ($getpost3['id']+1);
		$getnext2 = mysql_query($getnext);
		$getnext3 = mysql_fetch_array($getnext2);
		if (isset($getnext3['title']))
		{
			$template->adds_block('NEXT', array(	'CODED' => $getnext3['slug'],
								'TITLE' => $getnext3['title']));
		}

		$template->add_ref(0, 'POST', array(	'ID' => $getpost3['id'],
							'YEARID' => ((date('Y',strtotime($getpost3['pubDate']))-2006) % 4),
							'DATE' => date('F dS Y \a\\t g:i:s a',strtotime($getpost3['pubDate'])),
							'MONTH' => date('M',strtotime($getpost3['pubDate'])),
							'DAY' => date('d',strtotime($getpost3['pubDate'])),
							'CODED' => $getpost3['slug'],
							'TITLE' => $getpost3['title'],
							'AUTHOR' => $getpost3['author'],
							'RATING' => $getpost3['rating'],
							'TEXT' => parseBBCode($getpost3['text'])));

		$tags = unserialize($getpost3['tags']);
		foreach ($tags as $tag)
		{
			$template->adds_ref_sub(0, 'TAGS', array('TAG' => $tag));
		}

		$template->display();

		$getpings = "SELECT * FROM pingbacks WHERE post_id = " . $getpost3['id'];
		$getpings2 = mysql_query($getpings);
		$i=0;
		while ($getpings3[$i] = mysql_fetch_array($getpings2))
		{
			if ($i==0)
			{
				$template = new FITemplate('pingbacks');
			}

			$template->adds_block('PINGBACK', array(	'TITLE' => $getpings3[$i]['title'],
									'URL' => $getpings3[$i]['url'],
									'DATE' => date('F d<\S\U\P>S</\S\U\P> Y', strtotime($getpings3[$i]['pubDate']))));
			$i++;
		}

		if ($i > 0)
		{
			$template->display();
		}

		$page_id = 'updates-' . $getpost3['id'];
		include('includes/comments.php');

		$getrelated = "SELECT *, MATCH (title, text) AGAINST (\"" . addslashes($getpost3['title']) . "\") AS score FROM updates WHERE MATCH (title, text) AGAINST (\"" . addslashes($getpost3['title']) . "\") AND id <> " . $getpost3['id'] . " LIMIT 0,5";
		$getrelated2 = mysql_query($getrelated);
		$i=0;
		while ($getrelated3[$i] = mysql_fetch_array($getrelated2))
		{
			if ($i==0)
			{
				$template = new FITemplate('related');
			}

			$template->adds_block('POST', array(	'TITLE' => $getrelated3[$i]['title'],
								'CODED' => $getrelated3[$i]['slug'],
								'AUTHOR' => $getrelated3[$i]['author'],
								'DATE' => date('F d<\S\U\P>S</\S\U\P> Y',strtotime($getrelated3[$i]['pubDate']))));
			$i++;
		}

		if ($i > 0)
		{
			$template->display();
		}
	} else {
		generateError('404');
	}
} else {
	$template = new FITemplate('archive');
	if (isset($_GET['author']))
	{
		$title = 'Author: ' . $_GET['author'] . ' - Blog Archive';
		$getposts = "SELECT * FROM updates WHERE author = \"" . $_GET['author'] . "\" ORDER BY id DESC";
		$getbio = "SELECT * FROM bio WHERE username = \"" . $_GET['author'] . "\"";
		$getbio2 = mysql_query($getbio);
		$getbio3 = mysql_fetch_array($getbio2);
		if ($getbio3['username'] == $_GET['author'])
		{
			$template->adds_block('BIO', array(	'TEXT' => $getbio3['text'],
								'USERNAME' => $getbio3['username'],
								'DATE' => date('F dS Y \a\\t g:i:s a',strtotime($getbio3['lastUpdated']))));
		}
	} elseif (isset($_GET['tag']))
	{
		$title = 'Tag: ' . $_GET['tag'] . ' - Blog Archive';
		$getposts = "SELECT * FROM updates WHERE tags LIKE '%s:" . strlen($_GET['tag']) . ":\"" . $_GET['tag'] . "\"%' ORDER BY id DESC";
	} else {
		$title = 'Blog Archive';
		$getposts = "SELECT * FROM updates ORDER BY id DESC";
	}
	$getposts2 = mysql_query($getposts);
	$i=0;
	while ($getposts3[$i] = mysql_fetch_array($getposts2))
	{
		if ((!isset($lastmonth)) || ($lastmonth != date('m-Y',strtotime($getposts3[$i]['pubDate']))))
		{
			if (!isset($curID))
			{
				$curID = 0;
			} else {
				$curID++;
			}
			$template->add_ref($curID, 'MONTH', array('TITLE' => date('F Y',strtotime($getposts3[$i]['pubDate']))));
			if ($curID == 0)
			{
				$template->adds_ref_sub($curID, 'BIGEND',array('exi'=>1));
			}
			$lastmonth = date('m-Y',strtotime($getposts3[$i]['pubDate']));
		}

		$page_id = 'updates-' . $getposts3[$i]['id'];
		$getcomments = "SELECT * FROM comments WHERE page_id = \"" . $page_id . "\" ORDER BY posttime";
		$getcomments2 = mysql_query($getcomments);
		$total_post=0;
		while ($getcomments3[$total_post] = mysql_fetch_array($getcomments2))
		{
			$total_post++;
		}
		if ($total_post >= 2)
		{
			$plural = 's';
		}
		if ($total_post == 0)
		{
			$comText = 'No Comments';
		} elseif ($total_post == 1)
		{
			$comText = '1 Comment';
		} else {
			$comText = $total_post . ' Comments';
		}

		if ($curID == 0)
		{
			$template->adds_ref_sub($curID, 'BIG',array(	'DATE' => date('m-d-Y',strtotime($getposts3[$i]['pubDate'])),
									'CODED' => $getposts3[$i]['slug'],
									'TITLE' => $getposts3[$i]['title'],
									'ID' => $getposts3[$i]['id'],
									'YEARID' => ((date('Y',strtotime($getposts3[$i]['pubDate']))-2006) % 4),
									'MONTH' => date('M',strtotime($getposts3[$i]['pubDate'])),
									'DAY' => date('d',strtotime($getposts3[$i]['pubDate'])),
									'AUTHOR' => $getposts3[$i]['author'],
									'PLURALCOMMENT' => (isset($plural) ? $plural : ''),
									'COMMENTS' => $comText));
		} else {
			$template->adds_ref_sub($curID, 'SMALL',array(	'DATE' => date('m-d-Y',strtotime($getposts3[$i]['pubDate'])),
									'CODED' => $getposts3[$i]['slug'],
									'TITLE' => $getposts3[$i]['title']));
		}
		$i++;
	}
	if ($i==0)
	{
		generateError('404');
	}
	$template->display();
}

?>
reqs)) def get_panel_reqs(self, panel_id: int, answer: str | None) -> AccessRequirements: if answer is None: if panel_id not in self.panel_reqs: self.panel_reqs[panel_id] = self.calculate_panel_reqs(panel_id, answer) return self.panel_reqs.get(panel_id) else: if panel_id not in self.proxy_reqs or answer not in self.proxy_reqs.get(panel_id): self.proxy_reqs.setdefault(panel_id, {})[answer] = self.calculate_panel_reqs(panel_id, answer) return self.proxy_reqs.get(panel_id).get(answer) def calculate_panel_reqs(self, panel_id: int, answer: str | None) -> AccessRequirements: panel = self.world.static_logic.objects.panels[panel_id] reqs = AccessRequirements() reqs.rooms.add(self.world.static_logic.get_room_region_name(panel.room_id)) if answer is not None: reqs.add_solution(answer) elif len(panel.proxies) > 0: possibilities = [] for proxy in panel.proxies: proxy_reqs = AccessRequirements() proxy_reqs.add_solution(proxy.answer) possibilities.append(proxy_reqs) if not any(proxy.answer == panel.answer for proxy in panel.proxies): proxy_reqs = AccessRequirements() proxy_reqs.add_solution(panel.answer) possibilities.append(proxy_reqs) reqs.or_logic.append(possibilities) else: reqs.add_solution(panel.answer) for symbol in panel.symbols: reqs.symbols.add(symbol) if panel.HasField("required_door"): door_reqs = self.get_door_open_reqs(panel.required_door) reqs.merge(door_reqs) if panel.HasField("required_room"): reqs.rooms.add(self.world.static_logic.get_room_region_name(panel.required_room)) return reqs # This gets/calculates the requirements described by the door object. This is most notably used as the requirements # for clearing a location, or opening a door when the door is not shuffled. def get_door_reqs(self, door_id: int) -> AccessRequirements: if door_id not in self.door_reqs: self.door_reqs[door_id] = self.calculate_door_reqs(door_id) return self.door_reqs.get(door_id) def calculate_door_reqs(self, door_id: int) -> AccessRequirements: door = self.world.static_logic.objects.doors[door_id] reqs = AccessRequirements() # TODO: lavender_cubes, endings if not door.HasField("complete_at") or door.complete_at == 0: for proxy in door.panels: panel_reqs = self.get_panel_reqs(proxy.panel, proxy.answer if proxy.HasField("answer") else None) reqs.merge(panel_reqs) elif door.complete_at == 1: reqs.or_logic.append([self.get_panel_reqs(proxy.panel, proxy.answer if proxy.HasField("answer") else None) for proxy in door.panels]) else: # TODO: Handle complete_at > 1 pass if door.HasField("control_center_color"): # TODO: Logic for ensuring two CC states aren't needed at once. reqs.rooms.add("Control Center - Main Area") reqs.add_solution(door.control_center_color) if door.double_letters: # TODO: When letter shuffle is on, change this to require any double letter instead. reqs.rooms.add("The Repetitive - Main Room") for keyholder_uses in door.keyholders: key_name = keyholder_uses.key.upper() if key_name not in reqs.letters: reqs.letters[key_name] = 1 keyholder = self.world.static_logic.objects.keyholders[keyholder_uses.keyholder] reqs.rooms.add(self.world.static_logic.get_room_region_name(keyholder.room_id)) for room in door.rooms: reqs.rooms.add(self.world.static_logic.get_room_region_name(room)) for ending_id in door.endings: ending = self.world.static_logic.objects.endings[ending_id] reqs.items.add(f"{ending.name.capitalize()} Ending (Achieved)") for sub_door_id in door.doors: sub_reqs = self.get_door_open_reqs(sub_door_id) reqs.merge(sub_reqs) return reqs # This gets the requirements to open a door within the world. When a door is shuffled, this means having the item # that acts as the door's key. def get_door_open_reqs(self, door_id: int) -> AccessRequirements: if door_id in self.item_by_door: reqs = AccessRequirements() item_name, amount = self.item_by_door.get(door_id) if amount == 1: reqs.items.add(item_name) else: reqs.progressives[item_name] = amount return reqs else: return self.get_door_reqs(door_id)