Browse Source

Login form autocomplete and some validation work

pjc 5 years ago
parent
commit
a161f636b5

+ 6
- 6
_packages/extension-parser/classes/config.php View File

@@ -74,11 +74,11 @@ $ContainersProt = [
74 74
 ];
75 75
 
76 76
 $Archives = [
77
-  '7z' => ['7z'],
78
-  'bzip2' => ['bz2', 'bzip2'],
79
-  'gzip' => ['gz', 'gzip', 'tgz', 'tpz'],
77
+  '7z'     => ['7z'],
78
+  'bzip2'  => ['bz2', 'bzip2'],
79
+  'gzip'   => ['gz', 'gzip', 'tgz', 'tpz'],
80 80
   'Pickle' => ['pickle', 'pkl'],
81
-  'RAR' => ['rar', 'rev'],
82
-  'ZIP' => ['zip', 'zipx'],
83
-  'None' => [''],
81
+  'RAR'    => ['rar', 'rev'],
82
+  'ZIP'    => ['zip', 'zipx'],
83
+  'None'   => [''],
84 84
 ];

+ 8
- 0
_packages/formatting-bugs/readme.md View File

@@ -0,0 +1,8 @@
1
+A function should run the same no matter how it's (legally) formatted.
2
+Having arbitrary whitespace break things, and using lax equality checks, are bugs.
3
+PHP is notorious for code that relies on edge cases in its abysmal concepts of things being "equal."
4
+
5
+This repo contains file paths and snippets that indicate broken code when run through PHP CS Fixer or converted to strict equality.
6
+According to Visual Studio Code with
7
+(only this PHP CS Fixer extension installed)[https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer]
8
+and set to run without arguments.

+ 11
- 0
_packages/formatting-bugs/sections/torrents/details.php View File

@@ -0,0 +1,11 @@
1
+<div class="spoilerContainer hideContainer">
2
+    <!--
3
+    This must be one line or the "Show/Hide MediaInfo" button fails
4
+    PHP CS Fixer breaks lines between the tags
5
+    -->
6
+    <input type="button" class="spoilerButton" value="Show MediaInfo" /><blockquote class="spoiler hidden">
7
+<?php
8
+        echo Text::full_format($MediaInfo);
9
+?>
10
+    </blockquote>
11
+  </div>

+ 1
- 0
classes/torrent_form.class.php View File

@@ -448,6 +448,7 @@ class TorrentForm
448 448
     </td>
449 449
     <td>
450 450
       <select name="media">
451
+      <option value="">---</option>
451 452
         <?php
452 453
           foreach ($this->Media as $Media) {
453 454
               echo "\t\t\t\t\t\t<option value=\"$Media\"";

+ 236
- 120
classes/validate.class.php View File

@@ -63,7 +63,6 @@ class Validate
63 63
                     } elseif (strlen($ValidateVar) < $MinLength) {
64 64
                         return $Field['ErrorMessage'];
65 65
                     }
66
-
67 66
                 } elseif ($Field['Type'] === 'number') {
68 67
                     if (isset($Field['MaxLength'])) {
69 68
                         $MaxLength = $Field['MaxLength'];
@@ -91,7 +90,6 @@ class Validate
91 90
                     } elseif ($ValidateVar < $MinLength) {
92 91
                         return $Field['ErrorMessage']."$MinLength";
93 92
                     }
94
-
95 93
                 } elseif ($Field['Type'] === 'email') {
96 94
                     if (isset($Field['MaxLength'])) {
97 95
                         $MaxLength = $Field['MaxLength'];
@@ -111,7 +109,6 @@ class Validate
111 109
                     } elseif (strlen($ValidateVar) < $MinLength) {
112 110
                         return $Field['ErrorMessage'];
113 111
                     }
114
-
115 112
                 } elseif ($Field['Type'] === 'link') {
116 113
                     if (isset($Field['MaxLength'])) {
117 114
                         $MaxLength = $Field['MaxLength'];
@@ -131,7 +128,6 @@ class Validate
131 128
                     } elseif (strlen($ValidateVar) < $MinLength) {
132 129
                         return $Field['ErrorMessage'];
133 130
                     }
134
-
135 131
                 } elseif ($Field['Type'] === 'username') {
136 132
                     if (isset($Field['MaxLength'])) {
137 133
                         $MaxLength = $Field['MaxLength'];
@@ -151,22 +147,18 @@ class Validate
151 147
                     } elseif (strlen($ValidateVar) < $MinLength) {
152 148
                         return $Field['ErrorMessage'];
153 149
                     }
154
-
155 150
                 } elseif ($Field['Type'] === 'checkbox') {
156 151
                     if (!isset($ValidateArray[$FieldKey])) {
157 152
                         return $Field['ErrorMessage'];
158 153
                     }
159
-
160 154
                 } elseif ($Field['Type'] === 'compare') {
161 155
                     if ($ValidateArray[$Field['CompareField']] !== $ValidateVar) {
162 156
                         return $Field['ErrorMessage'];
163 157
                     }
164
-
165 158
                 } elseif ($Field['Type'] === 'inarray') {
166 159
                     if (array_search($ValidateVar, $Field['InArray']) === false) {
167 160
                         return $Field['ErrorMessage'];
168 161
                     }
169
-
170 162
                 } elseif ($Field['Type'] === 'regex') {
171 163
                     if (!preg_match($Field['Regex'], $ValidateVar)) {
172 164
                         return $Field['ErrorMessage'];
@@ -176,121 +168,245 @@ class Validate
176 168
         } // while
177 169
     } // function
178 170
 
179
-  public function GenerateJS($FormID)
180
-  {
181
-      /*
182
-      $ReturnJS = "<script type=\"text/javascript\" language=\"javascript\">\r\n";
183
-      $ReturnJS .= "function formVal() {\r\n";
184
-      $ReturnJS .= "  clearErrors('$FormID');\r\n";
171
+    /**
172
+     * Extension Parser
173
+     *
174
+     * Takes an associative array of file types and extension, e.g.,
175
+     * $Archives = [
176
+     *   '7z'     => ['7z'],
177
+     *   'bzip2'  => ['bz2', 'bzip2'],
178
+     *   'gzip'   => ['gz', 'gzip', 'tgz', 'tpz'],
179
+     *   ...
180
+     * ];
181
+     *
182
+     * Then it finds all the extensions in a torrent file list,
183
+     * organizes them by file size, and returns the "heaviest" match.
184
+     *
185
+     * That way, you can have, e.g., 5 GiB FASTQ sequence data in one file,
186
+     * and 100 other small files, and get the format of the actual data.
187
+     *
188
+     * todo: Incorporate into the main function (remove if statements first)
189
+     * todo: Make this work with a more robust object than $Tor->file_list()
190
+     */
191
+    public function ParseExtensions($FileList, $FileTypes)
192
+    {
193
+        # Make $Tor->file_list() output manageable
194
+        $UnNested = array_values($FileList[1]);
195
+        /*
196
+        $Sorted = usort($UnNested, function ($a, $b) {
197
+            return $b[0] <=> $a[0];
198
+        });
199
+        */
200
+        $TopTen = array_slice($UnNested, 0, 10); # Good
201
+        $Result = [];
202
+
203
+        print_r('<pre>');
204
+        var_dump($TopTen);
205
+        print_r('</pre>');
206
+
207
+
208
+        foreach ($TopTen as $TopTen) {
209
+            $Extensions = explode('.', strtolower($TopTen[1]));
210
+            $Result = array_filter($Extensions, function ($a) {
211
+                foreach ($FileTypes as $FileType) {
212
+                    in_array($a, $FileType);
213
+                }
214
+            });
215
+            /*
216
+            foreach ($FileTypes as $Key => $FileTypes) {
217
+                print_r('<pre>');
218
+
219
+            var_dump($UnNested);
220
+            var_dump( $FileTypes[$Key]);
221
+            print_r('</pre>');
222
+
223
+        }
224
+        */
225
+        }
226
+        /*
227
+        foreach ($TopTen as $TopTen) {
228
+            $Extensions = explode('.', strtolower($TopTen[1]));
229
+            #foreach ($FileTypes as $Key => $FileTypes) {
230
+                print_r('<pre>');
231
+                #$Result = (in_array($Extensions, $FileTypes)) ? $FileTypes[$Key] : false;
232
+                var_dump($Extensions);
233
+                var_dump(array_intersect($Extensions, $FileTypes));
234
+                print_r('</pre>');
235
+
236
+            #}
237
+            print_r('<pre>');
238
+            //var_dump(array_intersect($Extensions, $FileTypes));
239
+            //var_dump($Extensions);
240
+            print_r('</pre>');
241
+
242
+        }
243
+        */
244
+        print_r('<pre>');
245
+        #var_dump(array_intersect($UnNested, $FileTypes));
246
+        #print_r($Sorted);
247
+        print_r($Result);
248
+        print_r('</pre>');
249
+ 
250
+        /*
251
+        while ($Result === false) {
252
+           foreach ($UnNested as $Key => $UnNested) {
253
+               $Exploded = explode('.', strtolower($UnNested[1]));
254
+               foreach ($Needles as $Key => $Needle) {
255
+                   $ID = array_search($Exploded, $Needle);
256
+                   var_dump($Needle[$ID]);
257
+               }
258
+               $dump = array_filter($Exploded, function($s){
259
+                   foreach ($Needles as $Type => $Extension) {
260
+                       return array_search($s, $Extension);
261
+                   }
262
+               });
263
+               #var_dump($dump);
264
+               /*
265
+               if (array_search($Needle, $Exploded, true)) {
266
+                   $Result = $Needles;
267
+               #break;
268
+               }
269
+           }
270
+
271
+         }
272
+        */
273
+#var_dump($Result);
274
+        /*
275
+#do {
276
+    foreach ($UnNested as $UnNested) {
277
+        $Exploded = explode('.', strtolower($UnNested[1]));
278
+            #var_dump(in_array(vals($names), $Explode));
279
+
280
+        }
281
+/*
282
+        if (array_intersect($names, $Exploded)) {
283
+            $result = array_search($Exploded, $names);
284
+
285
+        }
286
+        *
287
+    }
288
+#} while ($result !== false);
289
+print_r($result);
290
+
291
+
292
+*/
293
+    }
185 294
 
186
-      reset($this->Fields);
187
-      foreach ($this->Fields as $FieldKey => $Field) {
188
-          if ($Field['Type'] === 'string') {
189
-              $ValItem = '  if ($(\'#'.$FieldKey.'\').raw().value === ""';
190
-              if (!empty($Field['MaxLength'])) {
191
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
192
-              } else {
193
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > 255';
194
-              }
195
-              if (!empty($Field['MinLength'])) {
196
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
197
-              }
198
-              $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
199
-          } elseif ($Field['Type'] === 'number') {
200
-              $Match = '0-9';
201
-              if (!empty($Field['AllowPeriod'])) {
202
-                  $Match .= '.';
203
-              }
204
-              if (!empty($Field['AllowComma'])) {
205
-                  $Match .= ',';
206
-              }
295
+    public function GenerateJS($FormID)
296
+    {
297
+        /*
298
+        $ReturnJS = "<script type=\"text/javascript\" language=\"javascript\">\r\n";
299
+        $ReturnJS .= "function formVal() {\r\n";
300
+        $ReturnJS .= "  clearErrors('$FormID');\r\n";
207 301
 
208
-              $ValItem = '  if ($(\'#'.$FieldKey.'\').raw().value.match(/[^'.$Match.']/) || $(\'#'.$FieldKey.'\').raw().value.length < 1';
209
-              if (!empty($Field['MaxLength'])) {
210
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value/1 > '.$Field['MaxLength'];
211
-              }
212
-              if (!empty($Field['MinLength'])) {
213
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value/1 < '.$Field['MinLength'];
214
-              }
215
-              $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
216
-          } elseif ($Field['Type'] === 'email') {
217
-              $ValItem = '  if (!validEmail($(\'#'.$FieldKey.'\').raw().value)';
218
-              if (!empty($Field['MaxLength'])) {
219
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
220
-              } else {
221
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > 255';
222
-              }
223
-              if (!empty($Field['MinLength'])) {
224
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
225
-              } else {
226
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < 6';
227
-              }
228
-              $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
229
-          } elseif ($Field['Type'] === 'link') {
230
-              $ValItem = '  if (!validLink($(\'#'.$FieldKey.'\').raw().value)';
231
-              if (!empty($Field['MaxLength'])) {
232
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
233
-              } else {
234
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > 255';
235
-              }
236
-              if (!empty($Field['MinLength'])) {
237
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
238
-              } else {
239
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < 10';
240
-              }
241
-              $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
242
-          } elseif ($Field['Type'] === 'username') {
243
-              $ValItem = '  if ($(\'#'.$FieldKey.'\').raw().value.match(/[^a-zA-Z0-9_\-]/)';
244
-              if (!empty($Field['MaxLength'])) {
245
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
246
-              }
247
-              if (!empty($Field['MinLength'])) {
248
-                  $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
249
-              }
250
-              $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
251
-          } elseif ($Field['Type'] === 'regex') {
252
-              $ValItem = '  if (!$(\'#'.$FieldKey.'\').raw().value.match('.$Field['Regex'].')) { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
253
-          } elseif ($Field['Type'] === 'date') {
254
-              $DisplayError = $FieldKey.'month';
255
-              if (isset($Field['MinLength']) && $Field['MinLength'] === 3) {
256
-                  $Day = '$(\'#'.$FieldKey.'day\').raw().value';
257
-                  $DisplayError .= ",{$FieldKey}day";
258
-              } else {
259
-                  $Day = '1';
260
-              }
261
-              $DisplayError .= ",{$FieldKey}year";
262
-              $ValItemHold = '  if (!validDate($(\'#'.$FieldKey.'month\').raw().value+\'/\'+'.$Day.'+\'/\'+$(\'#'.$FieldKey.'year\').raw().value)) { return showError(\''.$DisplayError.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
302
+        reset($this->Fields);
303
+        foreach ($this->Fields as $FieldKey => $Field) {
304
+            if ($Field['Type'] === 'string') {
305
+                $ValItem = '  if ($(\'#'.$FieldKey.'\').raw().value === ""';
306
+                if (!empty($Field['MaxLength'])) {
307
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
308
+                } else {
309
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > 255';
310
+                }
311
+                if (!empty($Field['MinLength'])) {
312
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
313
+                }
314
+                $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
315
+            } elseif ($Field['Type'] === 'number') {
316
+                $Match = '0-9';
317
+                if (!empty($Field['AllowPeriod'])) {
318
+                    $Match .= '.';
319
+                }
320
+                if (!empty($Field['AllowComma'])) {
321
+                    $Match .= ',';
322
+                }
323
+
324
+                $ValItem = '  if ($(\'#'.$FieldKey.'\').raw().value.match(/[^'.$Match.']/) || $(\'#'.$FieldKey.'\').raw().value.length < 1';
325
+                if (!empty($Field['MaxLength'])) {
326
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value/1 > '.$Field['MaxLength'];
327
+                }
328
+                if (!empty($Field['MinLength'])) {
329
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value/1 < '.$Field['MinLength'];
330
+                }
331
+                $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
332
+            } elseif ($Field['Type'] === 'email') {
333
+                $ValItem = '  if (!validEmail($(\'#'.$FieldKey.'\').raw().value)';
334
+                if (!empty($Field['MaxLength'])) {
335
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
336
+                } else {
337
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > 255';
338
+                }
339
+                if (!empty($Field['MinLength'])) {
340
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
341
+                } else {
342
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < 6';
343
+                }
344
+                $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
345
+            } elseif ($Field['Type'] === 'link') {
346
+                $ValItem = '  if (!validLink($(\'#'.$FieldKey.'\').raw().value)';
347
+                if (!empty($Field['MaxLength'])) {
348
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
349
+                } else {
350
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > 255';
351
+                }
352
+                if (!empty($Field['MinLength'])) {
353
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
354
+                } else {
355
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < 10';
356
+                }
357
+                $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
358
+            } elseif ($Field['Type'] === 'username') {
359
+                $ValItem = '  if ($(\'#'.$FieldKey.'\').raw().value.match(/[^a-zA-Z0-9_\-]/)';
360
+                if (!empty($Field['MaxLength'])) {
361
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
362
+                }
363
+                if (!empty($Field['MinLength'])) {
364
+                    $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
365
+                }
366
+                $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
367
+            } elseif ($Field['Type'] === 'regex') {
368
+                $ValItem = '  if (!$(\'#'.$FieldKey.'\').raw().value.match('.$Field['Regex'].')) { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
369
+            } elseif ($Field['Type'] === 'date') {
370
+                $DisplayError = $FieldKey.'month';
371
+                if (isset($Field['MinLength']) && $Field['MinLength'] === 3) {
372
+                    $Day = '$(\'#'.$FieldKey.'day\').raw().value';
373
+                    $DisplayError .= ",{$FieldKey}day";
374
+                } else {
375
+                    $Day = '1';
376
+                }
377
+                $DisplayError .= ",{$FieldKey}year";
378
+                $ValItemHold = '  if (!validDate($(\'#'.$FieldKey.'month\').raw().value+\'/\'+'.$Day.'+\'/\'+$(\'#'.$FieldKey.'year\').raw().value)) { return showError(\''.$DisplayError.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
263 379
 
264
-              if (empty($Field['Required'])) {
265
-                  $ValItem = '  if ($(\'#'.$FieldKey.'month\').raw().value !== ""';
266
-                  if (isset($Field['MinLength']) && $Field['MinLength'] === 3) {
267
-                      $ValItem .= ' || $(\'#'.$FieldKey.'day\').raw().value !== ""';
268
-                  }
269
-                  $ValItem .= ' || $(\'#'.$FieldKey.'year\').raw().value !== "") {'."\r\n";
270
-                  $ValItem .= $ValItemHold;
271
-                  $ValItem .= " }\r\n";
272
-              } else {
273
-                  $ValItem .= $ValItemHold;
274
-              }
275
-          } elseif ($Field['Type'] === 'checkbox') {
276
-              $ValItem = '  if (!$(\'#'.$FieldKey.'\').checked) { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
277
-          } elseif ($Field['Type'] === 'compare') {
278
-              $ValItem = '  if ($(\'#'.$FieldKey.'\').raw().value!==$(\'#'.$Field['CompareField'].'\').raw().value) { return showError(\''.$FieldKey.','.$Field['CompareField'].'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
279
-          }
380
+                if (empty($Field['Required'])) {
381
+                    $ValItem = '  if ($(\'#'.$FieldKey.'month\').raw().value !== ""';
382
+                    if (isset($Field['MinLength']) && $Field['MinLength'] === 3) {
383
+                        $ValItem .= ' || $(\'#'.$FieldKey.'day\').raw().value !== ""';
384
+                    }
385
+                    $ValItem .= ' || $(\'#'.$FieldKey.'year\').raw().value !== "") {'."\r\n";
386
+                    $ValItem .= $ValItemHold;
387
+                    $ValItem .= " }\r\n";
388
+                } else {
389
+                    $ValItem .= $ValItemHold;
390
+                }
391
+            } elseif ($Field['Type'] === 'checkbox') {
392
+                $ValItem = '  if (!$(\'#'.$FieldKey.'\').checked) { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
393
+            } elseif ($Field['Type'] === 'compare') {
394
+                $ValItem = '  if ($(\'#'.$FieldKey.'\').raw().value!==$(\'#'.$Field['CompareField'].'\').raw().value) { return showError(\''.$FieldKey.','.$Field['CompareField'].'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
395
+            }
280 396
 
281
-          if (empty($Field['Required']) && $Field['Type'] !== 'date') {
282
-              $ReturnJS .= '  if ($(\'#'.$FieldKey.'\').raw().value!=="") {'."\r\n ";
283
-              $ReturnJS .= $ValItem;
284
-              $ReturnJS .= "  }\r\n";
285
-          } else {
286
-              $ReturnJS .= $ValItem;
287
-          }
288
-          $ValItem = '';
289
-      }
397
+            if (empty($Field['Required']) && $Field['Type'] !== 'date') {
398
+                $ReturnJS .= '  if ($(\'#'.$FieldKey.'\').raw().value!=="") {'."\r\n ";
399
+                $ReturnJS .= $ValItem;
400
+                $ReturnJS .= "  }\r\n";
401
+            } else {
402
+                $ReturnJS .= $ValItem;
403
+            }
404
+            $ValItem = '';
405
+        }
290 406
 
291
-      $ReturnJS .= "}\r\n";
292
-      $ReturnJS .= "</script>\r\n";
293
-      return $ReturnJS;
294
-      */
295
-  }
407
+        $ReturnJS .= "}\r\n";
408
+        $ReturnJS .= "</script>\r\n";
409
+        return $ReturnJS;
410
+        */
411
+    }
296 412
 }

+ 6
- 3
sections/login/login.php View File

@@ -35,17 +35,20 @@ if (!$Banned) {
35 35
       <td colspan="2">
36 36
         <input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" name="username"
37 37
           id="username" class="inputtext" required="required" maxlength="20" pattern="[A-Za-z0-9_?]{1,20}"
38
-          autofocus="autofocus" placeholder="Username" size="40" />
38
+          autofocus="autofocus" placeholder="Username" size="40"
39
+          autocomplete="username" />
39 40
       </td>
40 41
     </tr>
41 42
     <tr>
42 43
       <td>
43 44
         <input type="password" name="password" id="password" class="inputtext" required="required" maxlength="307200"
44
-          pattern=".{6,307200}" placeholder="Password" />
45
+          pattern=".{6,307200}" placeholder="Password"
46
+          autocomplete="current-password" />
45 47
       </td>
46 48
       <td>
47 49
         <input type="text" name="twofa" id="twofa" class="inputtext" maxlength="6" pattern="[0-9]{6}"
48
-          inputmode="numeric" placeholder="2FA" size="6" title="Leave blank if you have not enabled 2FA" />
50
+          inputmode="numeric" placeholder="2FA" size="6" title="Leave blank if you have not enabled 2FA"
51
+          autocomplete="one-time-code" />
49 52
       </td>
50 53
     </tr>
51 54
     <tr>

+ 25
- 12
sections/upload/upload_handle.php View File

@@ -30,7 +30,7 @@ $Feed = new Feed;
30 30
 //*****************************************************************************//
31 31
 //--------------- Set $Properties array ---------------------------------------//
32 32
 // This is used if the form doesn't validate, and when the time comes to enter //
33
-// it into the database.                 
33
+// it into the database.
34 34
 // todo: Do something about this mess
35 35
 //****************************************************************************//
36 36
 
@@ -197,7 +197,7 @@ default:
197 197
 
198 198
         # torrents_group.Studio
199 199
         $Validate->SetFields(
200
-           'studio',
200
+            'studio',
201 201
             '0',
202 202
             'string',
203 203
             'Department/Lab must be between 0 and 100 characters.',
@@ -213,6 +213,7 @@ default:
213 213
             array('maxlength' => 100, 'minlength' => 0)
214 214
         );
215 215
 
216
+        /* todo: Fix the year validation
216 217
         # torrents_group.Year
217 218
         $Validate->SetFields(
218 219
             'year',
@@ -221,6 +222,7 @@ default:
221 222
             'The year of the original release must be entered.',
222 223
             array('maxlength' => 4, 'minlength' => 4)
223 224
         );
225
+        */
224 226
 
225 227
         # torrents.Media
226 228
         $Validate->SetFields(
@@ -228,16 +230,7 @@ default:
228 230
             '1',
229 231
             'inarray',
230 232
             'Please select a valid platform.',
231
-            array('inarray' => array_merge($Media, $MediaManga, $Platform))
232
-        );
233
-
234
-        # torrents.Container
235
-        $Validate->SetFields(
236
-            'container',
237
-            '1',
238
-            'inarray',
239
-            'Please select a valid format.',
240
-            array('inarray' => array_merge($Containers, $ContainersGames, ContainersProt))
233
+            array('inarray' => array_merge($Media, $MediaManga))
241 234
         );
242 235
 
243 236
         /*
@@ -279,6 +272,7 @@ default:
279 272
         array('maxlength' => 65535, 'minlength' => 10)
280 273
     );
281 274
 
275
+    /* todo: Fix the Group ID validation
282 276
     # torrents_group.ID
283 277
     $Validate->SetFields(
284 278
         'groupid',
@@ -286,6 +280,7 @@ default:
286 280
         'number',
287 281
         'Group ID was not numeric.'
288 282
     );
283
+    */
289 284
 }
290 285
 
291 286
 $Err = $Validate->ValidateForm($_POST); // Validate the form
@@ -394,6 +389,24 @@ if (!empty($Err)) { // Show the upload form, with the data the user entered
394 389
     die();
395 390
 }
396 391
 
392
+//******************************************************************************//
393
+//--------------- Autofill format and archive ----------------------------------//
394
+
395
+if ($T['Container'] === 'Autofill' || $T['Archive'] === 'Autofill') {
396
+# torrents.Container
397
+$Validate->ParseExtensions(
398
+    $Tor->file_list(),
399
+    array_merge($Containers, $ContainersGames, $ContainersProt)
400
+);
401
+/*
402
+# torrents.Archive
403
+$Validate->ParseExtensions(
404
+    $Tor->file_list(),
405
+    array_merge($Containers, $ContainersGames, $ContainersProt)
406
+);
407
+*/
408
+}
409
+
397 410
 //******************************************************************************//
398 411
 //--------------- Start database stuff -----------------------------------------//
399 412
 

Loading…
Cancel
Save