functions.php 338 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175
  1. <?php
  2. // ===================================
  3. // Define Version
  4. define('INSTALLEDVERSION', '1.50');
  5. // ===================================
  6. use Kryptonit3\Sonarr\Sonarr;
  7. use Kryptonit3\SickRage\SickRage;
  8. //homepage order
  9. function homepageOrder(){
  10. $homepageOrder = array(
  11. "homepageOrdercustomhtml" => homepageOrdercustomhtml,
  12. "homepageOrdernotice" => homepageOrdernotice,
  13. "homepageOrderplexsearch" => homepageOrderplexsearch,
  14. "homepageOrderspeedtest" => homepageOrderspeedtest,
  15. "homepageOrdernzbget" => homepageOrdernzbget,
  16. "homepageOrdersabnzbd" => homepageOrdersabnzbd,
  17. "homepageOrderplexnowplaying" => homepageOrderplexnowplaying,
  18. "homepageOrderplexrecent" => homepageOrderplexrecent,
  19. "homepageOrderplexplaylist" => homepageOrderplexplaylist,
  20. "homepageOrderembynowplaying" => homepageOrderembynowplaying,
  21. "homepageOrderembyrecent" => homepageOrderembyrecent,
  22. "homepageOrderombi" => homepageOrderombi,
  23. "homepageOrdercalendar" => homepageOrdercalendar,
  24. );
  25. asort($homepageOrder);
  26. return $homepageOrder;
  27. }
  28. // Debugging output functions
  29. function debug_out($variable, $die = false) {
  30. $trace = debug_backtrace()[0];
  31. echo "<center><img height='200px' src='images/confused.png'></center>";
  32. echo "<center>Look's like something happened, here are the errors and perhaps how to fix them:</center>";
  33. 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>';
  34. if ($die) { http_response_code(503); die(); }
  35. }
  36. // ==== Auth Plugins START ====
  37. if (function_exists('ldap_connect')) :
  38. // Pass credentials to LDAP backend
  39. function plugin_auth_ldap($username, $password) {
  40. $ldapServers = explode(',',AUTHBACKENDHOST);
  41. foreach($ldapServers as $key => $value) {
  42. // Calculate parts
  43. $digest = parse_url(trim($value));
  44. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:'ldap'));
  45. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  46. $port = (isset($digest['port'])?$digest['port']:(strtolower($scheme)=='ldap'?389:636));
  47. // Reassign
  48. $ldapServers[$key] = $scheme.'://'.$host.':'.$port;
  49. }
  50. // returns true or false
  51. $ldap = ldap_connect(implode(' ',$ldapServers));
  52. if(empty(AUTHBACKENDDOMAINFORMAT)){
  53. if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
  54. writeLog("success", "LDAP authentication success");
  55. return true;
  56. } else {
  57. writeLog("error", "LDAP could not authenticate");
  58. return false;
  59. }
  60. }else{
  61. ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
  62. ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
  63. $bind = @ldap_bind($ldap, sprintf(AUTHBACKENDDOMAINFORMAT, $username), $password);
  64. if ($bind) {
  65. writeLog("success", "LDAP authentication success");
  66. return true;
  67. } else {
  68. writeLog("error", "LDPA could not authenticate");
  69. return false;
  70. }
  71. }
  72. writeLog("error", "LDAP could not authenticate");
  73. return false;
  74. }
  75. else :
  76. // Ldap Auth Missing Dependancy
  77. function plugin_auth_ldap_disabled() {
  78. return 'LDAP - Disabled (Dependancy: php-ldap missing!)';
  79. }
  80. endif;
  81. // Pass credentials to FTP backend
  82. function plugin_auth_ftp($username, $password) {
  83. // Calculate parts
  84. $digest = parse_url(AUTHBACKENDHOST);
  85. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:(function_exists('ftp_ssl_connect')?'ftps':'ftp')));
  86. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  87. $port = (isset($digest['port'])?$digest['port']:21);
  88. // Determine Connection Type
  89. if ($scheme == 'ftps') {
  90. $conn_id = ftp_ssl_connect($host, $port, 20);
  91. } elseif ($scheme == 'ftp') {
  92. $conn_id = ftp_connect($host, $port, 20);
  93. } else {
  94. debug_out('Invalid FTP scheme. Use ftp or ftps');
  95. writeLog("error", "invalid FTP scheme");
  96. return false;
  97. }
  98. // Check if valid FTP connection
  99. if ($conn_id) {
  100. // Attempt login
  101. @$login_result = ftp_login($conn_id, $username, $password);
  102. ftp_close($conn_id);
  103. // Return Result
  104. if ($login_result) {
  105. writeLog("success", "$username authenticated");
  106. return true;
  107. } else {
  108. writeLog("error", "$username could not authenticate");
  109. return false;
  110. }
  111. } else {
  112. return false;
  113. }
  114. return false;
  115. }
  116. // Pass credentials to Emby Backend
  117. function plugin_auth_emby_local($username, $password) {
  118. $embyAddress = qualifyURL(EMBYURL);
  119. $headers = array(
  120. 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"',
  121. 'Content-Type' => 'application/json',
  122. );
  123. $body = array(
  124. 'Username' => $username,
  125. 'Password' => sha1($password),
  126. 'PasswordMd5' => md5($password),
  127. );
  128. $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers);
  129. if (isset($response['content'])) {
  130. $json = json_decode($response['content'], true);
  131. if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
  132. // Login Success - Now Logout Emby Session As We No Longer Need It
  133. $headers = array(
  134. 'X-Mediabrowser-Token' => $json['AccessToken'],
  135. );
  136. $response = post_router($embyAddress.'/Sessions/Logout', array(), $headers);
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. if (function_exists('curl_version')) :
  143. // Authenticate Against Emby Local (first) and Emby Connect
  144. function plugin_auth_emby_all($username, $password) {
  145. $localResult = plugin_auth_emby_local($username, $password);
  146. if ($localResult) {
  147. return $localResult;
  148. } else {
  149. return plugin_auth_emby_connect($username, $password);
  150. }
  151. }
  152. // Authenicate against emby connect
  153. function plugin_auth_emby_connect($username, $password) {
  154. $embyAddress = qualifyURL(EMBYURL);
  155. // Get A User
  156. $connectId = '';
  157. $userIds = json_decode(file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
  158. if (is_array($userIds)) {
  159. foreach ($userIds as $key => $value) { // Scan for this user
  160. if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
  161. if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
  162. $connectId = $value['ConnectUserId'];
  163. break;
  164. }
  165. }
  166. }
  167. if ($connectId) {
  168. $connectURL = 'https://connect.emby.media/service/user/authenticate';
  169. $headers = array(
  170. 'Accept'=> 'application/json',
  171. 'Content-Type' => 'application/x-www-form-urlencoded',
  172. );
  173. $body = array(
  174. 'nameOrEmail' => $username,
  175. 'rawpw' => $password,
  176. );
  177. $result = curl_post($connectURL, $body, $headers);
  178. if (isset($result['content'])) {
  179. $json = json_decode($result['content'], true);
  180. if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
  181. return array(
  182. 'email' => $json['User']['Email'],
  183. 'image' => $json['User']['ImageUrl'],
  184. );
  185. }
  186. }
  187. }
  188. }
  189. return false;
  190. }
  191. // Pass credentials to Plex Backend
  192. function plugin_auth_plex($username, $password) {
  193. // Quick out
  194. $isAdmin = false;
  195. if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
  196. writeLog("success", "Admin: ".$username." authenticated by plex");
  197. //return true;
  198. $isAdmin = true;
  199. }
  200. //Get User List
  201. $userURL = 'https://plex.tv/pms/friends/all';
  202. $userHeaders = array(
  203. 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD),
  204. );
  205. libxml_use_internal_errors(true);
  206. $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
  207. if (is_array($userXML) || is_object($userXML)) {
  208. $isUser = false;
  209. $usernameLower = strtolower($username);
  210. foreach($userXML AS $child) {
  211. if(isset($child['username']) && strtolower($child['username']) == $usernameLower) {
  212. $isUser = true;
  213. writeLog("success", $usernameLower." was found in plex friends list");
  214. break;
  215. }
  216. }
  217. if ($isUser || $isAdmin) {
  218. //Login User
  219. $connectURL = 'https://plex.tv/users/sign_in.json';
  220. $headers = array(
  221. 'Accept'=> 'application/json',
  222. 'Content-Type' => 'application/x-www-form-urlencoded',
  223. 'X-Plex-Product' => 'Organizr',
  224. 'X-Plex-Version' => '1.0',
  225. 'X-Plex-Client-Identifier' => '01010101-10101010',
  226. );
  227. $body = array(
  228. 'user[login]' => $username,
  229. 'user[password]' => $password,
  230. );
  231. $result = curl_post($connectURL, $body, $headers);
  232. if (isset($result['content'])) {
  233. $json = json_decode($result['content'], true);
  234. if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && strtolower($json['user']['username']) == $usernameLower) {
  235. writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
  236. return array(
  237. 'email' => $json['user']['email'],
  238. 'image' => $json['user']['thumb'],
  239. 'token' => $json['user']['authToken']
  240. );
  241. }
  242. }
  243. }else{
  244. writeLog("error", "$username is not an authorized PLEX user or entered invalid password");
  245. }
  246. }else{
  247. writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");
  248. }
  249. return false;
  250. }
  251. else :
  252. // Plex Auth Missing Dependancy
  253. function plugin_auth_plex_disabled() {
  254. return 'Plex - Disabled (Dependancy: php-curl missing!)';
  255. }
  256. // Emby Connect Auth Missing Dependancy
  257. function plugin_auth_emby_connect_disabled() {
  258. return 'Emby Connect - Disabled (Dependancy: php-curl missing!)';
  259. }
  260. // Emby Both Auth Missing Dependancy
  261. function plugin_auth_emby_both_disabled() {
  262. return 'Emby Both - Disabled (Dependancy: php-curl missing!)';
  263. }
  264. endif;
  265. // ==== Auth Plugins END ====
  266. // ==== General Class Definitions START ====
  267. $userLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  268. class setLanguage {
  269. private $language = null;
  270. private $langCode = null;
  271. function __construct($language = false) {
  272. // Default
  273. if (!$language) {
  274. $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  275. }
  276. if (!file_exists("lang/{$language}.ini")) {
  277. $language = 'en';
  278. }
  279. $this->langCode = $language;
  280. $this->language = parse_ini_file("lang/{$language}.ini", false, INI_SCANNER_RAW);
  281. if (file_exists("lang/{$language}.cust.ini")) {
  282. foreach($tmp = parse_ini_file("lang/{$language}.cust.ini", false, INI_SCANNER_RAW) as $k => $v) {
  283. $this->language[$k] = $v;
  284. }
  285. }
  286. }
  287. public function getLang() {
  288. return $this->langCode;
  289. }
  290. public function translate($originalWord) {
  291. $getArg = func_num_args();
  292. if ($getArg > 1) {
  293. $allWords = func_get_args();
  294. array_shift($allWords);
  295. } else {
  296. $allWords = array();
  297. }
  298. $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null;
  299. if (!$translatedWord) {
  300. return ucwords(str_replace("_", " ", strtolower($originalWord)));
  301. //echo "WHOA!!!!!!! $originalWord";
  302. }
  303. $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES);
  304. return vsprintf($translatedWord, $allWords);
  305. }
  306. }
  307. $language = new setLanguage;
  308. // ==== General Class Definitions END ====
  309. // Direct request to curl if it exists, otherwise handle if not HTTPS
  310. function post_router($url, $data, $headers = array(), $referer='') {
  311. if (function_exists('curl_version')) {
  312. return curl_post($url, $data, $headers, $referer);
  313. } else {
  314. return post_request($url, $data, $headers, $referer);
  315. }
  316. }
  317. if (function_exists('curl_version')) :
  318. // Curl Post
  319. function curl_post($url, $data, $headers = array(), $referer='') {
  320. // Initiate cURL
  321. $curlReq = curl_init($url);
  322. // As post request
  323. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST");
  324. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  325. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  326. if(localURL($url)){
  327. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  328. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  329. }
  330. // Format Data
  331. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  332. case 'application/json':
  333. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  334. break;
  335. case 'application/x-www-form-urlencoded':
  336. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  337. break;
  338. default:
  339. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  340. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  341. }
  342. // Format Headers
  343. $cHeaders = array();
  344. foreach ($headers as $k => $v) {
  345. $cHeaders[] = $k.': '.$v;
  346. }
  347. if (count($cHeaders)) {
  348. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  349. }
  350. // Execute
  351. $result = curl_exec($curlReq);
  352. $httpcode = curl_getinfo($curlReq);
  353. // Close
  354. curl_close($curlReq);
  355. // Return
  356. return array('content'=>$result, 'http_code'=>$httpcode);
  357. }
  358. //Curl Get Function
  359. function curl_get($url, $headers = array()) {
  360. // Initiate cURL
  361. $curlReq = curl_init($url);
  362. // As post request
  363. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET");
  364. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  365. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  366. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  367. if(localURL($url)){
  368. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  369. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  370. }
  371. // Format Headers
  372. $cHeaders = array();
  373. foreach ($headers as $k => $v) {
  374. $cHeaders[] = $k.': '.$v;
  375. }
  376. if (count($cHeaders)) {
  377. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  378. }
  379. // Execute
  380. $result = curl_exec($curlReq);
  381. // Close
  382. curl_close($curlReq);
  383. // Return
  384. return $result;
  385. }
  386. //Curl Delete Function
  387. function curl_delete($url, $headers = array()) {
  388. // Initiate cURL
  389. $curlReq = curl_init($url);
  390. // As post request
  391. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE");
  392. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  393. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  394. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  395. if(localURL($url)){
  396. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  397. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  398. }
  399. // Format Headers
  400. $cHeaders = array();
  401. foreach ($headers as $k => $v) {
  402. $cHeaders[] = $k.': '.$v;
  403. }
  404. if (count($cHeaders)) {
  405. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  406. }
  407. // Execute
  408. $result = curl_exec($curlReq);
  409. $httpcode = curl_getinfo($curlReq);
  410. // Close
  411. curl_close($curlReq);
  412. // Return
  413. return array('content'=>$result, 'http_code'=>$httpcode);
  414. }
  415. endif;
  416. //Case-Insensitive Function
  417. function in_arrayi($needle, $haystack) {
  418. return in_array(strtolower($needle), array_map('strtolower', $haystack));
  419. }
  420. // HTTP post request (Removes need for curl, probably useless)
  421. function post_request($url, $data, $headers = array(), $referer='') {
  422. // Adapted from http://stackoverflow.com/a/28387011/6810513
  423. // Convert the data array into URL Parameters like a=b&foo=bar etc.
  424. if (isset($headers['Content-Type'])) {
  425. switch ($headers['Content-Type']) {
  426. case 'application/json':
  427. $data = json_encode($data);
  428. break;
  429. case 'application/x-www-form-urlencoded':
  430. $data = http_build_query($data);
  431. break;
  432. }
  433. } else {
  434. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  435. $data = http_build_query($data);
  436. }
  437. // parse the given URL
  438. $urlDigest = parse_url($url);
  439. // extract host and path:
  440. $host = $urlDigest['host'];
  441. $path = $urlDigest['path'];
  442. if ($urlDigest['scheme'] != 'http') {
  443. die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')');
  444. }
  445. // open a socket connection on port 80 - timeout: 30 sec
  446. $fp = fsockopen($host, (isset($urlDigest['port'])?':'.$urlDigest['port']:80), $errno, $errstr, 30);
  447. if ($fp){
  448. // send the request headers:
  449. fputs($fp, "POST $path HTTP/1.1\r\n");
  450. fputs($fp, "Host: $host\r\n");
  451. if ($referer != '')
  452. fputs($fp, "Referer: $referer\r\n");
  453. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  454. foreach($headers as $k => $v) {
  455. fputs($fp, $k.": ".$v."\r\n");
  456. }
  457. fputs($fp, "Connection: close\r\n\r\n");
  458. fputs($fp, $data);
  459. $result = '';
  460. while(!feof($fp)) {
  461. // receive the results of the request
  462. $result .= fgets($fp, 128);
  463. }
  464. }
  465. else {
  466. return array(
  467. 'status' => 'err',
  468. 'error' => "$errstr ($errno)"
  469. );
  470. }
  471. // close the socket connection:
  472. fclose($fp);
  473. // split the result header from the content
  474. $result = explode("\r\n\r\n", $result, 2);
  475. $header = isset($result[0]) ? $result[0] : '';
  476. $content = isset($result[1]) ? $result[1] : '';
  477. // return as structured array:
  478. return array(
  479. 'status' => 'ok',
  480. 'header' => $header,
  481. 'content' => $content,
  482. );
  483. }
  484. // Format item from Emby for Carousel
  485. function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $moreInfo = false) {
  486. // Static Height
  487. $height = 444;
  488. // Get Item Details
  489. $itemDetails = json_decode(file_get_contents($address.'/Items?Ids='.$item['Id'].'&api_key='.$token),true)['Items'][0];
  490. /*if (substr_count(EMBYURL, ':') == 2) {
  491. $URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  492. }else{
  493. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  494. }*/
  495. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  496. switch ($itemDetails['Type']) {
  497. case 'Episode':
  498. $title = (isset($itemDetails['SeriesName'])?$itemDetails['SeriesName']:"");
  499. $imageId = (isset($itemDetails['SeriesId'])?$itemDetails['SeriesId']:$itemDetails['Id']);
  500. $width = 300;
  501. $style = '';
  502. $image = 'slick-image-tall';
  503. if(!$nowPlaying){
  504. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  505. $key = $itemDetails['Id'] . "-list";
  506. }else{
  507. $height = 281;
  508. $width = 500;
  509. $imageId = isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId'] : (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  510. $imageType = isset($itemDetails['ParentThumbItemId']) ? "Thumb" : (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  511. $key = (isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId']."-np" : "none-np");
  512. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  513. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  514. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  515. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  516. $stream = $moreInfo['PlayState']['PlayMethod'];
  517. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  518. $id = $moreInfo['DeviceId'];
  519. $streamInfo = buildStream(array(
  520. 'platform' => (string) $moreInfo['Client'],
  521. 'device' => (string) $moreInfo['DeviceName'],
  522. 'stream' => streamType($stream),
  523. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  524. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  525. ));
  526. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  527. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$itemDetails['Name'].'</h5>';
  528. $bottomTitle = '<small class="zero-m">S'.$itemDetails['ParentIndexNumber'].' · E'.$itemDetails['IndexNumber'].'</small>';
  529. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  530. }
  531. break;
  532. case 'MusicAlbum':
  533. case 'Audio':
  534. $title = $itemDetails['Name'];
  535. $imageId = $itemDetails['Id'];
  536. $width = 444;
  537. $style = '';
  538. $image = 'slick-image-short';
  539. if(!$nowPlaying){
  540. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  541. $key = $itemDetails['Id'] . "-list";
  542. }else{
  543. $height = 281;
  544. $width = 500;
  545. $imageId = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  546. $imageType = (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  547. $key = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : "no-np") . "-np";
  548. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  549. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  550. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  551. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  552. $stream = $moreInfo['PlayState']['PlayMethod'];
  553. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  554. $id = $moreInfo['DeviceId'];
  555. $streamInfo = buildStream(array(
  556. 'platform' => (string) $moreInfo['Client'],
  557. 'device' => (string) $moreInfo['DeviceName'],
  558. 'stream' => streamType($stream),
  559. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  560. ));
  561. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  562. $topTitle = '<h5 class="text-center zero-m elip">'.$itemDetails['AlbumArtist'].' - '.$itemDetails['Album'].'</h5>';
  563. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  564. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  565. }
  566. break;
  567. case 'TvChannel':
  568. $title = $itemDetails['CurrentProgram']['Name'];
  569. $imageId = $itemDetails['Id'];
  570. $width = 300;
  571. $style = '';
  572. $image = 'slick-image-tall';
  573. if(!$nowPlaying){
  574. $imageType = "Primary";
  575. $key = $itemDetails['Id'] . "-list";
  576. }else{
  577. $height = 281;
  578. $width = 500;
  579. $imageType = "Thumb";
  580. $key = $itemDetails['Id'] . "-np";
  581. $useImage = "images/livetv.png";
  582. $watched = "0";
  583. $stream = $moreInfo['PlayState']['PlayMethod'];
  584. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  585. $id = $moreInfo['DeviceId'];
  586. $streamInfo = buildStream(array(
  587. 'platform' => (string) $moreInfo['Client'],
  588. 'device' => (string) $moreInfo['DeviceName'],
  589. 'stream' => streamType($stream),
  590. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  591. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  592. ));
  593. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  594. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  595. $bottomTitle = '<small class="zero-m">'.$itemDetails['Name'].' - '.$itemDetails['ChannelNumber'].'</small>';
  596. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  597. }
  598. break;
  599. default:
  600. $title = $itemDetails['Name'];
  601. $imageId = $itemDetails['Id'];
  602. $width = 300;
  603. $style = '';
  604. $image = 'slick-image-tall';
  605. if(!$nowPlaying){
  606. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  607. $key = $itemDetails['Id'] . "-list";
  608. }else{
  609. $height = 281;
  610. $width = 500;
  611. $imageType = isset($itemDetails['ImageTags']['Thumb']) ? "Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
  612. $key = $itemDetails['Id'] . "-np";
  613. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  614. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  615. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  616. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  617. $stream = $moreInfo['PlayState']['PlayMethod'];
  618. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  619. $id = $moreInfo['DeviceId'];
  620. $streamInfo = buildStream(array(
  621. 'platform' => (string) $moreInfo['Client'],
  622. 'device' => (string) $moreInfo['DeviceName'],
  623. 'stream' => streamType($stream),
  624. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  625. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  626. ));
  627. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  628. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  629. $bottomTitle = '<small class="zero-m">'.$moreInfo['NowPlayingItem']['ProductionYear'].'</small>';
  630. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  631. }
  632. }
  633. // If No Overview
  634. if (!isset($itemDetails['Overview'])) {
  635. $itemDetails['Overview'] = '';
  636. }
  637. $original_image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  638. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  639. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  640. $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'';
  641. }
  642. if($nowPlaying){
  643. if(!$imageType){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  644. if(!$imageId){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  645. }else{
  646. if(!$imageType){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  647. if(!$imageId){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  648. }
  649. if(isset($useImage)){ $image_url = $useImage; }
  650. // Assemble Item And Cache Into Array
  651. if($nowPlaying){
  652. //prettyPrint($itemDetails);
  653. 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="refreshNP 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'].'" original-image="'.$original_image_url.'" class="refreshImageSource"></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>';
  654. }else{
  655. return '<div class="item-'.$itemDetails['Type'].'"><div class="ultra-widget refreshImage"><span class="w-refresh w-p-icon gray"><span class="fa-stack fa-lg" style="font-size: .4em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-refresh fa-stack-1x fa-inverse"></i></span></span></div><a href="'.$URL.'" target="_blank"><img alt="'.$itemDetails['Name'].'" class="'.$image.' refreshImageSource" data-lazy="'.$image_url.'" original-image="'.$original_image_url.'"></a><small class="elip slick-bottom-title">'.$title.'</small></div>';
  656. }
  657. }
  658. // Format item from Plex for Carousel
  659. function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $playlist = false) {
  660. // Static Height
  661. $height = 444;
  662. $widthOverride = 100;
  663. $playlist = ($playlist) ? " playlist-$playlist" : "";
  664. switch ($item['type']) {
  665. case 'season':
  666. $title = $item['parentTitle'];
  667. $summary = $item['parentSummary'];
  668. $width = 300;
  669. $image = 'slick-image-tall';
  670. $style = '';
  671. if(!$nowPlaying){
  672. $thumb = $item['thumb'];
  673. $key = $item['ratingKey'] . "-list";
  674. }else {
  675. $height = 281;
  676. $width = 500;
  677. $thumb = $item['art'];
  678. $key = $item['ratingKey'] . "-np";
  679. $elapsed = $item['viewOffset'];
  680. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  681. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  682. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  683. $stream = $item->Media->Part->Stream['decision'];
  684. $user = $role == "admin" ? $item->User['title'] : "";
  685. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  686. $streamInfo = buildStream(array(
  687. 'platform' => (string) $item->Player['platform'],
  688. 'device' => (string) $item->Player['device'],
  689. 'stream' => streamType($item->Media->Part['decision']),
  690. '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'].")",
  691. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  692. ));
  693. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  694. }
  695. break;
  696. case 'episode':
  697. $title = $item['grandparentTitle'];
  698. $summary = $item['title'];
  699. $width = 300;
  700. $image = 'slick-image-tall';
  701. $style = '';
  702. if(!$nowPlaying){
  703. $thumb = ($item['parentThumb'] ? $item['parentThumb'] : $item['grandparentThumb']);
  704. $key = $item['ratingKey'] . "-list";
  705. }else {
  706. $height = 281;
  707. $width = 500;
  708. $thumb = $item['art'];
  709. $key = $item['ratingKey'] . "-np";
  710. $elapsed = $item['viewOffset'];
  711. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  712. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  713. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  714. $stream = $item->Media->Part->Stream['decision'];
  715. $user = $role == "admin" ? $item->User['title'] : "";
  716. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  717. $streamInfo = buildStream(array(
  718. 'platform' => (string) $item->Player['platform'],
  719. 'device' => (string) $item->Player['device'],
  720. 'stream' => streamType($item->Media->Part['decision']),
  721. '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'].")",
  722. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  723. ));
  724. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  725. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$item['title'].'</h5>';
  726. $bottomTitle = '<small class="zero-m">S'.$item['parentIndex'].' · E'.$item['index'].'</small>';
  727. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  728. }
  729. break;
  730. case 'clip':
  731. $title = $item['title'];
  732. $summary = $item['summary'];
  733. $width = 300;
  734. $image = 'slick-image-tall';
  735. $style = '';
  736. if(!$nowPlaying){
  737. $thumb = $item['thumb'];
  738. $key = $item['ratingKey'] . "-list";
  739. }else {
  740. $height = 281;
  741. $width = 500;
  742. $thumb = $item['art'];
  743. $key = isset($item['ratingKey']) ? $item['ratingKey'] . "-np" : (isset($item['live']) ? "livetv.png" : ":)");
  744. $useImage = (isset($item['live']) ? "images/livetv.png" : null);
  745. $extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
  746. $elapsed = $item['viewOffset'];
  747. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  748. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  749. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  750. $stream = $item->Media->Part->Stream['decision'];
  751. $user = $role == "admin" ? $item->User['title'] : "";
  752. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  753. $streamInfo = buildStream(array(
  754. 'platform' => (string) $item->Player['platform'],
  755. 'device' => (string) $item->Player['device'],
  756. 'stream' => streamType($item->Media->Part['decision']),
  757. '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'].")",
  758. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  759. ));
  760. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  761. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  762. $bottomTitle = '<small class="zero-m">'.$extraInfo.'</small>';
  763. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  764. }
  765. break;
  766. case 'album':
  767. case 'track':
  768. $title = $item['parentTitle'];
  769. $summary = $item['title'];
  770. $image = 'slick-image-short';
  771. $style = 'left: 160px !important;';
  772. $item['ratingKey'] = $item['parentRatingKey'];
  773. if(!$nowPlaying){
  774. $width = 444;
  775. $thumb = $item['thumb'];
  776. $key = $item['ratingKey'] . "-list";
  777. }else {
  778. $height = 281;
  779. $width = 500;
  780. $thumb = ($item['art']) ? $item['art'] : $item['parentThumb'];
  781. $widthOverride = ($item['art']) ? 100 : 56;
  782. $key = $item['ratingKey'] . "-np";
  783. $elapsed = $item['viewOffset'];
  784. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  785. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  786. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  787. $stream = $item->Media->Part->Stream['decision'];
  788. $user = $role == "admin" ? $item->User['title'] : "";
  789. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  790. $streamInfo = buildStream(array(
  791. 'platform' => (string) $item->Player['platform'],
  792. 'device' => (string) $item->Player['device'],
  793. 'stream' => streamType($item->Media->Part['decision']),
  794. 'audio' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['channels']."ch)",
  795. ));
  796. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  797. $topTitle = '<h5 class="text-center zero-m elip">'.$item['grandparentTitle'].' - '.$item['title'].'</h5>';
  798. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  799. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  800. }
  801. break;
  802. default:
  803. $title = $item['title'];
  804. $summary = $item['summary'];
  805. $image = 'slick-image-tall';
  806. $style = '';
  807. if(!$nowPlaying){
  808. $width = 300;
  809. $thumb = $item['thumb'];
  810. $key = $item['ratingKey'] . "-list";
  811. }else {
  812. $height = 281;
  813. $width = 500;
  814. $thumb = $item['art'];
  815. $key = $item['ratingKey'] . "-np";
  816. $elapsed = $item['viewOffset'];
  817. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  818. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  819. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  820. $stream = $item->Media->Part->Stream['decision'];
  821. $user = $role == "admin" ? $item->User['title'] : "";
  822. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  823. $streamInfo = buildStream(array(
  824. 'platform' => (string) $item->Player['platform'],
  825. 'device' => (string) $item->Player['device'],
  826. 'stream' => streamType($item->Media->Part['decision']),
  827. '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'].")",
  828. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  829. ));
  830. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  831. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  832. $bottomTitle = '<small class="zero-m">'.$item['year'].'</small>';
  833. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  834. }
  835. }
  836. if (PLEXTABURL) {
  837. $address = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  838. }else{
  839. $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  840. }
  841. // If No Overview
  842. if (!isset($itemDetails['Overview'])) { $itemDetails['Overview'] = ''; }
  843. $original_image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  844. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  845. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  846. $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'';
  847. }
  848. if($nowPlaying){
  849. if(!$thumb){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  850. }else{
  851. if(!$thumb){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  852. }
  853. if(isset($useImage)){ $image_url = $useImage; }
  854. $openTab = (PLEXTABNAME) ? "true" : "false";
  855. // Assemble Item And Cache Into Array
  856. if($nowPlaying){
  857. 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="refreshNP 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><div class="ultra-widget refreshImage"><span class="w-refresh w-p-icon gray"><span class="fa-stack fa-lg" style="font-size: .4em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-refresh fa-stack-1x fa-inverse"></i></span></span></div><a class="openTab" extraTitle="'.$title.'" extraType="'.$item['type'].'" openTab="'.$openTab.'" href="'.$address.'" target="_blank"><img class="refreshImageSource" style="width: '.$widthOverride.'%; display:block;" src="'.$image_url.'" original-image="'.$original_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>';
  858. }else{
  859. return '<div class="item-'.$item['type'].$playlist.'"><div style="" class="ultra-widget refreshImage"><span class="w-refresh w-p-icon gray"><span class="fa-stack fa-lg" style="font-size: .4em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-refresh fa-stack-1x fa-inverse"></i></span></span></div><a class="openTab" extraTitle="'.$title.'" extraType="'.$item['type'].'" openTab="'.$openTab.'" href="'.$address.'" target="_blank"><img alt="'.$item['Name'].'" class="'.$image.' refreshImageSource" data-lazy="'.$image_url.'" original-image="'.$original_image_url.'"></a><small class="elip slick-bottom-title">'.$title.'</small></div>';
  860. }
  861. }
  862. //$hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  863. //Recent Added
  864. function outputRecentAdded($header, $items, $script = false, $array) {
  865. $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">';
  866. if(preg_grep("/item-movie/", $items)){
  867. $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>';
  868. }
  869. if(preg_grep("/item-season/", $items)){
  870. $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>';
  871. }
  872. if(preg_grep("/item-album/", $items)){
  873. $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>';
  874. }
  875. $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>';
  876. $hideMenu .= '</ul></div></div>';
  877. // If None Populate Empty Item
  878. if (!count($items)) {
  879. 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>';
  880. }else{
  881. $className = str_replace(' ', '', $header);
  882. 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>':'');
  883. }
  884. }
  885. // Create Carousel
  886. function outputNowPlaying($header, $size, $type, $items, $script = false) {
  887. // If None Populate Empty Item
  888. if (!count($items)) {
  889. return '<div id=streamz></div>'.($script?'<script>'.$script.'</script>':'');
  890. }else{
  891. return '<div id=streamz><h5 class="zero-m big-box"><strong>'.$header.'</strong></h5>'.implode('',$items).'</div>'.($script?'<script>'.$script.'</script>':'');
  892. }
  893. }
  894. // Get Now Playing Streams From Emby
  895. function getEmbyStreams($size, $showNames, $role) {
  896. $address = qualifyURL(EMBYURL);
  897. $api = json_decode(@file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
  898. if (!is_array($api)) { return 'Could not load!'; }
  899. $playingItems = array();
  900. foreach($api as $key => $value) {
  901. if (isset($value['NowPlayingItem'])) {
  902. $playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem'], true, $showNames, $role, $value);
  903. }
  904. }
  905. return outputNowPlaying(translate('PLAYING_NOW_ON_EMBY'), $size, 'streams-emby', $playingItems, "
  906. setInterval(function() {
  907. $('<div></div>').load('ajax.php?a=emby-streams',function() {
  908. var element = $(this).find('[id]');
  909. var loadedID = element.attr('id');
  910. $('#'+loadedID).replaceWith(element);
  911. console.log('Loaded updated: '+loadedID);
  912. });
  913. }, ".NOWPLAYINGREFRESH.");
  914. ");
  915. }
  916. // Get Now Playing Streams From Plex
  917. function getPlexStreams($size, $showNames, $role){
  918. $address = qualifyURL(PLEXURL);
  919. // Perform API requests
  920. $api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
  921. libxml_use_internal_errors(true);
  922. $api = simplexml_load_string($api);
  923. if (is_array($api) || is_object($api)){
  924. if (!$api->head->title){
  925. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  926. if (!$getServer) { return 'Could not load!'; }
  927. // Identify the local machine
  928. $gotServer = $getServer['machineIdentifier'];
  929. $items = array();
  930. foreach($api AS $child) {
  931. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
  932. }
  933. return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." ( ".count($items)." Streams )", $size, 'streams-plex', $items, "
  934. setInterval(function() {
  935. $('<div></div>').load('ajax.php?a=plex-streams',function() {
  936. var element = $(this).find('[id]');
  937. var loadedID = element.attr('id');
  938. $('#'+loadedID).replaceWith(element);
  939. console.log('Loaded updated: '+loadedID);
  940. });
  941. }, ".NOWPLAYINGREFRESH.");
  942. ");
  943. }else{
  944. writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
  945. }
  946. }else{
  947. writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
  948. }
  949. }
  950. // Get Recent Content From Emby
  951. function getEmbyRecent($array) {
  952. $address = qualifyURL(EMBYURL);
  953. $header = translate('RECENT_CONTENT');
  954. // Currently Logged In User
  955. $username = false;
  956. if (isset($GLOBALS['USER'])) {
  957. $username = strtolower($GLOBALS['USER']->username);
  958. }
  959. // Get A User
  960. $userIds = json_decode(@file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
  961. if (!is_array($userIds)) { return 'Could not load!'; }
  962. $showPlayed = true;
  963. foreach ($userIds as $value) { // Scan for admin user
  964. if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
  965. $userId = $value['Id'];
  966. }
  967. if ($username && strtolower($value['Name']) == $username) {
  968. $userId = $value['Id'];
  969. $showPlayed = false;
  970. break;
  971. }
  972. }
  973. // Get the latest Items
  974. $latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?EnableImages=false&Limit='.EMBYRECENTITEMS.'&api_key='.EMBYTOKEN.($showPlayed?'':'&IsPlayed=false')),true);
  975. // For Each Item In Category
  976. $items = array();
  977. foreach ($latest as $k => $v) {
  978. $type = (string) $v['Type'];
  979. if(@$array[$type] == "true"){
  980. $items[] = resolveEmbyItem($address, EMBYTOKEN, $v, false, false, false);
  981. }
  982. }
  983. $array["movie"] = $array["Movie"];
  984. $array["season"] = $array["Episode"];
  985. $array["album"] = $array["MusicAlbum"];
  986. unset($array["Movie"]);
  987. unset($array["Episode"]);
  988. unset($array["MusicAlbum"]);
  989. unset($array["Series"]);
  990. return outputRecentAdded($header, $items, "
  991. setInterval(function() {
  992. $('<div></div>').load('ajax.php?a=emby-recent',function() {
  993. var element = $(this).find('#recentMedia');
  994. var loadedID = element.attr('id');
  995. $('#recentMedia').replaceWith(element);
  996. console.log('Loaded recent: '+loadedID);
  997. loadSlick();
  998. });
  999. }, ".RECENTREFRESH.");
  1000. ", $array);
  1001. }
  1002. // Get Recent Content From Plex
  1003. function getPlexRecent($array){
  1004. $address = qualifyURL(PLEXURL);
  1005. $header = translate('RECENT_CONTENT');
  1006. // Perform Requests
  1007. $api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN);
  1008. libxml_use_internal_errors(true);
  1009. $api = simplexml_load_string($api);
  1010. if (is_array($api) || is_object($api)){
  1011. if (!$api->head->title){
  1012. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  1013. if (!$getServer) { return 'Could not load!'; }
  1014. // Identify the local machine
  1015. $gotServer = $getServer['machineIdentifier'];
  1016. $items = array();
  1017. foreach($api AS $child) {
  1018. $type = (string) $child['type'];
  1019. if($array[$type] == "true"){
  1020. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
  1021. }
  1022. }
  1023. return outputRecentAdded($header, $items, "
  1024. setInterval(function() {
  1025. $('<div></div>').load('ajax.php?a=plex-recent',function() {
  1026. var element = $(this).find('#recentMedia');
  1027. var loadedID = element.attr('id');
  1028. $('#recentMedia').replaceWith(element);
  1029. console.log('Loaded recent: '+loadedID);
  1030. loadSlick();
  1031. });
  1032. }, ".RECENTREFRESH.");
  1033. ", $array);
  1034. }else{
  1035. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check token - if HTTPS, is cert valid");
  1036. }
  1037. }else{
  1038. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check URL - if HTTPS, is cert valid");
  1039. }
  1040. }
  1041. // Get Image From Emby
  1042. function getEmbyImage() {
  1043. $refresh = false;
  1044. $embyAddress = qualifyURL(EMBYURL);
  1045. if (!file_exists('images/cache')) {
  1046. mkdir('images/cache', 0777, true);
  1047. }
  1048. $itemId = $_GET['img'];
  1049. $key = $_GET['key'];
  1050. if(strpos($key, '$') !== false){
  1051. $key = explode('$', $key)[0];
  1052. $refresh = true;
  1053. }
  1054. $itemType = $_GET['type'];
  1055. $imgParams = array();
  1056. if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
  1057. if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
  1058. if(isset($itemId)) {
  1059. $image_src = $embyAddress . '/Items/'.$itemId.'/Images/'.$itemType.'?'.implode('&', $imgParams);
  1060. $cachefile = 'images/cache/'.$key.'.jpg';
  1061. $cachetime = 604800;
  1062. // Serve from the cache if it is younger than $cachetime
  1063. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh !== true) {
  1064. header("Content-type: image/jpeg");
  1065. @readfile($cachefile);
  1066. exit;
  1067. }
  1068. ob_start(); // Start the output buffer
  1069. header('Content-type: image/jpeg');
  1070. @readfile($image_src);
  1071. // Cache the output to a file
  1072. $fp = fopen($cachefile, 'wb');
  1073. fwrite($fp, ob_get_contents());
  1074. fclose($fp);
  1075. ob_end_flush(); // Send the output to the browser
  1076. die();
  1077. } else {
  1078. debug_out('Invalid Request',1);
  1079. }
  1080. }
  1081. // Get Image From Plex
  1082. function getPlexImage() {
  1083. $refresh = false;
  1084. $plexAddress = qualifyURL(PLEXURL);
  1085. if (!file_exists('images/cache')) {
  1086. mkdir('images/cache', 0777, true);
  1087. }
  1088. $image_url = $_GET['img'];
  1089. $key = $_GET['key'];
  1090. if(strpos($key, '$') !== false){
  1091. $key = explode('$', $key)[0];
  1092. $refresh = true;
  1093. }
  1094. $image_height = $_GET['height'];
  1095. $image_width = $_GET['width'];
  1096. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  1097. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  1098. $cachefile = 'images/cache/'.$key.'.jpg';
  1099. $cachetime = 604800;
  1100. // Serve from the cache if it is younger than $cachetime
  1101. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh == false) {
  1102. header("Content-type: image/jpeg");
  1103. @readfile($cachefile);
  1104. exit;
  1105. }
  1106. ob_start(); // Start the output buffer
  1107. header('Content-type: image/jpeg');
  1108. @readfile($image_src);
  1109. // Cache the output to a file
  1110. $fp = fopen($cachefile, 'wb');
  1111. fwrite($fp, ob_get_contents());
  1112. fclose($fp);
  1113. ob_end_flush(); // Send the output to the browser
  1114. die();
  1115. } else {
  1116. echo "Invalid Plex Request";
  1117. }
  1118. }
  1119. // Simplier access to class
  1120. function translate($string) {
  1121. if (isset($GLOBALS['language'])) {
  1122. return $GLOBALS['language']->translate($string);
  1123. } else {
  1124. return '!Translations Not Loaded!';
  1125. }
  1126. }
  1127. // Generate Random string
  1128. function randString($length = 10, $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  1129. $tmp = '';
  1130. for ($i = 0; $i < $length; $i++) {
  1131. $tmp .= substr(str_shuffle($chars), 0, 1);
  1132. }
  1133. return $tmp;
  1134. }
  1135. // Create config file in the return syntax
  1136. function createConfig($array, $path = 'config/config.php', $nest = 0) {
  1137. // Define Initial Value
  1138. $output = array();
  1139. // Sort Items
  1140. ksort($array);
  1141. // Update the current config version
  1142. if (!$nest) {
  1143. // Inject Current Version
  1144. $output[] = "\t'CONFIG_VERSION' => '".(isset($array['apply_CONFIG_VERSION'])?$array['apply_CONFIG_VERSION']:INSTALLEDVERSION)."'";
  1145. }
  1146. unset($array['CONFIG_VERSION']);
  1147. unset($array['apply_CONFIG_VERSION']);
  1148. // Process Settings
  1149. foreach ($array as $k => $v) {
  1150. $allowCommit = true;
  1151. switch (gettype($v)) {
  1152. case 'boolean':
  1153. $item = ($v?'true':'false');
  1154. break;
  1155. case 'integer':
  1156. case 'double':
  1157. case 'integer':
  1158. case 'NULL':
  1159. $item = $v;
  1160. break;
  1161. case 'string':
  1162. $item = "'".str_replace(array('\\',"'"),array('\\\\',"\'"),$v)."'";
  1163. break;
  1164. case 'array':
  1165. $item = createConfig($v, false, $nest+1);
  1166. break;
  1167. default:
  1168. $allowCommit = false;
  1169. }
  1170. if($allowCommit) {
  1171. $output[] = str_repeat("\t",$nest+1)."'$k' => $item";
  1172. }
  1173. }
  1174. // Build output
  1175. $output = (!$nest?"<?php\nreturn ":'')."array(\n".implode(",\n",$output)."\n".str_repeat("\t",$nest).')'.(!$nest?';':'');
  1176. if (!$nest && $path) {
  1177. $pathDigest = pathinfo($path);
  1178. @mkdir($pathDigest['dirname'], 0770, true);
  1179. if (file_exists($path)) {
  1180. rename($path, $pathDigest['dirname'].'/'.$pathDigest['filename'].'.bak.php');
  1181. }
  1182. $file = fopen($path, 'w');
  1183. fwrite($file, $output);
  1184. fclose($file);
  1185. if (file_exists($path)) {
  1186. return true;
  1187. }
  1188. writeLog("error", "config was unable to write");
  1189. return false;
  1190. } else {
  1191. writeLog("success", "config was updated with new values");
  1192. return $output;
  1193. }
  1194. }
  1195. // Load a config file written in the return syntax
  1196. function loadConfig($path = 'config/config.php') {
  1197. // Adapted from http://stackoverflow.com/a/14173339/6810513
  1198. if (!is_file($path)) {
  1199. return null;
  1200. } else {
  1201. return (array) call_user_func(function() use($path) {
  1202. return include($path);
  1203. });
  1204. }
  1205. }
  1206. // Commit new values to the configuration
  1207. function updateConfig($new, $current = false) {
  1208. // Get config if not supplied
  1209. if ($current === false) {
  1210. $current = loadConfig();
  1211. } else if (is_string($current) && is_file($current)) {
  1212. $current = loadConfig($current);
  1213. }
  1214. // Inject Parts
  1215. foreach ($new as $k => $v) {
  1216. $current[$k] = $v;
  1217. }
  1218. // Return Create
  1219. return createConfig($current);
  1220. }
  1221. // Inject Defaults As Needed
  1222. function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
  1223. if (is_string($path)) {
  1224. $loadedDefaults = loadConfig($path);
  1225. } else {
  1226. $loadedDefaults = $path;
  1227. }
  1228. return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
  1229. }
  1230. // support function for fillDefaultConfig()
  1231. function fillDefaultConfig_recurse($current, $defaults) {
  1232. foreach($defaults as $k => $v) {
  1233. if (!isset($current[$k])) {
  1234. $current[$k] = $v;
  1235. } else if (is_array($current[$k]) && is_array($v)) {
  1236. $current[$k] = fillDefaultConfig_recurse($current[$k], $v);
  1237. }
  1238. }
  1239. return $current;
  1240. };
  1241. // Define Scalar Variables (nest non-secular with underscores)
  1242. function defineConfig($array, $anyCase = true, $nest_prefix = false) {
  1243. foreach($array as $k => $v) {
  1244. if (is_scalar($v) && !defined($nest_prefix.$k)) {
  1245. define($nest_prefix.$k, $v, $anyCase);
  1246. } else if (is_array($v)) {
  1247. defineConfig($v, $anyCase, $nest_prefix.$k.'_');
  1248. }
  1249. }
  1250. }
  1251. // This function exists only because I am lazy
  1252. function configLazy($path = 'config/config.php') {
  1253. // Load config or default
  1254. if (file_exists($path)) {
  1255. $config = fillDefaultConfig(loadConfig($path));
  1256. } else {
  1257. $config = loadConfig('config/configDefaults.php');
  1258. }
  1259. if (is_array($config)) {
  1260. defineConfig($config);
  1261. }
  1262. return $config;
  1263. }
  1264. // Qualify URL
  1265. function qualifyURL($url) {
  1266. //local address?
  1267. if(substr($url, 0,1) == "/"){
  1268. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  1269. $protocol = "https://";
  1270. } else {
  1271. $protocol = "http://";
  1272. }
  1273. $url = $protocol.getServer().$url;
  1274. }
  1275. // Get Digest
  1276. $digest = parse_url($url);
  1277. // http/https
  1278. if (!isset($digest['scheme'])) {
  1279. if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096,32400,7878,8989,8182,8081,6789))) {
  1280. $scheme = 'http';
  1281. } else {
  1282. $scheme = 'https';
  1283. }
  1284. } else {
  1285. $scheme = $digest['scheme'];
  1286. }
  1287. // Host
  1288. $host = (isset($digest['host'])?$digest['host']:'');
  1289. // Port
  1290. $port = (isset($digest['port'])?':'.$digest['port']:'');
  1291. // Path
  1292. $path = (isset($digest['path'])?$digest['path']:'');
  1293. // Output
  1294. return $scheme.'://'.$host.$port.$path;
  1295. }
  1296. // Function to be called at top of each to allow upgrading environment as the spec changes
  1297. function upgradeCheck() {
  1298. // Upgrade to 1.31
  1299. if (file_exists('homepageSettings.ini.php')) {
  1300. $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
  1301. $homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
  1302. $databaseConfig = array_merge($databaseConfig, $homepageConfig);
  1303. $databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
  1304. foreach($databaseConfig as $k => $v) {
  1305. if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
  1306. $databaseData .= $k . " = \"" . $v . "\"\r\n";
  1307. }
  1308. write_ini_file($databaseData, 'databaseLocation.ini.php');
  1309. unlink('homepageSettings.ini.php');
  1310. unset($databaseData);
  1311. unset($homepageConfig);
  1312. }
  1313. // Upgrade to 1.32
  1314. if (file_exists('databaseLocation.ini.php')) {
  1315. // Load Existing
  1316. $config = parse_ini_file('databaseLocation.ini.php', true);
  1317. // Refactor
  1318. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['databaseLocation'].'/');
  1319. $config['user_home'] = $config['database_Location'].'users/';
  1320. unset($config['databaseLocation']);
  1321. // Turn Off Emby And Plex Recent
  1322. $config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
  1323. unset($config["embyPort"]);
  1324. $config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
  1325. unset($config["plexPort"]);
  1326. $config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
  1327. unset($config["nzbgetPort"]);
  1328. $config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
  1329. unset($config["sabnzbdPort"]);
  1330. $config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
  1331. unset($config["headphonesPort"]);
  1332. // Write config file
  1333. $config['CONFIG_VERSION'] = '1.32';
  1334. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][pre1.32].bak.php');
  1335. $createConfigSuccess = createConfig($config);
  1336. // Create new config
  1337. if ($createConfigSuccess) {
  1338. if (file_exists('config/config.php')) {
  1339. // Remove Old ini file
  1340. unlink('databaseLocation.ini.php');
  1341. } else {
  1342. debug_out('Something is not right here!');
  1343. }
  1344. } else {
  1345. debug_out('Couldn\'t create updated configuration.' ,1);
  1346. }
  1347. }
  1348. // Upgrade to 1.33
  1349. $config = loadConfig();
  1350. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
  1351. // Fix User Directory
  1352. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['database_Location'].'/');
  1353. $config['user_home'] = $config['database_Location'].'users/';
  1354. unset($config['USER_HOME']);
  1355. // Backend auth merge
  1356. if (isset($config['authBackendPort']) && !isset(parse_url($config['authBackendHost'])['port'])) {
  1357. $config['authBackendHost'] .= ':'.$config['authBackendPort'];
  1358. }
  1359. unset($config['authBackendPort']);
  1360. // If auth is being used move it to embyURL as that is now used in auth functions
  1361. 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')))) {
  1362. $config['embyURL'] = $config['authBackendHost'];
  1363. }
  1364. // Upgrade database to latest version
  1365. updateSQLiteDB($config['database_Location'],'1.32');
  1366. // Update Version and Commit
  1367. $config['apply_CONFIG_VERSION'] = '1.33';
  1368. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.32].bak.php');
  1369. $createConfigSuccess = createConfig($config);
  1370. unset($config);
  1371. }
  1372. // Upgrade to 1.34
  1373. $config = loadConfig();
  1374. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.34')) {
  1375. // Upgrade database to latest version
  1376. updateSQLiteDB($config['database_Location'],'1.33');
  1377. // Update Version and Commit
  1378. $config['CONFIG_VERSION'] = '1.34';
  1379. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.33].bak.php');
  1380. $createConfigSuccess = createConfig($config);
  1381. unset($config);
  1382. }
  1383. // Upgrade to 1.40
  1384. $config = loadConfig();
  1385. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.40')) {
  1386. // Upgrade database to latest version
  1387. updateSQLiteDB($config['database_Location'],'1.38');
  1388. // Update Version and Commit
  1389. $config['CONFIG_VERSION'] = '1.40';
  1390. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.38].bak.php');
  1391. $createConfigSuccess = createConfig($config);
  1392. unset($config);
  1393. }
  1394. // Upgrade to 1.50
  1395. $config = loadConfig();
  1396. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.50')) {
  1397. // Upgrade database to latest version
  1398. updateSQLiteDB($config['database_Location'],'1.40');
  1399. // Update Version and Commit
  1400. $config['CONFIG_VERSION'] = '1.50';
  1401. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.40].bak.php');
  1402. $createConfigSuccess = createConfig($config);
  1403. unset($config);
  1404. }
  1405. return true;
  1406. }
  1407. // Get OS from server
  1408. function getOS(){
  1409. if(PHP_SHLIB_SUFFIX == "dll"){
  1410. return "win";
  1411. }else{
  1412. return "nix";
  1413. }
  1414. }
  1415. //Get Error by Server OS
  1416. function getError($os, $error){
  1417. $ini = (!empty(php_ini_loaded_file()) ? php_ini_loaded_file() : "php.ini");
  1418. $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'");
  1419. $errors = array(
  1420. 'pdo_sqlite' => array(
  1421. 'win' => '<b>PDO:SQLite</b> not enabled, uncomment ;extension=php_pdo_sqlite.dll in the file php.ini | '.$ext,
  1422. 'nix' => '<b>PDO:SQLite</b> not enabled, PHP7 -> run sudo apt-get install php7.0-sqlite | PHP5 -> run sudo apt-get install php5-sqlite',
  1423. ),
  1424. 'sqlite3' => array(
  1425. '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',
  1426. 'nix' => '<b>SQLite3</b> not enabled, run sudo apt-get install php-sqlite3',
  1427. ),
  1428. 'curl' => array(
  1429. 'win' => '<b>cURL</b> not enabled, uncomment ;extension=php_curl.dll in the file php.ini | '.$ext,
  1430. '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',
  1431. ),
  1432. 'zip' => array(
  1433. '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',
  1434. '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',
  1435. ),
  1436. );
  1437. return (isset($errors[$error][$os]) ? $errors[$error][$os] : 'No Error Info Found');
  1438. }
  1439. // Check if all software dependancies are met
  1440. function dependCheck() {
  1441. $output = array();
  1442. $i = 1;
  1443. if (!extension_loaded('pdo_sqlite')) { $output["Step $i"] = getError(getOS(),'pdo_sqlite'); $i++; }
  1444. if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; }
  1445. if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; }
  1446. //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
  1447. if ($output) {
  1448. $output["Step $i"] = "<b>Restart PHP and/or Webserver to apply changes</b>"; $i++;
  1449. $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++;
  1450. debug_out($output,1);
  1451. }
  1452. return true;
  1453. }
  1454. // Process file uploads
  1455. function uploadFiles($path, $ext_mask = null) {
  1456. if (isset($_FILES) && count($_FILES)) {
  1457. require_once('class.uploader.php');
  1458. $uploader = new Uploader();
  1459. $data = $uploader->upload($_FILES['files'], array(
  1460. 'limit' => 10,
  1461. 'maxSize' => 10,
  1462. 'extensions' => $ext_mask,
  1463. 'required' => false,
  1464. 'uploadDir' => str_replace('//','/',$path.'/'),
  1465. 'title' => array('name'),
  1466. 'removeFiles' => true,
  1467. 'replace' => true,
  1468. ));
  1469. if($data['isComplete']){
  1470. $files = $data['data'];
  1471. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1472. echo json_encode($files['metas'][0]['name']);
  1473. }
  1474. if($data['hasErrors']){
  1475. $errors = $data['errors'];
  1476. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1477. echo json_encode($errors);
  1478. }
  1479. } else {
  1480. writeLog("error", "image was not uploaded");
  1481. echo json_encode('No files submitted!');
  1482. }
  1483. }
  1484. // Process file uploads
  1485. function uploadAvatar($path, $ext_mask = null) {
  1486. if (isset($_FILES) && count($_FILES)) {
  1487. require_once('class.uploader.php');
  1488. $uploader = new Uploader();
  1489. $data = $uploader->upload($_FILES['files'], array(
  1490. 'limit' => 10,
  1491. 'maxSize' => 10,
  1492. 'extensions' => $ext_mask,
  1493. 'required' => false,
  1494. 'uploadDir' => str_replace('//','/',$path.'/'),
  1495. 'title' => array('name'),
  1496. 'removeFiles' => true,
  1497. 'replace' => true,
  1498. ));
  1499. if($data['isComplete']){
  1500. $files = $data['data'];
  1501. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1502. echo json_encode($files['metas'][0]['name']);
  1503. }
  1504. if($data['hasErrors']){
  1505. $errors = $data['errors'];
  1506. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1507. echo json_encode($errors);
  1508. }
  1509. } else {
  1510. writeLog("error", "image was not uploaded");
  1511. echo json_encode('No files submitted!');
  1512. }
  1513. }
  1514. // Remove file
  1515. function removeFiles($path) {
  1516. if(is_file($path)) {
  1517. writeLog("success", "file was removed");
  1518. unlink($path);
  1519. } else {
  1520. writeLog("error", "file was not removed");
  1521. echo json_encode('No file specified for removal!');
  1522. }
  1523. }
  1524. // Lazy select options
  1525. function resolveSelectOptions($array, $selected = '', $multi = false) {
  1526. $output = array();
  1527. $selectedArr = ($multi?explode('|', $selected):array());
  1528. foreach ($array as $key => $value) {
  1529. if (is_array($value)) {
  1530. if (isset($value['optgroup'])) {
  1531. $output[] = '<optgroup label="'.$key.'">';
  1532. foreach($value['optgroup'] as $k => $v) {
  1533. $output[] = '<option value="'.$v['value'].'"'.($selected===$v['value']||in_array($v['value'],$selectedArr)?' selected':'').(isset($v['disabled']) && $v['disabled']?' disabled':'').'>'.$k.'</option>';
  1534. }
  1535. } else {
  1536. $output[] = '<option value="'.$value['value'].'"'.($selected===$value['value']||in_array($value['value'],$selectedArr)?' selected':'').(isset($value['disabled']) && $value['disabled']?' disabled':'').'>'.$key.'</option>';
  1537. }
  1538. } else {
  1539. $output[] = '<option value="'.$value.'"'.($selected===$value||in_array($value,$selectedArr)?' selected':'').'>'.$key.'</option>';
  1540. }
  1541. }
  1542. return implode('',$output);
  1543. }
  1544. // Check if user is allowed to continue
  1545. function qualifyUser($type, $errOnFail = false) {
  1546. if (!isset($GLOBALS['USER'])) {
  1547. require_once("user.php");
  1548. $GLOBALS['USER'] = new User('registration_callback');
  1549. }
  1550. if (is_bool($type)) {
  1551. if ($type === true) {
  1552. $authorized = ($GLOBALS['USER']->authenticated == true);
  1553. } else {
  1554. $authorized = true;
  1555. }
  1556. } elseif (is_string($type) || is_array($type)) {
  1557. if ($type !== 'false') {
  1558. if (!is_array($type)) {
  1559. $type = explode('|',$type);
  1560. }
  1561. $authorized = ($GLOBALS['USER']->authenticated && in_array($GLOBALS['USER']->role,$type));
  1562. } else {
  1563. $authorized = true;
  1564. }
  1565. } else {
  1566. debug_out('Invalid Syntax!',1);
  1567. }
  1568. if (!$authorized && $errOnFail) {
  1569. if ($GLOBALS['USER']->authenticated) {
  1570. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401');
  1571. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401\'</script>';
  1572. } else {
  1573. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999');
  1574. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999\'</script>';
  1575. }
  1576. debug_out('Not Authorized' ,1);
  1577. } else {
  1578. return $authorized;
  1579. }
  1580. }
  1581. // Build an (optionally) tabbed settings page.
  1582. function buildSettings($array) {
  1583. /*
  1584. array(
  1585. 'title' => '',
  1586. 'id' => '',
  1587. 'fields' => array( See buildField() ),
  1588. 'tabs' => array(
  1589. array(
  1590. 'title' => '',
  1591. 'id' => '',
  1592. 'image' => '',
  1593. 'fields' => array( See buildField() ),
  1594. ),
  1595. ),
  1596. );
  1597. */
  1598. $notifyExplode = explode("-", NOTIFYEFFECT);
  1599. $fieldFunc = function($fieldArr) {
  1600. $fields = '<div class="row">';
  1601. foreach($fieldArr as $key => $value) {
  1602. $isSingle = isset($value['type']);
  1603. if ($isSingle) { $value = array($value); }
  1604. $tmpField = '';
  1605. $sizeLg = max(floor(12/count($value)),2);
  1606. $sizeMd = max(floor(($isSingle?12:6)/count($value)),3);
  1607. foreach($value as $k => $v) {
  1608. $tmpField .= buildField($v, 12, $sizeMd, $sizeLg);
  1609. }
  1610. $fields .= ($isSingle?$tmpField:'<div class="row col-sm-12 content-form">'.$tmpField.'</div>');
  1611. }
  1612. $fields .= '</div>';
  1613. return $fields;
  1614. };
  1615. $fields = (isset($array['fields'])?$fieldFunc($array['fields']):'');
  1616. $tabSelectors = array();
  1617. $tabContent = array();
  1618. if (isset($array['tabs'])) {
  1619. foreach($array['tabs'] as $key => $value) {
  1620. $id = (isset($value['id'])?$value['id']:randString(32));
  1621. $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>';
  1622. $tabContent[$key] = '<div class="tab-pane big-box fade'.($tabContent?'':' active in').'" id="tab-'.$id.'">'.$fieldFunc($value['fields']).'</div>';
  1623. }
  1624. }
  1625. $pageID = (isset($array['id'])?$array['id']:str_replace(array(' ','"',"'"),array('_'),strtolower($array['id'])));
  1626. $extraClick = ($pageID == 'appearance_settings' ? "$('#advanced_settings_form_submit').click();console.log('add theme settings');" : "");
  1627. return '
  1628. <div class="email-body">
  1629. <div class="email-header gray-bg">
  1630. <button type="button" class="btn btn-danger btn-sm waves close-button"><i class="fa fa-close"></i></button>
  1631. <button id="'.$pageID.'_form_submit" class="btn waves btn-labeled btn-success btn btn-sm text-uppercase waves-effect waves-float save-btn-form">
  1632. <span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save
  1633. </button>
  1634. <h1>'.$array['title'].'</h1>
  1635. </div>
  1636. <div class="email-inner small-box">
  1637. <div class="email-inner-section">
  1638. <div class="small-box fade in" id="'.$pageID.'_frame">
  1639. <div class="col-lg-12">
  1640. '.(isset($array['customBeforeForm'])?$array['customBeforeForm']:'').'
  1641. <form class="content-form" name="'.$pageID.'" id="'.$pageID.'_form" onsubmit="return false;">
  1642. '.$fields.($tabContent?'
  1643. <div class="tabbable tabs-with-bg" id="'.$pageID.'_tabs">
  1644. <ul class="nav nav-tabs apps">
  1645. '.implode('', $tabSelectors).'
  1646. </ul>
  1647. <div class="clearfix"></div>
  1648. <div class="tab-content">
  1649. '.implode('', $tabContent).'
  1650. </div>
  1651. </div>':'').'
  1652. </form>
  1653. '.(isset($array['customAfterForm'])?$array['customAfterForm']:'').'
  1654. </div>
  1655. </div>
  1656. </div>
  1657. </div>
  1658. </div>
  1659. <script>
  1660. $(document).ready(function() {
  1661. $(\'#'.$pageID.'_form\').find(\'input, select, textarea\').on(\'change\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1662. var '.$pageID.'Validate = function() { if (this.value && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { $(this).addClass(\'invalid\'); } else { $(this).removeClass(\'invalid\'); } };
  1663. $(\'#'.$pageID.'_form\').find(\'input[pattern]\').each('.$pageID.'Validate).on(\'keyup\', '.$pageID.'Validate);
  1664. $(\'#'.$pageID.'_form\').find(\'select[multiple]\').on(\'change click\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1665. $(\'#'.$pageID.'_form_submit\').on(\'click\', function () {
  1666. var newVals = {};
  1667. var hasVals = false;
  1668. var errorFields = [];
  1669. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').each(function() {
  1670. hasVals = true;
  1671. if (this.type == \'checkbox\') {
  1672. newVals[this.name] = this.checked;
  1673. } else if ($(this).hasClass(\'summernote\')) {
  1674. newVals[$(this).attr(\'name\')] = $(this).siblings(\'.note-editor\').find(\'.panel-body\').html();
  1675. } else {
  1676. if (this.value && this.pattern && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { errorFields.push(this.name); }
  1677. var fieldVal = $(this).val();
  1678. if (typeof fieldVal == \'object\') {
  1679. if (typeof fieldVal.join == \'function\') {
  1680. fieldVal = fieldVal.join(\'|\');
  1681. } else {
  1682. fieldVal = JSON.stringify(fieldVal);
  1683. }
  1684. }
  1685. newVals[this.name] = fieldVal;
  1686. }
  1687. });
  1688. if (errorFields.length) {
  1689. parent.notify(\'Fields have errors: \'+errorFields.join(\', \')+\'!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1690. } else if (hasVals) {
  1691. console.log(newVals);
  1692. ajax_request(\'POST\', \''.(isset($array['submitAction'])?$array['submitAction']:'update-config').'\', newVals, function(data, code) {
  1693. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').removeAttr(\'data-changed\');
  1694. });
  1695. '.$extraClick.'
  1696. } else {
  1697. parent.notify(\'Nothing to update!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1698. }
  1699. return false;
  1700. });
  1701. '.(isset($array['onready'])?$array['onready']:'').'
  1702. });
  1703. </script>
  1704. ';
  1705. }
  1706. // Build Settings Fields
  1707. function buildField($params, $sizeSm = 12, $sizeMd = 12, $sizeLg = 12) {
  1708. /*
  1709. array(
  1710. 'type' => '',
  1711. 'placeholder' => '',
  1712. 'label' => '',
  1713. 'labelTranslate' => '',
  1714. 'assist' => '',
  1715. 'name' => '',
  1716. 'pattern' => '',
  1717. 'options' => array( // For SELECT only
  1718. 'Display' => 'value',
  1719. ),
  1720. )
  1721. */
  1722. // Tags
  1723. $tags = array();
  1724. foreach(array('placeholder','style','disabled','readonly','pattern','min','max','required','onkeypress','onchange','onfocus','onleave','href','onclick') as $value) {
  1725. if (isset($params[$value])) {
  1726. if (is_string($params[$value])) { $tags[] = $value.'="'.$params[$value].'"';
  1727. } else if ($params[$value] === true) { $tags[] = $value; }
  1728. }
  1729. }
  1730. $format = (isset($params['format']) && in_array($params['format'],array(false,'colour','color'))?$params['format']:false);
  1731. $name = (isset($params['name'])?$params['name']:(isset($params['id'])?$params['id']:''));
  1732. $id = (isset($params['id'])?$params['id']:(isset($params['name'])?$params['name'].'_id':randString(32)));
  1733. $val = (isset($params['value'])?$params['value']:'');
  1734. $class = (isset($params['class'])?' '.$params['class']:'');
  1735. $wrapClass = (isset($params['wrapClass'])?$params['wrapClass']:'form-content');
  1736. $assist = (isset($params['assist'])?' - i.e. '.$params['assist']:'');
  1737. $label = (isset($params['labelTranslate'])?translate($params['labelTranslate']):(isset($params['label'])?$params['label']:''));
  1738. $labelOut = '<p class="help-text">'.$label.$assist.'</p>';
  1739. // Field Design
  1740. switch ($params['type']) {
  1741. case 'text':
  1742. case 'number':
  1743. case 'password':
  1744. $field = '<input id="'.$id.'" name="'.$name.'" type="'.$params['type'].'" class="form-control material input-sm'.$class.'" '.implode(' ',$tags).' autocorrect="off" autocapitalize="off" value="'.$val.'">';
  1745. break;
  1746. case 'select':
  1747. case 'dropdown':
  1748. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control material input-sm" '.implode(' ',$tags).'>'.resolveSelectOptions($params['options'], $val).'</select>';
  1749. break;
  1750. case 'select-multi':
  1751. case 'dropdown-multi':
  1752. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control input-sm" '.implode(' ',$tags).' multiple="multiple">'.resolveSelectOptions($params['options'], $val, true).'</select>';
  1753. break;
  1754. case 'check':
  1755. case 'checkbox':
  1756. case 'toggle':
  1757. $checked = ((is_bool($val) && $val) || trim($val) === 'true'?' checked':'');
  1758. $colour = (isset($params['colour'])?$params['colour']:'success');
  1759. $labelOut = '<label for="'.$id.'"></label>'.$label;
  1760. $field = '<input id="'.$id.'" name="'.$name.'" type="checkbox" class="switcher switcher-'.$colour.' '.$class.'" '.implode(' ',$tags).' data-value="'.$val.'"'.$checked.'>';
  1761. break;
  1762. case 'radio':
  1763. $labelOut = '';
  1764. $checked = ((is_bool($val) && $val) || ($val && trim($val) !== 'false')?' checked':'');
  1765. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1766. $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>';
  1767. break;
  1768. case 'date':
  1769. $field = 'Unsupported, planned.';
  1770. break;
  1771. case 'hidden':
  1772. return '<input id="'.$id.'" name="'.$name.'" type="hidden" class="'.$class.'" '.implode(' ',$tags).' value="'.$val.'">';
  1773. break;
  1774. case 'header':
  1775. $labelOut = '';
  1776. $headType = (isset($params['value'])?$params['value']:3);
  1777. $field = '<h'.$headType.' class="'.$class.'" '.implode(' ',$tags).'>'.$label.'</h'.$headType.'>';
  1778. break;
  1779. case 'button':
  1780. $labelOut = '';
  1781. $icon = (isset($params['icon'])?$params['icon']:'flask');
  1782. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1783. $bDropdown = (isset($params['buttonDrop'])?$params['buttonDrop']:'');
  1784. $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><span class="btn-text">'.$label.'</span></button>'.($bDropdown?$bDropdown.'</div>':'');
  1785. break;
  1786. case 'textarea':
  1787. $rows = (isset($params['rows'])?$params['rows']:5);
  1788. $field = '<textarea id="'.$id.'" name="'.$name.'" class="form-control'.$class.'" rows="'.$rows.'" '.implode(' ',$tags).'>'.$val.'</textarea>';
  1789. break;
  1790. case 'custom':
  1791. // Settings
  1792. $settings = array(
  1793. '$id' => $id,
  1794. '$name' => $name,
  1795. '$val' => $val,
  1796. '$label' => $label,
  1797. '$labelOut' => $labelOut,
  1798. );
  1799. // Get HTML
  1800. $html = (isset($params['html'])?$params['html']:'Nothing Specified!');
  1801. // If LabelOut is in html dont print it twice
  1802. $labelOut = (strpos($html,'$label')!==false?'':$labelOut);
  1803. // Replace variables in settings
  1804. $html = preg_replace_callback('/\$\w+\b/', function ($match) use ($settings) { return (isset($settings[$match[0]])?$settings[$match[0]]:'{'.$match[0].' is undefined}'); }, $html);
  1805. // Build Field
  1806. $field = '<div id="'.$id.'_html" class="custom-field">'.$html.'</div>';
  1807. break;
  1808. case 'space':
  1809. $labelOut = '';
  1810. $field = str_repeat('<br>', (isset($params['value'])?$params['value']:1));
  1811. break;
  1812. default:
  1813. $field = 'Unsupported field type';
  1814. break;
  1815. }
  1816. // Field Formats
  1817. switch ($format) {
  1818. case 'colour': // Fuckin Eh, Canada!
  1819. case 'color':
  1820. $labelBef = '<center>'.$label.'</center>';
  1821. $wrapClass = 'gray-bg colour-field';
  1822. $labelAft = '';
  1823. $field = str_replace(' material input-sm','',$field);
  1824. break;
  1825. default:
  1826. $labelBef = '';
  1827. $labelAft = $labelOut;
  1828. }
  1829. return '<div class="'.$wrapClass.' col-sm-'.$sizeSm.' col-md-'.$sizeMd.' col-lg-'.$sizeLg.'">'.$labelBef.$field.$labelAft.'</div>';
  1830. }
  1831. // Tab Settings Generation
  1832. function printTabRow($data) {
  1833. $hidden = false;
  1834. if ($data===false) {
  1835. $hidden = true;
  1836. $data = array( // New Tab Defaults
  1837. 'id' => 'new',
  1838. 'name' => '',
  1839. 'url' => '',
  1840. 'icon' => 'fa-diamond',
  1841. 'iconurl' => '',
  1842. 'active' => 'true',
  1843. 'user' => 'true',
  1844. 'guest' => 'true',
  1845. 'window' => 'false',
  1846. 'splash' => 'true',
  1847. 'ping' => 'false',
  1848. 'ping_url' => '',
  1849. 'defaultz' => '',
  1850. );
  1851. }
  1852. $image = '<span style="font: normal normal normal 30px/1 FontAwesome;" class="fa fa-hand-paper-o"></span>';
  1853. $output = '
  1854. <li id="tab-'.$data['id'].'" class="list-group-item" style="position: relative; left: 0px; top: 0px; '.($hidden?' display: none;':'').'">
  1855. <tab class="content-form form-inline">
  1856. <div class="row">
  1857. '.buildField(array(
  1858. 'type' => 'custom',
  1859. '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>',
  1860. ),12,1,1).'
  1861. '.buildField(array(
  1862. 'type' => 'hidden',
  1863. 'id' => 'tab-'.$data['id'].'-id',
  1864. 'name' => 'id['.$data['id'].']',
  1865. 'value' => $data['id'],
  1866. ),12,2,1).'
  1867. '.buildField(array(
  1868. 'type' => 'text',
  1869. 'id' => 'tab-'.$data['id'].'-name',
  1870. 'name' => 'name['.$data['id'].']',
  1871. 'required' => true,
  1872. 'placeholder' => 'Organizr Homepage',
  1873. 'labelTranslate' => 'TAB_NAME',
  1874. 'value' => $data['name'],
  1875. 'class' => 'darkBold',
  1876. ),12,2,1).'
  1877. '.buildField(array(
  1878. 'type' => 'text',
  1879. 'id' => 'tab-'.$data['id'].'-url',
  1880. 'name' => 'url['.$data['id'].']',
  1881. 'required' => true,
  1882. 'placeholder' => 'homepage.php',
  1883. 'labelTranslate' => 'TAB_URL',
  1884. 'value' => $data['url'],
  1885. 'class' => 'darkBold',
  1886. ),12,2,2).'
  1887. '.buildField(array(
  1888. 'type' => 'text',
  1889. 'id' => 'tab-'.$data['id'].'-iconurl',
  1890. 'name' => 'iconurl['.$data['id'].']',
  1891. 'placeholder' => 'images/organizr.png',
  1892. 'labelTranslate' => 'ICON_URL',
  1893. 'value' => $data['iconurl'],
  1894. 'class' => 'darkBold',
  1895. ),12,2,1).'
  1896. '.buildField(array(
  1897. 'type' => 'text',
  1898. 'id' => 'tab-'.$data['id'].'-icon',
  1899. 'name' => 'icon['.$data['id'].']',
  1900. 'placeholder' => 'fa-icon',
  1901. 'labelTranslate' => 'OR_ICON_NAME',
  1902. 'value' => $data['icon'],
  1903. 'class' => 'iconpickeradd darkBold',
  1904. ),12,1,1).'
  1905. '.buildField(array(
  1906. 'type' => 'text',
  1907. 'id' => 'tab-'.$data['id'].'-ping_url',
  1908. 'name' => 'ping_url['.$data['id'].']',
  1909. 'placeholder' => 'host:port',
  1910. 'labelTranslate' => 'PING_URL',
  1911. 'value' => $data['ping_url'],
  1912. 'class' => 'darkBold',
  1913. ),12,2,1).'
  1914. '.buildField(array(
  1915. 'type' => 'radio',
  1916. 'labelTranslate' => 'DEFAULT',
  1917. 'name' => 'defaultz['.$data['id'].']',
  1918. 'value' => $data['defaultz'],
  1919. 'onclick' => "$('[type=radio][id!=\''+this.id+'\']').each(function() { this.checked=false; });",
  1920. ),12,1,1).'
  1921. '.buildField(array(
  1922. 'type' => 'button',
  1923. 'icon' => 'chevron-down',
  1924. 'buttonType' => 'success',
  1925. 'labelTranslate' => 'MORE',
  1926. 'onclick' => "$(this).parent().parent().parent().find('.slideInUp').toggle()",
  1927. 'class' => 'toggleTabExtra',
  1928. ),12,1,1).'
  1929. '.buildField(array(
  1930. 'type' => 'button',
  1931. 'icon' => 'trash',
  1932. 'buttonType' => 'danger',
  1933. 'labelTranslate' => 'REMOVE',
  1934. 'onclick' => "$(this).parents('li').remove();",
  1935. ),12,1,1).'</div><div id = "tab-'.$data['id'].'-row" class = "row animated slideInUp" style = "display:none;" ><div></div>
  1936. '.buildField(array(
  1937. 'type' => 'checkbox',
  1938. 'labelTranslate' => 'ACTIVE',
  1939. 'name' => 'active['.$data['id'].']',
  1940. 'value' => $data['active'],
  1941. ),12,1,1).'
  1942. '.buildField(array(
  1943. 'type' => 'checkbox',
  1944. 'labelTranslate' => 'USER',
  1945. 'colour' => 'primary',
  1946. 'name' => 'user['.$data['id'].']',
  1947. 'value' => $data['user'],
  1948. ),12,1,1).'
  1949. '.buildField(array(
  1950. 'type' => 'checkbox',
  1951. 'labelTranslate' => 'GUEST',
  1952. 'colour' => 'warning',
  1953. 'name' => 'guest['.$data['id'].']',
  1954. 'value' => $data['guest'],
  1955. ),12,1,1).'
  1956. '.buildField(array(
  1957. 'type' => 'checkbox',
  1958. 'labelTranslate' => 'NO_IFRAME',
  1959. 'colour' => 'danger',
  1960. 'name' => 'window['.$data['id'].']',
  1961. 'value' => $data['window'],
  1962. ),12,1,1).'
  1963. '.buildField(array(
  1964. 'type' => 'checkbox',
  1965. 'labelTranslate' => 'SPLASH',
  1966. 'colour' => 'success',
  1967. 'name' => 'splash['.$data['id'].']',
  1968. 'value' => $data['splash'],
  1969. ),12,1,1).'
  1970. '.buildField(array(
  1971. 'type' => 'checkbox',
  1972. 'labelTranslate' => 'PING',
  1973. 'colour' => 'success',
  1974. 'name' => 'ping['.$data['id'].']',
  1975. 'value' => $data['ping'],
  1976. ),12,1,1).'
  1977. </div>
  1978. </tab>
  1979. </li>
  1980. ';
  1981. return $output;
  1982. }
  1983. // Timezone array
  1984. function timezoneOptions() {
  1985. $output = array();
  1986. $timezones = array();
  1987. $regions = array(
  1988. 'Africa' => DateTimeZone::AFRICA,
  1989. 'America' => DateTimeZone::AMERICA,
  1990. 'Antarctica' => DateTimeZone::ANTARCTICA,
  1991. 'Arctic' => DateTimeZone::ARCTIC,
  1992. 'Asia' => DateTimeZone::ASIA,
  1993. 'Atlantic' => DateTimeZone::ATLANTIC,
  1994. 'Australia' => DateTimeZone::AUSTRALIA,
  1995. 'Europe' => DateTimeZone::EUROPE,
  1996. 'Indian' => DateTimeZone::INDIAN,
  1997. 'Pacific' => DateTimeZone::PACIFIC
  1998. );
  1999. foreach ($regions as $name => $mask) {
  2000. $zones = DateTimeZone::listIdentifiers($mask);
  2001. foreach($zones as $timezone) {
  2002. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2003. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2004. $output[$name]['optgroup'][substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm]['value'] = $timezone;
  2005. }
  2006. }
  2007. return $output;
  2008. }
  2009. // Build Database
  2010. function createSQLiteDB($path = false) {
  2011. if ($path === false) {
  2012. if (DATABASE_LOCATION){
  2013. $path = DATABASE_LOCATION;
  2014. } else {
  2015. debug_out('No Path Specified!');
  2016. }
  2017. }
  2018. if (!is_file($path.'users.db') || filesize($path.'users.db') <= 0) {
  2019. if (!isset($GLOBALS['file_db'])) {
  2020. $GLOBALS['file_db'] = new PDO('sqlite:'.$path.'users.db');
  2021. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2022. }
  2023. // Create Users
  2024. $users = $GLOBALS['file_db']->query('CREATE TABLE `users` (
  2025. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2026. `username` TEXT UNIQUE,
  2027. `password` TEXT,
  2028. `email` TEXT,
  2029. `token` TEXT,
  2030. `role` TEXT,
  2031. `active` TEXT,
  2032. `last` TEXT,
  2033. `auth_service` TEXT DEFAULT \'internal\'
  2034. );');
  2035. // Create Tabs
  2036. $tabs = $GLOBALS['file_db']->query('CREATE TABLE `tabs` (
  2037. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2038. `order` INTEGER,
  2039. `users_id` INTEGER,
  2040. `name` TEXT,
  2041. `url` TEXT,
  2042. `defaultz` TEXT,
  2043. `active` TEXT,
  2044. `user` TEXT,
  2045. `guest` TEXT,
  2046. `icon` TEXT,
  2047. `iconurl` TEXT,
  2048. `window` TEXT,
  2049. `splash` TEXT,
  2050. `ping` TEXT,
  2051. `ping_url` TEXT
  2052. );');
  2053. // Create Options
  2054. $options = $GLOBALS['file_db']->query('CREATE TABLE `options` (
  2055. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2056. `users_id` INTEGER UNIQUE,
  2057. `title` TEXT UNIQUE,
  2058. `topbar` TEXT,
  2059. `bottombar` TEXT,
  2060. `sidebar` TEXT,
  2061. `hoverbg` TEXT,
  2062. `topbartext` TEXT,
  2063. `activetabBG` TEXT,
  2064. `activetabicon` TEXT,
  2065. `activetabtext` TEXT,
  2066. `inactiveicon` TEXT,
  2067. `inactivetext` TEXT,
  2068. `loading` TEXT,
  2069. `hovertext` TEXT
  2070. );');
  2071. // Create Invites
  2072. $invites = $GLOBALS['file_db']->query('CREATE TABLE `invites` (
  2073. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2074. `code` TEXT UNIQUE,
  2075. `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  2076. `email` TEXT,
  2077. `username` TEXT,
  2078. `dateused` TIMESTAMP,
  2079. `usedby` TEXT,
  2080. `ip` TEXT,
  2081. `valid` TEXT
  2082. );');
  2083. writeLog("success", "database created/saved");
  2084. return $users && $tabs && $options && $invites;
  2085. } else {
  2086. writeLog("error", "database was unable to be created/saved");
  2087. return false;
  2088. }
  2089. }
  2090. // Upgrade Database
  2091. function updateSQLiteDB($db_path = false, $oldVerNum = false) {
  2092. if (!$db_path) {
  2093. if (defined('DATABASE_LOCATION')) {
  2094. $db_path = DATABASE_LOCATION;
  2095. } else {
  2096. debug_out('No Path Specified',1);
  2097. }
  2098. }
  2099. if (!isset($GLOBALS['file_db'])) {
  2100. $GLOBALS['file_db'] = new PDO('sqlite:'.$db_path.'users.db');
  2101. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2102. }
  2103. // Cache current DB
  2104. $cache = array();
  2105. foreach($GLOBALS['file_db']->query('SELECT name FROM sqlite_master WHERE type="table";') as $table) {
  2106. foreach($GLOBALS['file_db']->query('SELECT * FROM '.$table['name'].';') as $key => $row) {
  2107. foreach($row as $k => $v) {
  2108. if (is_string($k)) {
  2109. $cache[$table['name']][$key][$k] = $v;
  2110. }
  2111. }
  2112. }
  2113. }
  2114. // Remove Current Database
  2115. $GLOBALS['file_db'] = null;
  2116. $pathDigest = pathinfo($db_path.'users.db');
  2117. if (file_exists($db_path.'users.db')) {
  2118. rename($db_path.'users.db', $pathDigest['dirname'].'/'.$pathDigest['filename'].'['.date('Y-m-d_H-i-s').']'.($oldVerNum?'['.$oldVerNum.']':'').'.bak.db');
  2119. }
  2120. // Create New Database
  2121. $success = createSQLiteDB($db_path);
  2122. // Restore Items
  2123. if ($success) {
  2124. foreach($cache as $table => $tableData) {
  2125. if ($tableData) {
  2126. $queryBase = 'INSERT INTO '.$table.' (`'.implode('`,`',array_keys(current($tableData))).'`) values ';
  2127. $insertValues = array();
  2128. reset($tableData);
  2129. foreach($tableData as $key => $value) {
  2130. $insertValues[] = '('.implode(',',array_map(function($d) {
  2131. return (isset($d)?$GLOBALS['file_db']->quote($d):'null');
  2132. }, $value)).')';
  2133. }
  2134. $GLOBALS['file_db']->query($queryBase.implode(',',$insertValues).';');
  2135. }
  2136. }
  2137. writeLog("success", "database values have been updated");
  2138. return true;
  2139. } else {
  2140. writeLog("error", "database values unable to be updated");
  2141. return false;
  2142. }
  2143. }
  2144. // Commit colours to database
  2145. function updateDBOptions($values) {
  2146. if (!isset($GLOBALS['file_db'])) {
  2147. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2148. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2149. }
  2150. // Commit new values to database
  2151. if ($GLOBALS['file_db']->query('UPDATE options SET '.implode(',',array_map(function($d, $k) {
  2152. return '`'.$k.'` = '.(isset($d)?"'".addslashes($d)."'":'null');
  2153. }, $values, array_keys($values))).';')->rowCount()) {
  2154. return true;
  2155. } else if ($GLOBALS['file_db']->query('INSERT OR IGNORE INTO options (`'.implode('`,`',array_keys($values)).'`) VALUES (\''.implode("','",$values).'\');')->rowCount()) {
  2156. writeLog("success", "database values for options table have been updated");
  2157. return true;
  2158. } else {
  2159. writeLog("error", "database values for options table unable to be updated");
  2160. return false;
  2161. }
  2162. }
  2163. // Send AJAX notification
  2164. function sendNotification($success, $message = false, $send = true) {
  2165. $notifyExplode = explode("-", NOTIFYEFFECT);
  2166. if ($success) {
  2167. $msg = array(
  2168. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_SAVED").'</strong>'),
  2169. 'icon' => 'floppy-o',
  2170. 'type' => 'success',
  2171. 'length' => '5000',
  2172. 'layout' => $notifyExplode[0],
  2173. 'effect' => $notifyExplode[1],
  2174. );
  2175. } else {
  2176. $msg = array(
  2177. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_NOT_SAVED").'</strong>'),
  2178. 'icon' => 'floppy-o',
  2179. 'type' => 'failed',
  2180. 'length' => '5000',
  2181. 'layout' => $notifyExplode[0],
  2182. 'effect' => $notifyExplode[1],
  2183. );
  2184. }
  2185. // Send and kill script?
  2186. if ($send) {
  2187. header('Content-Type: application/json');
  2188. echo json_encode(array('notify'=>$msg));
  2189. die();
  2190. }
  2191. return $msg;
  2192. }
  2193. // Load colours from the database
  2194. function loadAppearance() {
  2195. // Defaults
  2196. $defaults = array(
  2197. 'title' => 'Organizr',
  2198. 'topbartext' => '#66D9EF',
  2199. 'topbar' => '#333333',
  2200. 'bottombar' => '#333333',
  2201. 'sidebar' => '#393939',
  2202. 'hoverbg' => '#AD80FD',
  2203. 'activetabBG' => '#F92671',
  2204. 'activetabicon' => '#FFFFFF',
  2205. 'activetabtext' => '#FFFFFF',
  2206. 'inactiveicon' => '#66D9EF',
  2207. 'inactivetext' => '#66D9EF',
  2208. 'loading' => '#66D9EF',
  2209. 'hovertext' => '#000000',
  2210. );
  2211. if (DATABASE_LOCATION) {
  2212. if(is_file(DATABASE_LOCATION.'users.db') && filesize(DATABASE_LOCATION.'users.db') > 0){
  2213. if (!isset($GLOBALS['file_db'])) {
  2214. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2215. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2216. }
  2217. // Database Lookup
  2218. $options = $GLOBALS['file_db']->query('SELECT * FROM options');
  2219. // Replace defaults with filled options
  2220. foreach($options as $row) {
  2221. foreach($defaults as $key => $value) {
  2222. if (isset($row[$key]) && $row[$key]) {
  2223. $defaults[$key] = $row[$key];
  2224. }
  2225. }
  2226. }
  2227. }
  2228. }
  2229. // Return the Results
  2230. return $defaults;
  2231. }
  2232. // Delete Database
  2233. function deleteDatabase() {
  2234. unset($_COOKIE['Organizr']);
  2235. setcookie('Organizr', '', time() - 3600, '/');
  2236. unset($_COOKIE['OrganizrU']);
  2237. setcookie('OrganizrU', '', time() - 3600, '/');
  2238. $GLOBALS['file_db'] = null;
  2239. unlink(DATABASE_LOCATION.'users.db');
  2240. foreach(glob(substr_replace($userdirpath, "", -1).'/*') as $file) {
  2241. if(is_dir($file)) {
  2242. rmdir($file);
  2243. } elseif (!is_dir($file)) {
  2244. unlink($file);
  2245. }
  2246. }
  2247. rmdir($userdirpath);
  2248. writeLog("success", "database has been deleted");
  2249. return true;
  2250. }
  2251. // Upgrade the installation
  2252. function upgradeInstall($branch = 'master') {
  2253. function downloadFile($url, $path){
  2254. ini_set('max_execution_time',0);
  2255. $folderPath = "upgrade/";
  2256. if(!mkdir($folderPath)){
  2257. writeLog("error", "organizr could not create upgrade folder");
  2258. }
  2259. $newfname = $folderPath . $path;
  2260. $file = fopen ($url, 'rb');
  2261. if ($file) {
  2262. $newf = fopen ($newfname, 'wb');
  2263. if ($newf) {
  2264. while(!feof($file)) {
  2265. fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
  2266. }
  2267. }
  2268. }else{
  2269. writeLog("error", "organizr could not download $url");
  2270. }
  2271. if ($file) {
  2272. fclose($file);
  2273. writeLog("success", "organizr finished downloading the github zip file");
  2274. }else{
  2275. writeLog("error", "organizr could not download the github zip file");
  2276. }
  2277. if ($newf) {
  2278. fclose($newf);
  2279. writeLog("success", "organizr created upgrade zip file from github zip file");
  2280. }else{
  2281. writeLog("error", "organizr could not create upgrade zip file from github zip file");
  2282. }
  2283. }
  2284. function unzipFile($zipFile){
  2285. $zip = new ZipArchive;
  2286. $extractPath = "upgrade/";
  2287. if($zip->open($extractPath . $zipFile) != "true"){
  2288. writeLog("error", "organizr could not unzip upgrade.zip");
  2289. }else{
  2290. writeLog("success", "organizr unzipped upgrade.zip");
  2291. }
  2292. /* Extract Zip File */
  2293. $zip->extractTo($extractPath);
  2294. $zip->close();
  2295. }
  2296. // Function to remove folders and files
  2297. function rrmdir($dir) {
  2298. if (is_dir($dir)) {
  2299. $files = scandir($dir);
  2300. foreach ($files as $file)
  2301. if ($file != "." && $file != "..") rrmdir("$dir/$file");
  2302. rmdir($dir);
  2303. }
  2304. else if (file_exists($dir)) unlink($dir);
  2305. }
  2306. // Function to Copy folders and files
  2307. function rcopy($src, $dst) {
  2308. if (is_dir ( $src )) {
  2309. if (!file_exists($dst)) : mkdir ( $dst ); endif;
  2310. $files = scandir ( $src );
  2311. foreach ( $files as $file )
  2312. if ($file != "." && $file != "..")
  2313. rcopy ( "$src/$file", "$dst/$file" );
  2314. } else if (file_exists ( $src ))
  2315. copy ( $src, $dst );
  2316. }
  2317. $url = 'https://github.com/causefx/Organizr/archive/'.$branch.'.zip';
  2318. $file = "upgrade.zip";
  2319. $source = __DIR__ . '/upgrade/Organizr-'.$branch.'/';
  2320. $cleanup = __DIR__ . "/upgrade/";
  2321. $destination = __DIR__ . "/";
  2322. writeLog("success", "starting organizr upgrade process");
  2323. downloadFile($url, $file);
  2324. unzipFile($file);
  2325. rcopy($source, $destination);
  2326. writeLog("success", "new organizr files copied");
  2327. rrmdir($cleanup);
  2328. writeLog("success", "organizr upgrade folder removed");
  2329. writeLog("success", "organizr has been updated");
  2330. return true;
  2331. }
  2332. // NzbGET Items
  2333. function nzbgetConnect($list = 'listgroups') {
  2334. $url = qualifyURL(NZBGETURL);
  2335. $api = curl_get($url.'/'.NZBGETUSERNAME.':'.NZBGETPASSWORD.'/jsonrpc/'.$list);
  2336. $api = json_decode($api, true);
  2337. $gotNZB = array();
  2338. if (is_array($api) || is_object($api)){
  2339. foreach ($api['result'] AS $child) {
  2340. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  2341. $downloadStatus = $child['Status'];
  2342. $downloadCategory = $child['Category'];
  2343. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  2344. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  2345. if($child['Health'] <= "750"){
  2346. $downloadHealth = "danger";
  2347. }elseif($child['Health'] <= "900"){
  2348. $downloadHealth = "warning";
  2349. }elseif($child['Health'] <= "1000"){
  2350. $downloadHealth = "success";
  2351. }
  2352. $gotNZB[] = '<tr>
  2353. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2354. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2355. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2356. <td class="col-xs-1 nzbtable nzbtable-row">'.realSize(($child['FileSizeMB']*1024)*1024).'</td>
  2357. <td class="col-xs-2 nzbtable nzbtable-row">
  2358. <div class="progress">
  2359. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2360. <p class="text-center">'.round($downloadPercent).'%</p>
  2361. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2362. </div>
  2363. </div>
  2364. </td>
  2365. </tr>';
  2366. }
  2367. if ($gotNZB) {
  2368. return implode('',$gotNZB);
  2369. } else {
  2370. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2371. }
  2372. }else{
  2373. writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Username and Password - if HTTPS, is cert valid");
  2374. }
  2375. }
  2376. // Sabnzbd Items
  2377. function sabnzbdConnect($list = 'queue') {
  2378. $url = qualifyURL(SABNZBDURL);
  2379. $api = file_get_contents($url.'/api?mode='.$list.'&output=json&apikey='.SABNZBDKEY);
  2380. $api = json_decode($api, true);
  2381. $gotNZB = array();
  2382. foreach ($api[$list]['slots'] AS $child) {
  2383. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  2384. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  2385. $downloadStatus = $child['status'];
  2386. $gotNZB[] = '<tr>
  2387. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2388. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2389. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2390. <td class="col-xs-1 nzbtable nzbtable-row">'.$child['size'].'</td>
  2391. <td class="col-xs-2 nzbtable nzbtable-row">
  2392. <div class="progress">
  2393. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2394. <p class="text-center">'.round($downloadPercent).'%</p>
  2395. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2396. </div>
  2397. </div>
  2398. </td>
  2399. </tr>';
  2400. }
  2401. if ($gotNZB) {
  2402. return implode('',$gotNZB);
  2403. } else {
  2404. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2405. }
  2406. }
  2407. // Apply new tab settings
  2408. function updateTabs($tabs) {
  2409. if (!isset($GLOBALS['file_db'])) {
  2410. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2411. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2412. }
  2413. // Validate
  2414. if (!isset($tabs['defaultz'])) { $tabs['defaultz'][current(array_keys($tabs['name']))] = 'true'; }
  2415. if (isset($tabs['name']) && isset($tabs['url']) && is_array($tabs['name'])) {
  2416. // Clear Existing Tabs
  2417. $GLOBALS['file_db']->query("DELETE FROM tabs");
  2418. // Process New Tabs
  2419. $totalValid = 0;
  2420. foreach ($tabs['name'] as $key => $value) {
  2421. // Qualify
  2422. if (!$value || !isset($tabs['url']) || !$tabs['url'][$key]) { continue; }
  2423. $totalValid++;
  2424. $fields = array();
  2425. foreach(array('id','name','url','icon','iconurl','order','ping_url') as $v) {
  2426. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = $tabs[$v][$key]; }
  2427. }
  2428. foreach(array('active','user','guest','defaultz','window','splash','ping') as $v) {
  2429. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = ($tabs[$v][$key]!=='false'?'true':'false'); }
  2430. }
  2431. $GLOBALS['file_db']->query('INSERT INTO tabs (`'.implode('`,`',array_keys($fields)).'`) VALUES (\''.implode("','",$fields).'\');');
  2432. }
  2433. writeLog("success", "tabs successfully saved");
  2434. return $totalValid;
  2435. } else {
  2436. writeLog("error", "tabs could not save");
  2437. return false;
  2438. }
  2439. writeLog("error", "tabs could not save");
  2440. return false;
  2441. }
  2442. // ==============
  2443. function clean($strin) {
  2444. $strout = null;
  2445. for ($i = 0; $i < strlen($strin); $i++) {
  2446. $ord = ord($strin[$i]);
  2447. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  2448. $strout .= "&amp;#{$ord};";
  2449. }
  2450. else {
  2451. switch ($strin[$i]) {
  2452. case '<':
  2453. $strout .= '&lt;';
  2454. break;
  2455. case '>':
  2456. $strout .= '&gt;';
  2457. break;
  2458. case '&':
  2459. $strout .= '&amp;';
  2460. break;
  2461. case '"':
  2462. $strout .= '&quot;';
  2463. break;
  2464. default:
  2465. $strout .= $strin[$i];
  2466. }
  2467. }
  2468. }
  2469. return $strout;
  2470. }
  2471. function registration_callback($username, $email, $userdir){
  2472. global $data;
  2473. $data = array($username, $email, $userdir);
  2474. }
  2475. function printArray($arrayName){
  2476. $messageCount = count($arrayName);
  2477. $i = 0;
  2478. foreach ( $arrayName as $item ) :
  2479. $i++;
  2480. if($i < $messageCount) :
  2481. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  2482. elseif($i = $messageCount) :
  2483. echo "<small class='text-uppercase'>" . $item . "</small>";
  2484. endif;
  2485. endforeach;
  2486. }
  2487. function write_ini_file($content, $path) {
  2488. if (!$handle = fopen($path, 'w')) {
  2489. return false;
  2490. }
  2491. $success = fwrite($handle, trim($content));
  2492. fclose($handle);
  2493. return $success;
  2494. }
  2495. function gotTimezone(){
  2496. $regions = array(
  2497. 'Africa' => DateTimeZone::AFRICA,
  2498. 'America' => DateTimeZone::AMERICA,
  2499. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2500. 'Arctic' => DateTimeZone::ARCTIC,
  2501. 'Asia' => DateTimeZone::ASIA,
  2502. 'Atlantic' => DateTimeZone::ATLANTIC,
  2503. 'Australia' => DateTimeZone::AUSTRALIA,
  2504. 'Europe' => DateTimeZone::EUROPE,
  2505. 'Indian' => DateTimeZone::INDIAN,
  2506. 'Pacific' => DateTimeZone::PACIFIC
  2507. );
  2508. $timezones = array();
  2509. foreach ($regions as $name => $mask) {
  2510. $zones = DateTimeZone::listIdentifiers($mask);
  2511. foreach($zones as $timezone) {
  2512. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2513. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2514. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2515. }
  2516. }
  2517. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  2518. foreach($timezones as $region => $list) {
  2519. print '<optgroup label="' . $region . '">' . "\n";
  2520. foreach($list as $timezone => $name) {
  2521. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  2522. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  2523. }
  2524. print '</optgroup>' . "\n";
  2525. }
  2526. print '</select>';
  2527. }
  2528. function getTimezone(){
  2529. $regions = array(
  2530. 'Africa' => DateTimeZone::AFRICA,
  2531. 'America' => DateTimeZone::AMERICA,
  2532. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2533. 'Arctic' => DateTimeZone::ARCTIC,
  2534. 'Asia' => DateTimeZone::ASIA,
  2535. 'Atlantic' => DateTimeZone::ATLANTIC,
  2536. 'Australia' => DateTimeZone::AUSTRALIA,
  2537. 'Europe' => DateTimeZone::EUROPE,
  2538. 'Indian' => DateTimeZone::INDIAN,
  2539. 'Pacific' => DateTimeZone::PACIFIC
  2540. );
  2541. $timezones = array();
  2542. foreach ($regions as $name => $mask) {
  2543. $zones = DateTimeZone::listIdentifiers($mask);
  2544. foreach($zones as $timezone) {
  2545. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2546. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2547. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2548. }
  2549. }
  2550. print '<select name="timezone" id="timezone" class="form-control material" required>';
  2551. foreach($timezones as $region => $list) {
  2552. print '<optgroup label="' . $region . '">' . "\n";
  2553. foreach($list as $timezone => $name) {
  2554. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  2555. }
  2556. print '</optgroup>' . "\n";
  2557. }
  2558. print '</select>';
  2559. }
  2560. function explosion($string, $position){
  2561. $getWord = explode("|", $string);
  2562. return $getWord[$position];
  2563. }
  2564. function getServerPath() {
  2565. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  2566. $protocol = "https://";
  2567. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  2568. $protocol = "https://";
  2569. } else {
  2570. $protocol = "http://";
  2571. }
  2572. $domain = '';
  2573. if (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], '.') !== false){
  2574. $domain = $_SERVER['SERVER_NAME'];
  2575. }elseif(isset($_SERVER['HTTP_HOST'])){
  2576. if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
  2577. $domain = explode(':', $_SERVER['HTTP_HOST'])[0];
  2578. $port = explode(':', $_SERVER['HTTP_HOST'])[1];
  2579. if ($port == "80" || $port == "443"){
  2580. $domain = $domain;
  2581. }else{
  2582. $domain = $_SERVER['HTTP_HOST'];
  2583. }
  2584. }else{
  2585. $domain = $_SERVER['HTTP_HOST'];
  2586. }
  2587. }
  2588. return $protocol . $domain . str_replace("\\", "/", dirname($_SERVER['REQUEST_URI']));
  2589. }
  2590. function get_browser_name() {
  2591. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  2592. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  2593. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  2594. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  2595. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  2596. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  2597. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  2598. return 'Other';
  2599. }
  2600. function getSickrageCalendarWanted($array){
  2601. $array = json_decode($array, true);
  2602. //$gotCalendar = "";
  2603. $gotCalendar = array();
  2604. $i = 0;
  2605. foreach($array['data']['missed'] AS $child) {
  2606. $i++;
  2607. $seriesName = $child['show_name'];
  2608. $episodeID = $child['tvdbid'];
  2609. $episodeAirDate = $child['airdate'];
  2610. $episodeAirDateTime = explode(" ",$child['airs']);
  2611. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2612. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2613. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2614. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2615. $downloaded = "0";
  2616. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2617. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2618. array_push($gotCalendar, array(
  2619. "id" => "Sick-Miss-".$i,
  2620. "title" => $seriesName,
  2621. "start" => $episodeAirDate,
  2622. "className" => $downloaded." tvID--".$episodeID,
  2623. "imagetype" => "tv",
  2624. ));
  2625. }
  2626. foreach($array['data']['today'] AS $child) {
  2627. $i++;
  2628. $seriesName = $child['show_name'];
  2629. $episodeID = $child['tvdbid'];
  2630. $episodeAirDate = $child['airdate'];
  2631. $episodeAirDateTime = explode(" ",$child['airs']);
  2632. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2633. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2634. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2635. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2636. $downloaded = "0";
  2637. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2638. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2639. array_push($gotCalendar, array(
  2640. "id" => "Sick-Today-".$i,
  2641. "title" => $seriesName,
  2642. "start" => $episodeAirDate,
  2643. "className" => $downloaded." tvID--".$episodeID,
  2644. "imagetype" => "tv",
  2645. ));
  2646. }
  2647. foreach($array['data']['soon'] AS $child) {
  2648. $i++;
  2649. $seriesName = $child['show_name'];
  2650. $episodeID = $child['tvdbid'];
  2651. $episodeAirDate = $child['airdate'];
  2652. $episodeAirDateTime = explode(" ",$child['airs']);
  2653. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2654. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2655. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2656. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2657. $downloaded = "0";
  2658. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2659. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2660. array_push($gotCalendar, array(
  2661. "id" => "Sick-Soon-".$i,
  2662. "title" => $seriesName,
  2663. "start" => $episodeAirDate,
  2664. "className" => $downloaded." tvID--".$episodeID,
  2665. "imagetype" => "tv",
  2666. ));
  2667. }
  2668. foreach($array['data']['later'] AS $child) {
  2669. $i++;
  2670. $seriesName = $child['show_name'];
  2671. $episodeID = $child['tvdbid'];
  2672. $episodeAirDate = $child['airdate'];
  2673. $episodeAirDateTime = explode(" ",$child['airs']);
  2674. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2675. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2676. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2677. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2678. $downloaded = "0";
  2679. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2680. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2681. array_push($gotCalendar, array(
  2682. "id" => "Sick-Later-".$i,
  2683. "title" => $seriesName,
  2684. "start" => $episodeAirDate,
  2685. "className" => $downloaded." tvID--".$episodeID,
  2686. "imagetype" => "tv",
  2687. ));
  2688. }
  2689. if ($i != 0){ return $gotCalendar; }
  2690. }
  2691. function getSickrageCalendarHistory($array){
  2692. $array = json_decode($array, true);
  2693. //$gotCalendar = "";
  2694. $gotCalendar = array();
  2695. $i = 0;
  2696. foreach($array['data'] AS $child) {
  2697. $i++;
  2698. $seriesName = $child['show_name'];
  2699. $episodeID = $child['tvdbid'];
  2700. $episodeAirDate = $child['date'];
  2701. $downloaded = "green-bg";
  2702. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2703. array_push($gotCalendar, array(
  2704. "id" => "Sick-History-".$i,
  2705. "title" => $seriesName,
  2706. "start" => $episodeAirDate,
  2707. "className" => $downloaded." tvID--".$episodeID,
  2708. "imagetype" => "tv",
  2709. ));
  2710. }
  2711. if ($i != 0){ return $gotCalendar; }
  2712. }
  2713. function getSonarrCalendar($array){
  2714. $array = json_decode($array, true);
  2715. //$gotCalendar = "";
  2716. $gotCalendar = array();
  2717. $i = 0;
  2718. foreach($array AS $child) {
  2719. $i++;
  2720. $seriesName = $child['series']['title'];
  2721. $episodeID = $child['series']['tvdbId'];
  2722. if(!isset($episodeID)){ $episodeID = ""; }
  2723. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  2724. if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
  2725. $episodeAirDate = $child['airDateUtc'];
  2726. $episodeAirDate = strtotime($episodeAirDate);
  2727. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2728. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2729. $downloaded = $child['hasFile'];
  2730. 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"; }
  2731. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2732. array_push($gotCalendar, array(
  2733. "id" => "Sonarr-".$i,
  2734. "title" => $seriesName,
  2735. "start" => $episodeAirDate,
  2736. "className" => $downloaded." tvID--".$episodeID,
  2737. "imagetype" => "tv",
  2738. ));
  2739. }
  2740. if ($i != 0){ return $gotCalendar; }
  2741. }
  2742. function getCouchCalendar(){
  2743. $url = qualifyURL(COUCHURL);
  2744. $api = curl_get($url."/api/".COUCHAPI."/media.list");
  2745. $api = json_decode($api, true);
  2746. $i = 0;
  2747. $gotCalendar = array();
  2748. if (is_array($api) || is_object($api)){
  2749. foreach($api['movies'] AS $child) {
  2750. if($child['status'] == "active" || $child['status'] == "done" ){
  2751. $i++;
  2752. $movieName = $child['info']['original_title'];
  2753. $movieID = $child['info']['tmdb_id'];
  2754. if(!isset($movieID)){ $movieID = ""; }
  2755. $physicalRelease = (isset($child['info']['released']) ? $child['info']['released'] : null);
  2756. $backupRelease = (isset($child['info']['release_date']['theater']) ? $child['info']['release_date']['theater'] : null);
  2757. $physicalRelease = (isset($physicalRelease) ? $physicalRelease : $backupRelease);
  2758. $physicalRelease = strtotime($physicalRelease);
  2759. $physicalRelease = date("Y-m-d", $physicalRelease);
  2760. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2761. $downloaded = ($child['status'] == "active") ? "0" : "1";
  2762. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2763. array_push($gotCalendar, array(
  2764. "id" => "CouchPotato-".$i,
  2765. "title" => $movieName,
  2766. "start" => $physicalRelease,
  2767. "className" => $downloaded." movieID--".$movieID,
  2768. "imagetype" => "film",
  2769. ));
  2770. }
  2771. }
  2772. if ($i != 0){ return $gotCalendar; }
  2773. }else{
  2774. writeLog("error", "CouchPotato ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2775. }
  2776. }
  2777. function getRadarrCalendar($array){
  2778. $array = json_decode($array, true);
  2779. $gotCalendar = array();
  2780. $i = 0;
  2781. foreach($array AS $child) {
  2782. if(isset($child['physicalRelease'])){
  2783. $i++;
  2784. $movieName = $child['title'];
  2785. $movieID = $child['tmdbId'];
  2786. if(!isset($movieID)){ $movieID = ""; }
  2787. $physicalRelease = $child['physicalRelease'];
  2788. $physicalRelease = strtotime($physicalRelease);
  2789. $physicalRelease = date("Y-m-d", $physicalRelease);
  2790. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2791. $downloaded = $child['hasFile'];
  2792. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2793. array_push($gotCalendar, array(
  2794. "id" => "Radarr-".$i,
  2795. "title" => $movieName,
  2796. "start" => $physicalRelease,
  2797. "className" => $downloaded." movieID--".$movieID,
  2798. "imagetype" => "film",
  2799. ));
  2800. }
  2801. }
  2802. if ($i != 0){ return $gotCalendar; }
  2803. }
  2804. function getHeadphonesCalendar($url, $key, $list){
  2805. $url = qualifyURL(HEADPHONESURL);
  2806. $api = curl_get($url."/api?apikey=".$key."&cmd=$list");
  2807. $api = json_decode($api, true);
  2808. $i = 0;
  2809. //$gotCalendar = "";
  2810. $gotCalendar = array();;
  2811. if (is_array($api) || is_object($api)){
  2812. foreach($api AS $child) {
  2813. if($child['Status'] == "Wanted" && $list == "getWanted" && $child['ReleaseDate']){
  2814. $i++;
  2815. $albumName = addslashes($child['AlbumTitle']);
  2816. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  2817. $albumDate = (strlen($child['ReleaseDate']) > 4) ? $child['ReleaseDate'] : $child['ReleaseDate']."-01-01";
  2818. $albumID = $child['AlbumID'];
  2819. $albumDate = strtotime($albumDate);
  2820. $albumDate = date("Y-m-d", $albumDate);
  2821. $albumStatus = $child['Status'];
  2822. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2823. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  2824. //$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2825. array_push($gotCalendar, array(
  2826. "id" => "Headphones-".$i,
  2827. "title" => $albumArtist.' - '.$albumName,
  2828. "start" => $albumDate,
  2829. "className" => $albumStatusColor,
  2830. "imagetype" => "music",
  2831. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2832. ));
  2833. }
  2834. if($child['Status'] == "Processed" && $list == "getHistory"){
  2835. $i++;
  2836. $find = array('_','[', ']', '\n');
  2837. $replace = array(' ','(', ')', ' ');
  2838. $albumName = addslashes(str_replace($find,$replace,$child['FolderName']));
  2839. $albumDate = $child['DateAdded'];
  2840. $albumID = $child['AlbumID'];
  2841. $albumDate = strtotime($albumDate);
  2842. $albumDate = date("Y-m-d", $albumDate);
  2843. $albumStatusColor = "green-bg";
  2844. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2845. //$gotCalendar .= "{ title: \"$albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2846. array_push($gotCalendar, array(
  2847. "id" => "Headphones-".$i,
  2848. "title" => $albumName,
  2849. "start" => $albumDate,
  2850. "className" => $albumStatusColor,
  2851. "imagetype" => "music",
  2852. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2853. ));
  2854. }
  2855. }
  2856. if ($i != 0){ return $gotCalendar; }
  2857. }else{
  2858. writeLog("error", "HEADPHONES $list ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2859. }
  2860. }
  2861. function checkRootPath($string){
  2862. if($string == "\\" || $string == "/"){
  2863. return "/";
  2864. }else{
  2865. return str_replace("\\", "/", $string) . "/";
  2866. }
  2867. }
  2868. function strip($string){
  2869. $string = strip_tags($string);
  2870. return preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $string));
  2871. }
  2872. function writeLog($type, $message){
  2873. if(file_exists("org.log")){
  2874. if(filesize("org.log") > 500000){
  2875. rename('org.log','org['.date('Y-m-d').'].log');
  2876. $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";
  2877. file_put_contents("org.log", $message2, FILE_APPEND | LOCK_EX);
  2878. }
  2879. }
  2880. $message = date("Y-m-d H:i:s")."|".$type."|".strip($message)."\n";
  2881. file_put_contents("org.log", $message, FILE_APPEND | LOCK_EX);
  2882. }
  2883. function readLog(){
  2884. $log = file("org.log",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  2885. $log = array_reverse($log);
  2886. foreach($log as $line){
  2887. if(substr_count($line, '|') == 2){
  2888. $line = explode("|", strip($line));
  2889. $line[1] = ($line[1] == "error") ? '<span class="label label-danger">Error</span>' : '<span class="label label-primary">Success</span>';
  2890. echo "<tr><td>".$line[0]."</td><td>".$line[2]."</td><td>".$line[1]."</td></tr>";
  2891. }
  2892. }
  2893. }
  2894. function buildStream($array){
  2895. $result = "";
  2896. if (array_key_exists('platform', $array)) {
  2897. $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>';
  2898. }
  2899. if (array_key_exists('device', $array)) {
  2900. $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>';
  2901. }
  2902. if (array_key_exists('stream', $array)) {
  2903. $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>';
  2904. }
  2905. if (array_key_exists('video', $array)) {
  2906. $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>';
  2907. }
  2908. if (array_key_exists('audio', $array)) {
  2909. $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>';
  2910. }
  2911. return $result;
  2912. }
  2913. function streamType($value){
  2914. if($value == "transcode" || $value == "Transcode"){
  2915. return "Transcode";
  2916. }elseif($value == "copy" || $value == "DirectStream"){
  2917. return "Direct Stream";
  2918. }elseif($value == "directplay" || $value == "DirectPlay"){
  2919. return "Direct Play";
  2920. }else{
  2921. return "Direct Play";
  2922. }
  2923. }
  2924. function getPlatform($platform){
  2925. $allPlatforms = array(
  2926. "Chrome" => "chrome.png",
  2927. "tvOS" => "atv.png",
  2928. "iOS" => "ios.png",
  2929. "Xbox One" => "xbox.png",
  2930. "Mystery 4" => "playstation.png",
  2931. "Samsung" => "samsung.png",
  2932. "Roku" => "roku.png",
  2933. "Emby for iOS" => "ios.png",
  2934. "Emby Mobile" => "emby.png",
  2935. "Emby Theater" => "emby.png",
  2936. "Emby Classic" => "emby.png",
  2937. "Safari" => "safari.png",
  2938. "Android" => "android.png",
  2939. "AndroidTv" => "android.png",
  2940. "Chromecast" => "chromecast.png",
  2941. "Dashboard" => "emby.png",
  2942. "Dlna" => "dlna.png",
  2943. "Windows Phone" => "wp.png",
  2944. "Windows RT" => "win8.png",
  2945. "Kodi" => "kodi.png",
  2946. );
  2947. if (array_key_exists($platform, $allPlatforms)) {
  2948. return $allPlatforms[$platform];
  2949. }else{
  2950. return "pmp.png";
  2951. }
  2952. }
  2953. function getServer(){
  2954. $server = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"];
  2955. return $server;
  2956. }
  2957. function prettyPrint($array) {
  2958. echo "<pre>";
  2959. print_r($array);
  2960. echo "</pre>";
  2961. echo "<br/>";
  2962. }
  2963. function checkFrame($array, $url){
  2964. if(array_key_exists("x-frame-options", $array)){
  2965. if($array['x-frame-options'] == "deny"){
  2966. return false;
  2967. }elseif($array['x-frame-options'] == "sameorgin"){
  2968. $digest = parse_url($url);
  2969. $host = (isset($digest['host'])?$digest['host']:'');
  2970. if(getServer() == $host){
  2971. return true;
  2972. }else{
  2973. return false;
  2974. }
  2975. }
  2976. }else{
  2977. if(!$array){
  2978. return false;
  2979. }
  2980. return true;
  2981. }
  2982. }
  2983. function frameTest($url){
  2984. $array = array_change_key_case(get_headers(qualifyURL($url), 1));
  2985. $url = qualifyURL($url);
  2986. if(checkFrame($array, $url)){
  2987. return true;
  2988. }else{
  2989. return false;
  2990. }
  2991. }
  2992. function sendResult($result, $icon = "floppy-o", $message = false, $success = "WAS_SUCCESSFUL", $fail = "HAS_FAILED", $send = true) {
  2993. $notifyExplode = explode("-", NOTIFYEFFECT);
  2994. if ($result) {
  2995. $msg = array(
  2996. 'html' => ($message?''.$message.' <strong>'.translate($success).'</strong>':'<strong>'.translate($success).'</strong>'),
  2997. 'icon' => $icon,
  2998. 'type' => 'success',
  2999. 'length' => '5000',
  3000. 'layout' => $notifyExplode[0],
  3001. 'effect' => $notifyExplode[1],
  3002. );
  3003. } else {
  3004. $msg = array(
  3005. 'html' => ($message?''.$message.' <strong>'.translate($fail).'</strong>':'<strong>'.translate($fail).'</strong>'),
  3006. 'icon' => $icon,
  3007. 'type' => 'error',
  3008. 'length' => '5000',
  3009. 'layout' => $notifyExplode[0],
  3010. 'effect' => $notifyExplode[1],
  3011. );
  3012. }
  3013. // Send and kill script?
  3014. if ($send) {
  3015. header('Content-Type: application/json');
  3016. echo json_encode(array('notify'=>$msg));
  3017. die();
  3018. }
  3019. return $msg;
  3020. }
  3021. function buildHomepageNotice($layout, $type, $title, $message){
  3022. switch ($layout) {
  3023. case 'elegant':
  3024. return '
  3025. <div id="homepageNotice" class="row">
  3026. <div class="col-lg-12">
  3027. <div class="content-box big-box box-shadow panel-box panel-'.$type.'">
  3028. <div class="content-title i-block">
  3029. <h4 class="zero-m"><strong>'.$title.'</strong></h4>
  3030. <div class="content-tools i-block pull-right">
  3031. <a class="close-btn">
  3032. <i class="fa fa-times"></i>
  3033. </a>
  3034. </div>
  3035. </div>
  3036. '.$message.'
  3037. </div>
  3038. </div>
  3039. </div>
  3040. ';
  3041. break;
  3042. case 'basic':
  3043. return '
  3044. <div id="homepageNotice" class="row">
  3045. <div class="col-lg-12">
  3046. <div class="panel panel-'.$type.'">
  3047. <div class="panel-heading">
  3048. <h3 class="panel-title">'.$title.'</h3>
  3049. </div>
  3050. <div class="panel-body">
  3051. '.$message.'
  3052. </div>
  3053. </div>
  3054. </div>
  3055. </div>
  3056. ';
  3057. break;
  3058. case 'jumbotron';
  3059. return '
  3060. <div id="homepageNotice" class="row">
  3061. <div class="col-lg-12">
  3062. <div class="jumbotron">
  3063. <div class="container">
  3064. <h1>'.$title.'</h1>
  3065. <p>'.$message.'</p>
  3066. </div>
  3067. </div>
  3068. </div>
  3069. </div>
  3070. ';
  3071. }
  3072. }
  3073. function embyArray($array, $type) {
  3074. $key = ($type == "video" ? "Height" : "Channels");
  3075. if (array_key_exists($key, $array)) {
  3076. switch ($type) {
  3077. case "video":
  3078. $codec = $array["Codec"];
  3079. $height = $array["Height"];
  3080. $width = $array["Width"];
  3081. break;
  3082. default:
  3083. $codec = $array["Codec"];
  3084. $channels = $array["Channels"];
  3085. }
  3086. return ($type == "video" ? "(".$codec.") (".$width."x".$height.")" : "(".$codec.") (".$channels."ch)");
  3087. }
  3088. foreach ($array as $element) {
  3089. if (is_array($element)) {
  3090. if (embyArray($element, $type)) {
  3091. return embyArray($element, $type);
  3092. }
  3093. }
  3094. }
  3095. }
  3096. // Get Now Playing Streams From Plex
  3097. function searchPlex($query){
  3098. $address = qualifyURL(PLEXURL);
  3099. $openTab = (PLEXTABNAME) ? "true" : "false";
  3100. // Perform API requests
  3101. $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
  3102. libxml_use_internal_errors(true);
  3103. $api = simplexml_load_string($api);
  3104. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3105. if (!$getServer) { return 'Could not load!'; }
  3106. // Identify the local machine
  3107. $server = $getServer['machineIdentifier'];
  3108. $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>";
  3109. $items = "";
  3110. $albums = $movies = $shows = 0;
  3111. $style = 'style="vertical-align: middle"';
  3112. foreach($api AS $child) {
  3113. if($child['type'] != "artist" && $child['type'] != "episode" && isset($child['librarySectionID'])){
  3114. $time = (string)$child['addedAt'];
  3115. $time = new DateTime("@$time");
  3116. $results = array(
  3117. "title" => (string)$child['title'],
  3118. "image" => (string)$child['thumb'],
  3119. "type" => (string)ucwords($child['type']),
  3120. "year" => (string)$child['year'],
  3121. "key" => (string)$child['ratingKey']."-search",
  3122. "ratingkey" => (string)$child['ratingKey'],
  3123. "genre" => (string)$child->Genre['tag'],
  3124. "added" => $time->format('Y-m-d'),
  3125. "extra" => "",
  3126. );
  3127. switch ($child['type']){
  3128. case "album":
  3129. $push = array(
  3130. "title" => (string)$child['parentTitle']." - ".(string)$child['title'],
  3131. );
  3132. $results = array_replace($results,$push);
  3133. $albums++;
  3134. break;
  3135. case "movie":
  3136. $push = array(
  3137. "extra" => "Content Rating: ".(string)$child['contentRating']."<br/>Movie Rating: ".(string)$child['rating'],
  3138. );
  3139. $results = array_replace($results,$push);
  3140. $movies++;
  3141. break;
  3142. case "show":
  3143. $push = array(
  3144. "extra" => "Seasons: ".(string)$child['childCount']."<br/>Episodes: ".(string)$child['leafCount'],
  3145. );
  3146. $results = array_replace($results,$push);
  3147. $shows++;
  3148. break;
  3149. }
  3150. if (file_exists('images/cache/'.$results['key'].'.jpg')){ $image_url = 'images/cache/'.$results['key'].'.jpg'; }
  3151. if (file_exists('images/cache/'.$results['key'].'.jpg') && (time() - 604800) > filemtime('images/cache/'.$results['key'].'.jpg') || !file_exists('images/cache/'.$results['key'].'.jpg')) {
  3152. $image_url = 'ajax.php?a=plex-image&img='.$results['image'].'&height=150&width=100&key='.$results['key'];
  3153. }
  3154. if(!$results['image']){ $image_url = "images/no-search.png"; $key = "no-search"; }
  3155. if (substr_count(PLEXURL, '.') != 2) {
  3156. $link = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3157. }else{
  3158. $link = PLEXURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3159. }
  3160. $items .= '<tr style="cursor: pointer;" class="openTab" extraTitle="'.$results['title'].'" extraType="'.$child['type'].'" openTab="'.$openTab.'" href="'.$link.'">
  3161. <th scope="row"><img src="'.$image_url.'"></th>
  3162. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
  3163. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
  3164. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
  3165. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
  3166. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
  3167. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['extra'].'</td>
  3168. </tr>';
  3169. }
  3170. }
  3171. $totals = '<div style="margin: 10px;" class="sort-todo pull-right">
  3172. <span class="badge gray-bg"><i class="fa fa-film fa-2x white"></i><strong style="
  3173. font-size: 23px;
  3174. ">&nbsp;'.$movies.'</strong></span>
  3175. <span class="badge gray-bg"><i class="fa fa-tv fa-2x white"></i><strong style="
  3176. font-size: 23px;
  3177. ">&nbsp;'.$shows.'</strong></span>
  3178. <span class="badge gray-bg"><i class="fa fa-music fa-2x white"></i><strong style="
  3179. font-size: 23px;
  3180. ">&nbsp;'.$albums.'</strong></span>
  3181. </div>';
  3182. return (!empty($items) ? $totals.$pre.$items."</div></table>" : "<h2 class='text-center'>No Results for $query</h2>" );
  3183. }
  3184. function getBannedUsers($string){
  3185. if (strpos($string, ',') !== false) {
  3186. $banned = explode(",", $string);
  3187. }else{
  3188. $banned = array($string);
  3189. }
  3190. return $banned;
  3191. }
  3192. function getWhitelist($string){
  3193. if (strpos($string, ',') !== false) {
  3194. $whitelist = explode(",", $string);
  3195. }else{
  3196. $whitelist = array($string);
  3197. }
  3198. foreach($whitelist as &$ip){
  3199. $ip = is_numeric(substr($ip, 0, 1)) ? $ip : gethostbyname($ip);
  3200. }
  3201. return $whitelist;
  3202. }
  3203. function get_client_ip() {
  3204. $ipaddress = '';
  3205. if (isset($_SERVER['HTTP_CLIENT_IP']))
  3206. $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
  3207. else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  3208. $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
  3209. else if(isset($_SERVER['HTTP_X_FORWARDED']))
  3210. $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
  3211. else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
  3212. $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
  3213. else if(isset($_SERVER['HTTP_FORWARDED']))
  3214. $ipaddress = $_SERVER['HTTP_FORWARDED'];
  3215. else if(isset($_SERVER['REMOTE_ADDR']))
  3216. $ipaddress = $_SERVER['REMOTE_ADDR'];
  3217. else
  3218. $ipaddress = 'UNKNOWN';
  3219. return $ipaddress;
  3220. }
  3221. //EMAIL SHIT
  3222. function sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null){
  3223. $mail = new PHPMailer;
  3224. $mail->isSMTP();
  3225. $mail->Host = SMTPHOST;
  3226. $mail->SMTPAuth = SMTPHOSTAUTH;
  3227. $mail->Username = SMTPHOSTUSERNAME;
  3228. $mail->Password = SMTPHOSTPASSWORD;
  3229. $mail->SMTPSecure = SMTPHOSTTYPE;
  3230. $mail->Port = SMTPHOSTPORT;
  3231. $mail->setFrom(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3232. $mail->addReplyTo(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3233. $mail->isHTML(true);
  3234. if($email){
  3235. $mail->addAddress($email, $username);
  3236. }
  3237. if($cc){
  3238. $mail->addCC($cc);
  3239. }
  3240. if($bcc){
  3241. if(strpos($bcc , ',') === false){
  3242. $mail->addBCC($bcc);
  3243. }else{
  3244. $allEmails = explode(",",$bcc);
  3245. foreach($allEmails as $gotEmail){
  3246. $mail->addBCC($gotEmail);
  3247. }
  3248. }
  3249. }
  3250. $mail->Subject = $subject;
  3251. $mail->Body = $body;
  3252. //$mail->send();
  3253. if(!$mail->send()) {
  3254. writeLog("error", "mail failed to send");
  3255. } else {
  3256. writeLog("success", "mail has been sent");
  3257. }
  3258. }
  3259. //EMAIL SHIT
  3260. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  3261. $mail = new PHPMailer;
  3262. $mail->isSMTP();
  3263. $mail->Host = $host;
  3264. $mail->SMTPAuth = $auth;
  3265. $mail->Username = $username;
  3266. $mail->Password = $password;
  3267. $mail->SMTPSecure = $type;
  3268. $mail->Port = $port;
  3269. $mail->setFrom($from, $sendername);
  3270. $mail->addReplyTo($from, $sendername);
  3271. $mail->isHTML(true);
  3272. $mail->addAddress($to, "Organizr Admin");
  3273. $mail->Subject = "Organizr Test E-Mail";
  3274. $mail->Body = "This was just a test!";
  3275. //$mail->send();
  3276. if(!$mail->send()) {
  3277. writeLog("error", "EMAIL TEST: mail failed to send - Error:".$mail->ErrorInfo);
  3278. return false;
  3279. } else {
  3280. writeLog("success", "EMAIL TEST: mail has been sent successfully");
  3281. return true;
  3282. }
  3283. }
  3284. function libraryList(){
  3285. $address = qualifyURL(PLEXURL);
  3286. $headers = array(
  3287. "Accept" => "application/json",
  3288. "X-Plex-Token" => PLEXTOKEN
  3289. );
  3290. libxml_use_internal_errors(true);
  3291. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3292. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3293. $api = simplexml_load_string(@curl_get("https://plex.tv/api/servers/$gotServer/shared_servers", $headers));
  3294. $libraryList = array();
  3295. foreach($api->SharedServer->Section AS $child) {
  3296. $libraryList['libraries'][(string)$child['title']] = (string)$child['id'];
  3297. }
  3298. foreach($api->SharedServer AS $child) {
  3299. if(!empty($child['username'])){
  3300. $username = (string)strtolower($child['username']);
  3301. $email = (string)strtolower($child['email']);
  3302. $libraryList['users'][$username] = (string)$child['id'];
  3303. $libraryList['emails'][$email] = (string)$child['id'];
  3304. $libraryList['both'][$username] = $email;
  3305. }
  3306. }
  3307. return (!empty($libraryList) ? array_change_key_case($libraryList,CASE_LOWER) : null );
  3308. }
  3309. function plexUserShare($username){
  3310. $address = qualifyURL(PLEXURL);
  3311. $headers = array(
  3312. "Accept" => "application/json",
  3313. "Content-Type" => "application/json",
  3314. "X-Plex-Token" => PLEXTOKEN
  3315. );
  3316. libxml_use_internal_errors(true);
  3317. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3318. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3319. $json = array(
  3320. "server_id" => $gotServer,
  3321. "shared_server" => array(
  3322. //"library_section_ids" => "[26527637]",
  3323. "invited_email" => $username
  3324. )
  3325. );
  3326. $api = curl_post("https://plex.tv/api/servers/$gotServer/shared_servers/", $json, $headers);
  3327. switch ($api['http_code']['http_code']){
  3328. case 400:
  3329. writeLog("error", "PLEX INVITE: $username already has access to the shared libraries");
  3330. $result = "$username already has access to the shared libraries";
  3331. break;
  3332. case 401:
  3333. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3334. $result = "Invalid Plex Token";
  3335. break;
  3336. case 200:
  3337. writeLog("success", "PLEX INVITE: $username now has access to your Plex Library");
  3338. $result = "$username now has access to your Plex Library";
  3339. break;
  3340. default:
  3341. writeLog("error", "PLEX INVITE: unknown error");
  3342. $result = false;
  3343. }
  3344. return (!empty($result) ? $result : null );
  3345. }
  3346. function plexUserDelete($username){
  3347. $address = qualifyURL(PLEXURL);
  3348. $headers = array(
  3349. "Accept" => "application/json",
  3350. "Content-Type" => "application/json",
  3351. "X-Plex-Token" => PLEXTOKEN
  3352. );
  3353. libxml_use_internal_errors(true);
  3354. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3355. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3356. $id = (is_numeric($username) ? $id : convertPlexName($username, "id"));
  3357. $api = curl_delete("https://plex.tv/api/servers/$gotServer/shared_servers/$id", $headers);
  3358. switch ($api['http_code']['http_code']){
  3359. case 401:
  3360. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3361. $result = "Invalid Plex Token";
  3362. break;
  3363. case 200:
  3364. writeLog("success", "PLEX INVITE: $username doesn't have access to your Plex Library anymore");
  3365. $result = "$username doesn't have access to your Plex Library anymore";
  3366. break;
  3367. default:
  3368. writeLog("error", "PLEX INVITE: unknown error");
  3369. $result = false;
  3370. }
  3371. return (!empty($result) ? $result : null );
  3372. }
  3373. function convertPlexName($user, $type){
  3374. $array = libraryList();
  3375. switch ($type){
  3376. case "username":
  3377. $plexUser = array_search ($user, $array['users']);
  3378. break;
  3379. case "id":
  3380. if (array_key_exists(strtolower($user), $array['users'])) {
  3381. $plexUser = $array['users'][strtolower($user)];
  3382. }
  3383. break;
  3384. default:
  3385. $plexUser = false;
  3386. }
  3387. return (!empty($plexUser) ? $plexUser : null );
  3388. }
  3389. function randomCode($length = 5, $type = null) {
  3390. switch ($type){
  3391. case "alpha":
  3392. $legend = array_merge(range('A', 'Z'));
  3393. break;
  3394. case "numeric":
  3395. $legend = array_merge(range(0,9));
  3396. break;
  3397. default:
  3398. $legend = array_merge(range(0,9),range('A', 'Z'));
  3399. }
  3400. $code = "";
  3401. for($i=0; $i < $length; $i++) {
  3402. $code .= $legend[mt_rand(0, count($legend) - 1)];
  3403. }
  3404. return $code;
  3405. }
  3406. function inviteCodes($action, $code = null, $usedBy = null) {
  3407. if (!isset($GLOBALS['file_db'])) {
  3408. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  3409. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  3410. }
  3411. $now = date("Y-m-d H:i:s");
  3412. switch ($action) {
  3413. case "get":
  3414. // Start Array
  3415. $result = array();
  3416. // Database Lookup
  3417. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes"');
  3418. // Get Codes
  3419. foreach($invites as $row) {
  3420. array_push($result, $row['code']);
  3421. }
  3422. // Return the Results
  3423. return (!empty($result) ? $result : false );
  3424. break;
  3425. case "check":
  3426. // Start Array
  3427. $result = array();
  3428. // Database Lookup
  3429. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes" AND code = "'.$code.'"');
  3430. // Get Codes
  3431. foreach($invites as $row) {
  3432. $result = $row['code'];
  3433. }
  3434. // Return the Results
  3435. return (!empty($result) ? $result : false );
  3436. break;
  3437. case "use":
  3438. $currentIP = get_client_ip();
  3439. $invites = $GLOBALS['file_db']->query('UPDATE invites SET valid = "No", usedby = "'.$usedBy.'", dateused = "'.$now.'", ip = "'.$currentIP.'" WHERE code = "'.$code.'"');
  3440. if(ENABLEMAIL){
  3441. if (!isset($GLOBALS['USER'])) {
  3442. require_once("user.php");
  3443. $GLOBALS['USER'] = new User('registration_callback');
  3444. }
  3445. 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."));
  3446. }
  3447. return (!empty($invites) ? true : false );
  3448. break;
  3449. }
  3450. }
  3451. function plexJoin($username, $email, $password){
  3452. $connectURL = 'https://plex.tv/users.json';
  3453. $headers = array(
  3454. 'Accept'=> 'application/json',
  3455. 'Content-Type' => 'application/x-www-form-urlencoded',
  3456. 'X-Plex-Product' => 'Organizr',
  3457. 'X-Plex-Version' => '1.0',
  3458. 'X-Plex-Client-Identifier' => '01010101-10101010',
  3459. );
  3460. $body = array(
  3461. 'user[email]' => $email,
  3462. 'user[username]' => $username,
  3463. 'user[password]' => $password,
  3464. );
  3465. $api = curl_post($connectURL, $body, $headers);
  3466. $json = json_decode($api['content'], true);
  3467. $errors = (!empty($json['errors']) ? true : false);
  3468. $success = (!empty($json['user']) ? true : false);
  3469. //Use This for later
  3470. $usernameError = (!empty($json['errors']['username']) ? $json['errors']['username'][0] : false);
  3471. $emailError = (!empty($json['errors']['email']) ? $json['errors']['email'][0] : false);
  3472. $passwordError = (!empty($json['errors']['password']) ? $json['errors']['password'][0] : false);
  3473. $errorMessage = "";
  3474. if($errors){
  3475. if($usernameError){ $errorMessage .= "[Username Error: ". $usernameError ."]"; }
  3476. if($emailError){ $errorMessage .= "[Email Error: ". $emailError ."]"; }
  3477. if($passwordError){ $errorMessage .= "[Password Error: ". $passwordError ."]"; }
  3478. }
  3479. switch ($api['http_code']['http_code']){
  3480. case 400:
  3481. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." $username already has access to the shared libraries $errorMessage");
  3482. break;
  3483. case 401:
  3484. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." invalid Plex Token $errorMessage");
  3485. break;
  3486. case 422:
  3487. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." user info error $errorMessage");
  3488. break;
  3489. case 429:
  3490. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." too many requests to plex.tv please try later $errorMessage");
  3491. break;
  3492. case 200:
  3493. case 201:
  3494. writeLog("success", "PLEX JOIN: $username now has access to your Plex Library");
  3495. break;
  3496. default:
  3497. writeLog("error", "PLEX JOIN: unknown error, $errorMessage Error: ".$api['http_code']['http_code']);
  3498. }
  3499. //prettyPrint($api);
  3500. //prettyPrint(json_decode($api['content'], true));
  3501. return (!empty($success) && empty($errors) ? true : false );
  3502. }
  3503. function getCert(){
  3504. $url = "http://curl.haxx.se/ca/cacert.pem";
  3505. $file = getcwd()."/config/cacert.pem";
  3506. $directory = getcwd()."/config/";
  3507. @mkdir($directory, 0770, true);
  3508. if(!file_exists($file)){
  3509. file_put_contents( $file, fopen($url, 'r'));
  3510. writeLog("success", "CERT PEM: pem file created");
  3511. }elseif (file_exists($file) && time() - 2592000 > filemtime($file)) {
  3512. file_put_contents( $file, fopen($url, 'r'));
  3513. writeLog("success", "CERT PEM: downloaded new pem file");
  3514. }
  3515. return $file;
  3516. }
  3517. function customCSS(){
  3518. if(CUSTOMCSS == "true") {
  3519. $template_file = "custom.css";
  3520. $file_handle = fopen($template_file, "rb");
  3521. echo "\n";
  3522. echo fread($file_handle, filesize($template_file));
  3523. fclose($file_handle);
  3524. echo "\n";
  3525. }
  3526. }
  3527. function tvdbToken(){
  3528. $headers = array(
  3529. "Accept" => "application/json",
  3530. "Content-Type" => "application/json"
  3531. );
  3532. $json = array(
  3533. "apikey" => "FBE7B62621F4CAD7",
  3534. "userkey" => "328BB46EB1E9A0F5",
  3535. "username" => "causefx"
  3536. );
  3537. $api = curl_post("https://api.thetvdb.com/login", $json, $headers);
  3538. return json_decode($api['content'], true)['token'];
  3539. }
  3540. function tvdbGet($id){
  3541. $headers = array(
  3542. "Accept" => "application/json",
  3543. "Authorization" => "Bearer ".tvdbToken(),
  3544. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3545. "trakt-api-version" => "2"
  3546. );
  3547. $trakt = curl_get("https://api.trakt.tv/search/tvdb/$id?type=show", $headers);
  3548. @$api['trakt'] = json_decode($trakt, true)[0]['show']['ids'];
  3549. if(empty($api['trakt'])){
  3550. $series = curl_get("https://api.thetvdb.com/series/$id", $headers);
  3551. $poster = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=poster", $headers);
  3552. $backdrop = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=fanart", $headers);
  3553. $api['series'] = json_decode($series, true)['data'];
  3554. $api['poster'] = json_decode($poster, true)['data'];
  3555. $api['backdrop'] = json_decode($backdrop, true)['data'];
  3556. }
  3557. return $api;
  3558. }
  3559. function tvdbSearch($name, $type){
  3560. $name = rawurlencode(preg_replace("/\(([^()]*+|(?R))*\)/","", $name));
  3561. $headers = array(
  3562. "Accept" => "application/json",
  3563. "Authorization" => "Bearer ".tvdbToken(),
  3564. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3565. "trakt-api-version" => "2"
  3566. );
  3567. $trakt = curl_get("https://api.trakt.tv/search/$type?query=$name", $headers);
  3568. @$api['trakt'] = json_decode($trakt, true)[0][$type]['ids'];
  3569. return $api;
  3570. }
  3571. function getPlexPlaylists(){
  3572. $address = qualifyURL(PLEXURL);
  3573. // Perform API requests
  3574. $api = @curl_get($address."/playlists?X-Plex-Token=".PLEXTOKEN);
  3575. libxml_use_internal_errors(true);
  3576. $api = simplexml_load_string($api);
  3577. if (is_array($api) || is_object($api)){
  3578. if (!$api->head->title){
  3579. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3580. if (!$getServer) { return 'Could not load!'; }
  3581. // Identify the local machine
  3582. $gotServer = $getServer['machineIdentifier'];
  3583. $output = "";
  3584. $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">';
  3585. foreach($api AS $child) {
  3586. $items = array();
  3587. if ($child['playlistType'] == "video" && strpos(strtolower($child['title']) , 'private') === false){
  3588. $api = @curl_get($address.$child['key']."?X-Plex-Token=".PLEXTOKEN);
  3589. $api = simplexml_load_string($api);
  3590. if (is_array($api) || is_object($api)){
  3591. if (!$api->head->title){
  3592. $className = preg_replace("/(\W)+/", "", $api['title']);
  3593. $hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  3594. foreach($api->Video AS $child){
  3595. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false,false,$className);
  3596. }
  3597. if (count($items)) {
  3598. $output .= ''.implode('',$items).'';
  3599. }
  3600. }
  3601. }
  3602. }
  3603. }
  3604. $hideMenu .= '</ul></div></div>';
  3605. 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>';
  3606. }else{
  3607. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check token - if HTTPS, is cert valid");
  3608. }
  3609. }else{
  3610. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check URL - if HTTPS, is cert valid");
  3611. }
  3612. }
  3613. function readExternalLog($type,$filename,$name = null){
  3614. $log = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3615. $log = array_reverse($log);
  3616. foreach($log as $line){
  3617. if(!empty($line) && $line[0] != " "){
  3618. $line = strip($line);
  3619. if($type == "single"){
  3620. if( strpos( strtolower($line), "ror" ) !== false ) {
  3621. echo "<tr><td class='red-bg'>".$line."</td></tr>";
  3622. }else{
  3623. echo "<tr><td>".$line."</td></tr>";
  3624. }
  3625. }elseif($type == "all"){
  3626. if( strpos( strtolower($line), "ror" ) !== false ) {
  3627. echo "<tr><td class='red-bg'>".$name."</td>";
  3628. echo "<td class='red-bg'>".$line."</td></tr>";
  3629. }else{
  3630. echo "<tr><td>".$name."</td>";
  3631. echo "<td>".$line."</td></tr>";
  3632. }
  3633. }
  3634. }
  3635. }
  3636. }
  3637. function getLogs(){
  3638. $path = __DIR__ ."/logs/";
  3639. @mkdir($path, 0770, true);
  3640. $logs = array();
  3641. $files = array_diff(scandir($path), array('.', '..'));
  3642. foreach($files as $v){
  3643. $title = explode(".", $v)[0];
  3644. $logs[$title] = $path.$v;
  3645. }
  3646. return $logs;
  3647. }
  3648. function getBackups(){
  3649. $path = DATABASE_LOCATION ."backups/";
  3650. @mkdir($path, 0770, true);
  3651. $backups = array();
  3652. $files = array_diff(scandir($path), array('.', '..'));
  3653. return array_reverse($files);
  3654. }
  3655. function getExtension($string) {
  3656. return preg_replace("#(.+)?\.(\w+)(\?.+)?#", "$2", $string);
  3657. }
  3658. function showFile(){
  3659. $file = $_GET['file'];
  3660. $fileType = getExtension($file);
  3661. if($fileType != 'php'){
  3662. header("Content-type: ".mimeTypes()[$fileType]);
  3663. @readfile($file);
  3664. }
  3665. }
  3666. function getCalendar(){
  3667. $sonarr = new Sonarr(SONARRURL, SONARRKEY);
  3668. $radarr = new Sonarr(RADARRURL, RADARRKEY);
  3669. $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
  3670. $startDate = date('Y-m-d',strtotime("-".CALENDARSTARTDAY." days"));
  3671. $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
  3672. $calendarItems = array();
  3673. if (SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)){
  3674. try {
  3675. $sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate));
  3676. if(!empty($sonarrCalendar)) { $calendarItems = array_merge($calendarItems, $sonarrCalendar); }
  3677. } catch (Exception $e) {
  3678. writeLog("error", "SONARR ERROR: ".strip($e->getMessage()));
  3679. }
  3680. }
  3681. if (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)){
  3682. try {
  3683. $radarrCalendar = getRadarrCalendar($radarr->getCalendar($startDate, $endDate));
  3684. if(!empty($radarrCalendar)) { $calendarItems = array_merge($calendarItems, $radarrCalendar); }
  3685. } catch (Exception $e) {
  3686. writeLog("error", "RADARR ERROR: ".strip($e->getMessage()));
  3687. }
  3688. }
  3689. if (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH)){
  3690. $couchCalendar = getCouchCalendar();
  3691. if(!empty($couchCalendar)) { $calendarItems = array_merge($calendarItems, $couchCalendar); }
  3692. }
  3693. if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
  3694. $headphonesHistory = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory");
  3695. $headphonesWanted = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted");
  3696. if(!empty($headphonesHistory)) { $calendarItems = array_merge($calendarItems, $headphonesHistory); }
  3697. if(!empty($headphonesWanted)) { $calendarItems = array_merge($calendarItems, $headphonesWanted); }
  3698. }
  3699. if (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)){
  3700. try {
  3701. $sickrageFuture = getSickrageCalendarWanted($sickrage->future());
  3702. if(!empty($sickrageFuture)) { $calendarItems = array_merge($calendarItems, $sickrageFuture); }
  3703. } catch (Exception $e) {
  3704. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3705. } try {
  3706. $sickrageHistory = getSickrageCalendarHistory($sickrage->history("100","downloaded"));
  3707. if(!empty($sickrageHistory)) { $calendarItems = array_merge($calendarItems, $sickrageHistory); }
  3708. } catch (Exception $e) {
  3709. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3710. }
  3711. }
  3712. return $calendarItems;
  3713. }
  3714. function localURL($url){
  3715. if (strpos($url, 'https') !== false) {
  3716. preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $url, $result);
  3717. $result = (!empty($result) ? true : false);
  3718. return $result;
  3719. }
  3720. }
  3721. function fileArray($files){
  3722. foreach($files as $file){
  3723. if(file_exists($file)){
  3724. $list[] = $file;
  3725. }
  3726. }
  3727. if(!empty($list)){ return $list; }
  3728. }
  3729. function backupDB(){
  3730. if (extension_loaded('ZIP')) {
  3731. $directory = DATABASE_LOCATION."backups/";
  3732. @mkdir($directory, 0770, true);
  3733. $orgFiles = array(
  3734. 'css' => 'custom.css',
  3735. 'temp' => 'cus.sd',
  3736. 'orgLog' => 'org.log',
  3737. 'loginLog' => 'loginLog.json',
  3738. 'chatDB' => 'chatpack.db',
  3739. 'config' => 'config/config.php',
  3740. 'database' => DATABASE_LOCATION.'users.db'
  3741. );
  3742. $files = fileArray($orgFiles);
  3743. if(!empty($files)){
  3744. writeLog("success", "BACKUP: backup process started");
  3745. $zipname = $directory.'backup['.date('Y-m-d_H-i').']['.INSTALLEDVERSION.'].zip';
  3746. $zip = new ZipArchive;
  3747. $zip->open($zipname, ZipArchive::CREATE);
  3748. foreach ($files as $file) {
  3749. $zip->addFile($file);
  3750. }
  3751. $zip->close();
  3752. writeLog("success", "BACKUP: backup process finished");
  3753. return true;
  3754. }else{
  3755. return false;
  3756. }
  3757. }else{
  3758. return false;
  3759. }
  3760. }
  3761. class Ping {
  3762. private $host;
  3763. private $ttl;
  3764. private $timeout;
  3765. private $port = 80;
  3766. private $data = 'Ping';
  3767. private $commandOutput;
  3768. /**
  3769. * Called when the Ping object is created.
  3770. *
  3771. * @param string $host
  3772. * The host to be pinged.
  3773. * @param int $ttl
  3774. * Time-to-live (TTL) (You may get a 'Time to live exceeded' error if this
  3775. * value is set too low. The TTL value indicates the scope or range in which
  3776. * a packet may be forwarded. By convention:
  3777. * - 0 = same host
  3778. * - 1 = same subnet
  3779. * - 32 = same site
  3780. * - 64 = same region
  3781. * - 128 = same continent
  3782. * - 255 = unrestricted
  3783. * @param int $timeout
  3784. * Timeout (in seconds) used for ping and fsockopen().
  3785. * @throws \Exception if the host is not set.
  3786. */
  3787. public function __construct($host, $ttl = 255, $timeout = 10) {
  3788. if (!isset($host)) {
  3789. throw new \Exception("Error: Host name not supplied.");
  3790. }
  3791. $this->host = $host;
  3792. $this->ttl = $ttl;
  3793. $this->timeout = $timeout;
  3794. }
  3795. /**
  3796. * Set the ttl (in hops).
  3797. *
  3798. * @param int $ttl
  3799. * TTL in hops.
  3800. */
  3801. public function setTtl($ttl) {
  3802. $this->ttl = $ttl;
  3803. }
  3804. /**
  3805. * Get the ttl.
  3806. *
  3807. * @return int
  3808. * The current ttl for Ping.
  3809. */
  3810. public function getTtl() {
  3811. return $this->ttl;
  3812. }
  3813. /**
  3814. * Set the timeout.
  3815. *
  3816. * @param int $timeout
  3817. * Time to wait in seconds.
  3818. */
  3819. public function setTimeout($timeout) {
  3820. $this->timeout = $timeout;
  3821. }
  3822. /**
  3823. * Get the timeout.
  3824. *
  3825. * @return int
  3826. * Current timeout for Ping.
  3827. */
  3828. public function getTimeout() {
  3829. return $this->timeout;
  3830. }
  3831. /**
  3832. * Set the host.
  3833. *
  3834. * @param string $host
  3835. * Host name or IP address.
  3836. */
  3837. public function setHost($host) {
  3838. $this->host = $host;
  3839. }
  3840. /**
  3841. * Get the host.
  3842. *
  3843. * @return string
  3844. * The current hostname for Ping.
  3845. */
  3846. public function getHost() {
  3847. return $this->host;
  3848. }
  3849. /**
  3850. * Set the port (only used for fsockopen method).
  3851. *
  3852. * Since regular pings use ICMP and don't need to worry about the concept of
  3853. * 'ports', this is only used for the fsockopen method, which pings servers by
  3854. * checking port 80 (by default).
  3855. *
  3856. * @param int $port
  3857. * Port to use for fsockopen ping (defaults to 80 if not set).
  3858. */
  3859. public function setPort($port) {
  3860. $this->port = $port;
  3861. }
  3862. /**
  3863. * Get the port (only used for fsockopen method).
  3864. *
  3865. * @return int
  3866. * The port used by fsockopen pings.
  3867. */
  3868. public function getPort() {
  3869. return $this->port;
  3870. }
  3871. /**
  3872. * Return the command output when method=exec.
  3873. * @return string
  3874. */
  3875. public function getCommandOutput(){
  3876. return $this->commandOutput;
  3877. }
  3878. /**
  3879. * Matches an IP on command output and returns.
  3880. * @return string
  3881. */
  3882. public function getIpAddress() {
  3883. $out = array();
  3884. if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $this->commandOutput, $out)){
  3885. return $out[0];
  3886. }
  3887. return null;
  3888. }
  3889. /**
  3890. * Ping a host.
  3891. *
  3892. * @param string $method
  3893. * Method to use when pinging:
  3894. * - exec (default): Pings through the system ping command. Fast and
  3895. * robust, but a security risk if you pass through user-submitted data.
  3896. * - fsockopen: Pings a server on port 80.
  3897. * - socket: Creates a RAW network socket. Only usable in some
  3898. * environments, as creating a SOCK_RAW socket requires root privileges.
  3899. *
  3900. * @throws InvalidArgumentException if $method is not supported.
  3901. *
  3902. * @return mixed
  3903. * Latency as integer, in ms, if host is reachable or FALSE if host is down.
  3904. */
  3905. public function ping($method = 'exec') {
  3906. $latency = false;
  3907. switch ($method) {
  3908. case 'exec':
  3909. $latency = $this->pingExec();
  3910. break;
  3911. case 'fsockopen':
  3912. $latency = $this->pingFsockopen();
  3913. break;
  3914. case 'socket':
  3915. $latency = $this->pingSocket();
  3916. break;
  3917. default:
  3918. throw new \InvalidArgumentException('Unsupported ping method.');
  3919. }
  3920. // Return the latency.
  3921. return $latency;
  3922. }
  3923. /**
  3924. * The exec method uses the possibly insecure exec() function, which passes
  3925. * the input to the system. This is potentially VERY dangerous if you pass in
  3926. * any user-submitted data. Be SURE you sanitize your inputs!
  3927. *
  3928. * @return int
  3929. * Latency, in ms.
  3930. */
  3931. private function pingExec() {
  3932. $latency = false;
  3933. $ttl = escapeshellcmd($this->ttl);
  3934. $timeout = escapeshellcmd($this->timeout);
  3935. $host = escapeshellcmd($this->host);
  3936. // Exec string for Windows-based systems.
  3937. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  3938. // -n = number of pings; -i = ttl; -w = timeout (in milliseconds).
  3939. $exec_string = 'ping -n 1 -i ' . $ttl . ' -w ' . ($timeout * 1000) . ' ' . $host;
  3940. }
  3941. // Exec string for Darwin based systems (OS X).
  3942. else if(strtoupper(PHP_OS) === 'DARWIN') {
  3943. // -n = numeric output; -c = number of pings; -m = ttl; -t = timeout.
  3944. $exec_string = 'ping -n -c 1 -m ' . $ttl . ' -t ' . $timeout . ' ' . $host;
  3945. }
  3946. // Exec string for other UNIX-based systems (Linux).
  3947. else {
  3948. // -n = numeric output; -c = number of pings; -t = ttl; -W = timeout
  3949. $exec_string = 'ping -n -c 1 -t ' . $ttl . ' -W ' . $timeout . ' ' . $host . ' 2>&1';
  3950. }
  3951. exec($exec_string, $output, $return);
  3952. // Strip empty lines and reorder the indexes from 0 (to make results more
  3953. // uniform across OS versions).
  3954. $this->commandOutput = implode($output, '');
  3955. $output = array_values(array_filter($output));
  3956. // If the result line in the output is not empty, parse it.
  3957. if (!empty($output[1])) {
  3958. // Search for a 'time' value in the result line.
  3959. $response = preg_match("/time(?:=|<)(?<time>[\.0-9]+)(?:|\s)ms/", $output[1], $matches);
  3960. // If there's a result and it's greater than 0, return the latency.
  3961. if ($response > 0 && isset($matches['time'])) {
  3962. $latency = round($matches['time'], 2);
  3963. }
  3964. }
  3965. return $latency;
  3966. }
  3967. /**
  3968. * The fsockopen method simply tries to reach the host on a port. This method
  3969. * is often the fastest, but not necessarily the most reliable. Even if a host
  3970. * doesn't respond, fsockopen may still make a connection.
  3971. *
  3972. * @return int
  3973. * Latency, in ms.
  3974. */
  3975. private function pingFsockopen() {
  3976. $start = microtime(true);
  3977. // fsockopen prints a bunch of errors if a host is unreachable. Hide those
  3978. // irrelevant errors and deal with the results instead.
  3979. $fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
  3980. if (!$fp) {
  3981. $latency = false;
  3982. }
  3983. else {
  3984. $latency = microtime(true) - $start;
  3985. $latency = round($latency * 1000, 2);
  3986. }
  3987. return $latency;
  3988. }
  3989. /**
  3990. * The socket method uses raw network packet data to try sending an ICMP ping
  3991. * packet to a server, then measures the response time. Using this method
  3992. * requires the script to be run with root privileges, though, so this method
  3993. * only works reliably on Windows systems and on Linux servers where the
  3994. * script is not being run as a web user.
  3995. *
  3996. * @return int
  3997. * Latency, in ms.
  3998. */
  3999. private function pingSocket() {
  4000. // Create a package.
  4001. $type = "\x08";
  4002. $code = "\x00";
  4003. $checksum = "\x00\x00";
  4004. $identifier = "\x00\x00";
  4005. $seq_number = "\x00\x00";
  4006. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4007. // Calculate the checksum.
  4008. $checksum = $this->calculateChecksum($package);
  4009. // Finalize the package.
  4010. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4011. // Create a socket, connect to server, then read socket and calculate.
  4012. if ($socket = socket_create(AF_INET, SOCK_RAW, 1)) {
  4013. socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array(
  4014. 'sec' => 10,
  4015. 'usec' => 0,
  4016. ));
  4017. // Prevent errors from being printed when host is unreachable.
  4018. @socket_connect($socket, $this->host, null);
  4019. $start = microtime(true);
  4020. // Send the package.
  4021. @socket_send($socket, $package, strlen($package), 0);
  4022. if (socket_read($socket, 255) !== false) {
  4023. $latency = microtime(true) - $start;
  4024. $latency = round($latency * 1000, 2);
  4025. }
  4026. else {
  4027. $latency = false;
  4028. }
  4029. }
  4030. else {
  4031. $latency = false;
  4032. }
  4033. // Close the socket.
  4034. socket_close($socket);
  4035. return $latency;
  4036. }
  4037. /**
  4038. * Calculate a checksum.
  4039. *
  4040. * @param string $data
  4041. * Data for which checksum will be calculated.
  4042. *
  4043. * @return string
  4044. * Binary string checksum of $data.
  4045. */
  4046. private function calculateChecksum($data) {
  4047. if (strlen($data) % 2) {
  4048. $data .= "\x00";
  4049. }
  4050. $bit = unpack('n*', $data);
  4051. $sum = array_sum($bit);
  4052. while ($sum >> 16) {
  4053. $sum = ($sum >> 16) + ($sum & 0xffff);
  4054. }
  4055. return pack('n*', ~$sum);
  4056. }
  4057. }
  4058. function ping($pings, $type = "string") {
  4059. $ping = new Ping("");
  4060. $ping->setTtl(128);
  4061. $ping->setTimeout(2);
  4062. switch ($type){
  4063. case "array":
  4064. $results = [];
  4065. foreach ($pings as $k => $v) {
  4066. if(strpos($v, ':') !== false){
  4067. $domain = explode(':', $v)[0];
  4068. $port = explode(':', $v)[1];
  4069. $ping->setHost($domain);
  4070. $ping->setPort($port);
  4071. $latency = $ping->ping('fsockopen');
  4072. }else{
  4073. $ping->setHost($v);
  4074. $latency = $ping->ping();
  4075. }
  4076. if ($latency || $latency === 0) {
  4077. $results[$k] = $latency;
  4078. } else {
  4079. $results[$k] = 0;
  4080. }
  4081. }
  4082. break;
  4083. case "string":
  4084. if(strpos($pings, ':') !== false){
  4085. $domain = explode(':', $pings)[0];
  4086. $port = explode(':', $pings)[1];
  4087. $ping->setHost($domain);
  4088. $ping->setPort($port);
  4089. $latency = $ping->ping('fsockopen');
  4090. }else{
  4091. $ping->setHost($pings);
  4092. $latency = $ping->ping();
  4093. }
  4094. if ($latency || $latency === 0) {
  4095. $results = $latency;
  4096. } else {
  4097. $results = 0;
  4098. }
  4099. break;
  4100. }
  4101. return $results;
  4102. }
  4103. function getPing($url, $style, $refresh = null){
  4104. if(ping($url) !== 0){
  4105. $class = 'success';
  4106. if(!$refresh){
  4107. $class .= " animated slideInLeft";
  4108. }
  4109. }else{
  4110. $class = "warning";
  4111. if(!$refresh){
  4112. $class .= " animated flash loop-animation-timeout";
  4113. }
  4114. }
  4115. echo '<span class="pingcheck badge ping-'.$class.'" style="position: absolute;z-index: 100;right: 5px; padding: 0px 0px;'.$style.';font-size: 10px;">&nbsp;</span>';
  4116. }
  4117. function speedTestData(){
  4118. $file_db = DATABASE_LOCATION."speedtest.db";
  4119. if(file_exists($file_db)){
  4120. $conn = new PDO("sqlite:$file_db") or die("1");
  4121. $result = $conn->query('SELECT * FROM speedtest_users');
  4122. $conn = null;
  4123. if (is_array($result) || is_object($result)){
  4124. foreach($result as $k => $v){
  4125. $return[$k] = $v;
  4126. }
  4127. return $return;
  4128. }
  4129. }
  4130. }
  4131. function speedTestDisplay($array, $output){
  4132. if (is_array($array) || is_object($array)){
  4133. if($output == "graph"){
  4134. $result = "Morris.Line({element: 'morris-line',data: [";
  4135. foreach($array as $k => $v){
  4136. $result .= "{ y: '".substr($v['timestamp'],0,10)."', a: ".$v['ul'].", b: ".$v['dl'].", c: ".$v['ping']." },";
  4137. }
  4138. $result .= "],xkey: 'y',ykeys: ['a', 'b', 'c'],labels: ['Upload', 'Download', 'Ping'],hideHover: 'auto',resize: true,lineColors: ['#63A8EB','#ccc','#000'] });";
  4139. }elseif($output == "table"){
  4140. $result = "";
  4141. foreach($array as $k => $v){
  4142. $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>";
  4143. }
  4144. }
  4145. return $result;
  4146. }
  4147. }
  4148. function buildMenuPhone($array){
  4149. if (is_array($array) || is_object($array)){
  4150. $result = '
  4151. <div class="content-box profile-sidebar box-shadow">
  4152. <img src="images/organizr-logo-h-d.png" width="100%" style="margin-top: -10px;">
  4153. <div class="profile-usermenu">
  4154. <ul class="nav" id="settings-list">
  4155. ';
  4156. foreach($array as $k => $v){
  4157. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4158. continue;
  4159. }
  4160. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4161. continue;
  4162. }
  4163. /*$result .= '
  4164. <li>
  4165. <a id="'.$v['id'].'" box="'.$v['box'].'">'.$v['name'].'
  4166. <span class="fa-stack fa-fw pull-right" style="margin-top: -5px;margin-right: -10px;">
  4167. <i class="fa fa-'.$v['icon_1'].' fa-stack-2x '.$v['color'].'" style="font-size:null;"></i>
  4168. <i class="fa fa-'.$v['icon_2'].' fa-stack-1x fa-inverse"></i>
  4169. </span>
  4170. </a>
  4171. </li>
  4172. ';*/
  4173. $result .= '<li><a id="'.$v['id'].'" box="'.$v['box'].'"><i class="fa fa-'.$v['icon_2'].' '.$v['color'].' fa-fw pull-right"></i>'.$v['name'].'</a></li>';
  4174. }
  4175. $result .= '</ul></div></div>';
  4176. return $result;
  4177. }
  4178. }
  4179. function buildMenu($array){
  4180. if (is_array($array) || is_object($array)){
  4181. $result = '<div class="settingsList">';
  4182. foreach($array as $k => $v){
  4183. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4184. continue;
  4185. }
  4186. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4187. continue;
  4188. }
  4189. $result .= '
  4190. <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">
  4191. <i class="mdi mdi-'.$v['icon_1'].' fa-fw pull-left" style="padding-left: '.$v['padding'].'px;font-size: 30px"></i>
  4192. <p class="" style="text-align: center;direction: rtl;display:none;margin: 2px;"><strong>'.$v['name'].'</strong></p>
  4193. </button>
  4194. ';
  4195. }
  4196. $result .= '</div>';
  4197. return $result;
  4198. }
  4199. }
  4200. function requestInvite($email, $username){
  4201. //sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null){
  4202. //orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  4203. 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."));
  4204. }
  4205. function errormessage($msg) {
  4206. echo "<div style=\"margin-top: 50px;\">";
  4207. echo "<span style=\"color:#d89334;\">error </span>";
  4208. echo $msg;
  4209. echo "</div>";
  4210. }
  4211. function getOrgUsers(){
  4212. $file_db = DATABASE_LOCATION."users.db";
  4213. if(file_exists($file_db)){
  4214. $conn = new PDO("sqlite:$file_db") or die("1");
  4215. $result = $conn->query('SELECT * FROM users');
  4216. $conn = null;
  4217. if (is_array($result) || is_object($result)){
  4218. foreach($result as $k => $v){
  4219. $return[$v['username']] = $v['email'];
  4220. }
  4221. return $return;
  4222. }
  4223. }
  4224. }
  4225. function getEmails($type = 'org'){
  4226. if($type == 'plex'){
  4227. $emails = array_merge(libraryList()['both'],getOrgUsers());
  4228. }elseif($type == 'emby'){
  4229. $emails = getOrgUsers();
  4230. }else{
  4231. $emails = getOrgUsers();
  4232. }
  4233. return $emails;
  4234. }
  4235. function printEmails($emails){
  4236. $result = '';
  4237. foreach($emails as $k => $v){
  4238. $result .= '<option value="'.$v.'">'.$k.'</option>';
  4239. }
  4240. return $result;
  4241. }
  4242. function massEmail($to, $subject, $message){
  4243. if (!isset($GLOBALS['file_db'])) {
  4244. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  4245. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  4246. }
  4247. sendEmail(null, null, $subject, orgEmail("Message From Admin", "Important Information", "There", $message, null, null, "Thank You!", "Thanks for taking the time to read this message from me."),$GLOBALS['USER']->adminEmail,$to);
  4248. }
  4249. function q2a($q){
  4250. if (is_array($q) || is_object($q)){
  4251. foreach ($q as $k => $v){
  4252. $a[$k] = $v;
  4253. }
  4254. if(!empty($a)){
  4255. return $a;
  4256. }
  4257. }
  4258. }
  4259. function getOmbiToken($username, $password){
  4260. $headers = array(
  4261. "Accept" => "application/json",
  4262. "Content-Type" => "application/json"
  4263. );
  4264. $json = array(
  4265. "username" => $username,
  4266. "password" => $password,
  4267. "rememberMe" => "true",
  4268. );
  4269. $api = curl_post(OMBIURL."/api/v1/Token", $json, $headers);
  4270. return json_decode($api['content'], true)['access_token'];
  4271. }
  4272. function ombiAction($id, $action, $type){
  4273. $headers = array(
  4274. "Accept" => "application/json",
  4275. "Content-Type" => "application/json",
  4276. "Apikey" => OMBIKEY
  4277. );
  4278. switch ($type) {
  4279. case 'season':
  4280. case 'tv':
  4281. $type = 'tv';
  4282. break;
  4283. default:
  4284. $type = 'movie';
  4285. break;
  4286. }
  4287. switch ($action) {
  4288. case 'approve':
  4289. # code...
  4290. break;
  4291. case 'deny':
  4292. # code...
  4293. break;
  4294. case 'delete':
  4295. $api = curl_delete(OMBIURL."/api/v1/Request/".$type."/".$id, $headers);
  4296. break;
  4297. default:
  4298. # code...
  4299. break;
  4300. }
  4301. switch ($api['http_code']['http_code']){
  4302. case 401:
  4303. writeLog("error", "OMBI: Invalid API KEY");
  4304. return false;
  4305. break;
  4306. case 200:
  4307. writeLog("success", "OMBI: action completed successfully");
  4308. return true;
  4309. break;
  4310. default:
  4311. writeLog("error", "OMBI: unknown error with request [type: $type | action: $action | id: $id]");
  4312. return false;
  4313. }
  4314. //return (!empty($result) ? $result : null );
  4315. }
  4316. function getOmbiRequests($type = "both"){
  4317. $headers = array(
  4318. "Accept" => "application/json",
  4319. "Apikey" => OMBIKEY,
  4320. );
  4321. $requests = array();
  4322. switch ($type) {
  4323. case 'movie':
  4324. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4325. break;
  4326. case 'tv':
  4327. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4328. break;
  4329. default:
  4330. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4331. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4332. break;
  4333. }
  4334. if(isset($movie)){
  4335. foreach ($movie as $key => $value) {
  4336. $requests['movie'][] = array(
  4337. 'id' => $value['theMovieDbId'],
  4338. 'title' => $value['title'],
  4339. 'poster' => (strpos($value['posterPath'], "http") !== false) ? $value['posterPath'] : 'https://image.tmdb.org/t/p/w300/'.$value['posterPath'],
  4340. 'approved' => $value['approved'],
  4341. 'available' => $value['available'],
  4342. 'denied' => $value['denied'],
  4343. 'deniedReason' => $value['deniedReason'],
  4344. 'user' => $value['requestedUser']['userName'],
  4345. 'request_id' => $value['id'],
  4346. );
  4347. }
  4348. }
  4349. if(isset($tv) && (is_array($tv) || is_object($tv))){
  4350. foreach ($tv as $key => $value) {
  4351. $requests['tv'][] = array(
  4352. 'id' => $value['tvDbId'],
  4353. 'title' => $value['title'],
  4354. 'poster' => $value['posterPath'],
  4355. 'approved' => $value['childRequests'][0]['approved'],
  4356. 'available' => $key['childRequests'][0]['available'],
  4357. 'denied' => $key['childRequests'][0]['denied'],
  4358. 'deniedReason' => $key['childRequests'][0]['deniedReason'],
  4359. 'user' => $value['childRequests'][0]['requestedUser']['userName'],
  4360. 'request_id' => $value['id'],
  4361. );
  4362. }
  4363. }
  4364. return (empty($requests)) ? '' : $requests;
  4365. }
  4366. function convertOmbiString($type, $value){
  4367. switch ($type) {
  4368. case 'approved':
  4369. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4370. $string['icon'] = ($value) ? 'mdi mdi-check' : 'mdi mdi-clock';
  4371. $string['color'] = ($value) ? 'green-bg' : 'yellow-bg';
  4372. break;
  4373. case 'available':
  4374. $string['string'] = ($value) ? 'Available' : 'Not Downloaded';
  4375. $string['icon'] = ($value) ? 'mdi mdi-server' : 'mdi mdi-server-off';
  4376. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4377. break;
  4378. case 'denied':
  4379. $string['string'] = ($value) ? 'Denied' : 'Approved';
  4380. $string['icon'] = ($value) ? 'mdi mdi-emoticon-sad' : 'mdi mdi-emoticon-happy';
  4381. $string['color'] = ($value) ? 'red-bg' : 'green-bg';
  4382. break;
  4383. case 'status':
  4384. switch ($value) {
  4385. case '1':
  4386. $string['string'] = 'Denied';
  4387. $string['icon'] = 'mdi mdi-window-close';
  4388. $string['color'] = 'red-bg';
  4389. break;
  4390. case '2':
  4391. $string['string'] = 'Approved';
  4392. $string['icon'] = 'mdi mdi-check';
  4393. $string['color'] = 'green-bg';
  4394. break;
  4395. case '3':
  4396. $string['string'] = 'Not Approved';
  4397. $string['icon'] = 'mdi mdi-clock';
  4398. $string['color'] = 'yellow-bg';
  4399. break;
  4400. default:
  4401. # code...
  4402. break;
  4403. }
  4404. break;
  4405. default:
  4406. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4407. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4408. break;
  4409. }
  4410. return $string;
  4411. }
  4412. function buildOmbiItem($type, $group, $user, $request){
  4413. if (is_array($request) || is_object($request)){
  4414. $actions = '';
  4415. if($request['denied']){
  4416. $status = 1;
  4417. $actions .= '<li request-type="'.$type.'" request-id="'.$request['id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve - Not Active</a></li>';
  4418. }else{
  4419. if($request['approved']){
  4420. $status = 2;
  4421. }else{
  4422. $status = 3;
  4423. $actions .= '<li request-type="'.$type.'" request-id="'.$request['id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve - Not Active</a></li>';
  4424. $actions .= '<li request-type="'.$type.'" request-id="'.$request['id'].'" request-name="deny"><a class="requestAction" href="javascript:void(0)">Deny - Not Active</a></li>';
  4425. }
  4426. }
  4427. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="delete"><a class="requestAction" href="javascript:void(0)">Delete</a></li>';
  4428. if(isset($group) && $group == 'admin'){
  4429. return '
  4430. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4431. <div class="requestOptions">
  4432. <div class="btn-group transparent" role="group">
  4433. <button type="button" class="btn waves btn-success btn-sm dropdown-toggle waves-effect waves-float transparent" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="mdi mdi-dots-vertical mdi-24px"></i></button>
  4434. <ul class="dropdown-menu"><h6 class="text-center">'.$request['user'].'</h6>'.$actions.'</ul>
  4435. </div>
  4436. </div>
  4437. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4438. <div class="requestBottom text-center">
  4439. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4440. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4441. </div>
  4442. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4443. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4444. </div>
  4445. </div>
  4446. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4447. </div>';
  4448. }elseif(isset($group) && $group == 'user'){
  4449. if(strtolower($request['user']) == strtolower($user)){
  4450. return '
  4451. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4452. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4453. <div class="requestBottom text-center">
  4454. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4455. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4456. </div>
  4457. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4458. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4459. </div>
  4460. </div>
  4461. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4462. </div>';
  4463. }
  4464. }
  4465. }
  4466. }
  4467. function buildOmbiList($group, $user){
  4468. $requests = array();
  4469. $openTab = 'true';
  4470. $movieList = getOmbiRequests('movie');
  4471. $tvList = getOmbiRequests('tv');
  4472. if (is_array($movieList) || is_object($movieList)){
  4473. foreach ($movieList['movie'] as $request) {
  4474. $requests[] = buildOmbiItem('movie', $group, $user, $request);
  4475. }
  4476. }
  4477. if (is_array($tvList) || is_object($tvList)){
  4478. foreach ($tvList['tv'] as $request) {
  4479. $requests[] = buildOmbiItem('season', $group, $user, $request);
  4480. }
  4481. }
  4482. return outputOmbiRequests("Requested Content", $requests, "
  4483. setInterval(function() {
  4484. $('<div></div>').load('ajax.php?a=ombi-requests',function() {
  4485. var element = $(this).find('#recentRequests');
  4486. var loadedID = element.attr('id');
  4487. $('#recentRequests').replaceWith(element);
  4488. console.log('Loaded updated: '+loadedID);
  4489. loadSlick();
  4490. });
  4491. }, ".RECENTREFRESH.");
  4492. ", false);
  4493. }
  4494. function outputOmbiRequests($header = "Requested Content", $items, $script = false, $array) {
  4495. $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-request-event">';
  4496. if(preg_grep("/item-movie-Approved/", $items)){
  4497. $hideMenu .= '<li data-filter="item-movie-Approved" data-name="Approved Movies" data-filter-on="false"><a class="js-filter-movie" href="javascript:void(0)">Approved Movies</a></li>';
  4498. }
  4499. if(preg_grep("/item-movie-Approval-Pending/", $items)){
  4500. $hideMenu .= '<li data-filter="item-movie-Approval-Pending" data-name="Approval Pending Movies" data-filter-on="false"><a class="js-filter-movie" href="javascript:void(0)">Approval Pending Movies</a></li>';
  4501. }
  4502. if(preg_grep("/item-season-Approved/", $items)){
  4503. $hideMenu .= '<li data-filter="item-season-Approved" data-name="Approved TV Shows" data-filter-on="false"><a class="js-filter-season" href="javascript:void(0)">Approved Shows</a></li>';
  4504. }
  4505. if(preg_grep("/item-season-Approval-Pending/", $items)){
  4506. $hideMenu .= '<li data-filter="item-season-Approval-Pending" data-name="Approval Pending TV Shows" data-filter-on="false"><a class="js-filter-season" href="javascript:void(0)">Approval Pending Shows</a></li>';
  4507. }
  4508. $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>';
  4509. $hideMenu .= '</ul></div></div>';
  4510. // If None Populate Empty Item
  4511. if (!count($items)) {
  4512. return '<div id="recentRequests" class="content-box box-shadow big-box"><h5 class="text-center">'.$header.'</h5><p class="text-center">No Requests Found</p></div>';
  4513. }else{
  4514. $className = str_replace(' ', '', $header);
  4515. return '<div id="recentRequests" class="content-box box-shadow big-box"><h5 id="requestContent-title" style="margin-bottom: -20px" class="text-center">'.$header.'</h5><div class="recentHeader inbox-pagination '.$className.'">'.$hideMenu.'</div><br/><br/><div class="recentItems-request" data-name="'.$className.'">'.implode('',$items).'</div></div>'.($script?'<script>'.$script.'</script>':'');
  4516. }
  4517. }
  4518. function buildHomepageSettings(){
  4519. $homepageOrder = homepageOrder();
  4520. $homepageList = '<h4>Drag Homepage Items to Order Them</h4><div id="homepage-items" class="external-events">';
  4521. $inputList = '<div id="homepage-values">';
  4522. foreach ($homepageOrder as $key => $val) {
  4523. $homepageList .= '
  4524. <div class="fc-event blue-bg">
  4525. <span class="ordinal-position text-uppercase" data-link="'.$key.'" style="float:left">'.strtoupper($val).'</span>
  4526. &nbsp; '.substr($key, 13).'
  4527. <span class="fa fa-bars remove-event"></span>
  4528. </div>';
  4529. $inputList .= '<input type="hidden" name="'.$key.'">';
  4530. }
  4531. $homepageList .= '</div>';
  4532. $inputList .= '</div>';
  4533. return $homepageList.$inputList;
  4534. }
  4535. function buildHomepage($group, $user){
  4536. $homepageOrder = homepageOrder();
  4537. $homepageBuilt = '';
  4538. foreach ($homepageOrder as $key => $value) {
  4539. $homepageBuilt .= buildHomepageItem($key, $group, $user);
  4540. }
  4541. return $homepageBuilt;
  4542. }
  4543. function realSize($bytes, $decimals = 2) {
  4544. $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
  4545. $factor = floor((strlen($bytes) - 1) / 3);
  4546. return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' '.@$size[$factor];
  4547. }
  4548. function buildHomepageItem($homepageItem, $group, $user){
  4549. $homepageItemBuilt = '';
  4550. switch ($homepageItem) {
  4551. case 'homepageOrderplexsearch':
  4552. if((qualifyUser(PLEXSEARCHAUTH) && PLEXSEARCH == "true" && qualifyUser(PLEXHOMEAUTH))) {
  4553. $homepageItemBuilt .= '
  4554. <div id="searchPlexRow" class="row">
  4555. <div class="col-lg-12">
  4556. <div class="content-box box-shadow big-box todo-list">
  4557. <form id="plexSearchForm" onsubmit="return false;" autocomplete="off">
  4558. <div class="">
  4559. <div class="input-group">
  4560. <div style="border-radius: 25px 0 0 25px; border:0" class="input-group-addon gray-bg"><i class="fa fa-search white"></i></div>
  4561. <input id="searchInput" type="text" style="border-radius: 0;" autocomplete="off" name="search-title" class="form-control input-group-addon gray-bg" placeholder="Media Search">
  4562. <div id="clearSearch" style="border-radius: 0 25px 25px 0;border:0; cursor: pointer;" class="input-group-addon gray-bg"><i class="fa fa-close white"></i></div>
  4563. <button style="display:none" id="plexSearchForm_submit" class="btn btn-primary waves"></button>
  4564. </div>
  4565. </div>
  4566. </form>
  4567. <div id="resultshere" class="table-responsive"></div>
  4568. </div>
  4569. </div>
  4570. </div>
  4571. ';
  4572. }
  4573. break;
  4574. case 'homepageOrdercustomhtml':
  4575. if (qualifyUser(HOMEPAGECUSTOMHTML1AUTH) && HOMEPAGECUSTOMHTML1) {
  4576. $homepageItemBuilt .= "<div>" . HOMEPAGECUSTOMHTML1 . "</div>";
  4577. }
  4578. break;
  4579. case 'homepageOrdernotice':
  4580. if (qualifyUser(HOMEPAGENOTICEAUTH) && HOMEPAGENOTICETITLE && HOMEPAGENOTICETYPE && HOMEPAGENOTICEMESSAGE && HOMEPAGENOTICELAYOUT) {
  4581. $homepageItemBuilt .= buildHomepageNotice(HOMEPAGENOTICELAYOUT, HOMEPAGENOTICETYPE, HOMEPAGENOTICETITLE, HOMEPAGENOTICEMESSAGE);
  4582. }
  4583. break;
  4584. case 'homepageOrderspeedtest':
  4585. if(SPEEDTEST == "true" && qualifyUser(SPEEDTESTAUTH)){
  4586. $homepageItemBuilt .= '
  4587. <style type="text/css">
  4588. .flash {
  4589. animation: flash 0.6s linear infinite;
  4590. }
  4591. @keyframes flash {
  4592. 0% { opacity: 0.6; }
  4593. 50% { opacity: 1; }
  4594. }
  4595. </style>
  4596. <script type="text/javascript">
  4597. var w = null
  4598. function runTest() {
  4599. document.getElementById("startBtn").style.display = "none"
  4600. document.getElementById("testArea").style.display = ""
  4601. document.getElementById("abortBtn").style.display = ""
  4602. w = new Worker("bower_components/speed/speedtest_worker.js")
  4603. var interval = setInterval(function () { w.postMessage("status") }, 100)
  4604. w.onmessage = function (event) {
  4605. var data = event.data.split(";")
  4606. var status = Number(data[0])
  4607. var dl = document.getElementById("download")
  4608. var ul = document.getElementById("upload")
  4609. var ping = document.getElementById("ping")
  4610. var jitter = document.getElementById("jitter")
  4611. dl.className = status === 1 ? "w-name flash" : "w-name"
  4612. ping.className = status === 2 ? "w-name flash" : "w-name"
  4613. jitter.className = ul.className = status === 3 ? "w-name flash" : "w-name"
  4614. if (status >= 4) {
  4615. clearInterval(interval)
  4616. document.getElementById("abortBtn").style.display = "none"
  4617. document.getElementById("startBtn").style.display = ""
  4618. w = null
  4619. }
  4620. if (status === 5) {
  4621. document.getElementById("testArea").style.display = "none"
  4622. }
  4623. dl.textContent = data[1] + " Mbit/s";
  4624. $("#downloadpercent").attr("style", "width: " + data[1] + "%;");
  4625. $("#uploadpercent").attr("style", "width: " + data[2] + "%;");
  4626. $("#pingpercent").attr("style", "width: " + data[3] + "%;");
  4627. $("#jitterpercent").attr("style", "width: " + data[5] + "%;");
  4628. ul.textContent = data[2] + " Mbit/s";
  4629. ping.textContent = data[3] + " ms";
  4630. jitter.textContent = data[5] + " ms";
  4631. }
  4632. w.postMessage(\'start {"telemetry_level":"basic"}\')
  4633. //w.postMessage("start")
  4634. }
  4635. function abortTest() {
  4636. if (w) w.postMessage("abort")
  4637. }
  4638. </script>
  4639. <div class="row" id="testArea" style="display:none">
  4640. <div class="test col-sm-3 col-lg-3">
  4641. <div class="content-box ultra-widget green-bg" data-counter="">
  4642. <div id="downloadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4643. <div class="w-content">
  4644. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-download"></i></div>
  4645. <div class="w-descr left pull-left text-center">
  4646. <span class="testName text-uppercase w-name">Download</span>
  4647. <br>
  4648. <span class="w-name counter" id="download" ></span>
  4649. </div>
  4650. </div>
  4651. </div>
  4652. </div>
  4653. <div class="test col-sm-3 col-lg-3">
  4654. <div class="content-box ultra-widget red-bg" data-counter="">
  4655. <div id="uploadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4656. <div class="w-content">
  4657. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-upload"></i></div>
  4658. <div class="w-descr left pull-left text-center">
  4659. <span class="testName text-uppercase w-name">Upload</span>
  4660. <br>
  4661. <span class="w-name counter" id="upload" ></span>
  4662. </div>
  4663. </div>
  4664. </div>
  4665. </div>
  4666. <div class="test col-sm-3 col-lg-3">
  4667. <div class="content-box ultra-widget yellow-bg" data-counter="">
  4668. <div id="pingpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4669. <div class="w-content">
  4670. <div class="w-icon right pull-right"><i class="mdi mdi-timer"></i></div>
  4671. <div class="w-descr left pull-left text-center">
  4672. <span class="testName text-uppercase w-name">Latency</span>
  4673. <br>
  4674. <span class="w-name counter" id="ping" ></span>
  4675. </div>
  4676. </div>
  4677. </div>
  4678. </div>
  4679. <div class="test col-sm-3 col-lg-3">
  4680. <div class="content-box ultra-widget blue-bg" data-counter="">
  4681. <div id="jitterpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4682. <div class="w-content">
  4683. <div class="w-icon right pull-right"><i class="mdi mdi-pulse"></i></div>
  4684. <div class="w-descr left pull-left text-center">
  4685. <span class="testName text-uppercase w-name">Jitter</span>
  4686. <br>
  4687. <span class="w-name counter" id="jitter" ></span>
  4688. </div>
  4689. </div>
  4690. </div>
  4691. </div>
  4692. <br/>
  4693. </div>
  4694. <div id="abortBtn" class="row" style="display: none" onclick="javascript:abortTest()">
  4695. <div class="col-lg-12">
  4696. <div class="content-box red-bg" style="cursor: pointer;">
  4697. <h1 style="margin: 10px" class="text-uppercase text-center">Abort Speed Test</h1>
  4698. <div class="clearfix"></div>
  4699. </div>
  4700. </div>
  4701. </div>
  4702. <div id="startBtn" class="row" onclick="javascript:runTest()">
  4703. <div class="col-lg-12">
  4704. <div class="content-box green-bg" style="cursor: pointer;">
  4705. <h1 style="margin: 10px" class="text-uppercase text-center">Run Speed Test</h1>
  4706. <div class="clearfix"></div>
  4707. </div>
  4708. </div>
  4709. </div>
  4710. ';
  4711. }
  4712. break;
  4713. case 'homepageOrdernzbget':
  4714. if(NZBGETURL != "" && qualifyUser(NZBGETHOMEAUTH)){
  4715. $homepageItemBuilt .= buildDownloader('nzbget');
  4716. }
  4717. break;
  4718. case 'homepageOrdersabnzbd':
  4719. if(SABNZBDURL != "" && qualifyUser(SABNZBDHOMEAUTH)) {
  4720. $homepageItemBuilt .= buildDownloader('sabnzbd');
  4721. }
  4722. break;
  4723. case 'homepageOrderplexnowplaying':
  4724. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4725. if(qualifyUser(PLEXPLAYINGNOWAUTH) && PLEXPLAYINGNOW == "true"){
  4726. $homepageItemBuilt .= '<div id="plexRowNowPlaying" class="row">';
  4727. $homepageItemBuilt .= getPlexStreams(12, PLEXSHOWNAMES, $group);
  4728. $homepageItemBuilt .= '</div>';
  4729. }
  4730. }
  4731. break;
  4732. case 'homepageOrderplexrecent':
  4733. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4734. if(qualifyUser(PLEXRECENTMOVIEAUTH) && PLEXRECENTMOVIE == "true" || qualifyUser(PLEXRECENTTVAUTH) && PLEXRECENTTV == "true" || qualifyUser(PLEXRECENTMUSICAUTH) && PLEXRECENTMUSIC == "true"){
  4735. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  4736. $homepageItemBuilt .= '<div id="plexRow" class="row"><div class="col-lg-12">';
  4737. $homepageItemBuilt .= getPlexRecent($plexArray);
  4738. $homepageItemBuilt .= '</div></div>';
  4739. }
  4740. }
  4741. break;
  4742. case 'homepageOrderplexplaylist':
  4743. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4744. if(qualifyUser(PLEXPLAYLISTSAUTH) && PLEXPLAYLISTS == "true"){
  4745. $homepageItemBuilt .= '<div id="plexPlaylists" class="row"><div class="col-lg-12">';
  4746. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  4747. $homepageItemBuilt .= getPlexPlaylists($plexArray);
  4748. $homepageItemBuilt .= '</div> </div>';
  4749. }
  4750. }
  4751. break;
  4752. case 'homepageOrderembynowplaying':
  4753. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  4754. if(qualifyUser(EMBYPLAYINGNOWAUTH) && EMBYPLAYINGNOW == "true"){
  4755. $homepageItemBuilt .= '<div id="embyRowNowPlaying" class="row">';
  4756. $homepageItemBuilt .= getEmbyStreams(12, EMBYSHOWNAMES, $USER->role);
  4757. $homepageItemBuilt .= '</div>';
  4758. }
  4759. }
  4760. break;
  4761. case 'homepageOrderembyrecent':
  4762. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  4763. if(qualifyUser(EMBYRECENTMOVIEAUTH) && EMBYRECENTMOVIE == "true" || qualifyUser(EMBYRECENTTVAUTH) && EMBYRECENTTV == "true" || qualifyUser(EMBYRECENTMUSICAUTH) && EMBYRECENTMUSIC == "true"){
  4764. $embyArray = array("Movie" => EMBYRECENTMOVIE, "Episode" => EMBYRECENTTV, "MusicAlbum" => EMBYRECENTMUSIC, "Series" => EMBYRECENTTV);
  4765. $homepageItemBuilt .= '<div id="embyRow" class="row"><div class="col-lg-12">';
  4766. $homepageItemBuilt .= getEmbyRecent($embyArray);
  4767. $homepageItemBuilt .= '</div></div>';
  4768. }
  4769. }
  4770. break;
  4771. case 'homepageOrderombi':
  4772. if (qualifyUser(OMBIAUTH) && OMBIURL) {
  4773. $homepageItemBuilt .= '<div id="ombiRequests" class="row"><div class="col-lg-12">';
  4774. $homepageItemBuilt .= buildOmbiList($group, $user);
  4775. $homepageItemBuilt .= '</div></div>';
  4776. }
  4777. break;
  4778. case 'homepageOrdercalendar':
  4779. if ((SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)) || (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)) || (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)) || (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)) || (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH))) {
  4780. $calendarItems = '';
  4781. if(RADARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="film" href="javascript:void(0)">Movies</a></li>'; }
  4782. if(SONARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="tv" href="javascript:void(0)">TV Shows</a></li>'; }
  4783. if(HEADPHONESURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="music" href="javascript:void(0)">Music</a></li>'; }
  4784. $homepageItemBuilt .= '
  4785. <div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">
  4786. <div class="col-lg-12 content-form form-inline">
  4787. <div class="form-group pull-right">
  4788. <span class="swal-legend label label-primary well-sm">Legend</span>&nbsp;
  4789. <div class="btn-group" role="group">
  4790. <button id="calendarSelected" style="margin-right: 0px;" type="button" class="btn waves btn-default btn-sm dropdown-toggle waves-effect waves-float" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">View All&nbsp;<span class="caret"></span></button>
  4791. <ul style="right:0; left: auto" class="dropdown-menu">
  4792. <li><a class="calendarOption" calendarOption="all" href="javascript:void(0)">View All</a></li>
  4793. '.$calendarItems.'
  4794. </ul>
  4795. </div>
  4796. </div>
  4797. </div>
  4798. </div>
  4799. <div id="calendarRow" class="row">
  4800. <div class="col-lg-12">
  4801. <div id="calendar" class="fc-calendar box-shadow fc fc-ltr fc-unthemed"></div>
  4802. </div>
  4803. </div>
  4804. ';
  4805. }
  4806. break;
  4807. default:
  4808. # code...
  4809. break;
  4810. }
  4811. return $homepageItemBuilt;
  4812. }
  4813. function buildDownloader($name){
  4814. return '
  4815. <div id="downloadClientRow" class="row">
  4816. <div class="col-xs-12 col-md-12">
  4817. <div class="content-box">
  4818. <div class="tabbable panel with-nav-tabs panel-default">
  4819. <div class="panel-heading">
  4820. <div class="content-tools i-block pull-right">
  4821. <a id="getDownloader" class="repeat-btn">
  4822. <i class="fa fa-repeat"></i>
  4823. </a>
  4824. </div>
  4825. <h3 class="pull-left">'.strtoupper($name).'</h3>
  4826. <ul class="nav nav-tabs pull-right">
  4827. <li class="active"><a href="#downloadQueue-'.$name.'" data-toggle="tab" aria-expanded="true">'.translate("QUEUE").'</a></li>
  4828. <li class=""><a href="#downloadHistory-'.$name.'" data-toggle="tab" aria-expanded="false">'.translate("HISTORY").'</a></li>
  4829. </ul>
  4830. <div class="clearfix"></div>
  4831. </div>
  4832. <div class="panel-body">
  4833. <div class="tab-content">
  4834. <div class="tab-pane fade active in" id="downloadQueue-'.$name.'">
  4835. <div class="table-responsive" style="max-height: 300px">
  4836. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  4837. <thead>
  4838. <tr>
  4839. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  4840. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  4841. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  4842. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  4843. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  4844. </tr>
  4845. </thead>
  4846. <tbody class="dl-queue '.$name.'"></tbody>
  4847. </table>
  4848. </div>
  4849. </div>
  4850. <div class="tab-pane fade" id="downloadHistory-'.$name.'">
  4851. <div class="table-responsive" style="max-height: 300px">
  4852. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  4853. <thead>
  4854. <tr>
  4855. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  4856. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  4857. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  4858. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  4859. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  4860. </tr>
  4861. </thead>
  4862. <tbody class="dl-history '.$name.'"></tbody>
  4863. </table>
  4864. </div>
  4865. </div>
  4866. </div>
  4867. </div>
  4868. </div>
  4869. </div>
  4870. </div>
  4871. </div>';
  4872. }
  4873. class Mobile_Detect
  4874. {
  4875. /**
  4876. * Mobile detection type.
  4877. *
  4878. * @deprecated since version 2.6.9
  4879. */
  4880. const DETECTION_TYPE_MOBILE = 'mobile';
  4881. /**
  4882. * Extended detection type.
  4883. *
  4884. * @deprecated since version 2.6.9
  4885. */
  4886. const DETECTION_TYPE_EXTENDED = 'extended';
  4887. /**
  4888. * A frequently used regular expression to extract version #s.
  4889. *
  4890. * @deprecated since version 2.6.9
  4891. */
  4892. const VER = '([\w._\+]+)';
  4893. /**
  4894. * Top-level device.
  4895. */
  4896. const MOBILE_GRADE_A = 'A';
  4897. /**
  4898. * Mid-level device.
  4899. */
  4900. const MOBILE_GRADE_B = 'B';
  4901. /**
  4902. * Low-level device.
  4903. */
  4904. const MOBILE_GRADE_C = 'C';
  4905. /**
  4906. * Stores the version number of the current release.
  4907. */
  4908. const VERSION = '2.8.26';
  4909. /**
  4910. * A type for the version() method indicating a string return value.
  4911. */
  4912. const VERSION_TYPE_STRING = 'text';
  4913. /**
  4914. * A type for the version() method indicating a float return value.
  4915. */
  4916. const VERSION_TYPE_FLOAT = 'float';
  4917. /**
  4918. * A cache for resolved matches
  4919. * @var array
  4920. */
  4921. protected $cache = array();
  4922. /**
  4923. * The User-Agent HTTP header is stored in here.
  4924. * @var string
  4925. */
  4926. protected $userAgent = null;
  4927. /**
  4928. * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
  4929. * @var array
  4930. */
  4931. protected $httpHeaders = array();
  4932. /**
  4933. * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
  4934. * @var array
  4935. */
  4936. protected $cloudfrontHeaders = array();
  4937. /**
  4938. * The matching Regex.
  4939. * This is good for debug.
  4940. * @var string
  4941. */
  4942. protected $matchingRegex = null;
  4943. /**
  4944. * The matches extracted from the regex expression.
  4945. * This is good for debug.
  4946. * @var string
  4947. */
  4948. protected $matchesArray = null;
  4949. /**
  4950. * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
  4951. *
  4952. * @deprecated since version 2.6.9
  4953. *
  4954. * @var string
  4955. */
  4956. protected $detectionType = self::DETECTION_TYPE_MOBILE;
  4957. /**
  4958. * HTTP headers that trigger the 'isMobile' detection
  4959. * to be true.
  4960. *
  4961. * @var array
  4962. */
  4963. protected static $mobileHeaders = array(
  4964. 'HTTP_ACCEPT' => array('matches' => array(
  4965. // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
  4966. 'application/x-obml2d',
  4967. // BlackBerry devices.
  4968. 'application/vnd.rim.html',
  4969. 'text/vnd.wap.wml',
  4970. 'application/vnd.wap.xhtml+xml'
  4971. )),
  4972. 'HTTP_X_WAP_PROFILE' => null,
  4973. 'HTTP_X_WAP_CLIENTID' => null,
  4974. 'HTTP_WAP_CONNECTION' => null,
  4975. 'HTTP_PROFILE' => null,
  4976. // Reported by Opera on Nokia devices (eg. C3).
  4977. 'HTTP_X_OPERAMINI_PHONE_UA' => null,
  4978. 'HTTP_X_NOKIA_GATEWAY_ID' => null,
  4979. 'HTTP_X_ORANGE_ID' => null,
  4980. 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
  4981. 'HTTP_X_HUAWEI_USERID' => null,
  4982. // Reported by Windows Smartphones.
  4983. 'HTTP_UA_OS' => null,
  4984. // Reported by Verizon, Vodafone proxy system.
  4985. 'HTTP_X_MOBILE_GATEWAY' => null,
  4986. // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
  4987. 'HTTP_X_ATT_DEVICEID' => null,
  4988. // Seen this on a HTC.
  4989. 'HTTP_UA_CPU' => array('matches' => array('ARM')),
  4990. );
  4991. /**
  4992. * List of mobile devices (phones).
  4993. *
  4994. * @var array
  4995. */
  4996. protected static $phoneDevices = array(
  4997. 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
  4998. 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
  4999. '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',
  5000. 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
  5001. // @todo: Is 'Dell Streak' a tablet or a phone? ;)
  5002. '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',
  5003. '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',
  5004. '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',
  5005. '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)',
  5006. 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
  5007. 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
  5008. 'NokiaLumia' => 'Lumia [0-9]{3,4}',
  5009. // http://www.micromaxinfo.com/mobiles/smartphones
  5010. // Added because the codes might conflict with Acer Tablets.
  5011. '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',
  5012. // @todo Complete the regex.
  5013. 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
  5014. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
  5015. // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
  5016. // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
  5017. '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',
  5018. // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
  5019. 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
  5020. // http://fr.wikomobile.com
  5021. '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',
  5022. 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
  5023. // Added simvalley mobile just for fun. They have some interesting devices.
  5024. // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
  5025. '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',
  5026. // Wolfgang - a brand that is sold by Aldi supermarkets.
  5027. // http://www.wolfgangmobile.com/
  5028. 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
  5029. 'Alcatel' => 'Alcatel',
  5030. 'Nintendo' => 'Nintendo 3DS',
  5031. // http://en.wikipedia.org/wiki/Amoi
  5032. 'Amoi' => 'Amoi',
  5033. // http://en.wikipedia.org/wiki/INQ
  5034. 'INQ' => 'INQ',
  5035. // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
  5036. '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',
  5037. );
  5038. /**
  5039. * List of tablet devices.
  5040. *
  5041. * @var array
  5042. */
  5043. protected static $tabletDevices = array(
  5044. // @todo: check for mobile friendly emails topic.
  5045. 'iPad' => 'iPad|iPad.*Mobile',
  5046. // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
  5047. // @see #442
  5048. 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
  5049. '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.
  5050. // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
  5051. '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)',
  5052. // Only the Surface tablets with Windows RT are considered mobile.
  5053. // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
  5054. 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
  5055. // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
  5056. 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
  5057. // Watch out for PadFone, see #132.
  5058. // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
  5059. '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',
  5060. 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
  5061. 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
  5062. 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
  5063. 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
  5064. // http://www.acer.ro/ac/ro/RO/content/drivers
  5065. // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
  5066. // http://us.acer.com/ac/en/US/content/group/tablets
  5067. // http://www.acer.de/ac/de/DE/content/models/tablets/
  5068. // Can conflict with Micromax and Motorola phones codes.
  5069. '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',
  5070. // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
  5071. // http://us.toshiba.com/tablets/tablet-finder
  5072. // http://www.toshiba.co.jp/regza/tablet/
  5073. 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
  5074. // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
  5075. // http://www.lg.com/us/tablets
  5076. 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
  5077. 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
  5078. // Prestigio Tablets http://www.prestigio.com/support
  5079. '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',
  5080. // http://support.lenovo.com/en_GB/downloads/default.page?#
  5081. '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|)',
  5082. // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
  5083. 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
  5084. // http://www.yarvik.com/en/matrix/tablets/
  5085. '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',
  5086. 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
  5087. 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
  5088. // http://www.intenso.de/kategorie_en.php?kategorie=33
  5089. // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
  5090. 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
  5091. // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
  5092. 'IRUTablet' => 'M702pro',
  5093. 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
  5094. // http://www.e-boda.ro/tablete-pc.html
  5095. 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
  5096. // http://www.allview.ro/produse/droseries/lista-tablete-pc/
  5097. 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
  5098. // http://wiki.archosfans.com/index.php?title=Main_Page
  5099. // @note Rewrite the regex format after we add more UAs.
  5100. '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',
  5101. // http://www.ainol.com/plugin.php?identifier=ainol&module=product
  5102. 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
  5103. 'NokiaLumiaTablet' => 'Lumia 2520',
  5104. // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
  5105. // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
  5106. // http://www.sony.jp/support/tablet/
  5107. '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',
  5108. // 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
  5109. 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
  5110. // db + http://www.cube-tablet.com/buy-products.html
  5111. 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
  5112. // http://www.cobyusa.com/?p=pcat&pcat_id=3001
  5113. 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
  5114. // http://www.match.net.cn/products.asp
  5115. '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',
  5116. // http://www.msi.com/support
  5117. // @todo Research the Windows Tablets.
  5118. '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',
  5119. // @todo http://www.kyoceramobile.com/support/drivers/
  5120. // 'KyoceraTablet' => null,
  5121. // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
  5122. // 'IntextTablet' => null,
  5123. // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
  5124. // http://www.imp3.net/14/show.php?itemid=20454
  5125. 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
  5126. // http://www.rock-chips.com/index.php?do=prod&pid=2
  5127. 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
  5128. // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
  5129. 'FlyTablet' => 'IQ310|Fly Vision',
  5130. // http://www.bqreaders.com/gb/tablets-prices-sale.html
  5131. 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
  5132. // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
  5133. // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
  5134. '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',
  5135. // Nec or Medias Tab
  5136. 'NecTablet' => '\bN-06D|\bN-08D',
  5137. // Pantech Tablets: http://www.pantechusa.com/phones/
  5138. 'PantechTablet' => 'Pantech.*P4100',
  5139. // Broncho Tablets: http://www.broncho.cn/ (hard to find)
  5140. 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
  5141. // http://versusuk.com/support.html
  5142. 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
  5143. // http://www.zync.in/index.php/our-products/tablet-phablets
  5144. 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
  5145. // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
  5146. 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
  5147. // https://www.nabitablet.com/
  5148. 'NabiTablet' => 'Android.*\bNabi',
  5149. 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
  5150. // French Danew Tablets http://www.danew.com/produits-tablette.php
  5151. 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
  5152. // Texet Tablets and Readers http://www.texet.ru/tablet/
  5153. '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',
  5154. // Avoid detecting 'PLAYSTATION 3' as mobile.
  5155. 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
  5156. // http://www.trekstor.de/surftabs.html
  5157. 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
  5158. // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
  5159. 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
  5160. // http://www.advandigital.com/index.php?link=content-product&jns=JP001
  5161. // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
  5162. '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 ',
  5163. // http://www.danytech.com/category/tablet-pc
  5164. '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',
  5165. // http://www.galapad.net/product.html
  5166. 'GalapadTablet' => 'Android.*\bG1\b',
  5167. // http://www.micromaxinfo.com/tablet/funbook
  5168. 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
  5169. // http://www.karbonnmobiles.com/products_tablet.php
  5170. 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
  5171. // http://www.myallfine.com/Products.asp
  5172. 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
  5173. // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
  5174. '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',
  5175. // http://www.yonesnav.com/products/products.php
  5176. 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
  5177. // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
  5178. // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
  5179. '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',
  5180. // http://www.gloryunion.cn/products.asp
  5181. // http://www.allwinnertech.com/en/apply/mobile.html
  5182. // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
  5183. // @todo: Softwiner tablets?
  5184. // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
  5185. '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
  5186. // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
  5187. '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',
  5188. // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
  5189. // @todo: add more tests.
  5190. 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
  5191. // http://hclmetablet.com/India/index.php
  5192. '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',
  5193. // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
  5194. 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
  5195. // http://www.visture.com/index.asp
  5196. 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
  5197. // http://www.mijncresta.nl/tablet
  5198. 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
  5199. // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
  5200. 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
  5201. // Concorde tab
  5202. 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
  5203. // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
  5204. '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',
  5205. // Modecom Tablets - http://www.modecom.eu/tablets/portal/
  5206. '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',
  5207. // Vonino Tablets - http://www.vonino.eu/tablets
  5208. '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',
  5209. // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
  5210. 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
  5211. // Storex Tablets - http://storex.fr/espace_client/support.html
  5212. // @note: no need to add all the tablet codes since they are guided by the first regex.
  5213. 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
  5214. // Generic Vodafone tablets.
  5215. 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
  5216. // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
  5217. // Aka: http://www.essentielb.fr/
  5218. 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
  5219. // Ross & Moor - http://ross-moor.ru/
  5220. 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
  5221. // i-mobile http://product.i-mobilephone.com/Mobile_Device
  5222. 'iMobileTablet' => 'i-mobile i-note',
  5223. // http://www.tolino.de/de/vergleichen/
  5224. 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
  5225. // AudioSonic - a Kmart brand
  5226. // 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
  5227. 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
  5228. // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
  5229. // @todo: add them gradually to avoid conflicts.
  5230. 'AMPETablet' => 'Android.* A78 ',
  5231. // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
  5232. 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
  5233. // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
  5234. 'TecnoTablet' => 'TECNO P9',
  5235. // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
  5236. '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',
  5237. // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
  5238. '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)',
  5239. // http://www.intracon.eu/tablet
  5240. 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
  5241. // http://www.xoro.de/produkte/
  5242. // @note: Might be the same brand with 'Simply tablets'
  5243. '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',
  5244. // http://www1.viewsonic.com/products/computing/tablets/
  5245. 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
  5246. // http://www.odys.de/web/internet-tablet_en.html
  5247. 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
  5248. // http://www.captiva-power.de/products.html#tablets-en
  5249. 'CaptivaTablet' => 'CAPTIVA PAD',
  5250. // IconBIT - http://www.iconbit.com/products/tablets/
  5251. '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',
  5252. // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
  5253. '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',
  5254. // Onda - http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
  5255. '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]+',
  5256. 'JaytechTablet' => 'TPC-PA762',
  5257. 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
  5258. // http://www.digma.ru/support/download/
  5259. // @todo: Ebooks also (if requested)
  5260. 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
  5261. // http://www.evolioshop.com/ro/tablete-pc.html
  5262. // http://www.evolio.ro/support/downloads_static.html?cat=2
  5263. // @todo: Research some more
  5264. 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
  5265. // @todo http://www.lavamobiles.com/tablets-data-cards
  5266. 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
  5267. // http://www.breezetablet.com/
  5268. 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
  5269. // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
  5270. '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',
  5271. // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
  5272. 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
  5273. // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
  5274. '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',
  5275. // http://www.mi.com/en
  5276. 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
  5277. // http://www.nbru.cn/index.html
  5278. 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
  5279. // http://navroad.com/products/produkty/tablety/
  5280. // http://navroad.com/products/produkty/tablety/
  5281. 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
  5282. // http://leader-online.com/new_site/product-category/tablets/
  5283. // http://www.leader-online.net.au/List/Tablet
  5284. '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',
  5285. // http://www.datawind.com/ubislate/
  5286. 'UbislateTablet' => 'UbiSlate[\s]?7C',
  5287. // http://www.pocketbook-int.com/ru/support
  5288. 'PocketBookTablet' => 'Pocketbook',
  5289. // http://www.kocaso.com/product_tablet.html
  5290. 'KocasoTablet' => '\b(TB-1207)\b',
  5291. // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
  5292. 'HisenseTablet' => '\b(F5281|E2371)\b',
  5293. // http://www.tesco.com/direct/hudl/
  5294. 'Hudl' => 'Hudl HT7S3|Hudl 2',
  5295. // http://www.telstra.com.au/home-phone/thub-2/
  5296. 'TelstraTablet' => 'T-Hub2',
  5297. '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'
  5298. );
  5299. /**
  5300. * List of mobile Operating Systems.
  5301. *
  5302. * @var array
  5303. */
  5304. protected static $operatingSystems = array(
  5305. 'AndroidOS' => 'Android',
  5306. 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
  5307. 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
  5308. 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
  5309. // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
  5310. 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
  5311. // @reference: http://en.wikipedia.org/wiki/Windows_Phone
  5312. // http://wifeng.cn/?r=blog&a=view&id=106
  5313. // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
  5314. // http://msdn.microsoft.com/library/ms537503.aspx
  5315. // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
  5316. 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
  5317. 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
  5318. // http://en.wikipedia.org/wiki/MeeGo
  5319. // @todo: research MeeGo in UAs
  5320. 'MeeGoOS' => 'MeeGo',
  5321. // http://en.wikipedia.org/wiki/Maemo
  5322. // @todo: research Maemo in UAs
  5323. 'MaemoOS' => 'Maemo',
  5324. 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
  5325. 'webOS' => 'webOS|hpwOS',
  5326. 'badaOS' => '\bBada\b',
  5327. 'BREWOS' => 'BREW',
  5328. );
  5329. /**
  5330. * List of mobile User Agents.
  5331. *
  5332. * IMPORTANT: This is a list of only mobile browsers.
  5333. * Mobile Detect 2.x supports only mobile browsers,
  5334. * it was never designed to detect all browsers.
  5335. * The change will come in 2017 in the 3.x release for PHP7.
  5336. *
  5337. * @var array
  5338. */
  5339. protected static $browsers = array(
  5340. //'Vivaldi' => 'Vivaldi',
  5341. // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
  5342. 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
  5343. 'Dolfin' => '\bDolfin\b',
  5344. 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
  5345. 'Skyfire' => 'Skyfire',
  5346. 'Edge' => 'Mobile Safari/[.0-9]* Edge',
  5347. 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
  5348. 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
  5349. 'Bolt' => 'bolt',
  5350. 'TeaShark' => 'teashark',
  5351. 'Blazer' => 'Blazer',
  5352. // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
  5353. 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
  5354. // http://en.wikipedia.org/wiki/Midori_(web_browser)
  5355. //'Midori' => 'midori',
  5356. //'Tizen' => 'Tizen',
  5357. 'UCBrowser' => 'UC.*Browser|UCWEB',
  5358. 'baiduboxapp' => 'baiduboxapp',
  5359. 'baidubrowser' => 'baidubrowser',
  5360. // https://github.com/serbanghita/Mobile-Detect/issues/7
  5361. 'DiigoBrowser' => 'DiigoBrowser',
  5362. // http://www.puffinbrowser.com/index.php
  5363. 'Puffin' => 'Puffin',
  5364. // http://mercury-browser.com/index.html
  5365. 'Mercury' => '\bMercury\b',
  5366. // http://en.wikipedia.org/wiki/Obigo_Browser
  5367. 'ObigoBrowser' => 'Obigo',
  5368. // http://en.wikipedia.org/wiki/NetFront
  5369. 'NetFront' => 'NF-Browser',
  5370. // @reference: http://en.wikipedia.org/wiki/Minimo
  5371. // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
  5372. 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
  5373. // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
  5374. 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
  5375. );
  5376. /**
  5377. * Utilities.
  5378. *
  5379. * @var array
  5380. */
  5381. protected static $utilities = array(
  5382. // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
  5383. // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
  5384. // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
  5385. // https://developers.facebook.com/docs/sharing/best-practices
  5386. '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',
  5387. 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
  5388. 'DesktopMode' => 'WPDesktop',
  5389. 'TV' => 'SonyDTV|HbbTV', // experimental
  5390. 'WebKit' => '(webkit)[ /]([\w.]+)',
  5391. // @todo: Include JXD consoles.
  5392. 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
  5393. 'Watch' => 'SM-V700',
  5394. );
  5395. /**
  5396. * All possible HTTP headers that represent the
  5397. * User-Agent string.
  5398. *
  5399. * @var array
  5400. */
  5401. protected static $uaHttpHeaders = array(
  5402. // The default User-Agent string.
  5403. 'HTTP_USER_AGENT',
  5404. // Header can occur on devices using Opera Mini.
  5405. 'HTTP_X_OPERAMINI_PHONE_UA',
  5406. // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
  5407. 'HTTP_X_DEVICE_USER_AGENT',
  5408. 'HTTP_X_ORIGINAL_USER_AGENT',
  5409. 'HTTP_X_SKYFIRE_PHONE',
  5410. 'HTTP_X_BOLT_PHONE_UA',
  5411. 'HTTP_DEVICE_STOCK_UA',
  5412. 'HTTP_X_UCBROWSER_DEVICE_UA'
  5413. );
  5414. /**
  5415. * The individual segments that could exist in a User-Agent string. VER refers to the regular
  5416. * expression defined in the constant self::VER.
  5417. *
  5418. * @var array
  5419. */
  5420. protected static $properties = array(
  5421. // Build
  5422. 'Mobile' => 'Mobile/[VER]',
  5423. 'Build' => 'Build/[VER]',
  5424. 'Version' => 'Version/[VER]',
  5425. 'VendorID' => 'VendorID/[VER]',
  5426. // Devices
  5427. 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
  5428. 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
  5429. 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
  5430. //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
  5431. 'Kindle' => 'Kindle/[VER]',
  5432. // Browser
  5433. 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
  5434. 'Coast' => array('Coast/[VER]'),
  5435. 'Dolfin' => 'Dolfin/[VER]',
  5436. // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
  5437. 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
  5438. 'Fennec' => 'Fennec/[VER]',
  5439. // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  5440. // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
  5441. 'Edge' => 'Edge/[VER]',
  5442. 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
  5443. // http://en.wikipedia.org/wiki/NetFront
  5444. 'NetFront' => 'NetFront/[VER]',
  5445. 'NokiaBrowser' => 'NokiaBrowser/[VER]',
  5446. 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
  5447. 'Opera Mini' => 'Opera Mini/[VER]',
  5448. 'Opera Mobi' => 'Version/[VER]',
  5449. 'UC Browser' => 'UC Browser[VER]',
  5450. 'MQQBrowser' => 'MQQBrowser/[VER]',
  5451. 'MicroMessenger' => 'MicroMessenger/[VER]',
  5452. 'baiduboxapp' => 'baiduboxapp/[VER]',
  5453. 'baidubrowser' => 'baidubrowser/[VER]',
  5454. 'SamsungBrowser' => 'SamsungBrowser/[VER]',
  5455. 'Iron' => 'Iron/[VER]',
  5456. // @note: Safari 7534.48.3 is actually Version 5.1.
  5457. // @note: On BlackBerry the Version is overwriten by the OS.
  5458. 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
  5459. 'Skyfire' => 'Skyfire/[VER]',
  5460. 'Tizen' => 'Tizen/[VER]',
  5461. 'Webkit' => 'webkit[ /][VER]',
  5462. 'PaleMoon' => 'PaleMoon/[VER]',
  5463. // Engine
  5464. 'Gecko' => 'Gecko/[VER]',
  5465. 'Trident' => 'Trident/[VER]',
  5466. 'Presto' => 'Presto/[VER]',
  5467. 'Goanna' => 'Goanna/[VER]',
  5468. // OS
  5469. 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
  5470. 'Android' => 'Android [VER]',
  5471. 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
  5472. 'BREW' => 'BREW [VER]',
  5473. 'Java' => 'Java/[VER]',
  5474. // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
  5475. // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
  5476. 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
  5477. 'Windows Phone' => 'Windows Phone [VER]',
  5478. 'Windows CE' => 'Windows CE/[VER]',
  5479. // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
  5480. 'Windows NT' => 'Windows NT [VER]',
  5481. 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
  5482. 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
  5483. );
  5484. /**
  5485. * Construct an instance of this class.
  5486. *
  5487. * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
  5488. * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
  5489. * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
  5490. * from the $headers array instead.
  5491. */
  5492. public function __construct(
  5493. array $headers = null,
  5494. $userAgent = null
  5495. ) {
  5496. $this->setHttpHeaders($headers);
  5497. $this->setUserAgent($userAgent);
  5498. }
  5499. /**
  5500. * Get the current script version.
  5501. * This is useful for the demo.php file,
  5502. * so people can check on what version they are testing
  5503. * for mobile devices.
  5504. *
  5505. * @return string The version number in semantic version format.
  5506. */
  5507. public static function getScriptVersion()
  5508. {
  5509. return self::VERSION;
  5510. }
  5511. /**
  5512. * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
  5513. *
  5514. * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
  5515. * the headers. The default null is left for backwards compatibility.
  5516. */
  5517. public function setHttpHeaders($httpHeaders = null)
  5518. {
  5519. // use global _SERVER if $httpHeaders aren't defined
  5520. if (!is_array($httpHeaders) || !count($httpHeaders)) {
  5521. $httpHeaders = $_SERVER;
  5522. }
  5523. // clear existing headers
  5524. $this->httpHeaders = array();
  5525. // Only save HTTP headers. In PHP land, that means only _SERVER vars that
  5526. // start with HTTP_.
  5527. foreach ($httpHeaders as $key => $value) {
  5528. if (substr($key, 0, 5) === 'HTTP_') {
  5529. $this->httpHeaders[$key] = $value;
  5530. }
  5531. }
  5532. // In case we're dealing with CloudFront, we need to know.
  5533. $this->setCfHeaders($httpHeaders);
  5534. }
  5535. /**
  5536. * Retrieves the HTTP headers.
  5537. *
  5538. * @return array
  5539. */
  5540. public function getHttpHeaders()
  5541. {
  5542. return $this->httpHeaders;
  5543. }
  5544. /**
  5545. * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
  5546. * Simply null is returned.
  5547. *
  5548. * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
  5549. * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
  5550. * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
  5551. *
  5552. * @return string|null The value of the header.
  5553. */
  5554. public function getHttpHeader($header)
  5555. {
  5556. // are we using PHP-flavored headers?
  5557. if (strpos($header, '_') === false) {
  5558. $header = str_replace('-', '_', $header);
  5559. $header = strtoupper($header);
  5560. }
  5561. // test the alternate, too
  5562. $altHeader = 'HTTP_' . $header;
  5563. //Test both the regular and the HTTP_ prefix
  5564. if (isset($this->httpHeaders[$header])) {
  5565. return $this->httpHeaders[$header];
  5566. } elseif (isset($this->httpHeaders[$altHeader])) {
  5567. return $this->httpHeaders[$altHeader];
  5568. }
  5569. return null;
  5570. }
  5571. public function getMobileHeaders()
  5572. {
  5573. return self::$mobileHeaders;
  5574. }
  5575. /**
  5576. * Get all possible HTTP headers that
  5577. * can contain the User-Agent string.
  5578. *
  5579. * @return array List of HTTP headers.
  5580. */
  5581. public function getUaHttpHeaders()
  5582. {
  5583. return self::$uaHttpHeaders;
  5584. }
  5585. /**
  5586. * Set CloudFront headers
  5587. * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
  5588. *
  5589. * @param array $cfHeaders List of HTTP headers
  5590. *
  5591. * @return boolean If there were CloudFront headers to be set
  5592. */
  5593. public function setCfHeaders($cfHeaders = null) {
  5594. // use global _SERVER if $cfHeaders aren't defined
  5595. if (!is_array($cfHeaders) || !count($cfHeaders)) {
  5596. $cfHeaders = $_SERVER;
  5597. }
  5598. // clear existing headers
  5599. $this->cloudfrontHeaders = array();
  5600. // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
  5601. // start with cloudfront-.
  5602. $response = false;
  5603. foreach ($cfHeaders as $key => $value) {
  5604. if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
  5605. $this->cloudfrontHeaders[strtoupper($key)] = $value;
  5606. $response = true;
  5607. }
  5608. }
  5609. return $response;
  5610. }
  5611. /**
  5612. * Retrieves the cloudfront headers.
  5613. *
  5614. * @return array
  5615. */
  5616. public function getCfHeaders()
  5617. {
  5618. return $this->cloudfrontHeaders;
  5619. }
  5620. /**
  5621. * Set the User-Agent to be used.
  5622. *
  5623. * @param string $userAgent The user agent string to set.
  5624. *
  5625. * @return string|null
  5626. */
  5627. public function setUserAgent($userAgent = null)
  5628. {
  5629. // Invalidate cache due to #375
  5630. $this->cache = array();
  5631. if (false === empty($userAgent)) {
  5632. return $this->userAgent = $userAgent;
  5633. } else {
  5634. $this->userAgent = null;
  5635. foreach ($this->getUaHttpHeaders() as $altHeader) {
  5636. if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
  5637. $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
  5638. }
  5639. }
  5640. if (!empty($this->userAgent)) {
  5641. return $this->userAgent = trim($this->userAgent);
  5642. }
  5643. }
  5644. if (count($this->getCfHeaders()) > 0) {
  5645. return $this->userAgent = 'Amazon CloudFront';
  5646. }
  5647. return $this->userAgent = null;
  5648. }
  5649. /**
  5650. * Retrieve the User-Agent.
  5651. *
  5652. * @return string|null The user agent if it's set.
  5653. */
  5654. public function getUserAgent()
  5655. {
  5656. return $this->userAgent;
  5657. }
  5658. /**
  5659. * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
  5660. * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
  5661. *
  5662. * @deprecated since version 2.6.9
  5663. *
  5664. * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
  5665. * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
  5666. */
  5667. public function setDetectionType($type = null)
  5668. {
  5669. if ($type === null) {
  5670. $type = self::DETECTION_TYPE_MOBILE;
  5671. }
  5672. if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
  5673. return;
  5674. }
  5675. $this->detectionType = $type;
  5676. }
  5677. public function getMatchingRegex()
  5678. {
  5679. return $this->matchingRegex;
  5680. }
  5681. public function getMatchesArray()
  5682. {
  5683. return $this->matchesArray;
  5684. }
  5685. /**
  5686. * Retrieve the list of known phone devices.
  5687. *
  5688. * @return array List of phone devices.
  5689. */
  5690. public static function getPhoneDevices()
  5691. {
  5692. return self::$phoneDevices;
  5693. }
  5694. /**
  5695. * Retrieve the list of known tablet devices.
  5696. *
  5697. * @return array List of tablet devices.
  5698. */
  5699. public static function getTabletDevices()
  5700. {
  5701. return self::$tabletDevices;
  5702. }
  5703. /**
  5704. * Alias for getBrowsers() method.
  5705. *
  5706. * @return array List of user agents.
  5707. */
  5708. public static function getUserAgents()
  5709. {
  5710. return self::getBrowsers();
  5711. }
  5712. /**
  5713. * Retrieve the list of known browsers. Specifically, the user agents.
  5714. *
  5715. * @return array List of browsers / user agents.
  5716. */
  5717. public static function getBrowsers()
  5718. {
  5719. return self::$browsers;
  5720. }
  5721. /**
  5722. * Retrieve the list of known utilities.
  5723. *
  5724. * @return array List of utilities.
  5725. */
  5726. public static function getUtilities()
  5727. {
  5728. return self::$utilities;
  5729. }
  5730. /**
  5731. * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
  5732. *
  5733. * @deprecated since version 2.6.9
  5734. *
  5735. * @return array All the rules (but not extended).
  5736. */
  5737. public static function getMobileDetectionRules()
  5738. {
  5739. static $rules;
  5740. if (!$rules) {
  5741. $rules = array_merge(
  5742. self::$phoneDevices,
  5743. self::$tabletDevices,
  5744. self::$operatingSystems,
  5745. self::$browsers
  5746. );
  5747. }
  5748. return $rules;
  5749. }
  5750. /**
  5751. * Method gets the mobile detection rules + utilities.
  5752. * The reason this is separate is because utilities rules
  5753. * don't necessary imply mobile. This method is used inside
  5754. * the new $detect->is('stuff') method.
  5755. *
  5756. * @deprecated since version 2.6.9
  5757. *
  5758. * @return array All the rules + extended.
  5759. */
  5760. public function getMobileDetectionRulesExtended()
  5761. {
  5762. static $rules;
  5763. if (!$rules) {
  5764. // Merge all rules together.
  5765. $rules = array_merge(
  5766. self::$phoneDevices,
  5767. self::$tabletDevices,
  5768. self::$operatingSystems,
  5769. self::$browsers,
  5770. self::$utilities
  5771. );
  5772. }
  5773. return $rules;
  5774. }
  5775. /**
  5776. * Retrieve the current set of rules.
  5777. *
  5778. * @deprecated since version 2.6.9
  5779. *
  5780. * @return array
  5781. */
  5782. public function getRules()
  5783. {
  5784. if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
  5785. return self::getMobileDetectionRulesExtended();
  5786. } else {
  5787. return self::getMobileDetectionRules();
  5788. }
  5789. }
  5790. /**
  5791. * Retrieve the list of mobile operating systems.
  5792. *
  5793. * @return array The list of mobile operating systems.
  5794. */
  5795. public static function getOperatingSystems()
  5796. {
  5797. return self::$operatingSystems;
  5798. }
  5799. /**
  5800. * Check the HTTP headers for signs of mobile.
  5801. * This is the fastest mobile check possible; it's used
  5802. * inside isMobile() method.
  5803. *
  5804. * @return bool
  5805. */
  5806. public function checkHttpHeadersForMobile()
  5807. {
  5808. foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
  5809. if (isset($this->httpHeaders[$mobileHeader])) {
  5810. if (is_array($matchType['matches'])) {
  5811. foreach ($matchType['matches'] as $_match) {
  5812. if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
  5813. return true;
  5814. }
  5815. }
  5816. return false;
  5817. } else {
  5818. return true;
  5819. }
  5820. }
  5821. }
  5822. return false;
  5823. }
  5824. /**
  5825. * Magic overloading method.
  5826. *
  5827. * @method boolean is[...]()
  5828. * @param string $name
  5829. * @param array $arguments
  5830. * @return mixed
  5831. * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
  5832. */
  5833. public function __call($name, $arguments)
  5834. {
  5835. // make sure the name starts with 'is', otherwise
  5836. if (substr($name, 0, 2) !== 'is') {
  5837. throw new BadMethodCallException("No such method exists: $name");
  5838. }
  5839. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5840. $key = substr($name, 2);
  5841. return $this->matchUAAgainstKey($key);
  5842. }
  5843. /**
  5844. * Find a detection rule that matches the current User-agent.
  5845. *
  5846. * @param null $userAgent deprecated
  5847. * @return boolean
  5848. */
  5849. protected function matchDetectionRulesAgainstUA($userAgent = null)
  5850. {
  5851. // Begin general search.
  5852. foreach ($this->getRules() as $_regex) {
  5853. if (empty($_regex)) {
  5854. continue;
  5855. }
  5856. if ($this->match($_regex, $userAgent)) {
  5857. return true;
  5858. }
  5859. }
  5860. return false;
  5861. }
  5862. /**
  5863. * Search for a certain key in the rules array.
  5864. * If the key is found then try to match the corresponding
  5865. * regex against the User-Agent.
  5866. *
  5867. * @param string $key
  5868. *
  5869. * @return boolean
  5870. */
  5871. protected function matchUAAgainstKey($key)
  5872. {
  5873. // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
  5874. $key = strtolower($key);
  5875. if (false === isset($this->cache[$key])) {
  5876. // change the keys to lower case
  5877. $_rules = array_change_key_case($this->getRules());
  5878. if (false === empty($_rules[$key])) {
  5879. $this->cache[$key] = $this->match($_rules[$key]);
  5880. }
  5881. if (false === isset($this->cache[$key])) {
  5882. $this->cache[$key] = false;
  5883. }
  5884. }
  5885. return $this->cache[$key];
  5886. }
  5887. /**
  5888. * Check if the device is mobile.
  5889. * Returns true if any type of mobile device detected, including special ones
  5890. * @param null $userAgent deprecated
  5891. * @param null $httpHeaders deprecated
  5892. * @return bool
  5893. */
  5894. public function isMobile($userAgent = null, $httpHeaders = null)
  5895. {
  5896. if ($httpHeaders) {
  5897. $this->setHttpHeaders($httpHeaders);
  5898. }
  5899. if ($userAgent) {
  5900. $this->setUserAgent($userAgent);
  5901. }
  5902. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  5903. if ($this->getUserAgent() === 'Amazon CloudFront') {
  5904. $cfHeaders = $this->getCfHeaders();
  5905. if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
  5906. return true;
  5907. }
  5908. }
  5909. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5910. if ($this->checkHttpHeadersForMobile()) {
  5911. return true;
  5912. } else {
  5913. return $this->matchDetectionRulesAgainstUA();
  5914. }
  5915. }
  5916. /**
  5917. * Check if the device is a tablet.
  5918. * Return true if any type of tablet device is detected.
  5919. *
  5920. * @param string $userAgent deprecated
  5921. * @param array $httpHeaders deprecated
  5922. * @return bool
  5923. */
  5924. public function isTablet($userAgent = null, $httpHeaders = null)
  5925. {
  5926. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  5927. if ($this->getUserAgent() === 'Amazon CloudFront') {
  5928. $cfHeaders = $this->getCfHeaders();
  5929. if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
  5930. return true;
  5931. }
  5932. }
  5933. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5934. foreach (self::$tabletDevices as $_regex) {
  5935. if ($this->match($_regex, $userAgent)) {
  5936. return true;
  5937. }
  5938. }
  5939. return false;
  5940. }
  5941. /**
  5942. * This method checks for a certain property in the
  5943. * userAgent.
  5944. * @todo: The httpHeaders part is not yet used.
  5945. *
  5946. * @param string $key
  5947. * @param string $userAgent deprecated
  5948. * @param string $httpHeaders deprecated
  5949. * @return bool|int|null
  5950. */
  5951. public function is($key, $userAgent = null, $httpHeaders = null)
  5952. {
  5953. // Set the UA and HTTP headers only if needed (eg. batch mode).
  5954. if ($httpHeaders) {
  5955. $this->setHttpHeaders($httpHeaders);
  5956. }
  5957. if ($userAgent) {
  5958. $this->setUserAgent($userAgent);
  5959. }
  5960. $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
  5961. return $this->matchUAAgainstKey($key);
  5962. }
  5963. /**
  5964. * Some detection rules are relative (not standard),
  5965. * because of the diversity of devices, vendors and
  5966. * their conventions in representing the User-Agent or
  5967. * the HTTP headers.
  5968. *
  5969. * This method will be used to check custom regexes against
  5970. * the User-Agent string.
  5971. *
  5972. * @param $regex
  5973. * @param string $userAgent
  5974. * @return bool
  5975. *
  5976. * @todo: search in the HTTP headers too.
  5977. */
  5978. public function match($regex, $userAgent = null)
  5979. {
  5980. $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
  5981. // If positive match is found, store the results for debug.
  5982. if ($match) {
  5983. $this->matchingRegex = $regex;
  5984. $this->matchesArray = $matches;
  5985. }
  5986. return $match;
  5987. }
  5988. /**
  5989. * Get the properties array.
  5990. *
  5991. * @return array
  5992. */
  5993. public static function getProperties()
  5994. {
  5995. return self::$properties;
  5996. }
  5997. /**
  5998. * Prepare the version number.
  5999. *
  6000. * @todo Remove the error supression from str_replace() call.
  6001. *
  6002. * @param string $ver The string version, like "2.6.21.2152";
  6003. *
  6004. * @return float
  6005. */
  6006. public function prepareVersionNo($ver)
  6007. {
  6008. $ver = str_replace(array('_', ' ', '/'), '.', $ver);
  6009. $arrVer = explode('.', $ver, 2);
  6010. if (isset($arrVer[1])) {
  6011. $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
  6012. }
  6013. return (float) implode('.', $arrVer);
  6014. }
  6015. /**
  6016. * Check the version of the given property in the User-Agent.
  6017. * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
  6018. *
  6019. * @param string $propertyName The name of the property. See self::getProperties() array
  6020. * keys for all possible properties.
  6021. * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
  6022. * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
  6023. * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
  6024. * invalid parameter will default to the this type as well.
  6025. *
  6026. * @return string|float The version of the property we are trying to extract.
  6027. */
  6028. public function version($propertyName, $type = self::VERSION_TYPE_STRING)
  6029. {
  6030. if (empty($propertyName)) {
  6031. return false;
  6032. }
  6033. // set the $type to the default if we don't recognize the type
  6034. if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
  6035. $type = self::VERSION_TYPE_STRING;
  6036. }
  6037. $properties = self::getProperties();
  6038. // Check if the property exists in the properties array.
  6039. if (true === isset($properties[$propertyName])) {
  6040. // Prepare the pattern to be matched.
  6041. // Make sure we always deal with an array (string is converted).
  6042. $properties[$propertyName] = (array) $properties[$propertyName];
  6043. foreach ($properties[$propertyName] as $propertyMatchString) {
  6044. $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
  6045. // Identify and extract the version.
  6046. preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
  6047. if (false === empty($match[1])) {
  6048. $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
  6049. return $version;
  6050. }
  6051. }
  6052. }
  6053. return false;
  6054. }
  6055. /**
  6056. * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
  6057. *
  6058. * @return string One of the self::MOBILE_GRADE_* constants.
  6059. */
  6060. public function mobileGrade()
  6061. {
  6062. $isMobile = $this->isMobile();
  6063. if (
  6064. // 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)
  6065. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6066. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6067. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6068. // 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)
  6069. // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
  6070. // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
  6071. // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
  6072. ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
  6073. // 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)
  6074. $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
  6075. // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
  6076. $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
  6077. // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
  6078. $this->match('Playbook.*Tablet') ||
  6079. // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
  6080. ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
  6081. // Palm WebOS 3.0 - Tested on HP TouchPad
  6082. $this->match('hp.*TouchPad') ||
  6083. // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
  6084. ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
  6085. // Chrome for Android - Tested on Android 4.0, 4.1 device
  6086. ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
  6087. // Skyfire 4.1 - Tested on Android 2.3 device
  6088. ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6089. // Opera Mobile 11.5-12: Tested on Android 2.3
  6090. ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
  6091. // Meego 1.2 - Tested on Nokia 950 and N9
  6092. $this->is('MeeGoOS') ||
  6093. // Tizen (pre-release) - Tested on early hardware
  6094. $this->is('Tizen') ||
  6095. // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
  6096. // @todo: more tests here!
  6097. $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
  6098. // UC Browser - Tested on Android 2.3 device
  6099. ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6100. // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
  6101. ( $this->match('Kindle Fire') ||
  6102. $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
  6103. // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
  6104. $this->is('AndroidOS') && $this->is('NookTablet') ||
  6105. // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
  6106. $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
  6107. // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
  6108. $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
  6109. // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
  6110. $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
  6111. // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
  6112. $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
  6113. // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
  6114. $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
  6115. ){
  6116. return self::MOBILE_GRADE_A;
  6117. }
  6118. if (
  6119. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
  6120. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
  6121. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
  6122. // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
  6123. $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
  6124. //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
  6125. ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
  6126. ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
  6127. // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
  6128. $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
  6129. // @todo: report this (tested on Nokia N71)
  6130. $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
  6131. ){
  6132. return self::MOBILE_GRADE_B;
  6133. }
  6134. if (
  6135. // Blackberry 4.x - Tested on the Curve 8330
  6136. $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
  6137. // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
  6138. $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
  6139. // Tested on original iPhone (3.1), iPhone 3 (3.2)
  6140. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6141. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6142. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6143. // Internet Explorer 7 and older - Tested on Windows XP
  6144. $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
  6145. ){
  6146. return self::MOBILE_GRADE_C;
  6147. }
  6148. // All older smartphone platforms and featurephones - Any device that doesn't support media queries
  6149. // will receive the basic, C grade experience.
  6150. return self::MOBILE_GRADE_C;
  6151. }
  6152. }
  6153. $mobileDetect = new Mobile_Detect;
  6154. $userDevice = ($mobileDetect->isMobile() ? ($mobileDetect->isTablet() ? 'tablet' : 'phone') : 'computer');
  6155. function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  6156. $path = getServerPath();
  6157. return '
  6158. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6159. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  6160. <head>
  6161. <!--[if gte mso 9]><xml>
  6162. <o:OfficeDocumentSettings>
  6163. <o:AllowPNG/>
  6164. <o:PixelsPerInch>96</o:PixelsPerInch>
  6165. </o:OfficeDocumentSettings>
  6166. </xml><![endif]-->
  6167. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6168. <meta name="viewport" content="width=device-width">
  6169. <!--[if !mso]><!-->
  6170. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6171. <!--<![endif]-->
  6172. <title></title>
  6173. <!--[if !mso]><!-- -->
  6174. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
  6175. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  6176. <!--<![endif]-->
  6177. <style type="text/css" id="media-query">
  6178. body {
  6179. margin: 0;
  6180. padding: 0;
  6181. }
  6182. table,
  6183. tr,
  6184. td {
  6185. vertical-align: top;
  6186. border-collapse: collapse;
  6187. }
  6188. .ie-browser table,
  6189. .mso-container table {
  6190. table-layout: fixed;
  6191. }
  6192. * {
  6193. line-height: inherit;
  6194. }
  6195. a[x-apple-data-detectors=true] {
  6196. color: inherit !important;
  6197. text-decoration: none !important;
  6198. }
  6199. [owa] .img-container div,
  6200. [owa] .img-container button {
  6201. display: block !important;
  6202. }
  6203. [owa] .fullwidth button {
  6204. width: 100% !important;
  6205. }
  6206. [owa] .block-grid .col {
  6207. display: table-cell;
  6208. float: none !important;
  6209. vertical-align: top;
  6210. }
  6211. .ie-browser .num12,
  6212. .ie-browser .block-grid,
  6213. [owa] .num12,
  6214. [owa] .block-grid {
  6215. width: 615px !important;
  6216. }
  6217. .ExternalClass,
  6218. .ExternalClass p,
  6219. .ExternalClass span,
  6220. .ExternalClass font,
  6221. .ExternalClass td,
  6222. .ExternalClass div {
  6223. line-height: 100%;
  6224. }
  6225. .ie-browser .mixed-two-up .num4,
  6226. [owa] .mixed-two-up .num4 {
  6227. width: 204px !important;
  6228. }
  6229. .ie-browser .mixed-two-up .num8,
  6230. [owa] .mixed-two-up .num8 {
  6231. width: 408px !important;
  6232. }
  6233. .ie-browser .block-grid.two-up .col,
  6234. [owa] .block-grid.two-up .col {
  6235. width: 307px !important;
  6236. }
  6237. .ie-browser .block-grid.three-up .col,
  6238. [owa] .block-grid.three-up .col {
  6239. width: 205px !important;
  6240. }
  6241. .ie-browser .block-grid.four-up .col,
  6242. [owa] .block-grid.four-up .col {
  6243. width: 153px !important;
  6244. }
  6245. .ie-browser .block-grid.five-up .col,
  6246. [owa] .block-grid.five-up .col {
  6247. width: 123px !important;
  6248. }
  6249. .ie-browser .block-grid.six-up .col,
  6250. [owa] .block-grid.six-up .col {
  6251. width: 102px !important;
  6252. }
  6253. .ie-browser .block-grid.seven-up .col,
  6254. [owa] .block-grid.seven-up .col {
  6255. width: 87px !important;
  6256. }
  6257. .ie-browser .block-grid.eight-up .col,
  6258. [owa] .block-grid.eight-up .col {
  6259. width: 76px !important;
  6260. }
  6261. .ie-browser .block-grid.nine-up .col,
  6262. [owa] .block-grid.nine-up .col {
  6263. width: 68px !important;
  6264. }
  6265. .ie-browser .block-grid.ten-up .col,
  6266. [owa] .block-grid.ten-up .col {
  6267. width: 61px !important;
  6268. }
  6269. .ie-browser .block-grid.eleven-up .col,
  6270. [owa] .block-grid.eleven-up .col {
  6271. width: 55px !important;
  6272. }
  6273. .ie-browser .block-grid.twelve-up .col,
  6274. [owa] .block-grid.twelve-up .col {
  6275. width: 51px !important;
  6276. }
  6277. @media only screen and (min-width: 635px) {
  6278. .block-grid {
  6279. width: 615px !important;
  6280. }
  6281. .block-grid .col {
  6282. display: table-cell;
  6283. Float: none !important;
  6284. vertical-align: top;
  6285. }
  6286. .block-grid .col.num12 {
  6287. width: 615px !important;
  6288. }
  6289. .block-grid.mixed-two-up .col.num4 {
  6290. width: 204px !important;
  6291. }
  6292. .block-grid.mixed-two-up .col.num8 {
  6293. width: 408px !important;
  6294. }
  6295. .block-grid.two-up .col {
  6296. width: 307px !important;
  6297. }
  6298. .block-grid.three-up .col {
  6299. width: 205px !important;
  6300. }
  6301. .block-grid.four-up .col {
  6302. width: 153px !important;
  6303. }
  6304. .block-grid.five-up .col {
  6305. width: 123px !important;
  6306. }
  6307. .block-grid.six-up .col {
  6308. width: 102px !important;
  6309. }
  6310. .block-grid.seven-up .col {
  6311. width: 87px !important;
  6312. }
  6313. .block-grid.eight-up .col {
  6314. width: 76px !important;
  6315. }
  6316. .block-grid.nine-up .col {
  6317. width: 68px !important;
  6318. }
  6319. .block-grid.ten-up .col {
  6320. width: 61px !important;
  6321. }
  6322. .block-grid.eleven-up .col {
  6323. width: 55px !important;
  6324. }
  6325. .block-grid.twelve-up .col {
  6326. width: 51px !important;
  6327. }
  6328. }
  6329. @media (max-width: 635px) {
  6330. .block-grid,
  6331. .col {
  6332. min-width: 320px !important;
  6333. max-width: 100% !important;
  6334. }
  6335. .block-grid {
  6336. width: calc(100% - 40px) !important;
  6337. }
  6338. .col {
  6339. width: 100% !important;
  6340. }
  6341. .col>div {
  6342. margin: 0 auto;
  6343. }
  6344. img.fullwidth {
  6345. max-width: 100% !important;
  6346. }
  6347. }
  6348. </style>
  6349. </head>
  6350. <body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #FFFFFF">
  6351. <!--[if IE]><div class="ie-browser"><![endif]-->
  6352. <!--[if mso]><div class="mso-container"><![endif]-->
  6353. <div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: #FFFFFF">
  6354. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #FFFFFF;"><![endif]-->
  6355. <div style="background-color:#333333;">
  6356. <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;"
  6357. class="block-grid ">
  6358. <div style="border-collapse: collapse;display: table;width: 100%;">
  6359. <!--[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]-->
  6360. <!--[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]-->
  6361. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6362. <div style="background-color: transparent; width: 100% !important;">
  6363. <!--[if (!mso)&(!IE)]><!-->
  6364. <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;">
  6365. <!--<![endif]-->
  6366. <div align="left" class="img-container left fullwidth" style="padding-right: 30px; padding-left: 30px;">
  6367. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px;" align="left"><![endif]-->
  6368. <img class="left fullwidth" align="left" border="0" src="'.$path.'images/organizr-logo-h.png" alt="Image" title="Image"
  6369. 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"
  6370. width="555">
  6371. <!--[if mso]></td></tr></table><![endif]-->
  6372. </div>
  6373. <!--[if (!mso)&(!IE)]><!-->
  6374. </div>
  6375. <!--<![endif]-->
  6376. </div>
  6377. </div>
  6378. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6379. </div>
  6380. </div>
  6381. </div>
  6382. <div style="background-color:#333333;">
  6383. <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;"
  6384. class="block-grid ">
  6385. <div style="border-collapse: collapse;display: table;width: 100%;">
  6386. <!--[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]-->
  6387. <!--[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]-->
  6388. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6389. <div style="background-color: transparent; width: 100% !important;">
  6390. <!--[if (!mso)&(!IE)]><!-->
  6391. <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;">
  6392. <!--<![endif]-->
  6393. <!--[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]-->
  6394. <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;">
  6395. <div style="font-size:12px;line-height:14px;color:#FFFFFF;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6396. <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>
  6397. </span>
  6398. </p>
  6399. </div>
  6400. </div>
  6401. <!--[if mso]></td></tr></table><![endif]-->
  6402. <!--[if (!mso)&(!IE)]><!-->
  6403. </div>
  6404. <!--<![endif]-->
  6405. </div>
  6406. </div>
  6407. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6408. </div>
  6409. </div>
  6410. </div>
  6411. <div style="background-color:#393939;">
  6412. <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;"
  6413. class="block-grid ">
  6414. <div style="border-collapse: collapse;display: table;width: 100%;">
  6415. <!--[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]-->
  6416. <!--[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]-->
  6417. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6418. <div style="background-color: transparent; width: 100% !important;">
  6419. <!--[if (!mso)&(!IE)]><!-->
  6420. <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;">
  6421. <!--<![endif]-->
  6422. <!--[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]-->
  6423. <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;">
  6424. <div style="font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6425. <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>
  6426. </div>
  6427. </div>
  6428. <!--[if mso]></td></tr></table><![endif]-->
  6429. <div style="padding-right: 5px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px;">
  6430. <!--[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]-->
  6431. <div align="center">
  6432. <div style="border-top: 2px solid #66D9EF; width:55%; line-height:2px; height:2px; font-size:2px;">&#160;</div>
  6433. </div>
  6434. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6435. </div>
  6436. <!--[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]-->
  6437. <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;">
  6438. <div style="font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6439. <p style="margin: 0;font-size: 12px;line-height: 14px"><span style="font-size: 28px; line-height: 33px;">Hey '.$user.',</span></p>
  6440. </div>
  6441. </div>
  6442. <!--[if mso]></td></tr></table><![endif]-->
  6443. <!--[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]-->
  6444. <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;">
  6445. <div style="font-size:12px;line-height:22px;font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;color:#FFFFFF;text-align:left;">
  6446. <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>
  6447. </span>
  6448. </p>
  6449. </div>
  6450. </div>
  6451. <!--[if mso]></td></tr></table><![endif]-->
  6452. <div align="center" class="button-container center" style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;">
  6453. <!--[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]-->
  6454. <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">
  6455. <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>
  6456. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6457. </div>
  6458. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6459. </div>
  6460. <!--[if (!mso)&(!IE)]><!-->
  6461. </div>
  6462. <!--<![endif]-->
  6463. </div>
  6464. </div>
  6465. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6466. </div>
  6467. </div>
  6468. </div>
  6469. <div style="background-color:#ffffff;">
  6470. <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;"
  6471. class="block-grid ">
  6472. <div style="border-collapse: collapse;display: table;width: 100%;">
  6473. <!--[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]-->
  6474. <!--[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]-->
  6475. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6476. <div style="background-color: transparent; width: 100% !important;">
  6477. <!--[if (!mso)&(!IE)]><!-->
  6478. <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;">
  6479. <!--<![endif]-->
  6480. <!--[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]-->
  6481. <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;">
  6482. <div style="font-size:12px;line-height:14px;color:#555555;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6483. <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>
  6484. </div>
  6485. </div>
  6486. <!--[if mso]></td></tr></table><![endif]-->
  6487. <div style="padding-right: 20px; padding-left: 20px; padding-top: 15px; padding-bottom: 20px;">
  6488. <!--[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]-->
  6489. <div align="center">
  6490. <div style="border-top: 3px solid #66D9EF; width:40%; line-height:3px; height:3px; font-size:3px;">&#160;</div>
  6491. </div>
  6492. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6493. </div>
  6494. <!--[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]-->
  6495. <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;">
  6496. <div style="font-size:12px;line-height:22px;color:#7E7D7D;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6497. <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>
  6498. </div>
  6499. </div>
  6500. <!--[if mso]></td></tr></table><![endif]-->
  6501. <!--[if (!mso)&(!IE)]><!-->
  6502. </div>
  6503. <!--<![endif]-->
  6504. </div>
  6505. </div>
  6506. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6507. </div>
  6508. </div>
  6509. </div>
  6510. <div style="background-color:#333333;">
  6511. <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;"
  6512. class="block-grid ">
  6513. <div style="border-collapse: collapse;display: table;width: 100%;">
  6514. <!--[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]-->
  6515. <!--[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]-->
  6516. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6517. <div style="background-color: transparent; width: 100% !important;">
  6518. <!--[if (!mso)&(!IE)]><!-->
  6519. <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;">
  6520. <!--<![endif]-->
  6521. <!--[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]-->
  6522. <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;">
  6523. <div style="font-size:12px;line-height:14px;color:#959595;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6524. <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"
  6525. href="https://github.com/causefx/Organizr" target="_blank" rel="noopener noreferrer">Organizr</a><strong><br></strong></p>
  6526. </div>
  6527. </div>
  6528. <!--[if mso]></td></tr></table><![endif]-->
  6529. <!--[if (!mso)&(!IE)]><!-->
  6530. </div>
  6531. <!--<![endif]-->
  6532. </div>
  6533. </div>
  6534. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6535. </div>
  6536. </div>
  6537. </div>
  6538. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  6539. </div>
  6540. <!--[if (mso)|(IE)]></div><![endif]-->
  6541. </body>
  6542. </html>
  6543. ';
  6544. }
  6545. function mimeTypes(){
  6546. return array(
  6547. '123' => 'application/vnd.lotus-1-2-3',
  6548. '3dml' => 'text/vnd.in3d.3dml',
  6549. '3ds' => 'image/x-3ds',
  6550. '3g2' => 'video/3gpp2',
  6551. '3gp' => 'video/3gpp',
  6552. '7z' => 'application/x-7z-compressed',
  6553. 'aab' => 'application/x-authorware-bin',
  6554. 'aac' => 'audio/x-aac',
  6555. 'aam' => 'application/x-authorware-map',
  6556. 'aas' => 'application/x-authorware-seg',
  6557. 'abw' => 'application/x-abiword',
  6558. 'ac' => 'application/pkix-attr-cert',
  6559. 'acc' => 'application/vnd.americandynamics.acc',
  6560. 'ace' => 'application/x-ace-compressed',
  6561. 'acu' => 'application/vnd.acucobol',
  6562. 'acutc' => 'application/vnd.acucorp',
  6563. 'adp' => 'audio/adpcm',
  6564. 'aep' => 'application/vnd.audiograph',
  6565. 'afm' => 'application/x-font-type1',
  6566. 'afp' => 'application/vnd.ibm.modcap',
  6567. 'ahead' => 'application/vnd.ahead.space',
  6568. 'ai' => 'application/postscript',
  6569. 'aif' => 'audio/x-aiff',
  6570. 'aifc' => 'audio/x-aiff',
  6571. 'aiff' => 'audio/x-aiff',
  6572. 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
  6573. 'ait' => 'application/vnd.dvb.ait',
  6574. 'ami' => 'application/vnd.amiga.ami',
  6575. 'apk' => 'application/vnd.android.package-archive',
  6576. 'appcache' => 'text/cache-manifest',
  6577. 'application' => 'application/x-ms-application',
  6578. 'apr' => 'application/vnd.lotus-approach',
  6579. 'arc' => 'application/x-freearc',
  6580. 'asc' => 'application/pgp-signature',
  6581. 'asf' => 'video/x-ms-asf',
  6582. 'asm' => 'text/x-asm',
  6583. 'aso' => 'application/vnd.accpac.simply.aso',
  6584. 'asx' => 'video/x-ms-asf',
  6585. 'atc' => 'application/vnd.acucorp',
  6586. 'atom' => 'application/atom+xml',
  6587. 'atomcat' => 'application/atomcat+xml',
  6588. 'atomsvc' => 'application/atomsvc+xml',
  6589. 'atx' => 'application/vnd.antix.game-component',
  6590. 'au' => 'audio/basic',
  6591. 'avi' => 'video/x-msvideo',
  6592. 'aw' => 'application/applixware',
  6593. 'azf' => 'application/vnd.airzip.filesecure.azf',
  6594. 'azs' => 'application/vnd.airzip.filesecure.azs',
  6595. 'azw' => 'application/vnd.amazon.ebook',
  6596. 'bat' => 'application/x-msdownload',
  6597. 'bcpio' => 'application/x-bcpio',
  6598. 'bdf' => 'application/x-font-bdf',
  6599. 'bdm' => 'application/vnd.syncml.dm+wbxml',
  6600. 'bed' => 'application/vnd.realvnc.bed',
  6601. 'bh2' => 'application/vnd.fujitsu.oasysprs',
  6602. 'bin' => 'application/octet-stream',
  6603. 'blb' => 'application/x-blorb',
  6604. 'blorb' => 'application/x-blorb',
  6605. 'bmi' => 'application/vnd.bmi',
  6606. 'bmp' => 'image/bmp',
  6607. 'book' => 'application/vnd.framemaker',
  6608. 'box' => 'application/vnd.previewsystems.box',
  6609. 'boz' => 'application/x-bzip2',
  6610. 'bpk' => 'application/octet-stream',
  6611. 'btif' => 'image/prs.btif',
  6612. 'bz' => 'application/x-bzip',
  6613. 'bz2' => 'application/x-bzip2',
  6614. 'c' => 'text/x-c',
  6615. 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
  6616. 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
  6617. 'c4d' => 'application/vnd.clonk.c4group',
  6618. 'c4f' => 'application/vnd.clonk.c4group',
  6619. 'c4g' => 'application/vnd.clonk.c4group',
  6620. 'c4p' => 'application/vnd.clonk.c4group',
  6621. 'c4u' => 'application/vnd.clonk.c4group',
  6622. 'cab' => 'application/vnd.ms-cab-compressed',
  6623. 'caf' => 'audio/x-caf',
  6624. 'cap' => 'application/vnd.tcpdump.pcap',
  6625. 'car' => 'application/vnd.curl.car',
  6626. 'cat' => 'application/vnd.ms-pki.seccat',
  6627. 'cb7' => 'application/x-cbr',
  6628. 'cba' => 'application/x-cbr',
  6629. 'cbr' => 'application/x-cbr',
  6630. 'cbt' => 'application/x-cbr',
  6631. 'cbz' => 'application/x-cbr',
  6632. 'cc' => 'text/x-c',
  6633. 'cct' => 'application/x-director',
  6634. 'ccxml' => 'application/ccxml+xml',
  6635. 'cdbcmsg' => 'application/vnd.contact.cmsg',
  6636. 'cdf' => 'application/x-netcdf',
  6637. 'cdkey' => 'application/vnd.mediastation.cdkey',
  6638. 'cdmia' => 'application/cdmi-capability',
  6639. 'cdmic' => 'application/cdmi-container',
  6640. 'cdmid' => 'application/cdmi-domain',
  6641. 'cdmio' => 'application/cdmi-object',
  6642. 'cdmiq' => 'application/cdmi-queue',
  6643. 'cdx' => 'chemical/x-cdx',
  6644. 'cdxml' => 'application/vnd.chemdraw+xml',
  6645. 'cdy' => 'application/vnd.cinderella',
  6646. 'cer' => 'application/pkix-cert',
  6647. 'cfs' => 'application/x-cfs-compressed',
  6648. 'cgm' => 'image/cgm',
  6649. 'chat' => 'application/x-chat',
  6650. 'chm' => 'application/vnd.ms-htmlhelp',
  6651. 'chrt' => 'application/vnd.kde.kchart',
  6652. 'cif' => 'chemical/x-cif',
  6653. 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
  6654. 'cil' => 'application/vnd.ms-artgalry',
  6655. 'cla' => 'application/vnd.claymore',
  6656. 'class' => 'application/java-vm',
  6657. 'clkk' => 'application/vnd.crick.clicker.keyboard',
  6658. 'clkp' => 'application/vnd.crick.clicker.palette',
  6659. 'clkt' => 'application/vnd.crick.clicker.template',
  6660. 'clkw' => 'application/vnd.crick.clicker.wordbank',
  6661. 'clkx' => 'application/vnd.crick.clicker',
  6662. 'clp' => 'application/x-msclip',
  6663. 'cmc' => 'application/vnd.cosmocaller',
  6664. 'cmdf' => 'chemical/x-cmdf',
  6665. 'cml' => 'chemical/x-cml',
  6666. 'cmp' => 'application/vnd.yellowriver-custom-menu',
  6667. 'cmx' => 'image/x-cmx',
  6668. 'cod' => 'application/vnd.rim.cod',
  6669. 'com' => 'application/x-msdownload',
  6670. 'conf' => 'text/plain',
  6671. 'cpio' => 'application/x-cpio',
  6672. 'cpp' => 'text/x-c',
  6673. 'cpt' => 'application/mac-compactpro',
  6674. 'crd' => 'application/x-mscardfile',
  6675. 'crl' => 'application/pkix-crl',
  6676. 'crt' => 'application/x-x509-ca-cert',
  6677. 'cryptonote' => 'application/vnd.rig.cryptonote',
  6678. 'csh' => 'application/x-csh',
  6679. 'csml' => 'chemical/x-csml',
  6680. 'csp' => 'application/vnd.commonspace',
  6681. 'css' => 'text/css',
  6682. 'cst' => 'application/x-director',
  6683. 'csv' => 'text/csv',
  6684. 'cu' => 'application/cu-seeme',
  6685. 'curl' => 'text/vnd.curl',
  6686. 'cww' => 'application/prs.cww',
  6687. 'cxt' => 'application/x-director',
  6688. 'cxx' => 'text/x-c',
  6689. 'dae' => 'model/vnd.collada+xml',
  6690. 'daf' => 'application/vnd.mobius.daf',
  6691. 'dart' => 'application/vnd.dart',
  6692. 'dataless' => 'application/vnd.fdsn.seed',
  6693. 'davmount' => 'application/davmount+xml',
  6694. 'dbk' => 'application/docbook+xml',
  6695. 'dcr' => 'application/x-director',
  6696. 'dcurl' => 'text/vnd.curl.dcurl',
  6697. 'dd2' => 'application/vnd.oma.dd2+xml',
  6698. 'ddd' => 'application/vnd.fujixerox.ddd',
  6699. 'deb' => 'application/x-debian-package',
  6700. 'def' => 'text/plain',
  6701. 'deploy' => 'application/octet-stream',
  6702. 'der' => 'application/x-x509-ca-cert',
  6703. 'dfac' => 'application/vnd.dreamfactory',
  6704. 'dgc' => 'application/x-dgc-compressed',
  6705. 'dic' => 'text/x-c',
  6706. 'dir' => 'application/x-director',
  6707. 'dis' => 'application/vnd.mobius.dis',
  6708. 'dist' => 'application/octet-stream',
  6709. 'distz' => 'application/octet-stream',
  6710. 'djv' => 'image/vnd.djvu',
  6711. 'djvu' => 'image/vnd.djvu',
  6712. 'dll' => 'application/x-msdownload',
  6713. 'dmg' => 'application/x-apple-diskimage',
  6714. 'dmp' => 'application/vnd.tcpdump.pcap',
  6715. 'dms' => 'application/octet-stream',
  6716. 'dna' => 'application/vnd.dna',
  6717. 'doc' => 'application/msword',
  6718. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  6719. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  6720. 'dot' => 'application/msword',
  6721. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  6722. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  6723. 'dp' => 'application/vnd.osgi.dp',
  6724. 'dpg' => 'application/vnd.dpgraph',
  6725. 'dra' => 'audio/vnd.dra',
  6726. 'dsc' => 'text/prs.lines.tag',
  6727. 'dssc' => 'application/dssc+der',
  6728. 'dtb' => 'application/x-dtbook+xml',
  6729. 'dtd' => 'application/xml-dtd',
  6730. 'dts' => 'audio/vnd.dts',
  6731. 'dtshd' => 'audio/vnd.dts.hd',
  6732. 'dump' => 'application/octet-stream',
  6733. 'dvb' => 'video/vnd.dvb.file',
  6734. 'dvi' => 'application/x-dvi',
  6735. 'dwf' => 'model/vnd.dwf',
  6736. 'dwg' => 'image/vnd.dwg',
  6737. 'dxf' => 'image/vnd.dxf',
  6738. 'dxp' => 'application/vnd.spotfire.dxp',
  6739. 'dxr' => 'application/x-director',
  6740. 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
  6741. 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
  6742. 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
  6743. 'ecma' => 'application/ecmascript',
  6744. 'edm' => 'application/vnd.novadigm.edm',
  6745. 'edx' => 'application/vnd.novadigm.edx',
  6746. 'efif' => 'application/vnd.picsel',
  6747. 'ei6' => 'application/vnd.pg.osasli',
  6748. 'elc' => 'application/octet-stream',
  6749. 'emf' => 'application/x-msmetafile',
  6750. 'eml' => 'message/rfc822',
  6751. 'emma' => 'application/emma+xml',
  6752. 'emz' => 'application/x-msmetafile',
  6753. 'eol' => 'audio/vnd.digital-winds',
  6754. 'eot' => 'application/vnd.ms-fontobject',
  6755. 'eps' => 'application/postscript',
  6756. 'epub' => 'application/epub+zip',
  6757. 'es3' => 'application/vnd.eszigno3+xml',
  6758. 'esa' => 'application/vnd.osgi.subsystem',
  6759. 'esf' => 'application/vnd.epson.esf',
  6760. 'et3' => 'application/vnd.eszigno3+xml',
  6761. 'etx' => 'text/x-setext',
  6762. 'eva' => 'application/x-eva',
  6763. 'evy' => 'application/x-envoy',
  6764. 'exe' => 'application/x-msdownload',
  6765. 'exi' => 'application/exi',
  6766. 'ext' => 'application/vnd.novadigm.ext',
  6767. 'ez' => 'application/andrew-inset',
  6768. 'ez2' => 'application/vnd.ezpix-album',
  6769. 'ez3' => 'application/vnd.ezpix-package',
  6770. 'f' => 'text/x-fortran',
  6771. 'f4v' => 'video/x-f4v',
  6772. 'f77' => 'text/x-fortran',
  6773. 'f90' => 'text/x-fortran',
  6774. 'fbs' => 'image/vnd.fastbidsheet',
  6775. 'fcdt' => 'application/vnd.adobe.formscentral.fcdt',
  6776. 'fcs' => 'application/vnd.isac.fcs',
  6777. 'fdf' => 'application/vnd.fdf',
  6778. 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
  6779. 'fg5' => 'application/vnd.fujitsu.oasysgp',
  6780. 'fgd' => 'application/x-director',
  6781. 'fh' => 'image/x-freehand',
  6782. 'fh4' => 'image/x-freehand',
  6783. 'fh5' => 'image/x-freehand',
  6784. 'fh7' => 'image/x-freehand',
  6785. 'fhc' => 'image/x-freehand',
  6786. 'fig' => 'application/x-xfig',
  6787. 'flac' => 'audio/x-flac',
  6788. 'fli' => 'video/x-fli',
  6789. 'flo' => 'application/vnd.micrografx.flo',
  6790. 'flv' => 'video/x-flv',
  6791. 'flw' => 'application/vnd.kde.kivio',
  6792. 'flx' => 'text/vnd.fmi.flexstor',
  6793. 'fly' => 'text/vnd.fly',
  6794. 'fm' => 'application/vnd.framemaker',
  6795. 'fnc' => 'application/vnd.frogans.fnc',
  6796. 'for' => 'text/x-fortran',
  6797. 'fpx' => 'image/vnd.fpx',
  6798. 'frame' => 'application/vnd.framemaker',
  6799. 'fsc' => 'application/vnd.fsc.weblaunch',
  6800. 'fst' => 'image/vnd.fst',
  6801. 'ftc' => 'application/vnd.fluxtime.clip',
  6802. 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
  6803. 'fvt' => 'video/vnd.fvt',
  6804. 'fxp' => 'application/vnd.adobe.fxp',
  6805. 'fxpl' => 'application/vnd.adobe.fxp',
  6806. 'fzs' => 'application/vnd.fuzzysheet',
  6807. 'g2w' => 'application/vnd.geoplan',
  6808. 'g3' => 'image/g3fax',
  6809. 'g3w' => 'application/vnd.geospace',
  6810. 'gac' => 'application/vnd.groove-account',
  6811. 'gam' => 'application/x-tads',
  6812. 'gbr' => 'application/rpki-ghostbusters',
  6813. 'gca' => 'application/x-gca-compressed',
  6814. 'gdl' => 'model/vnd.gdl',
  6815. 'geo' => 'application/vnd.dynageo',
  6816. 'gex' => 'application/vnd.geometry-explorer',
  6817. 'ggb' => 'application/vnd.geogebra.file',
  6818. 'ggt' => 'application/vnd.geogebra.tool',
  6819. 'ghf' => 'application/vnd.groove-help',
  6820. 'gif' => 'image/gif',
  6821. 'gim' => 'application/vnd.groove-identity-message',
  6822. 'gml' => 'application/gml+xml',
  6823. 'gmx' => 'application/vnd.gmx',
  6824. 'gnumeric' => 'application/x-gnumeric',
  6825. 'gph' => 'application/vnd.flographit',
  6826. 'gpx' => 'application/gpx+xml',
  6827. 'gqf' => 'application/vnd.grafeq',
  6828. 'gqs' => 'application/vnd.grafeq',
  6829. 'gram' => 'application/srgs',
  6830. 'gramps' => 'application/x-gramps-xml',
  6831. 'gre' => 'application/vnd.geometry-explorer',
  6832. 'grv' => 'application/vnd.groove-injector',
  6833. 'grxml' => 'application/srgs+xml',
  6834. 'gsf' => 'application/x-font-ghostscript',
  6835. 'gtar' => 'application/x-gtar',
  6836. 'gtm' => 'application/vnd.groove-tool-message',
  6837. 'gtw' => 'model/vnd.gtw',
  6838. 'gv' => 'text/vnd.graphviz',
  6839. 'gxf' => 'application/gxf',
  6840. 'gxt' => 'application/vnd.geonext',
  6841. 'h' => 'text/x-c',
  6842. 'h261' => 'video/h261',
  6843. 'h263' => 'video/h263',
  6844. 'h264' => 'video/h264',
  6845. 'hal' => 'application/vnd.hal+xml',
  6846. 'hbci' => 'application/vnd.hbci',
  6847. 'hdf' => 'application/x-hdf',
  6848. 'hh' => 'text/x-c',
  6849. 'hlp' => 'application/winhlp',
  6850. 'hpgl' => 'application/vnd.hp-hpgl',
  6851. 'hpid' => 'application/vnd.hp-hpid',
  6852. 'hps' => 'application/vnd.hp-hps',
  6853. 'hqx' => 'application/mac-binhex40',
  6854. 'htke' => 'application/vnd.kenameaapp',
  6855. 'htm' => 'text/html',
  6856. 'html' => 'text/html',
  6857. 'hvd' => 'application/vnd.yamaha.hv-dic',
  6858. 'hvp' => 'application/vnd.yamaha.hv-voice',
  6859. 'hvs' => 'application/vnd.yamaha.hv-script',
  6860. 'i2g' => 'application/vnd.intergeo',
  6861. 'icc' => 'application/vnd.iccprofile',
  6862. 'ice' => 'x-conference/x-cooltalk',
  6863. 'icm' => 'application/vnd.iccprofile',
  6864. 'ico' => 'image/x-icon',
  6865. 'ics' => 'text/calendar',
  6866. 'ief' => 'image/ief',
  6867. 'ifb' => 'text/calendar',
  6868. 'ifm' => 'application/vnd.shana.informed.formdata',
  6869. 'iges' => 'model/iges',
  6870. 'igl' => 'application/vnd.igloader',
  6871. 'igm' => 'application/vnd.insors.igm',
  6872. 'igs' => 'model/iges',
  6873. 'igx' => 'application/vnd.micrografx.igx',
  6874. 'iif' => 'application/vnd.shana.informed.interchange',
  6875. 'imp' => 'application/vnd.accpac.simply.imp',
  6876. 'ims' => 'application/vnd.ms-ims',
  6877. 'in' => 'text/plain',
  6878. 'ink' => 'application/inkml+xml',
  6879. 'inkml' => 'application/inkml+xml',
  6880. 'install' => 'application/x-install-instructions',
  6881. 'iota' => 'application/vnd.astraea-software.iota',
  6882. 'ipfix' => 'application/ipfix',
  6883. 'ipk' => 'application/vnd.shana.informed.package',
  6884. 'irm' => 'application/vnd.ibm.rights-management',
  6885. 'irp' => 'application/vnd.irepository.package+xml',
  6886. 'iso' => 'application/x-iso9660-image',
  6887. 'itp' => 'application/vnd.shana.informed.formtemplate',
  6888. 'ivp' => 'application/vnd.immervision-ivp',
  6889. 'ivu' => 'application/vnd.immervision-ivu',
  6890. 'jad' => 'text/vnd.sun.j2me.app-descriptor',
  6891. 'jam' => 'application/vnd.jam',
  6892. 'jar' => 'application/java-archive',
  6893. 'java' => 'text/x-java-source',
  6894. 'jisp' => 'application/vnd.jisp',
  6895. 'jlt' => 'application/vnd.hp-jlyt',
  6896. 'jnlp' => 'application/x-java-jnlp-file',
  6897. 'joda' => 'application/vnd.joost.joda-archive',
  6898. 'jpe' => 'image/jpeg',
  6899. 'jpeg' => 'image/jpeg',
  6900. 'jpg' => 'image/jpeg',
  6901. 'jpgm' => 'video/jpm',
  6902. 'jpgv' => 'video/jpeg',
  6903. 'jpm' => 'video/jpm',
  6904. 'js' => 'application/javascript',
  6905. 'json' => 'application/json',
  6906. 'jsonml' => 'application/jsonml+json',
  6907. 'kar' => 'audio/midi',
  6908. 'karbon' => 'application/vnd.kde.karbon',
  6909. 'kfo' => 'application/vnd.kde.kformula',
  6910. 'kia' => 'application/vnd.kidspiration',
  6911. 'kml' => 'application/vnd.google-earth.kml+xml',
  6912. 'kmz' => 'application/vnd.google-earth.kmz',
  6913. 'kne' => 'application/vnd.kinar',
  6914. 'knp' => 'application/vnd.kinar',
  6915. 'kon' => 'application/vnd.kde.kontour',
  6916. 'kpr' => 'application/vnd.kde.kpresenter',
  6917. 'kpt' => 'application/vnd.kde.kpresenter',
  6918. 'kpxx' => 'application/vnd.ds-keypoint',
  6919. 'ksp' => 'application/vnd.kde.kspread',
  6920. 'ktr' => 'application/vnd.kahootz',
  6921. 'ktx' => 'image/ktx',
  6922. 'ktz' => 'application/vnd.kahootz',
  6923. 'kwd' => 'application/vnd.kde.kword',
  6924. 'kwt' => 'application/vnd.kde.kword',
  6925. 'lasxml' => 'application/vnd.las.las+xml',
  6926. 'latex' => 'application/x-latex',
  6927. 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  6928. 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  6929. 'les' => 'application/vnd.hhe.lesson-player',
  6930. 'lha' => 'application/x-lzh-compressed',
  6931. 'link66' => 'application/vnd.route66.link66+xml',
  6932. 'list' => 'text/plain',
  6933. 'list3820' => 'application/vnd.ibm.modcap',
  6934. 'listafp' => 'application/vnd.ibm.modcap',
  6935. 'lnk' => 'application/x-ms-shortcut',
  6936. 'log' => 'text/plain',
  6937. 'lostxml' => 'application/lost+xml',
  6938. 'lrf' => 'application/octet-stream',
  6939. 'lrm' => 'application/vnd.ms-lrm',
  6940. 'ltf' => 'application/vnd.frogans.ltf',
  6941. 'lvp' => 'audio/vnd.lucent.voice',
  6942. 'lwp' => 'application/vnd.lotus-wordpro',
  6943. 'lzh' => 'application/x-lzh-compressed',
  6944. 'm13' => 'application/x-msmediaview',
  6945. 'm14' => 'application/x-msmediaview',
  6946. 'm1v' => 'video/mpeg',
  6947. 'm21' => 'application/mp21',
  6948. 'm2a' => 'audio/mpeg',
  6949. 'm2v' => 'video/mpeg',
  6950. 'm3a' => 'audio/mpeg',
  6951. 'm3u' => 'audio/x-mpegurl',
  6952. 'm3u8' => 'application/vnd.apple.mpegurl',
  6953. 'm4a' => 'audio/mp4',
  6954. 'm4u' => 'video/vnd.mpegurl',
  6955. 'm4v' => 'video/x-m4v',
  6956. 'ma' => 'application/mathematica',
  6957. 'mads' => 'application/mads+xml',
  6958. 'mag' => 'application/vnd.ecowin.chart',
  6959. 'maker' => 'application/vnd.framemaker',
  6960. 'man' => 'text/troff',
  6961. 'mar' => 'application/octet-stream',
  6962. 'mathml' => 'application/mathml+xml',
  6963. 'mb' => 'application/mathematica',
  6964. 'mbk' => 'application/vnd.mobius.mbk',
  6965. 'mbox' => 'application/mbox',
  6966. 'mc1' => 'application/vnd.medcalcdata',
  6967. 'mcd' => 'application/vnd.mcd',
  6968. 'mcurl' => 'text/vnd.curl.mcurl',
  6969. 'mdb' => 'application/x-msaccess',
  6970. 'mdi' => 'image/vnd.ms-modi',
  6971. 'me' => 'text/troff',
  6972. 'mesh' => 'model/mesh',
  6973. 'meta4' => 'application/metalink4+xml',
  6974. 'metalink' => 'application/metalink+xml',
  6975. 'mets' => 'application/mets+xml',
  6976. 'mfm' => 'application/vnd.mfmp',
  6977. 'mft' => 'application/rpki-manifest',
  6978. 'mgp' => 'application/vnd.osgeo.mapguide.package',
  6979. 'mgz' => 'application/vnd.proteus.magazine',
  6980. 'mid' => 'audio/midi',
  6981. 'midi' => 'audio/midi',
  6982. 'mie' => 'application/x-mie',
  6983. 'mif' => 'application/vnd.mif',
  6984. 'mime' => 'message/rfc822',
  6985. 'mj2' => 'video/mj2',
  6986. 'mjp2' => 'video/mj2',
  6987. 'mk3d' => 'video/x-matroska',
  6988. 'mka' => 'audio/x-matroska',
  6989. 'mks' => 'video/x-matroska',
  6990. 'mkv' => 'video/x-matroska',
  6991. 'mlp' => 'application/vnd.dolby.mlp',
  6992. 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
  6993. 'mmf' => 'application/vnd.smaf',
  6994. 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
  6995. 'mng' => 'video/x-mng',
  6996. 'mny' => 'application/x-msmoney',
  6997. 'mobi' => 'application/x-mobipocket-ebook',
  6998. 'mods' => 'application/mods+xml',
  6999. 'mov' => 'video/quicktime',
  7000. 'movie' => 'video/x-sgi-movie',
  7001. 'mp2' => 'audio/mpeg',
  7002. 'mp21' => 'application/mp21',
  7003. 'mp2a' => 'audio/mpeg',
  7004. 'mp3' => 'audio/mpeg',
  7005. 'mp4' => 'video/mp4',
  7006. 'mp4a' => 'audio/mp4',
  7007. 'mp4s' => 'application/mp4',
  7008. 'mp4v' => 'video/mp4',
  7009. 'mpc' => 'application/vnd.mophun.certificate',
  7010. 'mpe' => 'video/mpeg',
  7011. 'mpeg' => 'video/mpeg',
  7012. 'mpg' => 'video/mpeg',
  7013. 'mpg4' => 'video/mp4',
  7014. 'mpga' => 'audio/mpeg',
  7015. 'mpkg' => 'application/vnd.apple.installer+xml',
  7016. 'mpm' => 'application/vnd.blueice.multipass',
  7017. 'mpn' => 'application/vnd.mophun.application',
  7018. 'mpp' => 'application/vnd.ms-project',
  7019. 'mpt' => 'application/vnd.ms-project',
  7020. 'mpy' => 'application/vnd.ibm.minipay',
  7021. 'mqy' => 'application/vnd.mobius.mqy',
  7022. 'mrc' => 'application/marc',
  7023. 'mrcx' => 'application/marcxml+xml',
  7024. 'ms' => 'text/troff',
  7025. 'mscml' => 'application/mediaservercontrol+xml',
  7026. 'mseed' => 'application/vnd.fdsn.mseed',
  7027. 'mseq' => 'application/vnd.mseq',
  7028. 'msf' => 'application/vnd.epson.msf',
  7029. 'msh' => 'model/mesh',
  7030. 'msi' => 'application/x-msdownload',
  7031. 'msl' => 'application/vnd.mobius.msl',
  7032. 'msty' => 'application/vnd.muvee.style',
  7033. 'mts' => 'model/vnd.mts',
  7034. 'mus' => 'application/vnd.musician',
  7035. 'musicxml' => 'application/vnd.recordare.musicxml+xml',
  7036. 'mvb' => 'application/x-msmediaview',
  7037. 'mwf' => 'application/vnd.mfer',
  7038. 'mxf' => 'application/mxf',
  7039. 'mxl' => 'application/vnd.recordare.musicxml',
  7040. 'mxml' => 'application/xv+xml',
  7041. 'mxs' => 'application/vnd.triscape.mxs',
  7042. 'mxu' => 'video/vnd.mpegurl',
  7043. 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  7044. 'n3' => 'text/n3',
  7045. 'nb' => 'application/mathematica',
  7046. 'nbp' => 'application/vnd.wolfram.player',
  7047. 'nc' => 'application/x-netcdf',
  7048. 'ncx' => 'application/x-dtbncx+xml',
  7049. 'nfo' => 'text/x-nfo',
  7050. 'ngdat' => 'application/vnd.nokia.n-gage.data',
  7051. 'nitf' => 'application/vnd.nitf',
  7052. 'nlu' => 'application/vnd.neurolanguage.nlu',
  7053. 'nml' => 'application/vnd.enliven',
  7054. 'nnd' => 'application/vnd.noblenet-directory',
  7055. 'nns' => 'application/vnd.noblenet-sealer',
  7056. 'nnw' => 'application/vnd.noblenet-web',
  7057. 'npx' => 'image/vnd.net-fpx',
  7058. 'nsc' => 'application/x-conference',
  7059. 'nsf' => 'application/vnd.lotus-notes',
  7060. 'ntf' => 'application/vnd.nitf',
  7061. 'nzb' => 'application/x-nzb',
  7062. 'oa2' => 'application/vnd.fujitsu.oasys2',
  7063. 'oa3' => 'application/vnd.fujitsu.oasys3',
  7064. 'oas' => 'application/vnd.fujitsu.oasys',
  7065. 'obd' => 'application/x-msbinder',
  7066. 'obj' => 'application/x-tgif',
  7067. 'oda' => 'application/oda',
  7068. 'odb' => 'application/vnd.oasis.opendocument.database',
  7069. 'odc' => 'application/vnd.oasis.opendocument.chart',
  7070. 'odf' => 'application/vnd.oasis.opendocument.formula',
  7071. 'odft' => 'application/vnd.oasis.opendocument.formula-template',
  7072. 'odg' => 'application/vnd.oasis.opendocument.graphics',
  7073. 'odi' => 'application/vnd.oasis.opendocument.image',
  7074. 'odm' => 'application/vnd.oasis.opendocument.text-master',
  7075. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  7076. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  7077. 'odt' => 'application/vnd.oasis.opendocument.text',
  7078. 'oga' => 'audio/ogg',
  7079. 'ogg' => 'audio/ogg',
  7080. 'ogv' => 'video/ogg',
  7081. 'ogx' => 'application/ogg',
  7082. 'omdoc' => 'application/omdoc+xml',
  7083. 'onepkg' => 'application/onenote',
  7084. 'onetmp' => 'application/onenote',
  7085. 'onetoc' => 'application/onenote',
  7086. 'onetoc2' => 'application/onenote',
  7087. 'opf' => 'application/oebps-package+xml',
  7088. 'opml' => 'text/x-opml',
  7089. 'oprc' => 'application/vnd.palm',
  7090. 'org' => 'application/vnd.lotus-organizer',
  7091. 'osf' => 'application/vnd.yamaha.openscoreformat',
  7092. 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  7093. 'otc' => 'application/vnd.oasis.opendocument.chart-template',
  7094. 'otf' => 'application/x-font-otf',
  7095. 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
  7096. 'oth' => 'application/vnd.oasis.opendocument.text-web',
  7097. 'oti' => 'application/vnd.oasis.opendocument.image-template',
  7098. 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
  7099. 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  7100. 'ott' => 'application/vnd.oasis.opendocument.text-template',
  7101. 'oxps' => 'application/oxps',
  7102. 'oxt' => 'application/vnd.openofficeorg.extension',
  7103. 'p' => 'text/x-pascal',
  7104. 'p10' => 'application/pkcs10',
  7105. 'p12' => 'application/x-pkcs12',
  7106. 'p7b' => 'application/x-pkcs7-certificates',
  7107. 'p7c' => 'application/pkcs7-mime',
  7108. 'p7m' => 'application/pkcs7-mime',
  7109. 'p7r' => 'application/x-pkcs7-certreqresp',
  7110. 'p7s' => 'application/pkcs7-signature',
  7111. 'p8' => 'application/pkcs8',
  7112. 'pas' => 'text/x-pascal',
  7113. 'paw' => 'application/vnd.pawaafile',
  7114. 'pbd' => 'application/vnd.powerbuilder6',
  7115. 'pbm' => 'image/x-portable-bitmap',
  7116. 'pcap' => 'application/vnd.tcpdump.pcap',
  7117. 'pcf' => 'application/x-font-pcf',
  7118. 'pcl' => 'application/vnd.hp-pcl',
  7119. 'pclxl' => 'application/vnd.hp-pclxl',
  7120. 'pct' => 'image/x-pict',
  7121. 'pcurl' => 'application/vnd.curl.pcurl',
  7122. 'pcx' => 'image/x-pcx',
  7123. 'pdb' => 'application/vnd.palm',
  7124. 'pdf' => 'application/pdf',
  7125. 'pfa' => 'application/x-font-type1',
  7126. 'pfb' => 'application/x-font-type1',
  7127. 'pfm' => 'application/x-font-type1',
  7128. 'pfr' => 'application/font-tdpfr',
  7129. 'pfx' => 'application/x-pkcs12',
  7130. 'pgm' => 'image/x-portable-graymap',
  7131. 'pgn' => 'application/x-chess-pgn',
  7132. 'pgp' => 'application/pgp-encrypted',
  7133. 'pic' => 'image/x-pict',
  7134. 'pkg' => 'application/octet-stream',
  7135. 'pki' => 'application/pkixcmp',
  7136. 'pkipath' => 'application/pkix-pkipath',
  7137. 'plb' => 'application/vnd.3gpp.pic-bw-large',
  7138. 'plc' => 'application/vnd.mobius.plc',
  7139. 'plf' => 'application/vnd.pocketlearn',
  7140. 'pls' => 'application/pls+xml',
  7141. 'pml' => 'application/vnd.ctc-posml',
  7142. 'png' => 'image/png',
  7143. 'pnm' => 'image/x-portable-anymap',
  7144. 'portpkg' => 'application/vnd.macports.portpkg',
  7145. 'pot' => 'application/vnd.ms-powerpoint',
  7146. 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
  7147. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  7148. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  7149. 'ppd' => 'application/vnd.cups-ppd',
  7150. 'ppm' => 'image/x-portable-pixmap',
  7151. 'pps' => 'application/vnd.ms-powerpoint',
  7152. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  7153. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  7154. 'ppt' => 'application/vnd.ms-powerpoint',
  7155. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  7156. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  7157. 'pqa' => 'application/vnd.palm',
  7158. 'prc' => 'application/x-mobipocket-ebook',
  7159. 'pre' => 'application/vnd.lotus-freelance',
  7160. 'prf' => 'application/pics-rules',
  7161. 'ps' => 'application/postscript',
  7162. 'psb' => 'application/vnd.3gpp.pic-bw-small',
  7163. 'psd' => 'image/vnd.adobe.photoshop',
  7164. 'psf' => 'application/x-font-linux-psf',
  7165. 'pskcxml' => 'application/pskc+xml',
  7166. 'ptid' => 'application/vnd.pvi.ptid1',
  7167. 'pub' => 'application/x-mspublisher',
  7168. 'pvb' => 'application/vnd.3gpp.pic-bw-var',
  7169. 'pwn' => 'application/vnd.3m.post-it-notes',
  7170. 'pya' => 'audio/vnd.ms-playready.media.pya',
  7171. 'pyv' => 'video/vnd.ms-playready.media.pyv',
  7172. 'qam' => 'application/vnd.epson.quickanime',
  7173. 'qbo' => 'application/vnd.intu.qbo',
  7174. 'qfx' => 'application/vnd.intu.qfx',
  7175. 'qps' => 'application/vnd.publishare-delta-tree',
  7176. 'qt' => 'video/quicktime',
  7177. 'qwd' => 'application/vnd.quark.quarkxpress',
  7178. 'qwt' => 'application/vnd.quark.quarkxpress',
  7179. 'qxb' => 'application/vnd.quark.quarkxpress',
  7180. 'qxd' => 'application/vnd.quark.quarkxpress',
  7181. 'qxl' => 'application/vnd.quark.quarkxpress',
  7182. 'qxt' => 'application/vnd.quark.quarkxpress',
  7183. 'ra' => 'audio/x-pn-realaudio',
  7184. 'ram' => 'audio/x-pn-realaudio',
  7185. 'rar' => 'application/x-rar-compressed',
  7186. 'ras' => 'image/x-cmu-raster',
  7187. 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
  7188. 'rdf' => 'application/rdf+xml',
  7189. 'rdz' => 'application/vnd.data-vision.rdz',
  7190. 'rep' => 'application/vnd.businessobjects',
  7191. 'res' => 'application/x-dtbresource+xml',
  7192. 'rgb' => 'image/x-rgb',
  7193. 'rif' => 'application/reginfo+xml',
  7194. 'rip' => 'audio/vnd.rip',
  7195. 'ris' => 'application/x-research-info-systems',
  7196. 'rl' => 'application/resource-lists+xml',
  7197. 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
  7198. 'rld' => 'application/resource-lists-diff+xml',
  7199. 'rm' => 'application/vnd.rn-realmedia',
  7200. 'rmi' => 'audio/midi',
  7201. 'rmp' => 'audio/x-pn-realaudio-plugin',
  7202. 'rms' => 'application/vnd.jcp.javame.midlet-rms',
  7203. 'rmvb' => 'application/vnd.rn-realmedia-vbr',
  7204. 'rnc' => 'application/relax-ng-compact-syntax',
  7205. 'roa' => 'application/rpki-roa',
  7206. 'roff' => 'text/troff',
  7207. 'rp9' => 'application/vnd.cloanto.rp9',
  7208. 'rpss' => 'application/vnd.nokia.radio-presets',
  7209. 'rpst' => 'application/vnd.nokia.radio-preset',
  7210. 'rq' => 'application/sparql-query',
  7211. 'rs' => 'application/rls-services+xml',
  7212. 'rsd' => 'application/rsd+xml',
  7213. 'rss' => 'application/rss+xml',
  7214. 'rtf' => 'application/rtf',
  7215. 'rtx' => 'text/richtext',
  7216. 's' => 'text/x-asm',
  7217. 's3m' => 'audio/s3m',
  7218. 'saf' => 'application/vnd.yamaha.smaf-audio',
  7219. 'sbml' => 'application/sbml+xml',
  7220. 'sc' => 'application/vnd.ibm.secure-container',
  7221. 'scd' => 'application/x-msschedule',
  7222. 'scm' => 'application/vnd.lotus-screencam',
  7223. 'scq' => 'application/scvp-cv-request',
  7224. 'scs' => 'application/scvp-cv-response',
  7225. 'scurl' => 'text/vnd.curl.scurl',
  7226. 'sda' => 'application/vnd.stardivision.draw',
  7227. 'sdc' => 'application/vnd.stardivision.calc',
  7228. 'sdd' => 'application/vnd.stardivision.impress',
  7229. 'sdkd' => 'application/vnd.solent.sdkm+xml',
  7230. 'sdkm' => 'application/vnd.solent.sdkm+xml',
  7231. 'sdp' => 'application/sdp',
  7232. 'sdw' => 'application/vnd.stardivision.writer',
  7233. 'see' => 'application/vnd.seemail',
  7234. 'seed' => 'application/vnd.fdsn.seed',
  7235. 'sema' => 'application/vnd.sema',
  7236. 'semd' => 'application/vnd.semd',
  7237. 'semf' => 'application/vnd.semf',
  7238. 'ser' => 'application/java-serialized-object',
  7239. 'setpay' => 'application/set-payment-initiation',
  7240. 'setreg' => 'application/set-registration-initiation',
  7241. 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
  7242. 'sfs' => 'application/vnd.spotfire.sfs',
  7243. 'sfv' => 'text/x-sfv',
  7244. 'sgi' => 'image/sgi',
  7245. 'sgl' => 'application/vnd.stardivision.writer-global',
  7246. 'sgm' => 'text/sgml',
  7247. 'sgml' => 'text/sgml',
  7248. 'sh' => 'application/x-sh',
  7249. 'shar' => 'application/x-shar',
  7250. 'shf' => 'application/shf+xml',
  7251. 'sid' => 'image/x-mrsid-image',
  7252. 'sig' => 'application/pgp-signature',
  7253. 'sil' => 'audio/silk',
  7254. 'silo' => 'model/mesh',
  7255. 'sis' => 'application/vnd.symbian.install',
  7256. 'sisx' => 'application/vnd.symbian.install',
  7257. 'sit' => 'application/x-stuffit',
  7258. 'sitx' => 'application/x-stuffitx',
  7259. 'skd' => 'application/vnd.koan',
  7260. 'skm' => 'application/vnd.koan',
  7261. 'skp' => 'application/vnd.koan',
  7262. 'skt' => 'application/vnd.koan',
  7263. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  7264. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  7265. 'slt' => 'application/vnd.epson.salt',
  7266. 'sm' => 'application/vnd.stepmania.stepchart',
  7267. 'smf' => 'application/vnd.stardivision.math',
  7268. 'smi' => 'application/smil+xml',
  7269. 'smil' => 'application/smil+xml',
  7270. 'smv' => 'video/x-smv',
  7271. 'smzip' => 'application/vnd.stepmania.package',
  7272. 'snd' => 'audio/basic',
  7273. 'snf' => 'application/x-font-snf',
  7274. 'so' => 'application/octet-stream',
  7275. 'spc' => 'application/x-pkcs7-certificates',
  7276. 'spf' => 'application/vnd.yamaha.smaf-phrase',
  7277. 'spl' => 'application/x-futuresplash',
  7278. 'spot' => 'text/vnd.in3d.spot',
  7279. 'spp' => 'application/scvp-vp-response',
  7280. 'spq' => 'application/scvp-vp-request',
  7281. 'spx' => 'audio/ogg',
  7282. 'sql' => 'application/x-sql',
  7283. 'src' => 'application/x-wais-source',
  7284. 'srt' => 'application/x-subrip',
  7285. 'sru' => 'application/sru+xml',
  7286. 'srx' => 'application/sparql-results+xml',
  7287. 'ssdl' => 'application/ssdl+xml',
  7288. 'sse' => 'application/vnd.kodak-descriptor',
  7289. 'ssf' => 'application/vnd.epson.ssf',
  7290. 'ssml' => 'application/ssml+xml',
  7291. 'st' => 'application/vnd.sailingtracker.track',
  7292. 'stc' => 'application/vnd.sun.xml.calc.template',
  7293. 'std' => 'application/vnd.sun.xml.draw.template',
  7294. 'stf' => 'application/vnd.wt.stf',
  7295. 'sti' => 'application/vnd.sun.xml.impress.template',
  7296. 'stk' => 'application/hyperstudio',
  7297. 'stl' => 'application/vnd.ms-pki.stl',
  7298. 'str' => 'application/vnd.pg.format',
  7299. 'stw' => 'application/vnd.sun.xml.writer.template',
  7300. 'sub' => 'image/vnd.dvb.subtitle',
  7301. 'sub' => 'text/vnd.dvb.subtitle',
  7302. 'sus' => 'application/vnd.sus-calendar',
  7303. 'susp' => 'application/vnd.sus-calendar',
  7304. 'sv4cpio' => 'application/x-sv4cpio',
  7305. 'sv4crc' => 'application/x-sv4crc',
  7306. 'svc' => 'application/vnd.dvb.service',
  7307. 'svd' => 'application/vnd.svd',
  7308. 'svg' => 'image/svg+xml',
  7309. 'svgz' => 'image/svg+xml',
  7310. 'swa' => 'application/x-director',
  7311. 'swf' => 'application/x-shockwave-flash',
  7312. 'swi' => 'application/vnd.aristanetworks.swi',
  7313. 'sxc' => 'application/vnd.sun.xml.calc',
  7314. 'sxd' => 'application/vnd.sun.xml.draw',
  7315. 'sxg' => 'application/vnd.sun.xml.writer.global',
  7316. 'sxi' => 'application/vnd.sun.xml.impress',
  7317. 'sxm' => 'application/vnd.sun.xml.math',
  7318. 'sxw' => 'application/vnd.sun.xml.writer',
  7319. 't' => 'text/troff',
  7320. 't3' => 'application/x-t3vm-image',
  7321. 'taglet' => 'application/vnd.mynfc',
  7322. 'tao' => 'application/vnd.tao.intent-module-archive',
  7323. 'tar' => 'application/x-tar',
  7324. 'tcap' => 'application/vnd.3gpp2.tcap',
  7325. 'tcl' => 'application/x-tcl',
  7326. 'teacher' => 'application/vnd.smart.teacher',
  7327. 'tei' => 'application/tei+xml',
  7328. 'teicorpus' => 'application/tei+xml',
  7329. 'tex' => 'application/x-tex',
  7330. 'texi' => 'application/x-texinfo',
  7331. 'texinfo' => 'application/x-texinfo',
  7332. 'text' => 'text/plain',
  7333. 'tfi' => 'application/thraud+xml',
  7334. 'tfm' => 'application/x-tex-tfm',
  7335. 'tga' => 'image/x-tga',
  7336. 'thmx' => 'application/vnd.ms-officetheme',
  7337. 'tif' => 'image/tiff',
  7338. 'tiff' => 'image/tiff',
  7339. 'tmo' => 'application/vnd.tmobile-livetv',
  7340. 'torrent' => 'application/x-bittorrent',
  7341. 'tpl' => 'application/vnd.groove-tool-template',
  7342. 'tpt' => 'application/vnd.trid.tpt',
  7343. 'tr' => 'text/troff',
  7344. 'tra' => 'application/vnd.trueapp',
  7345. 'trm' => 'application/x-msterminal',
  7346. 'tsd' => 'application/timestamped-data',
  7347. 'tsv' => 'text/tab-separated-values',
  7348. 'ttc' => 'application/x-font-ttf',
  7349. 'ttf' => 'application/x-font-ttf',
  7350. 'ttl' => 'text/turtle',
  7351. 'twd' => 'application/vnd.simtech-mindmapper',
  7352. 'twds' => 'application/vnd.simtech-mindmapper',
  7353. 'txd' => 'application/vnd.genomatix.tuxedo',
  7354. 'txf' => 'application/vnd.mobius.txf',
  7355. 'txt' => 'text/plain',
  7356. 'u32' => 'application/x-authorware-bin',
  7357. 'udeb' => 'application/x-debian-package',
  7358. 'ufd' => 'application/vnd.ufdl',
  7359. 'ufdl' => 'application/vnd.ufdl',
  7360. 'ulx' => 'application/x-glulx',
  7361. 'umj' => 'application/vnd.umajin',
  7362. 'unityweb' => 'application/vnd.unity',
  7363. 'uoml' => 'application/vnd.uoml+xml',
  7364. 'uri' => 'text/uri-list',
  7365. 'uris' => 'text/uri-list',
  7366. 'urls' => 'text/uri-list',
  7367. 'ustar' => 'application/x-ustar',
  7368. 'utz' => 'application/vnd.uiq.theme',
  7369. 'uu' => 'text/x-uuencode',
  7370. 'uva' => 'audio/vnd.dece.audio',
  7371. 'uvd' => 'application/vnd.dece.data',
  7372. 'uvf' => 'application/vnd.dece.data',
  7373. 'uvg' => 'image/vnd.dece.graphic',
  7374. 'uvh' => 'video/vnd.dece.hd',
  7375. 'uvi' => 'image/vnd.dece.graphic',
  7376. 'uvm' => 'video/vnd.dece.mobile',
  7377. 'uvp' => 'video/vnd.dece.pd',
  7378. 'uvs' => 'video/vnd.dece.sd',
  7379. 'uvt' => 'application/vnd.dece.ttml+xml',
  7380. 'uvu' => 'video/vnd.uvvu.mp4',
  7381. 'uvv' => 'video/vnd.dece.video',
  7382. 'uvva' => 'audio/vnd.dece.audio',
  7383. 'uvvd' => 'application/vnd.dece.data',
  7384. 'uvvf' => 'application/vnd.dece.data',
  7385. 'uvvg' => 'image/vnd.dece.graphic',
  7386. 'uvvh' => 'video/vnd.dece.hd',
  7387. 'uvvi' => 'image/vnd.dece.graphic',
  7388. 'uvvm' => 'video/vnd.dece.mobile',
  7389. 'uvvp' => 'video/vnd.dece.pd',
  7390. 'uvvs' => 'video/vnd.dece.sd',
  7391. 'uvvt' => 'application/vnd.dece.ttml+xml',
  7392. 'uvvu' => 'video/vnd.uvvu.mp4',
  7393. 'uvvv' => 'video/vnd.dece.video',
  7394. 'uvvx' => 'application/vnd.dece.unspecified',
  7395. 'uvvz' => 'application/vnd.dece.zip',
  7396. 'uvx' => 'application/vnd.dece.unspecified',
  7397. 'uvz' => 'application/vnd.dece.zip',
  7398. 'vcard' => 'text/vcard',
  7399. 'vcd' => 'application/x-cdlink',
  7400. 'vcf' => 'text/x-vcard',
  7401. 'vcg' => 'application/vnd.groove-vcard',
  7402. 'vcs' => 'text/x-vcalendar',
  7403. 'vcx' => 'application/vnd.vcx',
  7404. 'vis' => 'application/vnd.visionary',
  7405. 'viv' => 'video/vnd.vivo',
  7406. 'vob' => 'video/x-ms-vob',
  7407. 'vor' => 'application/vnd.stardivision.writer',
  7408. 'vox' => 'application/x-authorware-bin',
  7409. 'vrml' => 'model/vrml',
  7410. 'vsd' => 'application/vnd.visio',
  7411. 'vsf' => 'application/vnd.vsf',
  7412. 'vss' => 'application/vnd.visio',
  7413. 'vst' => 'application/vnd.visio',
  7414. 'vsw' => 'application/vnd.visio',
  7415. 'vtu' => 'model/vnd.vtu',
  7416. 'vxml' => 'application/voicexml+xml',
  7417. 'w3d' => 'application/x-director',
  7418. 'wad' => 'application/x-doom',
  7419. 'wav' => 'audio/x-wav',
  7420. 'wax' => 'audio/x-ms-wax',
  7421. 'wbmp' => 'image/vnd.wap.wbmp',
  7422. 'wbs' => 'application/vnd.criticaltools.wbs+xml',
  7423. 'wbxml' => 'application/vnd.wap.wbxml',
  7424. 'wcm' => 'application/vnd.ms-works',
  7425. 'wdb' => 'application/vnd.ms-works',
  7426. 'wdp' => 'image/vnd.ms-photo',
  7427. 'weba' => 'audio/webm',
  7428. 'webm' => 'video/webm',
  7429. 'webp' => 'image/webp',
  7430. 'wg' => 'application/vnd.pmi.widget',
  7431. 'wgt' => 'application/widget',
  7432. 'wks' => 'application/vnd.ms-works',
  7433. 'wm' => 'video/x-ms-wm',
  7434. 'wma' => 'audio/x-ms-wma',
  7435. 'wmd' => 'application/x-ms-wmd',
  7436. 'wmf' => 'application/x-msmetafile',
  7437. 'wml' => 'text/vnd.wap.wml',
  7438. 'wmlc' => 'application/vnd.wap.wmlc',
  7439. 'wmls' => 'text/vnd.wap.wmlscript',
  7440. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  7441. 'wmv' => 'video/x-ms-wmv',
  7442. 'wmx' => 'video/x-ms-wmx',
  7443. 'wmz' => 'application/x-ms-wmz',
  7444. 'wmz' => 'application/x-msmetafile',
  7445. 'woff' => 'application/font-woff',
  7446. 'wpd' => 'application/vnd.wordperfect',
  7447. 'wpl' => 'application/vnd.ms-wpl',
  7448. 'wps' => 'application/vnd.ms-works',
  7449. 'wqd' => 'application/vnd.wqd',
  7450. 'wri' => 'application/x-mswrite',
  7451. 'wrl' => 'model/vrml',
  7452. 'wsdl' => 'application/wsdl+xml',
  7453. 'wspolicy' => 'application/wspolicy+xml',
  7454. 'wtb' => 'application/vnd.webturbo',
  7455. 'wvx' => 'video/x-ms-wvx',
  7456. 'x32' => 'application/x-authorware-bin',
  7457. 'x3d' => 'model/x3d+xml',
  7458. 'x3db' => 'model/x3d+binary',
  7459. 'x3dbz' => 'model/x3d+binary',
  7460. 'x3dv' => 'model/x3d+vrml',
  7461. 'x3dvz' => 'model/x3d+vrml',
  7462. 'x3dz' => 'model/x3d+xml',
  7463. 'xaml' => 'application/xaml+xml',
  7464. 'xap' => 'application/x-silverlight-app',
  7465. 'xar' => 'application/vnd.xara',
  7466. 'xbap' => 'application/x-ms-xbap',
  7467. 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
  7468. 'xbm' => 'image/x-xbitmap',
  7469. 'xdf' => 'application/xcap-diff+xml',
  7470. 'xdm' => 'application/vnd.syncml.dm+xml',
  7471. 'xdp' => 'application/vnd.adobe.xdp+xml',
  7472. 'xdssc' => 'application/dssc+xml',
  7473. 'xdw' => 'application/vnd.fujixerox.docuworks',
  7474. 'xenc' => 'application/xenc+xml',
  7475. 'xer' => 'application/patch-ops-error+xml',
  7476. 'xfdf' => 'application/vnd.adobe.xfdf',
  7477. 'xfdl' => 'application/vnd.xfdl',
  7478. 'xht' => 'application/xhtml+xml',
  7479. 'xhtml' => 'application/xhtml+xml',
  7480. 'xhvml' => 'application/xv+xml',
  7481. 'xif' => 'image/vnd.xiff',
  7482. 'xla' => 'application/vnd.ms-excel',
  7483. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  7484. 'xlc' => 'application/vnd.ms-excel',
  7485. 'xlf' => 'application/x-xliff+xml',
  7486. 'xlm' => 'application/vnd.ms-excel',
  7487. 'xls' => 'application/vnd.ms-excel',
  7488. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  7489. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  7490. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  7491. 'xlt' => 'application/vnd.ms-excel',
  7492. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  7493. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  7494. 'xlw' => 'application/vnd.ms-excel',
  7495. 'xm' => 'audio/xm',
  7496. 'xml' => 'application/xml',
  7497. 'xo' => 'application/vnd.olpc-sugar',
  7498. 'xop' => 'application/xop+xml',
  7499. 'xpi' => 'application/x-xpinstall',
  7500. 'xpl' => 'application/xproc+xml',
  7501. 'xpm' => 'image/x-xpixmap',
  7502. 'xpr' => 'application/vnd.is-xpr',
  7503. 'xps' => 'application/vnd.ms-xpsdocument',
  7504. 'xpw' => 'application/vnd.intercon.formnet',
  7505. 'xpx' => 'application/vnd.intercon.formnet',
  7506. 'xsl' => 'application/xml',
  7507. 'xslt' => 'application/xslt+xml',
  7508. 'xsm' => 'application/vnd.syncml+xml',
  7509. 'xspf' => 'application/xspf+xml',
  7510. 'xul' => 'application/vnd.mozilla.xul+xml',
  7511. 'xvm' => 'application/xv+xml',
  7512. 'xvml' => 'application/xv+xml',
  7513. 'xwd' => 'image/x-xwindowdump',
  7514. 'xyz' => 'chemical/x-xyz',
  7515. 'xz' => 'application/x-xz',
  7516. 'yang' => 'application/yang',
  7517. 'yin' => 'application/yin+xml',
  7518. 'z1' => 'application/x-zmachine',
  7519. 'z2' => 'application/x-zmachine',
  7520. 'z3' => 'application/x-zmachine',
  7521. 'z4' => 'application/x-zmachine',
  7522. 'z5' => 'application/x-zmachine',
  7523. 'z6' => 'application/x-zmachine',
  7524. 'z7' => 'application/x-zmachine',
  7525. 'z8' => 'application/x-zmachine',
  7526. 'zaz' => 'application/vnd.zzazz.deck+xml',
  7527. 'zip' => 'application/zip',
  7528. 'zir' => 'application/vnd.zul',
  7529. 'zirz' => 'application/vnd.zul',
  7530. 'zmm' => 'application/vnd.handheld-entertainment+xml'
  7531. );
  7532. }
  7533. // Always run this
  7534. if(strpos($_SERVER['SCRIPT_NAME'], 'check.php') == false){
  7535. dependCheck();
  7536. }