functions.php 305 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350
  1. <?php
  2. // ===================================
  3. // Define Version
  4. define('INSTALLEDVERSION', '1.50');
  5. // ===================================
  6. use Kryptonit3\Sonarr\Sonarr;
  7. use Kryptonit3\SickRage\SickRage;
  8. // Debugging output functions
  9. function debug_out($variable, $die = false) {
  10. $trace = debug_backtrace()[0];
  11. echo "<center><img height='200px' src='images/confused.png'></center>";
  12. echo "<center>Look's like something happened, here are the errors and perhaps how to fix them:</center>";
  13. echo '<pre style="white-space: pre-line; background-color: #f2f2f2; border: 2px solid black; border-radius: 5px; padding: 5px; margin: 5px;">'.$trace['file'].':'.$trace['line']."\n\n".print_r($variable, true).'</pre>';
  14. if ($die) { http_response_code(503); die(); }
  15. }
  16. // ==== Auth Plugins START ====
  17. if (function_exists('ldap_connect')) :
  18. // Pass credentials to LDAP backend
  19. function plugin_auth_ldap($username, $password) {
  20. $ldapServers = explode(',',AUTHBACKENDHOST);
  21. foreach($ldapServers as $key => $value) {
  22. // Calculate parts
  23. $digest = parse_url(trim($value));
  24. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:'ldap'));
  25. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  26. $port = (isset($digest['port'])?$digest['port']:(strtolower($scheme)=='ldap'?389:636));
  27. // Reassign
  28. $ldapServers[$key] = $scheme.'://'.$host.':'.$port;
  29. }
  30. // returns true or false
  31. $ldap = ldap_connect(implode(' ',$ldapServers));
  32. if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
  33. writeLog("success", "LDAP authentication success");
  34. return true;
  35. } else {
  36. writeLog("error", "LDPA could not authenticate");
  37. return false;
  38. }
  39. writeLog("error", "LDPA could not authenticate");
  40. return false;
  41. }
  42. else :
  43. // Ldap Auth Missing Dependancy
  44. function plugin_auth_ldap_disabled() {
  45. return 'LDAP - Disabled (Dependancy: php-ldap missing!)';
  46. }
  47. endif;
  48. // Pass credentials to FTP backend
  49. function plugin_auth_ftp($username, $password) {
  50. // Calculate parts
  51. $digest = parse_url(AUTHBACKENDHOST);
  52. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:(function_exists('ftp_ssl_connect')?'ftps':'ftp')));
  53. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  54. $port = (isset($digest['port'])?$digest['port']:21);
  55. // Determine Connection Type
  56. if ($scheme == 'ftps') {
  57. $conn_id = ftp_ssl_connect($host, $port, 20);
  58. } elseif ($scheme == 'ftp') {
  59. $conn_id = ftp_connect($host, $port, 20);
  60. } else {
  61. debug_out('Invalid FTP scheme. Use ftp or ftps');
  62. writeLog("error", "invalid FTP scheme");
  63. return false;
  64. }
  65. // Check if valid FTP connection
  66. if ($conn_id) {
  67. // Attempt login
  68. @$login_result = ftp_login($conn_id, $username, $password);
  69. ftp_close($conn_id);
  70. // Return Result
  71. if ($login_result) {
  72. writeLog("success", "$username authenticated");
  73. return true;
  74. } else {
  75. writeLog("error", "$username could not authenticate");
  76. return false;
  77. }
  78. } else {
  79. return false;
  80. }
  81. return false;
  82. }
  83. // Pass credentials to Emby Backend
  84. function plugin_auth_emby_local($username, $password) {
  85. $embyAddress = qualifyURL(EMBYURL);
  86. $headers = array(
  87. 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"',
  88. 'Content-Type' => 'application/json',
  89. );
  90. $body = array(
  91. 'Username' => $username,
  92. 'Password' => sha1($password),
  93. 'PasswordMd5' => md5($password),
  94. );
  95. $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers);
  96. if (isset($response['content'])) {
  97. $json = json_decode($response['content'], true);
  98. if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
  99. // Login Success - Now Logout Emby Session As We No Longer Need It
  100. $headers = array(
  101. 'X-Mediabrowser-Token' => $json['AccessToken'],
  102. );
  103. $response = post_router($embyAddress.'/Sessions/Logout', array(), $headers);
  104. return true;
  105. }
  106. }
  107. return false;
  108. }
  109. if (function_exists('curl_version')) :
  110. // Authenticate Against Emby Local (first) and Emby Connect
  111. function plugin_auth_emby_all($username, $password) {
  112. $localResult = plugin_auth_emby_local($username, $password);
  113. if ($localResult) {
  114. return $localResult;
  115. } else {
  116. return plugin_auth_emby_connect($username, $password);
  117. }
  118. }
  119. // Authenicate against emby connect
  120. function plugin_auth_emby_connect($username, $password) {
  121. $embyAddress = qualifyURL(EMBYURL);
  122. // Get A User
  123. $connectId = '';
  124. $userIds = json_decode(file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
  125. if (is_array($userIds)) {
  126. foreach ($userIds as $key => $value) { // Scan for this user
  127. if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
  128. if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
  129. $connectId = $value['ConnectUserId'];
  130. break;
  131. }
  132. }
  133. }
  134. if ($connectId) {
  135. $connectURL = 'https://connect.emby.media/service/user/authenticate';
  136. $headers = array(
  137. 'Accept'=> 'application/json',
  138. 'Content-Type' => 'application/x-www-form-urlencoded',
  139. );
  140. $body = array(
  141. 'nameOrEmail' => $username,
  142. 'rawpw' => $password,
  143. );
  144. $result = curl_post($connectURL, $body, $headers);
  145. if (isset($result['content'])) {
  146. $json = json_decode($result['content'], true);
  147. if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
  148. return array(
  149. 'email' => $json['User']['Email'],
  150. 'image' => $json['User']['ImageUrl'],
  151. );
  152. }
  153. }
  154. }
  155. }
  156. return false;
  157. }
  158. // Pass credentials to Plex Backend
  159. function plugin_auth_plex($username, $password) {
  160. // Quick out
  161. if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
  162. writeLog("success", $username." authenticated by plex");
  163. return true;
  164. }
  165. //Get User List
  166. $userURL = 'https://plex.tv/pms/friends/all';
  167. $userHeaders = array(
  168. 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD),
  169. );
  170. libxml_use_internal_errors(true);
  171. $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
  172. if (is_array($userXML) || is_object($userXML)) {
  173. $isUser = false;
  174. $usernameLower = strtolower($username);
  175. foreach($userXML AS $child) {
  176. if(isset($child['username']) && strtolower($child['username']) == $usernameLower) {
  177. $isUser = true;
  178. writeLog("success", $usernameLower." was found in plex friends list");
  179. break;
  180. }
  181. }
  182. if ($isUser) {
  183. //Login User
  184. $connectURL = 'https://plex.tv/users/sign_in.json';
  185. $headers = array(
  186. 'Accept'=> 'application/json',
  187. 'Content-Type' => 'application/x-www-form-urlencoded',
  188. 'X-Plex-Product' => 'Organizr',
  189. 'X-Plex-Version' => '1.0',
  190. 'X-Plex-Client-Identifier' => '01010101-10101010',
  191. );
  192. $body = array(
  193. 'user[login]' => $username,
  194. 'user[password]' => $password,
  195. );
  196. $result = curl_post($connectURL, $body, $headers);
  197. if (isset($result['content'])) {
  198. $json = json_decode($result['content'], true);
  199. if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && strtolower($json['user']['username']) == $usernameLower) {
  200. writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
  201. return array(
  202. 'email' => $json['user']['email'],
  203. 'image' => $json['user']['thumb']
  204. );
  205. }
  206. }
  207. }else{
  208. writeLog("error", "$username is not an authorized PLEX user or entered invalid password");
  209. }
  210. }else{
  211. writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");
  212. }
  213. return false;
  214. }
  215. else :
  216. // Plex Auth Missing Dependancy
  217. function plugin_auth_plex_disabled() {
  218. return 'Plex - Disabled (Dependancy: php-curl missing!)';
  219. }
  220. // Emby Connect Auth Missing Dependancy
  221. function plugin_auth_emby_connect_disabled() {
  222. return 'Emby Connect - Disabled (Dependancy: php-curl missing!)';
  223. }
  224. // Emby Both Auth Missing Dependancy
  225. function plugin_auth_emby_both_disabled() {
  226. return 'Emby Both - Disabled (Dependancy: php-curl missing!)';
  227. }
  228. endif;
  229. // ==== Auth Plugins END ====
  230. // ==== General Class Definitions START ====
  231. class setLanguage {
  232. private $language = null;
  233. private $langCode = null;
  234. function __construct($language = false) {
  235. // Default
  236. if (!$language) {
  237. $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  238. }
  239. if (!file_exists("lang/{$language}.ini")) {
  240. $language = 'en';
  241. }
  242. $this->langCode = $language;
  243. $this->language = parse_ini_file("lang/{$language}.ini", false, INI_SCANNER_RAW);
  244. if (file_exists("lang/{$language}.cust.ini")) {
  245. foreach($tmp = parse_ini_file("lang/{$language}.cust.ini", false, INI_SCANNER_RAW) as $k => $v) {
  246. $this->language[$k] = $v;
  247. }
  248. }
  249. }
  250. public function getLang() {
  251. return $this->langCode;
  252. }
  253. public function translate($originalWord) {
  254. $getArg = func_num_args();
  255. if ($getArg > 1) {
  256. $allWords = func_get_args();
  257. array_shift($allWords);
  258. } else {
  259. $allWords = array();
  260. }
  261. $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null;
  262. if (!$translatedWord) {
  263. return ucwords(str_replace("_", " ", strtolower($originalWord)));
  264. //echo "WHOA!!!!!!! $originalWord";
  265. }
  266. $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES);
  267. return vsprintf($translatedWord, $allWords);
  268. }
  269. }
  270. $language = new setLanguage;
  271. // ==== General Class Definitions END ====
  272. // Direct request to curl if it exists, otherwise handle if not HTTPS
  273. function post_router($url, $data, $headers = array(), $referer='') {
  274. if (function_exists('curl_version')) {
  275. return curl_post($url, $data, $headers, $referer);
  276. } else {
  277. return post_request($url, $data, $headers, $referer);
  278. }
  279. }
  280. if (function_exists('curl_version')) :
  281. // Curl Post
  282. function curl_post($url, $data, $headers = array(), $referer='') {
  283. // Initiate cURL
  284. $curlReq = curl_init($url);
  285. // As post request
  286. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST");
  287. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  288. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  289. if(localURL($url)){
  290. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  291. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  292. }
  293. // Format Data
  294. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  295. case 'application/json':
  296. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  297. break;
  298. case 'application/x-www-form-urlencoded';
  299. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  300. break;
  301. default:
  302. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  303. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  304. }
  305. // Format Headers
  306. $cHeaders = array();
  307. foreach ($headers as $k => $v) {
  308. $cHeaders[] = $k.': '.$v;
  309. }
  310. if (count($cHeaders)) {
  311. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  312. }
  313. // Execute
  314. $result = curl_exec($curlReq);
  315. $httpcode = curl_getinfo($curlReq);
  316. // Close
  317. curl_close($curlReq);
  318. // Return
  319. return array('content'=>$result, 'http_code'=>$httpcode);
  320. }
  321. //Curl Get Function
  322. function curl_get($url, $headers = array()) {
  323. // Initiate cURL
  324. $curlReq = curl_init($url);
  325. // As post request
  326. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET");
  327. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  328. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  329. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  330. if(localURL($url)){
  331. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  332. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  333. }
  334. // Format Headers
  335. $cHeaders = array();
  336. foreach ($headers as $k => $v) {
  337. $cHeaders[] = $k.': '.$v;
  338. }
  339. if (count($cHeaders)) {
  340. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  341. }
  342. // Execute
  343. $result = curl_exec($curlReq);
  344. // Close
  345. curl_close($curlReq);
  346. // Return
  347. return $result;
  348. }
  349. //Curl Delete Function
  350. function curl_delete($url, $headers = array()) {
  351. // Initiate cURL
  352. $curlReq = curl_init($url);
  353. // As post request
  354. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE");
  355. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  356. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  357. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  358. if(localURL($url)){
  359. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  360. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  361. }
  362. // Format Headers
  363. $cHeaders = array();
  364. foreach ($headers as $k => $v) {
  365. $cHeaders[] = $k.': '.$v;
  366. }
  367. if (count($cHeaders)) {
  368. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  369. }
  370. // Execute
  371. $result = curl_exec($curlReq);
  372. $httpcode = curl_getinfo($curlReq);
  373. // Close
  374. curl_close($curlReq);
  375. // Return
  376. return array('content'=>$result, 'http_code'=>$httpcode);
  377. }
  378. endif;
  379. //Case-Insensitive Function
  380. function in_arrayi($needle, $haystack) {
  381. return in_array(strtolower($needle), array_map('strtolower', $haystack));
  382. }
  383. // HTTP post request (Removes need for curl, probably useless)
  384. function post_request($url, $data, $headers = array(), $referer='') {
  385. // Adapted from http://stackoverflow.com/a/28387011/6810513
  386. // Convert the data array into URL Parameters like a=b&foo=bar etc.
  387. if (isset($headers['Content-Type'])) {
  388. switch ($headers['Content-Type']) {
  389. case 'application/json':
  390. $data = json_encode($data);
  391. break;
  392. case 'application/x-www-form-urlencoded':
  393. $data = http_build_query($data);
  394. break;
  395. }
  396. } else {
  397. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  398. $data = http_build_query($data);
  399. }
  400. // parse the given URL
  401. $urlDigest = parse_url($url);
  402. // extract host and path:
  403. $host = $urlDigest['host'];
  404. $path = $urlDigest['path'];
  405. if ($urlDigest['scheme'] != 'http') {
  406. die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')');
  407. }
  408. // open a socket connection on port 80 - timeout: 30 sec
  409. $fp = fsockopen($host, (isset($urlDigest['port'])?':'.$urlDigest['port']:80), $errno, $errstr, 30);
  410. if ($fp){
  411. // send the request headers:
  412. fputs($fp, "POST $path HTTP/1.1\r\n");
  413. fputs($fp, "Host: $host\r\n");
  414. if ($referer != '')
  415. fputs($fp, "Referer: $referer\r\n");
  416. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  417. foreach($headers as $k => $v) {
  418. fputs($fp, $k.": ".$v."\r\n");
  419. }
  420. fputs($fp, "Connection: close\r\n\r\n");
  421. fputs($fp, $data);
  422. $result = '';
  423. while(!feof($fp)) {
  424. // receive the results of the request
  425. $result .= fgets($fp, 128);
  426. }
  427. }
  428. else {
  429. return array(
  430. 'status' => 'err',
  431. 'error' => "$errstr ($errno)"
  432. );
  433. }
  434. // close the socket connection:
  435. fclose($fp);
  436. // split the result header from the content
  437. $result = explode("\r\n\r\n", $result, 2);
  438. $header = isset($result[0]) ? $result[0] : '';
  439. $content = isset($result[1]) ? $result[1] : '';
  440. // return as structured array:
  441. return array(
  442. 'status' => 'ok',
  443. 'header' => $header,
  444. 'content' => $content,
  445. );
  446. }
  447. // Format item from Emby for Carousel
  448. function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $moreInfo = false) {
  449. // Static Height
  450. $height = 444;
  451. // Get Item Details
  452. $itemDetails = json_decode(file_get_contents($address.'/Items?Ids='.$item['Id'].'&api_key='.$token),true)['Items'][0];
  453. if (substr_count(EMBYURL, ':') == 2) {
  454. $URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  455. }else{
  456. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  457. }
  458. //$URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  459. switch ($itemDetails['Type']) {
  460. case 'Episode':
  461. $title = (isset($itemDetails['SeriesName'])?$itemDetails['SeriesName']:"");
  462. $imageId = (isset($itemDetails['SeriesId'])?$itemDetails['SeriesId']:$itemDetails['Id']);
  463. $width = 300;
  464. $style = '';
  465. $image = 'slick-image-tall';
  466. if(!$nowPlaying){
  467. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  468. $key = $itemDetails['Id'] . "-list";
  469. }else{
  470. $height = 281;
  471. $width = 500;
  472. $imageId = isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId'] : (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  473. $imageType = isset($itemDetails['ParentThumbItemId']) ? "Thumb" : (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  474. $key = (isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId']."-np" : "none-np");
  475. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  476. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  477. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  478. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  479. $stream = $moreInfo['PlayState']['PlayMethod'];
  480. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  481. $id = $moreInfo['DeviceId'];
  482. $streamInfo = buildStream(array(
  483. 'platform' => (string) $moreInfo['Client'],
  484. 'device' => (string) $moreInfo['DeviceName'],
  485. 'stream' => streamType($stream),
  486. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  487. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  488. ));
  489. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  490. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$itemDetails['Name'].'</h5>';
  491. $bottomTitle = '<small class="zero-m">S'.$itemDetails['ParentIndexNumber'].' · E'.$itemDetails['IndexNumber'].'</small>';
  492. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  493. }
  494. break;
  495. case 'MusicAlbum':
  496. case 'Audio':
  497. $title = $itemDetails['Name'];
  498. $imageId = $itemDetails['Id'];
  499. $width = 444;
  500. $style = '';
  501. $image = 'slick-image-short';
  502. if(!$nowPlaying){
  503. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  504. $key = $itemDetails['Id'] . "-list";
  505. }else{
  506. $height = 281;
  507. $width = 500;
  508. $imageId = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  509. $imageType = (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  510. $key = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : "no-np") . "-np";
  511. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  512. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  513. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  514. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  515. $stream = $moreInfo['PlayState']['PlayMethod'];
  516. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  517. $id = $moreInfo['DeviceId'];
  518. $streamInfo = buildStream(array(
  519. 'platform' => (string) $moreInfo['Client'],
  520. 'device' => (string) $moreInfo['DeviceName'],
  521. 'stream' => streamType($stream),
  522. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  523. ));
  524. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  525. $topTitle = '<h5 class="text-center zero-m elip">'.$itemDetails['AlbumArtist'].' - '.$itemDetails['Album'].'</h5>';
  526. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  527. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  528. }
  529. break;
  530. case 'TvChannel':
  531. $title = $itemDetails['CurrentProgram']['Name'];
  532. $imageId = $itemDetails['Id'];
  533. $width = 300;
  534. $style = '';
  535. $image = 'slick-image-tall';
  536. if(!$nowPlaying){
  537. $imageType = "Primary";
  538. $key = $itemDetails['Id'] . "-list";
  539. }else{
  540. $height = 281;
  541. $width = 500;
  542. $imageType = "Thumb";
  543. $key = $itemDetails['Id'] . "-np";
  544. $useImage = "images/livetv.png";
  545. $watched = "0";
  546. $stream = $moreInfo['PlayState']['PlayMethod'];
  547. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  548. $id = $moreInfo['DeviceId'];
  549. $streamInfo = buildStream(array(
  550. 'platform' => (string) $moreInfo['Client'],
  551. 'device' => (string) $moreInfo['DeviceName'],
  552. 'stream' => streamType($stream),
  553. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  554. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  555. ));
  556. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  557. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  558. $bottomTitle = '<small class="zero-m">'.$itemDetails['Name'].' - '.$itemDetails['ChannelNumber'].'</small>';
  559. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  560. }
  561. break;
  562. default:
  563. $title = $itemDetails['Name'];
  564. $imageId = $itemDetails['Id'];
  565. $width = 300;
  566. $style = '';
  567. $image = 'slick-image-tall';
  568. if(!$nowPlaying){
  569. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  570. $key = $itemDetails['Id'] . "-list";
  571. }else{
  572. $height = 281;
  573. $width = 500;
  574. $imageType = isset($itemDetails['ImageTags']['Thumb']) ? "Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
  575. $key = $itemDetails['Id'] . "-np";
  576. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  577. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  578. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  579. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  580. $stream = $moreInfo['PlayState']['PlayMethod'];
  581. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  582. $id = $moreInfo['DeviceId'];
  583. $streamInfo = buildStream(array(
  584. 'platform' => (string) $moreInfo['Client'],
  585. 'device' => (string) $moreInfo['DeviceName'],
  586. 'stream' => streamType($stream),
  587. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  588. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  589. ));
  590. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  591. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  592. $bottomTitle = '<small class="zero-m">'.$moreInfo['NowPlayingItem']['ProductionYear'].'</small>';
  593. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  594. }
  595. }
  596. // If No Overview
  597. if (!isset($itemDetails['Overview'])) {
  598. $itemDetails['Overview'] = '';
  599. }
  600. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  601. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  602. $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'';
  603. }
  604. if($nowPlaying){
  605. if(!$imageType){ $image_url = "images/no-np.png"; $key = "no-np"; }
  606. if(!$imageId){ $image_url = "images/no-np.png"; $key = "no-np"; }
  607. }else{
  608. if(!$imageType){ $image_url = "images/no-list.png"; $key = "no-list"; }
  609. if(!$imageId){ $image_url = "images/no-list.png"; $key = "no-list"; }
  610. }
  611. if(isset($useImage)){ $image_url = $useImage; }
  612. // Assemble Item And Cache Into Array
  613. if($nowPlaying){
  614. //prettyPrint($itemDetails);
  615. return '<div class="col-sm-6 col-md-3"><div class="thumbnail ultra-widget"><div style="display: none;" np="'.$id.'" class="overlay content-box small-box gray-bg">'.$streamInfo.'</div><span class="w-refresh w-p-icon gray" link="'.$id.'"><span class="fa-stack fa-lg" style="font-size: .5em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-info-circle fa-stack-1x fa-inverse"></i></span></span><a href="'.$URL.'" target="_blank"><img style="width: 100%; display:inherit;" src="'.$image_url.'" alt="'.$itemDetails['Name'].'"></a><div class="progress progress-bar-sm zero-m"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$watched.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$watched.'%"></div><div class="progress-bar palette-Grey-500 bg" style="width: 0%"></div></div><div class="caption"><i style="float:left" class="fa fa-'.$state.'"></i>'.$topTitle.''.$bottomTitle.'</div></div></div>';
  616. }else{
  617. return '<div class="item-'.$itemDetails['Type'].'"><a href="'.$URL.'" target="_blank"><img alt="'.$itemDetails['Name'].'" class="'.$image.'" data-lazy="'.$image_url.'"></a><small style="margin-right: 13px" class="elip">'.$title.'</small></div>';
  618. }
  619. }
  620. // Format item from Plex for Carousel
  621. function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $playlist = false) {
  622. // Static Height
  623. $height = 444;
  624. $playlist = ($playlist) ? " playlist-$playlist" : "";
  625. switch ($item['type']) {
  626. case 'season':
  627. $title = $item['parentTitle'];
  628. $summary = $item['parentSummary'];
  629. $width = 300;
  630. $image = 'slick-image-tall';
  631. $style = '';
  632. if(!$nowPlaying){
  633. $thumb = $item['thumb'];
  634. $key = $item['ratingKey'] . "-list";
  635. }else {
  636. $height = 281;
  637. $width = 500;
  638. $thumb = $item['art'];
  639. $key = $item['ratingKey'] . "-np";
  640. $elapsed = $item['viewOffset'];
  641. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  642. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  643. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  644. $stream = $item->Media->Part->Stream['decision'];
  645. $user = $role == "admin" ? $item->User['title'] : "";
  646. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  647. $streamInfo = buildStream(array(
  648. 'platform' => (string) $item->Player['platform'],
  649. 'device' => (string) $item->Player['device'],
  650. 'stream' => streamType($item->Media->Part['decision']),
  651. 'video' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['width']."x".$item->Media->Part->Stream[0]['height'].")",
  652. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  653. ));
  654. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  655. }
  656. break;
  657. case 'episode':
  658. $title = $item['grandparentTitle'];
  659. $summary = $item['title'];
  660. $width = 300;
  661. $image = 'slick-image-tall';
  662. $style = '';
  663. if(!$nowPlaying){
  664. $thumb = ($item['parentThumb'] ? $item['parentThumb'] : $item['grandparentThumb']);
  665. $key = $item['ratingKey'] . "-list";
  666. }else {
  667. $height = 281;
  668. $width = 500;
  669. $thumb = $item['art'];
  670. $key = $item['ratingKey'] . "-np";
  671. $elapsed = $item['viewOffset'];
  672. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  673. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  674. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  675. $stream = $item->Media->Part->Stream['decision'];
  676. $user = $role == "admin" ? $item->User['title'] : "";
  677. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  678. $streamInfo = buildStream(array(
  679. 'platform' => (string) $item->Player['platform'],
  680. 'device' => (string) $item->Player['device'],
  681. 'stream' => streamType($item->Media->Part['decision']),
  682. 'video' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['width']."x".$item->Media->Part->Stream[0]['height'].")",
  683. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  684. ));
  685. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  686. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$item['title'].'</h5>';
  687. $bottomTitle = '<small class="zero-m">S'.$item['parentIndex'].' · E'.$item['index'].'</small>';
  688. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  689. }
  690. break;
  691. case 'clip':
  692. $title = $item['title'];
  693. $summary = $item['summary'];
  694. $width = 300;
  695. $image = 'slick-image-tall';
  696. $style = '';
  697. if(!$nowPlaying){
  698. $thumb = $item['thumb'];
  699. $key = $item['ratingKey'] . "-list";
  700. }else {
  701. $height = 281;
  702. $width = 500;
  703. $thumb = $item['art'];
  704. $key = isset($item['ratingKey']) ? $item['ratingKey'] . "-np" : (isset($item['live']) ? "livetv.png" : ":)");
  705. $useImage = (isset($item['live']) ? "images/livetv.png" : null);
  706. $extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
  707. $elapsed = $item['viewOffset'];
  708. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  709. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  710. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  711. $stream = $item->Media->Part->Stream['decision'];
  712. $user = $role == "admin" ? $item->User['title'] : "";
  713. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  714. $streamInfo = buildStream(array(
  715. 'platform' => (string) $item->Player['platform'],
  716. 'device' => (string) $item->Player['device'],
  717. 'stream' => streamType($item->Media->Part['decision']),
  718. 'video' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['width']."x".$item->Media->Part->Stream[0]['height'].")",
  719. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  720. ));
  721. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  722. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  723. $bottomTitle = '<small class="zero-m">'.$extraInfo.'</small>';
  724. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  725. }
  726. break;
  727. case 'album':
  728. case 'track':
  729. $title = $item['parentTitle'];
  730. $summary = $item['title'];
  731. $image = 'slick-image-short';
  732. $style = 'left: 160px !important;';
  733. $item['ratingKey'] = $item['parentRatingKey'];
  734. if(!$nowPlaying){
  735. $width = 444;
  736. $thumb = $item['thumb'];
  737. $key = $item['ratingKey'] . "-list";
  738. }else {
  739. $height = 281;
  740. $width = 500;
  741. $thumb = $item['art'];
  742. $key = $item['ratingKey'] . "-np";
  743. $elapsed = $item['viewOffset'];
  744. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  745. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  746. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  747. $stream = $item->Media->Part->Stream['decision'];
  748. $user = $role == "admin" ? $item->User['title'] : "";
  749. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  750. $streamInfo = buildStream(array(
  751. 'platform' => (string) $item->Player['platform'],
  752. 'device' => (string) $item->Player['device'],
  753. 'stream' => streamType($item->Media->Part['decision']),
  754. 'audio' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['channels']."ch)",
  755. ));
  756. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  757. $topTitle = '<h5 class="text-center zero-m elip">'.$item['grandparentTitle'].' - '.$item['title'].'</h5>';
  758. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  759. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  760. }
  761. break;
  762. default:
  763. $title = $item['title'];
  764. $summary = $item['summary'];
  765. $image = 'slick-image-tall';
  766. $style = '';
  767. if(!$nowPlaying){
  768. $width = 300;
  769. $thumb = $item['thumb'];
  770. $key = $item['ratingKey'] . "-list";
  771. }else {
  772. $height = 281;
  773. $width = 500;
  774. $thumb = $item['art'];
  775. $key = $item['ratingKey'] . "-np";
  776. $elapsed = $item['viewOffset'];
  777. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  778. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  779. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  780. $stream = $item->Media->Part->Stream['decision'];
  781. $user = $role == "admin" ? $item->User['title'] : "";
  782. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  783. $streamInfo = buildStream(array(
  784. 'platform' => (string) $item->Player['platform'],
  785. 'device' => (string) $item->Player['device'],
  786. 'stream' => streamType($item->Media->Part['decision']),
  787. 'video' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['width']."x".$item->Media->Part->Stream[0]['height'].")",
  788. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  789. ));
  790. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  791. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  792. $bottomTitle = '<small class="zero-m">'.$item['year'].'</small>';
  793. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  794. }
  795. }
  796. if (substr_count(PLEXURL, '.') != 2) {
  797. $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  798. }else{
  799. $address = PLEXURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  800. }
  801. // If No Overview
  802. if (!isset($itemDetails['Overview'])) { $itemDetails['Overview'] = ''; }
  803. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  804. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  805. $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'';
  806. }
  807. if($nowPlaying){
  808. if(!$thumb){ $image_url = "images/no-np.png"; $key = "no-np"; }
  809. }else{
  810. if(!$thumb){ $image_url = "images/no-list.png"; $key = "no-list"; }
  811. }
  812. if(isset($useImage)){ $image_url = $useImage; }
  813. $openTab = (PLEXTABNAME) ? "true" : "false";
  814. // Assemble Item And Cache Into Array
  815. if($nowPlaying){
  816. return '<div class="col-sm-6 col-md-3"><div class="thumbnail ultra-widget"><div style="display: none;" np="'.$id.'" class="overlay content-box small-box gray-bg">'.$streamInfo.'</div><span class="w-refresh w-p-icon gray" link="'.$id.'"><span class="fa-stack fa-lg" style="font-size: .5em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-info-circle fa-stack-1x fa-inverse"></i></span></span><a class="openTab" extraTitle="'.$title.'" extraType="'.$item['type'].'" openTab="'.$openTab.'" href="'.$address.'" target="_blank"><img style="width: 100%; display:inherit;" src="'.$image_url.'" alt="'.$item['Name'].'"></a><div class="progress progress-bar-sm zero-m"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$watched.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$watched.'%"></div><div class="progress-bar palette-Grey-500 bg" style="width: '.$transcoded.'%"></div></div><div class="caption"><i style="float:left" class="fa fa-'.$state.'"></i>'.$topTitle.''.$bottomTitle.'</div></div></div>';
  817. }else{
  818. return '<div class="item-'.$item['type'].$playlist.'"><a class="openTab" extraTitle="'.$title.'" extraType="'.$item['type'].'" openTab="'.$openTab.'" href="'.$address.'" target="_blank"><img alt="'.$item['Name'].'" class="'.$image.'" data-lazy="'.$image_url.'"></a><small style="margin-right: 13px" class="elip">'.$title.'</small></div>';
  819. }
  820. }
  821. //$hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  822. //Recent Added
  823. function outputRecentAdded($header, $items, $script = false, $array) {
  824. $hideMenu = '<div class="pull-right"><div class="btn-group" role="group"><button type="button" class="btn waves btn-default btn-sm dropdown-toggle waves-effect waves-float" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Filter &nbsp;<span class="caret"></span></button><ul style="right:0; left: auto" class="dropdown-menu filter-recent-event">';
  825. if(preg_grep("/item-movie/", $items)){
  826. $hideMenu .= '<li data-filter="item-movie" data-name="Movies" data-filter-on="false"><a class="js-filter-movie" href="javascript:void(0)">Movies</a></li>';
  827. }
  828. if(preg_grep("/item-season/", $items)){
  829. $hideMenu .= '<li data-filter="item-season" data-name="TV Shows" data-filter-on="false"><a class="js-filter-season" href="javascript:void(0)">Shows</a></li>';
  830. }
  831. if(preg_grep("/item-album/", $items)){
  832. $hideMenu .= '<li data-filter="item-album" data-name="Music Albums" data-filter-on="false"><a class="js-filter-album" href="javascript:void(0)">Music</a></li>';
  833. }
  834. $hideMenu .= '<li data-filter="item-all" data-name="Content" data-filter-on="false"><a class="js-filter-all" href="javascript:void(0)">All</a></li>';
  835. $hideMenu .= '</ul></div></div>';
  836. // If None Populate Empty Item
  837. if (!count($items)) {
  838. return '<div id="recentMedia" class="content-box box-shadow big-box"><h5 class="text-center">'.$header.'</h5><p class="text-center">No Media Found</p></div>';
  839. }else{
  840. $className = str_replace(' ', '', $header);
  841. return '<div id="recentMedia" class="content-box box-shadow big-box"><h5 id="recentContent-title" style="margin-bottom: -20px" class="text-center">'.$header.'</h5><div class="recentHeader inbox-pagination '.$className.'">'.$hideMenu.'</div><br/><br/><div class="recentItems-recent" data-name="'.$className.'">'.implode('',$items).'</div></div>'.($script?'<script>'.$script.'</script>':'');
  842. }
  843. }
  844. // Create Carousel
  845. function outputNowPlaying($header, $size, $type, $items, $script = false) {
  846. // If None Populate Empty Item
  847. if (!count($items)) {
  848. return '<div id=streamz></div>'.($script?'<script>'.$script.'</script>':'');
  849. }else{
  850. return '<div id=streamz><h5 class="zero-m big-box"><strong>'.$header.'</strong></h5>'.implode('',$items).'</div>'.($script?'<script>'.$script.'</script>':'');
  851. }
  852. }
  853. // Get Now Playing Streams From Emby
  854. function getEmbyStreams($size, $showNames, $role) {
  855. $address = qualifyURL(EMBYURL);
  856. $api = json_decode(@file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
  857. if (!is_array($api)) { return 'Could not load!'; }
  858. $playingItems = array();
  859. foreach($api as $key => $value) {
  860. if (isset($value['NowPlayingItem'])) {
  861. $playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem'], true, $showNames, $role, $value);
  862. }
  863. }
  864. return outputNowPlaying(translate('PLAYING_NOW_ON_EMBY'), $size, 'streams-emby', $playingItems, "
  865. setInterval(function() {
  866. $('<div></div>').load('ajax.php?a=emby-streams',function() {
  867. var element = $(this).find('[id]');
  868. var loadedID = element.attr('id');
  869. $('#'+loadedID).replaceWith(element);
  870. console.log('Loaded updated: '+loadedID);
  871. });
  872. }, 15000);
  873. ");
  874. }
  875. // Get Now Playing Streams From Plex
  876. function getPlexStreams($size, $showNames, $role){
  877. $address = qualifyURL(PLEXURL);
  878. // Perform API requests
  879. $api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
  880. libxml_use_internal_errors(true);
  881. $api = simplexml_load_string($api);
  882. if (is_array($api) || is_object($api)){
  883. if (!$api->head->title){
  884. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  885. if (!$getServer) { return 'Could not load!'; }
  886. // Identify the local machine
  887. $gotServer = $getServer['machineIdentifier'];
  888. $items = array();
  889. foreach($api AS $child) {
  890. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
  891. }
  892. return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." ( ".count($items)." Streams )", $size, 'streams-plex', $items, "
  893. setInterval(function() {
  894. $('<div></div>').load('ajax.php?a=plex-streams',function() {
  895. var element = $(this).find('[id]');
  896. var loadedID = element.attr('id');
  897. $('#'+loadedID).replaceWith(element);
  898. console.log('Loaded updated: '+loadedID);
  899. });
  900. }, 15000);
  901. ");
  902. }else{
  903. writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
  904. }
  905. }else{
  906. writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
  907. }
  908. }
  909. // Get Recent Content From Emby
  910. function getEmbyRecent($array) {
  911. $address = qualifyURL(EMBYURL);
  912. $header = translate('RECENT_CONTENT');
  913. // Currently Logged In User
  914. $username = false;
  915. if (isset($GLOBALS['USER'])) {
  916. $username = strtolower($GLOBALS['USER']->username);
  917. }
  918. // Get A User
  919. $userIds = json_decode(@file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
  920. if (!is_array($userIds)) { return 'Could not load!'; }
  921. $showPlayed = true;
  922. foreach ($userIds as $value) { // Scan for admin user
  923. if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
  924. $userId = $value['Id'];
  925. }
  926. if ($username && strtolower($value['Name']) == $username) {
  927. $userId = $value['Id'];
  928. $showPlayed = false;
  929. break;
  930. }
  931. }
  932. // Get the latest Items
  933. $latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?EnableImages=false&Limit='.EMBYRECENTITEMS.'&api_key='.EMBYTOKEN.($showPlayed?'':'&IsPlayed=false')),true);
  934. // For Each Item In Category
  935. $items = array();
  936. foreach ($latest as $k => $v) {
  937. $type = (string) $v['Type'];
  938. if(@$array[$type] == "true"){
  939. $items[] = resolveEmbyItem($address, EMBYTOKEN, $v, false, false, false);
  940. }
  941. }
  942. $array["movie"] = $array["Movie"];
  943. $array["season"] = $array["Episode"];
  944. $array["album"] = $array["MusicAlbum"];
  945. unset($array["Movie"]);
  946. unset($array["Episode"]);
  947. unset($array["MusicAlbum"]);
  948. unset($array["Series"]);
  949. return outputRecentAdded($header, $items, "", $array);
  950. }
  951. // Get Recent Content From Plex
  952. function getPlexRecent($array){
  953. $address = qualifyURL(PLEXURL);
  954. $header = translate('RECENT_CONTENT');
  955. // Perform Requests
  956. $api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN);
  957. libxml_use_internal_errors(true);
  958. $api = simplexml_load_string($api);
  959. if (is_array($api) || is_object($api)){
  960. if (!$api->head->title){
  961. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  962. if (!$getServer) { return 'Could not load!'; }
  963. // Identify the local machine
  964. $gotServer = $getServer['machineIdentifier'];
  965. $items = array();
  966. foreach($api AS $child) {
  967. $type = (string) $child['type'];
  968. if($array[$type] == "true"){
  969. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
  970. }
  971. }
  972. return outputRecentAdded($header, $items, "", $array);
  973. }else{
  974. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check token - if HTTPS, is cert valid");
  975. }
  976. }else{
  977. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check URL - if HTTPS, is cert valid");
  978. }
  979. }
  980. // Get Image From Emby
  981. function getEmbyImage() {
  982. $embyAddress = qualifyURL(EMBYURL);
  983. if (!file_exists('images/cache')) {
  984. mkdir('images/cache', 0777, true);
  985. }
  986. $itemId = $_GET['img'];
  987. $key = $_GET['key'];
  988. $itemType = $_GET['type'];
  989. $imgParams = array();
  990. if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
  991. if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
  992. if(isset($itemId)) {
  993. $image_src = $embyAddress . '/Items/'.$itemId.'/Images/'.$itemType.'?'.implode('&', $imgParams);
  994. $cachefile = 'images/cache/'.$key.'.jpg';
  995. $cachetime = 604800;
  996. // Serve from the cache if it is younger than $cachetime
  997. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
  998. header("Content-type: image/jpeg");
  999. @readfile($cachefile);
  1000. exit;
  1001. }
  1002. ob_start(); // Start the output buffer
  1003. header('Content-type: image/jpeg');
  1004. @readfile($image_src);
  1005. // Cache the output to a file
  1006. $fp = fopen($cachefile, 'wb');
  1007. fwrite($fp, ob_get_contents());
  1008. fclose($fp);
  1009. ob_end_flush(); // Send the output to the browser
  1010. die();
  1011. } else {
  1012. debug_out('Invalid Request',1);
  1013. }
  1014. }
  1015. // Get Image From Plex
  1016. function getPlexImage() {
  1017. $plexAddress = qualifyURL(PLEXURL);
  1018. if (!file_exists('images/cache')) {
  1019. mkdir('images/cache', 0777, true);
  1020. }
  1021. $image_url = $_GET['img'];
  1022. $key = $_GET['key'];
  1023. $image_height = $_GET['height'];
  1024. $image_width = $_GET['width'];
  1025. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  1026. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  1027. $cachefile = 'images/cache/'.$key.'.jpg';
  1028. $cachetime = 604800;
  1029. // Serve from the cache if it is younger than $cachetime
  1030. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
  1031. header("Content-type: image/jpeg");
  1032. @readfile($cachefile);
  1033. exit;
  1034. }
  1035. ob_start(); // Start the output buffer
  1036. header('Content-type: image/jpeg');
  1037. @readfile($image_src);
  1038. // Cache the output to a file
  1039. $fp = fopen($cachefile, 'wb');
  1040. fwrite($fp, ob_get_contents());
  1041. fclose($fp);
  1042. ob_end_flush(); // Send the output to the browser
  1043. die();
  1044. } else {
  1045. echo "Invalid Plex Request";
  1046. }
  1047. }
  1048. // Simplier access to class
  1049. function translate($string) {
  1050. if (isset($GLOBALS['language'])) {
  1051. return $GLOBALS['language']->translate($string);
  1052. } else {
  1053. return '!Translations Not Loaded!';
  1054. }
  1055. }
  1056. // Generate Random string
  1057. function randString($length = 10, $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  1058. $tmp = '';
  1059. for ($i = 0; $i < $length; $i++) {
  1060. $tmp .= substr(str_shuffle($chars), 0, 1);
  1061. }
  1062. return $tmp;
  1063. }
  1064. // Create config file in the return syntax
  1065. function createConfig($array, $path = 'config/config.php', $nest = 0) {
  1066. // Define Initial Value
  1067. $output = array();
  1068. // Sort Items
  1069. ksort($array);
  1070. // Update the current config version
  1071. if (!$nest) {
  1072. // Inject Current Version
  1073. $output[] = "\t'CONFIG_VERSION' => '".(isset($array['apply_CONFIG_VERSION'])?$array['apply_CONFIG_VERSION']:INSTALLEDVERSION)."'";
  1074. }
  1075. unset($array['CONFIG_VERSION']);
  1076. unset($array['apply_CONFIG_VERSION']);
  1077. // Process Settings
  1078. foreach ($array as $k => $v) {
  1079. $allowCommit = true;
  1080. switch (gettype($v)) {
  1081. case 'boolean':
  1082. $item = ($v?'true':'false');
  1083. break;
  1084. case 'integer':
  1085. case 'double':
  1086. case 'integer':
  1087. case 'NULL':
  1088. $item = $v;
  1089. break;
  1090. case 'string':
  1091. $item = "'".str_replace(array('\\',"'"),array('\\\\',"\'"),$v)."'";
  1092. break;
  1093. case 'array':
  1094. $item = createConfig($v, false, $nest+1);
  1095. break;
  1096. default:
  1097. $allowCommit = false;
  1098. }
  1099. if($allowCommit) {
  1100. $output[] = str_repeat("\t",$nest+1)."'$k' => $item";
  1101. }
  1102. }
  1103. // Build output
  1104. $output = (!$nest?"<?php\nreturn ":'')."array(\n".implode(",\n",$output)."\n".str_repeat("\t",$nest).')'.(!$nest?';':'');
  1105. if (!$nest && $path) {
  1106. $pathDigest = pathinfo($path);
  1107. @mkdir($pathDigest['dirname'], 0770, true);
  1108. if (file_exists($path)) {
  1109. rename($path, $pathDigest['dirname'].'/'.$pathDigest['filename'].'.bak.php');
  1110. }
  1111. $file = fopen($path, 'w');
  1112. fwrite($file, $output);
  1113. fclose($file);
  1114. if (file_exists($path)) {
  1115. return true;
  1116. }
  1117. writeLog("error", "config was unable to write");
  1118. return false;
  1119. } else {
  1120. writeLog("success", "config was updated with new values");
  1121. return $output;
  1122. }
  1123. }
  1124. // Load a config file written in the return syntax
  1125. function loadConfig($path = 'config/config.php') {
  1126. // Adapted from http://stackoverflow.com/a/14173339/6810513
  1127. if (!is_file($path)) {
  1128. return null;
  1129. } else {
  1130. return (array) call_user_func(function() use($path) {
  1131. return include($path);
  1132. });
  1133. }
  1134. }
  1135. // Commit new values to the configuration
  1136. function updateConfig($new, $current = false) {
  1137. // Get config if not supplied
  1138. if ($current === false) {
  1139. $current = loadConfig();
  1140. } else if (is_string($current) && is_file($current)) {
  1141. $current = loadConfig($current);
  1142. }
  1143. // Inject Parts
  1144. foreach ($new as $k => $v) {
  1145. $current[$k] = $v;
  1146. }
  1147. // Return Create
  1148. return createConfig($current);
  1149. }
  1150. // Inject Defaults As Needed
  1151. function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
  1152. if (is_string($path)) {
  1153. $loadedDefaults = loadConfig($path);
  1154. } else {
  1155. $loadedDefaults = $path;
  1156. }
  1157. return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
  1158. }
  1159. // support function for fillDefaultConfig()
  1160. function fillDefaultConfig_recurse($current, $defaults) {
  1161. foreach($defaults as $k => $v) {
  1162. if (!isset($current[$k])) {
  1163. $current[$k] = $v;
  1164. } else if (is_array($current[$k]) && is_array($v)) {
  1165. $current[$k] = fillDefaultConfig_recurse($current[$k], $v);
  1166. }
  1167. }
  1168. return $current;
  1169. };
  1170. // Define Scalar Variables (nest non-secular with underscores)
  1171. function defineConfig($array, $anyCase = true, $nest_prefix = false) {
  1172. foreach($array as $k => $v) {
  1173. if (is_scalar($v) && !defined($nest_prefix.$k)) {
  1174. define($nest_prefix.$k, $v, $anyCase);
  1175. } else if (is_array($v)) {
  1176. defineConfig($v, $anyCase, $nest_prefix.$k.'_');
  1177. }
  1178. }
  1179. }
  1180. // This function exists only because I am lazy
  1181. function configLazy($path = 'config/config.php') {
  1182. // Load config or default
  1183. if (file_exists($path)) {
  1184. $config = fillDefaultConfig(loadConfig($path));
  1185. } else {
  1186. $config = loadConfig('config/configDefaults.php');
  1187. }
  1188. if (is_array($config)) {
  1189. defineConfig($config);
  1190. }
  1191. return $config;
  1192. }
  1193. // Qualify URL
  1194. function qualifyURL($url) {
  1195. //local address?
  1196. if(substr($url, 0,1) == "/"){
  1197. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  1198. $protocol = "https://";
  1199. } else {
  1200. $protocol = "http://";
  1201. }
  1202. $url = $protocol.getServer().$url;
  1203. }
  1204. // Get Digest
  1205. $digest = parse_url($url);
  1206. // http/https
  1207. if (!isset($digest['scheme'])) {
  1208. if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096,32400,7878,8989,8182,8081,6789))) {
  1209. $scheme = 'http';
  1210. } else {
  1211. $scheme = 'https';
  1212. }
  1213. } else {
  1214. $scheme = $digest['scheme'];
  1215. }
  1216. // Host
  1217. $host = (isset($digest['host'])?$digest['host']:'');
  1218. // Port
  1219. $port = (isset($digest['port'])?':'.$digest['port']:'');
  1220. // Path
  1221. $path = (isset($digest['path'])?$digest['path']:'');
  1222. // Output
  1223. return $scheme.'://'.$host.$port.$path;
  1224. }
  1225. // Function to be called at top of each to allow upgrading environment as the spec changes
  1226. function upgradeCheck() {
  1227. // Upgrade to 1.31
  1228. if (file_exists('homepageSettings.ini.php')) {
  1229. $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
  1230. $homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
  1231. $databaseConfig = array_merge($databaseConfig, $homepageConfig);
  1232. $databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
  1233. foreach($databaseConfig as $k => $v) {
  1234. if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
  1235. $databaseData .= $k . " = \"" . $v . "\"\r\n";
  1236. }
  1237. write_ini_file($databaseData, 'databaseLocation.ini.php');
  1238. unlink('homepageSettings.ini.php');
  1239. unset($databaseData);
  1240. unset($homepageConfig);
  1241. }
  1242. // Upgrade to 1.32
  1243. if (file_exists('databaseLocation.ini.php')) {
  1244. // Load Existing
  1245. $config = parse_ini_file('databaseLocation.ini.php', true);
  1246. // Refactor
  1247. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['databaseLocation'].'/');
  1248. $config['user_home'] = $config['database_Location'].'users/';
  1249. unset($config['databaseLocation']);
  1250. // Turn Off Emby And Plex Recent
  1251. $config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
  1252. unset($config["embyPort"]);
  1253. $config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
  1254. unset($config["plexPort"]);
  1255. $config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
  1256. unset($config["nzbgetPort"]);
  1257. $config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
  1258. unset($config["sabnzbdPort"]);
  1259. $config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
  1260. unset($config["headphonesPort"]);
  1261. // Write config file
  1262. $config['CONFIG_VERSION'] = '1.32';
  1263. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][pre1.32].bak.php');
  1264. $createConfigSuccess = createConfig($config);
  1265. // Create new config
  1266. if ($createConfigSuccess) {
  1267. if (file_exists('config/config.php')) {
  1268. // Remove Old ini file
  1269. unlink('databaseLocation.ini.php');
  1270. } else {
  1271. debug_out('Something is not right here!');
  1272. }
  1273. } else {
  1274. debug_out('Couldn\'t create updated configuration.' ,1);
  1275. }
  1276. }
  1277. // Upgrade to 1.33
  1278. $config = loadConfig();
  1279. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
  1280. // Fix User Directory
  1281. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['database_Location'].'/');
  1282. $config['user_home'] = $config['database_Location'].'users/';
  1283. unset($config['USER_HOME']);
  1284. // Backend auth merge
  1285. if (isset($config['authBackendPort']) && !isset(parse_url($config['authBackendHost'])['port'])) {
  1286. $config['authBackendHost'] .= ':'.$config['authBackendPort'];
  1287. }
  1288. unset($config['authBackendPort']);
  1289. // If auth is being used move it to embyURL as that is now used in auth functions
  1290. if ((isset($config['authType']) && $config['authType'] == 'true') && (isset($config['authBackendHost']) && $config['authBackendHost'] == 'true') && (isset($config['authBackend']) && in_array($config['authBackend'], array('emby_all','emby_local','emby_connect')))) {
  1291. $config['embyURL'] = $config['authBackendHost'];
  1292. }
  1293. // Upgrade database to latest version
  1294. updateSQLiteDB($config['database_Location'],'1.32');
  1295. // Update Version and Commit
  1296. $config['apply_CONFIG_VERSION'] = '1.33';
  1297. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.32].bak.php');
  1298. $createConfigSuccess = createConfig($config);
  1299. unset($config);
  1300. }
  1301. // Upgrade to 1.34
  1302. $config = loadConfig();
  1303. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.34')) {
  1304. // Upgrade database to latest version
  1305. updateSQLiteDB($config['database_Location'],'1.33');
  1306. // Update Version and Commit
  1307. $config['CONFIG_VERSION'] = '1.34';
  1308. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.33].bak.php');
  1309. $createConfigSuccess = createConfig($config);
  1310. unset($config);
  1311. }
  1312. // Upgrade to 1.40
  1313. $config = loadConfig();
  1314. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.40')) {
  1315. // Upgrade database to latest version
  1316. updateSQLiteDB($config['database_Location'],'1.38');
  1317. // Update Version and Commit
  1318. $config['CONFIG_VERSION'] = '1.40';
  1319. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.38].bak.php');
  1320. $createConfigSuccess = createConfig($config);
  1321. unset($config);
  1322. }
  1323. // Upgrade to 1.50
  1324. $config = loadConfig();
  1325. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.50')) {
  1326. // Upgrade database to latest version
  1327. updateSQLiteDB($config['database_Location'],'1.40');
  1328. // Update Version and Commit
  1329. $config['CONFIG_VERSION'] = '1.50';
  1330. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.40].bak.php');
  1331. $createConfigSuccess = createConfig($config);
  1332. unset($config);
  1333. }
  1334. return true;
  1335. }
  1336. // Get OS from server
  1337. function getOS(){
  1338. if(PHP_SHLIB_SUFFIX == "dll"){
  1339. return "win";
  1340. }else{
  1341. return "nix";
  1342. }
  1343. }
  1344. //Get Error by Server OS
  1345. function getError($os, $error){
  1346. $ini = (!empty(php_ini_loaded_file()) ? php_ini_loaded_file() : "php.ini");
  1347. $ext = (!empty(ini_get('extension_dir')) ? "uncomment ;extension_dir = and make sure it says -> extension_dir = '".ini_get('extension_dir')."'" : "uncomment ;extension_dir = and add path to 'ext' to make it like extension_dir = 'C:\nginx\php\ext'");
  1348. $errors = array(
  1349. 'pdo_sqlite' => array(
  1350. 'win' => '<b>PDO:SQLite</b> not enabled, uncomment ;extension=php_pdo_sqlite.dll in the file php.ini | '.$ext,
  1351. 'nix' => '<b>PDO:SQLite</b> not enabled, PHP7 -> run sudo apt-get install php7.0-sqlite | PHP5 -> run sudo apt-get install php5-sqlite',
  1352. ),
  1353. 'sqlite3' => array(
  1354. 'win' => '<b>SQLite3</b> not enabled, uncomment ;extension=php_sqlite3.dll in the file php.ini | uncomment ;sqlite3.extension_dir = and add "ext" to make it sqlite3.extension_dir = ext',
  1355. 'nix' => '<b>SQLite3</b> not enabled, run sudo apt-get install php-sqlite3',
  1356. ),
  1357. 'curl' => array(
  1358. 'win' => '<b>cURL</b> not enabled, uncomment ;extension=php_curl.dll in the file php.ini | '.$ext,
  1359. 'nix' => '<b>cURL</b> not enabled, PHP7 -> sudo apt-get install php-curl or sudo apt-get install php7.0-curl | PHP5 -> run sudo apt-get install php5.6-curl',
  1360. ),
  1361. 'zip' => array(
  1362. 'win' => '<b>PHP Zip</b> not enabled, uncomment ;extension=php_zip.dll in the file php.ini, if that doesn\'t work remove that line',
  1363. 'nix' => '<b>PHP Zip</b> not enabled, PHP7 -> run sudo apt-get install php7.0-zip | PHP5 -> run sudo apt-get install php5.6-zip',
  1364. ),
  1365. );
  1366. return (isset($errors[$error][$os]) ? $errors[$error][$os] : 'No Error Info Found');
  1367. }
  1368. // Check if all software dependancies are met
  1369. function dependCheck() {
  1370. $output = array();
  1371. $i = 1;
  1372. if (!extension_loaded('pdo_sqlite')) { $output["Step $i"] = getError(getOS(),'pdo_sqlite'); $i++; }
  1373. if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; }
  1374. if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; }
  1375. //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
  1376. if ($output) {
  1377. $output["Step $i"] = "<b>Restart PHP and/or Webserver to apply changes</b>"; $i++;
  1378. $output["Step $i"] = "<b>Please visit here to also check status of necessary components after you fix them: <a href='check.php'>check.php<a/></b>"; $i++;
  1379. debug_out($output,1);
  1380. }
  1381. return true;
  1382. }
  1383. // Process file uploads
  1384. function uploadFiles($path, $ext_mask = null) {
  1385. if (isset($_FILES) && count($_FILES)) {
  1386. require_once('class.uploader.php');
  1387. $uploader = new Uploader();
  1388. $data = $uploader->upload($_FILES['files'], array(
  1389. 'limit' => 10,
  1390. 'maxSize' => 10,
  1391. 'extensions' => $ext_mask,
  1392. 'required' => false,
  1393. 'uploadDir' => str_replace('//','/',$path.'/'),
  1394. 'title' => array('name'),
  1395. 'removeFiles' => true,
  1396. 'replace' => true,
  1397. ));
  1398. if($data['isComplete']){
  1399. $files = $data['data'];
  1400. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1401. echo json_encode($files['metas'][0]['name']);
  1402. }
  1403. if($data['hasErrors']){
  1404. $errors = $data['errors'];
  1405. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1406. echo json_encode($errors);
  1407. }
  1408. } else {
  1409. writeLog("error", "image was not uploaded");
  1410. echo json_encode('No files submitted!');
  1411. }
  1412. }
  1413. // Process file uploads
  1414. function uploadAvatar($path, $ext_mask = null) {
  1415. if (isset($_FILES) && count($_FILES)) {
  1416. require_once('class.uploader.php');
  1417. $uploader = new Uploader();
  1418. $data = $uploader->upload($_FILES['files'], array(
  1419. 'limit' => 10,
  1420. 'maxSize' => 10,
  1421. 'extensions' => $ext_mask,
  1422. 'required' => false,
  1423. 'uploadDir' => str_replace('//','/',$path.'/'),
  1424. 'title' => array('name'),
  1425. 'removeFiles' => true,
  1426. 'replace' => true,
  1427. ));
  1428. if($data['isComplete']){
  1429. $files = $data['data'];
  1430. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1431. echo json_encode($files['metas'][0]['name']);
  1432. }
  1433. if($data['hasErrors']){
  1434. $errors = $data['errors'];
  1435. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1436. echo json_encode($errors);
  1437. }
  1438. } else {
  1439. writeLog("error", "image was not uploaded");
  1440. echo json_encode('No files submitted!');
  1441. }
  1442. }
  1443. // Remove file
  1444. function removeFiles($path) {
  1445. if(is_file($path)) {
  1446. writeLog("success", "image was removed");
  1447. unlink($path);
  1448. } else {
  1449. writeLog("error", "image was not removed");
  1450. echo json_encode('No file specified for removal!');
  1451. }
  1452. }
  1453. // Lazy select options
  1454. function resolveSelectOptions($array, $selected = '', $multi = false) {
  1455. $output = array();
  1456. $selectedArr = ($multi?explode('|', $selected):array());
  1457. foreach ($array as $key => $value) {
  1458. if (is_array($value)) {
  1459. if (isset($value['optgroup'])) {
  1460. $output[] = '<optgroup label="'.$key.'">';
  1461. foreach($value['optgroup'] as $k => $v) {
  1462. $output[] = '<option value="'.$v['value'].'"'.($selected===$v['value']||in_array($v['value'],$selectedArr)?' selected':'').(isset($v['disabled']) && $v['disabled']?' disabled':'').'>'.$k.'</option>';
  1463. }
  1464. } else {
  1465. $output[] = '<option value="'.$value['value'].'"'.($selected===$value['value']||in_array($value['value'],$selectedArr)?' selected':'').(isset($value['disabled']) && $value['disabled']?' disabled':'').'>'.$key.'</option>';
  1466. }
  1467. } else {
  1468. $output[] = '<option value="'.$value.'"'.($selected===$value||in_array($value,$selectedArr)?' selected':'').'>'.$key.'</option>';
  1469. }
  1470. }
  1471. return implode('',$output);
  1472. }
  1473. // Check if user is allowed to continue
  1474. function qualifyUser($type, $errOnFail = false) {
  1475. if (!isset($GLOBALS['USER'])) {
  1476. require_once("user.php");
  1477. $GLOBALS['USER'] = new User('registration_callback');
  1478. }
  1479. if (is_bool($type)) {
  1480. if ($type === true) {
  1481. $authorized = ($GLOBALS['USER']->authenticated == true);
  1482. } else {
  1483. $authorized = true;
  1484. }
  1485. } elseif (is_string($type) || is_array($type)) {
  1486. if ($type !== 'false') {
  1487. if (!is_array($type)) {
  1488. $type = explode('|',$type);
  1489. }
  1490. $authorized = ($GLOBALS['USER']->authenticated && in_array($GLOBALS['USER']->role,$type));
  1491. } else {
  1492. $authorized = true;
  1493. }
  1494. } else {
  1495. debug_out('Invalid Syntax!',1);
  1496. }
  1497. if (!$authorized && $errOnFail) {
  1498. if ($GLOBALS['USER']->authenticated) {
  1499. header('Location: '.dirname($_SERVER['SCRIPT_NAME']).'error.php?error=401');
  1500. echo '<script>window.location.href = \''.dirname($_SERVER['SCRIPT_NAME']).'error.php?error=401\'</script>';
  1501. } else {
  1502. header('Location: '.dirname($_SERVER['SCRIPT_NAME']).'error.php?error=999');
  1503. echo '<script>window.location.href = \''.dirname($_SERVER['SCRIPT_NAME']).'error.php?error=999\'</script>';
  1504. }
  1505. debug_out('Not Authorized' ,1);
  1506. } else {
  1507. return $authorized;
  1508. }
  1509. }
  1510. // Build an (optionally) tabbed settings page.
  1511. function buildSettings($array) {
  1512. /*
  1513. array(
  1514. 'title' => '',
  1515. 'id' => '',
  1516. 'fields' => array( See buildField() ),
  1517. 'tabs' => array(
  1518. array(
  1519. 'title' => '',
  1520. 'id' => '',
  1521. 'image' => '',
  1522. 'fields' => array( See buildField() ),
  1523. ),
  1524. ),
  1525. );
  1526. */
  1527. $notifyExplode = explode("-", NOTIFYEFFECT);
  1528. $fieldFunc = function($fieldArr) {
  1529. $fields = '<div class="row">';
  1530. foreach($fieldArr as $key => $value) {
  1531. $isSingle = isset($value['type']);
  1532. if ($isSingle) { $value = array($value); }
  1533. $tmpField = '';
  1534. $sizeLg = max(floor(12/count($value)),2);
  1535. $sizeMd = max(floor(($isSingle?12:6)/count($value)),3);
  1536. foreach($value as $k => $v) {
  1537. $tmpField .= buildField($v, 12, $sizeMd, $sizeLg);
  1538. }
  1539. $fields .= ($isSingle?$tmpField:'<div class="row col-sm-12 content-form">'.$tmpField.'</div>');
  1540. }
  1541. $fields .= '</div>';
  1542. return $fields;
  1543. };
  1544. $fields = (isset($array['fields'])?$fieldFunc($array['fields']):'');
  1545. $tabSelectors = array();
  1546. $tabContent = array();
  1547. if (isset($array['tabs'])) {
  1548. foreach($array['tabs'] as $key => $value) {
  1549. $id = (isset($value['id'])?$value['id']:randString(32));
  1550. $tabSelectors[$key] = '<li class="apps'.($tabSelectors?'':' active').'"><a href="#tab-'.$id.'" data-toggle="tab" aria-expanded="true"><img style="height:40px; width:40px;" src="'.(isset($value['image'])?$value['image']:'images/organizr.png').'"></a></li>';
  1551. $tabContent[$key] = '<div class="tab-pane big-box fade'.($tabContent?'':' active in').'" id="tab-'.$id.'">'.$fieldFunc($value['fields']).'</div>';
  1552. }
  1553. }
  1554. $pageID = (isset($array['id'])?$array['id']:str_replace(array(' ','"',"'"),array('_'),strtolower($array['id'])));
  1555. $extraClick = ($pageID == 'appearance_settings' ? "$('#advanced_settings_form_submit').click();console.log('add theme settings');" : "");
  1556. return '
  1557. <div class="email-body">
  1558. <div class="email-header gray-bg">
  1559. <button type="button" class="btn btn-danger btn-sm waves close-button"><i class="fa fa-close"></i></button>
  1560. <h1>'.$array['title'].'</h1>
  1561. </div>
  1562. <div class="email-inner small-box">
  1563. <div class="email-inner-section">
  1564. <div class="small-box fade in" id="'.$pageID.'_frame">
  1565. <div class="col-lg-12">
  1566. '.(isset($array['customBeforeForm'])?$array['customBeforeForm']:'').'
  1567. <form class="content-form" name="'.$pageID.'" id="'.$pageID.'_form" onsubmit="return false;">
  1568. <button id="'.$pageID.'_form_submit" class="btn waves btn-labeled btn-success btn btn-sm pull-right text-uppercase waves-effect waves-float">
  1569. <span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save
  1570. </button>
  1571. '.$fields.($tabContent?'
  1572. <div class="tabbable tabs-with-bg" id="'.$pageID.'_tabs">
  1573. <ul class="nav nav-tabs apps">
  1574. '.implode('', $tabSelectors).'
  1575. </ul>
  1576. <div class="clearfix"></div>
  1577. <div class="tab-content">
  1578. '.implode('', $tabContent).'
  1579. </div>
  1580. </div>':'').'
  1581. </form>
  1582. '.(isset($array['customAfterForm'])?$array['customAfterForm']:'').'
  1583. </div>
  1584. </div>
  1585. </div>
  1586. </div>
  1587. </div>
  1588. <script>
  1589. $(document).ready(function() {
  1590. $(\'#'.$pageID.'_form\').find(\'input, select, textarea\').on(\'change\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1591. var '.$pageID.'Validate = function() { if (this.value && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { $(this).addClass(\'invalid\'); } else { $(this).removeClass(\'invalid\'); } };
  1592. $(\'#'.$pageID.'_form\').find(\'input[pattern]\').each('.$pageID.'Validate).on(\'keyup\', '.$pageID.'Validate);
  1593. $(\'#'.$pageID.'_form\').find(\'select[multiple]\').on(\'change click\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1594. $(\'#'.$pageID.'_form_submit\').on(\'click\', function () {
  1595. var newVals = {};
  1596. var hasVals = false;
  1597. var errorFields = [];
  1598. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').each(function() {
  1599. hasVals = true;
  1600. if (this.type == \'checkbox\') {
  1601. newVals[this.name] = this.checked;
  1602. } else if ($(this).hasClass(\'summernote\')) {
  1603. newVals[$(this).attr(\'name\')] = $(this).siblings(\'.note-editor\').find(\'.panel-body\').html();
  1604. } else {
  1605. if (this.value && this.pattern && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { errorFields.push(this.name); }
  1606. var fieldVal = $(this).val();
  1607. if (typeof fieldVal == \'object\') {
  1608. if (typeof fieldVal.join == \'function\') {
  1609. fieldVal = fieldVal.join(\'|\');
  1610. } else {
  1611. fieldVal = JSON.stringify(fieldVal);
  1612. }
  1613. }
  1614. newVals[this.name] = fieldVal;
  1615. }
  1616. });
  1617. if (errorFields.length) {
  1618. parent.notify(\'Fields have errors: \'+errorFields.join(\', \')+\'!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1619. } else if (hasVals) {
  1620. console.log(newVals);
  1621. ajax_request(\'POST\', \''.(isset($array['submitAction'])?$array['submitAction']:'update-config').'\', newVals, function(data, code) {
  1622. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').removeAttr(\'data-changed\');
  1623. });
  1624. '.$extraClick.'
  1625. } else {
  1626. parent.notify(\'Nothing to update!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1627. }
  1628. return false;
  1629. });
  1630. '.(isset($array['onready'])?$array['onready']:'').'
  1631. });
  1632. </script>
  1633. ';
  1634. }
  1635. // Build Settings Fields
  1636. function buildField($params, $sizeSm = 12, $sizeMd = 12, $sizeLg = 12) {
  1637. /*
  1638. array(
  1639. 'type' => '',
  1640. 'placeholder' => '',
  1641. 'label' => '',
  1642. 'labelTranslate' => '',
  1643. 'assist' => '',
  1644. 'name' => '',
  1645. 'pattern' => '',
  1646. 'options' => array( // For SELECT only
  1647. 'Display' => 'value',
  1648. ),
  1649. )
  1650. */
  1651. // Tags
  1652. $tags = array();
  1653. foreach(array('placeholder','style','disabled','readonly','pattern','min','max','required','onkeypress','onchange','onfocus','onleave','href','onclick') as $value) {
  1654. if (isset($params[$value])) {
  1655. if (is_string($params[$value])) { $tags[] = $value.'="'.$params[$value].'"';
  1656. } else if ($params[$value] === true) { $tags[] = $value; }
  1657. }
  1658. }
  1659. $format = (isset($params['format']) && in_array($params['format'],array(false,'colour','color'))?$params['format']:false);
  1660. $name = (isset($params['name'])?$params['name']:(isset($params['id'])?$params['id']:''));
  1661. $id = (isset($params['id'])?$params['id']:(isset($params['name'])?$params['name'].'_id':randString(32)));
  1662. $val = (isset($params['value'])?$params['value']:'');
  1663. $class = (isset($params['class'])?' '.$params['class']:'');
  1664. $wrapClass = (isset($params['wrapClass'])?$params['wrapClass']:'form-content');
  1665. $assist = (isset($params['assist'])?' - i.e. '.$params['assist']:'');
  1666. $label = (isset($params['labelTranslate'])?translate($params['labelTranslate']):(isset($params['label'])?$params['label']:''));
  1667. $labelOut = '<p class="help-text">'.$label.$assist.'</p>';
  1668. // Field Design
  1669. switch ($params['type']) {
  1670. case 'text':
  1671. case 'number':
  1672. case 'password':
  1673. $field = '<input id="'.$id.'" name="'.$name.'" type="'.$params['type'].'" class="form-control material input-sm'.$class.'" '.implode(' ',$tags).' autocorrect="off" autocapitalize="off" value="'.$val.'">';
  1674. break;
  1675. case 'select':
  1676. case 'dropdown':
  1677. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control material input-sm" '.implode(' ',$tags).'>'.resolveSelectOptions($params['options'], $val).'</select>';
  1678. break;
  1679. case 'select-multi':
  1680. case 'dropdown-multi':
  1681. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control input-sm" '.implode(' ',$tags).' multiple="multiple">'.resolveSelectOptions($params['options'], $val, true).'</select>';
  1682. break;
  1683. case 'check':
  1684. case 'checkbox':
  1685. case 'toggle':
  1686. $checked = ((is_bool($val) && $val) || trim($val) === 'true'?' checked':'');
  1687. $colour = (isset($params['colour'])?$params['colour']:'success');
  1688. $labelOut = '<label for="'.$id.'"></label>'.$label;
  1689. $field = '<input id="'.$id.'" name="'.$name.'" type="checkbox" class="switcher switcher-'.$colour.' '.$class.'" '.implode(' ',$tags).' data-value="'.$val.'"'.$checked.'>';
  1690. break;
  1691. case 'radio':
  1692. $labelOut = '';
  1693. $checked = ((is_bool($val) && $val) || ($val && trim($val) !== 'false')?' checked':'');
  1694. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1695. $field = '<div class="radio radio-'.$bType.'"><input id="'.$id.'" name="'.$name.'" type="radio" class="'.$class.'" '.implode(' ',$tags).' value="'.$val.'"'.$checked.'><label for="'.$id.'">'.$label.'</label></div>';
  1696. break;
  1697. case 'date':
  1698. $field = 'Unsupported, planned.';
  1699. break;
  1700. case 'hidden':
  1701. return '<input id="'.$id.'" name="'.$name.'" type="hidden" class="'.$class.'" '.implode(' ',$tags).' value="'.$val.'">';
  1702. break;
  1703. case 'header':
  1704. $labelOut = '';
  1705. $headType = (isset($params['value'])?$params['value']:3);
  1706. $field = '<h'.$headType.' class="'.$class.'" '.implode(' ',$tags).'>'.$label.'</h'.$headType.'>';
  1707. break;
  1708. case 'button':
  1709. $labelOut = '';
  1710. $icon = (isset($params['icon'])?$params['icon']:'flask');
  1711. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1712. $bDropdown = (isset($params['buttonDrop'])?$params['buttonDrop']:'');
  1713. $field = ($bDropdown?'<div class="btn-group">':'').'<button id="'.$id.'" type="button" class="btn waves btn-labeled btn-'.$bType.' btn-sm text-uppercase waves-effect waves-float'.$class.''.($bDropdown?' dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"':'"').' '.implode(' ',$tags).'><span class="btn-label"><i class="fa fa-'.$icon.'"></i></span>'.$label.'</button>'.($bDropdown?$bDropdown.'</div>':'');
  1714. break;
  1715. case 'textarea':
  1716. $rows = (isset($params['rows'])?$params['rows']:5);
  1717. $field = '<textarea id="'.$id.'" name="'.$name.'" class="form-control'.$class.'" rows="'.$rows.'" '.implode(' ',$tags).'>'.$val.'</textarea>';
  1718. break;
  1719. case 'custom':
  1720. // Settings
  1721. $settings = array(
  1722. '$id' => $id,
  1723. '$name' => $name,
  1724. '$val' => $val,
  1725. '$label' => $label,
  1726. '$labelOut' => $labelOut,
  1727. );
  1728. // Get HTML
  1729. $html = (isset($params['html'])?$params['html']:'Nothing Specified!');
  1730. // If LabelOut is in html dont print it twice
  1731. $labelOut = (strpos($html,'$label')!==false?'':$labelOut);
  1732. // Replace variables in settings
  1733. $html = preg_replace_callback('/\$\w+\b/', function ($match) use ($settings) { return (isset($settings[$match[0]])?$settings[$match[0]]:'{'.$match[0].' is undefined}'); }, $html);
  1734. // Build Field
  1735. $field = '<div id="'.$id.'_html" class="custom-field">'.$html.'</div>';
  1736. break;
  1737. case 'space':
  1738. $labelOut = '';
  1739. $field = str_repeat('<br>', (isset($params['value'])?$params['value']:1));
  1740. break;
  1741. default:
  1742. $field = 'Unsupported field type';
  1743. break;
  1744. }
  1745. // Field Formats
  1746. switch ($format) {
  1747. case 'colour': // Fuckin Eh, Canada!
  1748. case 'color':
  1749. $labelBef = '<center>'.$label.'</center>';
  1750. $wrapClass = 'gray-bg colour-field';
  1751. $labelAft = '';
  1752. $field = str_replace(' material input-sm','',$field);
  1753. break;
  1754. default:
  1755. $labelBef = '';
  1756. $labelAft = $labelOut;
  1757. }
  1758. return '<div class="'.$wrapClass.' col-sm-'.$sizeSm.' col-md-'.$sizeMd.' col-lg-'.$sizeLg.'">'.$labelBef.$field.$labelAft.'</div>';
  1759. }
  1760. // Tab Settings Generation
  1761. function printTabRow($data) {
  1762. $hidden = false;
  1763. if ($data===false) {
  1764. $hidden = true;
  1765. $data = array( // New Tab Defaults
  1766. 'id' => 'new',
  1767. 'name' => '',
  1768. 'url' => '',
  1769. 'icon' => 'fa-diamond',
  1770. 'iconurl' => '',
  1771. 'active' => 'true',
  1772. 'user' => 'true',
  1773. 'guest' => 'true',
  1774. 'window' => 'false',
  1775. 'splash' => 'true',
  1776. 'ping' => 'false',
  1777. 'ping_url' => '',
  1778. 'defaultz' => '',
  1779. );
  1780. }
  1781. $image = '<span style="font: normal normal normal 30px/1 FontAwesome;" class="fa fa-hand-paper-o"></span>';
  1782. $output = '
  1783. <li id="tab-'.$data['id'].'" class="list-group-item" style="position: relative; left: 0px; top: 0px; '.($hidden?' display: none;':'').'">
  1784. <tab class="content-form form-inline">
  1785. <div class="row">
  1786. '.buildField(array(
  1787. 'type' => 'custom',
  1788. 'html' => '<div class="action-btns tabIconView"><a style="margin-left: 0px">'.($data['iconurl']?'<img src="'.$data['iconurl'].'" height="30" width="30">':'<span style="font: normal normal normal 30px/1 FontAwesome;" class="fa '.($data['icon']?$data['icon']:'hand-paper-o').'"></span>').'</a></div>',
  1789. ),12,1,1).'
  1790. '.buildField(array(
  1791. 'type' => 'hidden',
  1792. 'id' => 'tab-'.$data['id'].'-id',
  1793. 'name' => 'id['.$data['id'].']',
  1794. 'value' => $data['id'],
  1795. ),12,2,1).'
  1796. '.buildField(array(
  1797. 'type' => 'text',
  1798. 'id' => 'tab-'.$data['id'].'-name',
  1799. 'name' => 'name['.$data['id'].']',
  1800. 'required' => true,
  1801. 'placeholder' => 'Organizr Homepage',
  1802. 'labelTranslate' => 'TAB_NAME',
  1803. 'value' => $data['name'],
  1804. ),12,2,1).'
  1805. '.buildField(array(
  1806. 'type' => 'text',
  1807. 'id' => 'tab-'.$data['id'].'-url',
  1808. 'name' => 'url['.$data['id'].']',
  1809. 'required' => true,
  1810. 'placeholder' => 'homepage.php',
  1811. 'labelTranslate' => 'TAB_URL',
  1812. 'value' => $data['url'],
  1813. ),12,2,1).'
  1814. '.buildField(array(
  1815. 'type' => 'text',
  1816. 'id' => 'tab-'.$data['id'].'-iconurl',
  1817. 'name' => 'iconurl['.$data['id'].']',
  1818. 'placeholder' => 'images/organizr.png',
  1819. 'labelTranslate' => 'ICON_URL',
  1820. 'value' => $data['iconurl'],
  1821. ),12,2,1).'
  1822. '.buildField(array(
  1823. 'type' => 'custom',
  1824. 'id' => 'tab-'.$data['id'].'-icon',
  1825. 'name' => 'icon['.$data['id'].']',
  1826. 'html' => '- '.translate('OR').' - <div class="input-group"><input data-placement="bottomRight" class="form-control material icp-auto'.($hidden?'-pend':'').'" id="$id" name="$name" value="$val" type="text" /><span class="input-group-addon"></span></div>',
  1827. 'value' => $data['icon'],
  1828. ),12,1,1).'
  1829. '.buildField(array(
  1830. 'type' => 'text',
  1831. 'id' => 'tab-'.$data['id'].'-ping_url',
  1832. 'name' => 'ping_url['.$data['id'].']',
  1833. 'placeholder' => 'host:port',
  1834. 'labelTranslate' => 'PING_URL',
  1835. 'value' => $data['ping_url'],
  1836. ),12,2,1).'
  1837. '.buildField(array(
  1838. 'type' => 'radio',
  1839. 'labelTranslate' => 'DEFAULT',
  1840. 'name' => 'defaultz['.$data['id'].']',
  1841. 'value' => $data['defaultz'],
  1842. 'onclick' => "$('[type=radio][id!=\''+this.id+'\']').each(function() { this.checked=false; });",
  1843. ),12,1,1).'
  1844. '.buildField(array(
  1845. 'type' => 'button',
  1846. 'icon' => 'caret-square-o-down',
  1847. 'buttonType' => 'success',
  1848. 'labelTranslate' => 'MORE',
  1849. 'onclick' => "$('#tab-".$data['id']."-row').toggle();",
  1850. ),12,1,1).'
  1851. '.buildField(array(
  1852. 'type' => 'button',
  1853. 'icon' => 'trash',
  1854. 'buttonType' => 'danger',
  1855. 'labelTranslate' => 'REMOVE',
  1856. 'onclick' => "$(this).parents('li').remove();",
  1857. ),12,1,1).'</div><div id = "tab-'.$data['id'].'-row" class = "row animated slideInUp" style = "display:none;" ><div></div>
  1858. '.buildField(array(
  1859. 'type' => 'checkbox',
  1860. 'labelTranslate' => 'ACTIVE',
  1861. 'name' => 'active['.$data['id'].']',
  1862. 'value' => $data['active'],
  1863. ),12,1,1).'
  1864. '.buildField(array(
  1865. 'type' => 'checkbox',
  1866. 'labelTranslate' => 'USER',
  1867. 'colour' => 'primary',
  1868. 'name' => 'user['.$data['id'].']',
  1869. 'value' => $data['user'],
  1870. ),12,1,1).'
  1871. '.buildField(array(
  1872. 'type' => 'checkbox',
  1873. 'labelTranslate' => 'GUEST',
  1874. 'colour' => 'warning',
  1875. 'name' => 'guest['.$data['id'].']',
  1876. 'value' => $data['guest'],
  1877. ),12,1,1).'
  1878. '.buildField(array(
  1879. 'type' => 'checkbox',
  1880. 'labelTranslate' => 'NO_IFRAME',
  1881. 'colour' => 'danger',
  1882. 'name' => 'window['.$data['id'].']',
  1883. 'value' => $data['window'],
  1884. ),12,1,1).'
  1885. '.buildField(array(
  1886. 'type' => 'checkbox',
  1887. 'labelTranslate' => 'SPLASH',
  1888. 'colour' => 'success',
  1889. 'name' => 'splash['.$data['id'].']',
  1890. 'value' => $data['splash'],
  1891. ),12,1,1).'
  1892. '.buildField(array(
  1893. 'type' => 'checkbox',
  1894. 'labelTranslate' => 'PING',
  1895. 'colour' => 'success',
  1896. 'name' => 'ping['.$data['id'].']',
  1897. 'value' => $data['ping'],
  1898. ),12,1,1).'
  1899. </div>
  1900. </tab>
  1901. </li>
  1902. ';
  1903. return $output;
  1904. }
  1905. // Timezone array
  1906. function timezoneOptions() {
  1907. $output = array();
  1908. $timezones = array();
  1909. $regions = array(
  1910. 'Africa' => DateTimeZone::AFRICA,
  1911. 'America' => DateTimeZone::AMERICA,
  1912. 'Antarctica' => DateTimeZone::ANTARCTICA,
  1913. 'Arctic' => DateTimeZone::ARCTIC,
  1914. 'Asia' => DateTimeZone::ASIA,
  1915. 'Atlantic' => DateTimeZone::ATLANTIC,
  1916. 'Australia' => DateTimeZone::AUSTRALIA,
  1917. 'Europe' => DateTimeZone::EUROPE,
  1918. 'Indian' => DateTimeZone::INDIAN,
  1919. 'Pacific' => DateTimeZone::PACIFIC
  1920. );
  1921. foreach ($regions as $name => $mask) {
  1922. $zones = DateTimeZone::listIdentifiers($mask);
  1923. foreach($zones as $timezone) {
  1924. $time = new DateTime(NULL, new DateTimeZone($timezone));
  1925. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  1926. $output[$name]['optgroup'][substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm]['value'] = $timezone;
  1927. }
  1928. }
  1929. return $output;
  1930. }
  1931. // Build Database
  1932. function createSQLiteDB($path = false) {
  1933. if ($path === false) {
  1934. if (DATABASE_LOCATION){
  1935. $path = DATABASE_LOCATION;
  1936. } else {
  1937. debug_out('No Path Specified!');
  1938. }
  1939. }
  1940. if (!is_file($path.'users.db') || filesize($path.'users.db') <= 0) {
  1941. if (!isset($GLOBALS['file_db'])) {
  1942. $GLOBALS['file_db'] = new PDO('sqlite:'.$path.'users.db');
  1943. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  1944. }
  1945. // Create Users
  1946. $users = $GLOBALS['file_db']->query('CREATE TABLE `users` (
  1947. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  1948. `username` TEXT UNIQUE,
  1949. `password` TEXT,
  1950. `email` TEXT,
  1951. `token` TEXT,
  1952. `role` TEXT,
  1953. `active` TEXT,
  1954. `last` TEXT,
  1955. `auth_service` TEXT DEFAULT \'internal\'
  1956. );');
  1957. // Create Tabs
  1958. $tabs = $GLOBALS['file_db']->query('CREATE TABLE `tabs` (
  1959. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  1960. `order` INTEGER,
  1961. `users_id` INTEGER,
  1962. `name` TEXT,
  1963. `url` TEXT,
  1964. `defaultz` TEXT,
  1965. `active` TEXT,
  1966. `user` TEXT,
  1967. `guest` TEXT,
  1968. `icon` TEXT,
  1969. `iconurl` TEXT,
  1970. `window` TEXT,
  1971. `splash` TEXT,
  1972. `ping` TEXT,
  1973. `ping_url` TEXT
  1974. );');
  1975. // Create Options
  1976. $options = $GLOBALS['file_db']->query('CREATE TABLE `options` (
  1977. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  1978. `users_id` INTEGER UNIQUE,
  1979. `title` TEXT UNIQUE,
  1980. `topbar` TEXT,
  1981. `bottombar` TEXT,
  1982. `sidebar` TEXT,
  1983. `hoverbg` TEXT,
  1984. `topbartext` TEXT,
  1985. `activetabBG` TEXT,
  1986. `activetabicon` TEXT,
  1987. `activetabtext` TEXT,
  1988. `inactiveicon` TEXT,
  1989. `inactivetext` TEXT,
  1990. `loading` TEXT,
  1991. `hovertext` TEXT
  1992. );');
  1993. // Create Invites
  1994. $invites = $GLOBALS['file_db']->query('CREATE TABLE `invites` (
  1995. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  1996. `code` TEXT UNIQUE,
  1997. `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  1998. `email` TEXT,
  1999. `username` TEXT,
  2000. `dateused` TIMESTAMP,
  2001. `usedby` TEXT,
  2002. `ip` TEXT,
  2003. `valid` TEXT
  2004. );');
  2005. writeLog("success", "database created/saved");
  2006. return $users && $tabs && $options && $invites;
  2007. } else {
  2008. writeLog("error", "database was unable to be created/saved");
  2009. return false;
  2010. }
  2011. }
  2012. // Upgrade Database
  2013. function updateSQLiteDB($db_path = false, $oldVerNum = false) {
  2014. if (!$db_path) {
  2015. if (defined('DATABASE_LOCATION')) {
  2016. $db_path = DATABASE_LOCATION;
  2017. } else {
  2018. debug_out('No Path Specified',1);
  2019. }
  2020. }
  2021. if (!isset($GLOBALS['file_db'])) {
  2022. $GLOBALS['file_db'] = new PDO('sqlite:'.$db_path.'users.db');
  2023. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2024. }
  2025. // Cache current DB
  2026. $cache = array();
  2027. foreach($GLOBALS['file_db']->query('SELECT name FROM sqlite_master WHERE type="table";') as $table) {
  2028. foreach($GLOBALS['file_db']->query('SELECT * FROM '.$table['name'].';') as $key => $row) {
  2029. foreach($row as $k => $v) {
  2030. if (is_string($k)) {
  2031. $cache[$table['name']][$key][$k] = $v;
  2032. }
  2033. }
  2034. }
  2035. }
  2036. // Remove Current Database
  2037. $GLOBALS['file_db'] = null;
  2038. $pathDigest = pathinfo($db_path.'users.db');
  2039. if (file_exists($db_path.'users.db')) {
  2040. rename($db_path.'users.db', $pathDigest['dirname'].'/'.$pathDigest['filename'].'['.date('Y-m-d_H-i-s').']'.($oldVerNum?'['.$oldVerNum.']':'').'.bak.db');
  2041. }
  2042. // Create New Database
  2043. $success = createSQLiteDB($db_path);
  2044. // Restore Items
  2045. if ($success) {
  2046. foreach($cache as $table => $tableData) {
  2047. if ($tableData) {
  2048. $queryBase = 'INSERT INTO '.$table.' (`'.implode('`,`',array_keys(current($tableData))).'`) values ';
  2049. $insertValues = array();
  2050. reset($tableData);
  2051. foreach($tableData as $key => $value) {
  2052. $insertValues[] = '('.implode(',',array_map(function($d) {
  2053. return (isset($d)?$GLOBALS['file_db']->quote($d):'null');
  2054. }, $value)).')';
  2055. }
  2056. $GLOBALS['file_db']->query($queryBase.implode(',',$insertValues).';');
  2057. }
  2058. }
  2059. writeLog("success", "database values have been updated");
  2060. return true;
  2061. } else {
  2062. writeLog("error", "database values unable to be updated");
  2063. return false;
  2064. }
  2065. }
  2066. // Commit colours to database
  2067. function updateDBOptions($values) {
  2068. if (!isset($GLOBALS['file_db'])) {
  2069. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2070. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2071. }
  2072. // Commit new values to database
  2073. if ($GLOBALS['file_db']->query('UPDATE options SET '.implode(',',array_map(function($d, $k) {
  2074. return '`'.$k.'` = '.(isset($d)?"'".addslashes($d)."'":'null');
  2075. }, $values, array_keys($values))).';')->rowCount()) {
  2076. return true;
  2077. } else if ($GLOBALS['file_db']->query('INSERT OR IGNORE INTO options (`'.implode('`,`',array_keys($values)).'`) VALUES (\''.implode("','",$values).'\');')->rowCount()) {
  2078. writeLog("success", "database values for options table have been updated");
  2079. return true;
  2080. } else {
  2081. writeLog("error", "database values for options table unable to be updated");
  2082. return false;
  2083. }
  2084. }
  2085. // Send AJAX notification
  2086. function sendNotification($success, $message = false, $send = true) {
  2087. $notifyExplode = explode("-", NOTIFYEFFECT);
  2088. if ($success) {
  2089. $msg = array(
  2090. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_SAVED").'</strong>'),
  2091. 'icon' => 'floppy-o',
  2092. 'type' => 'success',
  2093. 'length' => '5000',
  2094. 'layout' => $notifyExplode[0],
  2095. 'effect' => $notifyExplode[1],
  2096. );
  2097. } else {
  2098. $msg = array(
  2099. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_NOT_SAVED").'</strong>'),
  2100. 'icon' => 'floppy-o',
  2101. 'type' => 'failed',
  2102. 'length' => '5000',
  2103. 'layout' => $notifyExplode[0],
  2104. 'effect' => $notifyExplode[1],
  2105. );
  2106. }
  2107. // Send and kill script?
  2108. if ($send) {
  2109. header('Content-Type: application/json');
  2110. echo json_encode(array('notify'=>$msg));
  2111. die();
  2112. }
  2113. return $msg;
  2114. }
  2115. // Load colours from the database
  2116. function loadAppearance() {
  2117. // Defaults
  2118. $defaults = array(
  2119. 'title' => 'Organizr',
  2120. 'topbartext' => '#66D9EF',
  2121. 'topbar' => '#333333',
  2122. 'bottombar' => '#333333',
  2123. 'sidebar' => '#393939',
  2124. 'hoverbg' => '#AD80FD',
  2125. 'activetabBG' => '#F92671',
  2126. 'activetabicon' => '#FFFFFF',
  2127. 'activetabtext' => '#FFFFFF',
  2128. 'inactiveicon' => '#66D9EF',
  2129. 'inactivetext' => '#66D9EF',
  2130. 'loading' => '#66D9EF',
  2131. 'hovertext' => '#000000',
  2132. );
  2133. if (DATABASE_LOCATION) {
  2134. if(is_file(DATABASE_LOCATION.'users.db') && filesize(DATABASE_LOCATION.'users.db') > 0){
  2135. if (!isset($GLOBALS['file_db'])) {
  2136. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2137. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2138. }
  2139. // Database Lookup
  2140. $options = $GLOBALS['file_db']->query('SELECT * FROM options');
  2141. // Replace defaults with filled options
  2142. foreach($options as $row) {
  2143. foreach($defaults as $key => $value) {
  2144. if (isset($row[$key]) && $row[$key]) {
  2145. $defaults[$key] = $row[$key];
  2146. }
  2147. }
  2148. }
  2149. }
  2150. }
  2151. // Return the Results
  2152. return $defaults;
  2153. }
  2154. // Delete Database
  2155. function deleteDatabase() {
  2156. unset($_COOKIE['Organizr']);
  2157. setcookie('Organizr', '', time() - 3600, '/');
  2158. unset($_COOKIE['OrganizrU']);
  2159. setcookie('OrganizrU', '', time() - 3600, '/');
  2160. $GLOBALS['file_db'] = null;
  2161. unlink(DATABASE_LOCATION.'users.db');
  2162. foreach(glob(substr_replace($userdirpath, "", -1).'/*') as $file) {
  2163. if(is_dir($file)) {
  2164. rmdir($file);
  2165. } elseif (!is_dir($file)) {
  2166. unlink($file);
  2167. }
  2168. }
  2169. rmdir($userdirpath);
  2170. writeLog("success", "database has been deleted");
  2171. return true;
  2172. }
  2173. // Upgrade the installation
  2174. function upgradeInstall($branch = 'master') {
  2175. function downloadFile($url, $path){
  2176. ini_set('max_execution_time',0);
  2177. $folderPath = "upgrade/";
  2178. if(!mkdir($folderPath)){
  2179. writeLog("error", "organizr could not create upgrade folder");
  2180. }
  2181. $newfname = $folderPath . $path;
  2182. $file = fopen ($url, 'rb');
  2183. if ($file) {
  2184. $newf = fopen ($newfname, 'wb');
  2185. if ($newf) {
  2186. while(!feof($file)) {
  2187. fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
  2188. }
  2189. }
  2190. }else{
  2191. writeLog("error", "organizr could not download $url");
  2192. }
  2193. if ($file) {
  2194. fclose($file);
  2195. writeLog("success", "organizr finished downloading the github zip file");
  2196. }else{
  2197. writeLog("error", "organizr could not download the github zip file");
  2198. }
  2199. if ($newf) {
  2200. fclose($newf);
  2201. writeLog("success", "organizr created upgrade zip file from github zip file");
  2202. }else{
  2203. writeLog("error", "organizr could not create upgrade zip file from github zip file");
  2204. }
  2205. }
  2206. function unzipFile($zipFile){
  2207. $zip = new ZipArchive;
  2208. $extractPath = "upgrade/";
  2209. if($zip->open($extractPath . $zipFile) != "true"){
  2210. writeLog("error", "organizr could not unzip upgrade.zip");
  2211. }else{
  2212. writeLog("success", "organizr unzipped upgrade.zip");
  2213. }
  2214. /* Extract Zip File */
  2215. $zip->extractTo($extractPath);
  2216. $zip->close();
  2217. }
  2218. // Function to remove folders and files
  2219. function rrmdir($dir) {
  2220. if (is_dir($dir)) {
  2221. $files = scandir($dir);
  2222. foreach ($files as $file)
  2223. if ($file != "." && $file != "..") rrmdir("$dir/$file");
  2224. rmdir($dir);
  2225. }
  2226. else if (file_exists($dir)) unlink($dir);
  2227. }
  2228. // Function to Copy folders and files
  2229. function rcopy($src, $dst) {
  2230. if (is_dir ( $src )) {
  2231. if (!file_exists($dst)) : mkdir ( $dst ); endif;
  2232. $files = scandir ( $src );
  2233. foreach ( $files as $file )
  2234. if ($file != "." && $file != "..")
  2235. rcopy ( "$src/$file", "$dst/$file" );
  2236. } else if (file_exists ( $src ))
  2237. copy ( $src, $dst );
  2238. }
  2239. $url = 'https://github.com/causefx/Organizr/archive/'.$branch.'.zip';
  2240. $file = "upgrade.zip";
  2241. $source = __DIR__ . '/upgrade/Organizr-'.$branch.'/';
  2242. $cleanup = __DIR__ . "/upgrade/";
  2243. $destination = __DIR__ . "/";
  2244. writeLog("success", "starting organizr upgrade process");
  2245. downloadFile($url, $file);
  2246. unzipFile($file);
  2247. rcopy($source, $destination);
  2248. writeLog("success", "new organizr files copied");
  2249. rrmdir($cleanup);
  2250. writeLog("success", "organizr upgrade folder removed");
  2251. writeLog("success", "organizr has been updated");
  2252. return true;
  2253. }
  2254. // NzbGET Items
  2255. function nzbgetConnect($list = 'listgroups') {
  2256. $url = qualifyURL(NZBGETURL);
  2257. $api = curl_get($url.'/'.NZBGETUSERNAME.':'.NZBGETPASSWORD.'/jsonrpc/'.$list);
  2258. $api = json_decode($api, true);
  2259. $gotNZB = array();
  2260. if (is_array($api) || is_object($api)){
  2261. foreach ($api['result'] AS $child) {
  2262. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  2263. $downloadStatus = $child['Status'];
  2264. $downloadCategory = $child['Category'];
  2265. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  2266. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  2267. if($child['Health'] <= "750"){
  2268. $downloadHealth = "danger";
  2269. }elseif($child['Health'] <= "900"){
  2270. $downloadHealth = "warning";
  2271. }elseif($child['Health'] <= "1000"){
  2272. $downloadHealth = "success";
  2273. }
  2274. $gotNZB[] = '<tr>
  2275. <td class="col-xs-7 nzbtable-file-row">'.$downloadName.'</td>
  2276. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2277. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2278. <td class="col-xs-2 nzbtable nzbtable-row">
  2279. <div class="progress">
  2280. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2281. <p class="text-center">'.round($downloadPercent).'%</p>
  2282. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2283. </div>
  2284. </div>
  2285. </td>
  2286. </tr>';
  2287. }
  2288. if ($gotNZB) {
  2289. return implode('',$gotNZB);
  2290. } else {
  2291. return '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>';
  2292. }
  2293. }else{
  2294. writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Usernamd and Password - if HTTPS, is cert valid");
  2295. }
  2296. }
  2297. // Sabnzbd Items
  2298. function sabnzbdConnect($list = 'queue') {
  2299. $url = qualifyURL(SABNZBDURL);
  2300. $api = file_get_contents($url.'/api?mode='.$list.'&output=json&apikey='.SABNZBDKEY);
  2301. $api = json_decode($api, true);
  2302. $gotNZB = array();
  2303. foreach ($api[$list]['slots'] AS $child) {
  2304. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  2305. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  2306. $downloadStatus = $child['status'];
  2307. $gotNZB[] = '<tr>
  2308. <td class="col-xs-7 nzbtable-file-row">'.$downloadName.'</td>
  2309. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2310. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2311. <td class="col-xs-2 nzbtable nzbtable-row">
  2312. <div class="progress">
  2313. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2314. <p class="text-center">'.round($downloadPercent).'%</p>
  2315. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2316. </div>
  2317. </div>
  2318. </td>
  2319. </tr>';
  2320. }
  2321. if ($gotNZB) {
  2322. return implode('',$gotNZB);
  2323. } else {
  2324. return '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>';
  2325. }
  2326. }
  2327. // Apply new tab settings
  2328. function updateTabs($tabs) {
  2329. if (!isset($GLOBALS['file_db'])) {
  2330. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2331. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2332. }
  2333. // Validate
  2334. if (!isset($tabs['defaultz'])) { $tabs['defaultz'][current(array_keys($tabs['name']))] = 'true'; }
  2335. if (isset($tabs['name']) && isset($tabs['url']) && is_array($tabs['name'])) {
  2336. // Clear Existing Tabs
  2337. $GLOBALS['file_db']->query("DELETE FROM tabs");
  2338. // Process New Tabs
  2339. $totalValid = 0;
  2340. foreach ($tabs['name'] as $key => $value) {
  2341. // Qualify
  2342. if (!$value || !isset($tabs['url']) || !$tabs['url'][$key]) { continue; }
  2343. $totalValid++;
  2344. $fields = array();
  2345. foreach(array('id','name','url','icon','iconurl','order','ping_url') as $v) {
  2346. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = $tabs[$v][$key]; }
  2347. }
  2348. foreach(array('active','user','guest','defaultz','window','splash','ping') as $v) {
  2349. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = ($tabs[$v][$key]!=='false'?'true':'false'); }
  2350. }
  2351. $GLOBALS['file_db']->query('INSERT INTO tabs (`'.implode('`,`',array_keys($fields)).'`) VALUES (\''.implode("','",$fields).'\');');
  2352. }
  2353. writeLog("success", "tabs successfully saved");
  2354. return $totalValid;
  2355. } else {
  2356. writeLog("error", "tabs could not save");
  2357. return false;
  2358. }
  2359. writeLog("error", "tabs could not save");
  2360. return false;
  2361. }
  2362. // ==============
  2363. function clean($strin) {
  2364. $strout = null;
  2365. for ($i = 0; $i < strlen($strin); $i++) {
  2366. $ord = ord($strin[$i]);
  2367. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  2368. $strout .= "&amp;#{$ord};";
  2369. }
  2370. else {
  2371. switch ($strin[$i]) {
  2372. case '<':
  2373. $strout .= '&lt;';
  2374. break;
  2375. case '>':
  2376. $strout .= '&gt;';
  2377. break;
  2378. case '&':
  2379. $strout .= '&amp;';
  2380. break;
  2381. case '"':
  2382. $strout .= '&quot;';
  2383. break;
  2384. default:
  2385. $strout .= $strin[$i];
  2386. }
  2387. }
  2388. }
  2389. return $strout;
  2390. }
  2391. function registration_callback($username, $email, $userdir){
  2392. global $data;
  2393. $data = array($username, $email, $userdir);
  2394. }
  2395. function printArray($arrayName){
  2396. $messageCount = count($arrayName);
  2397. $i = 0;
  2398. foreach ( $arrayName as $item ) :
  2399. $i++;
  2400. if($i < $messageCount) :
  2401. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  2402. elseif($i = $messageCount) :
  2403. echo "<small class='text-uppercase'>" . $item . "</small>";
  2404. endif;
  2405. endforeach;
  2406. }
  2407. function write_ini_file($content, $path) {
  2408. if (!$handle = fopen($path, 'w')) {
  2409. return false;
  2410. }
  2411. $success = fwrite($handle, trim($content));
  2412. fclose($handle);
  2413. return $success;
  2414. }
  2415. function gotTimezone(){
  2416. $regions = array(
  2417. 'Africa' => DateTimeZone::AFRICA,
  2418. 'America' => DateTimeZone::AMERICA,
  2419. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2420. 'Arctic' => DateTimeZone::ARCTIC,
  2421. 'Asia' => DateTimeZone::ASIA,
  2422. 'Atlantic' => DateTimeZone::ATLANTIC,
  2423. 'Australia' => DateTimeZone::AUSTRALIA,
  2424. 'Europe' => DateTimeZone::EUROPE,
  2425. 'Indian' => DateTimeZone::INDIAN,
  2426. 'Pacific' => DateTimeZone::PACIFIC
  2427. );
  2428. $timezones = array();
  2429. foreach ($regions as $name => $mask) {
  2430. $zones = DateTimeZone::listIdentifiers($mask);
  2431. foreach($zones as $timezone) {
  2432. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2433. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2434. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2435. }
  2436. }
  2437. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  2438. foreach($timezones as $region => $list) {
  2439. print '<optgroup label="' . $region . '">' . "\n";
  2440. foreach($list as $timezone => $name) {
  2441. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  2442. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  2443. }
  2444. print '</optgroup>' . "\n";
  2445. }
  2446. print '</select>';
  2447. }
  2448. function getTimezone(){
  2449. $regions = array(
  2450. 'Africa' => DateTimeZone::AFRICA,
  2451. 'America' => DateTimeZone::AMERICA,
  2452. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2453. 'Arctic' => DateTimeZone::ARCTIC,
  2454. 'Asia' => DateTimeZone::ASIA,
  2455. 'Atlantic' => DateTimeZone::ATLANTIC,
  2456. 'Australia' => DateTimeZone::AUSTRALIA,
  2457. 'Europe' => DateTimeZone::EUROPE,
  2458. 'Indian' => DateTimeZone::INDIAN,
  2459. 'Pacific' => DateTimeZone::PACIFIC
  2460. );
  2461. $timezones = array();
  2462. foreach ($regions as $name => $mask) {
  2463. $zones = DateTimeZone::listIdentifiers($mask);
  2464. foreach($zones as $timezone) {
  2465. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2466. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2467. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2468. }
  2469. }
  2470. print '<select name="timezone" id="timezone" class="form-control material" required>';
  2471. foreach($timezones as $region => $list) {
  2472. print '<optgroup label="' . $region . '">' . "\n";
  2473. foreach($list as $timezone => $name) {
  2474. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  2475. }
  2476. print '</optgroup>' . "\n";
  2477. }
  2478. print '</select>';
  2479. }
  2480. function explosion($string, $position){
  2481. $getWord = explode("|", $string);
  2482. return $getWord[$position];
  2483. }
  2484. function getServerPath() {
  2485. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  2486. $protocol = "https://";
  2487. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  2488. $protocol = "https://";
  2489. } else {
  2490. $protocol = "http://";
  2491. }
  2492. $domain = '';
  2493. if (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], '.') !== false){
  2494. $domain = $_SERVER['SERVER_NAME'];
  2495. }elseif(isset($_SERVER['HTTP_HOST'])){
  2496. if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
  2497. $domain = explode(':', $_SERVER['HTTP_HOST'])[0];
  2498. $port = explode(':', $_SERVER['HTTP_HOST'])[1];
  2499. if ($port == "80" || $port == "443"){
  2500. $domain = $domain;
  2501. }else{
  2502. $domain = $_SERVER['HTTP_HOST'];
  2503. }
  2504. }else{
  2505. $domain = $_SERVER['HTTP_HOST'];
  2506. }
  2507. }
  2508. return $protocol . $domain . dirname($_SERVER['REQUEST_URI']);
  2509. }
  2510. function get_browser_name() {
  2511. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  2512. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  2513. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  2514. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  2515. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  2516. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  2517. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  2518. return 'Other';
  2519. }
  2520. function getSickrageCalendarWanted($array){
  2521. $array = json_decode($array, true);
  2522. //$gotCalendar = "";
  2523. $gotCalendar = array();
  2524. $i = 0;
  2525. foreach($array['data']['missed'] AS $child) {
  2526. $i++;
  2527. $seriesName = $child['show_name'];
  2528. $episodeID = $child['tvdbid'];
  2529. $episodeAirDate = $child['airdate'];
  2530. $episodeAirDateTime = explode(" ",$child['airs']);
  2531. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2532. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2533. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2534. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2535. $downloaded = "0";
  2536. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2537. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2538. array_push($gotCalendar, array(
  2539. "id" => "Sick-Miss-".$i,
  2540. "title" => $seriesName,
  2541. "start" => $episodeAirDate,
  2542. "className" => $downloaded." tvID--".$episodeID,
  2543. "imagetype" => "tv",
  2544. ));
  2545. }
  2546. foreach($array['data']['today'] AS $child) {
  2547. $i++;
  2548. $seriesName = $child['show_name'];
  2549. $episodeID = $child['tvdbid'];
  2550. $episodeAirDate = $child['airdate'];
  2551. $episodeAirDateTime = explode(" ",$child['airs']);
  2552. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2553. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2554. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2555. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2556. $downloaded = "0";
  2557. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2558. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2559. array_push($gotCalendar, array(
  2560. "id" => "Sick-Today-".$i,
  2561. "title" => $seriesName,
  2562. "start" => $episodeAirDate,
  2563. "className" => $downloaded." tvID--".$episodeID,
  2564. "imagetype" => "tv",
  2565. ));
  2566. }
  2567. foreach($array['data']['soon'] AS $child) {
  2568. $i++;
  2569. $seriesName = $child['show_name'];
  2570. $episodeID = $child['tvdbid'];
  2571. $episodeAirDate = $child['airdate'];
  2572. $episodeAirDateTime = explode(" ",$child['airs']);
  2573. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2574. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2575. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2576. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2577. $downloaded = "0";
  2578. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2579. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2580. array_push($gotCalendar, array(
  2581. "id" => "Sick-Soon-".$i,
  2582. "title" => $seriesName,
  2583. "start" => $episodeAirDate,
  2584. "className" => $downloaded." tvID--".$episodeID,
  2585. "imagetype" => "tv",
  2586. ));
  2587. }
  2588. foreach($array['data']['later'] AS $child) {
  2589. $i++;
  2590. $seriesName = $child['show_name'];
  2591. $episodeID = $child['tvdbid'];
  2592. $episodeAirDate = $child['airdate'];
  2593. $episodeAirDateTime = explode(" ",$child['airs']);
  2594. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2595. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2596. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2597. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2598. $downloaded = "0";
  2599. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2600. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2601. array_push($gotCalendar, array(
  2602. "id" => "Sick-Later-".$i,
  2603. "title" => $seriesName,
  2604. "start" => $episodeAirDate,
  2605. "className" => $downloaded." tvID--".$episodeID,
  2606. "imagetype" => "tv",
  2607. ));
  2608. }
  2609. if ($i != 0){ return $gotCalendar; }
  2610. }
  2611. function getSickrageCalendarHistory($array){
  2612. $array = json_decode($array, true);
  2613. //$gotCalendar = "";
  2614. $gotCalendar = array();
  2615. $i = 0;
  2616. foreach($array['data'] AS $child) {
  2617. $i++;
  2618. $seriesName = $child['show_name'];
  2619. $episodeID = $child['tvdbid'];
  2620. $episodeAirDate = $child['date'];
  2621. $downloaded = "green-bg";
  2622. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2623. array_push($gotCalendar, array(
  2624. "id" => "Sick-History-".$i,
  2625. "title" => $seriesName,
  2626. "start" => $episodeAirDate,
  2627. "className" => $downloaded." tvID--".$episodeID,
  2628. "imagetype" => "tv",
  2629. ));
  2630. }
  2631. if ($i != 0){ return $gotCalendar; }
  2632. }
  2633. function getSonarrCalendar($array){
  2634. $array = json_decode($array, true);
  2635. //$gotCalendar = "";
  2636. $gotCalendar = array();
  2637. $i = 0;
  2638. foreach($array AS $child) {
  2639. $i++;
  2640. $seriesName = $child['series']['title'];
  2641. $episodeID = $child['series']['tvdbId'];
  2642. if(!isset($episodeID)){ $episodeID = ""; }
  2643. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  2644. if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
  2645. $episodeAirDate = $child['airDateUtc'];
  2646. $episodeAirDate = strtotime($episodeAirDate);
  2647. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2648. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2649. $downloaded = $child['hasFile'];
  2650. if($downloaded == "0" && isset($unaired) && $episodePremier == "true"){ $downloaded = "light-blue-bg"; }elseif($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2651. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2652. array_push($gotCalendar, array(
  2653. "id" => "Sonarr-".$i,
  2654. "title" => $seriesName,
  2655. "start" => $episodeAirDate,
  2656. "className" => $downloaded." tvID--".$episodeID,
  2657. "imagetype" => "tv",
  2658. ));
  2659. }
  2660. if ($i != 0){ return $gotCalendar; }
  2661. }
  2662. function getRadarrCalendar($array){
  2663. $array = json_decode($array, true);
  2664. $gotCalendar = array();
  2665. $i = 0;
  2666. foreach($array AS $child) {
  2667. if(isset($child['physicalRelease'])){
  2668. $i++;
  2669. $movieName = $child['title'];
  2670. $movieID = $child['tmdbId'];
  2671. if(!isset($movieID)){ $movieID = ""; }
  2672. $physicalRelease = $child['physicalRelease'];
  2673. $physicalRelease = strtotime($physicalRelease);
  2674. $physicalRelease = date("Y-m-d", $physicalRelease);
  2675. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2676. $downloaded = $child['hasFile'];
  2677. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2678. array_push($gotCalendar, array(
  2679. "id" => "Radarr-".$i,
  2680. "title" => $movieName,
  2681. "start" => $physicalRelease,
  2682. "className" => $downloaded." movieID--".$movieID,
  2683. "imagetype" => "film",
  2684. ));
  2685. }
  2686. }
  2687. if ($i != 0){ return $gotCalendar; }
  2688. }
  2689. function getHeadphonesCalendar($url, $key, $list){
  2690. $url = qualifyURL(HEADPHONESURL);
  2691. $api = curl_get($url."/api?apikey=".$key."&cmd=$list");
  2692. $api = json_decode($api, true);
  2693. $i = 0;
  2694. //$gotCalendar = "";
  2695. $gotCalendar = array();;
  2696. if (is_array($api) || is_object($api)){
  2697. foreach($api AS $child) {
  2698. if($child['Status'] == "Wanted" && $list == "getWanted" && $child['ReleaseDate']){
  2699. $i++;
  2700. $albumName = addslashes($child['AlbumTitle']);
  2701. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  2702. $albumDate = (strlen($child['ReleaseDate']) > 4) ? $child['ReleaseDate'] : $child['ReleaseDate']."-01-01";
  2703. $albumID = $child['AlbumID'];
  2704. $albumDate = strtotime($albumDate);
  2705. $albumDate = date("Y-m-d", $albumDate);
  2706. $albumStatus = $child['Status'];
  2707. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2708. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  2709. //$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2710. array_push($gotCalendar, array(
  2711. "id" => "Headphones-".$i,
  2712. "title" => $albumArtist.' - '.$albumName,
  2713. "start" => $albumDate,
  2714. "className" => $albumStatusColor,
  2715. "imagetype" => "music",
  2716. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2717. ));
  2718. }
  2719. if($child['Status'] == "Processed" && $list == "getHistory"){
  2720. $i++;
  2721. $find = array('_','[', ']', '\n');
  2722. $replace = array(' ','(', ')', ' ');
  2723. $albumName = addslashes(str_replace($find,$replace,$child['FolderName']));
  2724. $albumDate = $child['DateAdded'];
  2725. $albumID = $child['AlbumID'];
  2726. $albumDate = strtotime($albumDate);
  2727. $albumDate = date("Y-m-d", $albumDate);
  2728. $albumStatusColor = "green-bg";
  2729. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2730. //$gotCalendar .= "{ title: \"$albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2731. array_push($gotCalendar, array(
  2732. "id" => "Headphones-".$i,
  2733. "title" => $albumName,
  2734. "start" => $albumDate,
  2735. "className" => $albumStatusColor,
  2736. "imagetype" => "music",
  2737. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2738. ));
  2739. }
  2740. }
  2741. if ($i != 0){ return $gotCalendar; }
  2742. }else{
  2743. writeLog("error", "HEADPHONES $list ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2744. }
  2745. }
  2746. function checkRootPath($string){
  2747. if($string == "\\" || $string == "/"){
  2748. return "/";
  2749. }else{
  2750. return str_replace("\\", "/", $string) . "/";
  2751. }
  2752. }
  2753. function strip($string){
  2754. $string = strip_tags($string);
  2755. return preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $string));
  2756. }
  2757. function writeLog($type, $message){
  2758. if(filesize("org.log") > 500000){
  2759. rename('org.log','org['.date('Y-m-d').'].log');
  2760. $message2 = date("Y-m-d H:i:s")."|".$type."|".strip("ORG LOG: Creating backup of org.log to org[".date('Y-m-d')."].log ")."\n";
  2761. file_put_contents("org.log", $message2, FILE_APPEND | LOCK_EX);
  2762. }
  2763. $message = date("Y-m-d H:i:s")."|".$type."|".strip($message)."\n";
  2764. file_put_contents("org.log", $message, FILE_APPEND | LOCK_EX);
  2765. }
  2766. function readLog(){
  2767. $log = file("org.log",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  2768. $log = array_reverse($log);
  2769. foreach($log as $line){
  2770. if(substr_count($line, '|') == 2){
  2771. $line = explode("|", strip($line));
  2772. $line[1] = ($line[1] == "error") ? '<span class="label label-danger">Error</span>' : '<span class="label label-primary">Success</span>';
  2773. echo "<tr><td>".$line[0]."</td><td>".$line[2]."</td><td>".$line[1]."</td></tr>";
  2774. }
  2775. }
  2776. }
  2777. function buildStream($array){
  2778. $result = "";
  2779. if (array_key_exists('platform', $array)) {
  2780. $result .= '<div class="reg-info" style="margin-top:0; padding-left:0; position: absolute; bottom: 10px; left: 10px;"><div style="margin-right: 0;" class="item pull-left text-center"><img alt="'.$array['platform'].'" class="img-circle" height="55px" src="images/platforms/'.getPlatform($array['platform']).'"></div></div><div class="clearfix"></div>';
  2781. }
  2782. if (array_key_exists('device', $array)) {
  2783. $result .= '<div class="reg-info" style="margin-top:0; padding-left:5%;"><div style="margin-right: 0;" class="item pull-left text-center"><span style="font-size: 15px;" class="block text-center"><i class="fa fa-laptop fa-fw"></i>'.$array['device'].'</span></div></div><div class="clearfix"></div>';
  2784. }
  2785. if (array_key_exists('stream', $array)) {
  2786. $result .= '<div class="reg-info" style="margin-top:0; padding-left:5%;"><div style="margin-right: 0;" class="item pull-left text-center"><span style="font-size: 15px;" class="block text-center"><i class="fa fa-play fa-fw"></i>'.$array['stream'].'</span></div></div><div class="clearfix"></div>';
  2787. }
  2788. if (array_key_exists('video', $array)) {
  2789. $result .= '<div class="reg-info" style="margin-top:0; padding-left:5%;"><div style="margin-right: 0;" class="item pull-left text-center"><span style="font-size: 15px;" class="block text-center"><i class="fa fa-film fa-fw"></i>'.$array['video'].'</span></div></div><div class="clearfix"></div>';
  2790. }
  2791. if (array_key_exists('audio', $array)) {
  2792. $result .= '<div class="reg-info" style="margin-top:0; padding-left:5%;"><div style="margin-right: 0;" class="item pull-left text-center"><span style="font-size: 15px;" class="block text-center"><i class="fa fa-volume-up fa-fw"></i>'.$array['audio'].'</span></div></div><div class="clearfix"></div>';
  2793. }
  2794. return $result;
  2795. }
  2796. function streamType($value){
  2797. if($value == "transcode" || $value == "Transcode"){
  2798. return "Transcode";
  2799. }elseif($value == "copy" || $value == "DirectStream"){
  2800. return "Direct Stream";
  2801. }elseif($value == "directplay" || $value == "DirectPlay"){
  2802. return "Direct Play";
  2803. }else{
  2804. return "Direct Play";
  2805. }
  2806. }
  2807. function getPlatform($platform){
  2808. $allPlatforms = array(
  2809. "Chrome" => "chrome.png",
  2810. "tvOS" => "atv.png",
  2811. "iOS" => "ios.png",
  2812. "Xbox One" => "xbox.png",
  2813. "Mystery 4" => "playstation.png",
  2814. "Samsung" => "samsung.png",
  2815. "Roku" => "roku.png",
  2816. "Emby for iOS" => "ios.png",
  2817. "Emby Mobile" => "emby.png",
  2818. "Emby Theater" => "emby.png",
  2819. "Emby Classic" => "emby.png",
  2820. "Safari" => "safari.png",
  2821. "Android" => "android.png",
  2822. "AndroidTv" => "android.png",
  2823. "Chromecast" => "chromecast.png",
  2824. "Dashboard" => "emby.png",
  2825. "Dlna" => "dlna.png",
  2826. "Windows Phone" => "wp.png",
  2827. "Windows RT" => "win8.png",
  2828. "Kodi" => "kodi.png",
  2829. );
  2830. if (array_key_exists($platform, $allPlatforms)) {
  2831. return $allPlatforms[$platform];
  2832. }else{
  2833. return "pmp.png";
  2834. }
  2835. }
  2836. function getServer(){
  2837. $server = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"];
  2838. return $server;
  2839. }
  2840. function prettyPrint($array) {
  2841. echo "<pre>";
  2842. print_r($array);
  2843. echo "</pre>";
  2844. echo "<br/>";
  2845. }
  2846. function checkFrame($array, $url){
  2847. if(array_key_exists("x-frame-options", $array)){
  2848. if($array['x-frame-options'] == "deny"){
  2849. return false;
  2850. }elseif($array['x-frame-options'] == "sameorgin"){
  2851. $digest = parse_url($url);
  2852. $host = (isset($digest['host'])?$digest['host']:'');
  2853. if(getServer() == $host){
  2854. return true;
  2855. }else{
  2856. return false;
  2857. }
  2858. }
  2859. }else{
  2860. if(!$array){
  2861. return false;
  2862. }
  2863. return true;
  2864. }
  2865. }
  2866. function frameTest($url){
  2867. $array = array_change_key_case(get_headers(qualifyURL($url), 1));
  2868. $url = qualifyURL($url);
  2869. if(checkFrame($array, $url)){
  2870. return true;
  2871. }else{
  2872. return false;
  2873. }
  2874. }
  2875. function sendResult($result, $icon = "floppy-o", $message = false, $success = "WAS_SUCCESSFUL", $fail = "HAS_FAILED", $send = true) {
  2876. $notifyExplode = explode("-", NOTIFYEFFECT);
  2877. if ($result) {
  2878. $msg = array(
  2879. 'html' => ($message?''.$message.' <strong>'.translate($success).'</strong>':'<strong>'.translate($success).'</strong>'),
  2880. 'icon' => $icon,
  2881. 'type' => 'success',
  2882. 'length' => '5000',
  2883. 'layout' => $notifyExplode[0],
  2884. 'effect' => $notifyExplode[1],
  2885. );
  2886. } else {
  2887. $msg = array(
  2888. 'html' => ($message?''.$message.' <strong>'.translate($fail).'</strong>':'<strong>'.translate($fail).'</strong>'),
  2889. 'icon' => $icon,
  2890. 'type' => 'error',
  2891. 'length' => '5000',
  2892. 'layout' => $notifyExplode[0],
  2893. 'effect' => $notifyExplode[1],
  2894. );
  2895. }
  2896. // Send and kill script?
  2897. if ($send) {
  2898. header('Content-Type: application/json');
  2899. echo json_encode(array('notify'=>$msg));
  2900. die();
  2901. }
  2902. return $msg;
  2903. }
  2904. function buildHomepageNotice($layout, $type, $title, $message){
  2905. switch ($layout) {
  2906. case 'elegant':
  2907. return '
  2908. <div id="homepageNotice" class="row">
  2909. <div class="col-lg-12">
  2910. <div class="content-box big-box box-shadow panel-box panel-'.$type.'">
  2911. <div class="content-title i-block">
  2912. <h4 class="zero-m"><strong>'.$title.'</strong></h4>
  2913. <div class="content-tools i-block pull-right">
  2914. <a class="close-btn">
  2915. <i class="fa fa-times"></i>
  2916. </a>
  2917. </div>
  2918. </div>
  2919. '.$message.'
  2920. </div>
  2921. </div>
  2922. </div>
  2923. ';
  2924. break;
  2925. case 'basic':
  2926. return '
  2927. <div id="homepageNotice" class="row">
  2928. <div class="col-lg-12">
  2929. <div class="panel panel-'.$type.'">
  2930. <div class="panel-heading">
  2931. <h3 class="panel-title">'.$title.'</h3>
  2932. </div>
  2933. <div class="panel-body">
  2934. '.$message.'
  2935. </div>
  2936. </div>
  2937. </div>
  2938. </div>
  2939. ';
  2940. break;
  2941. case 'jumbotron';
  2942. return '
  2943. <div id="homepageNotice" class="row">
  2944. <div class="col-lg-12">
  2945. <div class="jumbotron">
  2946. <div class="container">
  2947. <h1>'.$title.'</h1>
  2948. <p>'.$message.'</p>
  2949. </div>
  2950. </div>
  2951. </div>
  2952. </div>
  2953. ';
  2954. }
  2955. }
  2956. function embyArray($array, $type) {
  2957. $key = ($type == "video" ? "Height" : "Channels");
  2958. if (array_key_exists($key, $array)) {
  2959. switch ($type) {
  2960. case "video":
  2961. $codec = $array["Codec"];
  2962. $height = $array["Height"];
  2963. $width = $array["Width"];
  2964. break;
  2965. default:
  2966. $codec = $array["Codec"];
  2967. $channels = $array["Channels"];
  2968. }
  2969. return ($type == "video" ? "(".$codec.") (".$width."x".$height.")" : "(".$codec.") (".$channels."ch)");
  2970. }
  2971. foreach ($array as $element) {
  2972. if (is_array($element)) {
  2973. if (embyArray($element, $type)) {
  2974. return embyArray($element, $type);
  2975. }
  2976. }
  2977. }
  2978. }
  2979. // Get Now Playing Streams From Plex
  2980. function searchPlex($query){
  2981. $address = qualifyURL(PLEXURL);
  2982. $openTab = (PLEXTABNAME) ? "true" : "false";
  2983. // Perform API requests
  2984. $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
  2985. libxml_use_internal_errors(true);
  2986. $api = simplexml_load_string($api);
  2987. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  2988. if (!$getServer) { return 'Could not load!'; }
  2989. // Identify the local machine
  2990. $server = $getServer['machineIdentifier'];
  2991. $pre = "<table class=\"table table-hover table-stripped\"><thead><tr><th>Cover</th><th>Title</th><th>Genre</th><th>Year</th><th>Type</th><th>Added</th><th>Extra Info</th></tr></thead><tbody>";
  2992. $items = "";
  2993. $albums = $movies = $shows = 0;
  2994. $style = 'style="vertical-align: middle"';
  2995. foreach($api AS $child) {
  2996. if($child['type'] != "artist" && $child['type'] != "episode" && isset($child['librarySectionID'])){
  2997. $time = (string)$child['addedAt'];
  2998. $time = new DateTime("@$time");
  2999. $results = array(
  3000. "title" => (string)$child['title'],
  3001. "image" => (string)$child['thumb'],
  3002. "type" => (string)ucwords($child['type']),
  3003. "year" => (string)$child['year'],
  3004. "key" => (string)$child['ratingKey']."-search",
  3005. "ratingkey" => (string)$child['ratingKey'],
  3006. "genre" => (string)$child->Genre['tag'],
  3007. "added" => $time->format('Y-m-d'),
  3008. "extra" => "",
  3009. );
  3010. switch ($child['type']){
  3011. case "album":
  3012. $push = array(
  3013. "title" => (string)$child['parentTitle']." - ".(string)$child['title'],
  3014. );
  3015. $results = array_replace($results,$push);
  3016. $albums++;
  3017. break;
  3018. case "movie":
  3019. $push = array(
  3020. "extra" => "Content Rating: ".(string)$child['contentRating']."<br/>Movie Rating: ".(string)$child['rating'],
  3021. );
  3022. $results = array_replace($results,$push);
  3023. $movies++;
  3024. break;
  3025. case "show":
  3026. $push = array(
  3027. "extra" => "Seasons: ".(string)$child['childCount']."<br/>Episodes: ".(string)$child['leafCount'],
  3028. );
  3029. $results = array_replace($results,$push);
  3030. $shows++;
  3031. break;
  3032. }
  3033. if (file_exists('images/cache/'.$results['key'].'.jpg')){ $image_url = 'images/cache/'.$results['key'].'.jpg'; }
  3034. if (file_exists('images/cache/'.$results['key'].'.jpg') && (time() - 604800) > filemtime('images/cache/'.$results['key'].'.jpg') || !file_exists('images/cache/'.$results['key'].'.jpg')) {
  3035. $image_url = 'ajax.php?a=plex-image&img='.$results['image'].'&height=150&width=100&key='.$results['key'];
  3036. }
  3037. if(!$results['image']){ $image_url = "images/no-search.png"; $key = "no-search"; }
  3038. if (substr_count(PLEXURL, '.') != 2) {
  3039. $link = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3040. }else{
  3041. $link = PLEXURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3042. }
  3043. $items .= '<tr style="cursor: pointer;" class="openTab" extraTitle="'.$results['title'].'" extraType="'.$child['type'].'" openTab="'.$openTab.'" href="'.$link.'">
  3044. <th scope="row"><img src="'.$image_url.'"></th>
  3045. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
  3046. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
  3047. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
  3048. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
  3049. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
  3050. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['extra'].'</td>
  3051. </tr>';
  3052. }
  3053. }
  3054. $totals = '<div style="margin: 10px;" class="sort-todo pull-right">
  3055. <span class="badge gray-bg"><i class="fa fa-film fa-2x white"></i><strong style="
  3056. font-size: 23px;
  3057. ">&nbsp;'.$movies.'</strong></span>
  3058. <span class="badge gray-bg"><i class="fa fa-tv fa-2x white"></i><strong style="
  3059. font-size: 23px;
  3060. ">&nbsp;'.$shows.'</strong></span>
  3061. <span class="badge gray-bg"><i class="fa fa-music fa-2x white"></i><strong style="
  3062. font-size: 23px;
  3063. ">&nbsp;'.$albums.'</strong></span>
  3064. </div>';
  3065. return (!empty($items) ? $totals.$pre.$items."</div></table>" : "<h2 class='text-center'>No Results for $query</h2>" );
  3066. }
  3067. function getBannedUsers($string){
  3068. if (strpos($string, ',') !== false) {
  3069. $banned = explode(",", $string);
  3070. }else{
  3071. $banned = array($string);
  3072. }
  3073. return $banned;
  3074. }
  3075. function getWhitelist($string){
  3076. if (strpos($string, ',') !== false) {
  3077. $whitelist = explode(",", $string);
  3078. }else{
  3079. $whitelist = array($string);
  3080. }
  3081. foreach($whitelist as &$ip){
  3082. $ip = is_numeric(substr($ip, 0, 1)) ? $ip : gethostbyname($ip);
  3083. }
  3084. return $whitelist;
  3085. }
  3086. function get_client_ip() {
  3087. $ipaddress = '';
  3088. if (isset($_SERVER['HTTP_CLIENT_IP']))
  3089. $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
  3090. else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  3091. $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
  3092. else if(isset($_SERVER['HTTP_X_FORWARDED']))
  3093. $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
  3094. else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
  3095. $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
  3096. else if(isset($_SERVER['HTTP_FORWARDED']))
  3097. $ipaddress = $_SERVER['HTTP_FORWARDED'];
  3098. else if(isset($_SERVER['REMOTE_ADDR']))
  3099. $ipaddress = $_SERVER['REMOTE_ADDR'];
  3100. else
  3101. $ipaddress = 'UNKNOWN';
  3102. return $ipaddress;
  3103. }
  3104. //EMAIL SHIT
  3105. function sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null){
  3106. $mail = new PHPMailer;
  3107. $mail->isSMTP();
  3108. $mail->Host = SMTPHOST;
  3109. $mail->SMTPAuth = SMTPHOSTAUTH;
  3110. $mail->Username = SMTPHOSTUSERNAME;
  3111. $mail->Password = SMTPHOSTPASSWORD;
  3112. $mail->SMTPSecure = SMTPHOSTTYPE;
  3113. $mail->Port = SMTPHOSTPORT;
  3114. $mail->setFrom(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3115. $mail->addReplyTo(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3116. $mail->isHTML(true);
  3117. $mail->addAddress($email, $username);
  3118. $mail->Subject = $subject;
  3119. $mail->Body = $body;
  3120. //$mail->send();
  3121. if(!$mail->send()) {
  3122. writeLog("error", "mail failed to send");
  3123. } else {
  3124. writeLog("success", "mail has been sent");
  3125. }
  3126. }
  3127. //EMAIL SHIT
  3128. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  3129. $mail = new PHPMailer;
  3130. $mail->isSMTP();
  3131. $mail->Host = $host;
  3132. $mail->SMTPAuth = $auth;
  3133. $mail->Username = $username;
  3134. $mail->Password = $password;
  3135. $mail->SMTPSecure = $type;
  3136. $mail->Port = $port;
  3137. $mail->setFrom($from, $sendername);
  3138. $mail->addReplyTo($from, $sendername);
  3139. $mail->isHTML(true);
  3140. $mail->addAddress($to, "Organizr Admin");
  3141. $mail->Subject = "Organizr Test E-Mail";
  3142. $mail->Body = "This was just a test!";
  3143. //$mail->send();
  3144. if(!$mail->send()) {
  3145. writeLog("error", "EMAIL TEST: mail failed to send - Error:".$mail->ErrorInfo);
  3146. return false;
  3147. } else {
  3148. writeLog("success", "EMAIL TEST: mail has been sent successfully");
  3149. return true;
  3150. }
  3151. }
  3152. function libraryList(){
  3153. $address = qualifyURL(PLEXURL);
  3154. $headers = array(
  3155. "Accept" => "application/json",
  3156. "X-Plex-Token" => PLEXTOKEN
  3157. );
  3158. libxml_use_internal_errors(true);
  3159. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3160. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3161. $api = simplexml_load_string(@curl_get("https://plex.tv/api/servers/$gotServer/shared_servers", $headers));
  3162. $libraryList = array();
  3163. foreach($api->SharedServer->Section AS $child) {
  3164. $libraryList['libraries'][(string)$child['title']] = (string)$child['id'];
  3165. }
  3166. foreach($api->SharedServer AS $child) {
  3167. if(!empty($child['username'])){
  3168. $username = (string)strtolower($child['username']);
  3169. $email = (string)strtolower($child['email']);
  3170. $libraryList['users'][$username] = (string)$child['id'];
  3171. $libraryList['emails'][$email] = (string)$child['id'];
  3172. }
  3173. }
  3174. return (!empty($libraryList) ? array_change_key_case($libraryList,CASE_LOWER) : null );
  3175. }
  3176. function plexUserShare($username){
  3177. $address = qualifyURL(PLEXURL);
  3178. $headers = array(
  3179. "Accept" => "application/json",
  3180. "Content-Type" => "application/json",
  3181. "X-Plex-Token" => PLEXTOKEN
  3182. );
  3183. libxml_use_internal_errors(true);
  3184. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3185. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3186. $json = array(
  3187. "server_id" => $gotServer,
  3188. "shared_server" => array(
  3189. //"library_section_ids" => "[26527637]",
  3190. "invited_email" => $username
  3191. )
  3192. );
  3193. $api = curl_post("https://plex.tv/api/servers/$gotServer/shared_servers/", $json, $headers);
  3194. switch ($api['http_code']['http_code']){
  3195. case 400:
  3196. writeLog("error", "PLEX INVITE: $username already has access to the shared libraries");
  3197. $result = "$username already has access to the shared libraries";
  3198. break;
  3199. case 401:
  3200. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3201. $result = "Invalid Plex Token";
  3202. break;
  3203. case 200:
  3204. writeLog("success", "PLEX INVITE: $username now has access to your Plex Library");
  3205. $result = "$username now has access to your Plex Library";
  3206. break;
  3207. default:
  3208. writeLog("error", "PLEX INVITE: unknown error");
  3209. $result = false;
  3210. }
  3211. return (!empty($result) ? $result : null );
  3212. }
  3213. function plexUserDelete($username){
  3214. $address = qualifyURL(PLEXURL);
  3215. $headers = array(
  3216. "Accept" => "application/json",
  3217. "Content-Type" => "application/json",
  3218. "X-Plex-Token" => PLEXTOKEN
  3219. );
  3220. libxml_use_internal_errors(true);
  3221. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3222. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3223. $id = (is_numeric($username) ? $id : convertPlexName($username, "id"));
  3224. $api = curl_delete("https://plex.tv/api/servers/$gotServer/shared_servers/$id", $headers);
  3225. switch ($api['http_code']['http_code']){
  3226. case 401:
  3227. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3228. $result = "Invalid Plex Token";
  3229. break;
  3230. case 200:
  3231. writeLog("success", "PLEX INVITE: $username doesn't have access to your Plex Library anymore");
  3232. $result = "$username doesn't have access to your Plex Library anymore";
  3233. break;
  3234. default:
  3235. writeLog("error", "PLEX INVITE: unknown error");
  3236. $result = false;
  3237. }
  3238. return (!empty($result) ? $result : null );
  3239. }
  3240. function convertPlexName($user, $type){
  3241. $array = libraryList();
  3242. switch ($type){
  3243. case "username":
  3244. $plexUser = array_search ($user, $array['users']);
  3245. break;
  3246. case "id":
  3247. if (array_key_exists(strtolower($user), $array['users'])) {
  3248. $plexUser = $array['users'][strtolower($user)];
  3249. }
  3250. break;
  3251. default:
  3252. $plexUser = false;
  3253. }
  3254. return (!empty($plexUser) ? $plexUser : null );
  3255. }
  3256. function randomCode($length = 5, $type = null) {
  3257. switch ($type){
  3258. case "alpha":
  3259. $legend = array_merge(range('A', 'Z'));
  3260. break;
  3261. case "numeric":
  3262. $legend = array_merge(range(0,9));
  3263. break;
  3264. default:
  3265. $legend = array_merge(range(0,9),range('A', 'Z'));
  3266. }
  3267. $code = "";
  3268. for($i=0; $i < $length; $i++) {
  3269. $code .= $legend[mt_rand(0, count($legend) - 1)];
  3270. }
  3271. return $code;
  3272. }
  3273. function inviteCodes($action, $code = null, $usedBy = null) {
  3274. if (!isset($GLOBALS['file_db'])) {
  3275. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  3276. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  3277. }
  3278. $now = date("Y-m-d H:i:s");
  3279. switch ($action) {
  3280. case "get":
  3281. // Start Array
  3282. $result = array();
  3283. // Database Lookup
  3284. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes"');
  3285. // Get Codes
  3286. foreach($invites as $row) {
  3287. array_push($result, $row['code']);
  3288. }
  3289. // Return the Results
  3290. return (!empty($result) ? $result : false );
  3291. break;
  3292. case "check":
  3293. // Start Array
  3294. $result = array();
  3295. // Database Lookup
  3296. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes" AND code = "'.$code.'"');
  3297. // Get Codes
  3298. foreach($invites as $row) {
  3299. $result = $row['code'];
  3300. }
  3301. // Return the Results
  3302. return (!empty($result) ? $result : false );
  3303. break;
  3304. case "use":
  3305. $currentIP = get_client_ip();
  3306. $invites = $GLOBALS['file_db']->query('UPDATE invites SET valid = "No", usedby = "'.$usedBy.'", dateused = "'.$now.'", ip = "'.$currentIP.'" WHERE code = "'.$code.'"');
  3307. if(ENABLEMAIL){
  3308. if (!isset($GLOBALS['USER'])) {
  3309. require_once("user.php");
  3310. $GLOBALS['USER'] = new User('registration_callback');
  3311. }
  3312. sendEmail($GLOBALS['USER']->adminEmail, "Admin", "Plex Invite Used", orgEmail("PLEX Invite Used", "Look who joined the cool club", "Admin", "Hey, The User: $usedBy has redeemd their invite code: [$code], their IP Address was: $currentIP", null, null, "What Next?", "Well, That is up to you. You can go check on them if you like."));
  3313. }
  3314. return (!empty($invites) ? true : false );
  3315. break;
  3316. }
  3317. }
  3318. function plexJoin($username, $email, $password){
  3319. $connectURL = 'https://plex.tv/users.json';
  3320. $headers = array(
  3321. 'Accept'=> 'application/json',
  3322. 'Content-Type' => 'application/x-www-form-urlencoded',
  3323. 'X-Plex-Product' => 'Organizr',
  3324. 'X-Plex-Version' => '1.0',
  3325. 'X-Plex-Client-Identifier' => '01010101-10101010',
  3326. );
  3327. $body = array(
  3328. 'user[email]' => $email,
  3329. 'user[username]' => $username,
  3330. 'user[password]' => $password,
  3331. );
  3332. $api = curl_post($connectURL, $body, $headers);
  3333. $json = json_decode($api['content'], true);
  3334. $errors = (!empty($json['errors']) ? true : false);
  3335. $success = (!empty($json['user']) ? true : false);
  3336. //Use This for later
  3337. $usernameError = (!empty($json['errors']['username']) ? $json['errors']['username'][0] : false);
  3338. $emailError = (!empty($json['errors']['email']) ? $json['errors']['email'][0] : false);
  3339. $passwordError = (!empty($json['errors']['password']) ? $json['errors']['password'][0] : false);
  3340. $errorMessage = "";
  3341. if($errors){
  3342. if($usernameError){ $errorMessage .= "[Username Error: ". $usernameError ."]"; }
  3343. if($emailError){ $errorMessage .= "[Email Error: ". $emailError ."]"; }
  3344. if($passwordError){ $errorMessage .= "[Password Error: ". $passwordError ."]"; }
  3345. }
  3346. switch ($api['http_code']['http_code']){
  3347. case 400:
  3348. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." $username already has access to the shared libraries $errorMessage");
  3349. break;
  3350. case 401:
  3351. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." invalid Plex Token $errorMessage");
  3352. break;
  3353. case 422:
  3354. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." user info error $errorMessage");
  3355. break;
  3356. case 429:
  3357. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." too many requests to plex.tv please try later $errorMessage");
  3358. break;
  3359. case 200:
  3360. case 201:
  3361. writeLog("success", "PLEX JOIN: $username now has access to your Plex Library");
  3362. break;
  3363. default:
  3364. writeLog("error", "PLEX JOIN: unknown error, $errorMessage Error: ".$api['http_code']['http_code']);
  3365. }
  3366. //prettyPrint($api);
  3367. //prettyPrint(json_decode($api['content'], true));
  3368. return (!empty($success) && empty($errors) ? true : false );
  3369. }
  3370. function getCert(){
  3371. $url = "http://curl.haxx.se/ca/cacert.pem";
  3372. $file = getcwd()."/config/cacert.pem";
  3373. $directory = getcwd()."/config/";
  3374. @mkdir($directory, 0770, true);
  3375. if(!file_exists($file)){
  3376. file_put_contents( $file, fopen($url, 'r'));
  3377. writeLog("success", "CERT PEM: pem file created");
  3378. }elseif (file_exists($file) && time() - 2592000 > filemtime($file)) {
  3379. file_put_contents( $file, fopen($url, 'r'));
  3380. writeLog("success", "CERT PEM: downloaded new pem file");
  3381. }
  3382. return $file;
  3383. }
  3384. function customCSS(){
  3385. if(CUSTOMCSS == "true") {
  3386. $template_file = "custom.css";
  3387. $file_handle = fopen($template_file, "rb");
  3388. echo "\n";
  3389. echo fread($file_handle, filesize($template_file));
  3390. fclose($file_handle);
  3391. echo "\n";
  3392. }
  3393. }
  3394. function tvdbToken(){
  3395. $headers = array(
  3396. "Accept" => "application/json",
  3397. "Content-Type" => "application/json"
  3398. );
  3399. $json = array(
  3400. "apikey" => "FBE7B62621F4CAD7",
  3401. "userkey" => "328BB46EB1E9A0F5",
  3402. "username" => "causefx"
  3403. );
  3404. $api = curl_post("https://api.thetvdb.com/login", $json, $headers);
  3405. return json_decode($api['content'], true)['token'];
  3406. }
  3407. function tvdbGet($id){
  3408. $headers = array(
  3409. "Accept" => "application/json",
  3410. "Authorization" => "Bearer ".tvdbToken(),
  3411. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3412. "trakt-api-version" => "2"
  3413. );
  3414. $trakt = curl_get("https://api.trakt.tv/search/tvdb/$id?type=show", $headers);
  3415. @$api['trakt'] = json_decode($trakt, true)[0]['show']['ids'];
  3416. if(empty($api['trakt'])){
  3417. $series = curl_get("https://api.thetvdb.com/series/$id", $headers);
  3418. $poster = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=poster", $headers);
  3419. $backdrop = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=fanart", $headers);
  3420. $api['series'] = json_decode($series, true)['data'];
  3421. $api['poster'] = json_decode($poster, true)['data'];
  3422. $api['backdrop'] = json_decode($backdrop, true)['data'];
  3423. }
  3424. return $api;
  3425. }
  3426. function tvdbSearch($name, $type){
  3427. $name = rawurlencode(preg_replace("/\(([^()]*+|(?R))*\)/","", $name));
  3428. $headers = array(
  3429. "Accept" => "application/json",
  3430. "Authorization" => "Bearer ".tvdbToken(),
  3431. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3432. "trakt-api-version" => "2"
  3433. );
  3434. $trakt = curl_get("https://api.trakt.tv/search/$type?query=$name", $headers);
  3435. @$api['trakt'] = json_decode($trakt, true)[0][$type]['ids'];
  3436. return $api;
  3437. }
  3438. function getPlexPlaylists(){
  3439. $address = qualifyURL(PLEXURL);
  3440. // Perform API requests
  3441. $api = @curl_get($address."/playlists?X-Plex-Token=".PLEXTOKEN);
  3442. libxml_use_internal_errors(true);
  3443. $api = simplexml_load_string($api);
  3444. if (is_array($api) || is_object($api)){
  3445. if (!$api->head->title){
  3446. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3447. if (!$getServer) { return 'Could not load!'; }
  3448. // Identify the local machine
  3449. $gotServer = $getServer['machineIdentifier'];
  3450. $output = "";
  3451. $hideMenu = '<div class="pull-right"><div class="btn-group" role="group"><button type="button" id="playlist-Name" class="btn waves btn-default btn-sm dropdown-toggle waves-effect waves-float" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Choose A Playlist &nbsp;<span class="caret"></span></button><ul style="right:0; left: auto; height: 200px;" class="dropdown-menu filter-recent-playlist playlist-listing">';
  3452. foreach($api AS $child) {
  3453. $items = array();
  3454. if ($child['playlistType'] == "video" && strpos(strtolower($child['title']) , 'private') === false){
  3455. $api = @curl_get($address.$child['key']."?X-Plex-Token=".PLEXTOKEN);
  3456. $api = simplexml_load_string($api);
  3457. if (is_array($api) || is_object($api)){
  3458. if (!$api->head->title){
  3459. $className = preg_replace("/(\W)+/", "", $api['title']);
  3460. $hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  3461. foreach($api->Video AS $child){
  3462. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false,false,$className);
  3463. }
  3464. if (count($items)) {
  3465. $output .= ''.implode('',$items).'';
  3466. }
  3467. }
  3468. }
  3469. }
  3470. }
  3471. $hideMenu .= '</ul></div></div>';
  3472. return '<div id="playlist-all" class="content-box box-shadow big-box"><h5 id="playlist-title" style="margin-bottom: -20px" class="text-center">All Playlists</h5><div class="recentHeader inbox-pagination all">'.$hideMenu.'</div><br/><br/><div class="recentItems-playlists" data-name="all">'.$output.'</div></div>';
  3473. }else{
  3474. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check token - if HTTPS, is cert valid");
  3475. }
  3476. }else{
  3477. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check URL - if HTTPS, is cert valid");
  3478. }
  3479. }
  3480. function readExternalLog($type,$filename,$name = null){
  3481. $log = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3482. $log = array_reverse($log);
  3483. foreach($log as $line){
  3484. if(!empty($line) && $line[0] != " "){
  3485. $line = strip($line);
  3486. if($type == "single"){
  3487. if( strpos( strtolower($line), "ror" ) !== false ) {
  3488. echo "<tr><td class='red-bg'>".$line."</td></tr>";
  3489. }else{
  3490. echo "<tr><td>".$line."</td></tr>";
  3491. }
  3492. }elseif($type == "all"){
  3493. if( strpos( strtolower($line), "ror" ) !== false ) {
  3494. echo "<tr><td class='red-bg'>".$name."</td>";
  3495. echo "<td class='red-bg'>".$line."</td></tr>";
  3496. }else{
  3497. echo "<tr><td>".$name."</td>";
  3498. echo "<td>".$line."</td></tr>";
  3499. }
  3500. }
  3501. }
  3502. }
  3503. }
  3504. function getLogs(){
  3505. $path = __DIR__ ."/logs/";
  3506. @mkdir($path, 0770, true);
  3507. $logs = array();
  3508. $files = array_diff(scandir($path), array('.', '..'));
  3509. foreach($files as $v){
  3510. $title = explode(".", $v)[0];
  3511. $logs[$title] = $path.$v;
  3512. }
  3513. return $logs;
  3514. }
  3515. function getBackups(){
  3516. $path = DATABASE_LOCATION ."backups/";
  3517. @mkdir($path, 0770, true);
  3518. $backups = array();
  3519. $files = array_diff(scandir($path), array('.', '..'));
  3520. return array_reverse($files);
  3521. }
  3522. function getExtension($string) {
  3523. return preg_replace("#(.+)?\.(\w+)(\?.+)?#", "$2", $string);
  3524. }
  3525. function showFile(){
  3526. $file = $_GET['file'];
  3527. $fileType = getExtension($file);
  3528. if($fileType != 'php'){
  3529. header("Content-type: ".mimeTypes()[$fileType]);
  3530. @readfile($file);
  3531. }
  3532. }
  3533. function getCalendar(){
  3534. $sonarr = new Sonarr(SONARRURL, SONARRKEY);
  3535. $radarr = new Sonarr(RADARRURL, RADARRKEY);
  3536. $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
  3537. $startDate = date('Y-m-d',strtotime("-".CALENDARSTARTDAY." days"));
  3538. $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
  3539. $calendarItems = array();
  3540. if (SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)){
  3541. try {
  3542. $sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate));
  3543. if(!empty($sonarrCalendar)) { $calendarItems = array_merge($calendarItems, $sonarrCalendar); }
  3544. } catch (Exception $e) {
  3545. writeLog("error", "SONARR ERROR: ".strip($e->getMessage()));
  3546. }
  3547. }
  3548. if (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)){
  3549. try {
  3550. $radarrCalendar = getRadarrCalendar($radarr->getCalendar($startDate, $endDate));
  3551. if(!empty($radarrCalendar)) { $calendarItems = array_merge($calendarItems, $radarrCalendar); }
  3552. } catch (Exception $e) {
  3553. writeLog("error", "RADARR ERROR: ".strip($e->getMessage()));
  3554. }
  3555. }
  3556. if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
  3557. $headphonesHistory = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory");
  3558. $headphonesWanted = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted");
  3559. if(!empty($headphonesHistory)) { $calendarItems = array_merge($calendarItems, $headphonesHistory); }
  3560. if(!empty($headphonesWanted)) { $calendarItems = array_merge($calendarItems, $headphonesWanted); }
  3561. }
  3562. if (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)){
  3563. try {
  3564. $sickrageFuture = getSickrageCalendarWanted($sickrage->future());
  3565. if(!empty($sickrageFuture)) { $calendarItems = array_merge($calendarItems, $sickrageFuture); }
  3566. } catch (Exception $e) {
  3567. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3568. } try {
  3569. $sickrageHistory = getSickrageCalendarHistory($sickrage->history("100","downloaded"));
  3570. if(!empty($sickrageHistory)) { $calendarItems = array_merge($calendarItems, $sickrageHistory); }
  3571. } catch (Exception $e) {
  3572. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3573. }
  3574. }
  3575. return $calendarItems;
  3576. }
  3577. function localURL($url){
  3578. if (strpos($url, 'https') !== false) {
  3579. preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $url, $result);
  3580. $result = (!empty($result) ? true : false);
  3581. return $result;
  3582. }
  3583. }
  3584. function fileArray($files){
  3585. foreach($files as $file){
  3586. if(file_exists($file)){
  3587. $list[] = $file;
  3588. }
  3589. }
  3590. if(!empty($list)){ return $list; }
  3591. }
  3592. function backupDB(){
  3593. if (extension_loaded('ZIP')) {
  3594. $directory = DATABASE_LOCATION."backups/";
  3595. @mkdir($directory, 0770, true);
  3596. $orgFiles = array(
  3597. 'css' => 'custom.css',
  3598. 'temp' => 'cus.sd',
  3599. 'orgLog' => 'org.log',
  3600. 'loginLog' => 'loginLog.json',
  3601. 'chatDB' => 'chatpack.db',
  3602. 'config' => 'config/config.php',
  3603. 'database' => DATABASE_LOCATION.'users.db'
  3604. );
  3605. $files = fileArray($orgFiles);
  3606. if(!empty($files)){
  3607. writeLog("success", "BACKUP: backup process started");
  3608. $zipname = $directory.'backup['.date('Y-m-d_H-i').']['.INSTALLEDVERSION.'].zip';
  3609. $zip = new ZipArchive;
  3610. $zip->open($zipname, ZipArchive::CREATE);
  3611. foreach ($files as $file) {
  3612. $zip->addFile($file);
  3613. }
  3614. $zip->close();
  3615. writeLog("success", "BACKUP: backup process finished");
  3616. return true;
  3617. }else{
  3618. return false;
  3619. }
  3620. }else{
  3621. return false;
  3622. }
  3623. }
  3624. class Ping {
  3625. private $host;
  3626. private $ttl;
  3627. private $timeout;
  3628. private $port = 80;
  3629. private $data = 'Ping';
  3630. private $commandOutput;
  3631. /**
  3632. * Called when the Ping object is created.
  3633. *
  3634. * @param string $host
  3635. * The host to be pinged.
  3636. * @param int $ttl
  3637. * Time-to-live (TTL) (You may get a 'Time to live exceeded' error if this
  3638. * value is set too low. The TTL value indicates the scope or range in which
  3639. * a packet may be forwarded. By convention:
  3640. * - 0 = same host
  3641. * - 1 = same subnet
  3642. * - 32 = same site
  3643. * - 64 = same region
  3644. * - 128 = same continent
  3645. * - 255 = unrestricted
  3646. * @param int $timeout
  3647. * Timeout (in seconds) used for ping and fsockopen().
  3648. * @throws \Exception if the host is not set.
  3649. */
  3650. public function __construct($host, $ttl = 255, $timeout = 10) {
  3651. if (!isset($host)) {
  3652. throw new \Exception("Error: Host name not supplied.");
  3653. }
  3654. $this->host = $host;
  3655. $this->ttl = $ttl;
  3656. $this->timeout = $timeout;
  3657. }
  3658. /**
  3659. * Set the ttl (in hops).
  3660. *
  3661. * @param int $ttl
  3662. * TTL in hops.
  3663. */
  3664. public function setTtl($ttl) {
  3665. $this->ttl = $ttl;
  3666. }
  3667. /**
  3668. * Get the ttl.
  3669. *
  3670. * @return int
  3671. * The current ttl for Ping.
  3672. */
  3673. public function getTtl() {
  3674. return $this->ttl;
  3675. }
  3676. /**
  3677. * Set the timeout.
  3678. *
  3679. * @param int $timeout
  3680. * Time to wait in seconds.
  3681. */
  3682. public function setTimeout($timeout) {
  3683. $this->timeout = $timeout;
  3684. }
  3685. /**
  3686. * Get the timeout.
  3687. *
  3688. * @return int
  3689. * Current timeout for Ping.
  3690. */
  3691. public function getTimeout() {
  3692. return $this->timeout;
  3693. }
  3694. /**
  3695. * Set the host.
  3696. *
  3697. * @param string $host
  3698. * Host name or IP address.
  3699. */
  3700. public function setHost($host) {
  3701. $this->host = $host;
  3702. }
  3703. /**
  3704. * Get the host.
  3705. *
  3706. * @return string
  3707. * The current hostname for Ping.
  3708. */
  3709. public function getHost() {
  3710. return $this->host;
  3711. }
  3712. /**
  3713. * Set the port (only used for fsockopen method).
  3714. *
  3715. * Since regular pings use ICMP and don't need to worry about the concept of
  3716. * 'ports', this is only used for the fsockopen method, which pings servers by
  3717. * checking port 80 (by default).
  3718. *
  3719. * @param int $port
  3720. * Port to use for fsockopen ping (defaults to 80 if not set).
  3721. */
  3722. public function setPort($port) {
  3723. $this->port = $port;
  3724. }
  3725. /**
  3726. * Get the port (only used for fsockopen method).
  3727. *
  3728. * @return int
  3729. * The port used by fsockopen pings.
  3730. */
  3731. public function getPort() {
  3732. return $this->port;
  3733. }
  3734. /**
  3735. * Return the command output when method=exec.
  3736. * @return string
  3737. */
  3738. public function getCommandOutput(){
  3739. return $this->commandOutput;
  3740. }
  3741. /**
  3742. * Matches an IP on command output and returns.
  3743. * @return string
  3744. */
  3745. public function getIpAddress() {
  3746. $out = array();
  3747. if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $this->commandOutput, $out)){
  3748. return $out[0];
  3749. }
  3750. return null;
  3751. }
  3752. /**
  3753. * Ping a host.
  3754. *
  3755. * @param string $method
  3756. * Method to use when pinging:
  3757. * - exec (default): Pings through the system ping command. Fast and
  3758. * robust, but a security risk if you pass through user-submitted data.
  3759. * - fsockopen: Pings a server on port 80.
  3760. * - socket: Creates a RAW network socket. Only usable in some
  3761. * environments, as creating a SOCK_RAW socket requires root privileges.
  3762. *
  3763. * @throws InvalidArgumentException if $method is not supported.
  3764. *
  3765. * @return mixed
  3766. * Latency as integer, in ms, if host is reachable or FALSE if host is down.
  3767. */
  3768. public function ping($method = 'exec') {
  3769. $latency = false;
  3770. switch ($method) {
  3771. case 'exec':
  3772. $latency = $this->pingExec();
  3773. break;
  3774. case 'fsockopen':
  3775. $latency = $this->pingFsockopen();
  3776. break;
  3777. case 'socket':
  3778. $latency = $this->pingSocket();
  3779. break;
  3780. default:
  3781. throw new \InvalidArgumentException('Unsupported ping method.');
  3782. }
  3783. // Return the latency.
  3784. return $latency;
  3785. }
  3786. /**
  3787. * The exec method uses the possibly insecure exec() function, which passes
  3788. * the input to the system. This is potentially VERY dangerous if you pass in
  3789. * any user-submitted data. Be SURE you sanitize your inputs!
  3790. *
  3791. * @return int
  3792. * Latency, in ms.
  3793. */
  3794. private function pingExec() {
  3795. $latency = false;
  3796. $ttl = escapeshellcmd($this->ttl);
  3797. $timeout = escapeshellcmd($this->timeout);
  3798. $host = escapeshellcmd($this->host);
  3799. // Exec string for Windows-based systems.
  3800. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  3801. // -n = number of pings; -i = ttl; -w = timeout (in milliseconds).
  3802. $exec_string = 'ping -n 1 -i ' . $ttl . ' -w ' . ($timeout * 1000) . ' ' . $host;
  3803. }
  3804. // Exec string for Darwin based systems (OS X).
  3805. else if(strtoupper(PHP_OS) === 'DARWIN') {
  3806. // -n = numeric output; -c = number of pings; -m = ttl; -t = timeout.
  3807. $exec_string = 'ping -n -c 1 -m ' . $ttl . ' -t ' . $timeout . ' ' . $host;
  3808. }
  3809. // Exec string for other UNIX-based systems (Linux).
  3810. else {
  3811. // -n = numeric output; -c = number of pings; -t = ttl; -W = timeout
  3812. $exec_string = 'ping -n -c 1 -t ' . $ttl . ' -W ' . $timeout . ' ' . $host . ' 2>&1';
  3813. }
  3814. exec($exec_string, $output, $return);
  3815. // Strip empty lines and reorder the indexes from 0 (to make results more
  3816. // uniform across OS versions).
  3817. $this->commandOutput = implode($output, '');
  3818. $output = array_values(array_filter($output));
  3819. // If the result line in the output is not empty, parse it.
  3820. if (!empty($output[1])) {
  3821. // Search for a 'time' value in the result line.
  3822. $response = preg_match("/time(?:=|<)(?<time>[\.0-9]+)(?:|\s)ms/", $output[1], $matches);
  3823. // If there's a result and it's greater than 0, return the latency.
  3824. if ($response > 0 && isset($matches['time'])) {
  3825. $latency = round($matches['time'], 2);
  3826. }
  3827. }
  3828. return $latency;
  3829. }
  3830. /**
  3831. * The fsockopen method simply tries to reach the host on a port. This method
  3832. * is often the fastest, but not necessarily the most reliable. Even if a host
  3833. * doesn't respond, fsockopen may still make a connection.
  3834. *
  3835. * @return int
  3836. * Latency, in ms.
  3837. */
  3838. private function pingFsockopen() {
  3839. $start = microtime(true);
  3840. // fsockopen prints a bunch of errors if a host is unreachable. Hide those
  3841. // irrelevant errors and deal with the results instead.
  3842. $fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
  3843. if (!$fp) {
  3844. $latency = false;
  3845. }
  3846. else {
  3847. $latency = microtime(true) - $start;
  3848. $latency = round($latency * 1000, 2);
  3849. }
  3850. return $latency;
  3851. }
  3852. /**
  3853. * The socket method uses raw network packet data to try sending an ICMP ping
  3854. * packet to a server, then measures the response time. Using this method
  3855. * requires the script to be run with root privileges, though, so this method
  3856. * only works reliably on Windows systems and on Linux servers where the
  3857. * script is not being run as a web user.
  3858. *
  3859. * @return int
  3860. * Latency, in ms.
  3861. */
  3862. private function pingSocket() {
  3863. // Create a package.
  3864. $type = "\x08";
  3865. $code = "\x00";
  3866. $checksum = "\x00\x00";
  3867. $identifier = "\x00\x00";
  3868. $seq_number = "\x00\x00";
  3869. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  3870. // Calculate the checksum.
  3871. $checksum = $this->calculateChecksum($package);
  3872. // Finalize the package.
  3873. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  3874. // Create a socket, connect to server, then read socket and calculate.
  3875. if ($socket = socket_create(AF_INET, SOCK_RAW, 1)) {
  3876. socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array(
  3877. 'sec' => 10,
  3878. 'usec' => 0,
  3879. ));
  3880. // Prevent errors from being printed when host is unreachable.
  3881. @socket_connect($socket, $this->host, null);
  3882. $start = microtime(true);
  3883. // Send the package.
  3884. @socket_send($socket, $package, strlen($package), 0);
  3885. if (socket_read($socket, 255) !== false) {
  3886. $latency = microtime(true) - $start;
  3887. $latency = round($latency * 1000, 2);
  3888. }
  3889. else {
  3890. $latency = false;
  3891. }
  3892. }
  3893. else {
  3894. $latency = false;
  3895. }
  3896. // Close the socket.
  3897. socket_close($socket);
  3898. return $latency;
  3899. }
  3900. /**
  3901. * Calculate a checksum.
  3902. *
  3903. * @param string $data
  3904. * Data for which checksum will be calculated.
  3905. *
  3906. * @return string
  3907. * Binary string checksum of $data.
  3908. */
  3909. private function calculateChecksum($data) {
  3910. if (strlen($data) % 2) {
  3911. $data .= "\x00";
  3912. }
  3913. $bit = unpack('n*', $data);
  3914. $sum = array_sum($bit);
  3915. while ($sum >> 16) {
  3916. $sum = ($sum >> 16) + ($sum & 0xffff);
  3917. }
  3918. return pack('n*', ~$sum);
  3919. }
  3920. }
  3921. function ping($pings, $type = "string") {
  3922. $ping = new Ping("");
  3923. $ping->setTtl(128);
  3924. $ping->setTimeout(2);
  3925. switch ($type){
  3926. case "array":
  3927. $results = [];
  3928. foreach ($pings as $k => $v) {
  3929. if(strpos($v, ':') !== false){
  3930. $domain = explode(':', $v)[0];
  3931. $port = explode(':', $v)[1];
  3932. $ping->setHost($domain);
  3933. $ping->setPort($port);
  3934. $latency = $ping->ping('fsockopen');
  3935. }else{
  3936. $ping->setHost($v);
  3937. $latency = $ping->ping();
  3938. }
  3939. if ($latency || $latency === 0) {
  3940. $results[$k] = $latency;
  3941. } else {
  3942. $results[$k] = 0;
  3943. }
  3944. }
  3945. break;
  3946. case "string":
  3947. if(strpos($pings, ':') !== false){
  3948. $domain = explode(':', $pings)[0];
  3949. $port = explode(':', $pings)[1];
  3950. $ping->setHost($domain);
  3951. $ping->setPort($port);
  3952. $latency = $ping->ping('fsockopen');
  3953. }else{
  3954. $ping->setHost($pings);
  3955. $latency = $ping->ping();
  3956. }
  3957. if ($latency || $latency === 0) {
  3958. $results = $latency;
  3959. } else {
  3960. $results = 0;
  3961. }
  3962. break;
  3963. }
  3964. return $results;
  3965. }
  3966. function getPing($url, $style, $refresh = null){
  3967. if(ping($url) !== 0){
  3968. $class = 'success';
  3969. if(!$refresh){
  3970. $class .= " animated slideInLeft";
  3971. }
  3972. }else{
  3973. $class = "warning";
  3974. if(!$refresh){
  3975. $class .= " animated flash loop-animation-timeout";
  3976. }
  3977. }
  3978. echo '<span class="badge ping-'.$class.'" style="position: absolute;z-index: 100;right: 5px; padding: 0px 0px;'.$style.';font-size: 10px;">&nbsp;</span>';
  3979. }
  3980. function speedTestData(){
  3981. $file_db = DATABASE_LOCATION."speedtest.db";
  3982. if(file_exists($file_db)){
  3983. $conn = new PDO("sqlite:$file_db") or die("1");
  3984. $result = $conn->query('SELECT * FROM speedtest_users');
  3985. $conn = null;
  3986. if (is_array($result) || is_object($result)){
  3987. foreach($result as $k => $v){
  3988. $return[$k] = $v;
  3989. }
  3990. return $return;
  3991. }
  3992. }
  3993. }
  3994. function speedTestDisplay($array, $output){
  3995. if (is_array($array) || is_object($array)){
  3996. if($output == "graph"){
  3997. $result = "Morris.Line({element: 'morris-line',data: [";
  3998. foreach($array as $k => $v){
  3999. $result .= "{ y: '".substr($v['timestamp'],0,10)."', a: ".$v['ul'].", b: ".$v['dl'].", c: ".$v['ping']." },";
  4000. }
  4001. $result .= "],xkey: 'y',ykeys: ['a', 'b', 'c'],labels: ['Upload', 'Download', 'Ping'],hideHover: 'auto',resize: true,lineColors: ['#63A8EB','#ccc','#000'] });";
  4002. }elseif($output == "table"){
  4003. $result = "";
  4004. foreach($array as $k => $v){
  4005. $result .= "<tr><td>".$v['timestamp']."</td><td>".$v['ip']."</td><td>".$v['dl']."</td><td>".$v['ul']."</td><td>".$v['ping']."</td><td>".$v['jitter']."</td></tr>";
  4006. }
  4007. }
  4008. return $result;
  4009. }
  4010. }
  4011. function buildMenuPhone($array){
  4012. if (is_array($array) || is_object($array)){
  4013. $result = '
  4014. <div class="content-box profile-sidebar box-shadow">
  4015. <img src="images/organizr-logo-h-d.png" width="100%" style="margin-top: -10px;">
  4016. <div class="profile-usermenu">
  4017. <ul class="nav" id="settings-list">
  4018. ';
  4019. foreach($array as $k => $v){
  4020. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4021. continue;
  4022. }
  4023. /*$result .= '
  4024. <li>
  4025. <a id="'.$v['id'].'" box="'.$v['box'].'">'.$v['name'].'
  4026. <span class="fa-stack fa-fw pull-right" style="margin-top: -5px;margin-right: -10px;">
  4027. <i class="fa fa-'.$v['icon_1'].' fa-stack-2x '.$v['color'].'" style="font-size:null;"></i>
  4028. <i class="fa fa-'.$v['icon_2'].' fa-stack-1x fa-inverse"></i>
  4029. </span>
  4030. </a>
  4031. </li>
  4032. ';*/
  4033. $result .= '<li><a id="'.$v['id'].'" box="'.$v['box'].'"><i class="fa fa-'.$v['icon_2'].' '.$v['color'].' pull-right"></i>'.$v['name'].'</a></li>';
  4034. }
  4035. $result .= '</ul></div></div>';
  4036. return $result;
  4037. }
  4038. }
  4039. function buildMenu($array){
  4040. if (is_array($array) || is_object($array)){
  4041. $result = '<div class="settingsList">';
  4042. foreach($array as $k => $v){
  4043. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4044. continue;
  4045. }
  4046. $result .= '
  4047. <button id="'.$v['id'].'" box="'.$v['box'].'" type="button" style="border-radius: 0px !important; -webkit-border-radius: 0px !important;margin-bottom: 3px;margin-left:5px;color:white;" class="btn '.$v['color2'].' btn-icon waves waves-circle waves-effect waves-float settingsMenu">
  4048. <i class="mdi mdi-'.$v['icon_1'].' fa-fw pull-left" style="padding-left: '.$v['padding'].'px;font-size: 30px"></i>
  4049. <p class="" style="text-align: center;direction: rtl;display:none;margin: 2px;"><strong>'.$v['name'].'</strong></p>
  4050. </button>
  4051. ';
  4052. }
  4053. $result .= '</div>';
  4054. return $result;
  4055. }
  4056. }
  4057. function requestInvite($email, $username){
  4058. //sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null){
  4059. //orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  4060. sendEmail($GLOBALS['USER']->adminEmail, "Admin", "Plex Invite Request", orgEmail("PLEX Invite Request", "Look who wants to join the cool club", "Admin", "Hey, The User: $user has requested access to your Plex Library.", "Generate Invite", null, "What Next?", "Well, That is up to you. You can go check on them if you like."));
  4061. }
  4062. function errormessage($msg) {
  4063. echo "<div style=\"margin-top: 50px;\">";
  4064. echo "<span style=\"color:#d89334;\">error </span>";
  4065. echo $msg;
  4066. echo "</div>";
  4067. }
  4068. class Mobile_Detect
  4069. {
  4070. /**
  4071. * Mobile detection type.
  4072. *
  4073. * @deprecated since version 2.6.9
  4074. */
  4075. const DETECTION_TYPE_MOBILE = 'mobile';
  4076. /**
  4077. * Extended detection type.
  4078. *
  4079. * @deprecated since version 2.6.9
  4080. */
  4081. const DETECTION_TYPE_EXTENDED = 'extended';
  4082. /**
  4083. * A frequently used regular expression to extract version #s.
  4084. *
  4085. * @deprecated since version 2.6.9
  4086. */
  4087. const VER = '([\w._\+]+)';
  4088. /**
  4089. * Top-level device.
  4090. */
  4091. const MOBILE_GRADE_A = 'A';
  4092. /**
  4093. * Mid-level device.
  4094. */
  4095. const MOBILE_GRADE_B = 'B';
  4096. /**
  4097. * Low-level device.
  4098. */
  4099. const MOBILE_GRADE_C = 'C';
  4100. /**
  4101. * Stores the version number of the current release.
  4102. */
  4103. const VERSION = '2.8.26';
  4104. /**
  4105. * A type for the version() method indicating a string return value.
  4106. */
  4107. const VERSION_TYPE_STRING = 'text';
  4108. /**
  4109. * A type for the version() method indicating a float return value.
  4110. */
  4111. const VERSION_TYPE_FLOAT = 'float';
  4112. /**
  4113. * A cache for resolved matches
  4114. * @var array
  4115. */
  4116. protected $cache = array();
  4117. /**
  4118. * The User-Agent HTTP header is stored in here.
  4119. * @var string
  4120. */
  4121. protected $userAgent = null;
  4122. /**
  4123. * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
  4124. * @var array
  4125. */
  4126. protected $httpHeaders = array();
  4127. /**
  4128. * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
  4129. * @var array
  4130. */
  4131. protected $cloudfrontHeaders = array();
  4132. /**
  4133. * The matching Regex.
  4134. * This is good for debug.
  4135. * @var string
  4136. */
  4137. protected $matchingRegex = null;
  4138. /**
  4139. * The matches extracted from the regex expression.
  4140. * This is good for debug.
  4141. * @var string
  4142. */
  4143. protected $matchesArray = null;
  4144. /**
  4145. * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
  4146. *
  4147. * @deprecated since version 2.6.9
  4148. *
  4149. * @var string
  4150. */
  4151. protected $detectionType = self::DETECTION_TYPE_MOBILE;
  4152. /**
  4153. * HTTP headers that trigger the 'isMobile' detection
  4154. * to be true.
  4155. *
  4156. * @var array
  4157. */
  4158. protected static $mobileHeaders = array(
  4159. 'HTTP_ACCEPT' => array('matches' => array(
  4160. // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
  4161. 'application/x-obml2d',
  4162. // BlackBerry devices.
  4163. 'application/vnd.rim.html',
  4164. 'text/vnd.wap.wml',
  4165. 'application/vnd.wap.xhtml+xml'
  4166. )),
  4167. 'HTTP_X_WAP_PROFILE' => null,
  4168. 'HTTP_X_WAP_CLIENTID' => null,
  4169. 'HTTP_WAP_CONNECTION' => null,
  4170. 'HTTP_PROFILE' => null,
  4171. // Reported by Opera on Nokia devices (eg. C3).
  4172. 'HTTP_X_OPERAMINI_PHONE_UA' => null,
  4173. 'HTTP_X_NOKIA_GATEWAY_ID' => null,
  4174. 'HTTP_X_ORANGE_ID' => null,
  4175. 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
  4176. 'HTTP_X_HUAWEI_USERID' => null,
  4177. // Reported by Windows Smartphones.
  4178. 'HTTP_UA_OS' => null,
  4179. // Reported by Verizon, Vodafone proxy system.
  4180. 'HTTP_X_MOBILE_GATEWAY' => null,
  4181. // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
  4182. 'HTTP_X_ATT_DEVICEID' => null,
  4183. // Seen this on a HTC.
  4184. 'HTTP_UA_CPU' => array('matches' => array('ARM')),
  4185. );
  4186. /**
  4187. * List of mobile devices (phones).
  4188. *
  4189. * @var array
  4190. */
  4191. protected static $phoneDevices = array(
  4192. 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
  4193. 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
  4194. 'HTC' => 'HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\bEVO\b|T-Mobile G1|Z520m',
  4195. 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
  4196. // @todo: Is 'Dell Streak' a tablet or a phone? ;)
  4197. 'Dell' => 'Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b',
  4198. 'Motorola' => 'Motorola|DROIDX|DROID BIONIC|\bDroid\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\bMoto E\b',
  4199. 'Samsung' => '\bSamsung\b|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|SM-N910C',
  4200. 'LG' => '\bLG\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323)',
  4201. 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
  4202. 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
  4203. 'NokiaLumia' => 'Lumia [0-9]{3,4}',
  4204. // http://www.micromaxinfo.com/mobiles/smartphones
  4205. // Added because the codes might conflict with Acer Tablets.
  4206. 'Micromax' => 'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b',
  4207. // @todo Complete the regex.
  4208. 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
  4209. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
  4210. // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
  4211. // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
  4212. 'Pantech' => 'PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790',
  4213. // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
  4214. 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
  4215. // http://fr.wikomobile.com
  4216. 'Wiko' => 'KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM',
  4217. 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
  4218. // Added simvalley mobile just for fun. They have some interesting devices.
  4219. // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
  4220. 'SimValley' => '\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\b',
  4221. // Wolfgang - a brand that is sold by Aldi supermarkets.
  4222. // http://www.wolfgangmobile.com/
  4223. 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
  4224. 'Alcatel' => 'Alcatel',
  4225. 'Nintendo' => 'Nintendo 3DS',
  4226. // http://en.wikipedia.org/wiki/Amoi
  4227. 'Amoi' => 'Amoi',
  4228. // http://en.wikipedia.org/wiki/INQ
  4229. 'INQ' => 'INQ',
  4230. // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
  4231. 'GenericPhone' => 'Tapatalk|PDA;|SAGEM|\bmmp\b|pocket|\bpsp\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\bwap\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser',
  4232. );
  4233. /**
  4234. * List of tablet devices.
  4235. *
  4236. * @var array
  4237. */
  4238. protected static $tabletDevices = array(
  4239. // @todo: check for mobile friendly emails topic.
  4240. 'iPad' => 'iPad|iPad.*Mobile',
  4241. // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
  4242. // @see #442
  4243. 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
  4244. 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y', // SCH-P709|SCH-P729|SM-T2558|GT-I9205 - Samsung Mega - treat them like a regular phone.
  4245. // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
  4246. 'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\b|Android.*Silk/[0-9.]+ like Chrome/[0-9.]+ (?!Mobile)',
  4247. // Only the Surface tablets with Windows RT are considered mobile.
  4248. // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
  4249. 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
  4250. // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
  4251. 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
  4252. // Watch out for PadFone, see #132.
  4253. // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
  4254. 'AsusTablet' => '^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\bK00F\b|\bK00C\b|\bK00E\b|\bK00L\b|TX201LA|ME176C|ME102A|\bM80TA\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\bME70C\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z|\bP027\b',
  4255. 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
  4256. 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
  4257. 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
  4258. 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
  4259. // http://www.acer.ro/ac/ro/RO/content/drivers
  4260. // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
  4261. // http://us.acer.com/ac/en/US/content/group/tablets
  4262. // http://www.acer.de/ac/de/DE/content/models/tablets/
  4263. // Can conflict with Micromax and Motorola phones codes.
  4264. 'AcerTablet' => 'Android.*; \b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\b|W3-810|\bA3-A10\b|\bA3-A11\b|\bA3-A20\b|\bA3-A30',
  4265. // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
  4266. // http://us.toshiba.com/tablets/tablet-finder
  4267. // http://www.toshiba.co.jp/regza/tablet/
  4268. 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
  4269. // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
  4270. // http://www.lg.com/us/tablets
  4271. 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
  4272. 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
  4273. // Prestigio Tablets http://www.prestigio.com/support
  4274. 'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002',
  4275. // http://support.lenovo.com/en_GB/downloads/default.page?#
  4276. 'LenovoTablet' => 'Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)',
  4277. // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
  4278. 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
  4279. // http://www.yarvik.com/en/matrix/tablets/
  4280. 'YarvikTablet' => 'Android.*\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\b',
  4281. 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
  4282. 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
  4283. // http://www.intenso.de/kategorie_en.php?kategorie=33
  4284. // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
  4285. 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
  4286. // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
  4287. 'IRUTablet' => 'M702pro',
  4288. 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
  4289. // http://www.e-boda.ro/tablete-pc.html
  4290. 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
  4291. // http://www.allview.ro/produse/droseries/lista-tablete-pc/
  4292. 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
  4293. // http://wiki.archosfans.com/index.php?title=Main_Page
  4294. // @note Rewrite the regex format after we add more UAs.
  4295. 'ArchosTablet' => '\b(101G9|80G9|A101IT)\b|Qilive 97R|Archos5|\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|c|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\b',
  4296. // http://www.ainol.com/plugin.php?identifier=ainol&module=product
  4297. 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
  4298. 'NokiaLumiaTablet' => 'Lumia 2520',
  4299. // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
  4300. // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
  4301. // http://www.sony.jp/support/tablet/
  4302. 'SonyTablet' => 'Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP612|SOT31',
  4303. // http://www.support.philips.com/support/catalog/worldproducts.jsp?userLanguage=en&userCountry=cn&categoryid=3G_LTE_TABLET_SU_CN_CARE&title=3G%20tablets%20/%20LTE%20range&_dyncharset=UTF-8
  4304. 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
  4305. // db + http://www.cube-tablet.com/buy-products.html
  4306. 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
  4307. // http://www.cobyusa.com/?p=pcat&pcat_id=3001
  4308. 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
  4309. // http://www.match.net.cn/products.asp
  4310. 'MIDTablet' => 'M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10',
  4311. // http://www.msi.com/support
  4312. // @todo Research the Windows Tablets.
  4313. 'MSITablet' => 'MSI \b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\b',
  4314. // @todo http://www.kyoceramobile.com/support/drivers/
  4315. // 'KyoceraTablet' => null,
  4316. // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
  4317. // 'IntextTablet' => null,
  4318. // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
  4319. // http://www.imp3.net/14/show.php?itemid=20454
  4320. 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
  4321. // http://www.rock-chips.com/index.php?do=prod&pid=2
  4322. 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
  4323. // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
  4324. 'FlyTablet' => 'IQ310|Fly Vision',
  4325. // http://www.bqreaders.com/gb/tablets-prices-sale.html
  4326. 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
  4327. // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
  4328. // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
  4329. 'HuaweiTablet' => 'MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim',
  4330. // Nec or Medias Tab
  4331. 'NecTablet' => '\bN-06D|\bN-08D',
  4332. // Pantech Tablets: http://www.pantechusa.com/phones/
  4333. 'PantechTablet' => 'Pantech.*P4100',
  4334. // Broncho Tablets: http://www.broncho.cn/ (hard to find)
  4335. 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
  4336. // http://versusuk.com/support.html
  4337. 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
  4338. // http://www.zync.in/index.php/our-products/tablet-phablets
  4339. 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
  4340. // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
  4341. 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
  4342. // https://www.nabitablet.com/
  4343. 'NabiTablet' => 'Android.*\bNabi',
  4344. 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
  4345. // French Danew Tablets http://www.danew.com/produits-tablette.php
  4346. 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
  4347. // Texet Tablets and Readers http://www.texet.ru/tablet/
  4348. 'TexetTablet' => 'NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE',
  4349. // Avoid detecting 'PLAYSTATION 3' as mobile.
  4350. 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
  4351. // http://www.trekstor.de/surftabs.html
  4352. 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
  4353. // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
  4354. 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
  4355. // http://www.advandigital.com/index.php?link=content-product&jns=JP001
  4356. // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
  4357. 'AdvanTablet' => 'Android.* \b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\b ',
  4358. // http://www.danytech.com/category/tablet-pc
  4359. 'DanyTechTablet' => 'Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1',
  4360. // http://www.galapad.net/product.html
  4361. 'GalapadTablet' => 'Android.*\bG1\b',
  4362. // http://www.micromaxinfo.com/tablet/funbook
  4363. 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
  4364. // http://www.karbonnmobiles.com/products_tablet.php
  4365. 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
  4366. // http://www.myallfine.com/Products.asp
  4367. 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
  4368. // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
  4369. 'PROSCANTablet' => '\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\b',
  4370. // http://www.yonesnav.com/products/products.php
  4371. 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
  4372. // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
  4373. // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
  4374. 'ChangJiaTablet' => 'TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503',
  4375. // http://www.gloryunion.cn/products.asp
  4376. // http://www.allwinnertech.com/en/apply/mobile.html
  4377. // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
  4378. // @todo: Softwiner tablets?
  4379. // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
  4380. 'GUTablet' => 'TX-A1301|TX-M9002|Q702|kf026', // A12R|D75A|D77|D79|R83|A95|A106C|R15|A75|A76|D71|D72|R71|R73|R77|D82|R85|D92|A97|D92|R91|A10F|A77F|W71F|A78F|W78F|W81F|A97F|W91F|W97F|R16G|C72|C73E|K72|K73|R96G
  4381. // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
  4382. 'PointOfViewTablet' => 'TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10',
  4383. // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
  4384. // @todo: add more tests.
  4385. 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
  4386. // http://hclmetablet.com/India/index.php
  4387. 'HCLTablet' => 'HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync',
  4388. // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
  4389. 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
  4390. // http://www.visture.com/index.asp
  4391. 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
  4392. // http://www.mijncresta.nl/tablet
  4393. 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
  4394. // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
  4395. 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
  4396. // Concorde tab
  4397. 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
  4398. // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
  4399. 'GoCleverTablet' => 'GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042',
  4400. // Modecom Tablets - http://www.modecom.eu/tablets/portal/
  4401. 'ModecomTablet' => 'FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003',
  4402. // Vonino Tablets - http://www.vonino.eu/tablets
  4403. 'VoninoTablet' => '\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\bQ8\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\b',
  4404. // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
  4405. 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
  4406. // Storex Tablets - http://storex.fr/espace_client/support.html
  4407. // @note: no need to add all the tablet codes since they are guided by the first regex.
  4408. 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
  4409. // Generic Vodafone tablets.
  4410. 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
  4411. // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
  4412. // Aka: http://www.essentielb.fr/
  4413. 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
  4414. // Ross & Moor - http://ross-moor.ru/
  4415. 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
  4416. // i-mobile http://product.i-mobilephone.com/Mobile_Device
  4417. 'iMobileTablet' => 'i-mobile i-note',
  4418. // http://www.tolino.de/de/vergleichen/
  4419. 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
  4420. // AudioSonic - a Kmart brand
  4421. // http://www.kmart.com.au/webapp/wcs/stores/servlet/Search?langId=-1&storeId=10701&catalogId=10001&categoryId=193001&pageSize=72&currentPage=1&searchCategory=193001%2b4294965664&sortBy=p_MaxPrice%7c1
  4422. 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
  4423. // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
  4424. // @todo: add them gradually to avoid conflicts.
  4425. 'AMPETablet' => 'Android.* A78 ',
  4426. // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
  4427. 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
  4428. // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
  4429. 'TecnoTablet' => 'TECNO P9',
  4430. // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
  4431. 'JXDTablet' => 'Android.* \b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\b',
  4432. // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
  4433. 'iJoyTablet' => 'Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)',
  4434. // http://www.intracon.eu/tablet
  4435. 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
  4436. // http://www.xoro.de/produkte/
  4437. // @note: Might be the same brand with 'Simply tablets'
  4438. 'XoroTablet' => 'KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151',
  4439. // http://www1.viewsonic.com/products/computing/tablets/
  4440. 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
  4441. // http://www.odys.de/web/internet-tablet_en.html
  4442. 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
  4443. // http://www.captiva-power.de/products.html#tablets-en
  4444. 'CaptivaTablet' => 'CAPTIVA PAD',
  4445. // IconBIT - http://www.iconbit.com/products/tablets/
  4446. 'IconbitTablet' => 'NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S',
  4447. // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
  4448. 'TeclastTablet' => 'T98 4G|\bP80\b|\bX90HD\b|X98 Air|X98 Air 3G|\bX89\b|P80 3G|\bX80h\b|P98 Air|\bX89HD\b|P98 3G|\bP90HD\b|P89 3G|X98 3G|\bP70h\b|P79HD 3G|G18d 3G|\bP79HD\b|\bP89s\b|\bA88\b|\bP10HD\b|\bP19HD\b|G18 3G|\bP78HD\b|\bA78\b|\bP75\b|G17s 3G|G17h 3G|\bP85t\b|\bP90\b|\bP11\b|\bP98t\b|\bP98HD\b|\bG18d\b|\bP85s\b|\bP11HD\b|\bP88s\b|\bA80HD\b|\bA80se\b|\bA10h\b|\bP89\b|\bP78s\b|\bG18\b|\bP85\b|\bA70h\b|\bA70\b|\bG17\b|\bP18\b|\bA80s\b|\bA11s\b|\bP88HD\b|\bA80h\b|\bP76s\b|\bP76h\b|\bP98\b|\bA10HD\b|\bP78\b|\bP88\b|\bA11\b|\bA10t\b|\bP76a\b|\bP76t\b|\bP76e\b|\bP85HD\b|\bP85a\b|\bP86\b|\bP75HD\b|\bP76v\b|\bA12\b|\bP75a\b|\bA15\b|\bP76Ti\b|\bP81HD\b|\bA10\b|\bT760VE\b|\bT720HD\b|\bP76\b|\bP73\b|\bP71\b|\bP72\b|\bT720SE\b|\bC520Ti\b|\bT760\b|\bT720VE\b|T720-3GE|T720-WiFi',
  4449. // Onda - http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
  4450. 'OndaTablet' => '\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\b[\s]+',
  4451. 'JaytechTablet' => 'TPC-PA762',
  4452. 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
  4453. // http://www.digma.ru/support/download/
  4454. // @todo: Ebooks also (if requested)
  4455. 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
  4456. // http://www.evolioshop.com/ro/tablete-pc.html
  4457. // http://www.evolio.ro/support/downloads_static.html?cat=2
  4458. // @todo: Research some more
  4459. 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
  4460. // @todo http://www.lavamobiles.com/tablets-data-cards
  4461. 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
  4462. // http://www.breezetablet.com/
  4463. 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
  4464. // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
  4465. 'MpmanTablet' => 'MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\bMPG7\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010',
  4466. // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
  4467. 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
  4468. // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
  4469. 'WolderTablet' => 'miTab \b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\b',
  4470. // http://www.mi.com/en
  4471. 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
  4472. // http://www.nbru.cn/index.html
  4473. 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
  4474. // http://navroad.com/products/produkty/tablety/
  4475. // http://navroad.com/products/produkty/tablety/
  4476. 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
  4477. // http://leader-online.com/new_site/product-category/tablets/
  4478. // http://www.leader-online.net.au/List/Tablet
  4479. 'LeaderTablet' => 'TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100',
  4480. // http://www.datawind.com/ubislate/
  4481. 'UbislateTablet' => 'UbiSlate[\s]?7C',
  4482. // http://www.pocketbook-int.com/ru/support
  4483. 'PocketBookTablet' => 'Pocketbook',
  4484. // http://www.kocaso.com/product_tablet.html
  4485. 'KocasoTablet' => '\b(TB-1207)\b',
  4486. // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
  4487. 'HisenseTablet' => '\b(F5281|E2371)\b',
  4488. // http://www.tesco.com/direct/hudl/
  4489. 'Hudl' => 'Hudl HT7S3|Hudl 2',
  4490. // http://www.telstra.com.au/home-phone/thub-2/
  4491. 'TelstraTablet' => 'T-Hub2',
  4492. 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\bM6pro\b|CT1020W|arc 10HD|\bTP750\b|\bQTAQZ3\b'
  4493. );
  4494. /**
  4495. * List of mobile Operating Systems.
  4496. *
  4497. * @var array
  4498. */
  4499. protected static $operatingSystems = array(
  4500. 'AndroidOS' => 'Android',
  4501. 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
  4502. 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
  4503. 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
  4504. // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
  4505. 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
  4506. // @reference: http://en.wikipedia.org/wiki/Windows_Phone
  4507. // http://wifeng.cn/?r=blog&a=view&id=106
  4508. // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
  4509. // http://msdn.microsoft.com/library/ms537503.aspx
  4510. // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
  4511. 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
  4512. 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
  4513. // http://en.wikipedia.org/wiki/MeeGo
  4514. // @todo: research MeeGo in UAs
  4515. 'MeeGoOS' => 'MeeGo',
  4516. // http://en.wikipedia.org/wiki/Maemo
  4517. // @todo: research Maemo in UAs
  4518. 'MaemoOS' => 'Maemo',
  4519. 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
  4520. 'webOS' => 'webOS|hpwOS',
  4521. 'badaOS' => '\bBada\b',
  4522. 'BREWOS' => 'BREW',
  4523. );
  4524. /**
  4525. * List of mobile User Agents.
  4526. *
  4527. * IMPORTANT: This is a list of only mobile browsers.
  4528. * Mobile Detect 2.x supports only mobile browsers,
  4529. * it was never designed to detect all browsers.
  4530. * The change will come in 2017 in the 3.x release for PHP7.
  4531. *
  4532. * @var array
  4533. */
  4534. protected static $browsers = array(
  4535. //'Vivaldi' => 'Vivaldi',
  4536. // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
  4537. 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
  4538. 'Dolfin' => '\bDolfin\b',
  4539. 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
  4540. 'Skyfire' => 'Skyfire',
  4541. 'Edge' => 'Mobile Safari/[.0-9]* Edge',
  4542. 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
  4543. 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
  4544. 'Bolt' => 'bolt',
  4545. 'TeaShark' => 'teashark',
  4546. 'Blazer' => 'Blazer',
  4547. // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
  4548. 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
  4549. // http://en.wikipedia.org/wiki/Midori_(web_browser)
  4550. //'Midori' => 'midori',
  4551. //'Tizen' => 'Tizen',
  4552. 'UCBrowser' => 'UC.*Browser|UCWEB',
  4553. 'baiduboxapp' => 'baiduboxapp',
  4554. 'baidubrowser' => 'baidubrowser',
  4555. // https://github.com/serbanghita/Mobile-Detect/issues/7
  4556. 'DiigoBrowser' => 'DiigoBrowser',
  4557. // http://www.puffinbrowser.com/index.php
  4558. 'Puffin' => 'Puffin',
  4559. // http://mercury-browser.com/index.html
  4560. 'Mercury' => '\bMercury\b',
  4561. // http://en.wikipedia.org/wiki/Obigo_Browser
  4562. 'ObigoBrowser' => 'Obigo',
  4563. // http://en.wikipedia.org/wiki/NetFront
  4564. 'NetFront' => 'NF-Browser',
  4565. // @reference: http://en.wikipedia.org/wiki/Minimo
  4566. // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
  4567. 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
  4568. // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
  4569. 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
  4570. );
  4571. /**
  4572. * Utilities.
  4573. *
  4574. * @var array
  4575. */
  4576. protected static $utilities = array(
  4577. // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
  4578. // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
  4579. // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
  4580. // https://developers.facebook.com/docs/sharing/best-practices
  4581. 'Bot' => 'Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom',
  4582. 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
  4583. 'DesktopMode' => 'WPDesktop',
  4584. 'TV' => 'SonyDTV|HbbTV', // experimental
  4585. 'WebKit' => '(webkit)[ /]([\w.]+)',
  4586. // @todo: Include JXD consoles.
  4587. 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
  4588. 'Watch' => 'SM-V700',
  4589. );
  4590. /**
  4591. * All possible HTTP headers that represent the
  4592. * User-Agent string.
  4593. *
  4594. * @var array
  4595. */
  4596. protected static $uaHttpHeaders = array(
  4597. // The default User-Agent string.
  4598. 'HTTP_USER_AGENT',
  4599. // Header can occur on devices using Opera Mini.
  4600. 'HTTP_X_OPERAMINI_PHONE_UA',
  4601. // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
  4602. 'HTTP_X_DEVICE_USER_AGENT',
  4603. 'HTTP_X_ORIGINAL_USER_AGENT',
  4604. 'HTTP_X_SKYFIRE_PHONE',
  4605. 'HTTP_X_BOLT_PHONE_UA',
  4606. 'HTTP_DEVICE_STOCK_UA',
  4607. 'HTTP_X_UCBROWSER_DEVICE_UA'
  4608. );
  4609. /**
  4610. * The individual segments that could exist in a User-Agent string. VER refers to the regular
  4611. * expression defined in the constant self::VER.
  4612. *
  4613. * @var array
  4614. */
  4615. protected static $properties = array(
  4616. // Build
  4617. 'Mobile' => 'Mobile/[VER]',
  4618. 'Build' => 'Build/[VER]',
  4619. 'Version' => 'Version/[VER]',
  4620. 'VendorID' => 'VendorID/[VER]',
  4621. // Devices
  4622. 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
  4623. 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
  4624. 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
  4625. //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
  4626. 'Kindle' => 'Kindle/[VER]',
  4627. // Browser
  4628. 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
  4629. 'Coast' => array('Coast/[VER]'),
  4630. 'Dolfin' => 'Dolfin/[VER]',
  4631. // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
  4632. 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
  4633. 'Fennec' => 'Fennec/[VER]',
  4634. // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  4635. // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
  4636. 'Edge' => 'Edge/[VER]',
  4637. 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
  4638. // http://en.wikipedia.org/wiki/NetFront
  4639. 'NetFront' => 'NetFront/[VER]',
  4640. 'NokiaBrowser' => 'NokiaBrowser/[VER]',
  4641. 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
  4642. 'Opera Mini' => 'Opera Mini/[VER]',
  4643. 'Opera Mobi' => 'Version/[VER]',
  4644. 'UC Browser' => 'UC Browser[VER]',
  4645. 'MQQBrowser' => 'MQQBrowser/[VER]',
  4646. 'MicroMessenger' => 'MicroMessenger/[VER]',
  4647. 'baiduboxapp' => 'baiduboxapp/[VER]',
  4648. 'baidubrowser' => 'baidubrowser/[VER]',
  4649. 'SamsungBrowser' => 'SamsungBrowser/[VER]',
  4650. 'Iron' => 'Iron/[VER]',
  4651. // @note: Safari 7534.48.3 is actually Version 5.1.
  4652. // @note: On BlackBerry the Version is overwriten by the OS.
  4653. 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
  4654. 'Skyfire' => 'Skyfire/[VER]',
  4655. 'Tizen' => 'Tizen/[VER]',
  4656. 'Webkit' => 'webkit[ /][VER]',
  4657. 'PaleMoon' => 'PaleMoon/[VER]',
  4658. // Engine
  4659. 'Gecko' => 'Gecko/[VER]',
  4660. 'Trident' => 'Trident/[VER]',
  4661. 'Presto' => 'Presto/[VER]',
  4662. 'Goanna' => 'Goanna/[VER]',
  4663. // OS
  4664. 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
  4665. 'Android' => 'Android [VER]',
  4666. 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
  4667. 'BREW' => 'BREW [VER]',
  4668. 'Java' => 'Java/[VER]',
  4669. // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
  4670. // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
  4671. 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
  4672. 'Windows Phone' => 'Windows Phone [VER]',
  4673. 'Windows CE' => 'Windows CE/[VER]',
  4674. // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
  4675. 'Windows NT' => 'Windows NT [VER]',
  4676. 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
  4677. 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
  4678. );
  4679. /**
  4680. * Construct an instance of this class.
  4681. *
  4682. * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
  4683. * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
  4684. * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
  4685. * from the $headers array instead.
  4686. */
  4687. public function __construct(
  4688. array $headers = null,
  4689. $userAgent = null
  4690. ) {
  4691. $this->setHttpHeaders($headers);
  4692. $this->setUserAgent($userAgent);
  4693. }
  4694. /**
  4695. * Get the current script version.
  4696. * This is useful for the demo.php file,
  4697. * so people can check on what version they are testing
  4698. * for mobile devices.
  4699. *
  4700. * @return string The version number in semantic version format.
  4701. */
  4702. public static function getScriptVersion()
  4703. {
  4704. return self::VERSION;
  4705. }
  4706. /**
  4707. * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
  4708. *
  4709. * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
  4710. * the headers. The default null is left for backwards compatibility.
  4711. */
  4712. public function setHttpHeaders($httpHeaders = null)
  4713. {
  4714. // use global _SERVER if $httpHeaders aren't defined
  4715. if (!is_array($httpHeaders) || !count($httpHeaders)) {
  4716. $httpHeaders = $_SERVER;
  4717. }
  4718. // clear existing headers
  4719. $this->httpHeaders = array();
  4720. // Only save HTTP headers. In PHP land, that means only _SERVER vars that
  4721. // start with HTTP_.
  4722. foreach ($httpHeaders as $key => $value) {
  4723. if (substr($key, 0, 5) === 'HTTP_') {
  4724. $this->httpHeaders[$key] = $value;
  4725. }
  4726. }
  4727. // In case we're dealing with CloudFront, we need to know.
  4728. $this->setCfHeaders($httpHeaders);
  4729. }
  4730. /**
  4731. * Retrieves the HTTP headers.
  4732. *
  4733. * @return array
  4734. */
  4735. public function getHttpHeaders()
  4736. {
  4737. return $this->httpHeaders;
  4738. }
  4739. /**
  4740. * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
  4741. * Simply null is returned.
  4742. *
  4743. * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
  4744. * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
  4745. * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
  4746. *
  4747. * @return string|null The value of the header.
  4748. */
  4749. public function getHttpHeader($header)
  4750. {
  4751. // are we using PHP-flavored headers?
  4752. if (strpos($header, '_') === false) {
  4753. $header = str_replace('-', '_', $header);
  4754. $header = strtoupper($header);
  4755. }
  4756. // test the alternate, too
  4757. $altHeader = 'HTTP_' . $header;
  4758. //Test both the regular and the HTTP_ prefix
  4759. if (isset($this->httpHeaders[$header])) {
  4760. return $this->httpHeaders[$header];
  4761. } elseif (isset($this->httpHeaders[$altHeader])) {
  4762. return $this->httpHeaders[$altHeader];
  4763. }
  4764. return null;
  4765. }
  4766. public function getMobileHeaders()
  4767. {
  4768. return self::$mobileHeaders;
  4769. }
  4770. /**
  4771. * Get all possible HTTP headers that
  4772. * can contain the User-Agent string.
  4773. *
  4774. * @return array List of HTTP headers.
  4775. */
  4776. public function getUaHttpHeaders()
  4777. {
  4778. return self::$uaHttpHeaders;
  4779. }
  4780. /**
  4781. * Set CloudFront headers
  4782. * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
  4783. *
  4784. * @param array $cfHeaders List of HTTP headers
  4785. *
  4786. * @return boolean If there were CloudFront headers to be set
  4787. */
  4788. public function setCfHeaders($cfHeaders = null) {
  4789. // use global _SERVER if $cfHeaders aren't defined
  4790. if (!is_array($cfHeaders) || !count($cfHeaders)) {
  4791. $cfHeaders = $_SERVER;
  4792. }
  4793. // clear existing headers
  4794. $this->cloudfrontHeaders = array();
  4795. // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
  4796. // start with cloudfront-.
  4797. $response = false;
  4798. foreach ($cfHeaders as $key => $value) {
  4799. if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
  4800. $this->cloudfrontHeaders[strtoupper($key)] = $value;
  4801. $response = true;
  4802. }
  4803. }
  4804. return $response;
  4805. }
  4806. /**
  4807. * Retrieves the cloudfront headers.
  4808. *
  4809. * @return array
  4810. */
  4811. public function getCfHeaders()
  4812. {
  4813. return $this->cloudfrontHeaders;
  4814. }
  4815. /**
  4816. * Set the User-Agent to be used.
  4817. *
  4818. * @param string $userAgent The user agent string to set.
  4819. *
  4820. * @return string|null
  4821. */
  4822. public function setUserAgent($userAgent = null)
  4823. {
  4824. // Invalidate cache due to #375
  4825. $this->cache = array();
  4826. if (false === empty($userAgent)) {
  4827. return $this->userAgent = $userAgent;
  4828. } else {
  4829. $this->userAgent = null;
  4830. foreach ($this->getUaHttpHeaders() as $altHeader) {
  4831. if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
  4832. $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
  4833. }
  4834. }
  4835. if (!empty($this->userAgent)) {
  4836. return $this->userAgent = trim($this->userAgent);
  4837. }
  4838. }
  4839. if (count($this->getCfHeaders()) > 0) {
  4840. return $this->userAgent = 'Amazon CloudFront';
  4841. }
  4842. return $this->userAgent = null;
  4843. }
  4844. /**
  4845. * Retrieve the User-Agent.
  4846. *
  4847. * @return string|null The user agent if it's set.
  4848. */
  4849. public function getUserAgent()
  4850. {
  4851. return $this->userAgent;
  4852. }
  4853. /**
  4854. * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
  4855. * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
  4856. *
  4857. * @deprecated since version 2.6.9
  4858. *
  4859. * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
  4860. * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
  4861. */
  4862. public function setDetectionType($type = null)
  4863. {
  4864. if ($type === null) {
  4865. $type = self::DETECTION_TYPE_MOBILE;
  4866. }
  4867. if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
  4868. return;
  4869. }
  4870. $this->detectionType = $type;
  4871. }
  4872. public function getMatchingRegex()
  4873. {
  4874. return $this->matchingRegex;
  4875. }
  4876. public function getMatchesArray()
  4877. {
  4878. return $this->matchesArray;
  4879. }
  4880. /**
  4881. * Retrieve the list of known phone devices.
  4882. *
  4883. * @return array List of phone devices.
  4884. */
  4885. public static function getPhoneDevices()
  4886. {
  4887. return self::$phoneDevices;
  4888. }
  4889. /**
  4890. * Retrieve the list of known tablet devices.
  4891. *
  4892. * @return array List of tablet devices.
  4893. */
  4894. public static function getTabletDevices()
  4895. {
  4896. return self::$tabletDevices;
  4897. }
  4898. /**
  4899. * Alias for getBrowsers() method.
  4900. *
  4901. * @return array List of user agents.
  4902. */
  4903. public static function getUserAgents()
  4904. {
  4905. return self::getBrowsers();
  4906. }
  4907. /**
  4908. * Retrieve the list of known browsers. Specifically, the user agents.
  4909. *
  4910. * @return array List of browsers / user agents.
  4911. */
  4912. public static function getBrowsers()
  4913. {
  4914. return self::$browsers;
  4915. }
  4916. /**
  4917. * Retrieve the list of known utilities.
  4918. *
  4919. * @return array List of utilities.
  4920. */
  4921. public static function getUtilities()
  4922. {
  4923. return self::$utilities;
  4924. }
  4925. /**
  4926. * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
  4927. *
  4928. * @deprecated since version 2.6.9
  4929. *
  4930. * @return array All the rules (but not extended).
  4931. */
  4932. public static function getMobileDetectionRules()
  4933. {
  4934. static $rules;
  4935. if (!$rules) {
  4936. $rules = array_merge(
  4937. self::$phoneDevices,
  4938. self::$tabletDevices,
  4939. self::$operatingSystems,
  4940. self::$browsers
  4941. );
  4942. }
  4943. return $rules;
  4944. }
  4945. /**
  4946. * Method gets the mobile detection rules + utilities.
  4947. * The reason this is separate is because utilities rules
  4948. * don't necessary imply mobile. This method is used inside
  4949. * the new $detect->is('stuff') method.
  4950. *
  4951. * @deprecated since version 2.6.9
  4952. *
  4953. * @return array All the rules + extended.
  4954. */
  4955. public function getMobileDetectionRulesExtended()
  4956. {
  4957. static $rules;
  4958. if (!$rules) {
  4959. // Merge all rules together.
  4960. $rules = array_merge(
  4961. self::$phoneDevices,
  4962. self::$tabletDevices,
  4963. self::$operatingSystems,
  4964. self::$browsers,
  4965. self::$utilities
  4966. );
  4967. }
  4968. return $rules;
  4969. }
  4970. /**
  4971. * Retrieve the current set of rules.
  4972. *
  4973. * @deprecated since version 2.6.9
  4974. *
  4975. * @return array
  4976. */
  4977. public function getRules()
  4978. {
  4979. if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
  4980. return self::getMobileDetectionRulesExtended();
  4981. } else {
  4982. return self::getMobileDetectionRules();
  4983. }
  4984. }
  4985. /**
  4986. * Retrieve the list of mobile operating systems.
  4987. *
  4988. * @return array The list of mobile operating systems.
  4989. */
  4990. public static function getOperatingSystems()
  4991. {
  4992. return self::$operatingSystems;
  4993. }
  4994. /**
  4995. * Check the HTTP headers for signs of mobile.
  4996. * This is the fastest mobile check possible; it's used
  4997. * inside isMobile() method.
  4998. *
  4999. * @return bool
  5000. */
  5001. public function checkHttpHeadersForMobile()
  5002. {
  5003. foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
  5004. if (isset($this->httpHeaders[$mobileHeader])) {
  5005. if (is_array($matchType['matches'])) {
  5006. foreach ($matchType['matches'] as $_match) {
  5007. if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
  5008. return true;
  5009. }
  5010. }
  5011. return false;
  5012. } else {
  5013. return true;
  5014. }
  5015. }
  5016. }
  5017. return false;
  5018. }
  5019. /**
  5020. * Magic overloading method.
  5021. *
  5022. * @method boolean is[...]()
  5023. * @param string $name
  5024. * @param array $arguments
  5025. * @return mixed
  5026. * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
  5027. */
  5028. public function __call($name, $arguments)
  5029. {
  5030. // make sure the name starts with 'is', otherwise
  5031. if (substr($name, 0, 2) !== 'is') {
  5032. throw new BadMethodCallException("No such method exists: $name");
  5033. }
  5034. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5035. $key = substr($name, 2);
  5036. return $this->matchUAAgainstKey($key);
  5037. }
  5038. /**
  5039. * Find a detection rule that matches the current User-agent.
  5040. *
  5041. * @param null $userAgent deprecated
  5042. * @return boolean
  5043. */
  5044. protected function matchDetectionRulesAgainstUA($userAgent = null)
  5045. {
  5046. // Begin general search.
  5047. foreach ($this->getRules() as $_regex) {
  5048. if (empty($_regex)) {
  5049. continue;
  5050. }
  5051. if ($this->match($_regex, $userAgent)) {
  5052. return true;
  5053. }
  5054. }
  5055. return false;
  5056. }
  5057. /**
  5058. * Search for a certain key in the rules array.
  5059. * If the key is found then try to match the corresponding
  5060. * regex against the User-Agent.
  5061. *
  5062. * @param string $key
  5063. *
  5064. * @return boolean
  5065. */
  5066. protected function matchUAAgainstKey($key)
  5067. {
  5068. // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
  5069. $key = strtolower($key);
  5070. if (false === isset($this->cache[$key])) {
  5071. // change the keys to lower case
  5072. $_rules = array_change_key_case($this->getRules());
  5073. if (false === empty($_rules[$key])) {
  5074. $this->cache[$key] = $this->match($_rules[$key]);
  5075. }
  5076. if (false === isset($this->cache[$key])) {
  5077. $this->cache[$key] = false;
  5078. }
  5079. }
  5080. return $this->cache[$key];
  5081. }
  5082. /**
  5083. * Check if the device is mobile.
  5084. * Returns true if any type of mobile device detected, including special ones
  5085. * @param null $userAgent deprecated
  5086. * @param null $httpHeaders deprecated
  5087. * @return bool
  5088. */
  5089. public function isMobile($userAgent = null, $httpHeaders = null)
  5090. {
  5091. if ($httpHeaders) {
  5092. $this->setHttpHeaders($httpHeaders);
  5093. }
  5094. if ($userAgent) {
  5095. $this->setUserAgent($userAgent);
  5096. }
  5097. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  5098. if ($this->getUserAgent() === 'Amazon CloudFront') {
  5099. $cfHeaders = $this->getCfHeaders();
  5100. if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
  5101. return true;
  5102. }
  5103. }
  5104. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5105. if ($this->checkHttpHeadersForMobile()) {
  5106. return true;
  5107. } else {
  5108. return $this->matchDetectionRulesAgainstUA();
  5109. }
  5110. }
  5111. /**
  5112. * Check if the device is a tablet.
  5113. * Return true if any type of tablet device is detected.
  5114. *
  5115. * @param string $userAgent deprecated
  5116. * @param array $httpHeaders deprecated
  5117. * @return bool
  5118. */
  5119. public function isTablet($userAgent = null, $httpHeaders = null)
  5120. {
  5121. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  5122. if ($this->getUserAgent() === 'Amazon CloudFront') {
  5123. $cfHeaders = $this->getCfHeaders();
  5124. if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
  5125. return true;
  5126. }
  5127. }
  5128. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5129. foreach (self::$tabletDevices as $_regex) {
  5130. if ($this->match($_regex, $userAgent)) {
  5131. return true;
  5132. }
  5133. }
  5134. return false;
  5135. }
  5136. /**
  5137. * This method checks for a certain property in the
  5138. * userAgent.
  5139. * @todo: The httpHeaders part is not yet used.
  5140. *
  5141. * @param string $key
  5142. * @param string $userAgent deprecated
  5143. * @param string $httpHeaders deprecated
  5144. * @return bool|int|null
  5145. */
  5146. public function is($key, $userAgent = null, $httpHeaders = null)
  5147. {
  5148. // Set the UA and HTTP headers only if needed (eg. batch mode).
  5149. if ($httpHeaders) {
  5150. $this->setHttpHeaders($httpHeaders);
  5151. }
  5152. if ($userAgent) {
  5153. $this->setUserAgent($userAgent);
  5154. }
  5155. $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
  5156. return $this->matchUAAgainstKey($key);
  5157. }
  5158. /**
  5159. * Some detection rules are relative (not standard),
  5160. * because of the diversity of devices, vendors and
  5161. * their conventions in representing the User-Agent or
  5162. * the HTTP headers.
  5163. *
  5164. * This method will be used to check custom regexes against
  5165. * the User-Agent string.
  5166. *
  5167. * @param $regex
  5168. * @param string $userAgent
  5169. * @return bool
  5170. *
  5171. * @todo: search in the HTTP headers too.
  5172. */
  5173. public function match($regex, $userAgent = null)
  5174. {
  5175. $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
  5176. // If positive match is found, store the results for debug.
  5177. if ($match) {
  5178. $this->matchingRegex = $regex;
  5179. $this->matchesArray = $matches;
  5180. }
  5181. return $match;
  5182. }
  5183. /**
  5184. * Get the properties array.
  5185. *
  5186. * @return array
  5187. */
  5188. public static function getProperties()
  5189. {
  5190. return self::$properties;
  5191. }
  5192. /**
  5193. * Prepare the version number.
  5194. *
  5195. * @todo Remove the error supression from str_replace() call.
  5196. *
  5197. * @param string $ver The string version, like "2.6.21.2152";
  5198. *
  5199. * @return float
  5200. */
  5201. public function prepareVersionNo($ver)
  5202. {
  5203. $ver = str_replace(array('_', ' ', '/'), '.', $ver);
  5204. $arrVer = explode('.', $ver, 2);
  5205. if (isset($arrVer[1])) {
  5206. $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
  5207. }
  5208. return (float) implode('.', $arrVer);
  5209. }
  5210. /**
  5211. * Check the version of the given property in the User-Agent.
  5212. * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
  5213. *
  5214. * @param string $propertyName The name of the property. See self::getProperties() array
  5215. * keys for all possible properties.
  5216. * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
  5217. * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
  5218. * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
  5219. * invalid parameter will default to the this type as well.
  5220. *
  5221. * @return string|float The version of the property we are trying to extract.
  5222. */
  5223. public function version($propertyName, $type = self::VERSION_TYPE_STRING)
  5224. {
  5225. if (empty($propertyName)) {
  5226. return false;
  5227. }
  5228. // set the $type to the default if we don't recognize the type
  5229. if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
  5230. $type = self::VERSION_TYPE_STRING;
  5231. }
  5232. $properties = self::getProperties();
  5233. // Check if the property exists in the properties array.
  5234. if (true === isset($properties[$propertyName])) {
  5235. // Prepare the pattern to be matched.
  5236. // Make sure we always deal with an array (string is converted).
  5237. $properties[$propertyName] = (array) $properties[$propertyName];
  5238. foreach ($properties[$propertyName] as $propertyMatchString) {
  5239. $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
  5240. // Identify and extract the version.
  5241. preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
  5242. if (false === empty($match[1])) {
  5243. $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
  5244. return $version;
  5245. }
  5246. }
  5247. }
  5248. return false;
  5249. }
  5250. /**
  5251. * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
  5252. *
  5253. * @return string One of the self::MOBILE_GRADE_* constants.
  5254. */
  5255. public function mobileGrade()
  5256. {
  5257. $isMobile = $this->isMobile();
  5258. if (
  5259. // Apple iOS 4-7.0 – Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3 / 5.1 / 6.1), iPad 3 (5.1 / 6.0), iPad Mini (6.1), iPad Retina (7.0), iPhone 3GS (4.3), iPhone 4 (4.3 / 5.1), iPhone 4S (5.1 / 6.0), iPhone 5 (6.0), and iPhone 5S (7.0)
  5260. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  5261. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  5262. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  5263. // Android 2.1-2.3 - Tested on the HTC Incredible (2.2), original Droid (2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6 but performance may be sluggish, tested on Google G1 (1.5)
  5264. // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
  5265. // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
  5266. // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
  5267. ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
  5268. // Windows Phone 7.5-8 - Tested on the HTC Surround (7.5), HTC Trophy (7.5), LG-E900 (7.5), Nokia 800 (7.8), HTC Mazaa (7.8), Nokia Lumia 520 (8), Nokia Lumia 920 (8), HTC 8x (8)
  5269. $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
  5270. // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
  5271. $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
  5272. // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
  5273. $this->match('Playbook.*Tablet') ||
  5274. // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
  5275. ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
  5276. // Palm WebOS 3.0 - Tested on HP TouchPad
  5277. $this->match('hp.*TouchPad') ||
  5278. // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
  5279. ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
  5280. // Chrome for Android - Tested on Android 4.0, 4.1 device
  5281. ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
  5282. // Skyfire 4.1 - Tested on Android 2.3 device
  5283. ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  5284. // Opera Mobile 11.5-12: Tested on Android 2.3
  5285. ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
  5286. // Meego 1.2 - Tested on Nokia 950 and N9
  5287. $this->is('MeeGoOS') ||
  5288. // Tizen (pre-release) - Tested on early hardware
  5289. $this->is('Tizen') ||
  5290. // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
  5291. // @todo: more tests here!
  5292. $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
  5293. // UC Browser - Tested on Android 2.3 device
  5294. ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  5295. // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
  5296. ( $this->match('Kindle Fire') ||
  5297. $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
  5298. // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
  5299. $this->is('AndroidOS') && $this->is('NookTablet') ||
  5300. // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
  5301. $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
  5302. // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
  5303. $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
  5304. // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
  5305. $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
  5306. // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
  5307. $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
  5308. // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
  5309. $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
  5310. ){
  5311. return self::MOBILE_GRADE_A;
  5312. }
  5313. if (
  5314. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
  5315. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
  5316. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
  5317. // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
  5318. $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
  5319. //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
  5320. ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
  5321. ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
  5322. // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
  5323. $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
  5324. // @todo: report this (tested on Nokia N71)
  5325. $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
  5326. ){
  5327. return self::MOBILE_GRADE_B;
  5328. }
  5329. if (
  5330. // Blackberry 4.x - Tested on the Curve 8330
  5331. $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
  5332. // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
  5333. $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
  5334. // Tested on original iPhone (3.1), iPhone 3 (3.2)
  5335. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  5336. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  5337. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  5338. // Internet Explorer 7 and older - Tested on Windows XP
  5339. $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
  5340. ){
  5341. return self::MOBILE_GRADE_C;
  5342. }
  5343. // All older smartphone platforms and featurephones - Any device that doesn't support media queries
  5344. // will receive the basic, C grade experience.
  5345. return self::MOBILE_GRADE_C;
  5346. }
  5347. }
  5348. $mobileDetect = new Mobile_Detect;
  5349. $userDevice = ($mobileDetect->isMobile() ? ($mobileDetect->isTablet() ? 'tablet' : 'phone') : 'computer');
  5350. function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  5351. $path = getServerPath();
  5352. return '
  5353. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5354. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  5355. <head>
  5356. <!--[if gte mso 9]><xml>
  5357. <o:OfficeDocumentSettings>
  5358. <o:AllowPNG/>
  5359. <o:PixelsPerInch>96</o:PixelsPerInch>
  5360. </o:OfficeDocumentSettings>
  5361. </xml><![endif]-->
  5362. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5363. <meta name="viewport" content="width=device-width">
  5364. <!--[if !mso]><!-->
  5365. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5366. <!--<![endif]-->
  5367. <title></title>
  5368. <!--[if !mso]><!-- -->
  5369. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
  5370. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  5371. <!--<![endif]-->
  5372. <style type="text/css" id="media-query">
  5373. body {
  5374. margin: 0;
  5375. padding: 0;
  5376. }
  5377. table,
  5378. tr,
  5379. td {
  5380. vertical-align: top;
  5381. border-collapse: collapse;
  5382. }
  5383. .ie-browser table,
  5384. .mso-container table {
  5385. table-layout: fixed;
  5386. }
  5387. * {
  5388. line-height: inherit;
  5389. }
  5390. a[x-apple-data-detectors=true] {
  5391. color: inherit !important;
  5392. text-decoration: none !important;
  5393. }
  5394. [owa] .img-container div,
  5395. [owa] .img-container button {
  5396. display: block !important;
  5397. }
  5398. [owa] .fullwidth button {
  5399. width: 100% !important;
  5400. }
  5401. [owa] .block-grid .col {
  5402. display: table-cell;
  5403. float: none !important;
  5404. vertical-align: top;
  5405. }
  5406. .ie-browser .num12,
  5407. .ie-browser .block-grid,
  5408. [owa] .num12,
  5409. [owa] .block-grid {
  5410. width: 615px !important;
  5411. }
  5412. .ExternalClass,
  5413. .ExternalClass p,
  5414. .ExternalClass span,
  5415. .ExternalClass font,
  5416. .ExternalClass td,
  5417. .ExternalClass div {
  5418. line-height: 100%;
  5419. }
  5420. .ie-browser .mixed-two-up .num4,
  5421. [owa] .mixed-two-up .num4 {
  5422. width: 204px !important;
  5423. }
  5424. .ie-browser .mixed-two-up .num8,
  5425. [owa] .mixed-two-up .num8 {
  5426. width: 408px !important;
  5427. }
  5428. .ie-browser .block-grid.two-up .col,
  5429. [owa] .block-grid.two-up .col {
  5430. width: 307px !important;
  5431. }
  5432. .ie-browser .block-grid.three-up .col,
  5433. [owa] .block-grid.three-up .col {
  5434. width: 205px !important;
  5435. }
  5436. .ie-browser .block-grid.four-up .col,
  5437. [owa] .block-grid.four-up .col {
  5438. width: 153px !important;
  5439. }
  5440. .ie-browser .block-grid.five-up .col,
  5441. [owa] .block-grid.five-up .col {
  5442. width: 123px !important;
  5443. }
  5444. .ie-browser .block-grid.six-up .col,
  5445. [owa] .block-grid.six-up .col {
  5446. width: 102px !important;
  5447. }
  5448. .ie-browser .block-grid.seven-up .col,
  5449. [owa] .block-grid.seven-up .col {
  5450. width: 87px !important;
  5451. }
  5452. .ie-browser .block-grid.eight-up .col,
  5453. [owa] .block-grid.eight-up .col {
  5454. width: 76px !important;
  5455. }
  5456. .ie-browser .block-grid.nine-up .col,
  5457. [owa] .block-grid.nine-up .col {
  5458. width: 68px !important;
  5459. }
  5460. .ie-browser .block-grid.ten-up .col,
  5461. [owa] .block-grid.ten-up .col {
  5462. width: 61px !important;
  5463. }
  5464. .ie-browser .block-grid.eleven-up .col,
  5465. [owa] .block-grid.eleven-up .col {
  5466. width: 55px !important;
  5467. }
  5468. .ie-browser .block-grid.twelve-up .col,
  5469. [owa] .block-grid.twelve-up .col {
  5470. width: 51px !important;
  5471. }
  5472. @media only screen and (min-width: 635px) {
  5473. .block-grid {
  5474. width: 615px !important;
  5475. }
  5476. .block-grid .col {
  5477. display: table-cell;
  5478. Float: none !important;
  5479. vertical-align: top;
  5480. }
  5481. .block-grid .col.num12 {
  5482. width: 615px !important;
  5483. }
  5484. .block-grid.mixed-two-up .col.num4 {
  5485. width: 204px !important;
  5486. }
  5487. .block-grid.mixed-two-up .col.num8 {
  5488. width: 408px !important;
  5489. }
  5490. .block-grid.two-up .col {
  5491. width: 307px !important;
  5492. }
  5493. .block-grid.three-up .col {
  5494. width: 205px !important;
  5495. }
  5496. .block-grid.four-up .col {
  5497. width: 153px !important;
  5498. }
  5499. .block-grid.five-up .col {
  5500. width: 123px !important;
  5501. }
  5502. .block-grid.six-up .col {
  5503. width: 102px !important;
  5504. }
  5505. .block-grid.seven-up .col {
  5506. width: 87px !important;
  5507. }
  5508. .block-grid.eight-up .col {
  5509. width: 76px !important;
  5510. }
  5511. .block-grid.nine-up .col {
  5512. width: 68px !important;
  5513. }
  5514. .block-grid.ten-up .col {
  5515. width: 61px !important;
  5516. }
  5517. .block-grid.eleven-up .col {
  5518. width: 55px !important;
  5519. }
  5520. .block-grid.twelve-up .col {
  5521. width: 51px !important;
  5522. }
  5523. }
  5524. @media (max-width: 635px) {
  5525. .block-grid,
  5526. .col {
  5527. min-width: 320px !important;
  5528. max-width: 100% !important;
  5529. }
  5530. .block-grid {
  5531. width: calc(100% - 40px) !important;
  5532. }
  5533. .col {
  5534. width: 100% !important;
  5535. }
  5536. .col>div {
  5537. margin: 0 auto;
  5538. }
  5539. img.fullwidth {
  5540. max-width: 100% !important;
  5541. }
  5542. }
  5543. </style>
  5544. </head>
  5545. <body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #FFFFFF">
  5546. <!--[if IE]><div class="ie-browser"><![endif]-->
  5547. <!--[if mso]><div class="mso-container"><![endif]-->
  5548. <div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: #FFFFFF">
  5549. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #FFFFFF;"><![endif]-->
  5550. <div style="background-color:#333333;">
  5551. <div style="Margin: 0 auto;min-width: 320px;max-width: 615px;width: 615px;width: calc(30500% - 193060px);overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;"
  5552. class="block-grid ">
  5553. <div style="border-collapse: collapse;display: table;width: 100%;">
  5554. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="background-color:#333333;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width: 615px;"><tr class="layout-full-width" style="background-color:transparent;"><![endif]-->
  5555. <!--[if (mso)|(IE)]><td align="center" width="615" style=" width:615px; padding-right: 0px; padding-left: 0px; padding-top:0px; padding-bottom:0px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;" valign="top"><![endif]-->
  5556. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  5557. <div style="background-color: transparent; width: 100% !important;">
  5558. <!--[if (!mso)&(!IE)]><!-->
  5559. <div style="border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent; padding-top:0px; padding-bottom:0px; padding-right: 0px; padding-left: 0px;">
  5560. <!--<![endif]-->
  5561. <div align="left" class="img-container left fullwidth" style="padding-right: 30px; padding-left: 30px;">
  5562. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px;" align="left"><![endif]-->
  5563. <img class="left fullwidth" align="left" border="0" src="'.$path.'images/organizr-logo-h.png" alt="Image" title="Image"
  5564. style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !important;border: 0;height: auto;float: none;width: 100%;max-width: 555px"
  5565. width="555">
  5566. <!--[if mso]></td></tr></table><![endif]-->
  5567. </div>
  5568. <!--[if (!mso)&(!IE)]><!-->
  5569. </div>
  5570. <!--<![endif]-->
  5571. </div>
  5572. </div>
  5573. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  5574. </div>
  5575. </div>
  5576. </div>
  5577. <div style="background-color:#333333;">
  5578. <div style="Margin: 0 auto;min-width: 320px;max-width: 615px;width: 615px;width: calc(30500% - 193060px);overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;"
  5579. class="block-grid ">
  5580. <div style="border-collapse: collapse;display: table;width: 100%;">
  5581. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="background-color:#333333;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width: 615px;"><tr class="layout-full-width" style="background-color:transparent;"><![endif]-->
  5582. <!--[if (mso)|(IE)]><td align="center" width="615" style=" width:615px; padding-right: 0px; padding-left: 0px; padding-top:0px; padding-bottom:0px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;" valign="top"><![endif]-->
  5583. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  5584. <div style="background-color: transparent; width: 100% !important;">
  5585. <!--[if (!mso)&(!IE)]><!-->
  5586. <div style="border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent; padding-top:0px; padding-bottom:0px; padding-right: 0px; padding-left: 0px;">
  5587. <!--<![endif]-->
  5588. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 0px; padding-left: 0px; padding-top: 0px; padding-bottom: 0px;"><![endif]-->
  5589. <div style="font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;line-height:120%;color:#FFFFFF; padding-right: 0px; padding-left: 0px; padding-top: 0px; padding-bottom: 0px;">
  5590. <div style="font-size:12px;line-height:14px;color:#FFFFFF;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  5591. <p style="margin: 0;font-size: 12px;line-height: 14px;text-align: center"><span style="font-size: 16px; line-height: 19px;"><strong><span style="line-height: 19px; font-size: 16px;">'.$header.'</span></strong>
  5592. </span>
  5593. </p>
  5594. </div>
  5595. </div>
  5596. <!--[if mso]></td></tr></table><![endif]-->
  5597. <!--[if (!mso)&(!IE)]><!-->
  5598. </div>
  5599. <!--<![endif]-->
  5600. </div>
  5601. </div>
  5602. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  5603. </div>
  5604. </div>
  5605. </div>
  5606. <div style="background-color:#393939;">
  5607. <div style="Margin: 0 auto;min-width: 320px;max-width: 615px;width: 615px;width: calc(30500% - 193060px);overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;"
  5608. class="block-grid ">
  5609. <div style="border-collapse: collapse;display: table;width: 100%;">
  5610. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="background-color:#393939;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width: 615px;"><tr class="layout-full-width" style="background-color:transparent;"><![endif]-->
  5611. <!--[if (mso)|(IE)]><td align="center" width="615" style=" width:615px; padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;" valign="top"><![endif]-->
  5612. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  5613. <div style="background-color: transparent; width: 100% !important;">
  5614. <!--[if (!mso)&(!IE)]><!-->
  5615. <div style="border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;">
  5616. <!--<![endif]-->
  5617. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px; padding-top: 0px; padding-bottom: 0px;"><![endif]-->
  5618. <div style="font-family:\'Ubuntu\', Tahoma, Verdana, Segoe, sans-serif;line-height:120%;color:#FFFFFF; padding-right: 30px; padding-left: 30px; padding-top: 0px; padding-bottom: 0px;">
  5619. <div style="font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  5620. <p style="margin: 0;font-size: 12px;line-height: 14px;text-align: center"><span style="font-size: 16px; line-height: 19px;"><strong>'.$title.'</strong></span></p>
  5621. </div>
  5622. </div>
  5623. <!--[if mso]></td></tr></table><![endif]-->
  5624. <div style="padding-right: 5px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px;">
  5625. <!--[if (mso)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 5px;padding-left: 5px; padding-top: 5px; padding-bottom: 5px;"><table width="55%" align="center" cellpadding="0" cellspacing="0" border="0"><tr><td><![endif]-->
  5626. <div align="center">
  5627. <div style="border-top: 2px solid #66D9EF; width:55%; line-height:2px; height:2px; font-size:2px;">&#160;</div>
  5628. </div>
  5629. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  5630. </div>
  5631. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px; padding-top: 15px; padding-bottom: 10px;"><![endif]-->
  5632. <div style="font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;line-height:120%;color:#FFFFFF; padding-right: 30px; padding-left: 30px; padding-top: 15px; padding-bottom: 10px;">
  5633. <div style="font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  5634. <p style="margin: 0;font-size: 12px;line-height: 14px"><span style="font-size: 28px; line-height: 33px;">Hey '.$user.',</span></p>
  5635. </div>
  5636. </div>
  5637. <!--[if mso]></td></tr></table><![endif]-->
  5638. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 15px; padding-left: 30px; padding-top: 10px; padding-bottom: 25px;"><![endif]-->
  5639. <div style="font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;line-height:180%;color:#FFFFFF; padding-right: 15px; padding-left: 30px; padding-top: 10px; padding-bottom: 25px;">
  5640. <div style="font-size:12px;line-height:22px;font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;color:#FFFFFF;text-align:left;">
  5641. <p style="margin: 0;font-size: 14px;line-height: 25px"><span style="font-size: 18px; line-height: 32px;"><em><span style="line-height: 32px; font-size: 18px;">'.$mainMessage.'</span></em>
  5642. </span>
  5643. </p>
  5644. </div>
  5645. </div>
  5646. <!--[if mso]></td></tr></table><![endif]-->
  5647. <div align="center" class="button-container center" style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;">
  5648. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0" style="border-spacing: 0; border-collapse: collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;"><tr><td style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;" align="center"><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="'.$path.'" style="height:48px; v-text-anchor:middle; width:194px;" arcsize="53%" strokecolor="" fillcolor="#66D9EF"><w:anchorlock/><center style="color:#000; font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif; font-size:18px;"><![endif]-->
  5649. <a href="'.$buttonURL.'" target="_blank" style="display: inline-block;text-decoration: none;-webkit-text-size-adjust: none;text-align: center;color: #000; background-color: #66D9EF; border-radius: 25px; -webkit-border-radius: 25px; -moz-border-radius: 25px; max-width: 180px; width: 114px; width: auto; border-top: 3px solid transparent; border-right: 3px solid transparent; border-bottom: 3px solid transparent; border-left: 3px solid transparent; padding-top: 5px; padding-right: 30px; padding-bottom: 5px; padding-left: 30px; font-family: \'Lato\', Tahoma, Verdana, Segoe, sans-serif;mso-border-alt: none">
  5650. <span style="font-size:12px;line-height:21px;"><span style="font-size: 18px; line-height: 32px;" data-mce-style="font-size: 18px; line-height: 44px;">'.$button.'</span></span></a>
  5651. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  5652. </div>
  5653. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  5654. </div>
  5655. <!--[if (!mso)&(!IE)]><!-->
  5656. </div>
  5657. <!--<![endif]-->
  5658. </div>
  5659. </div>
  5660. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  5661. </div>
  5662. </div>
  5663. </div>
  5664. <div style="background-color:#ffffff;">
  5665. <div style="Margin: 0 auto;min-width: 320px;max-width: 615px;width: 615px;width: calc(30500% - 193060px);overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;"
  5666. class="block-grid ">
  5667. <div style="border-collapse: collapse;display: table;width: 100%;">
  5668. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="background-color:#ffffff;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width: 615px;"><tr class="layout-full-width" style="background-color:transparent;"><![endif]-->
  5669. <!--[if (mso)|(IE)]><td align="center" width="615" style=" width:615px; padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:30px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;" valign="top"><![endif]-->
  5670. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  5671. <div style="background-color: transparent; width: 100% !important;">
  5672. <!--[if (!mso)&(!IE)]><!-->
  5673. <div style="border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent; padding-top:5px; padding-bottom:30px; padding-right: 0px; padding-left: 0px;">
  5674. <!--<![endif]-->
  5675. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 10px; padding-left: 10px; padding-top: 0px; padding-bottom: 10px;"><![endif]-->
  5676. <div style="font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;line-height:120%;color:#555555; padding-right: 10px; padding-left: 10px; padding-top: 0px; padding-bottom: 10px;">
  5677. <div style="font-size:12px;line-height:14px;color:#555555;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  5678. <p style="margin: 0;font-size: 14px;line-height: 17px;text-align: center"><strong><span style="font-size: 26px; line-height: 31px;">'.$subTitle.'<br></span></strong></p>
  5679. </div>
  5680. </div>
  5681. <!--[if mso]></td></tr></table><![endif]-->
  5682. <div style="padding-right: 20px; padding-left: 20px; padding-top: 15px; padding-bottom: 20px;">
  5683. <!--[if (mso)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 20px;padding-left: 20px; padding-top: 15px; padding-bottom: 20px;"><table width="40%" align="center" cellpadding="0" cellspacing="0" border="0"><tr><td><![endif]-->
  5684. <div align="center">
  5685. <div style="border-top: 3px solid #66D9EF; width:40%; line-height:3px; height:3px; font-size:3px;">&#160;</div>
  5686. </div>
  5687. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  5688. </div>
  5689. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 10px; padding-left: 10px; padding-top: 0px; padding-bottom: 0px;"><![endif]-->
  5690. <div style="font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;line-height:180%;color:#7E7D7D; padding-right: 10px; padding-left: 10px; padding-top: 0px; padding-bottom: 0px;">
  5691. <div style="font-size:12px;line-height:22px;color:#7E7D7D;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  5692. <p style="margin: 0;font-size: 14px;line-height: 25px;text-align: center"><em><span style="font-size: 18px; line-height: 32px;">'.$subMessage.'</span></em></p>
  5693. </div>
  5694. </div>
  5695. <!--[if mso]></td></tr></table><![endif]-->
  5696. <!--[if (!mso)&(!IE)]><!-->
  5697. </div>
  5698. <!--<![endif]-->
  5699. </div>
  5700. </div>
  5701. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  5702. </div>
  5703. </div>
  5704. </div>
  5705. <div style="background-color:#333333;">
  5706. <div style="Margin: 0 auto;min-width: 320px;max-width: 615px;width: 615px;width: calc(30500% - 193060px);overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;"
  5707. class="block-grid ">
  5708. <div style="border-collapse: collapse;display: table;width: 100%;">
  5709. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="background-color:#333333;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width: 615px;"><tr class="layout-full-width" style="background-color:transparent;"><![endif]-->
  5710. <!--[if (mso)|(IE)]><td align="center" width="615" style=" width:615px; padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;" valign="top"><![endif]-->
  5711. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  5712. <div style="background-color: transparent; width: 100% !important;">
  5713. <!--[if (!mso)&(!IE)]><!-->
  5714. <div style="border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;">
  5715. <!--<![endif]-->
  5716. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 10px;"><![endif]-->
  5717. <div style="font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;line-height:120%;color:#959595; padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 10px;">
  5718. <div style="font-size:12px;line-height:14px;color:#959595;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  5719. <p style="margin: 0;font-size: 14px;line-height: 17px;text-align: center">This&#160;email was sent by <a style="color:#AD80FD;text-decoration: underline;" title="Organizr"
  5720. href="https://github.com/causefx/Organizr" target="_blank" rel="noopener noreferrer">Organizr</a><strong><br></strong></p>
  5721. </div>
  5722. </div>
  5723. <!--[if mso]></td></tr></table><![endif]-->
  5724. <!--[if (!mso)&(!IE)]><!-->
  5725. </div>
  5726. <!--<![endif]-->
  5727. </div>
  5728. </div>
  5729. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  5730. </div>
  5731. </div>
  5732. </div>
  5733. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  5734. </div>
  5735. <!--[if (mso)|(IE)]></div><![endif]-->
  5736. </body>
  5737. </html>
  5738. ';
  5739. }
  5740. function mimeTypes(){
  5741. return array(
  5742. '123' => 'application/vnd.lotus-1-2-3',
  5743. '3dml' => 'text/vnd.in3d.3dml',
  5744. '3ds' => 'image/x-3ds',
  5745. '3g2' => 'video/3gpp2',
  5746. '3gp' => 'video/3gpp',
  5747. '7z' => 'application/x-7z-compressed',
  5748. 'aab' => 'application/x-authorware-bin',
  5749. 'aac' => 'audio/x-aac',
  5750. 'aam' => 'application/x-authorware-map',
  5751. 'aas' => 'application/x-authorware-seg',
  5752. 'abw' => 'application/x-abiword',
  5753. 'ac' => 'application/pkix-attr-cert',
  5754. 'acc' => 'application/vnd.americandynamics.acc',
  5755. 'ace' => 'application/x-ace-compressed',
  5756. 'acu' => 'application/vnd.acucobol',
  5757. 'acutc' => 'application/vnd.acucorp',
  5758. 'adp' => 'audio/adpcm',
  5759. 'aep' => 'application/vnd.audiograph',
  5760. 'afm' => 'application/x-font-type1',
  5761. 'afp' => 'application/vnd.ibm.modcap',
  5762. 'ahead' => 'application/vnd.ahead.space',
  5763. 'ai' => 'application/postscript',
  5764. 'aif' => 'audio/x-aiff',
  5765. 'aifc' => 'audio/x-aiff',
  5766. 'aiff' => 'audio/x-aiff',
  5767. 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
  5768. 'ait' => 'application/vnd.dvb.ait',
  5769. 'ami' => 'application/vnd.amiga.ami',
  5770. 'apk' => 'application/vnd.android.package-archive',
  5771. 'appcache' => 'text/cache-manifest',
  5772. 'application' => 'application/x-ms-application',
  5773. 'apr' => 'application/vnd.lotus-approach',
  5774. 'arc' => 'application/x-freearc',
  5775. 'asc' => 'application/pgp-signature',
  5776. 'asf' => 'video/x-ms-asf',
  5777. 'asm' => 'text/x-asm',
  5778. 'aso' => 'application/vnd.accpac.simply.aso',
  5779. 'asx' => 'video/x-ms-asf',
  5780. 'atc' => 'application/vnd.acucorp',
  5781. 'atom' => 'application/atom+xml',
  5782. 'atomcat' => 'application/atomcat+xml',
  5783. 'atomsvc' => 'application/atomsvc+xml',
  5784. 'atx' => 'application/vnd.antix.game-component',
  5785. 'au' => 'audio/basic',
  5786. 'avi' => 'video/x-msvideo',
  5787. 'aw' => 'application/applixware',
  5788. 'azf' => 'application/vnd.airzip.filesecure.azf',
  5789. 'azs' => 'application/vnd.airzip.filesecure.azs',
  5790. 'azw' => 'application/vnd.amazon.ebook',
  5791. 'bat' => 'application/x-msdownload',
  5792. 'bcpio' => 'application/x-bcpio',
  5793. 'bdf' => 'application/x-font-bdf',
  5794. 'bdm' => 'application/vnd.syncml.dm+wbxml',
  5795. 'bed' => 'application/vnd.realvnc.bed',
  5796. 'bh2' => 'application/vnd.fujitsu.oasysprs',
  5797. 'bin' => 'application/octet-stream',
  5798. 'blb' => 'application/x-blorb',
  5799. 'blorb' => 'application/x-blorb',
  5800. 'bmi' => 'application/vnd.bmi',
  5801. 'bmp' => 'image/bmp',
  5802. 'book' => 'application/vnd.framemaker',
  5803. 'box' => 'application/vnd.previewsystems.box',
  5804. 'boz' => 'application/x-bzip2',
  5805. 'bpk' => 'application/octet-stream',
  5806. 'btif' => 'image/prs.btif',
  5807. 'bz' => 'application/x-bzip',
  5808. 'bz2' => 'application/x-bzip2',
  5809. 'c' => 'text/x-c',
  5810. 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
  5811. 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
  5812. 'c4d' => 'application/vnd.clonk.c4group',
  5813. 'c4f' => 'application/vnd.clonk.c4group',
  5814. 'c4g' => 'application/vnd.clonk.c4group',
  5815. 'c4p' => 'application/vnd.clonk.c4group',
  5816. 'c4u' => 'application/vnd.clonk.c4group',
  5817. 'cab' => 'application/vnd.ms-cab-compressed',
  5818. 'caf' => 'audio/x-caf',
  5819. 'cap' => 'application/vnd.tcpdump.pcap',
  5820. 'car' => 'application/vnd.curl.car',
  5821. 'cat' => 'application/vnd.ms-pki.seccat',
  5822. 'cb7' => 'application/x-cbr',
  5823. 'cba' => 'application/x-cbr',
  5824. 'cbr' => 'application/x-cbr',
  5825. 'cbt' => 'application/x-cbr',
  5826. 'cbz' => 'application/x-cbr',
  5827. 'cc' => 'text/x-c',
  5828. 'cct' => 'application/x-director',
  5829. 'ccxml' => 'application/ccxml+xml',
  5830. 'cdbcmsg' => 'application/vnd.contact.cmsg',
  5831. 'cdf' => 'application/x-netcdf',
  5832. 'cdkey' => 'application/vnd.mediastation.cdkey',
  5833. 'cdmia' => 'application/cdmi-capability',
  5834. 'cdmic' => 'application/cdmi-container',
  5835. 'cdmid' => 'application/cdmi-domain',
  5836. 'cdmio' => 'application/cdmi-object',
  5837. 'cdmiq' => 'application/cdmi-queue',
  5838. 'cdx' => 'chemical/x-cdx',
  5839. 'cdxml' => 'application/vnd.chemdraw+xml',
  5840. 'cdy' => 'application/vnd.cinderella',
  5841. 'cer' => 'application/pkix-cert',
  5842. 'cfs' => 'application/x-cfs-compressed',
  5843. 'cgm' => 'image/cgm',
  5844. 'chat' => 'application/x-chat',
  5845. 'chm' => 'application/vnd.ms-htmlhelp',
  5846. 'chrt' => 'application/vnd.kde.kchart',
  5847. 'cif' => 'chemical/x-cif',
  5848. 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
  5849. 'cil' => 'application/vnd.ms-artgalry',
  5850. 'cla' => 'application/vnd.claymore',
  5851. 'class' => 'application/java-vm',
  5852. 'clkk' => 'application/vnd.crick.clicker.keyboard',
  5853. 'clkp' => 'application/vnd.crick.clicker.palette',
  5854. 'clkt' => 'application/vnd.crick.clicker.template',
  5855. 'clkw' => 'application/vnd.crick.clicker.wordbank',
  5856. 'clkx' => 'application/vnd.crick.clicker',
  5857. 'clp' => 'application/x-msclip',
  5858. 'cmc' => 'application/vnd.cosmocaller',
  5859. 'cmdf' => 'chemical/x-cmdf',
  5860. 'cml' => 'chemical/x-cml',
  5861. 'cmp' => 'application/vnd.yellowriver-custom-menu',
  5862. 'cmx' => 'image/x-cmx',
  5863. 'cod' => 'application/vnd.rim.cod',
  5864. 'com' => 'application/x-msdownload',
  5865. 'conf' => 'text/plain',
  5866. 'cpio' => 'application/x-cpio',
  5867. 'cpp' => 'text/x-c',
  5868. 'cpt' => 'application/mac-compactpro',
  5869. 'crd' => 'application/x-mscardfile',
  5870. 'crl' => 'application/pkix-crl',
  5871. 'crt' => 'application/x-x509-ca-cert',
  5872. 'cryptonote' => 'application/vnd.rig.cryptonote',
  5873. 'csh' => 'application/x-csh',
  5874. 'csml' => 'chemical/x-csml',
  5875. 'csp' => 'application/vnd.commonspace',
  5876. 'css' => 'text/css',
  5877. 'cst' => 'application/x-director',
  5878. 'csv' => 'text/csv',
  5879. 'cu' => 'application/cu-seeme',
  5880. 'curl' => 'text/vnd.curl',
  5881. 'cww' => 'application/prs.cww',
  5882. 'cxt' => 'application/x-director',
  5883. 'cxx' => 'text/x-c',
  5884. 'dae' => 'model/vnd.collada+xml',
  5885. 'daf' => 'application/vnd.mobius.daf',
  5886. 'dart' => 'application/vnd.dart',
  5887. 'dataless' => 'application/vnd.fdsn.seed',
  5888. 'davmount' => 'application/davmount+xml',
  5889. 'dbk' => 'application/docbook+xml',
  5890. 'dcr' => 'application/x-director',
  5891. 'dcurl' => 'text/vnd.curl.dcurl',
  5892. 'dd2' => 'application/vnd.oma.dd2+xml',
  5893. 'ddd' => 'application/vnd.fujixerox.ddd',
  5894. 'deb' => 'application/x-debian-package',
  5895. 'def' => 'text/plain',
  5896. 'deploy' => 'application/octet-stream',
  5897. 'der' => 'application/x-x509-ca-cert',
  5898. 'dfac' => 'application/vnd.dreamfactory',
  5899. 'dgc' => 'application/x-dgc-compressed',
  5900. 'dic' => 'text/x-c',
  5901. 'dir' => 'application/x-director',
  5902. 'dis' => 'application/vnd.mobius.dis',
  5903. 'dist' => 'application/octet-stream',
  5904. 'distz' => 'application/octet-stream',
  5905. 'djv' => 'image/vnd.djvu',
  5906. 'djvu' => 'image/vnd.djvu',
  5907. 'dll' => 'application/x-msdownload',
  5908. 'dmg' => 'application/x-apple-diskimage',
  5909. 'dmp' => 'application/vnd.tcpdump.pcap',
  5910. 'dms' => 'application/octet-stream',
  5911. 'dna' => 'application/vnd.dna',
  5912. 'doc' => 'application/msword',
  5913. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  5914. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  5915. 'dot' => 'application/msword',
  5916. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  5917. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  5918. 'dp' => 'application/vnd.osgi.dp',
  5919. 'dpg' => 'application/vnd.dpgraph',
  5920. 'dra' => 'audio/vnd.dra',
  5921. 'dsc' => 'text/prs.lines.tag',
  5922. 'dssc' => 'application/dssc+der',
  5923. 'dtb' => 'application/x-dtbook+xml',
  5924. 'dtd' => 'application/xml-dtd',
  5925. 'dts' => 'audio/vnd.dts',
  5926. 'dtshd' => 'audio/vnd.dts.hd',
  5927. 'dump' => 'application/octet-stream',
  5928. 'dvb' => 'video/vnd.dvb.file',
  5929. 'dvi' => 'application/x-dvi',
  5930. 'dwf' => 'model/vnd.dwf',
  5931. 'dwg' => 'image/vnd.dwg',
  5932. 'dxf' => 'image/vnd.dxf',
  5933. 'dxp' => 'application/vnd.spotfire.dxp',
  5934. 'dxr' => 'application/x-director',
  5935. 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
  5936. 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
  5937. 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
  5938. 'ecma' => 'application/ecmascript',
  5939. 'edm' => 'application/vnd.novadigm.edm',
  5940. 'edx' => 'application/vnd.novadigm.edx',
  5941. 'efif' => 'application/vnd.picsel',
  5942. 'ei6' => 'application/vnd.pg.osasli',
  5943. 'elc' => 'application/octet-stream',
  5944. 'emf' => 'application/x-msmetafile',
  5945. 'eml' => 'message/rfc822',
  5946. 'emma' => 'application/emma+xml',
  5947. 'emz' => 'application/x-msmetafile',
  5948. 'eol' => 'audio/vnd.digital-winds',
  5949. 'eot' => 'application/vnd.ms-fontobject',
  5950. 'eps' => 'application/postscript',
  5951. 'epub' => 'application/epub+zip',
  5952. 'es3' => 'application/vnd.eszigno3+xml',
  5953. 'esa' => 'application/vnd.osgi.subsystem',
  5954. 'esf' => 'application/vnd.epson.esf',
  5955. 'et3' => 'application/vnd.eszigno3+xml',
  5956. 'etx' => 'text/x-setext',
  5957. 'eva' => 'application/x-eva',
  5958. 'evy' => 'application/x-envoy',
  5959. 'exe' => 'application/x-msdownload',
  5960. 'exi' => 'application/exi',
  5961. 'ext' => 'application/vnd.novadigm.ext',
  5962. 'ez' => 'application/andrew-inset',
  5963. 'ez2' => 'application/vnd.ezpix-album',
  5964. 'ez3' => 'application/vnd.ezpix-package',
  5965. 'f' => 'text/x-fortran',
  5966. 'f4v' => 'video/x-f4v',
  5967. 'f77' => 'text/x-fortran',
  5968. 'f90' => 'text/x-fortran',
  5969. 'fbs' => 'image/vnd.fastbidsheet',
  5970. 'fcdt' => 'application/vnd.adobe.formscentral.fcdt',
  5971. 'fcs' => 'application/vnd.isac.fcs',
  5972. 'fdf' => 'application/vnd.fdf',
  5973. 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
  5974. 'fg5' => 'application/vnd.fujitsu.oasysgp',
  5975. 'fgd' => 'application/x-director',
  5976. 'fh' => 'image/x-freehand',
  5977. 'fh4' => 'image/x-freehand',
  5978. 'fh5' => 'image/x-freehand',
  5979. 'fh7' => 'image/x-freehand',
  5980. 'fhc' => 'image/x-freehand',
  5981. 'fig' => 'application/x-xfig',
  5982. 'flac' => 'audio/x-flac',
  5983. 'fli' => 'video/x-fli',
  5984. 'flo' => 'application/vnd.micrografx.flo',
  5985. 'flv' => 'video/x-flv',
  5986. 'flw' => 'application/vnd.kde.kivio',
  5987. 'flx' => 'text/vnd.fmi.flexstor',
  5988. 'fly' => 'text/vnd.fly',
  5989. 'fm' => 'application/vnd.framemaker',
  5990. 'fnc' => 'application/vnd.frogans.fnc',
  5991. 'for' => 'text/x-fortran',
  5992. 'fpx' => 'image/vnd.fpx',
  5993. 'frame' => 'application/vnd.framemaker',
  5994. 'fsc' => 'application/vnd.fsc.weblaunch',
  5995. 'fst' => 'image/vnd.fst',
  5996. 'ftc' => 'application/vnd.fluxtime.clip',
  5997. 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
  5998. 'fvt' => 'video/vnd.fvt',
  5999. 'fxp' => 'application/vnd.adobe.fxp',
  6000. 'fxpl' => 'application/vnd.adobe.fxp',
  6001. 'fzs' => 'application/vnd.fuzzysheet',
  6002. 'g2w' => 'application/vnd.geoplan',
  6003. 'g3' => 'image/g3fax',
  6004. 'g3w' => 'application/vnd.geospace',
  6005. 'gac' => 'application/vnd.groove-account',
  6006. 'gam' => 'application/x-tads',
  6007. 'gbr' => 'application/rpki-ghostbusters',
  6008. 'gca' => 'application/x-gca-compressed',
  6009. 'gdl' => 'model/vnd.gdl',
  6010. 'geo' => 'application/vnd.dynageo',
  6011. 'gex' => 'application/vnd.geometry-explorer',
  6012. 'ggb' => 'application/vnd.geogebra.file',
  6013. 'ggt' => 'application/vnd.geogebra.tool',
  6014. 'ghf' => 'application/vnd.groove-help',
  6015. 'gif' => 'image/gif',
  6016. 'gim' => 'application/vnd.groove-identity-message',
  6017. 'gml' => 'application/gml+xml',
  6018. 'gmx' => 'application/vnd.gmx',
  6019. 'gnumeric' => 'application/x-gnumeric',
  6020. 'gph' => 'application/vnd.flographit',
  6021. 'gpx' => 'application/gpx+xml',
  6022. 'gqf' => 'application/vnd.grafeq',
  6023. 'gqs' => 'application/vnd.grafeq',
  6024. 'gram' => 'application/srgs',
  6025. 'gramps' => 'application/x-gramps-xml',
  6026. 'gre' => 'application/vnd.geometry-explorer',
  6027. 'grv' => 'application/vnd.groove-injector',
  6028. 'grxml' => 'application/srgs+xml',
  6029. 'gsf' => 'application/x-font-ghostscript',
  6030. 'gtar' => 'application/x-gtar',
  6031. 'gtm' => 'application/vnd.groove-tool-message',
  6032. 'gtw' => 'model/vnd.gtw',
  6033. 'gv' => 'text/vnd.graphviz',
  6034. 'gxf' => 'application/gxf',
  6035. 'gxt' => 'application/vnd.geonext',
  6036. 'h' => 'text/x-c',
  6037. 'h261' => 'video/h261',
  6038. 'h263' => 'video/h263',
  6039. 'h264' => 'video/h264',
  6040. 'hal' => 'application/vnd.hal+xml',
  6041. 'hbci' => 'application/vnd.hbci',
  6042. 'hdf' => 'application/x-hdf',
  6043. 'hh' => 'text/x-c',
  6044. 'hlp' => 'application/winhlp',
  6045. 'hpgl' => 'application/vnd.hp-hpgl',
  6046. 'hpid' => 'application/vnd.hp-hpid',
  6047. 'hps' => 'application/vnd.hp-hps',
  6048. 'hqx' => 'application/mac-binhex40',
  6049. 'htke' => 'application/vnd.kenameaapp',
  6050. 'htm' => 'text/html',
  6051. 'html' => 'text/html',
  6052. 'hvd' => 'application/vnd.yamaha.hv-dic',
  6053. 'hvp' => 'application/vnd.yamaha.hv-voice',
  6054. 'hvs' => 'application/vnd.yamaha.hv-script',
  6055. 'i2g' => 'application/vnd.intergeo',
  6056. 'icc' => 'application/vnd.iccprofile',
  6057. 'ice' => 'x-conference/x-cooltalk',
  6058. 'icm' => 'application/vnd.iccprofile',
  6059. 'ico' => 'image/x-icon',
  6060. 'ics' => 'text/calendar',
  6061. 'ief' => 'image/ief',
  6062. 'ifb' => 'text/calendar',
  6063. 'ifm' => 'application/vnd.shana.informed.formdata',
  6064. 'iges' => 'model/iges',
  6065. 'igl' => 'application/vnd.igloader',
  6066. 'igm' => 'application/vnd.insors.igm',
  6067. 'igs' => 'model/iges',
  6068. 'igx' => 'application/vnd.micrografx.igx',
  6069. 'iif' => 'application/vnd.shana.informed.interchange',
  6070. 'imp' => 'application/vnd.accpac.simply.imp',
  6071. 'ims' => 'application/vnd.ms-ims',
  6072. 'in' => 'text/plain',
  6073. 'ink' => 'application/inkml+xml',
  6074. 'inkml' => 'application/inkml+xml',
  6075. 'install' => 'application/x-install-instructions',
  6076. 'iota' => 'application/vnd.astraea-software.iota',
  6077. 'ipfix' => 'application/ipfix',
  6078. 'ipk' => 'application/vnd.shana.informed.package',
  6079. 'irm' => 'application/vnd.ibm.rights-management',
  6080. 'irp' => 'application/vnd.irepository.package+xml',
  6081. 'iso' => 'application/x-iso9660-image',
  6082. 'itp' => 'application/vnd.shana.informed.formtemplate',
  6083. 'ivp' => 'application/vnd.immervision-ivp',
  6084. 'ivu' => 'application/vnd.immervision-ivu',
  6085. 'jad' => 'text/vnd.sun.j2me.app-descriptor',
  6086. 'jam' => 'application/vnd.jam',
  6087. 'jar' => 'application/java-archive',
  6088. 'java' => 'text/x-java-source',
  6089. 'jisp' => 'application/vnd.jisp',
  6090. 'jlt' => 'application/vnd.hp-jlyt',
  6091. 'jnlp' => 'application/x-java-jnlp-file',
  6092. 'joda' => 'application/vnd.joost.joda-archive',
  6093. 'jpe' => 'image/jpeg',
  6094. 'jpeg' => 'image/jpeg',
  6095. 'jpg' => 'image/jpeg',
  6096. 'jpgm' => 'video/jpm',
  6097. 'jpgv' => 'video/jpeg',
  6098. 'jpm' => 'video/jpm',
  6099. 'js' => 'application/javascript',
  6100. 'json' => 'application/json',
  6101. 'jsonml' => 'application/jsonml+json',
  6102. 'kar' => 'audio/midi',
  6103. 'karbon' => 'application/vnd.kde.karbon',
  6104. 'kfo' => 'application/vnd.kde.kformula',
  6105. 'kia' => 'application/vnd.kidspiration',
  6106. 'kml' => 'application/vnd.google-earth.kml+xml',
  6107. 'kmz' => 'application/vnd.google-earth.kmz',
  6108. 'kne' => 'application/vnd.kinar',
  6109. 'knp' => 'application/vnd.kinar',
  6110. 'kon' => 'application/vnd.kde.kontour',
  6111. 'kpr' => 'application/vnd.kde.kpresenter',
  6112. 'kpt' => 'application/vnd.kde.kpresenter',
  6113. 'kpxx' => 'application/vnd.ds-keypoint',
  6114. 'ksp' => 'application/vnd.kde.kspread',
  6115. 'ktr' => 'application/vnd.kahootz',
  6116. 'ktx' => 'image/ktx',
  6117. 'ktz' => 'application/vnd.kahootz',
  6118. 'kwd' => 'application/vnd.kde.kword',
  6119. 'kwt' => 'application/vnd.kde.kword',
  6120. 'lasxml' => 'application/vnd.las.las+xml',
  6121. 'latex' => 'application/x-latex',
  6122. 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  6123. 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  6124. 'les' => 'application/vnd.hhe.lesson-player',
  6125. 'lha' => 'application/x-lzh-compressed',
  6126. 'link66' => 'application/vnd.route66.link66+xml',
  6127. 'list' => 'text/plain',
  6128. 'list3820' => 'application/vnd.ibm.modcap',
  6129. 'listafp' => 'application/vnd.ibm.modcap',
  6130. 'lnk' => 'application/x-ms-shortcut',
  6131. 'log' => 'text/plain',
  6132. 'lostxml' => 'application/lost+xml',
  6133. 'lrf' => 'application/octet-stream',
  6134. 'lrm' => 'application/vnd.ms-lrm',
  6135. 'ltf' => 'application/vnd.frogans.ltf',
  6136. 'lvp' => 'audio/vnd.lucent.voice',
  6137. 'lwp' => 'application/vnd.lotus-wordpro',
  6138. 'lzh' => 'application/x-lzh-compressed',
  6139. 'm13' => 'application/x-msmediaview',
  6140. 'm14' => 'application/x-msmediaview',
  6141. 'm1v' => 'video/mpeg',
  6142. 'm21' => 'application/mp21',
  6143. 'm2a' => 'audio/mpeg',
  6144. 'm2v' => 'video/mpeg',
  6145. 'm3a' => 'audio/mpeg',
  6146. 'm3u' => 'audio/x-mpegurl',
  6147. 'm3u8' => 'application/vnd.apple.mpegurl',
  6148. 'm4a' => 'audio/mp4',
  6149. 'm4u' => 'video/vnd.mpegurl',
  6150. 'm4v' => 'video/x-m4v',
  6151. 'ma' => 'application/mathematica',
  6152. 'mads' => 'application/mads+xml',
  6153. 'mag' => 'application/vnd.ecowin.chart',
  6154. 'maker' => 'application/vnd.framemaker',
  6155. 'man' => 'text/troff',
  6156. 'mar' => 'application/octet-stream',
  6157. 'mathml' => 'application/mathml+xml',
  6158. 'mb' => 'application/mathematica',
  6159. 'mbk' => 'application/vnd.mobius.mbk',
  6160. 'mbox' => 'application/mbox',
  6161. 'mc1' => 'application/vnd.medcalcdata',
  6162. 'mcd' => 'application/vnd.mcd',
  6163. 'mcurl' => 'text/vnd.curl.mcurl',
  6164. 'mdb' => 'application/x-msaccess',
  6165. 'mdi' => 'image/vnd.ms-modi',
  6166. 'me' => 'text/troff',
  6167. 'mesh' => 'model/mesh',
  6168. 'meta4' => 'application/metalink4+xml',
  6169. 'metalink' => 'application/metalink+xml',
  6170. 'mets' => 'application/mets+xml',
  6171. 'mfm' => 'application/vnd.mfmp',
  6172. 'mft' => 'application/rpki-manifest',
  6173. 'mgp' => 'application/vnd.osgeo.mapguide.package',
  6174. 'mgz' => 'application/vnd.proteus.magazine',
  6175. 'mid' => 'audio/midi',
  6176. 'midi' => 'audio/midi',
  6177. 'mie' => 'application/x-mie',
  6178. 'mif' => 'application/vnd.mif',
  6179. 'mime' => 'message/rfc822',
  6180. 'mj2' => 'video/mj2',
  6181. 'mjp2' => 'video/mj2',
  6182. 'mk3d' => 'video/x-matroska',
  6183. 'mka' => 'audio/x-matroska',
  6184. 'mks' => 'video/x-matroska',
  6185. 'mkv' => 'video/x-matroska',
  6186. 'mlp' => 'application/vnd.dolby.mlp',
  6187. 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
  6188. 'mmf' => 'application/vnd.smaf',
  6189. 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
  6190. 'mng' => 'video/x-mng',
  6191. 'mny' => 'application/x-msmoney',
  6192. 'mobi' => 'application/x-mobipocket-ebook',
  6193. 'mods' => 'application/mods+xml',
  6194. 'mov' => 'video/quicktime',
  6195. 'movie' => 'video/x-sgi-movie',
  6196. 'mp2' => 'audio/mpeg',
  6197. 'mp21' => 'application/mp21',
  6198. 'mp2a' => 'audio/mpeg',
  6199. 'mp3' => 'audio/mpeg',
  6200. 'mp4' => 'video/mp4',
  6201. 'mp4a' => 'audio/mp4',
  6202. 'mp4s' => 'application/mp4',
  6203. 'mp4v' => 'video/mp4',
  6204. 'mpc' => 'application/vnd.mophun.certificate',
  6205. 'mpe' => 'video/mpeg',
  6206. 'mpeg' => 'video/mpeg',
  6207. 'mpg' => 'video/mpeg',
  6208. 'mpg4' => 'video/mp4',
  6209. 'mpga' => 'audio/mpeg',
  6210. 'mpkg' => 'application/vnd.apple.installer+xml',
  6211. 'mpm' => 'application/vnd.blueice.multipass',
  6212. 'mpn' => 'application/vnd.mophun.application',
  6213. 'mpp' => 'application/vnd.ms-project',
  6214. 'mpt' => 'application/vnd.ms-project',
  6215. 'mpy' => 'application/vnd.ibm.minipay',
  6216. 'mqy' => 'application/vnd.mobius.mqy',
  6217. 'mrc' => 'application/marc',
  6218. 'mrcx' => 'application/marcxml+xml',
  6219. 'ms' => 'text/troff',
  6220. 'mscml' => 'application/mediaservercontrol+xml',
  6221. 'mseed' => 'application/vnd.fdsn.mseed',
  6222. 'mseq' => 'application/vnd.mseq',
  6223. 'msf' => 'application/vnd.epson.msf',
  6224. 'msh' => 'model/mesh',
  6225. 'msi' => 'application/x-msdownload',
  6226. 'msl' => 'application/vnd.mobius.msl',
  6227. 'msty' => 'application/vnd.muvee.style',
  6228. 'mts' => 'model/vnd.mts',
  6229. 'mus' => 'application/vnd.musician',
  6230. 'musicxml' => 'application/vnd.recordare.musicxml+xml',
  6231. 'mvb' => 'application/x-msmediaview',
  6232. 'mwf' => 'application/vnd.mfer',
  6233. 'mxf' => 'application/mxf',
  6234. 'mxl' => 'application/vnd.recordare.musicxml',
  6235. 'mxml' => 'application/xv+xml',
  6236. 'mxs' => 'application/vnd.triscape.mxs',
  6237. 'mxu' => 'video/vnd.mpegurl',
  6238. 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  6239. 'n3' => 'text/n3',
  6240. 'nb' => 'application/mathematica',
  6241. 'nbp' => 'application/vnd.wolfram.player',
  6242. 'nc' => 'application/x-netcdf',
  6243. 'ncx' => 'application/x-dtbncx+xml',
  6244. 'nfo' => 'text/x-nfo',
  6245. 'ngdat' => 'application/vnd.nokia.n-gage.data',
  6246. 'nitf' => 'application/vnd.nitf',
  6247. 'nlu' => 'application/vnd.neurolanguage.nlu',
  6248. 'nml' => 'application/vnd.enliven',
  6249. 'nnd' => 'application/vnd.noblenet-directory',
  6250. 'nns' => 'application/vnd.noblenet-sealer',
  6251. 'nnw' => 'application/vnd.noblenet-web',
  6252. 'npx' => 'image/vnd.net-fpx',
  6253. 'nsc' => 'application/x-conference',
  6254. 'nsf' => 'application/vnd.lotus-notes',
  6255. 'ntf' => 'application/vnd.nitf',
  6256. 'nzb' => 'application/x-nzb',
  6257. 'oa2' => 'application/vnd.fujitsu.oasys2',
  6258. 'oa3' => 'application/vnd.fujitsu.oasys3',
  6259. 'oas' => 'application/vnd.fujitsu.oasys',
  6260. 'obd' => 'application/x-msbinder',
  6261. 'obj' => 'application/x-tgif',
  6262. 'oda' => 'application/oda',
  6263. 'odb' => 'application/vnd.oasis.opendocument.database',
  6264. 'odc' => 'application/vnd.oasis.opendocument.chart',
  6265. 'odf' => 'application/vnd.oasis.opendocument.formula',
  6266. 'odft' => 'application/vnd.oasis.opendocument.formula-template',
  6267. 'odg' => 'application/vnd.oasis.opendocument.graphics',
  6268. 'odi' => 'application/vnd.oasis.opendocument.image',
  6269. 'odm' => 'application/vnd.oasis.opendocument.text-master',
  6270. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  6271. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  6272. 'odt' => 'application/vnd.oasis.opendocument.text',
  6273. 'oga' => 'audio/ogg',
  6274. 'ogg' => 'audio/ogg',
  6275. 'ogv' => 'video/ogg',
  6276. 'ogx' => 'application/ogg',
  6277. 'omdoc' => 'application/omdoc+xml',
  6278. 'onepkg' => 'application/onenote',
  6279. 'onetmp' => 'application/onenote',
  6280. 'onetoc' => 'application/onenote',
  6281. 'onetoc2' => 'application/onenote',
  6282. 'opf' => 'application/oebps-package+xml',
  6283. 'opml' => 'text/x-opml',
  6284. 'oprc' => 'application/vnd.palm',
  6285. 'org' => 'application/vnd.lotus-organizer',
  6286. 'osf' => 'application/vnd.yamaha.openscoreformat',
  6287. 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  6288. 'otc' => 'application/vnd.oasis.opendocument.chart-template',
  6289. 'otf' => 'application/x-font-otf',
  6290. 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
  6291. 'oth' => 'application/vnd.oasis.opendocument.text-web',
  6292. 'oti' => 'application/vnd.oasis.opendocument.image-template',
  6293. 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
  6294. 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  6295. 'ott' => 'application/vnd.oasis.opendocument.text-template',
  6296. 'oxps' => 'application/oxps',
  6297. 'oxt' => 'application/vnd.openofficeorg.extension',
  6298. 'p' => 'text/x-pascal',
  6299. 'p10' => 'application/pkcs10',
  6300. 'p12' => 'application/x-pkcs12',
  6301. 'p7b' => 'application/x-pkcs7-certificates',
  6302. 'p7c' => 'application/pkcs7-mime',
  6303. 'p7m' => 'application/pkcs7-mime',
  6304. 'p7r' => 'application/x-pkcs7-certreqresp',
  6305. 'p7s' => 'application/pkcs7-signature',
  6306. 'p8' => 'application/pkcs8',
  6307. 'pas' => 'text/x-pascal',
  6308. 'paw' => 'application/vnd.pawaafile',
  6309. 'pbd' => 'application/vnd.powerbuilder6',
  6310. 'pbm' => 'image/x-portable-bitmap',
  6311. 'pcap' => 'application/vnd.tcpdump.pcap',
  6312. 'pcf' => 'application/x-font-pcf',
  6313. 'pcl' => 'application/vnd.hp-pcl',
  6314. 'pclxl' => 'application/vnd.hp-pclxl',
  6315. 'pct' => 'image/x-pict',
  6316. 'pcurl' => 'application/vnd.curl.pcurl',
  6317. 'pcx' => 'image/x-pcx',
  6318. 'pdb' => 'application/vnd.palm',
  6319. 'pdf' => 'application/pdf',
  6320. 'pfa' => 'application/x-font-type1',
  6321. 'pfb' => 'application/x-font-type1',
  6322. 'pfm' => 'application/x-font-type1',
  6323. 'pfr' => 'application/font-tdpfr',
  6324. 'pfx' => 'application/x-pkcs12',
  6325. 'pgm' => 'image/x-portable-graymap',
  6326. 'pgn' => 'application/x-chess-pgn',
  6327. 'pgp' => 'application/pgp-encrypted',
  6328. 'pic' => 'image/x-pict',
  6329. 'pkg' => 'application/octet-stream',
  6330. 'pki' => 'application/pkixcmp',
  6331. 'pkipath' => 'application/pkix-pkipath',
  6332. 'plb' => 'application/vnd.3gpp.pic-bw-large',
  6333. 'plc' => 'application/vnd.mobius.plc',
  6334. 'plf' => 'application/vnd.pocketlearn',
  6335. 'pls' => 'application/pls+xml',
  6336. 'pml' => 'application/vnd.ctc-posml',
  6337. 'png' => 'image/png',
  6338. 'pnm' => 'image/x-portable-anymap',
  6339. 'portpkg' => 'application/vnd.macports.portpkg',
  6340. 'pot' => 'application/vnd.ms-powerpoint',
  6341. 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
  6342. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  6343. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  6344. 'ppd' => 'application/vnd.cups-ppd',
  6345. 'ppm' => 'image/x-portable-pixmap',
  6346. 'pps' => 'application/vnd.ms-powerpoint',
  6347. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  6348. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  6349. 'ppt' => 'application/vnd.ms-powerpoint',
  6350. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  6351. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  6352. 'pqa' => 'application/vnd.palm',
  6353. 'prc' => 'application/x-mobipocket-ebook',
  6354. 'pre' => 'application/vnd.lotus-freelance',
  6355. 'prf' => 'application/pics-rules',
  6356. 'ps' => 'application/postscript',
  6357. 'psb' => 'application/vnd.3gpp.pic-bw-small',
  6358. 'psd' => 'image/vnd.adobe.photoshop',
  6359. 'psf' => 'application/x-font-linux-psf',
  6360. 'pskcxml' => 'application/pskc+xml',
  6361. 'ptid' => 'application/vnd.pvi.ptid1',
  6362. 'pub' => 'application/x-mspublisher',
  6363. 'pvb' => 'application/vnd.3gpp.pic-bw-var',
  6364. 'pwn' => 'application/vnd.3m.post-it-notes',
  6365. 'pya' => 'audio/vnd.ms-playready.media.pya',
  6366. 'pyv' => 'video/vnd.ms-playready.media.pyv',
  6367. 'qam' => 'application/vnd.epson.quickanime',
  6368. 'qbo' => 'application/vnd.intu.qbo',
  6369. 'qfx' => 'application/vnd.intu.qfx',
  6370. 'qps' => 'application/vnd.publishare-delta-tree',
  6371. 'qt' => 'video/quicktime',
  6372. 'qwd' => 'application/vnd.quark.quarkxpress',
  6373. 'qwt' => 'application/vnd.quark.quarkxpress',
  6374. 'qxb' => 'application/vnd.quark.quarkxpress',
  6375. 'qxd' => 'application/vnd.quark.quarkxpress',
  6376. 'qxl' => 'application/vnd.quark.quarkxpress',
  6377. 'qxt' => 'application/vnd.quark.quarkxpress',
  6378. 'ra' => 'audio/x-pn-realaudio',
  6379. 'ram' => 'audio/x-pn-realaudio',
  6380. 'rar' => 'application/x-rar-compressed',
  6381. 'ras' => 'image/x-cmu-raster',
  6382. 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
  6383. 'rdf' => 'application/rdf+xml',
  6384. 'rdz' => 'application/vnd.data-vision.rdz',
  6385. 'rep' => 'application/vnd.businessobjects',
  6386. 'res' => 'application/x-dtbresource+xml',
  6387. 'rgb' => 'image/x-rgb',
  6388. 'rif' => 'application/reginfo+xml',
  6389. 'rip' => 'audio/vnd.rip',
  6390. 'ris' => 'application/x-research-info-systems',
  6391. 'rl' => 'application/resource-lists+xml',
  6392. 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
  6393. 'rld' => 'application/resource-lists-diff+xml',
  6394. 'rm' => 'application/vnd.rn-realmedia',
  6395. 'rmi' => 'audio/midi',
  6396. 'rmp' => 'audio/x-pn-realaudio-plugin',
  6397. 'rms' => 'application/vnd.jcp.javame.midlet-rms',
  6398. 'rmvb' => 'application/vnd.rn-realmedia-vbr',
  6399. 'rnc' => 'application/relax-ng-compact-syntax',
  6400. 'roa' => 'application/rpki-roa',
  6401. 'roff' => 'text/troff',
  6402. 'rp9' => 'application/vnd.cloanto.rp9',
  6403. 'rpss' => 'application/vnd.nokia.radio-presets',
  6404. 'rpst' => 'application/vnd.nokia.radio-preset',
  6405. 'rq' => 'application/sparql-query',
  6406. 'rs' => 'application/rls-services+xml',
  6407. 'rsd' => 'application/rsd+xml',
  6408. 'rss' => 'application/rss+xml',
  6409. 'rtf' => 'application/rtf',
  6410. 'rtx' => 'text/richtext',
  6411. 's' => 'text/x-asm',
  6412. 's3m' => 'audio/s3m',
  6413. 'saf' => 'application/vnd.yamaha.smaf-audio',
  6414. 'sbml' => 'application/sbml+xml',
  6415. 'sc' => 'application/vnd.ibm.secure-container',
  6416. 'scd' => 'application/x-msschedule',
  6417. 'scm' => 'application/vnd.lotus-screencam',
  6418. 'scq' => 'application/scvp-cv-request',
  6419. 'scs' => 'application/scvp-cv-response',
  6420. 'scurl' => 'text/vnd.curl.scurl',
  6421. 'sda' => 'application/vnd.stardivision.draw',
  6422. 'sdc' => 'application/vnd.stardivision.calc',
  6423. 'sdd' => 'application/vnd.stardivision.impress',
  6424. 'sdkd' => 'application/vnd.solent.sdkm+xml',
  6425. 'sdkm' => 'application/vnd.solent.sdkm+xml',
  6426. 'sdp' => 'application/sdp',
  6427. 'sdw' => 'application/vnd.stardivision.writer',
  6428. 'see' => 'application/vnd.seemail',
  6429. 'seed' => 'application/vnd.fdsn.seed',
  6430. 'sema' => 'application/vnd.sema',
  6431. 'semd' => 'application/vnd.semd',
  6432. 'semf' => 'application/vnd.semf',
  6433. 'ser' => 'application/java-serialized-object',
  6434. 'setpay' => 'application/set-payment-initiation',
  6435. 'setreg' => 'application/set-registration-initiation',
  6436. 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
  6437. 'sfs' => 'application/vnd.spotfire.sfs',
  6438. 'sfv' => 'text/x-sfv',
  6439. 'sgi' => 'image/sgi',
  6440. 'sgl' => 'application/vnd.stardivision.writer-global',
  6441. 'sgm' => 'text/sgml',
  6442. 'sgml' => 'text/sgml',
  6443. 'sh' => 'application/x-sh',
  6444. 'shar' => 'application/x-shar',
  6445. 'shf' => 'application/shf+xml',
  6446. 'sid' => 'image/x-mrsid-image',
  6447. 'sig' => 'application/pgp-signature',
  6448. 'sil' => 'audio/silk',
  6449. 'silo' => 'model/mesh',
  6450. 'sis' => 'application/vnd.symbian.install',
  6451. 'sisx' => 'application/vnd.symbian.install',
  6452. 'sit' => 'application/x-stuffit',
  6453. 'sitx' => 'application/x-stuffitx',
  6454. 'skd' => 'application/vnd.koan',
  6455. 'skm' => 'application/vnd.koan',
  6456. 'skp' => 'application/vnd.koan',
  6457. 'skt' => 'application/vnd.koan',
  6458. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  6459. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  6460. 'slt' => 'application/vnd.epson.salt',
  6461. 'sm' => 'application/vnd.stepmania.stepchart',
  6462. 'smf' => 'application/vnd.stardivision.math',
  6463. 'smi' => 'application/smil+xml',
  6464. 'smil' => 'application/smil+xml',
  6465. 'smv' => 'video/x-smv',
  6466. 'smzip' => 'application/vnd.stepmania.package',
  6467. 'snd' => 'audio/basic',
  6468. 'snf' => 'application/x-font-snf',
  6469. 'so' => 'application/octet-stream',
  6470. 'spc' => 'application/x-pkcs7-certificates',
  6471. 'spf' => 'application/vnd.yamaha.smaf-phrase',
  6472. 'spl' => 'application/x-futuresplash',
  6473. 'spot' => 'text/vnd.in3d.spot',
  6474. 'spp' => 'application/scvp-vp-response',
  6475. 'spq' => 'application/scvp-vp-request',
  6476. 'spx' => 'audio/ogg',
  6477. 'sql' => 'application/x-sql',
  6478. 'src' => 'application/x-wais-source',
  6479. 'srt' => 'application/x-subrip',
  6480. 'sru' => 'application/sru+xml',
  6481. 'srx' => 'application/sparql-results+xml',
  6482. 'ssdl' => 'application/ssdl+xml',
  6483. 'sse' => 'application/vnd.kodak-descriptor',
  6484. 'ssf' => 'application/vnd.epson.ssf',
  6485. 'ssml' => 'application/ssml+xml',
  6486. 'st' => 'application/vnd.sailingtracker.track',
  6487. 'stc' => 'application/vnd.sun.xml.calc.template',
  6488. 'std' => 'application/vnd.sun.xml.draw.template',
  6489. 'stf' => 'application/vnd.wt.stf',
  6490. 'sti' => 'application/vnd.sun.xml.impress.template',
  6491. 'stk' => 'application/hyperstudio',
  6492. 'stl' => 'application/vnd.ms-pki.stl',
  6493. 'str' => 'application/vnd.pg.format',
  6494. 'stw' => 'application/vnd.sun.xml.writer.template',
  6495. 'sub' => 'image/vnd.dvb.subtitle',
  6496. 'sub' => 'text/vnd.dvb.subtitle',
  6497. 'sus' => 'application/vnd.sus-calendar',
  6498. 'susp' => 'application/vnd.sus-calendar',
  6499. 'sv4cpio' => 'application/x-sv4cpio',
  6500. 'sv4crc' => 'application/x-sv4crc',
  6501. 'svc' => 'application/vnd.dvb.service',
  6502. 'svd' => 'application/vnd.svd',
  6503. 'svg' => 'image/svg+xml',
  6504. 'svgz' => 'image/svg+xml',
  6505. 'swa' => 'application/x-director',
  6506. 'swf' => 'application/x-shockwave-flash',
  6507. 'swi' => 'application/vnd.aristanetworks.swi',
  6508. 'sxc' => 'application/vnd.sun.xml.calc',
  6509. 'sxd' => 'application/vnd.sun.xml.draw',
  6510. 'sxg' => 'application/vnd.sun.xml.writer.global',
  6511. 'sxi' => 'application/vnd.sun.xml.impress',
  6512. 'sxm' => 'application/vnd.sun.xml.math',
  6513. 'sxw' => 'application/vnd.sun.xml.writer',
  6514. 't' => 'text/troff',
  6515. 't3' => 'application/x-t3vm-image',
  6516. 'taglet' => 'application/vnd.mynfc',
  6517. 'tao' => 'application/vnd.tao.intent-module-archive',
  6518. 'tar' => 'application/x-tar',
  6519. 'tcap' => 'application/vnd.3gpp2.tcap',
  6520. 'tcl' => 'application/x-tcl',
  6521. 'teacher' => 'application/vnd.smart.teacher',
  6522. 'tei' => 'application/tei+xml',
  6523. 'teicorpus' => 'application/tei+xml',
  6524. 'tex' => 'application/x-tex',
  6525. 'texi' => 'application/x-texinfo',
  6526. 'texinfo' => 'application/x-texinfo',
  6527. 'text' => 'text/plain',
  6528. 'tfi' => 'application/thraud+xml',
  6529. 'tfm' => 'application/x-tex-tfm',
  6530. 'tga' => 'image/x-tga',
  6531. 'thmx' => 'application/vnd.ms-officetheme',
  6532. 'tif' => 'image/tiff',
  6533. 'tiff' => 'image/tiff',
  6534. 'tmo' => 'application/vnd.tmobile-livetv',
  6535. 'torrent' => 'application/x-bittorrent',
  6536. 'tpl' => 'application/vnd.groove-tool-template',
  6537. 'tpt' => 'application/vnd.trid.tpt',
  6538. 'tr' => 'text/troff',
  6539. 'tra' => 'application/vnd.trueapp',
  6540. 'trm' => 'application/x-msterminal',
  6541. 'tsd' => 'application/timestamped-data',
  6542. 'tsv' => 'text/tab-separated-values',
  6543. 'ttc' => 'application/x-font-ttf',
  6544. 'ttf' => 'application/x-font-ttf',
  6545. 'ttl' => 'text/turtle',
  6546. 'twd' => 'application/vnd.simtech-mindmapper',
  6547. 'twds' => 'application/vnd.simtech-mindmapper',
  6548. 'txd' => 'application/vnd.genomatix.tuxedo',
  6549. 'txf' => 'application/vnd.mobius.txf',
  6550. 'txt' => 'text/plain',
  6551. 'u32' => 'application/x-authorware-bin',
  6552. 'udeb' => 'application/x-debian-package',
  6553. 'ufd' => 'application/vnd.ufdl',
  6554. 'ufdl' => 'application/vnd.ufdl',
  6555. 'ulx' => 'application/x-glulx',
  6556. 'umj' => 'application/vnd.umajin',
  6557. 'unityweb' => 'application/vnd.unity',
  6558. 'uoml' => 'application/vnd.uoml+xml',
  6559. 'uri' => 'text/uri-list',
  6560. 'uris' => 'text/uri-list',
  6561. 'urls' => 'text/uri-list',
  6562. 'ustar' => 'application/x-ustar',
  6563. 'utz' => 'application/vnd.uiq.theme',
  6564. 'uu' => 'text/x-uuencode',
  6565. 'uva' => 'audio/vnd.dece.audio',
  6566. 'uvd' => 'application/vnd.dece.data',
  6567. 'uvf' => 'application/vnd.dece.data',
  6568. 'uvg' => 'image/vnd.dece.graphic',
  6569. 'uvh' => 'video/vnd.dece.hd',
  6570. 'uvi' => 'image/vnd.dece.graphic',
  6571. 'uvm' => 'video/vnd.dece.mobile',
  6572. 'uvp' => 'video/vnd.dece.pd',
  6573. 'uvs' => 'video/vnd.dece.sd',
  6574. 'uvt' => 'application/vnd.dece.ttml+xml',
  6575. 'uvu' => 'video/vnd.uvvu.mp4',
  6576. 'uvv' => 'video/vnd.dece.video',
  6577. 'uvva' => 'audio/vnd.dece.audio',
  6578. 'uvvd' => 'application/vnd.dece.data',
  6579. 'uvvf' => 'application/vnd.dece.data',
  6580. 'uvvg' => 'image/vnd.dece.graphic',
  6581. 'uvvh' => 'video/vnd.dece.hd',
  6582. 'uvvi' => 'image/vnd.dece.graphic',
  6583. 'uvvm' => 'video/vnd.dece.mobile',
  6584. 'uvvp' => 'video/vnd.dece.pd',
  6585. 'uvvs' => 'video/vnd.dece.sd',
  6586. 'uvvt' => 'application/vnd.dece.ttml+xml',
  6587. 'uvvu' => 'video/vnd.uvvu.mp4',
  6588. 'uvvv' => 'video/vnd.dece.video',
  6589. 'uvvx' => 'application/vnd.dece.unspecified',
  6590. 'uvvz' => 'application/vnd.dece.zip',
  6591. 'uvx' => 'application/vnd.dece.unspecified',
  6592. 'uvz' => 'application/vnd.dece.zip',
  6593. 'vcard' => 'text/vcard',
  6594. 'vcd' => 'application/x-cdlink',
  6595. 'vcf' => 'text/x-vcard',
  6596. 'vcg' => 'application/vnd.groove-vcard',
  6597. 'vcs' => 'text/x-vcalendar',
  6598. 'vcx' => 'application/vnd.vcx',
  6599. 'vis' => 'application/vnd.visionary',
  6600. 'viv' => 'video/vnd.vivo',
  6601. 'vob' => 'video/x-ms-vob',
  6602. 'vor' => 'application/vnd.stardivision.writer',
  6603. 'vox' => 'application/x-authorware-bin',
  6604. 'vrml' => 'model/vrml',
  6605. 'vsd' => 'application/vnd.visio',
  6606. 'vsf' => 'application/vnd.vsf',
  6607. 'vss' => 'application/vnd.visio',
  6608. 'vst' => 'application/vnd.visio',
  6609. 'vsw' => 'application/vnd.visio',
  6610. 'vtu' => 'model/vnd.vtu',
  6611. 'vxml' => 'application/voicexml+xml',
  6612. 'w3d' => 'application/x-director',
  6613. 'wad' => 'application/x-doom',
  6614. 'wav' => 'audio/x-wav',
  6615. 'wax' => 'audio/x-ms-wax',
  6616. 'wbmp' => 'image/vnd.wap.wbmp',
  6617. 'wbs' => 'application/vnd.criticaltools.wbs+xml',
  6618. 'wbxml' => 'application/vnd.wap.wbxml',
  6619. 'wcm' => 'application/vnd.ms-works',
  6620. 'wdb' => 'application/vnd.ms-works',
  6621. 'wdp' => 'image/vnd.ms-photo',
  6622. 'weba' => 'audio/webm',
  6623. 'webm' => 'video/webm',
  6624. 'webp' => 'image/webp',
  6625. 'wg' => 'application/vnd.pmi.widget',
  6626. 'wgt' => 'application/widget',
  6627. 'wks' => 'application/vnd.ms-works',
  6628. 'wm' => 'video/x-ms-wm',
  6629. 'wma' => 'audio/x-ms-wma',
  6630. 'wmd' => 'application/x-ms-wmd',
  6631. 'wmf' => 'application/x-msmetafile',
  6632. 'wml' => 'text/vnd.wap.wml',
  6633. 'wmlc' => 'application/vnd.wap.wmlc',
  6634. 'wmls' => 'text/vnd.wap.wmlscript',
  6635. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  6636. 'wmv' => 'video/x-ms-wmv',
  6637. 'wmx' => 'video/x-ms-wmx',
  6638. 'wmz' => 'application/x-ms-wmz',
  6639. 'wmz' => 'application/x-msmetafile',
  6640. 'woff' => 'application/font-woff',
  6641. 'wpd' => 'application/vnd.wordperfect',
  6642. 'wpl' => 'application/vnd.ms-wpl',
  6643. 'wps' => 'application/vnd.ms-works',
  6644. 'wqd' => 'application/vnd.wqd',
  6645. 'wri' => 'application/x-mswrite',
  6646. 'wrl' => 'model/vrml',
  6647. 'wsdl' => 'application/wsdl+xml',
  6648. 'wspolicy' => 'application/wspolicy+xml',
  6649. 'wtb' => 'application/vnd.webturbo',
  6650. 'wvx' => 'video/x-ms-wvx',
  6651. 'x32' => 'application/x-authorware-bin',
  6652. 'x3d' => 'model/x3d+xml',
  6653. 'x3db' => 'model/x3d+binary',
  6654. 'x3dbz' => 'model/x3d+binary',
  6655. 'x3dv' => 'model/x3d+vrml',
  6656. 'x3dvz' => 'model/x3d+vrml',
  6657. 'x3dz' => 'model/x3d+xml',
  6658. 'xaml' => 'application/xaml+xml',
  6659. 'xap' => 'application/x-silverlight-app',
  6660. 'xar' => 'application/vnd.xara',
  6661. 'xbap' => 'application/x-ms-xbap',
  6662. 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
  6663. 'xbm' => 'image/x-xbitmap',
  6664. 'xdf' => 'application/xcap-diff+xml',
  6665. 'xdm' => 'application/vnd.syncml.dm+xml',
  6666. 'xdp' => 'application/vnd.adobe.xdp+xml',
  6667. 'xdssc' => 'application/dssc+xml',
  6668. 'xdw' => 'application/vnd.fujixerox.docuworks',
  6669. 'xenc' => 'application/xenc+xml',
  6670. 'xer' => 'application/patch-ops-error+xml',
  6671. 'xfdf' => 'application/vnd.adobe.xfdf',
  6672. 'xfdl' => 'application/vnd.xfdl',
  6673. 'xht' => 'application/xhtml+xml',
  6674. 'xhtml' => 'application/xhtml+xml',
  6675. 'xhvml' => 'application/xv+xml',
  6676. 'xif' => 'image/vnd.xiff',
  6677. 'xla' => 'application/vnd.ms-excel',
  6678. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  6679. 'xlc' => 'application/vnd.ms-excel',
  6680. 'xlf' => 'application/x-xliff+xml',
  6681. 'xlm' => 'application/vnd.ms-excel',
  6682. 'xls' => 'application/vnd.ms-excel',
  6683. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  6684. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  6685. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  6686. 'xlt' => 'application/vnd.ms-excel',
  6687. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  6688. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  6689. 'xlw' => 'application/vnd.ms-excel',
  6690. 'xm' => 'audio/xm',
  6691. 'xml' => 'application/xml',
  6692. 'xo' => 'application/vnd.olpc-sugar',
  6693. 'xop' => 'application/xop+xml',
  6694. 'xpi' => 'application/x-xpinstall',
  6695. 'xpl' => 'application/xproc+xml',
  6696. 'xpm' => 'image/x-xpixmap',
  6697. 'xpr' => 'application/vnd.is-xpr',
  6698. 'xps' => 'application/vnd.ms-xpsdocument',
  6699. 'xpw' => 'application/vnd.intercon.formnet',
  6700. 'xpx' => 'application/vnd.intercon.formnet',
  6701. 'xsl' => 'application/xml',
  6702. 'xslt' => 'application/xslt+xml',
  6703. 'xsm' => 'application/vnd.syncml+xml',
  6704. 'xspf' => 'application/xspf+xml',
  6705. 'xul' => 'application/vnd.mozilla.xul+xml',
  6706. 'xvm' => 'application/xv+xml',
  6707. 'xvml' => 'application/xv+xml',
  6708. 'xwd' => 'image/x-xwindowdump',
  6709. 'xyz' => 'chemical/x-xyz',
  6710. 'xz' => 'application/x-xz',
  6711. 'yang' => 'application/yang',
  6712. 'yin' => 'application/yin+xml',
  6713. 'z1' => 'application/x-zmachine',
  6714. 'z2' => 'application/x-zmachine',
  6715. 'z3' => 'application/x-zmachine',
  6716. 'z4' => 'application/x-zmachine',
  6717. 'z5' => 'application/x-zmachine',
  6718. 'z6' => 'application/x-zmachine',
  6719. 'z7' => 'application/x-zmachine',
  6720. 'z8' => 'application/x-zmachine',
  6721. 'zaz' => 'application/vnd.zzazz.deck+xml',
  6722. 'zip' => 'application/zip',
  6723. 'zir' => 'application/vnd.zul',
  6724. 'zirz' => 'application/vnd.zul',
  6725. 'zmm' => 'application/vnd.handheld-entertainment+xml'
  6726. );
  6727. }
  6728. // Always run this
  6729. dependCheck();