Browse Source

Add legals to Twig templates

biotorrents 4 years ago
parent
commit
52d4f4410f

+ 14
- 1
classes/env.class.php View File

@@ -29,7 +29,7 @@ class ENV
29 29
 
30 30
 
31 31
     /**
32
-     * __functions()
32
+     * __functions
33 33
      */
34 34
 
35 35
     # Prevents outside construction
@@ -49,6 +49,15 @@ class ENV
49 49
         );
50 50
     }
51 51
 
52
+    # Prevents unserializing
53
+    public function __wakeup()
54
+    {
55
+        return trigger_error(
56
+            'wakeup() not allowed',
57
+            E_USER_ERROR
58
+        );
59
+    }
60
+
52 61
     # $this->key returns public->key
53 62
     public function __get($key)
54 63
     {
@@ -263,6 +272,7 @@ class RecursiveArrayObject extends \ArrayObject
263 272
         return $this;
264 273
     }
265 274
 
275
+
266 276
     /**
267 277
      * __set
268 278
      */
@@ -275,6 +285,7 @@ class RecursiveArrayObject extends \ArrayObject
275 285
         }
276 286
     }
277 287
 
288
+
278 289
     /**
279 290
      * __get
280 291
      */
@@ -289,6 +300,7 @@ class RecursiveArrayObject extends \ArrayObject
289 300
         }
290 301
     }
291 302
 
303
+
292 304
     /**
293 305
      * __isset
294 306
      */
@@ -297,6 +309,7 @@ class RecursiveArrayObject extends \ArrayObject
297 309
         return array_key_exists($name, $this);
298 310
     }
299 311
 
312
+    
300 313
     /**
301 314
      * __unset
302 315
      */

+ 37
- 25
classes/twig.class.php View File

@@ -15,7 +15,7 @@ declare(strict_types=1);
15 15
 class Twig
16 16
 {
17 17
     /**
18
-     * Singleton stuff
18
+     * __functions
19 19
      */
20 20
 
21 21
     private static $Twig = null;
@@ -33,6 +33,18 @@ class Twig
33 33
         );
34 34
     }
35 35
 
36
+    public function __wakeup()
37
+    {
38
+        return trigger_error(
39
+            'wakeup() not allowed',
40
+            E_USER_ERROR
41
+        );
42
+    }
43
+
44
+
45
+    /**
46
+     * go
47
+     */
36 48
     public static function go()
37 49
     {
38 50
         return (self::$Twig === null)
@@ -48,7 +60,7 @@ class Twig
48 60
     private static function factory(): \Twig\Environment
49 61
     {
50 62
         $ENV = ENV::go();
51
-        $twig = new \Twig\Environment(
63
+        $Twig = new \Twig\Environment(
52 64
             new \Twig\Loader\FilesystemLoader("$ENV->SERVER_ROOT/templates"),
53 65
             [
54 66
                 'auto_reload' => true,
@@ -58,49 +70,49 @@ class Twig
58 70
         ]
59 71
         );
60 72
 
61
-        $twig->addFilter(new \Twig\TwigFilter(
73
+        $Twig->addFilter(new \Twig\TwigFilter(
62 74
             'article',
63 75
             function ($word) {
64 76
                 return preg_match('/^[aeiou]/i', $word) ? 'an' : 'a';
65 77
             }
66 78
         ));
67 79
 
68
-        $twig->addFilter(new \Twig\TwigFilter(
80
+        $Twig->addFilter(new \Twig\TwigFilter(
69 81
             'b64',
70 82
             function (string $binary) {
71 83
                 return base64_encode($binary);
72 84
             }
73 85
         ));
74 86
 
75
-        $twig->addFilter(new \Twig\TwigFilter(
87
+        $Twig->addFilter(new \Twig\TwigFilter(
76 88
             'bb_format',
77 89
             function ($text) {
78 90
                 return new \Twig\Markup(\Text::full_format($text), 'UTF-8');
79 91
             }
80 92
         ));
81 93
 
82
-        $twig->addFilter(new \Twig\TwigFilter(
94
+        $Twig->addFilter(new \Twig\TwigFilter(
83 95
             'checked',
84 96
             function ($isChecked) {
85 97
                 return $isChecked ? ' checked="checked"' : '';
86 98
             }
87 99
         ));
88 100
 
89
-        $twig->addFilter(new \Twig\TwigFilter(
101
+        $Twig->addFilter(new \Twig\TwigFilter(
90 102
             'image',
91 103
             function ($i) {
92 104
                 return new \Twig\Markup(\ImageTools::process($i, true), 'UTF-8');
93 105
             }
94 106
         ));
95 107
 
96
-        $twig->addFilter(new \Twig\TwigFilter(
108
+        $Twig->addFilter(new \Twig\TwigFilter(
97 109
             'ipaddr',
98 110
             function ($ipaddr) {
99 111
                 return new \Twig\Markup(\Tools::display_ip($ipaddr), 'UTF-8');
100 112
             }
101 113
         ));
102 114
 
103
-        $twig->addFilter(new \Twig\TwigFilter(
115
+        $Twig->addFilter(new \Twig\TwigFilter(
104 116
             'octet_size',
105 117
             function ($size, array $option = []) {
106 118
                 return \Format::get_size($size, empty($option) ? 2 : $option[0]);
@@ -108,42 +120,42 @@ class Twig
108 120
             ['is_variadic' => true]
109 121
         ));
110 122
 
111
-        $twig->addFilter(new \Twig\TwigFilter(
123
+        $Twig->addFilter(new \Twig\TwigFilter(
112 124
             'plural',
113 125
             function ($number) {
114 126
                 return plural($number);
115 127
             }
116 128
         ));
117 129
 
118
-        $twig->addFilter(new \Twig\TwigFilter(
130
+        $Twig->addFilter(new \Twig\TwigFilter(
119 131
             'selected',
120 132
             function ($isSelected) {
121 133
                 return $isSelected ? ' selected="selected"' : '';
122 134
             }
123 135
         ));
124 136
 
125
-        $twig->addFilter(new \Twig\TwigFilter(
137
+        $Twig->addFilter(new \Twig\TwigFilter(
126 138
             'shorten',
127 139
             function (string $text, int $length) {
128 140
                 return shortenString($text, $length);
129 141
             }
130 142
         ));
131 143
 
132
-        $twig->addFilter(new \Twig\TwigFilter(
144
+        $Twig->addFilter(new \Twig\TwigFilter(
133 145
             'time_diff',
134 146
             function ($time) {
135 147
                 return new \Twig\Markup(time_diff($time), 'UTF-8');
136 148
             }
137 149
         ));
138 150
 
139
-        $twig->addFilter(new \Twig\TwigFilter(
151
+        $Twig->addFilter(new \Twig\TwigFilter(
140 152
             'ucfirst',
141 153
             function ($text) {
142 154
                 return ucfirst($text);
143 155
             }
144 156
         ));
145 157
 
146
-        $twig->addFilter(new \Twig\TwigFilter(
158
+        $Twig->addFilter(new \Twig\TwigFilter(
147 159
             'ucfirstall',
148 160
             function ($text) {
149 161
                 return implode(' ', array_map(function ($w) {
@@ -152,28 +164,28 @@ class Twig
152 164
             }
153 165
         ));
154 166
 
155
-        $twig->addFilter(new \Twig\TwigFilter(
167
+        $Twig->addFilter(new \Twig\TwigFilter(
156 168
             'user_url',
157 169
             function ($userId) {
158 170
                 return new \Twig\Markup(\Users::format_username($userId, false, false, false), 'UTF-8');
159 171
             }
160 172
         ));
161 173
 
162
-        $twig->addFilter(new \Twig\TwigFilter(
174
+        $Twig->addFilter(new \Twig\TwigFilter(
163 175
             'user_full',
164 176
             function ($userId) {
165 177
                 return new \Twig\Markup(\Users::format_username($userId, true, true, true, true), 'UTF-8');
166 178
             }
167 179
         ));
168 180
 
169
-        $twig->addFunction(new \Twig\TwigFunction('donor_icon', function ($icon, $userId) {
181
+        $Twig->addFunction(new \Twig\TwigFunction('donor_icon', function ($icon, $userId) {
170 182
             return new \Twig\Markup(
171 183
                 \ImageTools::process($icon, false, 'donoricon', $userId),
172 184
                 'UTF-8'
173 185
             );
174 186
         }));
175 187
 
176
-        $twig->addFunction(new \Twig\TwigFunction('privilege', function ($default, $config, $key) {
188
+        $Twig->addFunction(new \Twig\TwigFunction('privilege', function ($default, $config, $key) {
177 189
             return new \Twig\Markup(
178 190
                 (
179 191
                     $default
@@ -197,14 +209,14 @@ class Twig
197 209
             );
198 210
         }));
199 211
 
200
-        $twig->addFunction(new \Twig\TwigFunction('ratio', function ($up, $down) {
212
+        $Twig->addFunction(new \Twig\TwigFunction('ratio', function ($up, $down) {
201 213
             return new \Twig\Markup(
202 214
                 \Format::get_ratio_html($up, $down),
203 215
                 'UTF-8'
204 216
             );
205 217
         }));
206 218
 
207
-        $twig->addFunction(new \Twig\TwigFunction('resolveCountryIpv4', function ($addr) {
219
+        $Twig->addFunction(new \Twig\TwigFunction('resolveCountryIpv4', function ($addr) {
208 220
             return new \Twig\Markup(
209 221
                 (function ($ip) {
210 222
                     static $cache = [];
@@ -225,7 +237,7 @@ class Twig
225 237
             );
226 238
         }));
227 239
 
228
-        $twig->addFunction(new \Twig\TwigFunction('resolveIpv4', function ($addr) {
240
+        $Twig->addFunction(new \Twig\TwigFunction('resolveIpv4', function ($addr) {
229 241
             return new \Twig\Markup(
230 242
                 (function ($ip) {
231 243
                     if (!$ip) {
@@ -244,19 +256,19 @@ class Twig
244 256
             );
245 257
         }));
246 258
 
247
-        $twig->addFunction(new \Twig\TwigFunction('shorten', function ($text, $length) {
259
+        $Twig->addFunction(new \Twig\TwigFunction('shorten', function ($text, $length) {
248 260
             return new \Twig\Markup(
249 261
                 shortenString($text, $length),
250 262
                 'UTF-8'
251 263
             );
252 264
         }));
253 265
 
254
-        $twig->addTest(
266
+        $Twig->addTest(
255 267
             new \Twig\TwigTest('numeric', function ($value) {
256 268
                 return is_numeric($value);
257 269
             })
258 270
         );
259 271
 
260
-        return $twig;
272
+        return $Twig;
261 273
     }
262 274
 }

+ 9
- 2
sections/legal/index.php View File

@@ -1,18 +1,25 @@
1 1
 <?php
2 2
 declare(strict_types=1);
3 3
 
4
+$Twig = Twig::go();
4 5
 $p = $_GET['p'];
5 6
 
6 7
 switch ($p) {
7 8
     case 'privacy':
8
-        require_once 'privacy.php';
9
+        View::show_header('Privacy');
10
+        echo $Twig->render('legal/privacy.html');
11
+        View::show_footer();
9 12
         break;
10 13
     
11 14
     case 'dmca':
12
-        require_once 'dmca.php';
15
+        View::show_header('DMCA');
16
+        echo $Twig->render('legal/dmca.html');
17
+        View::show_footer();
13 18
         break;
14 19
     
15 20
     default:
21
+        View::show_header('404 Not Found');
16 22
         error(404);
23
+        View::show_footer();
17 24
         break;
18 25
 }

+ 1
- 1
sections/tools/data/registration_log.php View File

@@ -53,7 +53,7 @@ $RS = "
53 53
     im.Enabled,
54 54
     ii.Donor,
55 55
     ii.Warned,
56
-    ii.JoinDate,
56
+    ii.JoinDate
57 57
   FROM users_main AS m
58 58
     LEFT JOIN users_info AS i ON i.UserID = m.ID
59 59
     LEFT JOIN users_main AS im ON i.Inviter = im.ID

sections/legal/dmca.php → templates/legal/dmca.html View File

@@ -1,8 +1,3 @@
1
-<?php
2
-declare(strict_types=1);
3
-
4
-View::show_header('DMCA'); ?>
5
-
6 1
 <h2>DMCA Information</h2>
7 2
 
8 3
 <section class="tldr">
@@ -37,7 +32,6 @@ View::show_header('DMCA'); ?>
37 32
       that you're authorized to act on behalf of an allegedly infringed exclusive right.
38 33
     </li>
39 34
 
40
-
41 35
     <li>
42 36
       Your physical or electronic signature, or of someone authorized to act on your behalf.
43 37
     </li>
@@ -53,45 +47,6 @@ View::show_header('DMCA'); ?>
53 47
     Omics Tools LLC reserves the right to ignore requests for unregistered works.
54 48
   </p>
55 49
 
56
-  <?php
57
-  /*
58
-  <p>
59
-    Circumstances that may delay processing, including not limited:
60
-  </p>
61
-
62
-  <ul class="p">
63
-    <li>
64
-      URI formulations that violate BioTorrents.de's normal access rules,
65
-      e.g., unsecured HTTP, <em>or</em> requests that fail to identify specific pieces of UGC.
66
-    </li>
67
-
68
-    <li>
69
-      Generic or boilerplate statements.
70
-      Neither statement should contain passages with quoted online search results.
71
-    </li>
72
-
73
-    <li>
74
-      Requests signed by other means than Ed25519 or RSA 4096,
75
-      or encoded in other formats than UTF-8 or ASCII.
76
-    </li>
77
-
78
-    <li>
79
-      PO boxes, addresses outside the U.S., or addresses that can't accept USPS Certified Mail.
80
-      VoIP telephone numbers or numbers without a <code>+1</code> country code.
81
-    </li>
82
-
83
-    <li>
84
-      Email servers that don't comply with at least two of:
85
-      <a href="https://tools.ietf.org/html/rfc7208">RFC 7208 (SPF)</a>,
86
-      <a href="https://tools.ietf.org/html/rfc8463">RFC 8463 (DKIM)</a>, and
87
-      <a href="https://tools.ietf.org/html/rfc7489">RFC 7489 (DMARC)</a>.
88
-      Requests from free mailboxes such as Gmail, ProtonMail, etc.
89
-      Any email that violates
90
-      <a href="https://www.law.cornell.edu/uscode/text/15/7704">15 USC 7704(a)</a>.
91
-    </li>
92
-  </ul>
93
-  */ ?>
94
-
95 50
   <p>
96 51
     We'll expeditiously disable access to the targets of valid requests.
97 52
     Our agent to receive notifications of claimed infringement is:
@@ -132,5 +87,3 @@ View::show_header('DMCA'); ?>
132 87
     if you wish.
133 88
   </p>
134 89
 </section>
135
-
136
-<?php View::show_footer();

sections/legal/privacy.php → templates/legal/privacy.html View File

@@ -1,8 +1,3 @@
1
-<?php
2
-declare(strict_types=1);
3
-
4
-View::show_header('Privacy'); ?>
5
-
6 1
 <h2>Privacy Policy</h2>
7 2
 
8 3
 <section class="tldr">
@@ -97,6 +92,7 @@ View::show_header('Privacy'); ?>
97 92
   </p>
98 93
 
99 94
   <p>
95
+    We don't store IP address, geolocation, passphrase, or passkey history.
100 96
     Note that we may need to keep data for archiving purposes.
101 97
   </p>
102 98
 
@@ -192,7 +188,7 @@ View::show_header('Privacy'); ?>
192 188
   </h3>
193 189
 
194 190
   <p>
195
-    We last updated this policy on 2021-02-13.
191
+    We last updated this policy on 2021-07-14.
196 192
   </p>
197 193
 
198 194
 
@@ -233,5 +229,3 @@ View::show_header('Privacy'); ?>
233 229
     if you wish.
234 230
   </p>
235 231
 </section>
236
-
237
-<?php View::show_footer();

+ 1
- 1
templates/torrent_form/version.html View File

@@ -14,6 +14,6 @@
14 14
       value="{{ version }}"
15 15
     />
16 16
 
17
-    <p>{{ note }}}}</p>
17
+    <p>{{ note }}</p>
18 18
   </td>
19 19
 </tr>

+ 0
- 10
templates/upload/result_warnings.twig View File

@@ -1,10 +0,0 @@
1
-<h1>Warning</h1>
2
-<p><strong>Your torrent has been uploaded; however, you must download your torrent from <a href="torrents.php?id={{ group_id }}">here</a> because:</strong></p>
3
-<ul>
4
-{% if public %}
5
-    <li><strong>You didn't make your torrent using the "private" option</strong></li>
6
-{% endif %}
7
-{% if unsourced %}
8
-    <li><strong>The "source" flag was not set to OPS. Please read the <a href="/wiki.php?action=article&id={{ source_flag_wiki_id }}">wiki page about source flags</a> to find out why this is important. </strong></li>
9
-{% endif %}
10
-</ul>

Loading…
Cancel
Save