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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364
  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. ENV::setPriv('IMAGE_PSK', '00000000000000000000000000000000');
  116. # Production
  117. if (!$ENV->DEV) {
  118. # Unused in OT Gazelle. Currently used for API token auth
  119. ENV::setPriv('ENCKEY', '00000000000000000000000000000000');
  120. # Alphanumeric random key. This key must be the argument to schedule.php for the schedule to work
  121. define('SCHEDULE_KEY', '00000000000000000000000000000000');
  122. ENV::setPriv('SCHEDULE_KEY', '00000000000000000000000000000000');
  123. # Random key. Used for generating unique RSS auth key
  124. define('RSS_HASH', '00000000000000000000000000000000');
  125. ENV::setPriv('RSS_HASH', '00000000000000000000000000000000');
  126. }
  127. # Development
  128. else {
  129. ENV::setPriv('ENCKEY', '00000000000000000000000000000000');
  130. define('SCHEDULE_KEY', '00000000000000000000000000000000');
  131. ENV::setPriv('SCHEDULE_KEY', '00000000000000000000000000000000');
  132. define('RSS_HASH', '00000000000000000000000000000000');
  133. ENV::setPriv('RSS_HASH', '00000000000000000000000000000000');
  134. }
  135. /**
  136. * Database
  137. */
  138. # Common info
  139. ENV::setPriv('SQLHOST', 'localhost');
  140. ENV::setPriv('SQLSOCK', '/var/run/mysqld/mysqld.sock');
  141. ENV::setPriv('SQLPORT', 3306);
  142. # Production
  143. if (!$ENV->DEV) {
  144. ENV::setPriv('SQLDB', 'gazelle_production');
  145. ENV::setPriv('SQLLOGIN', 'gazelle_production');
  146. ENV::setPriv('SQLPASS', '00000000000000000000000000000000');
  147. }
  148. # Development
  149. else {
  150. ENV::setPriv('SQLDB', 'gazelle_development');
  151. ENV::setPriv('SQLLOGIN', 'gazelle_development');
  152. ENV::setPriv('SQLPASS', '00000000000000000000000000000000');
  153. }
  154. /**
  155. * Tracker
  156. */
  157. # Ocelot connection, e.g., 0.0.0.0
  158. define('TRACKER_HOST', '0.0.0.0');
  159. ENV::setPriv('TRACKER_HOST', '0.0.0.0');
  160. # Production
  161. if (!$ENV->DEV) {
  162. define('TRACKER_PORT', 34000);
  163. ENV::setPriv('TRACKER_PORT', 34000);
  164. # Must be 32 alphanumeric characters and match site_password in ocelot.conf
  165. define('TRACKER_SECRET', '00000000000000000000000000000000');
  166. ENV::setPriv('TRACKER_SECRET', '00000000000000000000000000000000');
  167. # Must be 32 alphanumeric characters and match report_password in ocelot.conf
  168. define('TRACKER_REPORTKEY', '00000000000000000000000000000000');
  169. ENV::setPriv('TRACKER_REPORTKEY', '00000000000000000000000000000000');
  170. }
  171. # Development
  172. else {
  173. define('TRACKER_PORT', 34001);
  174. ENV::setPriv('TRACKER_PORT', 34001);
  175. define('TRACKER_SECRET', '00000000000000000000000000000000');
  176. ENV::setPriv('TRACKER_SECRET', '00000000000000000000000000000000');
  177. define('TRACKER_REPORTKEY', '00000000000000000000000000000000');
  178. ENV::setPriv('TRACKER_REPORTKEY', '00000000000000000000000000000000');
  179. }
  180. /**
  181. * Tracker URLs
  182. *
  183. * Added to torrents à la http://bittorrent.org/beps/bep_0012.html
  184. */
  185. # Production
  186. if (!$ENV->DEV) {
  187. define('ANNOUNCE_URLS', [
  188. [ # Tier 1
  189. 'https://track.biotorrents.de:443',
  190. ], [] # Tier 2
  191. ]);
  192. $AnnounceURLs = [
  193. [ # Tier 1
  194. 'https://track.biotorrents.de:443',
  195. ],
  196. [ # Tier 2
  197. #'udp://tracker.coppersurfer.tk:6969/announce',
  198. #'udp://tracker.cyberia.is:6969/announce',
  199. #'udp://tracker.leechers-paradise.org:6969/announce',
  200. ],
  201. ];
  202. ENV::setPub(
  203. 'ANNOUNCE_URLS',
  204. new RecursiveArrayObject($AnnounceURLs)
  205. );
  206. }
  207. # Development
  208. else {
  209. define('ANNOUNCE_URLS', [
  210. [ # Tier 1
  211. 'https://devtr.biotorrents.de:443',
  212. ], [] # Tier 2
  213. ]);
  214. $AnnounceURLs = [
  215. [ # Tier 1
  216. 'https://devtr.biotorrents.de:443',
  217. ], [], # Tier 2
  218. ];
  219. ENV::setPub(
  220. 'ANNOUNCE_URLS',
  221. new RecursiveArrayObject($AnnounceURLs)
  222. );
  223. }
  224. /**
  225. * Search
  226. */
  227. # SphinxqlQuery needs constants
  228. # $ENV breaks the torrent and request pages
  229. define('SPHINXQL_HOST', '127.0.0.1');
  230. define('SPHINXQL_PORT', 9306);
  231. define('SPHINXQL_SOCK', false);
  232. define('SPHINX_MAX_MATCHES', 1000); // Must be <= the server's max_matches variable (default 1000)
  233. /**
  234. * memcached
  235. *
  236. * Very important to run two instances,
  237. * one each for development and production.
  238. */
  239. # Production
  240. if (!$ENV->DEV) {
  241. ENV::setPriv(
  242. 'MEMCACHED_SERVERS',
  243. [[
  244. 'host' => 'unix:///var/run/memcached/memcached.sock',
  245. 'port' => 0,
  246. 'buckets' => 1
  247. ]]
  248. );
  249. }
  250. # Development
  251. else {
  252. ENV::setPriv(
  253. 'MEMCACHED_SERVERS',
  254. [[
  255. 'host' => 'unix:///var/run/memcached/memcached-dev.sock',
  256. 'port' => 0,
  257. 'buckets' => 1
  258. ]]
  259. );
  260. }
  261. /**
  262. * IRC/Slack
  263. */
  264. # IRC server address. Used for onsite chat tool
  265. define('BOT_SERVER', 'irc.'.SITE_DOMAIN);
  266. define('SOCKET_LISTEN_ADDRESS', 'localhost');
  267. define('SOCKET_LISTEN_PORT', 51010);
  268. define('BOT_NICK', 'ebooks');
  269. # IRC channels for official business
  270. define('ANNOUNCE_CHAN', '#announce');
  271. define('DEBUG_CHAN', '#debug');
  272. define('REQUEST_CHAN', '#requests');
  273. define('STAFF_CHAN', '#staff');
  274. define('ADMIN_CHAN', '#staff');
  275. define('HELP_CHAN', '#support');
  276. define('DISABLED_CHAN', '#support');
  277. #define('BOT_CHAN', '#userbots');
  278. # Slack invite link
  279. ENV::setPub(
  280. 'SLACK_INVITE',
  281. '00000000000000000000000000000000'
  282. );
  283. /**
  284. * ================
  285. * = NO MORE =
  286. * = PRIVATE INFO =
  287. * ================
  288. */
  289. /**
  290. * Features
  291. */
  292. # Enable donation page
  293. ENV::setPub('FEATURE_DONATE', true);
  294. # Send re-enable requests to user's email
  295. define('FEATURE_EMAIL_REENABLE', true); //
  296. ENV::setPub('FEATURE_EMAIL_REENABLE', true);
  297. # Require users to verify login from unknown locations
  298. ENV::setPub('FEATURE_ENFORCE_LOCATIONS', false);
  299. # Attempt to send messages to IRC
  300. ENV::setPub('FEATURE_IRC', true);
  301. # Attempt to send email from the site
  302. ENV::setPub('FEATURE_SEND_EMAIL', true);
  303. # Allow the site encryption key to be set without an account
  304. # (should only be used for initial setup)
  305. ENV::setPub('FEATURE_SET_ENC_KEY_PUBLIC', false);
  306. /**
  307. * Settings
  308. */
  309. # Set to false if you don't want everyone to see debug information; can be overriden with 'site_debug'
  310. define('DEBUG_MODE', false);
  311. ENV::setPub('DEBUG_MODE', false);
  312. # Set to false to disable open registration, true to allow anyone to register
  313. ENV::setPub(
  314. 'OPEN_REGISTRATION',
  315. (!$ENV->DEV
  316. ? true # Production
  317. : false) # Development
  318. );
  319. # The maximum number of users the site can have, 0 for no limit
  320. define('USER_LIMIT', 0);
  321. ENV::setPub('USER_LIMIT', 0);
  322. # User perks
  323. ENV::setPub('STARTING_INVITES', 2);
  324. ENV::setPub('STARTING_TOKENS', 2);
  325. ENV::setPub('STARTING_UPLOAD', 5368709120);
  326. define('DONOR_INVITES', 2);
  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 of 15 characters or longer will be accepted, but a strong password
  348. <ul>
  349. <li>is really a pass<em>phrase</em> with uppercase and lowercase letters and many small words,</li>
  350. <li>that contains numbers and symbols, including complex Unicode characters like 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' => 60,
  464. '10' => 61,
  465. '25' => 62,
  466. '50' => 63,
  467. '100' => 64,
  468. '250' => 65,
  469. '500' => 66,
  470. '1000' => 67,
  471. '2500' => 68,
  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. $DatabaseFields = [
  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. 'DBMAP',
  534. new RecursiveArrayObject($DatabaseFields)
  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. );