master
ブランチ master
LittleBeast / src / Site / Controller / Page.php
6.4 KB、200行 生 Blame 履歴
1<?php
2/*************************************************************
3# 076 License
4
5Copyright (c) テクニカル諏訪子
6
7Permission is hereby granted to any person obtaining a copy of the software
8Little Beast (the "Software") to use, modify, merge, copy, publish, distribute,
9sublicense, and/or sell copies of the Software, subject to the following conditions:
10
11 1. **Origin Attribution**:
12 - You must not misrepresent the origin of the Software; you must not claim
13 you created the original Software.
14 - If the Software is used in a product, you must either:
15 a. Provide clear attribution in the product's documentation, user interface,
16 or other visible areas, **OR**
17 b. Pay the original developers a fee they specify in writing.
18 2. **Usage Restriction**:
19 - The Software, or any derivative works, dependencies, or libraries
20 incorporating it, must not be used for censorship or to suppress freedom of
21 speech, expression, or creativity. Prohibited uses include, but are not
22 limited to:
23 - Censorship of so-called "hate speech", visuals, non-mainstream opinions,
24 ideas, or objective reality.
25 - Tools or systems designed to restrict access to information or
26 artistic works.
27 3. **Notice Preservation**:
28 - This license and the above copyright notice must remain intact in all copies
29 of the source code.
30
31THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
32INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
33PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
34HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
35CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 */
38namespace Site\Controller;
39
40use Site\Controller\Mods;
41use Std\Lib\Auth;
42use Std\Lib\Template;
43use Roles;
44
45use Std\Lib\Syntax; // TEST
46
47class Page {
48 use Mods;
49
50 public function test(array $params): void {
51 try {
52 $tmpl = new Template('/');
53 $pagetit = '新ページ';
54 $description = 'PHPフレームワークについて';
55
56 // ユーザー
57 $auth = new Auth();
58 $user = $auth->getLoggedInUser();
59 $tmpl->assign('user', $user);
60
61 $codeAsm = file_get_contents(ROOT.'/data/main.s');
62 $codeC = file_get_contents(ROOT.'/data/main.c');
63 $asm = new Syntax('asm');
64 $c = new Syntax('c');
65
66 $tmpl->assign('cCode', $c->colorize($codeC));
67 $tmpl->assign('asmCode', $asm->colorize($codeAsm));
68
69 $tmpl->assign('pagetit', $pagetit);
70 $tmpl->assign('curPage', 'test');
71 $tmpl->assign('custCss', false);
72 $tmpl->assign('menu', $this->getMenu());
73 $tmpl->assign('description', $description);
74
75 $tmpl->addCss('code');
76 $tmpl->render('test');
77 } catch (\Exception $e) {
78 throw new \Exception($e->getMessage());
79 }
80 }
81
82 public function about(array $params): void {
83 try {
84 $tmpl = new Template('/');
85 $pagetit = '新ページ';
86 $description = 'PHPフレームワークについて';
87
88 // ユーザー
89 $auth = new Auth();
90 $user = $auth->getLoggedInUser();
91 $tmpl->assign('user', $user);
92
93 $tmpl->assign('pagetit', $pagetit);
94 $tmpl->assign('curPage', 'about');
95 $tmpl->assign('custCss', false);
96 $tmpl->assign('menu', $this->getMenu());
97 $tmpl->assign('description', $description);
98
99 $tmpl->render('about');
100 } catch (\Exception $e) {
101 throw new \Exception($e->getMessage());
102 }
103 }
104
105 public function monero(array $params): void {
106 try {
107 $tmpl = new Template('/');
108 $pagetit = 'モネロ(XMR)で支援♡';
109 $description = 'テクニカル諏訪子ちゃんをモネロで支援♡';
110
111 // ユーザー
112 $auth = new Auth();
113 $user = $auth->getLoggedInUser();
114 $tmpl->assign('user', $user);
115
116 $tmpl->assign('pagetit', $pagetit);
117 $tmpl->assign('curPage', 'support');
118 $tmpl->assign('custCss', true);
119 $tmpl->assign('menu', $this->getMenu());
120 $tmpl->assign('description', $description);
121
122 $tmpl->addCss('code');
123 $tmpl->render('monero');
124 } catch (\Exception $e) {
125 throw new \Exception($e->getMessage());
126 }
127 }
128
129 public function secret(array $params): void {
130 try {
131 $tmpl = new Template('/');
132 $pagetit = '秘密のページ';
133 $description = 'ケロ';
134
135 // ユーザー
136 $auth = new Auth();
137 $user = $auth->getLoggedInUser();
138 $tmpl->assign('user', $user);
139
140 $tmpl->assign('pagetit', $pagetit);
141 $tmpl->assign('curPage', 'support');
142 $tmpl->assign('custCss', false);
143 $tmpl->assign('menu', $this->getMenu());
144 $tmpl->assign('description', $description);
145
146 $tmpl->render('secret');
147 } catch (\Exception $e) {
148 throw new \Exception($e->getMessage());
149 }
150 }
151
152 public function memberonly(array $params): void {
153 try {
154 $tmpl = new Template('/');
155 $pagetit = 'サインインしたユーザー限定';
156 $description = 'PHPフレームワークについて';
157
158 // ユーザー
159 $auth = new Auth();
160 $user = $auth->getLoggedInUser();
161
162 $tmpl->assign('user', $user);
163
164 $tmpl->assign('pagetit', $pagetit);
165 $tmpl->assign('curPage', 'memberonly');
166 $tmpl->assign('custCss', false);
167 $tmpl->assign('menu', $this->getMenu());
168 $tmpl->assign('description', $description);
169
170 if ($user && $user->role !== Roles::BANNED) $tmpl->render('memberonly');
171 else $tmpl->render('nopermission');
172 } catch (\Exception $e) {
173 throw new \Exception($e->getMessage());
174 }
175 }
176
177 public function staffonly(array $params): void {
178 try {
179 $tmpl = new Template('/');
180 $pagetit = 'スタッフ限定';
181 $description = 'PHPフレームワークについて';
182
183 // ユーザー
184 $auth = new Auth();
185 $user = $auth->getLoggedInUser();
186 $tmpl->assign('user', $user);
187
188 $tmpl->assign('pagetit', $pagetit);
189 $tmpl->assign('curPage', 'staffonly');
190 $tmpl->assign('custCss', false);
191 $tmpl->assign('menu', $this->getMenu());
192 $tmpl->assign('description', $description);
193
194 if ($user && $user->role & (Roles::ADMIN | Roles::STAFF)) $tmpl->render('staffonly');
195 else $tmpl->render('nopermission');
196 } catch (\Exception $e) {
197 throw new \Exception($e->getMessage());
198 }
199 }
200}