functions.php 347 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421
  1. <?php
  2. // ===================================
  3. // Define Version
  4. define('INSTALLEDVERSION', '1.603');
  5. // ===================================
  6. $debugOrganizr = true;
  7. if($debugOrganizr == true && file_exists('debug.php')){ require_once('debug.php'); }
  8. use Kryptonit3\Sonarr\Sonarr;
  9. use Kryptonit3\SickRage\SickRage;
  10. //homepage order
  11. function homepageOrder(){
  12. $homepageOrder = array(
  13. "homepageOrdercustomhtml" => homepageOrdercustomhtml,
  14. "homepageOrdernotice" => homepageOrdernotice,
  15. "homepageOrderplexsearch" => homepageOrderplexsearch,
  16. "homepageOrderspeedtest" => homepageOrderspeedtest,
  17. "homepageOrdernzbget" => homepageOrdernzbget,
  18. "homepageOrdersabnzbd" => homepageOrdersabnzbd,
  19. "homepageOrderplexnowplaying" => homepageOrderplexnowplaying,
  20. "homepageOrderplexrecent" => homepageOrderplexrecent,
  21. "homepageOrderplexplaylist" => homepageOrderplexplaylist,
  22. "homepageOrderembynowplaying" => homepageOrderembynowplaying,
  23. "homepageOrderembyrecent" => homepageOrderembyrecent,
  24. "homepageOrderombi" => homepageOrderombi,
  25. "homepageOrdercalendar" => homepageOrdercalendar,
  26. );
  27. asort($homepageOrder);
  28. return $homepageOrder;
  29. }
  30. // Debugging output functions
  31. function debug_out($variable, $die = false) {
  32. $trace = debug_backtrace()[0];
  33. echo "<center><img height='200px' src='images/confused.png'></center>";
  34. echo "<center>Look's like something happened, here are the errors and perhaps how to fix them:</center>";
  35. 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>';
  36. if ($die) { http_response_code(503); die(); }
  37. }
  38. //Cookie Function
  39. function coookie($type, $name, $value = '', $days = -1, $http = true){
  40. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  41. $Secure = true;
  42. $HTTPOnly = true;
  43. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  44. $Secure = true;
  45. $HTTPOnly = true;
  46. } else {
  47. $Secure = false;
  48. $HTTPOnly = false;
  49. }
  50. if(!$http){ $HTTPOnly = false; }
  51. $Path = '/';
  52. $Domain = $_SERVER['HTTP_HOST'];
  53. $Port = strpos($Domain, ':');
  54. if ($Port !== false) $Domain = substr($Domain, 0, $Port);
  55. $Port = strpos($Domain, ':');
  56. $check = substr_count($Domain, '.');
  57. if($check >= 3){
  58. if(is_numeric($Domain[0])){
  59. $Domain = '';
  60. }else{
  61. $Domain = '.'.explode('.',$Domain)[1].'.'.explode('.',$Domain)[2].'.'.explode('.',$Domain)[3];
  62. }
  63. }elseif($check == 2){
  64. $Domain = '.'.explode('.',$Domain)[1].'.'.explode('.',$Domain)[2];
  65. }elseif($check == 1){
  66. $Domain = '.' . $Domain;
  67. }else{
  68. $Domain = '';
  69. }
  70. if($type = 'set'){
  71. $_COOKIE[$name] = $value;
  72. header('Set-Cookie: ' . rawurlencode($name) . '=' . rawurlencode($value)
  73. . (empty($days) ? '' : '; expires=' . gmdate('D, d-M-Y H:i:s', time() + (86400 * $days)) . ' GMT')
  74. . (empty($Path) ? '' : '; path=' . $Path)
  75. . (empty($Domain) ? '' : '; domain=' . $Domain)
  76. . (!$Secure ? '' : '; secure')
  77. . (!$HTTPOnly ? '' : '; HttpOnly'), false);
  78. }elseif($type = 'delete'){
  79. unset($_COOKIE[$name]);
  80. header('Set-Cookie: ' . rawurlencode($name) . '=' . rawurlencode($value)
  81. . (empty($days) ? '' : '; expires=' . gmdate('D, d-M-Y H:i:s', time() - 3600) . ' GMT')
  82. . (empty($Path) ? '' : '; path=' . $Path)
  83. . (empty($Domain) ? '' : '; domain=' . $Domain)
  84. . (!$Secure ? '' : '; secure')
  85. . (!$HTTPOnly ? '' : '; HttpOnly'), false);
  86. }
  87. }
  88. // ==== Auth Plugins START ====
  89. if (function_exists('ldap_connect')) :
  90. // Pass credentials to LDAP backend
  91. function plugin_auth_ldap($username, $password) {
  92. $ldapServers = explode(',',AUTHBACKENDHOST);
  93. foreach($ldapServers as $key => $value) {
  94. // Calculate parts
  95. $digest = parse_url(trim($value));
  96. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:'ldap'));
  97. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  98. $port = (isset($digest['port'])?$digest['port']:(strtolower($scheme)=='ldap'?389:636));
  99. // Reassign
  100. $ldapServers[$key] = $scheme.'://'.$host.':'.$port;
  101. }
  102. // returns true or false
  103. $ldap = ldap_connect(implode(' ',$ldapServers));
  104. if(empty(AUTHBACKENDDOMAINFORMAT)){
  105. if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
  106. writeLog("success", "LDAP authentication success");
  107. return true;
  108. } else {
  109. writeLog("error", "LDAP could not authenticate");
  110. return false;
  111. }
  112. }else{
  113. ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
  114. ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
  115. $bind = @ldap_bind($ldap, sprintf(AUTHBACKENDDOMAINFORMAT, $username), $password);
  116. if ($bind) {
  117. writeLog("success", "LDAP authentication success");
  118. return true;
  119. } else {
  120. writeLog("error", "LDPA could not authenticate");
  121. return false;
  122. }
  123. }
  124. writeLog("error", "LDAP could not authenticate");
  125. return false;
  126. }
  127. else :
  128. // Ldap Auth Missing Dependancy
  129. function plugin_auth_ldap_disabled() {
  130. return 'LDAP - Disabled (Dependancy: php-ldap missing!)';
  131. }
  132. endif;
  133. // Pass credentials to FTP backend
  134. function plugin_auth_ftp($username, $password) {
  135. // Calculate parts
  136. $digest = parse_url(AUTHBACKENDHOST);
  137. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:(function_exists('ftp_ssl_connect')?'ftps':'ftp')));
  138. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  139. $port = (isset($digest['port'])?$digest['port']:21);
  140. // Determine Connection Type
  141. if ($scheme == 'ftps') {
  142. $conn_id = ftp_ssl_connect($host, $port, 20);
  143. } elseif ($scheme == 'ftp') {
  144. $conn_id = ftp_connect($host, $port, 20);
  145. } else {
  146. debug_out('Invalid FTP scheme. Use ftp or ftps');
  147. writeLog("error", "invalid FTP scheme");
  148. return false;
  149. }
  150. // Check if valid FTP connection
  151. if ($conn_id) {
  152. // Attempt login
  153. @$login_result = ftp_login($conn_id, $username, $password);
  154. ftp_close($conn_id);
  155. // Return Result
  156. if ($login_result) {
  157. writeLog("success", "$username authenticated");
  158. return true;
  159. } else {
  160. writeLog("error", "$username could not authenticate");
  161. return false;
  162. }
  163. } else {
  164. return false;
  165. }
  166. return false;
  167. }
  168. // Pass credentials to Emby Backend
  169. function plugin_auth_emby_local($username, $password) {
  170. $embyAddress = qualifyURL(EMBYURL);
  171. $headers = array(
  172. 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"',
  173. 'Content-Type' => 'application/json',
  174. );
  175. $body = array(
  176. 'Username' => $username,
  177. 'Password' => sha1($password),
  178. 'PasswordMd5' => md5($password),
  179. );
  180. $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers);
  181. if (isset($response['content'])) {
  182. $json = json_decode($response['content'], true);
  183. if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
  184. // Login Success - Now Logout Emby Session As We No Longer Need It
  185. $headers = array(
  186. 'X-Mediabrowser-Token' => $json['AccessToken'],
  187. );
  188. $response = post_router($embyAddress.'/Sessions/Logout', array(), $headers);
  189. return true;
  190. }
  191. }
  192. return false;
  193. }
  194. if (function_exists('curl_version')) :
  195. // Authenticate Against Emby Local (first) and Emby Connect
  196. function plugin_auth_emby_all($username, $password) {
  197. $localResult = plugin_auth_emby_local($username, $password);
  198. if ($localResult) {
  199. return $localResult;
  200. } else {
  201. return plugin_auth_emby_connect($username, $password);
  202. }
  203. }
  204. // Authenicate against emby connect
  205. function plugin_auth_emby_connect($username, $password) {
  206. $embyAddress = qualifyURL(EMBYURL);
  207. // Get A User
  208. $connectId = '';
  209. $userIds = json_decode(@file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
  210. if (is_array($userIds)) {
  211. foreach ($userIds as $key => $value) { // Scan for this user
  212. if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
  213. if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
  214. $connectId = $value['ConnectUserId'];
  215. break;
  216. }
  217. }
  218. }
  219. if ($connectId) {
  220. $connectURL = 'https://connect.emby.media/service/user/authenticate';
  221. $headers = array(
  222. 'Accept'=> 'application/json',
  223. 'Content-Type' => 'application/x-www-form-urlencoded',
  224. );
  225. $body = array(
  226. 'nameOrEmail' => $username,
  227. 'rawpw' => $password,
  228. );
  229. $result = curl_post($connectURL, $body, $headers);
  230. if (isset($result['content'])) {
  231. $json = json_decode($result['content'], true);
  232. if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
  233. return array(
  234. 'email' => $json['User']['Email'],
  235. 'image' => $json['User']['ImageUrl'],
  236. );
  237. }
  238. }
  239. }
  240. }
  241. return false;
  242. }
  243. // Pass credentials to Plex Backend
  244. function plugin_auth_plex($username, $password) {
  245. // Quick out
  246. $isAdmin = false;
  247. if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
  248. writeLog("success", "Admin: ".$username." authenticated by plex");
  249. //return true;
  250. $isAdmin = true;
  251. }
  252. //Get User List
  253. $userURL = 'https://plex.tv/pms/friends/all';
  254. $userHeaders = array(
  255. 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD),
  256. );
  257. libxml_use_internal_errors(true);
  258. $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
  259. if (is_array($userXML) || is_object($userXML)) {
  260. $isUser = false;
  261. $usernameLower = strtolower($username);
  262. foreach($userXML AS $child) {
  263. if(isset($child['username']) && strtolower($child['username']) == $usernameLower) {
  264. $isUser = true;
  265. writeLog("success", $usernameLower." was found in plex friends list");
  266. break;
  267. }
  268. }
  269. if ($isUser || $isAdmin) {
  270. //Login User
  271. $connectURL = 'https://plex.tv/users/sign_in.json';
  272. $headers = array(
  273. 'Accept'=> 'application/json',
  274. 'Content-Type' => 'application/x-www-form-urlencoded',
  275. 'X-Plex-Product' => 'Organizr',
  276. 'X-Plex-Version' => '1.0',
  277. 'X-Plex-Client-Identifier' => '01010101-10101010',
  278. );
  279. $body = array(
  280. 'user[login]' => $username,
  281. 'user[password]' => $password,
  282. );
  283. $result = curl_post($connectURL, $body, $headers);
  284. if (isset($result['content'])) {
  285. $json = json_decode($result['content'], true);
  286. if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && strtolower($json['user']['username']) == $usernameLower) {
  287. writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
  288. return array(
  289. 'email' => $json['user']['email'],
  290. 'image' => $json['user']['thumb'],
  291. 'token' => $json['user']['authToken']
  292. );
  293. }
  294. }
  295. }else{
  296. writeLog("error", "$username is not an authorized PLEX user or entered invalid password");
  297. }
  298. }else{
  299. writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");
  300. }
  301. return false;
  302. }
  303. else :
  304. // Plex Auth Missing Dependancy
  305. function plugin_auth_plex_disabled() {
  306. return 'Plex - Disabled (Dependancy: php-curl missing!)';
  307. }
  308. // Emby Connect Auth Missing Dependancy
  309. function plugin_auth_emby_connect_disabled() {
  310. return 'Emby Connect - Disabled (Dependancy: php-curl missing!)';
  311. }
  312. // Emby Both Auth Missing Dependancy
  313. function plugin_auth_emby_both_disabled() {
  314. return 'Emby Both - Disabled (Dependancy: php-curl missing!)';
  315. }
  316. endif;
  317. // ==== Auth Plugins END ====
  318. // ==== General Class Definitions START ====
  319. $userLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  320. class setLanguage {
  321. private $language = null;
  322. private $langCode = null;
  323. function __construct($language = false) {
  324. // Default
  325. if (!$language) {
  326. $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  327. }
  328. if (!file_exists("lang/{$language}.ini")) {
  329. $language = 'en';
  330. }
  331. $this->langCode = $language;
  332. $this->language = parse_ini_file("lang/{$language}.ini", false, INI_SCANNER_RAW);
  333. if (file_exists("lang/{$language}.cust.ini")) {
  334. foreach($tmp = parse_ini_file("lang/{$language}.cust.ini", false, INI_SCANNER_RAW) as $k => $v) {
  335. $this->language[$k] = $v;
  336. }
  337. }
  338. }
  339. public function getLang() {
  340. return $this->langCode;
  341. }
  342. public function translate($originalWord) {
  343. $getArg = func_num_args();
  344. if ($getArg > 1) {
  345. $allWords = func_get_args();
  346. array_shift($allWords);
  347. } else {
  348. $allWords = array();
  349. }
  350. $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null;
  351. if (!$translatedWord) {
  352. return ucwords(str_replace("_", " ", strtolower($originalWord)));
  353. //echo "WHOA!!!!!!! $originalWord";
  354. }
  355. $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES);
  356. return vsprintf($translatedWord, $allWords);
  357. }
  358. }
  359. $language = new setLanguage;
  360. // ==== General Class Definitions END ====
  361. // Direct request to curl if it exists, otherwise handle if not HTTPS
  362. function post_router($url, $data, $headers = array(), $referer='') {
  363. if (function_exists('curl_version')) {
  364. return curl_post($url, $data, $headers, $referer);
  365. } else {
  366. return post_request($url, $data, $headers, $referer);
  367. }
  368. }
  369. if (function_exists('curl_version')) :
  370. // Curl Post
  371. function curl_post($url, $data, $headers = array(), $referer='') {
  372. // Initiate cURL
  373. $curlReq = curl_init($url);
  374. // As post request
  375. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST");
  376. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  377. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  378. if(localURL($url)){
  379. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  380. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  381. }
  382. // Format Data
  383. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  384. case 'application/json':
  385. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  386. break;
  387. case 'application/x-www-form-urlencoded':
  388. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  389. break;
  390. default:
  391. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  392. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  393. }
  394. // Format Headers
  395. $cHeaders = array();
  396. foreach ($headers as $k => $v) {
  397. $cHeaders[] = $k.': '.$v;
  398. }
  399. if (count($cHeaders)) {
  400. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  401. }
  402. // Execute
  403. $result = curl_exec($curlReq);
  404. $httpcode = curl_getinfo($curlReq);
  405. // Close
  406. curl_close($curlReq);
  407. // Return
  408. return array('content'=>$result, 'http_code'=>$httpcode);
  409. }
  410. // Curl Put
  411. function curl_put($url, $data, $headers = array(), $referer='') {
  412. // Initiate cURL
  413. $curlReq = curl_init($url);
  414. // As post request
  415. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "PUT");
  416. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  417. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  418. if(localURL($url)){
  419. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  420. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  421. }
  422. // Format Data
  423. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  424. case 'application/json':
  425. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  426. break;
  427. case 'application/x-www-form-urlencoded':
  428. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  429. break;
  430. default:
  431. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  432. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  433. }
  434. // Format Headers
  435. $cHeaders = array();
  436. foreach ($headers as $k => $v) {
  437. $cHeaders[] = $k.': '.$v;
  438. }
  439. if (count($cHeaders)) {
  440. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  441. }
  442. // Execute
  443. $result = curl_exec($curlReq);
  444. $httpcode = curl_getinfo($curlReq);
  445. // Close
  446. curl_close($curlReq);
  447. // Return
  448. return array('content'=>$result, 'http_code'=>$httpcode);
  449. }
  450. //Curl Get Function
  451. function curl_get($url, $headers = array()) {
  452. // Initiate cURL
  453. $curlReq = curl_init($url);
  454. // As post request
  455. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET");
  456. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  457. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  458. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  459. if(localURL($url)){
  460. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  461. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  462. }
  463. // Format Headers
  464. $cHeaders = array();
  465. foreach ($headers as $k => $v) {
  466. $cHeaders[] = $k.': '.$v;
  467. }
  468. if (count($cHeaders)) {
  469. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  470. }
  471. // Execute
  472. $result = curl_exec($curlReq);
  473. // Close
  474. curl_close($curlReq);
  475. // Return
  476. return $result;
  477. }
  478. //Curl Delete Function
  479. function curl_delete($url, $headers = array()) {
  480. // Initiate cURL
  481. $curlReq = curl_init($url);
  482. // As post request
  483. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE");
  484. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  485. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  486. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  487. if(localURL($url)){
  488. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  489. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  490. }
  491. // Format Headers
  492. $cHeaders = array();
  493. foreach ($headers as $k => $v) {
  494. $cHeaders[] = $k.': '.$v;
  495. }
  496. if (count($cHeaders)) {
  497. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  498. }
  499. // Execute
  500. $result = curl_exec($curlReq);
  501. $httpcode = curl_getinfo($curlReq);
  502. // Close
  503. curl_close($curlReq);
  504. // Return
  505. return array('content'=>$result, 'http_code'=>$httpcode);
  506. }
  507. endif;
  508. //Case-Insensitive Function
  509. function in_arrayi($needle, $haystack) {
  510. return in_array(strtolower($needle), array_map('strtolower', $haystack));
  511. }
  512. // HTTP post request (Removes need for curl, probably useless)
  513. function post_request($url, $data, $headers = array(), $referer='') {
  514. // Adapted from http://stackoverflow.com/a/28387011/6810513
  515. // Convert the data array into URL Parameters like a=b&foo=bar etc.
  516. if (isset($headers['Content-Type'])) {
  517. switch ($headers['Content-Type']) {
  518. case 'application/json':
  519. $data = json_encode($data);
  520. break;
  521. case 'application/x-www-form-urlencoded':
  522. $data = http_build_query($data);
  523. break;
  524. }
  525. } else {
  526. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  527. $data = http_build_query($data);
  528. }
  529. // parse the given URL
  530. $urlDigest = parse_url($url);
  531. // extract host and path:
  532. $host = $urlDigest['host'];
  533. $path = $urlDigest['path'];
  534. if ($urlDigest['scheme'] != 'http') {
  535. die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')');
  536. }
  537. // open a socket connection on port 80 - timeout: 30 sec
  538. $fp = fsockopen($host, (isset($urlDigest['port'])?':'.$urlDigest['port']:80), $errno, $errstr, 30);
  539. if ($fp){
  540. // send the request headers:
  541. fputs($fp, "POST $path HTTP/1.1\r\n");
  542. fputs($fp, "Host: $host\r\n");
  543. if ($referer != '')
  544. fputs($fp, "Referer: $referer\r\n");
  545. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  546. foreach($headers as $k => $v) {
  547. fputs($fp, $k.": ".$v."\r\n");
  548. }
  549. fputs($fp, "Connection: close\r\n\r\n");
  550. fputs($fp, $data);
  551. $result = '';
  552. while(!feof($fp)) {
  553. // receive the results of the request
  554. $result .= fgets($fp, 128);
  555. }
  556. }
  557. else {
  558. return array(
  559. 'status' => 'err',
  560. 'error' => "$errstr ($errno)"
  561. );
  562. }
  563. // close the socket connection:
  564. fclose($fp);
  565. // split the result header from the content
  566. $result = explode("\r\n\r\n", $result, 2);
  567. $header = isset($result[0]) ? $result[0] : '';
  568. $content = isset($result[1]) ? $result[1] : '';
  569. // return as structured array:
  570. return array(
  571. 'status' => 'ok',
  572. 'header' => $header,
  573. 'content' => $content,
  574. );
  575. }
  576. // Format item from Emby for Carousel
  577. function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $moreInfo = false) {
  578. // Static Height
  579. $height = 444;
  580. // Get Item Details
  581. $itemDetails = json_decode(@file_get_contents($address.'/Items?Ids='.$item['Id'].'&api_key='.$token),true)['Items'][0];
  582. /*if (substr_count(EMBYURL, ':') == 2) {
  583. $URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  584. }else{
  585. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  586. }*/
  587. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  588. switch ($itemDetails['Type']) {
  589. case 'Episode':
  590. case 'Series':
  591. $title = (isset($itemDetails['SeriesName'])?$itemDetails['SeriesName']:"");
  592. $imageId = (isset($itemDetails['SeriesId'])?$itemDetails['SeriesId']:$itemDetails['Id']);
  593. $width = 300;
  594. $style = '';
  595. $image = 'slick-image-tall';
  596. if(!$nowPlaying){
  597. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  598. $key = $itemDetails['Id'] . "-list";
  599. $itemType = 'season';
  600. }else{
  601. $height = 281;
  602. $width = 500;
  603. $imageId = isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId'] : (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  604. $imageType = isset($itemDetails['ParentThumbItemId']) ? "Thumb" : (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  605. $key = (isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId']."-np" : "none-np");
  606. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  607. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  608. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  609. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  610. $stream = $moreInfo['PlayState']['PlayMethod'];
  611. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  612. $id = $moreInfo['DeviceId'];
  613. $streamInfo = buildStream(array(
  614. 'platform' => (string) $moreInfo['Client'],
  615. 'device' => (string) $moreInfo['DeviceName'],
  616. 'stream' => streamType($stream),
  617. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  618. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  619. ));
  620. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  621. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$itemDetails['Name'].'</h5>';
  622. $bottomTitle = '<small class="zero-m">S'.$itemDetails['ParentIndexNumber'].' · E'.$itemDetails['IndexNumber'].'</small>';
  623. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  624. }
  625. break;
  626. case 'MusicAlbum':
  627. case 'Audio':
  628. $title = $itemDetails['Name'];
  629. $imageId = $itemDetails['Id'];
  630. $width = 444;
  631. $style = '';
  632. $image = 'slick-image-short';
  633. if(!$nowPlaying){
  634. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  635. $key = $itemDetails['Id'] . "-list";
  636. $itemType = 'album';
  637. }else{
  638. $height = 281;
  639. $width = 500;
  640. $imageId = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  641. $imageType = (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  642. $key = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : "no-np") . "-np";
  643. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  644. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  645. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  646. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  647. $stream = $moreInfo['PlayState']['PlayMethod'];
  648. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  649. $id = $moreInfo['DeviceId'];
  650. $streamInfo = buildStream(array(
  651. 'platform' => (string) $moreInfo['Client'],
  652. 'device' => (string) $moreInfo['DeviceName'],
  653. 'stream' => streamType($stream),
  654. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  655. ));
  656. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  657. $topTitle = '<h5 class="text-center zero-m elip">'.$itemDetails['AlbumArtist'].' - '.$itemDetails['Album'].'</h5>';
  658. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  659. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  660. }
  661. break;
  662. case 'TvChannel':
  663. $title = $itemDetails['CurrentProgram']['Name'];
  664. $imageId = $itemDetails['Id'];
  665. $width = 300;
  666. $style = '';
  667. $image = 'slick-image-tall';
  668. if(!$nowPlaying){
  669. $imageType = "Primary";
  670. $key = $itemDetails['Id'] . "-list";
  671. }else{
  672. $height = 281;
  673. $width = 500;
  674. $imageType = "Thumb";
  675. $key = $itemDetails['Id'] . "-np";
  676. $useImage = "images/livetv.png";
  677. $watched = "0";
  678. $stream = $moreInfo['PlayState']['PlayMethod'];
  679. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  680. $id = $moreInfo['DeviceId'];
  681. $streamInfo = buildStream(array(
  682. 'platform' => (string) $moreInfo['Client'],
  683. 'device' => (string) $moreInfo['DeviceName'],
  684. 'stream' => streamType($stream),
  685. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  686. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  687. ));
  688. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  689. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  690. $bottomTitle = '<small class="zero-m">'.$itemDetails['Name'].' - '.$itemDetails['ChannelNumber'].'</small>';
  691. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  692. }
  693. break;
  694. default:
  695. $title = $itemDetails['Name'];
  696. $imageId = $itemDetails['Id'];
  697. $width = 300;
  698. $style = '';
  699. $image = 'slick-image-tall';
  700. if(!$nowPlaying){
  701. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  702. $key = $itemDetails['Id'] . "-list";
  703. $itemType = 'movie';
  704. }else{
  705. $height = 281;
  706. $width = 500;
  707. $imageType = isset($itemDetails['ImageTags']['Thumb']) ? "Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
  708. $key = $itemDetails['Id'] . "-np";
  709. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  710. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  711. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  712. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  713. $stream = $moreInfo['PlayState']['PlayMethod'];
  714. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  715. $id = $moreInfo['DeviceId'];
  716. $streamInfo = buildStream(array(
  717. 'platform' => (string) $moreInfo['Client'],
  718. 'device' => (string) $moreInfo['DeviceName'],
  719. 'stream' => streamType($stream),
  720. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  721. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  722. ));
  723. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  724. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  725. $bottomTitle = '<small class="zero-m">'.$moreInfo['NowPlayingItem']['ProductionYear'].'</small>';
  726. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  727. }
  728. }
  729. // If No Overview
  730. if (!isset($itemDetails['Overview'])) {
  731. $itemDetails['Overview'] = '';
  732. }
  733. $original_image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  734. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  735. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  736. $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'';
  737. }
  738. if($nowPlaying){
  739. if(!$imageType){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  740. if(!$imageId){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  741. }else{
  742. if(!$imageType){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  743. if(!$imageId){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  744. }
  745. if(isset($useImage)){ $image_url = $useImage; }
  746. // Assemble Item And Cache Into Array
  747. if($nowPlaying){
  748. //prettyPrint($itemDetails);
  749. 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>';
  750. }else{
  751. return '<div class="item-'.$itemType.'"><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>';
  752. }
  753. }
  754. // Format item from Plex for Carousel
  755. function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $playlist = false) {
  756. // Static Height
  757. $height = 444;
  758. $widthOverride = 100;
  759. $playlist = ($playlist) ? " playlist-$playlist" : "";
  760. switch ($item['type']) {
  761. case 'season':
  762. $title = $item['parentTitle'];
  763. $summary = $item['parentSummary'];
  764. $width = 300;
  765. $image = 'slick-image-tall';
  766. $style = '';
  767. if(!$nowPlaying){
  768. $thumb = $item['thumb'];
  769. $key = $item['ratingKey'] . "-list";
  770. }else {
  771. $height = 281;
  772. $width = 500;
  773. $thumb = $item['art'];
  774. $key = $item['ratingKey'] . "-np";
  775. $elapsed = $item['viewOffset'];
  776. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  777. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  778. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  779. $stream = $item->Media->Part->Stream['decision'];
  780. $user = $role == "admin" ? $item->User['title'] : "";
  781. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  782. $streamInfo = buildStream(array(
  783. 'platform' => (string) $item->Player['platform'],
  784. 'device' => (string) $item->Player['device'],
  785. 'stream' => streamType($item->Media->Part['decision']),
  786. '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'].")",
  787. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  788. ));
  789. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  790. }
  791. break;
  792. case 'episode':
  793. $title = $item['grandparentTitle'];
  794. $summary = $item['title'];
  795. $width = 300;
  796. $image = 'slick-image-tall';
  797. $style = '';
  798. if(!$nowPlaying){
  799. $thumb = ($item['parentThumb'] ? $item['parentThumb'] : $item['grandparentThumb']);
  800. $key = $item['ratingKey'] . "-list";
  801. }else {
  802. $height = 281;
  803. $width = 500;
  804. $thumb = $item['art'];
  805. $key = $item['ratingKey'] . "-np";
  806. $elapsed = $item['viewOffset'];
  807. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  808. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  809. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  810. $stream = $item->Media->Part->Stream['decision'];
  811. $user = $role == "admin" ? $item->User['title'] : "";
  812. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  813. $streamInfo = buildStream(array(
  814. 'platform' => (string) $item->Player['platform'],
  815. 'device' => (string) $item->Player['device'],
  816. 'stream' => streamType($item->Media->Part['decision']),
  817. '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'].")",
  818. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  819. ));
  820. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  821. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$item['title'].'</h5>';
  822. $bottomTitle = '<small class="zero-m">S'.$item['parentIndex'].' · E'.$item['index'].'</small>';
  823. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  824. }
  825. break;
  826. case 'clip':
  827. $title = $item['title'];
  828. $summary = $item['summary'];
  829. $width = 300;
  830. $image = 'slick-image-tall';
  831. $style = '';
  832. if(!$nowPlaying){
  833. $thumb = $item['thumb'];
  834. $key = $item['ratingKey'] . "-list";
  835. }else {
  836. $height = 281;
  837. $width = 500;
  838. $thumb = $item['art'];
  839. $key = isset($item['ratingKey']) ? $item['ratingKey'] . "-np" : (isset($item['live']) ? "livetv.png" : ":)");
  840. $useImage = (isset($item['live']) ? "images/livetv.png" : null);
  841. $extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
  842. $elapsed = $item['viewOffset'];
  843. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  844. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  845. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  846. $stream = $item->Media->Part->Stream['decision'];
  847. $user = $role == "admin" ? $item->User['title'] : "";
  848. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  849. $streamInfo = buildStream(array(
  850. 'platform' => (string) $item->Player['platform'],
  851. 'device' => (string) $item->Player['device'],
  852. 'stream' => streamType($item->Media->Part['decision']),
  853. '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'].")",
  854. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  855. ));
  856. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  857. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  858. $bottomTitle = '<small class="zero-m">'.$extraInfo.'</small>';
  859. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  860. }
  861. break;
  862. case 'album':
  863. case 'track':
  864. $title = $item['parentTitle'];
  865. $summary = $item['title'];
  866. $image = 'slick-image-short';
  867. $style = 'left: 160px !important;';
  868. $item['ratingKey'] = $item['parentRatingKey'];
  869. if(!$nowPlaying){
  870. $width = 444;
  871. $thumb = $item['thumb'];
  872. $key = $item['ratingKey'] . "-list";
  873. }else {
  874. $height = 281;
  875. $width = 500;
  876. $thumb = ($item['art']) ? $item['art'] : $item['parentThumb'];
  877. $widthOverride = ($item['art']) ? 100 : 56;
  878. $key = $item['ratingKey'] . "-np";
  879. $elapsed = $item['viewOffset'];
  880. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  881. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  882. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  883. $stream = $item->Media->Part->Stream['decision'];
  884. $user = $role == "admin" ? $item->User['title'] : "";
  885. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  886. $streamInfo = buildStream(array(
  887. 'platform' => (string) $item->Player['platform'],
  888. 'device' => (string) $item->Player['device'],
  889. 'stream' => streamType($item->Media->Part['decision']),
  890. 'audio' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['channels']."ch)",
  891. ));
  892. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  893. $topTitle = '<h5 class="text-center zero-m elip">'.$item['grandparentTitle'].' - '.$item['title'].'</h5>';
  894. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  895. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  896. }
  897. break;
  898. default:
  899. $title = $item['title'];
  900. $summary = $item['summary'];
  901. $image = 'slick-image-tall';
  902. $style = '';
  903. if(!$nowPlaying){
  904. $width = 300;
  905. $thumb = $item['thumb'];
  906. $key = $item['ratingKey'] . "-list";
  907. }else {
  908. $height = 281;
  909. $width = 500;
  910. $thumb = $item['art'];
  911. $key = $item['ratingKey'] . "-np";
  912. $elapsed = $item['viewOffset'];
  913. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  914. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  915. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  916. $stream = $item->Media->Part->Stream['decision'];
  917. $user = $role == "admin" ? $item->User['title'] : "";
  918. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  919. $streamInfo = buildStream(array(
  920. 'platform' => (string) $item->Player['platform'],
  921. 'device' => (string) $item->Player['device'],
  922. 'stream' => streamType($item->Media->Part['decision']),
  923. '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'].")",
  924. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  925. ));
  926. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  927. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  928. $bottomTitle = '<small class="zero-m">'.$item['year'].'</small>';
  929. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  930. }
  931. }
  932. if (PLEXTABURL) {
  933. $address = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  934. }else{
  935. $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  936. }
  937. // If No Overview
  938. if (!isset($itemDetails['Overview'])) { $itemDetails['Overview'] = ''; }
  939. $original_image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  940. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  941. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  942. $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'';
  943. }
  944. if($nowPlaying){
  945. if(!$thumb){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  946. }else{
  947. if(!$thumb){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  948. }
  949. if(isset($useImage)){ $image_url = $useImage; }
  950. $openTab = (PLEXTABNAME) ? "true" : "false";
  951. // Assemble Item And Cache Into Array
  952. if($nowPlaying){
  953. 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>';
  954. }else{
  955. 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>';
  956. }
  957. }
  958. //$hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  959. //Recent Added
  960. function outputRecentAdded($header, $items, $script = false, $array, $type) {
  961. $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">';
  962. if(preg_grep("/item-movie/", $items)){
  963. $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>';
  964. }
  965. if(preg_grep("/item-season/", $items)){
  966. $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>';
  967. }
  968. if(preg_grep("/item-album/", $items)){
  969. $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>';
  970. }
  971. $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>';
  972. $hideMenu .= '</ul></div></div>';
  973. // If None Populate Empty Item
  974. if (!count($items)) {
  975. return '<div id="recentMedia'.$type.'" class="content-box box-shadow big-box"><h5 class="text-center">'.$header.'</h5><p class="text-center">No Media Found</p></div>';
  976. }else{
  977. $className = str_replace(' ', '', $header.' on '.$type);
  978. return '<div id="recentMedia'.$type.'" class="content-box box-shadow big-box"><h5 id="recentContent-title-'.$type.'" style="margin-bottom: -20px" class="text-center">'.$header.'</h5><div class="recentHeader inbox-pagination '.$className.'">'.$hideMenu.'</div><br/><br/><div class="recentItems-recent-'.$type.'" data-name="'.$className.'">'.implode('',$items).'</div></div>'.($script?'<script>'.$script.'</script>':'');
  979. }
  980. }
  981. // Create Carousel
  982. function outputNowPlaying($header, $size, $type, $items, $script = false) {
  983. // If None Populate Empty Item
  984. if (!count($items)) {
  985. return '<div id="'.$type.'"></div>'.($script?'<script>'.$script.'</script>':'');
  986. }else{
  987. return '<div id="'.$type.'"><h5 class="zero-m big-box"><strong>'.$header.'</strong></h5>'.implode('',$items).'</div>'.($script?'<script>'.$script.'</script>':'');
  988. }
  989. }
  990. // Get Now Playing Streams From Emby
  991. function getEmbyStreams($size, $showNames, $role) {
  992. $address = qualifyURL(EMBYURL);
  993. $api = json_decode(@file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
  994. if (!is_array($api)) { return 'Could not load!'; }
  995. $playingItems = array();
  996. foreach($api as $key => $value) {
  997. if (isset($value['NowPlayingItem'])) {
  998. $playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem'], true, $showNames, $role, $value);
  999. }
  1000. }
  1001. return outputNowPlaying(translate('PLAYING_NOW_ON_EMBY')." ( ".count($playingItems)." Streams )", $size, 'streams-emby', $playingItems, ajaxLoop('emby-streams',NOWPLAYINGREFRESH));
  1002. }
  1003. // Get Now Playing Streams From Plex
  1004. function getPlexStreams($size, $showNames, $role){
  1005. $address = qualifyURL(PLEXURL);
  1006. // Perform API requests
  1007. $api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
  1008. libxml_use_internal_errors(true);
  1009. $api = simplexml_load_string($api);
  1010. if (is_array($api) || is_object($api)){
  1011. if (!$api->head->title){
  1012. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  1013. if (!$getServer) { return 'Could not load!'; }
  1014. // Identify the local machine
  1015. $gotServer = $getServer['machineIdentifier'];
  1016. $items = array();
  1017. foreach($api AS $child) {
  1018. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
  1019. }
  1020. return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." ( ".count($items)." Streams )", $size, 'streams-plex', $items, ajaxLoop('plex-streams',NOWPLAYINGREFRESH));
  1021. }else{
  1022. writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
  1023. }
  1024. }else{
  1025. writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
  1026. }
  1027. }
  1028. // Get Recent Content From Emby
  1029. function getEmbyRecent($array) {
  1030. $address = qualifyURL(EMBYURL);
  1031. $header = translate('RECENT_CONTENT');
  1032. // Currently Logged In User
  1033. $username = false;
  1034. if (isset($GLOBALS['USER'])) {
  1035. $username = strtolower($GLOBALS['USER']->username);
  1036. }
  1037. // Get A User
  1038. $userIds = json_decode(@file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
  1039. if (!is_array($userIds)) { return 'Could not load!'; }
  1040. $showPlayed = true;
  1041. foreach ($userIds as $value) { // Scan for admin user
  1042. if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
  1043. $userId = $value['Id'];
  1044. }
  1045. if ($username && strtolower($value['Name']) == $username) {
  1046. $userId = $value['Id'];
  1047. $showPlayed = false;
  1048. break;
  1049. }
  1050. }
  1051. // Get the latest Items
  1052. $latest = json_decode(@file_get_contents($address.'/Users/'.$userId.'/Items/Latest?EnableImages=false&Limit='.EMBYRECENTITEMS.'&api_key='.EMBYTOKEN.($showPlayed?'':'&IsPlayed=false')),true);
  1053. // For Each Item In Category
  1054. $items = array();
  1055. foreach ($latest as $k => $v) {
  1056. $type = (string) $v['Type'];
  1057. if(@$array[$type] == "true"){
  1058. $items[] = resolveEmbyItem($address, EMBYTOKEN, $v, false, false, false);
  1059. }
  1060. }
  1061. $array["movie"] = $array["Movie"];
  1062. $array["season"] = $array["Episode"];
  1063. $array["album"] = $array["MusicAlbum"];
  1064. unset($array["Movie"]);
  1065. unset($array["Episode"]);
  1066. unset($array["MusicAlbum"]);
  1067. unset($array["Series"]);
  1068. return outputRecentAdded($header, $items, ajaxLoop('emby-recent',RECENTREFRESH,'loadSlick();'), $array, 'Emby');
  1069. }
  1070. // Get Recent Content From Plex
  1071. function getPlexRecent($array){
  1072. $address = qualifyURL(PLEXURL);
  1073. $header = translate('RECENT_CONTENT');
  1074. // Perform Requests
  1075. $api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN);
  1076. libxml_use_internal_errors(true);
  1077. $api = simplexml_load_string($api);
  1078. if (is_array($api) || is_object($api)){
  1079. if (!$api->head->title){
  1080. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  1081. if (!$getServer) { return 'Could not load!'; }
  1082. // Identify the local machine
  1083. $gotServer = $getServer['machineIdentifier'];
  1084. $items = array();
  1085. foreach($api AS $child) {
  1086. $type = (string) $child['type'];
  1087. if($array[$type] == "true"){
  1088. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
  1089. }
  1090. }
  1091. return outputRecentAdded($header, $items, ajaxLoop('plex-recent',RECENTREFRESH,'loadSlick();'), $array, 'Plex');
  1092. }else{
  1093. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check token - if HTTPS, is cert valid");
  1094. }
  1095. }else{
  1096. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check URL - if HTTPS, is cert valid");
  1097. }
  1098. }
  1099. // Get Image From Emby
  1100. function getEmbyImage() {
  1101. $refresh = false;
  1102. $embyAddress = qualifyURL(EMBYURL);
  1103. if (!file_exists('images/cache')) {
  1104. mkdir('images/cache', 0777, true);
  1105. }
  1106. $itemId = $_GET['img'];
  1107. $key = $_GET['key'];
  1108. if(strpos($key, '$') !== false){
  1109. $key = explode('$', $key)[0];
  1110. $refresh = true;
  1111. }
  1112. $itemType = $_GET['type'];
  1113. $imgParams = array();
  1114. if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
  1115. if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
  1116. if(isset($itemId)) {
  1117. $image_src = $embyAddress . '/Items/'.$itemId.'/Images/'.$itemType.'?'.implode('&', $imgParams);
  1118. $cachefile = 'images/cache/'.$key.'.jpg';
  1119. $cachetime = 604800;
  1120. // Serve from the cache if it is younger than $cachetime
  1121. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh !== true) {
  1122. header("Content-type: image/jpeg");
  1123. @readfile($cachefile);
  1124. exit;
  1125. }
  1126. ob_start(); // Start the output buffer
  1127. header('Content-type: image/jpeg');
  1128. //@readfile($image_src);
  1129. echo @curl_get($image_src);
  1130. // Cache the output to a file
  1131. $fp = fopen($cachefile, 'wb');
  1132. fwrite($fp, ob_get_contents());
  1133. fclose($fp);
  1134. ob_end_flush(); // Send the output to the browser
  1135. die();
  1136. } else {
  1137. debug_out('Invalid Request',1);
  1138. }
  1139. }
  1140. // Get Image From Plex
  1141. function getPlexImage() {
  1142. $refresh = false;
  1143. $plexAddress = qualifyURL(PLEXURL);
  1144. if (!file_exists('images/cache')) {
  1145. mkdir('images/cache', 0777, true);
  1146. }
  1147. $image_url = $_GET['img'];
  1148. $key = $_GET['key'];
  1149. if(strpos($key, '$') !== false){
  1150. $key = explode('$', $key)[0];
  1151. $refresh = true;
  1152. }
  1153. $image_height = $_GET['height'];
  1154. $image_width = $_GET['width'];
  1155. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  1156. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  1157. $cachefile = 'images/cache/'.$key.'.jpg';
  1158. $cachetime = 604800;
  1159. // Serve from the cache if it is younger than $cachetime
  1160. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh == false) {
  1161. header("Content-type: image/jpeg");
  1162. @readfile($cachefile);
  1163. exit;
  1164. }
  1165. ob_start(); // Start the output buffer
  1166. header('Content-type: image/jpeg');
  1167. //@readfile($image_src);
  1168. echo @curl_get($image_src);
  1169. // Cache the output to a file
  1170. $fp = fopen($cachefile, 'wb');
  1171. fwrite($fp, ob_get_contents());
  1172. fclose($fp);
  1173. ob_end_flush(); // Send the output to the browser
  1174. die();
  1175. } else {
  1176. echo "Invalid Plex Request";
  1177. }
  1178. }
  1179. // Simplier access to class
  1180. function translate($string) {
  1181. if (isset($GLOBALS['language'])) {
  1182. return $GLOBALS['language']->translate($string);
  1183. } else {
  1184. return '!Translations Not Loaded!';
  1185. }
  1186. }
  1187. // Generate Random string
  1188. function randString($length = 10, $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  1189. $tmp = '';
  1190. for ($i = 0; $i < $length; $i++) {
  1191. $tmp .= substr(str_shuffle($chars), 0, 1);
  1192. }
  1193. return $tmp;
  1194. }
  1195. // Create config file in the return syntax
  1196. function createConfig($array, $path = 'config/config.php', $nest = 0) {
  1197. // Define Initial Value
  1198. $output = array();
  1199. // Sort Items
  1200. ksort($array);
  1201. // Update the current config version
  1202. if (!$nest) {
  1203. // Inject Current Version
  1204. $output[] = "\t'CONFIG_VERSION' => '".(isset($array['apply_CONFIG_VERSION'])?$array['apply_CONFIG_VERSION']:INSTALLEDVERSION)."'";
  1205. }
  1206. unset($array['CONFIG_VERSION']);
  1207. unset($array['apply_CONFIG_VERSION']);
  1208. // Process Settings
  1209. foreach ($array as $k => $v) {
  1210. $allowCommit = true;
  1211. switch (gettype($v)) {
  1212. case 'boolean':
  1213. $item = ($v?'true':'false');
  1214. break;
  1215. case 'integer':
  1216. case 'double':
  1217. case 'integer':
  1218. case 'NULL':
  1219. $item = $v;
  1220. break;
  1221. case 'string':
  1222. $item = "'".str_replace(array('\\',"'"),array('\\\\',"\'"),$v)."'";
  1223. break;
  1224. case 'array':
  1225. $item = createConfig($v, false, $nest+1);
  1226. break;
  1227. default:
  1228. $allowCommit = false;
  1229. }
  1230. if($allowCommit) {
  1231. $output[] = str_repeat("\t",$nest+1)."'$k' => $item";
  1232. }
  1233. }
  1234. // Build output
  1235. $output = (!$nest?"<?php\nreturn ":'')."array(\n".implode(",\n",$output)."\n".str_repeat("\t",$nest).')'.(!$nest?';':'');
  1236. if (!$nest && $path) {
  1237. $pathDigest = pathinfo($path);
  1238. @mkdir($pathDigest['dirname'], 0770, true);
  1239. if (file_exists($path)) {
  1240. rename($path, $pathDigest['dirname'].'/'.$pathDigest['filename'].'.bak.php');
  1241. }
  1242. $file = fopen($path, 'w');
  1243. fwrite($file, $output);
  1244. fclose($file);
  1245. if (file_exists($path)) {
  1246. return true;
  1247. }
  1248. writeLog("error", "config was unable to write");
  1249. return false;
  1250. } else {
  1251. writeLog("success", "config was updated with new values");
  1252. return $output;
  1253. }
  1254. }
  1255. // Load a config file written in the return syntax
  1256. function loadConfig($path = 'config/config.php') {
  1257. // Adapted from http://stackoverflow.com/a/14173339/6810513
  1258. if (!is_file($path)) {
  1259. return null;
  1260. } else {
  1261. return (array) call_user_func(function() use($path) {
  1262. return include($path);
  1263. });
  1264. }
  1265. }
  1266. // Commit new values to the configuration
  1267. function updateConfig($new, $current = false) {
  1268. // Get config if not supplied
  1269. if ($current === false) {
  1270. $current = loadConfig();
  1271. } else if (is_string($current) && is_file($current)) {
  1272. $current = loadConfig($current);
  1273. }
  1274. // Inject Parts
  1275. foreach ($new as $k => $v) {
  1276. $current[$k] = $v;
  1277. }
  1278. // Return Create
  1279. return createConfig($current);
  1280. }
  1281. // Inject Defaults As Needed
  1282. function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
  1283. if (is_string($path)) {
  1284. $loadedDefaults = loadConfig($path);
  1285. } else {
  1286. $loadedDefaults = $path;
  1287. }
  1288. return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
  1289. }
  1290. // support function for fillDefaultConfig()
  1291. function fillDefaultConfig_recurse($current, $defaults) {
  1292. foreach($defaults as $k => $v) {
  1293. if (!isset($current[$k])) {
  1294. $current[$k] = $v;
  1295. } else if (is_array($current[$k]) && is_array($v)) {
  1296. $current[$k] = fillDefaultConfig_recurse($current[$k], $v);
  1297. }
  1298. }
  1299. return $current;
  1300. };
  1301. // Define Scalar Variables (nest non-secular with underscores)
  1302. function defineConfig($array, $anyCase = true, $nest_prefix = false) {
  1303. foreach($array as $k => $v) {
  1304. if (is_scalar($v) && !defined($nest_prefix.$k)) {
  1305. define($nest_prefix.$k, $v, $anyCase);
  1306. } else if (is_array($v)) {
  1307. defineConfig($v, $anyCase, $nest_prefix.$k.'_');
  1308. }
  1309. }
  1310. }
  1311. // This function exists only because I am lazy
  1312. function configLazy($path = 'config/config.php') {
  1313. // Load config or default
  1314. if (file_exists($path)) {
  1315. $config = fillDefaultConfig(loadConfig($path));
  1316. } else {
  1317. $config = loadConfig('config/configDefaults.php');
  1318. }
  1319. if (is_array($config)) {
  1320. defineConfig($config);
  1321. }
  1322. return $config;
  1323. }
  1324. // Qualify URL
  1325. function qualifyURL($url) {
  1326. //local address?
  1327. if(substr($url, 0,1) == "/"){
  1328. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  1329. $protocol = "https://";
  1330. } else {
  1331. $protocol = "http://";
  1332. }
  1333. $url = $protocol.getServer().$url;
  1334. }
  1335. // Get Digest
  1336. $digest = parse_url($url);
  1337. // http/https
  1338. if (!isset($digest['scheme'])) {
  1339. if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096,32400,7878,8989,8182,8081,6789))) {
  1340. $scheme = 'http';
  1341. } else {
  1342. $scheme = 'https';
  1343. }
  1344. } else {
  1345. $scheme = $digest['scheme'];
  1346. }
  1347. // Host
  1348. $host = (isset($digest['host'])?$digest['host']:'');
  1349. // Port
  1350. $port = (isset($digest['port'])?':'.$digest['port']:'');
  1351. // Path
  1352. $path = (isset($digest['path'])?$digest['path']:'');
  1353. // Output
  1354. return $scheme.'://'.$host.$port.$path;
  1355. }
  1356. // Function to be called at top of each to allow upgrading environment as the spec changes
  1357. function upgradeCheck() {
  1358. // Upgrade to 1.31
  1359. if (file_exists('homepageSettings.ini.php')) {
  1360. $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
  1361. $homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
  1362. $databaseConfig = array_merge($databaseConfig, $homepageConfig);
  1363. $databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
  1364. foreach($databaseConfig as $k => $v) {
  1365. if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
  1366. $databaseData .= $k . " = \"" . $v . "\"\r\n";
  1367. }
  1368. write_ini_file($databaseData, 'databaseLocation.ini.php');
  1369. unlink('homepageSettings.ini.php');
  1370. unset($databaseData);
  1371. unset($homepageConfig);
  1372. }
  1373. // Upgrade to 1.32
  1374. if (file_exists('databaseLocation.ini.php')) {
  1375. // Load Existing
  1376. $config = parse_ini_file('databaseLocation.ini.php', true);
  1377. // Refactor
  1378. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['databaseLocation'].'/');
  1379. $config['user_home'] = $config['database_Location'].'users/';
  1380. unset($config['databaseLocation']);
  1381. // Turn Off Emby And Plex Recent
  1382. $config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
  1383. unset($config["embyPort"]);
  1384. $config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
  1385. unset($config["plexPort"]);
  1386. $config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
  1387. unset($config["nzbgetPort"]);
  1388. $config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
  1389. unset($config["sabnzbdPort"]);
  1390. $config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
  1391. unset($config["headphonesPort"]);
  1392. // Write config file
  1393. $config['CONFIG_VERSION'] = '1.32';
  1394. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][pre1.32].bak.php');
  1395. $createConfigSuccess = createConfig($config);
  1396. // Create new config
  1397. if ($createConfigSuccess) {
  1398. if (file_exists('config/config.php')) {
  1399. // Remove Old ini file
  1400. unlink('databaseLocation.ini.php');
  1401. } else {
  1402. debug_out('Something is not right here!');
  1403. }
  1404. } else {
  1405. debug_out('Couldn\'t create updated configuration.' ,1);
  1406. }
  1407. }
  1408. // Upgrade to 1.33
  1409. $config = loadConfig();
  1410. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
  1411. // Fix User Directory
  1412. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['database_Location'].'/');
  1413. $config['user_home'] = $config['database_Location'].'users/';
  1414. unset($config['USER_HOME']);
  1415. // Backend auth merge
  1416. if (isset($config['authBackendPort']) && !isset(parse_url($config['authBackendHost'])['port'])) {
  1417. $config['authBackendHost'] .= ':'.$config['authBackendPort'];
  1418. }
  1419. unset($config['authBackendPort']);
  1420. // If auth is being used move it to embyURL as that is now used in auth functions
  1421. 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')))) {
  1422. $config['embyURL'] = $config['authBackendHost'];
  1423. }
  1424. // Upgrade database to latest version
  1425. updateSQLiteDB($config['database_Location'],'1.32');
  1426. // Update Version and Commit
  1427. $config['apply_CONFIG_VERSION'] = '1.33';
  1428. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.32].bak.php');
  1429. $createConfigSuccess = createConfig($config);
  1430. unset($config);
  1431. }
  1432. // Upgrade to 1.34
  1433. $config = loadConfig();
  1434. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.34')) {
  1435. // Upgrade database to latest version
  1436. updateSQLiteDB($config['database_Location'],'1.33');
  1437. // Update Version and Commit
  1438. $config['CONFIG_VERSION'] = '1.34';
  1439. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.33].bak.php');
  1440. $createConfigSuccess = createConfig($config);
  1441. unset($config);
  1442. }
  1443. // Upgrade to 1.40
  1444. $config = loadConfig();
  1445. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.40')) {
  1446. // Upgrade database to latest version
  1447. updateSQLiteDB($config['database_Location'],'1.38');
  1448. // Update Version and Commit
  1449. $config['CONFIG_VERSION'] = '1.40';
  1450. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.38].bak.php');
  1451. $createConfigSuccess = createConfig($config);
  1452. unset($config);
  1453. }
  1454. // Upgrade to 1.50
  1455. $config = loadConfig();
  1456. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.50')) {
  1457. // Upgrade database to latest version
  1458. updateSQLiteDB($config['database_Location'],'1.40');
  1459. // Update Version and Commit
  1460. $config['CONFIG_VERSION'] = '1.50';
  1461. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.40].bak.php');
  1462. $createConfigSuccess = createConfig($config);
  1463. unset($config);
  1464. }
  1465. // Upgrade to 1.603
  1466. $config = loadConfig();
  1467. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.603')) {
  1468. // Update Version and Commit
  1469. $config['CONFIG_VERSION'] = '1.603';
  1470. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.601].bak.php');
  1471. $createConfigSuccess = createConfig($config);
  1472. unset($config);
  1473. if(file_exists('org.log')){
  1474. copy('org.log', DATABASE_LOCATION.'org.log');
  1475. unlink('org.log');
  1476. }
  1477. if(file_exists('loginLog.json')){
  1478. copy('loginLog.json', DATABASE_LOCATION.'loginLog.json');
  1479. unlink('loginLog.json');
  1480. }
  1481. }
  1482. return true;
  1483. }
  1484. // Get OS from server
  1485. function getOS(){
  1486. if(PHP_SHLIB_SUFFIX == "dll"){
  1487. return "win";
  1488. }else{
  1489. return "nix";
  1490. }
  1491. }
  1492. //Get Error by Server OS
  1493. function getError($os, $error){
  1494. $ini = (!empty(php_ini_loaded_file()) ? php_ini_loaded_file() : "php.ini");
  1495. $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'");
  1496. $errors = array(
  1497. 'pdo_sqlite' => array(
  1498. 'win' => '<b>PDO:SQLite</b> not enabled, uncomment ;extension=php_pdo_sqlite.dll in the file php.ini | '.$ext,
  1499. 'nix' => '<b>PDO:SQLite</b> not enabled, PHP7 -> run sudo apt-get install php7.0-sqlite | PHP5 -> run sudo apt-get install php5-sqlite',
  1500. ),
  1501. 'sqlite3' => array(
  1502. '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',
  1503. 'nix' => '<b>SQLite3</b> not enabled, run sudo apt-get install php-sqlite3',
  1504. ),
  1505. 'curl' => array(
  1506. 'win' => '<b>cURL</b> not enabled, uncomment ;extension=php_curl.dll in the file php.ini | '.$ext,
  1507. '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',
  1508. ),
  1509. 'zip' => array(
  1510. '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',
  1511. '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',
  1512. ),
  1513. );
  1514. return (isset($errors[$error][$os]) ? $errors[$error][$os] : 'No Error Info Found');
  1515. }
  1516. // Check if all software dependancies are met
  1517. function dependCheck() {
  1518. $output = array();
  1519. $i = 1;
  1520. if (!extension_loaded('pdo_sqlite')) { $output["Step $i"] = getError(getOS(),'pdo_sqlite'); $i++; }
  1521. if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; }
  1522. if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; }
  1523. //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
  1524. if ($output) {
  1525. $output["Step $i"] = "<b>Restart PHP and/or Webserver to apply changes</b>"; $i++;
  1526. $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++;
  1527. debug_out($output,1);
  1528. }
  1529. return true;
  1530. }
  1531. // Process file uploads
  1532. function uploadFiles($path, $ext_mask = null) {
  1533. if (isset($_FILES) && count($_FILES)) {
  1534. require_once('class.uploader.php');
  1535. $uploader = new Uploader();
  1536. $data = $uploader->upload($_FILES['files'], array(
  1537. 'limit' => 10,
  1538. 'maxSize' => 10,
  1539. 'extensions' => $ext_mask,
  1540. 'required' => false,
  1541. 'uploadDir' => str_replace('//','/',$path.'/'),
  1542. 'title' => array('name'),
  1543. 'removeFiles' => true,
  1544. 'replace' => true,
  1545. ));
  1546. if($data['isComplete']){
  1547. $files = $data['data'];
  1548. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1549. echo json_encode($files['metas'][0]['name']);
  1550. }
  1551. if($data['hasErrors']){
  1552. $errors = $data['errors'];
  1553. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1554. echo json_encode($errors);
  1555. }
  1556. } else {
  1557. writeLog("error", "image was not uploaded");
  1558. echo json_encode('No files submitted!');
  1559. }
  1560. }
  1561. // Process file uploads
  1562. function uploadAvatar($path, $ext_mask = null) {
  1563. if (isset($_FILES) && count($_FILES)) {
  1564. require_once('class.uploader.php');
  1565. $uploader = new Uploader();
  1566. $data = $uploader->upload($_FILES['files'], array(
  1567. 'limit' => 10,
  1568. 'maxSize' => 10,
  1569. 'extensions' => $ext_mask,
  1570. 'required' => false,
  1571. 'uploadDir' => str_replace('//','/',$path.'/'),
  1572. 'title' => array('name'),
  1573. 'removeFiles' => true,
  1574. 'replace' => true,
  1575. ));
  1576. if($data['isComplete']){
  1577. $files = $data['data'];
  1578. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1579. echo json_encode($files['metas'][0]['name']);
  1580. }
  1581. if($data['hasErrors']){
  1582. $errors = $data['errors'];
  1583. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1584. echo json_encode($errors);
  1585. }
  1586. } else {
  1587. writeLog("error", "image was not uploaded");
  1588. echo json_encode('No files submitted!');
  1589. }
  1590. }
  1591. // Remove file
  1592. function removeFiles($path) {
  1593. if(is_file($path)) {
  1594. writeLog("success", "file was removed");
  1595. unlink($path);
  1596. } else {
  1597. writeLog("error", "file was not removed");
  1598. echo json_encode('No file specified for removal!');
  1599. }
  1600. }
  1601. // Lazy select options
  1602. function resolveSelectOptions($array, $selected = '', $multi = false) {
  1603. $output = array();
  1604. $selectedArr = ($multi?explode('|', $selected):array());
  1605. foreach ($array as $key => $value) {
  1606. if (is_array($value)) {
  1607. if (isset($value['optgroup'])) {
  1608. $output[] = '<optgroup label="'.$key.'">';
  1609. foreach($value['optgroup'] as $k => $v) {
  1610. $output[] = '<option value="'.$v['value'].'"'.($selected===$v['value']||in_array($v['value'],$selectedArr)?' selected':'').(isset($v['disabled']) && $v['disabled']?' disabled':'').'>'.$k.'</option>';
  1611. }
  1612. } else {
  1613. $output[] = '<option value="'.$value['value'].'"'.($selected===$value['value']||in_array($value['value'],$selectedArr)?' selected':'').(isset($value['disabled']) && $value['disabled']?' disabled':'').'>'.$key.'</option>';
  1614. }
  1615. } else {
  1616. $output[] = '<option value="'.$value.'"'.($selected===$value||in_array($value,$selectedArr)?' selected':'').'>'.$key.'</option>';
  1617. }
  1618. }
  1619. return implode('',$output);
  1620. }
  1621. // Check if user is allowed to continue
  1622. function qualifyUser($type, $errOnFail = false) {
  1623. if (!isset($GLOBALS['USER'])) {
  1624. require_once("user.php");
  1625. $GLOBALS['USER'] = new User('registration_callback');
  1626. }
  1627. if (is_bool($type)) {
  1628. if ($type === true) {
  1629. $authorized = ($GLOBALS['USER']->authenticated == true);
  1630. } else {
  1631. $authorized = true;
  1632. }
  1633. } elseif (is_string($type) || is_array($type)) {
  1634. if ($type !== 'false') {
  1635. if (!is_array($type)) {
  1636. $type = explode('|',$type);
  1637. }
  1638. $authorized = ($GLOBALS['USER']->authenticated && in_array($GLOBALS['USER']->role,$type));
  1639. } else {
  1640. $authorized = true;
  1641. }
  1642. } else {
  1643. debug_out('Invalid Syntax!',1);
  1644. }
  1645. if (!$authorized && $errOnFail) {
  1646. if ($GLOBALS['USER']->authenticated) {
  1647. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401');
  1648. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401\'</script>';
  1649. } else {
  1650. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999');
  1651. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999\'</script>';
  1652. }
  1653. debug_out('Not Authorized' ,1);
  1654. } else {
  1655. return $authorized;
  1656. }
  1657. }
  1658. // Build an (optionally) tabbed settings page.
  1659. function buildSettings($array) {
  1660. /*
  1661. array(
  1662. 'title' => '',
  1663. 'id' => '',
  1664. 'fields' => array( See buildField() ),
  1665. 'tabs' => array(
  1666. array(
  1667. 'title' => '',
  1668. 'id' => '',
  1669. 'image' => '',
  1670. 'fields' => array( See buildField() ),
  1671. ),
  1672. ),
  1673. );
  1674. */
  1675. $notifyExplode = explode("-", NOTIFYEFFECT);
  1676. $fieldFunc = function($fieldArr) {
  1677. $fields = '<div class="row">';
  1678. foreach($fieldArr as $key => $value) {
  1679. $isSingle = isset($value['type']);
  1680. if ($isSingle) { $value = array($value); }
  1681. $tmpField = '';
  1682. $sizeLg = max(floor(12/count($value)),2);
  1683. $sizeMd = max(floor(($isSingle?12:6)/count($value)),3);
  1684. foreach($value as $k => $v) {
  1685. $tmpField .= buildField($v, 12, $sizeMd, $sizeLg);
  1686. }
  1687. $fields .= ($isSingle?$tmpField:'<div class="row col-sm-12 content-form">'.$tmpField.'</div>');
  1688. }
  1689. $fields .= '</div>';
  1690. return $fields;
  1691. };
  1692. $fields = (isset($array['fields'])?$fieldFunc($array['fields']):'');
  1693. $tabSelectors = array();
  1694. $tabContent = array();
  1695. if (isset($array['tabs'])) {
  1696. foreach($array['tabs'] as $key => $value) {
  1697. $id = (isset($value['id'])?$value['id']:randString(32));
  1698. $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>';
  1699. $tabContent[$key] = '<div class="tab-pane big-box fade'.($tabContent?'':' active in').'" id="tab-'.$id.'">'.$fieldFunc($value['fields']).'</div>';
  1700. }
  1701. }
  1702. $pageID = (isset($array['id'])?$array['id']:str_replace(array(' ','"',"'"),array('_'),strtolower($array['id'])));
  1703. $extraClick = ($pageID == 'appearance_settings' ? "$('#advanced_settings_form_submit').click();console.log('add theme settings');" : "");
  1704. return '
  1705. <div class="email-body">
  1706. <div class="email-header gray-bg">
  1707. <button type="button" class="btn btn-danger btn-sm waves close-button"><i class="fa fa-close"></i></button>
  1708. <button id="'.$pageID.'_form_submit" class="btn waves btn-labeled btn-success btn btn-sm text-uppercase waves-effect waves-float save-btn-form">
  1709. <span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save
  1710. </button>
  1711. <h1>'.$array['title'].'</h1>
  1712. </div>
  1713. <div class="email-inner small-box">
  1714. <div class="email-inner-section">
  1715. <div class="small-box fade in" id="'.$pageID.'_frame">
  1716. <div class="col-lg-12">
  1717. '.(isset($array['customBeforeForm'])?$array['customBeforeForm']:'').'
  1718. <form class="content-form" name="'.$pageID.'" id="'.$pageID.'_form" onsubmit="return false;">
  1719. '.$fields.($tabContent?'
  1720. <div class="tabbable tabs-with-bg" id="'.$pageID.'_tabs">
  1721. <ul class="nav nav-tabs apps">
  1722. '.implode('', $tabSelectors).'
  1723. </ul>
  1724. <div class="clearfix"></div>
  1725. <div class="tab-content">
  1726. '.implode('', $tabContent).'
  1727. </div>
  1728. </div>':'').'
  1729. </form>
  1730. '.(isset($array['customAfterForm'])?$array['customAfterForm']:'').'
  1731. </div>
  1732. </div>
  1733. </div>
  1734. </div>
  1735. </div>
  1736. <script>
  1737. $(document).ready(function() {
  1738. $(\'#'.$pageID.'_form\').find(\'input, select, textarea\').on(\'change\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1739. var '.$pageID.'Validate = function() { if (this.value && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { $(this).addClass(\'invalid\'); } else { $(this).removeClass(\'invalid\'); } };
  1740. $(\'#'.$pageID.'_form\').find(\'input[pattern]\').each('.$pageID.'Validate).on(\'keyup\', '.$pageID.'Validate);
  1741. $(\'#'.$pageID.'_form\').find(\'select[multiple]\').on(\'change click\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1742. $(\'#'.$pageID.'_form_submit\').on(\'click\', function () {
  1743. var newVals = {};
  1744. var hasVals = false;
  1745. var errorFields = [];
  1746. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').each(function() {
  1747. hasVals = true;
  1748. if (this.type == \'checkbox\') {
  1749. newVals[this.name] = this.checked;
  1750. } else if ($(this).hasClass(\'summernote\')) {
  1751. newVals[$(this).attr(\'name\')] = $(this).siblings(\'.note-editor\').find(\'.panel-body\').html();
  1752. } else {
  1753. if (this.value && this.pattern && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { errorFields.push(this.name); }
  1754. var fieldVal = $(this).val();
  1755. if (typeof fieldVal == \'object\') {
  1756. if (typeof fieldVal.join == \'function\') {
  1757. fieldVal = fieldVal.join(\'|\');
  1758. } else {
  1759. fieldVal = JSON.stringify(fieldVal);
  1760. }
  1761. }
  1762. newVals[this.name] = fieldVal;
  1763. }
  1764. });
  1765. if (errorFields.length) {
  1766. parent.notify(\'Fields have errors: \'+errorFields.join(\', \')+\'!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1767. } else if (hasVals) {
  1768. console.log(newVals);
  1769. ajax_request(\'POST\', \''.(isset($array['submitAction'])?$array['submitAction']:'update-config').'\', newVals, function(data, code) {
  1770. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').removeAttr(\'data-changed\');
  1771. });
  1772. '.$extraClick.'
  1773. } else {
  1774. parent.notify(\'Nothing to update!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1775. }
  1776. return false;
  1777. });
  1778. '.(isset($array['onready'])?$array['onready']:'').'
  1779. });
  1780. </script>
  1781. ';
  1782. }
  1783. // Build Settings Fields
  1784. function buildField($params, $sizeSm = 12, $sizeMd = 12, $sizeLg = 12) {
  1785. /*
  1786. array(
  1787. 'type' => '',
  1788. 'placeholder' => '',
  1789. 'label' => '',
  1790. 'labelTranslate' => '',
  1791. 'assist' => '',
  1792. 'name' => '',
  1793. 'pattern' => '',
  1794. 'options' => array( // For SELECT only
  1795. 'Display' => 'value',
  1796. ),
  1797. )
  1798. */
  1799. // Tags
  1800. $tags = array();
  1801. foreach(array('placeholder','style','disabled','readonly','pattern','min','max','required','onkeypress','onchange','onfocus','onleave','href','onclick') as $value) {
  1802. if (isset($params[$value])) {
  1803. if (is_string($params[$value])) { $tags[] = $value.'="'.$params[$value].'"';
  1804. } else if ($params[$value] === true) { $tags[] = $value; }
  1805. }
  1806. }
  1807. $format = (isset($params['format']) && in_array($params['format'],array(false,'colour','color'))?$params['format']:false);
  1808. $name = (isset($params['name'])?$params['name']:(isset($params['id'])?$params['id']:''));
  1809. $id = (isset($params['id'])?$params['id']:(isset($params['name'])?$params['name'].'_id':randString(32)));
  1810. $val = (isset($params['value'])?$params['value']:'');
  1811. $class = (isset($params['class'])?' '.$params['class']:'');
  1812. $wrapClass = (isset($params['wrapClass'])?$params['wrapClass']:'form-content');
  1813. $assist = (isset($params['assist'])?' - i.e. '.$params['assist']:'');
  1814. $label = (isset($params['labelTranslate'])?translate($params['labelTranslate']):(isset($params['label'])?$params['label']:''));
  1815. $labelOut = '<p class="help-text">'.$label.$assist.'</p>';
  1816. // Field Design
  1817. switch ($params['type']) {
  1818. case 'text':
  1819. case 'number':
  1820. case 'password':
  1821. $field = '<input id="'.$id.'" name="'.$name.'" type="'.$params['type'].'" class="form-control material input-sm'.$class.'" '.implode(' ',$tags).' autocorrect="off" autocapitalize="off" value="'.$val.'">';
  1822. break;
  1823. case 'select':
  1824. case 'dropdown':
  1825. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control material input-sm" '.implode(' ',$tags).'>'.resolveSelectOptions($params['options'], $val).'</select>';
  1826. break;
  1827. case 'select-multi':
  1828. case 'dropdown-multi':
  1829. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control input-sm" '.implode(' ',$tags).' multiple="multiple">'.resolveSelectOptions($params['options'], $val, true).'</select>';
  1830. break;
  1831. case 'check':
  1832. case 'checkbox':
  1833. case 'toggle':
  1834. $checked = ((is_bool($val) && $val) || trim($val) === 'true'?' checked':'');
  1835. $colour = (isset($params['colour'])?$params['colour']:'success');
  1836. $labelOut = '<label for="'.$id.'"></label>'.$label;
  1837. $field = '<input id="'.$id.'" name="'.$name.'" type="checkbox" class="switcher switcher-'.$colour.' '.$class.'" '.implode(' ',$tags).' data-value="'.$val.'"'.$checked.'>';
  1838. break;
  1839. case 'radio':
  1840. $labelOut = '';
  1841. $checked = ((is_bool($val) && $val) || ($val && trim($val) !== 'false')?' checked':'');
  1842. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1843. $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>';
  1844. break;
  1845. case 'date':
  1846. $field = 'Unsupported, planned.';
  1847. break;
  1848. case 'hidden':
  1849. return '<input id="'.$id.'" name="'.$name.'" type="hidden" class="'.$class.'" '.implode(' ',$tags).' value="'.$val.'">';
  1850. break;
  1851. case 'header':
  1852. $labelOut = '';
  1853. $headType = (isset($params['value'])?$params['value']:3);
  1854. $field = '<h'.$headType.' class="'.$class.'" '.implode(' ',$tags).'>'.$label.'</h'.$headType.'>';
  1855. break;
  1856. case 'button':
  1857. $labelOut = '';
  1858. $icon = (isset($params['icon'])?$params['icon']:'flask');
  1859. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1860. $bDropdown = (isset($params['buttonDrop'])?$params['buttonDrop']:'');
  1861. $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>':'');
  1862. break;
  1863. case 'textarea':
  1864. $rows = (isset($params['rows'])?$params['rows']:5);
  1865. $field = '<textarea id="'.$id.'" name="'.$name.'" class="form-control'.$class.'" rows="'.$rows.'" '.implode(' ',$tags).'>'.$val.'</textarea>';
  1866. break;
  1867. case 'custom':
  1868. // Settings
  1869. $settings = array(
  1870. '$id' => $id,
  1871. '$name' => $name,
  1872. '$val' => $val,
  1873. '$label' => $label,
  1874. '$labelOut' => $labelOut,
  1875. );
  1876. // Get HTML
  1877. $html = (isset($params['html'])?$params['html']:'Nothing Specified!');
  1878. // If LabelOut is in html dont print it twice
  1879. $labelOut = (strpos($html,'$label')!==false?'':$labelOut);
  1880. // Replace variables in settings
  1881. $html = preg_replace_callback('/\$\w+\b/', function ($match) use ($settings) { return (isset($settings[$match[0]])?$settings[$match[0]]:'{'.$match[0].' is undefined}'); }, $html);
  1882. // Build Field
  1883. $field = '<div id="'.$id.'_html" class="custom-field">'.$html.'</div>';
  1884. break;
  1885. case 'space':
  1886. $labelOut = '';
  1887. $field = str_repeat('<br>', (isset($params['value'])?$params['value']:1));
  1888. break;
  1889. default:
  1890. $field = 'Unsupported field type';
  1891. break;
  1892. }
  1893. // Field Formats
  1894. switch ($format) {
  1895. case 'colour': // Fuckin Eh, Canada!
  1896. case 'color':
  1897. $labelBef = '<center>'.$label.'</center>';
  1898. $wrapClass = 'gray-bg colour-field';
  1899. $labelAft = '';
  1900. $field = str_replace(' material input-sm','',$field);
  1901. break;
  1902. default:
  1903. $labelBef = '';
  1904. $labelAft = $labelOut;
  1905. }
  1906. return '<div class="'.$wrapClass.' col-sm-'.$sizeSm.' col-md-'.$sizeMd.' col-lg-'.$sizeLg.'">'.$labelBef.$field.$labelAft.'</div>';
  1907. }
  1908. // Tab Settings Generation
  1909. function printTabRow($data) {
  1910. $hidden = false;
  1911. if ($data===false) {
  1912. $hidden = true;
  1913. $data = array( // New Tab Defaults
  1914. 'id' => 'new',
  1915. 'name' => '',
  1916. 'url' => '',
  1917. 'icon' => 'fa-diamond',
  1918. 'iconurl' => '',
  1919. 'active' => 'true',
  1920. 'user' => 'true',
  1921. 'guest' => 'true',
  1922. 'window' => 'false',
  1923. 'splash' => 'true',
  1924. 'ping' => 'false',
  1925. 'ping_url' => '',
  1926. 'defaultz' => '',
  1927. );
  1928. }
  1929. $image = '<span style="font: normal normal normal 30px/1 FontAwesome;" class="fa fa-hand-paper-o"></span>';
  1930. $output = '
  1931. <li id="tab-'.$data['id'].'" class="list-group-item" style="position: relative; left: 0px; top: 0px; '.($hidden?' display: none;':'').'">
  1932. <tab class="content-form form-inline">
  1933. <div class="row">
  1934. '.buildField(array(
  1935. 'type' => 'custom',
  1936. '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>',
  1937. ),12,1,1).'
  1938. '.buildField(array(
  1939. 'type' => 'hidden',
  1940. 'id' => 'tab-'.$data['id'].'-id',
  1941. 'name' => 'id['.$data['id'].']',
  1942. 'value' => $data['id'],
  1943. ),12,2,1).'
  1944. '.buildField(array(
  1945. 'type' => 'text',
  1946. 'id' => 'tab-'.$data['id'].'-name',
  1947. 'name' => 'name['.$data['id'].']',
  1948. 'required' => true,
  1949. 'placeholder' => 'Organizr Homepage',
  1950. 'labelTranslate' => 'TAB_NAME',
  1951. 'value' => $data['name'],
  1952. 'class' => 'darkBold',
  1953. ),12,2,1).'
  1954. '.buildField(array(
  1955. 'type' => 'text',
  1956. 'id' => 'tab-'.$data['id'].'-url',
  1957. 'name' => 'url['.$data['id'].']',
  1958. 'required' => true,
  1959. 'placeholder' => 'homepage.php',
  1960. 'labelTranslate' => 'TAB_URL',
  1961. 'value' => $data['url'],
  1962. 'class' => 'darkBold',
  1963. ),12,2,2).'
  1964. '.buildField(array(
  1965. 'type' => 'text',
  1966. 'id' => 'tab-'.$data['id'].'-iconurl',
  1967. 'name' => 'iconurl['.$data['id'].']',
  1968. 'placeholder' => 'images/organizr.png',
  1969. 'labelTranslate' => 'ICON_URL',
  1970. 'value' => $data['iconurl'],
  1971. 'class' => 'darkBold',
  1972. ),12,2,1).'
  1973. '.buildField(array(
  1974. 'type' => 'text',
  1975. 'id' => 'tab-'.$data['id'].'-icon',
  1976. 'name' => 'icon['.$data['id'].']',
  1977. 'placeholder' => 'fa-icon',
  1978. 'labelTranslate' => 'OR_ICON_NAME',
  1979. 'value' => $data['icon'],
  1980. 'class' => 'iconpickeradd darkBold',
  1981. ),12,1,1).'
  1982. '.buildField(array(
  1983. 'type' => 'text',
  1984. 'id' => 'tab-'.$data['id'].'-ping_url',
  1985. 'name' => 'ping_url['.$data['id'].']',
  1986. 'placeholder' => 'host:port',
  1987. 'labelTranslate' => 'PING_URL',
  1988. 'value' => $data['ping_url'],
  1989. 'class' => 'darkBold',
  1990. ),12,2,1).'
  1991. '.buildField(array(
  1992. 'type' => 'radio',
  1993. 'labelTranslate' => 'DEFAULT',
  1994. 'name' => 'defaultz['.$data['id'].']',
  1995. 'value' => $data['defaultz'],
  1996. 'onclick' => "$('[type=radio][id!=\''+this.id+'\']').each(function() { this.checked=false; });",
  1997. ),12,1,1).'
  1998. '.buildField(array(
  1999. 'type' => 'button',
  2000. 'icon' => 'chevron-down',
  2001. 'buttonType' => 'success',
  2002. 'labelTranslate' => 'MORE',
  2003. 'onclick' => "$(this).parent().parent().parent().find('.slideInUp').toggle()",
  2004. 'class' => 'toggleTabExtra',
  2005. ),12,1,1).'
  2006. '.buildField(array(
  2007. 'type' => 'button',
  2008. 'icon' => 'trash',
  2009. 'buttonType' => 'danger',
  2010. 'labelTranslate' => 'REMOVE',
  2011. 'onclick' => "$(this).parents('li').remove();",
  2012. ),12,1,1).'</div><div id = "tab-'.$data['id'].'-row" class = "row animated slideInUp" style = "display:none;" ><div></div>
  2013. '.buildField(array(
  2014. 'type' => 'checkbox',
  2015. 'labelTranslate' => 'ACTIVE',
  2016. 'name' => 'active['.$data['id'].']',
  2017. 'value' => $data['active'],
  2018. ),12,1,1).'
  2019. '.buildField(array(
  2020. 'type' => 'checkbox',
  2021. 'labelTranslate' => 'USER',
  2022. 'colour' => 'primary',
  2023. 'name' => 'user['.$data['id'].']',
  2024. 'value' => $data['user'],
  2025. ),12,1,1).'
  2026. '.buildField(array(
  2027. 'type' => 'checkbox',
  2028. 'labelTranslate' => 'GUEST',
  2029. 'colour' => 'warning',
  2030. 'name' => 'guest['.$data['id'].']',
  2031. 'value' => $data['guest'],
  2032. ),12,1,1).'
  2033. '.buildField(array(
  2034. 'type' => 'checkbox',
  2035. 'labelTranslate' => 'NO_IFRAME',
  2036. 'colour' => 'danger',
  2037. 'name' => 'window['.$data['id'].']',
  2038. 'value' => $data['window'],
  2039. ),12,1,1).'
  2040. '.buildField(array(
  2041. 'type' => 'checkbox',
  2042. 'labelTranslate' => 'SPLASH',
  2043. 'colour' => 'success',
  2044. 'name' => 'splash['.$data['id'].']',
  2045. 'value' => $data['splash'],
  2046. ),12,1,1).'
  2047. '.buildField(array(
  2048. 'type' => 'checkbox',
  2049. 'labelTranslate' => 'PING',
  2050. 'colour' => 'success',
  2051. 'name' => 'ping['.$data['id'].']',
  2052. 'value' => $data['ping'],
  2053. ),12,1,1).'
  2054. </div>
  2055. </tab>
  2056. </li>
  2057. ';
  2058. return $output;
  2059. }
  2060. // Timezone array
  2061. function timezoneOptions() {
  2062. $output = array();
  2063. $timezones = array();
  2064. $regions = array(
  2065. 'Africa' => DateTimeZone::AFRICA,
  2066. 'America' => DateTimeZone::AMERICA,
  2067. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2068. 'Arctic' => DateTimeZone::ARCTIC,
  2069. 'Asia' => DateTimeZone::ASIA,
  2070. 'Atlantic' => DateTimeZone::ATLANTIC,
  2071. 'Australia' => DateTimeZone::AUSTRALIA,
  2072. 'Europe' => DateTimeZone::EUROPE,
  2073. 'Indian' => DateTimeZone::INDIAN,
  2074. 'Pacific' => DateTimeZone::PACIFIC
  2075. );
  2076. foreach ($regions as $name => $mask) {
  2077. $zones = DateTimeZone::listIdentifiers($mask);
  2078. foreach($zones as $timezone) {
  2079. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2080. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2081. $output[$name]['optgroup'][substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm]['value'] = $timezone;
  2082. }
  2083. }
  2084. return $output;
  2085. }
  2086. // Build Database
  2087. function createSQLiteDB($path = false) {
  2088. if ($path === false) {
  2089. if (DATABASE_LOCATION){
  2090. $path = DATABASE_LOCATION;
  2091. } else {
  2092. debug_out('No Path Specified!');
  2093. }
  2094. }
  2095. if (!is_file($path.'users.db') || filesize($path.'users.db') <= 0) {
  2096. if (!isset($GLOBALS['file_db'])) {
  2097. $GLOBALS['file_db'] = new PDO('sqlite:'.$path.'users.db');
  2098. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2099. }
  2100. // Create Users
  2101. $users = $GLOBALS['file_db']->query('CREATE TABLE `users` (
  2102. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2103. `username` TEXT UNIQUE,
  2104. `password` TEXT,
  2105. `email` TEXT,
  2106. `token` TEXT,
  2107. `role` TEXT,
  2108. `active` TEXT,
  2109. `last` TEXT,
  2110. `auth_service` TEXT DEFAULT \'internal\'
  2111. );');
  2112. // Create Tabs
  2113. $tabs = $GLOBALS['file_db']->query('CREATE TABLE `tabs` (
  2114. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2115. `order` INTEGER,
  2116. `users_id` INTEGER,
  2117. `name` TEXT,
  2118. `url` TEXT,
  2119. `defaultz` TEXT,
  2120. `active` TEXT,
  2121. `user` TEXT,
  2122. `guest` TEXT,
  2123. `icon` TEXT,
  2124. `iconurl` TEXT,
  2125. `window` TEXT,
  2126. `splash` TEXT,
  2127. `ping` TEXT,
  2128. `ping_url` TEXT
  2129. );');
  2130. // Create Options
  2131. $options = $GLOBALS['file_db']->query('CREATE TABLE `options` (
  2132. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2133. `users_id` INTEGER UNIQUE,
  2134. `title` TEXT UNIQUE,
  2135. `topbar` TEXT,
  2136. `bottombar` TEXT,
  2137. `sidebar` TEXT,
  2138. `hoverbg` TEXT,
  2139. `topbartext` TEXT,
  2140. `activetabBG` TEXT,
  2141. `activetabicon` TEXT,
  2142. `activetabtext` TEXT,
  2143. `inactiveicon` TEXT,
  2144. `inactivetext` TEXT,
  2145. `loading` TEXT,
  2146. `hovertext` TEXT
  2147. );');
  2148. // Create Invites
  2149. $invites = $GLOBALS['file_db']->query('CREATE TABLE `invites` (
  2150. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2151. `code` TEXT UNIQUE,
  2152. `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  2153. `email` TEXT,
  2154. `username` TEXT,
  2155. `dateused` TIMESTAMP,
  2156. `usedby` TEXT,
  2157. `ip` TEXT,
  2158. `valid` TEXT
  2159. );');
  2160. writeLog("success", "database created/saved");
  2161. return $users && $tabs && $options && $invites;
  2162. } else {
  2163. writeLog("error", "database was unable to be created/saved");
  2164. return false;
  2165. }
  2166. }
  2167. // Upgrade Database
  2168. function updateSQLiteDB($db_path = false, $oldVerNum = false) {
  2169. if (!$db_path) {
  2170. if (defined('DATABASE_LOCATION')) {
  2171. $db_path = DATABASE_LOCATION;
  2172. } else {
  2173. debug_out('No Path Specified',1);
  2174. }
  2175. }
  2176. if (!isset($GLOBALS['file_db'])) {
  2177. $GLOBALS['file_db'] = new PDO('sqlite:'.$db_path.'users.db');
  2178. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2179. }
  2180. // Cache current DB
  2181. $cache = array();
  2182. foreach($GLOBALS['file_db']->query('SELECT name FROM sqlite_master WHERE type="table";') as $table) {
  2183. foreach($GLOBALS['file_db']->query('SELECT * FROM '.$table['name'].';') as $key => $row) {
  2184. foreach($row as $k => $v) {
  2185. if (is_string($k)) {
  2186. $cache[$table['name']][$key][$k] = $v;
  2187. }
  2188. }
  2189. }
  2190. }
  2191. // Remove Current Database
  2192. $GLOBALS['file_db'] = null;
  2193. $pathDigest = pathinfo($db_path.'users.db');
  2194. if (file_exists($db_path.'users.db')) {
  2195. rename($db_path.'users.db', $pathDigest['dirname'].'/'.$pathDigest['filename'].'['.date('Y-m-d_H-i-s').']'.($oldVerNum?'['.$oldVerNum.']':'').'.bak.db');
  2196. }
  2197. // Create New Database
  2198. $success = createSQLiteDB($db_path);
  2199. // Restore Items
  2200. if ($success) {
  2201. foreach($cache as $table => $tableData) {
  2202. if ($tableData) {
  2203. $queryBase = 'INSERT INTO '.$table.' (`'.implode('`,`',array_keys(current($tableData))).'`) values ';
  2204. $insertValues = array();
  2205. reset($tableData);
  2206. foreach($tableData as $key => $value) {
  2207. $insertValues[] = '('.implode(',',array_map(function($d) {
  2208. return (isset($d)?$GLOBALS['file_db']->quote($d):'null');
  2209. }, $value)).')';
  2210. }
  2211. $GLOBALS['file_db']->query($queryBase.implode(',',$insertValues).';');
  2212. }
  2213. }
  2214. writeLog("success", "database values have been updated");
  2215. return true;
  2216. } else {
  2217. writeLog("error", "database values unable to be updated");
  2218. return false;
  2219. }
  2220. }
  2221. // Commit colours to database
  2222. function updateDBOptions($values) {
  2223. if (!isset($GLOBALS['file_db'])) {
  2224. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2225. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2226. }
  2227. // Commit new values to database
  2228. if ($GLOBALS['file_db']->query('UPDATE options SET '.implode(',',array_map(function($d, $k) {
  2229. return '`'.$k.'` = '.(isset($d)?"'".addslashes($d)."'":'null');
  2230. }, $values, array_keys($values))).';')->rowCount()) {
  2231. return true;
  2232. } else if ($GLOBALS['file_db']->query('INSERT OR IGNORE INTO options (`'.implode('`,`',array_keys($values)).'`) VALUES (\''.implode("','",$values).'\');')->rowCount()) {
  2233. writeLog("success", "database values for options table have been updated");
  2234. return true;
  2235. } else {
  2236. writeLog("error", "database values for options table unable to be updated");
  2237. return false;
  2238. }
  2239. }
  2240. // Send AJAX notification
  2241. function sendNotification($success, $message = false, $send = true) {
  2242. $notifyExplode = explode("-", NOTIFYEFFECT);
  2243. if ($success) {
  2244. $msg = array(
  2245. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_SAVED").'</strong>'),
  2246. 'icon' => 'floppy-o',
  2247. 'type' => 'success',
  2248. 'length' => '5000',
  2249. 'layout' => $notifyExplode[0],
  2250. 'effect' => $notifyExplode[1],
  2251. );
  2252. } else {
  2253. $msg = array(
  2254. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_NOT_SAVED").'</strong>'),
  2255. 'icon' => 'floppy-o',
  2256. 'type' => 'failed',
  2257. 'length' => '5000',
  2258. 'layout' => $notifyExplode[0],
  2259. 'effect' => $notifyExplode[1],
  2260. );
  2261. }
  2262. // Send and kill script?
  2263. if ($send) {
  2264. header('Content-Type: application/json');
  2265. echo json_encode(array('notify'=>$msg));
  2266. die();
  2267. }
  2268. return $msg;
  2269. }
  2270. // Load colours from the database
  2271. function loadAppearance() {
  2272. // Defaults
  2273. $defaults = array(
  2274. 'title' => 'Organizr',
  2275. 'topbartext' => '#66D9EF',
  2276. 'topbar' => '#333333',
  2277. 'bottombar' => '#333333',
  2278. 'sidebar' => '#393939',
  2279. 'hoverbg' => '#AD80FD',
  2280. 'activetabBG' => '#F92671',
  2281. 'activetabicon' => '#FFFFFF',
  2282. 'activetabtext' => '#FFFFFF',
  2283. 'inactiveicon' => '#66D9EF',
  2284. 'inactivetext' => '#66D9EF',
  2285. 'loading' => '#66D9EF',
  2286. 'hovertext' => '#000000',
  2287. );
  2288. if (DATABASE_LOCATION) {
  2289. if(is_file(DATABASE_LOCATION.'users.db') && filesize(DATABASE_LOCATION.'users.db') > 0){
  2290. if (!isset($GLOBALS['file_db'])) {
  2291. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2292. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2293. }
  2294. // Database Lookup
  2295. $options = $GLOBALS['file_db']->query('SELECT * FROM options');
  2296. // Replace defaults with filled options
  2297. foreach($options as $row) {
  2298. foreach($defaults as $key => $value) {
  2299. if (isset($row[$key]) && $row[$key]) {
  2300. $defaults[$key] = $row[$key];
  2301. }
  2302. }
  2303. }
  2304. }
  2305. }
  2306. // Return the Results
  2307. return $defaults;
  2308. }
  2309. // Delete Database
  2310. function deleteDatabase() {
  2311. unset($_COOKIE['Organizr']);
  2312. setcookie('Organizr', '', time() - 3600, '/');
  2313. unset($_COOKIE['OrganizrU']);
  2314. setcookie('OrganizrU', '', time() - 3600, '/');
  2315. $GLOBALS['file_db'] = null;
  2316. unlink(DATABASE_LOCATION.'users.db');
  2317. foreach(glob(substr_replace($userdirpath, "", -1).'/*') as $file) {
  2318. if(is_dir($file)) {
  2319. rmdir($file);
  2320. } elseif (!is_dir($file)) {
  2321. unlink($file);
  2322. }
  2323. }
  2324. rmdir($userdirpath);
  2325. writeLog("success", "database has been deleted");
  2326. return true;
  2327. }
  2328. // Upgrade the installation
  2329. function upgradeInstall($branch = 'master') {
  2330. function downloadFile($url, $path){
  2331. ini_set('max_execution_time',0);
  2332. $folderPath = "upgrade/";
  2333. if(!mkdir($folderPath)){
  2334. writeLog("error", "organizr could not create upgrade folder");
  2335. }
  2336. $newfname = $folderPath . $path;
  2337. $file = fopen ($url, 'rb');
  2338. if ($file) {
  2339. $newf = fopen ($newfname, 'wb');
  2340. if ($newf) {
  2341. while(!feof($file)) {
  2342. fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
  2343. }
  2344. }
  2345. }else{
  2346. writeLog("error", "organizr could not download $url");
  2347. }
  2348. if ($file) {
  2349. fclose($file);
  2350. writeLog("success", "organizr finished downloading the github zip file");
  2351. }else{
  2352. writeLog("error", "organizr could not download the github zip file");
  2353. }
  2354. if ($newf) {
  2355. fclose($newf);
  2356. writeLog("success", "organizr created upgrade zip file from github zip file");
  2357. }else{
  2358. writeLog("error", "organizr could not create upgrade zip file from github zip file");
  2359. }
  2360. }
  2361. function unzipFile($zipFile){
  2362. $zip = new ZipArchive;
  2363. $extractPath = "upgrade/";
  2364. if($zip->open($extractPath . $zipFile) != "true"){
  2365. writeLog("error", "organizr could not unzip upgrade.zip");
  2366. }else{
  2367. writeLog("success", "organizr unzipped upgrade.zip");
  2368. }
  2369. /* Extract Zip File */
  2370. $zip->extractTo($extractPath);
  2371. $zip->close();
  2372. }
  2373. // Function to remove folders and files
  2374. function rrmdir($dir) {
  2375. if (is_dir($dir)) {
  2376. $files = scandir($dir);
  2377. foreach ($files as $file)
  2378. if ($file != "." && $file != "..") rrmdir("$dir/$file");
  2379. rmdir($dir);
  2380. }
  2381. else if (file_exists($dir)) unlink($dir);
  2382. }
  2383. // Function to Copy folders and files
  2384. function rcopy($src, $dst) {
  2385. if (is_dir ( $src )) {
  2386. if (!file_exists($dst)) : mkdir ( $dst ); endif;
  2387. $files = scandir ( $src );
  2388. foreach ( $files as $file )
  2389. if ($file != "." && $file != "..")
  2390. rcopy ( "$src/$file", "$dst/$file" );
  2391. } else if (file_exists ( $src ))
  2392. copy ( $src, $dst );
  2393. }
  2394. $url = 'https://github.com/causefx/Organizr/archive/'.$branch.'.zip';
  2395. $file = "upgrade.zip";
  2396. $source = __DIR__ . '/upgrade/Organizr-'.$branch.'/';
  2397. $cleanup = __DIR__ . "/upgrade/";
  2398. $destination = __DIR__ . "/";
  2399. writeLog("success", "starting organizr upgrade process");
  2400. downloadFile($url, $file);
  2401. unzipFile($file);
  2402. rcopy($source, $destination);
  2403. writeLog("success", "new organizr files copied");
  2404. rrmdir($cleanup);
  2405. writeLog("success", "organizr upgrade folder removed");
  2406. writeLog("success", "organizr has been updated");
  2407. return true;
  2408. }
  2409. // NzbGET Items
  2410. function nzbgetConnect($list = 'listgroups') {
  2411. $url = qualifyURL(NZBGETURL);
  2412. $api = curl_get($url.'/'.NZBGETUSERNAME.':'.NZBGETPASSWORD.'/jsonrpc/'.$list);
  2413. $api = json_decode($api, true);
  2414. $gotNZB = array();
  2415. if (is_array($api) || is_object($api)){
  2416. foreach ($api['result'] AS $child) {
  2417. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  2418. $downloadStatus = $child['Status'];
  2419. $downloadCategory = $child['Category'];
  2420. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  2421. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  2422. if($child['Health'] <= "750"){
  2423. $downloadHealth = "danger";
  2424. }elseif($child['Health'] <= "900"){
  2425. $downloadHealth = "warning";
  2426. }elseif($child['Health'] <= "1000"){
  2427. $downloadHealth = "success";
  2428. }
  2429. $gotNZB[] = '<tr>
  2430. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2431. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2432. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2433. <td class="col-xs-1 nzbtable nzbtable-row">'.realSize(($child['FileSizeMB']*1024)*1024).'</td>
  2434. <td class="col-xs-2 nzbtable nzbtable-row">
  2435. <div class="progress">
  2436. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2437. <p class="text-center">'.round($downloadPercent).'%</p>
  2438. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2439. </div>
  2440. </div>
  2441. </td>
  2442. </tr>';
  2443. }
  2444. if ($gotNZB) {
  2445. return implode('',$gotNZB);
  2446. } else {
  2447. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2448. }
  2449. }else{
  2450. writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Username and Password - if HTTPS, is cert valid");
  2451. }
  2452. }
  2453. // Sabnzbd Items
  2454. function sabnzbdConnect($list = 'queue') {
  2455. $url = qualifyURL(SABNZBDURL);
  2456. $api = @file_get_contents($url.'/api?mode='.$list.'&output=json&apikey='.SABNZBDKEY);
  2457. $api = json_decode($api, true);
  2458. $gotNZB = array();
  2459. if (is_array($api) || is_object($api)){
  2460. foreach ($api[$list]['slots'] AS $child) {
  2461. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  2462. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  2463. $downloadStatus = $child['status'];
  2464. $gotNZB[] = '<tr>
  2465. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2466. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2467. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2468. <td class="col-xs-1 nzbtable nzbtable-row">'.$child['size'].'</td>
  2469. <td class="col-xs-2 nzbtable nzbtable-row">
  2470. <div class="progress">
  2471. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2472. <p class="text-center">'.round($downloadPercent).'%</p>
  2473. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2474. </div>
  2475. </div>
  2476. </td>
  2477. </tr>';
  2478. }
  2479. if ($gotNZB) {
  2480. return implode('',$gotNZB);
  2481. } else {
  2482. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2483. }
  2484. }else{
  2485. writeLog("error", "SABNZBD ERROR: could not connect - check URL and/or check token - if HTTPS, is cert valid");
  2486. }
  2487. }
  2488. // Apply new tab settings
  2489. function updateTabs($tabs) {
  2490. if (!isset($GLOBALS['file_db'])) {
  2491. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2492. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2493. }
  2494. // Validate
  2495. if (!isset($tabs['defaultz'])) { $tabs['defaultz'][current(array_keys($tabs['name']))] = 'true'; }
  2496. if (isset($tabs['name']) && isset($tabs['url']) && is_array($tabs['name'])) {
  2497. // Clear Existing Tabs
  2498. $GLOBALS['file_db']->query("DELETE FROM tabs");
  2499. // Process New Tabs
  2500. $totalValid = 0;
  2501. foreach ($tabs['name'] as $key => $value) {
  2502. // Qualify
  2503. if (!$value || !isset($tabs['url']) || !$tabs['url'][$key]) { continue; }
  2504. $totalValid++;
  2505. $fields = array();
  2506. foreach(array('id','name','url','icon','iconurl','order','ping_url') as $v) {
  2507. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = $tabs[$v][$key]; }
  2508. }
  2509. foreach(array('active','user','guest','defaultz','window','splash','ping') as $v) {
  2510. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = ($tabs[$v][$key]!=='false'?'true':'false'); }
  2511. }
  2512. $GLOBALS['file_db']->query('INSERT INTO tabs (`'.implode('`,`',array_keys($fields)).'`) VALUES (\''.implode("','",$fields).'\');');
  2513. }
  2514. writeLog("success", "tabs successfully saved");
  2515. return $totalValid;
  2516. } else {
  2517. writeLog("error", "tabs could not save");
  2518. return false;
  2519. }
  2520. writeLog("error", "tabs could not save");
  2521. return false;
  2522. }
  2523. // ==============
  2524. function clean($strin) {
  2525. $strout = null;
  2526. for ($i = 0; $i < strlen($strin); $i++) {
  2527. $ord = ord($strin[$i]);
  2528. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  2529. $strout .= "&amp;#{$ord};";
  2530. }
  2531. else {
  2532. switch ($strin[$i]) {
  2533. case '<':
  2534. $strout .= '&lt;';
  2535. break;
  2536. case '>':
  2537. $strout .= '&gt;';
  2538. break;
  2539. case '&':
  2540. $strout .= '&amp;';
  2541. break;
  2542. case '"':
  2543. $strout .= '&quot;';
  2544. break;
  2545. default:
  2546. $strout .= $strin[$i];
  2547. }
  2548. }
  2549. }
  2550. return $strout;
  2551. }
  2552. function registration_callback($username, $email, $userdir){
  2553. global $data;
  2554. $data = array($username, $email, $userdir);
  2555. }
  2556. function printArray($arrayName){
  2557. $messageCount = count($arrayName);
  2558. $i = 0;
  2559. foreach ( $arrayName as $item ) :
  2560. $i++;
  2561. if($i < $messageCount) :
  2562. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  2563. elseif($i = $messageCount) :
  2564. echo "<small class='text-uppercase'>" . $item . "</small>";
  2565. endif;
  2566. endforeach;
  2567. }
  2568. function write_ini_file($content, $path) {
  2569. if (!$handle = fopen($path, 'w')) {
  2570. return false;
  2571. }
  2572. $success = fwrite($handle, trim($content));
  2573. fclose($handle);
  2574. return $success;
  2575. }
  2576. function gotTimezone(){
  2577. $regions = array(
  2578. 'Africa' => DateTimeZone::AFRICA,
  2579. 'America' => DateTimeZone::AMERICA,
  2580. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2581. 'Arctic' => DateTimeZone::ARCTIC,
  2582. 'Asia' => DateTimeZone::ASIA,
  2583. 'Atlantic' => DateTimeZone::ATLANTIC,
  2584. 'Australia' => DateTimeZone::AUSTRALIA,
  2585. 'Europe' => DateTimeZone::EUROPE,
  2586. 'Indian' => DateTimeZone::INDIAN,
  2587. 'Pacific' => DateTimeZone::PACIFIC
  2588. );
  2589. $timezones = array();
  2590. foreach ($regions as $name => $mask) {
  2591. $zones = DateTimeZone::listIdentifiers($mask);
  2592. foreach($zones as $timezone) {
  2593. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2594. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2595. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2596. }
  2597. }
  2598. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  2599. foreach($timezones as $region => $list) {
  2600. print '<optgroup label="' . $region . '">' . "\n";
  2601. foreach($list as $timezone => $name) {
  2602. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  2603. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  2604. }
  2605. print '</optgroup>' . "\n";
  2606. }
  2607. print '</select>';
  2608. }
  2609. function getTimezone(){
  2610. $regions = array(
  2611. 'Africa' => DateTimeZone::AFRICA,
  2612. 'America' => DateTimeZone::AMERICA,
  2613. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2614. 'Arctic' => DateTimeZone::ARCTIC,
  2615. 'Asia' => DateTimeZone::ASIA,
  2616. 'Atlantic' => DateTimeZone::ATLANTIC,
  2617. 'Australia' => DateTimeZone::AUSTRALIA,
  2618. 'Europe' => DateTimeZone::EUROPE,
  2619. 'Indian' => DateTimeZone::INDIAN,
  2620. 'Pacific' => DateTimeZone::PACIFIC
  2621. );
  2622. $timezones = array();
  2623. foreach ($regions as $name => $mask) {
  2624. $zones = DateTimeZone::listIdentifiers($mask);
  2625. foreach($zones as $timezone) {
  2626. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2627. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2628. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2629. }
  2630. }
  2631. print '<select name="timezone" id="timezone" class="form-control material" required>';
  2632. foreach($timezones as $region => $list) {
  2633. print '<optgroup label="' . $region . '">' . "\n";
  2634. foreach($list as $timezone => $name) {
  2635. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  2636. }
  2637. print '</optgroup>' . "\n";
  2638. }
  2639. print '</select>';
  2640. }
  2641. function explosion($string, $position){
  2642. $getWord = explode("|", $string);
  2643. return $getWord[$position];
  2644. }
  2645. function getServerPath() {
  2646. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  2647. $protocol = "https://";
  2648. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  2649. $protocol = "https://";
  2650. } else {
  2651. $protocol = "http://";
  2652. }
  2653. $domain = '';
  2654. if (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], '.') !== false){
  2655. $domain = $_SERVER['SERVER_NAME'];
  2656. }elseif(isset($_SERVER['HTTP_HOST'])){
  2657. if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
  2658. $domain = explode(':', $_SERVER['HTTP_HOST'])[0];
  2659. $port = explode(':', $_SERVER['HTTP_HOST'])[1];
  2660. if ($port == "80" || $port == "443"){
  2661. $domain = $domain;
  2662. }else{
  2663. $domain = $_SERVER['HTTP_HOST'];
  2664. }
  2665. }else{
  2666. $domain = $_SERVER['HTTP_HOST'];
  2667. }
  2668. }
  2669. return $protocol . $domain . str_replace("\\", "/", dirname($_SERVER['REQUEST_URI']));
  2670. }
  2671. function get_browser_name() {
  2672. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  2673. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  2674. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  2675. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  2676. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  2677. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  2678. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  2679. return 'Other';
  2680. }
  2681. function getSickrageCalendarWanted($array){
  2682. $array = json_decode($array, true);
  2683. //$gotCalendar = "";
  2684. $gotCalendar = array();
  2685. $i = 0;
  2686. foreach($array['data']['missed'] AS $child) {
  2687. $i++;
  2688. $seriesName = $child['show_name'];
  2689. $episodeID = $child['tvdbid'];
  2690. $episodeAirDate = $child['airdate'];
  2691. $episodeAirDateTime = explode(" ",$child['airs']);
  2692. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2693. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2694. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2695. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2696. $downloaded = "0";
  2697. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2698. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2699. array_push($gotCalendar, array(
  2700. "id" => "Sick-Miss-".$i,
  2701. "title" => $seriesName,
  2702. "start" => $episodeAirDate,
  2703. "className" => $downloaded." tvID--".$episodeID,
  2704. "imagetype" => "tv",
  2705. ));
  2706. }
  2707. foreach($array['data']['today'] AS $child) {
  2708. $i++;
  2709. $seriesName = $child['show_name'];
  2710. $episodeID = $child['tvdbid'];
  2711. $episodeAirDate = $child['airdate'];
  2712. $episodeAirDateTime = explode(" ",$child['airs']);
  2713. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2714. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2715. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2716. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2717. $downloaded = "0";
  2718. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2719. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2720. array_push($gotCalendar, array(
  2721. "id" => "Sick-Today-".$i,
  2722. "title" => $seriesName,
  2723. "start" => $episodeAirDate,
  2724. "className" => $downloaded." tvID--".$episodeID,
  2725. "imagetype" => "tv",
  2726. ));
  2727. }
  2728. foreach($array['data']['soon'] AS $child) {
  2729. $i++;
  2730. $seriesName = $child['show_name'];
  2731. $episodeID = $child['tvdbid'];
  2732. $episodeAirDate = $child['airdate'];
  2733. $episodeAirDateTime = explode(" ",$child['airs']);
  2734. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2735. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2736. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2737. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2738. $downloaded = "0";
  2739. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2740. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2741. array_push($gotCalendar, array(
  2742. "id" => "Sick-Soon-".$i,
  2743. "title" => $seriesName,
  2744. "start" => $episodeAirDate,
  2745. "className" => $downloaded." tvID--".$episodeID,
  2746. "imagetype" => "tv",
  2747. ));
  2748. }
  2749. foreach($array['data']['later'] AS $child) {
  2750. $i++;
  2751. $seriesName = $child['show_name'];
  2752. $episodeID = $child['tvdbid'];
  2753. $episodeAirDate = $child['airdate'];
  2754. $episodeAirDateTime = explode(" ",$child['airs']);
  2755. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2756. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2757. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2758. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2759. $downloaded = "0";
  2760. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2761. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2762. array_push($gotCalendar, array(
  2763. "id" => "Sick-Later-".$i,
  2764. "title" => $seriesName,
  2765. "start" => $episodeAirDate,
  2766. "className" => $downloaded." tvID--".$episodeID,
  2767. "imagetype" => "tv",
  2768. ));
  2769. }
  2770. if ($i != 0){ return $gotCalendar; }
  2771. }
  2772. function getSickrageCalendarHistory($array){
  2773. $array = json_decode($array, true);
  2774. //$gotCalendar = "";
  2775. $gotCalendar = array();
  2776. $i = 0;
  2777. foreach($array['data'] AS $child) {
  2778. $i++;
  2779. $seriesName = $child['show_name'];
  2780. $episodeID = $child['tvdbid'];
  2781. $episodeAirDate = $child['date'];
  2782. $downloaded = "green-bg";
  2783. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2784. array_push($gotCalendar, array(
  2785. "id" => "Sick-History-".$i,
  2786. "title" => $seriesName,
  2787. "start" => $episodeAirDate,
  2788. "className" => $downloaded." tvID--".$episodeID,
  2789. "imagetype" => "tv",
  2790. ));
  2791. }
  2792. if ($i != 0){ return $gotCalendar; }
  2793. }
  2794. function getSonarrCalendar($array){
  2795. $array = json_decode($array, true);
  2796. //$gotCalendar = "";
  2797. $gotCalendar = array();
  2798. $i = 0;
  2799. foreach($array AS $child) {
  2800. $i++;
  2801. $seriesName = $child['series']['title'];
  2802. $episodeID = $child['series']['tvdbId'];
  2803. if(!isset($episodeID)){ $episodeID = ""; }
  2804. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  2805. if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
  2806. $episodeAirDate = $child['airDateUtc'];
  2807. $episodeAirDate = strtotime($episodeAirDate);
  2808. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2809. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2810. $downloaded = $child['hasFile'];
  2811. 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"; }
  2812. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2813. array_push($gotCalendar, array(
  2814. "id" => "Sonarr-".$i,
  2815. "title" => $seriesName,
  2816. "start" => $episodeAirDate,
  2817. "className" => $downloaded." tvID--".$episodeID,
  2818. "imagetype" => "tv",
  2819. ));
  2820. }
  2821. if ($i != 0){ return $gotCalendar; }
  2822. }
  2823. function getCouchCalendar(){
  2824. $url = qualifyURL(COUCHURL);
  2825. $api = curl_get($url."/api/".COUCHAPI."/media.list");
  2826. $api = json_decode($api, true);
  2827. $i = 0;
  2828. $gotCalendar = array();
  2829. if (is_array($api) || is_object($api)){
  2830. foreach($api['movies'] AS $child) {
  2831. if($child['status'] == "active" || $child['status'] == "done" ){
  2832. $i++;
  2833. $movieName = $child['info']['original_title'];
  2834. $movieID = $child['info']['tmdb_id'];
  2835. if(!isset($movieID)){ $movieID = ""; }
  2836. $physicalRelease = (isset($child['info']['released']) ? $child['info']['released'] : null);
  2837. $backupRelease = (isset($child['info']['release_date']['theater']) ? $child['info']['release_date']['theater'] : null);
  2838. $physicalRelease = (isset($physicalRelease) ? $physicalRelease : $backupRelease);
  2839. $physicalRelease = strtotime($physicalRelease);
  2840. $physicalRelease = date("Y-m-d", $physicalRelease);
  2841. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2842. $downloaded = ($child['status'] == "active") ? "0" : "1";
  2843. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2844. array_push($gotCalendar, array(
  2845. "id" => "CouchPotato-".$i,
  2846. "title" => $movieName,
  2847. "start" => $physicalRelease,
  2848. "className" => $downloaded." movieID--".$movieID,
  2849. "imagetype" => "film",
  2850. ));
  2851. }
  2852. }
  2853. if ($i != 0){ return $gotCalendar; }
  2854. }else{
  2855. writeLog("error", "CouchPotato ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2856. }
  2857. }
  2858. function getRadarrCalendar($array){
  2859. $array = json_decode($array, true);
  2860. $gotCalendar = array();
  2861. $i = 0;
  2862. foreach($array AS $child) {
  2863. if(isset($child['physicalRelease'])){
  2864. $i++;
  2865. $movieName = $child['title'];
  2866. $movieID = $child['tmdbId'];
  2867. if(!isset($movieID)){ $movieID = ""; }
  2868. $physicalRelease = $child['physicalRelease'];
  2869. $physicalRelease = strtotime($physicalRelease);
  2870. $physicalRelease = date("Y-m-d", $physicalRelease);
  2871. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2872. $downloaded = $child['hasFile'];
  2873. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2874. array_push($gotCalendar, array(
  2875. "id" => "Radarr-".$i,
  2876. "title" => $movieName,
  2877. "start" => $physicalRelease,
  2878. "className" => $downloaded." movieID--".$movieID,
  2879. "imagetype" => "film",
  2880. ));
  2881. }
  2882. }
  2883. if ($i != 0){ return $gotCalendar; }
  2884. }
  2885. function getHeadphonesCalendar($url, $key, $list){
  2886. $url = qualifyURL(HEADPHONESURL);
  2887. $api = curl_get($url."/api?apikey=".$key."&cmd=$list");
  2888. $api = json_decode($api, true);
  2889. $i = 0;
  2890. //$gotCalendar = "";
  2891. $gotCalendar = array();;
  2892. if (is_array($api) || is_object($api)){
  2893. foreach($api AS $child) {
  2894. if($child['Status'] == "Wanted" && $list == "getWanted" && $child['ReleaseDate']){
  2895. $i++;
  2896. $albumName = addslashes($child['AlbumTitle']);
  2897. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  2898. $albumDate = (strlen($child['ReleaseDate']) > 4) ? $child['ReleaseDate'] : $child['ReleaseDate']."-01-01";
  2899. $albumID = $child['AlbumID'];
  2900. $albumDate = strtotime($albumDate);
  2901. $albumDate = date("Y-m-d", $albumDate);
  2902. $albumStatus = $child['Status'];
  2903. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2904. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  2905. //$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2906. array_push($gotCalendar, array(
  2907. "id" => "Headphones-".$i,
  2908. "title" => $albumArtist.' - '.$albumName,
  2909. "start" => $albumDate,
  2910. "className" => $albumStatusColor,
  2911. "imagetype" => "music",
  2912. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2913. ));
  2914. }
  2915. if($child['Status'] == "Processed" && $list == "getHistory"){
  2916. $i++;
  2917. $find = array('_','[', ']', '\n');
  2918. $replace = array(' ','(', ')', ' ');
  2919. $albumName = addslashes(str_replace($find,$replace,$child['FolderName']));
  2920. $albumDate = $child['DateAdded'];
  2921. $albumID = $child['AlbumID'];
  2922. $albumDate = strtotime($albumDate);
  2923. $albumDate = date("Y-m-d", $albumDate);
  2924. $albumStatusColor = "green-bg";
  2925. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2926. //$gotCalendar .= "{ title: \"$albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2927. array_push($gotCalendar, array(
  2928. "id" => "Headphones-".$i,
  2929. "title" => $albumName,
  2930. "start" => $albumDate,
  2931. "className" => $albumStatusColor,
  2932. "imagetype" => "music",
  2933. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2934. ));
  2935. }
  2936. }
  2937. if ($i != 0){ return $gotCalendar; }
  2938. }else{
  2939. writeLog("error", "HEADPHONES $list ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2940. }
  2941. }
  2942. function checkRootPath($string){
  2943. if($string == "\\" || $string == "/"){
  2944. return "/";
  2945. }else{
  2946. return str_replace("\\", "/", $string) . "/";
  2947. }
  2948. }
  2949. function strip($string){
  2950. $string = strip_tags($string);
  2951. return preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $string));
  2952. }
  2953. function writeLog($type, $message){
  2954. if(file_exists(DATABASE_LOCATION."org.log")){
  2955. if(filesize(DATABASE_LOCATION."org.log") > 500000){
  2956. rename(DATABASE_LOCATION.'org.log',DATABASE_LOCATION.'org['.date('Y-m-d').'].log');
  2957. $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";
  2958. file_put_contents(DATABASE_LOCATION."org.log", $message2, FILE_APPEND | LOCK_EX);
  2959. }
  2960. }
  2961. $message = date("Y-m-d H:i:s")."|".$type."|".strip($message)."\n";
  2962. file_put_contents(DATABASE_LOCATION."org.log", $message, FILE_APPEND | LOCK_EX);
  2963. }
  2964. function readLog(){
  2965. $log = file(DATABASE_LOCATION."org.log",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  2966. $log = array_reverse($log);
  2967. foreach($log as $line){
  2968. if(substr_count($line, '|') == 2){
  2969. $line = explode("|", strip($line));
  2970. $line[1] = ($line[1] == "error") ? '<span class="label label-danger">Error</span>' : '<span class="label label-primary">Success</span>';
  2971. echo "<tr><td>".$line[0]."</td><td>".$line[2]."</td><td>".$line[1]."</td></tr>";
  2972. }
  2973. }
  2974. }
  2975. function buildStream($array){
  2976. $result = "";
  2977. if (array_key_exists('platform', $array)) {
  2978. $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>';
  2979. }
  2980. if (array_key_exists('device', $array)) {
  2981. $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>';
  2982. }
  2983. if (array_key_exists('stream', $array)) {
  2984. $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>';
  2985. }
  2986. if (array_key_exists('video', $array)) {
  2987. $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>';
  2988. }
  2989. if (array_key_exists('audio', $array)) {
  2990. $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>';
  2991. }
  2992. return $result;
  2993. }
  2994. function streamType($value){
  2995. if($value == "transcode" || $value == "Transcode"){
  2996. return "Transcode";
  2997. }elseif($value == "copy" || $value == "DirectStream"){
  2998. return "Direct Stream";
  2999. }elseif($value == "directplay" || $value == "DirectPlay"){
  3000. return "Direct Play";
  3001. }else{
  3002. return "Direct Play";
  3003. }
  3004. }
  3005. function getPlatform($platform){
  3006. $allPlatforms = array(
  3007. "Chrome" => "chrome.png",
  3008. "tvOS" => "atv.png",
  3009. "iOS" => "ios.png",
  3010. "Xbox One" => "xbox.png",
  3011. "Mystery 4" => "playstation.png",
  3012. "Samsung" => "samsung.png",
  3013. "Roku" => "roku.png",
  3014. "Emby for iOS" => "ios.png",
  3015. "Emby Mobile" => "emby.png",
  3016. "Emby Theater" => "emby.png",
  3017. "Emby Classic" => "emby.png",
  3018. "Safari" => "safari.png",
  3019. "Android" => "android.png",
  3020. "AndroidTv" => "android.png",
  3021. "Chromecast" => "chromecast.png",
  3022. "Dashboard" => "emby.png",
  3023. "Dlna" => "dlna.png",
  3024. "Windows Phone" => "wp.png",
  3025. "Windows RT" => "win8.png",
  3026. "Kodi" => "kodi.png",
  3027. );
  3028. if (array_key_exists($platform, $allPlatforms)) {
  3029. return $allPlatforms[$platform];
  3030. }else{
  3031. return "pmp.png";
  3032. }
  3033. }
  3034. function getServer(){
  3035. $server = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"];
  3036. return $server;
  3037. }
  3038. function prettyPrint($array) {
  3039. echo "<pre>";
  3040. print_r($array);
  3041. echo "</pre>";
  3042. echo "<br/>";
  3043. }
  3044. function checkFrame($array, $url){
  3045. if(array_key_exists("x-frame-options", $array)){
  3046. if($array['x-frame-options'] == "deny"){
  3047. return false;
  3048. }elseif($array['x-frame-options'] == "sameorgin"){
  3049. $digest = parse_url($url);
  3050. $host = (isset($digest['host'])?$digest['host']:'');
  3051. if(getServer() == $host){
  3052. return true;
  3053. }else{
  3054. return false;
  3055. }
  3056. }
  3057. }else{
  3058. if(!$array){
  3059. return false;
  3060. }
  3061. return true;
  3062. }
  3063. }
  3064. function frameTest($url){
  3065. $array = array_change_key_case(get_headers(qualifyURL($url), 1));
  3066. $url = qualifyURL($url);
  3067. if(checkFrame($array, $url)){
  3068. return true;
  3069. }else{
  3070. return false;
  3071. }
  3072. }
  3073. function sendResult($result, $icon = "floppy-o", $message = false, $success = "WAS_SUCCESSFUL", $fail = "HAS_FAILED", $send = true) {
  3074. $notifyExplode = explode("-", NOTIFYEFFECT);
  3075. if ($result) {
  3076. $msg = array(
  3077. 'html' => ($message?''.$message.' <strong>'.translate($success).'</strong>':'<strong>'.translate($success).'</strong>'),
  3078. 'icon' => $icon,
  3079. 'type' => 'success',
  3080. 'length' => '5000',
  3081. 'layout' => $notifyExplode[0],
  3082. 'effect' => $notifyExplode[1],
  3083. );
  3084. } else {
  3085. $msg = array(
  3086. 'html' => ($message?''.$message.' <strong>'.translate($fail).'</strong>':'<strong>'.translate($fail).'</strong>'),
  3087. 'icon' => $icon,
  3088. 'type' => 'error',
  3089. 'length' => '5000',
  3090. 'layout' => $notifyExplode[0],
  3091. 'effect' => $notifyExplode[1],
  3092. );
  3093. }
  3094. // Send and kill script?
  3095. if ($send) {
  3096. header('Content-Type: application/json');
  3097. echo json_encode(array('notify'=>$msg));
  3098. die();
  3099. }
  3100. return $msg;
  3101. }
  3102. function buildHomepageNotice($layout, $type, $title, $message){
  3103. switch ($layout) {
  3104. case 'elegant':
  3105. return '
  3106. <div id="homepageNotice" class="row">
  3107. <div class="col-lg-12">
  3108. <div class="content-box big-box box-shadow panel-box panel-'.$type.'">
  3109. <div class="content-title i-block">
  3110. <h4 class="zero-m"><strong>'.$title.'</strong></h4>
  3111. <div class="content-tools i-block pull-right">
  3112. <a class="close-btn">
  3113. <i class="fa fa-times"></i>
  3114. </a>
  3115. </div>
  3116. </div>
  3117. '.$message.'
  3118. </div>
  3119. </div>
  3120. </div>
  3121. ';
  3122. break;
  3123. case 'basic':
  3124. return '
  3125. <div id="homepageNotice" class="row">
  3126. <div class="col-lg-12">
  3127. <div class="panel panel-'.$type.'">
  3128. <div class="panel-heading">
  3129. <h3 class="panel-title">'.$title.'</h3>
  3130. </div>
  3131. <div class="panel-body">
  3132. '.$message.'
  3133. </div>
  3134. </div>
  3135. </div>
  3136. </div>
  3137. ';
  3138. break;
  3139. case 'jumbotron';
  3140. return '
  3141. <div id="homepageNotice" class="row">
  3142. <div class="col-lg-12">
  3143. <div class="jumbotron">
  3144. <div class="container">
  3145. <h1>'.$title.'</h1>
  3146. <p>'.$message.'</p>
  3147. </div>
  3148. </div>
  3149. </div>
  3150. </div>
  3151. ';
  3152. }
  3153. }
  3154. function embyArray($array, $type) {
  3155. $key = ($type == "video" ? "Height" : "Channels");
  3156. if (array_key_exists($key, $array)) {
  3157. switch ($type) {
  3158. case "video":
  3159. $codec = $array["Codec"];
  3160. $height = $array["Height"];
  3161. $width = $array["Width"];
  3162. break;
  3163. default:
  3164. $codec = $array["Codec"];
  3165. $channels = $array["Channels"];
  3166. }
  3167. return ($type == "video" ? "(".$codec.") (".$width."x".$height.")" : "(".$codec.") (".$channels."ch)");
  3168. }
  3169. foreach ($array as $element) {
  3170. if (is_array($element)) {
  3171. if (embyArray($element, $type)) {
  3172. return embyArray($element, $type);
  3173. }
  3174. }
  3175. }
  3176. }
  3177. // Get Now Playing Streams From Plex
  3178. function searchPlex($query){
  3179. $address = qualifyURL(PLEXURL);
  3180. $openTab = (PLEXTABNAME) ? "true" : "false";
  3181. // Perform API requests
  3182. $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
  3183. libxml_use_internal_errors(true);
  3184. $api = simplexml_load_string($api);
  3185. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3186. if (!$getServer) { return 'Could not load!'; }
  3187. // Identify the local machine
  3188. $server = $getServer['machineIdentifier'];
  3189. $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>";
  3190. $items = "";
  3191. $albums = $movies = $shows = 0;
  3192. $style = 'style="vertical-align: middle"';
  3193. foreach($api AS $child) {
  3194. if($child['type'] != "artist" && $child['type'] != "episode" && isset($child['librarySectionID'])){
  3195. $time = (string)$child['addedAt'];
  3196. $time = new DateTime("@$time");
  3197. $results = array(
  3198. "title" => (string)$child['title'],
  3199. "image" => (string)$child['thumb'],
  3200. "type" => (string)ucwords($child['type']),
  3201. "year" => (string)$child['year'],
  3202. "key" => (string)$child['ratingKey']."-search",
  3203. "ratingkey" => (string)$child['ratingKey'],
  3204. "genre" => (string)$child->Genre['tag'],
  3205. "added" => $time->format('Y-m-d'),
  3206. "extra" => "",
  3207. );
  3208. switch ($child['type']){
  3209. case "album":
  3210. $push = array(
  3211. "title" => (string)$child['parentTitle']." - ".(string)$child['title'],
  3212. );
  3213. $results = array_replace($results,$push);
  3214. $albums++;
  3215. break;
  3216. case "movie":
  3217. $push = array(
  3218. "extra" => "Content Rating: ".(string)$child['contentRating']."<br/>Movie Rating: ".(string)$child['rating'],
  3219. );
  3220. $results = array_replace($results,$push);
  3221. $movies++;
  3222. break;
  3223. case "show":
  3224. $push = array(
  3225. "extra" => "Seasons: ".(string)$child['childCount']."<br/>Episodes: ".(string)$child['leafCount'],
  3226. );
  3227. $results = array_replace($results,$push);
  3228. $shows++;
  3229. break;
  3230. }
  3231. if (file_exists('images/cache/'.$results['key'].'.jpg')){ $image_url = 'images/cache/'.$results['key'].'.jpg'; }
  3232. if (file_exists('images/cache/'.$results['key'].'.jpg') && (time() - 604800) > filemtime('images/cache/'.$results['key'].'.jpg') || !file_exists('images/cache/'.$results['key'].'.jpg')) {
  3233. $image_url = 'ajax.php?a=plex-image&img='.$results['image'].'&height=150&width=100&key='.$results['key'];
  3234. }
  3235. if(!$results['image']){ $image_url = "images/no-search.png"; $key = "no-search"; }
  3236. if (PLEXTABURL) {
  3237. $link = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3238. }else{
  3239. $link = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3240. }
  3241. $items .= '<tr style="cursor: pointer;" class="openTab" extraTitle="'.$results['title'].'" extraType="'.$child['type'].'" openTab="'.$openTab.'" href="'.$link.'">
  3242. <th scope="row"><img src="'.$image_url.'"></th>
  3243. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
  3244. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
  3245. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
  3246. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
  3247. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
  3248. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['extra'].'</td>
  3249. </tr>';
  3250. }
  3251. }
  3252. $totals = '<div style="margin: 10px;" class="sort-todo pull-right">
  3253. <span class="badge gray-bg"><i class="fa fa-film fa-2x white"></i><strong style="
  3254. font-size: 23px;
  3255. ">&nbsp;'.$movies.'</strong></span>
  3256. <span class="badge gray-bg"><i class="fa fa-tv fa-2x white"></i><strong style="
  3257. font-size: 23px;
  3258. ">&nbsp;'.$shows.'</strong></span>
  3259. <span class="badge gray-bg"><i class="fa fa-music fa-2x white"></i><strong style="
  3260. font-size: 23px;
  3261. ">&nbsp;'.$albums.'</strong></span>
  3262. </div>';
  3263. return (!empty($items) ? $totals.$pre.$items."</div></table>" : "<h2 class='text-center'>No Results for $query</h2>" );
  3264. }
  3265. function getBannedUsers($string){
  3266. if (strpos($string, ',') !== false) {
  3267. $banned = explode(",", $string);
  3268. }else{
  3269. $banned = array($string);
  3270. }
  3271. return $banned;
  3272. }
  3273. function getWhitelist($string){
  3274. if (strpos($string, ',') !== false) {
  3275. $whitelist = explode(",", $string);
  3276. }else{
  3277. $whitelist = array($string);
  3278. }
  3279. foreach($whitelist as &$ip){
  3280. $ip = is_numeric(substr($ip, 0, 1)) ? $ip : gethostbyname($ip);
  3281. }
  3282. return $whitelist;
  3283. }
  3284. function get_client_ip() {
  3285. $ipaddress = '';
  3286. if (isset($_SERVER['HTTP_CLIENT_IP']))
  3287. $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
  3288. else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  3289. $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
  3290. else if(isset($_SERVER['HTTP_X_FORWARDED']))
  3291. $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
  3292. else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
  3293. $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
  3294. else if(isset($_SERVER['HTTP_FORWARDED']))
  3295. $ipaddress = $_SERVER['HTTP_FORWARDED'];
  3296. else if(isset($_SERVER['REMOTE_ADDR']))
  3297. $ipaddress = $_SERVER['REMOTE_ADDR'];
  3298. else
  3299. $ipaddress = 'UNKNOWN';
  3300. return $ipaddress;
  3301. }
  3302. //EMAIL SHIT
  3303. function sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null){
  3304. $mail = new PHPMailer;
  3305. $mail->isSMTP();
  3306. $mail->Host = SMTPHOST;
  3307. $mail->SMTPAuth = SMTPHOSTAUTH;
  3308. $mail->Username = SMTPHOSTUSERNAME;
  3309. $mail->Password = SMTPHOSTPASSWORD;
  3310. $mail->SMTPSecure = SMTPHOSTTYPE;
  3311. $mail->Port = SMTPHOSTPORT;
  3312. $mail->setFrom(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3313. $mail->addReplyTo(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3314. $mail->isHTML(true);
  3315. if($email){
  3316. $mail->addAddress($email, $username);
  3317. }
  3318. if($cc){
  3319. $mail->addCC($cc);
  3320. }
  3321. if($bcc){
  3322. if(strpos($bcc , ',') === false){
  3323. $mail->addBCC($bcc);
  3324. }else{
  3325. $allEmails = explode(",",$bcc);
  3326. foreach($allEmails as $gotEmail){
  3327. $mail->addBCC($gotEmail);
  3328. }
  3329. }
  3330. }
  3331. $mail->Subject = $subject;
  3332. $mail->Body = $body;
  3333. //$mail->send();
  3334. if(!$mail->send()) {
  3335. writeLog("error", "mail failed to send");
  3336. } else {
  3337. writeLog("success", "mail has been sent");
  3338. }
  3339. }
  3340. //EMAIL SHIT
  3341. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  3342. $mail = new PHPMailer;
  3343. $mail->isSMTP();
  3344. $mail->Host = $host;
  3345. $mail->SMTPAuth = $auth;
  3346. $mail->Username = $username;
  3347. $mail->Password = $password;
  3348. $mail->SMTPSecure = $type;
  3349. $mail->Port = $port;
  3350. $mail->setFrom($from, $sendername);
  3351. $mail->addReplyTo($from, $sendername);
  3352. $mail->isHTML(true);
  3353. $mail->addAddress($to, "Organizr Admin");
  3354. $mail->Subject = "Organizr Test E-Mail";
  3355. $mail->Body = "This was just a test!";
  3356. //$mail->send();
  3357. if(!$mail->send()) {
  3358. writeLog("error", "EMAIL TEST: mail failed to send - Error:".$mail->ErrorInfo);
  3359. return false;
  3360. } else {
  3361. writeLog("success", "EMAIL TEST: mail has been sent successfully");
  3362. return true;
  3363. }
  3364. }
  3365. function libraryList(){
  3366. $address = qualifyURL(PLEXURL);
  3367. $headers = array(
  3368. "Accept" => "application/json",
  3369. "X-Plex-Token" => PLEXTOKEN
  3370. );
  3371. libxml_use_internal_errors(true);
  3372. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3373. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3374. $api = simplexml_load_string(@curl_get("https://plex.tv/api/servers/$gotServer/shared_servers", $headers));
  3375. $libraryList = array();
  3376. foreach($api->SharedServer->Section AS $child) {
  3377. $libraryList['libraries'][(string)$child['title']] = (string)$child['id'];
  3378. }
  3379. foreach($api->SharedServer AS $child) {
  3380. if(!empty($child['username'])){
  3381. $username = (string)strtolower($child['username']);
  3382. $email = (string)strtolower($child['email']);
  3383. $libraryList['users'][$username] = (string)$child['id'];
  3384. $libraryList['emails'][$email] = (string)$child['id'];
  3385. $libraryList['both'][$username] = $email;
  3386. }
  3387. }
  3388. return (!empty($libraryList) ? array_change_key_case($libraryList,CASE_LOWER) : null );
  3389. }
  3390. function plexUserShare($username){
  3391. $address = qualifyURL(PLEXURL);
  3392. $headers = array(
  3393. "Accept" => "application/json",
  3394. "Content-Type" => "application/json",
  3395. "X-Plex-Token" => PLEXTOKEN
  3396. );
  3397. libxml_use_internal_errors(true);
  3398. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3399. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3400. $json = array(
  3401. "server_id" => $gotServer,
  3402. "shared_server" => array(
  3403. //"library_section_ids" => "[26527637]",
  3404. "invited_email" => $username
  3405. )
  3406. );
  3407. $api = curl_post("https://plex.tv/api/servers/$gotServer/shared_servers/", $json, $headers);
  3408. switch ($api['http_code']['http_code']){
  3409. case 400:
  3410. writeLog("error", "PLEX INVITE: $username already has access to the shared libraries");
  3411. $result = "$username already has access to the shared libraries";
  3412. break;
  3413. case 401:
  3414. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3415. $result = "Invalid Plex Token";
  3416. break;
  3417. case 200:
  3418. writeLog("success", "PLEX INVITE: $username now has access to your Plex Library");
  3419. $result = "$username now has access to your Plex Library";
  3420. break;
  3421. default:
  3422. writeLog("error", "PLEX INVITE: unknown error");
  3423. $result = false;
  3424. }
  3425. return (!empty($result) ? $result : null );
  3426. }
  3427. function plexUserDelete($username){
  3428. $address = qualifyURL(PLEXURL);
  3429. $headers = array(
  3430. "Accept" => "application/json",
  3431. "Content-Type" => "application/json",
  3432. "X-Plex-Token" => PLEXTOKEN
  3433. );
  3434. libxml_use_internal_errors(true);
  3435. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3436. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3437. $id = (is_numeric($username) ? $id : convertPlexName($username, "id"));
  3438. $api = curl_delete("https://plex.tv/api/servers/$gotServer/shared_servers/$id", $headers);
  3439. switch ($api['http_code']['http_code']){
  3440. case 401:
  3441. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3442. $result = "Invalid Plex Token";
  3443. break;
  3444. case 200:
  3445. writeLog("success", "PLEX INVITE: $username doesn't have access to your Plex Library anymore");
  3446. $result = "$username doesn't have access to your Plex Library anymore";
  3447. break;
  3448. default:
  3449. writeLog("error", "PLEX INVITE: unknown error");
  3450. $result = false;
  3451. }
  3452. return (!empty($result) ? $result : null );
  3453. }
  3454. function convertPlexName($user, $type){
  3455. $array = libraryList();
  3456. switch ($type){
  3457. case "username":
  3458. $plexUser = array_search ($user, $array['users']);
  3459. break;
  3460. case "id":
  3461. if (array_key_exists(strtolower($user), $array['users'])) {
  3462. $plexUser = $array['users'][strtolower($user)];
  3463. }
  3464. break;
  3465. default:
  3466. $plexUser = false;
  3467. }
  3468. return (!empty($plexUser) ? $plexUser : null );
  3469. }
  3470. function randomCode($length = 5, $type = null) {
  3471. switch ($type){
  3472. case "alpha":
  3473. $legend = array_merge(range('A', 'Z'));
  3474. break;
  3475. case "numeric":
  3476. $legend = array_merge(range(0,9));
  3477. break;
  3478. default:
  3479. $legend = array_merge(range(0,9),range('A', 'Z'));
  3480. }
  3481. $code = "";
  3482. for($i=0; $i < $length; $i++) {
  3483. $code .= $legend[mt_rand(0, count($legend) - 1)];
  3484. }
  3485. return $code;
  3486. }
  3487. function inviteCodes($action, $code = null, $usedBy = null) {
  3488. if (!isset($GLOBALS['file_db'])) {
  3489. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  3490. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  3491. }
  3492. $now = date("Y-m-d H:i:s");
  3493. switch ($action) {
  3494. case "get":
  3495. // Start Array
  3496. $result = array();
  3497. // Database Lookup
  3498. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes"');
  3499. // Get Codes
  3500. foreach($invites as $row) {
  3501. array_push($result, $row['code']);
  3502. }
  3503. // Return the Results
  3504. return (!empty($result) ? $result : false );
  3505. break;
  3506. case "check":
  3507. // Start Array
  3508. $result = array();
  3509. // Database Lookup
  3510. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes" AND code = "'.$code.'"');
  3511. // Get Codes
  3512. foreach($invites as $row) {
  3513. $result = $row['code'];
  3514. }
  3515. // Return the Results
  3516. return (!empty($result) ? $result : false );
  3517. break;
  3518. case "use":
  3519. $currentIP = get_client_ip();
  3520. $invites = $GLOBALS['file_db']->query('UPDATE invites SET valid = "No", usedby = "'.$usedBy.'", dateused = "'.$now.'", ip = "'.$currentIP.'" WHERE code = "'.$code.'"');
  3521. if(ENABLEMAIL){
  3522. if (!isset($GLOBALS['USER'])) {
  3523. require_once("user.php");
  3524. $GLOBALS['USER'] = new User('registration_callback');
  3525. }
  3526. 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."));
  3527. }
  3528. return (!empty($invites) ? true : false );
  3529. break;
  3530. }
  3531. }
  3532. function plexJoin($username, $email, $password){
  3533. $connectURL = 'https://plex.tv/users.json';
  3534. $headers = array(
  3535. 'Accept'=> 'application/json',
  3536. 'Content-Type' => 'application/x-www-form-urlencoded',
  3537. 'X-Plex-Product' => 'Organizr',
  3538. 'X-Plex-Version' => '1.0',
  3539. 'X-Plex-Client-Identifier' => '01010101-10101010',
  3540. );
  3541. $body = array(
  3542. 'user[email]' => $email,
  3543. 'user[username]' => $username,
  3544. 'user[password]' => $password,
  3545. );
  3546. $api = curl_post($connectURL, $body, $headers);
  3547. $json = json_decode($api['content'], true);
  3548. $errors = (!empty($json['errors']) ? true : false);
  3549. $success = (!empty($json['user']) ? true : false);
  3550. //Use This for later
  3551. $usernameError = (!empty($json['errors']['username']) ? $json['errors']['username'][0] : false);
  3552. $emailError = (!empty($json['errors']['email']) ? $json['errors']['email'][0] : false);
  3553. $passwordError = (!empty($json['errors']['password']) ? $json['errors']['password'][0] : false);
  3554. $errorMessage = "";
  3555. if($errors){
  3556. if($usernameError){ $errorMessage .= "[Username Error: ". $usernameError ."]"; }
  3557. if($emailError){ $errorMessage .= "[Email Error: ". $emailError ."]"; }
  3558. if($passwordError){ $errorMessage .= "[Password Error: ". $passwordError ."]"; }
  3559. }
  3560. switch ($api['http_code']['http_code']){
  3561. case 400:
  3562. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." $username already has access to the shared libraries $errorMessage");
  3563. break;
  3564. case 401:
  3565. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." invalid Plex Token $errorMessage");
  3566. break;
  3567. case 422:
  3568. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." user info error $errorMessage");
  3569. break;
  3570. case 429:
  3571. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." too many requests to plex.tv please try later $errorMessage");
  3572. break;
  3573. case 200:
  3574. case 201:
  3575. writeLog("success", "PLEX JOIN: $username now has access to your Plex Library");
  3576. break;
  3577. default:
  3578. writeLog("error", "PLEX JOIN: unknown error, $errorMessage Error: ".$api['http_code']['http_code']);
  3579. }
  3580. //prettyPrint($api);
  3581. //prettyPrint(json_decode($api['content'], true));
  3582. return (!empty($success) && empty($errors) ? true : false );
  3583. }
  3584. function getCert(){
  3585. $url = "http://curl.haxx.se/ca/cacert.pem";
  3586. $file = getcwd()."/config/cacert.pem";
  3587. $directory = getcwd()."/config/";
  3588. @mkdir($directory, 0770, true);
  3589. if(!file_exists($file)){
  3590. file_put_contents( $file, fopen($url, 'r'));
  3591. writeLog("success", "CERT PEM: pem file created");
  3592. }elseif (file_exists($file) && time() - 2592000 > filemtime($file)) {
  3593. file_put_contents( $file, fopen($url, 'r'));
  3594. writeLog("success", "CERT PEM: downloaded new pem file");
  3595. }
  3596. return $file;
  3597. }
  3598. function customCSS(){
  3599. if(CUSTOMCSS == "true") {
  3600. $template_file = "custom.css";
  3601. $file_handle = fopen($template_file, "rb");
  3602. echo "\n";
  3603. echo fread($file_handle, filesize($template_file));
  3604. fclose($file_handle);
  3605. echo "\n";
  3606. }
  3607. }
  3608. function tvdbToken(){
  3609. $headers = array(
  3610. "Accept" => "application/json",
  3611. "Content-Type" => "application/json"
  3612. );
  3613. $json = array(
  3614. "apikey" => "FBE7B62621F4CAD7",
  3615. "userkey" => "328BB46EB1E9A0F5",
  3616. "username" => "causefx"
  3617. );
  3618. $api = curl_post("https://api.thetvdb.com/login", $json, $headers);
  3619. return json_decode($api['content'], true)['token'];
  3620. }
  3621. function tvdbGet($id){
  3622. $headers = array(
  3623. "Accept" => "application/json",
  3624. "Authorization" => "Bearer ".tvdbToken(),
  3625. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3626. "trakt-api-version" => "2"
  3627. );
  3628. $trakt = curl_get("https://api.trakt.tv/search/tvdb/$id?type=show", $headers);
  3629. @$api['trakt'] = json_decode($trakt, true)[0]['show']['ids'];
  3630. if(empty($api['trakt'])){
  3631. $series = curl_get("https://api.thetvdb.com/series/$id", $headers);
  3632. $poster = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=poster", $headers);
  3633. $backdrop = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=fanart", $headers);
  3634. $api['series'] = json_decode($series, true)['data'];
  3635. $api['poster'] = json_decode($poster, true)['data'];
  3636. $api['backdrop'] = json_decode($backdrop, true)['data'];
  3637. }
  3638. return $api;
  3639. }
  3640. function tvdbSearch($name, $type){
  3641. $name = rawurlencode(preg_replace("/\(([^()]*+|(?R))*\)/","", $name));
  3642. $headers = array(
  3643. "Accept" => "application/json",
  3644. "Authorization" => "Bearer ".tvdbToken(),
  3645. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3646. "trakt-api-version" => "2"
  3647. );
  3648. $trakt = curl_get("https://api.trakt.tv/search/$type?query=$name", $headers);
  3649. @$api['trakt'] = json_decode($trakt, true)[0][$type]['ids'];
  3650. return $api;
  3651. }
  3652. function getPlexPlaylists(){
  3653. $address = qualifyURL(PLEXURL);
  3654. // Perform API requests
  3655. $api = @curl_get($address."/playlists?X-Plex-Token=".PLEXTOKEN);
  3656. libxml_use_internal_errors(true);
  3657. $api = simplexml_load_string($api);
  3658. if (is_array($api) || is_object($api)){
  3659. if (!$api->head->title){
  3660. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3661. if (!$getServer) { return 'Could not load!'; }
  3662. // Identify the local machine
  3663. $gotServer = $getServer['machineIdentifier'];
  3664. $output = "";
  3665. $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">';
  3666. foreach($api AS $child) {
  3667. $items = array();
  3668. if ($child['playlistType'] == "video" && strpos(strtolower($child['title']) , 'private') === false){
  3669. $api = @curl_get($address.$child['key']."?X-Plex-Token=".PLEXTOKEN);
  3670. $api = simplexml_load_string($api);
  3671. if (is_array($api) || is_object($api)){
  3672. if (!$api->head->title){
  3673. $className = preg_replace("/(\W)+/", "", $api['title']);
  3674. $hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  3675. foreach($api->Video AS $child){
  3676. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false,false,$className);
  3677. }
  3678. if (count($items)) {
  3679. $output .= ''.implode('',$items).'';
  3680. }
  3681. }
  3682. }
  3683. }
  3684. }
  3685. $hideMenu .= '</ul></div></div>';
  3686. 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>';
  3687. }else{
  3688. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check token - if HTTPS, is cert valid");
  3689. }
  3690. }else{
  3691. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check URL - if HTTPS, is cert valid");
  3692. }
  3693. }
  3694. function readExternalLog($type,$filename,$name = null){
  3695. $log = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3696. $log = array_reverse($log);
  3697. foreach($log as $line){
  3698. if(!empty($line) && $line[0] != " "){
  3699. $line = strip($line);
  3700. if($type == "single"){
  3701. if( strpos( strtolower($line), "ror" ) !== false ) {
  3702. echo "<tr><td class='red-bg'>".$line."</td></tr>";
  3703. }else{
  3704. echo "<tr><td>".$line."</td></tr>";
  3705. }
  3706. }elseif($type == "all"){
  3707. if( strpos( strtolower($line), "ror" ) !== false ) {
  3708. echo "<tr><td class='red-bg'>".$name."</td>";
  3709. echo "<td class='red-bg'>".$line."</td></tr>";
  3710. }else{
  3711. echo "<tr><td>".$name."</td>";
  3712. echo "<td>".$line."</td></tr>";
  3713. }
  3714. }
  3715. }
  3716. }
  3717. }
  3718. function getLogs(){
  3719. $path = __DIR__ ."/logs/";
  3720. @mkdir($path, 0770, true);
  3721. $logs = array();
  3722. $files = array_diff(scandir($path), array('.', '..'));
  3723. foreach($files as $v){
  3724. $title = explode(".", $v)[0];
  3725. $logs[$title] = $path.$v;
  3726. }
  3727. return $logs;
  3728. }
  3729. function getBackups(){
  3730. $path = DATABASE_LOCATION ."backups/";
  3731. @mkdir($path, 0770, true);
  3732. $backups = array();
  3733. $files = array_diff(scandir($path), array('.', '..'));
  3734. return array_reverse($files);
  3735. }
  3736. function getExtension($string) {
  3737. return preg_replace("#(.+)?\.(\w+)(\?.+)?#", "$2", $string);
  3738. }
  3739. function showFile(){
  3740. $file = $_GET['file'];
  3741. $fileType = getExtension($file);
  3742. if($fileType != 'php'){
  3743. header("Content-type: ".mimeTypes()[$fileType]);
  3744. @readfile($file);
  3745. }
  3746. }
  3747. function getCalendar(){
  3748. $sonarr = new Sonarr(SONARRURL, SONARRKEY);
  3749. $radarr = new Sonarr(RADARRURL, RADARRKEY);
  3750. $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
  3751. $startDate = date('Y-m-d',strtotime("-".CALENDARSTARTDAY." days"));
  3752. $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
  3753. $calendarItems = array();
  3754. if (SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)){
  3755. try {
  3756. $sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate));
  3757. if(!empty($sonarrCalendar)) { $calendarItems = array_merge($calendarItems, $sonarrCalendar); }
  3758. } catch (Exception $e) {
  3759. writeLog("error", "SONARR ERROR: ".strip($e->getMessage()));
  3760. }
  3761. }
  3762. if (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)){
  3763. try {
  3764. $radarrCalendar = getRadarrCalendar($radarr->getCalendar($startDate, $endDate));
  3765. if(!empty($radarrCalendar)) { $calendarItems = array_merge($calendarItems, $radarrCalendar); }
  3766. } catch (Exception $e) {
  3767. writeLog("error", "RADARR ERROR: ".strip($e->getMessage()));
  3768. }
  3769. }
  3770. if (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH)){
  3771. $couchCalendar = getCouchCalendar();
  3772. if(!empty($couchCalendar)) { $calendarItems = array_merge($calendarItems, $couchCalendar); }
  3773. }
  3774. if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
  3775. $headphonesHistory = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory");
  3776. $headphonesWanted = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted");
  3777. if(!empty($headphonesHistory)) { $calendarItems = array_merge($calendarItems, $headphonesHistory); }
  3778. if(!empty($headphonesWanted)) { $calendarItems = array_merge($calendarItems, $headphonesWanted); }
  3779. }
  3780. if (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)){
  3781. try {
  3782. $sickrageFuture = getSickrageCalendarWanted($sickrage->future());
  3783. if(!empty($sickrageFuture)) { $calendarItems = array_merge($calendarItems, $sickrageFuture); }
  3784. } catch (Exception $e) {
  3785. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3786. } try {
  3787. $sickrageHistory = getSickrageCalendarHistory($sickrage->history("100","downloaded"));
  3788. if(!empty($sickrageHistory)) { $calendarItems = array_merge($calendarItems, $sickrageHistory); }
  3789. } catch (Exception $e) {
  3790. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3791. }
  3792. }
  3793. return $calendarItems;
  3794. }
  3795. function localURL($url){
  3796. if (strpos($url, 'https') !== false) {
  3797. preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $url, $result);
  3798. $result = (!empty($result) ? true : false);
  3799. return $result;
  3800. }
  3801. }
  3802. function fileArray($files){
  3803. foreach($files as $file){
  3804. if(file_exists($file)){
  3805. $list[] = $file;
  3806. }
  3807. }
  3808. if(!empty($list)){ return $list; }
  3809. }
  3810. function backupDB(){
  3811. if (extension_loaded('ZIP')) {
  3812. $directory = DATABASE_LOCATION."backups/";
  3813. @mkdir($directory, 0770, true);
  3814. $orgFiles = array(
  3815. 'css' => 'custom.css',
  3816. 'temp' => 'cus.sd',
  3817. 'orgLog' => DATABASE_LOCATION.'org.log',
  3818. 'loginLog' => DATABASE_LOCATION.'loginLog.json',
  3819. 'chatDB' => 'chatpack.db',
  3820. 'config' => 'config/config.php',
  3821. 'database' => DATABASE_LOCATION.'users.db'
  3822. );
  3823. $files = fileArray($orgFiles);
  3824. if(!empty($files)){
  3825. writeLog("success", "BACKUP: backup process started");
  3826. $zipname = $directory.'backup['.date('Y-m-d_H-i').']['.INSTALLEDVERSION.'].zip';
  3827. $zip = new ZipArchive;
  3828. $zip->open($zipname, ZipArchive::CREATE);
  3829. foreach ($files as $file) {
  3830. $zip->addFile($file);
  3831. }
  3832. $zip->close();
  3833. writeLog("success", "BACKUP: backup process finished");
  3834. return true;
  3835. }else{
  3836. return false;
  3837. }
  3838. }else{
  3839. return false;
  3840. }
  3841. }
  3842. class Ping {
  3843. private $host;
  3844. private $ttl;
  3845. private $timeout;
  3846. private $port = 80;
  3847. private $data = 'Ping';
  3848. private $commandOutput;
  3849. /**
  3850. * Called when the Ping object is created.
  3851. *
  3852. * @param string $host
  3853. * The host to be pinged.
  3854. * @param int $ttl
  3855. * Time-to-live (TTL) (You may get a 'Time to live exceeded' error if this
  3856. * value is set too low. The TTL value indicates the scope or range in which
  3857. * a packet may be forwarded. By convention:
  3858. * - 0 = same host
  3859. * - 1 = same subnet
  3860. * - 32 = same site
  3861. * - 64 = same region
  3862. * - 128 = same continent
  3863. * - 255 = unrestricted
  3864. * @param int $timeout
  3865. * Timeout (in seconds) used for ping and fsockopen().
  3866. * @throws \Exception if the host is not set.
  3867. */
  3868. public function __construct($host, $ttl = 255, $timeout = 10) {
  3869. if (!isset($host)) {
  3870. throw new \Exception("Error: Host name not supplied.");
  3871. }
  3872. $this->host = $host;
  3873. $this->ttl = $ttl;
  3874. $this->timeout = $timeout;
  3875. }
  3876. /**
  3877. * Set the ttl (in hops).
  3878. *
  3879. * @param int $ttl
  3880. * TTL in hops.
  3881. */
  3882. public function setTtl($ttl) {
  3883. $this->ttl = $ttl;
  3884. }
  3885. /**
  3886. * Get the ttl.
  3887. *
  3888. * @return int
  3889. * The current ttl for Ping.
  3890. */
  3891. public function getTtl() {
  3892. return $this->ttl;
  3893. }
  3894. /**
  3895. * Set the timeout.
  3896. *
  3897. * @param int $timeout
  3898. * Time to wait in seconds.
  3899. */
  3900. public function setTimeout($timeout) {
  3901. $this->timeout = $timeout;
  3902. }
  3903. /**
  3904. * Get the timeout.
  3905. *
  3906. * @return int
  3907. * Current timeout for Ping.
  3908. */
  3909. public function getTimeout() {
  3910. return $this->timeout;
  3911. }
  3912. /**
  3913. * Set the host.
  3914. *
  3915. * @param string $host
  3916. * Host name or IP address.
  3917. */
  3918. public function setHost($host) {
  3919. $this->host = $host;
  3920. }
  3921. /**
  3922. * Get the host.
  3923. *
  3924. * @return string
  3925. * The current hostname for Ping.
  3926. */
  3927. public function getHost() {
  3928. return $this->host;
  3929. }
  3930. /**
  3931. * Set the port (only used for fsockopen method).
  3932. *
  3933. * Since regular pings use ICMP and don't need to worry about the concept of
  3934. * 'ports', this is only used for the fsockopen method, which pings servers by
  3935. * checking port 80 (by default).
  3936. *
  3937. * @param int $port
  3938. * Port to use for fsockopen ping (defaults to 80 if not set).
  3939. */
  3940. public function setPort($port) {
  3941. $this->port = $port;
  3942. }
  3943. /**
  3944. * Get the port (only used for fsockopen method).
  3945. *
  3946. * @return int
  3947. * The port used by fsockopen pings.
  3948. */
  3949. public function getPort() {
  3950. return $this->port;
  3951. }
  3952. /**
  3953. * Return the command output when method=exec.
  3954. * @return string
  3955. */
  3956. public function getCommandOutput(){
  3957. return $this->commandOutput;
  3958. }
  3959. /**
  3960. * Matches an IP on command output and returns.
  3961. * @return string
  3962. */
  3963. public function getIpAddress() {
  3964. $out = array();
  3965. if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $this->commandOutput, $out)){
  3966. return $out[0];
  3967. }
  3968. return null;
  3969. }
  3970. /**
  3971. * Ping a host.
  3972. *
  3973. * @param string $method
  3974. * Method to use when pinging:
  3975. * - exec (default): Pings through the system ping command. Fast and
  3976. * robust, but a security risk if you pass through user-submitted data.
  3977. * - fsockopen: Pings a server on port 80.
  3978. * - socket: Creates a RAW network socket. Only usable in some
  3979. * environments, as creating a SOCK_RAW socket requires root privileges.
  3980. *
  3981. * @throws InvalidArgumentException if $method is not supported.
  3982. *
  3983. * @return mixed
  3984. * Latency as integer, in ms, if host is reachable or FALSE if host is down.
  3985. */
  3986. public function ping($method = 'exec') {
  3987. $latency = false;
  3988. switch ($method) {
  3989. case 'exec':
  3990. $latency = $this->pingExec();
  3991. break;
  3992. case 'fsockopen':
  3993. $latency = $this->pingFsockopen();
  3994. break;
  3995. case 'socket':
  3996. $latency = $this->pingSocket();
  3997. break;
  3998. default:
  3999. throw new \InvalidArgumentException('Unsupported ping method.');
  4000. }
  4001. // Return the latency.
  4002. return $latency;
  4003. }
  4004. /**
  4005. * The exec method uses the possibly insecure exec() function, which passes
  4006. * the input to the system. This is potentially VERY dangerous if you pass in
  4007. * any user-submitted data. Be SURE you sanitize your inputs!
  4008. *
  4009. * @return int
  4010. * Latency, in ms.
  4011. */
  4012. private function pingExec() {
  4013. $latency = false;
  4014. $ttl = escapeshellcmd($this->ttl);
  4015. $timeout = escapeshellcmd($this->timeout);
  4016. $host = escapeshellcmd($this->host);
  4017. // Exec string for Windows-based systems.
  4018. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  4019. // -n = number of pings; -i = ttl; -w = timeout (in milliseconds).
  4020. $exec_string = 'ping -n 1 -i ' . $ttl . ' -w ' . ($timeout * 1000) . ' ' . $host;
  4021. }
  4022. // Exec string for Darwin based systems (OS X).
  4023. else if(strtoupper(PHP_OS) === 'DARWIN') {
  4024. // -n = numeric output; -c = number of pings; -m = ttl; -t = timeout.
  4025. $exec_string = 'ping -n -c 1 -m ' . $ttl . ' -t ' . $timeout . ' ' . $host;
  4026. }
  4027. // Exec string for other UNIX-based systems (Linux).
  4028. else {
  4029. // -n = numeric output; -c = number of pings; -t = ttl; -W = timeout
  4030. $exec_string = 'ping -n -c 1 -t ' . $ttl . ' -W ' . $timeout . ' ' . $host . ' 2>&1';
  4031. }
  4032. exec($exec_string, $output, $return);
  4033. // Strip empty lines and reorder the indexes from 0 (to make results more
  4034. // uniform across OS versions).
  4035. $this->commandOutput = implode($output, '');
  4036. $output = array_values(array_filter($output));
  4037. // If the result line in the output is not empty, parse it.
  4038. if (!empty($output[1])) {
  4039. // Search for a 'time' value in the result line.
  4040. $response = preg_match("/time(?:=|<)(?<time>[\.0-9]+)(?:|\s)ms/", $output[1], $matches);
  4041. // If there's a result and it's greater than 0, return the latency.
  4042. if ($response > 0 && isset($matches['time'])) {
  4043. $latency = round($matches['time'], 2);
  4044. }
  4045. }
  4046. return $latency;
  4047. }
  4048. /**
  4049. * The fsockopen method simply tries to reach the host on a port. This method
  4050. * is often the fastest, but not necessarily the most reliable. Even if a host
  4051. * doesn't respond, fsockopen may still make a connection.
  4052. *
  4053. * @return int
  4054. * Latency, in ms.
  4055. */
  4056. private function pingFsockopen() {
  4057. $start = microtime(true);
  4058. // fsockopen prints a bunch of errors if a host is unreachable. Hide those
  4059. // irrelevant errors and deal with the results instead.
  4060. $fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
  4061. if (!$fp) {
  4062. $latency = false;
  4063. }
  4064. else {
  4065. $latency = microtime(true) - $start;
  4066. $latency = round($latency * 1000, 2);
  4067. }
  4068. return $latency;
  4069. }
  4070. /**
  4071. * The socket method uses raw network packet data to try sending an ICMP ping
  4072. * packet to a server, then measures the response time. Using this method
  4073. * requires the script to be run with root privileges, though, so this method
  4074. * only works reliably on Windows systems and on Linux servers where the
  4075. * script is not being run as a web user.
  4076. *
  4077. * @return int
  4078. * Latency, in ms.
  4079. */
  4080. private function pingSocket() {
  4081. // Create a package.
  4082. $type = "\x08";
  4083. $code = "\x00";
  4084. $checksum = "\x00\x00";
  4085. $identifier = "\x00\x00";
  4086. $seq_number = "\x00\x00";
  4087. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4088. // Calculate the checksum.
  4089. $checksum = $this->calculateChecksum($package);
  4090. // Finalize the package.
  4091. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4092. // Create a socket, connect to server, then read socket and calculate.
  4093. if ($socket = socket_create(AF_INET, SOCK_RAW, 1)) {
  4094. socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array(
  4095. 'sec' => 10,
  4096. 'usec' => 0,
  4097. ));
  4098. // Prevent errors from being printed when host is unreachable.
  4099. @socket_connect($socket, $this->host, null);
  4100. $start = microtime(true);
  4101. // Send the package.
  4102. @socket_send($socket, $package, strlen($package), 0);
  4103. if (socket_read($socket, 255) !== false) {
  4104. $latency = microtime(true) - $start;
  4105. $latency = round($latency * 1000, 2);
  4106. }
  4107. else {
  4108. $latency = false;
  4109. }
  4110. }
  4111. else {
  4112. $latency = false;
  4113. }
  4114. // Close the socket.
  4115. socket_close($socket);
  4116. return $latency;
  4117. }
  4118. /**
  4119. * Calculate a checksum.
  4120. *
  4121. * @param string $data
  4122. * Data for which checksum will be calculated.
  4123. *
  4124. * @return string
  4125. * Binary string checksum of $data.
  4126. */
  4127. private function calculateChecksum($data) {
  4128. if (strlen($data) % 2) {
  4129. $data .= "\x00";
  4130. }
  4131. $bit = unpack('n*', $data);
  4132. $sum = array_sum($bit);
  4133. while ($sum >> 16) {
  4134. $sum = ($sum >> 16) + ($sum & 0xffff);
  4135. }
  4136. return pack('n*', ~$sum);
  4137. }
  4138. }
  4139. function ping($pings, $type = "string") {
  4140. $ping = new Ping("");
  4141. $ping->setTtl(128);
  4142. $ping->setTimeout(2);
  4143. switch ($type){
  4144. case "array":
  4145. $results = [];
  4146. foreach ($pings as $k => $v) {
  4147. if(strpos($v, ':') !== false){
  4148. $domain = explode(':', $v)[0];
  4149. $port = explode(':', $v)[1];
  4150. $ping->setHost($domain);
  4151. $ping->setPort($port);
  4152. $latency = $ping->ping('fsockopen');
  4153. }else{
  4154. $ping->setHost($v);
  4155. $latency = $ping->ping();
  4156. }
  4157. if ($latency || $latency === 0) {
  4158. $results[$k] = $latency;
  4159. } else {
  4160. $results[$k] = 0;
  4161. }
  4162. }
  4163. break;
  4164. case "string":
  4165. if(strpos($pings, ':') !== false){
  4166. $domain = explode(':', $pings)[0];
  4167. $port = explode(':', $pings)[1];
  4168. $ping->setHost($domain);
  4169. $ping->setPort($port);
  4170. $latency = $ping->ping('fsockopen');
  4171. }else{
  4172. $ping->setHost($pings);
  4173. $latency = $ping->ping();
  4174. }
  4175. if ($latency || $latency === 0) {
  4176. $results = $latency;
  4177. } else {
  4178. $results = 0;
  4179. }
  4180. break;
  4181. }
  4182. return $results;
  4183. }
  4184. function getPing($url, $style, $refresh = null){
  4185. if(ping($url) !== 0){
  4186. $class = 'success';
  4187. if(!$refresh){
  4188. $class .= " animated slideInLeft";
  4189. }
  4190. }else{
  4191. $class = "warning";
  4192. if(!$refresh){
  4193. $class .= " animated flash loop-animation-timeout";
  4194. }
  4195. }
  4196. echo '<span class="pingcheck badge ping-'.$class.'" style="position: absolute;z-index: 100;right: 5px; padding: 0px 0px;'.$style.';font-size: 10px;">&nbsp;</span>';
  4197. }
  4198. function speedTestData(){
  4199. $file_db = DATABASE_LOCATION."speedtest.db";
  4200. if(file_exists($file_db)){
  4201. $conn = new PDO("sqlite:$file_db") or die("1");
  4202. $result = $conn->query('SELECT * FROM speedtest_users');
  4203. $conn = null;
  4204. if (is_array($result) || is_object($result)){
  4205. foreach($result as $k => $v){
  4206. $return[$k] = $v;
  4207. }
  4208. return $return;
  4209. }
  4210. }
  4211. }
  4212. function speedTestDisplay($array, $output){
  4213. if (is_array($array) || is_object($array)){
  4214. if($output == "graph"){
  4215. $result = "Morris.Line({element: 'morris-line',data: [";
  4216. foreach($array as $k => $v){
  4217. $result .= "{ y: '".substr($v['timestamp'],0,10)."', a: ".$v['ul'].", b: ".$v['dl'].", c: ".$v['ping']." },";
  4218. }
  4219. $result .= "],xkey: 'y',ykeys: ['a', 'b', 'c'],labels: ['Upload', 'Download', 'Ping'],hideHover: 'auto',resize: true,lineColors: ['#63A8EB','#ccc','#000'] });";
  4220. }elseif($output == "table"){
  4221. $result = "";
  4222. foreach($array as $k => $v){
  4223. $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>";
  4224. }
  4225. }
  4226. return $result;
  4227. }
  4228. }
  4229. function buildMenuPhone($array){
  4230. if (is_array($array) || is_object($array)){
  4231. $result = '
  4232. <div class="content-box profile-sidebar box-shadow">
  4233. <img src="images/organizr-logo-h-d.png" width="100%" style="margin-top: -10px;">
  4234. <div class="profile-usermenu">
  4235. <ul class="nav" id="settings-list">
  4236. ';
  4237. foreach($array as $k => $v){
  4238. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4239. continue;
  4240. }
  4241. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4242. continue;
  4243. }
  4244. /*$result .= '
  4245. <li>
  4246. <a id="'.$v['id'].'" box="'.$v['box'].'">'.$v['name'].'
  4247. <span class="fa-stack fa-fw pull-right" style="margin-top: -5px;margin-right: -10px;">
  4248. <i class="fa fa-'.$v['icon_1'].' fa-stack-2x '.$v['color'].'" style="font-size:null;"></i>
  4249. <i class="fa fa-'.$v['icon_2'].' fa-stack-1x fa-inverse"></i>
  4250. </span>
  4251. </a>
  4252. </li>
  4253. ';*/
  4254. $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>';
  4255. }
  4256. $result .= '</ul></div></div>';
  4257. return $result;
  4258. }
  4259. }
  4260. function buildMenu($array){
  4261. if (is_array($array) || is_object($array)){
  4262. $result = '<div class="settingsList">';
  4263. foreach($array as $k => $v){
  4264. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4265. continue;
  4266. }
  4267. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4268. continue;
  4269. }
  4270. $result .= '
  4271. <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">
  4272. <i class="mdi mdi-'.$v['icon_1'].' fa-fw pull-left" style="padding-left: '.$v['padding'].'px;font-size: 30px"></i>
  4273. <p class="" style="text-align: center;direction: rtl;display:none;margin: 2px;"><strong>'.$v['name'].'</strong></p>
  4274. </button>
  4275. ';
  4276. }
  4277. $result .= '</div>';
  4278. return $result;
  4279. }
  4280. }
  4281. function requestInvite($email, $username){
  4282. //sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null){
  4283. //orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  4284. 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."));
  4285. }
  4286. function errormessage($msg) {
  4287. echo "<div style=\"margin-top: 50px;\">";
  4288. echo "<span style=\"color:#d89334;\">error </span>";
  4289. echo $msg;
  4290. echo "</div>";
  4291. }
  4292. function ajaxLoop($ajaxFunction, $refresh, $extraFunction = ''){
  4293. return "
  4294. setInterval(function() {
  4295. $.ajax({
  4296. url: 'ajax.php?a=".$ajaxFunction."',
  4297. timeout: 10000,
  4298. type: 'GET',
  4299. success: function(response) {
  4300. var getDiv = response;
  4301. var loadedID = $(getDiv).attr('id');
  4302. if (typeof loadedID !== 'undefined') {
  4303. $('#'+loadedID).replaceWith($(getDiv).prop('outerHTML'));
  4304. ".$extraFunction."
  4305. console.log('".$ajaxFunction." has been updated');
  4306. }else{
  4307. console.log('".$ajaxFunction." data was not sufficent or is offline');
  4308. }
  4309. },
  4310. error: function(jqXHR, textStatus, errorThrown) {
  4311. console.error('".$ajaxFunction." could not be updated');
  4312. }
  4313. });
  4314. }, ".$refresh.");
  4315. ";
  4316. }
  4317. function getOrgUsers(){
  4318. $file_db = DATABASE_LOCATION."users.db";
  4319. if(file_exists($file_db)){
  4320. $conn = new PDO("sqlite:$file_db") or die("1");
  4321. $result = $conn->query('SELECT * FROM users');
  4322. $conn = null;
  4323. if (is_array($result) || is_object($result)){
  4324. foreach($result as $k => $v){
  4325. $return[$v['username']] = $v['email'];
  4326. }
  4327. return $return;
  4328. }
  4329. }
  4330. }
  4331. function getEmails($type = 'org'){
  4332. if($type == 'plex'){
  4333. $emails = array_merge(libraryList()['both'],getOrgUsers());
  4334. }elseif($type == 'emby'){
  4335. $emails = getOrgUsers();
  4336. }else{
  4337. $emails = getOrgUsers();
  4338. }
  4339. return $emails;
  4340. }
  4341. function printEmails($emails){
  4342. $result = '';
  4343. foreach($emails as $k => $v){
  4344. $result .= '<option value="'.$v.'">'.$k.'</option>';
  4345. }
  4346. return $result;
  4347. }
  4348. function massEmail($to, $subject, $message){
  4349. if (!isset($GLOBALS['file_db'])) {
  4350. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  4351. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  4352. }
  4353. 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);
  4354. }
  4355. function q2a($q){
  4356. if (is_array($q) || is_object($q)){
  4357. foreach ($q as $k => $v){
  4358. $a[$k] = $v;
  4359. }
  4360. if(!empty($a)){
  4361. return $a;
  4362. }
  4363. }
  4364. }
  4365. function getOmbiToken($username, $password){
  4366. $headers = array(
  4367. "Accept" => "application/json",
  4368. "Content-Type" => "application/json"
  4369. );
  4370. $json = array(
  4371. "username" => $username,
  4372. "password" => $password,
  4373. "rememberMe" => "true",
  4374. );
  4375. $api = curl_post(OMBIURL."/api/v1/Token", $json, $headers);
  4376. if (isset($api['content'])) {
  4377. return json_decode($api['content'], true)['access_token'];
  4378. }else{
  4379. return false;
  4380. }
  4381. }
  4382. function ombiAction($id, $action, $type){
  4383. $headers = array(
  4384. "Accept" => "application/json",
  4385. "Content-Type" => "application/json",
  4386. "Apikey" => OMBIKEY
  4387. );
  4388. $body = array(
  4389. 'id' => $id,
  4390. );
  4391. switch ($type) {
  4392. case 'season':
  4393. case 'tv':
  4394. $type = 'tv';
  4395. break;
  4396. default:
  4397. $type = 'movie';
  4398. break;
  4399. }
  4400. switch ($action) {
  4401. case 'approve':
  4402. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/approve", $body, $headers);
  4403. break;
  4404. case 'available':
  4405. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/available", $body, $headers);
  4406. break;
  4407. case 'unavailable':
  4408. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/unavailable", $body, $headers);
  4409. break;
  4410. case 'deny':
  4411. $api = curl_put(OMBIURL."/api/v1/Request/".$type."/deny", $body, $headers);
  4412. break;
  4413. case 'delete':
  4414. $api = curl_delete(OMBIURL."/api/v1/Request/".$type."/".$id, $headers);
  4415. break;
  4416. default:
  4417. # code...
  4418. break;
  4419. }
  4420. switch ($api['http_code']['http_code']){
  4421. case 401:
  4422. writeLog("error", "OMBI: Invalid API KEY");
  4423. return false;
  4424. break;
  4425. case 200:
  4426. writeLog("success", "OMBI: action completed successfully for [type: $type - action: $action - id: $id]");
  4427. return true;
  4428. break;
  4429. default:
  4430. writeLog("error", "OMBI: unknown error with request [type: $type - action: $action - id: $id]");
  4431. return false;
  4432. }
  4433. //return (!empty($result) ? $result : null );
  4434. }
  4435. function getOmbiRequests($type = "both"){
  4436. $headers = array(
  4437. "Accept" => "application/json",
  4438. "Apikey" => OMBIKEY,
  4439. );
  4440. $requests = array();
  4441. switch ($type) {
  4442. case 'movie':
  4443. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4444. break;
  4445. case 'tv':
  4446. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4447. break;
  4448. default:
  4449. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4450. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4451. break;
  4452. }
  4453. if(isset($movie)){
  4454. //$movie = array_reverse($movie);
  4455. foreach ($movie as $key => $value) {
  4456. $poster = explode('/',$value['posterPath']);
  4457. $requests[] = array(
  4458. 'id' => $value['theMovieDbId'],
  4459. 'title' => $value['title'],
  4460. 'poster' => (strpos($value['posterPath'], "/") !== false) ? 'https://image.tmdb.org/t/p/w300/'.end($poster) : 'https://image.tmdb.org/t/p/w300/'.$value['posterPath'],
  4461. 'approved' => $value['approved'],
  4462. 'available' => $value['available'],
  4463. 'denied' => $value['denied'],
  4464. 'deniedReason' => $value['deniedReason'],
  4465. 'user' => $value['requestedUser']['userName'],
  4466. 'request_id' => $value['id'],
  4467. 'request_date' => $value['requestedDate'],
  4468. 'release_date' => $value['releaseDate'],
  4469. 'type' => 'movie',
  4470. 'icon' => 'mdi mdi-filmstrip',
  4471. 'color' => 'palette-Deep-Purple-900 bg white',
  4472. );
  4473. }
  4474. }
  4475. if(isset($tv) && (is_array($tv) || is_object($tv))){
  4476. foreach ($tv as $key => $value) {
  4477. if(is_array($value['childRequests'][0])){
  4478. $requests[] = array(
  4479. 'id' => $value['tvDbId'],
  4480. 'title' => $value['title'],
  4481. 'poster' => $value['posterPath'],
  4482. 'approved' => $value['childRequests'][0]['approved'],
  4483. 'available' => $value['childRequests'][0]['available'],
  4484. 'denied' => $value['childRequests'][0]['denied'],
  4485. 'deniedReason' => $value['childRequests'][0]['deniedReason'],
  4486. 'user' => $value['childRequests'][0]['requestedUser']['userName'],
  4487. 'request_id' => $value['id'],
  4488. 'request_date' => $value['childRequests'][0]['requestedDate'],
  4489. 'release_date' => $value['releaseDate'],
  4490. 'type' => 'tv',
  4491. 'icon' => 'mdi mdi-television',
  4492. 'color' => 'grayish-blue-bg',
  4493. );
  4494. }
  4495. }
  4496. }
  4497. return (empty($requests)) ? '' : $requests;
  4498. }
  4499. function convertOmbiString($type, $value){
  4500. switch ($type) {
  4501. case 'approved':
  4502. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4503. $string['icon'] = ($value) ? 'mdi mdi-check' : 'mdi mdi-clock';
  4504. $string['color'] = ($value) ? 'green-bg' : 'yellow-bg';
  4505. break;
  4506. case 'available':
  4507. $string['string'] = ($value) ? 'Available' : 'Not Downloaded';
  4508. $string['icon'] = ($value) ? 'mdi mdi-server' : 'mdi mdi-server-off';
  4509. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4510. break;
  4511. case 'denied':
  4512. $string['string'] = ($value) ? 'Denied' : 'Approved';
  4513. $string['icon'] = ($value) ? 'mdi mdi-emoticon-sad' : 'mdi mdi-emoticon-happy';
  4514. $string['color'] = ($value) ? 'red-bg' : 'green-bg';
  4515. break;
  4516. case 'status':
  4517. switch ($value) {
  4518. case '1':
  4519. $string['string'] = 'Denied';
  4520. $string['icon'] = 'mdi mdi-window-close';
  4521. $string['color'] = 'red-bg';
  4522. break;
  4523. case '2':
  4524. $string['string'] = 'Approved';
  4525. $string['icon'] = 'mdi mdi-check';
  4526. $string['color'] = 'green-bg';
  4527. break;
  4528. case '3':
  4529. $string['string'] = 'Not Approved';
  4530. $string['icon'] = 'mdi mdi-clock';
  4531. $string['color'] = 'yellow-bg';
  4532. break;
  4533. default:
  4534. # code...
  4535. break;
  4536. }
  4537. break;
  4538. default:
  4539. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4540. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4541. break;
  4542. }
  4543. return $string;
  4544. }
  4545. function buildOmbiItem($type, $group, $user, $request){
  4546. if (is_array($request) || is_object($request)){
  4547. $actions = '';
  4548. if($request['denied']){
  4549. $status = 1;
  4550. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4551. }else{
  4552. if($request['approved']){
  4553. $status = 2;
  4554. }else{
  4555. $status = 3;
  4556. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4557. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="deny"><a class="requestAction" href="javascript:void(0)">Deny</a></li>';
  4558. }
  4559. }
  4560. if($request['available']){
  4561. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="unavailable"><a class="requestAction" href="javascript:void(0)">Mark as Unavailable</a></li>';
  4562. }else{
  4563. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="available"><a class="requestAction" href="javascript:void(0)">Mark as Available</a></li>';
  4564. }
  4565. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="delete"><a class="requestAction" href="javascript:void(0)">Delete</a></li>';
  4566. if(isset($group) && $group == 'admin'){
  4567. $actionMenu = '
  4568. <div class="requestOptions">
  4569. <div class="btn-group transparent" role="group">
  4570. <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>
  4571. <ul class="dropdown-menu"><h6 class="text-center requestHeader gray-bg">'.$request['user'].'</h6>'.$actions.'</ul>
  4572. </div>
  4573. </div>
  4574. ';
  4575. }else{
  4576. $actionMenu = '';
  4577. }
  4578. if((isset($group)) && $group == 'admin' || REQUESTEDUSERONLY == 'false'){
  4579. return '
  4580. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4581. '.$actionMenu.'
  4582. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4583. <div class="requestBottom text-center">
  4584. <div data-toggle="tooltip" data-placement="top" data-original-title="'.$request['type'].'" class="zero-m requestGroup '.$request['color'].'">
  4585. <i class="'.$request['icon'].'"></i>
  4586. </div>
  4587. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4588. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4589. </div>
  4590. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4591. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4592. </div>
  4593. </div>
  4594. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4595. </div>';
  4596. }else{
  4597. if(strtolower($request['user']) == strtolower($user)){
  4598. return '
  4599. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4600. '.$actionMenu.'
  4601. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4602. <div class="requestBottom text-center">
  4603. <div data-toggle="tooltip" data-placement="top" data-original-title="'.$request['type'].'" class="zero-m requestGroup '.$request['color'].'">
  4604. <i class="'.$request['icon'].'"></i>
  4605. </div>
  4606. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4607. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4608. </div>
  4609. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4610. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4611. </div>
  4612. </div>
  4613. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4614. </div>';
  4615. }
  4616. }
  4617. }
  4618. }
  4619. function buildOmbiList($group, $user){
  4620. $requests = array();
  4621. $movieList = getOmbiRequests('movie');
  4622. $tvList = getOmbiRequests('tv');
  4623. if(is_array($movieList) && is_array($tvList)){
  4624. $result = array_merge($movieList , $tvList );
  4625. }else{
  4626. if(is_array($movieList)){
  4627. $result = $movieList;
  4628. }elseif(is_array($movieList)){
  4629. $result = $tvList;
  4630. }else{
  4631. $result = false;
  4632. }
  4633. }
  4634. if (is_array($result) || is_object($result)){
  4635. usort($result, function ($item1, $item2) {
  4636. if ($item1['request_date'] == $item2['request_date']) return 0;
  4637. return $item1['request_date'] > $item2['request_date'] ? -1 : 1;
  4638. });
  4639. foreach ($result as $request) {
  4640. if($request['type'] == 'movie'){
  4641. $requests[] = buildOmbiItem('movie', $group, $user, $request);
  4642. }elseif($request['type'] == 'tv'){
  4643. $requests[] = buildOmbiItem('season', $group, $user, $request);
  4644. }
  4645. }
  4646. }
  4647. return outputOmbiRequests("Requested Content", $requests, ajaxLoop('ombi-requests',REQUESTREFRESH,'loadSlick();'), false);
  4648. }
  4649. function outputOmbiRequests($header = "Requested Content", $items, $script = false, $array) {
  4650. $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">';
  4651. if(preg_grep("/item-movie-Approved/", $items)){
  4652. $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>';
  4653. }
  4654. if(preg_grep("/item-movie-Approval-Pending/", $items)){
  4655. $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>';
  4656. }
  4657. if(preg_grep("/item-season-Approved/", $items)){
  4658. $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>';
  4659. }
  4660. if(preg_grep("/item-season-Approval-Pending/", $items)){
  4661. $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>';
  4662. }
  4663. $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>';
  4664. $hideMenu .= '</ul></div></div>';
  4665. // If None Populate Empty Item
  4666. //if (count(array_flip($items)) < 1) {
  4667. if(!array_filter($items)) {
  4668. return '<div id="recentRequests"></div>';
  4669. }else{
  4670. $className = str_replace(' ', '', $header);
  4671. 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>':'');
  4672. }
  4673. }
  4674. function loadIcons(){
  4675. $dirname = "images/";
  4676. $images = scandir($dirname);
  4677. $ignore = Array(".", "..", "favicon", "settings", "cache", "platforms", "._.DS_Store", ".DS_Store", "confused.png", "sowwy.png", "sort-btns", "loading.png", "titlelogo.png", "default.svg", "login.png", "no-np.png", "no-list.png", "no-np.psd", "no-list.psd", "themes", "nadaplaying.jpg", "organizr-logo-h-d.png", "organizr-logo-h.png");
  4678. $allIcons = '';
  4679. foreach($images as $curimg){
  4680. if(!in_array($curimg, $ignore)) {
  4681. $allIcons .= '
  4682. <div class="col-xs-2" style="width: 75px; height: 75px; padding-right: 0px;">
  4683. <a data-toggle="tooltip" data-placement="bottom" title="'.$dirname.$curimg.'" class="thumbnail" style="box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);">
  4684. <img style="width: 50px; height: 50px;" data-src="'.$dirname.$curimg.'" alt="thumbnail" class="allIcons lazyload shadow">
  4685. </a>
  4686. </div>
  4687. ';
  4688. }
  4689. }
  4690. return $allIcons;
  4691. }
  4692. function buildHomepageSettings(){
  4693. $homepageOrder = homepageOrder();
  4694. $homepageList = '<h4>Drag Homepage Items to Order Them</h4><div id="homepage-items" class="external-events">';
  4695. $inputList = '<div id="homepage-values" class="row">';
  4696. foreach ($homepageOrder as $key => $val) {
  4697. switch ($key) {
  4698. case 'homepageOrdercustomhtml':
  4699. $class = 'palette-Deep-Purple-100 bg gray';
  4700. $image = 'images/html.png';
  4701. if(empty(HOMEPAGECUSTOMHTML1)){
  4702. $class .= ' faded';
  4703. }
  4704. break;
  4705. case 'homepageOrdernotice':
  4706. $class = 'palette-Cyan-A400 bg gray';
  4707. $image = 'images/pin.png';
  4708. if(empty(HOMEPAGENOTICETITLE) && empty(HOMEPAGENOTICEMESSAGE)){
  4709. $class .= ' faded';
  4710. }
  4711. break;
  4712. case 'homepageOrderspeedtest':
  4713. $class = 'red-bg';
  4714. $image = 'images/settings/full-color/png/64px/speedometer.png';
  4715. if(SPEEDTEST !== "true"){
  4716. $class .= ' faded';
  4717. }
  4718. break;
  4719. case 'homepageOrdernzbget':
  4720. $class = 'green-bg';
  4721. $image = 'images/nzbget.png';
  4722. if(empty(NZBGETURL)){
  4723. $class .= ' faded';
  4724. }
  4725. break;
  4726. case 'homepageOrdersabnzbd':
  4727. $class = 'yellow-bg';
  4728. $image = 'images/sabnzbd.png';
  4729. if(empty(SABNZBDURL)){
  4730. $class .= ' faded';
  4731. }
  4732. break;
  4733. case 'homepageOrderplexsearch':
  4734. case 'homepageOrderplexnowplaying':
  4735. case 'homepageOrderplexrecent':
  4736. case 'homepageOrderplexplaylist':
  4737. $class = 'palette-Amber-A700 bg gray';
  4738. $image = 'images/plex.png';
  4739. if(empty(PLEXURL)){
  4740. $class .= ' faded';
  4741. }
  4742. break;
  4743. case 'homepageOrderembynowplaying':
  4744. case 'homepageOrderembyrecent':
  4745. $class = 'palette-Green-A700 bg gray';
  4746. $image = 'images/emby.png';
  4747. if(empty(EMBYURL)){
  4748. $class .= ' faded';
  4749. }
  4750. break;
  4751. case 'homepageOrderombi':
  4752. $class = 'orange-bg';
  4753. $image = 'images/ombi.png';
  4754. if(empty(OMBIURL)){
  4755. $class .= ' faded';
  4756. }
  4757. break;
  4758. case 'homepageOrdercalendar':
  4759. $class = 'palette-Blue-400 bg gray';
  4760. $image = 'images/calendar.png';
  4761. if(SONARRURL == "" && RADARRURL == "" && HEADPHONESURL == "" && SICKRAGEURL == "" && COUCHURL == "" ){
  4762. $class .= ' faded';
  4763. }
  4764. break;
  4765. default:
  4766. $class = 'blue-bg';
  4767. $image = '';
  4768. break;
  4769. }
  4770. $homepageList .= '
  4771. <div class="col-md-3 sort-homepage"><div class="fc-event '.$class.'">
  4772. <span class="ordinal-position text-uppercase badge badge-gray" data-link="'.$key.'" style="float:left;width: 30px;">'.$val.'</span>
  4773. &nbsp; '.strtoupper(substr($key, 13)).'
  4774. <span class="remove-event"><img style="width: 22px;" src="'.$image.'"></span>
  4775. </div></div>';
  4776. $inputList .= '<input type="hidden" name="'.$key.'">';
  4777. }
  4778. $homepageList .= '</div>';
  4779. $inputList .= '</div>';
  4780. return $homepageList.$inputList;
  4781. }
  4782. function buildHomepage($group, $user){
  4783. $homepageOrder = homepageOrder();
  4784. $homepageBuilt = '';
  4785. foreach ($homepageOrder as $key => $value) {
  4786. $homepageBuilt .= buildHomepageItem($key, $group, $user);
  4787. }
  4788. return $homepageBuilt;
  4789. }
  4790. function realSize($bytes, $decimals = 2) {
  4791. $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
  4792. $factor = floor((strlen($bytes) - 1) / 3);
  4793. return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' '.@$size[$factor];
  4794. }
  4795. function buildHomepageItem($homepageItem, $group, $user){
  4796. $homepageItemBuilt = '';
  4797. switch ($homepageItem) {
  4798. case 'homepageOrderplexsearch':
  4799. if((qualifyUser(PLEXSEARCHAUTH) && PLEXSEARCH == "true" && qualifyUser(PLEXHOMEAUTH))) {
  4800. $homepageItemBuilt .= '
  4801. <div id="searchPlexRow" class="row">
  4802. <div class="col-lg-12">
  4803. <div class="content-box box-shadow big-box todo-list">
  4804. <form id="plexSearchForm" onsubmit="return false;" autocomplete="off">
  4805. <div class="">
  4806. <div class="input-group">
  4807. <div style="border-radius: 25px 0 0 25px; border:0" class="input-group-addon gray-bg"><i class="fa fa-search white"></i></div>
  4808. <input id="searchInput" type="text" style="border-radius: 0;" autocomplete="off" name="search-title" class="form-control input-group-addon gray-bg" placeholder="Media Search">
  4809. <div id="clearSearch" style="border-radius: 0 25px 25px 0;border:0; cursor: pointer;" class="input-group-addon gray-bg"><i class="fa fa-close white"></i></div>
  4810. <button style="display:none" id="plexSearchForm_submit" class="btn btn-primary waves"></button>
  4811. </div>
  4812. </div>
  4813. </form>
  4814. <div id="resultshere" class="table-responsive"></div>
  4815. </div>
  4816. </div>
  4817. </div>
  4818. ';
  4819. }
  4820. break;
  4821. case 'homepageOrdercustomhtml':
  4822. if (qualifyUser(HOMEPAGECUSTOMHTML1AUTH) && HOMEPAGECUSTOMHTML1) {
  4823. $homepageItemBuilt .= "<div>" . HOMEPAGECUSTOMHTML1 . "</div>";
  4824. }
  4825. break;
  4826. case 'homepageOrdernotice':
  4827. if (qualifyUser(HOMEPAGENOTICEAUTH) && HOMEPAGENOTICETITLE && HOMEPAGENOTICETYPE && HOMEPAGENOTICEMESSAGE && HOMEPAGENOTICELAYOUT) {
  4828. $homepageItemBuilt .= buildHomepageNotice(HOMEPAGENOTICELAYOUT, HOMEPAGENOTICETYPE, HOMEPAGENOTICETITLE, HOMEPAGENOTICEMESSAGE);
  4829. }
  4830. break;
  4831. case 'homepageOrderspeedtest':
  4832. if(SPEEDTEST == "true" && qualifyUser(SPEEDTESTAUTH)){
  4833. $homepageItemBuilt .= '
  4834. <style type="text/css">
  4835. .flash {
  4836. animation: flash 0.6s linear infinite;
  4837. }
  4838. @keyframes flash {
  4839. 0% { opacity: 0.6; }
  4840. 50% { opacity: 1; }
  4841. }
  4842. </style>
  4843. <script type="text/javascript">
  4844. var w = null
  4845. function runTest() {
  4846. document.getElementById("startBtn").style.display = "none"
  4847. document.getElementById("testArea").style.display = ""
  4848. document.getElementById("abortBtn").style.display = ""
  4849. w = new Worker("bower_components/speed/speedtest_worker.js")
  4850. var interval = setInterval(function () { w.postMessage("status") }, 100)
  4851. w.onmessage = function (event) {
  4852. var data = event.data.split(";")
  4853. var status = Number(data[0])
  4854. var dl = document.getElementById("download")
  4855. var ul = document.getElementById("upload")
  4856. var ping = document.getElementById("ping")
  4857. var jitter = document.getElementById("jitter")
  4858. dl.className = status === 1 ? "w-name flash" : "w-name"
  4859. ping.className = status === 2 ? "w-name flash" : "w-name"
  4860. jitter.className = ul.className = status === 3 ? "w-name flash" : "w-name"
  4861. if (status >= 4) {
  4862. clearInterval(interval)
  4863. document.getElementById("abortBtn").style.display = "none"
  4864. document.getElementById("startBtn").style.display = ""
  4865. w = null
  4866. }
  4867. if (status === 5) {
  4868. document.getElementById("testArea").style.display = "none"
  4869. }
  4870. dl.textContent = data[1] + " Mbit/s";
  4871. $("#downloadpercent").attr("style", "width: " + data[1] + "%;");
  4872. $("#uploadpercent").attr("style", "width: " + data[2] + "%;");
  4873. $("#pingpercent").attr("style", "width: " + data[3] + "%;");
  4874. $("#jitterpercent").attr("style", "width: " + data[5] + "%;");
  4875. ul.textContent = data[2] + " Mbit/s";
  4876. ping.textContent = data[3] + " ms";
  4877. jitter.textContent = data[5] + " ms";
  4878. }
  4879. w.postMessage(\'start {"telemetry_level":"basic"}\')
  4880. //w.postMessage("start")
  4881. }
  4882. function abortTest() {
  4883. if (w) w.postMessage("abort")
  4884. }
  4885. </script>
  4886. <div class="row" id="testArea" style="display:none">
  4887. <div class="test col-sm-3 col-lg-3">
  4888. <div class="content-box ultra-widget green-bg" data-counter="">
  4889. <div id="downloadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4890. <div class="w-content">
  4891. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-download"></i></div>
  4892. <div class="w-descr left pull-left text-center">
  4893. <span class="testName text-uppercase w-name">Download</span>
  4894. <br>
  4895. <span class="w-name counter" id="download" ></span>
  4896. </div>
  4897. </div>
  4898. </div>
  4899. </div>
  4900. <div class="test col-sm-3 col-lg-3">
  4901. <div class="content-box ultra-widget red-bg" data-counter="">
  4902. <div id="uploadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4903. <div class="w-content">
  4904. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-upload"></i></div>
  4905. <div class="w-descr left pull-left text-center">
  4906. <span class="testName text-uppercase w-name">Upload</span>
  4907. <br>
  4908. <span class="w-name counter" id="upload" ></span>
  4909. </div>
  4910. </div>
  4911. </div>
  4912. </div>
  4913. <div class="test col-sm-3 col-lg-3">
  4914. <div class="content-box ultra-widget yellow-bg" data-counter="">
  4915. <div id="pingpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4916. <div class="w-content">
  4917. <div class="w-icon right pull-right"><i class="mdi mdi-timer"></i></div>
  4918. <div class="w-descr left pull-left text-center">
  4919. <span class="testName text-uppercase w-name">Latency</span>
  4920. <br>
  4921. <span class="w-name counter" id="ping" ></span>
  4922. </div>
  4923. </div>
  4924. </div>
  4925. </div>
  4926. <div class="test col-sm-3 col-lg-3">
  4927. <div class="content-box ultra-widget blue-bg" data-counter="">
  4928. <div id="jitterpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4929. <div class="w-content">
  4930. <div class="w-icon right pull-right"><i class="mdi mdi-pulse"></i></div>
  4931. <div class="w-descr left pull-left text-center">
  4932. <span class="testName text-uppercase w-name">Jitter</span>
  4933. <br>
  4934. <span class="w-name counter" id="jitter" ></span>
  4935. </div>
  4936. </div>
  4937. </div>
  4938. </div>
  4939. <br/>
  4940. </div>
  4941. <div id="abortBtn" class="row" style="display: none" onclick="javascript:abortTest()">
  4942. <div class="col-lg-12">
  4943. <div class="content-box red-bg" style="cursor: pointer;">
  4944. <h1 style="margin: 10px" class="text-uppercase text-center">Abort Speed Test</h1>
  4945. <div class="clearfix"></div>
  4946. </div>
  4947. </div>
  4948. </div>
  4949. <div id="startBtn" class="row" onclick="javascript:runTest()">
  4950. <div class="col-lg-12">
  4951. <div class="content-box green-bg" style="cursor: pointer;">
  4952. <h1 style="margin: 10px" class="text-uppercase text-center">Run Speed Test</h1>
  4953. <div class="clearfix"></div>
  4954. </div>
  4955. </div>
  4956. </div>
  4957. ';
  4958. }
  4959. break;
  4960. case 'homepageOrdernzbget':
  4961. if(NZBGETURL != "" && qualifyUser(NZBGETHOMEAUTH)){
  4962. $homepageItemBuilt .= buildDownloader('nzbget');
  4963. }
  4964. break;
  4965. case 'homepageOrdersabnzbd':
  4966. if(SABNZBDURL != "" && qualifyUser(SABNZBDHOMEAUTH)) {
  4967. $homepageItemBuilt .= buildDownloader('sabnzbd');
  4968. }
  4969. break;
  4970. case 'homepageOrderplexnowplaying':
  4971. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4972. if(qualifyUser(PLEXPLAYINGNOWAUTH) && PLEXPLAYINGNOW == "true"){
  4973. $homepageItemBuilt .= '<div id="plexRowNowPlaying" class="row">';
  4974. $homepageItemBuilt .= getPlexStreams(12, PLEXSHOWNAMES, $group);
  4975. $homepageItemBuilt .= '</div>';
  4976. }
  4977. }
  4978. break;
  4979. case 'homepageOrderplexrecent':
  4980. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4981. if(qualifyUser(PLEXRECENTMOVIEAUTH) && PLEXRECENTMOVIE == "true" || qualifyUser(PLEXRECENTTVAUTH) && PLEXRECENTTV == "true" || qualifyUser(PLEXRECENTMUSICAUTH) && PLEXRECENTMUSIC == "true"){
  4982. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  4983. $homepageItemBuilt .= '<div id="plexRow" class="row"><div class="col-lg-12">';
  4984. $homepageItemBuilt .= getPlexRecent($plexArray);
  4985. $homepageItemBuilt .= '</div></div>';
  4986. }
  4987. }
  4988. break;
  4989. case 'homepageOrderplexplaylist':
  4990. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4991. if(qualifyUser(PLEXPLAYLISTSAUTH) && PLEXPLAYLISTS == "true"){
  4992. $homepageItemBuilt .= '<div id="plexPlaylists" class="row"><div class="col-lg-12">';
  4993. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  4994. $homepageItemBuilt .= getPlexPlaylists($plexArray);
  4995. $homepageItemBuilt .= '</div> </div>';
  4996. }
  4997. }
  4998. break;
  4999. case 'homepageOrderembynowplaying':
  5000. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  5001. if(qualifyUser(EMBYPLAYINGNOWAUTH) && EMBYPLAYINGNOW == "true"){
  5002. $homepageItemBuilt .= '<div id="embyRowNowPlaying" class="row">';
  5003. $homepageItemBuilt .= getEmbyStreams(12, EMBYSHOWNAMES, $group);
  5004. $homepageItemBuilt .= '</div>';
  5005. }
  5006. }
  5007. break;
  5008. case 'homepageOrderembyrecent':
  5009. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  5010. if(qualifyUser(EMBYRECENTMOVIEAUTH) && EMBYRECENTMOVIE == "true" || qualifyUser(EMBYRECENTTVAUTH) && EMBYRECENTTV == "true" || qualifyUser(EMBYRECENTMUSICAUTH) && EMBYRECENTMUSIC == "true"){
  5011. $embyArray = array("Movie" => EMBYRECENTMOVIE, "Episode" => EMBYRECENTTV, "MusicAlbum" => EMBYRECENTMUSIC, "Series" => EMBYRECENTTV);
  5012. $homepageItemBuilt .= '<div id="embyRow" class="row"><div class="col-lg-12">';
  5013. $homepageItemBuilt .= getEmbyRecent($embyArray);
  5014. $homepageItemBuilt .= '</div></div>';
  5015. }
  5016. }
  5017. break;
  5018. case 'homepageOrderombi':
  5019. if (qualifyUser(OMBIAUTH) && OMBIURL) {
  5020. $homepageItemBuilt .= '<div id="ombiRequests" class="row"><div class="col-lg-12">';
  5021. $homepageItemBuilt .= buildOmbiList($group, $user);
  5022. $homepageItemBuilt .= '</div></div>';
  5023. }
  5024. break;
  5025. case 'homepageOrdercalendar':
  5026. if ((SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)) || (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)) || (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)) || (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)) || (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH))) {
  5027. $calendarItems = '';
  5028. if(RADARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="film" href="javascript:void(0)">Movies</a></li>'; }
  5029. if(SONARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="tv" href="javascript:void(0)">TV Shows</a></li>'; }
  5030. if(HEADPHONESURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="music" href="javascript:void(0)">Music</a></li>'; }
  5031. $homepageItemBuilt .= '
  5032. <div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">
  5033. <div class="col-lg-12 content-form form-inline">
  5034. <div class="form-group pull-right">
  5035. <span class="swal-legend label label-primary well-sm">Legend</span>&nbsp;
  5036. <div class="btn-group" role="group">
  5037. <button id="calendarSelected" style="margin-right: 0px;" type="button" class="btn waves btn-default btn-sm dropdown-toggle waves-effect waves-float" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">View All&nbsp;<span class="caret"></span></button>
  5038. <ul style="right:0; left: auto" class="dropdown-menu">
  5039. <li><a class="calendarOption" calendarOption="all" href="javascript:void(0)">View All</a></li>
  5040. '.$calendarItems.'
  5041. </ul>
  5042. </div>
  5043. </div>
  5044. </div>
  5045. </div>
  5046. <div id="calendarRow" class="row">
  5047. <div class="col-lg-12">
  5048. <div id="calendar" class="fc-calendar box-shadow fc fc-ltr fc-unthemed"></div>
  5049. </div>
  5050. </div>
  5051. ';
  5052. }
  5053. break;
  5054. default:
  5055. # code...
  5056. break;
  5057. }
  5058. return $homepageItemBuilt;
  5059. }
  5060. function buildDownloader($name){
  5061. return '
  5062. <div id="downloadClientRow" class="row">
  5063. <div class="col-xs-12 col-md-12">
  5064. <div class="content-box">
  5065. <div class="tabbable panel with-nav-tabs panel-default">
  5066. <div class="panel-heading">
  5067. <div class="content-tools i-block pull-right">
  5068. <a id="getDownloader" class="repeat-btn">
  5069. <i class="fa fa-repeat"></i>
  5070. </a>
  5071. </div>
  5072. <h3 class="pull-left">'.strtoupper($name).'</h3>
  5073. <ul class="nav nav-tabs pull-right">
  5074. <li class="active"><a href="#downloadQueue-'.$name.'" data-toggle="tab" aria-expanded="true">'.translate("QUEUE").'</a></li>
  5075. <li class=""><a href="#downloadHistory-'.$name.'" data-toggle="tab" aria-expanded="false">'.translate("HISTORY").'</a></li>
  5076. </ul>
  5077. <div class="clearfix"></div>
  5078. </div>
  5079. <div class="panel-body">
  5080. <div class="tab-content">
  5081. <div class="tab-pane fade active in" id="downloadQueue-'.$name.'">
  5082. <div class="table-responsive" style="max-height: 300px">
  5083. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  5084. <thead>
  5085. <tr>
  5086. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  5087. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  5088. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  5089. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  5090. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  5091. </tr>
  5092. </thead>
  5093. <tbody class="dl-queue '.$name.'"></tbody>
  5094. </table>
  5095. </div>
  5096. </div>
  5097. <div class="tab-pane fade" id="downloadHistory-'.$name.'">
  5098. <div class="table-responsive" style="max-height: 300px">
  5099. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  5100. <thead>
  5101. <tr>
  5102. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  5103. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  5104. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  5105. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  5106. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  5107. </tr>
  5108. </thead>
  5109. <tbody class="dl-history '.$name.'"></tbody>
  5110. </table>
  5111. </div>
  5112. </div>
  5113. </div>
  5114. </div>
  5115. </div>
  5116. </div>
  5117. </div>
  5118. </div>';
  5119. }
  5120. class Mobile_Detect
  5121. {
  5122. /**
  5123. * Mobile detection type.
  5124. *
  5125. * @deprecated since version 2.6.9
  5126. */
  5127. const DETECTION_TYPE_MOBILE = 'mobile';
  5128. /**
  5129. * Extended detection type.
  5130. *
  5131. * @deprecated since version 2.6.9
  5132. */
  5133. const DETECTION_TYPE_EXTENDED = 'extended';
  5134. /**
  5135. * A frequently used regular expression to extract version #s.
  5136. *
  5137. * @deprecated since version 2.6.9
  5138. */
  5139. const VER = '([\w._\+]+)';
  5140. /**
  5141. * Top-level device.
  5142. */
  5143. const MOBILE_GRADE_A = 'A';
  5144. /**
  5145. * Mid-level device.
  5146. */
  5147. const MOBILE_GRADE_B = 'B';
  5148. /**
  5149. * Low-level device.
  5150. */
  5151. const MOBILE_GRADE_C = 'C';
  5152. /**
  5153. * Stores the version number of the current release.
  5154. */
  5155. const VERSION = '2.8.26';
  5156. /**
  5157. * A type for the version() method indicating a string return value.
  5158. */
  5159. const VERSION_TYPE_STRING = 'text';
  5160. /**
  5161. * A type for the version() method indicating a float return value.
  5162. */
  5163. const VERSION_TYPE_FLOAT = 'float';
  5164. /**
  5165. * A cache for resolved matches
  5166. * @var array
  5167. */
  5168. protected $cache = array();
  5169. /**
  5170. * The User-Agent HTTP header is stored in here.
  5171. * @var string
  5172. */
  5173. protected $userAgent = null;
  5174. /**
  5175. * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
  5176. * @var array
  5177. */
  5178. protected $httpHeaders = array();
  5179. /**
  5180. * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
  5181. * @var array
  5182. */
  5183. protected $cloudfrontHeaders = array();
  5184. /**
  5185. * The matching Regex.
  5186. * This is good for debug.
  5187. * @var string
  5188. */
  5189. protected $matchingRegex = null;
  5190. /**
  5191. * The matches extracted from the regex expression.
  5192. * This is good for debug.
  5193. * @var string
  5194. */
  5195. protected $matchesArray = null;
  5196. /**
  5197. * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
  5198. *
  5199. * @deprecated since version 2.6.9
  5200. *
  5201. * @var string
  5202. */
  5203. protected $detectionType = self::DETECTION_TYPE_MOBILE;
  5204. /**
  5205. * HTTP headers that trigger the 'isMobile' detection
  5206. * to be true.
  5207. *
  5208. * @var array
  5209. */
  5210. protected static $mobileHeaders = array(
  5211. 'HTTP_ACCEPT' => array('matches' => array(
  5212. // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
  5213. 'application/x-obml2d',
  5214. // BlackBerry devices.
  5215. 'application/vnd.rim.html',
  5216. 'text/vnd.wap.wml',
  5217. 'application/vnd.wap.xhtml+xml'
  5218. )),
  5219. 'HTTP_X_WAP_PROFILE' => null,
  5220. 'HTTP_X_WAP_CLIENTID' => null,
  5221. 'HTTP_WAP_CONNECTION' => null,
  5222. 'HTTP_PROFILE' => null,
  5223. // Reported by Opera on Nokia devices (eg. C3).
  5224. 'HTTP_X_OPERAMINI_PHONE_UA' => null,
  5225. 'HTTP_X_NOKIA_GATEWAY_ID' => null,
  5226. 'HTTP_X_ORANGE_ID' => null,
  5227. 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
  5228. 'HTTP_X_HUAWEI_USERID' => null,
  5229. // Reported by Windows Smartphones.
  5230. 'HTTP_UA_OS' => null,
  5231. // Reported by Verizon, Vodafone proxy system.
  5232. 'HTTP_X_MOBILE_GATEWAY' => null,
  5233. // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
  5234. 'HTTP_X_ATT_DEVICEID' => null,
  5235. // Seen this on a HTC.
  5236. 'HTTP_UA_CPU' => array('matches' => array('ARM')),
  5237. );
  5238. /**
  5239. * List of mobile devices (phones).
  5240. *
  5241. * @var array
  5242. */
  5243. protected static $phoneDevices = array(
  5244. 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
  5245. 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
  5246. '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',
  5247. 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
  5248. // @todo: Is 'Dell Streak' a tablet or a phone? ;)
  5249. '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',
  5250. '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',
  5251. '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',
  5252. '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)',
  5253. 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
  5254. 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
  5255. 'NokiaLumia' => 'Lumia [0-9]{3,4}',
  5256. // http://www.micromaxinfo.com/mobiles/smartphones
  5257. // Added because the codes might conflict with Acer Tablets.
  5258. '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',
  5259. // @todo Complete the regex.
  5260. 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
  5261. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
  5262. // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
  5263. // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
  5264. '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',
  5265. // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
  5266. 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
  5267. // http://fr.wikomobile.com
  5268. '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',
  5269. 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
  5270. // Added simvalley mobile just for fun. They have some interesting devices.
  5271. // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
  5272. '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',
  5273. // Wolfgang - a brand that is sold by Aldi supermarkets.
  5274. // http://www.wolfgangmobile.com/
  5275. 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
  5276. 'Alcatel' => 'Alcatel',
  5277. 'Nintendo' => 'Nintendo 3DS',
  5278. // http://en.wikipedia.org/wiki/Amoi
  5279. 'Amoi' => 'Amoi',
  5280. // http://en.wikipedia.org/wiki/INQ
  5281. 'INQ' => 'INQ',
  5282. // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
  5283. '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',
  5284. );
  5285. /**
  5286. * List of tablet devices.
  5287. *
  5288. * @var array
  5289. */
  5290. protected static $tabletDevices = array(
  5291. // @todo: check for mobile friendly emails topic.
  5292. 'iPad' => 'iPad|iPad.*Mobile',
  5293. // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
  5294. // @see #442
  5295. 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
  5296. '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.
  5297. // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
  5298. '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)',
  5299. // Only the Surface tablets with Windows RT are considered mobile.
  5300. // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
  5301. 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
  5302. // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
  5303. 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
  5304. // Watch out for PadFone, see #132.
  5305. // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
  5306. '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',
  5307. 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
  5308. 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
  5309. 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
  5310. 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
  5311. // http://www.acer.ro/ac/ro/RO/content/drivers
  5312. // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
  5313. // http://us.acer.com/ac/en/US/content/group/tablets
  5314. // http://www.acer.de/ac/de/DE/content/models/tablets/
  5315. // Can conflict with Micromax and Motorola phones codes.
  5316. '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',
  5317. // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
  5318. // http://us.toshiba.com/tablets/tablet-finder
  5319. // http://www.toshiba.co.jp/regza/tablet/
  5320. 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
  5321. // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
  5322. // http://www.lg.com/us/tablets
  5323. 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
  5324. 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
  5325. // Prestigio Tablets http://www.prestigio.com/support
  5326. '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',
  5327. // http://support.lenovo.com/en_GB/downloads/default.page?#
  5328. '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|)',
  5329. // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
  5330. 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
  5331. // http://www.yarvik.com/en/matrix/tablets/
  5332. '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',
  5333. 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
  5334. 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
  5335. // http://www.intenso.de/kategorie_en.php?kategorie=33
  5336. // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
  5337. 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
  5338. // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
  5339. 'IRUTablet' => 'M702pro',
  5340. 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
  5341. // http://www.e-boda.ro/tablete-pc.html
  5342. 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
  5343. // http://www.allview.ro/produse/droseries/lista-tablete-pc/
  5344. 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
  5345. // http://wiki.archosfans.com/index.php?title=Main_Page
  5346. // @note Rewrite the regex format after we add more UAs.
  5347. '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',
  5348. // http://www.ainol.com/plugin.php?identifier=ainol&module=product
  5349. 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
  5350. 'NokiaLumiaTablet' => 'Lumia 2520',
  5351. // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
  5352. // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
  5353. // http://www.sony.jp/support/tablet/
  5354. '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',
  5355. // 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
  5356. 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
  5357. // db + http://www.cube-tablet.com/buy-products.html
  5358. 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
  5359. // http://www.cobyusa.com/?p=pcat&pcat_id=3001
  5360. 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
  5361. // http://www.match.net.cn/products.asp
  5362. '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',
  5363. // http://www.msi.com/support
  5364. // @todo Research the Windows Tablets.
  5365. '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',
  5366. // @todo http://www.kyoceramobile.com/support/drivers/
  5367. // 'KyoceraTablet' => null,
  5368. // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
  5369. // 'IntextTablet' => null,
  5370. // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
  5371. // http://www.imp3.net/14/show.php?itemid=20454
  5372. 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
  5373. // http://www.rock-chips.com/index.php?do=prod&pid=2
  5374. 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
  5375. // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
  5376. 'FlyTablet' => 'IQ310|Fly Vision',
  5377. // http://www.bqreaders.com/gb/tablets-prices-sale.html
  5378. 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
  5379. // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
  5380. // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
  5381. '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',
  5382. // Nec or Medias Tab
  5383. 'NecTablet' => '\bN-06D|\bN-08D',
  5384. // Pantech Tablets: http://www.pantechusa.com/phones/
  5385. 'PantechTablet' => 'Pantech.*P4100',
  5386. // Broncho Tablets: http://www.broncho.cn/ (hard to find)
  5387. 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
  5388. // http://versusuk.com/support.html
  5389. 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
  5390. // http://www.zync.in/index.php/our-products/tablet-phablets
  5391. 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
  5392. // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
  5393. 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
  5394. // https://www.nabitablet.com/
  5395. 'NabiTablet' => 'Android.*\bNabi',
  5396. 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
  5397. // French Danew Tablets http://www.danew.com/produits-tablette.php
  5398. 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
  5399. // Texet Tablets and Readers http://www.texet.ru/tablet/
  5400. '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',
  5401. // Avoid detecting 'PLAYSTATION 3' as mobile.
  5402. 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
  5403. // http://www.trekstor.de/surftabs.html
  5404. 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
  5405. // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
  5406. 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
  5407. // http://www.advandigital.com/index.php?link=content-product&jns=JP001
  5408. // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
  5409. '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 ',
  5410. // http://www.danytech.com/category/tablet-pc
  5411. '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',
  5412. // http://www.galapad.net/product.html
  5413. 'GalapadTablet' => 'Android.*\bG1\b',
  5414. // http://www.micromaxinfo.com/tablet/funbook
  5415. 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
  5416. // http://www.karbonnmobiles.com/products_tablet.php
  5417. 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
  5418. // http://www.myallfine.com/Products.asp
  5419. 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
  5420. // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
  5421. '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',
  5422. // http://www.yonesnav.com/products/products.php
  5423. 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
  5424. // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
  5425. // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
  5426. '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',
  5427. // http://www.gloryunion.cn/products.asp
  5428. // http://www.allwinnertech.com/en/apply/mobile.html
  5429. // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
  5430. // @todo: Softwiner tablets?
  5431. // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
  5432. '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
  5433. // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
  5434. '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',
  5435. // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
  5436. // @todo: add more tests.
  5437. 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
  5438. // http://hclmetablet.com/India/index.php
  5439. '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',
  5440. // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
  5441. 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
  5442. // http://www.visture.com/index.asp
  5443. 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
  5444. // http://www.mijncresta.nl/tablet
  5445. 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
  5446. // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
  5447. 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
  5448. // Concorde tab
  5449. 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
  5450. // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
  5451. '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',
  5452. // Modecom Tablets - http://www.modecom.eu/tablets/portal/
  5453. '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',
  5454. // Vonino Tablets - http://www.vonino.eu/tablets
  5455. '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',
  5456. // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
  5457. 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
  5458. // Storex Tablets - http://storex.fr/espace_client/support.html
  5459. // @note: no need to add all the tablet codes since they are guided by the first regex.
  5460. 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
  5461. // Generic Vodafone tablets.
  5462. 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
  5463. // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
  5464. // Aka: http://www.essentielb.fr/
  5465. 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
  5466. // Ross & Moor - http://ross-moor.ru/
  5467. 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
  5468. // i-mobile http://product.i-mobilephone.com/Mobile_Device
  5469. 'iMobileTablet' => 'i-mobile i-note',
  5470. // http://www.tolino.de/de/vergleichen/
  5471. 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
  5472. // AudioSonic - a Kmart brand
  5473. // 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
  5474. 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
  5475. // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
  5476. // @todo: add them gradually to avoid conflicts.
  5477. 'AMPETablet' => 'Android.* A78 ',
  5478. // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
  5479. 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
  5480. // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
  5481. 'TecnoTablet' => 'TECNO P9',
  5482. // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
  5483. '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',
  5484. // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
  5485. '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)',
  5486. // http://www.intracon.eu/tablet
  5487. 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
  5488. // http://www.xoro.de/produkte/
  5489. // @note: Might be the same brand with 'Simply tablets'
  5490. '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',
  5491. // http://www1.viewsonic.com/products/computing/tablets/
  5492. 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
  5493. // http://www.odys.de/web/internet-tablet_en.html
  5494. 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
  5495. // http://www.captiva-power.de/products.html#tablets-en
  5496. 'CaptivaTablet' => 'CAPTIVA PAD',
  5497. // IconBIT - http://www.iconbit.com/products/tablets/
  5498. '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',
  5499. // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
  5500. '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',
  5501. // Onda - http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
  5502. '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]+',
  5503. 'JaytechTablet' => 'TPC-PA762',
  5504. 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
  5505. // http://www.digma.ru/support/download/
  5506. // @todo: Ebooks also (if requested)
  5507. 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
  5508. // http://www.evolioshop.com/ro/tablete-pc.html
  5509. // http://www.evolio.ro/support/downloads_static.html?cat=2
  5510. // @todo: Research some more
  5511. 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
  5512. // @todo http://www.lavamobiles.com/tablets-data-cards
  5513. 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
  5514. // http://www.breezetablet.com/
  5515. 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
  5516. // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
  5517. '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',
  5518. // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
  5519. 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
  5520. // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
  5521. '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',
  5522. // http://www.mi.com/en
  5523. 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
  5524. // http://www.nbru.cn/index.html
  5525. 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
  5526. // http://navroad.com/products/produkty/tablety/
  5527. // http://navroad.com/products/produkty/tablety/
  5528. 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
  5529. // http://leader-online.com/new_site/product-category/tablets/
  5530. // http://www.leader-online.net.au/List/Tablet
  5531. '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',
  5532. // http://www.datawind.com/ubislate/
  5533. 'UbislateTablet' => 'UbiSlate[\s]?7C',
  5534. // http://www.pocketbook-int.com/ru/support
  5535. 'PocketBookTablet' => 'Pocketbook',
  5536. // http://www.kocaso.com/product_tablet.html
  5537. 'KocasoTablet' => '\b(TB-1207)\b',
  5538. // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
  5539. 'HisenseTablet' => '\b(F5281|E2371)\b',
  5540. // http://www.tesco.com/direct/hudl/
  5541. 'Hudl' => 'Hudl HT7S3|Hudl 2',
  5542. // http://www.telstra.com.au/home-phone/thub-2/
  5543. 'TelstraTablet' => 'T-Hub2',
  5544. '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'
  5545. );
  5546. /**
  5547. * List of mobile Operating Systems.
  5548. *
  5549. * @var array
  5550. */
  5551. protected static $operatingSystems = array(
  5552. 'AndroidOS' => 'Android',
  5553. 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
  5554. 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
  5555. 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
  5556. // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
  5557. 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
  5558. // @reference: http://en.wikipedia.org/wiki/Windows_Phone
  5559. // http://wifeng.cn/?r=blog&a=view&id=106
  5560. // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
  5561. // http://msdn.microsoft.com/library/ms537503.aspx
  5562. // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
  5563. 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
  5564. 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
  5565. // http://en.wikipedia.org/wiki/MeeGo
  5566. // @todo: research MeeGo in UAs
  5567. 'MeeGoOS' => 'MeeGo',
  5568. // http://en.wikipedia.org/wiki/Maemo
  5569. // @todo: research Maemo in UAs
  5570. 'MaemoOS' => 'Maemo',
  5571. 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
  5572. 'webOS' => 'webOS|hpwOS',
  5573. 'badaOS' => '\bBada\b',
  5574. 'BREWOS' => 'BREW',
  5575. );
  5576. /**
  5577. * List of mobile User Agents.
  5578. *
  5579. * IMPORTANT: This is a list of only mobile browsers.
  5580. * Mobile Detect 2.x supports only mobile browsers,
  5581. * it was never designed to detect all browsers.
  5582. * The change will come in 2017 in the 3.x release for PHP7.
  5583. *
  5584. * @var array
  5585. */
  5586. protected static $browsers = array(
  5587. //'Vivaldi' => 'Vivaldi',
  5588. // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
  5589. 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
  5590. 'Dolfin' => '\bDolfin\b',
  5591. 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
  5592. 'Skyfire' => 'Skyfire',
  5593. 'Edge' => 'Mobile Safari/[.0-9]* Edge',
  5594. 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
  5595. 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
  5596. 'Bolt' => 'bolt',
  5597. 'TeaShark' => 'teashark',
  5598. 'Blazer' => 'Blazer',
  5599. // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
  5600. 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
  5601. // http://en.wikipedia.org/wiki/Midori_(web_browser)
  5602. //'Midori' => 'midori',
  5603. //'Tizen' => 'Tizen',
  5604. 'UCBrowser' => 'UC.*Browser|UCWEB',
  5605. 'baiduboxapp' => 'baiduboxapp',
  5606. 'baidubrowser' => 'baidubrowser',
  5607. // https://github.com/serbanghita/Mobile-Detect/issues/7
  5608. 'DiigoBrowser' => 'DiigoBrowser',
  5609. // http://www.puffinbrowser.com/index.php
  5610. 'Puffin' => 'Puffin',
  5611. // http://mercury-browser.com/index.html
  5612. 'Mercury' => '\bMercury\b',
  5613. // http://en.wikipedia.org/wiki/Obigo_Browser
  5614. 'ObigoBrowser' => 'Obigo',
  5615. // http://en.wikipedia.org/wiki/NetFront
  5616. 'NetFront' => 'NF-Browser',
  5617. // @reference: http://en.wikipedia.org/wiki/Minimo
  5618. // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
  5619. 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
  5620. // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
  5621. 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
  5622. );
  5623. /**
  5624. * Utilities.
  5625. *
  5626. * @var array
  5627. */
  5628. protected static $utilities = array(
  5629. // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
  5630. // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
  5631. // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
  5632. // https://developers.facebook.com/docs/sharing/best-practices
  5633. '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',
  5634. 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
  5635. 'DesktopMode' => 'WPDesktop',
  5636. 'TV' => 'SonyDTV|HbbTV', // experimental
  5637. 'WebKit' => '(webkit)[ /]([\w.]+)',
  5638. // @todo: Include JXD consoles.
  5639. 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
  5640. 'Watch' => 'SM-V700',
  5641. );
  5642. /**
  5643. * All possible HTTP headers that represent the
  5644. * User-Agent string.
  5645. *
  5646. * @var array
  5647. */
  5648. protected static $uaHttpHeaders = array(
  5649. // The default User-Agent string.
  5650. 'HTTP_USER_AGENT',
  5651. // Header can occur on devices using Opera Mini.
  5652. 'HTTP_X_OPERAMINI_PHONE_UA',
  5653. // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
  5654. 'HTTP_X_DEVICE_USER_AGENT',
  5655. 'HTTP_X_ORIGINAL_USER_AGENT',
  5656. 'HTTP_X_SKYFIRE_PHONE',
  5657. 'HTTP_X_BOLT_PHONE_UA',
  5658. 'HTTP_DEVICE_STOCK_UA',
  5659. 'HTTP_X_UCBROWSER_DEVICE_UA'
  5660. );
  5661. /**
  5662. * The individual segments that could exist in a User-Agent string. VER refers to the regular
  5663. * expression defined in the constant self::VER.
  5664. *
  5665. * @var array
  5666. */
  5667. protected static $properties = array(
  5668. // Build
  5669. 'Mobile' => 'Mobile/[VER]',
  5670. 'Build' => 'Build/[VER]',
  5671. 'Version' => 'Version/[VER]',
  5672. 'VendorID' => 'VendorID/[VER]',
  5673. // Devices
  5674. 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
  5675. 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
  5676. 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
  5677. //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
  5678. 'Kindle' => 'Kindle/[VER]',
  5679. // Browser
  5680. 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
  5681. 'Coast' => array('Coast/[VER]'),
  5682. 'Dolfin' => 'Dolfin/[VER]',
  5683. // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
  5684. 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
  5685. 'Fennec' => 'Fennec/[VER]',
  5686. // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  5687. // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
  5688. 'Edge' => 'Edge/[VER]',
  5689. 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
  5690. // http://en.wikipedia.org/wiki/NetFront
  5691. 'NetFront' => 'NetFront/[VER]',
  5692. 'NokiaBrowser' => 'NokiaBrowser/[VER]',
  5693. 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
  5694. 'Opera Mini' => 'Opera Mini/[VER]',
  5695. 'Opera Mobi' => 'Version/[VER]',
  5696. 'UC Browser' => 'UC Browser[VER]',
  5697. 'MQQBrowser' => 'MQQBrowser/[VER]',
  5698. 'MicroMessenger' => 'MicroMessenger/[VER]',
  5699. 'baiduboxapp' => 'baiduboxapp/[VER]',
  5700. 'baidubrowser' => 'baidubrowser/[VER]',
  5701. 'SamsungBrowser' => 'SamsungBrowser/[VER]',
  5702. 'Iron' => 'Iron/[VER]',
  5703. // @note: Safari 7534.48.3 is actually Version 5.1.
  5704. // @note: On BlackBerry the Version is overwriten by the OS.
  5705. 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
  5706. 'Skyfire' => 'Skyfire/[VER]',
  5707. 'Tizen' => 'Tizen/[VER]',
  5708. 'Webkit' => 'webkit[ /][VER]',
  5709. 'PaleMoon' => 'PaleMoon/[VER]',
  5710. // Engine
  5711. 'Gecko' => 'Gecko/[VER]',
  5712. 'Trident' => 'Trident/[VER]',
  5713. 'Presto' => 'Presto/[VER]',
  5714. 'Goanna' => 'Goanna/[VER]',
  5715. // OS
  5716. 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
  5717. 'Android' => 'Android [VER]',
  5718. 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
  5719. 'BREW' => 'BREW [VER]',
  5720. 'Java' => 'Java/[VER]',
  5721. // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
  5722. // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
  5723. 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
  5724. 'Windows Phone' => 'Windows Phone [VER]',
  5725. 'Windows CE' => 'Windows CE/[VER]',
  5726. // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
  5727. 'Windows NT' => 'Windows NT [VER]',
  5728. 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
  5729. 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
  5730. );
  5731. /**
  5732. * Construct an instance of this class.
  5733. *
  5734. * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
  5735. * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
  5736. * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
  5737. * from the $headers array instead.
  5738. */
  5739. public function __construct(
  5740. array $headers = null,
  5741. $userAgent = null
  5742. ) {
  5743. $this->setHttpHeaders($headers);
  5744. $this->setUserAgent($userAgent);
  5745. }
  5746. /**
  5747. * Get the current script version.
  5748. * This is useful for the demo.php file,
  5749. * so people can check on what version they are testing
  5750. * for mobile devices.
  5751. *
  5752. * @return string The version number in semantic version format.
  5753. */
  5754. public static function getScriptVersion()
  5755. {
  5756. return self::VERSION;
  5757. }
  5758. /**
  5759. * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
  5760. *
  5761. * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
  5762. * the headers. The default null is left for backwards compatibility.
  5763. */
  5764. public function setHttpHeaders($httpHeaders = null)
  5765. {
  5766. // use global _SERVER if $httpHeaders aren't defined
  5767. if (!is_array($httpHeaders) || !count($httpHeaders)) {
  5768. $httpHeaders = $_SERVER;
  5769. }
  5770. // clear existing headers
  5771. $this->httpHeaders = array();
  5772. // Only save HTTP headers. In PHP land, that means only _SERVER vars that
  5773. // start with HTTP_.
  5774. foreach ($httpHeaders as $key => $value) {
  5775. if (substr($key, 0, 5) === 'HTTP_') {
  5776. $this->httpHeaders[$key] = $value;
  5777. }
  5778. }
  5779. // In case we're dealing with CloudFront, we need to know.
  5780. $this->setCfHeaders($httpHeaders);
  5781. }
  5782. /**
  5783. * Retrieves the HTTP headers.
  5784. *
  5785. * @return array
  5786. */
  5787. public function getHttpHeaders()
  5788. {
  5789. return $this->httpHeaders;
  5790. }
  5791. /**
  5792. * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
  5793. * Simply null is returned.
  5794. *
  5795. * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
  5796. * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
  5797. * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
  5798. *
  5799. * @return string|null The value of the header.
  5800. */
  5801. public function getHttpHeader($header)
  5802. {
  5803. // are we using PHP-flavored headers?
  5804. if (strpos($header, '_') === false) {
  5805. $header = str_replace('-', '_', $header);
  5806. $header = strtoupper($header);
  5807. }
  5808. // test the alternate, too
  5809. $altHeader = 'HTTP_' . $header;
  5810. //Test both the regular and the HTTP_ prefix
  5811. if (isset($this->httpHeaders[$header])) {
  5812. return $this->httpHeaders[$header];
  5813. } elseif (isset($this->httpHeaders[$altHeader])) {
  5814. return $this->httpHeaders[$altHeader];
  5815. }
  5816. return null;
  5817. }
  5818. public function getMobileHeaders()
  5819. {
  5820. return self::$mobileHeaders;
  5821. }
  5822. /**
  5823. * Get all possible HTTP headers that
  5824. * can contain the User-Agent string.
  5825. *
  5826. * @return array List of HTTP headers.
  5827. */
  5828. public function getUaHttpHeaders()
  5829. {
  5830. return self::$uaHttpHeaders;
  5831. }
  5832. /**
  5833. * Set CloudFront headers
  5834. * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
  5835. *
  5836. * @param array $cfHeaders List of HTTP headers
  5837. *
  5838. * @return boolean If there were CloudFront headers to be set
  5839. */
  5840. public function setCfHeaders($cfHeaders = null) {
  5841. // use global _SERVER if $cfHeaders aren't defined
  5842. if (!is_array($cfHeaders) || !count($cfHeaders)) {
  5843. $cfHeaders = $_SERVER;
  5844. }
  5845. // clear existing headers
  5846. $this->cloudfrontHeaders = array();
  5847. // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
  5848. // start with cloudfront-.
  5849. $response = false;
  5850. foreach ($cfHeaders as $key => $value) {
  5851. if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
  5852. $this->cloudfrontHeaders[strtoupper($key)] = $value;
  5853. $response = true;
  5854. }
  5855. }
  5856. return $response;
  5857. }
  5858. /**
  5859. * Retrieves the cloudfront headers.
  5860. *
  5861. * @return array
  5862. */
  5863. public function getCfHeaders()
  5864. {
  5865. return $this->cloudfrontHeaders;
  5866. }
  5867. /**
  5868. * Set the User-Agent to be used.
  5869. *
  5870. * @param string $userAgent The user agent string to set.
  5871. *
  5872. * @return string|null
  5873. */
  5874. public function setUserAgent($userAgent = null)
  5875. {
  5876. // Invalidate cache due to #375
  5877. $this->cache = array();
  5878. if (false === empty($userAgent)) {
  5879. return $this->userAgent = $userAgent;
  5880. } else {
  5881. $this->userAgent = null;
  5882. foreach ($this->getUaHttpHeaders() as $altHeader) {
  5883. if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
  5884. $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
  5885. }
  5886. }
  5887. if (!empty($this->userAgent)) {
  5888. return $this->userAgent = trim($this->userAgent);
  5889. }
  5890. }
  5891. if (count($this->getCfHeaders()) > 0) {
  5892. return $this->userAgent = 'Amazon CloudFront';
  5893. }
  5894. return $this->userAgent = null;
  5895. }
  5896. /**
  5897. * Retrieve the User-Agent.
  5898. *
  5899. * @return string|null The user agent if it's set.
  5900. */
  5901. public function getUserAgent()
  5902. {
  5903. return $this->userAgent;
  5904. }
  5905. /**
  5906. * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
  5907. * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
  5908. *
  5909. * @deprecated since version 2.6.9
  5910. *
  5911. * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
  5912. * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
  5913. */
  5914. public function setDetectionType($type = null)
  5915. {
  5916. if ($type === null) {
  5917. $type = self::DETECTION_TYPE_MOBILE;
  5918. }
  5919. if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
  5920. return;
  5921. }
  5922. $this->detectionType = $type;
  5923. }
  5924. public function getMatchingRegex()
  5925. {
  5926. return $this->matchingRegex;
  5927. }
  5928. public function getMatchesArray()
  5929. {
  5930. return $this->matchesArray;
  5931. }
  5932. /**
  5933. * Retrieve the list of known phone devices.
  5934. *
  5935. * @return array List of phone devices.
  5936. */
  5937. public static function getPhoneDevices()
  5938. {
  5939. return self::$phoneDevices;
  5940. }
  5941. /**
  5942. * Retrieve the list of known tablet devices.
  5943. *
  5944. * @return array List of tablet devices.
  5945. */
  5946. public static function getTabletDevices()
  5947. {
  5948. return self::$tabletDevices;
  5949. }
  5950. /**
  5951. * Alias for getBrowsers() method.
  5952. *
  5953. * @return array List of user agents.
  5954. */
  5955. public static function getUserAgents()
  5956. {
  5957. return self::getBrowsers();
  5958. }
  5959. /**
  5960. * Retrieve the list of known browsers. Specifically, the user agents.
  5961. *
  5962. * @return array List of browsers / user agents.
  5963. */
  5964. public static function getBrowsers()
  5965. {
  5966. return self::$browsers;
  5967. }
  5968. /**
  5969. * Retrieve the list of known utilities.
  5970. *
  5971. * @return array List of utilities.
  5972. */
  5973. public static function getUtilities()
  5974. {
  5975. return self::$utilities;
  5976. }
  5977. /**
  5978. * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
  5979. *
  5980. * @deprecated since version 2.6.9
  5981. *
  5982. * @return array All the rules (but not extended).
  5983. */
  5984. public static function getMobileDetectionRules()
  5985. {
  5986. static $rules;
  5987. if (!$rules) {
  5988. $rules = array_merge(
  5989. self::$phoneDevices,
  5990. self::$tabletDevices,
  5991. self::$operatingSystems,
  5992. self::$browsers
  5993. );
  5994. }
  5995. return $rules;
  5996. }
  5997. /**
  5998. * Method gets the mobile detection rules + utilities.
  5999. * The reason this is separate is because utilities rules
  6000. * don't necessary imply mobile. This method is used inside
  6001. * the new $detect->is('stuff') method.
  6002. *
  6003. * @deprecated since version 2.6.9
  6004. *
  6005. * @return array All the rules + extended.
  6006. */
  6007. public function getMobileDetectionRulesExtended()
  6008. {
  6009. static $rules;
  6010. if (!$rules) {
  6011. // Merge all rules together.
  6012. $rules = array_merge(
  6013. self::$phoneDevices,
  6014. self::$tabletDevices,
  6015. self::$operatingSystems,
  6016. self::$browsers,
  6017. self::$utilities
  6018. );
  6019. }
  6020. return $rules;
  6021. }
  6022. /**
  6023. * Retrieve the current set of rules.
  6024. *
  6025. * @deprecated since version 2.6.9
  6026. *
  6027. * @return array
  6028. */
  6029. public function getRules()
  6030. {
  6031. if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
  6032. return self::getMobileDetectionRulesExtended();
  6033. } else {
  6034. return self::getMobileDetectionRules();
  6035. }
  6036. }
  6037. /**
  6038. * Retrieve the list of mobile operating systems.
  6039. *
  6040. * @return array The list of mobile operating systems.
  6041. */
  6042. public static function getOperatingSystems()
  6043. {
  6044. return self::$operatingSystems;
  6045. }
  6046. /**
  6047. * Check the HTTP headers for signs of mobile.
  6048. * This is the fastest mobile check possible; it's used
  6049. * inside isMobile() method.
  6050. *
  6051. * @return bool
  6052. */
  6053. public function checkHttpHeadersForMobile()
  6054. {
  6055. foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
  6056. if (isset($this->httpHeaders[$mobileHeader])) {
  6057. if (is_array($matchType['matches'])) {
  6058. foreach ($matchType['matches'] as $_match) {
  6059. if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
  6060. return true;
  6061. }
  6062. }
  6063. return false;
  6064. } else {
  6065. return true;
  6066. }
  6067. }
  6068. }
  6069. return false;
  6070. }
  6071. /**
  6072. * Magic overloading method.
  6073. *
  6074. * @method boolean is[...]()
  6075. * @param string $name
  6076. * @param array $arguments
  6077. * @return mixed
  6078. * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
  6079. */
  6080. public function __call($name, $arguments)
  6081. {
  6082. // make sure the name starts with 'is', otherwise
  6083. if (substr($name, 0, 2) !== 'is') {
  6084. throw new BadMethodCallException("No such method exists: $name");
  6085. }
  6086. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6087. $key = substr($name, 2);
  6088. return $this->matchUAAgainstKey($key);
  6089. }
  6090. /**
  6091. * Find a detection rule that matches the current User-agent.
  6092. *
  6093. * @param null $userAgent deprecated
  6094. * @return boolean
  6095. */
  6096. protected function matchDetectionRulesAgainstUA($userAgent = null)
  6097. {
  6098. // Begin general search.
  6099. foreach ($this->getRules() as $_regex) {
  6100. if (empty($_regex)) {
  6101. continue;
  6102. }
  6103. if ($this->match($_regex, $userAgent)) {
  6104. return true;
  6105. }
  6106. }
  6107. return false;
  6108. }
  6109. /**
  6110. * Search for a certain key in the rules array.
  6111. * If the key is found then try to match the corresponding
  6112. * regex against the User-Agent.
  6113. *
  6114. * @param string $key
  6115. *
  6116. * @return boolean
  6117. */
  6118. protected function matchUAAgainstKey($key)
  6119. {
  6120. // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
  6121. $key = strtolower($key);
  6122. if (false === isset($this->cache[$key])) {
  6123. // change the keys to lower case
  6124. $_rules = array_change_key_case($this->getRules());
  6125. if (false === empty($_rules[$key])) {
  6126. $this->cache[$key] = $this->match($_rules[$key]);
  6127. }
  6128. if (false === isset($this->cache[$key])) {
  6129. $this->cache[$key] = false;
  6130. }
  6131. }
  6132. return $this->cache[$key];
  6133. }
  6134. /**
  6135. * Check if the device is mobile.
  6136. * Returns true if any type of mobile device detected, including special ones
  6137. * @param null $userAgent deprecated
  6138. * @param null $httpHeaders deprecated
  6139. * @return bool
  6140. */
  6141. public function isMobile($userAgent = null, $httpHeaders = null)
  6142. {
  6143. if ($httpHeaders) {
  6144. $this->setHttpHeaders($httpHeaders);
  6145. }
  6146. if ($userAgent) {
  6147. $this->setUserAgent($userAgent);
  6148. }
  6149. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6150. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6151. $cfHeaders = $this->getCfHeaders();
  6152. if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
  6153. return true;
  6154. }
  6155. }
  6156. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6157. if ($this->checkHttpHeadersForMobile()) {
  6158. return true;
  6159. } else {
  6160. return $this->matchDetectionRulesAgainstUA();
  6161. }
  6162. }
  6163. /**
  6164. * Check if the device is a tablet.
  6165. * Return true if any type of tablet device is detected.
  6166. *
  6167. * @param string $userAgent deprecated
  6168. * @param array $httpHeaders deprecated
  6169. * @return bool
  6170. */
  6171. public function isTablet($userAgent = null, $httpHeaders = null)
  6172. {
  6173. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6174. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6175. $cfHeaders = $this->getCfHeaders();
  6176. if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
  6177. return true;
  6178. }
  6179. }
  6180. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6181. foreach (self::$tabletDevices as $_regex) {
  6182. if ($this->match($_regex, $userAgent)) {
  6183. return true;
  6184. }
  6185. }
  6186. return false;
  6187. }
  6188. /**
  6189. * This method checks for a certain property in the
  6190. * userAgent.
  6191. * @todo: The httpHeaders part is not yet used.
  6192. *
  6193. * @param string $key
  6194. * @param string $userAgent deprecated
  6195. * @param string $httpHeaders deprecated
  6196. * @return bool|int|null
  6197. */
  6198. public function is($key, $userAgent = null, $httpHeaders = null)
  6199. {
  6200. // Set the UA and HTTP headers only if needed (eg. batch mode).
  6201. if ($httpHeaders) {
  6202. $this->setHttpHeaders($httpHeaders);
  6203. }
  6204. if ($userAgent) {
  6205. $this->setUserAgent($userAgent);
  6206. }
  6207. $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
  6208. return $this->matchUAAgainstKey($key);
  6209. }
  6210. /**
  6211. * Some detection rules are relative (not standard),
  6212. * because of the diversity of devices, vendors and
  6213. * their conventions in representing the User-Agent or
  6214. * the HTTP headers.
  6215. *
  6216. * This method will be used to check custom regexes against
  6217. * the User-Agent string.
  6218. *
  6219. * @param $regex
  6220. * @param string $userAgent
  6221. * @return bool
  6222. *
  6223. * @todo: search in the HTTP headers too.
  6224. */
  6225. public function match($regex, $userAgent = null)
  6226. {
  6227. $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
  6228. // If positive match is found, store the results for debug.
  6229. if ($match) {
  6230. $this->matchingRegex = $regex;
  6231. $this->matchesArray = $matches;
  6232. }
  6233. return $match;
  6234. }
  6235. /**
  6236. * Get the properties array.
  6237. *
  6238. * @return array
  6239. */
  6240. public static function getProperties()
  6241. {
  6242. return self::$properties;
  6243. }
  6244. /**
  6245. * Prepare the version number.
  6246. *
  6247. * @todo Remove the error supression from str_replace() call.
  6248. *
  6249. * @param string $ver The string version, like "2.6.21.2152";
  6250. *
  6251. * @return float
  6252. */
  6253. public function prepareVersionNo($ver)
  6254. {
  6255. $ver = str_replace(array('_', ' ', '/'), '.', $ver);
  6256. $arrVer = explode('.', $ver, 2);
  6257. if (isset($arrVer[1])) {
  6258. $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
  6259. }
  6260. return (float) implode('.', $arrVer);
  6261. }
  6262. /**
  6263. * Check the version of the given property in the User-Agent.
  6264. * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
  6265. *
  6266. * @param string $propertyName The name of the property. See self::getProperties() array
  6267. * keys for all possible properties.
  6268. * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
  6269. * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
  6270. * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
  6271. * invalid parameter will default to the this type as well.
  6272. *
  6273. * @return string|float The version of the property we are trying to extract.
  6274. */
  6275. public function version($propertyName, $type = self::VERSION_TYPE_STRING)
  6276. {
  6277. if (empty($propertyName)) {
  6278. return false;
  6279. }
  6280. // set the $type to the default if we don't recognize the type
  6281. if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
  6282. $type = self::VERSION_TYPE_STRING;
  6283. }
  6284. $properties = self::getProperties();
  6285. // Check if the property exists in the properties array.
  6286. if (true === isset($properties[$propertyName])) {
  6287. // Prepare the pattern to be matched.
  6288. // Make sure we always deal with an array (string is converted).
  6289. $properties[$propertyName] = (array) $properties[$propertyName];
  6290. foreach ($properties[$propertyName] as $propertyMatchString) {
  6291. $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
  6292. // Identify and extract the version.
  6293. preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
  6294. if (false === empty($match[1])) {
  6295. $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
  6296. return $version;
  6297. }
  6298. }
  6299. }
  6300. return false;
  6301. }
  6302. /**
  6303. * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
  6304. *
  6305. * @return string One of the self::MOBILE_GRADE_* constants.
  6306. */
  6307. public function mobileGrade()
  6308. {
  6309. $isMobile = $this->isMobile();
  6310. if (
  6311. // 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)
  6312. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6313. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6314. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6315. // 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)
  6316. // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
  6317. // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
  6318. // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
  6319. ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
  6320. // 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)
  6321. $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
  6322. // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
  6323. $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
  6324. // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
  6325. $this->match('Playbook.*Tablet') ||
  6326. // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
  6327. ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
  6328. // Palm WebOS 3.0 - Tested on HP TouchPad
  6329. $this->match('hp.*TouchPad') ||
  6330. // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
  6331. ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
  6332. // Chrome for Android - Tested on Android 4.0, 4.1 device
  6333. ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
  6334. // Skyfire 4.1 - Tested on Android 2.3 device
  6335. ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6336. // Opera Mobile 11.5-12: Tested on Android 2.3
  6337. ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
  6338. // Meego 1.2 - Tested on Nokia 950 and N9
  6339. $this->is('MeeGoOS') ||
  6340. // Tizen (pre-release) - Tested on early hardware
  6341. $this->is('Tizen') ||
  6342. // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
  6343. // @todo: more tests here!
  6344. $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
  6345. // UC Browser - Tested on Android 2.3 device
  6346. ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6347. // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
  6348. ( $this->match('Kindle Fire') ||
  6349. $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
  6350. // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
  6351. $this->is('AndroidOS') && $this->is('NookTablet') ||
  6352. // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
  6353. $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
  6354. // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
  6355. $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
  6356. // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
  6357. $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
  6358. // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
  6359. $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
  6360. // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
  6361. $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
  6362. ){
  6363. return self::MOBILE_GRADE_A;
  6364. }
  6365. if (
  6366. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
  6367. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
  6368. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
  6369. // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
  6370. $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
  6371. //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
  6372. ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
  6373. ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
  6374. // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
  6375. $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
  6376. // @todo: report this (tested on Nokia N71)
  6377. $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
  6378. ){
  6379. return self::MOBILE_GRADE_B;
  6380. }
  6381. if (
  6382. // Blackberry 4.x - Tested on the Curve 8330
  6383. $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
  6384. // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
  6385. $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
  6386. // Tested on original iPhone (3.1), iPhone 3 (3.2)
  6387. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6388. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6389. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6390. // Internet Explorer 7 and older - Tested on Windows XP
  6391. $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
  6392. ){
  6393. return self::MOBILE_GRADE_C;
  6394. }
  6395. // All older smartphone platforms and featurephones - Any device that doesn't support media queries
  6396. // will receive the basic, C grade experience.
  6397. return self::MOBILE_GRADE_C;
  6398. }
  6399. }
  6400. $mobileDetect = new Mobile_Detect;
  6401. $userDevice = ($mobileDetect->isMobile() ? ($mobileDetect->isTablet() ? 'tablet' : 'phone') : 'computer');
  6402. function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  6403. $path = getServerPath();
  6404. return '
  6405. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6406. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  6407. <head>
  6408. <!--[if gte mso 9]><xml>
  6409. <o:OfficeDocumentSettings>
  6410. <o:AllowPNG/>
  6411. <o:PixelsPerInch>96</o:PixelsPerInch>
  6412. </o:OfficeDocumentSettings>
  6413. </xml><![endif]-->
  6414. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6415. <meta name="viewport" content="width=device-width">
  6416. <!--[if !mso]><!-->
  6417. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6418. <!--<![endif]-->
  6419. <title></title>
  6420. <!--[if !mso]><!-- -->
  6421. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
  6422. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  6423. <!--<![endif]-->
  6424. <style type="text/css" id="media-query">
  6425. body {
  6426. margin: 0;
  6427. padding: 0;
  6428. }
  6429. table,
  6430. tr,
  6431. td {
  6432. vertical-align: top;
  6433. border-collapse: collapse;
  6434. }
  6435. .ie-browser table,
  6436. .mso-container table {
  6437. table-layout: fixed;
  6438. }
  6439. * {
  6440. line-height: inherit;
  6441. }
  6442. a[x-apple-data-detectors=true] {
  6443. color: inherit !important;
  6444. text-decoration: none !important;
  6445. }
  6446. [owa] .img-container div,
  6447. [owa] .img-container button {
  6448. display: block !important;
  6449. }
  6450. [owa] .fullwidth button {
  6451. width: 100% !important;
  6452. }
  6453. [owa] .block-grid .col {
  6454. display: table-cell;
  6455. float: none !important;
  6456. vertical-align: top;
  6457. }
  6458. .ie-browser .num12,
  6459. .ie-browser .block-grid,
  6460. [owa] .num12,
  6461. [owa] .block-grid {
  6462. width: 615px !important;
  6463. }
  6464. .ExternalClass,
  6465. .ExternalClass p,
  6466. .ExternalClass span,
  6467. .ExternalClass font,
  6468. .ExternalClass td,
  6469. .ExternalClass div {
  6470. line-height: 100%;
  6471. }
  6472. .ie-browser .mixed-two-up .num4,
  6473. [owa] .mixed-two-up .num4 {
  6474. width: 204px !important;
  6475. }
  6476. .ie-browser .mixed-two-up .num8,
  6477. [owa] .mixed-two-up .num8 {
  6478. width: 408px !important;
  6479. }
  6480. .ie-browser .block-grid.two-up .col,
  6481. [owa] .block-grid.two-up .col {
  6482. width: 307px !important;
  6483. }
  6484. .ie-browser .block-grid.three-up .col,
  6485. [owa] .block-grid.three-up .col {
  6486. width: 205px !important;
  6487. }
  6488. .ie-browser .block-grid.four-up .col,
  6489. [owa] .block-grid.four-up .col {
  6490. width: 153px !important;
  6491. }
  6492. .ie-browser .block-grid.five-up .col,
  6493. [owa] .block-grid.five-up .col {
  6494. width: 123px !important;
  6495. }
  6496. .ie-browser .block-grid.six-up .col,
  6497. [owa] .block-grid.six-up .col {
  6498. width: 102px !important;
  6499. }
  6500. .ie-browser .block-grid.seven-up .col,
  6501. [owa] .block-grid.seven-up .col {
  6502. width: 87px !important;
  6503. }
  6504. .ie-browser .block-grid.eight-up .col,
  6505. [owa] .block-grid.eight-up .col {
  6506. width: 76px !important;
  6507. }
  6508. .ie-browser .block-grid.nine-up .col,
  6509. [owa] .block-grid.nine-up .col {
  6510. width: 68px !important;
  6511. }
  6512. .ie-browser .block-grid.ten-up .col,
  6513. [owa] .block-grid.ten-up .col {
  6514. width: 61px !important;
  6515. }
  6516. .ie-browser .block-grid.eleven-up .col,
  6517. [owa] .block-grid.eleven-up .col {
  6518. width: 55px !important;
  6519. }
  6520. .ie-browser .block-grid.twelve-up .col,
  6521. [owa] .block-grid.twelve-up .col {
  6522. width: 51px !important;
  6523. }
  6524. @media only screen and (min-width: 635px) {
  6525. .block-grid {
  6526. width: 615px !important;
  6527. }
  6528. .block-grid .col {
  6529. display: table-cell;
  6530. Float: none !important;
  6531. vertical-align: top;
  6532. }
  6533. .block-grid .col.num12 {
  6534. width: 615px !important;
  6535. }
  6536. .block-grid.mixed-two-up .col.num4 {
  6537. width: 204px !important;
  6538. }
  6539. .block-grid.mixed-two-up .col.num8 {
  6540. width: 408px !important;
  6541. }
  6542. .block-grid.two-up .col {
  6543. width: 307px !important;
  6544. }
  6545. .block-grid.three-up .col {
  6546. width: 205px !important;
  6547. }
  6548. .block-grid.four-up .col {
  6549. width: 153px !important;
  6550. }
  6551. .block-grid.five-up .col {
  6552. width: 123px !important;
  6553. }
  6554. .block-grid.six-up .col {
  6555. width: 102px !important;
  6556. }
  6557. .block-grid.seven-up .col {
  6558. width: 87px !important;
  6559. }
  6560. .block-grid.eight-up .col {
  6561. width: 76px !important;
  6562. }
  6563. .block-grid.nine-up .col {
  6564. width: 68px !important;
  6565. }
  6566. .block-grid.ten-up .col {
  6567. width: 61px !important;
  6568. }
  6569. .block-grid.eleven-up .col {
  6570. width: 55px !important;
  6571. }
  6572. .block-grid.twelve-up .col {
  6573. width: 51px !important;
  6574. }
  6575. }
  6576. @media (max-width: 635px) {
  6577. .block-grid,
  6578. .col {
  6579. min-width: 320px !important;
  6580. max-width: 100% !important;
  6581. }
  6582. .block-grid {
  6583. width: calc(100% - 40px) !important;
  6584. }
  6585. .col {
  6586. width: 100% !important;
  6587. }
  6588. .col>div {
  6589. margin: 0 auto;
  6590. }
  6591. img.fullwidth {
  6592. max-width: 100% !important;
  6593. }
  6594. }
  6595. </style>
  6596. </head>
  6597. <body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #FFFFFF">
  6598. <!--[if IE]><div class="ie-browser"><![endif]-->
  6599. <!--[if mso]><div class="mso-container"><![endif]-->
  6600. <div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: #FFFFFF">
  6601. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #FFFFFF;"><![endif]-->
  6602. <div style="background-color:#333333;">
  6603. <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;"
  6604. class="block-grid ">
  6605. <div style="border-collapse: collapse;display: table;width: 100%;">
  6606. <!--[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]-->
  6607. <!--[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]-->
  6608. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6609. <div style="background-color: transparent; width: 100% !important;">
  6610. <!--[if (!mso)&(!IE)]><!-->
  6611. <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;">
  6612. <!--<![endif]-->
  6613. <div align="left" class="img-container left fullwidth" style="padding-right: 30px; padding-left: 30px;">
  6614. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px;" align="left"><![endif]-->
  6615. <img class="left fullwidth" align="left" border="0" src="'.$path.'images/organizr-logo-h.png" alt="Image" title="Image"
  6616. 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"
  6617. width="555">
  6618. <!--[if mso]></td></tr></table><![endif]-->
  6619. </div>
  6620. <!--[if (!mso)&(!IE)]><!-->
  6621. </div>
  6622. <!--<![endif]-->
  6623. </div>
  6624. </div>
  6625. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6626. </div>
  6627. </div>
  6628. </div>
  6629. <div style="background-color:#333333;">
  6630. <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;"
  6631. class="block-grid ">
  6632. <div style="border-collapse: collapse;display: table;width: 100%;">
  6633. <!--[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]-->
  6634. <!--[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]-->
  6635. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6636. <div style="background-color: transparent; width: 100% !important;">
  6637. <!--[if (!mso)&(!IE)]><!-->
  6638. <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;">
  6639. <!--<![endif]-->
  6640. <!--[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]-->
  6641. <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;">
  6642. <div style="font-size:12px;line-height:14px;color:#FFFFFF;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6643. <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>
  6644. </span>
  6645. </p>
  6646. </div>
  6647. </div>
  6648. <!--[if mso]></td></tr></table><![endif]-->
  6649. <!--[if (!mso)&(!IE)]><!-->
  6650. </div>
  6651. <!--<![endif]-->
  6652. </div>
  6653. </div>
  6654. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6655. </div>
  6656. </div>
  6657. </div>
  6658. <div style="background-color:#393939;">
  6659. <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;"
  6660. class="block-grid ">
  6661. <div style="border-collapse: collapse;display: table;width: 100%;">
  6662. <!--[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]-->
  6663. <!--[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]-->
  6664. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6665. <div style="background-color: transparent; width: 100% !important;">
  6666. <!--[if (!mso)&(!IE)]><!-->
  6667. <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;">
  6668. <!--<![endif]-->
  6669. <!--[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]-->
  6670. <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;">
  6671. <div style="font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6672. <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>
  6673. </div>
  6674. </div>
  6675. <!--[if mso]></td></tr></table><![endif]-->
  6676. <div style="padding-right: 5px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px;">
  6677. <!--[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]-->
  6678. <div align="center">
  6679. <div style="border-top: 2px solid #66D9EF; width:55%; line-height:2px; height:2px; font-size:2px;">&#160;</div>
  6680. </div>
  6681. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6682. </div>
  6683. <!--[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]-->
  6684. <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;">
  6685. <div style="font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6686. <p style="margin: 0;font-size: 12px;line-height: 14px"><span style="font-size: 28px; line-height: 33px;">Hey '.$user.',</span></p>
  6687. </div>
  6688. </div>
  6689. <!--[if mso]></td></tr></table><![endif]-->
  6690. <!--[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]-->
  6691. <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;">
  6692. <div style="font-size:12px;line-height:22px;font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;color:#FFFFFF;text-align:left;">
  6693. <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>
  6694. </span>
  6695. </p>
  6696. </div>
  6697. </div>
  6698. <!--[if mso]></td></tr></table><![endif]-->
  6699. <div align="center" class="button-container center" style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;">
  6700. <!--[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]-->
  6701. <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">
  6702. <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>
  6703. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6704. </div>
  6705. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6706. </div>
  6707. <!--[if (!mso)&(!IE)]><!-->
  6708. </div>
  6709. <!--<![endif]-->
  6710. </div>
  6711. </div>
  6712. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6713. </div>
  6714. </div>
  6715. </div>
  6716. <div style="background-color:#ffffff;">
  6717. <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;"
  6718. class="block-grid ">
  6719. <div style="border-collapse: collapse;display: table;width: 100%;">
  6720. <!--[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]-->
  6721. <!--[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]-->
  6722. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6723. <div style="background-color: transparent; width: 100% !important;">
  6724. <!--[if (!mso)&(!IE)]><!-->
  6725. <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;">
  6726. <!--<![endif]-->
  6727. <!--[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]-->
  6728. <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;">
  6729. <div style="font-size:12px;line-height:14px;color:#555555;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6730. <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>
  6731. </div>
  6732. </div>
  6733. <!--[if mso]></td></tr></table><![endif]-->
  6734. <div style="padding-right: 20px; padding-left: 20px; padding-top: 15px; padding-bottom: 20px;">
  6735. <!--[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]-->
  6736. <div align="center">
  6737. <div style="border-top: 3px solid #66D9EF; width:40%; line-height:3px; height:3px; font-size:3px;">&#160;</div>
  6738. </div>
  6739. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6740. </div>
  6741. <!--[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]-->
  6742. <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;">
  6743. <div style="font-size:12px;line-height:22px;color:#7E7D7D;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6744. <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>
  6745. </div>
  6746. </div>
  6747. <!--[if mso]></td></tr></table><![endif]-->
  6748. <!--[if (!mso)&(!IE)]><!-->
  6749. </div>
  6750. <!--<![endif]-->
  6751. </div>
  6752. </div>
  6753. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6754. </div>
  6755. </div>
  6756. </div>
  6757. <div style="background-color:#333333;">
  6758. <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;"
  6759. class="block-grid ">
  6760. <div style="border-collapse: collapse;display: table;width: 100%;">
  6761. <!--[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]-->
  6762. <!--[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]-->
  6763. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6764. <div style="background-color: transparent; width: 100% !important;">
  6765. <!--[if (!mso)&(!IE)]><!-->
  6766. <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;">
  6767. <!--<![endif]-->
  6768. <!--[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]-->
  6769. <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;">
  6770. <div style="font-size:12px;line-height:14px;color:#959595;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6771. <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"
  6772. href="https://github.com/causefx/Organizr" target="_blank" rel="noopener noreferrer">Organizr</a><strong><br></strong></p>
  6773. </div>
  6774. </div>
  6775. <!--[if mso]></td></tr></table><![endif]-->
  6776. <!--[if (!mso)&(!IE)]><!-->
  6777. </div>
  6778. <!--<![endif]-->
  6779. </div>
  6780. </div>
  6781. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6782. </div>
  6783. </div>
  6784. </div>
  6785. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  6786. </div>
  6787. <!--[if (mso)|(IE)]></div><![endif]-->
  6788. </body>
  6789. </html>
  6790. ';
  6791. }
  6792. function mimeTypes(){
  6793. return array(
  6794. '123' => 'application/vnd.lotus-1-2-3',
  6795. '3dml' => 'text/vnd.in3d.3dml',
  6796. '3ds' => 'image/x-3ds',
  6797. '3g2' => 'video/3gpp2',
  6798. '3gp' => 'video/3gpp',
  6799. '7z' => 'application/x-7z-compressed',
  6800. 'aab' => 'application/x-authorware-bin',
  6801. 'aac' => 'audio/x-aac',
  6802. 'aam' => 'application/x-authorware-map',
  6803. 'aas' => 'application/x-authorware-seg',
  6804. 'abw' => 'application/x-abiword',
  6805. 'ac' => 'application/pkix-attr-cert',
  6806. 'acc' => 'application/vnd.americandynamics.acc',
  6807. 'ace' => 'application/x-ace-compressed',
  6808. 'acu' => 'application/vnd.acucobol',
  6809. 'acutc' => 'application/vnd.acucorp',
  6810. 'adp' => 'audio/adpcm',
  6811. 'aep' => 'application/vnd.audiograph',
  6812. 'afm' => 'application/x-font-type1',
  6813. 'afp' => 'application/vnd.ibm.modcap',
  6814. 'ahead' => 'application/vnd.ahead.space',
  6815. 'ai' => 'application/postscript',
  6816. 'aif' => 'audio/x-aiff',
  6817. 'aifc' => 'audio/x-aiff',
  6818. 'aiff' => 'audio/x-aiff',
  6819. 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
  6820. 'ait' => 'application/vnd.dvb.ait',
  6821. 'ami' => 'application/vnd.amiga.ami',
  6822. 'apk' => 'application/vnd.android.package-archive',
  6823. 'appcache' => 'text/cache-manifest',
  6824. 'application' => 'application/x-ms-application',
  6825. 'apr' => 'application/vnd.lotus-approach',
  6826. 'arc' => 'application/x-freearc',
  6827. 'asc' => 'application/pgp-signature',
  6828. 'asf' => 'video/x-ms-asf',
  6829. 'asm' => 'text/x-asm',
  6830. 'aso' => 'application/vnd.accpac.simply.aso',
  6831. 'asx' => 'video/x-ms-asf',
  6832. 'atc' => 'application/vnd.acucorp',
  6833. 'atom' => 'application/atom+xml',
  6834. 'atomcat' => 'application/atomcat+xml',
  6835. 'atomsvc' => 'application/atomsvc+xml',
  6836. 'atx' => 'application/vnd.antix.game-component',
  6837. 'au' => 'audio/basic',
  6838. 'avi' => 'video/x-msvideo',
  6839. 'aw' => 'application/applixware',
  6840. 'azf' => 'application/vnd.airzip.filesecure.azf',
  6841. 'azs' => 'application/vnd.airzip.filesecure.azs',
  6842. 'azw' => 'application/vnd.amazon.ebook',
  6843. 'bat' => 'application/x-msdownload',
  6844. 'bcpio' => 'application/x-bcpio',
  6845. 'bdf' => 'application/x-font-bdf',
  6846. 'bdm' => 'application/vnd.syncml.dm+wbxml',
  6847. 'bed' => 'application/vnd.realvnc.bed',
  6848. 'bh2' => 'application/vnd.fujitsu.oasysprs',
  6849. 'bin' => 'application/octet-stream',
  6850. 'blb' => 'application/x-blorb',
  6851. 'blorb' => 'application/x-blorb',
  6852. 'bmi' => 'application/vnd.bmi',
  6853. 'bmp' => 'image/bmp',
  6854. 'book' => 'application/vnd.framemaker',
  6855. 'box' => 'application/vnd.previewsystems.box',
  6856. 'boz' => 'application/x-bzip2',
  6857. 'bpk' => 'application/octet-stream',
  6858. 'btif' => 'image/prs.btif',
  6859. 'bz' => 'application/x-bzip',
  6860. 'bz2' => 'application/x-bzip2',
  6861. 'c' => 'text/x-c',
  6862. 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
  6863. 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
  6864. 'c4d' => 'application/vnd.clonk.c4group',
  6865. 'c4f' => 'application/vnd.clonk.c4group',
  6866. 'c4g' => 'application/vnd.clonk.c4group',
  6867. 'c4p' => 'application/vnd.clonk.c4group',
  6868. 'c4u' => 'application/vnd.clonk.c4group',
  6869. 'cab' => 'application/vnd.ms-cab-compressed',
  6870. 'caf' => 'audio/x-caf',
  6871. 'cap' => 'application/vnd.tcpdump.pcap',
  6872. 'car' => 'application/vnd.curl.car',
  6873. 'cat' => 'application/vnd.ms-pki.seccat',
  6874. 'cb7' => 'application/x-cbr',
  6875. 'cba' => 'application/x-cbr',
  6876. 'cbr' => 'application/x-cbr',
  6877. 'cbt' => 'application/x-cbr',
  6878. 'cbz' => 'application/x-cbr',
  6879. 'cc' => 'text/x-c',
  6880. 'cct' => 'application/x-director',
  6881. 'ccxml' => 'application/ccxml+xml',
  6882. 'cdbcmsg' => 'application/vnd.contact.cmsg',
  6883. 'cdf' => 'application/x-netcdf',
  6884. 'cdkey' => 'application/vnd.mediastation.cdkey',
  6885. 'cdmia' => 'application/cdmi-capability',
  6886. 'cdmic' => 'application/cdmi-container',
  6887. 'cdmid' => 'application/cdmi-domain',
  6888. 'cdmio' => 'application/cdmi-object',
  6889. 'cdmiq' => 'application/cdmi-queue',
  6890. 'cdx' => 'chemical/x-cdx',
  6891. 'cdxml' => 'application/vnd.chemdraw+xml',
  6892. 'cdy' => 'application/vnd.cinderella',
  6893. 'cer' => 'application/pkix-cert',
  6894. 'cfs' => 'application/x-cfs-compressed',
  6895. 'cgm' => 'image/cgm',
  6896. 'chat' => 'application/x-chat',
  6897. 'chm' => 'application/vnd.ms-htmlhelp',
  6898. 'chrt' => 'application/vnd.kde.kchart',
  6899. 'cif' => 'chemical/x-cif',
  6900. 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
  6901. 'cil' => 'application/vnd.ms-artgalry',
  6902. 'cla' => 'application/vnd.claymore',
  6903. 'class' => 'application/java-vm',
  6904. 'clkk' => 'application/vnd.crick.clicker.keyboard',
  6905. 'clkp' => 'application/vnd.crick.clicker.palette',
  6906. 'clkt' => 'application/vnd.crick.clicker.template',
  6907. 'clkw' => 'application/vnd.crick.clicker.wordbank',
  6908. 'clkx' => 'application/vnd.crick.clicker',
  6909. 'clp' => 'application/x-msclip',
  6910. 'cmc' => 'application/vnd.cosmocaller',
  6911. 'cmdf' => 'chemical/x-cmdf',
  6912. 'cml' => 'chemical/x-cml',
  6913. 'cmp' => 'application/vnd.yellowriver-custom-menu',
  6914. 'cmx' => 'image/x-cmx',
  6915. 'cod' => 'application/vnd.rim.cod',
  6916. 'com' => 'application/x-msdownload',
  6917. 'conf' => 'text/plain',
  6918. 'cpio' => 'application/x-cpio',
  6919. 'cpp' => 'text/x-c',
  6920. 'cpt' => 'application/mac-compactpro',
  6921. 'crd' => 'application/x-mscardfile',
  6922. 'crl' => 'application/pkix-crl',
  6923. 'crt' => 'application/x-x509-ca-cert',
  6924. 'cryptonote' => 'application/vnd.rig.cryptonote',
  6925. 'csh' => 'application/x-csh',
  6926. 'csml' => 'chemical/x-csml',
  6927. 'csp' => 'application/vnd.commonspace',
  6928. 'css' => 'text/css',
  6929. 'cst' => 'application/x-director',
  6930. 'csv' => 'text/csv',
  6931. 'cu' => 'application/cu-seeme',
  6932. 'curl' => 'text/vnd.curl',
  6933. 'cww' => 'application/prs.cww',
  6934. 'cxt' => 'application/x-director',
  6935. 'cxx' => 'text/x-c',
  6936. 'dae' => 'model/vnd.collada+xml',
  6937. 'daf' => 'application/vnd.mobius.daf',
  6938. 'dart' => 'application/vnd.dart',
  6939. 'dataless' => 'application/vnd.fdsn.seed',
  6940. 'davmount' => 'application/davmount+xml',
  6941. 'dbk' => 'application/docbook+xml',
  6942. 'dcr' => 'application/x-director',
  6943. 'dcurl' => 'text/vnd.curl.dcurl',
  6944. 'dd2' => 'application/vnd.oma.dd2+xml',
  6945. 'ddd' => 'application/vnd.fujixerox.ddd',
  6946. 'deb' => 'application/x-debian-package',
  6947. 'def' => 'text/plain',
  6948. 'deploy' => 'application/octet-stream',
  6949. 'der' => 'application/x-x509-ca-cert',
  6950. 'dfac' => 'application/vnd.dreamfactory',
  6951. 'dgc' => 'application/x-dgc-compressed',
  6952. 'dic' => 'text/x-c',
  6953. 'dir' => 'application/x-director',
  6954. 'dis' => 'application/vnd.mobius.dis',
  6955. 'dist' => 'application/octet-stream',
  6956. 'distz' => 'application/octet-stream',
  6957. 'djv' => 'image/vnd.djvu',
  6958. 'djvu' => 'image/vnd.djvu',
  6959. 'dll' => 'application/x-msdownload',
  6960. 'dmg' => 'application/x-apple-diskimage',
  6961. 'dmp' => 'application/vnd.tcpdump.pcap',
  6962. 'dms' => 'application/octet-stream',
  6963. 'dna' => 'application/vnd.dna',
  6964. 'doc' => 'application/msword',
  6965. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  6966. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  6967. 'dot' => 'application/msword',
  6968. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  6969. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  6970. 'dp' => 'application/vnd.osgi.dp',
  6971. 'dpg' => 'application/vnd.dpgraph',
  6972. 'dra' => 'audio/vnd.dra',
  6973. 'dsc' => 'text/prs.lines.tag',
  6974. 'dssc' => 'application/dssc+der',
  6975. 'dtb' => 'application/x-dtbook+xml',
  6976. 'dtd' => 'application/xml-dtd',
  6977. 'dts' => 'audio/vnd.dts',
  6978. 'dtshd' => 'audio/vnd.dts.hd',
  6979. 'dump' => 'application/octet-stream',
  6980. 'dvb' => 'video/vnd.dvb.file',
  6981. 'dvi' => 'application/x-dvi',
  6982. 'dwf' => 'model/vnd.dwf',
  6983. 'dwg' => 'image/vnd.dwg',
  6984. 'dxf' => 'image/vnd.dxf',
  6985. 'dxp' => 'application/vnd.spotfire.dxp',
  6986. 'dxr' => 'application/x-director',
  6987. 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
  6988. 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
  6989. 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
  6990. 'ecma' => 'application/ecmascript',
  6991. 'edm' => 'application/vnd.novadigm.edm',
  6992. 'edx' => 'application/vnd.novadigm.edx',
  6993. 'efif' => 'application/vnd.picsel',
  6994. 'ei6' => 'application/vnd.pg.osasli',
  6995. 'elc' => 'application/octet-stream',
  6996. 'emf' => 'application/x-msmetafile',
  6997. 'eml' => 'message/rfc822',
  6998. 'emma' => 'application/emma+xml',
  6999. 'emz' => 'application/x-msmetafile',
  7000. 'eol' => 'audio/vnd.digital-winds',
  7001. 'eot' => 'application/vnd.ms-fontobject',
  7002. 'eps' => 'application/postscript',
  7003. 'epub' => 'application/epub+zip',
  7004. 'es3' => 'application/vnd.eszigno3+xml',
  7005. 'esa' => 'application/vnd.osgi.subsystem',
  7006. 'esf' => 'application/vnd.epson.esf',
  7007. 'et3' => 'application/vnd.eszigno3+xml',
  7008. 'etx' => 'text/x-setext',
  7009. 'eva' => 'application/x-eva',
  7010. 'evy' => 'application/x-envoy',
  7011. 'exe' => 'application/x-msdownload',
  7012. 'exi' => 'application/exi',
  7013. 'ext' => 'application/vnd.novadigm.ext',
  7014. 'ez' => 'application/andrew-inset',
  7015. 'ez2' => 'application/vnd.ezpix-album',
  7016. 'ez3' => 'application/vnd.ezpix-package',
  7017. 'f' => 'text/x-fortran',
  7018. 'f4v' => 'video/x-f4v',
  7019. 'f77' => 'text/x-fortran',
  7020. 'f90' => 'text/x-fortran',
  7021. 'fbs' => 'image/vnd.fastbidsheet',
  7022. 'fcdt' => 'application/vnd.adobe.formscentral.fcdt',
  7023. 'fcs' => 'application/vnd.isac.fcs',
  7024. 'fdf' => 'application/vnd.fdf',
  7025. 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
  7026. 'fg5' => 'application/vnd.fujitsu.oasysgp',
  7027. 'fgd' => 'application/x-director',
  7028. 'fh' => 'image/x-freehand',
  7029. 'fh4' => 'image/x-freehand',
  7030. 'fh5' => 'image/x-freehand',
  7031. 'fh7' => 'image/x-freehand',
  7032. 'fhc' => 'image/x-freehand',
  7033. 'fig' => 'application/x-xfig',
  7034. 'flac' => 'audio/x-flac',
  7035. 'fli' => 'video/x-fli',
  7036. 'flo' => 'application/vnd.micrografx.flo',
  7037. 'flv' => 'video/x-flv',
  7038. 'flw' => 'application/vnd.kde.kivio',
  7039. 'flx' => 'text/vnd.fmi.flexstor',
  7040. 'fly' => 'text/vnd.fly',
  7041. 'fm' => 'application/vnd.framemaker',
  7042. 'fnc' => 'application/vnd.frogans.fnc',
  7043. 'for' => 'text/x-fortran',
  7044. 'fpx' => 'image/vnd.fpx',
  7045. 'frame' => 'application/vnd.framemaker',
  7046. 'fsc' => 'application/vnd.fsc.weblaunch',
  7047. 'fst' => 'image/vnd.fst',
  7048. 'ftc' => 'application/vnd.fluxtime.clip',
  7049. 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
  7050. 'fvt' => 'video/vnd.fvt',
  7051. 'fxp' => 'application/vnd.adobe.fxp',
  7052. 'fxpl' => 'application/vnd.adobe.fxp',
  7053. 'fzs' => 'application/vnd.fuzzysheet',
  7054. 'g2w' => 'application/vnd.geoplan',
  7055. 'g3' => 'image/g3fax',
  7056. 'g3w' => 'application/vnd.geospace',
  7057. 'gac' => 'application/vnd.groove-account',
  7058. 'gam' => 'application/x-tads',
  7059. 'gbr' => 'application/rpki-ghostbusters',
  7060. 'gca' => 'application/x-gca-compressed',
  7061. 'gdl' => 'model/vnd.gdl',
  7062. 'geo' => 'application/vnd.dynageo',
  7063. 'gex' => 'application/vnd.geometry-explorer',
  7064. 'ggb' => 'application/vnd.geogebra.file',
  7065. 'ggt' => 'application/vnd.geogebra.tool',
  7066. 'ghf' => 'application/vnd.groove-help',
  7067. 'gif' => 'image/gif',
  7068. 'gim' => 'application/vnd.groove-identity-message',
  7069. 'gml' => 'application/gml+xml',
  7070. 'gmx' => 'application/vnd.gmx',
  7071. 'gnumeric' => 'application/x-gnumeric',
  7072. 'gph' => 'application/vnd.flographit',
  7073. 'gpx' => 'application/gpx+xml',
  7074. 'gqf' => 'application/vnd.grafeq',
  7075. 'gqs' => 'application/vnd.grafeq',
  7076. 'gram' => 'application/srgs',
  7077. 'gramps' => 'application/x-gramps-xml',
  7078. 'gre' => 'application/vnd.geometry-explorer',
  7079. 'grv' => 'application/vnd.groove-injector',
  7080. 'grxml' => 'application/srgs+xml',
  7081. 'gsf' => 'application/x-font-ghostscript',
  7082. 'gtar' => 'application/x-gtar',
  7083. 'gtm' => 'application/vnd.groove-tool-message',
  7084. 'gtw' => 'model/vnd.gtw',
  7085. 'gv' => 'text/vnd.graphviz',
  7086. 'gxf' => 'application/gxf',
  7087. 'gxt' => 'application/vnd.geonext',
  7088. 'h' => 'text/x-c',
  7089. 'h261' => 'video/h261',
  7090. 'h263' => 'video/h263',
  7091. 'h264' => 'video/h264',
  7092. 'hal' => 'application/vnd.hal+xml',
  7093. 'hbci' => 'application/vnd.hbci',
  7094. 'hdf' => 'application/x-hdf',
  7095. 'hh' => 'text/x-c',
  7096. 'hlp' => 'application/winhlp',
  7097. 'hpgl' => 'application/vnd.hp-hpgl',
  7098. 'hpid' => 'application/vnd.hp-hpid',
  7099. 'hps' => 'application/vnd.hp-hps',
  7100. 'hqx' => 'application/mac-binhex40',
  7101. 'htke' => 'application/vnd.kenameaapp',
  7102. 'htm' => 'text/html',
  7103. 'html' => 'text/html',
  7104. 'hvd' => 'application/vnd.yamaha.hv-dic',
  7105. 'hvp' => 'application/vnd.yamaha.hv-voice',
  7106. 'hvs' => 'application/vnd.yamaha.hv-script',
  7107. 'i2g' => 'application/vnd.intergeo',
  7108. 'icc' => 'application/vnd.iccprofile',
  7109. 'ice' => 'x-conference/x-cooltalk',
  7110. 'icm' => 'application/vnd.iccprofile',
  7111. 'ico' => 'image/x-icon',
  7112. 'ics' => 'text/calendar',
  7113. 'ief' => 'image/ief',
  7114. 'ifb' => 'text/calendar',
  7115. 'ifm' => 'application/vnd.shana.informed.formdata',
  7116. 'iges' => 'model/iges',
  7117. 'igl' => 'application/vnd.igloader',
  7118. 'igm' => 'application/vnd.insors.igm',
  7119. 'igs' => 'model/iges',
  7120. 'igx' => 'application/vnd.micrografx.igx',
  7121. 'iif' => 'application/vnd.shana.informed.interchange',
  7122. 'imp' => 'application/vnd.accpac.simply.imp',
  7123. 'ims' => 'application/vnd.ms-ims',
  7124. 'in' => 'text/plain',
  7125. 'ink' => 'application/inkml+xml',
  7126. 'inkml' => 'application/inkml+xml',
  7127. 'install' => 'application/x-install-instructions',
  7128. 'iota' => 'application/vnd.astraea-software.iota',
  7129. 'ipfix' => 'application/ipfix',
  7130. 'ipk' => 'application/vnd.shana.informed.package',
  7131. 'irm' => 'application/vnd.ibm.rights-management',
  7132. 'irp' => 'application/vnd.irepository.package+xml',
  7133. 'iso' => 'application/x-iso9660-image',
  7134. 'itp' => 'application/vnd.shana.informed.formtemplate',
  7135. 'ivp' => 'application/vnd.immervision-ivp',
  7136. 'ivu' => 'application/vnd.immervision-ivu',
  7137. 'jad' => 'text/vnd.sun.j2me.app-descriptor',
  7138. 'jam' => 'application/vnd.jam',
  7139. 'jar' => 'application/java-archive',
  7140. 'java' => 'text/x-java-source',
  7141. 'jisp' => 'application/vnd.jisp',
  7142. 'jlt' => 'application/vnd.hp-jlyt',
  7143. 'jnlp' => 'application/x-java-jnlp-file',
  7144. 'joda' => 'application/vnd.joost.joda-archive',
  7145. 'jpe' => 'image/jpeg',
  7146. 'jpeg' => 'image/jpeg',
  7147. 'jpg' => 'image/jpeg',
  7148. 'jpgm' => 'video/jpm',
  7149. 'jpgv' => 'video/jpeg',
  7150. 'jpm' => 'video/jpm',
  7151. 'js' => 'application/javascript',
  7152. 'json' => 'application/json',
  7153. 'jsonml' => 'application/jsonml+json',
  7154. 'kar' => 'audio/midi',
  7155. 'karbon' => 'application/vnd.kde.karbon',
  7156. 'kfo' => 'application/vnd.kde.kformula',
  7157. 'kia' => 'application/vnd.kidspiration',
  7158. 'kml' => 'application/vnd.google-earth.kml+xml',
  7159. 'kmz' => 'application/vnd.google-earth.kmz',
  7160. 'kne' => 'application/vnd.kinar',
  7161. 'knp' => 'application/vnd.kinar',
  7162. 'kon' => 'application/vnd.kde.kontour',
  7163. 'kpr' => 'application/vnd.kde.kpresenter',
  7164. 'kpt' => 'application/vnd.kde.kpresenter',
  7165. 'kpxx' => 'application/vnd.ds-keypoint',
  7166. 'ksp' => 'application/vnd.kde.kspread',
  7167. 'ktr' => 'application/vnd.kahootz',
  7168. 'ktx' => 'image/ktx',
  7169. 'ktz' => 'application/vnd.kahootz',
  7170. 'kwd' => 'application/vnd.kde.kword',
  7171. 'kwt' => 'application/vnd.kde.kword',
  7172. 'lasxml' => 'application/vnd.las.las+xml',
  7173. 'latex' => 'application/x-latex',
  7174. 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  7175. 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  7176. 'les' => 'application/vnd.hhe.lesson-player',
  7177. 'lha' => 'application/x-lzh-compressed',
  7178. 'link66' => 'application/vnd.route66.link66+xml',
  7179. 'list' => 'text/plain',
  7180. 'list3820' => 'application/vnd.ibm.modcap',
  7181. 'listafp' => 'application/vnd.ibm.modcap',
  7182. 'lnk' => 'application/x-ms-shortcut',
  7183. 'log' => 'text/plain',
  7184. 'lostxml' => 'application/lost+xml',
  7185. 'lrf' => 'application/octet-stream',
  7186. 'lrm' => 'application/vnd.ms-lrm',
  7187. 'ltf' => 'application/vnd.frogans.ltf',
  7188. 'lvp' => 'audio/vnd.lucent.voice',
  7189. 'lwp' => 'application/vnd.lotus-wordpro',
  7190. 'lzh' => 'application/x-lzh-compressed',
  7191. 'm13' => 'application/x-msmediaview',
  7192. 'm14' => 'application/x-msmediaview',
  7193. 'm1v' => 'video/mpeg',
  7194. 'm21' => 'application/mp21',
  7195. 'm2a' => 'audio/mpeg',
  7196. 'm2v' => 'video/mpeg',
  7197. 'm3a' => 'audio/mpeg',
  7198. 'm3u' => 'audio/x-mpegurl',
  7199. 'm3u8' => 'application/vnd.apple.mpegurl',
  7200. 'm4a' => 'audio/mp4',
  7201. 'm4u' => 'video/vnd.mpegurl',
  7202. 'm4v' => 'video/x-m4v',
  7203. 'ma' => 'application/mathematica',
  7204. 'mads' => 'application/mads+xml',
  7205. 'mag' => 'application/vnd.ecowin.chart',
  7206. 'maker' => 'application/vnd.framemaker',
  7207. 'man' => 'text/troff',
  7208. 'mar' => 'application/octet-stream',
  7209. 'mathml' => 'application/mathml+xml',
  7210. 'mb' => 'application/mathematica',
  7211. 'mbk' => 'application/vnd.mobius.mbk',
  7212. 'mbox' => 'application/mbox',
  7213. 'mc1' => 'application/vnd.medcalcdata',
  7214. 'mcd' => 'application/vnd.mcd',
  7215. 'mcurl' => 'text/vnd.curl.mcurl',
  7216. 'mdb' => 'application/x-msaccess',
  7217. 'mdi' => 'image/vnd.ms-modi',
  7218. 'me' => 'text/troff',
  7219. 'mesh' => 'model/mesh',
  7220. 'meta4' => 'application/metalink4+xml',
  7221. 'metalink' => 'application/metalink+xml',
  7222. 'mets' => 'application/mets+xml',
  7223. 'mfm' => 'application/vnd.mfmp',
  7224. 'mft' => 'application/rpki-manifest',
  7225. 'mgp' => 'application/vnd.osgeo.mapguide.package',
  7226. 'mgz' => 'application/vnd.proteus.magazine',
  7227. 'mid' => 'audio/midi',
  7228. 'midi' => 'audio/midi',
  7229. 'mie' => 'application/x-mie',
  7230. 'mif' => 'application/vnd.mif',
  7231. 'mime' => 'message/rfc822',
  7232. 'mj2' => 'video/mj2',
  7233. 'mjp2' => 'video/mj2',
  7234. 'mk3d' => 'video/x-matroska',
  7235. 'mka' => 'audio/x-matroska',
  7236. 'mks' => 'video/x-matroska',
  7237. 'mkv' => 'video/x-matroska',
  7238. 'mlp' => 'application/vnd.dolby.mlp',
  7239. 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
  7240. 'mmf' => 'application/vnd.smaf',
  7241. 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
  7242. 'mng' => 'video/x-mng',
  7243. 'mny' => 'application/x-msmoney',
  7244. 'mobi' => 'application/x-mobipocket-ebook',
  7245. 'mods' => 'application/mods+xml',
  7246. 'mov' => 'video/quicktime',
  7247. 'movie' => 'video/x-sgi-movie',
  7248. 'mp2' => 'audio/mpeg',
  7249. 'mp21' => 'application/mp21',
  7250. 'mp2a' => 'audio/mpeg',
  7251. 'mp3' => 'audio/mpeg',
  7252. 'mp4' => 'video/mp4',
  7253. 'mp4a' => 'audio/mp4',
  7254. 'mp4s' => 'application/mp4',
  7255. 'mp4v' => 'video/mp4',
  7256. 'mpc' => 'application/vnd.mophun.certificate',
  7257. 'mpe' => 'video/mpeg',
  7258. 'mpeg' => 'video/mpeg',
  7259. 'mpg' => 'video/mpeg',
  7260. 'mpg4' => 'video/mp4',
  7261. 'mpga' => 'audio/mpeg',
  7262. 'mpkg' => 'application/vnd.apple.installer+xml',
  7263. 'mpm' => 'application/vnd.blueice.multipass',
  7264. 'mpn' => 'application/vnd.mophun.application',
  7265. 'mpp' => 'application/vnd.ms-project',
  7266. 'mpt' => 'application/vnd.ms-project',
  7267. 'mpy' => 'application/vnd.ibm.minipay',
  7268. 'mqy' => 'application/vnd.mobius.mqy',
  7269. 'mrc' => 'application/marc',
  7270. 'mrcx' => 'application/marcxml+xml',
  7271. 'ms' => 'text/troff',
  7272. 'mscml' => 'application/mediaservercontrol+xml',
  7273. 'mseed' => 'application/vnd.fdsn.mseed',
  7274. 'mseq' => 'application/vnd.mseq',
  7275. 'msf' => 'application/vnd.epson.msf',
  7276. 'msh' => 'model/mesh',
  7277. 'msi' => 'application/x-msdownload',
  7278. 'msl' => 'application/vnd.mobius.msl',
  7279. 'msty' => 'application/vnd.muvee.style',
  7280. 'mts' => 'model/vnd.mts',
  7281. 'mus' => 'application/vnd.musician',
  7282. 'musicxml' => 'application/vnd.recordare.musicxml+xml',
  7283. 'mvb' => 'application/x-msmediaview',
  7284. 'mwf' => 'application/vnd.mfer',
  7285. 'mxf' => 'application/mxf',
  7286. 'mxl' => 'application/vnd.recordare.musicxml',
  7287. 'mxml' => 'application/xv+xml',
  7288. 'mxs' => 'application/vnd.triscape.mxs',
  7289. 'mxu' => 'video/vnd.mpegurl',
  7290. 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  7291. 'n3' => 'text/n3',
  7292. 'nb' => 'application/mathematica',
  7293. 'nbp' => 'application/vnd.wolfram.player',
  7294. 'nc' => 'application/x-netcdf',
  7295. 'ncx' => 'application/x-dtbncx+xml',
  7296. 'nfo' => 'text/x-nfo',
  7297. 'ngdat' => 'application/vnd.nokia.n-gage.data',
  7298. 'nitf' => 'application/vnd.nitf',
  7299. 'nlu' => 'application/vnd.neurolanguage.nlu',
  7300. 'nml' => 'application/vnd.enliven',
  7301. 'nnd' => 'application/vnd.noblenet-directory',
  7302. 'nns' => 'application/vnd.noblenet-sealer',
  7303. 'nnw' => 'application/vnd.noblenet-web',
  7304. 'npx' => 'image/vnd.net-fpx',
  7305. 'nsc' => 'application/x-conference',
  7306. 'nsf' => 'application/vnd.lotus-notes',
  7307. 'ntf' => 'application/vnd.nitf',
  7308. 'nzb' => 'application/x-nzb',
  7309. 'oa2' => 'application/vnd.fujitsu.oasys2',
  7310. 'oa3' => 'application/vnd.fujitsu.oasys3',
  7311. 'oas' => 'application/vnd.fujitsu.oasys',
  7312. 'obd' => 'application/x-msbinder',
  7313. 'obj' => 'application/x-tgif',
  7314. 'oda' => 'application/oda',
  7315. 'odb' => 'application/vnd.oasis.opendocument.database',
  7316. 'odc' => 'application/vnd.oasis.opendocument.chart',
  7317. 'odf' => 'application/vnd.oasis.opendocument.formula',
  7318. 'odft' => 'application/vnd.oasis.opendocument.formula-template',
  7319. 'odg' => 'application/vnd.oasis.opendocument.graphics',
  7320. 'odi' => 'application/vnd.oasis.opendocument.image',
  7321. 'odm' => 'application/vnd.oasis.opendocument.text-master',
  7322. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  7323. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  7324. 'odt' => 'application/vnd.oasis.opendocument.text',
  7325. 'oga' => 'audio/ogg',
  7326. 'ogg' => 'audio/ogg',
  7327. 'ogv' => 'video/ogg',
  7328. 'ogx' => 'application/ogg',
  7329. 'omdoc' => 'application/omdoc+xml',
  7330. 'onepkg' => 'application/onenote',
  7331. 'onetmp' => 'application/onenote',
  7332. 'onetoc' => 'application/onenote',
  7333. 'onetoc2' => 'application/onenote',
  7334. 'opf' => 'application/oebps-package+xml',
  7335. 'opml' => 'text/x-opml',
  7336. 'oprc' => 'application/vnd.palm',
  7337. 'org' => 'application/vnd.lotus-organizer',
  7338. 'osf' => 'application/vnd.yamaha.openscoreformat',
  7339. 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  7340. 'otc' => 'application/vnd.oasis.opendocument.chart-template',
  7341. 'otf' => 'application/x-font-otf',
  7342. 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
  7343. 'oth' => 'application/vnd.oasis.opendocument.text-web',
  7344. 'oti' => 'application/vnd.oasis.opendocument.image-template',
  7345. 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
  7346. 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  7347. 'ott' => 'application/vnd.oasis.opendocument.text-template',
  7348. 'oxps' => 'application/oxps',
  7349. 'oxt' => 'application/vnd.openofficeorg.extension',
  7350. 'p' => 'text/x-pascal',
  7351. 'p10' => 'application/pkcs10',
  7352. 'p12' => 'application/x-pkcs12',
  7353. 'p7b' => 'application/x-pkcs7-certificates',
  7354. 'p7c' => 'application/pkcs7-mime',
  7355. 'p7m' => 'application/pkcs7-mime',
  7356. 'p7r' => 'application/x-pkcs7-certreqresp',
  7357. 'p7s' => 'application/pkcs7-signature',
  7358. 'p8' => 'application/pkcs8',
  7359. 'pas' => 'text/x-pascal',
  7360. 'paw' => 'application/vnd.pawaafile',
  7361. 'pbd' => 'application/vnd.powerbuilder6',
  7362. 'pbm' => 'image/x-portable-bitmap',
  7363. 'pcap' => 'application/vnd.tcpdump.pcap',
  7364. 'pcf' => 'application/x-font-pcf',
  7365. 'pcl' => 'application/vnd.hp-pcl',
  7366. 'pclxl' => 'application/vnd.hp-pclxl',
  7367. 'pct' => 'image/x-pict',
  7368. 'pcurl' => 'application/vnd.curl.pcurl',
  7369. 'pcx' => 'image/x-pcx',
  7370. 'pdb' => 'application/vnd.palm',
  7371. 'pdf' => 'application/pdf',
  7372. 'pfa' => 'application/x-font-type1',
  7373. 'pfb' => 'application/x-font-type1',
  7374. 'pfm' => 'application/x-font-type1',
  7375. 'pfr' => 'application/font-tdpfr',
  7376. 'pfx' => 'application/x-pkcs12',
  7377. 'pgm' => 'image/x-portable-graymap',
  7378. 'pgn' => 'application/x-chess-pgn',
  7379. 'pgp' => 'application/pgp-encrypted',
  7380. 'pic' => 'image/x-pict',
  7381. 'pkg' => 'application/octet-stream',
  7382. 'pki' => 'application/pkixcmp',
  7383. 'pkipath' => 'application/pkix-pkipath',
  7384. 'plb' => 'application/vnd.3gpp.pic-bw-large',
  7385. 'plc' => 'application/vnd.mobius.plc',
  7386. 'plf' => 'application/vnd.pocketlearn',
  7387. 'pls' => 'application/pls+xml',
  7388. 'pml' => 'application/vnd.ctc-posml',
  7389. 'png' => 'image/png',
  7390. 'pnm' => 'image/x-portable-anymap',
  7391. 'portpkg' => 'application/vnd.macports.portpkg',
  7392. 'pot' => 'application/vnd.ms-powerpoint',
  7393. 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
  7394. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  7395. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  7396. 'ppd' => 'application/vnd.cups-ppd',
  7397. 'ppm' => 'image/x-portable-pixmap',
  7398. 'pps' => 'application/vnd.ms-powerpoint',
  7399. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  7400. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  7401. 'ppt' => 'application/vnd.ms-powerpoint',
  7402. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  7403. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  7404. 'pqa' => 'application/vnd.palm',
  7405. 'prc' => 'application/x-mobipocket-ebook',
  7406. 'pre' => 'application/vnd.lotus-freelance',
  7407. 'prf' => 'application/pics-rules',
  7408. 'ps' => 'application/postscript',
  7409. 'psb' => 'application/vnd.3gpp.pic-bw-small',
  7410. 'psd' => 'image/vnd.adobe.photoshop',
  7411. 'psf' => 'application/x-font-linux-psf',
  7412. 'pskcxml' => 'application/pskc+xml',
  7413. 'ptid' => 'application/vnd.pvi.ptid1',
  7414. 'pub' => 'application/x-mspublisher',
  7415. 'pvb' => 'application/vnd.3gpp.pic-bw-var',
  7416. 'pwn' => 'application/vnd.3m.post-it-notes',
  7417. 'pya' => 'audio/vnd.ms-playready.media.pya',
  7418. 'pyv' => 'video/vnd.ms-playready.media.pyv',
  7419. 'qam' => 'application/vnd.epson.quickanime',
  7420. 'qbo' => 'application/vnd.intu.qbo',
  7421. 'qfx' => 'application/vnd.intu.qfx',
  7422. 'qps' => 'application/vnd.publishare-delta-tree',
  7423. 'qt' => 'video/quicktime',
  7424. 'qwd' => 'application/vnd.quark.quarkxpress',
  7425. 'qwt' => 'application/vnd.quark.quarkxpress',
  7426. 'qxb' => 'application/vnd.quark.quarkxpress',
  7427. 'qxd' => 'application/vnd.quark.quarkxpress',
  7428. 'qxl' => 'application/vnd.quark.quarkxpress',
  7429. 'qxt' => 'application/vnd.quark.quarkxpress',
  7430. 'ra' => 'audio/x-pn-realaudio',
  7431. 'ram' => 'audio/x-pn-realaudio',
  7432. 'rar' => 'application/x-rar-compressed',
  7433. 'ras' => 'image/x-cmu-raster',
  7434. 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
  7435. 'rdf' => 'application/rdf+xml',
  7436. 'rdz' => 'application/vnd.data-vision.rdz',
  7437. 'rep' => 'application/vnd.businessobjects',
  7438. 'res' => 'application/x-dtbresource+xml',
  7439. 'rgb' => 'image/x-rgb',
  7440. 'rif' => 'application/reginfo+xml',
  7441. 'rip' => 'audio/vnd.rip',
  7442. 'ris' => 'application/x-research-info-systems',
  7443. 'rl' => 'application/resource-lists+xml',
  7444. 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
  7445. 'rld' => 'application/resource-lists-diff+xml',
  7446. 'rm' => 'application/vnd.rn-realmedia',
  7447. 'rmi' => 'audio/midi',
  7448. 'rmp' => 'audio/x-pn-realaudio-plugin',
  7449. 'rms' => 'application/vnd.jcp.javame.midlet-rms',
  7450. 'rmvb' => 'application/vnd.rn-realmedia-vbr',
  7451. 'rnc' => 'application/relax-ng-compact-syntax',
  7452. 'roa' => 'application/rpki-roa',
  7453. 'roff' => 'text/troff',
  7454. 'rp9' => 'application/vnd.cloanto.rp9',
  7455. 'rpss' => 'application/vnd.nokia.radio-presets',
  7456. 'rpst' => 'application/vnd.nokia.radio-preset',
  7457. 'rq' => 'application/sparql-query',
  7458. 'rs' => 'application/rls-services+xml',
  7459. 'rsd' => 'application/rsd+xml',
  7460. 'rss' => 'application/rss+xml',
  7461. 'rtf' => 'application/rtf',
  7462. 'rtx' => 'text/richtext',
  7463. 's' => 'text/x-asm',
  7464. 's3m' => 'audio/s3m',
  7465. 'saf' => 'application/vnd.yamaha.smaf-audio',
  7466. 'sbml' => 'application/sbml+xml',
  7467. 'sc' => 'application/vnd.ibm.secure-container',
  7468. 'scd' => 'application/x-msschedule',
  7469. 'scm' => 'application/vnd.lotus-screencam',
  7470. 'scq' => 'application/scvp-cv-request',
  7471. 'scs' => 'application/scvp-cv-response',
  7472. 'scurl' => 'text/vnd.curl.scurl',
  7473. 'sda' => 'application/vnd.stardivision.draw',
  7474. 'sdc' => 'application/vnd.stardivision.calc',
  7475. 'sdd' => 'application/vnd.stardivision.impress',
  7476. 'sdkd' => 'application/vnd.solent.sdkm+xml',
  7477. 'sdkm' => 'application/vnd.solent.sdkm+xml',
  7478. 'sdp' => 'application/sdp',
  7479. 'sdw' => 'application/vnd.stardivision.writer',
  7480. 'see' => 'application/vnd.seemail',
  7481. 'seed' => 'application/vnd.fdsn.seed',
  7482. 'sema' => 'application/vnd.sema',
  7483. 'semd' => 'application/vnd.semd',
  7484. 'semf' => 'application/vnd.semf',
  7485. 'ser' => 'application/java-serialized-object',
  7486. 'setpay' => 'application/set-payment-initiation',
  7487. 'setreg' => 'application/set-registration-initiation',
  7488. 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
  7489. 'sfs' => 'application/vnd.spotfire.sfs',
  7490. 'sfv' => 'text/x-sfv',
  7491. 'sgi' => 'image/sgi',
  7492. 'sgl' => 'application/vnd.stardivision.writer-global',
  7493. 'sgm' => 'text/sgml',
  7494. 'sgml' => 'text/sgml',
  7495. 'sh' => 'application/x-sh',
  7496. 'shar' => 'application/x-shar',
  7497. 'shf' => 'application/shf+xml',
  7498. 'sid' => 'image/x-mrsid-image',
  7499. 'sig' => 'application/pgp-signature',
  7500. 'sil' => 'audio/silk',
  7501. 'silo' => 'model/mesh',
  7502. 'sis' => 'application/vnd.symbian.install',
  7503. 'sisx' => 'application/vnd.symbian.install',
  7504. 'sit' => 'application/x-stuffit',
  7505. 'sitx' => 'application/x-stuffitx',
  7506. 'skd' => 'application/vnd.koan',
  7507. 'skm' => 'application/vnd.koan',
  7508. 'skp' => 'application/vnd.koan',
  7509. 'skt' => 'application/vnd.koan',
  7510. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  7511. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  7512. 'slt' => 'application/vnd.epson.salt',
  7513. 'sm' => 'application/vnd.stepmania.stepchart',
  7514. 'smf' => 'application/vnd.stardivision.math',
  7515. 'smi' => 'application/smil+xml',
  7516. 'smil' => 'application/smil+xml',
  7517. 'smv' => 'video/x-smv',
  7518. 'smzip' => 'application/vnd.stepmania.package',
  7519. 'snd' => 'audio/basic',
  7520. 'snf' => 'application/x-font-snf',
  7521. 'so' => 'application/octet-stream',
  7522. 'spc' => 'application/x-pkcs7-certificates',
  7523. 'spf' => 'application/vnd.yamaha.smaf-phrase',
  7524. 'spl' => 'application/x-futuresplash',
  7525. 'spot' => 'text/vnd.in3d.spot',
  7526. 'spp' => 'application/scvp-vp-response',
  7527. 'spq' => 'application/scvp-vp-request',
  7528. 'spx' => 'audio/ogg',
  7529. 'sql' => 'application/x-sql',
  7530. 'src' => 'application/x-wais-source',
  7531. 'srt' => 'application/x-subrip',
  7532. 'sru' => 'application/sru+xml',
  7533. 'srx' => 'application/sparql-results+xml',
  7534. 'ssdl' => 'application/ssdl+xml',
  7535. 'sse' => 'application/vnd.kodak-descriptor',
  7536. 'ssf' => 'application/vnd.epson.ssf',
  7537. 'ssml' => 'application/ssml+xml',
  7538. 'st' => 'application/vnd.sailingtracker.track',
  7539. 'stc' => 'application/vnd.sun.xml.calc.template',
  7540. 'std' => 'application/vnd.sun.xml.draw.template',
  7541. 'stf' => 'application/vnd.wt.stf',
  7542. 'sti' => 'application/vnd.sun.xml.impress.template',
  7543. 'stk' => 'application/hyperstudio',
  7544. 'stl' => 'application/vnd.ms-pki.stl',
  7545. 'str' => 'application/vnd.pg.format',
  7546. 'stw' => 'application/vnd.sun.xml.writer.template',
  7547. 'sub' => 'image/vnd.dvb.subtitle',
  7548. 'sub' => 'text/vnd.dvb.subtitle',
  7549. 'sus' => 'application/vnd.sus-calendar',
  7550. 'susp' => 'application/vnd.sus-calendar',
  7551. 'sv4cpio' => 'application/x-sv4cpio',
  7552. 'sv4crc' => 'application/x-sv4crc',
  7553. 'svc' => 'application/vnd.dvb.service',
  7554. 'svd' => 'application/vnd.svd',
  7555. 'svg' => 'image/svg+xml',
  7556. 'svgz' => 'image/svg+xml',
  7557. 'swa' => 'application/x-director',
  7558. 'swf' => 'application/x-shockwave-flash',
  7559. 'swi' => 'application/vnd.aristanetworks.swi',
  7560. 'sxc' => 'application/vnd.sun.xml.calc',
  7561. 'sxd' => 'application/vnd.sun.xml.draw',
  7562. 'sxg' => 'application/vnd.sun.xml.writer.global',
  7563. 'sxi' => 'application/vnd.sun.xml.impress',
  7564. 'sxm' => 'application/vnd.sun.xml.math',
  7565. 'sxw' => 'application/vnd.sun.xml.writer',
  7566. 't' => 'text/troff',
  7567. 't3' => 'application/x-t3vm-image',
  7568. 'taglet' => 'application/vnd.mynfc',
  7569. 'tao' => 'application/vnd.tao.intent-module-archive',
  7570. 'tar' => 'application/x-tar',
  7571. 'tcap' => 'application/vnd.3gpp2.tcap',
  7572. 'tcl' => 'application/x-tcl',
  7573. 'teacher' => 'application/vnd.smart.teacher',
  7574. 'tei' => 'application/tei+xml',
  7575. 'teicorpus' => 'application/tei+xml',
  7576. 'tex' => 'application/x-tex',
  7577. 'texi' => 'application/x-texinfo',
  7578. 'texinfo' => 'application/x-texinfo',
  7579. 'text' => 'text/plain',
  7580. 'tfi' => 'application/thraud+xml',
  7581. 'tfm' => 'application/x-tex-tfm',
  7582. 'tga' => 'image/x-tga',
  7583. 'thmx' => 'application/vnd.ms-officetheme',
  7584. 'tif' => 'image/tiff',
  7585. 'tiff' => 'image/tiff',
  7586. 'tmo' => 'application/vnd.tmobile-livetv',
  7587. 'torrent' => 'application/x-bittorrent',
  7588. 'tpl' => 'application/vnd.groove-tool-template',
  7589. 'tpt' => 'application/vnd.trid.tpt',
  7590. 'tr' => 'text/troff',
  7591. 'tra' => 'application/vnd.trueapp',
  7592. 'trm' => 'application/x-msterminal',
  7593. 'tsd' => 'application/timestamped-data',
  7594. 'tsv' => 'text/tab-separated-values',
  7595. 'ttc' => 'application/x-font-ttf',
  7596. 'ttf' => 'application/x-font-ttf',
  7597. 'ttl' => 'text/turtle',
  7598. 'twd' => 'application/vnd.simtech-mindmapper',
  7599. 'twds' => 'application/vnd.simtech-mindmapper',
  7600. 'txd' => 'application/vnd.genomatix.tuxedo',
  7601. 'txf' => 'application/vnd.mobius.txf',
  7602. 'txt' => 'text/plain',
  7603. 'u32' => 'application/x-authorware-bin',
  7604. 'udeb' => 'application/x-debian-package',
  7605. 'ufd' => 'application/vnd.ufdl',
  7606. 'ufdl' => 'application/vnd.ufdl',
  7607. 'ulx' => 'application/x-glulx',
  7608. 'umj' => 'application/vnd.umajin',
  7609. 'unityweb' => 'application/vnd.unity',
  7610. 'uoml' => 'application/vnd.uoml+xml',
  7611. 'uri' => 'text/uri-list',
  7612. 'uris' => 'text/uri-list',
  7613. 'urls' => 'text/uri-list',
  7614. 'ustar' => 'application/x-ustar',
  7615. 'utz' => 'application/vnd.uiq.theme',
  7616. 'uu' => 'text/x-uuencode',
  7617. 'uva' => 'audio/vnd.dece.audio',
  7618. 'uvd' => 'application/vnd.dece.data',
  7619. 'uvf' => 'application/vnd.dece.data',
  7620. 'uvg' => 'image/vnd.dece.graphic',
  7621. 'uvh' => 'video/vnd.dece.hd',
  7622. 'uvi' => 'image/vnd.dece.graphic',
  7623. 'uvm' => 'video/vnd.dece.mobile',
  7624. 'uvp' => 'video/vnd.dece.pd',
  7625. 'uvs' => 'video/vnd.dece.sd',
  7626. 'uvt' => 'application/vnd.dece.ttml+xml',
  7627. 'uvu' => 'video/vnd.uvvu.mp4',
  7628. 'uvv' => 'video/vnd.dece.video',
  7629. 'uvva' => 'audio/vnd.dece.audio',
  7630. 'uvvd' => 'application/vnd.dece.data',
  7631. 'uvvf' => 'application/vnd.dece.data',
  7632. 'uvvg' => 'image/vnd.dece.graphic',
  7633. 'uvvh' => 'video/vnd.dece.hd',
  7634. 'uvvi' => 'image/vnd.dece.graphic',
  7635. 'uvvm' => 'video/vnd.dece.mobile',
  7636. 'uvvp' => 'video/vnd.dece.pd',
  7637. 'uvvs' => 'video/vnd.dece.sd',
  7638. 'uvvt' => 'application/vnd.dece.ttml+xml',
  7639. 'uvvu' => 'video/vnd.uvvu.mp4',
  7640. 'uvvv' => 'video/vnd.dece.video',
  7641. 'uvvx' => 'application/vnd.dece.unspecified',
  7642. 'uvvz' => 'application/vnd.dece.zip',
  7643. 'uvx' => 'application/vnd.dece.unspecified',
  7644. 'uvz' => 'application/vnd.dece.zip',
  7645. 'vcard' => 'text/vcard',
  7646. 'vcd' => 'application/x-cdlink',
  7647. 'vcf' => 'text/x-vcard',
  7648. 'vcg' => 'application/vnd.groove-vcard',
  7649. 'vcs' => 'text/x-vcalendar',
  7650. 'vcx' => 'application/vnd.vcx',
  7651. 'vis' => 'application/vnd.visionary',
  7652. 'viv' => 'video/vnd.vivo',
  7653. 'vob' => 'video/x-ms-vob',
  7654. 'vor' => 'application/vnd.stardivision.writer',
  7655. 'vox' => 'application/x-authorware-bin',
  7656. 'vrml' => 'model/vrml',
  7657. 'vsd' => 'application/vnd.visio',
  7658. 'vsf' => 'application/vnd.vsf',
  7659. 'vss' => 'application/vnd.visio',
  7660. 'vst' => 'application/vnd.visio',
  7661. 'vsw' => 'application/vnd.visio',
  7662. 'vtu' => 'model/vnd.vtu',
  7663. 'vxml' => 'application/voicexml+xml',
  7664. 'w3d' => 'application/x-director',
  7665. 'wad' => 'application/x-doom',
  7666. 'wav' => 'audio/x-wav',
  7667. 'wax' => 'audio/x-ms-wax',
  7668. 'wbmp' => 'image/vnd.wap.wbmp',
  7669. 'wbs' => 'application/vnd.criticaltools.wbs+xml',
  7670. 'wbxml' => 'application/vnd.wap.wbxml',
  7671. 'wcm' => 'application/vnd.ms-works',
  7672. 'wdb' => 'application/vnd.ms-works',
  7673. 'wdp' => 'image/vnd.ms-photo',
  7674. 'weba' => 'audio/webm',
  7675. 'webm' => 'video/webm',
  7676. 'webp' => 'image/webp',
  7677. 'wg' => 'application/vnd.pmi.widget',
  7678. 'wgt' => 'application/widget',
  7679. 'wks' => 'application/vnd.ms-works',
  7680. 'wm' => 'video/x-ms-wm',
  7681. 'wma' => 'audio/x-ms-wma',
  7682. 'wmd' => 'application/x-ms-wmd',
  7683. 'wmf' => 'application/x-msmetafile',
  7684. 'wml' => 'text/vnd.wap.wml',
  7685. 'wmlc' => 'application/vnd.wap.wmlc',
  7686. 'wmls' => 'text/vnd.wap.wmlscript',
  7687. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  7688. 'wmv' => 'video/x-ms-wmv',
  7689. 'wmx' => 'video/x-ms-wmx',
  7690. 'wmz' => 'application/x-ms-wmz',
  7691. 'wmz' => 'application/x-msmetafile',
  7692. 'woff' => 'application/font-woff',
  7693. 'wpd' => 'application/vnd.wordperfect',
  7694. 'wpl' => 'application/vnd.ms-wpl',
  7695. 'wps' => 'application/vnd.ms-works',
  7696. 'wqd' => 'application/vnd.wqd',
  7697. 'wri' => 'application/x-mswrite',
  7698. 'wrl' => 'model/vrml',
  7699. 'wsdl' => 'application/wsdl+xml',
  7700. 'wspolicy' => 'application/wspolicy+xml',
  7701. 'wtb' => 'application/vnd.webturbo',
  7702. 'wvx' => 'video/x-ms-wvx',
  7703. 'x32' => 'application/x-authorware-bin',
  7704. 'x3d' => 'model/x3d+xml',
  7705. 'x3db' => 'model/x3d+binary',
  7706. 'x3dbz' => 'model/x3d+binary',
  7707. 'x3dv' => 'model/x3d+vrml',
  7708. 'x3dvz' => 'model/x3d+vrml',
  7709. 'x3dz' => 'model/x3d+xml',
  7710. 'xaml' => 'application/xaml+xml',
  7711. 'xap' => 'application/x-silverlight-app',
  7712. 'xar' => 'application/vnd.xara',
  7713. 'xbap' => 'application/x-ms-xbap',
  7714. 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
  7715. 'xbm' => 'image/x-xbitmap',
  7716. 'xdf' => 'application/xcap-diff+xml',
  7717. 'xdm' => 'application/vnd.syncml.dm+xml',
  7718. 'xdp' => 'application/vnd.adobe.xdp+xml',
  7719. 'xdssc' => 'application/dssc+xml',
  7720. 'xdw' => 'application/vnd.fujixerox.docuworks',
  7721. 'xenc' => 'application/xenc+xml',
  7722. 'xer' => 'application/patch-ops-error+xml',
  7723. 'xfdf' => 'application/vnd.adobe.xfdf',
  7724. 'xfdl' => 'application/vnd.xfdl',
  7725. 'xht' => 'application/xhtml+xml',
  7726. 'xhtml' => 'application/xhtml+xml',
  7727. 'xhvml' => 'application/xv+xml',
  7728. 'xif' => 'image/vnd.xiff',
  7729. 'xla' => 'application/vnd.ms-excel',
  7730. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  7731. 'xlc' => 'application/vnd.ms-excel',
  7732. 'xlf' => 'application/x-xliff+xml',
  7733. 'xlm' => 'application/vnd.ms-excel',
  7734. 'xls' => 'application/vnd.ms-excel',
  7735. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  7736. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  7737. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  7738. 'xlt' => 'application/vnd.ms-excel',
  7739. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  7740. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  7741. 'xlw' => 'application/vnd.ms-excel',
  7742. 'xm' => 'audio/xm',
  7743. 'xml' => 'application/xml',
  7744. 'xo' => 'application/vnd.olpc-sugar',
  7745. 'xop' => 'application/xop+xml',
  7746. 'xpi' => 'application/x-xpinstall',
  7747. 'xpl' => 'application/xproc+xml',
  7748. 'xpm' => 'image/x-xpixmap',
  7749. 'xpr' => 'application/vnd.is-xpr',
  7750. 'xps' => 'application/vnd.ms-xpsdocument',
  7751. 'xpw' => 'application/vnd.intercon.formnet',
  7752. 'xpx' => 'application/vnd.intercon.formnet',
  7753. 'xsl' => 'application/xml',
  7754. 'xslt' => 'application/xslt+xml',
  7755. 'xsm' => 'application/vnd.syncml+xml',
  7756. 'xspf' => 'application/xspf+xml',
  7757. 'xul' => 'application/vnd.mozilla.xul+xml',
  7758. 'xvm' => 'application/xv+xml',
  7759. 'xvml' => 'application/xv+xml',
  7760. 'xwd' => 'image/x-xwindowdump',
  7761. 'xyz' => 'chemical/x-xyz',
  7762. 'xz' => 'application/x-xz',
  7763. 'yang' => 'application/yang',
  7764. 'yin' => 'application/yin+xml',
  7765. 'z1' => 'application/x-zmachine',
  7766. 'z2' => 'application/x-zmachine',
  7767. 'z3' => 'application/x-zmachine',
  7768. 'z4' => 'application/x-zmachine',
  7769. 'z5' => 'application/x-zmachine',
  7770. 'z6' => 'application/x-zmachine',
  7771. 'z7' => 'application/x-zmachine',
  7772. 'z8' => 'application/x-zmachine',
  7773. 'zaz' => 'application/vnd.zzazz.deck+xml',
  7774. 'zip' => 'application/zip',
  7775. 'zir' => 'application/vnd.zul',
  7776. 'zirz' => 'application/vnd.zul',
  7777. 'zmm' => 'application/vnd.handheld-entertainment+xml'
  7778. );
  7779. }
  7780. // Always run this
  7781. if(strpos($_SERVER['SCRIPT_NAME'], 'check.php') == false){
  7782. dependCheck();
  7783. }