Browse Source

Start DOI and Sci-Hub integration

pjc 5 years ago
parent
commit
b5a79bcab4

+ 1
- 1
classes/regex.php View File

14
 define('TORRENT_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?torrentid=(\d+)'); // torrentid = group 4
14
 define('TORRENT_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?torrentid=(\d+)'); // torrentid = group 4
15
 define('TORRENT_GROUP_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?id=(\d+)'); // id = group 4
15
 define('TORRENT_GROUP_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?id=(\d+)'); // id = group 4
16
 define('ARTIST_REGEX', SITELINK_REGEX.'\/artist\.php\?(.*&)?id=(\d+)'); // id = group 4
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
       <input type="text" id="idols_<?= $Num ?>" name="idols[]"
334
       <input type="text" id="idols_<?= $Num ?>" name="idols[]"
335
         size="45" value="<?= display_str($Artist['name']) ?>"
335
         size="45" value="<?= display_str($Artist['name']) ?>"
336
         <?= $this->Disabled ?>/>
336
         <?= $this->Disabled ?>/>
337
-      <?php if ($Num == 0) { ?>
337
+      <?php if ($Num === 0) { ?>
338
       <a class="add_artist_button brackets">+</a>
338
       <a class="add_artist_button brackets">+</a>
339
       <a class="remove_artist_button brackets">&minus;</a>
339
       <a class="remove_artist_button brackets">&minus;</a>
340
       <?php
340
       <?php
584
     </tr>
584
     </tr>
585
   <?php } ?>
585
   <?php } ?>
586
 
586
 
587
-  <!-- Artist description -->
587
+  <!-- Album description -->
588
   <tr id="group_desc_tr">
588
   <tr id="group_desc_tr">
589
     <td class="label">Torrent Group Description</td>
589
     <td class="label">Torrent Group Description</td>
590
     <td>
590
     <td>

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

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

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

10
 // Maximum allowed size for uploaded files
10
 // Maximum allowed size for uploaded files
11
 // https://php.net/upload-max-filesize
11
 // https://php.net/upload-max-filesize
12
 ini_set('upload_max_filesize', 2097152); // 2 MiB
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
 define('MAX_FILENAME_LENGTH', 180);
17
 define('MAX_FILENAME_LENGTH', 180);
15
 
18
 
16
 include(SERVER_ROOT.'/classes/validate.class.php');
19
 include(SERVER_ROOT.'/classes/validate.class.php');
82
 $Properties['GroupDescription'] = trim($_POST['album_desc']);
85
 $Properties['GroupDescription'] = trim($_POST['album_desc']);
83
 $Properties['TorrentDescription'] = $_POST['release_desc'];
86
 $Properties['TorrentDescription'] = $_POST['release_desc'];
84
 $Properties['MediaInfo'] = 'nil';
87
 $Properties['MediaInfo'] = 'nil';
85
-$Properties['Screenshots'] = isset($_POST['screenshots']) ? $_POST['screenshots'] : "";
88
+$Properties['Screenshots'] = isset($_POST['screenshots']) ? $_POST['screenshots'] : '';
86
 
89
 
87
 if ($_POST['album_desc']) {
90
 if ($_POST['album_desc']) {
88
     $Properties['GroupDescription'] = trim($_POST['album_desc']);
91
     $Properties['GroupDescription'] = trim($_POST['album_desc']);
168
             'title',
171
             'title',
169
             '0',
172
             '0',
170
             'string',
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
             array('maxlength'=>300, 'minlength'=>1)
175
             array('maxlength'=>300, 'minlength'=>1)
173
         );
176
         );
174
         $Validate->SetFields(
177
         $Validate->SetFields(
382
 // Needs to be here as it isn't set for add format until now
385
 // Needs to be here as it isn't set for add format until now
383
 $LogName .= $T['Title'];
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
 $IsNewGroup = !isset($GroupID) || !$GroupID;
389
 $IsNewGroup = !isset($GroupID) || !$GroupID;
387
 
390
 
388
 //----- Start inserts
391
 //----- Start inserts
447
 
450
 
448
     // Add screenshots
451
     // Add screenshots
449
     $Screenshots = explode("\n", $T['Screenshots']);
452
     $Screenshots = explode("\n", $T['Screenshots']);
450
-    $Screenshots = array_map("trim", $Screenshots);
453
+    $Screenshots = array_map('trim', $Screenshots);
454
+
451
     $Screenshots = array_filter($Screenshots, function ($s) {
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
     $Screenshots = array_unique($Screenshots);
460
     $Screenshots = array_unique($Screenshots);
455
     $Screenshots = array_slice($Screenshots, 0, 10);
461
     $Screenshots = array_slice($Screenshots, 0, 10);
456
 
462
 
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
 // Download doesn't count, upload does
545
 // Download doesn't count, upload does
540
-if (($TotalSize > 107374182400)) { # 100 GiB
546
+if (($TotalSize > 53687091200)) { # 50 GiB
541
   $T['FreeTorrent'] = '2';
547
   $T['FreeTorrent'] = '2';
542
   $T['FreeLeechType'] = '2';
548
   $T['FreeLeechType'] = '2';
543
 }
549
 }
595
 $Cache->cache_value("torrent_{$TorrentID}_lock", true, 600);
601
 $Cache->cache_value("torrent_{$TorrentID}_lock", true, 600);
596
 
602
 
597
 // Give BP if necessary
603
 // Give BP if necessary
604
+// @todo Repurpose this
598
 if (($Type === "Movies" || $Type === "Anime") && ($T['Container'] === 'ISO' || $T['Container'] === 'M2TS' || $T['Container'] === 'VOB IFO')) {
605
 if (($Type === "Movies" || $Type === "Anime") && ($T['Container'] === 'ISO' || $T['Container'] === 'M2TS' || $T['Container'] === 'VOB IFO')) {
599
     $BPAmt = (int) 2*($TotalSize / (1024*1024*1024))*1000;
606
     $BPAmt = (int) 2*($TotalSize / (1024*1024*1024))*1000;
600
 
607
 
682
 if ($PublicTorrent) {
689
 if ($PublicTorrent) {
683
     View::show_header('Warning'); ?>
690
     View::show_header('Warning'); ?>
684
 <h1>Warning</h1>
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
 <?php
697
 <?php
689
   View::show_footer();
698
   View::show_footer();
690
 } elseif ($UnsourcedTorrent) {
699
 } elseif ($UnsourcedTorrent) {
691
     View::show_header('Warning'); ?>
700
     View::show_header('Warning'); ?>
692
 <h1>Warning</h1>
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
 <?php
707
 <?php
697
   View::show_footer();
708
   View::show_footer();
698
 } elseif ($RequestID) {
709
 } elseif ($RequestID) {

Loading…
Cancel
Save