BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

config.template 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * Environment
  5. * Config Loader v2
  6. *
  7. * To use the new system, which has significant security benefits,
  8. * (fine-grained scoping, ephemeral access lifetime, public vs. private, etc.),
  9. * please follow the example below.
  10. *
  11. * $ENV = ENV::go();
  12. * $ENV->PUBLIC_VALUE;
  13. * $ENV->getPriv('PRIVATE_VALUE');
  14. *
  15. * Using a central static $ENV singleton class has additional benefits.
  16. * The RecursiveArrayObject class included in env.class.php is a powerful tool:
  17. *
  18. * $LongArray = [];
  19. * ENV::setPub(
  20. * 'CONFIG',
  21. * new RecursiveArrayObject($LongArray)
  22. * );
  23. *
  24. * $ENV = ENV::go();
  25. * foreach ($ENV->CATS as $Cat) {
  26. * var_dump($Cat->Name);
  27. * }
  28. *
  29. * One more example using custom RecursiveArrayObject methods:
  30. * @see https://www.php.net/manual/en/class.arrayobject.php
  31. *
  32. * var_dump(
  33. * $ENV->dedupe(
  34. * $ENV->CATS->SEQ->Platforms,
  35. * $ENV->CATS->IMG->Platforms->toArray(),
  36. * [$MapVectorFormats, $MapRasterFormats, $PlainFormats]
  37. * )
  38. * );
  39. */
  40. # https://www.php.net/manual/en/language.oop5.autoload.php
  41. require_once 'env.class.php';
  42. # Initialize
  43. $ENV = ENV::go();
  44. ENV::setPub('PHP_MIN', '7.4.0');
  45. ENV::setPub('DEV', true);
  46. # Modern PHP
  47. if (version_compare($ENV->PHP_MIN, '7.4.0', '<')) {
  48. throw new Exception("Gazelle requires PHP > $ENV->PHP_MIN");
  49. }
  50. /**
  51. * Site identity
  52. */
  53. # Site name
  54. ENV::setPub(
  55. 'SITE_NAME',
  56. (!$ENV->DEV
  57. ? 'BioTorrents.de' # Production
  58. : '[Dev] BioTorrents.de') # Development
  59. );
  60. # Meta description
  61. ENV::setPub('DESCRIPTION', 'A platform to share biological sequence and medical imaging data');
  62. # Navigation glyphs
  63. ENV::setPub('SEP', '⸬'); # e.g., News ⸬ BioTorrents.de
  64. ENV::setPub('CRUMB', '›'); # e.g., Forums › Board › Thread
  65. # The FQDN of your site, e.g., dev.biotorrents.de
  66. ( # Old format
  67. !$ENV->DEV
  68. ? define('SITE_DOMAIN', 'biotorrents.de') # Production
  69. : define('SITE_DOMAIN', 'dev.biotorrents.de') # Development
  70. );
  71. ENV::setPub(
  72. 'SITE_DOMAIN',
  73. (!$ENV->DEV
  74. ? 'biotorrents.de' # Production
  75. : 'dev.biotorrents.de') # Development
  76. );
  77. # The FQDN of your image host, e.g., pics.biotorrents.de
  78. ENV::setPub('IMAGE_DOMAIN', 'pics.biotorrents.de');
  79. # The root of the server, used for includes, e.g., /var/www/html/dev.biotorrents.de/
  80. ( # Old format
  81. !$ENV->DEV
  82. ? define('SERVER_ROOT', '/var/www/html/biotorrents.de/') # Production
  83. : define('SERVER_ROOT', '/var/www/html/dev.biotorrents.de/') # Development
  84. );
  85. ENV::setPub(
  86. 'SERVER_ROOT',
  87. (!$ENV->DEV
  88. ? '/var/www/html/biotorrents.de/' # Production
  89. : '/var/www/html/dev.biotorrents.de/') # Development
  90. );
  91. # Where torrent files are stored, e.g., /var/www/torrents-dev/
  92. ( # Old format
  93. !$ENV->DEV
  94. ? define('TORRENT_STORE', '/var/www/torrents/') # Production
  95. : define('TORRENT_STORE', '/var/www/torrents-dev/') # Development
  96. );
  97. ENV::setPub(
  98. 'TORRENT_STORE',
  99. (!$ENV->DEV
  100. ? '/var/www/torrents/' # Production
  101. : '/var/www/torrents-dev/') # Development);
  102. );
  103. # Allows you to run static content off another server. Default is usually what you want
  104. define('STATIC_SERVER', '/static/');
  105. ENV::setPub('STATIC_SERVER', '/static/');
  106. # The hashing algorithm used for SRI
  107. ENV::setPub('SRI', 'sha384');
  108. /**
  109. * Tech support
  110. */
  111. $TechSupport = [
  112. 'Email' => 'help@biotorrents.de',
  113. 'Subject' => '[TxID '.strtoupper(bin2hex(random_bytes(2))).'] Specific subject line with TxID intact',
  114. 'Body' => 'A detailed description of how you reach the error and the full text of any site messages you may receive.'
  115. ];
  116. ENV::setPub(
  117. 'HELP',
  118. new RecursiveArrayObject($TechSupport)
  119. );
  120. /**
  121. * App keys
  122. *
  123. * Separate keys for development and production.
  124. * Increased security and protection against config overwrites.
  125. */
  126. # Pre-shared key for generating hmacs for the image proxy
  127. ENV::setPriv('IMAGE_PSK', '00000000000000000000000000000000');
  128. # Production
  129. if (!$ENV->DEV) {
  130. # Unused in OT Gazelle. Currently used for API token auth
  131. ENV::setPriv('ENCKEY', '00000000000000000000000000000000');
  132. # Alphanumeric random key. This key must be the argument to schedule.php for the schedule to work
  133. ENV::setPriv('SCHEDULE_KEY', '00000000000000000000000000000000');
  134. # Random key. Used for generating unique RSS auth key
  135. ENV::setPriv('RSS_HASH', '00000000000000000000000000000000');
  136. }
  137. # Development
  138. else {
  139. ENV::setPriv('ENCKEY', '00000000000000000000000000000000');
  140. ENV::setPriv('SCHEDULE_KEY', '00000000000000000000000000000000');
  141. ENV::setPriv('RSS_HASH', '00000000000000000000000000000000');
  142. }
  143. /**
  144. * Database
  145. */
  146. # Common info
  147. ENV::setPriv('SQLHOST', 'localhost');
  148. ENV::setPriv('SQLSOCK', '/var/run/mysqld/mysqld.sock');
  149. ENV::setPriv('SQLPORT', 3306);
  150. # Production
  151. if (!$ENV->DEV) {
  152. ENV::setPriv('SQLDB', 'gazelle_production');
  153. ENV::setPriv('SQLLOGIN', 'gazelle_production');
  154. ENV::setPriv('SQLPASS', '00000000000000000000000000000000');
  155. }
  156. # Development
  157. else {
  158. ENV::setPriv('SQLDB', 'gazelle_development');
  159. ENV::setPriv('SQLLOGIN', 'gazelle_development');
  160. ENV::setPriv('SQLPASS', '00000000000000000000000000000000');
  161. }
  162. /**
  163. * Tracker
  164. */
  165. # Ocelot connection, e.g., 0.0.0.0
  166. ENV::setPriv('TRACKER_HOST', '0.0.0.0');
  167. # Production
  168. if (!$ENV->DEV) {
  169. ENV::setPriv('TRACKER_PORT', 34000);
  170. # Must be 32 alphanumeric characters and match site_password in ocelot.conf
  171. ENV::setPriv('TRACKER_SECRET', '00000000000000000000000000000000');
  172. # Must be 32 alphanumeric characters and match report_password in ocelot.conf
  173. ENV::setPriv('TRACKER_REPORTKEY', '00000000000000000000000000000000');
  174. }
  175. # Development
  176. else {
  177. ENV::setPriv('TRACKER_PORT', 34001);
  178. ENV::setPriv('TRACKER_SECRET', '00000000000000000000000000000000');
  179. ENV::setPriv('TRACKER_REPORTKEY', '00000000000000000000000000000000');
  180. }
  181. /**
  182. * Tracker URLs
  183. *
  184. * Added to torrents à la http://bittorrent.org/beps/bep_0012.html
  185. */
  186. # Production
  187. if (!$ENV->DEV) {
  188. define('ANNOUNCE_URLS', [
  189. [ # Tier 1
  190. 'https://track.biotorrents.de:443',
  191. ], [] # Tier 2
  192. ]);
  193. $AnnounceURLs = [
  194. [ # Tier 1
  195. 'https://track.biotorrents.de:443',
  196. ],
  197. [ # Tier 2
  198. #'udp://tracker.coppersurfer.tk:6969/announce',
  199. #'udp://tracker.cyberia.is:6969/announce',
  200. #'udp://tracker.leechers-paradise.org:6969/announce',
  201. ],
  202. ];
  203. ENV::setPub(
  204. 'ANNOUNCE_URLS',
  205. new RecursiveArrayObject($AnnounceURLs)
  206. );
  207. }
  208. # Development
  209. else {
  210. define('ANNOUNCE_URLS', [
  211. [ # Tier 1
  212. 'https://trx.biotorrents.de:443',
  213. ], [] # Tier 2
  214. ]);
  215. $AnnounceURLs = [
  216. [ # Tier 1
  217. 'https://trx.biotorrents.de:443',
  218. ], [], # Tier 2
  219. ];
  220. ENV::setPub(
  221. 'ANNOUNCE_URLS',
  222. new RecursiveArrayObject($AnnounceURLs)
  223. );
  224. }
  225. /**
  226. * Search
  227. */
  228. # SphinxqlQuery needs constants
  229. # $ENV breaks the torrent and request pages
  230. define('SPHINXQL_HOST', '127.0.0.1');
  231. define('SPHINXQL_PORT', 9306);
  232. define('SPHINXQL_SOCK', false);
  233. define('SPHINX_MAX_MATCHES', 1000); // Must be <= the server's max_matches variable (default 1000)
  234. /**
  235. * memcached
  236. *
  237. * Very important to run two instances,
  238. * one each for development and production.
  239. */
  240. # Production
  241. if (!$ENV->DEV) {
  242. ENV::setPriv(
  243. 'MEMCACHED_SERVERS',
  244. [[
  245. 'host' => 'unix:///var/run/memcached/memcached.sock',
  246. 'port' => 0,
  247. 'buckets' => 1
  248. ]]
  249. );
  250. }
  251. # Development
  252. else {
  253. ENV::setPriv(
  254. 'MEMCACHED_SERVERS',
  255. [[
  256. 'host' => 'unix:///var/run/memcached/memcached-dev.sock',
  257. 'port' => 0,
  258. 'buckets' => 1
  259. ]]
  260. );
  261. }
  262. /**
  263. * IRC/Slack
  264. */
  265. # IRC server address. Used for onsite chat tool
  266. define('BOT_SERVER', 'irc.'.SITE_DOMAIN);
  267. define('SOCKET_LISTEN_ADDRESS', 'localhost');
  268. define('SOCKET_LISTEN_PORT', 51010);
  269. define('BOT_NICK', 'ebooks');
  270. # IRC channels for official business
  271. define('ANNOUNCE_CHAN', '#announce');
  272. define('DEBUG_CHAN', '#debug');
  273. define('REQUEST_CHAN', '#requests');
  274. define('STAFF_CHAN', '#staff');
  275. define('ADMIN_CHAN', '#staff');
  276. define('HELP_CHAN', '#support');
  277. define('DISABLED_CHAN', '#support');
  278. #define('BOT_CHAN', '#userbots');
  279. # Slack invite link
  280. ENV::setPub(
  281. 'SLACK_INVITE',
  282. '00000000000000000000000000000000'
  283. );
  284. /**
  285. * ================
  286. * = NO MORE =
  287. * = PRIVATE INFO =
  288. * ================
  289. */
  290. /**
  291. * Features
  292. */
  293. # Enable donation page
  294. ENV::setPub('FEATURE_DONATE', true);
  295. # Send re-enable requests to user's email
  296. define('FEATURE_EMAIL_REENABLE', true); //
  297. ENV::setPub('FEATURE_EMAIL_REENABLE', true);
  298. # Require users to verify login from unknown locations
  299. ENV::setPub('FEATURE_ENFORCE_LOCATIONS', false);
  300. # Attempt to send messages to IRC
  301. ENV::setPub('FEATURE_IRC', true);
  302. # Attempt to send email from the site
  303. ENV::setPub('FEATURE_SEND_EMAIL', true);
  304. # Allow the site encryption key to be set without an account
  305. # (should only be used for initial setup)
  306. ENV::setPub('FEATURE_SET_ENC_KEY_PUBLIC', false);
  307. /**
  308. * Settings
  309. */
  310. # Set to false if you don't want everyone to see debug information; can be overriden with 'site_debug'
  311. define('DEBUG_MODE', false);
  312. ENV::setPub('DEBUG_MODE', false);
  313. # Set to false to disable open registration, true to allow anyone to register
  314. ENV::setPub(
  315. 'OPEN_REGISTRATION',
  316. (!$ENV->DEV
  317. ? true # Production
  318. : false) # Development
  319. );
  320. # The maximum number of users the site can have, 0 for no limit
  321. define('USER_LIMIT', 0);
  322. ENV::setPub('USER_LIMIT', 0);
  323. # User perks
  324. ENV::setPub('STARTING_INVITES', 2);
  325. ENV::setPub('STARTING_TOKENS', 2);
  326. ENV::setPub('STARTING_UPLOAD', 5368709120);
  327. ENV::setPub('DONOR_INVITES', 2);
  328. # Bonus Points
  329. define('BONUS_POINTS', 'Bonus Points');
  330. ENV::setPub('BONUS_POINTS', 'Bonus Points');
  331. ENV::setPub('BP_COEFF', 1.5); # OT default 0.5
  332. # Tag namespaces (configurable via CSS selectors)
  333. #define('TAG_NAMESPACES', ['male', 'female', 'parody', 'character']);
  334. # Banned stuff (file characters, browsers, etc.)
  335. ENV::setPub(
  336. 'BAD_CHARS',
  337. ['"', '*', '/', ':', '<', '>', '?', '\\', '|']
  338. );
  339. # Set to true to block Opera Mini proxy
  340. ENV::setPub('BLOCK_OPERA_MINI', true);
  341. # Misc stuff like generic reusable snippets
  342. # Example of a variable using heredoc syntax
  343. ENV::setPub(
  344. 'PASSWORD_ADVICE',
  345. <<<HTML
  346. <p>
  347. Any password 15 characters or longer is accepted, but a strong password
  348. <ul>
  349. <li>is a pass<em>phrase</em> of mixed case with many small words,</li>
  350. <li>that contains complex characters including Unicode and emoji.</li>
  351. </ul>
  352. </p>
  353. HTML
  354. );
  355. /**
  356. * Services
  357. *
  358. * Public APIs, domains, etc.
  359. * Not intended for private API keys.
  360. */
  361. # Current Sci-Hub domains
  362. # https://lovescihub.wordpress.com
  363. define('SCI_HUB', 'se');
  364. ENV::setPub(
  365. 'SCI_HUB',
  366. ['ren', 'tw', 'se']
  367. );
  368. # Semantic Scholar
  369. # https://api.semanticscholar.org
  370. ENV::setPub(
  371. 'SS',
  372. [
  373. 'Paper' => 'https://api.semanticscholar.org/v1/paper/',
  374. 'Author' => 'https://api.semanticscholar.org/v1/author/',
  375. ]
  376. );
  377. /**
  378. * User class IDs
  379. *
  380. * Needed for automatic promotions.
  381. * Found in the `permissions` table.
  382. */
  383. # Name of class Class ID (not level)
  384. define('ADMIN', '1');
  385. define('USER', '2');
  386. define('MEMBER', '3');
  387. define('POWER', '4');
  388. define('ELITE', '5');
  389. define('LEGEND', '8');
  390. define('MOD', '11');
  391. define('SYSOP', '15');
  392. define('ARTIST', '19');
  393. define('DONOR', '20');
  394. define('VIP', '21');
  395. define('TORRENT_MASTER', '23');
  396. define('POWER_TM', '24');
  397. define('FLS_TEAM', '33');
  398. define('FORUM_MOD', '9001');
  399. /**
  400. * Forums
  401. */
  402. define('STAFF_FORUM', 3);
  403. define('DONOR_FORUM', 7);
  404. ENV::setPub('TRASH_FORUM', 8);
  405. ENV::setPub('ANNOUNCEMENT_FORUM', 1);
  406. ENV::setPub('SUGGESTIONS_FORUM', 2);
  407. # Pagination
  408. define('TORRENT_COMMENTS_PER_PAGE', 10);
  409. define('POSTS_PER_PAGE', 25);
  410. define('TOPICS_PER_PAGE', 50);
  411. define('TORRENTS_PER_PAGE', 50);
  412. define('REQUESTS_PER_PAGE', 25);
  413. define('MESSAGES_PER_PAGE', 25);
  414. define('LOG_ENTRIES_PER_PAGE', 50);
  415. # Cache catalogues
  416. define('THREAD_CATALOGUE', 500); // Limit to THREAD_CATALOGUE posts per cache key
  417. # Miscellaneous values
  418. define('MAX_RANK', 6);
  419. define('MAX_EXTRA_RANK', 8);
  420. define('MAX_SPECIAL_RANK', 3);
  421. ENV::setPub('DONOR_FORUM_RANK', 6);
  422. /**
  423. * Ratio and badges
  424. */
  425. # Ratio requirements, in descending order
  426. define('RATIO_REQUIREMENTS', [
  427. # Downloaded Req (0% seed) Req (100% seed)
  428. [200 * 1024**3, 0.60, 0.60],
  429. [160 * 1024**3, 0.60, 0.50],
  430. [120 * 1024**3, 0.50, 0.40],
  431. [100 * 1024**3, 0.40, 0.30],
  432. [80 * 1024**3, 0.30, 0.20],
  433. [60 * 1024**3, 0.20, 0.10],
  434. [40 * 1024**3, 0.15, 0.00],
  435. [20 * 1024**3, 0.10, 0.00],
  436. [10 * 1024**3, 0.05, 0.00],
  437. ]);
  438. # God I wish I didn't have to do this but I just don't care anymore
  439. $AutomatedBadgeIDs = [
  440. 'DL' => [
  441. '8' => 10,
  442. '16' => 11,
  443. '32' => 12,
  444. '64' => 13,
  445. '128' => 14,
  446. '256' => 15,
  447. '512' => 16,
  448. '1024' => 17,
  449. '2048' => 18,
  450. ],
  451. 'UL' => [
  452. '16' => 20,
  453. '32' => 21,
  454. '64' => 22,
  455. '128' => 23,
  456. '256' => 24,
  457. '512' => 25,
  458. '1024' => 26,
  459. '2048' => 27,
  460. '4096' => 28,
  461. ],
  462. 'Posts' => [
  463. '5' => 30,
  464. '10' => 31,
  465. '25' => 32,
  466. '50' => 33,
  467. '100' => 34,
  468. '250' => 35,
  469. '500' => 36,
  470. '1000' => 37,
  471. '2500' => 38,
  472. ]
  473. ];
  474. ENV::setPub(
  475. 'AUTOMATED_BADGE_IDS',
  476. new RecursiveArrayObject($AutomatedBadgeIDs)
  477. );
  478. /**
  479. * Metadata abstraction map
  480. *
  481. * A set of 'label' → $DB->query() mappings.
  482. * The database should store generic data, e.g.,
  483. * - Title1, Title2, Title3
  484. * - Creator, Affiliation, Location
  485. *
  486. * Then Gazelle's job is to map text labels over the fields in HTML.
  487. * So $Input->Print($ID = $ENV->Creator) would print an Author form input.
  488. *
  489. * The structure:
  490. * $ENV->DBMAP =
  491. * (DatabaseField
  492. * ->(
  493. * Label->TextLabel,
  494. * OldField->Oppaitime,
  495. * )
  496. * );
  497. *
  498. * An example:
  499. * $Title1 = $ENV->DBMAP->Title1;
  500. * $ElementID =
  501. * strtolower($Title1->Label)
  502. * . '_class_label_'
  503. * . $InstanceID;
  504. */
  505. $DB = [
  506. 'AccessionNumber' => [
  507. 'Label' => 'Accession Number',
  508. 'Selector' => ['DOI' => 'javdb', 'RefSeq' => 'anidb', 'UniProt' => 'ehentai'],
  509. 'OldField' => 'CatalogueNumber',
  510. 'Description' => 'RefSeq and UniProt preferred',
  511. ],
  512. 'Title1' => [
  513. 'Label' => 'Torrent Title',
  514. 'Selector' => ['title'],
  515. 'OldField' => 'Name',
  516. 'Description' => 'Definition line, e.g., Alcohol dehydrogenase ADH1',
  517. ],
  518. 'Title2' => [
  519. 'Label' => 'Organism',
  520. 'Selector' => ['DOI' => 'javdb_tr', 'RefSeq' => 'anidb_tr', 'UniProt' => 'ehentai_tr'],
  521. 'OldField' => 'NameRJ',
  522. 'Description' => 'Organism line binomial, e.g., Saccharomyces cerevisiae',
  523. ],
  524. 'Title3' => [
  525. 'Label' => 'Strain/Variety',
  526. 'Selector' => ['DOI' => 'javdb_tr', 'RefSeq' => 'anidb_tr', 'UniProt' => 'ehentai_tr'],
  527. 'OldField' => 'NameJP',
  528. 'Description' => 'Organism line if any, e.g., S288C',
  529. ],
  530. # etc.
  531. ];
  532. ENV::setPub(
  533. 'META',
  534. new RecursiveArrayObject($DB)
  535. );
  536. /**
  537. * Site Categories
  538. * v2 modular ontology
  539. */
  540. # Main Categories
  541. # Old OT Gazelle format
  542. # https://www.ncbi.nlm.nih.gov/books/NBK25464/
  543. $Categories = [
  544. 'Sequences',
  545. 'Graphs',
  546. 'Systems',
  547. 'Geometric',
  548. 'Scalars/Vectors',
  549. 'Patterns',
  550. 'Constraints',
  551. 'Images',
  552. 'Spatial',
  553. 'Models',
  554. 'Documents',
  555. 'Machine Data',
  556. ];
  557. $GroupedCategories = $Categories;
  558. # Plain Formats
  559. $PlainFormats = [
  560. 'CSV' => ['csv'],
  561. 'JSON' => ['json'],
  562. 'Text' => ['txt'],
  563. 'XML' => ['xml'],
  564. 'Other' => [''],
  565. ];
  566. /**
  567. * Sequences
  568. */
  569. # Platforms
  570. $SeqPlatforms = [
  571. # DNA
  572. 'Complete Genomics',
  573. 'cPAS-BGI/MGI',
  574. 'Helicos',
  575. 'Illumina HiSeq',
  576. 'Illumina MiSeq',
  577. 'Ion Torrent',
  578. 'Microfluidics',
  579. 'Nanopore',
  580. 'PacBio',
  581. 'Roche 454',
  582. 'Sanger',
  583. 'SOLiD',
  584. # RNA, Protein, etc.
  585. 'De Novo',
  586. 'HPLC',
  587. 'Mass Spec',
  588. 'RNA-Seq',
  589. 'Other',
  590. ];
  591. # Sequence Formats
  592. # https://www.ncbi.nlm.nih.gov/sra/docs/submitformats/
  593. $SeqFormats = [
  594. 'BAM' => ['bam'],
  595. 'CRAM' => ['cram'],
  596. 'EMBL' => ['embl'],
  597. 'FASTA' => ['fa', 'fasta', 'fsa'],
  598. 'FASTA+QUAL' => ['qual'],
  599. 'CSFASTA' => ['csfa', 'csfasta', 'csfsa'],
  600. 'FASTQ' => ['fastq', 'fq', 'sanfastq'],
  601. 'GFF' => ['gff', 'gff2', 'gff3'],
  602. 'GTF' => ['gtf'],
  603. 'GenBank' => ['gb', 'gbk', 'genbank'],
  604. 'HDF5' => ['bash5', 'baxh5', 'fast5', 'h5', 'hdf5'],
  605. 'PIR' => ['pir'],
  606. 'QSeq' => ['qseq'],
  607. 'SAM' => ['sam'],
  608. 'SFF' => ['sff'],
  609. 'SRF' => ['srf'],
  610. 'SnapGene' => ['dna', 'seq'],
  611. 'SwissProt' => ['dat'],
  612. 'VCF' => ['vcf'],
  613. ];
  614. # Protein Formats
  615. # DON'T PARSE RAW FILES. TOO MANY COMPETING VENDORS
  616. # https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3518119/
  617. $ProtFormats = [
  618. 'ABI/Sciex' => ['t2d', 'wiff'],
  619. 'APML' => ['apml'],
  620. 'ASF' => ['asf'],
  621. 'Agilent/Bruker' => ['baf', 'd', 'fid', 'tdf', 'yep'],
  622. 'BlibBuild' => ['blib'],
  623. 'Bruker/Varian' => ['sms', 'xms'],
  624. 'Finnigan' => ['dat', 'ms'],
  625. 'ION-TOF' => ['ita', 'itm'],
  626. 'JCAMP-DX' => ['jdx'],
  627. 'MGF' => ['mgf'],
  628. 'MS2' => ['ms2'],
  629. 'MSF' => ['msf'],
  630. 'mzData' => ['mzdata'],
  631. 'mzML' => ['mzml'],
  632. 'mzXML' => ['mzxml'],
  633. 'OMSSA' => ['omssa', 'omx'],
  634. 'PEFF' => ['peff'],
  635. 'pepXML' => ['pepxml'],
  636. 'protXML' => ['protxml'],
  637. 'Shimadzu' => ['lcd', 'qgd', 'spc'],
  638. 'Skyline' => ['sky', 'skyd'],
  639. 'TPP/SPC' => ['dta'],
  640. 'Tandem' => ['tandem'],
  641. 'TraML' => ['traml'],
  642. 'ULVAC-PHI' => ['tdc'],
  643. ];
  644. /**
  645. * Graphs
  646. */
  647. # Graph Platforms
  648. # https://en.wikipedia.org/wiki/Graph_drawing#Software
  649. $GraphPlatforms = [
  650. 'BioFabric',
  651. 'BioTapestry',
  652. 'Cytoscape',
  653. 'Edraw Max',
  654. 'GenMAPP',
  655. 'Gephi',
  656. 'graph-tool',
  657. 'Graphviz',
  658. 'InCroMAP',
  659. 'LaNet-vi',
  660. 'Linkurious',
  661. 'MATLAB',
  662. 'MEGA',
  663. 'Maple',
  664. 'Mathematica',
  665. #'Microsoft Automatic Graph Layout',
  666. 'NetworkX',
  667. 'Other',
  668. 'PGF/TikZ',
  669. 'PathVisio',
  670. 'Pathview',
  671. 'R',
  672. 'Systrip',
  673. 'Tom Sawyer Software',
  674. 'Tulip',
  675. 'yEd',
  676. ];
  677. # XML Graph Formats
  678. $GraphXmlFormats = [
  679. 'DGML' => ['dgml'],
  680. 'DotML' => ['dotml'],
  681. 'GEXF' => ['gexf'],
  682. 'GXL' => ['gxl'],
  683. 'GraphML' => ['graphml'],
  684. 'XGMML' => ['xgmml'],
  685. ];
  686. # Text Graph Formats
  687. $GraphTxtFormats = [
  688. 'DOT' => ['gv'],
  689. 'GML' => ['gml'],
  690. 'LCF' => ['lcf'],
  691. 'Newick' => ['xsd', 'sgf'],
  692. 'SIF' => ['sif'],
  693. 'TGF' => ['tgf'],
  694. ];
  695. /**
  696. * Images
  697. */
  698. # Image Platforms
  699. $ImgPlatforms = [
  700. 'CT/CAT',
  701. 'ECG',
  702. 'Elastography',
  703. 'FNIR/NIRS',
  704. 'MPI',
  705. 'MRI/NMR',
  706. 'Microscopy',
  707. 'Photoacoustic',
  708. 'Photography',
  709. 'Scint/SPECT/PET',
  710. 'Ultrasound',
  711. 'X-Rays',
  712. 'Other',
  713. ];
  714. # Image Formats
  715. # https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3948928/
  716. $ImgFormats = [
  717. 'Analyze' => ['hdr', 'img'],
  718. 'Interfile' => ['h33'],
  719. 'DICOM' => ['dcm', 'dicom'],
  720. 'HDF5' => ['bash5', 'baxh5', 'fast5', 'h5', 'hdf5'],
  721. 'NIfTI' => ['nii', 'nifti'],
  722. 'MINC' => ['minc', 'mnc'],
  723. 'JPEG' => ['jfif', 'jpeg', 'jpg'],
  724. 'JPEG 2000' => ['j2k', 'jp2', 'jpf', 'jpm', 'jpx', 'mj2'],
  725. 'PNG' => ['png'],
  726. 'TIFF' => ['tif', 'tiff'],
  727. 'WebP' => ['webp'],
  728. ];
  729. /**
  730. * Spatial
  731. */
  732. # Vector Map Formats
  733. $MapVectorFormats = [
  734. 'AutoCAD DXF' => ['dxf'],
  735. 'Cartesian (XYZ)' => ['xyz'],
  736. 'DLG' => ['dlg'],
  737. 'Esri TIN' => ['adf', 'dbf'],
  738. 'GML' => ['gml'],
  739. 'GeoJSON' => ['geojson'],
  740. 'ISFC' => ['isfc'],
  741. 'KML' => ['kml', 'kmzv'],
  742. # DAT omitted
  743. # https://en.wikipedia.org/wiki/MapInfo_TAB_format
  744. 'MapInfo TAB' => ['tab', 'ind', 'map', 'id'],
  745. 'Measure Map Pro' => ['mmp'],
  746. 'NTF' => ['ntf'],
  747. # DBF omitted
  748. # https://en.wikipedia.org/wiki/Shapefile
  749. 'Shapefile' => ['shp', 'shx'],
  750. 'Spatial Data File' => ['sdf', 'sdf3', 'sif', 'kif'],
  751. 'SOSI' => ['sosi'],
  752. 'SVG' => ['svg'],
  753. 'TIGER' => ['tiger'],
  754. 'VPF' => ['vpf'],
  755. ];
  756. # Raster Map Formats
  757. $MapRasterFormats = [
  758. 'ADRG' => ['adrg'],
  759. 'Binary' => ['bsq', 'bip', 'bil'],
  760. 'DRG' => ['drg'],
  761. 'ECRG' => ['ecrg'],
  762. 'ECW' => ['ecw'],
  763. # DAT and ASC omitted (common)
  764. # https://support.esri.com/en/technical-article/000008526
  765. # https://web.archive.org/web/20150128024528/http://docs.codehaus.org/display/GEOTOOLS/ArcInfo+ASCII+Grid+format
  766. 'Esri Grid' => ['adf', 'nit', 'asc', 'grd'],
  767. 'GeoTIFF' => ['tfw'],
  768. #'IMG' => ['img'],
  769. #'JPEG 2000' => ['j2k', 'jp2', 'jpf', 'jpm', 'jpx', 'mj2'],
  770. 'MrSID' => ['sid'],
  771. 'netCDF' => ['nc'],
  772. 'RPF' => ['cadrg', 'cib'],
  773. ];
  774. /**
  775. * Documents
  776. */
  777. $DocPlatforms = [
  778. # Composed
  779. 'Literature',
  780. 'Software',
  781. # Generated
  782. 'Kernel',
  783. 'Metadata',
  784. 'Notebook',
  785. 'Other',
  786. ];
  787. # Binary Document Formats
  788. # https://en.wikipedia.org/wiki/OpenDocument
  789. # https://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensions
  790. $BinDocFormats = [
  791. 'OpenDocument' => ['odt', 'fodt', 'ods', 'fods', 'odp', 'fodp', 'odg', 'fodg', 'odf'],
  792. 'Word' => ['doc', 'dot', 'wbk', 'docx', 'docm', 'dotx', 'dotm', 'docb'],
  793. 'PowerPoint' => ['ppt', 'pot', 'pps', 'pptx', 'pptm', 'potx', 'potm', 'ppam', 'ppsx', 'ppsm', 'sldx', 'sldm'],
  794. 'Excel' => ['xls', 'xlt', 'xlm', 'xlsx', 'xlsm', 'xltx', 'xltm', 'xlsb', 'xla', 'xlam', 'xll', 'xlw'],
  795. 'PDF' => ['pdf', 'fdf', 'xfdf'],
  796. ];
  797. # Extra Formats
  798. # DON'T PARSE IMG OR ISO FILES
  799. # https://en.wikipedia.org/wiki/Disk_image#File_formats
  800. # http://dcjtech.info/topic/python-file-extensions/
  801. $CpuGenFormats = [
  802. 'Docker' => ['dockerfile'],
  803. 'Hard Disk' => ['fvd', 'dmg', 'esd', 'qcow', 'qcow2', 'qcow3', 'smi', 'swm', 'vdi', 'vhd', 'vhdx', 'vmdk', 'wim'],
  804. 'Optical Disc' => ['bin', 'ccd', 'cso', 'cue', 'daa', 'isz', 'mdf', 'mds', 'mdx', 'nrg', 'uif'],
  805. 'Python' => ['pxd', 'py', 'py3', 'pyc', 'pyd', 'pyde', 'pyi', 'pyo', 'pyp', 'pyt', 'pyw', 'pywz', 'pyx', 'pyz', 'rpy', 'xpy'],
  806. 'Jupyter' => ['ipynb'],
  807. 'Ontology' => ['cgif', 'cl', 'clif', 'csv', 'htm', 'html', 'kif', 'obo', 'owl', 'rdf', 'rdfa', 'rdfs', 'rif', 'tsv', 'xcl', 'xht', 'xhtml', 'xml'],
  808. ];
  809. /**
  810. * Machine Data
  811. */
  812. $RawPlatforms = [
  813. 'Binary',
  814. 'Text',
  815. ];
  816. # Archives
  817. $Archives = [
  818. '7z' => ['7z'],
  819. 'bzip2' => ['bz2', 'bzip2'],
  820. 'gzip' => ['gz', 'gzip', 'tgz', 'tpz'],
  821. 'Pickle' => ['pickle', 'pkl'],
  822. 'RAR' => ['rar', 'rev'],
  823. 'tar' => ['tar'],
  824. 'ZIP' => ['zip', 'zipx'],
  825. 'None' => [''],
  826. ];
  827. # Licenses
  828. $Codecs = [
  829. 'BSD-2',
  830. 'BSD-3',
  831. 'CC BY',
  832. 'CC BY-SA',
  833. 'CC BY-ND',
  834. 'CC BY-NC',
  835. 'CC BY-NC-SA',
  836. 'CC BY-NC-ND',
  837. 'GNU GPL',
  838. 'GNU LGPL',
  839. 'GNU AGPL',
  840. 'GNU FDL',
  841. 'MIT',
  842. 'ODC-By',
  843. 'ODC-ODbL',
  844. 'OpenMTA',
  845. 'Public Domain',
  846. 'Unspecified',
  847. 'Other',
  848. ];
  849. # Resolutions
  850. $Resolutions = [
  851. 'Nano',
  852. 'Micro',
  853. 'Milli',
  854. 'Centi',
  855. 'Kilo',
  856. 'Mega',
  857. 'Giga',
  858. 'Tera',
  859. ];
  860. $SeqResolutions = [
  861. 'Contig',
  862. 'Scaffold',
  863. 'Chromosome',
  864. 'Genome',
  865. 'Proteome',
  866. 'Transcriptome',
  867. ];
  868. $LocResolutions = [
  869. 'Organization',
  870. 'Locality',
  871. 'State',
  872. 'Province',
  873. 'Country',
  874. 'Continent',
  875. 'World',
  876. ];
  877. $XmlResolutions = [
  878. 'Value',
  879. 'Attribute',
  880. 'Group',
  881. 'Element',
  882. 'Schema',
  883. ];
  884. $ScalarResolutions = [
  885. 'Area',
  886. 'Density',
  887. 'Distance',
  888. 'Energy',
  889. 'Mass',
  890. 'Speed',
  891. 'Temperature',
  892. 'Time',
  893. 'Volume',
  894. 'Work',
  895. ];
  896. $VectorResolutions = [
  897. 'Acceleration',
  898. 'Displacement',
  899. 'Force',
  900. 'Polarization',
  901. 'Momentum',
  902. 'Position',
  903. 'Thrust',
  904. 'Velocity',
  905. 'Weight',
  906. ];
  907. # Collage categories
  908. $CollageCats = [
  909. 0 => 'Personal',
  910. 1 => 'Theme',
  911. 2 => 'Staff Picks',
  912. 3 => 'Group Picks',
  913. ];
  914. /**
  915. * Now for the good stuff.
  916. * The short names are for convenience.
  917. * It should be easy enough to find and replace,
  918. * e.g., if you want to use other names.
  919. */
  920. $CatIcons = '/static/common/bioicons/';
  921. $CATS = [
  922. 'SEQ' => [
  923. 'ID' => 1,
  924. 'Name' => 'Sequences',
  925. 'Icon' => $CatIcons.'sequences.png',
  926. 'Platforms' => $SeqPlatforms,
  927. 'Formats' => [
  928. 'NucleoSeq' => $SeqFormats,
  929. 'ProtSeq' => $ProtFormats,
  930. 'Plain' => $PlainFormats
  931. ],
  932. 'Description' => "For data that's ACGT, ACGU, amino acid letters on disk.",
  933. ],
  934. 'GRF' => [
  935. 'ID' => 2,
  936. 'Name' => 'Graphs',
  937. 'Icon' => $CatIcons.'graphs.png',
  938. 'Platforms' => $GraphPlatforms,
  939. 'Formats' => [
  940. 'GraphXml' => $GraphXmlFormats,
  941. 'GraphTxt' => $GraphTxtFormats,
  942. 'Plain' => $PlainFormats
  943. ],
  944. 'Description' => 'For pathway and regulatory network data, structured taxonomies, etc.',
  945. ],
  946. 'SYS' => [
  947. 'ID' => 3,
  948. 'Name' => 'Systems',
  949. 'Icon' => $CatIcons.'systems.png',
  950. 'Platforms' => $GraphPlatforms,
  951. 'Formats' => [
  952. 'GraphXml' => $GraphXmlFormats,
  953. 'GraphTxt' => $GraphTxtFormats,
  954. 'Plain' => $PlainFormats
  955. ],
  956. 'Description' => 'For data that examines one facet broadly, not one subject deeply.',
  957. ],
  958. 'GEO' => [
  959. 'ID' => 4,
  960. 'Name' => 'Geometric',
  961. 'Icon' => $CatIcons.'geometric.png',
  962. 'Platforms' => $GraphPlatforms,
  963. 'Formats' => [
  964. 'GraphXml' => $GraphXmlFormats,
  965. 'GraphTxt' => $GraphTxtFormats,
  966. 'Plain' => $PlainFormats
  967. ],
  968. 'Description' => "For structured data (XML, etc.) that describes the subject's orientation in space.",
  969. ],
  970. 'SCV' => [
  971. 'ID' => 5,
  972. 'Name' => 'Scalars/Vectors',
  973. 'Icon' => $CatIcons.'scalars_vectors.png',
  974. 'Platforms' => $GraphPlatforms,
  975. 'Formats' => [
  976. 'GraphXml' => $GraphXmlFormats,
  977. 'GraphTxt' => $GraphTxtFormats,
  978. 'Plain' => $PlainFormats
  979. ],
  980. 'Description' => 'For data that describes observations over time and/or space.',
  981. ],
  982. 'PTRN' => [
  983. 'ID' => 6,
  984. 'Name' => 'Patterns',
  985. 'Icon' => $CatIcons.'patterns.png',
  986. 'Platforms' => $GraphPlatforms,
  987. 'Formats' => [
  988. 'GraphXml' => $GraphXmlFormats,
  989. 'GraphTxt' => $GraphTxtFormats,
  990. 'Plain' => $PlainFormats
  991. ],
  992. 'Description' => 'For data that describes recurring structures in nature such as common pathways or motifs in the proteome or metabolome.',
  993. ],
  994. 'CNST' => [
  995. 'ID' => 7,
  996. 'Name' => 'Constraints',
  997. 'Icon' => $CatIcons.'constraints.png',
  998. 'Platforms' => $GraphPlatforms,
  999. 'Formats' => [
  1000. 'GraphXml' => $GraphXmlFormats,
  1001. 'GraphTxt' => $GraphTxtFormats,
  1002. 'Plain' => $PlainFormats
  1003. ],
  1004. 'Description' => 'For data that records experimental control behavior, checks readings against known physical constants, tracks the thermodynamic limits of reactions, etc.',
  1005. ],
  1006. 'IMG' => [
  1007. 'ID' => 8,
  1008. 'Name' => 'Images',
  1009. 'Icon' => $CatIcons.'images.png',
  1010. 'Platforms' => $ImgPlatforms,
  1011. 'Formats' => [
  1012. 'ImgRaster' => $ImgFormats,
  1013. #'ImgVector' => $ImgFormats,
  1014. 'Plain' => $PlainFormats
  1015. ],
  1016. 'Description' => 'For data you can look at!',
  1017. ],
  1018. 'SPAT' => [
  1019. 'ID' => 9,
  1020. 'Name' => 'Spatial',
  1021. 'Icon' => $CatIcons.'spatial.png',
  1022. 'Platforms' => $GraphPlatforms,
  1023. 'Formats' => [
  1024. 'MapVector' => $MapVectorFormats,
  1025. 'MapRaster' => $MapRasterFormats,
  1026. 'ImgRaster' => $ImgFormats,
  1027. 'Plain' => $PlainFormats
  1028. ],
  1029. 'Description' => "For data that's limited to specific locations or otherwise describes macroscopic space.",
  1030. ],
  1031. 'MOD' => [
  1032. 'ID' => 10,
  1033. 'Name' => 'Models',
  1034. 'Icon' => $CatIcons.'models.png',
  1035. 'Platforms' => $GraphPlatforms,
  1036. 'Formats' => [
  1037. 'MapVector' => $MapVectorFormats,
  1038. 'MapRaster' => $MapRasterFormats,
  1039. 'ImgRaster' => $ImgFormats,
  1040. 'Plain' => $PlainFormats
  1041. ],
  1042. 'Description' => 'For projections, simulations, and other hypothetical or computer-generated data.',
  1043. ],
  1044. 'DOC' => [
  1045. 'ID' => 11,
  1046. 'Name' => 'Documents',
  1047. 'Icon' => $CatIcons.'documents.png',
  1048. 'Platforms' => $DocPlatforms,
  1049. 'Formats' => [
  1050. 'BinDoc' => $BinDocFormats,
  1051. 'CpuGen' => $CpuGenFormats,
  1052. 'Plain' => $PlainFormats
  1053. ],
  1054. 'Description' => 'For documentation, software, disk images, and literature datasets.',
  1055. ],
  1056. 'RAW' => [
  1057. 'ID' => 12,
  1058. 'Name' => 'Machine Data',
  1059. 'Icon' => $CatIcons.'machine_data.png',
  1060. 'Platforms' => $RawPlatforms,
  1061. 'Formats' => ['Plain' => $PlainFormats],
  1062. 'Description' => 'For raw reads and machine data of any category.',
  1063. ],
  1064. ];
  1065. ENV::setPub(
  1066. 'CATS',
  1067. new RecursiveArrayObject($CATS)
  1068. );
  1069. /**
  1070. * Regular expressions
  1071. *
  1072. * The Gazelle regex collection.
  1073. * Formerly in classes/regex.php.
  1074. */
  1075. // resource_type://username:password@domain:port/path?query_string#anchor
  1076. define('RESOURCE_REGEX', '(https?|ftps?):\/\/');
  1077. ENV::setPub(
  1078. 'RESOURCE_REGEX',
  1079. '(https?|ftps?):\/\/'
  1080. );
  1081. define('IP_REGEX', '(\d{1,3}\.){3}\d{1,3}');
  1082. ENV::setPub(
  1083. 'IP_REGEX',
  1084. '(\d{1,3}\.){3}\d{1,3}'
  1085. );
  1086. define('DOMAIN_REGEX', '([a-z0-9\-\_]+\.)*[a-z0-9\-\_]+');
  1087. ENV::setPub(
  1088. 'DOMAIN_REGEX',
  1089. '([a-z0-9\-\_]+\.)*[a-z0-9\-\_]+'
  1090. );
  1091. define('PORT_REGEX', ':\d{1,5}');
  1092. ENV::setPub(
  1093. 'PORT_REGEX',
  1094. ':\d{1,5}'
  1095. );
  1096. define('URL_REGEX', '('.RESOURCE_REGEX.')('.IP_REGEX.'|'.DOMAIN_REGEX.')('.PORT_REGEX.')?(\/\S*)*');
  1097. ENV::setPub(
  1098. 'URL_REGEX',
  1099. "($ENV->RESOURCE_REGEX)($ENV->IP_REGEX|$ENV->DOMAIN_REGEX)($ENV->PORT_REGEX)?(\/\S*)*"
  1100. );
  1101. define('USERNAME_REGEX', '/^[a-z0-9_]{2,20}$/iD');
  1102. ENV::setPub(
  1103. 'USERNAME_REGEX',
  1104. '/^[a-z0-9_]{2,20}$/iD'
  1105. );
  1106. define('EMAIL_REGEX', '[_a-z0-9-]+([.+][_a-z0-9-]+)*@'.DOMAIN_REGEX);
  1107. ENV::setPub(
  1108. 'EMAIL_REGEX',
  1109. "[_a-z0-9-]+([.+][_a-z0-9-]+)*@$ENV->DOMAIN_REGEX"
  1110. );
  1111. define('IMAGE_REGEX', URL_REGEX.'\/\S+\.(jpg|jpeg|tif|tiff|png|gif|bmp)(\?\S*)?');
  1112. ENV::setPub(
  1113. 'IMAGE_REGEX',
  1114. "$ENV->URL_REGEX\/\S+\.(jpg|jpeg|tif|tiff|png|gif|bmp)(\?\S*)?"
  1115. );
  1116. define('VIDEO_REGEX', URL_REGEX.'\/\S+\.(webm)(\?\S*)?');
  1117. ENV::setPub(
  1118. 'VIDEO_REGEX',
  1119. "$ENV->URL_REGEX\/\S+\.(webm)(\?\S*)?"
  1120. );
  1121. define('CSS_REGEX', URL_REGEX.'\/\S+\.css(\?\S*)?');
  1122. ENV::setPub(
  1123. 'CSS_REGEX',
  1124. "$ENV->URL_REGEX\/\S+\.css(\?\S*)?"
  1125. );
  1126. define('SITELINK_REGEX', RESOURCE_REGEX.'(www.)?'.preg_quote(SITE_DOMAIN, '/'));
  1127. ENV::setPub(
  1128. 'SITELINK_REGEX',
  1129. "$ENV->RESOURCE_REGEX(www.)?".preg_quote(SITE_DOMAIN, '/')
  1130. );
  1131. define('TORRENT_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?torrentid=(\d+)'); // torrentid = group 4
  1132. ENV::setPub(
  1133. 'TORRENT_REGEX',
  1134. "$ENV->SITELINK_REGEX\/torrents\.php\?(.*&)?torrentid=(\d+)"
  1135. );
  1136. define('TORRENT_GROUP_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?id=(\d+)'); // id = group 4
  1137. ENV::setPub(
  1138. 'TORRENT_GROUP_REGEX',
  1139. "$ENV->SITELINK_REGEX\/torrents\.php\?(.*&)?id=(\d+)"
  1140. );
  1141. define('ARTIST_REGEX', SITELINK_REGEX.'\/artist\.php\?(.*&)?id=(\d+)'); // id = group 4
  1142. ENV::setPub(
  1143. 'ARTIST_REGEX',
  1144. "$ENV->SITELINK_REGEX\/artist\.php\?(.*&)?id=(\d+)"
  1145. );
  1146. # https://stackoverflow.com/a/3180176
  1147. ENV::setPub(
  1148. 'HTML_REGEX',
  1149. '<([\w]+)([^>]*?)(([\s]*\/>)|(>((([^<]*?|<\!\-\-.*?\-\->)|(?R))*)<\/\\1[\s]*>))'
  1150. );
  1151. ENV::setPub(
  1152. 'BBCODE_REGEX',
  1153. '\[([\w]+)([^\]]*?)(([\s]*\/\])|(\]((([^\[]*?|\[\!\-\-.*?\-\-\])|(?R))*)\[\/\\1[\s]*\]))'
  1154. );
  1155. # https://www.crossref.org/blog/dois-and-matching-regular-expressions/
  1156. ENV::setPub(
  1157. 'DOI_REGEX',
  1158. '10.\d{4,9}\/[-._;()\/:A-Z0-9]+'
  1159. );
  1160. # https://www.biostars.org/p/13753/
  1161. ENV::setPub(
  1162. 'ENTREZ_REGEX',
  1163. '\d*'
  1164. );
  1165. # https://www.wikidata.org/wiki/Property:P496
  1166. ENV::setPub(
  1167. 'ORCID_REGEX',
  1168. '0000-000(1-[5-9]|2-[0-9]|3-[0-4])\d{3}-\d{3}[\dX]'
  1169. );
  1170. # https://www.biostars.org/p/13753/
  1171. ENV::setPub(
  1172. 'REFSEQ_REGEX',
  1173. '\w{2}_\d{1,}\.\d{1,}'
  1174. );
  1175. # https://www.uniprot.org/help/accession_numbers
  1176. ENV::setPub(
  1177. 'UNIPROT_REGEX',
  1178. '[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}'
  1179. );