Browse Source

Add legals to Twig templates

biotorrents 4 years ago
parent
commit
52d4f4410f

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

29
 
29
 
30
 
30
 
31
     /**
31
     /**
32
-     * __functions()
32
+     * __functions
33
      */
33
      */
34
 
34
 
35
     # Prevents outside construction
35
     # Prevents outside construction
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
     # $this->key returns public->key
61
     # $this->key returns public->key
53
     public function __get($key)
62
     public function __get($key)
54
     {
63
     {
263
         return $this;
272
         return $this;
264
     }
273
     }
265
 
274
 
275
+
266
     /**
276
     /**
267
      * __set
277
      * __set
268
      */
278
      */
275
         }
285
         }
276
     }
286
     }
277
 
287
 
288
+
278
     /**
289
     /**
279
      * __get
290
      * __get
280
      */
291
      */
289
         }
300
         }
290
     }
301
     }
291
 
302
 
303
+
292
     /**
304
     /**
293
      * __isset
305
      * __isset
294
      */
306
      */
297
         return array_key_exists($name, $this);
309
         return array_key_exists($name, $this);
298
     }
310
     }
299
 
311
 
312
+    
300
     /**
313
     /**
301
      * __unset
314
      * __unset
302
      */
315
      */

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

15
 class Twig
15
 class Twig
16
 {
16
 {
17
     /**
17
     /**
18
-     * Singleton stuff
18
+     * __functions
19
      */
19
      */
20
 
20
 
21
     private static $Twig = null;
21
     private static $Twig = null;
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
     public static function go()
48
     public static function go()
37
     {
49
     {
38
         return (self::$Twig === null)
50
         return (self::$Twig === null)
48
     private static function factory(): \Twig\Environment
60
     private static function factory(): \Twig\Environment
49
     {
61
     {
50
         $ENV = ENV::go();
62
         $ENV = ENV::go();
51
-        $twig = new \Twig\Environment(
63
+        $Twig = new \Twig\Environment(
52
             new \Twig\Loader\FilesystemLoader("$ENV->SERVER_ROOT/templates"),
64
             new \Twig\Loader\FilesystemLoader("$ENV->SERVER_ROOT/templates"),
53
             [
65
             [
54
                 'auto_reload' => true,
66
                 'auto_reload' => true,
58
         ]
70
         ]
59
         );
71
         );
60
 
72
 
61
-        $twig->addFilter(new \Twig\TwigFilter(
73
+        $Twig->addFilter(new \Twig\TwigFilter(
62
             'article',
74
             'article',
63
             function ($word) {
75
             function ($word) {
64
                 return preg_match('/^[aeiou]/i', $word) ? 'an' : 'a';
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
             'b64',
81
             'b64',
70
             function (string $binary) {
82
             function (string $binary) {
71
                 return base64_encode($binary);
83
                 return base64_encode($binary);
72
             }
84
             }
73
         ));
85
         ));
74
 
86
 
75
-        $twig->addFilter(new \Twig\TwigFilter(
87
+        $Twig->addFilter(new \Twig\TwigFilter(
76
             'bb_format',
88
             'bb_format',
77
             function ($text) {
89
             function ($text) {
78
                 return new \Twig\Markup(\Text::full_format($text), 'UTF-8');
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
             'checked',
95
             'checked',
84
             function ($isChecked) {
96
             function ($isChecked) {
85
                 return $isChecked ? ' checked="checked"' : '';
97
                 return $isChecked ? ' checked="checked"' : '';
86
             }
98
             }
87
         ));
99
         ));
88
 
100
 
89
-        $twig->addFilter(new \Twig\TwigFilter(
101
+        $Twig->addFilter(new \Twig\TwigFilter(
90
             'image',
102
             'image',
91
             function ($i) {
103
             function ($i) {
92
                 return new \Twig\Markup(\ImageTools::process($i, true), 'UTF-8');
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
             'ipaddr',
109
             'ipaddr',
98
             function ($ipaddr) {
110
             function ($ipaddr) {
99
                 return new \Twig\Markup(\Tools::display_ip($ipaddr), 'UTF-8');
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
             'octet_size',
116
             'octet_size',
105
             function ($size, array $option = []) {
117
             function ($size, array $option = []) {
106
                 return \Format::get_size($size, empty($option) ? 2 : $option[0]);
118
                 return \Format::get_size($size, empty($option) ? 2 : $option[0]);
108
             ['is_variadic' => true]
120
             ['is_variadic' => true]
109
         ));
121
         ));
110
 
122
 
111
-        $twig->addFilter(new \Twig\TwigFilter(
123
+        $Twig->addFilter(new \Twig\TwigFilter(
112
             'plural',
124
             'plural',
113
             function ($number) {
125
             function ($number) {
114
                 return plural($number);
126
                 return plural($number);
115
             }
127
             }
116
         ));
128
         ));
117
 
129
 
118
-        $twig->addFilter(new \Twig\TwigFilter(
130
+        $Twig->addFilter(new \Twig\TwigFilter(
119
             'selected',
131
             'selected',
120
             function ($isSelected) {
132
             function ($isSelected) {
121
                 return $isSelected ? ' selected="selected"' : '';
133
                 return $isSelected ? ' selected="selected"' : '';
122
             }
134
             }
123
         ));
135
         ));
124
 
136
 
125
-        $twig->addFilter(new \Twig\TwigFilter(
137
+        $Twig->addFilter(new \Twig\TwigFilter(
126
             'shorten',
138
             'shorten',
127
             function (string $text, int $length) {
139
             function (string $text, int $length) {
128
                 return shortenString($text, $length);
140
                 return shortenString($text, $length);
129
             }
141
             }
130
         ));
142
         ));
131
 
143
 
132
-        $twig->addFilter(new \Twig\TwigFilter(
144
+        $Twig->addFilter(new \Twig\TwigFilter(
133
             'time_diff',
145
             'time_diff',
134
             function ($time) {
146
             function ($time) {
135
                 return new \Twig\Markup(time_diff($time), 'UTF-8');
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
             'ucfirst',
152
             'ucfirst',
141
             function ($text) {
153
             function ($text) {
142
                 return ucfirst($text);
154
                 return ucfirst($text);
143
             }
155
             }
144
         ));
156
         ));
145
 
157
 
146
-        $twig->addFilter(new \Twig\TwigFilter(
158
+        $Twig->addFilter(new \Twig\TwigFilter(
147
             'ucfirstall',
159
             'ucfirstall',
148
             function ($text) {
160
             function ($text) {
149
                 return implode(' ', array_map(function ($w) {
161
                 return implode(' ', array_map(function ($w) {
152
             }
164
             }
153
         ));
165
         ));
154
 
166
 
155
-        $twig->addFilter(new \Twig\TwigFilter(
167
+        $Twig->addFilter(new \Twig\TwigFilter(
156
             'user_url',
168
             'user_url',
157
             function ($userId) {
169
             function ($userId) {
158
                 return new \Twig\Markup(\Users::format_username($userId, false, false, false), 'UTF-8');
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
             'user_full',
175
             'user_full',
164
             function ($userId) {
176
             function ($userId) {
165
                 return new \Twig\Markup(\Users::format_username($userId, true, true, true, true), 'UTF-8');
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
             return new \Twig\Markup(
182
             return new \Twig\Markup(
171
                 \ImageTools::process($icon, false, 'donoricon', $userId),
183
                 \ImageTools::process($icon, false, 'donoricon', $userId),
172
                 'UTF-8'
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
             return new \Twig\Markup(
189
             return new \Twig\Markup(
178
                 (
190
                 (
179
                     $default
191
                     $default
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
             return new \Twig\Markup(
213
             return new \Twig\Markup(
202
                 \Format::get_ratio_html($up, $down),
214
                 \Format::get_ratio_html($up, $down),
203
                 'UTF-8'
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
             return new \Twig\Markup(
220
             return new \Twig\Markup(
209
                 (function ($ip) {
221
                 (function ($ip) {
210
                     static $cache = [];
222
                     static $cache = [];
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
             return new \Twig\Markup(
241
             return new \Twig\Markup(
230
                 (function ($ip) {
242
                 (function ($ip) {
231
                     if (!$ip) {
243
                     if (!$ip) {
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
             return new \Twig\Markup(
260
             return new \Twig\Markup(
249
                 shortenString($text, $length),
261
                 shortenString($text, $length),
250
                 'UTF-8'
262
                 'UTF-8'
251
             );
263
             );
252
         }));
264
         }));
253
 
265
 
254
-        $twig->addTest(
266
+        $Twig->addTest(
255
             new \Twig\TwigTest('numeric', function ($value) {
267
             new \Twig\TwigTest('numeric', function ($value) {
256
                 return is_numeric($value);
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
 <?php
1
 <?php
2
 declare(strict_types=1);
2
 declare(strict_types=1);
3
 
3
 
4
+$Twig = Twig::go();
4
 $p = $_GET['p'];
5
 $p = $_GET['p'];
5
 
6
 
6
 switch ($p) {
7
 switch ($p) {
7
     case 'privacy':
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
         break;
12
         break;
10
     
13
     
11
     case 'dmca':
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
         break;
18
         break;
14
     
19
     
15
     default:
20
     default:
21
+        View::show_header('404 Not Found');
16
         error(404);
22
         error(404);
23
+        View::show_footer();
17
         break;
24
         break;
18
 }
25
 }

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

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

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

1
-<?php
2
-declare(strict_types=1);
3
-
4
-View::show_header('DMCA'); ?>
5
-
6
 <h2>DMCA Information</h2>
1
 <h2>DMCA Information</h2>
7
 
2
 
8
 <section class="tldr">
3
 <section class="tldr">
37
       that you're authorized to act on behalf of an allegedly infringed exclusive right.
32
       that you're authorized to act on behalf of an allegedly infringed exclusive right.
38
     </li>
33
     </li>
39
 
34
 
40
-
41
     <li>
35
     <li>
42
       Your physical or electronic signature, or of someone authorized to act on your behalf.
36
       Your physical or electronic signature, or of someone authorized to act on your behalf.
43
     </li>
37
     </li>
53
     Omics Tools LLC reserves the right to ignore requests for unregistered works.
47
     Omics Tools LLC reserves the right to ignore requests for unregistered works.
54
   </p>
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
   <p>
50
   <p>
96
     We'll expeditiously disable access to the targets of valid requests.
51
     We'll expeditiously disable access to the targets of valid requests.
97
     Our agent to receive notifications of claimed infringement is:
52
     Our agent to receive notifications of claimed infringement is:
132
     if you wish.
87
     if you wish.
133
   </p>
88
   </p>
134
 </section>
89
 </section>
135
-
136
-<?php View::show_footer();

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

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

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

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

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

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