Browse Source

Start DOI and Sci-Hub integration

pjc 5 years ago
parent
commit
b5a79bcab4
4 changed files with 30 additions and 17 deletions
  1. 1
    1
      classes/regex.php
  2. 2
    2
      classes/torrent_form.class.php
  3. 2
    0
      classes/validate.class.php
  4. 25
    14
      sections/upload/upload_handle.php

+ 1
- 1
classes/regex.php View File

@@ -14,4 +14,4 @@ define('SITELINK_REGEX', RESOURCE_REGEX.'(www.)?'.preg_quote(SITE_DOMAIN, '/'));
14 14
 define('TORRENT_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?torrentid=(\d+)'); // torrentid = group 4
15 15
 define('TORRENT_GROUP_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?id=(\d+)'); // id = group 4
16 16
 define('ARTIST_REGEX', SITELINK_REGEX.'\/artist\.php\?(.*&)?id=(\d+)'); // id = group 4
17
-define('DOI_REGEX', '/^10.\d{4,9}/[-._;()/:A-Z0-9]+$/i'); # https://www.crossref.org/blog/dois-and-matching-regular-expressions/
17
+define('DOI_REGEX', '10.\d{4,9}\/[-._;()\/:A-Z0-9]+'); # https://www.crossref.org/blog/dois-and-matching-regular-expressions/

+ 2
- 2
classes/torrent_form.class.php View File

@@ -334,7 +334,7 @@ class TorrentForm
334 334
       <input type="text" id="idols_<?= $Num ?>" name="idols[]"
335 335
         size="45" value="<?= display_str($Artist['name']) ?>"
336 336
         <?= $this->Disabled ?>/>
337
-      <?php if ($Num == 0) { ?>
337
+      <?php if ($Num === 0) { ?>
338 338
       <a class="add_artist_button brackets">+</a>
339 339
       <a class="remove_artist_button brackets">&minus;</a>
340 340
       <?php
@@ -584,7 +584,7 @@ class TorrentForm
584 584
     </tr>
585 585
   <?php } ?>
586 586
 
587
-  <!-- Artist description -->
587
+  <!-- Album description -->
588 588
   <tr id="group_desc_tr">
589 589
     <td class="label">Torrent Group Description</td>
590 590
     <td>

+ 2
- 0
classes/validate.class.php View File

@@ -1,4 +1,5 @@
1 1
 <?php
2
+
2 3
 /*-- TODO ---------------------------//
3 4
 Writeup how to use the VALIDATE class, add in support for form id checks
4 5
 Complete the number and date validation
@@ -14,6 +15,7 @@ class VALIDATE
14 15
         $this->Fields[$FieldName]['Type'] = strtolower($FieldType);
15 16
         $this->Fields[$FieldName]['Required'] = $Required;
16 17
         $this->Fields[$FieldName]['ErrorMessage'] = $ErrorMessage;
18
+
17 19
         if (!empty($Options['maxlength'])) {
18 20
             $this->Fields[$FieldName]['MaxLength'] = $Options['maxlength'];
19 21
         }

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

@@ -10,7 +10,10 @@
10 10
 // Maximum allowed size for uploaded files
11 11
 // https://php.net/upload-max-filesize
12 12
 ini_set('upload_max_filesize', 2097152); // 2 MiB
13
-ini_set('max_file_uploads', 100);
13
+
14
+# Allow many uncompressed files,
15
+# e.g., http://academictorrents.com/details/5a447ff50062194bd58dd11c0fedead59e6d873c/tech
16
+ini_set('max_file_uploads', 65535);
14 17
 define('MAX_FILENAME_LENGTH', 180);
15 18
 
16 19
 include(SERVER_ROOT.'/classes/validate.class.php');
@@ -82,7 +85,7 @@ if (isset($_POST['release'])) {
82 85
 $Properties['GroupDescription'] = trim($_POST['album_desc']);
83 86
 $Properties['TorrentDescription'] = $_POST['release_desc'];
84 87
 $Properties['MediaInfo'] = 'nil';
85
-$Properties['Screenshots'] = isset($_POST['screenshots']) ? $_POST['screenshots'] : "";
88
+$Properties['Screenshots'] = isset($_POST['screenshots']) ? $_POST['screenshots'] : '';
86 89
 
87 90
 if ($_POST['album_desc']) {
88 91
     $Properties['GroupDescription'] = trim($_POST['album_desc']);
@@ -168,7 +171,7 @@ switch ($Type) {
168 171
             'title',
169 172
             '0',
170 173
             'string',
171
-            'Sequence Name must be between 1 and 300 characters.', # `torrents_group` limits
174
+            'Torrent Title must be between 1 and 300 characters.', # `torrents_group` limits
172 175
             array('maxlength'=>300, 'minlength'=>1)
173 176
         );
174 177
         $Validate->SetFields(
@@ -382,7 +385,7 @@ if (!isset($GroupID) || !$GroupID) {
382 385
 // Needs to be here as it isn't set for add format until now
383 386
 $LogName .= $T['Title'];
384 387
 
385
-// For notifications---take note now whether it's a new group
388
+// For notifications. Take note now whether it's a new group
386 389
 $IsNewGroup = !isset($GroupID) || !$GroupID;
387 390
 
388 391
 //----- Start inserts
@@ -447,10 +450,13 @@ if (!isset($GroupID) || !$GroupID) {
447 450
 
448 451
     // Add screenshots
449 452
     $Screenshots = explode("\n", $T['Screenshots']);
450
-    $Screenshots = array_map("trim", $Screenshots);
453
+    $Screenshots = array_map('trim', $Screenshots);
454
+
451 455
     $Screenshots = array_filter($Screenshots, function ($s) {
452
-        return preg_match('/^'.IMAGE_REGEX.'$/i', $s);
456
+        return preg_match('/^'.DOI_REGEX.'$/i', $s);
457
+        #return preg_match('/^'.IMAGE_REGEX.'$/i', $s);
453 458
     });
459
+
454 460
     $Screenshots = array_unique($Screenshots);
455 461
     $Screenshots = array_slice($Screenshots, 0, 10);
456 462
 
@@ -535,9 +541,9 @@ if ($DB->has_results()) {
535 541
     }
536 542
 }
537 543
 
538
-// Torrents over 100 GiB are neutral leech
544
+// Torrents over a size in bytes are neutral leech
539 545
 // Download doesn't count, upload does
540
-if (($TotalSize > 107374182400)) { # 100 GiB
546
+if (($TotalSize > 53687091200)) { # 50 GiB
541 547
   $T['FreeTorrent'] = '2';
542 548
   $T['FreeLeechType'] = '2';
543 549
 }
@@ -595,6 +601,7 @@ $Debug->set_flag('upload: ocelot updated');
595 601
 $Cache->cache_value("torrent_{$TorrentID}_lock", true, 600);
596 602
 
597 603
 // Give BP if necessary
604
+// @todo Repurpose this
598 605
 if (($Type === "Movies" || $Type === "Anime") && ($T['Container'] === 'ISO' || $T['Container'] === 'M2TS' || $T['Container'] === 'VOB IFO')) {
599 606
     $BPAmt = (int) 2*($TotalSize / (1024*1024*1024))*1000;
600 607
 
@@ -682,17 +689,21 @@ if (trim($T['Image']) !== '') {
682 689
 if ($PublicTorrent) {
683 690
     View::show_header('Warning'); ?>
684 691
 <h1>Warning</h1>
685
-<p><strong>Your torrent has been uploaded - but you must re-download your torrent file from <a
686
-      href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>">here</a>
687
-    because the site modified it to make it private.</strong></p>
692
+<p>
693
+  <strong>Your torrent has been uploaded but you must re-download your torrent file from
694
+  <a href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>">here</a>
695
+  because the site modified it to make it private.</strong>
696
+</p>
688 697
 <?php
689 698
   View::show_footer();
690 699
 } elseif ($UnsourcedTorrent) {
691 700
     View::show_header('Warning'); ?>
692 701
 <h1>Warning</h1>
693
-<p><strong>Your torrent has been uploaded - but you must re-download your torrent file from <a
694
-      href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>">here</a>
695
-    because the site modified it to add a source flag.</strong></p>
702
+<p>
703
+  <strong>Your torrent has been uploaded but you must re-download your torrent file from
704
+  <a href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>">here</a>
705
+  because the site modified it to add a source flag.</strong>
706
+</p>
696 707
 <?php
697 708
   View::show_footer();
698 709
 } elseif ($RequestID) {

Loading…
Cancel
Save