functions.php 325 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863
  1. <?php
  2. // ===================================
  3. // Define Version
  4. define('INSTALLEDVERSION', '1.50');
  5. // ===================================
  6. use Kryptonit3\Sonarr\Sonarr;
  7. use Kryptonit3\SickRage\SickRage;
  8. // Debugging output functions
  9. function debug_out($variable, $die = false) {
  10. $trace = debug_backtrace()[0];
  11. echo "<center><img height='200px' src='images/confused.png'></center>";
  12. echo "<center>Look's like something happened, here are the errors and perhaps how to fix them:</center>";
  13. echo '<pre style="white-space: pre-line; background-color: #f2f2f2; border: 2px solid black; border-radius: 5px; padding: 5px; margin: 5px;">'.$trace['file'].':'.$trace['line']."\n\n".print_r($variable, true).'</pre>';
  14. if ($die) { http_response_code(503); die(); }
  15. }
  16. // ==== Auth Plugins START ====
  17. if (function_exists('ldap_connect')) :
  18. // Pass credentials to LDAP backend
  19. function plugin_auth_ldap($username, $password) {
  20. $ldapServers = explode(',',AUTHBACKENDHOST);
  21. foreach($ldapServers as $key => $value) {
  22. // Calculate parts
  23. $digest = parse_url(trim($value));
  24. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:'ldap'));
  25. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  26. $port = (isset($digest['port'])?$digest['port']:(strtolower($scheme)=='ldap'?389:636));
  27. // Reassign
  28. $ldapServers[$key] = $scheme.'://'.$host.':'.$port;
  29. }
  30. // returns true or false
  31. $ldap = ldap_connect(implode(' ',$ldapServers));
  32. if(empty(AUTHBACKENDDOMAINFORMAT)){
  33. if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
  34. writeLog("success", "LDAP authentication success");
  35. return true;
  36. } else {
  37. writeLog("error", "LDAP could not authenticate");
  38. return false;
  39. }
  40. }else{
  41. ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
  42. ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
  43. $bind = @ldap_bind($ldap, sprintf(AUTHBACKENDDOMAINFORMAT, $username), $password);
  44. if ($bind) {
  45. writeLog("success", "LDAP authentication success");
  46. return true;
  47. } else {
  48. writeLog("error", "LDPA could not authenticate");
  49. return false;
  50. }
  51. }
  52. writeLog("error", "LDAP could not authenticate");
  53. return false;
  54. }
  55. else :
  56. // Ldap Auth Missing Dependancy
  57. function plugin_auth_ldap_disabled() {
  58. return 'LDAP - Disabled (Dependancy: php-ldap missing!)';
  59. }
  60. endif;
  61. // Pass credentials to FTP backend
  62. function plugin_auth_ftp($username, $password) {
  63. // Calculate parts
  64. $digest = parse_url(AUTHBACKENDHOST);
  65. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:(function_exists('ftp_ssl_connect')?'ftps':'ftp')));
  66. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  67. $port = (isset($digest['port'])?$digest['port']:21);
  68. // Determine Connection Type
  69. if ($scheme == 'ftps') {
  70. $conn_id = ftp_ssl_connect($host, $port, 20);
  71. } elseif ($scheme == 'ftp') {
  72. $conn_id = ftp_connect($host, $port, 20);
  73. } else {
  74. debug_out('Invalid FTP scheme. Use ftp or ftps');
  75. writeLog("error", "invalid FTP scheme");
  76. return false;
  77. }
  78. // Check if valid FTP connection
  79. if ($conn_id) {
  80. // Attempt login
  81. @$login_result = ftp_login($conn_id, $username, $password);
  82. ftp_close($conn_id);
  83. // Return Result
  84. if ($login_result) {
  85. writeLog("success", "$username authenticated");
  86. return true;
  87. } else {
  88. writeLog("error", "$username could not authenticate");
  89. return false;
  90. }
  91. } else {
  92. return false;
  93. }
  94. return false;
  95. }
  96. // Pass credentials to Emby Backend
  97. function plugin_auth_emby_local($username, $password) {
  98. $embyAddress = qualifyURL(EMBYURL);
  99. $headers = array(
  100. 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"',
  101. 'Content-Type' => 'application/json',
  102. );
  103. $body = array(
  104. 'Username' => $username,
  105. 'Password' => sha1($password),
  106. 'PasswordMd5' => md5($password),
  107. );
  108. $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers);
  109. if (isset($response['content'])) {
  110. $json = json_decode($response['content'], true);
  111. if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
  112. // Login Success - Now Logout Emby Session As We No Longer Need It
  113. $headers = array(
  114. 'X-Mediabrowser-Token' => $json['AccessToken'],
  115. );
  116. $response = post_router($embyAddress.'/Sessions/Logout', array(), $headers);
  117. return true;
  118. }
  119. }
  120. return false;
  121. }
  122. if (function_exists('curl_version')) :
  123. // Authenticate Against Emby Local (first) and Emby Connect
  124. function plugin_auth_emby_all($username, $password) {
  125. $localResult = plugin_auth_emby_local($username, $password);
  126. if ($localResult) {
  127. return $localResult;
  128. } else {
  129. return plugin_auth_emby_connect($username, $password);
  130. }
  131. }
  132. // Authenicate against emby connect
  133. function plugin_auth_emby_connect($username, $password) {
  134. $embyAddress = qualifyURL(EMBYURL);
  135. // Get A User
  136. $connectId = '';
  137. $userIds = json_decode(file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
  138. if (is_array($userIds)) {
  139. foreach ($userIds as $key => $value) { // Scan for this user
  140. if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
  141. if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
  142. $connectId = $value['ConnectUserId'];
  143. break;
  144. }
  145. }
  146. }
  147. if ($connectId) {
  148. $connectURL = 'https://connect.emby.media/service/user/authenticate';
  149. $headers = array(
  150. 'Accept'=> 'application/json',
  151. 'Content-Type' => 'application/x-www-form-urlencoded',
  152. );
  153. $body = array(
  154. 'nameOrEmail' => $username,
  155. 'rawpw' => $password,
  156. );
  157. $result = curl_post($connectURL, $body, $headers);
  158. if (isset($result['content'])) {
  159. $json = json_decode($result['content'], true);
  160. if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
  161. return array(
  162. 'email' => $json['User']['Email'],
  163. 'image' => $json['User']['ImageUrl'],
  164. );
  165. }
  166. }
  167. }
  168. }
  169. return false;
  170. }
  171. // Pass credentials to Plex Backend
  172. function plugin_auth_plex($username, $password) {
  173. // Quick out
  174. $isAdmin = false;
  175. if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
  176. writeLog("success", "Admin: ".$username." authenticated by plex");
  177. //return true;
  178. $isAdmin = true;
  179. }
  180. //Get User List
  181. $userURL = 'https://plex.tv/pms/friends/all';
  182. $userHeaders = array(
  183. 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD),
  184. );
  185. libxml_use_internal_errors(true);
  186. $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
  187. if (is_array($userXML) || is_object($userXML)) {
  188. $isUser = false;
  189. $usernameLower = strtolower($username);
  190. foreach($userXML AS $child) {
  191. if(isset($child['username']) && strtolower($child['username']) == $usernameLower) {
  192. $isUser = true;
  193. writeLog("success", $usernameLower." was found in plex friends list");
  194. break;
  195. }
  196. }
  197. if ($isUser || $isAdmin) {
  198. //Login User
  199. $connectURL = 'https://plex.tv/users/sign_in.json';
  200. $headers = array(
  201. 'Accept'=> 'application/json',
  202. 'Content-Type' => 'application/x-www-form-urlencoded',
  203. 'X-Plex-Product' => 'Organizr',
  204. 'X-Plex-Version' => '1.0',
  205. 'X-Plex-Client-Identifier' => '01010101-10101010',
  206. );
  207. $body = array(
  208. 'user[login]' => $username,
  209. 'user[password]' => $password,
  210. );
  211. $result = curl_post($connectURL, $body, $headers);
  212. if (isset($result['content'])) {
  213. $json = json_decode($result['content'], true);
  214. if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && strtolower($json['user']['username']) == $usernameLower) {
  215. writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
  216. return array(
  217. 'email' => $json['user']['email'],
  218. 'image' => $json['user']['thumb'],
  219. 'token' => $json['user']['authToken']
  220. );
  221. }
  222. }
  223. }else{
  224. writeLog("error", "$username is not an authorized PLEX user or entered invalid password");
  225. }
  226. }else{
  227. writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");
  228. }
  229. return false;
  230. }
  231. else :
  232. // Plex Auth Missing Dependancy
  233. function plugin_auth_plex_disabled() {
  234. return 'Plex - Disabled (Dependancy: php-curl missing!)';
  235. }
  236. // Emby Connect Auth Missing Dependancy
  237. function plugin_auth_emby_connect_disabled() {
  238. return 'Emby Connect - Disabled (Dependancy: php-curl missing!)';
  239. }
  240. // Emby Both Auth Missing Dependancy
  241. function plugin_auth_emby_both_disabled() {
  242. return 'Emby Both - Disabled (Dependancy: php-curl missing!)';
  243. }
  244. endif;
  245. // ==== Auth Plugins END ====
  246. // ==== General Class Definitions START ====
  247. $userLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  248. class setLanguage {
  249. private $language = null;
  250. private $langCode = null;
  251. function __construct($language = false) {
  252. // Default
  253. if (!$language) {
  254. $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  255. }
  256. if (!file_exists("lang/{$language}.ini")) {
  257. $language = 'en';
  258. }
  259. $this->langCode = $language;
  260. $this->language = parse_ini_file("lang/{$language}.ini", false, INI_SCANNER_RAW);
  261. if (file_exists("lang/{$language}.cust.ini")) {
  262. foreach($tmp = parse_ini_file("lang/{$language}.cust.ini", false, INI_SCANNER_RAW) as $k => $v) {
  263. $this->language[$k] = $v;
  264. }
  265. }
  266. }
  267. public function getLang() {
  268. return $this->langCode;
  269. }
  270. public function translate($originalWord) {
  271. $getArg = func_num_args();
  272. if ($getArg > 1) {
  273. $allWords = func_get_args();
  274. array_shift($allWords);
  275. } else {
  276. $allWords = array();
  277. }
  278. $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null;
  279. if (!$translatedWord) {
  280. return ucwords(str_replace("_", " ", strtolower($originalWord)));
  281. //echo "WHOA!!!!!!! $originalWord";
  282. }
  283. $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES);
  284. return vsprintf($translatedWord, $allWords);
  285. }
  286. }
  287. $language = new setLanguage;
  288. // ==== General Class Definitions END ====
  289. // Direct request to curl if it exists, otherwise handle if not HTTPS
  290. function post_router($url, $data, $headers = array(), $referer='') {
  291. if (function_exists('curl_version')) {
  292. return curl_post($url, $data, $headers, $referer);
  293. } else {
  294. return post_request($url, $data, $headers, $referer);
  295. }
  296. }
  297. if (function_exists('curl_version')) :
  298. // Curl Post
  299. function curl_post($url, $data, $headers = array(), $referer='') {
  300. // Initiate cURL
  301. $curlReq = curl_init($url);
  302. // As post request
  303. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST");
  304. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  305. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  306. if(localURL($url)){
  307. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  308. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  309. }
  310. // Format Data
  311. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  312. case 'application/json':
  313. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  314. break;
  315. case 'application/x-www-form-urlencoded':
  316. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  317. break;
  318. default:
  319. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  320. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  321. }
  322. // Format Headers
  323. $cHeaders = array();
  324. foreach ($headers as $k => $v) {
  325. $cHeaders[] = $k.': '.$v;
  326. }
  327. if (count($cHeaders)) {
  328. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  329. }
  330. // Execute
  331. $result = curl_exec($curlReq);
  332. $httpcode = curl_getinfo($curlReq);
  333. // Close
  334. curl_close($curlReq);
  335. // Return
  336. return array('content'=>$result, 'http_code'=>$httpcode);
  337. }
  338. //Curl Get Function
  339. function curl_get($url, $headers = array()) {
  340. // Initiate cURL
  341. $curlReq = curl_init($url);
  342. // As post request
  343. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET");
  344. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  345. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  346. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  347. if(localURL($url)){
  348. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  349. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  350. }
  351. // Format Headers
  352. $cHeaders = array();
  353. foreach ($headers as $k => $v) {
  354. $cHeaders[] = $k.': '.$v;
  355. }
  356. if (count($cHeaders)) {
  357. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  358. }
  359. // Execute
  360. $result = curl_exec($curlReq);
  361. // Close
  362. curl_close($curlReq);
  363. // Return
  364. return $result;
  365. }
  366. //Curl Delete Function
  367. function curl_delete($url, $headers = array()) {
  368. // Initiate cURL
  369. $curlReq = curl_init($url);
  370. // As post request
  371. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE");
  372. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  373. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  374. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  375. if(localURL($url)){
  376. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  377. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  378. }
  379. // Format Headers
  380. $cHeaders = array();
  381. foreach ($headers as $k => $v) {
  382. $cHeaders[] = $k.': '.$v;
  383. }
  384. if (count($cHeaders)) {
  385. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  386. }
  387. // Execute
  388. $result = curl_exec($curlReq);
  389. $httpcode = curl_getinfo($curlReq);
  390. // Close
  391. curl_close($curlReq);
  392. // Return
  393. return array('content'=>$result, 'http_code'=>$httpcode);
  394. }
  395. endif;
  396. //Case-Insensitive Function
  397. function in_arrayi($needle, $haystack) {
  398. return in_array(strtolower($needle), array_map('strtolower', $haystack));
  399. }
  400. // HTTP post request (Removes need for curl, probably useless)
  401. function post_request($url, $data, $headers = array(), $referer='') {
  402. // Adapted from http://stackoverflow.com/a/28387011/6810513
  403. // Convert the data array into URL Parameters like a=b&foo=bar etc.
  404. if (isset($headers['Content-Type'])) {
  405. switch ($headers['Content-Type']) {
  406. case 'application/json':
  407. $data = json_encode($data);
  408. break;
  409. case 'application/x-www-form-urlencoded':
  410. $data = http_build_query($data);
  411. break;
  412. }
  413. } else {
  414. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  415. $data = http_build_query($data);
  416. }
  417. // parse the given URL
  418. $urlDigest = parse_url($url);
  419. // extract host and path:
  420. $host = $urlDigest['host'];
  421. $path = $urlDigest['path'];
  422. if ($urlDigest['scheme'] != 'http') {
  423. die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')');
  424. }
  425. // open a socket connection on port 80 - timeout: 30 sec
  426. $fp = fsockopen($host, (isset($urlDigest['port'])?':'.$urlDigest['port']:80), $errno, $errstr, 30);
  427. if ($fp){
  428. // send the request headers:
  429. fputs($fp, "POST $path HTTP/1.1\r\n");
  430. fputs($fp, "Host: $host\r\n");
  431. if ($referer != '')
  432. fputs($fp, "Referer: $referer\r\n");
  433. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  434. foreach($headers as $k => $v) {
  435. fputs($fp, $k.": ".$v."\r\n");
  436. }
  437. fputs($fp, "Connection: close\r\n\r\n");
  438. fputs($fp, $data);
  439. $result = '';
  440. while(!feof($fp)) {
  441. // receive the results of the request
  442. $result .= fgets($fp, 128);
  443. }
  444. }
  445. else {
  446. return array(
  447. 'status' => 'err',
  448. 'error' => "$errstr ($errno)"
  449. );
  450. }
  451. // close the socket connection:
  452. fclose($fp);
  453. // split the result header from the content
  454. $result = explode("\r\n\r\n", $result, 2);
  455. $header = isset($result[0]) ? $result[0] : '';
  456. $content = isset($result[1]) ? $result[1] : '';
  457. // return as structured array:
  458. return array(
  459. 'status' => 'ok',
  460. 'header' => $header,
  461. 'content' => $content,
  462. );
  463. }
  464. // Format item from Emby for Carousel
  465. function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $moreInfo = false) {
  466. // Static Height
  467. $height = 444;
  468. // Get Item Details
  469. $itemDetails = json_decode(file_get_contents($address.'/Items?Ids='.$item['Id'].'&api_key='.$token),true)['Items'][0];
  470. /*if (substr_count(EMBYURL, ':') == 2) {
  471. $URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  472. }else{
  473. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  474. }*/
  475. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  476. switch ($itemDetails['Type']) {
  477. case 'Episode':
  478. $title = (isset($itemDetails['SeriesName'])?$itemDetails['SeriesName']:"");
  479. $imageId = (isset($itemDetails['SeriesId'])?$itemDetails['SeriesId']:$itemDetails['Id']);
  480. $width = 300;
  481. $style = '';
  482. $image = 'slick-image-tall';
  483. if(!$nowPlaying){
  484. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  485. $key = $itemDetails['Id'] . "-list";
  486. }else{
  487. $height = 281;
  488. $width = 500;
  489. $imageId = isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId'] : (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  490. $imageType = isset($itemDetails['ParentThumbItemId']) ? "Thumb" : (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  491. $key = (isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId']."-np" : "none-np");
  492. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  493. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  494. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  495. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  496. $stream = $moreInfo['PlayState']['PlayMethod'];
  497. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  498. $id = $moreInfo['DeviceId'];
  499. $streamInfo = buildStream(array(
  500. 'platform' => (string) $moreInfo['Client'],
  501. 'device' => (string) $moreInfo['DeviceName'],
  502. 'stream' => streamType($stream),
  503. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  504. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  505. ));
  506. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  507. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$itemDetails['Name'].'</h5>';
  508. $bottomTitle = '<small class="zero-m">S'.$itemDetails['ParentIndexNumber'].' · E'.$itemDetails['IndexNumber'].'</small>';
  509. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  510. }
  511. break;
  512. case 'MusicAlbum':
  513. case 'Audio':
  514. $title = $itemDetails['Name'];
  515. $imageId = $itemDetails['Id'];
  516. $width = 444;
  517. $style = '';
  518. $image = 'slick-image-short';
  519. if(!$nowPlaying){
  520. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  521. $key = $itemDetails['Id'] . "-list";
  522. }else{
  523. $height = 281;
  524. $width = 500;
  525. $imageId = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  526. $imageType = (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  527. $key = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : "no-np") . "-np";
  528. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  529. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  530. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  531. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  532. $stream = $moreInfo['PlayState']['PlayMethod'];
  533. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  534. $id = $moreInfo['DeviceId'];
  535. $streamInfo = buildStream(array(
  536. 'platform' => (string) $moreInfo['Client'],
  537. 'device' => (string) $moreInfo['DeviceName'],
  538. 'stream' => streamType($stream),
  539. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  540. ));
  541. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  542. $topTitle = '<h5 class="text-center zero-m elip">'.$itemDetails['AlbumArtist'].' - '.$itemDetails['Album'].'</h5>';
  543. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  544. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  545. }
  546. break;
  547. case 'TvChannel':
  548. $title = $itemDetails['CurrentProgram']['Name'];
  549. $imageId = $itemDetails['Id'];
  550. $width = 300;
  551. $style = '';
  552. $image = 'slick-image-tall';
  553. if(!$nowPlaying){
  554. $imageType = "Primary";
  555. $key = $itemDetails['Id'] . "-list";
  556. }else{
  557. $height = 281;
  558. $width = 500;
  559. $imageType = "Thumb";
  560. $key = $itemDetails['Id'] . "-np";
  561. $useImage = "images/livetv.png";
  562. $watched = "0";
  563. $stream = $moreInfo['PlayState']['PlayMethod'];
  564. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  565. $id = $moreInfo['DeviceId'];
  566. $streamInfo = buildStream(array(
  567. 'platform' => (string) $moreInfo['Client'],
  568. 'device' => (string) $moreInfo['DeviceName'],
  569. 'stream' => streamType($stream),
  570. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  571. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  572. ));
  573. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  574. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  575. $bottomTitle = '<small class="zero-m">'.$itemDetails['Name'].' - '.$itemDetails['ChannelNumber'].'</small>';
  576. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  577. }
  578. break;
  579. default:
  580. $title = $itemDetails['Name'];
  581. $imageId = $itemDetails['Id'];
  582. $width = 300;
  583. $style = '';
  584. $image = 'slick-image-tall';
  585. if(!$nowPlaying){
  586. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  587. $key = $itemDetails['Id'] . "-list";
  588. }else{
  589. $height = 281;
  590. $width = 500;
  591. $imageType = isset($itemDetails['ImageTags']['Thumb']) ? "Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
  592. $key = $itemDetails['Id'] . "-np";
  593. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  594. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  595. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  596. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  597. $stream = $moreInfo['PlayState']['PlayMethod'];
  598. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  599. $id = $moreInfo['DeviceId'];
  600. $streamInfo = buildStream(array(
  601. 'platform' => (string) $moreInfo['Client'],
  602. 'device' => (string) $moreInfo['DeviceName'],
  603. 'stream' => streamType($stream),
  604. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  605. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  606. ));
  607. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  608. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  609. $bottomTitle = '<small class="zero-m">'.$moreInfo['NowPlayingItem']['ProductionYear'].'</small>';
  610. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  611. }
  612. }
  613. // If No Overview
  614. if (!isset($itemDetails['Overview'])) {
  615. $itemDetails['Overview'] = '';
  616. }
  617. $original_image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  618. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  619. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  620. $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'';
  621. }
  622. if($nowPlaying){
  623. if(!$imageType){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  624. if(!$imageId){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  625. }else{
  626. if(!$imageType){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  627. if(!$imageId){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  628. }
  629. if(isset($useImage)){ $image_url = $useImage; }
  630. // Assemble Item And Cache Into Array
  631. if($nowPlaying){
  632. //prettyPrint($itemDetails);
  633. 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>';
  634. }else{
  635. 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>';
  636. }
  637. }
  638. // Format item from Plex for Carousel
  639. function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $playlist = false) {
  640. // Static Height
  641. $height = 444;
  642. $widthOverride = 100;
  643. $playlist = ($playlist) ? " playlist-$playlist" : "";
  644. switch ($item['type']) {
  645. case 'season':
  646. $title = $item['parentTitle'];
  647. $summary = $item['parentSummary'];
  648. $width = 300;
  649. $image = 'slick-image-tall';
  650. $style = '';
  651. if(!$nowPlaying){
  652. $thumb = $item['thumb'];
  653. $key = $item['ratingKey'] . "-list";
  654. }else {
  655. $height = 281;
  656. $width = 500;
  657. $thumb = $item['art'];
  658. $key = $item['ratingKey'] . "-np";
  659. $elapsed = $item['viewOffset'];
  660. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  661. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  662. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  663. $stream = $item->Media->Part->Stream['decision'];
  664. $user = $role == "admin" ? $item->User['title'] : "";
  665. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  666. $streamInfo = buildStream(array(
  667. 'platform' => (string) $item->Player['platform'],
  668. 'device' => (string) $item->Player['device'],
  669. 'stream' => streamType($item->Media->Part['decision']),
  670. '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'].")",
  671. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  672. ));
  673. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  674. }
  675. break;
  676. case 'episode':
  677. $title = $item['grandparentTitle'];
  678. $summary = $item['title'];
  679. $width = 300;
  680. $image = 'slick-image-tall';
  681. $style = '';
  682. if(!$nowPlaying){
  683. $thumb = ($item['parentThumb'] ? $item['parentThumb'] : $item['grandparentThumb']);
  684. $key = $item['ratingKey'] . "-list";
  685. }else {
  686. $height = 281;
  687. $width = 500;
  688. $thumb = $item['art'];
  689. $key = $item['ratingKey'] . "-np";
  690. $elapsed = $item['viewOffset'];
  691. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  692. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  693. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  694. $stream = $item->Media->Part->Stream['decision'];
  695. $user = $role == "admin" ? $item->User['title'] : "";
  696. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  697. $streamInfo = buildStream(array(
  698. 'platform' => (string) $item->Player['platform'],
  699. 'device' => (string) $item->Player['device'],
  700. 'stream' => streamType($item->Media->Part['decision']),
  701. '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'].")",
  702. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  703. ));
  704. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  705. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$item['title'].'</h5>';
  706. $bottomTitle = '<small class="zero-m">S'.$item['parentIndex'].' · E'.$item['index'].'</small>';
  707. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  708. }
  709. break;
  710. case 'clip':
  711. $title = $item['title'];
  712. $summary = $item['summary'];
  713. $width = 300;
  714. $image = 'slick-image-tall';
  715. $style = '';
  716. if(!$nowPlaying){
  717. $thumb = $item['thumb'];
  718. $key = $item['ratingKey'] . "-list";
  719. }else {
  720. $height = 281;
  721. $width = 500;
  722. $thumb = $item['art'];
  723. $key = isset($item['ratingKey']) ? $item['ratingKey'] . "-np" : (isset($item['live']) ? "livetv.png" : ":)");
  724. $useImage = (isset($item['live']) ? "images/livetv.png" : null);
  725. $extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
  726. $elapsed = $item['viewOffset'];
  727. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  728. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  729. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  730. $stream = $item->Media->Part->Stream['decision'];
  731. $user = $role == "admin" ? $item->User['title'] : "";
  732. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  733. $streamInfo = buildStream(array(
  734. 'platform' => (string) $item->Player['platform'],
  735. 'device' => (string) $item->Player['device'],
  736. 'stream' => streamType($item->Media->Part['decision']),
  737. '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'].")",
  738. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  739. ));
  740. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  741. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  742. $bottomTitle = '<small class="zero-m">'.$extraInfo.'</small>';
  743. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  744. }
  745. break;
  746. case 'album':
  747. case 'track':
  748. $title = $item['parentTitle'];
  749. $summary = $item['title'];
  750. $image = 'slick-image-short';
  751. $style = 'left: 160px !important;';
  752. $item['ratingKey'] = $item['parentRatingKey'];
  753. if(!$nowPlaying){
  754. $width = 444;
  755. $thumb = $item['thumb'];
  756. $key = $item['ratingKey'] . "-list";
  757. }else {
  758. $height = 281;
  759. $width = 500;
  760. $thumb = ($item['art']) ? $item['art'] : $item['parentThumb'];
  761. $widthOverride = ($item['art']) ? 100 : 56;
  762. $key = $item['ratingKey'] . "-np";
  763. $elapsed = $item['viewOffset'];
  764. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  765. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  766. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  767. $stream = $item->Media->Part->Stream['decision'];
  768. $user = $role == "admin" ? $item->User['title'] : "";
  769. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  770. $streamInfo = buildStream(array(
  771. 'platform' => (string) $item->Player['platform'],
  772. 'device' => (string) $item->Player['device'],
  773. 'stream' => streamType($item->Media->Part['decision']),
  774. 'audio' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['channels']."ch)",
  775. ));
  776. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  777. $topTitle = '<h5 class="text-center zero-m elip">'.$item['grandparentTitle'].' - '.$item['title'].'</h5>';
  778. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  779. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  780. }
  781. break;
  782. default:
  783. $title = $item['title'];
  784. $summary = $item['summary'];
  785. $image = 'slick-image-tall';
  786. $style = '';
  787. if(!$nowPlaying){
  788. $width = 300;
  789. $thumb = $item['thumb'];
  790. $key = $item['ratingKey'] . "-list";
  791. }else {
  792. $height = 281;
  793. $width = 500;
  794. $thumb = $item['art'];
  795. $key = $item['ratingKey'] . "-np";
  796. $elapsed = $item['viewOffset'];
  797. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  798. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  799. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  800. $stream = $item->Media->Part->Stream['decision'];
  801. $user = $role == "admin" ? $item->User['title'] : "";
  802. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  803. $streamInfo = buildStream(array(
  804. 'platform' => (string) $item->Player['platform'],
  805. 'device' => (string) $item->Player['device'],
  806. 'stream' => streamType($item->Media->Part['decision']),
  807. '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'].")",
  808. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  809. ));
  810. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  811. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  812. $bottomTitle = '<small class="zero-m">'.$item['year'].'</small>';
  813. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  814. }
  815. }
  816. if (PLEXTABURL) {
  817. $address = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  818. }else{
  819. $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  820. }
  821. // If No Overview
  822. if (!isset($itemDetails['Overview'])) { $itemDetails['Overview'] = ''; }
  823. $original_image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  824. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  825. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  826. $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'';
  827. }
  828. if($nowPlaying){
  829. if(!$thumb){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  830. }else{
  831. if(!$thumb){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  832. }
  833. if(isset($useImage)){ $image_url = $useImage; }
  834. $openTab = (PLEXTABNAME) ? "true" : "false";
  835. // Assemble Item And Cache Into Array
  836. if($nowPlaying){
  837. 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>';
  838. }else{
  839. 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>';
  840. }
  841. }
  842. //$hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  843. //Recent Added
  844. function outputRecentAdded($header, $items, $script = false, $array) {
  845. $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">';
  846. if(preg_grep("/item-movie/", $items)){
  847. $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>';
  848. }
  849. if(preg_grep("/item-season/", $items)){
  850. $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>';
  851. }
  852. if(preg_grep("/item-album/", $items)){
  853. $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>';
  854. }
  855. $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>';
  856. $hideMenu .= '</ul></div></div>';
  857. // If None Populate Empty Item
  858. if (!count($items)) {
  859. 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>';
  860. }else{
  861. $className = str_replace(' ', '', $header);
  862. 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>':'');
  863. }
  864. }
  865. // Create Carousel
  866. function outputNowPlaying($header, $size, $type, $items, $script = false) {
  867. // If None Populate Empty Item
  868. if (!count($items)) {
  869. return '<div id=streamz></div>'.($script?'<script>'.$script.'</script>':'');
  870. }else{
  871. return '<div id=streamz><h5 class="zero-m big-box"><strong>'.$header.'</strong></h5>'.implode('',$items).'</div>'.($script?'<script>'.$script.'</script>':'');
  872. }
  873. }
  874. // Get Now Playing Streams From Emby
  875. function getEmbyStreams($size, $showNames, $role) {
  876. $address = qualifyURL(EMBYURL);
  877. $api = json_decode(@file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
  878. if (!is_array($api)) { return 'Could not load!'; }
  879. $playingItems = array();
  880. foreach($api as $key => $value) {
  881. if (isset($value['NowPlayingItem'])) {
  882. $playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem'], true, $showNames, $role, $value);
  883. }
  884. }
  885. return outputNowPlaying(translate('PLAYING_NOW_ON_EMBY'), $size, 'streams-emby', $playingItems, "
  886. setInterval(function() {
  887. $('<div></div>').load('ajax.php?a=emby-streams',function() {
  888. var element = $(this).find('[id]');
  889. var loadedID = element.attr('id');
  890. $('#'+loadedID).replaceWith(element);
  891. console.log('Loaded updated: '+loadedID);
  892. });
  893. }, ".NOWPLAYINGREFRESH.");
  894. ");
  895. }
  896. // Get Now Playing Streams From Plex
  897. function getPlexStreams($size, $showNames, $role){
  898. $address = qualifyURL(PLEXURL);
  899. // Perform API requests
  900. $api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
  901. libxml_use_internal_errors(true);
  902. $api = simplexml_load_string($api);
  903. if (is_array($api) || is_object($api)){
  904. if (!$api->head->title){
  905. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  906. if (!$getServer) { return 'Could not load!'; }
  907. // Identify the local machine
  908. $gotServer = $getServer['machineIdentifier'];
  909. $items = array();
  910. foreach($api AS $child) {
  911. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
  912. }
  913. return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." ( ".count($items)." Streams )", $size, 'streams-plex', $items, "
  914. setInterval(function() {
  915. $('<div></div>').load('ajax.php?a=plex-streams',function() {
  916. var element = $(this).find('[id]');
  917. var loadedID = element.attr('id');
  918. $('#'+loadedID).replaceWith(element);
  919. console.log('Loaded updated: '+loadedID);
  920. });
  921. }, ".NOWPLAYINGREFRESH.");
  922. ");
  923. }else{
  924. writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
  925. }
  926. }else{
  927. writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
  928. }
  929. }
  930. // Get Recent Content From Emby
  931. function getEmbyRecent($array) {
  932. $address = qualifyURL(EMBYURL);
  933. $header = translate('RECENT_CONTENT');
  934. // Currently Logged In User
  935. $username = false;
  936. if (isset($GLOBALS['USER'])) {
  937. $username = strtolower($GLOBALS['USER']->username);
  938. }
  939. // Get A User
  940. $userIds = json_decode(@file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
  941. if (!is_array($userIds)) { return 'Could not load!'; }
  942. $showPlayed = true;
  943. foreach ($userIds as $value) { // Scan for admin user
  944. if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
  945. $userId = $value['Id'];
  946. }
  947. if ($username && strtolower($value['Name']) == $username) {
  948. $userId = $value['Id'];
  949. $showPlayed = false;
  950. break;
  951. }
  952. }
  953. // Get the latest Items
  954. $latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?EnableImages=false&Limit='.EMBYRECENTITEMS.'&api_key='.EMBYTOKEN.($showPlayed?'':'&IsPlayed=false')),true);
  955. // For Each Item In Category
  956. $items = array();
  957. foreach ($latest as $k => $v) {
  958. $type = (string) $v['Type'];
  959. if(@$array[$type] == "true"){
  960. $items[] = resolveEmbyItem($address, EMBYTOKEN, $v, false, false, false);
  961. }
  962. }
  963. $array["movie"] = $array["Movie"];
  964. $array["season"] = $array["Episode"];
  965. $array["album"] = $array["MusicAlbum"];
  966. unset($array["Movie"]);
  967. unset($array["Episode"]);
  968. unset($array["MusicAlbum"]);
  969. unset($array["Series"]);
  970. return outputRecentAdded($header, $items, "
  971. setInterval(function() {
  972. $('<div></div>').load('ajax.php?a=emby-recent',function() {
  973. var element = $(this).find('#recentMedia');
  974. var loadedID = element.attr('id');
  975. $('#recentMedia').replaceWith(element);
  976. console.log('Loaded recent: '+loadedID);
  977. loadSlick();
  978. });
  979. }, ".RECENTREFRESH.");
  980. ", $array);
  981. }
  982. // Get Recent Content From Plex
  983. function getPlexRecent($array){
  984. $address = qualifyURL(PLEXURL);
  985. $header = translate('RECENT_CONTENT');
  986. // Perform Requests
  987. $api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN);
  988. libxml_use_internal_errors(true);
  989. $api = simplexml_load_string($api);
  990. if (is_array($api) || is_object($api)){
  991. if (!$api->head->title){
  992. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  993. if (!$getServer) { return 'Could not load!'; }
  994. // Identify the local machine
  995. $gotServer = $getServer['machineIdentifier'];
  996. $items = array();
  997. foreach($api AS $child) {
  998. $type = (string) $child['type'];
  999. if($array[$type] == "true"){
  1000. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
  1001. }
  1002. }
  1003. return outputRecentAdded($header, $items, "
  1004. setInterval(function() {
  1005. $('<div></div>').load('ajax.php?a=plex-recent',function() {
  1006. var element = $(this).find('#recentMedia');
  1007. var loadedID = element.attr('id');
  1008. $('#recentMedia').replaceWith(element);
  1009. console.log('Loaded recent: '+loadedID);
  1010. loadSlick();
  1011. });
  1012. }, ".RECENTREFRESH.");
  1013. ", $array);
  1014. }else{
  1015. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check token - if HTTPS, is cert valid");
  1016. }
  1017. }else{
  1018. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check URL - if HTTPS, is cert valid");
  1019. }
  1020. }
  1021. // Get Image From Emby
  1022. function getEmbyImage() {
  1023. $refresh = false;
  1024. $embyAddress = qualifyURL(EMBYURL);
  1025. if (!file_exists('images/cache')) {
  1026. mkdir('images/cache', 0777, true);
  1027. }
  1028. $itemId = $_GET['img'];
  1029. $key = $_GET['key'];
  1030. if(strpos($key, '$') !== false){
  1031. $key = explode('$', $key)[0];
  1032. $refresh = true;
  1033. }
  1034. $itemType = $_GET['type'];
  1035. $imgParams = array();
  1036. if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
  1037. if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
  1038. if(isset($itemId)) {
  1039. $image_src = $embyAddress . '/Items/'.$itemId.'/Images/'.$itemType.'?'.implode('&', $imgParams);
  1040. $cachefile = 'images/cache/'.$key.'.jpg';
  1041. $cachetime = 604800;
  1042. // Serve from the cache if it is younger than $cachetime
  1043. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh !== true) {
  1044. header("Content-type: image/jpeg");
  1045. @readfile($cachefile);
  1046. exit;
  1047. }
  1048. ob_start(); // Start the output buffer
  1049. header('Content-type: image/jpeg');
  1050. @readfile($image_src);
  1051. // Cache the output to a file
  1052. $fp = fopen($cachefile, 'wb');
  1053. fwrite($fp, ob_get_contents());
  1054. fclose($fp);
  1055. ob_end_flush(); // Send the output to the browser
  1056. die();
  1057. } else {
  1058. debug_out('Invalid Request',1);
  1059. }
  1060. }
  1061. // Get Image From Plex
  1062. function getPlexImage() {
  1063. $refresh = false;
  1064. $plexAddress = qualifyURL(PLEXURL);
  1065. if (!file_exists('images/cache')) {
  1066. mkdir('images/cache', 0777, true);
  1067. }
  1068. $image_url = $_GET['img'];
  1069. $key = $_GET['key'];
  1070. if(strpos($key, '$') !== false){
  1071. $key = explode('$', $key)[0];
  1072. $refresh = true;
  1073. }
  1074. $image_height = $_GET['height'];
  1075. $image_width = $_GET['width'];
  1076. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  1077. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  1078. $cachefile = 'images/cache/'.$key.'.jpg';
  1079. $cachetime = 604800;
  1080. // Serve from the cache if it is younger than $cachetime
  1081. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh == false) {
  1082. header("Content-type: image/jpeg");
  1083. @readfile($cachefile);
  1084. exit;
  1085. }
  1086. ob_start(); // Start the output buffer
  1087. header('Content-type: image/jpeg');
  1088. @readfile($image_src);
  1089. // Cache the output to a file
  1090. $fp = fopen($cachefile, 'wb');
  1091. fwrite($fp, ob_get_contents());
  1092. fclose($fp);
  1093. ob_end_flush(); // Send the output to the browser
  1094. die();
  1095. } else {
  1096. echo "Invalid Plex Request";
  1097. }
  1098. }
  1099. // Simplier access to class
  1100. function translate($string) {
  1101. if (isset($GLOBALS['language'])) {
  1102. return $GLOBALS['language']->translate($string);
  1103. } else {
  1104. return '!Translations Not Loaded!';
  1105. }
  1106. }
  1107. // Generate Random string
  1108. function randString($length = 10, $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  1109. $tmp = '';
  1110. for ($i = 0; $i < $length; $i++) {
  1111. $tmp .= substr(str_shuffle($chars), 0, 1);
  1112. }
  1113. return $tmp;
  1114. }
  1115. // Create config file in the return syntax
  1116. function createConfig($array, $path = 'config/config.php', $nest = 0) {
  1117. // Define Initial Value
  1118. $output = array();
  1119. // Sort Items
  1120. ksort($array);
  1121. // Update the current config version
  1122. if (!$nest) {
  1123. // Inject Current Version
  1124. $output[] = "\t'CONFIG_VERSION' => '".(isset($array['apply_CONFIG_VERSION'])?$array['apply_CONFIG_VERSION']:INSTALLEDVERSION)."'";
  1125. }
  1126. unset($array['CONFIG_VERSION']);
  1127. unset($array['apply_CONFIG_VERSION']);
  1128. // Process Settings
  1129. foreach ($array as $k => $v) {
  1130. $allowCommit = true;
  1131. switch (gettype($v)) {
  1132. case 'boolean':
  1133. $item = ($v?'true':'false');
  1134. break;
  1135. case 'integer':
  1136. case 'double':
  1137. case 'integer':
  1138. case 'NULL':
  1139. $item = $v;
  1140. break;
  1141. case 'string':
  1142. $item = "'".str_replace(array('\\',"'"),array('\\\\',"\'"),$v)."'";
  1143. break;
  1144. case 'array':
  1145. $item = createConfig($v, false, $nest+1);
  1146. break;
  1147. default:
  1148. $allowCommit = false;
  1149. }
  1150. if($allowCommit) {
  1151. $output[] = str_repeat("\t",$nest+1)."'$k' => $item";
  1152. }
  1153. }
  1154. // Build output
  1155. $output = (!$nest?"<?php\nreturn ":'')."array(\n".implode(",\n",$output)."\n".str_repeat("\t",$nest).')'.(!$nest?';':'');
  1156. if (!$nest && $path) {
  1157. $pathDigest = pathinfo($path);
  1158. @mkdir($pathDigest['dirname'], 0770, true);
  1159. if (file_exists($path)) {
  1160. rename($path, $pathDigest['dirname'].'/'.$pathDigest['filename'].'.bak.php');
  1161. }
  1162. $file = fopen($path, 'w');
  1163. fwrite($file, $output);
  1164. fclose($file);
  1165. if (file_exists($path)) {
  1166. return true;
  1167. }
  1168. writeLog("error", "config was unable to write");
  1169. return false;
  1170. } else {
  1171. writeLog("success", "config was updated with new values");
  1172. return $output;
  1173. }
  1174. }
  1175. // Load a config file written in the return syntax
  1176. function loadConfig($path = 'config/config.php') {
  1177. // Adapted from http://stackoverflow.com/a/14173339/6810513
  1178. if (!is_file($path)) {
  1179. return null;
  1180. } else {
  1181. return (array) call_user_func(function() use($path) {
  1182. return include($path);
  1183. });
  1184. }
  1185. }
  1186. // Commit new values to the configuration
  1187. function updateConfig($new, $current = false) {
  1188. // Get config if not supplied
  1189. if ($current === false) {
  1190. $current = loadConfig();
  1191. } else if (is_string($current) && is_file($current)) {
  1192. $current = loadConfig($current);
  1193. }
  1194. // Inject Parts
  1195. foreach ($new as $k => $v) {
  1196. $current[$k] = $v;
  1197. }
  1198. // Return Create
  1199. return createConfig($current);
  1200. }
  1201. // Inject Defaults As Needed
  1202. function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
  1203. if (is_string($path)) {
  1204. $loadedDefaults = loadConfig($path);
  1205. } else {
  1206. $loadedDefaults = $path;
  1207. }
  1208. return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
  1209. }
  1210. // support function for fillDefaultConfig()
  1211. function fillDefaultConfig_recurse($current, $defaults) {
  1212. foreach($defaults as $k => $v) {
  1213. if (!isset($current[$k])) {
  1214. $current[$k] = $v;
  1215. } else if (is_array($current[$k]) && is_array($v)) {
  1216. $current[$k] = fillDefaultConfig_recurse($current[$k], $v);
  1217. }
  1218. }
  1219. return $current;
  1220. };
  1221. // Define Scalar Variables (nest non-secular with underscores)
  1222. function defineConfig($array, $anyCase = true, $nest_prefix = false) {
  1223. foreach($array as $k => $v) {
  1224. if (is_scalar($v) && !defined($nest_prefix.$k)) {
  1225. define($nest_prefix.$k, $v, $anyCase);
  1226. } else if (is_array($v)) {
  1227. defineConfig($v, $anyCase, $nest_prefix.$k.'_');
  1228. }
  1229. }
  1230. }
  1231. // This function exists only because I am lazy
  1232. function configLazy($path = 'config/config.php') {
  1233. // Load config or default
  1234. if (file_exists($path)) {
  1235. $config = fillDefaultConfig(loadConfig($path));
  1236. } else {
  1237. $config = loadConfig('config/configDefaults.php');
  1238. }
  1239. if (is_array($config)) {
  1240. defineConfig($config);
  1241. }
  1242. return $config;
  1243. }
  1244. // Qualify URL
  1245. function qualifyURL($url) {
  1246. //local address?
  1247. if(substr($url, 0,1) == "/"){
  1248. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  1249. $protocol = "https://";
  1250. } else {
  1251. $protocol = "http://";
  1252. }
  1253. $url = $protocol.getServer().$url;
  1254. }
  1255. // Get Digest
  1256. $digest = parse_url($url);
  1257. // http/https
  1258. if (!isset($digest['scheme'])) {
  1259. if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096,32400,7878,8989,8182,8081,6789))) {
  1260. $scheme = 'http';
  1261. } else {
  1262. $scheme = 'https';
  1263. }
  1264. } else {
  1265. $scheme = $digest['scheme'];
  1266. }
  1267. // Host
  1268. $host = (isset($digest['host'])?$digest['host']:'');
  1269. // Port
  1270. $port = (isset($digest['port'])?':'.$digest['port']:'');
  1271. // Path
  1272. $path = (isset($digest['path'])?$digest['path']:'');
  1273. // Output
  1274. return $scheme.'://'.$host.$port.$path;
  1275. }
  1276. // Function to be called at top of each to allow upgrading environment as the spec changes
  1277. function upgradeCheck() {
  1278. // Upgrade to 1.31
  1279. if (file_exists('homepageSettings.ini.php')) {
  1280. $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
  1281. $homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
  1282. $databaseConfig = array_merge($databaseConfig, $homepageConfig);
  1283. $databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
  1284. foreach($databaseConfig as $k => $v) {
  1285. if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
  1286. $databaseData .= $k . " = \"" . $v . "\"\r\n";
  1287. }
  1288. write_ini_file($databaseData, 'databaseLocation.ini.php');
  1289. unlink('homepageSettings.ini.php');
  1290. unset($databaseData);
  1291. unset($homepageConfig);
  1292. }
  1293. // Upgrade to 1.32
  1294. if (file_exists('databaseLocation.ini.php')) {
  1295. // Load Existing
  1296. $config = parse_ini_file('databaseLocation.ini.php', true);
  1297. // Refactor
  1298. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['databaseLocation'].'/');
  1299. $config['user_home'] = $config['database_Location'].'users/';
  1300. unset($config['databaseLocation']);
  1301. // Turn Off Emby And Plex Recent
  1302. $config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
  1303. unset($config["embyPort"]);
  1304. $config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
  1305. unset($config["plexPort"]);
  1306. $config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
  1307. unset($config["nzbgetPort"]);
  1308. $config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
  1309. unset($config["sabnzbdPort"]);
  1310. $config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
  1311. unset($config["headphonesPort"]);
  1312. // Write config file
  1313. $config['CONFIG_VERSION'] = '1.32';
  1314. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][pre1.32].bak.php');
  1315. $createConfigSuccess = createConfig($config);
  1316. // Create new config
  1317. if ($createConfigSuccess) {
  1318. if (file_exists('config/config.php')) {
  1319. // Remove Old ini file
  1320. unlink('databaseLocation.ini.php');
  1321. } else {
  1322. debug_out('Something is not right here!');
  1323. }
  1324. } else {
  1325. debug_out('Couldn\'t create updated configuration.' ,1);
  1326. }
  1327. }
  1328. // Upgrade to 1.33
  1329. $config = loadConfig();
  1330. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
  1331. // Fix User Directory
  1332. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['database_Location'].'/');
  1333. $config['user_home'] = $config['database_Location'].'users/';
  1334. unset($config['USER_HOME']);
  1335. // Backend auth merge
  1336. if (isset($config['authBackendPort']) && !isset(parse_url($config['authBackendHost'])['port'])) {
  1337. $config['authBackendHost'] .= ':'.$config['authBackendPort'];
  1338. }
  1339. unset($config['authBackendPort']);
  1340. // If auth is being used move it to embyURL as that is now used in auth functions
  1341. 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')))) {
  1342. $config['embyURL'] = $config['authBackendHost'];
  1343. }
  1344. // Upgrade database to latest version
  1345. updateSQLiteDB($config['database_Location'],'1.32');
  1346. // Update Version and Commit
  1347. $config['apply_CONFIG_VERSION'] = '1.33';
  1348. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.32].bak.php');
  1349. $createConfigSuccess = createConfig($config);
  1350. unset($config);
  1351. }
  1352. // Upgrade to 1.34
  1353. $config = loadConfig();
  1354. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.34')) {
  1355. // Upgrade database to latest version
  1356. updateSQLiteDB($config['database_Location'],'1.33');
  1357. // Update Version and Commit
  1358. $config['CONFIG_VERSION'] = '1.34';
  1359. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.33].bak.php');
  1360. $createConfigSuccess = createConfig($config);
  1361. unset($config);
  1362. }
  1363. // Upgrade to 1.40
  1364. $config = loadConfig();
  1365. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.40')) {
  1366. // Upgrade database to latest version
  1367. updateSQLiteDB($config['database_Location'],'1.38');
  1368. // Update Version and Commit
  1369. $config['CONFIG_VERSION'] = '1.40';
  1370. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.38].bak.php');
  1371. $createConfigSuccess = createConfig($config);
  1372. unset($config);
  1373. }
  1374. // Upgrade to 1.50
  1375. $config = loadConfig();
  1376. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.50')) {
  1377. // Upgrade database to latest version
  1378. updateSQLiteDB($config['database_Location'],'1.40');
  1379. // Update Version and Commit
  1380. $config['CONFIG_VERSION'] = '1.50';
  1381. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.40].bak.php');
  1382. $createConfigSuccess = createConfig($config);
  1383. unset($config);
  1384. }
  1385. return true;
  1386. }
  1387. // Get OS from server
  1388. function getOS(){
  1389. if(PHP_SHLIB_SUFFIX == "dll"){
  1390. return "win";
  1391. }else{
  1392. return "nix";
  1393. }
  1394. }
  1395. //Get Error by Server OS
  1396. function getError($os, $error){
  1397. $ini = (!empty(php_ini_loaded_file()) ? php_ini_loaded_file() : "php.ini");
  1398. $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'");
  1399. $errors = array(
  1400. 'pdo_sqlite' => array(
  1401. 'win' => '<b>PDO:SQLite</b> not enabled, uncomment ;extension=php_pdo_sqlite.dll in the file php.ini | '.$ext,
  1402. 'nix' => '<b>PDO:SQLite</b> not enabled, PHP7 -> run sudo apt-get install php7.0-sqlite | PHP5 -> run sudo apt-get install php5-sqlite',
  1403. ),
  1404. 'sqlite3' => array(
  1405. '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',
  1406. 'nix' => '<b>SQLite3</b> not enabled, run sudo apt-get install php-sqlite3',
  1407. ),
  1408. 'curl' => array(
  1409. 'win' => '<b>cURL</b> not enabled, uncomment ;extension=php_curl.dll in the file php.ini | '.$ext,
  1410. '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',
  1411. ),
  1412. 'zip' => array(
  1413. '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',
  1414. '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',
  1415. ),
  1416. );
  1417. return (isset($errors[$error][$os]) ? $errors[$error][$os] : 'No Error Info Found');
  1418. }
  1419. // Check if all software dependancies are met
  1420. function dependCheck() {
  1421. $output = array();
  1422. $i = 1;
  1423. if (!extension_loaded('pdo_sqlite')) { $output["Step $i"] = getError(getOS(),'pdo_sqlite'); $i++; }
  1424. if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; }
  1425. if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; }
  1426. //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
  1427. if ($output) {
  1428. $output["Step $i"] = "<b>Restart PHP and/or Webserver to apply changes</b>"; $i++;
  1429. $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++;
  1430. debug_out($output,1);
  1431. }
  1432. return true;
  1433. }
  1434. // Process file uploads
  1435. function uploadFiles($path, $ext_mask = null) {
  1436. if (isset($_FILES) && count($_FILES)) {
  1437. require_once('class.uploader.php');
  1438. $uploader = new Uploader();
  1439. $data = $uploader->upload($_FILES['files'], array(
  1440. 'limit' => 10,
  1441. 'maxSize' => 10,
  1442. 'extensions' => $ext_mask,
  1443. 'required' => false,
  1444. 'uploadDir' => str_replace('//','/',$path.'/'),
  1445. 'title' => array('name'),
  1446. 'removeFiles' => true,
  1447. 'replace' => true,
  1448. ));
  1449. if($data['isComplete']){
  1450. $files = $data['data'];
  1451. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1452. echo json_encode($files['metas'][0]['name']);
  1453. }
  1454. if($data['hasErrors']){
  1455. $errors = $data['errors'];
  1456. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1457. echo json_encode($errors);
  1458. }
  1459. } else {
  1460. writeLog("error", "image was not uploaded");
  1461. echo json_encode('No files submitted!');
  1462. }
  1463. }
  1464. // Process file uploads
  1465. function uploadAvatar($path, $ext_mask = null) {
  1466. if (isset($_FILES) && count($_FILES)) {
  1467. require_once('class.uploader.php');
  1468. $uploader = new Uploader();
  1469. $data = $uploader->upload($_FILES['files'], array(
  1470. 'limit' => 10,
  1471. 'maxSize' => 10,
  1472. 'extensions' => $ext_mask,
  1473. 'required' => false,
  1474. 'uploadDir' => str_replace('//','/',$path.'/'),
  1475. 'title' => array('name'),
  1476. 'removeFiles' => true,
  1477. 'replace' => true,
  1478. ));
  1479. if($data['isComplete']){
  1480. $files = $data['data'];
  1481. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1482. echo json_encode($files['metas'][0]['name']);
  1483. }
  1484. if($data['hasErrors']){
  1485. $errors = $data['errors'];
  1486. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1487. echo json_encode($errors);
  1488. }
  1489. } else {
  1490. writeLog("error", "image was not uploaded");
  1491. echo json_encode('No files submitted!');
  1492. }
  1493. }
  1494. // Remove file
  1495. function removeFiles($path) {
  1496. if(is_file($path)) {
  1497. writeLog("success", "file was removed");
  1498. unlink($path);
  1499. } else {
  1500. writeLog("error", "file was not removed");
  1501. echo json_encode('No file specified for removal!');
  1502. }
  1503. }
  1504. // Lazy select options
  1505. function resolveSelectOptions($array, $selected = '', $multi = false) {
  1506. $output = array();
  1507. $selectedArr = ($multi?explode('|', $selected):array());
  1508. foreach ($array as $key => $value) {
  1509. if (is_array($value)) {
  1510. if (isset($value['optgroup'])) {
  1511. $output[] = '<optgroup label="'.$key.'">';
  1512. foreach($value['optgroup'] as $k => $v) {
  1513. $output[] = '<option value="'.$v['value'].'"'.($selected===$v['value']||in_array($v['value'],$selectedArr)?' selected':'').(isset($v['disabled']) && $v['disabled']?' disabled':'').'>'.$k.'</option>';
  1514. }
  1515. } else {
  1516. $output[] = '<option value="'.$value['value'].'"'.($selected===$value['value']||in_array($value['value'],$selectedArr)?' selected':'').(isset($value['disabled']) && $value['disabled']?' disabled':'').'>'.$key.'</option>';
  1517. }
  1518. } else {
  1519. $output[] = '<option value="'.$value.'"'.($selected===$value||in_array($value,$selectedArr)?' selected':'').'>'.$key.'</option>';
  1520. }
  1521. }
  1522. return implode('',$output);
  1523. }
  1524. // Check if user is allowed to continue
  1525. function qualifyUser($type, $errOnFail = false) {
  1526. if (!isset($GLOBALS['USER'])) {
  1527. require_once("user.php");
  1528. $GLOBALS['USER'] = new User('registration_callback');
  1529. }
  1530. if (is_bool($type)) {
  1531. if ($type === true) {
  1532. $authorized = ($GLOBALS['USER']->authenticated == true);
  1533. } else {
  1534. $authorized = true;
  1535. }
  1536. } elseif (is_string($type) || is_array($type)) {
  1537. if ($type !== 'false') {
  1538. if (!is_array($type)) {
  1539. $type = explode('|',$type);
  1540. }
  1541. $authorized = ($GLOBALS['USER']->authenticated && in_array($GLOBALS['USER']->role,$type));
  1542. } else {
  1543. $authorized = true;
  1544. }
  1545. } else {
  1546. debug_out('Invalid Syntax!',1);
  1547. }
  1548. if (!$authorized && $errOnFail) {
  1549. if ($GLOBALS['USER']->authenticated) {
  1550. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401');
  1551. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401\'</script>';
  1552. } else {
  1553. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999');
  1554. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999\'</script>';
  1555. }
  1556. debug_out('Not Authorized' ,1);
  1557. } else {
  1558. return $authorized;
  1559. }
  1560. }
  1561. // Build an (optionally) tabbed settings page.
  1562. function buildSettings($array) {
  1563. /*
  1564. array(
  1565. 'title' => '',
  1566. 'id' => '',
  1567. 'fields' => array( See buildField() ),
  1568. 'tabs' => array(
  1569. array(
  1570. 'title' => '',
  1571. 'id' => '',
  1572. 'image' => '',
  1573. 'fields' => array( See buildField() ),
  1574. ),
  1575. ),
  1576. );
  1577. */
  1578. $notifyExplode = explode("-", NOTIFYEFFECT);
  1579. $fieldFunc = function($fieldArr) {
  1580. $fields = '<div class="row">';
  1581. foreach($fieldArr as $key => $value) {
  1582. $isSingle = isset($value['type']);
  1583. if ($isSingle) { $value = array($value); }
  1584. $tmpField = '';
  1585. $sizeLg = max(floor(12/count($value)),2);
  1586. $sizeMd = max(floor(($isSingle?12:6)/count($value)),3);
  1587. foreach($value as $k => $v) {
  1588. $tmpField .= buildField($v, 12, $sizeMd, $sizeLg);
  1589. }
  1590. $fields .= ($isSingle?$tmpField:'<div class="row col-sm-12 content-form">'.$tmpField.'</div>');
  1591. }
  1592. $fields .= '</div>';
  1593. return $fields;
  1594. };
  1595. $fields = (isset($array['fields'])?$fieldFunc($array['fields']):'');
  1596. $tabSelectors = array();
  1597. $tabContent = array();
  1598. if (isset($array['tabs'])) {
  1599. foreach($array['tabs'] as $key => $value) {
  1600. $id = (isset($value['id'])?$value['id']:randString(32));
  1601. $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>';
  1602. $tabContent[$key] = '<div class="tab-pane big-box fade'.($tabContent?'':' active in').'" id="tab-'.$id.'">'.$fieldFunc($value['fields']).'</div>';
  1603. }
  1604. }
  1605. $pageID = (isset($array['id'])?$array['id']:str_replace(array(' ','"',"'"),array('_'),strtolower($array['id'])));
  1606. $extraClick = ($pageID == 'appearance_settings' ? "$('#advanced_settings_form_submit').click();console.log('add theme settings');" : "");
  1607. return '
  1608. <div class="email-body">
  1609. <div class="email-header gray-bg">
  1610. <button type="button" class="btn btn-danger btn-sm waves close-button"><i class="fa fa-close"></i></button>
  1611. <button id="'.$pageID.'_form_submit" class="btn waves btn-labeled btn-success btn btn-sm text-uppercase waves-effect waves-float save-btn-form">
  1612. <span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save
  1613. </button>
  1614. <h1>'.$array['title'].'</h1>
  1615. </div>
  1616. <div class="email-inner small-box">
  1617. <div class="email-inner-section">
  1618. <div class="small-box fade in" id="'.$pageID.'_frame">
  1619. <div class="col-lg-12">
  1620. '.(isset($array['customBeforeForm'])?$array['customBeforeForm']:'').'
  1621. <form class="content-form" name="'.$pageID.'" id="'.$pageID.'_form" onsubmit="return false;">
  1622. '.$fields.($tabContent?'
  1623. <div class="tabbable tabs-with-bg" id="'.$pageID.'_tabs">
  1624. <ul class="nav nav-tabs apps">
  1625. '.implode('', $tabSelectors).'
  1626. </ul>
  1627. <div class="clearfix"></div>
  1628. <div class="tab-content">
  1629. '.implode('', $tabContent).'
  1630. </div>
  1631. </div>':'').'
  1632. </form>
  1633. '.(isset($array['customAfterForm'])?$array['customAfterForm']:'').'
  1634. </div>
  1635. </div>
  1636. </div>
  1637. </div>
  1638. </div>
  1639. <script>
  1640. $(document).ready(function() {
  1641. $(\'#'.$pageID.'_form\').find(\'input, select, textarea\').on(\'change\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1642. var '.$pageID.'Validate = function() { if (this.value && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { $(this).addClass(\'invalid\'); } else { $(this).removeClass(\'invalid\'); } };
  1643. $(\'#'.$pageID.'_form\').find(\'input[pattern]\').each('.$pageID.'Validate).on(\'keyup\', '.$pageID.'Validate);
  1644. $(\'#'.$pageID.'_form\').find(\'select[multiple]\').on(\'change click\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1645. $(\'#'.$pageID.'_form_submit\').on(\'click\', function () {
  1646. var newVals = {};
  1647. var hasVals = false;
  1648. var errorFields = [];
  1649. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').each(function() {
  1650. hasVals = true;
  1651. if (this.type == \'checkbox\') {
  1652. newVals[this.name] = this.checked;
  1653. } else if ($(this).hasClass(\'summernote\')) {
  1654. newVals[$(this).attr(\'name\')] = $(this).siblings(\'.note-editor\').find(\'.panel-body\').html();
  1655. } else {
  1656. if (this.value && this.pattern && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { errorFields.push(this.name); }
  1657. var fieldVal = $(this).val();
  1658. if (typeof fieldVal == \'object\') {
  1659. if (typeof fieldVal.join == \'function\') {
  1660. fieldVal = fieldVal.join(\'|\');
  1661. } else {
  1662. fieldVal = JSON.stringify(fieldVal);
  1663. }
  1664. }
  1665. newVals[this.name] = fieldVal;
  1666. }
  1667. });
  1668. if (errorFields.length) {
  1669. parent.notify(\'Fields have errors: \'+errorFields.join(\', \')+\'!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1670. } else if (hasVals) {
  1671. console.log(newVals);
  1672. ajax_request(\'POST\', \''.(isset($array['submitAction'])?$array['submitAction']:'update-config').'\', newVals, function(data, code) {
  1673. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').removeAttr(\'data-changed\');
  1674. });
  1675. '.$extraClick.'
  1676. } else {
  1677. parent.notify(\'Nothing to update!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1678. }
  1679. return false;
  1680. });
  1681. '.(isset($array['onready'])?$array['onready']:'').'
  1682. });
  1683. </script>
  1684. ';
  1685. }
  1686. // Build Settings Fields
  1687. function buildField($params, $sizeSm = 12, $sizeMd = 12, $sizeLg = 12) {
  1688. /*
  1689. array(
  1690. 'type' => '',
  1691. 'placeholder' => '',
  1692. 'label' => '',
  1693. 'labelTranslate' => '',
  1694. 'assist' => '',
  1695. 'name' => '',
  1696. 'pattern' => '',
  1697. 'options' => array( // For SELECT only
  1698. 'Display' => 'value',
  1699. ),
  1700. )
  1701. */
  1702. // Tags
  1703. $tags = array();
  1704. foreach(array('placeholder','style','disabled','readonly','pattern','min','max','required','onkeypress','onchange','onfocus','onleave','href','onclick') as $value) {
  1705. if (isset($params[$value])) {
  1706. if (is_string($params[$value])) { $tags[] = $value.'="'.$params[$value].'"';
  1707. } else if ($params[$value] === true) { $tags[] = $value; }
  1708. }
  1709. }
  1710. $format = (isset($params['format']) && in_array($params['format'],array(false,'colour','color'))?$params['format']:false);
  1711. $name = (isset($params['name'])?$params['name']:(isset($params['id'])?$params['id']:''));
  1712. $id = (isset($params['id'])?$params['id']:(isset($params['name'])?$params['name'].'_id':randString(32)));
  1713. $val = (isset($params['value'])?$params['value']:'');
  1714. $class = (isset($params['class'])?' '.$params['class']:'');
  1715. $wrapClass = (isset($params['wrapClass'])?$params['wrapClass']:'form-content');
  1716. $assist = (isset($params['assist'])?' - i.e. '.$params['assist']:'');
  1717. $label = (isset($params['labelTranslate'])?translate($params['labelTranslate']):(isset($params['label'])?$params['label']:''));
  1718. $labelOut = '<p class="help-text">'.$label.$assist.'</p>';
  1719. // Field Design
  1720. switch ($params['type']) {
  1721. case 'text':
  1722. case 'number':
  1723. case 'password':
  1724. $field = '<input id="'.$id.'" name="'.$name.'" type="'.$params['type'].'" class="form-control material input-sm'.$class.'" '.implode(' ',$tags).' autocorrect="off" autocapitalize="off" value="'.$val.'">';
  1725. break;
  1726. case 'select':
  1727. case 'dropdown':
  1728. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control material input-sm" '.implode(' ',$tags).'>'.resolveSelectOptions($params['options'], $val).'</select>';
  1729. break;
  1730. case 'select-multi':
  1731. case 'dropdown-multi':
  1732. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control input-sm" '.implode(' ',$tags).' multiple="multiple">'.resolveSelectOptions($params['options'], $val, true).'</select>';
  1733. break;
  1734. case 'check':
  1735. case 'checkbox':
  1736. case 'toggle':
  1737. $checked = ((is_bool($val) && $val) || trim($val) === 'true'?' checked':'');
  1738. $colour = (isset($params['colour'])?$params['colour']:'success');
  1739. $labelOut = '<label for="'.$id.'"></label>'.$label;
  1740. $field = '<input id="'.$id.'" name="'.$name.'" type="checkbox" class="switcher switcher-'.$colour.' '.$class.'" '.implode(' ',$tags).' data-value="'.$val.'"'.$checked.'>';
  1741. break;
  1742. case 'radio':
  1743. $labelOut = '';
  1744. $checked = ((is_bool($val) && $val) || ($val && trim($val) !== 'false')?' checked':'');
  1745. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1746. $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>';
  1747. break;
  1748. case 'date':
  1749. $field = 'Unsupported, planned.';
  1750. break;
  1751. case 'hidden':
  1752. return '<input id="'.$id.'" name="'.$name.'" type="hidden" class="'.$class.'" '.implode(' ',$tags).' value="'.$val.'">';
  1753. break;
  1754. case 'header':
  1755. $labelOut = '';
  1756. $headType = (isset($params['value'])?$params['value']:3);
  1757. $field = '<h'.$headType.' class="'.$class.'" '.implode(' ',$tags).'>'.$label.'</h'.$headType.'>';
  1758. break;
  1759. case 'button':
  1760. $labelOut = '';
  1761. $icon = (isset($params['icon'])?$params['icon']:'flask');
  1762. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1763. $bDropdown = (isset($params['buttonDrop'])?$params['buttonDrop']:'');
  1764. $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>':'');
  1765. break;
  1766. case 'textarea':
  1767. $rows = (isset($params['rows'])?$params['rows']:5);
  1768. $field = '<textarea id="'.$id.'" name="'.$name.'" class="form-control'.$class.'" rows="'.$rows.'" '.implode(' ',$tags).'>'.$val.'</textarea>';
  1769. break;
  1770. case 'custom':
  1771. // Settings
  1772. $settings = array(
  1773. '$id' => $id,
  1774. '$name' => $name,
  1775. '$val' => $val,
  1776. '$label' => $label,
  1777. '$labelOut' => $labelOut,
  1778. );
  1779. // Get HTML
  1780. $html = (isset($params['html'])?$params['html']:'Nothing Specified!');
  1781. // If LabelOut is in html dont print it twice
  1782. $labelOut = (strpos($html,'$label')!==false?'':$labelOut);
  1783. // Replace variables in settings
  1784. $html = preg_replace_callback('/\$\w+\b/', function ($match) use ($settings) { return (isset($settings[$match[0]])?$settings[$match[0]]:'{'.$match[0].' is undefined}'); }, $html);
  1785. // Build Field
  1786. $field = '<div id="'.$id.'_html" class="custom-field">'.$html.'</div>';
  1787. break;
  1788. case 'space':
  1789. $labelOut = '';
  1790. $field = str_repeat('<br>', (isset($params['value'])?$params['value']:1));
  1791. break;
  1792. default:
  1793. $field = 'Unsupported field type';
  1794. break;
  1795. }
  1796. // Field Formats
  1797. switch ($format) {
  1798. case 'colour': // Fuckin Eh, Canada!
  1799. case 'color':
  1800. $labelBef = '<center>'.$label.'</center>';
  1801. $wrapClass = 'gray-bg colour-field';
  1802. $labelAft = '';
  1803. $field = str_replace(' material input-sm','',$field);
  1804. break;
  1805. default:
  1806. $labelBef = '';
  1807. $labelAft = $labelOut;
  1808. }
  1809. return '<div class="'.$wrapClass.' col-sm-'.$sizeSm.' col-md-'.$sizeMd.' col-lg-'.$sizeLg.'">'.$labelBef.$field.$labelAft.'</div>';
  1810. }
  1811. // Tab Settings Generation
  1812. function printTabRow($data) {
  1813. $hidden = false;
  1814. if ($data===false) {
  1815. $hidden = true;
  1816. $data = array( // New Tab Defaults
  1817. 'id' => 'new',
  1818. 'name' => '',
  1819. 'url' => '',
  1820. 'icon' => 'fa-diamond',
  1821. 'iconurl' => '',
  1822. 'active' => 'true',
  1823. 'user' => 'true',
  1824. 'guest' => 'true',
  1825. 'window' => 'false',
  1826. 'splash' => 'true',
  1827. 'ping' => 'false',
  1828. 'ping_url' => '',
  1829. 'defaultz' => '',
  1830. );
  1831. }
  1832. $image = '<span style="font: normal normal normal 30px/1 FontAwesome;" class="fa fa-hand-paper-o"></span>';
  1833. $output = '
  1834. <li id="tab-'.$data['id'].'" class="list-group-item" style="position: relative; left: 0px; top: 0px; '.($hidden?' display: none;':'').'">
  1835. <tab class="content-form form-inline">
  1836. <div class="row">
  1837. '.buildField(array(
  1838. 'type' => 'custom',
  1839. '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>',
  1840. ),12,1,1).'
  1841. '.buildField(array(
  1842. 'type' => 'hidden',
  1843. 'id' => 'tab-'.$data['id'].'-id',
  1844. 'name' => 'id['.$data['id'].']',
  1845. 'value' => $data['id'],
  1846. ),12,2,1).'
  1847. '.buildField(array(
  1848. 'type' => 'text',
  1849. 'id' => 'tab-'.$data['id'].'-name',
  1850. 'name' => 'name['.$data['id'].']',
  1851. 'required' => true,
  1852. 'placeholder' => 'Organizr Homepage',
  1853. 'labelTranslate' => 'TAB_NAME',
  1854. 'value' => $data['name'],
  1855. 'class' => 'darkBold',
  1856. ),12,2,1).'
  1857. '.buildField(array(
  1858. 'type' => 'text',
  1859. 'id' => 'tab-'.$data['id'].'-url',
  1860. 'name' => 'url['.$data['id'].']',
  1861. 'required' => true,
  1862. 'placeholder' => 'homepage.php',
  1863. 'labelTranslate' => 'TAB_URL',
  1864. 'value' => $data['url'],
  1865. 'class' => 'darkBold',
  1866. ),12,2,2).'
  1867. '.buildField(array(
  1868. 'type' => 'text',
  1869. 'id' => 'tab-'.$data['id'].'-iconurl',
  1870. 'name' => 'iconurl['.$data['id'].']',
  1871. 'placeholder' => 'images/organizr.png',
  1872. 'labelTranslate' => 'ICON_URL',
  1873. 'value' => $data['iconurl'],
  1874. 'class' => 'darkBold',
  1875. ),12,2,1).'
  1876. '.buildField(array(
  1877. 'type' => 'text',
  1878. 'id' => 'tab-'.$data['id'].'-icon',
  1879. 'name' => 'icon['.$data['id'].']',
  1880. 'placeholder' => 'fa-icon',
  1881. 'labelTranslate' => 'OR_ICON_NAME',
  1882. 'value' => $data['icon'],
  1883. 'class' => 'iconpickeradd darkBold',
  1884. ),12,1,1).'
  1885. '.buildField(array(
  1886. 'type' => 'text',
  1887. 'id' => 'tab-'.$data['id'].'-ping_url',
  1888. 'name' => 'ping_url['.$data['id'].']',
  1889. 'placeholder' => 'host:port',
  1890. 'labelTranslate' => 'PING_URL',
  1891. 'value' => $data['ping_url'],
  1892. 'class' => 'darkBold',
  1893. ),12,2,1).'
  1894. '.buildField(array(
  1895. 'type' => 'radio',
  1896. 'labelTranslate' => 'DEFAULT',
  1897. 'name' => 'defaultz['.$data['id'].']',
  1898. 'value' => $data['defaultz'],
  1899. 'onclick' => "$('[type=radio][id!=\''+this.id+'\']').each(function() { this.checked=false; });",
  1900. ),12,1,1).'
  1901. '.buildField(array(
  1902. 'type' => 'button',
  1903. 'icon' => 'chevron-down',
  1904. 'buttonType' => 'success',
  1905. 'labelTranslate' => 'MORE',
  1906. 'onclick' => "$(this).parent().parent().parent().find('.slideInUp').toggle()",
  1907. 'class' => 'toggleTabExtra',
  1908. ),12,1,1).'
  1909. '.buildField(array(
  1910. 'type' => 'button',
  1911. 'icon' => 'trash',
  1912. 'buttonType' => 'danger',
  1913. 'labelTranslate' => 'REMOVE',
  1914. 'onclick' => "$(this).parents('li').remove();",
  1915. ),12,1,1).'</div><div id = "tab-'.$data['id'].'-row" class = "row animated slideInUp" style = "display:none;" ><div></div>
  1916. '.buildField(array(
  1917. 'type' => 'checkbox',
  1918. 'labelTranslate' => 'ACTIVE',
  1919. 'name' => 'active['.$data['id'].']',
  1920. 'value' => $data['active'],
  1921. ),12,1,1).'
  1922. '.buildField(array(
  1923. 'type' => 'checkbox',
  1924. 'labelTranslate' => 'USER',
  1925. 'colour' => 'primary',
  1926. 'name' => 'user['.$data['id'].']',
  1927. 'value' => $data['user'],
  1928. ),12,1,1).'
  1929. '.buildField(array(
  1930. 'type' => 'checkbox',
  1931. 'labelTranslate' => 'GUEST',
  1932. 'colour' => 'warning',
  1933. 'name' => 'guest['.$data['id'].']',
  1934. 'value' => $data['guest'],
  1935. ),12,1,1).'
  1936. '.buildField(array(
  1937. 'type' => 'checkbox',
  1938. 'labelTranslate' => 'NO_IFRAME',
  1939. 'colour' => 'danger',
  1940. 'name' => 'window['.$data['id'].']',
  1941. 'value' => $data['window'],
  1942. ),12,1,1).'
  1943. '.buildField(array(
  1944. 'type' => 'checkbox',
  1945. 'labelTranslate' => 'SPLASH',
  1946. 'colour' => 'success',
  1947. 'name' => 'splash['.$data['id'].']',
  1948. 'value' => $data['splash'],
  1949. ),12,1,1).'
  1950. '.buildField(array(
  1951. 'type' => 'checkbox',
  1952. 'labelTranslate' => 'PING',
  1953. 'colour' => 'success',
  1954. 'name' => 'ping['.$data['id'].']',
  1955. 'value' => $data['ping'],
  1956. ),12,1,1).'
  1957. </div>
  1958. </tab>
  1959. </li>
  1960. ';
  1961. return $output;
  1962. }
  1963. // Timezone array
  1964. function timezoneOptions() {
  1965. $output = array();
  1966. $timezones = array();
  1967. $regions = array(
  1968. 'Africa' => DateTimeZone::AFRICA,
  1969. 'America' => DateTimeZone::AMERICA,
  1970. 'Antarctica' => DateTimeZone::ANTARCTICA,
  1971. 'Arctic' => DateTimeZone::ARCTIC,
  1972. 'Asia' => DateTimeZone::ASIA,
  1973. 'Atlantic' => DateTimeZone::ATLANTIC,
  1974. 'Australia' => DateTimeZone::AUSTRALIA,
  1975. 'Europe' => DateTimeZone::EUROPE,
  1976. 'Indian' => DateTimeZone::INDIAN,
  1977. 'Pacific' => DateTimeZone::PACIFIC
  1978. );
  1979. foreach ($regions as $name => $mask) {
  1980. $zones = DateTimeZone::listIdentifiers($mask);
  1981. foreach($zones as $timezone) {
  1982. $time = new DateTime(NULL, new DateTimeZone($timezone));
  1983. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  1984. $output[$name]['optgroup'][substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm]['value'] = $timezone;
  1985. }
  1986. }
  1987. return $output;
  1988. }
  1989. // Build Database
  1990. function createSQLiteDB($path = false) {
  1991. if ($path === false) {
  1992. if (DATABASE_LOCATION){
  1993. $path = DATABASE_LOCATION;
  1994. } else {
  1995. debug_out('No Path Specified!');
  1996. }
  1997. }
  1998. if (!is_file($path.'users.db') || filesize($path.'users.db') <= 0) {
  1999. if (!isset($GLOBALS['file_db'])) {
  2000. $GLOBALS['file_db'] = new PDO('sqlite:'.$path.'users.db');
  2001. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2002. }
  2003. // Create Users
  2004. $users = $GLOBALS['file_db']->query('CREATE TABLE `users` (
  2005. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2006. `username` TEXT UNIQUE,
  2007. `password` TEXT,
  2008. `email` TEXT,
  2009. `token` TEXT,
  2010. `role` TEXT,
  2011. `active` TEXT,
  2012. `last` TEXT,
  2013. `auth_service` TEXT DEFAULT \'internal\'
  2014. );');
  2015. // Create Tabs
  2016. $tabs = $GLOBALS['file_db']->query('CREATE TABLE `tabs` (
  2017. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2018. `order` INTEGER,
  2019. `users_id` INTEGER,
  2020. `name` TEXT,
  2021. `url` TEXT,
  2022. `defaultz` TEXT,
  2023. `active` TEXT,
  2024. `user` TEXT,
  2025. `guest` TEXT,
  2026. `icon` TEXT,
  2027. `iconurl` TEXT,
  2028. `window` TEXT,
  2029. `splash` TEXT,
  2030. `ping` TEXT,
  2031. `ping_url` TEXT
  2032. );');
  2033. // Create Options
  2034. $options = $GLOBALS['file_db']->query('CREATE TABLE `options` (
  2035. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2036. `users_id` INTEGER UNIQUE,
  2037. `title` TEXT UNIQUE,
  2038. `topbar` TEXT,
  2039. `bottombar` TEXT,
  2040. `sidebar` TEXT,
  2041. `hoverbg` TEXT,
  2042. `topbartext` TEXT,
  2043. `activetabBG` TEXT,
  2044. `activetabicon` TEXT,
  2045. `activetabtext` TEXT,
  2046. `inactiveicon` TEXT,
  2047. `inactivetext` TEXT,
  2048. `loading` TEXT,
  2049. `hovertext` TEXT
  2050. );');
  2051. // Create Invites
  2052. $invites = $GLOBALS['file_db']->query('CREATE TABLE `invites` (
  2053. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2054. `code` TEXT UNIQUE,
  2055. `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  2056. `email` TEXT,
  2057. `username` TEXT,
  2058. `dateused` TIMESTAMP,
  2059. `usedby` TEXT,
  2060. `ip` TEXT,
  2061. `valid` TEXT
  2062. );');
  2063. writeLog("success", "database created/saved");
  2064. return $users && $tabs && $options && $invites;
  2065. } else {
  2066. writeLog("error", "database was unable to be created/saved");
  2067. return false;
  2068. }
  2069. }
  2070. // Upgrade Database
  2071. function updateSQLiteDB($db_path = false, $oldVerNum = false) {
  2072. if (!$db_path) {
  2073. if (defined('DATABASE_LOCATION')) {
  2074. $db_path = DATABASE_LOCATION;
  2075. } else {
  2076. debug_out('No Path Specified',1);
  2077. }
  2078. }
  2079. if (!isset($GLOBALS['file_db'])) {
  2080. $GLOBALS['file_db'] = new PDO('sqlite:'.$db_path.'users.db');
  2081. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2082. }
  2083. // Cache current DB
  2084. $cache = array();
  2085. foreach($GLOBALS['file_db']->query('SELECT name FROM sqlite_master WHERE type="table";') as $table) {
  2086. foreach($GLOBALS['file_db']->query('SELECT * FROM '.$table['name'].';') as $key => $row) {
  2087. foreach($row as $k => $v) {
  2088. if (is_string($k)) {
  2089. $cache[$table['name']][$key][$k] = $v;
  2090. }
  2091. }
  2092. }
  2093. }
  2094. // Remove Current Database
  2095. $GLOBALS['file_db'] = null;
  2096. $pathDigest = pathinfo($db_path.'users.db');
  2097. if (file_exists($db_path.'users.db')) {
  2098. rename($db_path.'users.db', $pathDigest['dirname'].'/'.$pathDigest['filename'].'['.date('Y-m-d_H-i-s').']'.($oldVerNum?'['.$oldVerNum.']':'').'.bak.db');
  2099. }
  2100. // Create New Database
  2101. $success = createSQLiteDB($db_path);
  2102. // Restore Items
  2103. if ($success) {
  2104. foreach($cache as $table => $tableData) {
  2105. if ($tableData) {
  2106. $queryBase = 'INSERT INTO '.$table.' (`'.implode('`,`',array_keys(current($tableData))).'`) values ';
  2107. $insertValues = array();
  2108. reset($tableData);
  2109. foreach($tableData as $key => $value) {
  2110. $insertValues[] = '('.implode(',',array_map(function($d) {
  2111. return (isset($d)?$GLOBALS['file_db']->quote($d):'null');
  2112. }, $value)).')';
  2113. }
  2114. $GLOBALS['file_db']->query($queryBase.implode(',',$insertValues).';');
  2115. }
  2116. }
  2117. writeLog("success", "database values have been updated");
  2118. return true;
  2119. } else {
  2120. writeLog("error", "database values unable to be updated");
  2121. return false;
  2122. }
  2123. }
  2124. // Commit colours to database
  2125. function updateDBOptions($values) {
  2126. if (!isset($GLOBALS['file_db'])) {
  2127. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2128. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2129. }
  2130. // Commit new values to database
  2131. if ($GLOBALS['file_db']->query('UPDATE options SET '.implode(',',array_map(function($d, $k) {
  2132. return '`'.$k.'` = '.(isset($d)?"'".addslashes($d)."'":'null');
  2133. }, $values, array_keys($values))).';')->rowCount()) {
  2134. return true;
  2135. } else if ($GLOBALS['file_db']->query('INSERT OR IGNORE INTO options (`'.implode('`,`',array_keys($values)).'`) VALUES (\''.implode("','",$values).'\');')->rowCount()) {
  2136. writeLog("success", "database values for options table have been updated");
  2137. return true;
  2138. } else {
  2139. writeLog("error", "database values for options table unable to be updated");
  2140. return false;
  2141. }
  2142. }
  2143. // Send AJAX notification
  2144. function sendNotification($success, $message = false, $send = true) {
  2145. $notifyExplode = explode("-", NOTIFYEFFECT);
  2146. if ($success) {
  2147. $msg = array(
  2148. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_SAVED").'</strong>'),
  2149. 'icon' => 'floppy-o',
  2150. 'type' => 'success',
  2151. 'length' => '5000',
  2152. 'layout' => $notifyExplode[0],
  2153. 'effect' => $notifyExplode[1],
  2154. );
  2155. } else {
  2156. $msg = array(
  2157. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_NOT_SAVED").'</strong>'),
  2158. 'icon' => 'floppy-o',
  2159. 'type' => 'failed',
  2160. 'length' => '5000',
  2161. 'layout' => $notifyExplode[0],
  2162. 'effect' => $notifyExplode[1],
  2163. );
  2164. }
  2165. // Send and kill script?
  2166. if ($send) {
  2167. header('Content-Type: application/json');
  2168. echo json_encode(array('notify'=>$msg));
  2169. die();
  2170. }
  2171. return $msg;
  2172. }
  2173. // Load colours from the database
  2174. function loadAppearance() {
  2175. // Defaults
  2176. $defaults = array(
  2177. 'title' => 'Organizr',
  2178. 'topbartext' => '#66D9EF',
  2179. 'topbar' => '#333333',
  2180. 'bottombar' => '#333333',
  2181. 'sidebar' => '#393939',
  2182. 'hoverbg' => '#AD80FD',
  2183. 'activetabBG' => '#F92671',
  2184. 'activetabicon' => '#FFFFFF',
  2185. 'activetabtext' => '#FFFFFF',
  2186. 'inactiveicon' => '#66D9EF',
  2187. 'inactivetext' => '#66D9EF',
  2188. 'loading' => '#66D9EF',
  2189. 'hovertext' => '#000000',
  2190. );
  2191. if (DATABASE_LOCATION) {
  2192. if(is_file(DATABASE_LOCATION.'users.db') && filesize(DATABASE_LOCATION.'users.db') > 0){
  2193. if (!isset($GLOBALS['file_db'])) {
  2194. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2195. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2196. }
  2197. // Database Lookup
  2198. $options = $GLOBALS['file_db']->query('SELECT * FROM options');
  2199. // Replace defaults with filled options
  2200. foreach($options as $row) {
  2201. foreach($defaults as $key => $value) {
  2202. if (isset($row[$key]) && $row[$key]) {
  2203. $defaults[$key] = $row[$key];
  2204. }
  2205. }
  2206. }
  2207. }
  2208. }
  2209. // Return the Results
  2210. return $defaults;
  2211. }
  2212. // Delete Database
  2213. function deleteDatabase() {
  2214. unset($_COOKIE['Organizr']);
  2215. setcookie('Organizr', '', time() - 3600, '/');
  2216. unset($_COOKIE['OrganizrU']);
  2217. setcookie('OrganizrU', '', time() - 3600, '/');
  2218. $GLOBALS['file_db'] = null;
  2219. unlink(DATABASE_LOCATION.'users.db');
  2220. foreach(glob(substr_replace($userdirpath, "", -1).'/*') as $file) {
  2221. if(is_dir($file)) {
  2222. rmdir($file);
  2223. } elseif (!is_dir($file)) {
  2224. unlink($file);
  2225. }
  2226. }
  2227. rmdir($userdirpath);
  2228. writeLog("success", "database has been deleted");
  2229. return true;
  2230. }
  2231. // Upgrade the installation
  2232. function upgradeInstall($branch = 'master') {
  2233. function downloadFile($url, $path){
  2234. ini_set('max_execution_time',0);
  2235. $folderPath = "upgrade/";
  2236. if(!mkdir($folderPath)){
  2237. writeLog("error", "organizr could not create upgrade folder");
  2238. }
  2239. $newfname = $folderPath . $path;
  2240. $file = fopen ($url, 'rb');
  2241. if ($file) {
  2242. $newf = fopen ($newfname, 'wb');
  2243. if ($newf) {
  2244. while(!feof($file)) {
  2245. fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
  2246. }
  2247. }
  2248. }else{
  2249. writeLog("error", "organizr could not download $url");
  2250. }
  2251. if ($file) {
  2252. fclose($file);
  2253. writeLog("success", "organizr finished downloading the github zip file");
  2254. }else{
  2255. writeLog("error", "organizr could not download the github zip file");
  2256. }
  2257. if ($newf) {
  2258. fclose($newf);
  2259. writeLog("success", "organizr created upgrade zip file from github zip file");
  2260. }else{
  2261. writeLog("error", "organizr could not create upgrade zip file from github zip file");
  2262. }
  2263. }
  2264. function unzipFile($zipFile){
  2265. $zip = new ZipArchive;
  2266. $extractPath = "upgrade/";
  2267. if($zip->open($extractPath . $zipFile) != "true"){
  2268. writeLog("error", "organizr could not unzip upgrade.zip");
  2269. }else{
  2270. writeLog("success", "organizr unzipped upgrade.zip");
  2271. }
  2272. /* Extract Zip File */
  2273. $zip->extractTo($extractPath);
  2274. $zip->close();
  2275. }
  2276. // Function to remove folders and files
  2277. function rrmdir($dir) {
  2278. if (is_dir($dir)) {
  2279. $files = scandir($dir);
  2280. foreach ($files as $file)
  2281. if ($file != "." && $file != "..") rrmdir("$dir/$file");
  2282. rmdir($dir);
  2283. }
  2284. else if (file_exists($dir)) unlink($dir);
  2285. }
  2286. // Function to Copy folders and files
  2287. function rcopy($src, $dst) {
  2288. if (is_dir ( $src )) {
  2289. if (!file_exists($dst)) : mkdir ( $dst ); endif;
  2290. $files = scandir ( $src );
  2291. foreach ( $files as $file )
  2292. if ($file != "." && $file != "..")
  2293. rcopy ( "$src/$file", "$dst/$file" );
  2294. } else if (file_exists ( $src ))
  2295. copy ( $src, $dst );
  2296. }
  2297. $url = 'https://github.com/causefx/Organizr/archive/'.$branch.'.zip';
  2298. $file = "upgrade.zip";
  2299. $source = __DIR__ . '/upgrade/Organizr-'.$branch.'/';
  2300. $cleanup = __DIR__ . "/upgrade/";
  2301. $destination = __DIR__ . "/";
  2302. writeLog("success", "starting organizr upgrade process");
  2303. downloadFile($url, $file);
  2304. unzipFile($file);
  2305. rcopy($source, $destination);
  2306. writeLog("success", "new organizr files copied");
  2307. rrmdir($cleanup);
  2308. writeLog("success", "organizr upgrade folder removed");
  2309. writeLog("success", "organizr has been updated");
  2310. return true;
  2311. }
  2312. // NzbGET Items
  2313. function nzbgetConnect($list = 'listgroups') {
  2314. $url = qualifyURL(NZBGETURL);
  2315. $api = curl_get($url.'/'.NZBGETUSERNAME.':'.NZBGETPASSWORD.'/jsonrpc/'.$list);
  2316. $api = json_decode($api, true);
  2317. $gotNZB = array();
  2318. if (is_array($api) || is_object($api)){
  2319. foreach ($api['result'] AS $child) {
  2320. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  2321. $downloadStatus = $child['Status'];
  2322. $downloadCategory = $child['Category'];
  2323. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  2324. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  2325. if($child['Health'] <= "750"){
  2326. $downloadHealth = "danger";
  2327. }elseif($child['Health'] <= "900"){
  2328. $downloadHealth = "warning";
  2329. }elseif($child['Health'] <= "1000"){
  2330. $downloadHealth = "success";
  2331. }
  2332. $gotNZB[] = '<tr>
  2333. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2334. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2335. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2336. <td class="col-xs-1 nzbtable nzbtable-row">'.realSize(($child['FileSizeMB']*1024)*1024).'</td>
  2337. <td class="col-xs-2 nzbtable nzbtable-row">
  2338. <div class="progress">
  2339. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2340. <p class="text-center">'.round($downloadPercent).'%</p>
  2341. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2342. </div>
  2343. </div>
  2344. </td>
  2345. </tr>';
  2346. }
  2347. if ($gotNZB) {
  2348. return implode('',$gotNZB);
  2349. } else {
  2350. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2351. }
  2352. }else{
  2353. writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Username and Password - if HTTPS, is cert valid");
  2354. }
  2355. }
  2356. // Sabnzbd Items
  2357. function sabnzbdConnect($list = 'queue') {
  2358. $url = qualifyURL(SABNZBDURL);
  2359. $api = file_get_contents($url.'/api?mode='.$list.'&output=json&apikey='.SABNZBDKEY);
  2360. $api = json_decode($api, true);
  2361. $gotNZB = array();
  2362. foreach ($api[$list]['slots'] AS $child) {
  2363. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  2364. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  2365. $downloadStatus = $child['status'];
  2366. $gotNZB[] = '<tr>
  2367. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2368. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2369. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2370. <td class="col-xs-1 nzbtable nzbtable-row">'.$child['size'].'</td>
  2371. <td class="col-xs-2 nzbtable nzbtable-row">
  2372. <div class="progress">
  2373. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2374. <p class="text-center">'.round($downloadPercent).'%</p>
  2375. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2376. </div>
  2377. </div>
  2378. </td>
  2379. </tr>';
  2380. }
  2381. if ($gotNZB) {
  2382. return implode('',$gotNZB);
  2383. } else {
  2384. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2385. }
  2386. }
  2387. // Apply new tab settings
  2388. function updateTabs($tabs) {
  2389. if (!isset($GLOBALS['file_db'])) {
  2390. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2391. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2392. }
  2393. // Validate
  2394. if (!isset($tabs['defaultz'])) { $tabs['defaultz'][current(array_keys($tabs['name']))] = 'true'; }
  2395. if (isset($tabs['name']) && isset($tabs['url']) && is_array($tabs['name'])) {
  2396. // Clear Existing Tabs
  2397. $GLOBALS['file_db']->query("DELETE FROM tabs");
  2398. // Process New Tabs
  2399. $totalValid = 0;
  2400. foreach ($tabs['name'] as $key => $value) {
  2401. // Qualify
  2402. if (!$value || !isset($tabs['url']) || !$tabs['url'][$key]) { continue; }
  2403. $totalValid++;
  2404. $fields = array();
  2405. foreach(array('id','name','url','icon','iconurl','order','ping_url') as $v) {
  2406. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = $tabs[$v][$key]; }
  2407. }
  2408. foreach(array('active','user','guest','defaultz','window','splash','ping') as $v) {
  2409. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = ($tabs[$v][$key]!=='false'?'true':'false'); }
  2410. }
  2411. $GLOBALS['file_db']->query('INSERT INTO tabs (`'.implode('`,`',array_keys($fields)).'`) VALUES (\''.implode("','",$fields).'\');');
  2412. }
  2413. writeLog("success", "tabs successfully saved");
  2414. return $totalValid;
  2415. } else {
  2416. writeLog("error", "tabs could not save");
  2417. return false;
  2418. }
  2419. writeLog("error", "tabs could not save");
  2420. return false;
  2421. }
  2422. // ==============
  2423. function clean($strin) {
  2424. $strout = null;
  2425. for ($i = 0; $i < strlen($strin); $i++) {
  2426. $ord = ord($strin[$i]);
  2427. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  2428. $strout .= "&amp;#{$ord};";
  2429. }
  2430. else {
  2431. switch ($strin[$i]) {
  2432. case '<':
  2433. $strout .= '&lt;';
  2434. break;
  2435. case '>':
  2436. $strout .= '&gt;';
  2437. break;
  2438. case '&':
  2439. $strout .= '&amp;';
  2440. break;
  2441. case '"':
  2442. $strout .= '&quot;';
  2443. break;
  2444. default:
  2445. $strout .= $strin[$i];
  2446. }
  2447. }
  2448. }
  2449. return $strout;
  2450. }
  2451. function registration_callback($username, $email, $userdir){
  2452. global $data;
  2453. $data = array($username, $email, $userdir);
  2454. }
  2455. function printArray($arrayName){
  2456. $messageCount = count($arrayName);
  2457. $i = 0;
  2458. foreach ( $arrayName as $item ) :
  2459. $i++;
  2460. if($i < $messageCount) :
  2461. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  2462. elseif($i = $messageCount) :
  2463. echo "<small class='text-uppercase'>" . $item . "</small>";
  2464. endif;
  2465. endforeach;
  2466. }
  2467. function write_ini_file($content, $path) {
  2468. if (!$handle = fopen($path, 'w')) {
  2469. return false;
  2470. }
  2471. $success = fwrite($handle, trim($content));
  2472. fclose($handle);
  2473. return $success;
  2474. }
  2475. function gotTimezone(){
  2476. $regions = array(
  2477. 'Africa' => DateTimeZone::AFRICA,
  2478. 'America' => DateTimeZone::AMERICA,
  2479. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2480. 'Arctic' => DateTimeZone::ARCTIC,
  2481. 'Asia' => DateTimeZone::ASIA,
  2482. 'Atlantic' => DateTimeZone::ATLANTIC,
  2483. 'Australia' => DateTimeZone::AUSTRALIA,
  2484. 'Europe' => DateTimeZone::EUROPE,
  2485. 'Indian' => DateTimeZone::INDIAN,
  2486. 'Pacific' => DateTimeZone::PACIFIC
  2487. );
  2488. $timezones = array();
  2489. foreach ($regions as $name => $mask) {
  2490. $zones = DateTimeZone::listIdentifiers($mask);
  2491. foreach($zones as $timezone) {
  2492. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2493. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2494. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2495. }
  2496. }
  2497. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  2498. foreach($timezones as $region => $list) {
  2499. print '<optgroup label="' . $region . '">' . "\n";
  2500. foreach($list as $timezone => $name) {
  2501. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  2502. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  2503. }
  2504. print '</optgroup>' . "\n";
  2505. }
  2506. print '</select>';
  2507. }
  2508. function getTimezone(){
  2509. $regions = array(
  2510. 'Africa' => DateTimeZone::AFRICA,
  2511. 'America' => DateTimeZone::AMERICA,
  2512. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2513. 'Arctic' => DateTimeZone::ARCTIC,
  2514. 'Asia' => DateTimeZone::ASIA,
  2515. 'Atlantic' => DateTimeZone::ATLANTIC,
  2516. 'Australia' => DateTimeZone::AUSTRALIA,
  2517. 'Europe' => DateTimeZone::EUROPE,
  2518. 'Indian' => DateTimeZone::INDIAN,
  2519. 'Pacific' => DateTimeZone::PACIFIC
  2520. );
  2521. $timezones = array();
  2522. foreach ($regions as $name => $mask) {
  2523. $zones = DateTimeZone::listIdentifiers($mask);
  2524. foreach($zones as $timezone) {
  2525. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2526. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2527. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2528. }
  2529. }
  2530. print '<select name="timezone" id="timezone" class="form-control material" required>';
  2531. foreach($timezones as $region => $list) {
  2532. print '<optgroup label="' . $region . '">' . "\n";
  2533. foreach($list as $timezone => $name) {
  2534. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  2535. }
  2536. print '</optgroup>' . "\n";
  2537. }
  2538. print '</select>';
  2539. }
  2540. function explosion($string, $position){
  2541. $getWord = explode("|", $string);
  2542. return $getWord[$position];
  2543. }
  2544. function getServerPath() {
  2545. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  2546. $protocol = "https://";
  2547. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  2548. $protocol = "https://";
  2549. } else {
  2550. $protocol = "http://";
  2551. }
  2552. $domain = '';
  2553. if (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], '.') !== false){
  2554. $domain = $_SERVER['SERVER_NAME'];
  2555. }elseif(isset($_SERVER['HTTP_HOST'])){
  2556. if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
  2557. $domain = explode(':', $_SERVER['HTTP_HOST'])[0];
  2558. $port = explode(':', $_SERVER['HTTP_HOST'])[1];
  2559. if ($port == "80" || $port == "443"){
  2560. $domain = $domain;
  2561. }else{
  2562. $domain = $_SERVER['HTTP_HOST'];
  2563. }
  2564. }else{
  2565. $domain = $_SERVER['HTTP_HOST'];
  2566. }
  2567. }
  2568. return $protocol . $domain . str_replace("\\", "/", dirname($_SERVER['REQUEST_URI']));
  2569. }
  2570. function get_browser_name() {
  2571. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  2572. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  2573. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  2574. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  2575. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  2576. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  2577. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  2578. return 'Other';
  2579. }
  2580. function getSickrageCalendarWanted($array){
  2581. $array = json_decode($array, true);
  2582. //$gotCalendar = "";
  2583. $gotCalendar = array();
  2584. $i = 0;
  2585. foreach($array['data']['missed'] AS $child) {
  2586. $i++;
  2587. $seriesName = $child['show_name'];
  2588. $episodeID = $child['tvdbid'];
  2589. $episodeAirDate = $child['airdate'];
  2590. $episodeAirDateTime = explode(" ",$child['airs']);
  2591. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2592. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2593. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2594. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2595. $downloaded = "0";
  2596. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2597. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2598. array_push($gotCalendar, array(
  2599. "id" => "Sick-Miss-".$i,
  2600. "title" => $seriesName,
  2601. "start" => $episodeAirDate,
  2602. "className" => $downloaded." tvID--".$episodeID,
  2603. "imagetype" => "tv",
  2604. ));
  2605. }
  2606. foreach($array['data']['today'] AS $child) {
  2607. $i++;
  2608. $seriesName = $child['show_name'];
  2609. $episodeID = $child['tvdbid'];
  2610. $episodeAirDate = $child['airdate'];
  2611. $episodeAirDateTime = explode(" ",$child['airs']);
  2612. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2613. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2614. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2615. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2616. $downloaded = "0";
  2617. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2618. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2619. array_push($gotCalendar, array(
  2620. "id" => "Sick-Today-".$i,
  2621. "title" => $seriesName,
  2622. "start" => $episodeAirDate,
  2623. "className" => $downloaded." tvID--".$episodeID,
  2624. "imagetype" => "tv",
  2625. ));
  2626. }
  2627. foreach($array['data']['soon'] AS $child) {
  2628. $i++;
  2629. $seriesName = $child['show_name'];
  2630. $episodeID = $child['tvdbid'];
  2631. $episodeAirDate = $child['airdate'];
  2632. $episodeAirDateTime = explode(" ",$child['airs']);
  2633. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2634. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2635. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2636. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2637. $downloaded = "0";
  2638. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2639. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2640. array_push($gotCalendar, array(
  2641. "id" => "Sick-Soon-".$i,
  2642. "title" => $seriesName,
  2643. "start" => $episodeAirDate,
  2644. "className" => $downloaded." tvID--".$episodeID,
  2645. "imagetype" => "tv",
  2646. ));
  2647. }
  2648. foreach($array['data']['later'] AS $child) {
  2649. $i++;
  2650. $seriesName = $child['show_name'];
  2651. $episodeID = $child['tvdbid'];
  2652. $episodeAirDate = $child['airdate'];
  2653. $episodeAirDateTime = explode(" ",$child['airs']);
  2654. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2655. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2656. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2657. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2658. $downloaded = "0";
  2659. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2660. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2661. array_push($gotCalendar, array(
  2662. "id" => "Sick-Later-".$i,
  2663. "title" => $seriesName,
  2664. "start" => $episodeAirDate,
  2665. "className" => $downloaded." tvID--".$episodeID,
  2666. "imagetype" => "tv",
  2667. ));
  2668. }
  2669. if ($i != 0){ return $gotCalendar; }
  2670. }
  2671. function getSickrageCalendarHistory($array){
  2672. $array = json_decode($array, true);
  2673. //$gotCalendar = "";
  2674. $gotCalendar = array();
  2675. $i = 0;
  2676. foreach($array['data'] AS $child) {
  2677. $i++;
  2678. $seriesName = $child['show_name'];
  2679. $episodeID = $child['tvdbid'];
  2680. $episodeAirDate = $child['date'];
  2681. $downloaded = "green-bg";
  2682. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2683. array_push($gotCalendar, array(
  2684. "id" => "Sick-History-".$i,
  2685. "title" => $seriesName,
  2686. "start" => $episodeAirDate,
  2687. "className" => $downloaded." tvID--".$episodeID,
  2688. "imagetype" => "tv",
  2689. ));
  2690. }
  2691. if ($i != 0){ return $gotCalendar; }
  2692. }
  2693. function getSonarrCalendar($array){
  2694. $array = json_decode($array, true);
  2695. //$gotCalendar = "";
  2696. $gotCalendar = array();
  2697. $i = 0;
  2698. foreach($array AS $child) {
  2699. $i++;
  2700. $seriesName = $child['series']['title'];
  2701. $episodeID = $child['series']['tvdbId'];
  2702. if(!isset($episodeID)){ $episodeID = ""; }
  2703. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  2704. if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
  2705. $episodeAirDate = $child['airDateUtc'];
  2706. $episodeAirDate = strtotime($episodeAirDate);
  2707. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2708. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2709. $downloaded = $child['hasFile'];
  2710. 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"; }
  2711. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2712. array_push($gotCalendar, array(
  2713. "id" => "Sonarr-".$i,
  2714. "title" => $seriesName,
  2715. "start" => $episodeAirDate,
  2716. "className" => $downloaded." tvID--".$episodeID,
  2717. "imagetype" => "tv",
  2718. ));
  2719. }
  2720. if ($i != 0){ return $gotCalendar; }
  2721. }
  2722. function getCouchCalendar(){
  2723. $url = qualifyURL(COUCHURL);
  2724. $api = curl_get($url."/api/".COUCHAPI."/media.list");
  2725. $api = json_decode($api, true);
  2726. $i = 0;
  2727. $gotCalendar = array();
  2728. if (is_array($api) || is_object($api)){
  2729. foreach($api['movies'] AS $child) {
  2730. if($child['status'] == "active" || $child['status'] == "done" ){
  2731. $i++;
  2732. $movieName = $child['info']['original_title'];
  2733. $movieID = $child['info']['tmdb_id'];
  2734. if(!isset($movieID)){ $movieID = ""; }
  2735. $physicalRelease = (isset($child['info']['released']) ? $child['info']['released'] : null);
  2736. $backupRelease = (isset($child['info']['release_date']['theater']) ? $child['info']['release_date']['theater'] : null);
  2737. $physicalRelease = (isset($physicalRelease) ? $physicalRelease : $backupRelease);
  2738. $physicalRelease = strtotime($physicalRelease);
  2739. $physicalRelease = date("Y-m-d", $physicalRelease);
  2740. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2741. $downloaded = ($child['status'] == "active") ? "0" : "1";
  2742. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2743. array_push($gotCalendar, array(
  2744. "id" => "CouchPotato-".$i,
  2745. "title" => $movieName,
  2746. "start" => $physicalRelease,
  2747. "className" => $downloaded." movieID--".$movieID,
  2748. "imagetype" => "film",
  2749. ));
  2750. }
  2751. }
  2752. if ($i != 0){ return $gotCalendar; }
  2753. }else{
  2754. writeLog("error", "CouchPotato ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2755. }
  2756. }
  2757. function getRadarrCalendar($array){
  2758. $array = json_decode($array, true);
  2759. $gotCalendar = array();
  2760. $i = 0;
  2761. foreach($array AS $child) {
  2762. if(isset($child['physicalRelease'])){
  2763. $i++;
  2764. $movieName = $child['title'];
  2765. $movieID = $child['tmdbId'];
  2766. if(!isset($movieID)){ $movieID = ""; }
  2767. $physicalRelease = $child['physicalRelease'];
  2768. $physicalRelease = strtotime($physicalRelease);
  2769. $physicalRelease = date("Y-m-d", $physicalRelease);
  2770. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2771. $downloaded = $child['hasFile'];
  2772. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2773. array_push($gotCalendar, array(
  2774. "id" => "Radarr-".$i,
  2775. "title" => $movieName,
  2776. "start" => $physicalRelease,
  2777. "className" => $downloaded." movieID--".$movieID,
  2778. "imagetype" => "film",
  2779. ));
  2780. }
  2781. }
  2782. if ($i != 0){ return $gotCalendar; }
  2783. }
  2784. function getHeadphonesCalendar($url, $key, $list){
  2785. $url = qualifyURL(HEADPHONESURL);
  2786. $api = curl_get($url."/api?apikey=".$key."&cmd=$list");
  2787. $api = json_decode($api, true);
  2788. $i = 0;
  2789. //$gotCalendar = "";
  2790. $gotCalendar = array();;
  2791. if (is_array($api) || is_object($api)){
  2792. foreach($api AS $child) {
  2793. if($child['Status'] == "Wanted" && $list == "getWanted" && $child['ReleaseDate']){
  2794. $i++;
  2795. $albumName = addslashes($child['AlbumTitle']);
  2796. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  2797. $albumDate = (strlen($child['ReleaseDate']) > 4) ? $child['ReleaseDate'] : $child['ReleaseDate']."-01-01";
  2798. $albumID = $child['AlbumID'];
  2799. $albumDate = strtotime($albumDate);
  2800. $albumDate = date("Y-m-d", $albumDate);
  2801. $albumStatus = $child['Status'];
  2802. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2803. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  2804. //$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2805. array_push($gotCalendar, array(
  2806. "id" => "Headphones-".$i,
  2807. "title" => $albumArtist.' - '.$albumName,
  2808. "start" => $albumDate,
  2809. "className" => $albumStatusColor,
  2810. "imagetype" => "music",
  2811. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2812. ));
  2813. }
  2814. if($child['Status'] == "Processed" && $list == "getHistory"){
  2815. $i++;
  2816. $find = array('_','[', ']', '\n');
  2817. $replace = array(' ','(', ')', ' ');
  2818. $albumName = addslashes(str_replace($find,$replace,$child['FolderName']));
  2819. $albumDate = $child['DateAdded'];
  2820. $albumID = $child['AlbumID'];
  2821. $albumDate = strtotime($albumDate);
  2822. $albumDate = date("Y-m-d", $albumDate);
  2823. $albumStatusColor = "green-bg";
  2824. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2825. //$gotCalendar .= "{ title: \"$albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2826. array_push($gotCalendar, array(
  2827. "id" => "Headphones-".$i,
  2828. "title" => $albumName,
  2829. "start" => $albumDate,
  2830. "className" => $albumStatusColor,
  2831. "imagetype" => "music",
  2832. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2833. ));
  2834. }
  2835. }
  2836. if ($i != 0){ return $gotCalendar; }
  2837. }else{
  2838. writeLog("error", "HEADPHONES $list ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2839. }
  2840. }
  2841. function checkRootPath($string){
  2842. if($string == "\\" || $string == "/"){
  2843. return "/";
  2844. }else{
  2845. return str_replace("\\", "/", $string) . "/";
  2846. }
  2847. }
  2848. function strip($string){
  2849. $string = strip_tags($string);
  2850. return preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $string));
  2851. }
  2852. function writeLog($type, $message){
  2853. if(file_exists("org.log")){
  2854. if(filesize("org.log") > 500000){
  2855. rename('org.log','org['.date('Y-m-d').'].log');
  2856. $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";
  2857. file_put_contents("org.log", $message2, FILE_APPEND | LOCK_EX);
  2858. }
  2859. }
  2860. $message = date("Y-m-d H:i:s")."|".$type."|".strip($message)."\n";
  2861. file_put_contents("org.log", $message, FILE_APPEND | LOCK_EX);
  2862. }
  2863. function readLog(){
  2864. $log = file("org.log",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  2865. $log = array_reverse($log);
  2866. foreach($log as $line){
  2867. if(substr_count($line, '|') == 2){
  2868. $line = explode("|", strip($line));
  2869. $line[1] = ($line[1] == "error") ? '<span class="label label-danger">Error</span>' : '<span class="label label-primary">Success</span>';
  2870. echo "<tr><td>".$line[0]."</td><td>".$line[2]."</td><td>".$line[1]."</td></tr>";
  2871. }
  2872. }
  2873. }
  2874. function buildStream($array){
  2875. $result = "";
  2876. if (array_key_exists('platform', $array)) {
  2877. $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>';
  2878. }
  2879. if (array_key_exists('device', $array)) {
  2880. $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>';
  2881. }
  2882. if (array_key_exists('stream', $array)) {
  2883. $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>';
  2884. }
  2885. if (array_key_exists('video', $array)) {
  2886. $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>';
  2887. }
  2888. if (array_key_exists('audio', $array)) {
  2889. $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>';
  2890. }
  2891. return $result;
  2892. }
  2893. function streamType($value){
  2894. if($value == "transcode" || $value == "Transcode"){
  2895. return "Transcode";
  2896. }elseif($value == "copy" || $value == "DirectStream"){
  2897. return "Direct Stream";
  2898. }elseif($value == "directplay" || $value == "DirectPlay"){
  2899. return "Direct Play";
  2900. }else{
  2901. return "Direct Play";
  2902. }
  2903. }
  2904. function getPlatform($platform){
  2905. $allPlatforms = array(
  2906. "Chrome" => "chrome.png",
  2907. "tvOS" => "atv.png",
  2908. "iOS" => "ios.png",
  2909. "Xbox One" => "xbox.png",
  2910. "Mystery 4" => "playstation.png",
  2911. "Samsung" => "samsung.png",
  2912. "Roku" => "roku.png",
  2913. "Emby for iOS" => "ios.png",
  2914. "Emby Mobile" => "emby.png",
  2915. "Emby Theater" => "emby.png",
  2916. "Emby Classic" => "emby.png",
  2917. "Safari" => "safari.png",
  2918. "Android" => "android.png",
  2919. "AndroidTv" => "android.png",
  2920. "Chromecast" => "chromecast.png",
  2921. "Dashboard" => "emby.png",
  2922. "Dlna" => "dlna.png",
  2923. "Windows Phone" => "wp.png",
  2924. "Windows RT" => "win8.png",
  2925. "Kodi" => "kodi.png",
  2926. );
  2927. if (array_key_exists($platform, $allPlatforms)) {
  2928. return $allPlatforms[$platform];
  2929. }else{
  2930. return "pmp.png";
  2931. }
  2932. }
  2933. function getServer(){
  2934. $server = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"];
  2935. return $server;
  2936. }
  2937. function prettyPrint($array) {
  2938. echo "<pre>";
  2939. print_r($array);
  2940. echo "</pre>";
  2941. echo "<br/>";
  2942. }
  2943. function checkFrame($array, $url){
  2944. if(array_key_exists("x-frame-options", $array)){
  2945. if($array['x-frame-options'] == "deny"){
  2946. return false;
  2947. }elseif($array['x-frame-options'] == "sameorgin"){
  2948. $digest = parse_url($url);
  2949. $host = (isset($digest['host'])?$digest['host']:'');
  2950. if(getServer() == $host){
  2951. return true;
  2952. }else{
  2953. return false;
  2954. }
  2955. }
  2956. }else{
  2957. if(!$array){
  2958. return false;
  2959. }
  2960. return true;
  2961. }
  2962. }
  2963. function frameTest($url){
  2964. $array = array_change_key_case(get_headers(qualifyURL($url), 1));
  2965. $url = qualifyURL($url);
  2966. if(checkFrame($array, $url)){
  2967. return true;
  2968. }else{
  2969. return false;
  2970. }
  2971. }
  2972. function sendResult($result, $icon = "floppy-o", $message = false, $success = "WAS_SUCCESSFUL", $fail = "HAS_FAILED", $send = true) {
  2973. $notifyExplode = explode("-", NOTIFYEFFECT);
  2974. if ($result) {
  2975. $msg = array(
  2976. 'html' => ($message?''.$message.' <strong>'.translate($success).'</strong>':'<strong>'.translate($success).'</strong>'),
  2977. 'icon' => $icon,
  2978. 'type' => 'success',
  2979. 'length' => '5000',
  2980. 'layout' => $notifyExplode[0],
  2981. 'effect' => $notifyExplode[1],
  2982. );
  2983. } else {
  2984. $msg = array(
  2985. 'html' => ($message?''.$message.' <strong>'.translate($fail).'</strong>':'<strong>'.translate($fail).'</strong>'),
  2986. 'icon' => $icon,
  2987. 'type' => 'error',
  2988. 'length' => '5000',
  2989. 'layout' => $notifyExplode[0],
  2990. 'effect' => $notifyExplode[1],
  2991. );
  2992. }
  2993. // Send and kill script?
  2994. if ($send) {
  2995. header('Content-Type: application/json');
  2996. echo json_encode(array('notify'=>$msg));
  2997. die();
  2998. }
  2999. return $msg;
  3000. }
  3001. function buildHomepageNotice($layout, $type, $title, $message){
  3002. switch ($layout) {
  3003. case 'elegant':
  3004. return '
  3005. <div id="homepageNotice" class="row">
  3006. <div class="col-lg-12">
  3007. <div class="content-box big-box box-shadow panel-box panel-'.$type.'">
  3008. <div class="content-title i-block">
  3009. <h4 class="zero-m"><strong>'.$title.'</strong></h4>
  3010. <div class="content-tools i-block pull-right">
  3011. <a class="close-btn">
  3012. <i class="fa fa-times"></i>
  3013. </a>
  3014. </div>
  3015. </div>
  3016. '.$message.'
  3017. </div>
  3018. </div>
  3019. </div>
  3020. ';
  3021. break;
  3022. case 'basic':
  3023. return '
  3024. <div id="homepageNotice" class="row">
  3025. <div class="col-lg-12">
  3026. <div class="panel panel-'.$type.'">
  3027. <div class="panel-heading">
  3028. <h3 class="panel-title">'.$title.'</h3>
  3029. </div>
  3030. <div class="panel-body">
  3031. '.$message.'
  3032. </div>
  3033. </div>
  3034. </div>
  3035. </div>
  3036. ';
  3037. break;
  3038. case 'jumbotron';
  3039. return '
  3040. <div id="homepageNotice" class="row">
  3041. <div class="col-lg-12">
  3042. <div class="jumbotron">
  3043. <div class="container">
  3044. <h1>'.$title.'</h1>
  3045. <p>'.$message.'</p>
  3046. </div>
  3047. </div>
  3048. </div>
  3049. </div>
  3050. ';
  3051. }
  3052. }
  3053. function embyArray($array, $type) {
  3054. $key = ($type == "video" ? "Height" : "Channels");
  3055. if (array_key_exists($key, $array)) {
  3056. switch ($type) {
  3057. case "video":
  3058. $codec = $array["Codec"];
  3059. $height = $array["Height"];
  3060. $width = $array["Width"];
  3061. break;
  3062. default:
  3063. $codec = $array["Codec"];
  3064. $channels = $array["Channels"];
  3065. }
  3066. return ($type == "video" ? "(".$codec.") (".$width."x".$height.")" : "(".$codec.") (".$channels."ch)");
  3067. }
  3068. foreach ($array as $element) {
  3069. if (is_array($element)) {
  3070. if (embyArray($element, $type)) {
  3071. return embyArray($element, $type);
  3072. }
  3073. }
  3074. }
  3075. }
  3076. // Get Now Playing Streams From Plex
  3077. function searchPlex($query){
  3078. $address = qualifyURL(PLEXURL);
  3079. $openTab = (PLEXTABNAME) ? "true" : "false";
  3080. // Perform API requests
  3081. $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
  3082. libxml_use_internal_errors(true);
  3083. $api = simplexml_load_string($api);
  3084. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3085. if (!$getServer) { return 'Could not load!'; }
  3086. // Identify the local machine
  3087. $server = $getServer['machineIdentifier'];
  3088. $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>";
  3089. $items = "";
  3090. $albums = $movies = $shows = 0;
  3091. $style = 'style="vertical-align: middle"';
  3092. foreach($api AS $child) {
  3093. if($child['type'] != "artist" && $child['type'] != "episode" && isset($child['librarySectionID'])){
  3094. $time = (string)$child['addedAt'];
  3095. $time = new DateTime("@$time");
  3096. $results = array(
  3097. "title" => (string)$child['title'],
  3098. "image" => (string)$child['thumb'],
  3099. "type" => (string)ucwords($child['type']),
  3100. "year" => (string)$child['year'],
  3101. "key" => (string)$child['ratingKey']."-search",
  3102. "ratingkey" => (string)$child['ratingKey'],
  3103. "genre" => (string)$child->Genre['tag'],
  3104. "added" => $time->format('Y-m-d'),
  3105. "extra" => "",
  3106. );
  3107. switch ($child['type']){
  3108. case "album":
  3109. $push = array(
  3110. "title" => (string)$child['parentTitle']." - ".(string)$child['title'],
  3111. );
  3112. $results = array_replace($results,$push);
  3113. $albums++;
  3114. break;
  3115. case "movie":
  3116. $push = array(
  3117. "extra" => "Content Rating: ".(string)$child['contentRating']."<br/>Movie Rating: ".(string)$child['rating'],
  3118. );
  3119. $results = array_replace($results,$push);
  3120. $movies++;
  3121. break;
  3122. case "show":
  3123. $push = array(
  3124. "extra" => "Seasons: ".(string)$child['childCount']."<br/>Episodes: ".(string)$child['leafCount'],
  3125. );
  3126. $results = array_replace($results,$push);
  3127. $shows++;
  3128. break;
  3129. }
  3130. if (file_exists('images/cache/'.$results['key'].'.jpg')){ $image_url = 'images/cache/'.$results['key'].'.jpg'; }
  3131. if (file_exists('images/cache/'.$results['key'].'.jpg') && (time() - 604800) > filemtime('images/cache/'.$results['key'].'.jpg') || !file_exists('images/cache/'.$results['key'].'.jpg')) {
  3132. $image_url = 'ajax.php?a=plex-image&img='.$results['image'].'&height=150&width=100&key='.$results['key'];
  3133. }
  3134. if(!$results['image']){ $image_url = "images/no-search.png"; $key = "no-search"; }
  3135. if (substr_count(PLEXURL, '.') != 2) {
  3136. $link = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3137. }else{
  3138. $link = PLEXURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3139. }
  3140. $items .= '<tr style="cursor: pointer;" class="openTab" extraTitle="'.$results['title'].'" extraType="'.$child['type'].'" openTab="'.$openTab.'" href="'.$link.'">
  3141. <th scope="row"><img src="'.$image_url.'"></th>
  3142. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
  3143. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
  3144. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
  3145. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
  3146. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
  3147. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['extra'].'</td>
  3148. </tr>';
  3149. }
  3150. }
  3151. $totals = '<div style="margin: 10px;" class="sort-todo pull-right">
  3152. <span class="badge gray-bg"><i class="fa fa-film fa-2x white"></i><strong style="
  3153. font-size: 23px;
  3154. ">&nbsp;'.$movies.'</strong></span>
  3155. <span class="badge gray-bg"><i class="fa fa-tv fa-2x white"></i><strong style="
  3156. font-size: 23px;
  3157. ">&nbsp;'.$shows.'</strong></span>
  3158. <span class="badge gray-bg"><i class="fa fa-music fa-2x white"></i><strong style="
  3159. font-size: 23px;
  3160. ">&nbsp;'.$albums.'</strong></span>
  3161. </div>';
  3162. return (!empty($items) ? $totals.$pre.$items."</div></table>" : "<h2 class='text-center'>No Results for $query</h2>" );
  3163. }
  3164. function getBannedUsers($string){
  3165. if (strpos($string, ',') !== false) {
  3166. $banned = explode(",", $string);
  3167. }else{
  3168. $banned = array($string);
  3169. }
  3170. return $banned;
  3171. }
  3172. function getWhitelist($string){
  3173. if (strpos($string, ',') !== false) {
  3174. $whitelist = explode(",", $string);
  3175. }else{
  3176. $whitelist = array($string);
  3177. }
  3178. foreach($whitelist as &$ip){
  3179. $ip = is_numeric(substr($ip, 0, 1)) ? $ip : gethostbyname($ip);
  3180. }
  3181. return $whitelist;
  3182. }
  3183. function get_client_ip() {
  3184. $ipaddress = '';
  3185. if (isset($_SERVER['HTTP_CLIENT_IP']))
  3186. $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
  3187. else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  3188. $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
  3189. else if(isset($_SERVER['HTTP_X_FORWARDED']))
  3190. $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
  3191. else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
  3192. $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
  3193. else if(isset($_SERVER['HTTP_FORWARDED']))
  3194. $ipaddress = $_SERVER['HTTP_FORWARDED'];
  3195. else if(isset($_SERVER['REMOTE_ADDR']))
  3196. $ipaddress = $_SERVER['REMOTE_ADDR'];
  3197. else
  3198. $ipaddress = 'UNKNOWN';
  3199. return $ipaddress;
  3200. }
  3201. //EMAIL SHIT
  3202. function sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null){
  3203. $mail = new PHPMailer;
  3204. $mail->isSMTP();
  3205. $mail->Host = SMTPHOST;
  3206. $mail->SMTPAuth = SMTPHOSTAUTH;
  3207. $mail->Username = SMTPHOSTUSERNAME;
  3208. $mail->Password = SMTPHOSTPASSWORD;
  3209. $mail->SMTPSecure = SMTPHOSTTYPE;
  3210. $mail->Port = SMTPHOSTPORT;
  3211. $mail->setFrom(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3212. $mail->addReplyTo(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3213. $mail->isHTML(true);
  3214. if($email){
  3215. $mail->addAddress($email, $username);
  3216. }
  3217. if($cc){
  3218. $mail->addCC($cc);
  3219. }
  3220. if($bcc){
  3221. if(strpos($bcc , ',') === false){
  3222. $mail->addBCC($bcc);
  3223. }else{
  3224. $allEmails = explode(",",$bcc);
  3225. foreach($allEmails as $gotEmail){
  3226. $mail->addBCC($gotEmail);
  3227. }
  3228. }
  3229. }
  3230. $mail->Subject = $subject;
  3231. $mail->Body = $body;
  3232. //$mail->send();
  3233. if(!$mail->send()) {
  3234. writeLog("error", "mail failed to send");
  3235. } else {
  3236. writeLog("success", "mail has been sent");
  3237. }
  3238. }
  3239. //EMAIL SHIT
  3240. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  3241. $mail = new PHPMailer;
  3242. $mail->isSMTP();
  3243. $mail->Host = $host;
  3244. $mail->SMTPAuth = $auth;
  3245. $mail->Username = $username;
  3246. $mail->Password = $password;
  3247. $mail->SMTPSecure = $type;
  3248. $mail->Port = $port;
  3249. $mail->setFrom($from, $sendername);
  3250. $mail->addReplyTo($from, $sendername);
  3251. $mail->isHTML(true);
  3252. $mail->addAddress($to, "Organizr Admin");
  3253. $mail->Subject = "Organizr Test E-Mail";
  3254. $mail->Body = "This was just a test!";
  3255. //$mail->send();
  3256. if(!$mail->send()) {
  3257. writeLog("error", "EMAIL TEST: mail failed to send - Error:".$mail->ErrorInfo);
  3258. return false;
  3259. } else {
  3260. writeLog("success", "EMAIL TEST: mail has been sent successfully");
  3261. return true;
  3262. }
  3263. }
  3264. function libraryList(){
  3265. $address = qualifyURL(PLEXURL);
  3266. $headers = array(
  3267. "Accept" => "application/json",
  3268. "X-Plex-Token" => PLEXTOKEN
  3269. );
  3270. libxml_use_internal_errors(true);
  3271. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3272. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3273. $api = simplexml_load_string(@curl_get("https://plex.tv/api/servers/$gotServer/shared_servers", $headers));
  3274. $libraryList = array();
  3275. foreach($api->SharedServer->Section AS $child) {
  3276. $libraryList['libraries'][(string)$child['title']] = (string)$child['id'];
  3277. }
  3278. foreach($api->SharedServer AS $child) {
  3279. if(!empty($child['username'])){
  3280. $username = (string)strtolower($child['username']);
  3281. $email = (string)strtolower($child['email']);
  3282. $libraryList['users'][$username] = (string)$child['id'];
  3283. $libraryList['emails'][$email] = (string)$child['id'];
  3284. $libraryList['both'][$username] = $email;
  3285. }
  3286. }
  3287. return (!empty($libraryList) ? array_change_key_case($libraryList,CASE_LOWER) : null );
  3288. }
  3289. function plexUserShare($username){
  3290. $address = qualifyURL(PLEXURL);
  3291. $headers = array(
  3292. "Accept" => "application/json",
  3293. "Content-Type" => "application/json",
  3294. "X-Plex-Token" => PLEXTOKEN
  3295. );
  3296. libxml_use_internal_errors(true);
  3297. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3298. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3299. $json = array(
  3300. "server_id" => $gotServer,
  3301. "shared_server" => array(
  3302. //"library_section_ids" => "[26527637]",
  3303. "invited_email" => $username
  3304. )
  3305. );
  3306. $api = curl_post("https://plex.tv/api/servers/$gotServer/shared_servers/", $json, $headers);
  3307. switch ($api['http_code']['http_code']){
  3308. case 400:
  3309. writeLog("error", "PLEX INVITE: $username already has access to the shared libraries");
  3310. $result = "$username already has access to the shared libraries";
  3311. break;
  3312. case 401:
  3313. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3314. $result = "Invalid Plex Token";
  3315. break;
  3316. case 200:
  3317. writeLog("success", "PLEX INVITE: $username now has access to your Plex Library");
  3318. $result = "$username now has access to your Plex Library";
  3319. break;
  3320. default:
  3321. writeLog("error", "PLEX INVITE: unknown error");
  3322. $result = false;
  3323. }
  3324. return (!empty($result) ? $result : null );
  3325. }
  3326. function plexUserDelete($username){
  3327. $address = qualifyURL(PLEXURL);
  3328. $headers = array(
  3329. "Accept" => "application/json",
  3330. "Content-Type" => "application/json",
  3331. "X-Plex-Token" => PLEXTOKEN
  3332. );
  3333. libxml_use_internal_errors(true);
  3334. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3335. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3336. $id = (is_numeric($username) ? $id : convertPlexName($username, "id"));
  3337. $api = curl_delete("https://plex.tv/api/servers/$gotServer/shared_servers/$id", $headers);
  3338. switch ($api['http_code']['http_code']){
  3339. case 401:
  3340. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3341. $result = "Invalid Plex Token";
  3342. break;
  3343. case 200:
  3344. writeLog("success", "PLEX INVITE: $username doesn't have access to your Plex Library anymore");
  3345. $result = "$username doesn't have access to your Plex Library anymore";
  3346. break;
  3347. default:
  3348. writeLog("error", "PLEX INVITE: unknown error");
  3349. $result = false;
  3350. }
  3351. return (!empty($result) ? $result : null );
  3352. }
  3353. function convertPlexName($user, $type){
  3354. $array = libraryList();
  3355. switch ($type){
  3356. case "username":
  3357. $plexUser = array_search ($user, $array['users']);
  3358. break;
  3359. case "id":
  3360. if (array_key_exists(strtolower($user), $array['users'])) {
  3361. $plexUser = $array['users'][strtolower($user)];
  3362. }
  3363. break;
  3364. default:
  3365. $plexUser = false;
  3366. }
  3367. return (!empty($plexUser) ? $plexUser : null );
  3368. }
  3369. function randomCode($length = 5, $type = null) {
  3370. switch ($type){
  3371. case "alpha":
  3372. $legend = array_merge(range('A', 'Z'));
  3373. break;
  3374. case "numeric":
  3375. $legend = array_merge(range(0,9));
  3376. break;
  3377. default:
  3378. $legend = array_merge(range(0,9),range('A', 'Z'));
  3379. }
  3380. $code = "";
  3381. for($i=0; $i < $length; $i++) {
  3382. $code .= $legend[mt_rand(0, count($legend) - 1)];
  3383. }
  3384. return $code;
  3385. }
  3386. function inviteCodes($action, $code = null, $usedBy = null) {
  3387. if (!isset($GLOBALS['file_db'])) {
  3388. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  3389. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  3390. }
  3391. $now = date("Y-m-d H:i:s");
  3392. switch ($action) {
  3393. case "get":
  3394. // Start Array
  3395. $result = array();
  3396. // Database Lookup
  3397. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes"');
  3398. // Get Codes
  3399. foreach($invites as $row) {
  3400. array_push($result, $row['code']);
  3401. }
  3402. // Return the Results
  3403. return (!empty($result) ? $result : false );
  3404. break;
  3405. case "check":
  3406. // Start Array
  3407. $result = array();
  3408. // Database Lookup
  3409. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes" AND code = "'.$code.'"');
  3410. // Get Codes
  3411. foreach($invites as $row) {
  3412. $result = $row['code'];
  3413. }
  3414. // Return the Results
  3415. return (!empty($result) ? $result : false );
  3416. break;
  3417. case "use":
  3418. $currentIP = get_client_ip();
  3419. $invites = $GLOBALS['file_db']->query('UPDATE invites SET valid = "No", usedby = "'.$usedBy.'", dateused = "'.$now.'", ip = "'.$currentIP.'" WHERE code = "'.$code.'"');
  3420. if(ENABLEMAIL){
  3421. if (!isset($GLOBALS['USER'])) {
  3422. require_once("user.php");
  3423. $GLOBALS['USER'] = new User('registration_callback');
  3424. }
  3425. 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."));
  3426. }
  3427. return (!empty($invites) ? true : false );
  3428. break;
  3429. }
  3430. }
  3431. function plexJoin($username, $email, $password){
  3432. $connectURL = 'https://plex.tv/users.json';
  3433. $headers = array(
  3434. 'Accept'=> 'application/json',
  3435. 'Content-Type' => 'application/x-www-form-urlencoded',
  3436. 'X-Plex-Product' => 'Organizr',
  3437. 'X-Plex-Version' => '1.0',
  3438. 'X-Plex-Client-Identifier' => '01010101-10101010',
  3439. );
  3440. $body = array(
  3441. 'user[email]' => $email,
  3442. 'user[username]' => $username,
  3443. 'user[password]' => $password,
  3444. );
  3445. $api = curl_post($connectURL, $body, $headers);
  3446. $json = json_decode($api['content'], true);
  3447. $errors = (!empty($json['errors']) ? true : false);
  3448. $success = (!empty($json['user']) ? true : false);
  3449. //Use This for later
  3450. $usernameError = (!empty($json['errors']['username']) ? $json['errors']['username'][0] : false);
  3451. $emailError = (!empty($json['errors']['email']) ? $json['errors']['email'][0] : false);
  3452. $passwordError = (!empty($json['errors']['password']) ? $json['errors']['password'][0] : false);
  3453. $errorMessage = "";
  3454. if($errors){
  3455. if($usernameError){ $errorMessage .= "[Username Error: ". $usernameError ."]"; }
  3456. if($emailError){ $errorMessage .= "[Email Error: ". $emailError ."]"; }
  3457. if($passwordError){ $errorMessage .= "[Password Error: ". $passwordError ."]"; }
  3458. }
  3459. switch ($api['http_code']['http_code']){
  3460. case 400:
  3461. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." $username already has access to the shared libraries $errorMessage");
  3462. break;
  3463. case 401:
  3464. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." invalid Plex Token $errorMessage");
  3465. break;
  3466. case 422:
  3467. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." user info error $errorMessage");
  3468. break;
  3469. case 429:
  3470. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." too many requests to plex.tv please try later $errorMessage");
  3471. break;
  3472. case 200:
  3473. case 201:
  3474. writeLog("success", "PLEX JOIN: $username now has access to your Plex Library");
  3475. break;
  3476. default:
  3477. writeLog("error", "PLEX JOIN: unknown error, $errorMessage Error: ".$api['http_code']['http_code']);
  3478. }
  3479. //prettyPrint($api);
  3480. //prettyPrint(json_decode($api['content'], true));
  3481. return (!empty($success) && empty($errors) ? true : false );
  3482. }
  3483. function getCert(){
  3484. $url = "http://curl.haxx.se/ca/cacert.pem";
  3485. $file = getcwd()."/config/cacert.pem";
  3486. $directory = getcwd()."/config/";
  3487. @mkdir($directory, 0770, true);
  3488. if(!file_exists($file)){
  3489. file_put_contents( $file, fopen($url, 'r'));
  3490. writeLog("success", "CERT PEM: pem file created");
  3491. }elseif (file_exists($file) && time() - 2592000 > filemtime($file)) {
  3492. file_put_contents( $file, fopen($url, 'r'));
  3493. writeLog("success", "CERT PEM: downloaded new pem file");
  3494. }
  3495. return $file;
  3496. }
  3497. function customCSS(){
  3498. if(CUSTOMCSS == "true") {
  3499. $template_file = "custom.css";
  3500. $file_handle = fopen($template_file, "rb");
  3501. echo "\n";
  3502. echo fread($file_handle, filesize($template_file));
  3503. fclose($file_handle);
  3504. echo "\n";
  3505. }
  3506. }
  3507. function tvdbToken(){
  3508. $headers = array(
  3509. "Accept" => "application/json",
  3510. "Content-Type" => "application/json"
  3511. );
  3512. $json = array(
  3513. "apikey" => "FBE7B62621F4CAD7",
  3514. "userkey" => "328BB46EB1E9A0F5",
  3515. "username" => "causefx"
  3516. );
  3517. $api = curl_post("https://api.thetvdb.com/login", $json, $headers);
  3518. return json_decode($api['content'], true)['token'];
  3519. }
  3520. function tvdbGet($id){
  3521. $headers = array(
  3522. "Accept" => "application/json",
  3523. "Authorization" => "Bearer ".tvdbToken(),
  3524. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3525. "trakt-api-version" => "2"
  3526. );
  3527. $trakt = curl_get("https://api.trakt.tv/search/tvdb/$id?type=show", $headers);
  3528. @$api['trakt'] = json_decode($trakt, true)[0]['show']['ids'];
  3529. if(empty($api['trakt'])){
  3530. $series = curl_get("https://api.thetvdb.com/series/$id", $headers);
  3531. $poster = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=poster", $headers);
  3532. $backdrop = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=fanart", $headers);
  3533. $api['series'] = json_decode($series, true)['data'];
  3534. $api['poster'] = json_decode($poster, true)['data'];
  3535. $api['backdrop'] = json_decode($backdrop, true)['data'];
  3536. }
  3537. return $api;
  3538. }
  3539. function tvdbSearch($name, $type){
  3540. $name = rawurlencode(preg_replace("/\(([^()]*+|(?R))*\)/","", $name));
  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/$type?query=$name", $headers);
  3548. @$api['trakt'] = json_decode($trakt, true)[0][$type]['ids'];
  3549. return $api;
  3550. }
  3551. function getPlexPlaylists(){
  3552. $address = qualifyURL(PLEXURL);
  3553. // Perform API requests
  3554. $api = @curl_get($address."/playlists?X-Plex-Token=".PLEXTOKEN);
  3555. libxml_use_internal_errors(true);
  3556. $api = simplexml_load_string($api);
  3557. if (is_array($api) || is_object($api)){
  3558. if (!$api->head->title){
  3559. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3560. if (!$getServer) { return 'Could not load!'; }
  3561. // Identify the local machine
  3562. $gotServer = $getServer['machineIdentifier'];
  3563. $output = "";
  3564. $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">';
  3565. foreach($api AS $child) {
  3566. $items = array();
  3567. if ($child['playlistType'] == "video" && strpos(strtolower($child['title']) , 'private') === false){
  3568. $api = @curl_get($address.$child['key']."?X-Plex-Token=".PLEXTOKEN);
  3569. $api = simplexml_load_string($api);
  3570. if (is_array($api) || is_object($api)){
  3571. if (!$api->head->title){
  3572. $className = preg_replace("/(\W)+/", "", $api['title']);
  3573. $hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  3574. foreach($api->Video AS $child){
  3575. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false,false,$className);
  3576. }
  3577. if (count($items)) {
  3578. $output .= ''.implode('',$items).'';
  3579. }
  3580. }
  3581. }
  3582. }
  3583. }
  3584. $hideMenu .= '</ul></div></div>';
  3585. 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>';
  3586. }else{
  3587. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check token - if HTTPS, is cert valid");
  3588. }
  3589. }else{
  3590. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check URL - if HTTPS, is cert valid");
  3591. }
  3592. }
  3593. function readExternalLog($type,$filename,$name = null){
  3594. $log = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3595. $log = array_reverse($log);
  3596. foreach($log as $line){
  3597. if(!empty($line) && $line[0] != " "){
  3598. $line = strip($line);
  3599. if($type == "single"){
  3600. if( strpos( strtolower($line), "ror" ) !== false ) {
  3601. echo "<tr><td class='red-bg'>".$line."</td></tr>";
  3602. }else{
  3603. echo "<tr><td>".$line."</td></tr>";
  3604. }
  3605. }elseif($type == "all"){
  3606. if( strpos( strtolower($line), "ror" ) !== false ) {
  3607. echo "<tr><td class='red-bg'>".$name."</td>";
  3608. echo "<td class='red-bg'>".$line."</td></tr>";
  3609. }else{
  3610. echo "<tr><td>".$name."</td>";
  3611. echo "<td>".$line."</td></tr>";
  3612. }
  3613. }
  3614. }
  3615. }
  3616. }
  3617. function getLogs(){
  3618. $path = __DIR__ ."/logs/";
  3619. @mkdir($path, 0770, true);
  3620. $logs = array();
  3621. $files = array_diff(scandir($path), array('.', '..'));
  3622. foreach($files as $v){
  3623. $title = explode(".", $v)[0];
  3624. $logs[$title] = $path.$v;
  3625. }
  3626. return $logs;
  3627. }
  3628. function getBackups(){
  3629. $path = DATABASE_LOCATION ."backups/";
  3630. @mkdir($path, 0770, true);
  3631. $backups = array();
  3632. $files = array_diff(scandir($path), array('.', '..'));
  3633. return array_reverse($files);
  3634. }
  3635. function getExtension($string) {
  3636. return preg_replace("#(.+)?\.(\w+)(\?.+)?#", "$2", $string);
  3637. }
  3638. function showFile(){
  3639. $file = $_GET['file'];
  3640. $fileType = getExtension($file);
  3641. if($fileType != 'php'){
  3642. header("Content-type: ".mimeTypes()[$fileType]);
  3643. @readfile($file);
  3644. }
  3645. }
  3646. function getCalendar(){
  3647. $sonarr = new Sonarr(SONARRURL, SONARRKEY);
  3648. $radarr = new Sonarr(RADARRURL, RADARRKEY);
  3649. $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
  3650. $startDate = date('Y-m-d',strtotime("-".CALENDARSTARTDAY." days"));
  3651. $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
  3652. $calendarItems = array();
  3653. if (SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)){
  3654. try {
  3655. $sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate));
  3656. if(!empty($sonarrCalendar)) { $calendarItems = array_merge($calendarItems, $sonarrCalendar); }
  3657. } catch (Exception $e) {
  3658. writeLog("error", "SONARR ERROR: ".strip($e->getMessage()));
  3659. }
  3660. }
  3661. if (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)){
  3662. try {
  3663. $radarrCalendar = getRadarrCalendar($radarr->getCalendar($startDate, $endDate));
  3664. if(!empty($radarrCalendar)) { $calendarItems = array_merge($calendarItems, $radarrCalendar); }
  3665. } catch (Exception $e) {
  3666. writeLog("error", "RADARR ERROR: ".strip($e->getMessage()));
  3667. }
  3668. }
  3669. if (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH)){
  3670. $couchCalendar = getCouchCalendar();
  3671. if(!empty($couchCalendar)) { $calendarItems = array_merge($calendarItems, $couchCalendar); }
  3672. }
  3673. if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
  3674. $headphonesHistory = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory");
  3675. $headphonesWanted = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted");
  3676. if(!empty($headphonesHistory)) { $calendarItems = array_merge($calendarItems, $headphonesHistory); }
  3677. if(!empty($headphonesWanted)) { $calendarItems = array_merge($calendarItems, $headphonesWanted); }
  3678. }
  3679. if (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)){
  3680. try {
  3681. $sickrageFuture = getSickrageCalendarWanted($sickrage->future());
  3682. if(!empty($sickrageFuture)) { $calendarItems = array_merge($calendarItems, $sickrageFuture); }
  3683. } catch (Exception $e) {
  3684. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3685. } try {
  3686. $sickrageHistory = getSickrageCalendarHistory($sickrage->history("100","downloaded"));
  3687. if(!empty($sickrageHistory)) { $calendarItems = array_merge($calendarItems, $sickrageHistory); }
  3688. } catch (Exception $e) {
  3689. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3690. }
  3691. }
  3692. return $calendarItems;
  3693. }
  3694. function localURL($url){
  3695. if (strpos($url, 'https') !== false) {
  3696. preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $url, $result);
  3697. $result = (!empty($result) ? true : false);
  3698. return $result;
  3699. }
  3700. }
  3701. function fileArray($files){
  3702. foreach($files as $file){
  3703. if(file_exists($file)){
  3704. $list[] = $file;
  3705. }
  3706. }
  3707. if(!empty($list)){ return $list; }
  3708. }
  3709. function backupDB(){
  3710. if (extension_loaded('ZIP')) {
  3711. $directory = DATABASE_LOCATION."backups/";
  3712. @mkdir($directory, 0770, true);
  3713. $orgFiles = array(
  3714. 'css' => 'custom.css',
  3715. 'temp' => 'cus.sd',
  3716. 'orgLog' => 'org.log',
  3717. 'loginLog' => 'loginLog.json',
  3718. 'chatDB' => 'chatpack.db',
  3719. 'config' => 'config/config.php',
  3720. 'database' => DATABASE_LOCATION.'users.db'
  3721. );
  3722. $files = fileArray($orgFiles);
  3723. if(!empty($files)){
  3724. writeLog("success", "BACKUP: backup process started");
  3725. $zipname = $directory.'backup['.date('Y-m-d_H-i').']['.INSTALLEDVERSION.'].zip';
  3726. $zip = new ZipArchive;
  3727. $zip->open($zipname, ZipArchive::CREATE);
  3728. foreach ($files as $file) {
  3729. $zip->addFile($file);
  3730. }
  3731. $zip->close();
  3732. writeLog("success", "BACKUP: backup process finished");
  3733. return true;
  3734. }else{
  3735. return false;
  3736. }
  3737. }else{
  3738. return false;
  3739. }
  3740. }
  3741. class Ping {
  3742. private $host;
  3743. private $ttl;
  3744. private $timeout;
  3745. private $port = 80;
  3746. private $data = 'Ping';
  3747. private $commandOutput;
  3748. /**
  3749. * Called when the Ping object is created.
  3750. *
  3751. * @param string $host
  3752. * The host to be pinged.
  3753. * @param int $ttl
  3754. * Time-to-live (TTL) (You may get a 'Time to live exceeded' error if this
  3755. * value is set too low. The TTL value indicates the scope or range in which
  3756. * a packet may be forwarded. By convention:
  3757. * - 0 = same host
  3758. * - 1 = same subnet
  3759. * - 32 = same site
  3760. * - 64 = same region
  3761. * - 128 = same continent
  3762. * - 255 = unrestricted
  3763. * @param int $timeout
  3764. * Timeout (in seconds) used for ping and fsockopen().
  3765. * @throws \Exception if the host is not set.
  3766. */
  3767. public function __construct($host, $ttl = 255, $timeout = 10) {
  3768. if (!isset($host)) {
  3769. throw new \Exception("Error: Host name not supplied.");
  3770. }
  3771. $this->host = $host;
  3772. $this->ttl = $ttl;
  3773. $this->timeout = $timeout;
  3774. }
  3775. /**
  3776. * Set the ttl (in hops).
  3777. *
  3778. * @param int $ttl
  3779. * TTL in hops.
  3780. */
  3781. public function setTtl($ttl) {
  3782. $this->ttl = $ttl;
  3783. }
  3784. /**
  3785. * Get the ttl.
  3786. *
  3787. * @return int
  3788. * The current ttl for Ping.
  3789. */
  3790. public function getTtl() {
  3791. return $this->ttl;
  3792. }
  3793. /**
  3794. * Set the timeout.
  3795. *
  3796. * @param int $timeout
  3797. * Time to wait in seconds.
  3798. */
  3799. public function setTimeout($timeout) {
  3800. $this->timeout = $timeout;
  3801. }
  3802. /**
  3803. * Get the timeout.
  3804. *
  3805. * @return int
  3806. * Current timeout for Ping.
  3807. */
  3808. public function getTimeout() {
  3809. return $this->timeout;
  3810. }
  3811. /**
  3812. * Set the host.
  3813. *
  3814. * @param string $host
  3815. * Host name or IP address.
  3816. */
  3817. public function setHost($host) {
  3818. $this->host = $host;
  3819. }
  3820. /**
  3821. * Get the host.
  3822. *
  3823. * @return string
  3824. * The current hostname for Ping.
  3825. */
  3826. public function getHost() {
  3827. return $this->host;
  3828. }
  3829. /**
  3830. * Set the port (only used for fsockopen method).
  3831. *
  3832. * Since regular pings use ICMP and don't need to worry about the concept of
  3833. * 'ports', this is only used for the fsockopen method, which pings servers by
  3834. * checking port 80 (by default).
  3835. *
  3836. * @param int $port
  3837. * Port to use for fsockopen ping (defaults to 80 if not set).
  3838. */
  3839. public function setPort($port) {
  3840. $this->port = $port;
  3841. }
  3842. /**
  3843. * Get the port (only used for fsockopen method).
  3844. *
  3845. * @return int
  3846. * The port used by fsockopen pings.
  3847. */
  3848. public function getPort() {
  3849. return $this->port;
  3850. }
  3851. /**
  3852. * Return the command output when method=exec.
  3853. * @return string
  3854. */
  3855. public function getCommandOutput(){
  3856. return $this->commandOutput;
  3857. }
  3858. /**
  3859. * Matches an IP on command output and returns.
  3860. * @return string
  3861. */
  3862. public function getIpAddress() {
  3863. $out = array();
  3864. if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $this->commandOutput, $out)){
  3865. return $out[0];
  3866. }
  3867. return null;
  3868. }
  3869. /**
  3870. * Ping a host.
  3871. *
  3872. * @param string $method
  3873. * Method to use when pinging:
  3874. * - exec (default): Pings through the system ping command. Fast and
  3875. * robust, but a security risk if you pass through user-submitted data.
  3876. * - fsockopen: Pings a server on port 80.
  3877. * - socket: Creates a RAW network socket. Only usable in some
  3878. * environments, as creating a SOCK_RAW socket requires root privileges.
  3879. *
  3880. * @throws InvalidArgumentException if $method is not supported.
  3881. *
  3882. * @return mixed
  3883. * Latency as integer, in ms, if host is reachable or FALSE if host is down.
  3884. */
  3885. public function ping($method = 'exec') {
  3886. $latency = false;
  3887. switch ($method) {
  3888. case 'exec':
  3889. $latency = $this->pingExec();
  3890. break;
  3891. case 'fsockopen':
  3892. $latency = $this->pingFsockopen();
  3893. break;
  3894. case 'socket':
  3895. $latency = $this->pingSocket();
  3896. break;
  3897. default:
  3898. throw new \InvalidArgumentException('Unsupported ping method.');
  3899. }
  3900. // Return the latency.
  3901. return $latency;
  3902. }
  3903. /**
  3904. * The exec method uses the possibly insecure exec() function, which passes
  3905. * the input to the system. This is potentially VERY dangerous if you pass in
  3906. * any user-submitted data. Be SURE you sanitize your inputs!
  3907. *
  3908. * @return int
  3909. * Latency, in ms.
  3910. */
  3911. private function pingExec() {
  3912. $latency = false;
  3913. $ttl = escapeshellcmd($this->ttl);
  3914. $timeout = escapeshellcmd($this->timeout);
  3915. $host = escapeshellcmd($this->host);
  3916. // Exec string for Windows-based systems.
  3917. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  3918. // -n = number of pings; -i = ttl; -w = timeout (in milliseconds).
  3919. $exec_string = 'ping -n 1 -i ' . $ttl . ' -w ' . ($timeout * 1000) . ' ' . $host;
  3920. }
  3921. // Exec string for Darwin based systems (OS X).
  3922. else if(strtoupper(PHP_OS) === 'DARWIN') {
  3923. // -n = numeric output; -c = number of pings; -m = ttl; -t = timeout.
  3924. $exec_string = 'ping -n -c 1 -m ' . $ttl . ' -t ' . $timeout . ' ' . $host;
  3925. }
  3926. // Exec string for other UNIX-based systems (Linux).
  3927. else {
  3928. // -n = numeric output; -c = number of pings; -t = ttl; -W = timeout
  3929. $exec_string = 'ping -n -c 1 -t ' . $ttl . ' -W ' . $timeout . ' ' . $host . ' 2>&1';
  3930. }
  3931. exec($exec_string, $output, $return);
  3932. // Strip empty lines and reorder the indexes from 0 (to make results more
  3933. // uniform across OS versions).
  3934. $this->commandOutput = implode($output, '');
  3935. $output = array_values(array_filter($output));
  3936. // If the result line in the output is not empty, parse it.
  3937. if (!empty($output[1])) {
  3938. // Search for a 'time' value in the result line.
  3939. $response = preg_match("/time(?:=|<)(?<time>[\.0-9]+)(?:|\s)ms/", $output[1], $matches);
  3940. // If there's a result and it's greater than 0, return the latency.
  3941. if ($response > 0 && isset($matches['time'])) {
  3942. $latency = round($matches['time'], 2);
  3943. }
  3944. }
  3945. return $latency;
  3946. }
  3947. /**
  3948. * The fsockopen method simply tries to reach the host on a port. This method
  3949. * is often the fastest, but not necessarily the most reliable. Even if a host
  3950. * doesn't respond, fsockopen may still make a connection.
  3951. *
  3952. * @return int
  3953. * Latency, in ms.
  3954. */
  3955. private function pingFsockopen() {
  3956. $start = microtime(true);
  3957. // fsockopen prints a bunch of errors if a host is unreachable. Hide those
  3958. // irrelevant errors and deal with the results instead.
  3959. $fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
  3960. if (!$fp) {
  3961. $latency = false;
  3962. }
  3963. else {
  3964. $latency = microtime(true) - $start;
  3965. $latency = round($latency * 1000, 2);
  3966. }
  3967. return $latency;
  3968. }
  3969. /**
  3970. * The socket method uses raw network packet data to try sending an ICMP ping
  3971. * packet to a server, then measures the response time. Using this method
  3972. * requires the script to be run with root privileges, though, so this method
  3973. * only works reliably on Windows systems and on Linux servers where the
  3974. * script is not being run as a web user.
  3975. *
  3976. * @return int
  3977. * Latency, in ms.
  3978. */
  3979. private function pingSocket() {
  3980. // Create a package.
  3981. $type = "\x08";
  3982. $code = "\x00";
  3983. $checksum = "\x00\x00";
  3984. $identifier = "\x00\x00";
  3985. $seq_number = "\x00\x00";
  3986. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  3987. // Calculate the checksum.
  3988. $checksum = $this->calculateChecksum($package);
  3989. // Finalize the package.
  3990. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  3991. // Create a socket, connect to server, then read socket and calculate.
  3992. if ($socket = socket_create(AF_INET, SOCK_RAW, 1)) {
  3993. socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array(
  3994. 'sec' => 10,
  3995. 'usec' => 0,
  3996. ));
  3997. // Prevent errors from being printed when host is unreachable.
  3998. @socket_connect($socket, $this->host, null);
  3999. $start = microtime(true);
  4000. // Send the package.
  4001. @socket_send($socket, $package, strlen($package), 0);
  4002. if (socket_read($socket, 255) !== false) {
  4003. $latency = microtime(true) - $start;
  4004. $latency = round($latency * 1000, 2);
  4005. }
  4006. else {
  4007. $latency = false;
  4008. }
  4009. }
  4010. else {
  4011. $latency = false;
  4012. }
  4013. // Close the socket.
  4014. socket_close($socket);
  4015. return $latency;
  4016. }
  4017. /**
  4018. * Calculate a checksum.
  4019. *
  4020. * @param string $data
  4021. * Data for which checksum will be calculated.
  4022. *
  4023. * @return string
  4024. * Binary string checksum of $data.
  4025. */
  4026. private function calculateChecksum($data) {
  4027. if (strlen($data) % 2) {
  4028. $data .= "\x00";
  4029. }
  4030. $bit = unpack('n*', $data);
  4031. $sum = array_sum($bit);
  4032. while ($sum >> 16) {
  4033. $sum = ($sum >> 16) + ($sum & 0xffff);
  4034. }
  4035. return pack('n*', ~$sum);
  4036. }
  4037. }
  4038. function ping($pings, $type = "string") {
  4039. $ping = new Ping("");
  4040. $ping->setTtl(128);
  4041. $ping->setTimeout(2);
  4042. switch ($type){
  4043. case "array":
  4044. $results = [];
  4045. foreach ($pings as $k => $v) {
  4046. if(strpos($v, ':') !== false){
  4047. $domain = explode(':', $v)[0];
  4048. $port = explode(':', $v)[1];
  4049. $ping->setHost($domain);
  4050. $ping->setPort($port);
  4051. $latency = $ping->ping('fsockopen');
  4052. }else{
  4053. $ping->setHost($v);
  4054. $latency = $ping->ping();
  4055. }
  4056. if ($latency || $latency === 0) {
  4057. $results[$k] = $latency;
  4058. } else {
  4059. $results[$k] = 0;
  4060. }
  4061. }
  4062. break;
  4063. case "string":
  4064. if(strpos($pings, ':') !== false){
  4065. $domain = explode(':', $pings)[0];
  4066. $port = explode(':', $pings)[1];
  4067. $ping->setHost($domain);
  4068. $ping->setPort($port);
  4069. $latency = $ping->ping('fsockopen');
  4070. }else{
  4071. $ping->setHost($pings);
  4072. $latency = $ping->ping();
  4073. }
  4074. if ($latency || $latency === 0) {
  4075. $results = $latency;
  4076. } else {
  4077. $results = 0;
  4078. }
  4079. break;
  4080. }
  4081. return $results;
  4082. }
  4083. function getPing($url, $style, $refresh = null){
  4084. if(ping($url) !== 0){
  4085. $class = 'success';
  4086. if(!$refresh){
  4087. $class .= " animated slideInLeft";
  4088. }
  4089. }else{
  4090. $class = "warning";
  4091. if(!$refresh){
  4092. $class .= " animated flash loop-animation-timeout";
  4093. }
  4094. }
  4095. echo '<span class="pingcheck badge ping-'.$class.'" style="position: absolute;z-index: 100;right: 5px; padding: 0px 0px;'.$style.';font-size: 10px;">&nbsp;</span>';
  4096. }
  4097. function speedTestData(){
  4098. $file_db = DATABASE_LOCATION."speedtest.db";
  4099. if(file_exists($file_db)){
  4100. $conn = new PDO("sqlite:$file_db") or die("1");
  4101. $result = $conn->query('SELECT * FROM speedtest_users');
  4102. $conn = null;
  4103. if (is_array($result) || is_object($result)){
  4104. foreach($result as $k => $v){
  4105. $return[$k] = $v;
  4106. }
  4107. return $return;
  4108. }
  4109. }
  4110. }
  4111. function speedTestDisplay($array, $output){
  4112. if (is_array($array) || is_object($array)){
  4113. if($output == "graph"){
  4114. $result = "Morris.Line({element: 'morris-line',data: [";
  4115. foreach($array as $k => $v){
  4116. $result .= "{ y: '".substr($v['timestamp'],0,10)."', a: ".$v['ul'].", b: ".$v['dl'].", c: ".$v['ping']." },";
  4117. }
  4118. $result .= "],xkey: 'y',ykeys: ['a', 'b', 'c'],labels: ['Upload', 'Download', 'Ping'],hideHover: 'auto',resize: true,lineColors: ['#63A8EB','#ccc','#000'] });";
  4119. }elseif($output == "table"){
  4120. $result = "";
  4121. foreach($array as $k => $v){
  4122. $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>";
  4123. }
  4124. }
  4125. return $result;
  4126. }
  4127. }
  4128. function buildMenuPhone($array){
  4129. if (is_array($array) || is_object($array)){
  4130. $result = '
  4131. <div class="content-box profile-sidebar box-shadow">
  4132. <img src="images/organizr-logo-h-d.png" width="100%" style="margin-top: -10px;">
  4133. <div class="profile-usermenu">
  4134. <ul class="nav" id="settings-list">
  4135. ';
  4136. foreach($array as $k => $v){
  4137. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4138. continue;
  4139. }
  4140. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4141. continue;
  4142. }
  4143. /*$result .= '
  4144. <li>
  4145. <a id="'.$v['id'].'" box="'.$v['box'].'">'.$v['name'].'
  4146. <span class="fa-stack fa-fw pull-right" style="margin-top: -5px;margin-right: -10px;">
  4147. <i class="fa fa-'.$v['icon_1'].' fa-stack-2x '.$v['color'].'" style="font-size:null;"></i>
  4148. <i class="fa fa-'.$v['icon_2'].' fa-stack-1x fa-inverse"></i>
  4149. </span>
  4150. </a>
  4151. </li>
  4152. ';*/
  4153. $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>';
  4154. }
  4155. $result .= '</ul></div></div>';
  4156. return $result;
  4157. }
  4158. }
  4159. function buildMenu($array){
  4160. if (is_array($array) || is_object($array)){
  4161. $result = '<div class="settingsList">';
  4162. foreach($array as $k => $v){
  4163. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4164. continue;
  4165. }
  4166. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4167. continue;
  4168. }
  4169. $result .= '
  4170. <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">
  4171. <i class="mdi mdi-'.$v['icon_1'].' fa-fw pull-left" style="padding-left: '.$v['padding'].'px;font-size: 30px"></i>
  4172. <p class="" style="text-align: center;direction: rtl;display:none;margin: 2px;"><strong>'.$v['name'].'</strong></p>
  4173. </button>
  4174. ';
  4175. }
  4176. $result .= '</div>';
  4177. return $result;
  4178. }
  4179. }
  4180. function requestInvite($email, $username){
  4181. //sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null){
  4182. //orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  4183. 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."));
  4184. }
  4185. function errormessage($msg) {
  4186. echo "<div style=\"margin-top: 50px;\">";
  4187. echo "<span style=\"color:#d89334;\">error </span>";
  4188. echo $msg;
  4189. echo "</div>";
  4190. }
  4191. function getOrgUsers(){
  4192. $file_db = DATABASE_LOCATION."users.db";
  4193. if(file_exists($file_db)){
  4194. $conn = new PDO("sqlite:$file_db") or die("1");
  4195. $result = $conn->query('SELECT * FROM users');
  4196. $conn = null;
  4197. if (is_array($result) || is_object($result)){
  4198. foreach($result as $k => $v){
  4199. $return[$v['username']] = $v['email'];
  4200. }
  4201. return $return;
  4202. }
  4203. }
  4204. }
  4205. function getEmails($type = 'org'){
  4206. if($type == 'plex'){
  4207. $emails = array_merge(libraryList()['both'],getOrgUsers());
  4208. }elseif($type == 'emby'){
  4209. $emails = getOrgUsers();
  4210. }else{
  4211. $emails = getOrgUsers();
  4212. }
  4213. return $emails;
  4214. }
  4215. function printEmails($emails){
  4216. $result = '';
  4217. foreach($emails as $k => $v){
  4218. $result .= '<option value="'.$v.'">'.$k.'</option>';
  4219. }
  4220. return $result;
  4221. }
  4222. function massEmail($to, $subject, $message){
  4223. if (!isset($GLOBALS['file_db'])) {
  4224. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  4225. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  4226. }
  4227. 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);
  4228. }
  4229. function q2a($q){
  4230. if (is_array($q) || is_object($q)){
  4231. foreach ($q as $k => $v){
  4232. $a[$k] = $v;
  4233. }
  4234. if(!empty($a)){
  4235. return $a;
  4236. }
  4237. }
  4238. }
  4239. function getOmbiToken($username, $password){
  4240. $headers = array(
  4241. "Accept" => "application/json",
  4242. "Content-Type" => "application/json"
  4243. );
  4244. $json = array(
  4245. "username" => $username,
  4246. "password" => $password,
  4247. "rememberMe" => "true",
  4248. );
  4249. $api = curl_post(OMBIURL."/api/v1/Token", $json, $headers);
  4250. return json_decode($api['content'], true)['access_token'];
  4251. }
  4252. function ombiAction($id, $action, $type){
  4253. $headers = array(
  4254. "Accept" => "application/json",
  4255. "Content-Type" => "application/json",
  4256. "Apikey" => OMBIKEY
  4257. );
  4258. switch ($type) {
  4259. case 'season':
  4260. case 'tv':
  4261. $type = 'tv';
  4262. break;
  4263. default:
  4264. $type = 'movie';
  4265. break;
  4266. }
  4267. switch ($action) {
  4268. case 'approve':
  4269. # code...
  4270. break;
  4271. case 'deny':
  4272. # code...
  4273. break;
  4274. case 'delete':
  4275. $api = curl_delete(OMBIURL."/api/v1/Request/".$type."/".$id, $headers);
  4276. break;
  4277. default:
  4278. # code...
  4279. break;
  4280. }
  4281. switch ($api['http_code']['http_code']){
  4282. case 401:
  4283. writeLog("error", "OMBI: Invalid API KEY");
  4284. return false;
  4285. break;
  4286. case 200:
  4287. writeLog("success", "OMBI: action completed successfully");
  4288. return true;
  4289. break;
  4290. default:
  4291. writeLog("error", "OMBI: unknown error with request [type: $type | action: $action | id: $id]");
  4292. return false;
  4293. }
  4294. //return (!empty($result) ? $result : null );
  4295. }
  4296. function getOmbiRequests($type = "both"){
  4297. $headers = array(
  4298. "Accept" => "application/json",
  4299. "Apikey" => OMBIKEY,
  4300. );
  4301. $requests = array();
  4302. switch ($type) {
  4303. case 'movie':
  4304. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4305. break;
  4306. case 'tv':
  4307. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4308. break;
  4309. default:
  4310. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4311. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4312. break;
  4313. }
  4314. if(isset($movie)){
  4315. foreach ($movie as $key => $value) {
  4316. $requests['movie'][] = array(
  4317. 'id' => $value['theMovieDbId'],
  4318. 'title' => $value['title'],
  4319. 'poster' => (strpos($value['posterPath'], "http") !== false) ? $value['posterPath'] : 'https://image.tmdb.org/t/p/w300/'.$value['posterPath'],
  4320. 'approved' => $value['approved'],
  4321. 'available' => $value['available'],
  4322. 'denied' => $value['denied'],
  4323. 'deniedReason' => $value['deniedReason'],
  4324. 'user' => $value['requestedUser']['userName'],
  4325. 'request_id' => $value['id'],
  4326. );
  4327. }
  4328. }
  4329. if(isset($tv) && (is_array($tv) || is_object($tv))){
  4330. foreach ($tv as $key => $value) {
  4331. $requests['tv'][] = array(
  4332. 'id' => $value['tvDbId'],
  4333. 'title' => $value['title'],
  4334. 'poster' => $value['posterPath'],
  4335. 'approved' => $value['childRequests'][0]['approved'],
  4336. 'available' => $key['childRequests'][0]['available'],
  4337. 'denied' => $key['childRequests'][0]['denied'],
  4338. 'deniedReason' => $key['childRequests'][0]['deniedReason'],
  4339. 'user' => $value['childRequests'][0]['requestedUser']['userName'],
  4340. 'request_id' => $value['id'],
  4341. );
  4342. }
  4343. }
  4344. return (empty($requests)) ? '' : $requests;
  4345. }
  4346. function convertOmbiString($type, $value){
  4347. switch ($type) {
  4348. case 'approved':
  4349. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4350. $string['icon'] = ($value) ? 'mdi mdi-check' : 'mdi mdi-clock';
  4351. $string['color'] = ($value) ? 'green-bg' : 'yellow-bg';
  4352. break;
  4353. case 'available':
  4354. $string['string'] = ($value) ? 'Available' : 'Not Downloaded';
  4355. $string['icon'] = ($value) ? 'mdi mdi-server' : 'mdi mdi-server-off';
  4356. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4357. break;
  4358. case 'denied':
  4359. $string['string'] = ($value) ? 'Denied' : 'Approved';
  4360. $string['icon'] = ($value) ? 'mdi mdi-emoticon-sad' : 'mdi mdi-emoticon-happy';
  4361. $string['color'] = ($value) ? 'red-bg' : 'green-bg';
  4362. break;
  4363. case 'status':
  4364. switch ($value) {
  4365. case '1':
  4366. $string['string'] = 'Denied';
  4367. $string['icon'] = 'mdi mdi-window-close';
  4368. $string['color'] = 'red-bg';
  4369. break;
  4370. case '2':
  4371. $string['string'] = 'Approved';
  4372. $string['icon'] = 'mdi mdi-check';
  4373. $string['color'] = 'green-bg';
  4374. break;
  4375. case '3':
  4376. $string['string'] = 'Not Approved';
  4377. $string['icon'] = 'mdi mdi-clock';
  4378. $string['color'] = 'yellow-bg';
  4379. break;
  4380. default:
  4381. # code...
  4382. break;
  4383. }
  4384. break;
  4385. default:
  4386. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4387. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4388. break;
  4389. }
  4390. return $string;
  4391. }
  4392. function buildOmbiItem($type, $group, $user, $request){
  4393. if (is_array($request) || is_object($request)){
  4394. $actions = '';
  4395. if($request['denied']){
  4396. $status = 1;
  4397. $actions .= '<li request-type="'.$type.'" request-id="'.$request['id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve - Not Active</a></li>';
  4398. }else{
  4399. if($request['approved']){
  4400. $status = 2;
  4401. }else{
  4402. $status = 3;
  4403. $actions .= '<li request-type="'.$type.'" request-id="'.$request['id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve - Not Active</a></li>';
  4404. $actions .= '<li request-type="'.$type.'" request-id="'.$request['id'].'" request-name="deny"><a class="requestAction" href="javascript:void(0)">Deny - Not Active</a></li>';
  4405. }
  4406. }
  4407. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="delete"><a class="requestAction" href="javascript:void(0)">Delete</a></li>';
  4408. if(isset($group) && $group == 'admin'){
  4409. return '
  4410. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4411. <div class="requestOptions">
  4412. <div class="btn-group transparent" role="group">
  4413. <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>
  4414. <ul class="dropdown-menu"><h6 class="text-center">'.$request['user'].'</h6>'.$actions.'</ul>
  4415. </div>
  4416. </div>
  4417. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4418. <div class="requestBottom text-center">
  4419. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4420. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4421. </div>
  4422. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4423. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4424. </div>
  4425. </div>
  4426. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4427. </div>';
  4428. }elseif(isset($group) && $group == 'user'){
  4429. if(strtolower($request['user']) == strtolower($user)){
  4430. return '
  4431. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4432. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4433. <div class="requestBottom text-center">
  4434. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4435. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4436. </div>
  4437. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4438. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4439. </div>
  4440. </div>
  4441. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4442. </div>';
  4443. }
  4444. }
  4445. }
  4446. }
  4447. function buildOmbiList($group, $user){
  4448. $requests = array();
  4449. $openTab = 'true';
  4450. $movieList = getOmbiRequests('movie');
  4451. $tvList = getOmbiRequests('tv');
  4452. if (is_array($movieList) || is_object($movieList)){
  4453. foreach ($movieList['movie'] as $request) {
  4454. $requests[] = buildOmbiItem('movie', $group, $user, $request);
  4455. }
  4456. }
  4457. if (is_array($tvList) || is_object($tvList)){
  4458. foreach ($tvList['tv'] as $request) {
  4459. $requests[] = buildOmbiItem('season', $group, $user, $request);
  4460. }
  4461. }
  4462. return outputOmbiRequests("Requested Content", $requests, "
  4463. setInterval(function() {
  4464. $('<div></div>').load('ajax.php?a=ombi-requests',function() {
  4465. var element = $(this).find('[id]');
  4466. var loadedID = element.attr('id');
  4467. $('#'+loadedID).replaceWith(element);
  4468. console.log('Loaded updated: '+loadedID);
  4469. loadSlick();
  4470. });
  4471. }, ".RECENTREFRESH.");
  4472. ", false);
  4473. }
  4474. function outputOmbiRequests($header = "Requested Content", $items, $script = false, $array) {
  4475. $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">';
  4476. if(preg_grep("/item-movie-Approved/", $items)){
  4477. $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>';
  4478. }
  4479. if(preg_grep("/item-movie-Approval-Pending/", $items)){
  4480. $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>';
  4481. }
  4482. if(preg_grep("/item-season-Approved/", $items)){
  4483. $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>';
  4484. }
  4485. if(preg_grep("/item-season-Approval-Pending/", $items)){
  4486. $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>';
  4487. }
  4488. $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>';
  4489. $hideMenu .= '</ul></div></div>';
  4490. // If None Populate Empty Item
  4491. if (!count($items)) {
  4492. 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>';
  4493. }else{
  4494. $className = str_replace(' ', '', $header);
  4495. 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>':'');
  4496. }
  4497. }
  4498. function realSize($bytes, $decimals = 2) {
  4499. $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
  4500. $factor = floor((strlen($bytes) - 1) / 3);
  4501. return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' '.@$size[$factor];
  4502. }
  4503. function buildDownloader($name){
  4504. return '
  4505. <div id="downloadClientRow" class="row">
  4506. <div class="col-xs-12 col-md-12">
  4507. <div class="content-box">
  4508. <div class="tabbable panel with-nav-tabs panel-default">
  4509. <div class="panel-heading">
  4510. <div class="content-tools i-block pull-right">
  4511. <a id="getDownloader" class="repeat-btn">
  4512. <i class="fa fa-repeat"></i>
  4513. </a>
  4514. </div>
  4515. <h3 class="pull-left">'.strtoupper($name).'</h3>
  4516. <ul class="nav nav-tabs pull-right">
  4517. <li class="active"><a href="#downloadQueue-'.$name.'" data-toggle="tab" aria-expanded="true">'.translate("QUEUE").'</a></li>
  4518. <li class=""><a href="#downloadHistory-'.$name.'" data-toggle="tab" aria-expanded="false">'.translate("HISTORY").'</a></li>
  4519. </ul>
  4520. <div class="clearfix"></div>
  4521. </div>
  4522. <div class="panel-body">
  4523. <div class="tab-content">
  4524. <div class="tab-pane fade active in" id="downloadQueue-'.$name.'">
  4525. <div class="table-responsive" style="max-height: 300px">
  4526. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  4527. <thead>
  4528. <tr>
  4529. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  4530. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  4531. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  4532. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  4533. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  4534. </tr>
  4535. </thead>
  4536. <tbody class="dl-queue '.$name.'"></tbody>
  4537. </table>
  4538. </div>
  4539. </div>
  4540. <div class="tab-pane fade" id="downloadHistory-'.$name.'">
  4541. <div class="table-responsive" style="max-height: 300px">
  4542. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  4543. <thead>
  4544. <tr>
  4545. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  4546. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  4547. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  4548. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  4549. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  4550. </tr>
  4551. </thead>
  4552. <tbody class="dl-history '.$name.'"></tbody>
  4553. </table>
  4554. </div>
  4555. </div>
  4556. </div>
  4557. </div>
  4558. </div>
  4559. </div>
  4560. </div>
  4561. </div>';
  4562. }
  4563. class Mobile_Detect
  4564. {
  4565. /**
  4566. * Mobile detection type.
  4567. *
  4568. * @deprecated since version 2.6.9
  4569. */
  4570. const DETECTION_TYPE_MOBILE = 'mobile';
  4571. /**
  4572. * Extended detection type.
  4573. *
  4574. * @deprecated since version 2.6.9
  4575. */
  4576. const DETECTION_TYPE_EXTENDED = 'extended';
  4577. /**
  4578. * A frequently used regular expression to extract version #s.
  4579. *
  4580. * @deprecated since version 2.6.9
  4581. */
  4582. const VER = '([\w._\+]+)';
  4583. /**
  4584. * Top-level device.
  4585. */
  4586. const MOBILE_GRADE_A = 'A';
  4587. /**
  4588. * Mid-level device.
  4589. */
  4590. const MOBILE_GRADE_B = 'B';
  4591. /**
  4592. * Low-level device.
  4593. */
  4594. const MOBILE_GRADE_C = 'C';
  4595. /**
  4596. * Stores the version number of the current release.
  4597. */
  4598. const VERSION = '2.8.26';
  4599. /**
  4600. * A type for the version() method indicating a string return value.
  4601. */
  4602. const VERSION_TYPE_STRING = 'text';
  4603. /**
  4604. * A type for the version() method indicating a float return value.
  4605. */
  4606. const VERSION_TYPE_FLOAT = 'float';
  4607. /**
  4608. * A cache for resolved matches
  4609. * @var array
  4610. */
  4611. protected $cache = array();
  4612. /**
  4613. * The User-Agent HTTP header is stored in here.
  4614. * @var string
  4615. */
  4616. protected $userAgent = null;
  4617. /**
  4618. * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
  4619. * @var array
  4620. */
  4621. protected $httpHeaders = array();
  4622. /**
  4623. * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
  4624. * @var array
  4625. */
  4626. protected $cloudfrontHeaders = array();
  4627. /**
  4628. * The matching Regex.
  4629. * This is good for debug.
  4630. * @var string
  4631. */
  4632. protected $matchingRegex = null;
  4633. /**
  4634. * The matches extracted from the regex expression.
  4635. * This is good for debug.
  4636. * @var string
  4637. */
  4638. protected $matchesArray = null;
  4639. /**
  4640. * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
  4641. *
  4642. * @deprecated since version 2.6.9
  4643. *
  4644. * @var string
  4645. */
  4646. protected $detectionType = self::DETECTION_TYPE_MOBILE;
  4647. /**
  4648. * HTTP headers that trigger the 'isMobile' detection
  4649. * to be true.
  4650. *
  4651. * @var array
  4652. */
  4653. protected static $mobileHeaders = array(
  4654. 'HTTP_ACCEPT' => array('matches' => array(
  4655. // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
  4656. 'application/x-obml2d',
  4657. // BlackBerry devices.
  4658. 'application/vnd.rim.html',
  4659. 'text/vnd.wap.wml',
  4660. 'application/vnd.wap.xhtml+xml'
  4661. )),
  4662. 'HTTP_X_WAP_PROFILE' => null,
  4663. 'HTTP_X_WAP_CLIENTID' => null,
  4664. 'HTTP_WAP_CONNECTION' => null,
  4665. 'HTTP_PROFILE' => null,
  4666. // Reported by Opera on Nokia devices (eg. C3).
  4667. 'HTTP_X_OPERAMINI_PHONE_UA' => null,
  4668. 'HTTP_X_NOKIA_GATEWAY_ID' => null,
  4669. 'HTTP_X_ORANGE_ID' => null,
  4670. 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
  4671. 'HTTP_X_HUAWEI_USERID' => null,
  4672. // Reported by Windows Smartphones.
  4673. 'HTTP_UA_OS' => null,
  4674. // Reported by Verizon, Vodafone proxy system.
  4675. 'HTTP_X_MOBILE_GATEWAY' => null,
  4676. // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
  4677. 'HTTP_X_ATT_DEVICEID' => null,
  4678. // Seen this on a HTC.
  4679. 'HTTP_UA_CPU' => array('matches' => array('ARM')),
  4680. );
  4681. /**
  4682. * List of mobile devices (phones).
  4683. *
  4684. * @var array
  4685. */
  4686. protected static $phoneDevices = array(
  4687. 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
  4688. 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
  4689. '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',
  4690. 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
  4691. // @todo: Is 'Dell Streak' a tablet or a phone? ;)
  4692. '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',
  4693. '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',
  4694. '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',
  4695. '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)',
  4696. 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
  4697. 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
  4698. 'NokiaLumia' => 'Lumia [0-9]{3,4}',
  4699. // http://www.micromaxinfo.com/mobiles/smartphones
  4700. // Added because the codes might conflict with Acer Tablets.
  4701. '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',
  4702. // @todo Complete the regex.
  4703. 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
  4704. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
  4705. // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
  4706. // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
  4707. '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',
  4708. // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
  4709. 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
  4710. // http://fr.wikomobile.com
  4711. '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',
  4712. 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
  4713. // Added simvalley mobile just for fun. They have some interesting devices.
  4714. // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
  4715. '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',
  4716. // Wolfgang - a brand that is sold by Aldi supermarkets.
  4717. // http://www.wolfgangmobile.com/
  4718. 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
  4719. 'Alcatel' => 'Alcatel',
  4720. 'Nintendo' => 'Nintendo 3DS',
  4721. // http://en.wikipedia.org/wiki/Amoi
  4722. 'Amoi' => 'Amoi',
  4723. // http://en.wikipedia.org/wiki/INQ
  4724. 'INQ' => 'INQ',
  4725. // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
  4726. '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',
  4727. );
  4728. /**
  4729. * List of tablet devices.
  4730. *
  4731. * @var array
  4732. */
  4733. protected static $tabletDevices = array(
  4734. // @todo: check for mobile friendly emails topic.
  4735. 'iPad' => 'iPad|iPad.*Mobile',
  4736. // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
  4737. // @see #442
  4738. 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
  4739. '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.
  4740. // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
  4741. '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)',
  4742. // Only the Surface tablets with Windows RT are considered mobile.
  4743. // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
  4744. 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
  4745. // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
  4746. 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
  4747. // Watch out for PadFone, see #132.
  4748. // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
  4749. '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',
  4750. 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
  4751. 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
  4752. 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
  4753. 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
  4754. // http://www.acer.ro/ac/ro/RO/content/drivers
  4755. // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
  4756. // http://us.acer.com/ac/en/US/content/group/tablets
  4757. // http://www.acer.de/ac/de/DE/content/models/tablets/
  4758. // Can conflict with Micromax and Motorola phones codes.
  4759. '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',
  4760. // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
  4761. // http://us.toshiba.com/tablets/tablet-finder
  4762. // http://www.toshiba.co.jp/regza/tablet/
  4763. 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
  4764. // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
  4765. // http://www.lg.com/us/tablets
  4766. 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
  4767. 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
  4768. // Prestigio Tablets http://www.prestigio.com/support
  4769. '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',
  4770. // http://support.lenovo.com/en_GB/downloads/default.page?#
  4771. '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|)',
  4772. // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
  4773. 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
  4774. // http://www.yarvik.com/en/matrix/tablets/
  4775. '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',
  4776. 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
  4777. 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
  4778. // http://www.intenso.de/kategorie_en.php?kategorie=33
  4779. // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
  4780. 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
  4781. // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
  4782. 'IRUTablet' => 'M702pro',
  4783. 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
  4784. // http://www.e-boda.ro/tablete-pc.html
  4785. 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
  4786. // http://www.allview.ro/produse/droseries/lista-tablete-pc/
  4787. 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
  4788. // http://wiki.archosfans.com/index.php?title=Main_Page
  4789. // @note Rewrite the regex format after we add more UAs.
  4790. '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',
  4791. // http://www.ainol.com/plugin.php?identifier=ainol&module=product
  4792. 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
  4793. 'NokiaLumiaTablet' => 'Lumia 2520',
  4794. // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
  4795. // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
  4796. // http://www.sony.jp/support/tablet/
  4797. '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',
  4798. // 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
  4799. 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
  4800. // db + http://www.cube-tablet.com/buy-products.html
  4801. 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
  4802. // http://www.cobyusa.com/?p=pcat&pcat_id=3001
  4803. 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
  4804. // http://www.match.net.cn/products.asp
  4805. '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',
  4806. // http://www.msi.com/support
  4807. // @todo Research the Windows Tablets.
  4808. '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',
  4809. // @todo http://www.kyoceramobile.com/support/drivers/
  4810. // 'KyoceraTablet' => null,
  4811. // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
  4812. // 'IntextTablet' => null,
  4813. // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
  4814. // http://www.imp3.net/14/show.php?itemid=20454
  4815. 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
  4816. // http://www.rock-chips.com/index.php?do=prod&pid=2
  4817. 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
  4818. // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
  4819. 'FlyTablet' => 'IQ310|Fly Vision',
  4820. // http://www.bqreaders.com/gb/tablets-prices-sale.html
  4821. 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
  4822. // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
  4823. // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
  4824. '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',
  4825. // Nec or Medias Tab
  4826. 'NecTablet' => '\bN-06D|\bN-08D',
  4827. // Pantech Tablets: http://www.pantechusa.com/phones/
  4828. 'PantechTablet' => 'Pantech.*P4100',
  4829. // Broncho Tablets: http://www.broncho.cn/ (hard to find)
  4830. 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
  4831. // http://versusuk.com/support.html
  4832. 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
  4833. // http://www.zync.in/index.php/our-products/tablet-phablets
  4834. 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
  4835. // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
  4836. 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
  4837. // https://www.nabitablet.com/
  4838. 'NabiTablet' => 'Android.*\bNabi',
  4839. 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
  4840. // French Danew Tablets http://www.danew.com/produits-tablette.php
  4841. 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
  4842. // Texet Tablets and Readers http://www.texet.ru/tablet/
  4843. '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',
  4844. // Avoid detecting 'PLAYSTATION 3' as mobile.
  4845. 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
  4846. // http://www.trekstor.de/surftabs.html
  4847. 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
  4848. // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
  4849. 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
  4850. // http://www.advandigital.com/index.php?link=content-product&jns=JP001
  4851. // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
  4852. '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 ',
  4853. // http://www.danytech.com/category/tablet-pc
  4854. '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',
  4855. // http://www.galapad.net/product.html
  4856. 'GalapadTablet' => 'Android.*\bG1\b',
  4857. // http://www.micromaxinfo.com/tablet/funbook
  4858. 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
  4859. // http://www.karbonnmobiles.com/products_tablet.php
  4860. 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
  4861. // http://www.myallfine.com/Products.asp
  4862. 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
  4863. // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
  4864. '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',
  4865. // http://www.yonesnav.com/products/products.php
  4866. 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
  4867. // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
  4868. // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
  4869. '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',
  4870. // http://www.gloryunion.cn/products.asp
  4871. // http://www.allwinnertech.com/en/apply/mobile.html
  4872. // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
  4873. // @todo: Softwiner tablets?
  4874. // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
  4875. '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
  4876. // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
  4877. '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',
  4878. // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
  4879. // @todo: add more tests.
  4880. 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
  4881. // http://hclmetablet.com/India/index.php
  4882. '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',
  4883. // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
  4884. 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
  4885. // http://www.visture.com/index.asp
  4886. 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
  4887. // http://www.mijncresta.nl/tablet
  4888. 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
  4889. // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
  4890. 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
  4891. // Concorde tab
  4892. 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
  4893. // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
  4894. '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',
  4895. // Modecom Tablets - http://www.modecom.eu/tablets/portal/
  4896. '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',
  4897. // Vonino Tablets - http://www.vonino.eu/tablets
  4898. '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',
  4899. // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
  4900. 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
  4901. // Storex Tablets - http://storex.fr/espace_client/support.html
  4902. // @note: no need to add all the tablet codes since they are guided by the first regex.
  4903. 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
  4904. // Generic Vodafone tablets.
  4905. 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
  4906. // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
  4907. // Aka: http://www.essentielb.fr/
  4908. 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
  4909. // Ross & Moor - http://ross-moor.ru/
  4910. 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
  4911. // i-mobile http://product.i-mobilephone.com/Mobile_Device
  4912. 'iMobileTablet' => 'i-mobile i-note',
  4913. // http://www.tolino.de/de/vergleichen/
  4914. 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
  4915. // AudioSonic - a Kmart brand
  4916. // 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
  4917. 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
  4918. // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
  4919. // @todo: add them gradually to avoid conflicts.
  4920. 'AMPETablet' => 'Android.* A78 ',
  4921. // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
  4922. 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
  4923. // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
  4924. 'TecnoTablet' => 'TECNO P9',
  4925. // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
  4926. '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',
  4927. // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
  4928. '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)',
  4929. // http://www.intracon.eu/tablet
  4930. 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
  4931. // http://www.xoro.de/produkte/
  4932. // @note: Might be the same brand with 'Simply tablets'
  4933. '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',
  4934. // http://www1.viewsonic.com/products/computing/tablets/
  4935. 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
  4936. // http://www.odys.de/web/internet-tablet_en.html
  4937. 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
  4938. // http://www.captiva-power.de/products.html#tablets-en
  4939. 'CaptivaTablet' => 'CAPTIVA PAD',
  4940. // IconBIT - http://www.iconbit.com/products/tablets/
  4941. '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',
  4942. // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
  4943. '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',
  4944. // Onda - http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
  4945. '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]+',
  4946. 'JaytechTablet' => 'TPC-PA762',
  4947. 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
  4948. // http://www.digma.ru/support/download/
  4949. // @todo: Ebooks also (if requested)
  4950. 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
  4951. // http://www.evolioshop.com/ro/tablete-pc.html
  4952. // http://www.evolio.ro/support/downloads_static.html?cat=2
  4953. // @todo: Research some more
  4954. 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
  4955. // @todo http://www.lavamobiles.com/tablets-data-cards
  4956. 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
  4957. // http://www.breezetablet.com/
  4958. 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
  4959. // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
  4960. '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',
  4961. // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
  4962. 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
  4963. // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
  4964. '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',
  4965. // http://www.mi.com/en
  4966. 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
  4967. // http://www.nbru.cn/index.html
  4968. 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
  4969. // http://navroad.com/products/produkty/tablety/
  4970. // http://navroad.com/products/produkty/tablety/
  4971. 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
  4972. // http://leader-online.com/new_site/product-category/tablets/
  4973. // http://www.leader-online.net.au/List/Tablet
  4974. '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',
  4975. // http://www.datawind.com/ubislate/
  4976. 'UbislateTablet' => 'UbiSlate[\s]?7C',
  4977. // http://www.pocketbook-int.com/ru/support
  4978. 'PocketBookTablet' => 'Pocketbook',
  4979. // http://www.kocaso.com/product_tablet.html
  4980. 'KocasoTablet' => '\b(TB-1207)\b',
  4981. // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
  4982. 'HisenseTablet' => '\b(F5281|E2371)\b',
  4983. // http://www.tesco.com/direct/hudl/
  4984. 'Hudl' => 'Hudl HT7S3|Hudl 2',
  4985. // http://www.telstra.com.au/home-phone/thub-2/
  4986. 'TelstraTablet' => 'T-Hub2',
  4987. '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'
  4988. );
  4989. /**
  4990. * List of mobile Operating Systems.
  4991. *
  4992. * @var array
  4993. */
  4994. protected static $operatingSystems = array(
  4995. 'AndroidOS' => 'Android',
  4996. 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
  4997. 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
  4998. 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
  4999. // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
  5000. 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
  5001. // @reference: http://en.wikipedia.org/wiki/Windows_Phone
  5002. // http://wifeng.cn/?r=blog&a=view&id=106
  5003. // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
  5004. // http://msdn.microsoft.com/library/ms537503.aspx
  5005. // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
  5006. 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
  5007. 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
  5008. // http://en.wikipedia.org/wiki/MeeGo
  5009. // @todo: research MeeGo in UAs
  5010. 'MeeGoOS' => 'MeeGo',
  5011. // http://en.wikipedia.org/wiki/Maemo
  5012. // @todo: research Maemo in UAs
  5013. 'MaemoOS' => 'Maemo',
  5014. 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
  5015. 'webOS' => 'webOS|hpwOS',
  5016. 'badaOS' => '\bBada\b',
  5017. 'BREWOS' => 'BREW',
  5018. );
  5019. /**
  5020. * List of mobile User Agents.
  5021. *
  5022. * IMPORTANT: This is a list of only mobile browsers.
  5023. * Mobile Detect 2.x supports only mobile browsers,
  5024. * it was never designed to detect all browsers.
  5025. * The change will come in 2017 in the 3.x release for PHP7.
  5026. *
  5027. * @var array
  5028. */
  5029. protected static $browsers = array(
  5030. //'Vivaldi' => 'Vivaldi',
  5031. // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
  5032. 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
  5033. 'Dolfin' => '\bDolfin\b',
  5034. 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
  5035. 'Skyfire' => 'Skyfire',
  5036. 'Edge' => 'Mobile Safari/[.0-9]* Edge',
  5037. 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
  5038. 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
  5039. 'Bolt' => 'bolt',
  5040. 'TeaShark' => 'teashark',
  5041. 'Blazer' => 'Blazer',
  5042. // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
  5043. 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
  5044. // http://en.wikipedia.org/wiki/Midori_(web_browser)
  5045. //'Midori' => 'midori',
  5046. //'Tizen' => 'Tizen',
  5047. 'UCBrowser' => 'UC.*Browser|UCWEB',
  5048. 'baiduboxapp' => 'baiduboxapp',
  5049. 'baidubrowser' => 'baidubrowser',
  5050. // https://github.com/serbanghita/Mobile-Detect/issues/7
  5051. 'DiigoBrowser' => 'DiigoBrowser',
  5052. // http://www.puffinbrowser.com/index.php
  5053. 'Puffin' => 'Puffin',
  5054. // http://mercury-browser.com/index.html
  5055. 'Mercury' => '\bMercury\b',
  5056. // http://en.wikipedia.org/wiki/Obigo_Browser
  5057. 'ObigoBrowser' => 'Obigo',
  5058. // http://en.wikipedia.org/wiki/NetFront
  5059. 'NetFront' => 'NF-Browser',
  5060. // @reference: http://en.wikipedia.org/wiki/Minimo
  5061. // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
  5062. 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
  5063. // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
  5064. 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
  5065. );
  5066. /**
  5067. * Utilities.
  5068. *
  5069. * @var array
  5070. */
  5071. protected static $utilities = array(
  5072. // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
  5073. // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
  5074. // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
  5075. // https://developers.facebook.com/docs/sharing/best-practices
  5076. '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',
  5077. 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
  5078. 'DesktopMode' => 'WPDesktop',
  5079. 'TV' => 'SonyDTV|HbbTV', // experimental
  5080. 'WebKit' => '(webkit)[ /]([\w.]+)',
  5081. // @todo: Include JXD consoles.
  5082. 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
  5083. 'Watch' => 'SM-V700',
  5084. );
  5085. /**
  5086. * All possible HTTP headers that represent the
  5087. * User-Agent string.
  5088. *
  5089. * @var array
  5090. */
  5091. protected static $uaHttpHeaders = array(
  5092. // The default User-Agent string.
  5093. 'HTTP_USER_AGENT',
  5094. // Header can occur on devices using Opera Mini.
  5095. 'HTTP_X_OPERAMINI_PHONE_UA',
  5096. // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
  5097. 'HTTP_X_DEVICE_USER_AGENT',
  5098. 'HTTP_X_ORIGINAL_USER_AGENT',
  5099. 'HTTP_X_SKYFIRE_PHONE',
  5100. 'HTTP_X_BOLT_PHONE_UA',
  5101. 'HTTP_DEVICE_STOCK_UA',
  5102. 'HTTP_X_UCBROWSER_DEVICE_UA'
  5103. );
  5104. /**
  5105. * The individual segments that could exist in a User-Agent string. VER refers to the regular
  5106. * expression defined in the constant self::VER.
  5107. *
  5108. * @var array
  5109. */
  5110. protected static $properties = array(
  5111. // Build
  5112. 'Mobile' => 'Mobile/[VER]',
  5113. 'Build' => 'Build/[VER]',
  5114. 'Version' => 'Version/[VER]',
  5115. 'VendorID' => 'VendorID/[VER]',
  5116. // Devices
  5117. 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
  5118. 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
  5119. 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
  5120. //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
  5121. 'Kindle' => 'Kindle/[VER]',
  5122. // Browser
  5123. 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
  5124. 'Coast' => array('Coast/[VER]'),
  5125. 'Dolfin' => 'Dolfin/[VER]',
  5126. // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
  5127. 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
  5128. 'Fennec' => 'Fennec/[VER]',
  5129. // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  5130. // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
  5131. 'Edge' => 'Edge/[VER]',
  5132. 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
  5133. // http://en.wikipedia.org/wiki/NetFront
  5134. 'NetFront' => 'NetFront/[VER]',
  5135. 'NokiaBrowser' => 'NokiaBrowser/[VER]',
  5136. 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
  5137. 'Opera Mini' => 'Opera Mini/[VER]',
  5138. 'Opera Mobi' => 'Version/[VER]',
  5139. 'UC Browser' => 'UC Browser[VER]',
  5140. 'MQQBrowser' => 'MQQBrowser/[VER]',
  5141. 'MicroMessenger' => 'MicroMessenger/[VER]',
  5142. 'baiduboxapp' => 'baiduboxapp/[VER]',
  5143. 'baidubrowser' => 'baidubrowser/[VER]',
  5144. 'SamsungBrowser' => 'SamsungBrowser/[VER]',
  5145. 'Iron' => 'Iron/[VER]',
  5146. // @note: Safari 7534.48.3 is actually Version 5.1.
  5147. // @note: On BlackBerry the Version is overwriten by the OS.
  5148. 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
  5149. 'Skyfire' => 'Skyfire/[VER]',
  5150. 'Tizen' => 'Tizen/[VER]',
  5151. 'Webkit' => 'webkit[ /][VER]',
  5152. 'PaleMoon' => 'PaleMoon/[VER]',
  5153. // Engine
  5154. 'Gecko' => 'Gecko/[VER]',
  5155. 'Trident' => 'Trident/[VER]',
  5156. 'Presto' => 'Presto/[VER]',
  5157. 'Goanna' => 'Goanna/[VER]',
  5158. // OS
  5159. 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
  5160. 'Android' => 'Android [VER]',
  5161. 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
  5162. 'BREW' => 'BREW [VER]',
  5163. 'Java' => 'Java/[VER]',
  5164. // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
  5165. // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
  5166. 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
  5167. 'Windows Phone' => 'Windows Phone [VER]',
  5168. 'Windows CE' => 'Windows CE/[VER]',
  5169. // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
  5170. 'Windows NT' => 'Windows NT [VER]',
  5171. 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
  5172. 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
  5173. );
  5174. /**
  5175. * Construct an instance of this class.
  5176. *
  5177. * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
  5178. * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
  5179. * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
  5180. * from the $headers array instead.
  5181. */
  5182. public function __construct(
  5183. array $headers = null,
  5184. $userAgent = null
  5185. ) {
  5186. $this->setHttpHeaders($headers);
  5187. $this->setUserAgent($userAgent);
  5188. }
  5189. /**
  5190. * Get the current script version.
  5191. * This is useful for the demo.php file,
  5192. * so people can check on what version they are testing
  5193. * for mobile devices.
  5194. *
  5195. * @return string The version number in semantic version format.
  5196. */
  5197. public static function getScriptVersion()
  5198. {
  5199. return self::VERSION;
  5200. }
  5201. /**
  5202. * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
  5203. *
  5204. * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
  5205. * the headers. The default null is left for backwards compatibility.
  5206. */
  5207. public function setHttpHeaders($httpHeaders = null)
  5208. {
  5209. // use global _SERVER if $httpHeaders aren't defined
  5210. if (!is_array($httpHeaders) || !count($httpHeaders)) {
  5211. $httpHeaders = $_SERVER;
  5212. }
  5213. // clear existing headers
  5214. $this->httpHeaders = array();
  5215. // Only save HTTP headers. In PHP land, that means only _SERVER vars that
  5216. // start with HTTP_.
  5217. foreach ($httpHeaders as $key => $value) {
  5218. if (substr($key, 0, 5) === 'HTTP_') {
  5219. $this->httpHeaders[$key] = $value;
  5220. }
  5221. }
  5222. // In case we're dealing with CloudFront, we need to know.
  5223. $this->setCfHeaders($httpHeaders);
  5224. }
  5225. /**
  5226. * Retrieves the HTTP headers.
  5227. *
  5228. * @return array
  5229. */
  5230. public function getHttpHeaders()
  5231. {
  5232. return $this->httpHeaders;
  5233. }
  5234. /**
  5235. * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
  5236. * Simply null is returned.
  5237. *
  5238. * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
  5239. * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
  5240. * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
  5241. *
  5242. * @return string|null The value of the header.
  5243. */
  5244. public function getHttpHeader($header)
  5245. {
  5246. // are we using PHP-flavored headers?
  5247. if (strpos($header, '_') === false) {
  5248. $header = str_replace('-', '_', $header);
  5249. $header = strtoupper($header);
  5250. }
  5251. // test the alternate, too
  5252. $altHeader = 'HTTP_' . $header;
  5253. //Test both the regular and the HTTP_ prefix
  5254. if (isset($this->httpHeaders[$header])) {
  5255. return $this->httpHeaders[$header];
  5256. } elseif (isset($this->httpHeaders[$altHeader])) {
  5257. return $this->httpHeaders[$altHeader];
  5258. }
  5259. return null;
  5260. }
  5261. public function getMobileHeaders()
  5262. {
  5263. return self::$mobileHeaders;
  5264. }
  5265. /**
  5266. * Get all possible HTTP headers that
  5267. * can contain the User-Agent string.
  5268. *
  5269. * @return array List of HTTP headers.
  5270. */
  5271. public function getUaHttpHeaders()
  5272. {
  5273. return self::$uaHttpHeaders;
  5274. }
  5275. /**
  5276. * Set CloudFront headers
  5277. * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
  5278. *
  5279. * @param array $cfHeaders List of HTTP headers
  5280. *
  5281. * @return boolean If there were CloudFront headers to be set
  5282. */
  5283. public function setCfHeaders($cfHeaders = null) {
  5284. // use global _SERVER if $cfHeaders aren't defined
  5285. if (!is_array($cfHeaders) || !count($cfHeaders)) {
  5286. $cfHeaders = $_SERVER;
  5287. }
  5288. // clear existing headers
  5289. $this->cloudfrontHeaders = array();
  5290. // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
  5291. // start with cloudfront-.
  5292. $response = false;
  5293. foreach ($cfHeaders as $key => $value) {
  5294. if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
  5295. $this->cloudfrontHeaders[strtoupper($key)] = $value;
  5296. $response = true;
  5297. }
  5298. }
  5299. return $response;
  5300. }
  5301. /**
  5302. * Retrieves the cloudfront headers.
  5303. *
  5304. * @return array
  5305. */
  5306. public function getCfHeaders()
  5307. {
  5308. return $this->cloudfrontHeaders;
  5309. }
  5310. /**
  5311. * Set the User-Agent to be used.
  5312. *
  5313. * @param string $userAgent The user agent string to set.
  5314. *
  5315. * @return string|null
  5316. */
  5317. public function setUserAgent($userAgent = null)
  5318. {
  5319. // Invalidate cache due to #375
  5320. $this->cache = array();
  5321. if (false === empty($userAgent)) {
  5322. return $this->userAgent = $userAgent;
  5323. } else {
  5324. $this->userAgent = null;
  5325. foreach ($this->getUaHttpHeaders() as $altHeader) {
  5326. if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
  5327. $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
  5328. }
  5329. }
  5330. if (!empty($this->userAgent)) {
  5331. return $this->userAgent = trim($this->userAgent);
  5332. }
  5333. }
  5334. if (count($this->getCfHeaders()) > 0) {
  5335. return $this->userAgent = 'Amazon CloudFront';
  5336. }
  5337. return $this->userAgent = null;
  5338. }
  5339. /**
  5340. * Retrieve the User-Agent.
  5341. *
  5342. * @return string|null The user agent if it's set.
  5343. */
  5344. public function getUserAgent()
  5345. {
  5346. return $this->userAgent;
  5347. }
  5348. /**
  5349. * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
  5350. * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
  5351. *
  5352. * @deprecated since version 2.6.9
  5353. *
  5354. * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
  5355. * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
  5356. */
  5357. public function setDetectionType($type = null)
  5358. {
  5359. if ($type === null) {
  5360. $type = self::DETECTION_TYPE_MOBILE;
  5361. }
  5362. if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
  5363. return;
  5364. }
  5365. $this->detectionType = $type;
  5366. }
  5367. public function getMatchingRegex()
  5368. {
  5369. return $this->matchingRegex;
  5370. }
  5371. public function getMatchesArray()
  5372. {
  5373. return $this->matchesArray;
  5374. }
  5375. /**
  5376. * Retrieve the list of known phone devices.
  5377. *
  5378. * @return array List of phone devices.
  5379. */
  5380. public static function getPhoneDevices()
  5381. {
  5382. return self::$phoneDevices;
  5383. }
  5384. /**
  5385. * Retrieve the list of known tablet devices.
  5386. *
  5387. * @return array List of tablet devices.
  5388. */
  5389. public static function getTabletDevices()
  5390. {
  5391. return self::$tabletDevices;
  5392. }
  5393. /**
  5394. * Alias for getBrowsers() method.
  5395. *
  5396. * @return array List of user agents.
  5397. */
  5398. public static function getUserAgents()
  5399. {
  5400. return self::getBrowsers();
  5401. }
  5402. /**
  5403. * Retrieve the list of known browsers. Specifically, the user agents.
  5404. *
  5405. * @return array List of browsers / user agents.
  5406. */
  5407. public static function getBrowsers()
  5408. {
  5409. return self::$browsers;
  5410. }
  5411. /**
  5412. * Retrieve the list of known utilities.
  5413. *
  5414. * @return array List of utilities.
  5415. */
  5416. public static function getUtilities()
  5417. {
  5418. return self::$utilities;
  5419. }
  5420. /**
  5421. * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
  5422. *
  5423. * @deprecated since version 2.6.9
  5424. *
  5425. * @return array All the rules (but not extended).
  5426. */
  5427. public static function getMobileDetectionRules()
  5428. {
  5429. static $rules;
  5430. if (!$rules) {
  5431. $rules = array_merge(
  5432. self::$phoneDevices,
  5433. self::$tabletDevices,
  5434. self::$operatingSystems,
  5435. self::$browsers
  5436. );
  5437. }
  5438. return $rules;
  5439. }
  5440. /**
  5441. * Method gets the mobile detection rules + utilities.
  5442. * The reason this is separate is because utilities rules
  5443. * don't necessary imply mobile. This method is used inside
  5444. * the new $detect->is('stuff') method.
  5445. *
  5446. * @deprecated since version 2.6.9
  5447. *
  5448. * @return array All the rules + extended.
  5449. */
  5450. public function getMobileDetectionRulesExtended()
  5451. {
  5452. static $rules;
  5453. if (!$rules) {
  5454. // Merge all rules together.
  5455. $rules = array_merge(
  5456. self::$phoneDevices,
  5457. self::$tabletDevices,
  5458. self::$operatingSystems,
  5459. self::$browsers,
  5460. self::$utilities
  5461. );
  5462. }
  5463. return $rules;
  5464. }
  5465. /**
  5466. * Retrieve the current set of rules.
  5467. *
  5468. * @deprecated since version 2.6.9
  5469. *
  5470. * @return array
  5471. */
  5472. public function getRules()
  5473. {
  5474. if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
  5475. return self::getMobileDetectionRulesExtended();
  5476. } else {
  5477. return self::getMobileDetectionRules();
  5478. }
  5479. }
  5480. /**
  5481. * Retrieve the list of mobile operating systems.
  5482. *
  5483. * @return array The list of mobile operating systems.
  5484. */
  5485. public static function getOperatingSystems()
  5486. {
  5487. return self::$operatingSystems;
  5488. }
  5489. /**
  5490. * Check the HTTP headers for signs of mobile.
  5491. * This is the fastest mobile check possible; it's used
  5492. * inside isMobile() method.
  5493. *
  5494. * @return bool
  5495. */
  5496. public function checkHttpHeadersForMobile()
  5497. {
  5498. foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
  5499. if (isset($this->httpHeaders[$mobileHeader])) {
  5500. if (is_array($matchType['matches'])) {
  5501. foreach ($matchType['matches'] as $_match) {
  5502. if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
  5503. return true;
  5504. }
  5505. }
  5506. return false;
  5507. } else {
  5508. return true;
  5509. }
  5510. }
  5511. }
  5512. return false;
  5513. }
  5514. /**
  5515. * Magic overloading method.
  5516. *
  5517. * @method boolean is[...]()
  5518. * @param string $name
  5519. * @param array $arguments
  5520. * @return mixed
  5521. * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
  5522. */
  5523. public function __call($name, $arguments)
  5524. {
  5525. // make sure the name starts with 'is', otherwise
  5526. if (substr($name, 0, 2) !== 'is') {
  5527. throw new BadMethodCallException("No such method exists: $name");
  5528. }
  5529. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5530. $key = substr($name, 2);
  5531. return $this->matchUAAgainstKey($key);
  5532. }
  5533. /**
  5534. * Find a detection rule that matches the current User-agent.
  5535. *
  5536. * @param null $userAgent deprecated
  5537. * @return boolean
  5538. */
  5539. protected function matchDetectionRulesAgainstUA($userAgent = null)
  5540. {
  5541. // Begin general search.
  5542. foreach ($this->getRules() as $_regex) {
  5543. if (empty($_regex)) {
  5544. continue;
  5545. }
  5546. if ($this->match($_regex, $userAgent)) {
  5547. return true;
  5548. }
  5549. }
  5550. return false;
  5551. }
  5552. /**
  5553. * Search for a certain key in the rules array.
  5554. * If the key is found then try to match the corresponding
  5555. * regex against the User-Agent.
  5556. *
  5557. * @param string $key
  5558. *
  5559. * @return boolean
  5560. */
  5561. protected function matchUAAgainstKey($key)
  5562. {
  5563. // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
  5564. $key = strtolower($key);
  5565. if (false === isset($this->cache[$key])) {
  5566. // change the keys to lower case
  5567. $_rules = array_change_key_case($this->getRules());
  5568. if (false === empty($_rules[$key])) {
  5569. $this->cache[$key] = $this->match($_rules[$key]);
  5570. }
  5571. if (false === isset($this->cache[$key])) {
  5572. $this->cache[$key] = false;
  5573. }
  5574. }
  5575. return $this->cache[$key];
  5576. }
  5577. /**
  5578. * Check if the device is mobile.
  5579. * Returns true if any type of mobile device detected, including special ones
  5580. * @param null $userAgent deprecated
  5581. * @param null $httpHeaders deprecated
  5582. * @return bool
  5583. */
  5584. public function isMobile($userAgent = null, $httpHeaders = null)
  5585. {
  5586. if ($httpHeaders) {
  5587. $this->setHttpHeaders($httpHeaders);
  5588. }
  5589. if ($userAgent) {
  5590. $this->setUserAgent($userAgent);
  5591. }
  5592. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  5593. if ($this->getUserAgent() === 'Amazon CloudFront') {
  5594. $cfHeaders = $this->getCfHeaders();
  5595. if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
  5596. return true;
  5597. }
  5598. }
  5599. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5600. if ($this->checkHttpHeadersForMobile()) {
  5601. return true;
  5602. } else {
  5603. return $this->matchDetectionRulesAgainstUA();
  5604. }
  5605. }
  5606. /**
  5607. * Check if the device is a tablet.
  5608. * Return true if any type of tablet device is detected.
  5609. *
  5610. * @param string $userAgent deprecated
  5611. * @param array $httpHeaders deprecated
  5612. * @return bool
  5613. */
  5614. public function isTablet($userAgent = null, $httpHeaders = null)
  5615. {
  5616. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  5617. if ($this->getUserAgent() === 'Amazon CloudFront') {
  5618. $cfHeaders = $this->getCfHeaders();
  5619. if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
  5620. return true;
  5621. }
  5622. }
  5623. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5624. foreach (self::$tabletDevices as $_regex) {
  5625. if ($this->match($_regex, $userAgent)) {
  5626. return true;
  5627. }
  5628. }
  5629. return false;
  5630. }
  5631. /**
  5632. * This method checks for a certain property in the
  5633. * userAgent.
  5634. * @todo: The httpHeaders part is not yet used.
  5635. *
  5636. * @param string $key
  5637. * @param string $userAgent deprecated
  5638. * @param string $httpHeaders deprecated
  5639. * @return bool|int|null
  5640. */
  5641. public function is($key, $userAgent = null, $httpHeaders = null)
  5642. {
  5643. // Set the UA and HTTP headers only if needed (eg. batch mode).
  5644. if ($httpHeaders) {
  5645. $this->setHttpHeaders($httpHeaders);
  5646. }
  5647. if ($userAgent) {
  5648. $this->setUserAgent($userAgent);
  5649. }
  5650. $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
  5651. return $this->matchUAAgainstKey($key);
  5652. }
  5653. /**
  5654. * Some detection rules are relative (not standard),
  5655. * because of the diversity of devices, vendors and
  5656. * their conventions in representing the User-Agent or
  5657. * the HTTP headers.
  5658. *
  5659. * This method will be used to check custom regexes against
  5660. * the User-Agent string.
  5661. *
  5662. * @param $regex
  5663. * @param string $userAgent
  5664. * @return bool
  5665. *
  5666. * @todo: search in the HTTP headers too.
  5667. */
  5668. public function match($regex, $userAgent = null)
  5669. {
  5670. $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
  5671. // If positive match is found, store the results for debug.
  5672. if ($match) {
  5673. $this->matchingRegex = $regex;
  5674. $this->matchesArray = $matches;
  5675. }
  5676. return $match;
  5677. }
  5678. /**
  5679. * Get the properties array.
  5680. *
  5681. * @return array
  5682. */
  5683. public static function getProperties()
  5684. {
  5685. return self::$properties;
  5686. }
  5687. /**
  5688. * Prepare the version number.
  5689. *
  5690. * @todo Remove the error supression from str_replace() call.
  5691. *
  5692. * @param string $ver The string version, like "2.6.21.2152";
  5693. *
  5694. * @return float
  5695. */
  5696. public function prepareVersionNo($ver)
  5697. {
  5698. $ver = str_replace(array('_', ' ', '/'), '.', $ver);
  5699. $arrVer = explode('.', $ver, 2);
  5700. if (isset($arrVer[1])) {
  5701. $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
  5702. }
  5703. return (float) implode('.', $arrVer);
  5704. }
  5705. /**
  5706. * Check the version of the given property in the User-Agent.
  5707. * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
  5708. *
  5709. * @param string $propertyName The name of the property. See self::getProperties() array
  5710. * keys for all possible properties.
  5711. * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
  5712. * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
  5713. * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
  5714. * invalid parameter will default to the this type as well.
  5715. *
  5716. * @return string|float The version of the property we are trying to extract.
  5717. */
  5718. public function version($propertyName, $type = self::VERSION_TYPE_STRING)
  5719. {
  5720. if (empty($propertyName)) {
  5721. return false;
  5722. }
  5723. // set the $type to the default if we don't recognize the type
  5724. if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
  5725. $type = self::VERSION_TYPE_STRING;
  5726. }
  5727. $properties = self::getProperties();
  5728. // Check if the property exists in the properties array.
  5729. if (true === isset($properties[$propertyName])) {
  5730. // Prepare the pattern to be matched.
  5731. // Make sure we always deal with an array (string is converted).
  5732. $properties[$propertyName] = (array) $properties[$propertyName];
  5733. foreach ($properties[$propertyName] as $propertyMatchString) {
  5734. $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
  5735. // Identify and extract the version.
  5736. preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
  5737. if (false === empty($match[1])) {
  5738. $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
  5739. return $version;
  5740. }
  5741. }
  5742. }
  5743. return false;
  5744. }
  5745. /**
  5746. * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
  5747. *
  5748. * @return string One of the self::MOBILE_GRADE_* constants.
  5749. */
  5750. public function mobileGrade()
  5751. {
  5752. $isMobile = $this->isMobile();
  5753. if (
  5754. // 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)
  5755. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  5756. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  5757. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  5758. // 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)
  5759. // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
  5760. // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
  5761. // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
  5762. ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
  5763. // 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)
  5764. $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
  5765. // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
  5766. $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
  5767. // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
  5768. $this->match('Playbook.*Tablet') ||
  5769. // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
  5770. ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
  5771. // Palm WebOS 3.0 - Tested on HP TouchPad
  5772. $this->match('hp.*TouchPad') ||
  5773. // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
  5774. ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
  5775. // Chrome for Android - Tested on Android 4.0, 4.1 device
  5776. ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
  5777. // Skyfire 4.1 - Tested on Android 2.3 device
  5778. ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  5779. // Opera Mobile 11.5-12: Tested on Android 2.3
  5780. ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
  5781. // Meego 1.2 - Tested on Nokia 950 and N9
  5782. $this->is('MeeGoOS') ||
  5783. // Tizen (pre-release) - Tested on early hardware
  5784. $this->is('Tizen') ||
  5785. // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
  5786. // @todo: more tests here!
  5787. $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
  5788. // UC Browser - Tested on Android 2.3 device
  5789. ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  5790. // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
  5791. ( $this->match('Kindle Fire') ||
  5792. $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
  5793. // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
  5794. $this->is('AndroidOS') && $this->is('NookTablet') ||
  5795. // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
  5796. $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
  5797. // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
  5798. $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
  5799. // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
  5800. $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
  5801. // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
  5802. $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
  5803. // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
  5804. $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
  5805. ){
  5806. return self::MOBILE_GRADE_A;
  5807. }
  5808. if (
  5809. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
  5810. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
  5811. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
  5812. // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
  5813. $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
  5814. //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
  5815. ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
  5816. ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
  5817. // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
  5818. $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
  5819. // @todo: report this (tested on Nokia N71)
  5820. $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
  5821. ){
  5822. return self::MOBILE_GRADE_B;
  5823. }
  5824. if (
  5825. // Blackberry 4.x - Tested on the Curve 8330
  5826. $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
  5827. // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
  5828. $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
  5829. // Tested on original iPhone (3.1), iPhone 3 (3.2)
  5830. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  5831. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  5832. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  5833. // Internet Explorer 7 and older - Tested on Windows XP
  5834. $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
  5835. ){
  5836. return self::MOBILE_GRADE_C;
  5837. }
  5838. // All older smartphone platforms and featurephones - Any device that doesn't support media queries
  5839. // will receive the basic, C grade experience.
  5840. return self::MOBILE_GRADE_C;
  5841. }
  5842. }
  5843. $mobileDetect = new Mobile_Detect;
  5844. $userDevice = ($mobileDetect->isMobile() ? ($mobileDetect->isTablet() ? 'tablet' : 'phone') : 'computer');
  5845. function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  5846. $path = getServerPath();
  5847. return '
  5848. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5849. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  5850. <head>
  5851. <!--[if gte mso 9]><xml>
  5852. <o:OfficeDocumentSettings>
  5853. <o:AllowPNG/>
  5854. <o:PixelsPerInch>96</o:PixelsPerInch>
  5855. </o:OfficeDocumentSettings>
  5856. </xml><![endif]-->
  5857. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5858. <meta name="viewport" content="width=device-width">
  5859. <!--[if !mso]><!-->
  5860. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5861. <!--<![endif]-->
  5862. <title></title>
  5863. <!--[if !mso]><!-- -->
  5864. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
  5865. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  5866. <!--<![endif]-->
  5867. <style type="text/css" id="media-query">
  5868. body {
  5869. margin: 0;
  5870. padding: 0;
  5871. }
  5872. table,
  5873. tr,
  5874. td {
  5875. vertical-align: top;
  5876. border-collapse: collapse;
  5877. }
  5878. .ie-browser table,
  5879. .mso-container table {
  5880. table-layout: fixed;
  5881. }
  5882. * {
  5883. line-height: inherit;
  5884. }
  5885. a[x-apple-data-detectors=true] {
  5886. color: inherit !important;
  5887. text-decoration: none !important;
  5888. }
  5889. [owa] .img-container div,
  5890. [owa] .img-container button {
  5891. display: block !important;
  5892. }
  5893. [owa] .fullwidth button {
  5894. width: 100% !important;
  5895. }
  5896. [owa] .block-grid .col {
  5897. display: table-cell;
  5898. float: none !important;
  5899. vertical-align: top;
  5900. }
  5901. .ie-browser .num12,
  5902. .ie-browser .block-grid,
  5903. [owa] .num12,
  5904. [owa] .block-grid {
  5905. width: 615px !important;
  5906. }
  5907. .ExternalClass,
  5908. .ExternalClass p,
  5909. .ExternalClass span,
  5910. .ExternalClass font,
  5911. .ExternalClass td,
  5912. .ExternalClass div {
  5913. line-height: 100%;
  5914. }
  5915. .ie-browser .mixed-two-up .num4,
  5916. [owa] .mixed-two-up .num4 {
  5917. width: 204px !important;
  5918. }
  5919. .ie-browser .mixed-two-up .num8,
  5920. [owa] .mixed-two-up .num8 {
  5921. width: 408px !important;
  5922. }
  5923. .ie-browser .block-grid.two-up .col,
  5924. [owa] .block-grid.two-up .col {
  5925. width: 307px !important;
  5926. }
  5927. .ie-browser .block-grid.three-up .col,
  5928. [owa] .block-grid.three-up .col {
  5929. width: 205px !important;
  5930. }
  5931. .ie-browser .block-grid.four-up .col,
  5932. [owa] .block-grid.four-up .col {
  5933. width: 153px !important;
  5934. }
  5935. .ie-browser .block-grid.five-up .col,
  5936. [owa] .block-grid.five-up .col {
  5937. width: 123px !important;
  5938. }
  5939. .ie-browser .block-grid.six-up .col,
  5940. [owa] .block-grid.six-up .col {
  5941. width: 102px !important;
  5942. }
  5943. .ie-browser .block-grid.seven-up .col,
  5944. [owa] .block-grid.seven-up .col {
  5945. width: 87px !important;
  5946. }
  5947. .ie-browser .block-grid.eight-up .col,
  5948. [owa] .block-grid.eight-up .col {
  5949. width: 76px !important;
  5950. }
  5951. .ie-browser .block-grid.nine-up .col,
  5952. [owa] .block-grid.nine-up .col {
  5953. width: 68px !important;
  5954. }
  5955. .ie-browser .block-grid.ten-up .col,
  5956. [owa] .block-grid.ten-up .col {
  5957. width: 61px !important;
  5958. }
  5959. .ie-browser .block-grid.eleven-up .col,
  5960. [owa] .block-grid.eleven-up .col {
  5961. width: 55px !important;
  5962. }
  5963. .ie-browser .block-grid.twelve-up .col,
  5964. [owa] .block-grid.twelve-up .col {
  5965. width: 51px !important;
  5966. }
  5967. @media only screen and (min-width: 635px) {
  5968. .block-grid {
  5969. width: 615px !important;
  5970. }
  5971. .block-grid .col {
  5972. display: table-cell;
  5973. Float: none !important;
  5974. vertical-align: top;
  5975. }
  5976. .block-grid .col.num12 {
  5977. width: 615px !important;
  5978. }
  5979. .block-grid.mixed-two-up .col.num4 {
  5980. width: 204px !important;
  5981. }
  5982. .block-grid.mixed-two-up .col.num8 {
  5983. width: 408px !important;
  5984. }
  5985. .block-grid.two-up .col {
  5986. width: 307px !important;
  5987. }
  5988. .block-grid.three-up .col {
  5989. width: 205px !important;
  5990. }
  5991. .block-grid.four-up .col {
  5992. width: 153px !important;
  5993. }
  5994. .block-grid.five-up .col {
  5995. width: 123px !important;
  5996. }
  5997. .block-grid.six-up .col {
  5998. width: 102px !important;
  5999. }
  6000. .block-grid.seven-up .col {
  6001. width: 87px !important;
  6002. }
  6003. .block-grid.eight-up .col {
  6004. width: 76px !important;
  6005. }
  6006. .block-grid.nine-up .col {
  6007. width: 68px !important;
  6008. }
  6009. .block-grid.ten-up .col {
  6010. width: 61px !important;
  6011. }
  6012. .block-grid.eleven-up .col {
  6013. width: 55px !important;
  6014. }
  6015. .block-grid.twelve-up .col {
  6016. width: 51px !important;
  6017. }
  6018. }
  6019. @media (max-width: 635px) {
  6020. .block-grid,
  6021. .col {
  6022. min-width: 320px !important;
  6023. max-width: 100% !important;
  6024. }
  6025. .block-grid {
  6026. width: calc(100% - 40px) !important;
  6027. }
  6028. .col {
  6029. width: 100% !important;
  6030. }
  6031. .col>div {
  6032. margin: 0 auto;
  6033. }
  6034. img.fullwidth {
  6035. max-width: 100% !important;
  6036. }
  6037. }
  6038. </style>
  6039. </head>
  6040. <body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #FFFFFF">
  6041. <!--[if IE]><div class="ie-browser"><![endif]-->
  6042. <!--[if mso]><div class="mso-container"><![endif]-->
  6043. <div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: #FFFFFF">
  6044. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #FFFFFF;"><![endif]-->
  6045. <div style="background-color:#333333;">
  6046. <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;"
  6047. class="block-grid ">
  6048. <div style="border-collapse: collapse;display: table;width: 100%;">
  6049. <!--[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]-->
  6050. <!--[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]-->
  6051. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6052. <div style="background-color: transparent; width: 100% !important;">
  6053. <!--[if (!mso)&(!IE)]><!-->
  6054. <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;">
  6055. <!--<![endif]-->
  6056. <div align="left" class="img-container left fullwidth" style="padding-right: 30px; padding-left: 30px;">
  6057. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px;" align="left"><![endif]-->
  6058. <img class="left fullwidth" align="left" border="0" src="'.$path.'images/organizr-logo-h.png" alt="Image" title="Image"
  6059. 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"
  6060. width="555">
  6061. <!--[if mso]></td></tr></table><![endif]-->
  6062. </div>
  6063. <!--[if (!mso)&(!IE)]><!-->
  6064. </div>
  6065. <!--<![endif]-->
  6066. </div>
  6067. </div>
  6068. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6069. </div>
  6070. </div>
  6071. </div>
  6072. <div style="background-color:#333333;">
  6073. <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;"
  6074. class="block-grid ">
  6075. <div style="border-collapse: collapse;display: table;width: 100%;">
  6076. <!--[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]-->
  6077. <!--[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]-->
  6078. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6079. <div style="background-color: transparent; width: 100% !important;">
  6080. <!--[if (!mso)&(!IE)]><!-->
  6081. <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;">
  6082. <!--<![endif]-->
  6083. <!--[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]-->
  6084. <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;">
  6085. <div style="font-size:12px;line-height:14px;color:#FFFFFF;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6086. <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>
  6087. </span>
  6088. </p>
  6089. </div>
  6090. </div>
  6091. <!--[if mso]></td></tr></table><![endif]-->
  6092. <!--[if (!mso)&(!IE)]><!-->
  6093. </div>
  6094. <!--<![endif]-->
  6095. </div>
  6096. </div>
  6097. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6098. </div>
  6099. </div>
  6100. </div>
  6101. <div style="background-color:#393939;">
  6102. <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;"
  6103. class="block-grid ">
  6104. <div style="border-collapse: collapse;display: table;width: 100%;">
  6105. <!--[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]-->
  6106. <!--[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]-->
  6107. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6108. <div style="background-color: transparent; width: 100% !important;">
  6109. <!--[if (!mso)&(!IE)]><!-->
  6110. <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;">
  6111. <!--<![endif]-->
  6112. <!--[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]-->
  6113. <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;">
  6114. <div style="font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6115. <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>
  6116. </div>
  6117. </div>
  6118. <!--[if mso]></td></tr></table><![endif]-->
  6119. <div style="padding-right: 5px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px;">
  6120. <!--[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]-->
  6121. <div align="center">
  6122. <div style="border-top: 2px solid #66D9EF; width:55%; line-height:2px; height:2px; font-size:2px;">&#160;</div>
  6123. </div>
  6124. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6125. </div>
  6126. <!--[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]-->
  6127. <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;">
  6128. <div style="font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6129. <p style="margin: 0;font-size: 12px;line-height: 14px"><span style="font-size: 28px; line-height: 33px;">Hey '.$user.',</span></p>
  6130. </div>
  6131. </div>
  6132. <!--[if mso]></td></tr></table><![endif]-->
  6133. <!--[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]-->
  6134. <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;">
  6135. <div style="font-size:12px;line-height:22px;font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;color:#FFFFFF;text-align:left;">
  6136. <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>
  6137. </span>
  6138. </p>
  6139. </div>
  6140. </div>
  6141. <!--[if mso]></td></tr></table><![endif]-->
  6142. <div align="center" class="button-container center" style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;">
  6143. <!--[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]-->
  6144. <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">
  6145. <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>
  6146. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6147. </div>
  6148. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6149. </div>
  6150. <!--[if (!mso)&(!IE)]><!-->
  6151. </div>
  6152. <!--<![endif]-->
  6153. </div>
  6154. </div>
  6155. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6156. </div>
  6157. </div>
  6158. </div>
  6159. <div style="background-color:#ffffff;">
  6160. <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;"
  6161. class="block-grid ">
  6162. <div style="border-collapse: collapse;display: table;width: 100%;">
  6163. <!--[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]-->
  6164. <!--[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]-->
  6165. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6166. <div style="background-color: transparent; width: 100% !important;">
  6167. <!--[if (!mso)&(!IE)]><!-->
  6168. <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;">
  6169. <!--<![endif]-->
  6170. <!--[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]-->
  6171. <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;">
  6172. <div style="font-size:12px;line-height:14px;color:#555555;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6173. <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>
  6174. </div>
  6175. </div>
  6176. <!--[if mso]></td></tr></table><![endif]-->
  6177. <div style="padding-right: 20px; padding-left: 20px; padding-top: 15px; padding-bottom: 20px;">
  6178. <!--[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]-->
  6179. <div align="center">
  6180. <div style="border-top: 3px solid #66D9EF; width:40%; line-height:3px; height:3px; font-size:3px;">&#160;</div>
  6181. </div>
  6182. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6183. </div>
  6184. <!--[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]-->
  6185. <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;">
  6186. <div style="font-size:12px;line-height:22px;color:#7E7D7D;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6187. <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>
  6188. </div>
  6189. </div>
  6190. <!--[if mso]></td></tr></table><![endif]-->
  6191. <!--[if (!mso)&(!IE)]><!-->
  6192. </div>
  6193. <!--<![endif]-->
  6194. </div>
  6195. </div>
  6196. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6197. </div>
  6198. </div>
  6199. </div>
  6200. <div style="background-color:#333333;">
  6201. <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;"
  6202. class="block-grid ">
  6203. <div style="border-collapse: collapse;display: table;width: 100%;">
  6204. <!--[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]-->
  6205. <!--[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]-->
  6206. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6207. <div style="background-color: transparent; width: 100% !important;">
  6208. <!--[if (!mso)&(!IE)]><!-->
  6209. <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;">
  6210. <!--<![endif]-->
  6211. <!--[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]-->
  6212. <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;">
  6213. <div style="font-size:12px;line-height:14px;color:#959595;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6214. <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"
  6215. href="https://github.com/causefx/Organizr" target="_blank" rel="noopener noreferrer">Organizr</a><strong><br></strong></p>
  6216. </div>
  6217. </div>
  6218. <!--[if mso]></td></tr></table><![endif]-->
  6219. <!--[if (!mso)&(!IE)]><!-->
  6220. </div>
  6221. <!--<![endif]-->
  6222. </div>
  6223. </div>
  6224. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6225. </div>
  6226. </div>
  6227. </div>
  6228. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  6229. </div>
  6230. <!--[if (mso)|(IE)]></div><![endif]-->
  6231. </body>
  6232. </html>
  6233. ';
  6234. }
  6235. function mimeTypes(){
  6236. return array(
  6237. '123' => 'application/vnd.lotus-1-2-3',
  6238. '3dml' => 'text/vnd.in3d.3dml',
  6239. '3ds' => 'image/x-3ds',
  6240. '3g2' => 'video/3gpp2',
  6241. '3gp' => 'video/3gpp',
  6242. '7z' => 'application/x-7z-compressed',
  6243. 'aab' => 'application/x-authorware-bin',
  6244. 'aac' => 'audio/x-aac',
  6245. 'aam' => 'application/x-authorware-map',
  6246. 'aas' => 'application/x-authorware-seg',
  6247. 'abw' => 'application/x-abiword',
  6248. 'ac' => 'application/pkix-attr-cert',
  6249. 'acc' => 'application/vnd.americandynamics.acc',
  6250. 'ace' => 'application/x-ace-compressed',
  6251. 'acu' => 'application/vnd.acucobol',
  6252. 'acutc' => 'application/vnd.acucorp',
  6253. 'adp' => 'audio/adpcm',
  6254. 'aep' => 'application/vnd.audiograph',
  6255. 'afm' => 'application/x-font-type1',
  6256. 'afp' => 'application/vnd.ibm.modcap',
  6257. 'ahead' => 'application/vnd.ahead.space',
  6258. 'ai' => 'application/postscript',
  6259. 'aif' => 'audio/x-aiff',
  6260. 'aifc' => 'audio/x-aiff',
  6261. 'aiff' => 'audio/x-aiff',
  6262. 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
  6263. 'ait' => 'application/vnd.dvb.ait',
  6264. 'ami' => 'application/vnd.amiga.ami',
  6265. 'apk' => 'application/vnd.android.package-archive',
  6266. 'appcache' => 'text/cache-manifest',
  6267. 'application' => 'application/x-ms-application',
  6268. 'apr' => 'application/vnd.lotus-approach',
  6269. 'arc' => 'application/x-freearc',
  6270. 'asc' => 'application/pgp-signature',
  6271. 'asf' => 'video/x-ms-asf',
  6272. 'asm' => 'text/x-asm',
  6273. 'aso' => 'application/vnd.accpac.simply.aso',
  6274. 'asx' => 'video/x-ms-asf',
  6275. 'atc' => 'application/vnd.acucorp',
  6276. 'atom' => 'application/atom+xml',
  6277. 'atomcat' => 'application/atomcat+xml',
  6278. 'atomsvc' => 'application/atomsvc+xml',
  6279. 'atx' => 'application/vnd.antix.game-component',
  6280. 'au' => 'audio/basic',
  6281. 'avi' => 'video/x-msvideo',
  6282. 'aw' => 'application/applixware',
  6283. 'azf' => 'application/vnd.airzip.filesecure.azf',
  6284. 'azs' => 'application/vnd.airzip.filesecure.azs',
  6285. 'azw' => 'application/vnd.amazon.ebook',
  6286. 'bat' => 'application/x-msdownload',
  6287. 'bcpio' => 'application/x-bcpio',
  6288. 'bdf' => 'application/x-font-bdf',
  6289. 'bdm' => 'application/vnd.syncml.dm+wbxml',
  6290. 'bed' => 'application/vnd.realvnc.bed',
  6291. 'bh2' => 'application/vnd.fujitsu.oasysprs',
  6292. 'bin' => 'application/octet-stream',
  6293. 'blb' => 'application/x-blorb',
  6294. 'blorb' => 'application/x-blorb',
  6295. 'bmi' => 'application/vnd.bmi',
  6296. 'bmp' => 'image/bmp',
  6297. 'book' => 'application/vnd.framemaker',
  6298. 'box' => 'application/vnd.previewsystems.box',
  6299. 'boz' => 'application/x-bzip2',
  6300. 'bpk' => 'application/octet-stream',
  6301. 'btif' => 'image/prs.btif',
  6302. 'bz' => 'application/x-bzip',
  6303. 'bz2' => 'application/x-bzip2',
  6304. 'c' => 'text/x-c',
  6305. 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
  6306. 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
  6307. 'c4d' => 'application/vnd.clonk.c4group',
  6308. 'c4f' => 'application/vnd.clonk.c4group',
  6309. 'c4g' => 'application/vnd.clonk.c4group',
  6310. 'c4p' => 'application/vnd.clonk.c4group',
  6311. 'c4u' => 'application/vnd.clonk.c4group',
  6312. 'cab' => 'application/vnd.ms-cab-compressed',
  6313. 'caf' => 'audio/x-caf',
  6314. 'cap' => 'application/vnd.tcpdump.pcap',
  6315. 'car' => 'application/vnd.curl.car',
  6316. 'cat' => 'application/vnd.ms-pki.seccat',
  6317. 'cb7' => 'application/x-cbr',
  6318. 'cba' => 'application/x-cbr',
  6319. 'cbr' => 'application/x-cbr',
  6320. 'cbt' => 'application/x-cbr',
  6321. 'cbz' => 'application/x-cbr',
  6322. 'cc' => 'text/x-c',
  6323. 'cct' => 'application/x-director',
  6324. 'ccxml' => 'application/ccxml+xml',
  6325. 'cdbcmsg' => 'application/vnd.contact.cmsg',
  6326. 'cdf' => 'application/x-netcdf',
  6327. 'cdkey' => 'application/vnd.mediastation.cdkey',
  6328. 'cdmia' => 'application/cdmi-capability',
  6329. 'cdmic' => 'application/cdmi-container',
  6330. 'cdmid' => 'application/cdmi-domain',
  6331. 'cdmio' => 'application/cdmi-object',
  6332. 'cdmiq' => 'application/cdmi-queue',
  6333. 'cdx' => 'chemical/x-cdx',
  6334. 'cdxml' => 'application/vnd.chemdraw+xml',
  6335. 'cdy' => 'application/vnd.cinderella',
  6336. 'cer' => 'application/pkix-cert',
  6337. 'cfs' => 'application/x-cfs-compressed',
  6338. 'cgm' => 'image/cgm',
  6339. 'chat' => 'application/x-chat',
  6340. 'chm' => 'application/vnd.ms-htmlhelp',
  6341. 'chrt' => 'application/vnd.kde.kchart',
  6342. 'cif' => 'chemical/x-cif',
  6343. 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
  6344. 'cil' => 'application/vnd.ms-artgalry',
  6345. 'cla' => 'application/vnd.claymore',
  6346. 'class' => 'application/java-vm',
  6347. 'clkk' => 'application/vnd.crick.clicker.keyboard',
  6348. 'clkp' => 'application/vnd.crick.clicker.palette',
  6349. 'clkt' => 'application/vnd.crick.clicker.template',
  6350. 'clkw' => 'application/vnd.crick.clicker.wordbank',
  6351. 'clkx' => 'application/vnd.crick.clicker',
  6352. 'clp' => 'application/x-msclip',
  6353. 'cmc' => 'application/vnd.cosmocaller',
  6354. 'cmdf' => 'chemical/x-cmdf',
  6355. 'cml' => 'chemical/x-cml',
  6356. 'cmp' => 'application/vnd.yellowriver-custom-menu',
  6357. 'cmx' => 'image/x-cmx',
  6358. 'cod' => 'application/vnd.rim.cod',
  6359. 'com' => 'application/x-msdownload',
  6360. 'conf' => 'text/plain',
  6361. 'cpio' => 'application/x-cpio',
  6362. 'cpp' => 'text/x-c',
  6363. 'cpt' => 'application/mac-compactpro',
  6364. 'crd' => 'application/x-mscardfile',
  6365. 'crl' => 'application/pkix-crl',
  6366. 'crt' => 'application/x-x509-ca-cert',
  6367. 'cryptonote' => 'application/vnd.rig.cryptonote',
  6368. 'csh' => 'application/x-csh',
  6369. 'csml' => 'chemical/x-csml',
  6370. 'csp' => 'application/vnd.commonspace',
  6371. 'css' => 'text/css',
  6372. 'cst' => 'application/x-director',
  6373. 'csv' => 'text/csv',
  6374. 'cu' => 'application/cu-seeme',
  6375. 'curl' => 'text/vnd.curl',
  6376. 'cww' => 'application/prs.cww',
  6377. 'cxt' => 'application/x-director',
  6378. 'cxx' => 'text/x-c',
  6379. 'dae' => 'model/vnd.collada+xml',
  6380. 'daf' => 'application/vnd.mobius.daf',
  6381. 'dart' => 'application/vnd.dart',
  6382. 'dataless' => 'application/vnd.fdsn.seed',
  6383. 'davmount' => 'application/davmount+xml',
  6384. 'dbk' => 'application/docbook+xml',
  6385. 'dcr' => 'application/x-director',
  6386. 'dcurl' => 'text/vnd.curl.dcurl',
  6387. 'dd2' => 'application/vnd.oma.dd2+xml',
  6388. 'ddd' => 'application/vnd.fujixerox.ddd',
  6389. 'deb' => 'application/x-debian-package',
  6390. 'def' => 'text/plain',
  6391. 'deploy' => 'application/octet-stream',
  6392. 'der' => 'application/x-x509-ca-cert',
  6393. 'dfac' => 'application/vnd.dreamfactory',
  6394. 'dgc' => 'application/x-dgc-compressed',
  6395. 'dic' => 'text/x-c',
  6396. 'dir' => 'application/x-director',
  6397. 'dis' => 'application/vnd.mobius.dis',
  6398. 'dist' => 'application/octet-stream',
  6399. 'distz' => 'application/octet-stream',
  6400. 'djv' => 'image/vnd.djvu',
  6401. 'djvu' => 'image/vnd.djvu',
  6402. 'dll' => 'application/x-msdownload',
  6403. 'dmg' => 'application/x-apple-diskimage',
  6404. 'dmp' => 'application/vnd.tcpdump.pcap',
  6405. 'dms' => 'application/octet-stream',
  6406. 'dna' => 'application/vnd.dna',
  6407. 'doc' => 'application/msword',
  6408. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  6409. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  6410. 'dot' => 'application/msword',
  6411. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  6412. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  6413. 'dp' => 'application/vnd.osgi.dp',
  6414. 'dpg' => 'application/vnd.dpgraph',
  6415. 'dra' => 'audio/vnd.dra',
  6416. 'dsc' => 'text/prs.lines.tag',
  6417. 'dssc' => 'application/dssc+der',
  6418. 'dtb' => 'application/x-dtbook+xml',
  6419. 'dtd' => 'application/xml-dtd',
  6420. 'dts' => 'audio/vnd.dts',
  6421. 'dtshd' => 'audio/vnd.dts.hd',
  6422. 'dump' => 'application/octet-stream',
  6423. 'dvb' => 'video/vnd.dvb.file',
  6424. 'dvi' => 'application/x-dvi',
  6425. 'dwf' => 'model/vnd.dwf',
  6426. 'dwg' => 'image/vnd.dwg',
  6427. 'dxf' => 'image/vnd.dxf',
  6428. 'dxp' => 'application/vnd.spotfire.dxp',
  6429. 'dxr' => 'application/x-director',
  6430. 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
  6431. 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
  6432. 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
  6433. 'ecma' => 'application/ecmascript',
  6434. 'edm' => 'application/vnd.novadigm.edm',
  6435. 'edx' => 'application/vnd.novadigm.edx',
  6436. 'efif' => 'application/vnd.picsel',
  6437. 'ei6' => 'application/vnd.pg.osasli',
  6438. 'elc' => 'application/octet-stream',
  6439. 'emf' => 'application/x-msmetafile',
  6440. 'eml' => 'message/rfc822',
  6441. 'emma' => 'application/emma+xml',
  6442. 'emz' => 'application/x-msmetafile',
  6443. 'eol' => 'audio/vnd.digital-winds',
  6444. 'eot' => 'application/vnd.ms-fontobject',
  6445. 'eps' => 'application/postscript',
  6446. 'epub' => 'application/epub+zip',
  6447. 'es3' => 'application/vnd.eszigno3+xml',
  6448. 'esa' => 'application/vnd.osgi.subsystem',
  6449. 'esf' => 'application/vnd.epson.esf',
  6450. 'et3' => 'application/vnd.eszigno3+xml',
  6451. 'etx' => 'text/x-setext',
  6452. 'eva' => 'application/x-eva',
  6453. 'evy' => 'application/x-envoy',
  6454. 'exe' => 'application/x-msdownload',
  6455. 'exi' => 'application/exi',
  6456. 'ext' => 'application/vnd.novadigm.ext',
  6457. 'ez' => 'application/andrew-inset',
  6458. 'ez2' => 'application/vnd.ezpix-album',
  6459. 'ez3' => 'application/vnd.ezpix-package',
  6460. 'f' => 'text/x-fortran',
  6461. 'f4v' => 'video/x-f4v',
  6462. 'f77' => 'text/x-fortran',
  6463. 'f90' => 'text/x-fortran',
  6464. 'fbs' => 'image/vnd.fastbidsheet',
  6465. 'fcdt' => 'application/vnd.adobe.formscentral.fcdt',
  6466. 'fcs' => 'application/vnd.isac.fcs',
  6467. 'fdf' => 'application/vnd.fdf',
  6468. 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
  6469. 'fg5' => 'application/vnd.fujitsu.oasysgp',
  6470. 'fgd' => 'application/x-director',
  6471. 'fh' => 'image/x-freehand',
  6472. 'fh4' => 'image/x-freehand',
  6473. 'fh5' => 'image/x-freehand',
  6474. 'fh7' => 'image/x-freehand',
  6475. 'fhc' => 'image/x-freehand',
  6476. 'fig' => 'application/x-xfig',
  6477. 'flac' => 'audio/x-flac',
  6478. 'fli' => 'video/x-fli',
  6479. 'flo' => 'application/vnd.micrografx.flo',
  6480. 'flv' => 'video/x-flv',
  6481. 'flw' => 'application/vnd.kde.kivio',
  6482. 'flx' => 'text/vnd.fmi.flexstor',
  6483. 'fly' => 'text/vnd.fly',
  6484. 'fm' => 'application/vnd.framemaker',
  6485. 'fnc' => 'application/vnd.frogans.fnc',
  6486. 'for' => 'text/x-fortran',
  6487. 'fpx' => 'image/vnd.fpx',
  6488. 'frame' => 'application/vnd.framemaker',
  6489. 'fsc' => 'application/vnd.fsc.weblaunch',
  6490. 'fst' => 'image/vnd.fst',
  6491. 'ftc' => 'application/vnd.fluxtime.clip',
  6492. 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
  6493. 'fvt' => 'video/vnd.fvt',
  6494. 'fxp' => 'application/vnd.adobe.fxp',
  6495. 'fxpl' => 'application/vnd.adobe.fxp',
  6496. 'fzs' => 'application/vnd.fuzzysheet',
  6497. 'g2w' => 'application/vnd.geoplan',
  6498. 'g3' => 'image/g3fax',
  6499. 'g3w' => 'application/vnd.geospace',
  6500. 'gac' => 'application/vnd.groove-account',
  6501. 'gam' => 'application/x-tads',
  6502. 'gbr' => 'application/rpki-ghostbusters',
  6503. 'gca' => 'application/x-gca-compressed',
  6504. 'gdl' => 'model/vnd.gdl',
  6505. 'geo' => 'application/vnd.dynageo',
  6506. 'gex' => 'application/vnd.geometry-explorer',
  6507. 'ggb' => 'application/vnd.geogebra.file',
  6508. 'ggt' => 'application/vnd.geogebra.tool',
  6509. 'ghf' => 'application/vnd.groove-help',
  6510. 'gif' => 'image/gif',
  6511. 'gim' => 'application/vnd.groove-identity-message',
  6512. 'gml' => 'application/gml+xml',
  6513. 'gmx' => 'application/vnd.gmx',
  6514. 'gnumeric' => 'application/x-gnumeric',
  6515. 'gph' => 'application/vnd.flographit',
  6516. 'gpx' => 'application/gpx+xml',
  6517. 'gqf' => 'application/vnd.grafeq',
  6518. 'gqs' => 'application/vnd.grafeq',
  6519. 'gram' => 'application/srgs',
  6520. 'gramps' => 'application/x-gramps-xml',
  6521. 'gre' => 'application/vnd.geometry-explorer',
  6522. 'grv' => 'application/vnd.groove-injector',
  6523. 'grxml' => 'application/srgs+xml',
  6524. 'gsf' => 'application/x-font-ghostscript',
  6525. 'gtar' => 'application/x-gtar',
  6526. 'gtm' => 'application/vnd.groove-tool-message',
  6527. 'gtw' => 'model/vnd.gtw',
  6528. 'gv' => 'text/vnd.graphviz',
  6529. 'gxf' => 'application/gxf',
  6530. 'gxt' => 'application/vnd.geonext',
  6531. 'h' => 'text/x-c',
  6532. 'h261' => 'video/h261',
  6533. 'h263' => 'video/h263',
  6534. 'h264' => 'video/h264',
  6535. 'hal' => 'application/vnd.hal+xml',
  6536. 'hbci' => 'application/vnd.hbci',
  6537. 'hdf' => 'application/x-hdf',
  6538. 'hh' => 'text/x-c',
  6539. 'hlp' => 'application/winhlp',
  6540. 'hpgl' => 'application/vnd.hp-hpgl',
  6541. 'hpid' => 'application/vnd.hp-hpid',
  6542. 'hps' => 'application/vnd.hp-hps',
  6543. 'hqx' => 'application/mac-binhex40',
  6544. 'htke' => 'application/vnd.kenameaapp',
  6545. 'htm' => 'text/html',
  6546. 'html' => 'text/html',
  6547. 'hvd' => 'application/vnd.yamaha.hv-dic',
  6548. 'hvp' => 'application/vnd.yamaha.hv-voice',
  6549. 'hvs' => 'application/vnd.yamaha.hv-script',
  6550. 'i2g' => 'application/vnd.intergeo',
  6551. 'icc' => 'application/vnd.iccprofile',
  6552. 'ice' => 'x-conference/x-cooltalk',
  6553. 'icm' => 'application/vnd.iccprofile',
  6554. 'ico' => 'image/x-icon',
  6555. 'ics' => 'text/calendar',
  6556. 'ief' => 'image/ief',
  6557. 'ifb' => 'text/calendar',
  6558. 'ifm' => 'application/vnd.shana.informed.formdata',
  6559. 'iges' => 'model/iges',
  6560. 'igl' => 'application/vnd.igloader',
  6561. 'igm' => 'application/vnd.insors.igm',
  6562. 'igs' => 'model/iges',
  6563. 'igx' => 'application/vnd.micrografx.igx',
  6564. 'iif' => 'application/vnd.shana.informed.interchange',
  6565. 'imp' => 'application/vnd.accpac.simply.imp',
  6566. 'ims' => 'application/vnd.ms-ims',
  6567. 'in' => 'text/plain',
  6568. 'ink' => 'application/inkml+xml',
  6569. 'inkml' => 'application/inkml+xml',
  6570. 'install' => 'application/x-install-instructions',
  6571. 'iota' => 'application/vnd.astraea-software.iota',
  6572. 'ipfix' => 'application/ipfix',
  6573. 'ipk' => 'application/vnd.shana.informed.package',
  6574. 'irm' => 'application/vnd.ibm.rights-management',
  6575. 'irp' => 'application/vnd.irepository.package+xml',
  6576. 'iso' => 'application/x-iso9660-image',
  6577. 'itp' => 'application/vnd.shana.informed.formtemplate',
  6578. 'ivp' => 'application/vnd.immervision-ivp',
  6579. 'ivu' => 'application/vnd.immervision-ivu',
  6580. 'jad' => 'text/vnd.sun.j2me.app-descriptor',
  6581. 'jam' => 'application/vnd.jam',
  6582. 'jar' => 'application/java-archive',
  6583. 'java' => 'text/x-java-source',
  6584. 'jisp' => 'application/vnd.jisp',
  6585. 'jlt' => 'application/vnd.hp-jlyt',
  6586. 'jnlp' => 'application/x-java-jnlp-file',
  6587. 'joda' => 'application/vnd.joost.joda-archive',
  6588. 'jpe' => 'image/jpeg',
  6589. 'jpeg' => 'image/jpeg',
  6590. 'jpg' => 'image/jpeg',
  6591. 'jpgm' => 'video/jpm',
  6592. 'jpgv' => 'video/jpeg',
  6593. 'jpm' => 'video/jpm',
  6594. 'js' => 'application/javascript',
  6595. 'json' => 'application/json',
  6596. 'jsonml' => 'application/jsonml+json',
  6597. 'kar' => 'audio/midi',
  6598. 'karbon' => 'application/vnd.kde.karbon',
  6599. 'kfo' => 'application/vnd.kde.kformula',
  6600. 'kia' => 'application/vnd.kidspiration',
  6601. 'kml' => 'application/vnd.google-earth.kml+xml',
  6602. 'kmz' => 'application/vnd.google-earth.kmz',
  6603. 'kne' => 'application/vnd.kinar',
  6604. 'knp' => 'application/vnd.kinar',
  6605. 'kon' => 'application/vnd.kde.kontour',
  6606. 'kpr' => 'application/vnd.kde.kpresenter',
  6607. 'kpt' => 'application/vnd.kde.kpresenter',
  6608. 'kpxx' => 'application/vnd.ds-keypoint',
  6609. 'ksp' => 'application/vnd.kde.kspread',
  6610. 'ktr' => 'application/vnd.kahootz',
  6611. 'ktx' => 'image/ktx',
  6612. 'ktz' => 'application/vnd.kahootz',
  6613. 'kwd' => 'application/vnd.kde.kword',
  6614. 'kwt' => 'application/vnd.kde.kword',
  6615. 'lasxml' => 'application/vnd.las.las+xml',
  6616. 'latex' => 'application/x-latex',
  6617. 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  6618. 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  6619. 'les' => 'application/vnd.hhe.lesson-player',
  6620. 'lha' => 'application/x-lzh-compressed',
  6621. 'link66' => 'application/vnd.route66.link66+xml',
  6622. 'list' => 'text/plain',
  6623. 'list3820' => 'application/vnd.ibm.modcap',
  6624. 'listafp' => 'application/vnd.ibm.modcap',
  6625. 'lnk' => 'application/x-ms-shortcut',
  6626. 'log' => 'text/plain',
  6627. 'lostxml' => 'application/lost+xml',
  6628. 'lrf' => 'application/octet-stream',
  6629. 'lrm' => 'application/vnd.ms-lrm',
  6630. 'ltf' => 'application/vnd.frogans.ltf',
  6631. 'lvp' => 'audio/vnd.lucent.voice',
  6632. 'lwp' => 'application/vnd.lotus-wordpro',
  6633. 'lzh' => 'application/x-lzh-compressed',
  6634. 'm13' => 'application/x-msmediaview',
  6635. 'm14' => 'application/x-msmediaview',
  6636. 'm1v' => 'video/mpeg',
  6637. 'm21' => 'application/mp21',
  6638. 'm2a' => 'audio/mpeg',
  6639. 'm2v' => 'video/mpeg',
  6640. 'm3a' => 'audio/mpeg',
  6641. 'm3u' => 'audio/x-mpegurl',
  6642. 'm3u8' => 'application/vnd.apple.mpegurl',
  6643. 'm4a' => 'audio/mp4',
  6644. 'm4u' => 'video/vnd.mpegurl',
  6645. 'm4v' => 'video/x-m4v',
  6646. 'ma' => 'application/mathematica',
  6647. 'mads' => 'application/mads+xml',
  6648. 'mag' => 'application/vnd.ecowin.chart',
  6649. 'maker' => 'application/vnd.framemaker',
  6650. 'man' => 'text/troff',
  6651. 'mar' => 'application/octet-stream',
  6652. 'mathml' => 'application/mathml+xml',
  6653. 'mb' => 'application/mathematica',
  6654. 'mbk' => 'application/vnd.mobius.mbk',
  6655. 'mbox' => 'application/mbox',
  6656. 'mc1' => 'application/vnd.medcalcdata',
  6657. 'mcd' => 'application/vnd.mcd',
  6658. 'mcurl' => 'text/vnd.curl.mcurl',
  6659. 'mdb' => 'application/x-msaccess',
  6660. 'mdi' => 'image/vnd.ms-modi',
  6661. 'me' => 'text/troff',
  6662. 'mesh' => 'model/mesh',
  6663. 'meta4' => 'application/metalink4+xml',
  6664. 'metalink' => 'application/metalink+xml',
  6665. 'mets' => 'application/mets+xml',
  6666. 'mfm' => 'application/vnd.mfmp',
  6667. 'mft' => 'application/rpki-manifest',
  6668. 'mgp' => 'application/vnd.osgeo.mapguide.package',
  6669. 'mgz' => 'application/vnd.proteus.magazine',
  6670. 'mid' => 'audio/midi',
  6671. 'midi' => 'audio/midi',
  6672. 'mie' => 'application/x-mie',
  6673. 'mif' => 'application/vnd.mif',
  6674. 'mime' => 'message/rfc822',
  6675. 'mj2' => 'video/mj2',
  6676. 'mjp2' => 'video/mj2',
  6677. 'mk3d' => 'video/x-matroska',
  6678. 'mka' => 'audio/x-matroska',
  6679. 'mks' => 'video/x-matroska',
  6680. 'mkv' => 'video/x-matroska',
  6681. 'mlp' => 'application/vnd.dolby.mlp',
  6682. 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
  6683. 'mmf' => 'application/vnd.smaf',
  6684. 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
  6685. 'mng' => 'video/x-mng',
  6686. 'mny' => 'application/x-msmoney',
  6687. 'mobi' => 'application/x-mobipocket-ebook',
  6688. 'mods' => 'application/mods+xml',
  6689. 'mov' => 'video/quicktime',
  6690. 'movie' => 'video/x-sgi-movie',
  6691. 'mp2' => 'audio/mpeg',
  6692. 'mp21' => 'application/mp21',
  6693. 'mp2a' => 'audio/mpeg',
  6694. 'mp3' => 'audio/mpeg',
  6695. 'mp4' => 'video/mp4',
  6696. 'mp4a' => 'audio/mp4',
  6697. 'mp4s' => 'application/mp4',
  6698. 'mp4v' => 'video/mp4',
  6699. 'mpc' => 'application/vnd.mophun.certificate',
  6700. 'mpe' => 'video/mpeg',
  6701. 'mpeg' => 'video/mpeg',
  6702. 'mpg' => 'video/mpeg',
  6703. 'mpg4' => 'video/mp4',
  6704. 'mpga' => 'audio/mpeg',
  6705. 'mpkg' => 'application/vnd.apple.installer+xml',
  6706. 'mpm' => 'application/vnd.blueice.multipass',
  6707. 'mpn' => 'application/vnd.mophun.application',
  6708. 'mpp' => 'application/vnd.ms-project',
  6709. 'mpt' => 'application/vnd.ms-project',
  6710. 'mpy' => 'application/vnd.ibm.minipay',
  6711. 'mqy' => 'application/vnd.mobius.mqy',
  6712. 'mrc' => 'application/marc',
  6713. 'mrcx' => 'application/marcxml+xml',
  6714. 'ms' => 'text/troff',
  6715. 'mscml' => 'application/mediaservercontrol+xml',
  6716. 'mseed' => 'application/vnd.fdsn.mseed',
  6717. 'mseq' => 'application/vnd.mseq',
  6718. 'msf' => 'application/vnd.epson.msf',
  6719. 'msh' => 'model/mesh',
  6720. 'msi' => 'application/x-msdownload',
  6721. 'msl' => 'application/vnd.mobius.msl',
  6722. 'msty' => 'application/vnd.muvee.style',
  6723. 'mts' => 'model/vnd.mts',
  6724. 'mus' => 'application/vnd.musician',
  6725. 'musicxml' => 'application/vnd.recordare.musicxml+xml',
  6726. 'mvb' => 'application/x-msmediaview',
  6727. 'mwf' => 'application/vnd.mfer',
  6728. 'mxf' => 'application/mxf',
  6729. 'mxl' => 'application/vnd.recordare.musicxml',
  6730. 'mxml' => 'application/xv+xml',
  6731. 'mxs' => 'application/vnd.triscape.mxs',
  6732. 'mxu' => 'video/vnd.mpegurl',
  6733. 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  6734. 'n3' => 'text/n3',
  6735. 'nb' => 'application/mathematica',
  6736. 'nbp' => 'application/vnd.wolfram.player',
  6737. 'nc' => 'application/x-netcdf',
  6738. 'ncx' => 'application/x-dtbncx+xml',
  6739. 'nfo' => 'text/x-nfo',
  6740. 'ngdat' => 'application/vnd.nokia.n-gage.data',
  6741. 'nitf' => 'application/vnd.nitf',
  6742. 'nlu' => 'application/vnd.neurolanguage.nlu',
  6743. 'nml' => 'application/vnd.enliven',
  6744. 'nnd' => 'application/vnd.noblenet-directory',
  6745. 'nns' => 'application/vnd.noblenet-sealer',
  6746. 'nnw' => 'application/vnd.noblenet-web',
  6747. 'npx' => 'image/vnd.net-fpx',
  6748. 'nsc' => 'application/x-conference',
  6749. 'nsf' => 'application/vnd.lotus-notes',
  6750. 'ntf' => 'application/vnd.nitf',
  6751. 'nzb' => 'application/x-nzb',
  6752. 'oa2' => 'application/vnd.fujitsu.oasys2',
  6753. 'oa3' => 'application/vnd.fujitsu.oasys3',
  6754. 'oas' => 'application/vnd.fujitsu.oasys',
  6755. 'obd' => 'application/x-msbinder',
  6756. 'obj' => 'application/x-tgif',
  6757. 'oda' => 'application/oda',
  6758. 'odb' => 'application/vnd.oasis.opendocument.database',
  6759. 'odc' => 'application/vnd.oasis.opendocument.chart',
  6760. 'odf' => 'application/vnd.oasis.opendocument.formula',
  6761. 'odft' => 'application/vnd.oasis.opendocument.formula-template',
  6762. 'odg' => 'application/vnd.oasis.opendocument.graphics',
  6763. 'odi' => 'application/vnd.oasis.opendocument.image',
  6764. 'odm' => 'application/vnd.oasis.opendocument.text-master',
  6765. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  6766. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  6767. 'odt' => 'application/vnd.oasis.opendocument.text',
  6768. 'oga' => 'audio/ogg',
  6769. 'ogg' => 'audio/ogg',
  6770. 'ogv' => 'video/ogg',
  6771. 'ogx' => 'application/ogg',
  6772. 'omdoc' => 'application/omdoc+xml',
  6773. 'onepkg' => 'application/onenote',
  6774. 'onetmp' => 'application/onenote',
  6775. 'onetoc' => 'application/onenote',
  6776. 'onetoc2' => 'application/onenote',
  6777. 'opf' => 'application/oebps-package+xml',
  6778. 'opml' => 'text/x-opml',
  6779. 'oprc' => 'application/vnd.palm',
  6780. 'org' => 'application/vnd.lotus-organizer',
  6781. 'osf' => 'application/vnd.yamaha.openscoreformat',
  6782. 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  6783. 'otc' => 'application/vnd.oasis.opendocument.chart-template',
  6784. 'otf' => 'application/x-font-otf',
  6785. 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
  6786. 'oth' => 'application/vnd.oasis.opendocument.text-web',
  6787. 'oti' => 'application/vnd.oasis.opendocument.image-template',
  6788. 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
  6789. 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  6790. 'ott' => 'application/vnd.oasis.opendocument.text-template',
  6791. 'oxps' => 'application/oxps',
  6792. 'oxt' => 'application/vnd.openofficeorg.extension',
  6793. 'p' => 'text/x-pascal',
  6794. 'p10' => 'application/pkcs10',
  6795. 'p12' => 'application/x-pkcs12',
  6796. 'p7b' => 'application/x-pkcs7-certificates',
  6797. 'p7c' => 'application/pkcs7-mime',
  6798. 'p7m' => 'application/pkcs7-mime',
  6799. 'p7r' => 'application/x-pkcs7-certreqresp',
  6800. 'p7s' => 'application/pkcs7-signature',
  6801. 'p8' => 'application/pkcs8',
  6802. 'pas' => 'text/x-pascal',
  6803. 'paw' => 'application/vnd.pawaafile',
  6804. 'pbd' => 'application/vnd.powerbuilder6',
  6805. 'pbm' => 'image/x-portable-bitmap',
  6806. 'pcap' => 'application/vnd.tcpdump.pcap',
  6807. 'pcf' => 'application/x-font-pcf',
  6808. 'pcl' => 'application/vnd.hp-pcl',
  6809. 'pclxl' => 'application/vnd.hp-pclxl',
  6810. 'pct' => 'image/x-pict',
  6811. 'pcurl' => 'application/vnd.curl.pcurl',
  6812. 'pcx' => 'image/x-pcx',
  6813. 'pdb' => 'application/vnd.palm',
  6814. 'pdf' => 'application/pdf',
  6815. 'pfa' => 'application/x-font-type1',
  6816. 'pfb' => 'application/x-font-type1',
  6817. 'pfm' => 'application/x-font-type1',
  6818. 'pfr' => 'application/font-tdpfr',
  6819. 'pfx' => 'application/x-pkcs12',
  6820. 'pgm' => 'image/x-portable-graymap',
  6821. 'pgn' => 'application/x-chess-pgn',
  6822. 'pgp' => 'application/pgp-encrypted',
  6823. 'pic' => 'image/x-pict',
  6824. 'pkg' => 'application/octet-stream',
  6825. 'pki' => 'application/pkixcmp',
  6826. 'pkipath' => 'application/pkix-pkipath',
  6827. 'plb' => 'application/vnd.3gpp.pic-bw-large',
  6828. 'plc' => 'application/vnd.mobius.plc',
  6829. 'plf' => 'application/vnd.pocketlearn',
  6830. 'pls' => 'application/pls+xml',
  6831. 'pml' => 'application/vnd.ctc-posml',
  6832. 'png' => 'image/png',
  6833. 'pnm' => 'image/x-portable-anymap',
  6834. 'portpkg' => 'application/vnd.macports.portpkg',
  6835. 'pot' => 'application/vnd.ms-powerpoint',
  6836. 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
  6837. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  6838. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  6839. 'ppd' => 'application/vnd.cups-ppd',
  6840. 'ppm' => 'image/x-portable-pixmap',
  6841. 'pps' => 'application/vnd.ms-powerpoint',
  6842. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  6843. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  6844. 'ppt' => 'application/vnd.ms-powerpoint',
  6845. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  6846. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  6847. 'pqa' => 'application/vnd.palm',
  6848. 'prc' => 'application/x-mobipocket-ebook',
  6849. 'pre' => 'application/vnd.lotus-freelance',
  6850. 'prf' => 'application/pics-rules',
  6851. 'ps' => 'application/postscript',
  6852. 'psb' => 'application/vnd.3gpp.pic-bw-small',
  6853. 'psd' => 'image/vnd.adobe.photoshop',
  6854. 'psf' => 'application/x-font-linux-psf',
  6855. 'pskcxml' => 'application/pskc+xml',
  6856. 'ptid' => 'application/vnd.pvi.ptid1',
  6857. 'pub' => 'application/x-mspublisher',
  6858. 'pvb' => 'application/vnd.3gpp.pic-bw-var',
  6859. 'pwn' => 'application/vnd.3m.post-it-notes',
  6860. 'pya' => 'audio/vnd.ms-playready.media.pya',
  6861. 'pyv' => 'video/vnd.ms-playready.media.pyv',
  6862. 'qam' => 'application/vnd.epson.quickanime',
  6863. 'qbo' => 'application/vnd.intu.qbo',
  6864. 'qfx' => 'application/vnd.intu.qfx',
  6865. 'qps' => 'application/vnd.publishare-delta-tree',
  6866. 'qt' => 'video/quicktime',
  6867. 'qwd' => 'application/vnd.quark.quarkxpress',
  6868. 'qwt' => 'application/vnd.quark.quarkxpress',
  6869. 'qxb' => 'application/vnd.quark.quarkxpress',
  6870. 'qxd' => 'application/vnd.quark.quarkxpress',
  6871. 'qxl' => 'application/vnd.quark.quarkxpress',
  6872. 'qxt' => 'application/vnd.quark.quarkxpress',
  6873. 'ra' => 'audio/x-pn-realaudio',
  6874. 'ram' => 'audio/x-pn-realaudio',
  6875. 'rar' => 'application/x-rar-compressed',
  6876. 'ras' => 'image/x-cmu-raster',
  6877. 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
  6878. 'rdf' => 'application/rdf+xml',
  6879. 'rdz' => 'application/vnd.data-vision.rdz',
  6880. 'rep' => 'application/vnd.businessobjects',
  6881. 'res' => 'application/x-dtbresource+xml',
  6882. 'rgb' => 'image/x-rgb',
  6883. 'rif' => 'application/reginfo+xml',
  6884. 'rip' => 'audio/vnd.rip',
  6885. 'ris' => 'application/x-research-info-systems',
  6886. 'rl' => 'application/resource-lists+xml',
  6887. 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
  6888. 'rld' => 'application/resource-lists-diff+xml',
  6889. 'rm' => 'application/vnd.rn-realmedia',
  6890. 'rmi' => 'audio/midi',
  6891. 'rmp' => 'audio/x-pn-realaudio-plugin',
  6892. 'rms' => 'application/vnd.jcp.javame.midlet-rms',
  6893. 'rmvb' => 'application/vnd.rn-realmedia-vbr',
  6894. 'rnc' => 'application/relax-ng-compact-syntax',
  6895. 'roa' => 'application/rpki-roa',
  6896. 'roff' => 'text/troff',
  6897. 'rp9' => 'application/vnd.cloanto.rp9',
  6898. 'rpss' => 'application/vnd.nokia.radio-presets',
  6899. 'rpst' => 'application/vnd.nokia.radio-preset',
  6900. 'rq' => 'application/sparql-query',
  6901. 'rs' => 'application/rls-services+xml',
  6902. 'rsd' => 'application/rsd+xml',
  6903. 'rss' => 'application/rss+xml',
  6904. 'rtf' => 'application/rtf',
  6905. 'rtx' => 'text/richtext',
  6906. 's' => 'text/x-asm',
  6907. 's3m' => 'audio/s3m',
  6908. 'saf' => 'application/vnd.yamaha.smaf-audio',
  6909. 'sbml' => 'application/sbml+xml',
  6910. 'sc' => 'application/vnd.ibm.secure-container',
  6911. 'scd' => 'application/x-msschedule',
  6912. 'scm' => 'application/vnd.lotus-screencam',
  6913. 'scq' => 'application/scvp-cv-request',
  6914. 'scs' => 'application/scvp-cv-response',
  6915. 'scurl' => 'text/vnd.curl.scurl',
  6916. 'sda' => 'application/vnd.stardivision.draw',
  6917. 'sdc' => 'application/vnd.stardivision.calc',
  6918. 'sdd' => 'application/vnd.stardivision.impress',
  6919. 'sdkd' => 'application/vnd.solent.sdkm+xml',
  6920. 'sdkm' => 'application/vnd.solent.sdkm+xml',
  6921. 'sdp' => 'application/sdp',
  6922. 'sdw' => 'application/vnd.stardivision.writer',
  6923. 'see' => 'application/vnd.seemail',
  6924. 'seed' => 'application/vnd.fdsn.seed',
  6925. 'sema' => 'application/vnd.sema',
  6926. 'semd' => 'application/vnd.semd',
  6927. 'semf' => 'application/vnd.semf',
  6928. 'ser' => 'application/java-serialized-object',
  6929. 'setpay' => 'application/set-payment-initiation',
  6930. 'setreg' => 'application/set-registration-initiation',
  6931. 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
  6932. 'sfs' => 'application/vnd.spotfire.sfs',
  6933. 'sfv' => 'text/x-sfv',
  6934. 'sgi' => 'image/sgi',
  6935. 'sgl' => 'application/vnd.stardivision.writer-global',
  6936. 'sgm' => 'text/sgml',
  6937. 'sgml' => 'text/sgml',
  6938. 'sh' => 'application/x-sh',
  6939. 'shar' => 'application/x-shar',
  6940. 'shf' => 'application/shf+xml',
  6941. 'sid' => 'image/x-mrsid-image',
  6942. 'sig' => 'application/pgp-signature',
  6943. 'sil' => 'audio/silk',
  6944. 'silo' => 'model/mesh',
  6945. 'sis' => 'application/vnd.symbian.install',
  6946. 'sisx' => 'application/vnd.symbian.install',
  6947. 'sit' => 'application/x-stuffit',
  6948. 'sitx' => 'application/x-stuffitx',
  6949. 'skd' => 'application/vnd.koan',
  6950. 'skm' => 'application/vnd.koan',
  6951. 'skp' => 'application/vnd.koan',
  6952. 'skt' => 'application/vnd.koan',
  6953. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  6954. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  6955. 'slt' => 'application/vnd.epson.salt',
  6956. 'sm' => 'application/vnd.stepmania.stepchart',
  6957. 'smf' => 'application/vnd.stardivision.math',
  6958. 'smi' => 'application/smil+xml',
  6959. 'smil' => 'application/smil+xml',
  6960. 'smv' => 'video/x-smv',
  6961. 'smzip' => 'application/vnd.stepmania.package',
  6962. 'snd' => 'audio/basic',
  6963. 'snf' => 'application/x-font-snf',
  6964. 'so' => 'application/octet-stream',
  6965. 'spc' => 'application/x-pkcs7-certificates',
  6966. 'spf' => 'application/vnd.yamaha.smaf-phrase',
  6967. 'spl' => 'application/x-futuresplash',
  6968. 'spot' => 'text/vnd.in3d.spot',
  6969. 'spp' => 'application/scvp-vp-response',
  6970. 'spq' => 'application/scvp-vp-request',
  6971. 'spx' => 'audio/ogg',
  6972. 'sql' => 'application/x-sql',
  6973. 'src' => 'application/x-wais-source',
  6974. 'srt' => 'application/x-subrip',
  6975. 'sru' => 'application/sru+xml',
  6976. 'srx' => 'application/sparql-results+xml',
  6977. 'ssdl' => 'application/ssdl+xml',
  6978. 'sse' => 'application/vnd.kodak-descriptor',
  6979. 'ssf' => 'application/vnd.epson.ssf',
  6980. 'ssml' => 'application/ssml+xml',
  6981. 'st' => 'application/vnd.sailingtracker.track',
  6982. 'stc' => 'application/vnd.sun.xml.calc.template',
  6983. 'std' => 'application/vnd.sun.xml.draw.template',
  6984. 'stf' => 'application/vnd.wt.stf',
  6985. 'sti' => 'application/vnd.sun.xml.impress.template',
  6986. 'stk' => 'application/hyperstudio',
  6987. 'stl' => 'application/vnd.ms-pki.stl',
  6988. 'str' => 'application/vnd.pg.format',
  6989. 'stw' => 'application/vnd.sun.xml.writer.template',
  6990. 'sub' => 'image/vnd.dvb.subtitle',
  6991. 'sub' => 'text/vnd.dvb.subtitle',
  6992. 'sus' => 'application/vnd.sus-calendar',
  6993. 'susp' => 'application/vnd.sus-calendar',
  6994. 'sv4cpio' => 'application/x-sv4cpio',
  6995. 'sv4crc' => 'application/x-sv4crc',
  6996. 'svc' => 'application/vnd.dvb.service',
  6997. 'svd' => 'application/vnd.svd',
  6998. 'svg' => 'image/svg+xml',
  6999. 'svgz' => 'image/svg+xml',
  7000. 'swa' => 'application/x-director',
  7001. 'swf' => 'application/x-shockwave-flash',
  7002. 'swi' => 'application/vnd.aristanetworks.swi',
  7003. 'sxc' => 'application/vnd.sun.xml.calc',
  7004. 'sxd' => 'application/vnd.sun.xml.draw',
  7005. 'sxg' => 'application/vnd.sun.xml.writer.global',
  7006. 'sxi' => 'application/vnd.sun.xml.impress',
  7007. 'sxm' => 'application/vnd.sun.xml.math',
  7008. 'sxw' => 'application/vnd.sun.xml.writer',
  7009. 't' => 'text/troff',
  7010. 't3' => 'application/x-t3vm-image',
  7011. 'taglet' => 'application/vnd.mynfc',
  7012. 'tao' => 'application/vnd.tao.intent-module-archive',
  7013. 'tar' => 'application/x-tar',
  7014. 'tcap' => 'application/vnd.3gpp2.tcap',
  7015. 'tcl' => 'application/x-tcl',
  7016. 'teacher' => 'application/vnd.smart.teacher',
  7017. 'tei' => 'application/tei+xml',
  7018. 'teicorpus' => 'application/tei+xml',
  7019. 'tex' => 'application/x-tex',
  7020. 'texi' => 'application/x-texinfo',
  7021. 'texinfo' => 'application/x-texinfo',
  7022. 'text' => 'text/plain',
  7023. 'tfi' => 'application/thraud+xml',
  7024. 'tfm' => 'application/x-tex-tfm',
  7025. 'tga' => 'image/x-tga',
  7026. 'thmx' => 'application/vnd.ms-officetheme',
  7027. 'tif' => 'image/tiff',
  7028. 'tiff' => 'image/tiff',
  7029. 'tmo' => 'application/vnd.tmobile-livetv',
  7030. 'torrent' => 'application/x-bittorrent',
  7031. 'tpl' => 'application/vnd.groove-tool-template',
  7032. 'tpt' => 'application/vnd.trid.tpt',
  7033. 'tr' => 'text/troff',
  7034. 'tra' => 'application/vnd.trueapp',
  7035. 'trm' => 'application/x-msterminal',
  7036. 'tsd' => 'application/timestamped-data',
  7037. 'tsv' => 'text/tab-separated-values',
  7038. 'ttc' => 'application/x-font-ttf',
  7039. 'ttf' => 'application/x-font-ttf',
  7040. 'ttl' => 'text/turtle',
  7041. 'twd' => 'application/vnd.simtech-mindmapper',
  7042. 'twds' => 'application/vnd.simtech-mindmapper',
  7043. 'txd' => 'application/vnd.genomatix.tuxedo',
  7044. 'txf' => 'application/vnd.mobius.txf',
  7045. 'txt' => 'text/plain',
  7046. 'u32' => 'application/x-authorware-bin',
  7047. 'udeb' => 'application/x-debian-package',
  7048. 'ufd' => 'application/vnd.ufdl',
  7049. 'ufdl' => 'application/vnd.ufdl',
  7050. 'ulx' => 'application/x-glulx',
  7051. 'umj' => 'application/vnd.umajin',
  7052. 'unityweb' => 'application/vnd.unity',
  7053. 'uoml' => 'application/vnd.uoml+xml',
  7054. 'uri' => 'text/uri-list',
  7055. 'uris' => 'text/uri-list',
  7056. 'urls' => 'text/uri-list',
  7057. 'ustar' => 'application/x-ustar',
  7058. 'utz' => 'application/vnd.uiq.theme',
  7059. 'uu' => 'text/x-uuencode',
  7060. 'uva' => 'audio/vnd.dece.audio',
  7061. 'uvd' => 'application/vnd.dece.data',
  7062. 'uvf' => 'application/vnd.dece.data',
  7063. 'uvg' => 'image/vnd.dece.graphic',
  7064. 'uvh' => 'video/vnd.dece.hd',
  7065. 'uvi' => 'image/vnd.dece.graphic',
  7066. 'uvm' => 'video/vnd.dece.mobile',
  7067. 'uvp' => 'video/vnd.dece.pd',
  7068. 'uvs' => 'video/vnd.dece.sd',
  7069. 'uvt' => 'application/vnd.dece.ttml+xml',
  7070. 'uvu' => 'video/vnd.uvvu.mp4',
  7071. 'uvv' => 'video/vnd.dece.video',
  7072. 'uvva' => 'audio/vnd.dece.audio',
  7073. 'uvvd' => 'application/vnd.dece.data',
  7074. 'uvvf' => 'application/vnd.dece.data',
  7075. 'uvvg' => 'image/vnd.dece.graphic',
  7076. 'uvvh' => 'video/vnd.dece.hd',
  7077. 'uvvi' => 'image/vnd.dece.graphic',
  7078. 'uvvm' => 'video/vnd.dece.mobile',
  7079. 'uvvp' => 'video/vnd.dece.pd',
  7080. 'uvvs' => 'video/vnd.dece.sd',
  7081. 'uvvt' => 'application/vnd.dece.ttml+xml',
  7082. 'uvvu' => 'video/vnd.uvvu.mp4',
  7083. 'uvvv' => 'video/vnd.dece.video',
  7084. 'uvvx' => 'application/vnd.dece.unspecified',
  7085. 'uvvz' => 'application/vnd.dece.zip',
  7086. 'uvx' => 'application/vnd.dece.unspecified',
  7087. 'uvz' => 'application/vnd.dece.zip',
  7088. 'vcard' => 'text/vcard',
  7089. 'vcd' => 'application/x-cdlink',
  7090. 'vcf' => 'text/x-vcard',
  7091. 'vcg' => 'application/vnd.groove-vcard',
  7092. 'vcs' => 'text/x-vcalendar',
  7093. 'vcx' => 'application/vnd.vcx',
  7094. 'vis' => 'application/vnd.visionary',
  7095. 'viv' => 'video/vnd.vivo',
  7096. 'vob' => 'video/x-ms-vob',
  7097. 'vor' => 'application/vnd.stardivision.writer',
  7098. 'vox' => 'application/x-authorware-bin',
  7099. 'vrml' => 'model/vrml',
  7100. 'vsd' => 'application/vnd.visio',
  7101. 'vsf' => 'application/vnd.vsf',
  7102. 'vss' => 'application/vnd.visio',
  7103. 'vst' => 'application/vnd.visio',
  7104. 'vsw' => 'application/vnd.visio',
  7105. 'vtu' => 'model/vnd.vtu',
  7106. 'vxml' => 'application/voicexml+xml',
  7107. 'w3d' => 'application/x-director',
  7108. 'wad' => 'application/x-doom',
  7109. 'wav' => 'audio/x-wav',
  7110. 'wax' => 'audio/x-ms-wax',
  7111. 'wbmp' => 'image/vnd.wap.wbmp',
  7112. 'wbs' => 'application/vnd.criticaltools.wbs+xml',
  7113. 'wbxml' => 'application/vnd.wap.wbxml',
  7114. 'wcm' => 'application/vnd.ms-works',
  7115. 'wdb' => 'application/vnd.ms-works',
  7116. 'wdp' => 'image/vnd.ms-photo',
  7117. 'weba' => 'audio/webm',
  7118. 'webm' => 'video/webm',
  7119. 'webp' => 'image/webp',
  7120. 'wg' => 'application/vnd.pmi.widget',
  7121. 'wgt' => 'application/widget',
  7122. 'wks' => 'application/vnd.ms-works',
  7123. 'wm' => 'video/x-ms-wm',
  7124. 'wma' => 'audio/x-ms-wma',
  7125. 'wmd' => 'application/x-ms-wmd',
  7126. 'wmf' => 'application/x-msmetafile',
  7127. 'wml' => 'text/vnd.wap.wml',
  7128. 'wmlc' => 'application/vnd.wap.wmlc',
  7129. 'wmls' => 'text/vnd.wap.wmlscript',
  7130. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  7131. 'wmv' => 'video/x-ms-wmv',
  7132. 'wmx' => 'video/x-ms-wmx',
  7133. 'wmz' => 'application/x-ms-wmz',
  7134. 'wmz' => 'application/x-msmetafile',
  7135. 'woff' => 'application/font-woff',
  7136. 'wpd' => 'application/vnd.wordperfect',
  7137. 'wpl' => 'application/vnd.ms-wpl',
  7138. 'wps' => 'application/vnd.ms-works',
  7139. 'wqd' => 'application/vnd.wqd',
  7140. 'wri' => 'application/x-mswrite',
  7141. 'wrl' => 'model/vrml',
  7142. 'wsdl' => 'application/wsdl+xml',
  7143. 'wspolicy' => 'application/wspolicy+xml',
  7144. 'wtb' => 'application/vnd.webturbo',
  7145. 'wvx' => 'video/x-ms-wvx',
  7146. 'x32' => 'application/x-authorware-bin',
  7147. 'x3d' => 'model/x3d+xml',
  7148. 'x3db' => 'model/x3d+binary',
  7149. 'x3dbz' => 'model/x3d+binary',
  7150. 'x3dv' => 'model/x3d+vrml',
  7151. 'x3dvz' => 'model/x3d+vrml',
  7152. 'x3dz' => 'model/x3d+xml',
  7153. 'xaml' => 'application/xaml+xml',
  7154. 'xap' => 'application/x-silverlight-app',
  7155. 'xar' => 'application/vnd.xara',
  7156. 'xbap' => 'application/x-ms-xbap',
  7157. 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
  7158. 'xbm' => 'image/x-xbitmap',
  7159. 'xdf' => 'application/xcap-diff+xml',
  7160. 'xdm' => 'application/vnd.syncml.dm+xml',
  7161. 'xdp' => 'application/vnd.adobe.xdp+xml',
  7162. 'xdssc' => 'application/dssc+xml',
  7163. 'xdw' => 'application/vnd.fujixerox.docuworks',
  7164. 'xenc' => 'application/xenc+xml',
  7165. 'xer' => 'application/patch-ops-error+xml',
  7166. 'xfdf' => 'application/vnd.adobe.xfdf',
  7167. 'xfdl' => 'application/vnd.xfdl',
  7168. 'xht' => 'application/xhtml+xml',
  7169. 'xhtml' => 'application/xhtml+xml',
  7170. 'xhvml' => 'application/xv+xml',
  7171. 'xif' => 'image/vnd.xiff',
  7172. 'xla' => 'application/vnd.ms-excel',
  7173. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  7174. 'xlc' => 'application/vnd.ms-excel',
  7175. 'xlf' => 'application/x-xliff+xml',
  7176. 'xlm' => 'application/vnd.ms-excel',
  7177. 'xls' => 'application/vnd.ms-excel',
  7178. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  7179. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  7180. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  7181. 'xlt' => 'application/vnd.ms-excel',
  7182. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  7183. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  7184. 'xlw' => 'application/vnd.ms-excel',
  7185. 'xm' => 'audio/xm',
  7186. 'xml' => 'application/xml',
  7187. 'xo' => 'application/vnd.olpc-sugar',
  7188. 'xop' => 'application/xop+xml',
  7189. 'xpi' => 'application/x-xpinstall',
  7190. 'xpl' => 'application/xproc+xml',
  7191. 'xpm' => 'image/x-xpixmap',
  7192. 'xpr' => 'application/vnd.is-xpr',
  7193. 'xps' => 'application/vnd.ms-xpsdocument',
  7194. 'xpw' => 'application/vnd.intercon.formnet',
  7195. 'xpx' => 'application/vnd.intercon.formnet',
  7196. 'xsl' => 'application/xml',
  7197. 'xslt' => 'application/xslt+xml',
  7198. 'xsm' => 'application/vnd.syncml+xml',
  7199. 'xspf' => 'application/xspf+xml',
  7200. 'xul' => 'application/vnd.mozilla.xul+xml',
  7201. 'xvm' => 'application/xv+xml',
  7202. 'xvml' => 'application/xv+xml',
  7203. 'xwd' => 'image/x-xwindowdump',
  7204. 'xyz' => 'chemical/x-xyz',
  7205. 'xz' => 'application/x-xz',
  7206. 'yang' => 'application/yang',
  7207. 'yin' => 'application/yin+xml',
  7208. 'z1' => 'application/x-zmachine',
  7209. 'z2' => 'application/x-zmachine',
  7210. 'z3' => 'application/x-zmachine',
  7211. 'z4' => 'application/x-zmachine',
  7212. 'z5' => 'application/x-zmachine',
  7213. 'z6' => 'application/x-zmachine',
  7214. 'z7' => 'application/x-zmachine',
  7215. 'z8' => 'application/x-zmachine',
  7216. 'zaz' => 'application/vnd.zzazz.deck+xml',
  7217. 'zip' => 'application/zip',
  7218. 'zir' => 'application/vnd.zul',
  7219. 'zirz' => 'application/vnd.zul',
  7220. 'zmm' => 'application/vnd.handheld-entertainment+xml'
  7221. );
  7222. }
  7223. // Always run this
  7224. if(strpos($_SERVER['SCRIPT_NAME'], 'check.php') == false){
  7225. dependCheck();
  7226. }