Merge pull request #5726 from 2002Bishwajeet/feat-whitelist-enums

Feat:  Whitelist enums
This commit is contained in:
Eldad A. Fux 2023-08-15 10:33:15 +03:00 committed by GitHub
commit 279b482f1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 467 additions and 237 deletions

View file

@ -2,20 +2,21 @@
return [
// Codes based on: https://github.com/matomo-org/device-detector/blob/master/Parser/Client/Browser.php
'aa' => __DIR__ . '/browsers/avant.png',
'an' => __DIR__ . '/browsers/android-webview-beta.png',
'ch' => __DIR__ . '/browsers/chrome.png',
'ci' => __DIR__ . '/browsers/chrome.png', //Chrome Mobile iOS
'cm' => __DIR__ . '/browsers/chrome.png', //Chrome Mobile
'cr' => __DIR__ . '/browsers/chromium.png',
'ff' => __DIR__ . '/browsers/firefox.png',
'sf' => __DIR__ . '/browsers/safari.png',
'mf' => __DIR__ . '/browsers/safari.png',
'ps' => __DIR__ . '/browsers/edge.png',
'oi' => __DIR__ . '/browsers/edge.png',
'om' => __DIR__ . '/browsers/opera-mini.png',
'op' => __DIR__ . '/browsers/opera.png',
'on' => __DIR__ . '/browsers/opera.png',
'aa' => ['name' => 'Avant Browser', 'path' => __DIR__ . '/browsers/avant.png'],
'an' => ['name' => 'Android WebView Beta', 'path' => __DIR__ . '/browsers/android-webview-beta.png'],
'ch' => ['name' => 'Google Chrome', 'path' => __DIR__ . '/browsers/chrome.png'],
'ci' => ['name' => 'Google Chrome (iOS)', 'path' => __DIR__ . '/browsers/chrome.png'],
'cm' => ['name' => 'Google Chrome (Mobile)', 'path' => __DIR__ . '/browsers/chrome.png'],
'cr' => ['name' => 'Chromium', 'path' => __DIR__ . '/browsers/chromium.png'],
'ff' => ['name' => 'Mozilla Firefox', 'path' => __DIR__ . '/browsers/firefox.png'],
'sf' => ['name' => 'Safari', 'path' => __DIR__ . '/browsers/safari.png'],
'mf' => ['name' => 'Mobile Safari', 'path' => __DIR__ . '/browsers/safari.png'],
'ps' => ['name' => 'Microsoft Edge', 'path' => __DIR__ . '/browsers/edge.png'],
'oi' => ['name' => 'Microsoft Edge (iOS)', 'path' => __DIR__ . '/browsers/edge.png'],
'om' => ['name' => 'Opera Mini', 'path' => __DIR__ . '/browsers/opera-mini.png'],
'op' => ['name' => 'Opera', 'path' => __DIR__ . '/browsers/opera.png'],
'on' => ['name' => 'Opera (Next)', 'path' => __DIR__ . '/browsers/opera.png'],
/*
'36' => '360 Phone Browser',

View file

@ -1,20 +1,20 @@
<?php
return [
'amex' => __DIR__ . '/credit-cards/amex.png',
'argencard' => __DIR__ . '/credit-cards/argencard.png',
'cabal' => __DIR__ . '/credit-cards/cabal.png',
'censosud' => __DIR__ . '/credit-cards/consosud.png',
'diners' => __DIR__ . '/credit-cards/diners.png',
'discover' => __DIR__ . '/credit-cards/discover.png',
'elo' => __DIR__ . '/credit-cards/elo.png',
'hipercard' => __DIR__ . '/credit-cards/hipercard.png',
'jcb' => __DIR__ . '/credit-cards/jcb.png',
'mastercard' => __DIR__ . '/credit-cards/mastercard.png',
'naranja' => __DIR__ . '/credit-cards/naranja.png',
'targeta-shopping' => __DIR__ . '/credit-cards/tarjeta-shopping.png',
'union-china-pay' => __DIR__ . '/credit-cards/union-china-pay.png',
'visa' => __DIR__ . '/credit-cards/visa.png',
'mir' => __DIR__ . '/credit-cards/mir.png',
'maestro' => __DIR__ . '/credit-cards/maestro.png',
];
'amex' => ['name' => 'American Express', 'path' => __DIR__ . '/credit-cards/amex.png'],
'argencard' => ['name' => 'Argencard', 'path' => __DIR__ . '/credit-cards/argencard.png'],
'cabal' => ['name' => 'Cabal', 'path' => __DIR__ . '/credit-cards/cabal.png'],
'censosud' => ['name' => 'Consosud', 'path' => __DIR__ . '/credit-cards/consosud.png'],
'diners' => ['name' => 'Diners Club', 'path' => __DIR__ . '/credit-cards/diners.png'],
'discover' => ['name' => 'Discover', 'path' => __DIR__ . '/credit-cards/discover.png'],
'elo' => ['name' => 'Elo', 'path' => __DIR__ . '/credit-cards/elo.png'],
'hipercard' => ['name' => 'Hipercard', 'path' => __DIR__ . '/credit-cards/hipercard.png'],
'jcb' => ['name' => 'JCB', 'path' => __DIR__ . '/credit-cards/jcb.png'],
'mastercard' => ['name' => 'Mastercard', 'path' => __DIR__ . '/credit-cards/mastercard.png'],
'naranja' => ['name' => 'Naranja', 'path' => __DIR__ . '/credit-cards/naranja.png'],
'targeta-shopping' => ['name' => 'Tarjeta Shopping', 'path' => __DIR__ . '/credit-cards/tarjeta-shopping.png'],
'union-china-pay' => ['name' => 'Union China Pay', 'path' => __DIR__ . '/credit-cards/union-china-pay.png'],
'visa' => ['name' => 'Visa', 'path' => __DIR__ . '/credit-cards/visa.png'],
'mir' => ['name' => 'MIR', 'path' => __DIR__ . '/credit-cards/mir.png'],
'maestro' => ['name' => 'Maestro', 'path' => __DIR__ . '/credit-cards/maestro.png']
];

View file

@ -1,198 +1,198 @@
<?php
return [
'af' => __DIR__ . '/flags/af.png',
'ao' => __DIR__ . '/flags/ao.png',
'al' => __DIR__ . '/flags/al.png',
'ad' => __DIR__ . '/flags/ad.png',
'ae' => __DIR__ . '/flags/ae.png',
'ar' => __DIR__ . '/flags/ar.png',
'am' => __DIR__ . '/flags/am.png',
'ag' => __DIR__ . '/flags/ag.png',
'au' => __DIR__ . '/flags/au.png',
'at' => __DIR__ . '/flags/at.png',
'az' => __DIR__ . '/flags/az.png',
'bi' => __DIR__ . '/flags/bi.png',
'be' => __DIR__ . '/flags/be.png',
'bj' => __DIR__ . '/flags/bj.png',
'bf' => __DIR__ . '/flags/bf.png',
'bd' => __DIR__ . '/flags/bd.png',
'bg' => __DIR__ . '/flags/bg.png',
'bh' => __DIR__ . '/flags/bh.png',
'bs' => __DIR__ . '/flags/bs.png',
'ba' => __DIR__ . '/flags/ba.png',
'by' => __DIR__ . '/flags/by.png',
'bz' => __DIR__ . '/flags/bz.png',
'bo' => __DIR__ . '/flags/bo.png',
'br' => __DIR__ . '/flags/br.png',
'bb' => __DIR__ . '/flags/bb.png',
'bn' => __DIR__ . '/flags/bn.png',
'bt' => __DIR__ . '/flags/bt.png',
'bw' => __DIR__ . '/flags/bw.png',
'cf' => __DIR__ . '/flags/cf.png',
'ca' => __DIR__ . '/flags/ca.png',
'ch' => __DIR__ . '/flags/ch.png',
'cl' => __DIR__ . '/flags/cl.png',
'cn' => __DIR__ . '/flags/cn.png',
'ci' => __DIR__ . '/flags/ci.png',
'cm' => __DIR__ . '/flags/cm.png',
'cd' => __DIR__ . '/flags/cd.png',
'cg' => __DIR__ . '/flags/cg.png',
'co' => __DIR__ . '/flags/co.png',
'km' => __DIR__ . '/flags/km.png',
'cv' => __DIR__ . '/flags/cv.png',
'cr' => __DIR__ . '/flags/cr.png',
'cu' => __DIR__ . '/flags/cu.png',
'cy' => __DIR__ . '/flags/cy.png',
'cz' => __DIR__ . '/flags/cz.png',
'de' => __DIR__ . '/flags/de.png',
'dj' => __DIR__ . '/flags/dj.png',
'dm' => __DIR__ . '/flags/dm.png',
'dk' => __DIR__ . '/flags/dk.png',
'do' => __DIR__ . '/flags/do.png',
'dz' => __DIR__ . '/flags/dz.png',
'ec' => __DIR__ . '/flags/ec.png',
'eg' => __DIR__ . '/flags/eg.png',
'er' => __DIR__ . '/flags/er.png',
'es' => __DIR__ . '/flags/es.png',
'ee' => __DIR__ . '/flags/ee.png',
'et' => __DIR__ . '/flags/et.png',
'fi' => __DIR__ . '/flags/fi.png',
'fj' => __DIR__ . '/flags/fj.png',
'fr' => __DIR__ . '/flags/fr.png',
'fm' => __DIR__ . '/flags/fm.png',
'ga' => __DIR__ . '/flags/ga.png',
'gb' => __DIR__ . '/flags/gb.png',
'ge' => __DIR__ . '/flags/ge.png',
'gh' => __DIR__ . '/flags/gh.png',
'gn' => __DIR__ . '/flags/gn.png',
'gm' => __DIR__ . '/flags/gm.png',
'gw' => __DIR__ . '/flags/gw.png',
'gq' => __DIR__ . '/flags/gq.png',
'gr' => __DIR__ . '/flags/gr.png',
'gd' => __DIR__ . '/flags/gd.png',
'gt' => __DIR__ . '/flags/gt.png',
'gy' => __DIR__ . '/flags/gy.png',
'hn' => __DIR__ . '/flags/hn.png',
'hr' => __DIR__ . '/flags/hr.png',
'ht' => __DIR__ . '/flags/ht.png',
'hu' => __DIR__ . '/flags/hu.png',
'id' => __DIR__ . '/flags/id.png',
'in' => __DIR__ . '/flags/in.png',
'ie' => __DIR__ . '/flags/ie.png',
'ir' => __DIR__ . '/flags/ir.png',
'iq' => __DIR__ . '/flags/iq.png',
'is' => __DIR__ . '/flags/is.png',
'il' => __DIR__ . '/flags/il.png',
'it' => __DIR__ . '/flags/it.png',
'jm' => __DIR__ . '/flags/jm.png',
'jo' => __DIR__ . '/flags/jo.png',
'jp' => __DIR__ . '/flags/jp.png',
'kz' => __DIR__ . '/flags/kz.png',
'ke' => __DIR__ . '/flags/ke.png',
'kg' => __DIR__ . '/flags/kg.png',
'kh' => __DIR__ . '/flags/kh.png',
'ki' => __DIR__ . '/flags/ki.png',
'kn' => __DIR__ . '/flags/kn.png',
'kr' => __DIR__ . '/flags/kr.png',
'kw' => __DIR__ . '/flags/kw.png',
'la' => __DIR__ . '/flags/la.png',
'lb' => __DIR__ . '/flags/lb.png',
'lr' => __DIR__ . '/flags/lr.png',
'ly' => __DIR__ . '/flags/ly.png',
'lc' => __DIR__ . '/flags/lc.png',
'li' => __DIR__ . '/flags/li.png',
'lk' => __DIR__ . '/flags/lk.png',
'ls' => __DIR__ . '/flags/ls.png',
'lt' => __DIR__ . '/flags/ls.png',
'lu' => __DIR__ . '/flags/lu.png',
'lv' => __DIR__ . '/flags/lv.png',
'ma' => __DIR__ . '/flags/ma.png',
'mc' => __DIR__ . '/flags/mc.png',
'md' => __DIR__ . '/flags/md.png',
'mg' => __DIR__ . '/flags/mg.png',
'mv' => __DIR__ . '/flags/mv.png',
'mx' => __DIR__ . '/flags/mx.png',
'mh' => __DIR__ . '/flags/mh.png',
'mk' => __DIR__ . '/flags/mk.png',
'ml' => __DIR__ . '/flags/ml.png',
'mt' => __DIR__ . '/flags/mt.png',
'mm' => __DIR__ . '/flags/mm.png',
'me' => __DIR__ . '/flags/me.png',
'mn' => __DIR__ . '/flags/mn.png',
'mz' => __DIR__ . '/flags/mz.png',
'mr' => __DIR__ . '/flags/mr.png',
'mu' => __DIR__ . '/flags/mu.png',
'mw' => __DIR__ . '/flags/mw.png',
'my' => __DIR__ . '/flags/my.png',
'na' => __DIR__ . '/flags/na.png',
'ne' => __DIR__ . '/flags/ne.png',
'ng' => __DIR__ . '/flags/ng.png',
'ni' => __DIR__ . '/flags/ni.png',
'nl' => __DIR__ . '/flags/nl.png',
'no' => __DIR__ . '/flags/no.png',
'np' => __DIR__ . '/flags/np.png',
'nr' => __DIR__ . '/flags/nr.png',
'nz' => __DIR__ . '/flags/nz.png',
'om' => __DIR__ . '/flags/om.png',
'pk' => __DIR__ . '/flags/pk.png',
'pa' => __DIR__ . '/flags/pa.png',
'pe' => __DIR__ . '/flags/pe.png',
'ph' => __DIR__ . '/flags/ph.png',
'pw' => __DIR__ . '/flags/pw.png',
'pg' => __DIR__ . '/flags/pg.png',
'pl' => __DIR__ . '/flags/pl.png',
'kp' => __DIR__ . '/flags/kp.png',
'pt' => __DIR__ . '/flags/pt.png',
'py' => __DIR__ . '/flags/py.png',
'qa' => __DIR__ . '/flags/qa.png',
'ro' => __DIR__ . '/flags/ro.png',
'ru' => __DIR__ . '/flags/ru.png',
'rw' => __DIR__ . '/flags/rw.png',
'sa' => __DIR__ . '/flags/sa.png',
'sd' => __DIR__ . '/flags/sd.png',
'sn' => __DIR__ . '/flags/sn.png',
'sg' => __DIR__ . '/flags/sg.png',
'sb' => __DIR__ . '/flags/sb.png',
'sl' => __DIR__ . '/flags/sl.png',
'sv' => __DIR__ . '/flags/sv.png',
'sm' => __DIR__ . '/flags/sm.png',
'so' => __DIR__ . '/flags/so.png',
'rs' => __DIR__ . '/flags/rs.png',
'ss' => __DIR__ . '/flags/ss.png',
'st' => __DIR__ . '/flags/st.png',
'sr' => __DIR__ . '/flags/sr.png',
'sk' => __DIR__ . '/flags/sk.png',
'si' => __DIR__ . '/flags/si.png',
'se' => __DIR__ . '/flags/se.png',
'sz' => __DIR__ . '/flags/sz.png',
'sc' => __DIR__ . '/flags/sc.png',
'sy' => __DIR__ . '/flags/sy.png',
'td' => __DIR__ . '/flags/td.png',
'tg' => __DIR__ . '/flags/tg.png',
'th' => __DIR__ . '/flags/th.png',
'tj' => __DIR__ . '/flags/tj.png',
'tm' => __DIR__ . '/flags/tm.png',
'tl' => __DIR__ . '/flags/tl.png',
'to' => __DIR__ . '/flags/to.png',
'tt' => __DIR__ . '/flags/tt.png',
'tn' => __DIR__ . '/flags/tn.png',
'tr' => __DIR__ . '/flags/tr.png',
'tv' => __DIR__ . '/flags/tv.png',
'tz' => __DIR__ . '/flags/tz.png',
'ug' => __DIR__ . '/flags/ug.png',
'ua' => __DIR__ . '/flags/ua.png',
'uy' => __DIR__ . '/flags/uy.png',
'us' => __DIR__ . '/flags/us.png',
'uz' => __DIR__ . '/flags/uz.png',
'va' => __DIR__ . '/flags/va.png',
'vc' => __DIR__ . '/flags/vc.png',
've' => __DIR__ . '/flags/ve.png',
'vn' => __DIR__ . '/flags/vn.png',
'vu' => __DIR__ . '/flags/vu.png',
'ws' => __DIR__ . '/flags/ws.png',
'ye' => __DIR__ . '/flags/ye.png',
'za' => __DIR__ . '/flags/za.png',
'zm' => __DIR__ . '/flags/zm.png',
'zw' => __DIR__ . '/flags/zw.png',
'af' => ['name' => 'Afghanistan', 'path' => __DIR__ . '/flags/af.png'],
'ao' => ['name' => 'Angola', 'path' => __DIR__ . '/flags/ao.png'],
'al' => ['name' => 'Albania', 'path' => __DIR__ . '/flags/al.png'],
'ad' => ['name' => 'Andorra', 'path' => __DIR__ . '/flags/ad.png'],
'ae' => ['name' => 'United Arab Emirates', 'path' => __DIR__ . '/flags/ae.png'],
'ar' => ['name' => 'Argentina', 'path' => __DIR__ . '/flags/ar.png'],
'am' => ['name' => 'Armenia', 'path' => __DIR__ . '/flags/am.png'],
'ag' => ['name' => 'Antigua and Barbuda', 'path' => __DIR__ . '/flags/ag.png'],
'au' => ['name' => 'Australia', 'path' => __DIR__ . '/flags/au.png'],
'at' => ['name' => 'Austria', 'path' => __DIR__ . '/flags/at.png'],
'az' => ['name' => 'Azerbaijan', 'path' => __DIR__ . '/flags/az.png'],
'bi' => ['name' => 'Burundi', 'path' => __DIR__ . '/flags/bi.png'],
'be' => ['name' => 'Belgium', 'path' => __DIR__ . '/flags/be.png'],
'bj' => ['name' => 'Benin', 'path' => __DIR__ . '/flags/bj.png'],
'bf' => ['name' => 'Burkina Faso', 'path' => __DIR__ . '/flags/bf.png'],
'bd' => ['name' => 'Bangladesh', 'path' => __DIR__ . '/flags/bd.png'],
'bg' => ['name' => 'Bulgaria', 'path' => __DIR__ . '/flags/bg.png'],
'bh' => ['name' => 'Bahrain', 'path' => __DIR__ . '/flags/bh.png'],
'bs' => ['name' => 'Bahamas', 'path' => __DIR__ . '/flags/bs.png'],
'ba' => ['name' => 'Bosnia and Herzegovina', 'path' => __DIR__ . '/flags/ba.png'],
'by' => ['name' => 'Belarus', 'path' => __DIR__ . '/flags/by.png'],
'bz' => ['name' => 'Belize', 'path' => __DIR__ . '/flags/bz.png'],
'bo' => ['name' => 'Bolivia', 'path' => __DIR__ . '/flags/bo.png'],
'br' => ['name' => 'Brazil', 'path' => __DIR__ . '/flags/br.png'],
'bb' => ['name' => 'Barbados', 'path' => __DIR__ . '/flags/bb.png'],
'bn' => ['name' => 'Brunei Darussalam', 'path' => __DIR__ . '/flags/bn.png'],
'bt' => ['name' => 'Bhutan', 'path' => __DIR__ . '/flags/bt.png'],
'bw' => ['name' => 'Botswana', 'path' => __DIR__ . '/flags/bw.png'],
'cf' => ['name' => 'Central African Republic', 'path' => __DIR__ . '/flags/cf.png'],
'ca' => ['name' => 'Canada', 'path' => __DIR__ . '/flags/ca.png'],
'ch' => ['name' => 'Switzerland', 'path' => __DIR__ . '/flags/ch.png'],
'cl' => ['name' => 'Chile', 'path' => __DIR__ . '/flags/cl.png'],
'cn' => ['name' => 'China', 'path' => __DIR__ . '/flags/cn.png'],
'ci' => ['name' => 'Côte d\'Ivoire', 'path' => __DIR__ . '/flags/ci.png'],
'cm' => ['name' => 'Cameroon', 'path' => __DIR__ . '/flags/cm.png'],
'cd' => ['name' => 'Democratic Republic of the Congo', 'path' => __DIR__ . '/flags/cd.png'],
'cg' => ['name' => 'Republic of the Congo', 'path' => __DIR__ . '/flags/cg.png'],
'co' => ['name' => 'Colombia', 'path' => __DIR__ . '/flags/co.png'],
'km' => ['name' => 'Comoros', 'path' => __DIR__ . '/flags/km.png'],
'cv' => ['name' => 'Cape Verde', 'path' => __DIR__ . '/flags/cv.png'],
'cr' => ['name' => 'Costa Rica', 'path' => __DIR__ . '/flags/cr.png'],
'cu' => ['name' => 'Cuba', 'path' => __DIR__ . '/flags/cu.png'],
'cy' => ['name' => 'Cyprus', 'path' => __DIR__ . '/flags/cy.png'],
'cz' => ['name' => 'Czech Republic', 'path' => __DIR__ . '/flags/cz.png'],
'de' => ['name' => 'Germany', 'path' => __DIR__ . '/flags/de.png'],
'dj' => ['name' => 'Djibouti', 'path' => __DIR__ . '/flags/dj.png'],
'dm' => ['name' => 'Dominica', 'path' => __DIR__ . '/flags/dm.png'],
'dk' => ['name' => 'Denmark', 'path' => __DIR__ . '/flags/dk.png'],
'do' => ['name' => 'Dominican Republic', 'path' => __DIR__ . '/flags/do.png'],
'dz' => ['name' => 'Algeria', 'path' => __DIR__ . '/flags/dz.png'],
'ec' => ['name' => 'Ecuador', 'path' => __DIR__ . '/flags/ec.png'],
'eg' => ['name' => 'Egypt', 'path' => __DIR__ . '/flags/eg.png'],
'er' => ['name' => 'Eritrea', 'path' => __DIR__ . '/flags/er.png'],
'es' => ['name' => 'Spain', 'path' => __DIR__ . '/flags/es.png'],
'ee' => ['name' => 'Estonia', 'path' => __DIR__ . '/flags/ee.png'],
'et' => ['name' => 'Ethiopia', 'path' => __DIR__ . '/flags/et.png'],
'fi' => ['name' => 'Finland', 'path' => __DIR__ . '/flags/fi.png'],
'fj' => ['name' => 'Fiji', 'path' => __DIR__ . '/flags/fj.png'],
'fr' => ['name' => 'France', 'path' => __DIR__ . '/flags/fr.png'],
'fm' => ['name' => 'Micronesia (Federated States of)', 'path' => __DIR__ . '/flags/fm.png'],
'ga' => ['name' => 'Gabon', 'path' => __DIR__ . '/flags/ga.png'],
'gb' => ['name' => 'United Kingdom', 'path' => __DIR__ . '/flags/gb.png'],
'ge' => ['name' => 'Georgia', 'path' => __DIR__ . '/flags/ge.png'],
'gh' => ['name' => 'Ghana', 'path' => __DIR__ . '/flags/gh.png'],
'gn' => ['name' => 'Guinea', 'path' => __DIR__ . '/flags/gn.png'],
'gm' => ['name' => 'Gambia', 'path' => __DIR__ . '/flags/gm.png'],
'gw' => ['name' => 'Guinea-Bissau', 'path' => __DIR__ . '/flags/gw.png'],
'gq' => ['name' => 'Equatorial Guinea', 'path' => __DIR__ . '/flags/gq.png'],
'gr' => ['name' => 'Greece', 'path' => __DIR__ . '/flags/gr.png'],
'gd' => ['name' => 'Grenada', 'path' => __DIR__ . '/flags/gd.png'],
'gt' => ['name' => 'Guatemala', 'path' => __DIR__ . '/flags/gt.png'],
'gy' => ['name' => 'Guyana', 'path' => __DIR__ . '/flags/gy.png'],
'hn' => ['name' => 'Honduras', 'path' => __DIR__ . '/flags/hn.png'],
'hr' => ['name' => 'Croatia', 'path' => __DIR__ . '/flags/hr.png'],
'ht' => ['name' => 'Haiti', 'path' => __DIR__ . '/flags/ht.png'],
'hu' => ['name' => 'Hungary', 'path' => __DIR__ . '/flags/hu.png'],
'id' => ['name' => 'Indonesia', 'path' => __DIR__ . '/flags/id.png'],
'in' => ['name' => 'India', 'path' => __DIR__ . '/flags/in.png'],
'ie' => ['name' => 'Ireland', 'path' => __DIR__ . '/flags/ie.png'],
'ir' => ['name' => 'Iran (Islamic Republic of)', 'path' => __DIR__ . '/flags/ir.png'],
'iq' => ['name' => 'Iraq', 'path' => __DIR__ . '/flags/iq.png'],
'is' => ['name' => 'Iceland', 'path' => __DIR__ . '/flags/is.png'],
'il' => ['name' => 'Israel', 'path' => __DIR__ . '/flags/il.png'],
'it' => ['name' => 'Italy', 'path' => __DIR__ . '/flags/it.png'],
'jm' => ['name' => 'Jamaica', 'path' => __DIR__ . '/flags/jm.png'],
'jo' => ['name' => 'Jordan', 'path' => __DIR__ . '/flags/jo.png'],
'jp' => ['name' => 'Japan', 'path' => __DIR__ . '/flags/jp.png'],
'kz' => ['name' => 'Kazakhstan', 'path' => __DIR__ . '/flags/kz.png'],
'ke' => ['name' => 'Kenya', 'path' => __DIR__ . '/flags/ke.png'],
'kg' => ['name' => 'Kyrgyzstan', 'path' => __DIR__ . '/flags/kg.png'],
'kh' => ['name' => 'Cambodia', 'path' => __DIR__ . '/flags/kh.png'],
'ki' => ['name' => 'Kiribati', 'path' => __DIR__ . '/flags/ki.png'],
'kn' => ['name' => 'Saint Kitts and Nevis', 'path' => __DIR__ . '/flags/kn.png'],
'kr' => ['name' => 'South Korea', 'path' => __DIR__ . '/flags/kr.png'],
'kw' => ['name' => 'Kuwait', 'path' => __DIR__ . '/flags/kw.png'],
'la' => ['name' => 'Lao People\'s Democratic Republic', 'path' => __DIR__ . '/flags/la.png'],
'lb' => ['name' => 'Lebanon', 'path' => __DIR__ . '/flags/lb.png'],
'lr' => ['name' => 'Liberia', 'path' => __DIR__ . '/flags/lr.png'],
'ly' => ['name' => 'Libya', 'path' => __DIR__ . '/flags/ly.png'],
'lc' => ['name' => 'Saint Lucia', 'path' => __DIR__ . '/flags/lc.png'],
'li' => ['name' => 'Liechtenstein', 'path' => __DIR__ . '/flags/li.png'],
'lk' => ['name' => 'Sri Lanka', 'path' => __DIR__ . '/flags/lk.png'],
'ls' => ['name' => 'Lesotho', 'path' => __DIR__ . '/flags/ls.png'],
'lt' => ['name' => 'Lithuania', 'path' => __DIR__ . '/flags/lt.png'],
'lu' => ['name' => 'Luxembourg', 'path' => __DIR__ . '/flags/lu.png'],
'lv' => ['name' => 'Latvia', 'path' => __DIR__ . '/flags/lv.png'],
'ma' => ['name' => 'Morocco', 'path' => __DIR__ . '/flags/ma.png'],
'mc' => ['name' => 'Monaco', 'path' => __DIR__ . '/flags/mc.png'],
'md' => ['name' => 'Moldova', 'path' => __DIR__ . '/flags/md.png'],
'mg' => ['name' => 'Madagascar', 'path' => __DIR__ . '/flags/mg.png'],
'mv' => ['name' => 'Maldives', 'path' => __DIR__ . '/flags/mv.png'],
'mx' => ['name' => 'Mexico', 'path' => __DIR__ . '/flags/mx.png'],
'mh' => ['name' => 'Marshall Islands', 'path' => __DIR__ . '/flags/mh.png'],
'mk' => ['name' => 'North Macedonia', 'path' => __DIR__ . '/flags/mk.png'],
'ml' => ['name' => 'Mali', 'path' => __DIR__ . '/flags/ml.png'],
'mt' => ['name' => 'Malta', 'path' => __DIR__ . '/flags/mt.png'],
'mm' => ['name' => 'Myanmar', 'path' => __DIR__ . '/flags/mm.png'],
'me' => ['name' => 'Montenegro', 'path' => __DIR__ . '/flags/me.png'],
'mn' => ['name' => 'Mongolia', 'path' => __DIR__ . '/flags/mn.png'],
'mz' => ['name' => 'Mozambique', 'path' => __DIR__ . '/flags/mz.png'],
'mr' => ['name' => 'Mauritania', 'path' => __DIR__ . '/flags/mr.png'],
'mu' => ['name' => 'Mauritius', 'path' => __DIR__ . '/flags/mu.png'],
'mw' => ['name' => 'Malawi', 'path' => __DIR__ . '/flags/mw.png'],
'my' => ['name' => 'Malaysia', 'path' => __DIR__ . '/flags/my.png'],
'na' => ['name' => 'Namibia', 'path' => __DIR__ . '/flags/na.png'],
'ne' => ['name' => 'Niger', 'path' => __DIR__ . '/flags/ne.png'],
'ng' => ['name' => 'Nigeria', 'path' => __DIR__ . '/flags/ng.png'],
'ni' => ['name' => 'Nicaragua', 'path' => __DIR__ . '/flags/ni.png'],
'nl' => ['name' => 'Netherlands', 'path' => __DIR__ . '/flags/nl.png'],
'no' => ['name' => 'Norway', 'path' => __DIR__ . '/flags/no.png'],
'np' => ['name' => 'Nepal', 'path' => __DIR__ . '/flags/np.png'],
'nr' => ['name' => 'Nauru', 'path' => __DIR__ . '/flags/nr.png'],
'nz' => ['name' => 'New Zealand', 'path' => __DIR__ . '/flags/nz.png'],
'om' => ['name' => 'Oman', 'path' => __DIR__ . '/flags/om.png'],
'pk' => ['name' => 'Pakistan', 'path' => __DIR__ . '/flags/pk.png'],
'pa' => ['name' => 'Panama', 'path' => __DIR__ . '/flags/pa.png'],
'pe' => ['name' => 'Peru', 'path' => __DIR__ . '/flags/pe.png'],
'ph' => ['name' => 'Philippines', 'path' => __DIR__ . '/flags/ph.png'],
'pw' => ['name' => 'Palau', 'path' => __DIR__ . '/flags/pw.png'],
'pg' => ['name' => 'Papua New Guinea', 'path' => __DIR__ . '/flags/pg.png'],
'pl' => ['name' => 'Poland', 'path' => __DIR__ . '/flags/pl.png'],
'kp' => ['name' => 'North Korea', 'path' => __DIR__ . '/flags/kp.png'],
'pt' => ['name' => 'Portugal', 'path' => __DIR__ . '/flags/pt.png'],
'py' => ['name' => 'Paraguay', 'path' => __DIR__ . '/flags/py.png'],
'qa' => ['name' => 'Qatar', 'path' => __DIR__ . '/flags/qa.png'],
'ro' => ['name' => 'Romania', 'path' => __DIR__ . '/flags/ro.png'],
'ru' => ['name' => 'Russia', 'path' => __DIR__ . '/flags/ru.png'],
'rw' => ['name' => 'Rwanda', 'path' => __DIR__ . '/flags/rw.png'],
'sa' => ['name' => 'Saudi Arabia', 'path' => __DIR__ . '/flags/sa.png'],
'sd' => ['name' => 'Sudan', 'path' => __DIR__ . '/flags/sd.png'],
'sn' => ['name' => 'Senegal', 'path' => __DIR__ . '/flags/sn.png'],
'sg' => ['name' => 'Singapore', 'path' => __DIR__ . '/flags/sg.png'],
'sb' => ['name' => 'Solomon Islands', 'path' => __DIR__ . '/flags/sb.png'],
'sl' => ['name' => 'Sierra Leone', 'path' => __DIR__ . '/flags/sl.png'],
'sv' => ['name' => 'El Salvador', 'path' => __DIR__ . '/flags/sv.png'],
'sm' => ['name' => 'San Marino', 'path' => __DIR__ . '/flags/sm.png'],
'so' => ['name' => 'Somalia', 'path' => __DIR__ . '/flags/so.png'],
'rs' => ['name' => 'Serbia', 'path' => __DIR__ . '/flags/rs.png'],
'ss' => ['name' => 'South Sudan', 'path' => __DIR__ . '/flags/ss.png'],
'st' => ['name' => 'Sao Tome and Principe', 'path' => __DIR__ . '/flags/st.png'],
'sr' => ['name' => 'Suriname', 'path' => __DIR__ . '/flags/sr.png'],
'sk' => ['name' => 'Slovakia', 'path' => __DIR__ . '/flags/sk.png'],
'si' => ['name' => 'Slovenia', 'path' => __DIR__ . '/flags/si.png'],
'se' => ['name' => 'Sweden', 'path' => __DIR__ . '/flags/se.png'],
'sz' => ['name' => 'Eswatini', 'path' => __DIR__ . '/flags/sz.png'],
'sc' => ['name' => 'Seychelles', 'path' => __DIR__ . '/flags/sc.png'],
'sy' => ['name' => 'Syria', 'path' => __DIR__ . '/flags/sy.png'],
'td' => ['name' => 'Chad', 'path' => __DIR__ . '/flags/td.png'],
'tg' => ['name' => 'Togo', 'path' => __DIR__ . '/flags/tg.png'],
'th' => ['name' => 'Thailand', 'path' => __DIR__ . '/flags/th.png'],
'tj' => ['name' => 'Tajikistan', 'path' => __DIR__ . '/flags/tj.png'],
'tm' => ['name' => 'Turkmenistan', 'path' => __DIR__ . '/flags/tm.png'],
'tl' => ['name' => 'Timor-Leste', 'path' => __DIR__ . '/flags/tl.png'],
'to' => ['name' => 'Tonga', 'path' => __DIR__ . '/flags/to.png'],
'tt' => ['name' => 'Trinidad and Tobago', 'path' => __DIR__ . '/flags/tt.png'],
'tn' => ['name' => 'Tunisia', 'path' => __DIR__ . '/flags/tn.png'],
'tr' => ['name' => 'Turkey', 'path' => __DIR__ . '/flags/tr.png'],
'tv' => ['name' => 'Tuvalu', 'path' => __DIR__ . '/flags/tv.png'],
'tz' => ['name' => 'Tanzania', 'path' => __DIR__ . '/flags/tz.png'],
'ug' => ['name' => 'Uganda', 'path' => __DIR__ . '/flags/ug.png'],
'ua' => ['name' => 'Ukraine', 'path' => __DIR__ . '/flags/ua.png'],
'uy' => ['name' => 'Uruguay', 'path' => __DIR__ . '/flags/uy.png'],
'us' => ['name' => 'United States', 'path' => __DIR__ . '/flags/us.png'],
'uz' => ['name' => 'Uzbekistan', 'path' => __DIR__ . '/flags/uz.png'],
'va' => ['name' => 'Vatican City', 'path' => __DIR__ . '/flags/va.png'],
'vc' => ['name' => 'Saint Vincent and the Grenadines', 'path' => __DIR__ . '/flags/vc.png'],
've' => ['name' => 'Venezuela', 'path' => __DIR__ . '/flags/ve.png'],
'vn' => ['name' => 'Vietnam', 'path' => __DIR__ . '/flags/vn.png'],
'vu' => ['name' => 'Vanuatu', 'path' => __DIR__ . '/flags/vu.png'],
'ws' => ['name' => 'Samoa', 'path' => __DIR__ . '/flags/ws.png'],
'ye' => ['name' => 'Yemen', 'path' => __DIR__ . '/flags/ye.png'],
'za' => ['name' => 'South Africa', 'path' => __DIR__ . '/flags/za.png'],
'zm' => ['name' => 'Zambia', 'path' => __DIR__ . '/flags/zm.png'],
'zw' => ['name' => 'Zimbabwe', 'path' => __DIR__ . '/flags/zw.png'],
];

View file

@ -358,6 +358,11 @@ return [
'description' => 'The requested range is not satisfiable. Please check the value of the Range header.',
'code' => 416,
],
Exception::STORAGE_INVALID_APPWRITE_ID => [
'name' => Exception::STORAGE_INVALID_APPWRITE_ID,
'description' => 'The value for x-appwrite-id header is invalid. Please check the value of the x-appwrite-id header is valid id and not unique().',
'code' => 400,
],
/** Functions */
Exception::FUNCTION_NOT_FOUND => [

View file

@ -362,10 +362,6 @@ return [
"code" => "ko",
"name" => "Korean",
],
[
"code" => "ko",
"name" => "Korean (Johab)",
],
[
"code" => "ku",
"name" => "Kurdish",

View file

@ -17,7 +17,7 @@
"emails.magicSession.signature": "Equipa {{project}}",
"emails.recovery.subject": "Redefinição de senha",
"emails.recovery.hello": "Olá {{name}}",
"emails.recovery.body": "tilize este link para redefinir a palavra-passe do seu projecto {{project}}",
"emails.recovery.body": "Utilize este link para redefinir a palavra-passe do seu projecto {{project}}",
"emails.recovery.footer": "Se não pediu para redefinir a sua palavra-passe, pode ignorar esta mensagem.",
"emails.recovery.thanks": "Obrigado",
"emails.recovery.signature": "Equipa {{project}}",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -42,7 +42,7 @@ $avatarCallback = function (string $type, string $code, int $width, int $height,
}
$output = 'png';
$path = $set[$code];
$path = $set[$code]['path'];
$type = 'png';
if (!\is_readable($path)) {

View file

@ -443,6 +443,11 @@ App::post('/v1/storage/buckets/:bucketId/files')
throw new Exception(Exception::STORAGE_INVALID_CONTENT_RANGE);
}
$idValidator = new UID();
if (!$idValidator->isValid($request->getHeader('x-appwrite-id'))) {
throw new Exception(Exception::STORAGE_INVALID_APPWRITE_ID);
}
// TODO remove the condition that checks `$end === $fileSize` in next breaking version
if ($end === $fileSize - 1 || $end === $fileSize) {
//if it's a last chunks the chunk size might differ, so we set the $chunks and $chunk to -1 notify it's last chunk

View file

@ -113,6 +113,7 @@ class Exception extends \Exception
public const STORAGE_BUCKET_NOT_FOUND = 'storage_bucket_not_found';
public const STORAGE_INVALID_CONTENT_RANGE = 'storage_invalid_content_range';
public const STORAGE_INVALID_RANGE = 'storage_invalid_range';
public const STORAGE_INVALID_APPWRITE_ID = 'storage_invalid_appwrite_id';
/** Functions */
public const FUNCTION_NOT_FOUND = 'function_not_found';

View file

@ -3,6 +3,7 @@
namespace Appwrite\Specification;
use Utopia\App;
use Utopia\Config\Config;
use Utopia\Route;
use Appwrite\Utopia\Response\Model;
@ -38,6 +39,17 @@ abstract class Format
'license.url' => '',
];
/*
* Blacklist to omit the enum types for the given route's parameter
*/
protected array $enumBlacklist = [
[
'namespace' => 'users',
'method' => 'getUsage',
'parameter' => 'provider'
]
];
public function __construct(App $app, array $services, array $routes, array $models, array $keys, int $authCount)
{
$this->app = $app;
@ -97,4 +109,141 @@ abstract class Format
{
return $this->params[$key] ?? $default;
}
protected function getEnumName(string $service, string $method, string $param): ?string
{
switch ($service) {
case 'account':
switch ($method) {
case 'createOAuth2Session':
return 'Provider';
}
break;
case 'avatars':
switch ($method) {
case 'getBrowser':
return 'Browser';
case 'getCreditCard':
return 'CreditCard';
case 'getFlag':
return 'Flag';
}
break;
case 'storage':
switch ($method) {
case 'getFilePreview':
switch ($param) {
case 'gravity':
return 'ImageGravity';
case 'output':
return 'ImageFormat';
}
break;
}
break;
case 'databases':
switch ($method) {
case 'createRelationshipAttribute':
switch ($param) {
case 'type':
return 'RelationshipType';
case 'onDelete':
return 'RelationMutate';
}
break;
case 'updateRelationshipAttribute':
switch ($param) {
case 'onDelete':
return 'RelationMutate';
}
break;
case 'createIndex':
switch ($param) {
case 'type':
return 'IndexType';
case 'orders':
return 'OrderBy';
}
}
break;
case 'projects':
switch ($method) {
case 'createPlatform':
switch ($param) {
case 'type':
return 'PlatformType';
}
break;
}
break;
}
return null;
}
public function getEnumKeys(string $service, string $method, string $param): array
{
$values = [];
switch ($service) {
case 'avatars':
switch ($method) {
case 'getBrowser':
$codes = Config::getParam('avatar-browsers');
foreach ($codes as $code => $value) {
$values[] = $value['name'];
}
return $values;
case 'getCreditCard':
$codes = Config::getParam('avatar-credit-cards');
foreach ($codes as $code => $value) {
$values[] = $value['name'];
}
return $values;
case 'getFlag':
$codes = Config::getParam('avatar-flags');
foreach ($codes as $code => $value) {
$values[] = $value['name'];
}
return $values;
}
break;
case 'databases':
switch ($method) {
case 'getUsage':
case 'getCollectionUsage':
case 'getDatabaseUsage':
// Range Enum Keys
$values = ['Twenty Four Hours', 'Seven Days', 'Thirty Days', 'Ninety Days'];
return $values;
}
break;
case 'function':
switch ($method) {
case 'getUsage':
case 'getFunctionUsage':
// Range Enum Keys
$values = ['Twenty Four Hours', 'Seven Days', 'Thirty Days', 'Ninety Days'];
return $values;
}
break;
case 'users':
switch ($method) {
case 'getUsage':
case 'getUserUsage':
// Range Enum Keys
if ($param == 'range') {
$values = ['Twenty Four Hours', 'Seven Days', 'Thirty Days', 'Ninety Days'];
return $values;
}
}
break;
case 'storage':
switch ($method) {
case 'getUsage':
case 'getBucketUsage':
// Range Enum Keys
$values = ['Twenty Four Hours', 'Seven Days', 'Thirty Days', 'Ninety Days'];
return $values;
}
}
return $values;
}
}

View file

@ -414,6 +414,25 @@ class OpenAPI3 extends Format
$node['schema']['type'] = $validator->getType();
$node['schema']['x-example'] = $validator->getList()[0];
//Iterate from the blackList. If it matches with the current one, then it is a blackList
// Do not add the enum
$allowed = true;
foreach ($this->enumBlacklist as $blacklist) {
if (
$blacklist['namespace'] == $route->getLabel('sdk.namespace', '')
&& $blacklist['method'] == $route->getLabel('sdk.method', '')
&& $blacklist['parameter'] == $name
) {
$allowed = false;
break;
}
}
if ($allowed) {
$node['schema']['enum'] = $validator->getList();
$node['schema']['x-enum-name'] = $this->getEnumName($route->getLabel('sdk.namespace', ''), $route->getLabel('sdk.method', ''), $name);
$node['schema']['x-enum-keys'] = $this->getEnumKeys($route->getLabel('sdk.namespace', ''), $route->getLabel('sdk.method', ''), $name);
}
if ($validator->getType() === 'integer') {
$node['format'] = 'int32';
}
@ -444,6 +463,13 @@ class OpenAPI3 extends Format
'x-example' => $node['schema']['x-example'] ?? null
];
if (isset($node['schema']['enum'])) {
/// If the enum flag is Set, add the enum values to the body
$body['content'][$consumes[0]]['schema']['properties'][$name]['enum'] = $node['schema']['enum'];
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-enum-name'] = $node['schema']['x-enum-name'] ?? null;
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-enum-keys'] = $node['schema']['x-enum-keys'] ?? null;
}
if ($node['schema']['x-upload-id'] ?? false) {
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-upload-id'] = $node['schema']['x-upload-id'];
}

View file

@ -293,6 +293,7 @@ class Swagger2 extends Format
$validator = $validator->getValidator();
}
switch ((!empty($validator)) ? \get_class($validator) : '') {
case 'Utopia\Validator\Text':
$node['type'] = $validator->getType();
@ -416,6 +417,22 @@ class Swagger2 extends Format
$node['type'] = $validator->getType();
$node['x-example'] = $validator->getList()[0];
//Iterate from the blackList. If it matches with the current one, then it is a blackList
// Do not add the enum
$allowed = true;
foreach ($this->enumBlacklist as $blacklist) {
if ($blacklist['namespace'] == $route->getLabel('sdk.namespace', '') && $blacklist['method'] == $route->getLabel('sdk.method', '') && $blacklist['parameter'] == $name) {
$allowed = false;
break;
}
}
if ($allowed) {
$node['enum'] = $validator->getList();
$node['x-enum-name'] = $this->getEnumName($route->getLabel('sdk.namespace', ''), $route->getLabel('sdk.method', ''), $name);
$node['x-enum-keys'] = $this->getEnumKeys($route->getLabel('sdk.namespace', ''), $route->getLabel('sdk.method', ''), $name);
}
if ($validator->getType() === 'integer') {
$node['format'] = 'int32';
}
@ -454,6 +471,13 @@ class Swagger2 extends Format
'x-example' => $node['x-example'] ?? null,
];
if (isset($node['enum'])) {
/// If the enum flag is Set, add the enum values to the body
$body['schema']['properties'][$name]['enum'] = $node['enum'];
$body['schema']['properties'][$name]['x-enum-name'] = $node['x-enum-name'] ?? null;
$body['schema']['properties'][$name]['x-enum-keys'] = $node['x-enum-keys'] ?? null;
}
if ($node['x-global'] ?? false) {
$body['schema']['properties'][$name]['x-global'] = true;
}

View file

@ -241,6 +241,29 @@ trait StorageBase
$this->assertEquals(400, $failedBucket['headers']['status-code']);
/**
* Test for FAILURE set x-appwrite-id to unique()
*/
$source = realpath(__DIR__ . '/../../../resources/logo.png');
$totalSize = \filesize($source);
$res = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files', array_merge([
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
'content-range' => 'bytes 0-' . $size . '/' . $size,
'x-appwrite-id' => 'unique()',
], $this->getHeaders()), [
'fileId' => ID::unique(),
'file' => new CURLFile($source, 'image/png', 'logo.png'),
'permissions' => [
Permission::read(Role::any()),
Permission::update(Role::any()),
Permission::delete(Role::any()),
],
]);
$this->assertEquals(400, $res['headers']['status-code']);
$this->assertEquals('The value for x-appwrite-id header is invalid. Please check the value of the x-appwrite-id header is valid id and not unique().', $res['body']['message']);
return ['bucketId' => $bucketId, 'fileId' => $file['body']['$id'], 'largeFileId' => $largeFile['body']['$id'], 'largeBucketId' => $bucket2['body']['$id']];
}