Browse Source

Add basic bioinformatics support

biotorrents 3 years ago
parent
commit
48e3ea4aac

+ 57
- 47
classes/config.template.php View File

@@ -1,4 +1,3 @@
1
-
2 1
 <?php
3 2
 declare(strict_types=1);
4 3
 
@@ -127,6 +126,7 @@ ENV::setPub('SRI', 'sha384');
127 126
  * Tech support
128 127
  */
129 128
 
129
+ /*
130 130
 $TechSupport = [
131 131
   'Email' => 'help@biotorrents.de',
132 132
   'Subject' => '[TxID '.strtoupper(bin2hex(random_bytes(2))).'] Specific subject line with TxID intact',
@@ -136,6 +136,7 @@ ENV::setPub(
136 136
     'HELP',
137 137
     $ENV->convert($TechSupport)
138 138
 );
139
+*/
139 140
 
140 141
 
141 142
 /**
@@ -380,7 +381,8 @@ ENV::setPub('FEATURE_SEND_EMAIL', true);
380 381
 # (should only be used for initial setup)
381 382
 ENV::setPub('FEATURE_SET_ENC_KEY_PUBLIC', false);
382 383
 
383
-# Attempt to support the Seqhash algorithm
384
+# Attempt to support the BioPHP library
385
+# https://packagist.org/packages/biotorrents/biophp
384 386
 # https://blog.libredna.org/post/seqhash/
385 387
 ENV::setPub('FEATURE_BIOPHP', true);
386 388
 
@@ -831,6 +833,9 @@ $DB = [
831 833
     'version' => ['name' => 'Version', 'desc' => 'Start with 0.1.0', 'note' => 'Please see <a href="https://semver.org" target="_blank">Semantic Versioning</a>'],
832 834
     'license' => ['name' => 'License', 'desc' => '', 'note' => 'Please see <a href="http://www.dcc.ac.uk/resources/how-guides/license-research-data" target="_blank">How to License Research Data</a>'],
833 835
     'mirrors' => ['name' => 'Mirrors', 'desc' => 'Up to two FTP/HTTP addresses that either point directly to a file, or for multi-file torrents, to the enclosing folder'],
836
+
837
+    # Original fields
838
+    'seqhash' => ['name' => 'Seqhash', 'desc' => 'Sample genome sequence in FASTA format (GenBank pending)', 'note' => 'Please see <a href="https://blog.libredna.org/post/seqhash/" target="_blank">The Seqhash Algorithm</a>'],
834 839
 ];
835 840
 ENV::setPub(
836 841
     'DB',
@@ -971,10 +976,23 @@ $META = [
971 976
         'Plain' => [
972 977
             'CSV'   => ['csv'], # 3
973 978
             'JSON'  => ['json'], # 3
974
-            'Text'  => ['txt'], # 3
979
+            'Text'  => ['txt', 'asc'], # 3
975 980
             'XML'   => ['xml'], # etc.
976 981
         ],
977 982
 
983
+        /**
984
+         * 2.
985
+         * Databases
986
+         */
987
+        'Databases' => [
988
+            'MS SQL'   => ['mdf', 'ndf', 'ldf'],
989
+            'MySQL'   => ['sql', 'mysql'],
990
+            'Oracle' => ['dbf', 'ora', 'oraenv'],
991
+            'IBM Db2' => ['ixf', 'del', 'cursor'],
992
+            'Postgres' => ['sql']
993
+        ],
994
+
995
+
978 996
         /**
979 997
          * 2.
980 998
          * Archives
@@ -1330,16 +1348,11 @@ $CATS = [
1330 1348
         'Icon' => "$CatIcons/sequences.png",
1331 1349
         'Description' => "For data that's ACGT, ACGU, amino acid letters on disk.",
1332 1350
         'Platforms' => $ENV->META->Platforms->Sequences,
1333
-        'Formats' => array_merge([
1334
-            /*
1335
-            'Sequences' => $ENV->META->Formats->Sequences,
1336
-            'Proteins' => $ENV->META->Formats->Proteins,
1337
-            'Plain' => $ENV->META->Formats->Plain,
1338
-            */
1351
+        'Formats' => [
1339 1352
             $ENV->META->Formats->Sequences,
1340 1353
             $ENV->META->Formats->Proteins,
1341 1354
             $ENV->META->Formats->Plain,
1342
-        ]),
1355
+        ],
1343 1356
     ],
1344 1357
 
1345 1358
     2 => [
@@ -1349,9 +1362,9 @@ $CATS = [
1349 1362
         'Description' => 'For pathway and regulatory network data, structured taxonomies, etc.',
1350 1363
         'Platforms' => $ENV->META->Platforms->Graphs,
1351 1364
         'Formats' => [
1352
-            'GraphXml' => $ENV->META->Formats->GraphXml,
1353
-            'GraphTxt' => $ENV->META->Formats->GraphTxt,
1354
-            'Plain' => $ENV->META->Formats->Plain,
1365
+            $ENV->META->Formats->GraphXml,
1366
+            $ENV->META->Formats->GraphTxt,
1367
+            $ENV->META->Formats->Plain,
1355 1368
         ],
1356 1369
     ],
1357 1370
 
@@ -1362,9 +1375,9 @@ $CATS = [
1362 1375
         'Description' => 'For data that examines one facet broadly, not one subject deeply.',
1363 1376
         'Platforms' => $ENV->META->Platforms->Graphs,
1364 1377
         'Formats' => [
1365
-            'GraphXml' => $ENV->META->Formats->GraphXml,
1366
-            'GraphTxt' => $ENV->META->Formats->GraphTxt,
1367
-            'Plain' => $ENV->META->Formats->Plain,
1378
+            $ENV->META->Formats->GraphXml,
1379
+            $ENV->META->Formats->GraphTxt,
1380
+            $ENV->META->Formats->Plain,
1368 1381
         ],
1369 1382
     ],
1370 1383
 
@@ -1375,9 +1388,9 @@ $CATS = [
1375 1388
         'Description' => "For structured data (XML, etc.) that describes the subject's orientation in space.",
1376 1389
         'Platforms' => $ENV->META->Platforms->Graphs,
1377 1390
         'Formats' => [
1378
-            'GraphXml' => $ENV->META->Formats->GraphXml,
1379
-            'GraphTxt' => $ENV->META->Formats->GraphTxt,
1380
-            'Plain' => $ENV->META->Formats->Plain,
1391
+            $ENV->META->Formats->GraphXml,
1392
+            $ENV->META->Formats->GraphTxt,
1393
+            $ENV->META->Formats->Plain,
1381 1394
         ],
1382 1395
     ],
1383 1396
 
@@ -1388,9 +1401,9 @@ $CATS = [
1388 1401
         'Description' => 'For data that describes observations over time and/or space.',
1389 1402
         'Platforms' => $ENV->META->Platforms->Graphs,
1390 1403
         'Formats' => [
1391
-            'GraphXml' => $ENV->META->Formats->GraphXml,
1392
-            'GraphTxt' => $ENV->META->Formats->GraphTxt,
1393
-            'Plain' => $ENV->META->Formats->Plain,
1404
+            $ENV->META->Formats->GraphXml,
1405
+            $ENV->META->Formats->GraphTxt,
1406
+            $ENV->META->Formats->Plain,
1394 1407
         ],
1395 1408
     ],
1396 1409
 
@@ -1401,9 +1414,9 @@ $CATS = [
1401 1414
         'Description' => 'For data that describes recurring structures in nature such as common pathways or motifs in the proteome or metabolome.',
1402 1415
         'Platforms' => $ENV->META->Platforms->Graphs,
1403 1416
         'Formats' => [
1404
-            'GraphXml' => $ENV->META->Formats->GraphXml,
1405
-            'GraphTxt' => $ENV->META->Formats->GraphTxt,
1406
-            'Plain' => $ENV->META->Formats->Plain,
1417
+            $ENV->META->Formats->GraphXml,
1418
+            $ENV->META->Formats->GraphTxt,
1419
+            $ENV->META->Formats->Plain,
1407 1420
         ],
1408 1421
     ],
1409 1422
 
@@ -1414,9 +1427,9 @@ $CATS = [
1414 1427
         'Description' => 'For data that records experimental control behavior, checks readings against known physical constants, tracks the thermodynamic limits of reactions, etc.',
1415 1428
         'Platforms' => $ENV->META->Platforms->Graphs,
1416 1429
         'Formats' => [
1417
-            'GraphXml' => $ENV->META->Formats->GraphXml,
1418
-            'GraphTxt' => $ENV->META->Formats->GraphTxt,
1419
-            'Plain' => $ENV->META->Formats->Plain,
1430
+            $ENV->META->Formats->GraphXml,
1431
+            $ENV->META->Formats->GraphTxt,
1432
+            $ENV->META->Formats->Plain,
1420 1433
         ],
1421 1434
     ],
1422 1435
 
@@ -1427,9 +1440,8 @@ $CATS = [
1427 1440
         'Description' => 'For data you can look at!',
1428 1441
         'Platforms' => $ENV->META->Platforms->Images,
1429 1442
         'Formats' => [
1430
-            'ImgRaster' => $ENV->META->Formats->ImgRaster,
1431
-            'ImgVector' => $ENV->META->Formats->ImgVector,
1432
-            'Plain' => $ENV->META->Formats->Plain,
1443
+            $ENV->META->Formats->ImgRaster,
1444
+            $ENV->META->Formats->ImgVector,
1433 1445
         ],
1434 1446
     ],
1435 1447
 
@@ -1440,11 +1452,10 @@ $CATS = [
1440 1452
         'Description' => "For data that's limited to specific locations or otherwise describes macroscopic space.",
1441 1453
         'Platforms' => $ENV->META->Platforms->Graphs,
1442 1454
         'Formats' => [
1443
-            'MapRaster' => $ENV->META->Formats->MapRaster,
1444
-            'MapVector' => $ENV->META->Formats->MapVector,
1445
-            'ImgRaster' => $ENV->META->Formats->ImgRaster,
1446
-            'ImgVector' => $ENV->META->Formats->ImgVector,
1447
-            'Plain' => $ENV->META->Formats->Plain,
1455
+            $ENV->META->Formats->MapRaster,
1456
+            $ENV->META->Formats->MapVector,
1457
+            $ENV->META->Formats->ImgRaster,
1458
+            $ENV->META->Formats->ImgVector,
1448 1459
         ],
1449 1460
     ],
1450 1461
 
@@ -1455,11 +1466,10 @@ $CATS = [
1455 1466
         'Description' => 'For projections, simulations, and other hypothetical or computer-generated data.',
1456 1467
         'Platforms' => $ENV->META->Platforms->Graphs,
1457 1468
         'Formats' => [
1458
-            'MapRaster' => $ENV->META->Formats->MapRaster,
1459
-            'MapVector' => $ENV->META->Formats->MapVector,
1460
-            'ImgRaster' => $ENV->META->Formats->ImgRaster,
1461
-            'ImgVector' => $ENV->META->Formats->ImgVector,
1462
-            'Plain' => $ENV->META->Formats->Plain,
1469
+            $ENV->META->Formats->MapRaster,
1470
+            $ENV->META->Formats->MapVector,
1471
+            $ENV->META->Formats->ImgRaster,
1472
+            $ENV->META->Formats->ImgVector,
1463 1473
         ],
1464 1474
     ],
1465 1475
 
@@ -1470,9 +1480,9 @@ $CATS = [
1470 1480
         'Description' => 'For documentation, software, disk images, and literature datasets.',
1471 1481
         'Platforms' => $ENV->META->Platforms->Documents,
1472 1482
         'Formats' => [
1473
-            'BinDoc' => $ENV->META->Formats->BinDoc,
1474
-            'CpuGen' => $ENV->META->Formats->CpuGen,
1475
-            'Plain' => $ENV->META->Formats->Plain,
1483
+            $ENV->META->Formats->BinDoc,
1484
+            $ENV->META->Formats->CpuGen,
1485
+            $ENV->META->Formats->Plain,
1476 1486
         ],
1477 1487
     ],
1478 1488
 
@@ -1483,7 +1493,7 @@ $CATS = [
1483 1493
         'Description' => 'For raw reads and machine data of any category.',
1484 1494
         'Platforms' => $ENV->META->Platforms->Raw,
1485 1495
         'Formats' => [
1486
-            'Plain' => $ENV->META->Formats->Plain,
1496
+            $ENV->META->Formats->Plain,
1487 1497
         ],
1488 1498
     ],
1489 1499
 ];
@@ -1501,10 +1511,10 @@ ENV::setPub(
1501 1511
  */
1502 1512
 
1503 1513
 // resource_type://username:password@domain:port/path?query_string#anchor
1504
-define('RESOURCE_REGEX', '(https?|ftps?):\/\/');
1514
+define('RESOURCE_REGEX', '(https?|ftps?|dat|ipfs):\/\/');
1505 1515
 ENV::setPub(
1506 1516
     'RESOURCE_REGEX',
1507
-    '(https?|ftps?):\/\/'
1517
+    '(https?|ftps?|dat|ipfs):\/\/'
1508 1518
 );
1509 1519
 
1510 1520
 define('IP_REGEX', '(\d{1,3}\.){3}\d{1,3}');

+ 28
- 52
classes/validate.class.php View File

@@ -46,6 +46,34 @@
46 46
 
47 47
 class Validate
48 48
 {
49
+    /**
50
+     * mirrors
51
+     *
52
+     * @param string $String The raw textarea, e.g., from torrent_form.class.php
53
+     * @param string $Regex  The regex to test against, e.g., from $ENV
54
+     * @return array An array of unique values that match the regex
55
+     */
56
+    public function textarea2array(string $String, string $Regex)
57
+    {
58
+        $ENV = ENV::go();
59
+
60
+        $String = array_map(
61
+            'trim',
62
+            explode(
63
+                "\n",
64
+                $String
65
+            )
66
+        );
67
+        
68
+        return array_unique(
69
+            preg_grep(
70
+                "/^$Regex$/i",
71
+                $String
72
+            )
73
+        );
74
+    }
75
+
76
+    
49 77
     /**
50 78
      * title
51 79
      *
@@ -245,58 +273,6 @@ class Validate
245 273
     }
246 274
 
247 275
 
248
-    /**
249
-     * Make input
250
-     * https://www.w3schools.com/html/html_form_input_types.asp
251
-     *
252
-     * Generate a secure HTML input element.
253
-     * Takes $Type, $Name (also used for id), and $Classes.
254
-     * Outputs a hardened input with the requested attributes.
255
-     *
256
-     * todo: See if this could work, one ugly switch for all forms in sections/
257
-     */
258
-
259
-    public function MakeInput($Type = 'text', $Name = '', $Classes = [])
260
-    {
261
-        if (!is_str($Type) || !is_str($Name)) {
262
-            error('$Type and $Name must be strings');
263
-        }
264
-
265
-        # Intentionally double quoted PHP constructing $HTML
266
-        # <input type='text' id='title_jp' name='title_jp' class='one two'
267
-        $HTML  = "";
268
-        $HTML .= "<input type='$Type' id='$Name' name='$Name'";
269
-        $HTML .= (!empty($Classes)) ? " class='" . implode(' ', $Classes) . "'" : "";
270
-
271
-        /*
272
-        'button'
273
-        'checkbox'
274
-        'color'
275
-        'date'
276
-        'datetime-local'
277
-        'email'
278
-        'file'
279
-        'hidden'
280
-        'image'
281
-        'month'
282
-        'number'
283
-        'password'
284
-        'radio'
285
-        'range'
286
-        'reset'
287
-        'search'
288
-        'submit'
289
-        'tel'
290
-        'text'
291
-        'time'
292
-        'url'
293
-        'week'
294
-        */
295
-                
296
-        return;
297
-    }
298
-    
299
-
300 276
     /**
301 277
      * Legacy class
302 278
      */

+ 31
- 29
composer.lock View File

@@ -776,16 +776,16 @@
776 776
         },
777 777
         {
778 778
             "name": "symfony/config",
779
-            "version": "v5.3.3",
779
+            "version": "v5.3.4",
780 780
             "source": {
781 781
                 "type": "git",
782 782
                 "url": "https://github.com/symfony/config.git",
783
-                "reference": "a69e0c55528b47df88d3c4067ddedf32d485d662"
783
+                "reference": "4268f3059c904c61636275182707f81645517a37"
784 784
             },
785 785
             "dist": {
786 786
                 "type": "zip",
787
-                "url": "https://api.github.com/repos/symfony/config/zipball/a69e0c55528b47df88d3c4067ddedf32d485d662",
788
-                "reference": "a69e0c55528b47df88d3c4067ddedf32d485d662",
787
+                "url": "https://api.github.com/repos/symfony/config/zipball/4268f3059c904c61636275182707f81645517a37",
788
+                "reference": "4268f3059c904c61636275182707f81645517a37",
789 789
                 "shasum": ""
790 790
             },
791 791
             "require": {
@@ -793,7 +793,7 @@
793 793
                 "symfony/deprecation-contracts": "^2.1",
794 794
                 "symfony/filesystem": "^4.4|^5.0",
795 795
                 "symfony/polyfill-ctype": "~1.8",
796
-                "symfony/polyfill-php80": "^1.15",
796
+                "symfony/polyfill-php80": "^1.16",
797 797
                 "symfony/polyfill-php81": "^1.22"
798 798
             },
799 799
             "conflict": {
@@ -835,7 +835,7 @@
835 835
             "description": "Helps you find, load, combine, autofill and validate configuration values of any kind",
836 836
             "homepage": "https://symfony.com",
837 837
             "support": {
838
-                "source": "https://github.com/symfony/config/tree/v5.3.3"
838
+                "source": "https://github.com/symfony/config/tree/v5.3.4"
839 839
             },
840 840
             "funding": [
841 841
                 {
@@ -851,20 +851,20 @@
851 851
                     "type": "tidelift"
852 852
                 }
853 853
             ],
854
-            "time": "2021-06-24T08:13:00+00:00"
854
+            "time": "2021-07-21T12:40:44+00:00"
855 855
         },
856 856
         {
857 857
             "name": "symfony/console",
858
-            "version": "v5.3.2",
858
+            "version": "v5.3.4",
859 859
             "source": {
860 860
                 "type": "git",
861 861
                 "url": "https://github.com/symfony/console.git",
862
-                "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1"
862
+                "reference": "ebd610dacd40d75b6a12bf64b5ccd494fc7d6ab1"
863 863
             },
864 864
             "dist": {
865 865
                 "type": "zip",
866
-                "url": "https://api.github.com/repos/symfony/console/zipball/649730483885ff2ca99ca0560ef0e5f6b03f2ac1",
867
-                "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1",
866
+                "url": "https://api.github.com/repos/symfony/console/zipball/ebd610dacd40d75b6a12bf64b5ccd494fc7d6ab1",
867
+                "reference": "ebd610dacd40d75b6a12bf64b5ccd494fc7d6ab1",
868 868
                 "shasum": ""
869 869
             },
870 870
             "require": {
@@ -872,11 +872,12 @@
872 872
                 "symfony/deprecation-contracts": "^2.1",
873 873
                 "symfony/polyfill-mbstring": "~1.0",
874 874
                 "symfony/polyfill-php73": "^1.8",
875
-                "symfony/polyfill-php80": "^1.15",
875
+                "symfony/polyfill-php80": "^1.16",
876 876
                 "symfony/service-contracts": "^1.1|^2",
877 877
                 "symfony/string": "^5.1"
878 878
             },
879 879
             "conflict": {
880
+                "psr/log": ">=3",
880 881
                 "symfony/dependency-injection": "<4.4",
881 882
                 "symfony/dotenv": "<5.1",
882 883
                 "symfony/event-dispatcher": "<4.4",
@@ -884,10 +885,10 @@
884 885
                 "symfony/process": "<4.4"
885 886
             },
886 887
             "provide": {
887
-                "psr/log-implementation": "1.0"
888
+                "psr/log-implementation": "1.0|2.0"
888 889
             },
889 890
             "require-dev": {
890
-                "psr/log": "~1.0",
891
+                "psr/log": "^1|^2",
891 892
                 "symfony/config": "^4.4|^5.0",
892 893
                 "symfony/dependency-injection": "^4.4|^5.0",
893 894
                 "symfony/event-dispatcher": "^4.4|^5.0",
@@ -933,7 +934,7 @@
933 934
                 "terminal"
934 935
             ],
935 936
             "support": {
936
-                "source": "https://github.com/symfony/console/tree/v5.3.2"
937
+                "source": "https://github.com/symfony/console/tree/v5.3.4"
937 938
             },
938 939
             "funding": [
939 940
                 {
@@ -949,7 +950,7 @@
949 950
                     "type": "tidelift"
950 951
                 }
951 952
             ],
952
-            "time": "2021-06-12T09:42:48+00:00"
953
+            "time": "2021-07-26T16:33:26+00:00"
953 954
         },
954 955
         {
955 956
             "name": "symfony/deprecation-contracts",
@@ -1020,21 +1021,22 @@
1020 1021
         },
1021 1022
         {
1022 1023
             "name": "symfony/filesystem",
1023
-            "version": "v5.3.3",
1024
+            "version": "v5.3.4",
1024 1025
             "source": {
1025 1026
                 "type": "git",
1026 1027
                 "url": "https://github.com/symfony/filesystem.git",
1027
-                "reference": "19b71c8f313b411172dd5f470fd61f24466d79a9"
1028
+                "reference": "343f4fe324383ca46792cae728a3b6e2f708fb32"
1028 1029
             },
1029 1030
             "dist": {
1030 1031
                 "type": "zip",
1031
-                "url": "https://api.github.com/repos/symfony/filesystem/zipball/19b71c8f313b411172dd5f470fd61f24466d79a9",
1032
-                "reference": "19b71c8f313b411172dd5f470fd61f24466d79a9",
1032
+                "url": "https://api.github.com/repos/symfony/filesystem/zipball/343f4fe324383ca46792cae728a3b6e2f708fb32",
1033
+                "reference": "343f4fe324383ca46792cae728a3b6e2f708fb32",
1033 1034
                 "shasum": ""
1034 1035
             },
1035 1036
             "require": {
1036 1037
                 "php": ">=7.2.5",
1037
-                "symfony/polyfill-ctype": "~1.8"
1038
+                "symfony/polyfill-ctype": "~1.8",
1039
+                "symfony/polyfill-php80": "^1.16"
1038 1040
             },
1039 1041
             "type": "library",
1040 1042
             "autoload": {
@@ -1062,7 +1064,7 @@
1062 1064
             "description": "Provides basic utilities for the filesystem",
1063 1065
             "homepage": "https://symfony.com",
1064 1066
             "support": {
1065
-                "source": "https://github.com/symfony/filesystem/tree/v5.3.3"
1067
+                "source": "https://github.com/symfony/filesystem/tree/v5.3.4"
1066 1068
             },
1067 1069
             "funding": [
1068 1070
                 {
@@ -1078,7 +1080,7 @@
1078 1080
                     "type": "tidelift"
1079 1081
                 }
1080 1082
             ],
1081
-            "time": "2021-06-30T07:27:52+00:00"
1083
+            "time": "2021-07-21T12:40:44+00:00"
1082 1084
         },
1083 1085
         {
1084 1086
             "name": "symfony/polyfill-ctype",
@@ -3934,16 +3936,16 @@
3934 3936
         },
3935 3937
         {
3936 3938
             "name": "theseer/tokenizer",
3937
-            "version": "1.2.0",
3939
+            "version": "1.2.1",
3938 3940
             "source": {
3939 3941
                 "type": "git",
3940 3942
                 "url": "https://github.com/theseer/tokenizer.git",
3941
-                "reference": "75a63c33a8577608444246075ea0af0d052e452a"
3943
+                "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e"
3942 3944
             },
3943 3945
             "dist": {
3944 3946
                 "type": "zip",
3945
-                "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a",
3946
-                "reference": "75a63c33a8577608444246075ea0af0d052e452a",
3947
+                "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e",
3948
+                "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e",
3947 3949
                 "shasum": ""
3948 3950
             },
3949 3951
             "require": {
@@ -3972,7 +3974,7 @@
3972 3974
             "description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
3973 3975
             "support": {
3974 3976
                 "issues": "https://github.com/theseer/tokenizer/issues",
3975
-                "source": "https://github.com/theseer/tokenizer/tree/master"
3977
+                "source": "https://github.com/theseer/tokenizer/tree/1.2.1"
3976 3978
             },
3977 3979
             "funding": [
3978 3980
                 {
@@ -3980,7 +3982,7 @@
3980 3982
                     "type": "github"
3981 3983
                 }
3982 3984
             ],
3983
-            "time": "2020-07-12T23:59:07+00:00"
3985
+            "time": "2021-07-28T10:34:58+00:00"
3984 3986
         },
3985 3987
         {
3986 3988
             "name": "webmozart/assert",

+ 21
- 16
gazelle.sql View File

@@ -143,6 +143,20 @@ CREATE TABLE `badges` (
143 143
 ) ENGINE=InnoDB CHARSET=utf8mb4;
144 144
 
145 145
 
146
+-- 2021-07-28
147
+CREATE TABLE `bioinformatics` (
148
+  `id` int NOT NULL AUTO_INCREMENT,
149
+  `torrent_id` int NOT NULL,
150
+  `user_id` int NOT NULL,
151
+  `timestamp` datetime NOT NULL,
152
+  `name` varchar(255) DEFAULT NULL,
153
+  `seqhash` varchar(100) DEFAULT NULL,
154
+  `gc_content` tinyint DEFAULT NULL,
155
+  `monoisotopic_mass` double DEFAULT NULL,
156
+  PRIMARY KEY (`id`,`torrent_id`,`user_id`) 
157
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
158
+
159
+
146 160
 -- 2020-03-09
147 161
 CREATE TABLE `blog` (
148 162
   `ID` int unsigned NOT NULL AUTO_INCREMENT,
@@ -1241,23 +1255,14 @@ CREATE TABLE `torrents_recommended` (
1241 1255
 ) ENGINE=InnoDB CHARSET=utf8mb4;
1242 1256
 
1243 1257
 
1244
-CREATE TABLE `torrents_doi` (
1245
-  `ID` int NOT NULL AUTO_INCREMENT,
1246
-  `TorrentID` int NOT NULL,
1247
-  `UserID` int NOT NULL,
1248
-  `Time` datetime,
1249
-  `URI` varchar(255) NOT NULL,
1250
-  PRIMARY KEY (`ID`,`GroupID`,`URI`)
1251
-) ENGINE=InnoDB CHARSET=utf8mb4;
1252
-
1253
-
1258
+-- 2021-07-28
1254 1259
 CREATE TABLE `torrents_mirrors` (
1255
-  `ID` int NOT NULL AUTO_INCREMENT,
1256
-  `GroupID` int NOT NULL,
1257
-  `UserID` int NOT NULL,
1258
-  `Time` datetime,
1259
-  `URI` varchar(255) NOT NULL,
1260
-  PRIMARY KEY (`ID`,`GroupID`,`URI`)
1260
+  `id` int NOT NULL AUTO_INCREMENT,
1261
+  `torrent_id` int NOT NULL,
1262
+  `user_id` int NOT NULL,
1263
+  `timestamp` datetime,
1264
+  `uri` varchar(255) NOT NULL,
1265
+  PRIMARY KEY (`id`,`torrent_id`,`uri`)
1261 1266
 ) ENGINE=InnoDB CHARSET=utf8mb4;
1262 1267
 
1263 1268
 

+ 6
- 6
sections/torrents/editgroup.php View File

@@ -43,14 +43,14 @@ list($title, $subject, $object, $Image, $Body, $picture, $description, $publishe
43 43
 
44 44
 $DB->prepare_query("
45 45
 SELECT
46
-  `ID`,
47
-  `UserID`,
48
-  `Time`,
49
-  `URI`
46
+  `id`,
47
+  `user_id`,
48
+  `timestamp`,
49
+  `doi`
50 50
 FROM
51
-  `torrents_doi`
51
+  `literature`
52 52
 WHERE
53
-  `TorrentID` = '$group_id'
53
+  `group_id` = '$group_id'
54 54
 ");
55 55
 $DB->exec_prepared_query();
56 56
 

+ 12
- 11
sections/torrents/functions.php View File

@@ -58,14 +58,14 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
58 58
         # Screenshots (Publications)
59 59
         $DB->query("
60 60
         SELECT
61
-          `ID`,
62
-          `UserID`,
63
-          `Time`,
64
-          `URI`
61
+          `id`,
62
+          `user_id`,
63
+          `timestamp`,
64
+          `doi`
65 65
         FROM
66
-          `torrents_doi`
66
+          `literature`
67 67
         WHERE
68
-          `TorrentID` = '$GroupID'
68
+          `group_id` = '$GroupID'
69 69
         ");
70 70
 
71 71
         if ($DB->has_results()) {
@@ -75,16 +75,17 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
75 75
         }
76 76
 
77 77
         # Mirrors
78
+        # todo: Fix $GroupID
78 79
         $DB->query("
79 80
         SELECT
80
-          `ID`,
81
-          `UserID`,
82
-          `Time`,
83
-          `URI`
81
+          `id`,
82
+          `user_id`,
83
+          `timestamp`,
84
+          `resource`
84 85
         FROM
85 86
           `torrents_mirrors`
86 87
         WHERE
87
-          `GroupID` = '$GroupID'
88
+          `torrent_id` = '$GroupID'
88 89
         ");
89 90
   
90 91
         if ($DB->has_results()) {

+ 8
- 8
sections/torrents/screenshotedit.php View File

@@ -36,12 +36,12 @@ if (count($Screenshots) > 10) {
36 36
 
37 37
 $DB->query("
38 38
 SELECT
39
-  `UserID`,
40
-  `URI`
39
+  `user_id`,
40
+  `doi`
41 41
 FROM
42
-  `torrents_doi`
42
+  `literature`
43 43
 WHERE
44
-  `TorrentID` = '$GroupID'
44
+  `group_id` = '$GroupID'
45 45
 ");
46 46
 
47 47
 // $Old is an array of the form URL => UserID where UserID is the ID of the User who originally uploaded that image.
@@ -81,9 +81,9 @@ if (!empty($Deleted)) {
81 81
         $DB->prepare_query("
82 82
         DELETE
83 83
         FROM
84
-          `torrents_doi`
84
+          `literature`
85 85
         WHERE
86
-          `URI` = '$ScreenDel'
86
+          `doi` = '$ScreenDel'
87 87
         ");
88 88
 
89 89
         foreach ($DeleteList as $ScreenDel) {
@@ -100,8 +100,8 @@ if (!empty($New)) {
100 100
     $Screenshot = '';
101 101
     $DB->prepare_query(
102 102
         "
103
-    INSERT INTO `torrents_doi`
104
-      (`TorrentID`, `UserID`, `Time`, `URI`)
103
+    INSERT INTO `literature`
104
+      (`group_id`, `user_id`, `timestamp`, `doi`)
105 105
     VALUES
106 106
       (?, ?, NOW(), ?)",
107 107
         $GroupID,

+ 97
- 60
sections/upload/upload_handle.php View File

@@ -79,6 +79,7 @@ $Properties['GroupDescription'] = trim($_POST['album_desc']);
79 79
 $Properties['TorrentDescription'] = $_POST['release_desc'];
80 80
 $Properties['Screenshots'] = isset($_POST['screenshots']) ? $_POST['screenshots'] : '';
81 81
 $Properties['Mirrors'] = isset($_POST['mirrors']) ? $_POST['mirrors'] : '';
82
+$Properties['Seqhash'] = isset($_POST['seqhash']) ? $_POST['seqhash'] : '';
82 83
 
83 84
 if ($_POST['album_desc']) {
84 85
     $Properties['GroupDescription'] = trim($_POST['album_desc']);
@@ -209,7 +210,7 @@ if (!$_POST['groupid']) {
209 210
         '1',
210 211
         'inarray',
211 212
         'Please select a valid platform.',
212
-        array('inarray' => $ENV->flatten($ENV->META->Platforms))
213
+        array('inarray' => $ENV->META->Platforms)
213 214
     );
214 215
 
215 216
     /*
@@ -438,8 +439,8 @@ if ($T['GroupID']) {
438 439
     FROM
439 440
       `torrents_group`
440 441
     WHERE
441
-      `id` = $T[GroupID]
442
-    ");
442
+      `id` = ?
443
+    ", $T['GroupID']);
443 444
     $DB->exec_prepared_query();
444 445
 
445 446
     if ($DB->has_results()) {
@@ -516,7 +517,7 @@ if ((!isset($GroupID) || !$GroupID)) {
516 517
 
517 518
 if (!isset($GroupID) || !$GroupID) {
518 519
     // Create torrent group
519
-    $DB->prepare_query(
520
+    $DB->query(
520 521
         "
521 522
       INSERT INTO torrents_group
522 523
         (`category_id`, `title`, `subject`, `object`, `year`,
@@ -526,7 +527,7 @@ if (!isset($GroupID) || !$GroupID) {
526 527
         ( ?, ?, ?, ?, ?,
527 528
           ?, ?, ?, NOW(),
528 529
           ?, ? )",
529
-        $TypeID,
530
+        $T['CategoryID'],
530 531
         $T['Title'],
531 532
         $T['Title2'],
532 533
         $T['TitleJP'],
@@ -537,7 +538,6 @@ if (!isset($GroupID) || !$GroupID) {
537 538
         $Body,
538 539
         $T['Image']
539 540
     );
540
-    $DB->exec_prepared_query();
541 541
 
542 542
     $GroupID = $DB->inserted_id();
543 543
     foreach ($ArtistForm as $Num => $Artist) {
@@ -550,67 +550,33 @@ if (!isset($GroupID) || !$GroupID) {
550 550
     }
551 551
     $Cache->increment('stats_group_count');
552 552
 
553
-    // Add screenshots
554
-    // todo: Clear DB_MYSQL::exec_prepared_query() errors
555
-    $Screenshots = explode("\n", $T['Screenshots']);
556
-    $Screenshots = array_map('trim', $Screenshots);
557
-
558
-    $Screenshots = array_filter($Screenshots, function ($s) {
559
-        return preg_match('/^'.$ENV->DOI_REGEX.'$/i', $s);
560
-    });
561
-
562
-    $Screenshots = array_unique($Screenshots);
563
-    $Screenshots = array_slice($Screenshots, 0, 10);
564
-
565
-    # Add optional web seeds similar to screenshots
566
-    # Support an arbitrary and limited number of sources
567
-    $Mirrors = explode("\n", $T['Mirrors']);
568
-    $Mirrors = array_map('trim', $Mirrors);
569
-
570
-    $Mirrors = array_filter($Mirrors, function ($s) {
571
-        return preg_match('/^'.URL_REGEX.'$/i', $s);
572
-    });
573
-
574
-    $Mirrors = array_unique($Mirrors);
575
-    $Mirrors = array_slice($Mirrors, 0, 2);
576
-
577
-    # Downgrade TLS on resource URIs
578
-    # Required for BEP 19 compatibility
579
-    $Mirrors = str_ireplace('tps://', 'tp://', $Mirrors);
580
-
581
-    # Perform the DB inserts here
582
-    # Screenshots (Publications)
583
-    if (!empty($Screenshots)) {
584
-        $Screenshot = '';
585
-        $DB->prepare_query("
586
-          INSERT INTO torrents_doi
587
-            (TorrentID, UserID, Time, URI)
588
-          VALUES (?, ?, NOW(), ?)", $GroupID, $LoggedUser['ID'], $Screenshot);
589
-
590
-        foreach ($Screenshots as $Screenshot) {
591
-            $DB->exec_prepared_query();
592
-        }
593
-    }
594 553
 
595
-    # Mirrors
596
-    if (!empty($Mirrors)) {
597
-        $Mirror = '';
598
-        $DB->prepare_query("
599
-          INSERT INTO torrents_mirrors
600
-            (GroupID, UserID, Time, URI)
601
-          VALUES (?, ?, NOW(), ?)", $GroupID, $LoggedUser['ID'], $Mirror);
554
+    /**
555
+     * DOI numbers
556
+     *
557
+     * Add optional citation info.
558
+     * todo: Query Semantic Scholar in the scheduler.
559
+     * THESE ARE ASSOCIATED WITH TORRENT GROUPS.s
560
+     */
561
+    if (!empty($T['Screenshots'])) {
562
+        $Screenshots = $Validate->textarea2array($T['Screenshots'], $ENV->DOI_REGEX);
563
+        $Screenshots = array_slice($Screenshots, 0, 10);
602 564
 
603
-        foreach ($Mirrors as $Mirror) {
604
-            $DB->exec_prepared_query();
565
+        foreach ($Screenshots as $Screenshot) {
566
+            $DB->query("
567
+            INSERT INTO `literature`
568
+            (`group_id`, `user_id`, `timestamp`, `doi`)
569
+          VALUES (?, ?, NOW(), ?)", $GroupID, $LoggedUser['ID'], $Screenshot);
605 570
         }
606 571
     }
572
+}
607 573
 
608
-    # Main if/else
609
-} else {
574
+# Main if/else
575
+else {
610 576
     $DB->query("
611 577
       UPDATE torrents_group
612
-      SET Time = NOW()
613
-        WHERE ID = ?", $GroupID);
578
+      SET `timestamp` = NOW()
579
+        WHERE `id` = ?", $GroupID);
614 580
 
615 581
     $Cache->delete_value("torrent_group_$GroupID");
616 582
     $Cache->delete_value("torrents_details_$GroupID");
@@ -728,6 +694,77 @@ $TorrentID = $DB->inserted_id();
728 694
 $Cache->increment('stats_torrent_count');
729 695
 $Tor->Dec['comment'] = 'https://'.SITE_DOMAIN.'/torrents.php?torrentid='.$TorrentID;
730 696
 
697
+
698
+/**
699
+ * Mirrors
700
+ *
701
+ * Add optional web seeds and IPFS/Dat mirrors.
702
+ * Support an arbitrary and limited number of sources.
703
+ * THESE ARE ASSOCIATED WITH INDIVIDUAL TORRENTS.
704
+ */
705
+
706
+if (!empty($T['Mirrors'])) {
707
+    $Mirrors = $Validate->textarea2array($T['Mirrors'], $ENV->URL_REGEX);
708
+    $Screenshots = array_slice($Screenshots, 0, 5);
709
+
710
+    foreach ($Mirrors as $Mirror) {
711
+        $DB->query(
712
+            "
713
+        INSERT INTO torrents_mirrors
714
+          (`torrent_id`, `user_id`, `timestamp`, `uri`)
715
+        VALUES (?, ?, NOW(), ?)",
716
+            $TorrentID,
717
+            $LoggedUser['ID'],
718
+            $Mirror
719
+        );
720
+    }
721
+}
722
+
723
+
724
+/**
725
+ * Seqhash
726
+ *
727
+ * Elementary Seqhash support
728
+ */
729
+if ($ENV->FEATURE_BIOPHP && !empty($T['Seqhash'])) {
730
+    $BioIO = new \BioPHP\IO();
731
+    $BioSeqhash = new \BioPHP\Seqhash();
732
+
733
+    $Parsed = $BioIO->readFasta($T['Seqhash']);
734
+    foreach ($Parsed as $Parsed) {
735
+        try {
736
+            # todo: Trim sequences in \BioPHP\Transform->normalize()
737
+            $Trimmed = preg_replace('/\s+/', '', $Parsed['sequence']);
738
+            $Seqhash = $BioSeqhash->hash(
739
+                $Trimmed,
740
+                $_POST['seqhash_meta1'],
741
+                $_POST['seqhash_meta2'],
742
+                $_POST['seqhash_meta3']
743
+            );
744
+
745
+            $DB->query(
746
+                "
747
+            INSERT INTO `bioinformatics`
748
+              (`torrent_id`, `user_id`, `timestamp`,
749
+               `name`, `seqhash`)
750
+            VALUES (?, ?, NOW(), ?, ?)",
751
+                $TorrentID,
752
+                $LoggedUser['ID'],
753
+                $Parsed['name'],
754
+                $Seqhash
755
+            );
756
+        } catch (Exception $Err) {
757
+            $UploadForm = $Type;
758
+            require_once SERVER_ROOT.'/sections/upload/upload.php' ;
759
+            error($Err->getMessage(), $NoHTML = true);
760
+        }
761
+    }
762
+}
763
+
764
+
765
+/**
766
+ * Update tracker
767
+ */
731 768
 Tracker::update_tracker('add_torrent', [
732 769
   'id'          => $TorrentID,
733 770
   'info_hash'   => rawurlencode($InfoHash),

+ 2
- 2
sections/user/community_stats.php View File

@@ -162,8 +162,8 @@ list($UniqueGroups) = $DB->next_record();
162 162
   if ($Override = check_paranoia_here('screenshotcount')) {
163 163
       $DB->query("
164 164
     SELECT COUNT(*)
165
-    FROM torrents_doi
166
-    WHERE UserID = '$UserID'");
165
+    FROM `literature`
166
+    WHERE user_id = '$UserID'");
167 167
       list($Screenshots) = $DB->next_record(); ?>
168 168
                 <li id="comm_screenshots">Screenshots added: <?=number_format($Screenshots)?>
169 169
                 </li>

Loading…
Cancel
Save