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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316
  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: ternary
  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: ternary
  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: ternary
  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. * App keys
  110. *
  111. * Separate keys for development and production.
  112. * Increased security and protection against config overwrites.
  113. */
  114. # Pre-shared key for generating hmacs for the image proxy
  115. define('IMAGE_PSK', '00000000000000000000000000000000');
  116. ENV::setPriv('IMAGE_PSK', '00000000000000000000000000000000');
  117. # Production
  118. if (!$ENV->DEV) {
  119. # Unused in OT Gazelle. Currently used for API token auth
  120. ENV::setPriv('ENCKEY', '00000000000000000000000000000000');
  121. # Alphanumeric random key. This key must be the argument to schedule.php for the schedule to work
  122. define('SCHEDULE_KEY', '00000000000000000000000000000000');
  123. ENV::setPriv('SCHEDULE_KEY', '00000000000000000000000000000000');
  124. # Random key. Used for generating unique RSS auth key
  125. define('RSS_HASH', '00000000000000000000000000000000');
  126. ENV::setPriv('RSS_HASH', '00000000000000000000000000000000');
  127. }
  128. # Development
  129. else {
  130. ENV::setPriv('ENCKEY', '00000000000000000000000000000000');
  131. define('SCHEDULE_KEY', '00000000000000000000000000000000');
  132. ENV::setPriv('SCHEDULE_KEY', '00000000000000000000000000000000');
  133. define('RSS_HASH', '00000000000000000000000000000000');
  134. ENV::setPriv('RSS_HASH', '00000000000000000000000000000000');
  135. }
  136. /**
  137. * Database
  138. */
  139. # Common info
  140. ENV::setPriv('SQLHOST', 'localhost');
  141. ENV::setPriv('SQLSOCK', '/var/run/mysqld/mysqld.sock');
  142. ENV::setPriv('SQLPORT', 3306);
  143. # Production
  144. if (!$ENV->DEV) {
  145. ENV::setPriv('SQLDB', 'gazelle_production');
  146. ENV::setPriv('SQLLOGIN', 'gazelle_production');
  147. ENV::setPriv('SQLPASS', '00000000000000000000000000000000');
  148. }
  149. # Development
  150. else {
  151. ENV::setPriv('SQLDB', 'gazelle_development');
  152. ENV::setPriv('SQLLOGIN', 'gazelle_development');
  153. ENV::setPriv('SQLPASS', '00000000000000000000000000000000');
  154. }
  155. /**
  156. * Tracker
  157. */
  158. # Ocelot connection, e.g., 0.0.0.0
  159. define('TRACKER_HOST', '0.0.0.0');
  160. ENV::setPriv('TRACKER_HOST', '0.0.0.0');
  161. # Production
  162. if (!$ENV->DEV) {
  163. define('TRACKER_PORT', 34000);
  164. ENV::setPriv('TRACKER_PORT', 34000);
  165. # Must be 32 alphanumeric characters and match site_password in ocelot.conf
  166. define('TRACKER_SECRET', '00000000000000000000000000000000');
  167. ENV::setPriv('TRACKER_SECRET', '00000000000000000000000000000000');
  168. # Must be 32 alphanumeric characters and match report_password in ocelot.conf
  169. define('TRACKER_REPORTKEY', '00000000000000000000000000000000');
  170. ENV::setPriv('TRACKER_REPORTKEY', '00000000000000000000000000000000');
  171. }
  172. # Development
  173. else {
  174. define('TRACKER_PORT', 34001);
  175. ENV::setPriv('TRACKER_PORT', 34001);
  176. define('TRACKER_SECRET', '00000000000000000000000000000000');
  177. ENV::setPriv('TRACKER_SECRET', '00000000000000000000000000000000');
  178. define('TRACKER_REPORTKEY', '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://devtr.biotorrents.de:443',
  213. ], [] # Tier 2
  214. ]);
  215. $AnnounceURLs = [
  216. [ # Tier 1
  217. 'https://devtr.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. define('DONOR_INVITES', 2);
  328. ENV::setPub('DONOR_INVITES', 2);
  329. # Bonus Points
  330. define('BONUS_POINTS', 'Bonus Points');
  331. ENV::setPub('BONUS_POINTS', 'Bonus Points');
  332. ENV::setPub('BP_COEFF', 1.5); # OT default 0.5
  333. # Tag namespaces (configurable via CSS selectors)
  334. #define('TAG_NAMESPACES', ['male', 'female', 'parody', 'character']);
  335. # Banned stuff (file characters, browsers, etc.)
  336. ENV::setPub(
  337. 'BAD_CHARS',
  338. ['"', '*', '/', ':', '<', '>', '?', '\\', '|']
  339. );
  340. # Set to true to block Opera Mini proxy
  341. ENV::setPub('BLOCK_OPERA_MINI', true);
  342. # Misc stuff like generic reusable snippets
  343. # Example of a variable using heredoc syntax
  344. ENV::setPub(
  345. 'PASSWORD_ADVICE',
  346. <<<HTML
  347. <p>
  348. Any password of 15 characters or longer will be accepted, but a strong password
  349. <ul>
  350. <li>is really a pass<em>phrase</em> with uppercase and lowercase letters and many small words,</li>
  351. <li>that contains numbers and symbols, including complex Unicode characters like emoji.</li>
  352. </ul>
  353. </p>
  354. HTML
  355. );
  356. /**
  357. * Services
  358. *
  359. * Public APIs, domains, etc.
  360. * Not intended for private API keys.
  361. */
  362. # Current Sci-Hub domains
  363. # https://lovescihub.wordpress.com
  364. define('SCI_HUB', 'se');
  365. ENV::setPub(
  366. 'SCI_HUB',
  367. ['ren', 'tw', 'se']
  368. );
  369. # Semantic Scholar
  370. # https://api.semanticscholar.org
  371. ENV::setPub(
  372. 'SS',
  373. [
  374. 'Paper' => 'https://api.semanticscholar.org/v1/paper/',
  375. 'Author' => 'https://api.semanticscholar.org/v1/author/',
  376. ]
  377. );
  378. /**
  379. * User class IDs
  380. *
  381. * Needed for automatic promotions.
  382. * Found in the `permissions` table.
  383. */
  384. # Name of class Class ID (not level)
  385. define('ADMIN', '1');
  386. define('USER', '2');
  387. define('MEMBER', '3');
  388. define('POWER', '4');
  389. define('ELITE', '5');
  390. define('LEGEND', '8');
  391. define('MOD', '11');
  392. define('SYSOP', '15');
  393. define('ARTIST', '19');
  394. define('DONOR', '20');
  395. define('VIP', '21');
  396. define('TORRENT_MASTER', '23');
  397. define('POWER_TM', '24');
  398. define('FLS_TEAM', '33');
  399. define('FORUM_MOD', '9001');
  400. /**
  401. * Forums
  402. */
  403. define('STAFF_FORUM', 3);
  404. define('DONOR_FORUM', 7);
  405. ENV::setPub('TRASH_FORUM', 8);
  406. ENV::setPub('ANNOUNCEMENT_FORUM', 1);
  407. ENV::setPub('SUGGESTIONS_FORUM', 2);
  408. # Pagination
  409. define('TORRENT_COMMENTS_PER_PAGE', 10);
  410. define('POSTS_PER_PAGE', 25);
  411. define('TOPICS_PER_PAGE', 50);
  412. define('TORRENTS_PER_PAGE', 50);
  413. define('REQUESTS_PER_PAGE', 25);
  414. define('MESSAGES_PER_PAGE', 25);
  415. define('LOG_ENTRIES_PER_PAGE', 50);
  416. # Cache catalogues
  417. define('THREAD_CATALOGUE', 500); // Limit to THREAD_CATALOGUE posts per cache key
  418. # Miscellaneous values
  419. define('MAX_RANK', 6);
  420. define('MAX_EXTRA_RANK', 8);
  421. define('MAX_SPECIAL_RANK', 3);
  422. ENV::setPub('DONOR_FORUM_RANK', 6);
  423. /**
  424. * Ratio and badges
  425. */
  426. # Ratio requirements, in descending order
  427. define('RATIO_REQUIREMENTS', [
  428. # Downloaded Req (0% seeded) Req (100% seeded)
  429. [200 * 1024**3, 0.60, 0.60],
  430. [160 * 1024**3, 0.60, 0.50],
  431. [120 * 1024**3, 0.50, 0.40],
  432. [100 * 1024**3, 0.40, 0.30],
  433. [80 * 1024**3, 0.30, 0.20],
  434. [60 * 1024**3, 0.20, 0.10],
  435. [40 * 1024**3, 0.15, 0.00],
  436. [20 * 1024**3, 0.10, 0.00],
  437. [10 * 1024**3, 0.05, 0.00],
  438. ]);
  439. # God I wish I didn't have to do this but I just don't care anymore
  440. $AutomatedBadgeIDs = [
  441. 'DL' => [
  442. '8' => 10,
  443. '16' => 11,
  444. '32' => 12,
  445. '64' => 13,
  446. '128' => 14,
  447. '256' => 15,
  448. '512' => 16,
  449. '1024' => 17,
  450. '2048' => 18
  451. ],
  452. 'UL' => [
  453. '16' => 20,
  454. '32' => 21,
  455. '64' => 22,
  456. '128' => 23,
  457. '256' => 24,
  458. '512' => 25,
  459. '1024' => 26,
  460. '2048' => 27,
  461. '4096' => 28
  462. ],
  463. 'Posts' => [
  464. '5' => 60,
  465. '10' => 61,
  466. '25' => 62,
  467. '50' => 63,
  468. '100' => 64,
  469. '250' => 65,
  470. '500' => 66,
  471. '1000' => 67,
  472. '2500' => 68
  473. ]
  474. ];
  475. ENV::setPub(
  476. 'AUTOMATED_BADGE_IDS',
  477. new RecursiveArrayObject($AutomatedBadgeIDs)
  478. );
  479. /**
  480. * Metadata abstraction map
  481. *
  482. * A set of 'label' → $DB->query() mappings.
  483. * The database should store generic data, e.g.,
  484. * - Title1, Title2, Title3
  485. * - Creator, Affiliation, Location
  486. *
  487. * Then Gazelle's job is to map text labels over the fields in HTML.
  488. * So $Input->Print($ID = $ENV->Creator) would print an Author form input.
  489. *
  490. * The structure:
  491. * $ENV->DBMAP =
  492. * (DatabaseField
  493. * ->(
  494. * Label->TextLabel,
  495. * OldField->Oppaitime,
  496. * )
  497. * );
  498. *
  499. * An example:
  500. * $Title1 = $ENV->DBMAP->Title1;
  501. * $ElementID =
  502. * strtolower($Title1->Label)
  503. * . '_class_label_'
  504. * . $InstanceID;
  505. */
  506. $DatabaseFields = [
  507. 'AccessionNumber' => [
  508. 'Label' => 'Accession Number',
  509. 'Selector' => ['DOI' => 'javdb', 'RefSeq' => 'anidb', 'UniProt' => 'ehentai'],
  510. 'OldField' => 'CatalogueNumber',
  511. 'Description' => 'RefSeq and UniProt preferred',
  512. ],
  513. 'Title1' => [
  514. 'Label' => 'Torrent Title',
  515. 'Selector' => ['title'],
  516. 'OldField' => 'Name',
  517. 'Description' => 'Definition line, e.g., Alcohol dehydrogenase ADH1',
  518. ],
  519. 'Title2' => [
  520. 'Label' => 'Organism',
  521. 'Selector' => ['DOI' => 'javdb_tr', 'RefSeq' => 'anidb_tr', 'UniProt' => 'ehentai_tr'],
  522. 'OldField' => 'NameRJ',
  523. 'Description' => 'Organism line binomial, e.g., Saccharomyces cerevisiae',
  524. ],
  525. 'Title3' => [
  526. 'Label' => 'Strain/Variety',
  527. 'Selector' => ['DOI' => 'javdb_tr', 'RefSeq' => 'anidb_tr', 'UniProt' => 'ehentai_tr'],
  528. 'OldField' => 'NameJP',
  529. 'Description' => 'Organism line if any, e.g., S288C',
  530. ],
  531. # etc.
  532. ];
  533. ENV::setPub(
  534. 'DBMAP',
  535. new RecursiveArrayObject($DatabaseFields)
  536. );
  537. /**
  538. * Site Categories
  539. * v2 modular ontology
  540. */
  541. # Main Categories
  542. # Old OT Gazelle format
  543. # https://www.ncbi.nlm.nih.gov/books/NBK25464/
  544. $Categories = [
  545. 'Sequences',
  546. 'Graphs',
  547. 'Systems',
  548. 'Geometric',
  549. 'Scalars/Vectors',
  550. 'Patterns',
  551. 'Constraints',
  552. 'Images',
  553. 'Spatial',
  554. 'Models',
  555. 'Documents',
  556. 'Machine Data',
  557. ];
  558. $GroupedCategories = $Categories;
  559. #$CategoryIcons = ['music.png', 'apps.png', 'ebook.png', 'audiobook.png', 'elearning.png', 'comedy.png', 'comics.png'];
  560. # Plain Formats
  561. $PlainFormats = [
  562. 'CSV' => ['csv'],
  563. 'JSON' => ['json'],
  564. 'Text' => ['txt'],
  565. 'XML' => ['xml'],
  566. 'Other' => [''],
  567. ];
  568. /**
  569. * Sequences
  570. */
  571. # Platforms
  572. $SeqPlatforms = [
  573. #$Media = [
  574. # DNA
  575. 'Complete Genomics',
  576. 'cPAS-BGI/MGI',
  577. 'Helicos',
  578. 'Illumina HiSeq',
  579. 'Illumina MiSeq',
  580. 'Ion Torrent',
  581. 'Microfluidics',
  582. 'Nanopore',
  583. 'PacBio',
  584. 'Roche 454',
  585. 'Sanger',
  586. 'SOLiD',
  587. # RNA, Protein, etc.
  588. 'De Novo',
  589. 'HPLC',
  590. 'Mass Spec',
  591. 'RNA-Seq',
  592. 'Other',
  593. ];
  594. # Sequence Formats
  595. # https://www.ncbi.nlm.nih.gov/sra/docs/submitformats/
  596. $SeqFormats = [
  597. #$Containers = [
  598. 'BAM' => ['bam'],
  599. 'CRAM' => ['cram'],
  600. 'EMBL' => ['embl'],
  601. 'FASTA' => ['fa', 'fasta', 'fsa'],
  602. 'FASTA+QUAL' => ['qual'],
  603. 'CSFASTA' => ['csfa', 'csfasta', 'csfsa'],
  604. 'FASTQ' => ['fastq', 'fq', 'sanfastq'],
  605. 'GFF' => ['gff', 'gff2', 'gff3'],
  606. 'GTF' => ['gtf'],
  607. 'GenBank' => ['gb', 'gbk', 'genbank'],
  608. 'HDF5' => ['bash5', 'baxh5', 'fast5', 'h5', 'hdf5'],
  609. 'PIR' => ['pir'],
  610. 'QSeq' => ['qseq'],
  611. 'SAM' => ['sam'],
  612. 'SFF' => ['sff'],
  613. 'SRF' => ['srf'],
  614. 'SnapGene' => ['dna', 'seq'],
  615. 'SwissProt' => ['dat'],
  616. 'VCF' => ['vcf'],
  617. ];
  618. # Protein Formats
  619. # DON'T PARSE RAW FILES. TOO MANY COMPETING VENDORS
  620. # https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3518119/
  621. $ProtFormats = [
  622. #$ContainersProt = [
  623. 'ABI/Sciex' => ['t2d', 'wiff'],
  624. 'APML' => ['apml'],
  625. 'ASF' => ['asf'],
  626. 'Agilent/Bruker' => ['baf', 'd', 'fid', 'tdf', 'yep'],
  627. 'BlibBuild' => ['blib'],
  628. 'Bruker/Varian' => ['sms', 'xms'],
  629. 'Finnigan' => ['dat', 'ms'],
  630. 'ION-TOF' => ['ita', 'itm'],
  631. 'JCAMP-DX' => ['jdx'],
  632. 'MGF' => ['mgf'],
  633. 'MS2' => ['ms2'],
  634. 'MSF' => ['msf'],
  635. 'mzData' => ['mzdata'],
  636. 'mzML' => ['mzml'],
  637. 'mzXML' => ['mzxml'],
  638. 'OMSSA' => ['omssa', 'omx'],
  639. 'PEFF' => ['peff'],
  640. 'pepXML' => ['pepxml'],
  641. 'protXML' => ['protxml'],
  642. 'Shimadzu' => ['lcd', 'qgd', 'spc'],
  643. 'Skyline' => ['sky', 'skyd'],
  644. 'TPP/SPC' => ['dta'],
  645. 'Tandem' => ['tandem'],
  646. 'TraML' => ['traml'],
  647. 'ULVAC-PHI' => ['tdc'],
  648. ];
  649. /**
  650. * Graphs
  651. */
  652. # Graph Platforms
  653. # https://en.wikipedia.org/wiki/Graph_drawing#Software
  654. $GraphPlatforms = [
  655. 'BioFabric',
  656. 'BioTapestry',
  657. 'Cytoscape',
  658. 'Edraw Max',
  659. 'GenMAPP',
  660. 'Gephi',
  661. 'graph-tool',
  662. 'Graphviz',
  663. 'InCroMAP',
  664. 'LaNet-vi',
  665. 'Linkurious',
  666. 'MATLAB',
  667. 'MEGA',
  668. 'Maple',
  669. 'Mathematica',
  670. #'Microsoft Automatic Graph Layout',
  671. 'NetworkX',
  672. 'Other',
  673. 'PGF/TikZ',
  674. 'PathVisio',
  675. 'Pathview',
  676. 'R',
  677. 'Systrip',
  678. 'Tom Sawyer Software',
  679. 'Tulip',
  680. 'yEd',
  681. ];
  682. # XML Graph Formats
  683. $GraphXmlFormats = [
  684. 'DGML' => ['dgml'],
  685. 'DotML' => ['dotml'],
  686. 'GEXF' => ['gexf'],
  687. 'GXL' => ['gxl'],
  688. 'GraphML' => ['graphml'],
  689. 'XGMML' => ['xgmml'],
  690. ];
  691. # Text Graph Formats
  692. $GraphTxtFormats = [
  693. 'DOT' => ['gv'],
  694. 'GML' => ['gml'],
  695. 'LCF' => ['lcf'],
  696. 'Newick' => ['xsd', 'sgf'],
  697. 'SIF' => ['sif'],
  698. 'TGF' => ['tgf'],
  699. ];
  700. /**
  701. * Images
  702. */
  703. # Image Platforms
  704. $ImgPlatforms = [
  705. #$MediaManga = [
  706. 'CT/CAT',
  707. 'ECG',
  708. 'Elastography',
  709. 'FNIR/NIRS',
  710. 'MPI',
  711. 'MRI/NMR',
  712. 'Microscopy',
  713. 'Photoacoustic',
  714. 'Photography',
  715. 'Scint/SPECT/PET',
  716. 'Ultrasound',
  717. 'X-Rays',
  718. 'Other',
  719. ];
  720. # Image Formats
  721. # https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3948928/
  722. $ImgFormats = [
  723. #$ContainersGames = [
  724. 'Analyze' => ['hdr', 'img'],
  725. 'Interfile' => ['h33'],
  726. 'DICOM' => ['dcm', 'dicom'],
  727. 'HDF5' => ['bash5', 'baxh5', 'fast5', 'h5', 'hdf5'],
  728. 'NIfTI' => ['nii', 'nifti'],
  729. 'MINC' => ['minc', 'mnc'],
  730. 'JPEG' => ['jfif', 'jpeg', 'jpg'],
  731. 'JPEG 2000' => ['j2k', 'jp2', 'jpf', 'jpm', 'jpx', 'mj2'],
  732. 'PNG' => ['png'],
  733. 'TIFF' => ['tif', 'tiff'],
  734. 'WebP' => ['webp'],
  735. ];
  736. /**
  737. * Spatial
  738. */
  739. # Vector Map Formats
  740. $MapVectorFormats = [
  741. 'AutoCAD DXF' => ['dxf'],
  742. 'Cartesian (XYZ)' => ['xyz'],
  743. 'DLG' => ['dlg'],
  744. 'Esri TIN' => ['adf', 'dbf'],
  745. 'GML' => ['gml'],
  746. 'GeoJSON' => ['geojson'],
  747. 'ISFC' => ['isfc'],
  748. 'KML' => ['kml', 'kmzv'],
  749. # DAT omitted
  750. # https://en.wikipedia.org/wiki/MapInfo_TAB_format
  751. 'MapInfo TAB' => ['tab', 'ind', 'map', 'id'],
  752. 'Measure Map Pro' => ['mmp'],
  753. 'NTF' => ['ntf'],
  754. # DBF omitted
  755. # https://en.wikipedia.org/wiki/Shapefile
  756. 'Shapefile' => ['shp', 'shx'],
  757. 'Spatial Data File' => ['sdf', 'sdf3', 'sif', 'kif'],
  758. 'SOSI' => ['sosi'],
  759. 'SVG' => ['svg'],
  760. 'TIGER' => ['tiger'],
  761. 'VPF' => ['vpf'],
  762. ];
  763. # Raster Map Formats
  764. $MapRasterFormats = [
  765. 'ADRG' => ['adrg'],
  766. 'Binary' => ['bsq', 'bip', 'bil'],
  767. 'DRG' => ['drg'],
  768. 'ECRG' => ['ecrg'],
  769. 'ECW' => ['ecw'],
  770. # DAT and ASC omitted (common)
  771. # https://support.esri.com/en/technical-article/000008526
  772. # https://web.archive.org/web/20150128024528/http://docs.codehaus.org/display/GEOTOOLS/ArcInfo+ASCII+Grid+format
  773. 'Esri Grid' => ['adf', 'nit', 'asc', 'grd'],
  774. 'GeoTIFF' => ['tfw'],
  775. #'IMG' => ['img'],
  776. #'JPEG 2000' => ['j2k', 'jp2', 'jpf', 'jpm', 'jpx', 'mj2'],
  777. 'MrSID' => ['sid'],
  778. 'netCDF' => ['nc'],
  779. 'RPF' => ['cadrg', 'cib'],
  780. ];
  781. /**
  782. * Documents
  783. */
  784. $DocPlatforms = [
  785. # Composed
  786. 'Literature',
  787. 'Software',
  788. # Generated
  789. 'Kernel',
  790. 'Metadata',
  791. 'Notebook',
  792. 'Other',
  793. ];
  794. # Binary Document Formats
  795. # https://en.wikipedia.org/wiki/OpenDocument
  796. # https://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensions
  797. $BinDocFormats = [
  798. 'OpenDocument' => ['odt', 'fodt', 'ods', 'fods', 'odp', 'fodp', 'odg', 'fodg', 'odf'],
  799. 'Word' => ['doc', 'dot', 'wbk', 'docx', 'docm', 'dotx', 'dotm', 'docb'],
  800. 'PowerPoint' => ['ppt', 'pot', 'pps', 'pptx', 'pptm', 'potx', 'potm', 'ppam', 'ppsx', 'ppsm', 'sldx', 'sldm'],
  801. 'Excel' => ['xls', 'xlt', 'xlm', 'xlsx', 'xlsm', 'xltx', 'xltm', 'xlsb', 'xla', 'xlam', 'xll', 'xlw'],
  802. 'PDF' => ['pdf', 'fdf', 'xfdf'],
  803. ];
  804. # Extra Formats
  805. # DON'T PARSE IMG OR ISO FILES
  806. # https://en.wikipedia.org/wiki/Disk_image#File_formats
  807. # http://dcjtech.info/topic/python-file-extensions/
  808. $CpuGenFormats = [
  809. 'Docker' => ['dockerfile'],
  810. 'Hard Disk' => ['fvd', 'dmg', 'esd', 'qcow', 'qcow2', 'qcow3', 'smi', 'swm', 'vdi', 'vhd', 'vhdx', 'vmdk', 'wim'],
  811. 'Optical Disc' => ['bin', 'ccd', 'cso', 'cue', 'daa', 'isz', 'mdf', 'mds', 'mdx', 'nrg', 'uif'],
  812. 'Python' => ['pxd', 'py', 'py3', 'pyc', 'pyd', 'pyde', 'pyi', 'pyo', 'pyp', 'pyt', 'pyw', 'pywz', 'pyx', 'pyz', 'rpy', 'xpy'],
  813. 'Jupyter' => ['ipynb'],
  814. 'Ontology' => ['cgif', 'cl', 'clif', 'csv', 'htm', 'html', 'kif', 'obo', 'owl', 'rdf', 'rdfa', 'rdfs', 'rif', 'tsv', 'xcl', 'xht', 'xhtml', 'xml'],
  815. ];
  816. /**
  817. * Machine Data
  818. */
  819. $RawPlatforms = [
  820. 'Binary',
  821. 'Text',
  822. ];
  823. # Archives
  824. $Archives = [
  825. '7z' => ['7z'],
  826. 'bzip2' => ['bz2', 'bzip2'],
  827. 'gzip' => ['gz', 'gzip', 'tgz', 'tpz'],
  828. 'Pickle' => ['pickle', 'pkl'],
  829. 'RAR' => ['rar', 'rev'],
  830. 'ZIP' => ['zip', 'zipx'],
  831. 'None' => [''],
  832. ];
  833. # Licenses
  834. $Codecs = [
  835. 'BSD-2',
  836. 'BSD-3',
  837. 'CC BY',
  838. 'CC BY-SA',
  839. 'CC BY-ND',
  840. 'CC BY-NC',
  841. 'CC BY-NC-SA',
  842. 'CC BY-NC-ND',
  843. 'GNU GPL',
  844. 'GNU LGPL',
  845. 'GNU AGPL',
  846. 'GNU FDL',
  847. 'MIT',
  848. 'ODC-By',
  849. 'ODC-ODbL',
  850. 'OpenMTA',
  851. 'Public Domain',
  852. 'Unspecified',
  853. 'Other',
  854. ];
  855. # Scopes
  856. $Resolutions = [
  857. 'Contig',
  858. 'Scaffold',
  859. 'Chromosome',
  860. 'Whole Genome',
  861. 'Other',
  862. ];
  863. # Collage categories
  864. $CollageCats = [
  865. 0 => 'Personal',
  866. 1 => 'Theme',
  867. 2 => 'Staff Picks',
  868. 3 => 'Group Picks',
  869. ];
  870. /**
  871. * Now for the good stuff.
  872. * The short names are for convenience.
  873. * It should be easy enough to find and replace,
  874. * e.g., if you want to use other names.
  875. */
  876. $CatIcons = '/static/common/bioicons/';
  877. $CATS = [
  878. 'SEQ' => [
  879. 'ID' => 1,
  880. 'Name' => 'Sequences',
  881. 'Icon' => $CatIcons.'sequences.png',
  882. 'Platforms' => $SeqPlatforms,
  883. 'Formats' => [
  884. 'NucleoSeq' => $SeqFormats,
  885. 'ProtSeq' => $ProtFormats,
  886. 'Plain' => $PlainFormats
  887. ],
  888. 'Description' => "For data that's ACGT, ACGU, amino acid letters on disk.",
  889. ],
  890. 'GRF' => [
  891. 'ID' => 2,
  892. 'Name' => 'Graphs',
  893. 'Icon' => $CatIcons.'graphs.png',
  894. 'Platforms' => $GraphPlatforms,
  895. 'Formats' => [
  896. 'GraphXml' => $GraphXmlFormats,
  897. 'GraphTxt' => $GraphTxtFormats,
  898. 'Plain' => $PlainFormats
  899. ],
  900. 'Description' => 'For pathway and regulatory network data, structured taxonomies, etc.',
  901. ],
  902. 'SYS' => [
  903. 'ID' => 3,
  904. 'Name' => 'Systems',
  905. 'Icon' => $CatIcons.'systems.png',
  906. 'Platforms' => $GraphPlatforms,
  907. 'Formats' => [
  908. 'GraphXml' => $GraphXmlFormats,
  909. 'GraphTxt' => $GraphTxtFormats,
  910. 'Plain' => $PlainFormats
  911. ],
  912. 'Description' => 'For data that examines one facet broadly, not one subject deeply.',
  913. ],
  914. 'GEO' => [
  915. 'ID' => 4,
  916. 'Name' => 'Geometric',
  917. 'Icon' => $CatIcons.'geometric.png',
  918. 'Platforms' => $GraphPlatforms,
  919. 'Formats' => [
  920. 'GraphXml' => $GraphXmlFormats,
  921. 'GraphTxt' => $GraphTxtFormats,
  922. 'Plain' => $PlainFormats
  923. ],
  924. 'Description' => "For structured data (XML, etc.) that describes the subject's orientation in space.",
  925. ],
  926. 'SCV' => [
  927. 'ID' => 5,
  928. 'Name' => 'Scalars/Vectors',
  929. 'Icon' => $CatIcons.'scalars_vectors.png',
  930. 'Platforms' => $GraphPlatforms,
  931. 'Formats' => [
  932. 'GraphXml' => $GraphXmlFormats,
  933. 'GraphTxt' => $GraphTxtFormats,
  934. 'Plain' => $PlainFormats
  935. ],
  936. 'Description' => 'For data that describes observations over time and/or space.',
  937. ],
  938. 'PTRN' => [
  939. 'ID' => 6,
  940. 'Name' => 'Patterns',
  941. 'Icon' => $CatIcons.'patterns.png',
  942. 'Platforms' => $GraphPlatforms,
  943. 'Formats' => [
  944. 'GraphXml' => $GraphXmlFormats,
  945. 'GraphTxt' => $GraphTxtFormats,
  946. 'Plain' => $PlainFormats
  947. ],
  948. 'Description' => 'For data that describes recurring structures in nature such as common pathways or motifs in the proteome or metabolome.',
  949. ],
  950. 'CNST' => [
  951. 'ID' => 7,
  952. 'Name' => 'Constraints',
  953. 'Icon' => $CatIcons.'constraints.png',
  954. 'Platforms' => $GraphPlatforms,
  955. 'Formats' => [
  956. 'GraphXml' => $GraphXmlFormats,
  957. 'GraphTxt' => $GraphTxtFormats,
  958. 'Plain' => $PlainFormats
  959. ],
  960. 'Description' => 'For data that records experimental control behavior, checks readings against known physical constants, tracks the thermodynamic limits of reactions, etc.',
  961. ],
  962. 'IMG' => [
  963. 'ID' => 8,
  964. 'Name' => 'Images',
  965. 'Icon' => $CatIcons.'images.png',
  966. 'Platforms' => $ImgPlatforms,
  967. 'Formats' => [
  968. 'ImgRaster' => $ImgFormats,
  969. #'ImgVector' => $ImgFormats,
  970. 'Plain' => $PlainFormats
  971. ],
  972. 'Description' => 'For data you can look at!',
  973. ],
  974. 'SPAT' => [
  975. 'ID' => 9,
  976. 'Name' => 'Spatial',
  977. 'Icon' => $CatIcons.'spatial.png',
  978. 'Platforms' => $GraphPlatforms,
  979. 'Formats' => [
  980. 'MapVector' => $MapVectorFormats,
  981. 'MapRaster' => $MapRasterFormats,
  982. 'ImgRaster' => $ImgFormats,
  983. 'Plain' => $PlainFormats
  984. ],
  985. 'Description' => "For data that's limited to specific locations or otherwise describes macroscopic space.",
  986. ],
  987. 'MOD' => [
  988. 'ID' => 10,
  989. 'Name' => 'Models',
  990. 'Icon' => $CatIcons.'models.png',
  991. 'Platforms' => $GraphPlatforms,
  992. 'Formats' => [
  993. 'MapVector' => $MapVectorFormats,
  994. 'MapRaster' => $MapRasterFormats,
  995. 'ImgRaster' => $ImgFormats,
  996. 'Plain' => $PlainFormats
  997. ],
  998. 'Description' => 'For projections, simulations, and other hypothetical or computer-generated data.',
  999. ],
  1000. 'DOC' => [
  1001. 'ID' => 11,
  1002. 'Name' => 'Documents',
  1003. 'Icon' => $CatIcons.'documents.png',
  1004. 'Platforms' => $DocPlatforms,
  1005. 'Formats' => [
  1006. 'BinDoc' => $BinDocFormats,
  1007. 'CpuGen' => $CpuGenFormats,
  1008. 'Plain' => $PlainFormats
  1009. ],
  1010. 'Description' => 'For documentation, software, disk images, and literature datasets.',
  1011. ],
  1012. 'RAW' => [
  1013. 'ID' => 12,
  1014. 'Name' => 'Machine Data',
  1015. 'Icon' => $CatIcons.'machine_data.png',
  1016. 'Platforms' => $RawPlatforms,
  1017. 'Formats' => ['Plain' => $PlainFormats],
  1018. 'Description' => 'For raw reads and machine data of any category.',
  1019. ],
  1020. ];
  1021. ENV::setPub(
  1022. 'CATS',
  1023. new RecursiveArrayObject($CATS)
  1024. );
  1025. /**
  1026. * Regular expressions
  1027. *
  1028. * The Gazelle regex collection.
  1029. * Formerly in classes/regex.php.
  1030. */
  1031. // resource_type://username:password@domain:port/path?query_string#anchor
  1032. define('RESOURCE_REGEX', '(https?|ftps?):\/\/');
  1033. ENV::setPub(
  1034. 'RESOURCE_REGEX',
  1035. '(https?|ftps?):\/\/'
  1036. );
  1037. define('IP_REGEX', '(\d{1,3}\.){3}\d{1,3}');
  1038. ENV::setPub(
  1039. 'IP_REGEX',
  1040. '(\d{1,3}\.){3}\d{1,3}'
  1041. );
  1042. define('DOMAIN_REGEX', '([a-z0-9\-\_]+\.)*[a-z0-9\-\_]+');
  1043. ENV::setPub(
  1044. 'DOMAIN_REGEX',
  1045. '([a-z0-9\-\_]+\.)*[a-z0-9\-\_]+'
  1046. );
  1047. define('PORT_REGEX', ':\d{1,5}');
  1048. ENV::setPub(
  1049. 'PORT_REGEX',
  1050. ':\d{1,5}'
  1051. );
  1052. define('URL_REGEX', '('.RESOURCE_REGEX.')('.IP_REGEX.'|'.DOMAIN_REGEX.')('.PORT_REGEX.')?(\/\S*)*');
  1053. ENV::setPub(
  1054. 'URL_REGEX',
  1055. "($ENV->RESOURCE_REGEX)($ENV->IP_REGEX|$ENV->DOMAIN_REGEX)($ENV->PORT_REGEX)?(\/\S*)*"
  1056. );
  1057. define('USERNAME_REGEX', '/^[a-z0-9_]{2,20}$/iD');
  1058. ENV::setPub(
  1059. 'USERNAME_REGEX',
  1060. '/^[a-z0-9_]{2,20}$/iD'
  1061. );
  1062. define('EMAIL_REGEX', '[_a-z0-9-]+([.+][_a-z0-9-]+)*@'.DOMAIN_REGEX);
  1063. ENV::setPub(
  1064. 'EMAIL_REGEX',
  1065. "[_a-z0-9-]+([.+][_a-z0-9-]+)*@$ENV->DOMAIN_REGEX"
  1066. );
  1067. define('IMAGE_REGEX', URL_REGEX.'\/\S+\.(jpg|jpeg|tif|tiff|png|gif|bmp)(\?\S*)?');
  1068. ENV::setPub(
  1069. 'IMAGE_REGEX',
  1070. "$ENV->URL_REGEX\/\S+\.(jpg|jpeg|tif|tiff|png|gif|bmp)(\?\S*)?"
  1071. );
  1072. define('VIDEO_REGEX', URL_REGEX.'\/\S+\.(webm)(\?\S*)?');
  1073. ENV::setPub(
  1074. 'VIDEO_REGEX',
  1075. "$ENV->URL_REGEX\/\S+\.(webm)(\?\S*)?"
  1076. );
  1077. define('CSS_REGEX', URL_REGEX.'\/\S+\.css(\?\S*)?');
  1078. ENV::setPub(
  1079. 'CSS_REGEX',
  1080. "$ENV->URL_REGEX\/\S+\.css(\?\S*)?"
  1081. );
  1082. define('SITELINK_REGEX', RESOURCE_REGEX.'(www.)?'.preg_quote(SITE_DOMAIN, '/'));
  1083. ENV::setPub(
  1084. 'SITELINK_REGEX',
  1085. "$ENV->RESOURCE_REGEX(www.)?".preg_quote(SITE_DOMAIN, '/')
  1086. );
  1087. define('TORRENT_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?torrentid=(\d+)'); // torrentid = group 4
  1088. ENV::setPub(
  1089. 'TORRENT_REGEX',
  1090. "$ENV->SITELINK_REGEX\/torrents\.php\?(.*&)?torrentid=(\d+)"
  1091. );
  1092. define('TORRENT_GROUP_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?id=(\d+)'); // id = group 4
  1093. ENV::setPub(
  1094. 'TORRENT_GROUP_REGEX',
  1095. "$ENV->SITELINK_REGEX\/torrents\.php\?(.*&)?id=(\d+)"
  1096. );
  1097. define('ARTIST_REGEX', SITELINK_REGEX.'\/artist\.php\?(.*&)?id=(\d+)'); // id = group 4
  1098. ENV::setPub(
  1099. 'ARTIST_REGEX',
  1100. "$ENV->SITELINK_REGEX\/artist\.php\?(.*&)?id=(\d+)"
  1101. );
  1102. # https://stackoverflow.com/a/3180176
  1103. ENV::setPub(
  1104. 'HTML_REGEX',
  1105. '<([\w]+)([^>]*?)(([\s]*\/>)|(>((([^<]*?|<\!\-\-.*?\-\->)|(?R))*)<\/\\1[\s]*>))'
  1106. );
  1107. ENV::setPub(
  1108. 'BBCODE_REGEX',
  1109. '\[([\w]+)([^\]]*?)(([\s]*\/\])|(\]((([^\[]*?|\[\!\-\-.*?\-\-\])|(?R))*)\[\/\\1[\s]*\]))'
  1110. );
  1111. # https://www.crossref.org/blog/dois-and-matching-regular-expressions/
  1112. ENV::setPub(
  1113. 'DOI_REGEX',
  1114. '10.\d{4,9}\/[-._;()\/:A-Z0-9]+'
  1115. );
  1116. # https://www.biostars.org/p/13753/
  1117. ENV::setPub(
  1118. 'ENTREZ_REGEX',
  1119. '\d*'
  1120. );
  1121. # https://www.wikidata.org/wiki/Property:P496
  1122. ENV::setPub(
  1123. 'ORCID_REGEX',
  1124. '0000-000(1-[5-9]|2-[0-9]|3-[0-4])\d{3}-\d{3}[\dX]'
  1125. );
  1126. # https://www.biostars.org/p/13753/
  1127. ENV::setPub(
  1128. 'REFSEQ_REGEX',
  1129. '\w{2}_\d{1,}\.\d{1,}'
  1130. );
  1131. # https://www.uniprot.org/help/accession_numbers
  1132. ENV::setPub(
  1133. 'UNIPROT_REGEX',
  1134. '[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}'
  1135. );