functions.php 356 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679
  1. <?php
  2. // ===================================
  3. // Define Version
  4. define('INSTALLEDVERSION', '1.61');
  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. "homepageOrdernoticeguest" => homepageOrdernoticeguest,
  27. "homepageOrdertransmisson" => homepageOrdertransmisson,
  28. );
  29. asort($homepageOrder);
  30. return $homepageOrder;
  31. }
  32. // Debugging output functions
  33. function debug_out($variable, $die = false) {
  34. $trace = debug_backtrace()[0];
  35. echo "<center><img height='200px' src='images/confused.png'></center>";
  36. echo "<center>Look's like something happened, here are the errors and perhaps how to fix them:</center>";
  37. 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>';
  38. if ($die) { http_response_code(503); die(); }
  39. }
  40. //Cookie Function
  41. function coookie($type, $name, $value = '', $days = -1, $http = true){
  42. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  43. $Secure = true;
  44. $HTTPOnly = true;
  45. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  46. $Secure = true;
  47. $HTTPOnly = true;
  48. } else {
  49. $Secure = false;
  50. $HTTPOnly = false;
  51. }
  52. if(!$http){ $HTTPOnly = false; }
  53. $Path = '/';
  54. $Domain = $_SERVER['HTTP_HOST'];
  55. $Port = strpos($Domain, ':');
  56. if ($Port !== false) $Domain = substr($Domain, 0, $Port);
  57. $Port = strpos($Domain, ':');
  58. $check = substr_count($Domain, '.');
  59. if($check >= 3){
  60. if(is_numeric($Domain[0])){
  61. $Domain = '';
  62. }else{
  63. $Domain = '.'.explode('.',$Domain)[1].'.'.explode('.',$Domain)[2].'.'.explode('.',$Domain)[3];
  64. }
  65. }elseif($check == 2){
  66. $Domain = '.'.explode('.',$Domain)[1].'.'.explode('.',$Domain)[2];
  67. }elseif($check == 1){
  68. $Domain = '.' . $Domain;
  69. }else{
  70. $Domain = '';
  71. }
  72. if($type = 'set'){
  73. $_COOKIE[$name] = $value;
  74. header('Set-Cookie: ' . rawurlencode($name) . '=' . rawurlencode($value)
  75. . (empty($days) ? '' : '; expires=' . gmdate('D, d-M-Y H:i:s', time() + (86400 * $days)) . ' GMT')
  76. . (empty($Path) ? '' : '; path=' . $Path)
  77. . (empty($Domain) ? '' : '; domain=' . $Domain)
  78. . (!$Secure ? '' : '; secure')
  79. . (!$HTTPOnly ? '' : '; HttpOnly'), false);
  80. }elseif($type = 'delete'){
  81. unset($_COOKIE[$name]);
  82. header('Set-Cookie: ' . rawurlencode($name) . '=' . rawurlencode($value)
  83. . (empty($days) ? '' : '; expires=' . gmdate('D, d-M-Y H:i:s', time() - 3600) . ' GMT')
  84. . (empty($Path) ? '' : '; path=' . $Path)
  85. . (empty($Domain) ? '' : '; domain=' . $Domain)
  86. . (!$Secure ? '' : '; secure')
  87. . (!$HTTPOnly ? '' : '; HttpOnly'), false);
  88. }
  89. }
  90. // ==== Auth Plugins START ====
  91. if (function_exists('ldap_connect')) :
  92. // Pass credentials to LDAP backend
  93. function plugin_auth_ldap($username, $password) {
  94. $ldapServers = explode(',',AUTHBACKENDHOST);
  95. foreach($ldapServers as $key => $value) {
  96. // Calculate parts
  97. $digest = parse_url(trim($value));
  98. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:'ldap'));
  99. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  100. $port = (isset($digest['port'])?$digest['port']:(strtolower($scheme)=='ldap'?389:636));
  101. // Reassign
  102. $ldapServers[$key] = $scheme.'://'.$host.':'.$port;
  103. }
  104. // returns true or false
  105. $ldap = ldap_connect(implode(' ',$ldapServers));
  106. if(empty(AUTHBACKENDDOMAINFORMAT)){
  107. if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
  108. writeLog("success", "LDAP authentication success");
  109. return true;
  110. } else {
  111. writeLog("error", "LDAP could not authenticate");
  112. return false;
  113. }
  114. }else{
  115. ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
  116. ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
  117. $bind = @ldap_bind($ldap, sprintf(AUTHBACKENDDOMAINFORMAT, $username), $password);
  118. if ($bind) {
  119. writeLog("success", "LDAP authentication success");
  120. return true;
  121. } else {
  122. writeLog("error", "LDPA could not authenticate");
  123. return false;
  124. }
  125. }
  126. writeLog("error", "LDAP could not authenticate");
  127. return false;
  128. }
  129. else :
  130. // Ldap Auth Missing Dependancy
  131. function plugin_auth_ldap_disabled() {
  132. return 'LDAP - Disabled (Dependancy: php-ldap missing!)';
  133. }
  134. endif;
  135. // Pass credentials to FTP backend
  136. function plugin_auth_ftp($username, $password) {
  137. // Calculate parts
  138. $digest = parse_url(AUTHBACKENDHOST);
  139. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:(function_exists('ftp_ssl_connect')?'ftps':'ftp')));
  140. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  141. $port = (isset($digest['port'])?$digest['port']:21);
  142. // Determine Connection Type
  143. if ($scheme == 'ftps') {
  144. $conn_id = ftp_ssl_connect($host, $port, 20);
  145. } elseif ($scheme == 'ftp') {
  146. $conn_id = ftp_connect($host, $port, 20);
  147. } else {
  148. debug_out('Invalid FTP scheme. Use ftp or ftps');
  149. writeLog("error", "invalid FTP scheme");
  150. return false;
  151. }
  152. // Check if valid FTP connection
  153. if ($conn_id) {
  154. // Attempt login
  155. @$login_result = ftp_login($conn_id, $username, $password);
  156. ftp_close($conn_id);
  157. // Return Result
  158. if ($login_result) {
  159. writeLog("success", "$username authenticated");
  160. return true;
  161. } else {
  162. writeLog("error", "$username could not authenticate");
  163. return false;
  164. }
  165. } else {
  166. return false;
  167. }
  168. return false;
  169. }
  170. // Pass credentials to Emby Backend
  171. function plugin_auth_emby_local($username, $password) {
  172. $embyAddress = qualifyURL(EMBYURL);
  173. $headers = array(
  174. 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"',
  175. 'Content-Type' => 'application/json',
  176. );
  177. $body = array(
  178. 'Username' => $username,
  179. 'Password' => sha1($password),
  180. 'PasswordMd5' => md5($password),
  181. );
  182. $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers);
  183. if (isset($response['content'])) {
  184. $json = json_decode($response['content'], true);
  185. if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
  186. // Login Success - Now Logout Emby Session As We No Longer Need It
  187. $headers = array(
  188. 'X-Mediabrowser-Token' => $json['AccessToken'],
  189. );
  190. $response = post_router($embyAddress.'/Sessions/Logout', array(), $headers);
  191. return true;
  192. }
  193. }
  194. return false;
  195. }
  196. if (function_exists('curl_version')) :
  197. // Authenticate Against Emby Local (first) and Emby Connect
  198. function plugin_auth_emby_all($username, $password) {
  199. $localResult = plugin_auth_emby_local($username, $password);
  200. if ($localResult) {
  201. return $localResult;
  202. } else {
  203. return plugin_auth_emby_connect($username, $password);
  204. }
  205. }
  206. // Authenicate against emby connect
  207. function plugin_auth_emby_connect($username, $password) {
  208. $embyAddress = qualifyURL(EMBYURL);
  209. // Get A User
  210. $connectId = '';
  211. $userIds = json_decode(@file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
  212. if (is_array($userIds)) {
  213. foreach ($userIds as $key => $value) { // Scan for this user
  214. if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
  215. if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
  216. $connectId = $value['ConnectUserId'];
  217. break;
  218. }
  219. }
  220. }
  221. if ($connectId) {
  222. $connectURL = 'https://connect.emby.media/service/user/authenticate';
  223. $headers = array(
  224. 'Accept'=> 'application/json',
  225. 'Content-Type' => 'application/x-www-form-urlencoded',
  226. );
  227. $body = array(
  228. 'nameOrEmail' => $username,
  229. 'rawpw' => $password,
  230. );
  231. $result = curl_post($connectURL, $body, $headers);
  232. if (isset($result['content'])) {
  233. $json = json_decode($result['content'], true);
  234. if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
  235. return array(
  236. 'email' => $json['User']['Email'],
  237. 'image' => $json['User']['ImageUrl'],
  238. );
  239. }
  240. }
  241. }
  242. }
  243. return false;
  244. }
  245. // Pass credentials to Plex Backend
  246. function plugin_auth_plex($username, $password) {
  247. // Quick out
  248. $isAdmin = false;
  249. if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
  250. writeLog("success", "Admin: ".$username." authenticated as plex Admin");
  251. $isAdmin = true;
  252. }
  253. //Get User List
  254. $userURL = 'https://plex.tv/pms/friends/all';
  255. $userHeaders = array(
  256. 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD),
  257. );
  258. libxml_use_internal_errors(true);
  259. $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
  260. if (is_array($userXML) || is_object($userXML)) {
  261. $isUser = false;
  262. $usernameLower = strtolower($username);
  263. foreach($userXML AS $child) {
  264. if(isset($child['username']) && strtolower($child['username']) == $usernameLower || isset($child['email']) && strtolower($child['email']) == $usernameLower) {
  265. $isUser = true;
  266. writeLog("success", $usernameLower." was found in plex friends list");
  267. break;
  268. }
  269. }
  270. if ($isUser || $isAdmin) {
  271. //Login User
  272. $connectURL = 'https://plex.tv/users/sign_in.json';
  273. $headers = array(
  274. 'Accept'=> 'application/json',
  275. 'Content-Type' => 'application/x-www-form-urlencoded',
  276. 'X-Plex-Product' => 'Organizr',
  277. 'X-Plex-Version' => '1.0',
  278. 'X-Plex-Client-Identifier' => '01010101-10101010',
  279. );
  280. $body = array(
  281. 'user[login]' => $username,
  282. 'user[password]' => $password,
  283. );
  284. $result = curl_post($connectURL, $body, $headers);
  285. if (isset($result['content'])) {
  286. $json = json_decode($result['content'], true);
  287. if ((is_array($json) && isset($json['user']) && isset($json['user']['username'])) && strtolower($json['user']['username']) == $usernameLower || strtolower($json['user']['email']) == $usernameLower) {
  288. writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
  289. return array(
  290. 'email' => $json['user']['email'],
  291. 'image' => $json['user']['thumb'],
  292. 'token' => $json['user']['authToken'],
  293. 'type' => $isAdmin ? 'admin' : 'user',
  294. );
  295. }
  296. }else{
  297. writeLog("error", "error occured while trying to sign $username into plex");
  298. }
  299. }else{
  300. writeLog("error", "$username is not an authorized PLEX user or entered invalid password");
  301. }
  302. }else{
  303. writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");
  304. }
  305. return false;
  306. }
  307. else :
  308. // Plex Auth Missing Dependancy
  309. function plugin_auth_plex_disabled() {
  310. return 'Plex - Disabled (Dependancy: php-curl missing!)';
  311. }
  312. // Emby Connect Auth Missing Dependancy
  313. function plugin_auth_emby_connect_disabled() {
  314. return 'Emby Connect - Disabled (Dependancy: php-curl missing!)';
  315. }
  316. // Emby Both Auth Missing Dependancy
  317. function plugin_auth_emby_both_disabled() {
  318. return 'Emby Both - Disabled (Dependancy: php-curl missing!)';
  319. }
  320. endif;
  321. // ==== Auth Plugins END ====
  322. // ==== General Class Definitions START ====
  323. $userLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  324. class setLanguage {
  325. private $language = null;
  326. private $langCode = null;
  327. function __construct($language = false) {
  328. // Default
  329. if (!$language) {
  330. $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  331. }
  332. if (!file_exists("lang/{$language}.ini")) {
  333. $language = 'en';
  334. }
  335. $this->langCode = $language;
  336. $this->language = parse_ini_file("lang/{$language}.ini", false, INI_SCANNER_RAW);
  337. if (file_exists("lang/{$language}.cust.ini")) {
  338. foreach($tmp = parse_ini_file("lang/{$language}.cust.ini", false, INI_SCANNER_RAW) as $k => $v) {
  339. $this->language[$k] = $v;
  340. }
  341. }
  342. }
  343. public function getLang() {
  344. return $this->langCode;
  345. }
  346. public function translate($originalWord) {
  347. $getArg = func_num_args();
  348. if ($getArg > 1) {
  349. $allWords = func_get_args();
  350. array_shift($allWords);
  351. } else {
  352. $allWords = array();
  353. }
  354. $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null;
  355. if (!$translatedWord) {
  356. return ucwords(str_replace("_", " ", strtolower($originalWord)));
  357. //echo "WHOA!!!!!!! $originalWord";
  358. }
  359. $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES);
  360. return vsprintf($translatedWord, $allWords);
  361. }
  362. }
  363. $language = new setLanguage;
  364. // ==== General Class Definitions END ====
  365. // Direct request to curl if it exists, otherwise handle if not HTTPS
  366. function post_router($url, $data, $headers = array(), $referer='') {
  367. if (function_exists('curl_version')) {
  368. return curl_post($url, $data, $headers, $referer);
  369. } else {
  370. return post_request($url, $data, $headers, $referer);
  371. }
  372. }
  373. if (function_exists('curl_version')) :
  374. // Curl Post
  375. function curl_post($url, $data, $headers = array(), $referer='') {
  376. // Initiate cURL
  377. $curlReq = curl_init($url);
  378. // As post request
  379. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST");
  380. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  381. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  382. if(localURL($url)){
  383. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  384. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  385. }
  386. // Format Data
  387. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  388. case 'application/json':
  389. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  390. break;
  391. case 'application/x-www-form-urlencoded':
  392. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  393. break;
  394. default:
  395. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  396. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  397. }
  398. // Format Headers
  399. $cHeaders = array();
  400. foreach ($headers as $k => $v) {
  401. $cHeaders[] = $k.': '.$v;
  402. }
  403. if (count($cHeaders)) {
  404. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  405. }
  406. // Execute
  407. $result = curl_exec($curlReq);
  408. $httpcode = curl_getinfo($curlReq);
  409. // Close
  410. curl_close($curlReq);
  411. // Return
  412. return array('content'=>$result, 'http_code'=>$httpcode);
  413. }
  414. // Curl Put
  415. function curl_put($url, $data, $headers = array(), $referer='') {
  416. // Initiate cURL
  417. $curlReq = curl_init($url);
  418. // As post request
  419. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "PUT");
  420. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  421. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  422. if(localURL($url)){
  423. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  424. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  425. }
  426. // Format Data
  427. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  428. case 'application/json':
  429. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  430. break;
  431. case 'application/x-www-form-urlencoded':
  432. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  433. break;
  434. default:
  435. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  436. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  437. }
  438. // Format Headers
  439. $cHeaders = array();
  440. foreach ($headers as $k => $v) {
  441. $cHeaders[] = $k.': '.$v;
  442. }
  443. if (count($cHeaders)) {
  444. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  445. }
  446. // Execute
  447. $result = curl_exec($curlReq);
  448. $httpcode = curl_getinfo($curlReq);
  449. // Close
  450. curl_close($curlReq);
  451. // Return
  452. return array('content'=>$result, 'http_code'=>$httpcode);
  453. }
  454. //Curl Get Function
  455. function curl_get($url, $headers = array()) {
  456. // Initiate cURL
  457. $curlReq = curl_init($url);
  458. // As post request
  459. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET");
  460. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  461. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  462. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  463. if(localURL($url)){
  464. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  465. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  466. }
  467. // Format Headers
  468. $cHeaders = array();
  469. foreach ($headers as $k => $v) {
  470. $cHeaders[] = $k.': '.$v;
  471. }
  472. if (count($cHeaders)) {
  473. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  474. }
  475. // Execute
  476. $result = curl_exec($curlReq);
  477. // Close
  478. curl_close($curlReq);
  479. // Return
  480. return $result;
  481. }
  482. //Curl Delete Function
  483. function curl_delete($url, $headers = array()) {
  484. // Initiate cURL
  485. $curlReq = curl_init($url);
  486. // As post request
  487. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE");
  488. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  489. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  490. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  491. if(localURL($url)){
  492. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  493. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  494. }
  495. // Format Headers
  496. $cHeaders = array();
  497. foreach ($headers as $k => $v) {
  498. $cHeaders[] = $k.': '.$v;
  499. }
  500. if (count($cHeaders)) {
  501. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  502. }
  503. // Execute
  504. $result = curl_exec($curlReq);
  505. $httpcode = curl_getinfo($curlReq);
  506. // Close
  507. curl_close($curlReq);
  508. // Return
  509. return array('content'=>$result, 'http_code'=>$httpcode);
  510. }
  511. endif;
  512. //Case-Insensitive Function
  513. function in_arrayi($needle, $haystack) {
  514. return in_array(strtolower($needle), array_map('strtolower', $haystack));
  515. }
  516. // HTTP post request (Removes need for curl, probably useless)
  517. function post_request($url, $data, $headers = array(), $referer='') {
  518. // Adapted from http://stackoverflow.com/a/28387011/6810513
  519. // Convert the data array into URL Parameters like a=b&foo=bar etc.
  520. if (isset($headers['Content-Type'])) {
  521. switch ($headers['Content-Type']) {
  522. case 'application/json':
  523. $data = json_encode($data);
  524. break;
  525. case 'application/x-www-form-urlencoded':
  526. $data = http_build_query($data);
  527. break;
  528. }
  529. } else {
  530. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  531. $data = http_build_query($data);
  532. }
  533. // parse the given URL
  534. $urlDigest = parse_url($url);
  535. // extract host and path:
  536. $host = $urlDigest['host'];
  537. $path = $urlDigest['path'];
  538. if ($urlDigest['scheme'] != 'http') {
  539. die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')');
  540. }
  541. // open a socket connection on port 80 - timeout: 30 sec
  542. $fp = fsockopen($host, (isset($urlDigest['port'])?':'.$urlDigest['port']:80), $errno, $errstr, 30);
  543. if ($fp){
  544. // send the request headers:
  545. fputs($fp, "POST $path HTTP/1.1\r\n");
  546. fputs($fp, "Host: $host\r\n");
  547. if ($referer != '')
  548. fputs($fp, "Referer: $referer\r\n");
  549. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  550. foreach($headers as $k => $v) {
  551. fputs($fp, $k.": ".$v."\r\n");
  552. }
  553. fputs($fp, "Connection: close\r\n\r\n");
  554. fputs($fp, $data);
  555. $result = '';
  556. while(!feof($fp)) {
  557. // receive the results of the request
  558. $result .= fgets($fp, 128);
  559. }
  560. }
  561. else {
  562. return array(
  563. 'status' => 'err',
  564. 'error' => "$errstr ($errno)"
  565. );
  566. }
  567. // close the socket connection:
  568. fclose($fp);
  569. // split the result header from the content
  570. $result = explode("\r\n\r\n", $result, 2);
  571. $header = isset($result[0]) ? $result[0] : '';
  572. $content = isset($result[1]) ? $result[1] : '';
  573. // return as structured array:
  574. return array(
  575. 'status' => 'ok',
  576. 'header' => $header,
  577. 'content' => $content,
  578. );
  579. }
  580. // Format item from Emby for Carousel
  581. function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $moreInfo = false) {
  582. // Static Height
  583. $height = 444;
  584. // Get Item Details
  585. $itemDetails = json_decode(@file_get_contents($address.'/Items?Ids='.$item['Id'].'&api_key='.$token),true)['Items'][0];
  586. /*if (substr_count(EMBYURL, ':') == 2) {
  587. $URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  588. }else{
  589. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  590. }*/
  591. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  592. switch ($itemDetails['Type']) {
  593. case 'Episode':
  594. case 'Series':
  595. $title = (isset($itemDetails['SeriesName'])?$itemDetails['SeriesName']:"");
  596. $imageId = (isset($itemDetails['SeriesId'])?$itemDetails['SeriesId']:$itemDetails['Id']);
  597. $width = 300;
  598. $style = '';
  599. $image = 'slick-image-tall';
  600. if(!$nowPlaying){
  601. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  602. $key = $itemDetails['Id'] . "-list";
  603. $itemType = 'season';
  604. }else{
  605. $height = 281;
  606. $width = 500;
  607. $imageId = isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId'] : (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  608. $imageType = isset($itemDetails['ParentThumbItemId']) ? "Thumb" : (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  609. $key = (isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId']."-np" : "none-np");
  610. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  611. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  612. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  613. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  614. $stream = $moreInfo['PlayState']['PlayMethod'];
  615. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  616. $id = $moreInfo['DeviceId'];
  617. $streamInfo = buildStream(array(
  618. 'platform' => (string) $moreInfo['Client'],
  619. 'device' => (string) $moreInfo['DeviceName'],
  620. 'stream' => streamType($stream),
  621. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  622. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  623. ));
  624. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  625. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$itemDetails['Name'].'</h5>';
  626. $bottomTitle = '<small class="zero-m">S'.$itemDetails['ParentIndexNumber'].' · E'.$itemDetails['IndexNumber'].'</small>';
  627. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  628. }
  629. break;
  630. case 'MusicAlbum':
  631. case 'Audio':
  632. $title = $itemDetails['Name'];
  633. $imageId = $itemDetails['Id'];
  634. $width = 444;
  635. $style = '';
  636. $image = 'slick-image-short';
  637. if(!$nowPlaying){
  638. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  639. $key = $itemDetails['Id'] . "-list";
  640. $itemType = 'album';
  641. }else{
  642. $height = 281;
  643. $width = 500;
  644. $imageId = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  645. $imageType = (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  646. $key = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : "no-np") . "-np";
  647. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  648. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  649. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  650. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  651. $stream = $moreInfo['PlayState']['PlayMethod'];
  652. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  653. $id = $moreInfo['DeviceId'];
  654. $streamInfo = buildStream(array(
  655. 'platform' => (string) $moreInfo['Client'],
  656. 'device' => (string) $moreInfo['DeviceName'],
  657. 'stream' => streamType($stream),
  658. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  659. ));
  660. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  661. $topTitle = '<h5 class="text-center zero-m elip">'.$itemDetails['AlbumArtist'].' - '.$itemDetails['Album'].'</h5>';
  662. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  663. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  664. }
  665. break;
  666. case 'TvChannel':
  667. $title = $itemDetails['CurrentProgram']['Name'];
  668. $imageId = $itemDetails['Id'];
  669. $width = 300;
  670. $style = '';
  671. $image = 'slick-image-tall';
  672. if(!$nowPlaying){
  673. $imageType = "Primary";
  674. $key = $itemDetails['Id'] . "-list";
  675. }else{
  676. $height = 281;
  677. $width = 500;
  678. $imageType = "Thumb";
  679. $key = $itemDetails['Id'] . "-np";
  680. $useImage = "images/livetv.png";
  681. $watched = "0";
  682. $stream = $moreInfo['PlayState']['PlayMethod'];
  683. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  684. $id = $moreInfo['DeviceId'];
  685. $streamInfo = buildStream(array(
  686. 'platform' => (string) $moreInfo['Client'],
  687. 'device' => (string) $moreInfo['DeviceName'],
  688. 'stream' => streamType($stream),
  689. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  690. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  691. ));
  692. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  693. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  694. $bottomTitle = '<small class="zero-m">'.$itemDetails['Name'].' - '.$itemDetails['ChannelNumber'].'</small>';
  695. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  696. }
  697. break;
  698. default:
  699. $title = $itemDetails['Name'];
  700. $imageId = $itemDetails['Id'];
  701. $width = 300;
  702. $style = '';
  703. $image = 'slick-image-tall';
  704. if(!$nowPlaying){
  705. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  706. $key = $itemDetails['Id'] . "-list";
  707. $itemType = 'movie';
  708. }else{
  709. $height = 281;
  710. $width = 500;
  711. $imageType = isset($itemDetails['ImageTags']['Thumb']) ? "Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
  712. $key = $itemDetails['Id'] . "-np";
  713. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  714. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  715. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  716. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  717. $stream = $moreInfo['PlayState']['PlayMethod'];
  718. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  719. $id = $moreInfo['DeviceId'];
  720. $streamInfo = buildStream(array(
  721. 'platform' => (string) $moreInfo['Client'],
  722. 'device' => (string) $moreInfo['DeviceName'],
  723. 'stream' => streamType($stream),
  724. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  725. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  726. ));
  727. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  728. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  729. $bottomTitle = '<small class="zero-m">'.$moreInfo['NowPlayingItem']['ProductionYear'].'</small>';
  730. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  731. }
  732. }
  733. // If No Overview
  734. if (!isset($itemDetails['Overview'])) {
  735. $itemDetails['Overview'] = '';
  736. }
  737. $original_image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  738. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  739. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  740. $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'';
  741. }
  742. if($nowPlaying){
  743. if(!$imageType){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  744. if(!$imageId){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  745. }else{
  746. if(!$imageType){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  747. if(!$imageId){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  748. }
  749. if(isset($useImage)){ $image_url = $useImage; }
  750. // Assemble Item And Cache Into Array
  751. if($nowPlaying){
  752. //prettyPrint($itemDetails);
  753. 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>';
  754. }else{
  755. 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>';
  756. }
  757. }
  758. // Format item from Plex for Carousel
  759. function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $playlist = false) {
  760. // Static Height
  761. $height = 444;
  762. $widthOverride = 100;
  763. $playlist = ($playlist) ? " playlist-$playlist" : "";
  764. switch ($item['type']) {
  765. case 'season':
  766. $title = $item['parentTitle'];
  767. $summary = $item['parentSummary'];
  768. $width = 300;
  769. $image = 'slick-image-tall';
  770. $style = '';
  771. if(!$nowPlaying){
  772. $thumb = $item['thumb'];
  773. $key = $item['ratingKey'] . "-list";
  774. }else {
  775. $height = 281;
  776. $width = 500;
  777. $thumb = $item['art'];
  778. $key = $item['ratingKey'] . "-np";
  779. $elapsed = $item['viewOffset'];
  780. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  781. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  782. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  783. $stream = $item->Media->Part->Stream['decision'];
  784. $user = $role == "admin" ? $item->User['title'] : "";
  785. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  786. $streamInfo = buildStream(array(
  787. 'platform' => (string) $item->Player['platform'],
  788. 'device' => (string) $item->Player['device'],
  789. 'stream' => streamType($item->Media->Part['decision']),
  790. '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'].")",
  791. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  792. ));
  793. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  794. }
  795. break;
  796. case 'episode':
  797. $title = $item['grandparentTitle'];
  798. $summary = $item['title'];
  799. $width = 300;
  800. $image = 'slick-image-tall';
  801. $style = '';
  802. if(!$nowPlaying){
  803. $thumb = ($item['parentThumb'] ? $item['parentThumb'] : $item['grandparentThumb']);
  804. $key = $item['ratingKey'] . "-list";
  805. }else {
  806. $height = 281;
  807. $width = 500;
  808. $thumb = $item['art'];
  809. $key = $item['ratingKey'] . "-np";
  810. $elapsed = $item['viewOffset'];
  811. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  812. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  813. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  814. $stream = $item->Media->Part->Stream['decision'];
  815. $user = $role == "admin" ? $item->User['title'] : "";
  816. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  817. $streamInfo = buildStream(array(
  818. 'platform' => (string) $item->Player['platform'],
  819. 'device' => (string) $item->Player['device'],
  820. 'stream' => streamType($item->Media->Part['decision']),
  821. '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'].")",
  822. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  823. ));
  824. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  825. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$item['title'].'</h5>';
  826. $bottomTitle = '<small class="zero-m">S'.$item['parentIndex'].' · E'.$item['index'].'</small>';
  827. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  828. }
  829. break;
  830. case 'clip':
  831. $title = $item['title'];
  832. $summary = $item['summary'];
  833. $width = 300;
  834. $image = 'slick-image-tall';
  835. $style = '';
  836. if(!$nowPlaying){
  837. $thumb = $item['thumb'];
  838. $key = $item['ratingKey'] . "-list";
  839. }else {
  840. $height = 281;
  841. $width = 500;
  842. $thumb = $item['art'];
  843. $key = isset($item['ratingKey']) ? $item['ratingKey'] . "-np" : (isset($item['live']) ? "livetv.png" : ":)");
  844. $useImage = (isset($item['live']) ? "images/livetv.png" : null);
  845. $extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
  846. $elapsed = $item['viewOffset'];
  847. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  848. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  849. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  850. $stream = $item->Media->Part->Stream['decision'];
  851. $user = $role == "admin" ? $item->User['title'] : "";
  852. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  853. $streamInfo = buildStream(array(
  854. 'platform' => (string) $item->Player['platform'],
  855. 'device' => (string) $item->Player['device'],
  856. 'stream' => streamType($item->Media->Part['decision']),
  857. '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'].")",
  858. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  859. ));
  860. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  861. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  862. $bottomTitle = '<small class="zero-m">'.$extraInfo.'</small>';
  863. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  864. }
  865. break;
  866. case 'album':
  867. case 'track':
  868. $title = $item['parentTitle'];
  869. $summary = $item['title'];
  870. $image = 'slick-image-short';
  871. $style = 'left: 160px !important;';
  872. $item['ratingKey'] = $item['parentRatingKey'];
  873. if(!$nowPlaying){
  874. $width = 444;
  875. $thumb = $item['thumb'];
  876. $key = $item['ratingKey'] . "-list";
  877. }else {
  878. $height = 281;
  879. $width = 500;
  880. $thumb = ($item['art']) ? $item['art'] : $item['parentThumb'];
  881. $widthOverride = ($item['art']) ? 100 : 56;
  882. $key = $item['ratingKey'] . "-np";
  883. $elapsed = $item['viewOffset'];
  884. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  885. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  886. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  887. $stream = $item->Media->Part->Stream['decision'];
  888. $user = $role == "admin" ? $item->User['title'] : "";
  889. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  890. $streamInfo = buildStream(array(
  891. 'platform' => (string) $item->Player['platform'],
  892. 'device' => (string) $item->Player['device'],
  893. 'stream' => streamType($item->Media->Part['decision']),
  894. 'audio' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['channels']."ch)",
  895. ));
  896. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  897. $topTitle = '<h5 class="text-center zero-m elip">'.$item['grandparentTitle'].' - '.$item['title'].'</h5>';
  898. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  899. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  900. }
  901. break;
  902. default:
  903. $title = $item['title'];
  904. $summary = $item['summary'];
  905. $image = 'slick-image-tall';
  906. $style = '';
  907. if(!$nowPlaying){
  908. $width = 300;
  909. $thumb = $item['thumb'];
  910. $key = $item['ratingKey'] . "-list";
  911. }else {
  912. $height = 281;
  913. $width = 500;
  914. $thumb = $item['art'];
  915. $key = $item['ratingKey'] . "-np";
  916. $elapsed = $item['viewOffset'];
  917. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  918. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  919. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  920. $stream = $item->Media->Part->Stream['decision'];
  921. $user = $role == "admin" ? $item->User['title'] : "";
  922. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  923. $streamInfo = buildStream(array(
  924. 'platform' => (string) $item->Player['platform'],
  925. 'device' => (string) $item->Player['device'],
  926. 'stream' => streamType($item->Media->Part['decision']),
  927. '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'].")",
  928. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  929. ));
  930. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  931. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  932. $bottomTitle = '<small class="zero-m">'.$item['year'].'</small>';
  933. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  934. }
  935. }
  936. if (PLEXTABURL) {
  937. $address = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  938. }else{
  939. $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  940. }
  941. // If No Overview
  942. if (!isset($itemDetails['Overview'])) { $itemDetails['Overview'] = ''; }
  943. $original_image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  944. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  945. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  946. $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'';
  947. }
  948. if($nowPlaying){
  949. if(!$thumb){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  950. }else{
  951. if(!$thumb){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  952. }
  953. if(isset($useImage)){ $image_url = $useImage; }
  954. $openTab = (PLEXTABNAME) ? "true" : "false";
  955. // Assemble Item And Cache Into Array
  956. if($nowPlaying){
  957. 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>';
  958. }else{
  959. 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>';
  960. }
  961. }
  962. //$hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  963. //Recent Added
  964. function outputRecentAdded($header, $items, $script = false, $array, $type) {
  965. $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">';
  966. if(preg_grep("/item-movie/", $items)){
  967. $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>';
  968. }
  969. if(preg_grep("/item-season/", $items)){
  970. $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>';
  971. }
  972. if(preg_grep("/item-album/", $items)){
  973. $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>';
  974. }
  975. $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>';
  976. $hideMenu .= '</ul></div></div>';
  977. // If None Populate Empty Item
  978. if (!count($items)) {
  979. 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>';
  980. }else{
  981. $className = str_replace(' ', '', $header.' on '.$type);
  982. 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>':'');
  983. }
  984. }
  985. // Create Carousel
  986. function outputNowPlaying($header, $size, $type, $items, $script = false) {
  987. // If None Populate Empty Item
  988. if (!count($items)) {
  989. return '<div id="'.$type.'"></div>'.($script?'<script>'.$script.'</script>':'');
  990. }else{
  991. return '<div id="'.$type.'"><h5 class="zero-m big-box"><strong>'.$header.'</strong></h5>'.implode('',$items).'</div>'.($script?'<script>'.$script.'</script>':'');
  992. }
  993. }
  994. // Get Now Playing Streams From Emby
  995. function getEmbyStreams($size, $showNames, $role) {
  996. $address = qualifyURL(EMBYURL);
  997. $api = json_decode(@file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
  998. if (!is_array($api)) { return 'Could not load!'; }
  999. $playingItems = array();
  1000. foreach($api as $key => $value) {
  1001. if (isset($value['NowPlayingItem'])) {
  1002. $playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem'], true, $showNames, $role, $value);
  1003. }
  1004. }
  1005. return outputNowPlaying(translate('PLAYING_NOW_ON_EMBY')." ( ".count($playingItems)." Streams )", $size, 'streams-emby', $playingItems, ajaxLoop('emby-streams',NOWPLAYINGREFRESH));
  1006. }
  1007. // Get Now Playing Streams From Plex
  1008. function getPlexStreams($size, $showNames, $role){
  1009. $address = qualifyURL(PLEXURL);
  1010. // Perform API requests
  1011. $api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
  1012. libxml_use_internal_errors(true);
  1013. $api = simplexml_load_string($api);
  1014. if (is_array($api) || is_object($api)){
  1015. if (!$api->head->title){
  1016. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  1017. if (!$getServer) { return 'Could not load!'; }
  1018. // Identify the local machine
  1019. $gotServer = $getServer['machineIdentifier'];
  1020. $items = array();
  1021. foreach($api AS $child) {
  1022. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
  1023. }
  1024. return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." ( ".count($items)." Streams )", $size, 'streams-plex', $items, ajaxLoop('plex-streams',NOWPLAYINGREFRESH));
  1025. }else{
  1026. writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
  1027. }
  1028. }else{
  1029. writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
  1030. }
  1031. }
  1032. // Get Recent Content From Emby
  1033. function getEmbyRecent($array) {
  1034. $address = qualifyURL(EMBYURL);
  1035. $header = translate('RECENT_CONTENT');
  1036. // Currently Logged In User
  1037. $username = false;
  1038. if (isset($GLOBALS['USER'])) {
  1039. $username = strtolower($GLOBALS['USER']->username);
  1040. }
  1041. // Get A User
  1042. $userIds = json_decode(@file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
  1043. if (!is_array($userIds)) { return 'Could not load!'; }
  1044. $showPlayed = true;
  1045. foreach ($userIds as $value) { // Scan for admin user
  1046. if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
  1047. $userId = $value['Id'];
  1048. }
  1049. if ($username && strtolower($value['Name']) == $username) {
  1050. $userId = $value['Id'];
  1051. $showPlayed = false;
  1052. break;
  1053. }
  1054. }
  1055. // Get the latest Items
  1056. $latest = json_decode(@file_get_contents($address.'/Users/'.$userId.'/Items/Latest?EnableImages=false&Limit='.EMBYRECENTITEMS.'&api_key='.EMBYTOKEN.($showPlayed?'':'&IsPlayed=false')),true);
  1057. // For Each Item In Category
  1058. $items = array();
  1059. foreach ($latest as $k => $v) {
  1060. $type = (string) $v['Type'];
  1061. if(@$array[$type] == "true"){
  1062. $items[] = resolveEmbyItem($address, EMBYTOKEN, $v, false, false, false);
  1063. }
  1064. }
  1065. $array["movie"] = $array["Movie"];
  1066. $array["season"] = $array["Episode"];
  1067. $array["album"] = $array["MusicAlbum"];
  1068. unset($array["Movie"]);
  1069. unset($array["Episode"]);
  1070. unset($array["MusicAlbum"]);
  1071. unset($array["Series"]);
  1072. return outputRecentAdded($header, $items, ajaxLoop('emby-recent',RECENTREFRESH,'loadSlick();'), $array, 'Emby');
  1073. }
  1074. // Get Recent Content From Plex
  1075. function getPlexRecent($array){
  1076. $address = qualifyURL(PLEXURL);
  1077. $header = translate('RECENT_CONTENT');
  1078. // Perform Requests
  1079. $api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN);
  1080. libxml_use_internal_errors(true);
  1081. $api = simplexml_load_string($api);
  1082. if (is_array($api) || is_object($api)){
  1083. if (!$api->head->title){
  1084. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  1085. if (!$getServer) { return 'Could not load!'; }
  1086. // Identify the local machine
  1087. $gotServer = $getServer['machineIdentifier'];
  1088. $items = array();
  1089. foreach($api AS $child) {
  1090. $type = (string) $child['type'];
  1091. if($array[$type] == "true"){
  1092. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
  1093. }
  1094. }
  1095. return outputRecentAdded($header, $items, ajaxLoop('plex-recent',RECENTREFRESH,'loadSlick();'), $array, 'Plex');
  1096. }else{
  1097. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check token - if HTTPS, is cert valid");
  1098. }
  1099. }else{
  1100. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check URL - if HTTPS, is cert valid");
  1101. }
  1102. }
  1103. // Get Image From Emby
  1104. function getEmbyImage() {
  1105. $refresh = false;
  1106. $embyAddress = qualifyURL(EMBYURL);
  1107. if (!file_exists('images/cache')) {
  1108. mkdir('images/cache', 0777, true);
  1109. }
  1110. $itemId = $_GET['img'];
  1111. $key = $_GET['key'];
  1112. if(strpos($key, '$') !== false){
  1113. $key = explode('$', $key)[0];
  1114. $refresh = true;
  1115. }
  1116. $itemType = $_GET['type'];
  1117. $imgParams = array();
  1118. if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
  1119. if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
  1120. if(isset($itemId)) {
  1121. $image_src = $embyAddress . '/Items/'.$itemId.'/Images/'.$itemType.'?'.implode('&', $imgParams);
  1122. $cachefile = 'images/cache/'.$key.'.jpg';
  1123. $cachetime = 604800;
  1124. // Serve from the cache if it is younger than $cachetime
  1125. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh !== true) {
  1126. header("Content-type: image/jpeg");
  1127. @readfile($cachefile);
  1128. exit;
  1129. }
  1130. ob_start(); // Start the output buffer
  1131. header('Content-type: image/jpeg');
  1132. //@readfile($image_src);
  1133. echo @curl_get($image_src);
  1134. // Cache the output to a file
  1135. $fp = fopen($cachefile, 'wb');
  1136. fwrite($fp, ob_get_contents());
  1137. fclose($fp);
  1138. ob_end_flush(); // Send the output to the browser
  1139. die();
  1140. } else {
  1141. debug_out('Invalid Request',1);
  1142. }
  1143. }
  1144. // Get Image From Plex
  1145. function getPlexImage() {
  1146. $refresh = false;
  1147. $plexAddress = qualifyURL(PLEXURL);
  1148. if (!file_exists('images/cache')) {
  1149. mkdir('images/cache', 0777, true);
  1150. }
  1151. $image_url = $_GET['img'];
  1152. $key = $_GET['key'];
  1153. if(strpos($key, '$') !== false){
  1154. $key = explode('$', $key)[0];
  1155. $refresh = true;
  1156. }
  1157. $image_height = $_GET['height'];
  1158. $image_width = $_GET['width'];
  1159. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  1160. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  1161. $cachefile = 'images/cache/'.$key.'.jpg';
  1162. $cachetime = 604800;
  1163. // Serve from the cache if it is younger than $cachetime
  1164. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh == false) {
  1165. header("Content-type: image/jpeg");
  1166. @readfile($cachefile);
  1167. exit;
  1168. }
  1169. ob_start(); // Start the output buffer
  1170. header('Content-type: image/jpeg');
  1171. //@readfile($image_src);
  1172. echo @curl_get($image_src);
  1173. // Cache the output to a file
  1174. $fp = fopen($cachefile, 'wb');
  1175. fwrite($fp, ob_get_contents());
  1176. fclose($fp);
  1177. ob_end_flush(); // Send the output to the browser
  1178. die();
  1179. } else {
  1180. echo "Invalid Plex Request";
  1181. }
  1182. }
  1183. // Simplier access to class
  1184. function translate($string) {
  1185. if (isset($GLOBALS['language'])) {
  1186. return $GLOBALS['language']->translate($string);
  1187. } else {
  1188. return '!Translations Not Loaded!';
  1189. }
  1190. }
  1191. // Generate Random string
  1192. function randString($length = 10, $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  1193. $tmp = '';
  1194. for ($i = 0; $i < $length; $i++) {
  1195. $tmp .= substr(str_shuffle($chars), 0, 1);
  1196. }
  1197. return $tmp;
  1198. }
  1199. // Create config file in the return syntax
  1200. function createConfig($array, $path = 'config/config.php', $nest = 0) {
  1201. // Define Initial Value
  1202. $output = array();
  1203. // Sort Items
  1204. ksort($array);
  1205. // Update the current config version
  1206. if (!$nest) {
  1207. // Inject Current Version
  1208. $output[] = "\t'CONFIG_VERSION' => '".(isset($array['apply_CONFIG_VERSION'])?$array['apply_CONFIG_VERSION']:INSTALLEDVERSION)."'";
  1209. }
  1210. unset($array['CONFIG_VERSION']);
  1211. unset($array['apply_CONFIG_VERSION']);
  1212. // Process Settings
  1213. foreach ($array as $k => $v) {
  1214. $allowCommit = true;
  1215. switch (gettype($v)) {
  1216. case 'boolean':
  1217. $item = ($v?'true':'false');
  1218. break;
  1219. case 'integer':
  1220. case 'double':
  1221. case 'integer':
  1222. case 'NULL':
  1223. $item = $v;
  1224. break;
  1225. case 'string':
  1226. $item = "'".str_replace(array('\\',"'"),array('\\\\',"\'"),$v)."'";
  1227. break;
  1228. case 'array':
  1229. $item = createConfig($v, false, $nest+1);
  1230. break;
  1231. default:
  1232. $allowCommit = false;
  1233. }
  1234. if($allowCommit) {
  1235. $output[] = str_repeat("\t",$nest+1)."'$k' => $item";
  1236. }
  1237. }
  1238. // Build output
  1239. $output = (!$nest?"<?php\nreturn ":'')."array(\n".implode(",\n",$output)."\n".str_repeat("\t",$nest).')'.(!$nest?';':'');
  1240. if (!$nest && $path) {
  1241. $pathDigest = pathinfo($path);
  1242. @mkdir($pathDigest['dirname'], 0770, true);
  1243. if (file_exists($path)) {
  1244. rename($path, $pathDigest['dirname'].'/'.$pathDigest['filename'].'.bak.php');
  1245. }
  1246. $file = fopen($path, 'w');
  1247. fwrite($file, $output);
  1248. fclose($file);
  1249. if (file_exists($path)) {
  1250. return true;
  1251. }
  1252. writeLog("error", "config was unable to write");
  1253. return false;
  1254. } else {
  1255. writeLog("success", "config was updated with new values");
  1256. return $output;
  1257. }
  1258. }
  1259. // Load a config file written in the return syntax
  1260. function loadConfig($path = 'config/config.php') {
  1261. // Adapted from http://stackoverflow.com/a/14173339/6810513
  1262. if (!is_file($path)) {
  1263. return null;
  1264. } else {
  1265. return (array) call_user_func(function() use($path) {
  1266. return include($path);
  1267. });
  1268. }
  1269. }
  1270. // Commit new values to the configuration
  1271. function updateConfig($new, $current = false) {
  1272. // Get config if not supplied
  1273. if ($current === false) {
  1274. $current = loadConfig();
  1275. } else if (is_string($current) && is_file($current)) {
  1276. $current = loadConfig($current);
  1277. }
  1278. // Inject Parts
  1279. foreach ($new as $k => $v) {
  1280. $current[$k] = $v;
  1281. }
  1282. // Return Create
  1283. return createConfig($current);
  1284. }
  1285. // Inject Defaults As Needed
  1286. function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
  1287. if (is_string($path)) {
  1288. $loadedDefaults = loadConfig($path);
  1289. } else {
  1290. $loadedDefaults = $path;
  1291. }
  1292. return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
  1293. }
  1294. // support function for fillDefaultConfig()
  1295. function fillDefaultConfig_recurse($current, $defaults) {
  1296. foreach($defaults as $k => $v) {
  1297. if (!isset($current[$k])) {
  1298. $current[$k] = $v;
  1299. } else if (is_array($current[$k]) && is_array($v)) {
  1300. $current[$k] = fillDefaultConfig_recurse($current[$k], $v);
  1301. }
  1302. }
  1303. return $current;
  1304. };
  1305. // Define Scalar Variables (nest non-secular with underscores)
  1306. function defineConfig($array, $anyCase = true, $nest_prefix = false) {
  1307. foreach($array as $k => $v) {
  1308. if (is_scalar($v) && !defined($nest_prefix.$k)) {
  1309. define($nest_prefix.$k, $v, $anyCase);
  1310. } else if (is_array($v)) {
  1311. defineConfig($v, $anyCase, $nest_prefix.$k.'_');
  1312. }
  1313. }
  1314. }
  1315. // This function exists only because I am lazy
  1316. function configLazy($path = 'config/config.php') {
  1317. // Load config or default
  1318. if (file_exists($path)) {
  1319. $config = fillDefaultConfig(loadConfig($path));
  1320. } else {
  1321. $config = loadConfig('config/configDefaults.php');
  1322. }
  1323. if (is_array($config)) {
  1324. defineConfig($config);
  1325. }
  1326. return $config;
  1327. }
  1328. // Qualify URL
  1329. function qualifyURL($url) {
  1330. //local address?
  1331. if(substr($url, 0,1) == "/"){
  1332. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  1333. $protocol = "https://";
  1334. } else {
  1335. $protocol = "http://";
  1336. }
  1337. $url = $protocol.getServer().$url;
  1338. }
  1339. // Get Digest
  1340. $digest = parse_url($url);
  1341. // http/https
  1342. if (!isset($digest['scheme'])) {
  1343. if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096,32400,7878,8989,8182,8081,6789))) {
  1344. $scheme = 'http';
  1345. } else {
  1346. $scheme = 'https';
  1347. }
  1348. } else {
  1349. $scheme = $digest['scheme'];
  1350. }
  1351. // Host
  1352. $host = (isset($digest['host'])?$digest['host']:'');
  1353. // Port
  1354. $port = (isset($digest['port'])?':'.$digest['port']:'');
  1355. // Path
  1356. $path = (isset($digest['path'])?$digest['path']:'');
  1357. // Output
  1358. return $scheme.'://'.$host.$port.$path;
  1359. }
  1360. // Function to be called at top of each to allow upgrading environment as the spec changes
  1361. function upgradeCheck() {
  1362. // Upgrade to 1.31
  1363. if (file_exists('homepageSettings.ini.php')) {
  1364. $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
  1365. $homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
  1366. $databaseConfig = array_merge($databaseConfig, $homepageConfig);
  1367. $databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
  1368. foreach($databaseConfig as $k => $v) {
  1369. if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
  1370. $databaseData .= $k . " = \"" . $v . "\"\r\n";
  1371. }
  1372. write_ini_file($databaseData, 'databaseLocation.ini.php');
  1373. unlink('homepageSettings.ini.php');
  1374. unset($databaseData);
  1375. unset($homepageConfig);
  1376. }
  1377. // Upgrade to 1.32
  1378. if (file_exists('databaseLocation.ini.php')) {
  1379. // Load Existing
  1380. $config = parse_ini_file('databaseLocation.ini.php', true);
  1381. // Refactor
  1382. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['databaseLocation'].'/');
  1383. $config['user_home'] = $config['database_Location'].'users/';
  1384. unset($config['databaseLocation']);
  1385. // Turn Off Emby And Plex Recent
  1386. $config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
  1387. unset($config["embyPort"]);
  1388. $config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
  1389. unset($config["plexPort"]);
  1390. $config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
  1391. unset($config["nzbgetPort"]);
  1392. $config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
  1393. unset($config["sabnzbdPort"]);
  1394. $config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
  1395. unset($config["headphonesPort"]);
  1396. // Write config file
  1397. $config['CONFIG_VERSION'] = '1.32';
  1398. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][pre1.32].bak.php');
  1399. $createConfigSuccess = createConfig($config);
  1400. // Create new config
  1401. if ($createConfigSuccess) {
  1402. if (file_exists('config/config.php')) {
  1403. // Remove Old ini file
  1404. unlink('databaseLocation.ini.php');
  1405. } else {
  1406. debug_out('Something is not right here!');
  1407. }
  1408. } else {
  1409. debug_out('Couldn\'t create updated configuration.' ,1);
  1410. }
  1411. }
  1412. // Upgrade to 1.33
  1413. $config = loadConfig();
  1414. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
  1415. // Fix User Directory
  1416. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['database_Location'].'/');
  1417. $config['user_home'] = $config['database_Location'].'users/';
  1418. unset($config['USER_HOME']);
  1419. // Backend auth merge
  1420. if (isset($config['authBackendPort']) && !isset(parse_url($config['authBackendHost'])['port'])) {
  1421. $config['authBackendHost'] .= ':'.$config['authBackendPort'];
  1422. }
  1423. unset($config['authBackendPort']);
  1424. // If auth is being used move it to embyURL as that is now used in auth functions
  1425. 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')))) {
  1426. $config['embyURL'] = $config['authBackendHost'];
  1427. }
  1428. // Upgrade database to latest version
  1429. updateSQLiteDB($config['database_Location'],'1.32');
  1430. // Update Version and Commit
  1431. $config['apply_CONFIG_VERSION'] = '1.33';
  1432. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.32].bak.php');
  1433. $createConfigSuccess = createConfig($config);
  1434. unset($config);
  1435. }
  1436. // Upgrade to 1.34
  1437. $config = loadConfig();
  1438. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.34')) {
  1439. // Upgrade database to latest version
  1440. updateSQLiteDB($config['database_Location'],'1.33');
  1441. // Update Version and Commit
  1442. $config['CONFIG_VERSION'] = '1.34';
  1443. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.33].bak.php');
  1444. $createConfigSuccess = createConfig($config);
  1445. unset($config);
  1446. }
  1447. // Upgrade to 1.40
  1448. $config = loadConfig();
  1449. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.40')) {
  1450. // Upgrade database to latest version
  1451. updateSQLiteDB($config['database_Location'],'1.38');
  1452. // Update Version and Commit
  1453. $config['CONFIG_VERSION'] = '1.40';
  1454. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.38].bak.php');
  1455. $createConfigSuccess = createConfig($config);
  1456. unset($config);
  1457. }
  1458. // Upgrade to 1.50
  1459. $config = loadConfig();
  1460. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.50')) {
  1461. // Upgrade database to latest version
  1462. updateSQLiteDB($config['database_Location'],'1.40');
  1463. // Update Version and Commit
  1464. $config['CONFIG_VERSION'] = '1.50';
  1465. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.40].bak.php');
  1466. $createConfigSuccess = createConfig($config);
  1467. unset($config);
  1468. }
  1469. // Upgrade to 1.603
  1470. $config = loadConfig();
  1471. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.603')) {
  1472. // Update Version and Commit
  1473. $config['CONFIG_VERSION'] = '1.603';
  1474. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.601].bak.php');
  1475. $createConfigSuccess = createConfig($config);
  1476. unset($config);
  1477. if(file_exists('org.log')){
  1478. copy('org.log', DATABASE_LOCATION.'org.log');
  1479. unlink('org.log');
  1480. }
  1481. if(file_exists('loginLog.json')){
  1482. copy('loginLog.json', DATABASE_LOCATION.'loginLog.json');
  1483. unlink('loginLog.json');
  1484. }
  1485. }
  1486. return true;
  1487. }
  1488. // Get OS from server
  1489. function getOS(){
  1490. if(PHP_SHLIB_SUFFIX == "dll"){
  1491. return "win";
  1492. }else{
  1493. return "nix";
  1494. }
  1495. }
  1496. //Get Error by Server OS
  1497. function getError($os, $error){
  1498. $ini = (!empty(php_ini_loaded_file()) ? php_ini_loaded_file() : "php.ini");
  1499. $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'");
  1500. $errors = array(
  1501. 'pdo_sqlite' => array(
  1502. 'win' => '<b>PDO:SQLite</b> not enabled, uncomment ;extension=php_pdo_sqlite.dll in the file php.ini | '.$ext,
  1503. 'nix' => '<b>PDO:SQLite</b> not enabled, PHP7 -> run sudo apt-get install php7.0-sqlite | PHP5 -> run sudo apt-get install php5-sqlite',
  1504. ),
  1505. 'sqlite3' => array(
  1506. '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',
  1507. 'nix' => '<b>SQLite3</b> not enabled, run sudo apt-get install php-sqlite3',
  1508. ),
  1509. 'curl' => array(
  1510. 'win' => '<b>cURL</b> not enabled, uncomment ;extension=php_curl.dll in the file php.ini | '.$ext,
  1511. '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',
  1512. ),
  1513. 'zip' => array(
  1514. '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',
  1515. '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',
  1516. ),
  1517. );
  1518. return (isset($errors[$error][$os]) ? $errors[$error][$os] : 'No Error Info Found');
  1519. }
  1520. // Check if all software dependancies are met
  1521. function dependCheck() {
  1522. $output = array();
  1523. $i = 1;
  1524. if (!extension_loaded('pdo_sqlite')) { $output["Step $i"] = getError(getOS(),'pdo_sqlite'); $i++; }
  1525. if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; }
  1526. if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; }
  1527. //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
  1528. if ($output) {
  1529. $output["Step $i"] = "<b>Restart PHP and/or Webserver to apply changes</b>"; $i++;
  1530. $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++;
  1531. debug_out($output,1);
  1532. }
  1533. return true;
  1534. }
  1535. // Process file uploads
  1536. function uploadFiles($path, $ext_mask = null) {
  1537. if (isset($_FILES) && count($_FILES)) {
  1538. require_once('class.uploader.php');
  1539. $uploader = new Uploader();
  1540. $data = $uploader->upload($_FILES['files'], array(
  1541. 'limit' => 10,
  1542. 'maxSize' => 10,
  1543. 'extensions' => $ext_mask,
  1544. 'required' => false,
  1545. 'uploadDir' => str_replace('//','/',$path.'/'),
  1546. 'title' => array('name'),
  1547. 'removeFiles' => true,
  1548. 'replace' => true,
  1549. ));
  1550. if($data['isComplete']){
  1551. $files = $data['data'];
  1552. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1553. echo json_encode($files['metas'][0]['name']);
  1554. }
  1555. if($data['hasErrors']){
  1556. $errors = $data['errors'];
  1557. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1558. echo json_encode($errors);
  1559. }
  1560. } else {
  1561. writeLog("error", "image was not uploaded");
  1562. echo json_encode('No files submitted!');
  1563. }
  1564. }
  1565. // Process file uploads
  1566. function uploadAvatar($path, $ext_mask = null) {
  1567. if (isset($_FILES) && count($_FILES)) {
  1568. require_once('class.uploader.php');
  1569. $uploader = new Uploader();
  1570. $data = $uploader->upload($_FILES['files'], array(
  1571. 'limit' => 10,
  1572. 'maxSize' => 10,
  1573. 'extensions' => $ext_mask,
  1574. 'required' => false,
  1575. 'uploadDir' => str_replace('//','/',$path.'/'),
  1576. 'title' => array('name'),
  1577. 'removeFiles' => true,
  1578. 'replace' => true,
  1579. ));
  1580. if($data['isComplete']){
  1581. $files = $data['data'];
  1582. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1583. echo json_encode($files['metas'][0]['name']);
  1584. }
  1585. if($data['hasErrors']){
  1586. $errors = $data['errors'];
  1587. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1588. echo json_encode($errors);
  1589. }
  1590. } else {
  1591. writeLog("error", "image was not uploaded");
  1592. echo json_encode('No files submitted!');
  1593. }
  1594. }
  1595. // Remove file
  1596. function removeFiles($path) {
  1597. if(is_file($path)) {
  1598. writeLog("success", "file was removed");
  1599. unlink($path);
  1600. } else {
  1601. writeLog("error", "file was not removed");
  1602. echo json_encode('No file specified for removal!');
  1603. }
  1604. }
  1605. // Lazy select options
  1606. function resolveSelectOptions($array, $selected = '', $multi = false) {
  1607. $output = array();
  1608. $selectedArr = ($multi?explode('|', $selected):array());
  1609. foreach ($array as $key => $value) {
  1610. if (is_array($value)) {
  1611. if (isset($value['optgroup'])) {
  1612. $output[] = '<optgroup label="'.$key.'">';
  1613. foreach($value['optgroup'] as $k => $v) {
  1614. $output[] = '<option value="'.$v['value'].'"'.($selected===$v['value']||in_array($v['value'],$selectedArr)?' selected':'').(isset($v['disabled']) && $v['disabled']?' disabled':'').'>'.$k.'</option>';
  1615. }
  1616. } else {
  1617. $output[] = '<option value="'.$value['value'].'"'.($selected===$value['value']||in_array($value['value'],$selectedArr)?' selected':'').(isset($value['disabled']) && $value['disabled']?' disabled':'').'>'.$key.'</option>';
  1618. }
  1619. } else {
  1620. $output[] = '<option value="'.$value.'"'.($selected===$value||in_array($value,$selectedArr)?' selected':'').'>'.$key.'</option>';
  1621. }
  1622. }
  1623. return implode('',$output);
  1624. }
  1625. // Check if user is allowed to continue
  1626. function qualifyUser($type, $errOnFail = false) {
  1627. if (!isset($GLOBALS['USER'])) {
  1628. require_once("user.php");
  1629. $GLOBALS['USER'] = new User('registration_callback');
  1630. }
  1631. if (is_bool($type)) {
  1632. if ($type === true) {
  1633. $authorized = ($GLOBALS['USER']->authenticated == true);
  1634. } else {
  1635. $authorized = true;
  1636. }
  1637. } elseif (is_string($type) || is_array($type)) {
  1638. if ($type !== 'false') {
  1639. if (!is_array($type)) {
  1640. $type = explode('|',$type);
  1641. }
  1642. $authorized = ($GLOBALS['USER']->authenticated && in_array($GLOBALS['USER']->role,$type));
  1643. } else {
  1644. $authorized = true;
  1645. }
  1646. } else {
  1647. debug_out('Invalid Syntax!',1);
  1648. }
  1649. if (!$authorized && $errOnFail) {
  1650. if ($GLOBALS['USER']->authenticated) {
  1651. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401');
  1652. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401\'</script>';
  1653. } else {
  1654. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999');
  1655. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999\'</script>';
  1656. }
  1657. debug_out('Not Authorized' ,1);
  1658. } else {
  1659. return $authorized;
  1660. }
  1661. }
  1662. // Build an (optionally) tabbed settings page.
  1663. function buildSettings($array) {
  1664. /*
  1665. array(
  1666. 'title' => '',
  1667. 'id' => '',
  1668. 'fields' => array( See buildField() ),
  1669. 'tabs' => array(
  1670. array(
  1671. 'title' => '',
  1672. 'id' => '',
  1673. 'image' => '',
  1674. 'fields' => array( See buildField() ),
  1675. ),
  1676. ),
  1677. );
  1678. */
  1679. $notifyExplode = explode("-", NOTIFYEFFECT);
  1680. $fieldFunc = function($fieldArr) {
  1681. $fields = '<div class="row">';
  1682. foreach($fieldArr as $key => $value) {
  1683. $isSingle = isset($value['type']);
  1684. if ($isSingle) { $value = array($value); }
  1685. $tmpField = '';
  1686. $sizeLg = max(floor(12/count($value)),2);
  1687. $sizeMd = max(floor(($isSingle?12:6)/count($value)),3);
  1688. foreach($value as $k => $v) {
  1689. $tmpField .= buildField($v, 12, $sizeMd, $sizeLg);
  1690. }
  1691. $fields .= ($isSingle?$tmpField:'<div class="row col-sm-12 content-form">'.$tmpField.'</div>');
  1692. }
  1693. $fields .= '</div>';
  1694. return $fields;
  1695. };
  1696. $fields = (isset($array['fields'])?$fieldFunc($array['fields']):'');
  1697. $tabSelectors = array();
  1698. $tabContent = array();
  1699. if (isset($array['tabs'])) {
  1700. foreach($array['tabs'] as $key => $value) {
  1701. $id = (isset($value['id'])?$value['id']:randString(32));
  1702. $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>';
  1703. $tabContent[$key] = '<div class="tab-pane big-box fade'.($tabContent?'':' active in').'" id="tab-'.$id.'">'.$fieldFunc($value['fields']).'</div>';
  1704. }
  1705. }
  1706. $pageID = (isset($array['id'])?$array['id']:str_replace(array(' ','"',"'"),array('_'),strtolower($array['id'])));
  1707. $extraClick = ($pageID == 'appearance_settings' ? "$('#advanced_settings_form_submit').click();console.log('add theme settings');" : "");
  1708. return '
  1709. <div class="email-body">
  1710. <div class="email-header gray-bg">
  1711. <button type="button" class="btn btn-danger btn-sm waves close-button"><i class="fa fa-close"></i></button>
  1712. <button id="'.$pageID.'_form_submit" class="btn waves btn-labeled btn-success btn btn-sm text-uppercase waves-effect waves-float save-btn-form">
  1713. <span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save
  1714. </button>
  1715. <h1>'.$array['title'].'</h1>
  1716. </div>
  1717. <div class="email-inner small-box">
  1718. <div class="email-inner-section">
  1719. <div class="small-box fade in" id="'.$pageID.'_frame">
  1720. <div class="col-lg-12">
  1721. '.(isset($array['customBeforeForm'])?$array['customBeforeForm']:'').'
  1722. <form class="content-form" name="'.$pageID.'" id="'.$pageID.'_form" onsubmit="return false;">
  1723. '.$fields.($tabContent?'
  1724. <div class="tabbable tabs-with-bg" id="'.$pageID.'_tabs">
  1725. <ul class="nav nav-tabs apps">
  1726. '.implode('', $tabSelectors).'
  1727. </ul>
  1728. <div class="clearfix"></div>
  1729. <div class="tab-content">
  1730. '.implode('', $tabContent).'
  1731. </div>
  1732. </div>':'').'
  1733. </form>
  1734. '.(isset($array['customAfterForm'])?$array['customAfterForm']:'').'
  1735. </div>
  1736. </div>
  1737. </div>
  1738. </div>
  1739. </div>
  1740. <script>
  1741. $(document).ready(function() {
  1742. $(\'#'.$pageID.'_form\').find(\'input, select, textarea\').on(\'change\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1743. var '.$pageID.'Validate = function() { if (this.value && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { $(this).addClass(\'invalid\'); } else { $(this).removeClass(\'invalid\'); } };
  1744. $(\'#'.$pageID.'_form\').find(\'input[pattern]\').each('.$pageID.'Validate).on(\'keyup\', '.$pageID.'Validate);
  1745. $(\'#'.$pageID.'_form\').find(\'select[multiple]\').on(\'change click\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1746. $(\'#'.$pageID.'_form_submit\').on(\'click\', function () {
  1747. var newVals = {};
  1748. var hasVals = false;
  1749. var errorFields = [];
  1750. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').each(function() {
  1751. hasVals = true;
  1752. if (this.type == \'checkbox\') {
  1753. newVals[this.name] = this.checked;
  1754. } else if ($(this).hasClass(\'summernote\')) {
  1755. newVals[$(this).attr(\'name\')] = $(this).siblings(\'.note-editor\').find(\'.panel-body\').html();
  1756. } else {
  1757. if (this.value && this.pattern && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { errorFields.push(this.name); }
  1758. var fieldVal = $(this).val();
  1759. if (typeof fieldVal == \'object\') {
  1760. if (typeof fieldVal.join == \'function\') {
  1761. fieldVal = fieldVal.join(\'|\');
  1762. } else {
  1763. fieldVal = JSON.stringify(fieldVal);
  1764. }
  1765. }
  1766. newVals[this.name] = fieldVal;
  1767. }
  1768. });
  1769. if (errorFields.length) {
  1770. parent.notify(\'Fields have errors: \'+errorFields.join(\', \')+\'!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1771. } else if (hasVals) {
  1772. console.log(newVals);
  1773. ajax_request(\'POST\', \''.(isset($array['submitAction'])?$array['submitAction']:'update-config').'\', newVals, function(data, code) {
  1774. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').removeAttr(\'data-changed\');
  1775. });
  1776. '.$extraClick.'
  1777. } else {
  1778. parent.notify(\'Nothing to update!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1779. }
  1780. return false;
  1781. });
  1782. '.(isset($array['onready'])?$array['onready']:'').'
  1783. });
  1784. </script>
  1785. ';
  1786. }
  1787. // Build Settings Fields
  1788. function buildField($params, $sizeSm = 12, $sizeMd = 12, $sizeLg = 12) {
  1789. /*
  1790. array(
  1791. 'type' => '',
  1792. 'placeholder' => '',
  1793. 'label' => '',
  1794. 'labelTranslate' => '',
  1795. 'assist' => '',
  1796. 'name' => '',
  1797. 'pattern' => '',
  1798. 'options' => array( // For SELECT only
  1799. 'Display' => 'value',
  1800. ),
  1801. )
  1802. */
  1803. // Tags
  1804. $tags = array();
  1805. foreach(array('placeholder','style','disabled','readonly','pattern','min','max','required','onkeypress','onchange','onfocus','onleave','href','onclick','autocomplete') as $value) {
  1806. if (isset($params[$value])) {
  1807. if (is_string($params[$value])) { $tags[] = $value.'="'.$params[$value].'"';
  1808. } else if ($params[$value] === true) { $tags[] = $value; }
  1809. }
  1810. }
  1811. $format = (isset($params['format']) && in_array($params['format'],array(false,'colour','color'))?$params['format']:false);
  1812. $name = (isset($params['name'])?$params['name']:(isset($params['id'])?$params['id']:''));
  1813. $id = (isset($params['id'])?$params['id']:(isset($params['name'])?$params['name'].'_id':randString(32)));
  1814. $val = (isset($params['value'])?$params['value']:'');
  1815. $class = (isset($params['class'])?' '.$params['class']:'');
  1816. $wrapClass = (isset($params['wrapClass'])?$params['wrapClass']:'form-content');
  1817. $assist = (isset($params['assist'])?' - i.e. '.$params['assist']:'');
  1818. $label = (isset($params['labelTranslate'])?translate($params['labelTranslate']):(isset($params['label'])?$params['label']:''));
  1819. $labelOut = '<p class="help-text">'.$label.$assist.'</p>';
  1820. // Field Design
  1821. switch ($params['type']) {
  1822. case 'text':
  1823. case 'number':
  1824. case 'password':
  1825. $field = '<input id="'.$id.'" name="'.$name.'" type="'.$params['type'].'" class="form-control material input-sm'.$class.'" '.implode(' ',$tags).' autocorrect="off" autocapitalize="off" value="'.$val.'">';
  1826. break;
  1827. case 'select':
  1828. case 'dropdown':
  1829. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control material input-sm" '.implode(' ',$tags).'>'.resolveSelectOptions($params['options'], $val).'</select>';
  1830. break;
  1831. case 'select-multi':
  1832. case 'dropdown-multi':
  1833. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control input-sm" '.implode(' ',$tags).' multiple="multiple">'.resolveSelectOptions($params['options'], $val, true).'</select>';
  1834. break;
  1835. case 'check':
  1836. case 'checkbox':
  1837. case 'toggle':
  1838. $checked = ((is_bool($val) && $val) || trim($val) === 'true'?' checked':'');
  1839. $colour = (isset($params['colour'])?$params['colour']:'success');
  1840. $labelOut = '<label for="'.$id.'"></label>'.$label;
  1841. $field = '<input id="'.$id.'" name="'.$name.'" type="checkbox" class="switcher switcher-'.$colour.' '.$class.'" '.implode(' ',$tags).' data-value="'.$val.'"'.$checked.'>';
  1842. break;
  1843. case 'radio':
  1844. $labelOut = '';
  1845. $checked = ((is_bool($val) && $val) || ($val && trim($val) !== 'false')?' checked':'');
  1846. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1847. $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>';
  1848. break;
  1849. case 'date':
  1850. $field = 'Unsupported, planned.';
  1851. break;
  1852. case 'hidden':
  1853. return '<input id="'.$id.'" name="'.$name.'" type="hidden" class="'.$class.'" '.implode(' ',$tags).' value="'.$val.'">';
  1854. break;
  1855. case 'header':
  1856. $labelOut = '';
  1857. $headType = (isset($params['value'])?$params['value']:3);
  1858. $field = '<h'.$headType.' class="'.$class.'" '.implode(' ',$tags).'>'.$label.'</h'.$headType.'>';
  1859. break;
  1860. case 'button':
  1861. $labelOut = '';
  1862. $icon = (isset($params['icon'])?$params['icon']:'flask');
  1863. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1864. $bDropdown = (isset($params['buttonDrop'])?$params['buttonDrop']:'');
  1865. $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>':'');
  1866. break;
  1867. case 'textarea':
  1868. $rows = (isset($params['rows'])?$params['rows']:5);
  1869. $field = '<textarea id="'.$id.'" name="'.$name.'" class="form-control'.$class.'" rows="'.$rows.'" '.implode(' ',$tags).'>'.$val.'</textarea>';
  1870. break;
  1871. case 'custom':
  1872. // Settings
  1873. $settings = array(
  1874. '$id' => $id,
  1875. '$name' => $name,
  1876. '$val' => $val,
  1877. '$label' => $label,
  1878. '$labelOut' => $labelOut,
  1879. );
  1880. // Get HTML
  1881. $html = (isset($params['html'])?$params['html']:'Nothing Specified!');
  1882. // If LabelOut is in html dont print it twice
  1883. $labelOut = (strpos($html,'$label')!==false?'':$labelOut);
  1884. // Replace variables in settings
  1885. $html = preg_replace_callback('/\$\w+\b/', function ($match) use ($settings) { return (isset($settings[$match[0]])?$settings[$match[0]]:'{'.$match[0].' is undefined}'); }, $html);
  1886. // Build Field
  1887. $field = '<div id="'.$id.'_html" class="custom-field">'.$html.'</div>';
  1888. break;
  1889. case 'space':
  1890. $labelOut = '';
  1891. $field = str_repeat('<br>', (isset($params['value'])?$params['value']:1));
  1892. break;
  1893. default:
  1894. $field = 'Unsupported field type';
  1895. break;
  1896. }
  1897. // Field Formats
  1898. switch ($format) {
  1899. case 'colour': // Fuckin Eh, Canada!
  1900. case 'color':
  1901. $labelBef = '<center>'.$label.'</center>';
  1902. $wrapClass = 'gray-bg colour-field';
  1903. $labelAft = '';
  1904. $field = str_replace(' material input-sm','',$field);
  1905. break;
  1906. default:
  1907. $labelBef = '';
  1908. $labelAft = $labelOut;
  1909. }
  1910. return '<div class="'.$wrapClass.' col-sm-'.$sizeSm.' col-md-'.$sizeMd.' col-lg-'.$sizeLg.'">'.$labelBef.$field.$labelAft.'</div>';
  1911. }
  1912. // Tab Settings Generation
  1913. function printTabRow($data) {
  1914. $hidden = false;
  1915. if ($data===false) {
  1916. $hidden = true;
  1917. $data = array( // New Tab Defaults
  1918. 'id' => 'new',
  1919. 'name' => '',
  1920. 'url' => '',
  1921. 'icon' => 'fa-diamond',
  1922. 'iconurl' => '',
  1923. 'active' => 'true',
  1924. 'user' => 'true',
  1925. 'guest' => 'true',
  1926. 'window' => 'false',
  1927. 'splash' => 'true',
  1928. 'ping' => 'false',
  1929. 'ping_url' => '',
  1930. 'defaultz' => '',
  1931. );
  1932. }
  1933. $image = '<span style="font: normal normal normal 30px/1 FontAwesome;" class="fa fa-hand-paper-o"></span>';
  1934. $output = '
  1935. <li id="tab-'.$data['id'].'" class="list-group-item" style="position: relative; left: 0px; top: 0px; '.($hidden?' display: none;':'').'">
  1936. <tab class="content-form form-inline">
  1937. <div class="row">
  1938. '.buildField(array(
  1939. 'type' => 'custom',
  1940. '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>',
  1941. ),12,1,1).'
  1942. '.buildField(array(
  1943. 'type' => 'hidden',
  1944. 'id' => 'tab-'.$data['id'].'-id',
  1945. 'name' => 'id['.$data['id'].']',
  1946. 'value' => $data['id'],
  1947. ),12,2,1).'
  1948. '.buildField(array(
  1949. 'type' => 'text',
  1950. 'id' => 'tab-'.$data['id'].'-name',
  1951. 'name' => 'name['.$data['id'].']',
  1952. 'required' => true,
  1953. 'placeholder' => 'Organizr Homepage',
  1954. 'labelTranslate' => 'TAB_NAME',
  1955. 'value' => $data['name'],
  1956. 'class' => 'darkBold',
  1957. ),12,2,1).'
  1958. '.buildField(array(
  1959. 'type' => 'text',
  1960. 'id' => 'tab-'.$data['id'].'-url',
  1961. 'name' => 'url['.$data['id'].']',
  1962. 'required' => true,
  1963. 'placeholder' => 'homepage.php',
  1964. 'labelTranslate' => 'TAB_URL',
  1965. 'value' => $data['url'],
  1966. 'class' => 'darkBold',
  1967. ),12,2,2).'
  1968. '.buildField(array(
  1969. 'type' => 'text',
  1970. 'id' => 'tab-'.$data['id'].'-iconurl',
  1971. 'name' => 'iconurl['.$data['id'].']',
  1972. 'placeholder' => 'images/organizr.png',
  1973. 'labelTranslate' => 'ICON_URL',
  1974. 'value' => $data['iconurl'],
  1975. 'class' => 'darkBold',
  1976. ),12,2,1).'
  1977. '.buildField(array(
  1978. 'type' => 'text',
  1979. 'id' => 'tab-'.$data['id'].'-icon',
  1980. 'name' => 'icon['.$data['id'].']',
  1981. 'placeholder' => 'fa-icon',
  1982. 'labelTranslate' => 'OR_ICON_NAME',
  1983. 'value' => $data['icon'],
  1984. 'class' => 'iconpickeradd darkBold',
  1985. ),12,1,1).'
  1986. '.buildField(array(
  1987. 'type' => 'text',
  1988. 'id' => 'tab-'.$data['id'].'-ping_url',
  1989. 'name' => 'ping_url['.$data['id'].']',
  1990. 'placeholder' => 'host:port',
  1991. 'labelTranslate' => 'PING_URL',
  1992. 'value' => $data['ping_url'],
  1993. 'class' => 'darkBold',
  1994. ),12,2,1).'
  1995. '.buildField(array(
  1996. 'type' => 'radio',
  1997. 'labelTranslate' => 'DEFAULT',
  1998. 'name' => 'defaultz['.$data['id'].']',
  1999. 'value' => $data['defaultz'],
  2000. 'onclick' => "$('[type=radio][id!=\''+this.id+'\']').each(function() { this.checked=false; });",
  2001. ),12,1,1).'
  2002. '.buildField(array(
  2003. 'type' => 'button',
  2004. 'icon' => 'chevron-down',
  2005. 'buttonType' => 'success',
  2006. 'labelTranslate' => 'MORE',
  2007. 'onclick' => "$(this).parent().parent().parent().find('.slideInUp').toggle()",
  2008. 'class' => 'toggleTabExtra',
  2009. ),12,1,1).'
  2010. '.buildField(array(
  2011. 'type' => 'button',
  2012. 'icon' => 'trash',
  2013. 'buttonType' => 'danger',
  2014. 'labelTranslate' => 'REMOVE',
  2015. 'onclick' => "$(this).parents('li').remove();",
  2016. ),12,1,1).'</div><div id = "tab-'.$data['id'].'-row" class = "row animated slideInUp" style = "display:none;" ><div></div>
  2017. '.buildField(array(
  2018. 'type' => 'checkbox',
  2019. 'labelTranslate' => 'ACTIVE',
  2020. 'name' => 'active['.$data['id'].']',
  2021. 'value' => $data['active'],
  2022. ),12,1,1).'
  2023. '.buildField(array(
  2024. 'type' => 'checkbox',
  2025. 'labelTranslate' => 'USER',
  2026. 'colour' => 'primary',
  2027. 'name' => 'user['.$data['id'].']',
  2028. 'value' => $data['user'],
  2029. ),12,1,1).'
  2030. '.buildField(array(
  2031. 'type' => 'checkbox',
  2032. 'labelTranslate' => 'GUEST',
  2033. 'colour' => 'warning',
  2034. 'name' => 'guest['.$data['id'].']',
  2035. 'value' => $data['guest'],
  2036. ),12,1,1).'
  2037. '.buildField(array(
  2038. 'type' => 'checkbox',
  2039. 'labelTranslate' => 'NO_IFRAME',
  2040. 'colour' => 'danger',
  2041. 'name' => 'window['.$data['id'].']',
  2042. 'value' => $data['window'],
  2043. ),12,1,1).'
  2044. '.buildField(array(
  2045. 'type' => 'checkbox',
  2046. 'labelTranslate' => 'SPLASH',
  2047. 'colour' => 'success',
  2048. 'name' => 'splash['.$data['id'].']',
  2049. 'value' => $data['splash'],
  2050. ),12,1,1).'
  2051. '.buildField(array(
  2052. 'type' => 'checkbox',
  2053. 'labelTranslate' => 'PING',
  2054. 'colour' => 'success',
  2055. 'name' => 'ping['.$data['id'].']',
  2056. 'value' => $data['ping'],
  2057. ),12,1,1).'
  2058. </div>
  2059. </tab>
  2060. </li>
  2061. ';
  2062. return $output;
  2063. }
  2064. // Timezone array
  2065. function timezoneOptions() {
  2066. $output = array();
  2067. $timezones = array();
  2068. $regions = array(
  2069. 'Africa' => DateTimeZone::AFRICA,
  2070. 'America' => DateTimeZone::AMERICA,
  2071. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2072. 'Arctic' => DateTimeZone::ARCTIC,
  2073. 'Asia' => DateTimeZone::ASIA,
  2074. 'Atlantic' => DateTimeZone::ATLANTIC,
  2075. 'Australia' => DateTimeZone::AUSTRALIA,
  2076. 'Europe' => DateTimeZone::EUROPE,
  2077. 'Indian' => DateTimeZone::INDIAN,
  2078. 'Pacific' => DateTimeZone::PACIFIC
  2079. );
  2080. foreach ($regions as $name => $mask) {
  2081. $zones = DateTimeZone::listIdentifiers($mask);
  2082. foreach($zones as $timezone) {
  2083. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2084. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2085. $output[$name]['optgroup'][substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm]['value'] = $timezone;
  2086. }
  2087. }
  2088. return $output;
  2089. }
  2090. // Build Database
  2091. function createSQLiteDB($path = false) {
  2092. if ($path === false) {
  2093. if (DATABASE_LOCATION){
  2094. $path = DATABASE_LOCATION;
  2095. } else {
  2096. debug_out('No Path Specified!');
  2097. }
  2098. }
  2099. if (!is_file($path.'users.db') || filesize($path.'users.db') <= 0) {
  2100. if (!isset($GLOBALS['file_db'])) {
  2101. $GLOBALS['file_db'] = new PDO('sqlite:'.$path.'users.db');
  2102. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2103. }
  2104. // Create Users
  2105. $users = $GLOBALS['file_db']->query('CREATE TABLE `users` (
  2106. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2107. `username` TEXT UNIQUE,
  2108. `password` TEXT,
  2109. `email` TEXT,
  2110. `token` TEXT,
  2111. `role` TEXT,
  2112. `active` TEXT,
  2113. `last` TEXT,
  2114. `auth_service` TEXT DEFAULT \'internal\'
  2115. );');
  2116. // Create Tabs
  2117. $tabs = $GLOBALS['file_db']->query('CREATE TABLE `tabs` (
  2118. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2119. `order` INTEGER,
  2120. `users_id` INTEGER,
  2121. `name` TEXT,
  2122. `url` TEXT,
  2123. `defaultz` TEXT,
  2124. `active` TEXT,
  2125. `user` TEXT,
  2126. `guest` TEXT,
  2127. `icon` TEXT,
  2128. `iconurl` TEXT,
  2129. `window` TEXT,
  2130. `splash` TEXT,
  2131. `ping` TEXT,
  2132. `ping_url` TEXT
  2133. );');
  2134. // Create Options
  2135. $options = $GLOBALS['file_db']->query('CREATE TABLE `options` (
  2136. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2137. `users_id` INTEGER UNIQUE,
  2138. `title` TEXT UNIQUE,
  2139. `topbar` TEXT,
  2140. `bottombar` TEXT,
  2141. `sidebar` TEXT,
  2142. `hoverbg` TEXT,
  2143. `topbartext` TEXT,
  2144. `activetabBG` TEXT,
  2145. `activetabicon` TEXT,
  2146. `activetabtext` TEXT,
  2147. `inactiveicon` TEXT,
  2148. `inactivetext` TEXT,
  2149. `loading` TEXT,
  2150. `hovertext` TEXT
  2151. );');
  2152. // Create Invites
  2153. $invites = $GLOBALS['file_db']->query('CREATE TABLE `invites` (
  2154. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2155. `code` TEXT UNIQUE,
  2156. `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  2157. `email` TEXT,
  2158. `username` TEXT,
  2159. `dateused` TIMESTAMP,
  2160. `usedby` TEXT,
  2161. `ip` TEXT,
  2162. `valid` TEXT
  2163. );');
  2164. writeLog("success", "database created/saved");
  2165. return $users && $tabs && $options && $invites;
  2166. } else {
  2167. writeLog("error", "database was unable to be created/saved");
  2168. return false;
  2169. }
  2170. }
  2171. // Upgrade Database
  2172. function updateSQLiteDB($db_path = false, $oldVerNum = false) {
  2173. if (!$db_path) {
  2174. if (defined('DATABASE_LOCATION')) {
  2175. $db_path = DATABASE_LOCATION;
  2176. } else {
  2177. debug_out('No Path Specified',1);
  2178. }
  2179. }
  2180. if (!isset($GLOBALS['file_db'])) {
  2181. $GLOBALS['file_db'] = new PDO('sqlite:'.$db_path.'users.db');
  2182. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2183. }
  2184. // Cache current DB
  2185. $cache = array();
  2186. foreach($GLOBALS['file_db']->query('SELECT name FROM sqlite_master WHERE type="table";') as $table) {
  2187. foreach($GLOBALS['file_db']->query('SELECT * FROM '.$table['name'].';') as $key => $row) {
  2188. foreach($row as $k => $v) {
  2189. if (is_string($k)) {
  2190. $cache[$table['name']][$key][$k] = $v;
  2191. }
  2192. }
  2193. }
  2194. }
  2195. // Remove Current Database
  2196. $GLOBALS['file_db'] = null;
  2197. $pathDigest = pathinfo($db_path.'users.db');
  2198. if (file_exists($db_path.'users.db')) {
  2199. rename($db_path.'users.db', $pathDigest['dirname'].'/'.$pathDigest['filename'].'['.date('Y-m-d_H-i-s').']'.($oldVerNum?'['.$oldVerNum.']':'').'.bak.db');
  2200. }
  2201. // Create New Database
  2202. $success = createSQLiteDB($db_path);
  2203. // Restore Items
  2204. if ($success) {
  2205. foreach($cache as $table => $tableData) {
  2206. if ($tableData) {
  2207. $queryBase = 'INSERT INTO '.$table.' (`'.implode('`,`',array_keys(current($tableData))).'`) values ';
  2208. $insertValues = array();
  2209. reset($tableData);
  2210. foreach($tableData as $key => $value) {
  2211. $insertValues[] = '('.implode(',',array_map(function($d) {
  2212. return (isset($d)?$GLOBALS['file_db']->quote($d):'null');
  2213. }, $value)).')';
  2214. }
  2215. $GLOBALS['file_db']->query($queryBase.implode(',',$insertValues).';');
  2216. }
  2217. }
  2218. writeLog("success", "database values have been updated");
  2219. return true;
  2220. } else {
  2221. writeLog("error", "database values unable to be updated");
  2222. return false;
  2223. }
  2224. }
  2225. // Commit colours to database
  2226. function updateDBOptions($values) {
  2227. if (!isset($GLOBALS['file_db'])) {
  2228. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2229. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2230. }
  2231. // Commit new values to database
  2232. if ($GLOBALS['file_db']->query('UPDATE options SET '.implode(',',array_map(function($d, $k) {
  2233. return '`'.$k.'` = '.(isset($d)?"'".addslashes($d)."'":'null');
  2234. }, $values, array_keys($values))).';')->rowCount()) {
  2235. return true;
  2236. } else if ($GLOBALS['file_db']->query('INSERT OR IGNORE INTO options (`'.implode('`,`',array_keys($values)).'`) VALUES (\''.implode("','",$values).'\');')->rowCount()) {
  2237. writeLog("success", "database values for options table have been updated");
  2238. return true;
  2239. } else {
  2240. writeLog("error", "database values for options table unable to be updated");
  2241. return false;
  2242. }
  2243. }
  2244. // Send AJAX notification
  2245. function sendNotification($success, $message = false, $send = true) {
  2246. $notifyExplode = explode("-", NOTIFYEFFECT);
  2247. if ($success) {
  2248. $msg = array(
  2249. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_SAVED").'</strong>'),
  2250. 'icon' => 'floppy-o',
  2251. 'type' => 'success',
  2252. 'length' => '5000',
  2253. 'layout' => $notifyExplode[0],
  2254. 'effect' => $notifyExplode[1],
  2255. );
  2256. } else {
  2257. $msg = array(
  2258. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_NOT_SAVED").'</strong>'),
  2259. 'icon' => 'floppy-o',
  2260. 'type' => 'failed',
  2261. 'length' => '5000',
  2262. 'layout' => $notifyExplode[0],
  2263. 'effect' => $notifyExplode[1],
  2264. );
  2265. }
  2266. // Send and kill script?
  2267. if ($send) {
  2268. header('Content-Type: application/json');
  2269. echo json_encode(array('notify'=>$msg));
  2270. die();
  2271. }
  2272. return $msg;
  2273. }
  2274. // Load colours from the database
  2275. function loadAppearance() {
  2276. // Defaults
  2277. $defaults = array(
  2278. 'title' => 'Organizr',
  2279. 'topbartext' => '#66D9EF',
  2280. 'topbar' => '#333333',
  2281. 'bottombar' => '#333333',
  2282. 'sidebar' => '#393939',
  2283. 'hoverbg' => '#AD80FD',
  2284. 'activetabBG' => '#F92671',
  2285. 'activetabicon' => '#FFFFFF',
  2286. 'activetabtext' => '#FFFFFF',
  2287. 'inactiveicon' => '#66D9EF',
  2288. 'inactivetext' => '#66D9EF',
  2289. 'loading' => '#66D9EF',
  2290. 'hovertext' => '#000000',
  2291. );
  2292. if (DATABASE_LOCATION) {
  2293. if(is_file(DATABASE_LOCATION.'users.db') && filesize(DATABASE_LOCATION.'users.db') > 0){
  2294. if (!isset($GLOBALS['file_db'])) {
  2295. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2296. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2297. }
  2298. // Database Lookup
  2299. $options = $GLOBALS['file_db']->query('SELECT * FROM options');
  2300. // Replace defaults with filled options
  2301. foreach($options as $row) {
  2302. foreach($defaults as $key => $value) {
  2303. if (isset($row[$key]) && $row[$key]) {
  2304. $defaults[$key] = $row[$key];
  2305. }
  2306. }
  2307. }
  2308. }
  2309. }
  2310. // Return the Results
  2311. return $defaults;
  2312. }
  2313. // Delete Database
  2314. function deleteDatabase() {
  2315. unset($_COOKIE['Organizr']);
  2316. setcookie('Organizr', '', time() - 3600, '/');
  2317. unset($_COOKIE['OrganizrU']);
  2318. setcookie('OrganizrU', '', time() - 3600, '/');
  2319. $GLOBALS['file_db'] = null;
  2320. unlink(DATABASE_LOCATION.'users.db');
  2321. foreach(glob(substr_replace($userdirpath, "", -1).'/*') as $file) {
  2322. if(is_dir($file)) {
  2323. rmdir($file);
  2324. } elseif (!is_dir($file)) {
  2325. unlink($file);
  2326. }
  2327. }
  2328. rmdir($userdirpath);
  2329. writeLog("success", "database has been deleted");
  2330. return true;
  2331. }
  2332. // Upgrade the installation
  2333. function upgradeInstall($branch = 'master') {
  2334. function downloadFile($url, $path){
  2335. ini_set('max_execution_time',0);
  2336. $folderPath = "upgrade/";
  2337. if(!mkdir($folderPath)){
  2338. writeLog("error", "organizr could not create upgrade folder");
  2339. }
  2340. $newfname = $folderPath . $path;
  2341. $file = fopen ($url, 'rb');
  2342. if ($file) {
  2343. $newf = fopen ($newfname, 'wb');
  2344. if ($newf) {
  2345. while(!feof($file)) {
  2346. fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
  2347. }
  2348. }
  2349. }else{
  2350. writeLog("error", "organizr could not download $url");
  2351. }
  2352. if ($file) {
  2353. fclose($file);
  2354. writeLog("success", "organizr finished downloading the github zip file");
  2355. }else{
  2356. writeLog("error", "organizr could not download the github zip file");
  2357. }
  2358. if ($newf) {
  2359. fclose($newf);
  2360. writeLog("success", "organizr created upgrade zip file from github zip file");
  2361. }else{
  2362. writeLog("error", "organizr could not create upgrade zip file from github zip file");
  2363. }
  2364. }
  2365. function unzipFile($zipFile){
  2366. $zip = new ZipArchive;
  2367. $extractPath = "upgrade/";
  2368. if($zip->open($extractPath . $zipFile) != "true"){
  2369. writeLog("error", "organizr could not unzip upgrade.zip");
  2370. }else{
  2371. writeLog("success", "organizr unzipped upgrade.zip");
  2372. }
  2373. /* Extract Zip File */
  2374. $zip->extractTo($extractPath);
  2375. $zip->close();
  2376. }
  2377. // Function to remove folders and files
  2378. function rrmdir($dir) {
  2379. if (is_dir($dir)) {
  2380. $files = scandir($dir);
  2381. foreach ($files as $file)
  2382. if ($file != "." && $file != "..") rrmdir("$dir/$file");
  2383. rmdir($dir);
  2384. }
  2385. else if (file_exists($dir)) unlink($dir);
  2386. }
  2387. // Function to Copy folders and files
  2388. function rcopy($src, $dst) {
  2389. if (is_dir ( $src )) {
  2390. if (!file_exists($dst)) : mkdir ( $dst ); endif;
  2391. $files = scandir ( $src );
  2392. foreach ( $files as $file )
  2393. if ($file != "." && $file != "..")
  2394. rcopy ( "$src/$file", "$dst/$file" );
  2395. } else if (file_exists ( $src ))
  2396. copy ( $src, $dst );
  2397. }
  2398. $url = 'https://github.com/causefx/Organizr/archive/'.$branch.'.zip';
  2399. $file = "upgrade.zip";
  2400. $source = __DIR__ . '/upgrade/Organizr-'.$branch.'/';
  2401. $cleanup = __DIR__ . "/upgrade/";
  2402. $destination = __DIR__ . "/";
  2403. writeLog("success", "starting organizr upgrade process");
  2404. downloadFile($url, $file);
  2405. unzipFile($file);
  2406. rcopy($source, $destination);
  2407. writeLog("success", "new organizr files copied");
  2408. rrmdir($cleanup);
  2409. writeLog("success", "organizr upgrade folder removed");
  2410. writeLog("success", "organizr has been updated");
  2411. return true;
  2412. }
  2413. // Transmission Items
  2414. function transmissionConnect($list = 'listgroups') {
  2415. $url = qualifyURL(TRANSMISSIONURL);
  2416. $digest = parse_url($url);
  2417. $scheme = (isset($digest['scheme'])) ? $digest['scheme'].'://' : 'http://';
  2418. $host = (isset($digest['host'])) ? $digest['host'] : '';
  2419. $port = (isset($digest['port'])) ? ':'.$digest['port'] : '';
  2420. $path = (isset($digest['path'])) ? $digest['path'] : '';
  2421. $passwordInclude = (TRANSMISSIONUSERNAME != '' && TRANSMISSIONPASSWORD != '') ? TRANSMISSIONUSERNAME.':'.TRANSMISSIONPASSWORD."@" : '';
  2422. $url = $scheme.$passwordInclude.$host.$port.$path.'/rpc';
  2423. $contextopts = array(
  2424. 'http' => array(
  2425. 'user_agent' => 'HTTP_UA',
  2426. 'ignore_errors' => true,
  2427. )
  2428. );
  2429. $context = stream_context_create( $contextopts );
  2430. $fp = @fopen( $url, 'r', false, $context );
  2431. $stream_meta = stream_get_meta_data( $fp );
  2432. fclose( $fp );
  2433. foreach( $stream_meta['wrapper_data'] as $header ){
  2434. if( strpos( $header, 'X-Transmission-Session-Id: ' ) === 0 ){
  2435. $session_id = trim( substr( $header, 27 ) );
  2436. break;
  2437. }
  2438. }
  2439. $headers = array(
  2440. 'X-Transmission-Session-Id' => $session_id,
  2441. 'Content-Type' => 'application/json'
  2442. );
  2443. $data = array(
  2444. 'method' => 'torrent-get',
  2445. 'arguments' => array(
  2446. 'fields' => array(
  2447. "id", "name", "totalSize", "eta", "isFinished", "isStalled", "percentDone", "rateDownload", "status", "downloadDir"
  2448. ),
  2449. ),
  2450. 'tags' => ''
  2451. );
  2452. $api = curl_post($url, $data, $headers);
  2453. $api = json_decode($api['content'], true);
  2454. $gotTorrent = array();
  2455. if (is_array($api) || is_object($api)){
  2456. foreach ($api['arguments']['torrents'] AS $child) {
  2457. $downloadName = htmlentities($child['name'], ENT_QUOTES);
  2458. $downloadDirectory = $child['downloadDir'];
  2459. $downloadPercent = $child['percentDone'] * 100;
  2460. $progressBar = "progress-bar-striped active";
  2461. if($child['status'] == "6"){
  2462. $downloadStatus = "Seeding";
  2463. $downloadHealth = "success";
  2464. }elseif($child['status'] == "4"){
  2465. $downloadStatus = "Downloading";
  2466. $downloadHealth = "danger";
  2467. }elseif($child['status'] == "3"){
  2468. $downloadStatus = "Queued";
  2469. $downloadHealth = "warning";
  2470. }elseif($child['status'] == "0"){
  2471. $downloadStatus = "Complete";
  2472. $downloadHealth = "success";
  2473. }
  2474. $gotTorrent[] = '<tr>
  2475. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2476. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2477. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadDirectory.'</td>
  2478. <td class="col-xs-1 nzbtable nzbtable-row">'.realSize($child['totalSize']).'</td>
  2479. <td class="col-xs-2 nzbtable nzbtable-row">
  2480. <div class="progress">
  2481. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2482. <p class="text-center">'.round($downloadPercent).'%</p>
  2483. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2484. </div>
  2485. </div>
  2486. </td>
  2487. </tr>';
  2488. }
  2489. if ($gotTorrent) {
  2490. return implode('',$gotTorrent);
  2491. } else {
  2492. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2493. }
  2494. }else{
  2495. writeLog("error", "TRANSMISSION ERROR: could not connect - check URL and/or check token and/or Username and Password - if HTTPS, is cert valid");
  2496. }
  2497. }
  2498. // NzbGET Items
  2499. function nzbgetConnect($list = 'listgroups') {
  2500. $url = qualifyURL(NZBGETURL);
  2501. $api = curl_get($url.'/'.NZBGETUSERNAME.':'.NZBGETPASSWORD.'/jsonrpc/'.$list);
  2502. $api = json_decode($api, true);
  2503. $gotNZB = array();
  2504. if (is_array($api) || is_object($api)){
  2505. foreach ($api['result'] AS $child) {
  2506. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  2507. $downloadStatus = $child['Status'];
  2508. $downloadCategory = $child['Category'];
  2509. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  2510. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  2511. if($child['Health'] <= "750"){
  2512. $downloadHealth = "danger";
  2513. }elseif($child['Health'] <= "900"){
  2514. $downloadHealth = "warning";
  2515. }elseif($child['Health'] <= "1000"){
  2516. $downloadHealth = "success";
  2517. }
  2518. $gotNZB[] = '<tr>
  2519. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2520. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2521. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2522. <td class="col-xs-1 nzbtable nzbtable-row">'.realSize(($child['FileSizeMB']*1024)*1024).'</td>
  2523. <td class="col-xs-2 nzbtable nzbtable-row">
  2524. <div class="progress">
  2525. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2526. <p class="text-center">'.round($downloadPercent).'%</p>
  2527. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2528. </div>
  2529. </div>
  2530. </td>
  2531. </tr>';
  2532. }
  2533. if ($gotNZB) {
  2534. return implode('',$gotNZB);
  2535. } else {
  2536. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2537. }
  2538. }else{
  2539. writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Username and Password - if HTTPS, is cert valid");
  2540. }
  2541. }
  2542. // Sabnzbd Items
  2543. function sabnzbdConnect($list = 'queue') {
  2544. $url = qualifyURL(SABNZBDURL);
  2545. $api = @file_get_contents($url.'/api?mode='.$list.'&output=json&apikey='.SABNZBDKEY);
  2546. $api = json_decode($api, true);
  2547. $gotNZB = array();
  2548. if (is_array($api) || is_object($api)){
  2549. foreach ($api[$list]['slots'] AS $child) {
  2550. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  2551. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  2552. $downloadStatus = $child['status'];
  2553. $gotNZB[] = '<tr>
  2554. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2555. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2556. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2557. <td class="col-xs-1 nzbtable nzbtable-row">'.$child['size'].'</td>
  2558. <td class="col-xs-2 nzbtable nzbtable-row">
  2559. <div class="progress">
  2560. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2561. <p class="text-center">'.round($downloadPercent).'%</p>
  2562. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2563. </div>
  2564. </div>
  2565. </td>
  2566. </tr>';
  2567. }
  2568. if ($gotNZB) {
  2569. return implode('',$gotNZB);
  2570. } else {
  2571. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2572. }
  2573. }else{
  2574. writeLog("error", "SABNZBD ERROR: could not connect - check URL and/or check token - if HTTPS, is cert valid");
  2575. }
  2576. }
  2577. // Apply new tab settings
  2578. function updateTabs($tabs) {
  2579. if (!isset($GLOBALS['file_db'])) {
  2580. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2581. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2582. }
  2583. // Validate
  2584. if (!isset($tabs['defaultz'])) { $tabs['defaultz'][current(array_keys($tabs['name']))] = 'true'; }
  2585. if (isset($tabs['name']) && isset($tabs['url']) && is_array($tabs['name'])) {
  2586. // Clear Existing Tabs
  2587. $GLOBALS['file_db']->query("DELETE FROM tabs");
  2588. // Process New Tabs
  2589. $totalValid = 0;
  2590. foreach ($tabs['name'] as $key => $value) {
  2591. // Qualify
  2592. if (!$value || !isset($tabs['url']) || !$tabs['url'][$key]) { continue; }
  2593. $totalValid++;
  2594. $fields = array();
  2595. foreach(array('id','name','url','icon','iconurl','order','ping_url') as $v) {
  2596. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = $tabs[$v][$key]; }
  2597. }
  2598. foreach(array('active','user','guest','defaultz','window','splash','ping') as $v) {
  2599. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = ($tabs[$v][$key]!=='false'?'true':'false'); }
  2600. }
  2601. $GLOBALS['file_db']->query('INSERT INTO tabs (`'.implode('`,`',array_keys($fields)).'`) VALUES (\''.implode("','",$fields).'\');');
  2602. }
  2603. writeLog("success", "tabs successfully saved");
  2604. return $totalValid;
  2605. } else {
  2606. writeLog("error", "tabs could not save");
  2607. return false;
  2608. }
  2609. writeLog("error", "tabs could not save");
  2610. return false;
  2611. }
  2612. // ==============
  2613. function clean($strin) {
  2614. $strout = null;
  2615. for ($i = 0; $i < strlen($strin); $i++) {
  2616. $ord = ord($strin[$i]);
  2617. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  2618. $strout .= "&amp;#{$ord};";
  2619. }
  2620. else {
  2621. switch ($strin[$i]) {
  2622. case '<':
  2623. $strout .= '&lt;';
  2624. break;
  2625. case '>':
  2626. $strout .= '&gt;';
  2627. break;
  2628. case '&':
  2629. $strout .= '&amp;';
  2630. break;
  2631. case '"':
  2632. $strout .= '&quot;';
  2633. break;
  2634. default:
  2635. $strout .= $strin[$i];
  2636. }
  2637. }
  2638. }
  2639. return $strout;
  2640. }
  2641. function registration_callback($username, $email, $userdir){
  2642. global $data;
  2643. $data = array($username, $email, $userdir);
  2644. }
  2645. function printArray($arrayName){
  2646. $messageCount = count($arrayName);
  2647. $i = 0;
  2648. foreach ( $arrayName as $item ) :
  2649. $i++;
  2650. if($i < $messageCount) :
  2651. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  2652. elseif($i = $messageCount) :
  2653. echo "<small class='text-uppercase'>" . $item . "</small>";
  2654. endif;
  2655. endforeach;
  2656. }
  2657. function write_ini_file($content, $path) {
  2658. if (!$handle = fopen($path, 'w')) {
  2659. return false;
  2660. }
  2661. $success = fwrite($handle, trim($content));
  2662. fclose($handle);
  2663. return $success;
  2664. }
  2665. function gotTimezone(){
  2666. $regions = array(
  2667. 'Africa' => DateTimeZone::AFRICA,
  2668. 'America' => DateTimeZone::AMERICA,
  2669. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2670. 'Arctic' => DateTimeZone::ARCTIC,
  2671. 'Asia' => DateTimeZone::ASIA,
  2672. 'Atlantic' => DateTimeZone::ATLANTIC,
  2673. 'Australia' => DateTimeZone::AUSTRALIA,
  2674. 'Europe' => DateTimeZone::EUROPE,
  2675. 'Indian' => DateTimeZone::INDIAN,
  2676. 'Pacific' => DateTimeZone::PACIFIC
  2677. );
  2678. $timezones = array();
  2679. foreach ($regions as $name => $mask) {
  2680. $zones = DateTimeZone::listIdentifiers($mask);
  2681. foreach($zones as $timezone) {
  2682. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2683. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2684. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2685. }
  2686. }
  2687. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  2688. foreach($timezones as $region => $list) {
  2689. print '<optgroup label="' . $region . '">' . "\n";
  2690. foreach($list as $timezone => $name) {
  2691. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  2692. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  2693. }
  2694. print '</optgroup>' . "\n";
  2695. }
  2696. print '</select>';
  2697. }
  2698. function getTimezone(){
  2699. $regions = array(
  2700. 'Africa' => DateTimeZone::AFRICA,
  2701. 'America' => DateTimeZone::AMERICA,
  2702. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2703. 'Arctic' => DateTimeZone::ARCTIC,
  2704. 'Asia' => DateTimeZone::ASIA,
  2705. 'Atlantic' => DateTimeZone::ATLANTIC,
  2706. 'Australia' => DateTimeZone::AUSTRALIA,
  2707. 'Europe' => DateTimeZone::EUROPE,
  2708. 'Indian' => DateTimeZone::INDIAN,
  2709. 'Pacific' => DateTimeZone::PACIFIC
  2710. );
  2711. $timezones = array();
  2712. foreach ($regions as $name => $mask) {
  2713. $zones = DateTimeZone::listIdentifiers($mask);
  2714. foreach($zones as $timezone) {
  2715. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2716. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2717. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2718. }
  2719. }
  2720. print '<select name="timezone" id="timezone" class="form-control material" required>';
  2721. foreach($timezones as $region => $list) {
  2722. print '<optgroup label="' . $region . '">' . "\n";
  2723. foreach($list as $timezone => $name) {
  2724. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  2725. }
  2726. print '</optgroup>' . "\n";
  2727. }
  2728. print '</select>';
  2729. }
  2730. function explosion($string, $position){
  2731. $getWord = explode("|", $string);
  2732. return $getWord[$position];
  2733. }
  2734. function getServerPath() {
  2735. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  2736. $protocol = "https://";
  2737. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  2738. $protocol = "https://";
  2739. } else {
  2740. $protocol = "http://";
  2741. }
  2742. $domain = '';
  2743. if (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], '.') !== false){
  2744. $domain = $_SERVER['SERVER_NAME'];
  2745. }elseif(isset($_SERVER['HTTP_HOST'])){
  2746. if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
  2747. $domain = explode(':', $_SERVER['HTTP_HOST'])[0];
  2748. $port = explode(':', $_SERVER['HTTP_HOST'])[1];
  2749. if ($port == "80" || $port == "443"){
  2750. $domain = $domain;
  2751. }else{
  2752. $domain = $_SERVER['HTTP_HOST'];
  2753. }
  2754. }else{
  2755. $domain = $_SERVER['HTTP_HOST'];
  2756. }
  2757. }
  2758. return $protocol . $domain . str_replace("\\", "/", dirname($_SERVER['REQUEST_URI']));
  2759. }
  2760. function get_browser_name() {
  2761. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  2762. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  2763. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  2764. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  2765. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  2766. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  2767. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  2768. return 'Other';
  2769. }
  2770. function getSickrageCalendarWanted($array){
  2771. $array = json_decode($array, true);
  2772. //$gotCalendar = "";
  2773. $gotCalendar = array();
  2774. $i = 0;
  2775. foreach($array['data']['missed'] AS $child) {
  2776. $i++;
  2777. $seriesName = $child['show_name'];
  2778. $episodeID = $child['tvdbid'];
  2779. $episodeAirDate = $child['airdate'];
  2780. $episodeAirDateTime = explode(" ",$child['airs']);
  2781. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2782. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2783. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2784. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2785. $downloaded = "0";
  2786. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2787. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2788. array_push($gotCalendar, array(
  2789. "id" => "Sick-Miss-".$i,
  2790. "title" => $seriesName,
  2791. "start" => $episodeAirDate,
  2792. "className" => $downloaded." tvID--".$episodeID,
  2793. "imagetype" => "tv",
  2794. ));
  2795. }
  2796. foreach($array['data']['today'] AS $child) {
  2797. $i++;
  2798. $seriesName = $child['show_name'];
  2799. $episodeID = $child['tvdbid'];
  2800. $episodeAirDate = $child['airdate'];
  2801. $episodeAirDateTime = explode(" ",$child['airs']);
  2802. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2803. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2804. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2805. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2806. $downloaded = "0";
  2807. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2808. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2809. array_push($gotCalendar, array(
  2810. "id" => "Sick-Today-".$i,
  2811. "title" => $seriesName,
  2812. "start" => $episodeAirDate,
  2813. "className" => $downloaded." tvID--".$episodeID,
  2814. "imagetype" => "tv",
  2815. ));
  2816. }
  2817. foreach($array['data']['soon'] AS $child) {
  2818. $i++;
  2819. $seriesName = $child['show_name'];
  2820. $episodeID = $child['tvdbid'];
  2821. $episodeAirDate = $child['airdate'];
  2822. $episodeAirDateTime = explode(" ",$child['airs']);
  2823. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2824. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2825. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2826. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2827. $downloaded = "0";
  2828. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2829. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2830. array_push($gotCalendar, array(
  2831. "id" => "Sick-Soon-".$i,
  2832. "title" => $seriesName,
  2833. "start" => $episodeAirDate,
  2834. "className" => $downloaded." tvID--".$episodeID,
  2835. "imagetype" => "tv",
  2836. ));
  2837. }
  2838. foreach($array['data']['later'] AS $child) {
  2839. $i++;
  2840. $seriesName = $child['show_name'];
  2841. $episodeID = $child['tvdbid'];
  2842. $episodeAirDate = $child['airdate'];
  2843. $episodeAirDateTime = explode(" ",$child['airs']);
  2844. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2845. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2846. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2847. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2848. $downloaded = "0";
  2849. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2850. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2851. array_push($gotCalendar, array(
  2852. "id" => "Sick-Later-".$i,
  2853. "title" => $seriesName,
  2854. "start" => $episodeAirDate,
  2855. "className" => $downloaded." tvID--".$episodeID,
  2856. "imagetype" => "tv",
  2857. ));
  2858. }
  2859. if ($i != 0){ return $gotCalendar; }
  2860. }
  2861. function getSickrageCalendarHistory($array){
  2862. $array = json_decode($array, true);
  2863. //$gotCalendar = "";
  2864. $gotCalendar = array();
  2865. $i = 0;
  2866. foreach($array['data'] AS $child) {
  2867. $i++;
  2868. $seriesName = $child['show_name'];
  2869. $episodeID = $child['tvdbid'];
  2870. $episodeAirDate = $child['date'];
  2871. $downloaded = "green-bg";
  2872. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2873. array_push($gotCalendar, array(
  2874. "id" => "Sick-History-".$i,
  2875. "title" => $seriesName,
  2876. "start" => $episodeAirDate,
  2877. "className" => $downloaded." tvID--".$episodeID,
  2878. "imagetype" => "tv",
  2879. ));
  2880. }
  2881. if ($i != 0){ return $gotCalendar; }
  2882. }
  2883. function getSonarrCalendar($array){
  2884. $array = json_decode($array, true);
  2885. //$gotCalendar = "";
  2886. $gotCalendar = array();
  2887. $i = 0;
  2888. foreach($array AS $child) {
  2889. $i++;
  2890. $seriesName = $child['series']['title'];
  2891. $episodeID = $child['series']['tvdbId'];
  2892. if(!isset($episodeID)){ $episodeID = ""; }
  2893. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  2894. if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
  2895. $episodeAirDate = $child['airDateUtc'];
  2896. $episodeAirDate = strtotime($episodeAirDate);
  2897. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2898. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2899. $downloaded = $child['hasFile'];
  2900. 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"; }
  2901. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2902. array_push($gotCalendar, array(
  2903. "id" => "Sonarr-".$i,
  2904. "title" => $seriesName,
  2905. "start" => $episodeAirDate,
  2906. "className" => $downloaded." tvID--".$episodeID,
  2907. "imagetype" => "tv",
  2908. ));
  2909. }
  2910. if ($i != 0){ return $gotCalendar; }
  2911. }
  2912. function getCouchCalendar(){
  2913. $url = qualifyURL(COUCHURL);
  2914. $api = curl_get($url."/api/".COUCHAPI."/media.list");
  2915. $api = json_decode($api, true);
  2916. $i = 0;
  2917. $gotCalendar = array();
  2918. if (is_array($api) || is_object($api)){
  2919. foreach($api['movies'] AS $child) {
  2920. if($child['status'] == "active" || $child['status'] == "done" ){
  2921. $i++;
  2922. $movieName = $child['info']['original_title'];
  2923. $movieID = $child['info']['tmdb_id'];
  2924. if(!isset($movieID)){ $movieID = ""; }
  2925. $physicalRelease = (isset($child['info']['released']) ? $child['info']['released'] : null);
  2926. $backupRelease = (isset($child['info']['release_date']['theater']) ? $child['info']['release_date']['theater'] : null);
  2927. $physicalRelease = (isset($physicalRelease) ? $physicalRelease : $backupRelease);
  2928. $physicalRelease = strtotime($physicalRelease);
  2929. $physicalRelease = date("Y-m-d", $physicalRelease);
  2930. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2931. $downloaded = ($child['status'] == "active") ? "0" : "1";
  2932. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2933. array_push($gotCalendar, array(
  2934. "id" => "CouchPotato-".$i,
  2935. "title" => $movieName,
  2936. "start" => $physicalRelease,
  2937. "className" => $downloaded." movieID--".$movieID,
  2938. "imagetype" => "film",
  2939. ));
  2940. }
  2941. }
  2942. if ($i != 0){ return $gotCalendar; }
  2943. }else{
  2944. writeLog("error", "CouchPotato ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2945. }
  2946. }
  2947. function getRadarrCalendar($array){
  2948. $array = json_decode($array, true);
  2949. $gotCalendar = array();
  2950. $i = 0;
  2951. foreach($array AS $child) {
  2952. if(isset($child['physicalRelease'])){
  2953. $i++;
  2954. $movieName = $child['title'];
  2955. $movieID = $child['tmdbId'];
  2956. if(!isset($movieID)){ $movieID = ""; }
  2957. $physicalRelease = $child['physicalRelease'];
  2958. $physicalRelease = strtotime($physicalRelease);
  2959. $physicalRelease = date("Y-m-d", $physicalRelease);
  2960. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2961. $downloaded = $child['hasFile'];
  2962. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2963. array_push($gotCalendar, array(
  2964. "id" => "Radarr-".$i,
  2965. "title" => $movieName,
  2966. "start" => $physicalRelease,
  2967. "className" => $downloaded." movieID--".$movieID,
  2968. "imagetype" => "film",
  2969. ));
  2970. }
  2971. }
  2972. if ($i != 0){ return $gotCalendar; }
  2973. }
  2974. function getHeadphonesCalendar($url, $key, $list){
  2975. $url = qualifyURL(HEADPHONESURL);
  2976. $api = curl_get($url."/api?apikey=".$key."&cmd=$list");
  2977. $api = json_decode($api, true);
  2978. $i = 0;
  2979. //$gotCalendar = "";
  2980. $gotCalendar = array();;
  2981. if (is_array($api) || is_object($api)){
  2982. foreach($api AS $child) {
  2983. if($child['Status'] == "Wanted" && $list == "getWanted" && $child['ReleaseDate']){
  2984. $i++;
  2985. $albumName = addslashes($child['AlbumTitle']);
  2986. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  2987. $albumDate = (strlen($child['ReleaseDate']) > 4) ? $child['ReleaseDate'] : $child['ReleaseDate']."-01-01";
  2988. $albumID = $child['AlbumID'];
  2989. $albumDate = strtotime($albumDate);
  2990. $albumDate = date("Y-m-d", $albumDate);
  2991. $albumStatus = $child['Status'];
  2992. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2993. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  2994. //$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2995. array_push($gotCalendar, array(
  2996. "id" => "Headphones-".$i,
  2997. "title" => $albumArtist.' - '.$albumName,
  2998. "start" => $albumDate,
  2999. "className" => $albumStatusColor,
  3000. "imagetype" => "music",
  3001. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  3002. ));
  3003. }
  3004. if($child['Status'] == "Processed" && $list == "getHistory"){
  3005. $i++;
  3006. $find = array('_','[', ']', '\n');
  3007. $replace = array(' ','(', ')', ' ');
  3008. $albumName = addslashes(str_replace($find,$replace,$child['FolderName']));
  3009. $albumDate = $child['DateAdded'];
  3010. $albumID = $child['AlbumID'];
  3011. $albumDate = strtotime($albumDate);
  3012. $albumDate = date("Y-m-d", $albumDate);
  3013. $albumStatusColor = "green-bg";
  3014. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  3015. //$gotCalendar .= "{ title: \"$albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  3016. array_push($gotCalendar, array(
  3017. "id" => "Headphones-".$i,
  3018. "title" => $albumName,
  3019. "start" => $albumDate,
  3020. "className" => $albumStatusColor,
  3021. "imagetype" => "music",
  3022. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  3023. ));
  3024. }
  3025. }
  3026. if ($i != 0){ return $gotCalendar; }
  3027. }else{
  3028. writeLog("error", "HEADPHONES $list ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  3029. }
  3030. }
  3031. function checkRootPath($string){
  3032. if($string == "\\" || $string == "/"){
  3033. return "/";
  3034. }else{
  3035. return str_replace("\\", "/", $string) . "/";
  3036. }
  3037. }
  3038. function strip($string){
  3039. $string = strip_tags($string);
  3040. return preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $string));
  3041. }
  3042. function writeLog($type, $message){
  3043. if(file_exists(DATABASE_LOCATION."org.log")){
  3044. if(filesize(DATABASE_LOCATION."org.log") > 500000){
  3045. rename(DATABASE_LOCATION.'org.log',DATABASE_LOCATION.'org['.date('Y-m-d').'].log');
  3046. $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";
  3047. file_put_contents(DATABASE_LOCATION."org.log", $message2, FILE_APPEND | LOCK_EX);
  3048. }
  3049. }
  3050. $message = date("Y-m-d H:i:s")."|".$type."|".strip($message)."\n";
  3051. file_put_contents(DATABASE_LOCATION."org.log", $message, FILE_APPEND | LOCK_EX);
  3052. }
  3053. function readLog(){
  3054. $log = file(DATABASE_LOCATION."org.log",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3055. $log = array_reverse($log);
  3056. foreach($log as $line){
  3057. if(substr_count($line, '|') == 2){
  3058. $line = explode("|", strip($line));
  3059. $line[1] = ($line[1] == "error") ? '<span class="label label-danger">Error</span>' : '<span class="label label-primary">Success</span>';
  3060. echo "<tr><td>".$line[0]."</td><td>".$line[2]."</td><td>".$line[1]."</td></tr>";
  3061. }
  3062. }
  3063. }
  3064. function buildStream($array){
  3065. $result = "";
  3066. if (array_key_exists('platform', $array)) {
  3067. $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>';
  3068. }
  3069. if (array_key_exists('device', $array)) {
  3070. $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>';
  3071. }
  3072. if (array_key_exists('stream', $array)) {
  3073. $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>';
  3074. }
  3075. if (array_key_exists('video', $array)) {
  3076. $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>';
  3077. }
  3078. if (array_key_exists('audio', $array)) {
  3079. $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>';
  3080. }
  3081. return $result;
  3082. }
  3083. function streamType($value){
  3084. if($value == "transcode" || $value == "Transcode"){
  3085. return "Transcode";
  3086. }elseif($value == "copy" || $value == "DirectStream"){
  3087. return "Direct Stream";
  3088. }elseif($value == "directplay" || $value == "DirectPlay"){
  3089. return "Direct Play";
  3090. }else{
  3091. return "Direct Play";
  3092. }
  3093. }
  3094. function getPlatform($platform){
  3095. $allPlatforms = array(
  3096. "Chrome" => "chrome.png",
  3097. "tvOS" => "atv.png",
  3098. "iOS" => "ios.png",
  3099. "Xbox One" => "xbox.png",
  3100. "Mystery 4" => "playstation.png",
  3101. "Samsung" => "samsung.png",
  3102. "Roku" => "roku.png",
  3103. "Emby for iOS" => "ios.png",
  3104. "Emby Mobile" => "emby.png",
  3105. "Emby Theater" => "emby.png",
  3106. "Emby Classic" => "emby.png",
  3107. "Safari" => "safari.png",
  3108. "Android" => "android.png",
  3109. "AndroidTv" => "android.png",
  3110. "Chromecast" => "chromecast.png",
  3111. "Dashboard" => "emby.png",
  3112. "Dlna" => "dlna.png",
  3113. "Windows Phone" => "wp.png",
  3114. "Windows RT" => "win8.png",
  3115. "Kodi" => "kodi.png",
  3116. );
  3117. if (array_key_exists($platform, $allPlatforms)) {
  3118. return $allPlatforms[$platform];
  3119. }else{
  3120. return "pmp.png";
  3121. }
  3122. }
  3123. function getServer(){
  3124. $server = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"];
  3125. return $server;
  3126. }
  3127. function prettyPrint($array) {
  3128. echo "<pre>";
  3129. print_r($array);
  3130. echo "</pre>";
  3131. echo "<br/>";
  3132. }
  3133. function checkFrame($array, $url){
  3134. if(array_key_exists("x-frame-options", $array)){
  3135. if($array['x-frame-options'] == "deny"){
  3136. return false;
  3137. }elseif($array['x-frame-options'] == "sameorgin"){
  3138. $digest = parse_url($url);
  3139. $host = (isset($digest['host'])?$digest['host']:'');
  3140. if(getServer() == $host){
  3141. return true;
  3142. }else{
  3143. return false;
  3144. }
  3145. }
  3146. }else{
  3147. if(!$array){
  3148. return false;
  3149. }
  3150. return true;
  3151. }
  3152. }
  3153. function frameTest($url){
  3154. $array = array_change_key_case(get_headers(qualifyURL($url), 1));
  3155. $url = qualifyURL($url);
  3156. if(checkFrame($array, $url)){
  3157. return true;
  3158. }else{
  3159. return false;
  3160. }
  3161. }
  3162. function sendResult($result, $icon = "floppy-o", $message = false, $success = "WAS_SUCCESSFUL", $fail = "HAS_FAILED", $send = true) {
  3163. $notifyExplode = explode("-", NOTIFYEFFECT);
  3164. if ($result) {
  3165. $msg = array(
  3166. 'html' => ($message?''.$message.' <strong>'.translate($success).'</strong>':'<strong>'.translate($success).'</strong>'),
  3167. 'icon' => $icon,
  3168. 'type' => 'success',
  3169. 'length' => '5000',
  3170. 'layout' => $notifyExplode[0],
  3171. 'effect' => $notifyExplode[1],
  3172. );
  3173. } else {
  3174. $msg = array(
  3175. 'html' => ($message?''.$message.' <strong>'.translate($fail).'</strong>':'<strong>'.translate($fail).'</strong>'),
  3176. 'icon' => $icon,
  3177. 'type' => 'error',
  3178. 'length' => '5000',
  3179. 'layout' => $notifyExplode[0],
  3180. 'effect' => $notifyExplode[1],
  3181. );
  3182. }
  3183. // Send and kill script?
  3184. if ($send) {
  3185. header('Content-Type: application/json');
  3186. echo json_encode(array('notify'=>$msg));
  3187. die();
  3188. }
  3189. return $msg;
  3190. }
  3191. function buildHomepageNotice($layout, $type, $title, $message){
  3192. switch ($layout) {
  3193. case 'elegant':
  3194. return '
  3195. <div id="homepageNotice" class="row">
  3196. <div class="col-lg-12">
  3197. <div class="content-box big-box box-shadow panel-box panel-'.$type.'">
  3198. <div class="content-title i-block">
  3199. <h4 class="zero-m"><strong>'.$title.'</strong></h4>
  3200. <div class="content-tools i-block pull-right">
  3201. <a class="close-btn">
  3202. <i class="fa fa-times"></i>
  3203. </a>
  3204. </div>
  3205. </div>
  3206. '.$message.'
  3207. </div>
  3208. </div>
  3209. </div>
  3210. ';
  3211. break;
  3212. case 'basic':
  3213. return '
  3214. <div id="homepageNotice" class="row">
  3215. <div class="col-lg-12">
  3216. <div class="panel panel-'.$type.'">
  3217. <div class="panel-heading">
  3218. <h3 class="panel-title">'.$title.'</h3>
  3219. </div>
  3220. <div class="panel-body">
  3221. '.$message.'
  3222. </div>
  3223. </div>
  3224. </div>
  3225. </div>
  3226. ';
  3227. break;
  3228. case 'jumbotron';
  3229. return '
  3230. <div id="homepageNotice" class="row">
  3231. <div class="col-lg-12">
  3232. <div class="jumbotron">
  3233. <div class="container">
  3234. <h1>'.$title.'</h1>
  3235. <p>'.$message.'</p>
  3236. </div>
  3237. </div>
  3238. </div>
  3239. </div>
  3240. ';
  3241. }
  3242. }
  3243. function embyArray($array, $type) {
  3244. $key = ($type == "video" ? "Height" : "Channels");
  3245. if (array_key_exists($key, $array)) {
  3246. switch ($type) {
  3247. case "video":
  3248. $codec = $array["Codec"];
  3249. $height = $array["Height"];
  3250. $width = $array["Width"];
  3251. break;
  3252. default:
  3253. $codec = $array["Codec"];
  3254. $channels = $array["Channels"];
  3255. }
  3256. return ($type == "video" ? "(".$codec.") (".$width."x".$height.")" : "(".$codec.") (".$channels."ch)");
  3257. }
  3258. foreach ($array as $element) {
  3259. if (is_array($element)) {
  3260. if (embyArray($element, $type)) {
  3261. return embyArray($element, $type);
  3262. }
  3263. }
  3264. }
  3265. }
  3266. // Get Now Playing Streams From Plex
  3267. function searchPlex($query){
  3268. $address = qualifyURL(PLEXURL);
  3269. $openTab = (PLEXTABNAME) ? "true" : "false";
  3270. // Perform API requests
  3271. $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
  3272. libxml_use_internal_errors(true);
  3273. $api = simplexml_load_string($api);
  3274. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3275. if (!$getServer) { return 'Could not load!'; }
  3276. // Identify the local machine
  3277. $server = $getServer['machineIdentifier'];
  3278. $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>";
  3279. $items = "";
  3280. $albums = $movies = $shows = 0;
  3281. $style = 'style="vertical-align: middle"';
  3282. foreach($api AS $child) {
  3283. if($child['type'] != "artist" && $child['type'] != "episode" && isset($child['librarySectionID'])){
  3284. $time = (string)$child['addedAt'];
  3285. $time = new DateTime("@$time");
  3286. $results = array(
  3287. "title" => (string)$child['title'],
  3288. "image" => (string)$child['thumb'],
  3289. "type" => (string)ucwords($child['type']),
  3290. "year" => (string)$child['year'],
  3291. "key" => (string)$child['ratingKey']."-search",
  3292. "ratingkey" => (string)$child['ratingKey'],
  3293. "genre" => (string)$child->Genre['tag'],
  3294. "added" => $time->format('Y-m-d'),
  3295. "extra" => "",
  3296. );
  3297. switch ($child['type']){
  3298. case "album":
  3299. $push = array(
  3300. "title" => (string)$child['parentTitle']." - ".(string)$child['title'],
  3301. );
  3302. $results = array_replace($results,$push);
  3303. $albums++;
  3304. break;
  3305. case "movie":
  3306. $push = array(
  3307. "extra" => "Content Rating: ".(string)$child['contentRating']."<br/>Movie Rating: ".(string)$child['rating'],
  3308. );
  3309. $results = array_replace($results,$push);
  3310. $movies++;
  3311. break;
  3312. case "show":
  3313. $push = array(
  3314. "extra" => "Seasons: ".(string)$child['childCount']."<br/>Episodes: ".(string)$child['leafCount'],
  3315. );
  3316. $results = array_replace($results,$push);
  3317. $shows++;
  3318. break;
  3319. }
  3320. if (file_exists('images/cache/'.$results['key'].'.jpg')){ $image_url = 'images/cache/'.$results['key'].'.jpg'; }
  3321. if (file_exists('images/cache/'.$results['key'].'.jpg') && (time() - 604800) > filemtime('images/cache/'.$results['key'].'.jpg') || !file_exists('images/cache/'.$results['key'].'.jpg')) {
  3322. $image_url = 'ajax.php?a=plex-image&img='.$results['image'].'&height=150&width=100&key='.$results['key'];
  3323. }
  3324. if(!$results['image']){ $image_url = "images/no-search.png"; $key = "no-search"; }
  3325. if (PLEXTABURL) {
  3326. $link = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3327. }else{
  3328. $link = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3329. }
  3330. $items .= '<tr style="cursor: pointer;" class="openTab" extraTitle="'.$results['title'].'" extraType="'.$child['type'].'" openTab="'.$openTab.'" href="'.$link.'">
  3331. <th scope="row"><img src="'.$image_url.'"></th>
  3332. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
  3333. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
  3334. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
  3335. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
  3336. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
  3337. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['extra'].'</td>
  3338. </tr>';
  3339. }
  3340. }
  3341. $totals = '<div style="margin: 10px;" class="sort-todo pull-right">
  3342. <span class="badge gray-bg"><i class="fa fa-film fa-2x white"></i><strong style="
  3343. font-size: 23px;
  3344. ">&nbsp;'.$movies.'</strong></span>
  3345. <span class="badge gray-bg"><i class="fa fa-tv fa-2x white"></i><strong style="
  3346. font-size: 23px;
  3347. ">&nbsp;'.$shows.'</strong></span>
  3348. <span class="badge gray-bg"><i class="fa fa-music fa-2x white"></i><strong style="
  3349. font-size: 23px;
  3350. ">&nbsp;'.$albums.'</strong></span>
  3351. </div>';
  3352. return (!empty($items) ? $totals.$pre.$items."</div></table>" : "<h2 class='text-center'>No Results for $query</h2>" );
  3353. }
  3354. function getBannedUsers($string){
  3355. if (strpos($string, ',') !== false) {
  3356. $banned = explode(",", $string);
  3357. }else{
  3358. $banned = array($string);
  3359. }
  3360. return $banned;
  3361. }
  3362. function getWhitelist($string){
  3363. if (strpos($string, ',') !== false) {
  3364. $whitelist = explode(",", $string);
  3365. }else{
  3366. $whitelist = array($string);
  3367. }
  3368. foreach($whitelist as &$ip){
  3369. $ip = is_numeric(substr($ip, 0, 1)) ? $ip : gethostbyname($ip);
  3370. }
  3371. return $whitelist;
  3372. }
  3373. function get_client_ip() {
  3374. $ipaddress = '';
  3375. if (isset($_SERVER['HTTP_CLIENT_IP']))
  3376. $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
  3377. else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  3378. $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
  3379. else if(isset($_SERVER['HTTP_X_FORWARDED']))
  3380. $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
  3381. else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
  3382. $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
  3383. else if(isset($_SERVER['HTTP_FORWARDED']))
  3384. $ipaddress = $_SERVER['HTTP_FORWARDED'];
  3385. else if(isset($_SERVER['REMOTE_ADDR']))
  3386. $ipaddress = $_SERVER['REMOTE_ADDR'];
  3387. else
  3388. $ipaddress = 'UNKNOWN';
  3389. return $ipaddress;
  3390. }
  3391. //EMAIL SHIT
  3392. function sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null){
  3393. $mail = new PHPMailer;
  3394. $mail->isSMTP();
  3395. $mail->Host = SMTPHOST;
  3396. $mail->SMTPAuth = SMTPHOSTAUTH;
  3397. $mail->Username = SMTPHOSTUSERNAME;
  3398. $mail->Password = SMTPHOSTPASSWORD;
  3399. $mail->SMTPSecure = SMTPHOSTTYPE;
  3400. $mail->Port = SMTPHOSTPORT;
  3401. $mail->setFrom(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3402. $mail->addReplyTo(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3403. $mail->isHTML(true);
  3404. if($email){
  3405. $mail->addAddress($email, $username);
  3406. }
  3407. if($cc){
  3408. $mail->addCC($cc);
  3409. }
  3410. if($bcc){
  3411. if(strpos($bcc , ',') === false){
  3412. $mail->addBCC($bcc);
  3413. }else{
  3414. $allEmails = explode(",",$bcc);
  3415. foreach($allEmails as $gotEmail){
  3416. $mail->addBCC($gotEmail);
  3417. }
  3418. }
  3419. }
  3420. $mail->Subject = $subject;
  3421. $mail->Body = $body;
  3422. //$mail->send();
  3423. if(!$mail->send()) {
  3424. writeLog("error", "mail failed to send");
  3425. } else {
  3426. writeLog("success", "mail has been sent");
  3427. }
  3428. }
  3429. //EMAIL SHIT
  3430. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  3431. $mail = new PHPMailer;
  3432. $mail->isSMTP();
  3433. $mail->Host = $host;
  3434. $mail->SMTPAuth = $auth;
  3435. $mail->Username = $username;
  3436. $mail->Password = $password;
  3437. $mail->SMTPSecure = $type;
  3438. $mail->Port = $port;
  3439. $mail->setFrom($from, $sendername);
  3440. $mail->addReplyTo($from, $sendername);
  3441. $mail->isHTML(true);
  3442. $mail->addAddress($to, "Organizr Admin");
  3443. $mail->Subject = "Organizr Test E-Mail";
  3444. $mail->Body = "This was just a test!";
  3445. //$mail->send();
  3446. if(!$mail->send()) {
  3447. writeLog("error", "EMAIL TEST: mail failed to send - Error:".$mail->ErrorInfo);
  3448. return false;
  3449. } else {
  3450. writeLog("success", "EMAIL TEST: mail has been sent successfully");
  3451. return true;
  3452. }
  3453. }
  3454. function libraryList(){
  3455. $address = qualifyURL(PLEXURL);
  3456. $headers = array(
  3457. "Accept" => "application/json",
  3458. "X-Plex-Token" => PLEXTOKEN
  3459. );
  3460. libxml_use_internal_errors(true);
  3461. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3462. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3463. $api = simplexml_load_string(@curl_get("https://plex.tv/api/servers/$gotServer/shared_servers", $headers));
  3464. $libraryList = array();
  3465. foreach($api->SharedServer->Section AS $child) {
  3466. $libraryList['libraries'][(string)$child['title']] = (string)$child['id'];
  3467. }
  3468. foreach($api->SharedServer AS $child) {
  3469. if(!empty($child['username'])){
  3470. $username = (string)strtolower($child['username']);
  3471. $email = (string)strtolower($child['email']);
  3472. $libraryList['users'][$username] = (string)$child['id'];
  3473. $libraryList['emails'][$email] = (string)$child['id'];
  3474. $libraryList['both'][$username] = $email;
  3475. }
  3476. }
  3477. return (!empty($libraryList) ? array_change_key_case($libraryList,CASE_LOWER) : null );
  3478. }
  3479. function plexUserShare($username){
  3480. $address = qualifyURL(PLEXURL);
  3481. $headers = array(
  3482. "Accept" => "application/json",
  3483. "Content-Type" => "application/json",
  3484. "X-Plex-Token" => PLEXTOKEN
  3485. );
  3486. libxml_use_internal_errors(true);
  3487. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3488. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3489. $json = array(
  3490. "server_id" => $gotServer,
  3491. "shared_server" => array(
  3492. //"library_section_ids" => "[26527637]",
  3493. "invited_email" => $username
  3494. )
  3495. );
  3496. $api = curl_post("https://plex.tv/api/servers/$gotServer/shared_servers/", $json, $headers);
  3497. switch ($api['http_code']['http_code']){
  3498. case 400:
  3499. writeLog("error", "PLEX INVITE: $username already has access to the shared libraries");
  3500. $result = "$username already has access to the shared libraries";
  3501. break;
  3502. case 401:
  3503. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3504. $result = "Invalid Plex Token";
  3505. break;
  3506. case 200:
  3507. writeLog("success", "PLEX INVITE: $username now has access to your Plex Library");
  3508. $result = "$username now has access to your Plex Library";
  3509. break;
  3510. default:
  3511. writeLog("error", "PLEX INVITE: unknown error");
  3512. $result = false;
  3513. }
  3514. return (!empty($result) ? $result : null );
  3515. }
  3516. function plexUserDelete($username){
  3517. $address = qualifyURL(PLEXURL);
  3518. $headers = array(
  3519. "Accept" => "application/json",
  3520. "Content-Type" => "application/json",
  3521. "X-Plex-Token" => PLEXTOKEN
  3522. );
  3523. libxml_use_internal_errors(true);
  3524. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3525. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3526. $id = (is_numeric($username) ? $id : convertPlexName($username, "id"));
  3527. $api = curl_delete("https://plex.tv/api/servers/$gotServer/shared_servers/$id", $headers);
  3528. switch ($api['http_code']['http_code']){
  3529. case 401:
  3530. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3531. $result = "Invalid Plex Token";
  3532. break;
  3533. case 200:
  3534. writeLog("success", "PLEX INVITE: $username doesn't have access to your Plex Library anymore");
  3535. $result = "$username doesn't have access to your Plex Library anymore";
  3536. break;
  3537. default:
  3538. writeLog("error", "PLEX INVITE: unknown error");
  3539. $result = false;
  3540. }
  3541. return (!empty($result) ? $result : null );
  3542. }
  3543. function convertPlexName($user, $type){
  3544. $array = libraryList();
  3545. switch ($type){
  3546. case "username":
  3547. $plexUser = array_search ($user, $array['users']);
  3548. break;
  3549. case "id":
  3550. if (array_key_exists(strtolower($user), $array['users'])) {
  3551. $plexUser = $array['users'][strtolower($user)];
  3552. }
  3553. break;
  3554. default:
  3555. $plexUser = false;
  3556. }
  3557. return (!empty($plexUser) ? $plexUser : null );
  3558. }
  3559. function randomCode($length = 5, $type = null) {
  3560. switch ($type){
  3561. case "alpha":
  3562. $legend = array_merge(range('A', 'Z'));
  3563. break;
  3564. case "numeric":
  3565. $legend = array_merge(range(0,9));
  3566. break;
  3567. default:
  3568. $legend = array_merge(range(0,9),range('A', 'Z'));
  3569. }
  3570. $code = "";
  3571. for($i=0; $i < $length; $i++) {
  3572. $code .= $legend[mt_rand(0, count($legend) - 1)];
  3573. }
  3574. return $code;
  3575. }
  3576. function inviteCodes($action, $code = null, $usedBy = null) {
  3577. if (!isset($GLOBALS['file_db'])) {
  3578. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  3579. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  3580. }
  3581. $now = date("Y-m-d H:i:s");
  3582. switch ($action) {
  3583. case "get":
  3584. // Start Array
  3585. $result = array();
  3586. // Database Lookup
  3587. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes"');
  3588. // Get Codes
  3589. foreach($invites as $row) {
  3590. array_push($result, $row['code']);
  3591. }
  3592. // Return the Results
  3593. return (!empty($result) ? $result : false );
  3594. break;
  3595. case "check":
  3596. // Start Array
  3597. $result = array();
  3598. // Database Lookup
  3599. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes" AND code = "'.$code.'"');
  3600. // Get Codes
  3601. foreach($invites as $row) {
  3602. $result = $row['code'];
  3603. }
  3604. // Return the Results
  3605. return (!empty($result) ? $result : false );
  3606. break;
  3607. case "use":
  3608. $currentIP = get_client_ip();
  3609. $invites = $GLOBALS['file_db']->query('UPDATE invites SET valid = "No", usedby = "'.$usedBy.'", dateused = "'.$now.'", ip = "'.$currentIP.'" WHERE code = "'.$code.'"');
  3610. if(ENABLEMAIL){
  3611. if (!isset($GLOBALS['USER'])) {
  3612. require_once("user.php");
  3613. $GLOBALS['USER'] = new User('registration_callback');
  3614. }
  3615. $emailTemplate = array(
  3616. 'type' => 'mass',
  3617. 'body' => 'The user: {user} has reddemed the code: {inviteCode} his IP Address was '.$currentIP,
  3618. 'subject' => 'Invite Code '.$code.' Has Been Used',
  3619. 'user' => $usedBy,
  3620. 'password' => null,
  3621. 'inviteCode' => $code,
  3622. );
  3623. $emailTemplate = emailTemplate($emailTemplate);
  3624. $subject = $emailTemplate['subject'];
  3625. $body = buildEmail($emailTemplate);
  3626. sendEmail($GLOBALS['USER']->adminEmail, "Admin", $subject, $body);
  3627. }
  3628. return (!empty($invites) ? true : false );
  3629. break;
  3630. }
  3631. }
  3632. function plexJoin($username, $email, $password){
  3633. $connectURL = 'https://plex.tv/users.json';
  3634. $headers = array(
  3635. 'Accept'=> 'application/json',
  3636. 'Content-Type' => 'application/x-www-form-urlencoded',
  3637. 'X-Plex-Product' => 'Organizr',
  3638. 'X-Plex-Version' => '1.0',
  3639. 'X-Plex-Client-Identifier' => '01010101-10101010',
  3640. );
  3641. $body = array(
  3642. 'user[email]' => $email,
  3643. 'user[username]' => $username,
  3644. 'user[password]' => $password,
  3645. );
  3646. $api = curl_post($connectURL, $body, $headers);
  3647. $json = json_decode($api['content'], true);
  3648. $errors = (!empty($json['errors']) ? true : false);
  3649. $success = (!empty($json['user']) ? true : false);
  3650. //Use This for later
  3651. $usernameError = (!empty($json['errors']['username']) ? $json['errors']['username'][0] : false);
  3652. $emailError = (!empty($json['errors']['email']) ? $json['errors']['email'][0] : false);
  3653. $passwordError = (!empty($json['errors']['password']) ? $json['errors']['password'][0] : false);
  3654. $errorMessage = "";
  3655. if($errors){
  3656. if($usernameError){ $errorMessage .= "[Username Error: ". $usernameError ."]"; }
  3657. if($emailError){ $errorMessage .= "[Email Error: ". $emailError ."]"; }
  3658. if($passwordError){ $errorMessage .= "[Password Error: ". $passwordError ."]"; }
  3659. }
  3660. switch ($api['http_code']['http_code']){
  3661. case 400:
  3662. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." $username already has access to the shared libraries $errorMessage");
  3663. break;
  3664. case 401:
  3665. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." invalid Plex Token $errorMessage");
  3666. break;
  3667. case 422:
  3668. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." user info error $errorMessage");
  3669. break;
  3670. case 429:
  3671. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." too many requests to plex.tv please try later $errorMessage");
  3672. break;
  3673. case 200:
  3674. case 201:
  3675. writeLog("success", "PLEX JOIN: $username now has access to your Plex Library");
  3676. break;
  3677. default:
  3678. writeLog("error", "PLEX JOIN: unknown error, $errorMessage Error: ".$api['http_code']['http_code']);
  3679. }
  3680. //prettyPrint($api);
  3681. //prettyPrint(json_decode($api['content'], true));
  3682. return (!empty($success) && empty($errors) ? true : false );
  3683. }
  3684. function getCert(){
  3685. $url = "http://curl.haxx.se/ca/cacert.pem";
  3686. $file = getcwd()."/config/cacert.pem";
  3687. $directory = getcwd()."/config/";
  3688. @mkdir($directory, 0770, true);
  3689. if(!file_exists($file)){
  3690. file_put_contents( $file, fopen($url, 'r'));
  3691. writeLog("success", "CERT PEM: pem file created");
  3692. }elseif (file_exists($file) && time() - 2592000 > filemtime($file)) {
  3693. file_put_contents( $file, fopen($url, 'r'));
  3694. writeLog("success", "CERT PEM: downloaded new pem file");
  3695. }
  3696. return $file;
  3697. }
  3698. function customCSS(){
  3699. if(CUSTOMCSS == "true") {
  3700. $template_file = "custom.css";
  3701. $file_handle = fopen($template_file, "rb");
  3702. echo "\n";
  3703. echo fread($file_handle, filesize($template_file));
  3704. fclose($file_handle);
  3705. echo "\n";
  3706. }
  3707. }
  3708. function tvdbToken(){
  3709. $headers = array(
  3710. "Accept" => "application/json",
  3711. "Content-Type" => "application/json"
  3712. );
  3713. $json = array(
  3714. "apikey" => "FBE7B62621F4CAD7",
  3715. "userkey" => "328BB46EB1E9A0F5",
  3716. "username" => "causefx"
  3717. );
  3718. $api = curl_post("https://api.thetvdb.com/login", $json, $headers);
  3719. return json_decode($api['content'], true)['token'];
  3720. }
  3721. function tvdbGet($id){
  3722. $headers = array(
  3723. "Accept" => "application/json",
  3724. "Authorization" => "Bearer ".tvdbToken(),
  3725. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3726. "trakt-api-version" => "2"
  3727. );
  3728. $trakt = curl_get("https://api.trakt.tv/search/tvdb/$id?type=show", $headers);
  3729. @$api['trakt'] = json_decode($trakt, true)[0]['show']['ids'];
  3730. if(empty($api['trakt'])){
  3731. $series = curl_get("https://api.thetvdb.com/series/$id", $headers);
  3732. $poster = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=poster", $headers);
  3733. $backdrop = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=fanart", $headers);
  3734. $api['series'] = json_decode($series, true)['data'];
  3735. $api['poster'] = json_decode($poster, true)['data'];
  3736. $api['backdrop'] = json_decode($backdrop, true)['data'];
  3737. }
  3738. return $api;
  3739. }
  3740. function tvdbSearch($name, $type){
  3741. $name = rawurlencode(preg_replace("/\(([^()]*+|(?R))*\)/","", $name));
  3742. $headers = array(
  3743. "Accept" => "application/json",
  3744. "Authorization" => "Bearer ".tvdbToken(),
  3745. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3746. "trakt-api-version" => "2"
  3747. );
  3748. $trakt = curl_get("https://api.trakt.tv/search/$type?query=$name", $headers);
  3749. @$api['trakt'] = json_decode($trakt, true)[0][$type]['ids'];
  3750. return $api;
  3751. }
  3752. function getPlexPlaylists(){
  3753. $address = qualifyURL(PLEXURL);
  3754. // Perform API requests
  3755. $api = @curl_get($address."/playlists?X-Plex-Token=".PLEXTOKEN);
  3756. libxml_use_internal_errors(true);
  3757. $api = simplexml_load_string($api);
  3758. if (is_array($api) || is_object($api)){
  3759. if (!$api->head->title){
  3760. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3761. if (!$getServer) { return 'Could not load!'; }
  3762. // Identify the local machine
  3763. $gotServer = $getServer['machineIdentifier'];
  3764. $output = "";
  3765. $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">';
  3766. foreach($api AS $child) {
  3767. $items = array();
  3768. if ($child['playlistType'] == "video" && strpos(strtolower($child['title']) , 'private') === false){
  3769. $api = @curl_get($address.$child['key']."?X-Plex-Token=".PLEXTOKEN);
  3770. $api = simplexml_load_string($api);
  3771. if (is_array($api) || is_object($api)){
  3772. if (!$api->head->title){
  3773. $className = preg_replace("/(\W)+/", "", $api['title']);
  3774. $hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  3775. foreach($api->Video AS $child){
  3776. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false,false,$className);
  3777. }
  3778. if (count($items)) {
  3779. $output .= ''.implode('',$items).'';
  3780. }
  3781. }
  3782. }
  3783. }
  3784. }
  3785. $hideMenu .= '</ul></div></div>';
  3786. 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>';
  3787. }else{
  3788. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check token - if HTTPS, is cert valid");
  3789. }
  3790. }else{
  3791. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check URL - if HTTPS, is cert valid");
  3792. }
  3793. }
  3794. function readExternalLog($type,$filename,$name = null){
  3795. $log = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3796. $log = array_reverse($log);
  3797. foreach($log as $line){
  3798. if(!empty($line) && $line[0] != " "){
  3799. $line = strip($line);
  3800. if($type == "single"){
  3801. if( strpos( strtolower($line), "ror" ) !== false ) {
  3802. echo "<tr><td class='red-bg'>".$line."</td></tr>";
  3803. }else{
  3804. echo "<tr><td>".$line."</td></tr>";
  3805. }
  3806. }elseif($type == "all"){
  3807. if( strpos( strtolower($line), "ror" ) !== false ) {
  3808. echo "<tr><td class='red-bg'>".$name."</td>";
  3809. echo "<td class='red-bg'>".$line."</td></tr>";
  3810. }else{
  3811. echo "<tr><td>".$name."</td>";
  3812. echo "<td>".$line."</td></tr>";
  3813. }
  3814. }
  3815. }
  3816. }
  3817. }
  3818. function getLogs(){
  3819. $path = __DIR__ ."/logs/";
  3820. @mkdir($path, 0770, true);
  3821. $logs = array();
  3822. $files = array_diff(scandir($path), array('.', '..'));
  3823. foreach($files as $v){
  3824. $title = explode(".", $v)[0];
  3825. $logs[$title] = $path.$v;
  3826. }
  3827. return $logs;
  3828. }
  3829. function getBackups(){
  3830. $path = DATABASE_LOCATION ."backups/";
  3831. @mkdir($path, 0770, true);
  3832. $backups = array();
  3833. $files = array_diff(scandir($path), array('.', '..'));
  3834. return array_reverse($files);
  3835. }
  3836. function getExtension($string) {
  3837. return preg_replace("#(.+)?\.(\w+)(\?.+)?#", "$2", $string);
  3838. }
  3839. function showFile(){
  3840. $file = $_GET['file'];
  3841. $fileType = getExtension($file);
  3842. if($fileType != 'php'){
  3843. header("Content-type: ".mimeTypes()[$fileType]);
  3844. @readfile($file);
  3845. }
  3846. }
  3847. function getCalendar(){
  3848. $sonarr = new Sonarr(SONARRURL, SONARRKEY);
  3849. $radarr = new Sonarr(RADARRURL, RADARRKEY);
  3850. $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
  3851. $startDate = date('Y-m-d',strtotime("-".CALENDARSTARTDAY." days"));
  3852. $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
  3853. $calendarItems = array();
  3854. if (SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)){
  3855. try {
  3856. $sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate));
  3857. if(!empty($sonarrCalendar)) { $calendarItems = array_merge($calendarItems, $sonarrCalendar); }
  3858. } catch (Exception $e) {
  3859. writeLog("error", "SONARR ERROR: ".strip($e->getMessage()));
  3860. }
  3861. }
  3862. if (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)){
  3863. try {
  3864. $radarrCalendar = getRadarrCalendar($radarr->getCalendar($startDate, $endDate));
  3865. if(!empty($radarrCalendar)) { $calendarItems = array_merge($calendarItems, $radarrCalendar); }
  3866. } catch (Exception $e) {
  3867. writeLog("error", "RADARR ERROR: ".strip($e->getMessage()));
  3868. }
  3869. }
  3870. if (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH)){
  3871. $couchCalendar = getCouchCalendar();
  3872. if(!empty($couchCalendar)) { $calendarItems = array_merge($calendarItems, $couchCalendar); }
  3873. }
  3874. if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
  3875. $headphonesHistory = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory");
  3876. $headphonesWanted = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted");
  3877. if(!empty($headphonesHistory)) { $calendarItems = array_merge($calendarItems, $headphonesHistory); }
  3878. if(!empty($headphonesWanted)) { $calendarItems = array_merge($calendarItems, $headphonesWanted); }
  3879. }
  3880. if (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)){
  3881. try {
  3882. $sickrageFuture = getSickrageCalendarWanted($sickrage->future());
  3883. if(!empty($sickrageFuture)) { $calendarItems = array_merge($calendarItems, $sickrageFuture); }
  3884. } catch (Exception $e) {
  3885. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3886. } try {
  3887. $sickrageHistory = getSickrageCalendarHistory($sickrage->history("100","downloaded"));
  3888. if(!empty($sickrageHistory)) { $calendarItems = array_merge($calendarItems, $sickrageHistory); }
  3889. } catch (Exception $e) {
  3890. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3891. }
  3892. }
  3893. return $calendarItems;
  3894. }
  3895. function localURL($url){
  3896. if (strpos($url, 'https') !== false) {
  3897. preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $url, $result);
  3898. $result = (!empty($result) ? true : false);
  3899. return $result;
  3900. }
  3901. }
  3902. function fileArray($files){
  3903. foreach($files as $file){
  3904. if(file_exists($file)){
  3905. $list[] = $file;
  3906. }
  3907. }
  3908. if(!empty($list)){ return $list; }
  3909. }
  3910. function backupDB(){
  3911. if (extension_loaded('ZIP')) {
  3912. $directory = DATABASE_LOCATION."backups/";
  3913. @mkdir($directory, 0770, true);
  3914. $orgFiles = array(
  3915. 'css' => 'custom.css',
  3916. 'temp' => 'cus.sd',
  3917. 'orgLog' => DATABASE_LOCATION.'org.log',
  3918. 'loginLog' => DATABASE_LOCATION.'loginLog.json',
  3919. 'chatDB' => 'chatpack.db',
  3920. 'config' => 'config/config.php',
  3921. 'database' => DATABASE_LOCATION.'users.db'
  3922. );
  3923. $files = fileArray($orgFiles);
  3924. if(!empty($files)){
  3925. writeLog("success", "BACKUP: backup process started");
  3926. $zipname = $directory.'backup['.date('Y-m-d_H-i').']['.INSTALLEDVERSION.'].zip';
  3927. $zip = new ZipArchive;
  3928. $zip->open($zipname, ZipArchive::CREATE);
  3929. foreach ($files as $file) {
  3930. $zip->addFile($file);
  3931. }
  3932. $zip->close();
  3933. writeLog("success", "BACKUP: backup process finished");
  3934. return true;
  3935. }else{
  3936. return false;
  3937. }
  3938. }else{
  3939. return false;
  3940. }
  3941. }
  3942. class Ping {
  3943. private $host;
  3944. private $ttl;
  3945. private $timeout;
  3946. private $port = 80;
  3947. private $data = 'Ping';
  3948. private $commandOutput;
  3949. /**
  3950. * Called when the Ping object is created.
  3951. *
  3952. * @param string $host
  3953. * The host to be pinged.
  3954. * @param int $ttl
  3955. * Time-to-live (TTL) (You may get a 'Time to live exceeded' error if this
  3956. * value is set too low. The TTL value indicates the scope or range in which
  3957. * a packet may be forwarded. By convention:
  3958. * - 0 = same host
  3959. * - 1 = same subnet
  3960. * - 32 = same site
  3961. * - 64 = same region
  3962. * - 128 = same continent
  3963. * - 255 = unrestricted
  3964. * @param int $timeout
  3965. * Timeout (in seconds) used for ping and fsockopen().
  3966. * @throws \Exception if the host is not set.
  3967. */
  3968. public function __construct($host, $ttl = 255, $timeout = 10) {
  3969. if (!isset($host)) {
  3970. throw new \Exception("Error: Host name not supplied.");
  3971. }
  3972. $this->host = $host;
  3973. $this->ttl = $ttl;
  3974. $this->timeout = $timeout;
  3975. }
  3976. /**
  3977. * Set the ttl (in hops).
  3978. *
  3979. * @param int $ttl
  3980. * TTL in hops.
  3981. */
  3982. public function setTtl($ttl) {
  3983. $this->ttl = $ttl;
  3984. }
  3985. /**
  3986. * Get the ttl.
  3987. *
  3988. * @return int
  3989. * The current ttl for Ping.
  3990. */
  3991. public function getTtl() {
  3992. return $this->ttl;
  3993. }
  3994. /**
  3995. * Set the timeout.
  3996. *
  3997. * @param int $timeout
  3998. * Time to wait in seconds.
  3999. */
  4000. public function setTimeout($timeout) {
  4001. $this->timeout = $timeout;
  4002. }
  4003. /**
  4004. * Get the timeout.
  4005. *
  4006. * @return int
  4007. * Current timeout for Ping.
  4008. */
  4009. public function getTimeout() {
  4010. return $this->timeout;
  4011. }
  4012. /**
  4013. * Set the host.
  4014. *
  4015. * @param string $host
  4016. * Host name or IP address.
  4017. */
  4018. public function setHost($host) {
  4019. $this->host = $host;
  4020. }
  4021. /**
  4022. * Get the host.
  4023. *
  4024. * @return string
  4025. * The current hostname for Ping.
  4026. */
  4027. public function getHost() {
  4028. return $this->host;
  4029. }
  4030. /**
  4031. * Set the port (only used for fsockopen method).
  4032. *
  4033. * Since regular pings use ICMP and don't need to worry about the concept of
  4034. * 'ports', this is only used for the fsockopen method, which pings servers by
  4035. * checking port 80 (by default).
  4036. *
  4037. * @param int $port
  4038. * Port to use for fsockopen ping (defaults to 80 if not set).
  4039. */
  4040. public function setPort($port) {
  4041. $this->port = $port;
  4042. }
  4043. /**
  4044. * Get the port (only used for fsockopen method).
  4045. *
  4046. * @return int
  4047. * The port used by fsockopen pings.
  4048. */
  4049. public function getPort() {
  4050. return $this->port;
  4051. }
  4052. /**
  4053. * Return the command output when method=exec.
  4054. * @return string
  4055. */
  4056. public function getCommandOutput(){
  4057. return $this->commandOutput;
  4058. }
  4059. /**
  4060. * Matches an IP on command output and returns.
  4061. * @return string
  4062. */
  4063. public function getIpAddress() {
  4064. $out = array();
  4065. if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $this->commandOutput, $out)){
  4066. return $out[0];
  4067. }
  4068. return null;
  4069. }
  4070. /**
  4071. * Ping a host.
  4072. *
  4073. * @param string $method
  4074. * Method to use when pinging:
  4075. * - exec (default): Pings through the system ping command. Fast and
  4076. * robust, but a security risk if you pass through user-submitted data.
  4077. * - fsockopen: Pings a server on port 80.
  4078. * - socket: Creates a RAW network socket. Only usable in some
  4079. * environments, as creating a SOCK_RAW socket requires root privileges.
  4080. *
  4081. * @throws InvalidArgumentException if $method is not supported.
  4082. *
  4083. * @return mixed
  4084. * Latency as integer, in ms, if host is reachable or FALSE if host is down.
  4085. */
  4086. public function ping($method = 'exec') {
  4087. $latency = false;
  4088. switch ($method) {
  4089. case 'exec':
  4090. $latency = $this->pingExec();
  4091. break;
  4092. case 'fsockopen':
  4093. $latency = $this->pingFsockopen();
  4094. break;
  4095. case 'socket':
  4096. $latency = $this->pingSocket();
  4097. break;
  4098. default:
  4099. throw new \InvalidArgumentException('Unsupported ping method.');
  4100. }
  4101. // Return the latency.
  4102. return $latency;
  4103. }
  4104. /**
  4105. * The exec method uses the possibly insecure exec() function, which passes
  4106. * the input to the system. This is potentially VERY dangerous if you pass in
  4107. * any user-submitted data. Be SURE you sanitize your inputs!
  4108. *
  4109. * @return int
  4110. * Latency, in ms.
  4111. */
  4112. private function pingExec() {
  4113. $latency = false;
  4114. $ttl = escapeshellcmd($this->ttl);
  4115. $timeout = escapeshellcmd($this->timeout);
  4116. $host = escapeshellcmd($this->host);
  4117. // Exec string for Windows-based systems.
  4118. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  4119. // -n = number of pings; -i = ttl; -w = timeout (in milliseconds).
  4120. $exec_string = 'ping -n 1 -i ' . $ttl . ' -w ' . ($timeout * 1000) . ' ' . $host;
  4121. }
  4122. // Exec string for Darwin based systems (OS X).
  4123. else if(strtoupper(PHP_OS) === 'DARWIN') {
  4124. // -n = numeric output; -c = number of pings; -m = ttl; -t = timeout.
  4125. $exec_string = 'ping -n -c 1 -m ' . $ttl . ' -t ' . $timeout . ' ' . $host;
  4126. }
  4127. // Exec string for other UNIX-based systems (Linux).
  4128. else {
  4129. // -n = numeric output; -c = number of pings; -t = ttl; -W = timeout
  4130. $exec_string = 'ping -n -c 1 -t ' . $ttl . ' -W ' . $timeout . ' ' . $host . ' 2>&1';
  4131. }
  4132. exec($exec_string, $output, $return);
  4133. // Strip empty lines and reorder the indexes from 0 (to make results more
  4134. // uniform across OS versions).
  4135. $this->commandOutput = implode($output, '');
  4136. $output = array_values(array_filter($output));
  4137. // If the result line in the output is not empty, parse it.
  4138. if (!empty($output[1])) {
  4139. // Search for a 'time' value in the result line.
  4140. $response = preg_match("/time(?:=|<)(?<time>[\.0-9]+)(?:|\s)ms/", $output[1], $matches);
  4141. // If there's a result and it's greater than 0, return the latency.
  4142. if ($response > 0 && isset($matches['time'])) {
  4143. $latency = round($matches['time'], 2);
  4144. }
  4145. }
  4146. return $latency;
  4147. }
  4148. /**
  4149. * The fsockopen method simply tries to reach the host on a port. This method
  4150. * is often the fastest, but not necessarily the most reliable. Even if a host
  4151. * doesn't respond, fsockopen may still make a connection.
  4152. *
  4153. * @return int
  4154. * Latency, in ms.
  4155. */
  4156. private function pingFsockopen() {
  4157. $start = microtime(true);
  4158. // fsockopen prints a bunch of errors if a host is unreachable. Hide those
  4159. // irrelevant errors and deal with the results instead.
  4160. $fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
  4161. if (!$fp) {
  4162. $latency = false;
  4163. }
  4164. else {
  4165. $latency = microtime(true) - $start;
  4166. $latency = round($latency * 1000, 2);
  4167. }
  4168. return $latency;
  4169. }
  4170. /**
  4171. * The socket method uses raw network packet data to try sending an ICMP ping
  4172. * packet to a server, then measures the response time. Using this method
  4173. * requires the script to be run with root privileges, though, so this method
  4174. * only works reliably on Windows systems and on Linux servers where the
  4175. * script is not being run as a web user.
  4176. *
  4177. * @return int
  4178. * Latency, in ms.
  4179. */
  4180. private function pingSocket() {
  4181. // Create a package.
  4182. $type = "\x08";
  4183. $code = "\x00";
  4184. $checksum = "\x00\x00";
  4185. $identifier = "\x00\x00";
  4186. $seq_number = "\x00\x00";
  4187. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4188. // Calculate the checksum.
  4189. $checksum = $this->calculateChecksum($package);
  4190. // Finalize the package.
  4191. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4192. // Create a socket, connect to server, then read socket and calculate.
  4193. if ($socket = socket_create(AF_INET, SOCK_RAW, 1)) {
  4194. socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array(
  4195. 'sec' => 10,
  4196. 'usec' => 0,
  4197. ));
  4198. // Prevent errors from being printed when host is unreachable.
  4199. @socket_connect($socket, $this->host, null);
  4200. $start = microtime(true);
  4201. // Send the package.
  4202. @socket_send($socket, $package, strlen($package), 0);
  4203. if (socket_read($socket, 255) !== false) {
  4204. $latency = microtime(true) - $start;
  4205. $latency = round($latency * 1000, 2);
  4206. }
  4207. else {
  4208. $latency = false;
  4209. }
  4210. }
  4211. else {
  4212. $latency = false;
  4213. }
  4214. // Close the socket.
  4215. socket_close($socket);
  4216. return $latency;
  4217. }
  4218. /**
  4219. * Calculate a checksum.
  4220. *
  4221. * @param string $data
  4222. * Data for which checksum will be calculated.
  4223. *
  4224. * @return string
  4225. * Binary string checksum of $data.
  4226. */
  4227. private function calculateChecksum($data) {
  4228. if (strlen($data) % 2) {
  4229. $data .= "\x00";
  4230. }
  4231. $bit = unpack('n*', $data);
  4232. $sum = array_sum($bit);
  4233. while ($sum >> 16) {
  4234. $sum = ($sum >> 16) + ($sum & 0xffff);
  4235. }
  4236. return pack('n*', ~$sum);
  4237. }
  4238. }
  4239. function ping($pings, $type = "string") {
  4240. $ping = new Ping("");
  4241. $ping->setTtl(128);
  4242. $ping->setTimeout(2);
  4243. switch ($type){
  4244. case "array":
  4245. $results = [];
  4246. foreach ($pings as $k => $v) {
  4247. if(strpos($v, ':') !== false){
  4248. $domain = explode(':', $v)[0];
  4249. $port = explode(':', $v)[1];
  4250. $ping->setHost($domain);
  4251. $ping->setPort($port);
  4252. $latency = $ping->ping('fsockopen');
  4253. }else{
  4254. $ping->setHost($v);
  4255. $latency = $ping->ping();
  4256. }
  4257. if ($latency || $latency === 0) {
  4258. $results[$k] = $latency;
  4259. } else {
  4260. $results[$k] = 0;
  4261. }
  4262. }
  4263. break;
  4264. case "string":
  4265. if(strpos($pings, ':') !== false){
  4266. $domain = explode(':', $pings)[0];
  4267. $port = explode(':', $pings)[1];
  4268. $ping->setHost($domain);
  4269. $ping->setPort($port);
  4270. $latency = $ping->ping('fsockopen');
  4271. }else{
  4272. $ping->setHost($pings);
  4273. $latency = $ping->ping();
  4274. }
  4275. if ($latency || $latency === 0) {
  4276. $results = $latency;
  4277. } else {
  4278. $results = 0;
  4279. }
  4280. break;
  4281. }
  4282. return $results;
  4283. }
  4284. function getPing($url, $style, $refresh = null){
  4285. if(ping($url) !== 0){
  4286. $class = 'success';
  4287. if(!$refresh){
  4288. $class .= " animated slideInLeft";
  4289. }
  4290. }else{
  4291. $class = "warning";
  4292. if(!$refresh){
  4293. $class .= " animated flash loop-animation-timeout";
  4294. }
  4295. }
  4296. echo '<span class="pingcheck badge ping-'.$class.'" style="position: absolute;z-index: 100;right: 5px; padding: 0px 0px;'.$style.';font-size: 10px;">&nbsp;</span>';
  4297. }
  4298. function speedTestData(){
  4299. $file_db = DATABASE_LOCATION."speedtest.db";
  4300. if(file_exists($file_db)){
  4301. $conn = new PDO("sqlite:$file_db") or die("1");
  4302. $result = $conn->query('SELECT * FROM speedtest_users');
  4303. $conn = null;
  4304. if (is_array($result) || is_object($result)){
  4305. foreach($result as $k => $v){
  4306. $return[$k] = $v;
  4307. }
  4308. return $return;
  4309. }
  4310. }
  4311. }
  4312. function speedTestDisplay($array, $output){
  4313. if (is_array($array) || is_object($array)){
  4314. if($output == "graph"){
  4315. $result = "Morris.Line({element: 'morris-line',data: [";
  4316. foreach($array as $k => $v){
  4317. $result .= "{ y: '".substr($v['timestamp'],0,10)."', a: ".$v['ul'].", b: ".$v['dl'].", c: ".$v['ping']." },";
  4318. }
  4319. $result .= "],xkey: 'y',ykeys: ['a', 'b', 'c'],labels: ['Upload', 'Download', 'Ping'],hideHover: 'auto',resize: true,lineColors: ['#63A8EB','#ccc','#000'] });";
  4320. }elseif($output == "table"){
  4321. $result = "";
  4322. foreach($array as $k => $v){
  4323. $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>";
  4324. }
  4325. }
  4326. return $result;
  4327. }
  4328. }
  4329. function buildMenuPhone($array){
  4330. if (is_array($array) || is_object($array)){
  4331. $result = '
  4332. <div class="content-box profile-sidebar box-shadow">
  4333. <img src="images/organizr-logo-h-d.png" width="100%" style="margin-top: -10px;">
  4334. <div class="profile-usermenu">
  4335. <ul class="nav" id="settings-list">
  4336. ';
  4337. foreach($array as $k => $v){
  4338. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4339. continue;
  4340. }
  4341. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4342. continue;
  4343. }
  4344. /*$result .= '
  4345. <li>
  4346. <a id="'.$v['id'].'" box="'.$v['box'].'">'.$v['name'].'
  4347. <span class="fa-stack fa-fw pull-right" style="margin-top: -5px;margin-right: -10px;">
  4348. <i class="fa fa-'.$v['icon_1'].' fa-stack-2x '.$v['color'].'" style="font-size:null;"></i>
  4349. <i class="fa fa-'.$v['icon_2'].' fa-stack-1x fa-inverse"></i>
  4350. </span>
  4351. </a>
  4352. </li>
  4353. ';*/
  4354. $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>';
  4355. }
  4356. $result .= '</ul></div></div>';
  4357. return $result;
  4358. }
  4359. }
  4360. function buildMenu($array){
  4361. if (is_array($array) || is_object($array)){
  4362. $result = '<div class="settingsList">';
  4363. foreach($array as $k => $v){
  4364. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4365. continue;
  4366. }
  4367. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4368. continue;
  4369. }
  4370. $result .= '
  4371. <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">
  4372. <i class="mdi mdi-'.$v['icon_1'].' fa-fw pull-left" style="padding-left: '.$v['padding'].'px;font-size: 30px"></i>
  4373. <p class="" style="text-align: center;direction: rtl;display:none;margin: 2px;"><strong>'.$v['name'].'</strong></p>
  4374. </button>
  4375. ';
  4376. }
  4377. $result .= '</div>';
  4378. return $result;
  4379. }
  4380. }
  4381. function requestInvite($email, $username){
  4382. //sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null)
  4383. 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."));
  4384. }
  4385. function errormessage($msg) {
  4386. echo "<div style=\"margin-top: 50px;\">";
  4387. echo "<span style=\"color:#d89334;\">error </span>";
  4388. echo $msg;
  4389. echo "</div>";
  4390. }
  4391. function ajaxLoop($ajaxFunction, $refresh, $extraFunction = ''){
  4392. return "
  4393. setInterval(function() {
  4394. $.ajax({
  4395. url: 'ajax.php?a=".$ajaxFunction."',
  4396. timeout: 10000,
  4397. type: 'GET',
  4398. success: function(response) {
  4399. var getDiv = response;
  4400. var loadedID = $(getDiv).attr('id');
  4401. if (typeof loadedID !== 'undefined') {
  4402. var oldElement = $('#'+loadedID).prop('outerHTML');
  4403. var newElement = $(getDiv).prop('outerHTML');
  4404. if(oldElement !== newElement){
  4405. $('#'+loadedID).replaceWith($(getDiv).prop('outerHTML'));
  4406. ".$extraFunction."
  4407. console.log('".$ajaxFunction." has been updated');
  4408. }
  4409. }else{
  4410. console.log('".$ajaxFunction." data was not sufficent or is offline');
  4411. }
  4412. },
  4413. error: function(jqXHR, textStatus, errorThrown) {
  4414. console.error('".$ajaxFunction." could not be updated');
  4415. }
  4416. });
  4417. }, ".$refresh.");
  4418. ";
  4419. }
  4420. function getOrgUsers(){
  4421. $file_db = DATABASE_LOCATION."users.db";
  4422. if(file_exists($file_db)){
  4423. $conn = new PDO("sqlite:$file_db") or die("1");
  4424. $result = $conn->query('SELECT * FROM users');
  4425. $conn = null;
  4426. if (is_array($result) || is_object($result)){
  4427. foreach($result as $k => $v){
  4428. $return[$v['username']] = $v['email'];
  4429. }
  4430. return $return;
  4431. }
  4432. }
  4433. }
  4434. function getEmails($type = 'org'){
  4435. if($type == 'plex'){
  4436. $emails = array_merge(libraryList()['both'],getOrgUsers());
  4437. }elseif($type == 'emby'){
  4438. $emails = getOrgUsers();
  4439. }else{
  4440. $emails = getOrgUsers();
  4441. }
  4442. return $emails;
  4443. }
  4444. function printEmails($emails){
  4445. $result = '';
  4446. foreach($emails as $k => $v){
  4447. $result .= '<option value="'.$v.'">'.$k.'</option>';
  4448. }
  4449. return $result;
  4450. }
  4451. function massEmail($to, $subject, $message){
  4452. if (!isset($GLOBALS['file_db'])) {
  4453. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  4454. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  4455. }
  4456. $emailTemplate = array(
  4457. 'type' => 'mass',
  4458. 'body' => $message,
  4459. 'subject' => $subject,
  4460. 'user' => null,
  4461. 'password' => null,
  4462. 'inviteCode' => null,
  4463. );
  4464. $emailTemplate = emailTemplate($emailTemplate);
  4465. $subject = $emailTemplate['subject'];
  4466. $body = buildEmail($emailTemplate);
  4467. sendEmail(null, null, $subject, $body, $GLOBALS['USER']->adminEmail,$to);
  4468. }
  4469. function q2a($q){
  4470. if (is_array($q) || is_object($q)){
  4471. foreach ($q as $k => $v){
  4472. $a[$k] = $v;
  4473. }
  4474. if(!empty($a)){
  4475. return $a;
  4476. }
  4477. }
  4478. }
  4479. function getOmbiToken($username, $password){
  4480. $headers = array(
  4481. "Accept" => "application/json",
  4482. "Content-Type" => "application/json"
  4483. );
  4484. $json = array(
  4485. "username" => $username,
  4486. "password" => $password,
  4487. "rememberMe" => "true",
  4488. );
  4489. $api = curl_post(OMBIURL."/api/v1/Token", $json, $headers);
  4490. if (isset($api['content'])) {
  4491. return json_decode($api['content'], true)['access_token'];
  4492. }else{
  4493. return false;
  4494. }
  4495. }
  4496. function ombiAction($id, $action, $type){
  4497. $headers = array(
  4498. "Accept" => "application/json",
  4499. "Content-Type" => "application/json",
  4500. "Apikey" => OMBIKEY
  4501. );
  4502. $body = array(
  4503. 'id' => $id,
  4504. );
  4505. switch ($type) {
  4506. case 'season':
  4507. case 'tv':
  4508. $type = 'tv';
  4509. break;
  4510. default:
  4511. $type = 'movie';
  4512. break;
  4513. }
  4514. switch ($action) {
  4515. case 'approve':
  4516. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/approve", $body, $headers);
  4517. break;
  4518. case 'available':
  4519. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/available", $body, $headers);
  4520. break;
  4521. case 'unavailable':
  4522. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/unavailable", $body, $headers);
  4523. break;
  4524. case 'deny':
  4525. $api = curl_put(OMBIURL."/api/v1/Request/".$type."/deny", $body, $headers);
  4526. break;
  4527. case 'delete':
  4528. $api = curl_delete(OMBIURL."/api/v1/Request/".$type."/".$id, $headers);
  4529. break;
  4530. default:
  4531. # code...
  4532. break;
  4533. }
  4534. switch ($api['http_code']['http_code']){
  4535. case 401:
  4536. writeLog("error", "OMBI: Invalid API KEY");
  4537. return false;
  4538. break;
  4539. case 200:
  4540. writeLog("success", "OMBI: action completed successfully for [type: $type - action: $action - id: $id]");
  4541. return true;
  4542. break;
  4543. default:
  4544. writeLog("error", "OMBI: unknown error with request [type: $type - action: $action - id: $id]");
  4545. return false;
  4546. }
  4547. //return (!empty($result) ? $result : null );
  4548. }
  4549. function getOmbiRequests($type = "both"){
  4550. $headers = array(
  4551. "Accept" => "application/json",
  4552. "Apikey" => OMBIKEY,
  4553. );
  4554. $requests = array();
  4555. switch ($type) {
  4556. case 'movie':
  4557. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4558. break;
  4559. case 'tv':
  4560. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4561. break;
  4562. default:
  4563. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4564. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4565. break;
  4566. }
  4567. if(isset($movie)){
  4568. //$movie = array_reverse($movie);
  4569. foreach ($movie as $key => $value) {
  4570. $poster = explode('/',$value['posterPath']);
  4571. $requests[] = array(
  4572. 'id' => $value['theMovieDbId'],
  4573. 'title' => $value['title'],
  4574. 'poster' => (strpos($value['posterPath'], "/") !== false) ? 'https://image.tmdb.org/t/p/w300/'.end($poster) : 'https://image.tmdb.org/t/p/w300/'.$value['posterPath'],
  4575. 'approved' => $value['approved'],
  4576. 'available' => $value['available'],
  4577. 'denied' => $value['denied'],
  4578. 'deniedReason' => $value['deniedReason'],
  4579. 'user' => $value['requestedUser']['userName'],
  4580. 'request_id' => $value['id'],
  4581. 'request_date' => $value['requestedDate'],
  4582. 'release_date' => $value['releaseDate'],
  4583. 'type' => 'movie',
  4584. 'icon' => 'mdi mdi-filmstrip',
  4585. 'color' => 'palette-Deep-Purple-900 bg white',
  4586. );
  4587. }
  4588. }
  4589. if(isset($tv) && (is_array($tv) || is_object($tv))){
  4590. foreach ($tv as $key => $value) {
  4591. if(is_array($value['childRequests'][0])){
  4592. $requests[] = array(
  4593. 'id' => $value['tvDbId'],
  4594. 'title' => $value['title'],
  4595. 'poster' => $value['posterPath'],
  4596. 'approved' => $value['childRequests'][0]['approved'],
  4597. 'available' => $value['childRequests'][0]['available'],
  4598. 'denied' => $value['childRequests'][0]['denied'],
  4599. 'deniedReason' => $value['childRequests'][0]['deniedReason'],
  4600. 'user' => $value['childRequests'][0]['requestedUser']['userName'],
  4601. 'request_id' => $value['id'],
  4602. 'request_date' => $value['childRequests'][0]['requestedDate'],
  4603. 'release_date' => $value['releaseDate'],
  4604. 'type' => 'tv',
  4605. 'icon' => 'mdi mdi-television',
  4606. 'color' => 'grayish-blue-bg',
  4607. );
  4608. }
  4609. }
  4610. }
  4611. return (empty($requests)) ? '' : $requests;
  4612. }
  4613. function convertOmbiString($type, $value){
  4614. switch ($type) {
  4615. case 'approved':
  4616. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4617. $string['icon'] = ($value) ? 'mdi mdi-check' : 'mdi mdi-clock';
  4618. $string['color'] = ($value) ? 'green-bg' : 'yellow-bg';
  4619. break;
  4620. case 'available':
  4621. $string['string'] = ($value) ? 'Available' : 'Not Downloaded';
  4622. $string['icon'] = ($value) ? 'mdi mdi-server' : 'mdi mdi-server-off';
  4623. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4624. break;
  4625. case 'denied':
  4626. $string['string'] = ($value) ? 'Denied' : 'Approved';
  4627. $string['icon'] = ($value) ? 'mdi mdi-emoticon-sad' : 'mdi mdi-emoticon-happy';
  4628. $string['color'] = ($value) ? 'red-bg' : 'green-bg';
  4629. break;
  4630. case 'status':
  4631. switch ($value) {
  4632. case '1':
  4633. $string['string'] = 'Denied';
  4634. $string['icon'] = 'mdi mdi-window-close';
  4635. $string['color'] = 'red-bg';
  4636. break;
  4637. case '2':
  4638. $string['string'] = 'Approved';
  4639. $string['icon'] = 'mdi mdi-check';
  4640. $string['color'] = 'green-bg';
  4641. break;
  4642. case '3':
  4643. $string['string'] = 'Not Approved';
  4644. $string['icon'] = 'mdi mdi-clock';
  4645. $string['color'] = 'yellow-bg';
  4646. break;
  4647. default:
  4648. # code...
  4649. break;
  4650. }
  4651. break;
  4652. default:
  4653. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4654. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4655. break;
  4656. }
  4657. return $string;
  4658. }
  4659. function buildOmbiItem($type, $group, $user, $request){
  4660. if (is_array($request) || is_object($request)){
  4661. $actions = '';
  4662. if($request['denied']){
  4663. $status = 1;
  4664. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4665. }else{
  4666. if($request['approved']){
  4667. $status = 2;
  4668. }else{
  4669. $status = 3;
  4670. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4671. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="deny"><a class="requestAction" href="javascript:void(0)">Deny</a></li>';
  4672. }
  4673. }
  4674. if($request['available']){
  4675. $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>';
  4676. }else{
  4677. $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>';
  4678. }
  4679. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="delete"><a class="requestAction" href="javascript:void(0)">Delete</a></li>';
  4680. if(isset($group) && $group == 'admin'){
  4681. $actionMenu = '
  4682. <div class="requestOptions">
  4683. <div class="btn-group transparent" role="group">
  4684. <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>
  4685. <ul class="dropdown-menu"><h6 class="text-center requestHeader gray-bg">'.$request['user'].'</h6>'.$actions.'</ul>
  4686. </div>
  4687. </div>
  4688. ';
  4689. }else{
  4690. $actionMenu = '';
  4691. }
  4692. if((isset($group)) && $group == 'admin' || REQUESTEDUSERONLY == 'false'){
  4693. return '
  4694. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4695. '.$actionMenu.'
  4696. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4697. <div class="requestBottom text-center">
  4698. <div data-toggle="tooltip" data-placement="top" data-original-title="'.$request['type'].'" class="zero-m requestGroup '.$request['color'].'">
  4699. <i class="'.$request['icon'].'"></i>
  4700. </div>
  4701. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4702. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4703. </div>
  4704. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4705. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4706. </div>
  4707. </div>
  4708. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4709. </div>';
  4710. }else{
  4711. if(strtolower($request['user']) == strtolower($user)){
  4712. return '
  4713. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4714. '.$actionMenu.'
  4715. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4716. <div class="requestBottom text-center">
  4717. <div data-toggle="tooltip" data-placement="top" data-original-title="'.$request['type'].'" class="zero-m requestGroup '.$request['color'].'">
  4718. <i class="'.$request['icon'].'"></i>
  4719. </div>
  4720. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4721. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4722. </div>
  4723. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4724. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4725. </div>
  4726. </div>
  4727. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4728. </div>';
  4729. }
  4730. }
  4731. }
  4732. }
  4733. function buildOmbiList($group, $user){
  4734. $requests = array();
  4735. $movieList = getOmbiRequests('movie');
  4736. $tvList = getOmbiRequests('tv');
  4737. if(is_array($movieList) && is_array($tvList)){
  4738. $result = array_merge($movieList , $tvList );
  4739. }else{
  4740. if(is_array($movieList)){
  4741. $result = $movieList;
  4742. }elseif(is_array($tvList)){
  4743. $result = $tvList;
  4744. }else{
  4745. $result = false;
  4746. }
  4747. }
  4748. if (is_array($result) || is_object($result)){
  4749. usort($result, function ($item1, $item2) {
  4750. if ($item1['request_date'] == $item2['request_date']) return 0;
  4751. return $item1['request_date'] > $item2['request_date'] ? -1 : 1;
  4752. });
  4753. foreach ($result as $request) {
  4754. if($request['type'] == 'movie'){
  4755. $requests[] = buildOmbiItem('movie', $group, $user, $request);
  4756. }elseif($request['type'] == 'tv'){
  4757. $requests[] = buildOmbiItem('season', $group, $user, $request);
  4758. }
  4759. }
  4760. }
  4761. return outputOmbiRequests("Requested Content", $requests, ajaxLoop('ombi-requests',REQUESTREFRESH,'loadSlick();'), false);
  4762. }
  4763. function outputOmbiRequests($header = "Requested Content", $items, $script = false, $array) {
  4764. $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">';
  4765. if(preg_grep("/item-movie-Approved/", $items)){
  4766. $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>';
  4767. }
  4768. if(preg_grep("/item-movie-Approval-Pending/", $items)){
  4769. $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>';
  4770. }
  4771. if(preg_grep("/item-season-Approved/", $items)){
  4772. $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>';
  4773. }
  4774. if(preg_grep("/item-season-Approval-Pending/", $items)){
  4775. $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>';
  4776. }
  4777. $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>';
  4778. $hideMenu .= '</ul></div></div>';
  4779. // If None Populate Empty Item
  4780. //if (count(array_flip($items)) < 1) {
  4781. if(!array_filter($items)) {
  4782. return '<div id="recentRequests"></div>';
  4783. }else{
  4784. $className = str_replace(' ', '', $header);
  4785. 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>':'');
  4786. }
  4787. }
  4788. function ombiAPI($action){
  4789. $headers = array(
  4790. "Accept" => "application/json",
  4791. "Content-Type" => "application/json",
  4792. "Apikey" => OMBIKEY
  4793. );
  4794. $body = array();
  4795. switch ($action) {
  4796. case 'plex-cache':
  4797. $api = curl_post(OMBIURL."/api/v1/Job/plexcontentcacher", $body, $headers);
  4798. break;
  4799. default:
  4800. break;
  4801. }
  4802. if(is_array($api) || is_object($api)){
  4803. switch ($api['http_code']['http_code']){
  4804. case 200:
  4805. return true;
  4806. break;
  4807. default:
  4808. return false;
  4809. }
  4810. }else{
  4811. return false;
  4812. }
  4813. }
  4814. function loadIcons(){
  4815. $dirname = "images/";
  4816. $images = scandir($dirname);
  4817. $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");
  4818. $allIcons = '';
  4819. foreach($images as $curimg){
  4820. if(!in_array($curimg, $ignore)) {
  4821. $allIcons .= '
  4822. <div class="col-xs-2" style="width: 75px; height: 75px; padding-right: 0px;">
  4823. <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);">
  4824. <img style="width: 50px; height: 50px;" data-src="'.$dirname.$curimg.'" alt="thumbnail" class="allIcons lazyload shadow">
  4825. </a>
  4826. </div>
  4827. ';
  4828. }
  4829. }
  4830. return $allIcons;
  4831. }
  4832. function buildHomepageSettings(){
  4833. $homepageOrder = homepageOrder();
  4834. $homepageList = '<h4>Drag Homepage Items to Order Them</h4><div id="homepage-items" class="external-events">';
  4835. $inputList = '<div id="homepage-values" class="row">';
  4836. foreach ($homepageOrder as $key => $val) {
  4837. switch ($key) {
  4838. case 'homepageOrdercustomhtml':
  4839. $class = 'palette-Deep-Purple-100 bg gray';
  4840. $image = 'images/html.png';
  4841. if(empty(HOMEPAGECUSTOMHTML1)){
  4842. $class .= ' faded';
  4843. }
  4844. break;
  4845. case 'homepageOrdernotice':
  4846. $class = 'palette-Cyan-A400 bg gray';
  4847. $image = 'images/pin.png';
  4848. if(empty(HOMEPAGENOTICETITLE) && empty(HOMEPAGENOTICEMESSAGE)){
  4849. $class .= ' faded';
  4850. }
  4851. break;
  4852. case 'homepageOrdernoticeguest':
  4853. $class = 'palette-Cyan-A400 bg gray';
  4854. $image = 'images/pin.png';
  4855. if(empty(HOMEPAGENOTICETITLEGUEST) && empty(HOMEPAGENOTICEMESSAGEGUEST)){
  4856. $class .= ' faded';
  4857. }
  4858. break;
  4859. case 'homepageOrderspeedtest':
  4860. $class = 'red-bg';
  4861. $image = 'images/settings/full-color/png/64px/speedometer.png';
  4862. if(SPEEDTEST !== "true"){
  4863. $class .= ' faded';
  4864. }
  4865. break;
  4866. case 'homepageOrdertransmisson':
  4867. $class = 'green-bg';
  4868. $image = 'images/transmission.png';
  4869. if(empty(TRANSMISSIONURL)){
  4870. $class .= ' faded';
  4871. }
  4872. break;
  4873. case 'homepageOrdernzbget':
  4874. $class = 'green-bg';
  4875. $image = 'images/nzbget.png';
  4876. if(empty(NZBGETURL)){
  4877. $class .= ' faded';
  4878. }
  4879. break;
  4880. case 'homepageOrdersabnzbd':
  4881. $class = 'yellow-bg';
  4882. $image = 'images/sabnzbd.png';
  4883. if(empty(SABNZBDURL)){
  4884. $class .= ' faded';
  4885. }
  4886. break;
  4887. case 'homepageOrderplexsearch':
  4888. case 'homepageOrderplexnowplaying':
  4889. case 'homepageOrderplexrecent':
  4890. case 'homepageOrderplexplaylist':
  4891. $class = 'palette-Amber-A700 bg gray';
  4892. $image = 'images/plex.png';
  4893. if(empty(PLEXURL)){
  4894. $class .= ' faded';
  4895. }
  4896. break;
  4897. case 'homepageOrderembynowplaying':
  4898. case 'homepageOrderembyrecent':
  4899. $class = 'palette-Green-A700 bg gray';
  4900. $image = 'images/emby.png';
  4901. if(empty(EMBYURL)){
  4902. $class .= ' faded';
  4903. }
  4904. break;
  4905. case 'homepageOrderombi':
  4906. $class = 'orange-bg';
  4907. $image = 'images/ombi.png';
  4908. if(empty(OMBIURL)){
  4909. $class .= ' faded';
  4910. }
  4911. break;
  4912. case 'homepageOrdercalendar':
  4913. $class = 'palette-Blue-400 bg gray';
  4914. $image = 'images/calendar.png';
  4915. if(SONARRURL == "" && RADARRURL == "" && HEADPHONESURL == "" && SICKRAGEURL == "" && COUCHURL == "" ){
  4916. $class .= ' faded';
  4917. }
  4918. break;
  4919. default:
  4920. $class = 'blue-bg';
  4921. $image = '';
  4922. break;
  4923. }
  4924. $homepageList .= '
  4925. <div class="col-md-3 sort-homepage"><div class="fc-event '.$class.'">
  4926. <span class="ordinal-position text-uppercase badge badge-gray" data-link="'.$key.'" style="float:left;width: 30px;">'.$val.'</span>
  4927. &nbsp; '.strtoupper(substr($key, 13)).'
  4928. <span class="remove-event"><img style="width: 22px;" src="'.$image.'"></span>
  4929. </div></div>';
  4930. $inputList .= '<input type="hidden" name="'.$key.'">';
  4931. }
  4932. $homepageList .= '</div>';
  4933. $inputList .= '</div>';
  4934. return $homepageList.$inputList;
  4935. }
  4936. function buildHomepage($group, $user){
  4937. $homepageOrder = homepageOrder();
  4938. $homepageBuilt = '';
  4939. foreach ($homepageOrder as $key => $value) {
  4940. $homepageBuilt .= buildHomepageItem($key, $group, $user);
  4941. }
  4942. return $homepageBuilt;
  4943. }
  4944. function realSize($bytes, $decimals = 2) {
  4945. $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
  4946. $factor = floor((strlen($bytes) - 1) / 3);
  4947. return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' '.@$size[$factor];
  4948. }
  4949. function buildHomepageItem($homepageItem, $group, $user){
  4950. $homepageItemBuilt = '';
  4951. switch ($homepageItem) {
  4952. case 'homepageOrderplexsearch':
  4953. if((qualifyUser(PLEXSEARCHAUTH) && PLEXSEARCH == "true" && qualifyUser(PLEXHOMEAUTH))) {
  4954. $homepageItemBuilt .= '
  4955. <div id="searchPlexRow" class="row">
  4956. <div class="col-lg-12">
  4957. <div class="content-box box-shadow big-box todo-list">
  4958. <form id="plexSearchForm" onsubmit="return false;" autocomplete="off">
  4959. <div class="">
  4960. <div class="input-group">
  4961. <div style="border-radius: 25px 0 0 25px; border:0" class="input-group-addon gray-bg"><i class="fa fa-search white"></i></div>
  4962. <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">
  4963. <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>
  4964. <button style="display:none" id="plexSearchForm_submit" class="btn btn-primary waves"></button>
  4965. </div>
  4966. </div>
  4967. </form>
  4968. <div id="resultshere" class="table-responsive"></div>
  4969. </div>
  4970. </div>
  4971. </div>
  4972. ';
  4973. }
  4974. break;
  4975. case 'homepageOrdercustomhtml':
  4976. if (qualifyUser(HOMEPAGECUSTOMHTML1AUTH) && HOMEPAGECUSTOMHTML1) {
  4977. $homepageItemBuilt .= "<div>" . HOMEPAGECUSTOMHTML1 . "</div>";
  4978. }
  4979. break;
  4980. case 'homepageOrdernotice':
  4981. if (qualifyUser(HOMEPAGENOTICEAUTH) && HOMEPAGENOTICETITLE && HOMEPAGENOTICETYPE && HOMEPAGENOTICEMESSAGE && HOMEPAGENOTICELAYOUT) {
  4982. $homepageItemBuilt .= buildHomepageNotice(HOMEPAGENOTICELAYOUT, HOMEPAGENOTICETYPE, HOMEPAGENOTICETITLE, HOMEPAGENOTICEMESSAGE);
  4983. }
  4984. break;
  4985. case 'homepageOrdernoticeguest':
  4986. if ($group == 'guest' && HOMEPAGENOTICETITLEGUEST && HOMEPAGENOTICETYPEGUEST && HOMEPAGENOTICEMESSAGEGUEST && HOMEPAGENOTICELAYOUTGUEST) {
  4987. $homepageItemBuilt .= buildHomepageNotice(HOMEPAGENOTICELAYOUTGUEST, HOMEPAGENOTICETYPEGUEST, HOMEPAGENOTICETITLEGUEST, HOMEPAGENOTICEMESSAGEGUEST);
  4988. }
  4989. break;
  4990. case 'homepageOrderspeedtest':
  4991. if(SPEEDTEST == "true" && qualifyUser(SPEEDTESTAUTH)){
  4992. $homepageItemBuilt .= '
  4993. <style type="text/css">
  4994. .flash {
  4995. animation: flash 0.6s linear infinite;
  4996. }
  4997. @keyframes flash {
  4998. 0% { opacity: 0.6; }
  4999. 50% { opacity: 1; }
  5000. }
  5001. </style>
  5002. <script type="text/javascript">
  5003. var w = null
  5004. function runTest() {
  5005. document.getElementById("startBtn").style.display = "none"
  5006. document.getElementById("testArea").style.display = ""
  5007. document.getElementById("abortBtn").style.display = ""
  5008. w = new Worker("bower_components/speed/speedtest_worker.js")
  5009. var interval = setInterval(function () { w.postMessage("status") }, 100)
  5010. w.onmessage = function (event) {
  5011. var data = event.data.split(";")
  5012. var status = Number(data[0])
  5013. var dl = document.getElementById("download")
  5014. var ul = document.getElementById("upload")
  5015. var ping = document.getElementById("ping")
  5016. var jitter = document.getElementById("jitter")
  5017. dl.className = status === 1 ? "w-name flash" : "w-name"
  5018. ping.className = status === 2 ? "w-name flash" : "w-name"
  5019. jitter.className = ul.className = status === 3 ? "w-name flash" : "w-name"
  5020. if (status >= 4) {
  5021. clearInterval(interval)
  5022. document.getElementById("abortBtn").style.display = "none"
  5023. document.getElementById("startBtn").style.display = ""
  5024. w = null
  5025. }
  5026. if (status === 5) {
  5027. document.getElementById("testArea").style.display = "none"
  5028. }
  5029. dl.textContent = data[1] + " Mbit/s";
  5030. $("#downloadpercent").attr("style", "width: " + data[1] + "%;");
  5031. $("#uploadpercent").attr("style", "width: " + data[2] + "%;");
  5032. $("#pingpercent").attr("style", "width: " + data[3] + "%;");
  5033. $("#jitterpercent").attr("style", "width: " + data[5] + "%;");
  5034. ul.textContent = data[2] + " Mbit/s";
  5035. ping.textContent = data[3] + " ms";
  5036. jitter.textContent = data[5] + " ms";
  5037. }
  5038. w.postMessage(\'start {"telemetry_level":"basic"}\')
  5039. //w.postMessage("start")
  5040. }
  5041. function abortTest() {
  5042. if (w) w.postMessage("abort")
  5043. }
  5044. </script>
  5045. <div class="row" id="testArea" style="display:none">
  5046. <div class="test col-sm-3 col-lg-3">
  5047. <div class="content-box ultra-widget green-bg" data-counter="">
  5048. <div id="downloadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  5049. <div class="w-content">
  5050. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-download"></i></div>
  5051. <div class="w-descr left pull-left text-center">
  5052. <span class="testName text-uppercase w-name">Download</span>
  5053. <br>
  5054. <span class="w-name counter" id="download" ></span>
  5055. </div>
  5056. </div>
  5057. </div>
  5058. </div>
  5059. <div class="test col-sm-3 col-lg-3">
  5060. <div class="content-box ultra-widget red-bg" data-counter="">
  5061. <div id="uploadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  5062. <div class="w-content">
  5063. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-upload"></i></div>
  5064. <div class="w-descr left pull-left text-center">
  5065. <span class="testName text-uppercase w-name">Upload</span>
  5066. <br>
  5067. <span class="w-name counter" id="upload" ></span>
  5068. </div>
  5069. </div>
  5070. </div>
  5071. </div>
  5072. <div class="test col-sm-3 col-lg-3">
  5073. <div class="content-box ultra-widget yellow-bg" data-counter="">
  5074. <div id="pingpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  5075. <div class="w-content">
  5076. <div class="w-icon right pull-right"><i class="mdi mdi-timer"></i></div>
  5077. <div class="w-descr left pull-left text-center">
  5078. <span class="testName text-uppercase w-name">Latency</span>
  5079. <br>
  5080. <span class="w-name counter" id="ping" ></span>
  5081. </div>
  5082. </div>
  5083. </div>
  5084. </div>
  5085. <div class="test col-sm-3 col-lg-3">
  5086. <div class="content-box ultra-widget blue-bg" data-counter="">
  5087. <div id="jitterpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  5088. <div class="w-content">
  5089. <div class="w-icon right pull-right"><i class="mdi mdi-pulse"></i></div>
  5090. <div class="w-descr left pull-left text-center">
  5091. <span class="testName text-uppercase w-name">Jitter</span>
  5092. <br>
  5093. <span class="w-name counter" id="jitter" ></span>
  5094. </div>
  5095. </div>
  5096. </div>
  5097. </div>
  5098. <br/>
  5099. </div>
  5100. <div id="abortBtn" class="row" style="display: none" onclick="javascript:abortTest()">
  5101. <div class="col-lg-12">
  5102. <div class="content-box red-bg" style="cursor: pointer;">
  5103. <h1 style="margin: 10px" class="text-uppercase text-center">Abort Speed Test</h1>
  5104. <div class="clearfix"></div>
  5105. </div>
  5106. </div>
  5107. </div>
  5108. <div id="startBtn" class="row" onclick="javascript:runTest()">
  5109. <div class="col-lg-12">
  5110. <div class="content-box green-bg" style="cursor: pointer;">
  5111. <h1 style="margin: 10px" class="text-uppercase text-center">Run Speed Test</h1>
  5112. <div class="clearfix"></div>
  5113. </div>
  5114. </div>
  5115. </div>
  5116. ';
  5117. }
  5118. break;
  5119. case 'homepageOrdertransmisson':
  5120. if(TRANSMISSIONURL != "" && qualifyUser(TRANSMISSIONHOMEAUTH)){
  5121. $homepageItemBuilt .= buildDownloader('transmission', 'no');
  5122. }
  5123. break;
  5124. case 'homepageOrdernzbget':
  5125. if(NZBGETURL != "" && qualifyUser(NZBGETHOMEAUTH)){
  5126. $homepageItemBuilt .= buildDownloader('nzbget');
  5127. }
  5128. break;
  5129. case 'homepageOrdersabnzbd':
  5130. if(SABNZBDURL != "" && qualifyUser(SABNZBDHOMEAUTH)) {
  5131. $homepageItemBuilt .= buildDownloader('sabnzbd');
  5132. }
  5133. break;
  5134. case 'homepageOrderplexnowplaying':
  5135. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  5136. if(qualifyUser(PLEXPLAYINGNOWAUTH) && PLEXPLAYINGNOW == "true"){
  5137. $homepageItemBuilt .= '<div id="plexRowNowPlaying" class="row">';
  5138. $homepageItemBuilt .= getPlexStreams(12, PLEXSHOWNAMES, $group);
  5139. $homepageItemBuilt .= '</div>';
  5140. }
  5141. }
  5142. break;
  5143. case 'homepageOrderplexrecent':
  5144. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  5145. if(qualifyUser(PLEXRECENTMOVIEAUTH) && PLEXRECENTMOVIE == "true" || qualifyUser(PLEXRECENTTVAUTH) && PLEXRECENTTV == "true" || qualifyUser(PLEXRECENTMUSICAUTH) && PLEXRECENTMUSIC == "true"){
  5146. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  5147. $homepageItemBuilt .= '<div id="plexRow" class="row"><div class="col-lg-12">';
  5148. $homepageItemBuilt .= getPlexRecent($plexArray);
  5149. $homepageItemBuilt .= '</div></div>';
  5150. }
  5151. }
  5152. break;
  5153. case 'homepageOrderplexplaylist':
  5154. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  5155. if(qualifyUser(PLEXPLAYLISTSAUTH) && PLEXPLAYLISTS == "true"){
  5156. $homepageItemBuilt .= '<div id="plexPlaylists" class="row"><div class="col-lg-12">';
  5157. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  5158. $homepageItemBuilt .= getPlexPlaylists($plexArray);
  5159. $homepageItemBuilt .= '</div> </div>';
  5160. }
  5161. }
  5162. break;
  5163. case 'homepageOrderembynowplaying':
  5164. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  5165. if(qualifyUser(EMBYPLAYINGNOWAUTH) && EMBYPLAYINGNOW == "true"){
  5166. $homepageItemBuilt .= '<div id="embyRowNowPlaying" class="row">';
  5167. $homepageItemBuilt .= getEmbyStreams(12, EMBYSHOWNAMES, $group);
  5168. $homepageItemBuilt .= '</div>';
  5169. }
  5170. }
  5171. break;
  5172. case 'homepageOrderembyrecent':
  5173. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  5174. if(qualifyUser(EMBYRECENTMOVIEAUTH) && EMBYRECENTMOVIE == "true" || qualifyUser(EMBYRECENTTVAUTH) && EMBYRECENTTV == "true" || qualifyUser(EMBYRECENTMUSICAUTH) && EMBYRECENTMUSIC == "true"){
  5175. $embyArray = array("Movie" => EMBYRECENTMOVIE, "Episode" => EMBYRECENTTV, "MusicAlbum" => EMBYRECENTMUSIC, "Series" => EMBYRECENTTV);
  5176. $homepageItemBuilt .= '<div id="embyRow" class="row"><div class="col-lg-12">';
  5177. $homepageItemBuilt .= getEmbyRecent($embyArray);
  5178. $homepageItemBuilt .= '</div></div>';
  5179. }
  5180. }
  5181. break;
  5182. case 'homepageOrderombi':
  5183. if (qualifyUser(OMBIAUTH) && OMBIURL) {
  5184. $homepageItemBuilt .= '<div id="ombiRequests" class="row"><div class="col-lg-12">';
  5185. $homepageItemBuilt .= buildOmbiList($group, $user);
  5186. $homepageItemBuilt .= '</div></div>';
  5187. }
  5188. break;
  5189. case 'homepageOrdercalendar':
  5190. if ((SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)) || (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)) || (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)) || (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)) || (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH))) {
  5191. $calendarItems = '';
  5192. if(RADARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="film" href="javascript:void(0)">Movies</a></li>'; }
  5193. if(SONARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="tv" href="javascript:void(0)">TV Shows</a></li>'; }
  5194. if(HEADPHONESURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="music" href="javascript:void(0)">Music</a></li>'; }
  5195. $homepageItemBuilt .= '
  5196. <div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">
  5197. <div class="col-lg-12 content-form form-inline">
  5198. <div class="form-group pull-right">
  5199. <span class="swal-legend label label-primary well-sm">Legend</span>&nbsp;
  5200. <div class="btn-group" role="group">
  5201. <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>
  5202. <ul style="right:0; left: auto" class="dropdown-menu">
  5203. <li><a class="calendarOption" calendarOption="all" href="javascript:void(0)">View All</a></li>
  5204. '.$calendarItems.'
  5205. </ul>
  5206. </div>
  5207. </div>
  5208. </div>
  5209. </div>
  5210. <div id="calendarRow" class="row">
  5211. <div class="col-lg-12">
  5212. <div id="calendar" class="fc-calendar box-shadow fc fc-ltr fc-unthemed"></div>
  5213. </div>
  5214. </div>
  5215. ';
  5216. }
  5217. break;
  5218. default:
  5219. # code...
  5220. break;
  5221. }
  5222. return $homepageItemBuilt;
  5223. }
  5224. function buildAccordion($items){
  5225. $i = 1;
  5226. $variables = '&nbsp; Available Variables: ';
  5227. $accordion = '<div style="margin-bottom: 0px;" class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">';
  5228. foreach ($items as $key => $value) {
  5229. if($value['type'] == 'template'){
  5230. foreach ($value['variables'] as $variable) {
  5231. $variables .= '<mark>'.$variable.'</mark>';
  5232. }
  5233. $accordion .= '
  5234. <div class="panel panel-default">
  5235. <div class="panel-heading" role="tab" id="heading-'.$i.'">
  5236. <h4 class="panel-title" style="text-decoration: none;" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-'.$i.'" aria-expanded="true" aria-controls="collapse-'.$i.'">'.$value['title'].'</h4>
  5237. </div>
  5238. <div id="collapse-'.$i.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-'.$i.'" aria-expanded="true">
  5239. <br/>'.$variables.'<br/></br/>
  5240. <div class="form-content col-sm-12 col-md-12 col-lg-12">
  5241. <input id="'.$value['template'].'Subject_id" name="'.$value['template'].'Subject" type="text" class="form-control material input-sm" autocorrect="off" autocapitalize="off" value="'.$value['subject'].'">
  5242. <p class="help-text">Email Subject</p>
  5243. </div>
  5244. <br/></br/>
  5245. <div class="summernote" name="'.$value['template'].'">'.$value['body'].'</div>
  5246. </div>
  5247. </div>
  5248. ';
  5249. $i++;
  5250. $variables = '&nbsp; Available Variables: ';
  5251. }else{
  5252. $accordion .= '
  5253. <div class="panel panel-default">
  5254. <div class="panel-heading" role="tab" id="heading-'.$i.'">
  5255. <h4 class="panel-title" style="text-decoration: none;" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-'.$i.'" aria-expanded="true" aria-controls="collapse-'.$i.'">Logo URL For Title</h4>
  5256. </div>
  5257. <div id="collapse-'.$i.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-'.$i.'" aria-expanded="true">
  5258. <div class="form-content col-sm-12 col-md-12 col-lg-12">
  5259. <input id="'.$value['name'].'_id" name="'.$value['name'].'" type="text" class="form-control material input-sm" autocorrect="off" autocapitalize="off" value="'.$value['value'].'">
  5260. <p class="help-text">Logo URL For Title</p>
  5261. </div>
  5262. <br/></br/><br/>
  5263. </div>
  5264. </div>
  5265. ';
  5266. $i++;
  5267. }
  5268. }
  5269. $accordion .= '</div>';
  5270. return $accordion;
  5271. }
  5272. function emailTemplate($emailTemplate){
  5273. $variables = [
  5274. '{user}' => $emailTemplate['user'],
  5275. '{domain}' => DOMAIN,
  5276. '{password}' => $emailTemplate['password'],
  5277. '{inviteCode}' => $emailTemplate['inviteCode'],
  5278. '{fullDomain}' => getServerPath(),
  5279. ];
  5280. $emailTemplate['body'] = strtr($emailTemplate['body'], $variables);
  5281. $emailTemplate['subject'] = strtr($emailTemplate['subject'], $variables);
  5282. return $emailTemplate;
  5283. }
  5284. function buildEmail($email){
  5285. $subject = (isset($email['subject'])) ? $email['subject'] : 'Message from Server';
  5286. $body = (isset($email['body'])) ? $email['body'] : 'Message Error Occured';
  5287. $type = (isset($email['type'])) ? $email['type'] : 'No Type';
  5288. switch ($type) {
  5289. case 'invite':
  5290. $extra = 'invite';
  5291. break;
  5292. case 'reset':
  5293. $extra = 'reset';
  5294. break;
  5295. default:
  5296. $extra = null;
  5297. break;
  5298. }
  5299. include('email.php');
  5300. return $email;
  5301. }
  5302. function buildDownloader($name, $type = 'both'){
  5303. if($type == 'both'){
  5304. $tabs = '
  5305. <ul class="nav nav-tabs pull-right">
  5306. <li class="active"><a href="#downloadQueue-'.$name.'" data-toggle="tab" aria-expanded="true">'.translate("QUEUE").'</a></li>
  5307. <li class=""><a href="#downloadHistory-'.$name.'" data-toggle="tab" aria-expanded="false">'.translate("HISTORY").'</a></li>
  5308. </ul>
  5309. ';
  5310. $bodyHistory = '
  5311. <div class="tab-pane fade" id="downloadHistory-'.$name.'">
  5312. <div class="table-responsive" style="max-height: 300px">
  5313. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  5314. <thead>
  5315. <tr>
  5316. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  5317. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  5318. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  5319. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  5320. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  5321. </tr>
  5322. </thead>
  5323. <tbody class="dl-history '.$name.'"></tbody>
  5324. </table>
  5325. </div>
  5326. </div>
  5327. ';
  5328. }else{
  5329. $tabs = '';
  5330. $bodyHistory = '';
  5331. }
  5332. return '
  5333. <div id="downloadClientRow" class="row">
  5334. <div class="col-xs-12 col-md-12">
  5335. <div class="content-box">
  5336. <div class="tabbable panel with-nav-tabs panel-default">
  5337. <div class="panel-heading">
  5338. <div class="content-tools i-block pull-right">
  5339. <a id="getDownloader" class="repeat-btn">
  5340. <i class="fa fa-repeat"></i>
  5341. </a>
  5342. </div>
  5343. <h3 class="pull-left">'.strtoupper($name).'</h3>
  5344. '.$tabs.'
  5345. <div class="clearfix"></div>
  5346. </div>
  5347. <div class="panel-body">
  5348. <div class="tab-content">
  5349. <div class="tab-pane fade active in" id="downloadQueue-'.$name.'">
  5350. <div class="table-responsive" style="max-height: 300px">
  5351. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  5352. <thead>
  5353. <tr>
  5354. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  5355. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  5356. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  5357. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  5358. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  5359. </tr>
  5360. </thead>
  5361. <tbody class="dl-queue '.$name.'"></tbody>
  5362. </table>
  5363. </div>
  5364. </div>
  5365. '.$bodyHistory.'
  5366. </div>
  5367. </div>
  5368. </div>
  5369. </div>
  5370. </div>
  5371. </div>';
  5372. }
  5373. class Mobile_Detect
  5374. {
  5375. /**
  5376. * Mobile detection type.
  5377. *
  5378. * @deprecated since version 2.6.9
  5379. */
  5380. const DETECTION_TYPE_MOBILE = 'mobile';
  5381. /**
  5382. * Extended detection type.
  5383. *
  5384. * @deprecated since version 2.6.9
  5385. */
  5386. const DETECTION_TYPE_EXTENDED = 'extended';
  5387. /**
  5388. * A frequently used regular expression to extract version #s.
  5389. *
  5390. * @deprecated since version 2.6.9
  5391. */
  5392. const VER = '([\w._\+]+)';
  5393. /**
  5394. * Top-level device.
  5395. */
  5396. const MOBILE_GRADE_A = 'A';
  5397. /**
  5398. * Mid-level device.
  5399. */
  5400. const MOBILE_GRADE_B = 'B';
  5401. /**
  5402. * Low-level device.
  5403. */
  5404. const MOBILE_GRADE_C = 'C';
  5405. /**
  5406. * Stores the version number of the current release.
  5407. */
  5408. const VERSION = '2.8.26';
  5409. /**
  5410. * A type for the version() method indicating a string return value.
  5411. */
  5412. const VERSION_TYPE_STRING = 'text';
  5413. /**
  5414. * A type for the version() method indicating a float return value.
  5415. */
  5416. const VERSION_TYPE_FLOAT = 'float';
  5417. /**
  5418. * A cache for resolved matches
  5419. * @var array
  5420. */
  5421. protected $cache = array();
  5422. /**
  5423. * The User-Agent HTTP header is stored in here.
  5424. * @var string
  5425. */
  5426. protected $userAgent = null;
  5427. /**
  5428. * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
  5429. * @var array
  5430. */
  5431. protected $httpHeaders = array();
  5432. /**
  5433. * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
  5434. * @var array
  5435. */
  5436. protected $cloudfrontHeaders = array();
  5437. /**
  5438. * The matching Regex.
  5439. * This is good for debug.
  5440. * @var string
  5441. */
  5442. protected $matchingRegex = null;
  5443. /**
  5444. * The matches extracted from the regex expression.
  5445. * This is good for debug.
  5446. * @var string
  5447. */
  5448. protected $matchesArray = null;
  5449. /**
  5450. * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
  5451. *
  5452. * @deprecated since version 2.6.9
  5453. *
  5454. * @var string
  5455. */
  5456. protected $detectionType = self::DETECTION_TYPE_MOBILE;
  5457. /**
  5458. * HTTP headers that trigger the 'isMobile' detection
  5459. * to be true.
  5460. *
  5461. * @var array
  5462. */
  5463. protected static $mobileHeaders = array(
  5464. 'HTTP_ACCEPT' => array('matches' => array(
  5465. // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
  5466. 'application/x-obml2d',
  5467. // BlackBerry devices.
  5468. 'application/vnd.rim.html',
  5469. 'text/vnd.wap.wml',
  5470. 'application/vnd.wap.xhtml+xml'
  5471. )),
  5472. 'HTTP_X_WAP_PROFILE' => null,
  5473. 'HTTP_X_WAP_CLIENTID' => null,
  5474. 'HTTP_WAP_CONNECTION' => null,
  5475. 'HTTP_PROFILE' => null,
  5476. // Reported by Opera on Nokia devices (eg. C3).
  5477. 'HTTP_X_OPERAMINI_PHONE_UA' => null,
  5478. 'HTTP_X_NOKIA_GATEWAY_ID' => null,
  5479. 'HTTP_X_ORANGE_ID' => null,
  5480. 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
  5481. 'HTTP_X_HUAWEI_USERID' => null,
  5482. // Reported by Windows Smartphones.
  5483. 'HTTP_UA_OS' => null,
  5484. // Reported by Verizon, Vodafone proxy system.
  5485. 'HTTP_X_MOBILE_GATEWAY' => null,
  5486. // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
  5487. 'HTTP_X_ATT_DEVICEID' => null,
  5488. // Seen this on a HTC.
  5489. 'HTTP_UA_CPU' => array('matches' => array('ARM')),
  5490. );
  5491. /**
  5492. * List of mobile devices (phones).
  5493. *
  5494. * @var array
  5495. */
  5496. protected static $phoneDevices = array(
  5497. 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
  5498. 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
  5499. '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',
  5500. 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
  5501. // @todo: Is 'Dell Streak' a tablet or a phone? ;)
  5502. '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',
  5503. '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',
  5504. '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',
  5505. '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)',
  5506. 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
  5507. 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
  5508. 'NokiaLumia' => 'Lumia [0-9]{3,4}',
  5509. // http://www.micromaxinfo.com/mobiles/smartphones
  5510. // Added because the codes might conflict with Acer Tablets.
  5511. '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',
  5512. // @todo Complete the regex.
  5513. 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
  5514. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
  5515. // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
  5516. // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
  5517. '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',
  5518. // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
  5519. 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
  5520. // http://fr.wikomobile.com
  5521. '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',
  5522. 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
  5523. // Added simvalley mobile just for fun. They have some interesting devices.
  5524. // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
  5525. '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',
  5526. // Wolfgang - a brand that is sold by Aldi supermarkets.
  5527. // http://www.wolfgangmobile.com/
  5528. 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
  5529. 'Alcatel' => 'Alcatel',
  5530. 'Nintendo' => 'Nintendo 3DS',
  5531. // http://en.wikipedia.org/wiki/Amoi
  5532. 'Amoi' => 'Amoi',
  5533. // http://en.wikipedia.org/wiki/INQ
  5534. 'INQ' => 'INQ',
  5535. // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
  5536. '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',
  5537. );
  5538. /**
  5539. * List of tablet devices.
  5540. *
  5541. * @var array
  5542. */
  5543. protected static $tabletDevices = array(
  5544. // @todo: check for mobile friendly emails topic.
  5545. 'iPad' => 'iPad|iPad.*Mobile',
  5546. // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
  5547. // @see #442
  5548. 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
  5549. '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.
  5550. // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
  5551. '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)',
  5552. // Only the Surface tablets with Windows RT are considered mobile.
  5553. // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
  5554. 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
  5555. // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
  5556. 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
  5557. // Watch out for PadFone, see #132.
  5558. // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
  5559. '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',
  5560. 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
  5561. 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
  5562. 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
  5563. 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
  5564. // http://www.acer.ro/ac/ro/RO/content/drivers
  5565. // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
  5566. // http://us.acer.com/ac/en/US/content/group/tablets
  5567. // http://www.acer.de/ac/de/DE/content/models/tablets/
  5568. // Can conflict with Micromax and Motorola phones codes.
  5569. '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',
  5570. // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
  5571. // http://us.toshiba.com/tablets/tablet-finder
  5572. // http://www.toshiba.co.jp/regza/tablet/
  5573. 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
  5574. // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
  5575. // http://www.lg.com/us/tablets
  5576. 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
  5577. 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
  5578. // Prestigio Tablets http://www.prestigio.com/support
  5579. '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',
  5580. // http://support.lenovo.com/en_GB/downloads/default.page?#
  5581. '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|)',
  5582. // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
  5583. 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
  5584. // http://www.yarvik.com/en/matrix/tablets/
  5585. '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',
  5586. 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
  5587. 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
  5588. // http://www.intenso.de/kategorie_en.php?kategorie=33
  5589. // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
  5590. 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
  5591. // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
  5592. 'IRUTablet' => 'M702pro',
  5593. 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
  5594. // http://www.e-boda.ro/tablete-pc.html
  5595. 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
  5596. // http://www.allview.ro/produse/droseries/lista-tablete-pc/
  5597. 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
  5598. // http://wiki.archosfans.com/index.php?title=Main_Page
  5599. // @note Rewrite the regex format after we add more UAs.
  5600. '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',
  5601. // http://www.ainol.com/plugin.php?identifier=ainol&module=product
  5602. 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
  5603. 'NokiaLumiaTablet' => 'Lumia 2520',
  5604. // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
  5605. // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
  5606. // http://www.sony.jp/support/tablet/
  5607. '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',
  5608. // 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
  5609. 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
  5610. // db + http://www.cube-tablet.com/buy-products.html
  5611. 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
  5612. // http://www.cobyusa.com/?p=pcat&pcat_id=3001
  5613. 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
  5614. // http://www.match.net.cn/products.asp
  5615. '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',
  5616. // http://www.msi.com/support
  5617. // @todo Research the Windows Tablets.
  5618. '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',
  5619. // @todo http://www.kyoceramobile.com/support/drivers/
  5620. // 'KyoceraTablet' => null,
  5621. // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
  5622. // 'IntextTablet' => null,
  5623. // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
  5624. // http://www.imp3.net/14/show.php?itemid=20454
  5625. 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
  5626. // http://www.rock-chips.com/index.php?do=prod&pid=2
  5627. 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
  5628. // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
  5629. 'FlyTablet' => 'IQ310|Fly Vision',
  5630. // http://www.bqreaders.com/gb/tablets-prices-sale.html
  5631. 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
  5632. // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
  5633. // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
  5634. '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',
  5635. // Nec or Medias Tab
  5636. 'NecTablet' => '\bN-06D|\bN-08D',
  5637. // Pantech Tablets: http://www.pantechusa.com/phones/
  5638. 'PantechTablet' => 'Pantech.*P4100',
  5639. // Broncho Tablets: http://www.broncho.cn/ (hard to find)
  5640. 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
  5641. // http://versusuk.com/support.html
  5642. 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
  5643. // http://www.zync.in/index.php/our-products/tablet-phablets
  5644. 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
  5645. // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
  5646. 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
  5647. // https://www.nabitablet.com/
  5648. 'NabiTablet' => 'Android.*\bNabi',
  5649. 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
  5650. // French Danew Tablets http://www.danew.com/produits-tablette.php
  5651. 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
  5652. // Texet Tablets and Readers http://www.texet.ru/tablet/
  5653. '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',
  5654. // Avoid detecting 'PLAYSTATION 3' as mobile.
  5655. 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
  5656. // http://www.trekstor.de/surftabs.html
  5657. 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
  5658. // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
  5659. 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
  5660. // http://www.advandigital.com/index.php?link=content-product&jns=JP001
  5661. // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
  5662. '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 ',
  5663. // http://www.danytech.com/category/tablet-pc
  5664. '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',
  5665. // http://www.galapad.net/product.html
  5666. 'GalapadTablet' => 'Android.*\bG1\b',
  5667. // http://www.micromaxinfo.com/tablet/funbook
  5668. 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
  5669. // http://www.karbonnmobiles.com/products_tablet.php
  5670. 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
  5671. // http://www.myallfine.com/Products.asp
  5672. 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
  5673. // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
  5674. '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',
  5675. // http://www.yonesnav.com/products/products.php
  5676. 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
  5677. // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
  5678. // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
  5679. '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',
  5680. // http://www.gloryunion.cn/products.asp
  5681. // http://www.allwinnertech.com/en/apply/mobile.html
  5682. // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
  5683. // @todo: Softwiner tablets?
  5684. // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
  5685. '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
  5686. // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
  5687. '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',
  5688. // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
  5689. // @todo: add more tests.
  5690. 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
  5691. // http://hclmetablet.com/India/index.php
  5692. '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',
  5693. // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
  5694. 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
  5695. // http://www.visture.com/index.asp
  5696. 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
  5697. // http://www.mijncresta.nl/tablet
  5698. 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
  5699. // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
  5700. 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
  5701. // Concorde tab
  5702. 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
  5703. // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
  5704. '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',
  5705. // Modecom Tablets - http://www.modecom.eu/tablets/portal/
  5706. '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',
  5707. // Vonino Tablets - http://www.vonino.eu/tablets
  5708. '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',
  5709. // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
  5710. 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
  5711. // Storex Tablets - http://storex.fr/espace_client/support.html
  5712. // @note: no need to add all the tablet codes since they are guided by the first regex.
  5713. 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
  5714. // Generic Vodafone tablets.
  5715. 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
  5716. // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
  5717. // Aka: http://www.essentielb.fr/
  5718. 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
  5719. // Ross & Moor - http://ross-moor.ru/
  5720. 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
  5721. // i-mobile http://product.i-mobilephone.com/Mobile_Device
  5722. 'iMobileTablet' => 'i-mobile i-note',
  5723. // http://www.tolino.de/de/vergleichen/
  5724. 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
  5725. // AudioSonic - a Kmart brand
  5726. // 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
  5727. 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
  5728. // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
  5729. // @todo: add them gradually to avoid conflicts.
  5730. 'AMPETablet' => 'Android.* A78 ',
  5731. // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
  5732. 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
  5733. // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
  5734. 'TecnoTablet' => 'TECNO P9',
  5735. // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
  5736. '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',
  5737. // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
  5738. '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)',
  5739. // http://www.intracon.eu/tablet
  5740. 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
  5741. // http://www.xoro.de/produkte/
  5742. // @note: Might be the same brand with 'Simply tablets'
  5743. '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',
  5744. // http://www1.viewsonic.com/products/computing/tablets/
  5745. 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
  5746. // http://www.odys.de/web/internet-tablet_en.html
  5747. 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
  5748. // http://www.captiva-power.de/products.html#tablets-en
  5749. 'CaptivaTablet' => 'CAPTIVA PAD',
  5750. // IconBIT - http://www.iconbit.com/products/tablets/
  5751. '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',
  5752. // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
  5753. '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',
  5754. // Onda - http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
  5755. '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]+',
  5756. 'JaytechTablet' => 'TPC-PA762',
  5757. 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
  5758. // http://www.digma.ru/support/download/
  5759. // @todo: Ebooks also (if requested)
  5760. 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
  5761. // http://www.evolioshop.com/ro/tablete-pc.html
  5762. // http://www.evolio.ro/support/downloads_static.html?cat=2
  5763. // @todo: Research some more
  5764. 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
  5765. // @todo http://www.lavamobiles.com/tablets-data-cards
  5766. 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
  5767. // http://www.breezetablet.com/
  5768. 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
  5769. // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
  5770. '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',
  5771. // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
  5772. 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
  5773. // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
  5774. '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',
  5775. // http://www.mi.com/en
  5776. 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
  5777. // http://www.nbru.cn/index.html
  5778. 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
  5779. // http://navroad.com/products/produkty/tablety/
  5780. // http://navroad.com/products/produkty/tablety/
  5781. 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
  5782. // http://leader-online.com/new_site/product-category/tablets/
  5783. // http://www.leader-online.net.au/List/Tablet
  5784. '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',
  5785. // http://www.datawind.com/ubislate/
  5786. 'UbislateTablet' => 'UbiSlate[\s]?7C',
  5787. // http://www.pocketbook-int.com/ru/support
  5788. 'PocketBookTablet' => 'Pocketbook',
  5789. // http://www.kocaso.com/product_tablet.html
  5790. 'KocasoTablet' => '\b(TB-1207)\b',
  5791. // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
  5792. 'HisenseTablet' => '\b(F5281|E2371)\b',
  5793. // http://www.tesco.com/direct/hudl/
  5794. 'Hudl' => 'Hudl HT7S3|Hudl 2',
  5795. // http://www.telstra.com.au/home-phone/thub-2/
  5796. 'TelstraTablet' => 'T-Hub2',
  5797. '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'
  5798. );
  5799. /**
  5800. * List of mobile Operating Systems.
  5801. *
  5802. * @var array
  5803. */
  5804. protected static $operatingSystems = array(
  5805. 'AndroidOS' => 'Android',
  5806. 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
  5807. 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
  5808. 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
  5809. // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
  5810. 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
  5811. // @reference: http://en.wikipedia.org/wiki/Windows_Phone
  5812. // http://wifeng.cn/?r=blog&a=view&id=106
  5813. // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
  5814. // http://msdn.microsoft.com/library/ms537503.aspx
  5815. // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
  5816. 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
  5817. 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
  5818. // http://en.wikipedia.org/wiki/MeeGo
  5819. // @todo: research MeeGo in UAs
  5820. 'MeeGoOS' => 'MeeGo',
  5821. // http://en.wikipedia.org/wiki/Maemo
  5822. // @todo: research Maemo in UAs
  5823. 'MaemoOS' => 'Maemo',
  5824. 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
  5825. 'webOS' => 'webOS|hpwOS',
  5826. 'badaOS' => '\bBada\b',
  5827. 'BREWOS' => 'BREW',
  5828. );
  5829. /**
  5830. * List of mobile User Agents.
  5831. *
  5832. * IMPORTANT: This is a list of only mobile browsers.
  5833. * Mobile Detect 2.x supports only mobile browsers,
  5834. * it was never designed to detect all browsers.
  5835. * The change will come in 2017 in the 3.x release for PHP7.
  5836. *
  5837. * @var array
  5838. */
  5839. protected static $browsers = array(
  5840. //'Vivaldi' => 'Vivaldi',
  5841. // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
  5842. 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
  5843. 'Dolfin' => '\bDolfin\b',
  5844. 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
  5845. 'Skyfire' => 'Skyfire',
  5846. 'Edge' => 'Mobile Safari/[.0-9]* Edge',
  5847. 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
  5848. 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
  5849. 'Bolt' => 'bolt',
  5850. 'TeaShark' => 'teashark',
  5851. 'Blazer' => 'Blazer',
  5852. // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
  5853. 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
  5854. // http://en.wikipedia.org/wiki/Midori_(web_browser)
  5855. //'Midori' => 'midori',
  5856. //'Tizen' => 'Tizen',
  5857. 'UCBrowser' => 'UC.*Browser|UCWEB',
  5858. 'baiduboxapp' => 'baiduboxapp',
  5859. 'baidubrowser' => 'baidubrowser',
  5860. // https://github.com/serbanghita/Mobile-Detect/issues/7
  5861. 'DiigoBrowser' => 'DiigoBrowser',
  5862. // http://www.puffinbrowser.com/index.php
  5863. 'Puffin' => 'Puffin',
  5864. // http://mercury-browser.com/index.html
  5865. 'Mercury' => '\bMercury\b',
  5866. // http://en.wikipedia.org/wiki/Obigo_Browser
  5867. 'ObigoBrowser' => 'Obigo',
  5868. // http://en.wikipedia.org/wiki/NetFront
  5869. 'NetFront' => 'NF-Browser',
  5870. // @reference: http://en.wikipedia.org/wiki/Minimo
  5871. // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
  5872. 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
  5873. // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
  5874. 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
  5875. );
  5876. /**
  5877. * Utilities.
  5878. *
  5879. * @var array
  5880. */
  5881. protected static $utilities = array(
  5882. // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
  5883. // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
  5884. // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
  5885. // https://developers.facebook.com/docs/sharing/best-practices
  5886. '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',
  5887. 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
  5888. 'DesktopMode' => 'WPDesktop',
  5889. 'TV' => 'SonyDTV|HbbTV', // experimental
  5890. 'WebKit' => '(webkit)[ /]([\w.]+)',
  5891. // @todo: Include JXD consoles.
  5892. 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
  5893. 'Watch' => 'SM-V700',
  5894. );
  5895. /**
  5896. * All possible HTTP headers that represent the
  5897. * User-Agent string.
  5898. *
  5899. * @var array
  5900. */
  5901. protected static $uaHttpHeaders = array(
  5902. // The default User-Agent string.
  5903. 'HTTP_USER_AGENT',
  5904. // Header can occur on devices using Opera Mini.
  5905. 'HTTP_X_OPERAMINI_PHONE_UA',
  5906. // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
  5907. 'HTTP_X_DEVICE_USER_AGENT',
  5908. 'HTTP_X_ORIGINAL_USER_AGENT',
  5909. 'HTTP_X_SKYFIRE_PHONE',
  5910. 'HTTP_X_BOLT_PHONE_UA',
  5911. 'HTTP_DEVICE_STOCK_UA',
  5912. 'HTTP_X_UCBROWSER_DEVICE_UA'
  5913. );
  5914. /**
  5915. * The individual segments that could exist in a User-Agent string. VER refers to the regular
  5916. * expression defined in the constant self::VER.
  5917. *
  5918. * @var array
  5919. */
  5920. protected static $properties = array(
  5921. // Build
  5922. 'Mobile' => 'Mobile/[VER]',
  5923. 'Build' => 'Build/[VER]',
  5924. 'Version' => 'Version/[VER]',
  5925. 'VendorID' => 'VendorID/[VER]',
  5926. // Devices
  5927. 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
  5928. 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
  5929. 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
  5930. //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
  5931. 'Kindle' => 'Kindle/[VER]',
  5932. // Browser
  5933. 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
  5934. 'Coast' => array('Coast/[VER]'),
  5935. 'Dolfin' => 'Dolfin/[VER]',
  5936. // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
  5937. 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
  5938. 'Fennec' => 'Fennec/[VER]',
  5939. // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  5940. // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
  5941. 'Edge' => 'Edge/[VER]',
  5942. 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
  5943. // http://en.wikipedia.org/wiki/NetFront
  5944. 'NetFront' => 'NetFront/[VER]',
  5945. 'NokiaBrowser' => 'NokiaBrowser/[VER]',
  5946. 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
  5947. 'Opera Mini' => 'Opera Mini/[VER]',
  5948. 'Opera Mobi' => 'Version/[VER]',
  5949. 'UC Browser' => 'UC Browser[VER]',
  5950. 'MQQBrowser' => 'MQQBrowser/[VER]',
  5951. 'MicroMessenger' => 'MicroMessenger/[VER]',
  5952. 'baiduboxapp' => 'baiduboxapp/[VER]',
  5953. 'baidubrowser' => 'baidubrowser/[VER]',
  5954. 'SamsungBrowser' => 'SamsungBrowser/[VER]',
  5955. 'Iron' => 'Iron/[VER]',
  5956. // @note: Safari 7534.48.3 is actually Version 5.1.
  5957. // @note: On BlackBerry the Version is overwriten by the OS.
  5958. 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
  5959. 'Skyfire' => 'Skyfire/[VER]',
  5960. 'Tizen' => 'Tizen/[VER]',
  5961. 'Webkit' => 'webkit[ /][VER]',
  5962. 'PaleMoon' => 'PaleMoon/[VER]',
  5963. // Engine
  5964. 'Gecko' => 'Gecko/[VER]',
  5965. 'Trident' => 'Trident/[VER]',
  5966. 'Presto' => 'Presto/[VER]',
  5967. 'Goanna' => 'Goanna/[VER]',
  5968. // OS
  5969. 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
  5970. 'Android' => 'Android [VER]',
  5971. 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
  5972. 'BREW' => 'BREW [VER]',
  5973. 'Java' => 'Java/[VER]',
  5974. // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
  5975. // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
  5976. 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
  5977. 'Windows Phone' => 'Windows Phone [VER]',
  5978. 'Windows CE' => 'Windows CE/[VER]',
  5979. // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
  5980. 'Windows NT' => 'Windows NT [VER]',
  5981. 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
  5982. 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
  5983. );
  5984. /**
  5985. * Construct an instance of this class.
  5986. *
  5987. * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
  5988. * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
  5989. * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
  5990. * from the $headers array instead.
  5991. */
  5992. public function __construct(
  5993. array $headers = null,
  5994. $userAgent = null
  5995. ) {
  5996. $this->setHttpHeaders($headers);
  5997. $this->setUserAgent($userAgent);
  5998. }
  5999. /**
  6000. * Get the current script version.
  6001. * This is useful for the demo.php file,
  6002. * so people can check on what version they are testing
  6003. * for mobile devices.
  6004. *
  6005. * @return string The version number in semantic version format.
  6006. */
  6007. public static function getScriptVersion()
  6008. {
  6009. return self::VERSION;
  6010. }
  6011. /**
  6012. * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
  6013. *
  6014. * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
  6015. * the headers. The default null is left for backwards compatibility.
  6016. */
  6017. public function setHttpHeaders($httpHeaders = null)
  6018. {
  6019. // use global _SERVER if $httpHeaders aren't defined
  6020. if (!is_array($httpHeaders) || !count($httpHeaders)) {
  6021. $httpHeaders = $_SERVER;
  6022. }
  6023. // clear existing headers
  6024. $this->httpHeaders = array();
  6025. // Only save HTTP headers. In PHP land, that means only _SERVER vars that
  6026. // start with HTTP_.
  6027. foreach ($httpHeaders as $key => $value) {
  6028. if (substr($key, 0, 5) === 'HTTP_') {
  6029. $this->httpHeaders[$key] = $value;
  6030. }
  6031. }
  6032. // In case we're dealing with CloudFront, we need to know.
  6033. $this->setCfHeaders($httpHeaders);
  6034. }
  6035. /**
  6036. * Retrieves the HTTP headers.
  6037. *
  6038. * @return array
  6039. */
  6040. public function getHttpHeaders()
  6041. {
  6042. return $this->httpHeaders;
  6043. }
  6044. /**
  6045. * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
  6046. * Simply null is returned.
  6047. *
  6048. * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
  6049. * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
  6050. * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
  6051. *
  6052. * @return string|null The value of the header.
  6053. */
  6054. public function getHttpHeader($header)
  6055. {
  6056. // are we using PHP-flavored headers?
  6057. if (strpos($header, '_') === false) {
  6058. $header = str_replace('-', '_', $header);
  6059. $header = strtoupper($header);
  6060. }
  6061. // test the alternate, too
  6062. $altHeader = 'HTTP_' . $header;
  6063. //Test both the regular and the HTTP_ prefix
  6064. if (isset($this->httpHeaders[$header])) {
  6065. return $this->httpHeaders[$header];
  6066. } elseif (isset($this->httpHeaders[$altHeader])) {
  6067. return $this->httpHeaders[$altHeader];
  6068. }
  6069. return null;
  6070. }
  6071. public function getMobileHeaders()
  6072. {
  6073. return self::$mobileHeaders;
  6074. }
  6075. /**
  6076. * Get all possible HTTP headers that
  6077. * can contain the User-Agent string.
  6078. *
  6079. * @return array List of HTTP headers.
  6080. */
  6081. public function getUaHttpHeaders()
  6082. {
  6083. return self::$uaHttpHeaders;
  6084. }
  6085. /**
  6086. * Set CloudFront headers
  6087. * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
  6088. *
  6089. * @param array $cfHeaders List of HTTP headers
  6090. *
  6091. * @return boolean If there were CloudFront headers to be set
  6092. */
  6093. public function setCfHeaders($cfHeaders = null) {
  6094. // use global _SERVER if $cfHeaders aren't defined
  6095. if (!is_array($cfHeaders) || !count($cfHeaders)) {
  6096. $cfHeaders = $_SERVER;
  6097. }
  6098. // clear existing headers
  6099. $this->cloudfrontHeaders = array();
  6100. // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
  6101. // start with cloudfront-.
  6102. $response = false;
  6103. foreach ($cfHeaders as $key => $value) {
  6104. if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
  6105. $this->cloudfrontHeaders[strtoupper($key)] = $value;
  6106. $response = true;
  6107. }
  6108. }
  6109. return $response;
  6110. }
  6111. /**
  6112. * Retrieves the cloudfront headers.
  6113. *
  6114. * @return array
  6115. */
  6116. public function getCfHeaders()
  6117. {
  6118. return $this->cloudfrontHeaders;
  6119. }
  6120. /**
  6121. * Set the User-Agent to be used.
  6122. *
  6123. * @param string $userAgent The user agent string to set.
  6124. *
  6125. * @return string|null
  6126. */
  6127. public function setUserAgent($userAgent = null)
  6128. {
  6129. // Invalidate cache due to #375
  6130. $this->cache = array();
  6131. if (false === empty($userAgent)) {
  6132. return $this->userAgent = $userAgent;
  6133. } else {
  6134. $this->userAgent = null;
  6135. foreach ($this->getUaHttpHeaders() as $altHeader) {
  6136. if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
  6137. $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
  6138. }
  6139. }
  6140. if (!empty($this->userAgent)) {
  6141. return $this->userAgent = trim($this->userAgent);
  6142. }
  6143. }
  6144. if (count($this->getCfHeaders()) > 0) {
  6145. return $this->userAgent = 'Amazon CloudFront';
  6146. }
  6147. return $this->userAgent = null;
  6148. }
  6149. /**
  6150. * Retrieve the User-Agent.
  6151. *
  6152. * @return string|null The user agent if it's set.
  6153. */
  6154. public function getUserAgent()
  6155. {
  6156. return $this->userAgent;
  6157. }
  6158. /**
  6159. * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
  6160. * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
  6161. *
  6162. * @deprecated since version 2.6.9
  6163. *
  6164. * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
  6165. * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
  6166. */
  6167. public function setDetectionType($type = null)
  6168. {
  6169. if ($type === null) {
  6170. $type = self::DETECTION_TYPE_MOBILE;
  6171. }
  6172. if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
  6173. return;
  6174. }
  6175. $this->detectionType = $type;
  6176. }
  6177. public function getMatchingRegex()
  6178. {
  6179. return $this->matchingRegex;
  6180. }
  6181. public function getMatchesArray()
  6182. {
  6183. return $this->matchesArray;
  6184. }
  6185. /**
  6186. * Retrieve the list of known phone devices.
  6187. *
  6188. * @return array List of phone devices.
  6189. */
  6190. public static function getPhoneDevices()
  6191. {
  6192. return self::$phoneDevices;
  6193. }
  6194. /**
  6195. * Retrieve the list of known tablet devices.
  6196. *
  6197. * @return array List of tablet devices.
  6198. */
  6199. public static function getTabletDevices()
  6200. {
  6201. return self::$tabletDevices;
  6202. }
  6203. /**
  6204. * Alias for getBrowsers() method.
  6205. *
  6206. * @return array List of user agents.
  6207. */
  6208. public static function getUserAgents()
  6209. {
  6210. return self::getBrowsers();
  6211. }
  6212. /**
  6213. * Retrieve the list of known browsers. Specifically, the user agents.
  6214. *
  6215. * @return array List of browsers / user agents.
  6216. */
  6217. public static function getBrowsers()
  6218. {
  6219. return self::$browsers;
  6220. }
  6221. /**
  6222. * Retrieve the list of known utilities.
  6223. *
  6224. * @return array List of utilities.
  6225. */
  6226. public static function getUtilities()
  6227. {
  6228. return self::$utilities;
  6229. }
  6230. /**
  6231. * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
  6232. *
  6233. * @deprecated since version 2.6.9
  6234. *
  6235. * @return array All the rules (but not extended).
  6236. */
  6237. public static function getMobileDetectionRules()
  6238. {
  6239. static $rules;
  6240. if (!$rules) {
  6241. $rules = array_merge(
  6242. self::$phoneDevices,
  6243. self::$tabletDevices,
  6244. self::$operatingSystems,
  6245. self::$browsers
  6246. );
  6247. }
  6248. return $rules;
  6249. }
  6250. /**
  6251. * Method gets the mobile detection rules + utilities.
  6252. * The reason this is separate is because utilities rules
  6253. * don't necessary imply mobile. This method is used inside
  6254. * the new $detect->is('stuff') method.
  6255. *
  6256. * @deprecated since version 2.6.9
  6257. *
  6258. * @return array All the rules + extended.
  6259. */
  6260. public function getMobileDetectionRulesExtended()
  6261. {
  6262. static $rules;
  6263. if (!$rules) {
  6264. // Merge all rules together.
  6265. $rules = array_merge(
  6266. self::$phoneDevices,
  6267. self::$tabletDevices,
  6268. self::$operatingSystems,
  6269. self::$browsers,
  6270. self::$utilities
  6271. );
  6272. }
  6273. return $rules;
  6274. }
  6275. /**
  6276. * Retrieve the current set of rules.
  6277. *
  6278. * @deprecated since version 2.6.9
  6279. *
  6280. * @return array
  6281. */
  6282. public function getRules()
  6283. {
  6284. if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
  6285. return self::getMobileDetectionRulesExtended();
  6286. } else {
  6287. return self::getMobileDetectionRules();
  6288. }
  6289. }
  6290. /**
  6291. * Retrieve the list of mobile operating systems.
  6292. *
  6293. * @return array The list of mobile operating systems.
  6294. */
  6295. public static function getOperatingSystems()
  6296. {
  6297. return self::$operatingSystems;
  6298. }
  6299. /**
  6300. * Check the HTTP headers for signs of mobile.
  6301. * This is the fastest mobile check possible; it's used
  6302. * inside isMobile() method.
  6303. *
  6304. * @return bool
  6305. */
  6306. public function checkHttpHeadersForMobile()
  6307. {
  6308. foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
  6309. if (isset($this->httpHeaders[$mobileHeader])) {
  6310. if (is_array($matchType['matches'])) {
  6311. foreach ($matchType['matches'] as $_match) {
  6312. if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
  6313. return true;
  6314. }
  6315. }
  6316. return false;
  6317. } else {
  6318. return true;
  6319. }
  6320. }
  6321. }
  6322. return false;
  6323. }
  6324. /**
  6325. * Magic overloading method.
  6326. *
  6327. * @method boolean is[...]()
  6328. * @param string $name
  6329. * @param array $arguments
  6330. * @return mixed
  6331. * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
  6332. */
  6333. public function __call($name, $arguments)
  6334. {
  6335. // make sure the name starts with 'is', otherwise
  6336. if (substr($name, 0, 2) !== 'is') {
  6337. throw new BadMethodCallException("No such method exists: $name");
  6338. }
  6339. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6340. $key = substr($name, 2);
  6341. return $this->matchUAAgainstKey($key);
  6342. }
  6343. /**
  6344. * Find a detection rule that matches the current User-agent.
  6345. *
  6346. * @param null $userAgent deprecated
  6347. * @return boolean
  6348. */
  6349. protected function matchDetectionRulesAgainstUA($userAgent = null)
  6350. {
  6351. // Begin general search.
  6352. foreach ($this->getRules() as $_regex) {
  6353. if (empty($_regex)) {
  6354. continue;
  6355. }
  6356. if ($this->match($_regex, $userAgent)) {
  6357. return true;
  6358. }
  6359. }
  6360. return false;
  6361. }
  6362. /**
  6363. * Search for a certain key in the rules array.
  6364. * If the key is found then try to match the corresponding
  6365. * regex against the User-Agent.
  6366. *
  6367. * @param string $key
  6368. *
  6369. * @return boolean
  6370. */
  6371. protected function matchUAAgainstKey($key)
  6372. {
  6373. // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
  6374. $key = strtolower($key);
  6375. if (false === isset($this->cache[$key])) {
  6376. // change the keys to lower case
  6377. $_rules = array_change_key_case($this->getRules());
  6378. if (false === empty($_rules[$key])) {
  6379. $this->cache[$key] = $this->match($_rules[$key]);
  6380. }
  6381. if (false === isset($this->cache[$key])) {
  6382. $this->cache[$key] = false;
  6383. }
  6384. }
  6385. return $this->cache[$key];
  6386. }
  6387. /**
  6388. * Check if the device is mobile.
  6389. * Returns true if any type of mobile device detected, including special ones
  6390. * @param null $userAgent deprecated
  6391. * @param null $httpHeaders deprecated
  6392. * @return bool
  6393. */
  6394. public function isMobile($userAgent = null, $httpHeaders = null)
  6395. {
  6396. if ($httpHeaders) {
  6397. $this->setHttpHeaders($httpHeaders);
  6398. }
  6399. if ($userAgent) {
  6400. $this->setUserAgent($userAgent);
  6401. }
  6402. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6403. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6404. $cfHeaders = $this->getCfHeaders();
  6405. if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
  6406. return true;
  6407. }
  6408. }
  6409. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6410. if ($this->checkHttpHeadersForMobile()) {
  6411. return true;
  6412. } else {
  6413. return $this->matchDetectionRulesAgainstUA();
  6414. }
  6415. }
  6416. /**
  6417. * Check if the device is a tablet.
  6418. * Return true if any type of tablet device is detected.
  6419. *
  6420. * @param string $userAgent deprecated
  6421. * @param array $httpHeaders deprecated
  6422. * @return bool
  6423. */
  6424. public function isTablet($userAgent = null, $httpHeaders = null)
  6425. {
  6426. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6427. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6428. $cfHeaders = $this->getCfHeaders();
  6429. if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
  6430. return true;
  6431. }
  6432. }
  6433. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6434. foreach (self::$tabletDevices as $_regex) {
  6435. if ($this->match($_regex, $userAgent)) {
  6436. return true;
  6437. }
  6438. }
  6439. return false;
  6440. }
  6441. /**
  6442. * This method checks for a certain property in the
  6443. * userAgent.
  6444. * @todo: The httpHeaders part is not yet used.
  6445. *
  6446. * @param string $key
  6447. * @param string $userAgent deprecated
  6448. * @param string $httpHeaders deprecated
  6449. * @return bool|int|null
  6450. */
  6451. public function is($key, $userAgent = null, $httpHeaders = null)
  6452. {
  6453. // Set the UA and HTTP headers only if needed (eg. batch mode).
  6454. if ($httpHeaders) {
  6455. $this->setHttpHeaders($httpHeaders);
  6456. }
  6457. if ($userAgent) {
  6458. $this->setUserAgent($userAgent);
  6459. }
  6460. $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
  6461. return $this->matchUAAgainstKey($key);
  6462. }
  6463. /**
  6464. * Some detection rules are relative (not standard),
  6465. * because of the diversity of devices, vendors and
  6466. * their conventions in representing the User-Agent or
  6467. * the HTTP headers.
  6468. *
  6469. * This method will be used to check custom regexes against
  6470. * the User-Agent string.
  6471. *
  6472. * @param $regex
  6473. * @param string $userAgent
  6474. * @return bool
  6475. *
  6476. * @todo: search in the HTTP headers too.
  6477. */
  6478. public function match($regex, $userAgent = null)
  6479. {
  6480. $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
  6481. // If positive match is found, store the results for debug.
  6482. if ($match) {
  6483. $this->matchingRegex = $regex;
  6484. $this->matchesArray = $matches;
  6485. }
  6486. return $match;
  6487. }
  6488. /**
  6489. * Get the properties array.
  6490. *
  6491. * @return array
  6492. */
  6493. public static function getProperties()
  6494. {
  6495. return self::$properties;
  6496. }
  6497. /**
  6498. * Prepare the version number.
  6499. *
  6500. * @todo Remove the error supression from str_replace() call.
  6501. *
  6502. * @param string $ver The string version, like "2.6.21.2152";
  6503. *
  6504. * @return float
  6505. */
  6506. public function prepareVersionNo($ver)
  6507. {
  6508. $ver = str_replace(array('_', ' ', '/'), '.', $ver);
  6509. $arrVer = explode('.', $ver, 2);
  6510. if (isset($arrVer[1])) {
  6511. $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
  6512. }
  6513. return (float) implode('.', $arrVer);
  6514. }
  6515. /**
  6516. * Check the version of the given property in the User-Agent.
  6517. * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
  6518. *
  6519. * @param string $propertyName The name of the property. See self::getProperties() array
  6520. * keys for all possible properties.
  6521. * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
  6522. * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
  6523. * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
  6524. * invalid parameter will default to the this type as well.
  6525. *
  6526. * @return string|float The version of the property we are trying to extract.
  6527. */
  6528. public function version($propertyName, $type = self::VERSION_TYPE_STRING)
  6529. {
  6530. if (empty($propertyName)) {
  6531. return false;
  6532. }
  6533. // set the $type to the default if we don't recognize the type
  6534. if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
  6535. $type = self::VERSION_TYPE_STRING;
  6536. }
  6537. $properties = self::getProperties();
  6538. // Check if the property exists in the properties array.
  6539. if (true === isset($properties[$propertyName])) {
  6540. // Prepare the pattern to be matched.
  6541. // Make sure we always deal with an array (string is converted).
  6542. $properties[$propertyName] = (array) $properties[$propertyName];
  6543. foreach ($properties[$propertyName] as $propertyMatchString) {
  6544. $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
  6545. // Identify and extract the version.
  6546. preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
  6547. if (false === empty($match[1])) {
  6548. $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
  6549. return $version;
  6550. }
  6551. }
  6552. }
  6553. return false;
  6554. }
  6555. /**
  6556. * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
  6557. *
  6558. * @return string One of the self::MOBILE_GRADE_* constants.
  6559. */
  6560. public function mobileGrade()
  6561. {
  6562. $isMobile = $this->isMobile();
  6563. if (
  6564. // 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)
  6565. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6566. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6567. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6568. // 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)
  6569. // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
  6570. // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
  6571. // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
  6572. ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
  6573. // 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)
  6574. $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
  6575. // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
  6576. $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
  6577. // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
  6578. $this->match('Playbook.*Tablet') ||
  6579. // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
  6580. ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
  6581. // Palm WebOS 3.0 - Tested on HP TouchPad
  6582. $this->match('hp.*TouchPad') ||
  6583. // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
  6584. ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
  6585. // Chrome for Android - Tested on Android 4.0, 4.1 device
  6586. ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
  6587. // Skyfire 4.1 - Tested on Android 2.3 device
  6588. ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6589. // Opera Mobile 11.5-12: Tested on Android 2.3
  6590. ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
  6591. // Meego 1.2 - Tested on Nokia 950 and N9
  6592. $this->is('MeeGoOS') ||
  6593. // Tizen (pre-release) - Tested on early hardware
  6594. $this->is('Tizen') ||
  6595. // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
  6596. // @todo: more tests here!
  6597. $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
  6598. // UC Browser - Tested on Android 2.3 device
  6599. ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6600. // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
  6601. ( $this->match('Kindle Fire') ||
  6602. $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
  6603. // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
  6604. $this->is('AndroidOS') && $this->is('NookTablet') ||
  6605. // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
  6606. $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
  6607. // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
  6608. $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
  6609. // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
  6610. $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
  6611. // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
  6612. $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
  6613. // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
  6614. $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
  6615. ){
  6616. return self::MOBILE_GRADE_A;
  6617. }
  6618. if (
  6619. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
  6620. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
  6621. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
  6622. // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
  6623. $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
  6624. //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
  6625. ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
  6626. ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
  6627. // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
  6628. $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
  6629. // @todo: report this (tested on Nokia N71)
  6630. $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
  6631. ){
  6632. return self::MOBILE_GRADE_B;
  6633. }
  6634. if (
  6635. // Blackberry 4.x - Tested on the Curve 8330
  6636. $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
  6637. // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
  6638. $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
  6639. // Tested on original iPhone (3.1), iPhone 3 (3.2)
  6640. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6641. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6642. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6643. // Internet Explorer 7 and older - Tested on Windows XP
  6644. $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
  6645. ){
  6646. return self::MOBILE_GRADE_C;
  6647. }
  6648. // All older smartphone platforms and featurephones - Any device that doesn't support media queries
  6649. // will receive the basic, C grade experience.
  6650. return self::MOBILE_GRADE_C;
  6651. }
  6652. }
  6653. $mobileDetect = new Mobile_Detect;
  6654. $userDevice = ($mobileDetect->isMobile() ? ($mobileDetect->isTablet() ? 'tablet' : 'phone') : 'computer');
  6655. function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  6656. $path = getServerPath();
  6657. return '
  6658. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6659. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  6660. <head>
  6661. <!--[if gte mso 9]><xml>
  6662. <o:OfficeDocumentSettings>
  6663. <o:AllowPNG/>
  6664. <o:PixelsPerInch>96</o:PixelsPerInch>
  6665. </o:OfficeDocumentSettings>
  6666. </xml><![endif]-->
  6667. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6668. <meta name="viewport" content="width=device-width">
  6669. <!--[if !mso]><!-->
  6670. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6671. <!--<![endif]-->
  6672. <title></title>
  6673. <!--[if !mso]><!-- -->
  6674. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
  6675. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  6676. <!--<![endif]-->
  6677. <style type="text/css" id="media-query">
  6678. body {
  6679. margin: 0;
  6680. padding: 0;
  6681. }
  6682. table,
  6683. tr,
  6684. td {
  6685. vertical-align: top;
  6686. border-collapse: collapse;
  6687. }
  6688. .ie-browser table,
  6689. .mso-container table {
  6690. table-layout: fixed;
  6691. }
  6692. * {
  6693. line-height: inherit;
  6694. }
  6695. a[x-apple-data-detectors=true] {
  6696. color: inherit !important;
  6697. text-decoration: none !important;
  6698. }
  6699. [owa] .img-container div,
  6700. [owa] .img-container button {
  6701. display: block !important;
  6702. }
  6703. [owa] .fullwidth button {
  6704. width: 100% !important;
  6705. }
  6706. [owa] .block-grid .col {
  6707. display: table-cell;
  6708. float: none !important;
  6709. vertical-align: top;
  6710. }
  6711. .ie-browser .num12,
  6712. .ie-browser .block-grid,
  6713. [owa] .num12,
  6714. [owa] .block-grid {
  6715. width: 615px !important;
  6716. }
  6717. .ExternalClass,
  6718. .ExternalClass p,
  6719. .ExternalClass span,
  6720. .ExternalClass font,
  6721. .ExternalClass td,
  6722. .ExternalClass div {
  6723. line-height: 100%;
  6724. }
  6725. .ie-browser .mixed-two-up .num4,
  6726. [owa] .mixed-two-up .num4 {
  6727. width: 204px !important;
  6728. }
  6729. .ie-browser .mixed-two-up .num8,
  6730. [owa] .mixed-two-up .num8 {
  6731. width: 408px !important;
  6732. }
  6733. .ie-browser .block-grid.two-up .col,
  6734. [owa] .block-grid.two-up .col {
  6735. width: 307px !important;
  6736. }
  6737. .ie-browser .block-grid.three-up .col,
  6738. [owa] .block-grid.three-up .col {
  6739. width: 205px !important;
  6740. }
  6741. .ie-browser .block-grid.four-up .col,
  6742. [owa] .block-grid.four-up .col {
  6743. width: 153px !important;
  6744. }
  6745. .ie-browser .block-grid.five-up .col,
  6746. [owa] .block-grid.five-up .col {
  6747. width: 123px !important;
  6748. }
  6749. .ie-browser .block-grid.six-up .col,
  6750. [owa] .block-grid.six-up .col {
  6751. width: 102px !important;
  6752. }
  6753. .ie-browser .block-grid.seven-up .col,
  6754. [owa] .block-grid.seven-up .col {
  6755. width: 87px !important;
  6756. }
  6757. .ie-browser .block-grid.eight-up .col,
  6758. [owa] .block-grid.eight-up .col {
  6759. width: 76px !important;
  6760. }
  6761. .ie-browser .block-grid.nine-up .col,
  6762. [owa] .block-grid.nine-up .col {
  6763. width: 68px !important;
  6764. }
  6765. .ie-browser .block-grid.ten-up .col,
  6766. [owa] .block-grid.ten-up .col {
  6767. width: 61px !important;
  6768. }
  6769. .ie-browser .block-grid.eleven-up .col,
  6770. [owa] .block-grid.eleven-up .col {
  6771. width: 55px !important;
  6772. }
  6773. .ie-browser .block-grid.twelve-up .col,
  6774. [owa] .block-grid.twelve-up .col {
  6775. width: 51px !important;
  6776. }
  6777. @media only screen and (min-width: 635px) {
  6778. .block-grid {
  6779. width: 615px !important;
  6780. }
  6781. .block-grid .col {
  6782. display: table-cell;
  6783. Float: none !important;
  6784. vertical-align: top;
  6785. }
  6786. .block-grid .col.num12 {
  6787. width: 615px !important;
  6788. }
  6789. .block-grid.mixed-two-up .col.num4 {
  6790. width: 204px !important;
  6791. }
  6792. .block-grid.mixed-two-up .col.num8 {
  6793. width: 408px !important;
  6794. }
  6795. .block-grid.two-up .col {
  6796. width: 307px !important;
  6797. }
  6798. .block-grid.three-up .col {
  6799. width: 205px !important;
  6800. }
  6801. .block-grid.four-up .col {
  6802. width: 153px !important;
  6803. }
  6804. .block-grid.five-up .col {
  6805. width: 123px !important;
  6806. }
  6807. .block-grid.six-up .col {
  6808. width: 102px !important;
  6809. }
  6810. .block-grid.seven-up .col {
  6811. width: 87px !important;
  6812. }
  6813. .block-grid.eight-up .col {
  6814. width: 76px !important;
  6815. }
  6816. .block-grid.nine-up .col {
  6817. width: 68px !important;
  6818. }
  6819. .block-grid.ten-up .col {
  6820. width: 61px !important;
  6821. }
  6822. .block-grid.eleven-up .col {
  6823. width: 55px !important;
  6824. }
  6825. .block-grid.twelve-up .col {
  6826. width: 51px !important;
  6827. }
  6828. }
  6829. @media (max-width: 635px) {
  6830. .block-grid,
  6831. .col {
  6832. min-width: 320px !important;
  6833. max-width: 100% !important;
  6834. }
  6835. .block-grid {
  6836. width: calc(100% - 40px) !important;
  6837. }
  6838. .col {
  6839. width: 100% !important;
  6840. }
  6841. .col>div {
  6842. margin: 0 auto;
  6843. }
  6844. img.fullwidth {
  6845. max-width: 100% !important;
  6846. }
  6847. }
  6848. </style>
  6849. </head>
  6850. <body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #FFFFFF">
  6851. <!--[if IE]><div class="ie-browser"><![endif]-->
  6852. <!--[if mso]><div class="mso-container"><![endif]-->
  6853. <div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: #FFFFFF">
  6854. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #FFFFFF;"><![endif]-->
  6855. <div style="background-color:#333333;">
  6856. <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;"
  6857. class="block-grid ">
  6858. <div style="border-collapse: collapse;display: table;width: 100%;">
  6859. <!--[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]-->
  6860. <!--[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]-->
  6861. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6862. <div style="background-color: transparent; width: 100% !important;">
  6863. <!--[if (!mso)&(!IE)]><!-->
  6864. <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;">
  6865. <!--<![endif]-->
  6866. <div align="left" class="img-container left fullwidth" style="padding-right: 30px; padding-left: 30px;">
  6867. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px;" align="left"><![endif]-->
  6868. <img class="left fullwidth" align="left" border="0" src="'.$path.'images/organizr-logo-h.png" alt="Image" title="Image"
  6869. 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"
  6870. width="555">
  6871. <!--[if mso]></td></tr></table><![endif]-->
  6872. </div>
  6873. <!--[if (!mso)&(!IE)]><!-->
  6874. </div>
  6875. <!--<![endif]-->
  6876. </div>
  6877. </div>
  6878. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6879. </div>
  6880. </div>
  6881. </div>
  6882. <div style="background-color:#333333;">
  6883. <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;"
  6884. class="block-grid ">
  6885. <div style="border-collapse: collapse;display: table;width: 100%;">
  6886. <!--[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]-->
  6887. <!--[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]-->
  6888. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6889. <div style="background-color: transparent; width: 100% !important;">
  6890. <!--[if (!mso)&(!IE)]><!-->
  6891. <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;">
  6892. <!--<![endif]-->
  6893. <!--[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]-->
  6894. <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;">
  6895. <div style="font-size:12px;line-height:14px;color:#FFFFFF;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6896. <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>
  6897. </span>
  6898. </p>
  6899. </div>
  6900. </div>
  6901. <!--[if mso]></td></tr></table><![endif]-->
  6902. <!--[if (!mso)&(!IE)]><!-->
  6903. </div>
  6904. <!--<![endif]-->
  6905. </div>
  6906. </div>
  6907. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6908. </div>
  6909. </div>
  6910. </div>
  6911. <div style="background-color:#393939;">
  6912. <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;"
  6913. class="block-grid ">
  6914. <div style="border-collapse: collapse;display: table;width: 100%;">
  6915. <!--[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]-->
  6916. <!--[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]-->
  6917. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6918. <div style="background-color: transparent; width: 100% !important;">
  6919. <!--[if (!mso)&(!IE)]><!-->
  6920. <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;">
  6921. <!--<![endif]-->
  6922. <!--[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]-->
  6923. <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;">
  6924. <div style="font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6925. <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>
  6926. </div>
  6927. </div>
  6928. <!--[if mso]></td></tr></table><![endif]-->
  6929. <div style="padding-right: 5px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px;">
  6930. <!--[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]-->
  6931. <div align="center">
  6932. <div style="border-top: 2px solid #66D9EF; width:55%; line-height:2px; height:2px; font-size:2px;">&#160;</div>
  6933. </div>
  6934. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6935. </div>
  6936. <!--[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]-->
  6937. <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;">
  6938. <div style="font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6939. <p style="margin: 0;font-size: 12px;line-height: 14px"><span style="font-size: 28px; line-height: 33px;">Hey '.$user.',</span></p>
  6940. </div>
  6941. </div>
  6942. <!--[if mso]></td></tr></table><![endif]-->
  6943. <!--[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]-->
  6944. <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;">
  6945. <div style="font-size:12px;line-height:22px;font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;color:#FFFFFF;text-align:left;">
  6946. <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>
  6947. </span>
  6948. </p>
  6949. </div>
  6950. </div>
  6951. <!--[if mso]></td></tr></table><![endif]-->
  6952. <div align="center" class="button-container center" style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;">
  6953. <!--[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]-->
  6954. <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">
  6955. <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>
  6956. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6957. </div>
  6958. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6959. </div>
  6960. <!--[if (!mso)&(!IE)]><!-->
  6961. </div>
  6962. <!--<![endif]-->
  6963. </div>
  6964. </div>
  6965. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6966. </div>
  6967. </div>
  6968. </div>
  6969. <div style="background-color:#ffffff;">
  6970. <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;"
  6971. class="block-grid ">
  6972. <div style="border-collapse: collapse;display: table;width: 100%;">
  6973. <!--[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]-->
  6974. <!--[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]-->
  6975. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6976. <div style="background-color: transparent; width: 100% !important;">
  6977. <!--[if (!mso)&(!IE)]><!-->
  6978. <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;">
  6979. <!--<![endif]-->
  6980. <!--[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]-->
  6981. <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;">
  6982. <div style="font-size:12px;line-height:14px;color:#555555;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6983. <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>
  6984. </div>
  6985. </div>
  6986. <!--[if mso]></td></tr></table><![endif]-->
  6987. <div style="padding-right: 20px; padding-left: 20px; padding-top: 15px; padding-bottom: 20px;">
  6988. <!--[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]-->
  6989. <div align="center">
  6990. <div style="border-top: 3px solid #66D9EF; width:40%; line-height:3px; height:3px; font-size:3px;">&#160;</div>
  6991. </div>
  6992. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6993. </div>
  6994. <!--[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]-->
  6995. <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;">
  6996. <div style="font-size:12px;line-height:22px;color:#7E7D7D;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6997. <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>
  6998. </div>
  6999. </div>
  7000. <!--[if mso]></td></tr></table><![endif]-->
  7001. <!--[if (!mso)&(!IE)]><!-->
  7002. </div>
  7003. <!--<![endif]-->
  7004. </div>
  7005. </div>
  7006. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  7007. </div>
  7008. </div>
  7009. </div>
  7010. <div style="background-color:#333333;">
  7011. <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;"
  7012. class="block-grid ">
  7013. <div style="border-collapse: collapse;display: table;width: 100%;">
  7014. <!--[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]-->
  7015. <!--[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]-->
  7016. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  7017. <div style="background-color: transparent; width: 100% !important;">
  7018. <!--[if (!mso)&(!IE)]><!-->
  7019. <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;">
  7020. <!--<![endif]-->
  7021. <!--[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]-->
  7022. <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;">
  7023. <div style="font-size:12px;line-height:14px;color:#959595;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  7024. <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"
  7025. href="https://github.com/causefx/Organizr" target="_blank" rel="noopener noreferrer">Organizr</a><strong><br></strong></p>
  7026. </div>
  7027. </div>
  7028. <!--[if mso]></td></tr></table><![endif]-->
  7029. <!--[if (!mso)&(!IE)]><!-->
  7030. </div>
  7031. <!--<![endif]-->
  7032. </div>
  7033. </div>
  7034. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  7035. </div>
  7036. </div>
  7037. </div>
  7038. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  7039. </div>
  7040. <!--[if (mso)|(IE)]></div><![endif]-->
  7041. </body>
  7042. </html>
  7043. ';
  7044. }
  7045. function mimeTypes(){
  7046. return array(
  7047. '123' => 'application/vnd.lotus-1-2-3',
  7048. '3dml' => 'text/vnd.in3d.3dml',
  7049. '3ds' => 'image/x-3ds',
  7050. '3g2' => 'video/3gpp2',
  7051. '3gp' => 'video/3gpp',
  7052. '7z' => 'application/x-7z-compressed',
  7053. 'aab' => 'application/x-authorware-bin',
  7054. 'aac' => 'audio/x-aac',
  7055. 'aam' => 'application/x-authorware-map',
  7056. 'aas' => 'application/x-authorware-seg',
  7057. 'abw' => 'application/x-abiword',
  7058. 'ac' => 'application/pkix-attr-cert',
  7059. 'acc' => 'application/vnd.americandynamics.acc',
  7060. 'ace' => 'application/x-ace-compressed',
  7061. 'acu' => 'application/vnd.acucobol',
  7062. 'acutc' => 'application/vnd.acucorp',
  7063. 'adp' => 'audio/adpcm',
  7064. 'aep' => 'application/vnd.audiograph',
  7065. 'afm' => 'application/x-font-type1',
  7066. 'afp' => 'application/vnd.ibm.modcap',
  7067. 'ahead' => 'application/vnd.ahead.space',
  7068. 'ai' => 'application/postscript',
  7069. 'aif' => 'audio/x-aiff',
  7070. 'aifc' => 'audio/x-aiff',
  7071. 'aiff' => 'audio/x-aiff',
  7072. 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
  7073. 'ait' => 'application/vnd.dvb.ait',
  7074. 'ami' => 'application/vnd.amiga.ami',
  7075. 'apk' => 'application/vnd.android.package-archive',
  7076. 'appcache' => 'text/cache-manifest',
  7077. 'application' => 'application/x-ms-application',
  7078. 'apr' => 'application/vnd.lotus-approach',
  7079. 'arc' => 'application/x-freearc',
  7080. 'asc' => 'application/pgp-signature',
  7081. 'asf' => 'video/x-ms-asf',
  7082. 'asm' => 'text/x-asm',
  7083. 'aso' => 'application/vnd.accpac.simply.aso',
  7084. 'asx' => 'video/x-ms-asf',
  7085. 'atc' => 'application/vnd.acucorp',
  7086. 'atom' => 'application/atom+xml',
  7087. 'atomcat' => 'application/atomcat+xml',
  7088. 'atomsvc' => 'application/atomsvc+xml',
  7089. 'atx' => 'application/vnd.antix.game-component',
  7090. 'au' => 'audio/basic',
  7091. 'avi' => 'video/x-msvideo',
  7092. 'aw' => 'application/applixware',
  7093. 'azf' => 'application/vnd.airzip.filesecure.azf',
  7094. 'azs' => 'application/vnd.airzip.filesecure.azs',
  7095. 'azw' => 'application/vnd.amazon.ebook',
  7096. 'bat' => 'application/x-msdownload',
  7097. 'bcpio' => 'application/x-bcpio',
  7098. 'bdf' => 'application/x-font-bdf',
  7099. 'bdm' => 'application/vnd.syncml.dm+wbxml',
  7100. 'bed' => 'application/vnd.realvnc.bed',
  7101. 'bh2' => 'application/vnd.fujitsu.oasysprs',
  7102. 'bin' => 'application/octet-stream',
  7103. 'blb' => 'application/x-blorb',
  7104. 'blorb' => 'application/x-blorb',
  7105. 'bmi' => 'application/vnd.bmi',
  7106. 'bmp' => 'image/bmp',
  7107. 'book' => 'application/vnd.framemaker',
  7108. 'box' => 'application/vnd.previewsystems.box',
  7109. 'boz' => 'application/x-bzip2',
  7110. 'bpk' => 'application/octet-stream',
  7111. 'btif' => 'image/prs.btif',
  7112. 'bz' => 'application/x-bzip',
  7113. 'bz2' => 'application/x-bzip2',
  7114. 'c' => 'text/x-c',
  7115. 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
  7116. 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
  7117. 'c4d' => 'application/vnd.clonk.c4group',
  7118. 'c4f' => 'application/vnd.clonk.c4group',
  7119. 'c4g' => 'application/vnd.clonk.c4group',
  7120. 'c4p' => 'application/vnd.clonk.c4group',
  7121. 'c4u' => 'application/vnd.clonk.c4group',
  7122. 'cab' => 'application/vnd.ms-cab-compressed',
  7123. 'caf' => 'audio/x-caf',
  7124. 'cap' => 'application/vnd.tcpdump.pcap',
  7125. 'car' => 'application/vnd.curl.car',
  7126. 'cat' => 'application/vnd.ms-pki.seccat',
  7127. 'cb7' => 'application/x-cbr',
  7128. 'cba' => 'application/x-cbr',
  7129. 'cbr' => 'application/x-cbr',
  7130. 'cbt' => 'application/x-cbr',
  7131. 'cbz' => 'application/x-cbr',
  7132. 'cc' => 'text/x-c',
  7133. 'cct' => 'application/x-director',
  7134. 'ccxml' => 'application/ccxml+xml',
  7135. 'cdbcmsg' => 'application/vnd.contact.cmsg',
  7136. 'cdf' => 'application/x-netcdf',
  7137. 'cdkey' => 'application/vnd.mediastation.cdkey',
  7138. 'cdmia' => 'application/cdmi-capability',
  7139. 'cdmic' => 'application/cdmi-container',
  7140. 'cdmid' => 'application/cdmi-domain',
  7141. 'cdmio' => 'application/cdmi-object',
  7142. 'cdmiq' => 'application/cdmi-queue',
  7143. 'cdx' => 'chemical/x-cdx',
  7144. 'cdxml' => 'application/vnd.chemdraw+xml',
  7145. 'cdy' => 'application/vnd.cinderella',
  7146. 'cer' => 'application/pkix-cert',
  7147. 'cfs' => 'application/x-cfs-compressed',
  7148. 'cgm' => 'image/cgm',
  7149. 'chat' => 'application/x-chat',
  7150. 'chm' => 'application/vnd.ms-htmlhelp',
  7151. 'chrt' => 'application/vnd.kde.kchart',
  7152. 'cif' => 'chemical/x-cif',
  7153. 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
  7154. 'cil' => 'application/vnd.ms-artgalry',
  7155. 'cla' => 'application/vnd.claymore',
  7156. 'class' => 'application/java-vm',
  7157. 'clkk' => 'application/vnd.crick.clicker.keyboard',
  7158. 'clkp' => 'application/vnd.crick.clicker.palette',
  7159. 'clkt' => 'application/vnd.crick.clicker.template',
  7160. 'clkw' => 'application/vnd.crick.clicker.wordbank',
  7161. 'clkx' => 'application/vnd.crick.clicker',
  7162. 'clp' => 'application/x-msclip',
  7163. 'cmc' => 'application/vnd.cosmocaller',
  7164. 'cmdf' => 'chemical/x-cmdf',
  7165. 'cml' => 'chemical/x-cml',
  7166. 'cmp' => 'application/vnd.yellowriver-custom-menu',
  7167. 'cmx' => 'image/x-cmx',
  7168. 'cod' => 'application/vnd.rim.cod',
  7169. 'com' => 'application/x-msdownload',
  7170. 'conf' => 'text/plain',
  7171. 'cpio' => 'application/x-cpio',
  7172. 'cpp' => 'text/x-c',
  7173. 'cpt' => 'application/mac-compactpro',
  7174. 'crd' => 'application/x-mscardfile',
  7175. 'crl' => 'application/pkix-crl',
  7176. 'crt' => 'application/x-x509-ca-cert',
  7177. 'cryptonote' => 'application/vnd.rig.cryptonote',
  7178. 'csh' => 'application/x-csh',
  7179. 'csml' => 'chemical/x-csml',
  7180. 'csp' => 'application/vnd.commonspace',
  7181. 'css' => 'text/css',
  7182. 'cst' => 'application/x-director',
  7183. 'csv' => 'text/csv',
  7184. 'cu' => 'application/cu-seeme',
  7185. 'curl' => 'text/vnd.curl',
  7186. 'cww' => 'application/prs.cww',
  7187. 'cxt' => 'application/x-director',
  7188. 'cxx' => 'text/x-c',
  7189. 'dae' => 'model/vnd.collada+xml',
  7190. 'daf' => 'application/vnd.mobius.daf',
  7191. 'dart' => 'application/vnd.dart',
  7192. 'dataless' => 'application/vnd.fdsn.seed',
  7193. 'davmount' => 'application/davmount+xml',
  7194. 'dbk' => 'application/docbook+xml',
  7195. 'dcr' => 'application/x-director',
  7196. 'dcurl' => 'text/vnd.curl.dcurl',
  7197. 'dd2' => 'application/vnd.oma.dd2+xml',
  7198. 'ddd' => 'application/vnd.fujixerox.ddd',
  7199. 'deb' => 'application/x-debian-package',
  7200. 'def' => 'text/plain',
  7201. 'deploy' => 'application/octet-stream',
  7202. 'der' => 'application/x-x509-ca-cert',
  7203. 'dfac' => 'application/vnd.dreamfactory',
  7204. 'dgc' => 'application/x-dgc-compressed',
  7205. 'dic' => 'text/x-c',
  7206. 'dir' => 'application/x-director',
  7207. 'dis' => 'application/vnd.mobius.dis',
  7208. 'dist' => 'application/octet-stream',
  7209. 'distz' => 'application/octet-stream',
  7210. 'djv' => 'image/vnd.djvu',
  7211. 'djvu' => 'image/vnd.djvu',
  7212. 'dll' => 'application/x-msdownload',
  7213. 'dmg' => 'application/x-apple-diskimage',
  7214. 'dmp' => 'application/vnd.tcpdump.pcap',
  7215. 'dms' => 'application/octet-stream',
  7216. 'dna' => 'application/vnd.dna',
  7217. 'doc' => 'application/msword',
  7218. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  7219. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  7220. 'dot' => 'application/msword',
  7221. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  7222. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  7223. 'dp' => 'application/vnd.osgi.dp',
  7224. 'dpg' => 'application/vnd.dpgraph',
  7225. 'dra' => 'audio/vnd.dra',
  7226. 'dsc' => 'text/prs.lines.tag',
  7227. 'dssc' => 'application/dssc+der',
  7228. 'dtb' => 'application/x-dtbook+xml',
  7229. 'dtd' => 'application/xml-dtd',
  7230. 'dts' => 'audio/vnd.dts',
  7231. 'dtshd' => 'audio/vnd.dts.hd',
  7232. 'dump' => 'application/octet-stream',
  7233. 'dvb' => 'video/vnd.dvb.file',
  7234. 'dvi' => 'application/x-dvi',
  7235. 'dwf' => 'model/vnd.dwf',
  7236. 'dwg' => 'image/vnd.dwg',
  7237. 'dxf' => 'image/vnd.dxf',
  7238. 'dxp' => 'application/vnd.spotfire.dxp',
  7239. 'dxr' => 'application/x-director',
  7240. 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
  7241. 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
  7242. 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
  7243. 'ecma' => 'application/ecmascript',
  7244. 'edm' => 'application/vnd.novadigm.edm',
  7245. 'edx' => 'application/vnd.novadigm.edx',
  7246. 'efif' => 'application/vnd.picsel',
  7247. 'ei6' => 'application/vnd.pg.osasli',
  7248. 'elc' => 'application/octet-stream',
  7249. 'emf' => 'application/x-msmetafile',
  7250. 'eml' => 'message/rfc822',
  7251. 'emma' => 'application/emma+xml',
  7252. 'emz' => 'application/x-msmetafile',
  7253. 'eol' => 'audio/vnd.digital-winds',
  7254. 'eot' => 'application/vnd.ms-fontobject',
  7255. 'eps' => 'application/postscript',
  7256. 'epub' => 'application/epub+zip',
  7257. 'es3' => 'application/vnd.eszigno3+xml',
  7258. 'esa' => 'application/vnd.osgi.subsystem',
  7259. 'esf' => 'application/vnd.epson.esf',
  7260. 'et3' => 'application/vnd.eszigno3+xml',
  7261. 'etx' => 'text/x-setext',
  7262. 'eva' => 'application/x-eva',
  7263. 'evy' => 'application/x-envoy',
  7264. 'exe' => 'application/x-msdownload',
  7265. 'exi' => 'application/exi',
  7266. 'ext' => 'application/vnd.novadigm.ext',
  7267. 'ez' => 'application/andrew-inset',
  7268. 'ez2' => 'application/vnd.ezpix-album',
  7269. 'ez3' => 'application/vnd.ezpix-package',
  7270. 'f' => 'text/x-fortran',
  7271. 'f4v' => 'video/x-f4v',
  7272. 'f77' => 'text/x-fortran',
  7273. 'f90' => 'text/x-fortran',
  7274. 'fbs' => 'image/vnd.fastbidsheet',
  7275. 'fcdt' => 'application/vnd.adobe.formscentral.fcdt',
  7276. 'fcs' => 'application/vnd.isac.fcs',
  7277. 'fdf' => 'application/vnd.fdf',
  7278. 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
  7279. 'fg5' => 'application/vnd.fujitsu.oasysgp',
  7280. 'fgd' => 'application/x-director',
  7281. 'fh' => 'image/x-freehand',
  7282. 'fh4' => 'image/x-freehand',
  7283. 'fh5' => 'image/x-freehand',
  7284. 'fh7' => 'image/x-freehand',
  7285. 'fhc' => 'image/x-freehand',
  7286. 'fig' => 'application/x-xfig',
  7287. 'flac' => 'audio/x-flac',
  7288. 'fli' => 'video/x-fli',
  7289. 'flo' => 'application/vnd.micrografx.flo',
  7290. 'flv' => 'video/x-flv',
  7291. 'flw' => 'application/vnd.kde.kivio',
  7292. 'flx' => 'text/vnd.fmi.flexstor',
  7293. 'fly' => 'text/vnd.fly',
  7294. 'fm' => 'application/vnd.framemaker',
  7295. 'fnc' => 'application/vnd.frogans.fnc',
  7296. 'for' => 'text/x-fortran',
  7297. 'fpx' => 'image/vnd.fpx',
  7298. 'frame' => 'application/vnd.framemaker',
  7299. 'fsc' => 'application/vnd.fsc.weblaunch',
  7300. 'fst' => 'image/vnd.fst',
  7301. 'ftc' => 'application/vnd.fluxtime.clip',
  7302. 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
  7303. 'fvt' => 'video/vnd.fvt',
  7304. 'fxp' => 'application/vnd.adobe.fxp',
  7305. 'fxpl' => 'application/vnd.adobe.fxp',
  7306. 'fzs' => 'application/vnd.fuzzysheet',
  7307. 'g2w' => 'application/vnd.geoplan',
  7308. 'g3' => 'image/g3fax',
  7309. 'g3w' => 'application/vnd.geospace',
  7310. 'gac' => 'application/vnd.groove-account',
  7311. 'gam' => 'application/x-tads',
  7312. 'gbr' => 'application/rpki-ghostbusters',
  7313. 'gca' => 'application/x-gca-compressed',
  7314. 'gdl' => 'model/vnd.gdl',
  7315. 'geo' => 'application/vnd.dynageo',
  7316. 'gex' => 'application/vnd.geometry-explorer',
  7317. 'ggb' => 'application/vnd.geogebra.file',
  7318. 'ggt' => 'application/vnd.geogebra.tool',
  7319. 'ghf' => 'application/vnd.groove-help',
  7320. 'gif' => 'image/gif',
  7321. 'gim' => 'application/vnd.groove-identity-message',
  7322. 'gml' => 'application/gml+xml',
  7323. 'gmx' => 'application/vnd.gmx',
  7324. 'gnumeric' => 'application/x-gnumeric',
  7325. 'gph' => 'application/vnd.flographit',
  7326. 'gpx' => 'application/gpx+xml',
  7327. 'gqf' => 'application/vnd.grafeq',
  7328. 'gqs' => 'application/vnd.grafeq',
  7329. 'gram' => 'application/srgs',
  7330. 'gramps' => 'application/x-gramps-xml',
  7331. 'gre' => 'application/vnd.geometry-explorer',
  7332. 'grv' => 'application/vnd.groove-injector',
  7333. 'grxml' => 'application/srgs+xml',
  7334. 'gsf' => 'application/x-font-ghostscript',
  7335. 'gtar' => 'application/x-gtar',
  7336. 'gtm' => 'application/vnd.groove-tool-message',
  7337. 'gtw' => 'model/vnd.gtw',
  7338. 'gv' => 'text/vnd.graphviz',
  7339. 'gxf' => 'application/gxf',
  7340. 'gxt' => 'application/vnd.geonext',
  7341. 'h' => 'text/x-c',
  7342. 'h261' => 'video/h261',
  7343. 'h263' => 'video/h263',
  7344. 'h264' => 'video/h264',
  7345. 'hal' => 'application/vnd.hal+xml',
  7346. 'hbci' => 'application/vnd.hbci',
  7347. 'hdf' => 'application/x-hdf',
  7348. 'hh' => 'text/x-c',
  7349. 'hlp' => 'application/winhlp',
  7350. 'hpgl' => 'application/vnd.hp-hpgl',
  7351. 'hpid' => 'application/vnd.hp-hpid',
  7352. 'hps' => 'application/vnd.hp-hps',
  7353. 'hqx' => 'application/mac-binhex40',
  7354. 'htke' => 'application/vnd.kenameaapp',
  7355. 'htm' => 'text/html',
  7356. 'html' => 'text/html',
  7357. 'hvd' => 'application/vnd.yamaha.hv-dic',
  7358. 'hvp' => 'application/vnd.yamaha.hv-voice',
  7359. 'hvs' => 'application/vnd.yamaha.hv-script',
  7360. 'i2g' => 'application/vnd.intergeo',
  7361. 'icc' => 'application/vnd.iccprofile',
  7362. 'ice' => 'x-conference/x-cooltalk',
  7363. 'icm' => 'application/vnd.iccprofile',
  7364. 'ico' => 'image/x-icon',
  7365. 'ics' => 'text/calendar',
  7366. 'ief' => 'image/ief',
  7367. 'ifb' => 'text/calendar',
  7368. 'ifm' => 'application/vnd.shana.informed.formdata',
  7369. 'iges' => 'model/iges',
  7370. 'igl' => 'application/vnd.igloader',
  7371. 'igm' => 'application/vnd.insors.igm',
  7372. 'igs' => 'model/iges',
  7373. 'igx' => 'application/vnd.micrografx.igx',
  7374. 'iif' => 'application/vnd.shana.informed.interchange',
  7375. 'imp' => 'application/vnd.accpac.simply.imp',
  7376. 'ims' => 'application/vnd.ms-ims',
  7377. 'in' => 'text/plain',
  7378. 'ink' => 'application/inkml+xml',
  7379. 'inkml' => 'application/inkml+xml',
  7380. 'install' => 'application/x-install-instructions',
  7381. 'iota' => 'application/vnd.astraea-software.iota',
  7382. 'ipfix' => 'application/ipfix',
  7383. 'ipk' => 'application/vnd.shana.informed.package',
  7384. 'irm' => 'application/vnd.ibm.rights-management',
  7385. 'irp' => 'application/vnd.irepository.package+xml',
  7386. 'iso' => 'application/x-iso9660-image',
  7387. 'itp' => 'application/vnd.shana.informed.formtemplate',
  7388. 'ivp' => 'application/vnd.immervision-ivp',
  7389. 'ivu' => 'application/vnd.immervision-ivu',
  7390. 'jad' => 'text/vnd.sun.j2me.app-descriptor',
  7391. 'jam' => 'application/vnd.jam',
  7392. 'jar' => 'application/java-archive',
  7393. 'java' => 'text/x-java-source',
  7394. 'jisp' => 'application/vnd.jisp',
  7395. 'jlt' => 'application/vnd.hp-jlyt',
  7396. 'jnlp' => 'application/x-java-jnlp-file',
  7397. 'joda' => 'application/vnd.joost.joda-archive',
  7398. 'jpe' => 'image/jpeg',
  7399. 'jpeg' => 'image/jpeg',
  7400. 'jpg' => 'image/jpeg',
  7401. 'jpgm' => 'video/jpm',
  7402. 'jpgv' => 'video/jpeg',
  7403. 'jpm' => 'video/jpm',
  7404. 'js' => 'application/javascript',
  7405. 'json' => 'application/json',
  7406. 'jsonml' => 'application/jsonml+json',
  7407. 'kar' => 'audio/midi',
  7408. 'karbon' => 'application/vnd.kde.karbon',
  7409. 'kfo' => 'application/vnd.kde.kformula',
  7410. 'kia' => 'application/vnd.kidspiration',
  7411. 'kml' => 'application/vnd.google-earth.kml+xml',
  7412. 'kmz' => 'application/vnd.google-earth.kmz',
  7413. 'kne' => 'application/vnd.kinar',
  7414. 'knp' => 'application/vnd.kinar',
  7415. 'kon' => 'application/vnd.kde.kontour',
  7416. 'kpr' => 'application/vnd.kde.kpresenter',
  7417. 'kpt' => 'application/vnd.kde.kpresenter',
  7418. 'kpxx' => 'application/vnd.ds-keypoint',
  7419. 'ksp' => 'application/vnd.kde.kspread',
  7420. 'ktr' => 'application/vnd.kahootz',
  7421. 'ktx' => 'image/ktx',
  7422. 'ktz' => 'application/vnd.kahootz',
  7423. 'kwd' => 'application/vnd.kde.kword',
  7424. 'kwt' => 'application/vnd.kde.kword',
  7425. 'lasxml' => 'application/vnd.las.las+xml',
  7426. 'latex' => 'application/x-latex',
  7427. 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  7428. 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  7429. 'les' => 'application/vnd.hhe.lesson-player',
  7430. 'lha' => 'application/x-lzh-compressed',
  7431. 'link66' => 'application/vnd.route66.link66+xml',
  7432. 'list' => 'text/plain',
  7433. 'list3820' => 'application/vnd.ibm.modcap',
  7434. 'listafp' => 'application/vnd.ibm.modcap',
  7435. 'lnk' => 'application/x-ms-shortcut',
  7436. 'log' => 'text/plain',
  7437. 'lostxml' => 'application/lost+xml',
  7438. 'lrf' => 'application/octet-stream',
  7439. 'lrm' => 'application/vnd.ms-lrm',
  7440. 'ltf' => 'application/vnd.frogans.ltf',
  7441. 'lvp' => 'audio/vnd.lucent.voice',
  7442. 'lwp' => 'application/vnd.lotus-wordpro',
  7443. 'lzh' => 'application/x-lzh-compressed',
  7444. 'm13' => 'application/x-msmediaview',
  7445. 'm14' => 'application/x-msmediaview',
  7446. 'm1v' => 'video/mpeg',
  7447. 'm21' => 'application/mp21',
  7448. 'm2a' => 'audio/mpeg',
  7449. 'm2v' => 'video/mpeg',
  7450. 'm3a' => 'audio/mpeg',
  7451. 'm3u' => 'audio/x-mpegurl',
  7452. 'm3u8' => 'application/vnd.apple.mpegurl',
  7453. 'm4a' => 'audio/mp4',
  7454. 'm4u' => 'video/vnd.mpegurl',
  7455. 'm4v' => 'video/x-m4v',
  7456. 'ma' => 'application/mathematica',
  7457. 'mads' => 'application/mads+xml',
  7458. 'mag' => 'application/vnd.ecowin.chart',
  7459. 'maker' => 'application/vnd.framemaker',
  7460. 'man' => 'text/troff',
  7461. 'mar' => 'application/octet-stream',
  7462. 'mathml' => 'application/mathml+xml',
  7463. 'mb' => 'application/mathematica',
  7464. 'mbk' => 'application/vnd.mobius.mbk',
  7465. 'mbox' => 'application/mbox',
  7466. 'mc1' => 'application/vnd.medcalcdata',
  7467. 'mcd' => 'application/vnd.mcd',
  7468. 'mcurl' => 'text/vnd.curl.mcurl',
  7469. 'mdb' => 'application/x-msaccess',
  7470. 'mdi' => 'image/vnd.ms-modi',
  7471. 'me' => 'text/troff',
  7472. 'mesh' => 'model/mesh',
  7473. 'meta4' => 'application/metalink4+xml',
  7474. 'metalink' => 'application/metalink+xml',
  7475. 'mets' => 'application/mets+xml',
  7476. 'mfm' => 'application/vnd.mfmp',
  7477. 'mft' => 'application/rpki-manifest',
  7478. 'mgp' => 'application/vnd.osgeo.mapguide.package',
  7479. 'mgz' => 'application/vnd.proteus.magazine',
  7480. 'mid' => 'audio/midi',
  7481. 'midi' => 'audio/midi',
  7482. 'mie' => 'application/x-mie',
  7483. 'mif' => 'application/vnd.mif',
  7484. 'mime' => 'message/rfc822',
  7485. 'mj2' => 'video/mj2',
  7486. 'mjp2' => 'video/mj2',
  7487. 'mk3d' => 'video/x-matroska',
  7488. 'mka' => 'audio/x-matroska',
  7489. 'mks' => 'video/x-matroska',
  7490. 'mkv' => 'video/x-matroska',
  7491. 'mlp' => 'application/vnd.dolby.mlp',
  7492. 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
  7493. 'mmf' => 'application/vnd.smaf',
  7494. 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
  7495. 'mng' => 'video/x-mng',
  7496. 'mny' => 'application/x-msmoney',
  7497. 'mobi' => 'application/x-mobipocket-ebook',
  7498. 'mods' => 'application/mods+xml',
  7499. 'mov' => 'video/quicktime',
  7500. 'movie' => 'video/x-sgi-movie',
  7501. 'mp2' => 'audio/mpeg',
  7502. 'mp21' => 'application/mp21',
  7503. 'mp2a' => 'audio/mpeg',
  7504. 'mp3' => 'audio/mpeg',
  7505. 'mp4' => 'video/mp4',
  7506. 'mp4a' => 'audio/mp4',
  7507. 'mp4s' => 'application/mp4',
  7508. 'mp4v' => 'video/mp4',
  7509. 'mpc' => 'application/vnd.mophun.certificate',
  7510. 'mpe' => 'video/mpeg',
  7511. 'mpeg' => 'video/mpeg',
  7512. 'mpg' => 'video/mpeg',
  7513. 'mpg4' => 'video/mp4',
  7514. 'mpga' => 'audio/mpeg',
  7515. 'mpkg' => 'application/vnd.apple.installer+xml',
  7516. 'mpm' => 'application/vnd.blueice.multipass',
  7517. 'mpn' => 'application/vnd.mophun.application',
  7518. 'mpp' => 'application/vnd.ms-project',
  7519. 'mpt' => 'application/vnd.ms-project',
  7520. 'mpy' => 'application/vnd.ibm.minipay',
  7521. 'mqy' => 'application/vnd.mobius.mqy',
  7522. 'mrc' => 'application/marc',
  7523. 'mrcx' => 'application/marcxml+xml',
  7524. 'ms' => 'text/troff',
  7525. 'mscml' => 'application/mediaservercontrol+xml',
  7526. 'mseed' => 'application/vnd.fdsn.mseed',
  7527. 'mseq' => 'application/vnd.mseq',
  7528. 'msf' => 'application/vnd.epson.msf',
  7529. 'msh' => 'model/mesh',
  7530. 'msi' => 'application/x-msdownload',
  7531. 'msl' => 'application/vnd.mobius.msl',
  7532. 'msty' => 'application/vnd.muvee.style',
  7533. 'mts' => 'model/vnd.mts',
  7534. 'mus' => 'application/vnd.musician',
  7535. 'musicxml' => 'application/vnd.recordare.musicxml+xml',
  7536. 'mvb' => 'application/x-msmediaview',
  7537. 'mwf' => 'application/vnd.mfer',
  7538. 'mxf' => 'application/mxf',
  7539. 'mxl' => 'application/vnd.recordare.musicxml',
  7540. 'mxml' => 'application/xv+xml',
  7541. 'mxs' => 'application/vnd.triscape.mxs',
  7542. 'mxu' => 'video/vnd.mpegurl',
  7543. 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  7544. 'n3' => 'text/n3',
  7545. 'nb' => 'application/mathematica',
  7546. 'nbp' => 'application/vnd.wolfram.player',
  7547. 'nc' => 'application/x-netcdf',
  7548. 'ncx' => 'application/x-dtbncx+xml',
  7549. 'nfo' => 'text/x-nfo',
  7550. 'ngdat' => 'application/vnd.nokia.n-gage.data',
  7551. 'nitf' => 'application/vnd.nitf',
  7552. 'nlu' => 'application/vnd.neurolanguage.nlu',
  7553. 'nml' => 'application/vnd.enliven',
  7554. 'nnd' => 'application/vnd.noblenet-directory',
  7555. 'nns' => 'application/vnd.noblenet-sealer',
  7556. 'nnw' => 'application/vnd.noblenet-web',
  7557. 'npx' => 'image/vnd.net-fpx',
  7558. 'nsc' => 'application/x-conference',
  7559. 'nsf' => 'application/vnd.lotus-notes',
  7560. 'ntf' => 'application/vnd.nitf',
  7561. 'nzb' => 'application/x-nzb',
  7562. 'oa2' => 'application/vnd.fujitsu.oasys2',
  7563. 'oa3' => 'application/vnd.fujitsu.oasys3',
  7564. 'oas' => 'application/vnd.fujitsu.oasys',
  7565. 'obd' => 'application/x-msbinder',
  7566. 'obj' => 'application/x-tgif',
  7567. 'oda' => 'application/oda',
  7568. 'odb' => 'application/vnd.oasis.opendocument.database',
  7569. 'odc' => 'application/vnd.oasis.opendocument.chart',
  7570. 'odf' => 'application/vnd.oasis.opendocument.formula',
  7571. 'odft' => 'application/vnd.oasis.opendocument.formula-template',
  7572. 'odg' => 'application/vnd.oasis.opendocument.graphics',
  7573. 'odi' => 'application/vnd.oasis.opendocument.image',
  7574. 'odm' => 'application/vnd.oasis.opendocument.text-master',
  7575. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  7576. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  7577. 'odt' => 'application/vnd.oasis.opendocument.text',
  7578. 'oga' => 'audio/ogg',
  7579. 'ogg' => 'audio/ogg',
  7580. 'ogv' => 'video/ogg',
  7581. 'ogx' => 'application/ogg',
  7582. 'omdoc' => 'application/omdoc+xml',
  7583. 'onepkg' => 'application/onenote',
  7584. 'onetmp' => 'application/onenote',
  7585. 'onetoc' => 'application/onenote',
  7586. 'onetoc2' => 'application/onenote',
  7587. 'opf' => 'application/oebps-package+xml',
  7588. 'opml' => 'text/x-opml',
  7589. 'oprc' => 'application/vnd.palm',
  7590. 'org' => 'application/vnd.lotus-organizer',
  7591. 'osf' => 'application/vnd.yamaha.openscoreformat',
  7592. 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  7593. 'otc' => 'application/vnd.oasis.opendocument.chart-template',
  7594. 'otf' => 'application/x-font-otf',
  7595. 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
  7596. 'oth' => 'application/vnd.oasis.opendocument.text-web',
  7597. 'oti' => 'application/vnd.oasis.opendocument.image-template',
  7598. 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
  7599. 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  7600. 'ott' => 'application/vnd.oasis.opendocument.text-template',
  7601. 'oxps' => 'application/oxps',
  7602. 'oxt' => 'application/vnd.openofficeorg.extension',
  7603. 'p' => 'text/x-pascal',
  7604. 'p10' => 'application/pkcs10',
  7605. 'p12' => 'application/x-pkcs12',
  7606. 'p7b' => 'application/x-pkcs7-certificates',
  7607. 'p7c' => 'application/pkcs7-mime',
  7608. 'p7m' => 'application/pkcs7-mime',
  7609. 'p7r' => 'application/x-pkcs7-certreqresp',
  7610. 'p7s' => 'application/pkcs7-signature',
  7611. 'p8' => 'application/pkcs8',
  7612. 'pas' => 'text/x-pascal',
  7613. 'paw' => 'application/vnd.pawaafile',
  7614. 'pbd' => 'application/vnd.powerbuilder6',
  7615. 'pbm' => 'image/x-portable-bitmap',
  7616. 'pcap' => 'application/vnd.tcpdump.pcap',
  7617. 'pcf' => 'application/x-font-pcf',
  7618. 'pcl' => 'application/vnd.hp-pcl',
  7619. 'pclxl' => 'application/vnd.hp-pclxl',
  7620. 'pct' => 'image/x-pict',
  7621. 'pcurl' => 'application/vnd.curl.pcurl',
  7622. 'pcx' => 'image/x-pcx',
  7623. 'pdb' => 'application/vnd.palm',
  7624. 'pdf' => 'application/pdf',
  7625. 'pfa' => 'application/x-font-type1',
  7626. 'pfb' => 'application/x-font-type1',
  7627. 'pfm' => 'application/x-font-type1',
  7628. 'pfr' => 'application/font-tdpfr',
  7629. 'pfx' => 'application/x-pkcs12',
  7630. 'pgm' => 'image/x-portable-graymap',
  7631. 'pgn' => 'application/x-chess-pgn',
  7632. 'pgp' => 'application/pgp-encrypted',
  7633. 'pic' => 'image/x-pict',
  7634. 'pkg' => 'application/octet-stream',
  7635. 'pki' => 'application/pkixcmp',
  7636. 'pkipath' => 'application/pkix-pkipath',
  7637. 'plb' => 'application/vnd.3gpp.pic-bw-large',
  7638. 'plc' => 'application/vnd.mobius.plc',
  7639. 'plf' => 'application/vnd.pocketlearn',
  7640. 'pls' => 'application/pls+xml',
  7641. 'pml' => 'application/vnd.ctc-posml',
  7642. 'png' => 'image/png',
  7643. 'pnm' => 'image/x-portable-anymap',
  7644. 'portpkg' => 'application/vnd.macports.portpkg',
  7645. 'pot' => 'application/vnd.ms-powerpoint',
  7646. 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
  7647. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  7648. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  7649. 'ppd' => 'application/vnd.cups-ppd',
  7650. 'ppm' => 'image/x-portable-pixmap',
  7651. 'pps' => 'application/vnd.ms-powerpoint',
  7652. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  7653. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  7654. 'ppt' => 'application/vnd.ms-powerpoint',
  7655. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  7656. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  7657. 'pqa' => 'application/vnd.palm',
  7658. 'prc' => 'application/x-mobipocket-ebook',
  7659. 'pre' => 'application/vnd.lotus-freelance',
  7660. 'prf' => 'application/pics-rules',
  7661. 'ps' => 'application/postscript',
  7662. 'psb' => 'application/vnd.3gpp.pic-bw-small',
  7663. 'psd' => 'image/vnd.adobe.photoshop',
  7664. 'psf' => 'application/x-font-linux-psf',
  7665. 'pskcxml' => 'application/pskc+xml',
  7666. 'ptid' => 'application/vnd.pvi.ptid1',
  7667. 'pub' => 'application/x-mspublisher',
  7668. 'pvb' => 'application/vnd.3gpp.pic-bw-var',
  7669. 'pwn' => 'application/vnd.3m.post-it-notes',
  7670. 'pya' => 'audio/vnd.ms-playready.media.pya',
  7671. 'pyv' => 'video/vnd.ms-playready.media.pyv',
  7672. 'qam' => 'application/vnd.epson.quickanime',
  7673. 'qbo' => 'application/vnd.intu.qbo',
  7674. 'qfx' => 'application/vnd.intu.qfx',
  7675. 'qps' => 'application/vnd.publishare-delta-tree',
  7676. 'qt' => 'video/quicktime',
  7677. 'qwd' => 'application/vnd.quark.quarkxpress',
  7678. 'qwt' => 'application/vnd.quark.quarkxpress',
  7679. 'qxb' => 'application/vnd.quark.quarkxpress',
  7680. 'qxd' => 'application/vnd.quark.quarkxpress',
  7681. 'qxl' => 'application/vnd.quark.quarkxpress',
  7682. 'qxt' => 'application/vnd.quark.quarkxpress',
  7683. 'ra' => 'audio/x-pn-realaudio',
  7684. 'ram' => 'audio/x-pn-realaudio',
  7685. 'rar' => 'application/x-rar-compressed',
  7686. 'ras' => 'image/x-cmu-raster',
  7687. 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
  7688. 'rdf' => 'application/rdf+xml',
  7689. 'rdz' => 'application/vnd.data-vision.rdz',
  7690. 'rep' => 'application/vnd.businessobjects',
  7691. 'res' => 'application/x-dtbresource+xml',
  7692. 'rgb' => 'image/x-rgb',
  7693. 'rif' => 'application/reginfo+xml',
  7694. 'rip' => 'audio/vnd.rip',
  7695. 'ris' => 'application/x-research-info-systems',
  7696. 'rl' => 'application/resource-lists+xml',
  7697. 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
  7698. 'rld' => 'application/resource-lists-diff+xml',
  7699. 'rm' => 'application/vnd.rn-realmedia',
  7700. 'rmi' => 'audio/midi',
  7701. 'rmp' => 'audio/x-pn-realaudio-plugin',
  7702. 'rms' => 'application/vnd.jcp.javame.midlet-rms',
  7703. 'rmvb' => 'application/vnd.rn-realmedia-vbr',
  7704. 'rnc' => 'application/relax-ng-compact-syntax',
  7705. 'roa' => 'application/rpki-roa',
  7706. 'roff' => 'text/troff',
  7707. 'rp9' => 'application/vnd.cloanto.rp9',
  7708. 'rpss' => 'application/vnd.nokia.radio-presets',
  7709. 'rpst' => 'application/vnd.nokia.radio-preset',
  7710. 'rq' => 'application/sparql-query',
  7711. 'rs' => 'application/rls-services+xml',
  7712. 'rsd' => 'application/rsd+xml',
  7713. 'rss' => 'application/rss+xml',
  7714. 'rtf' => 'application/rtf',
  7715. 'rtx' => 'text/richtext',
  7716. 's' => 'text/x-asm',
  7717. 's3m' => 'audio/s3m',
  7718. 'saf' => 'application/vnd.yamaha.smaf-audio',
  7719. 'sbml' => 'application/sbml+xml',
  7720. 'sc' => 'application/vnd.ibm.secure-container',
  7721. 'scd' => 'application/x-msschedule',
  7722. 'scm' => 'application/vnd.lotus-screencam',
  7723. 'scq' => 'application/scvp-cv-request',
  7724. 'scs' => 'application/scvp-cv-response',
  7725. 'scurl' => 'text/vnd.curl.scurl',
  7726. 'sda' => 'application/vnd.stardivision.draw',
  7727. 'sdc' => 'application/vnd.stardivision.calc',
  7728. 'sdd' => 'application/vnd.stardivision.impress',
  7729. 'sdkd' => 'application/vnd.solent.sdkm+xml',
  7730. 'sdkm' => 'application/vnd.solent.sdkm+xml',
  7731. 'sdp' => 'application/sdp',
  7732. 'sdw' => 'application/vnd.stardivision.writer',
  7733. 'see' => 'application/vnd.seemail',
  7734. 'seed' => 'application/vnd.fdsn.seed',
  7735. 'sema' => 'application/vnd.sema',
  7736. 'semd' => 'application/vnd.semd',
  7737. 'semf' => 'application/vnd.semf',
  7738. 'ser' => 'application/java-serialized-object',
  7739. 'setpay' => 'application/set-payment-initiation',
  7740. 'setreg' => 'application/set-registration-initiation',
  7741. 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
  7742. 'sfs' => 'application/vnd.spotfire.sfs',
  7743. 'sfv' => 'text/x-sfv',
  7744. 'sgi' => 'image/sgi',
  7745. 'sgl' => 'application/vnd.stardivision.writer-global',
  7746. 'sgm' => 'text/sgml',
  7747. 'sgml' => 'text/sgml',
  7748. 'sh' => 'application/x-sh',
  7749. 'shar' => 'application/x-shar',
  7750. 'shf' => 'application/shf+xml',
  7751. 'sid' => 'image/x-mrsid-image',
  7752. 'sig' => 'application/pgp-signature',
  7753. 'sil' => 'audio/silk',
  7754. 'silo' => 'model/mesh',
  7755. 'sis' => 'application/vnd.symbian.install',
  7756. 'sisx' => 'application/vnd.symbian.install',
  7757. 'sit' => 'application/x-stuffit',
  7758. 'sitx' => 'application/x-stuffitx',
  7759. 'skd' => 'application/vnd.koan',
  7760. 'skm' => 'application/vnd.koan',
  7761. 'skp' => 'application/vnd.koan',
  7762. 'skt' => 'application/vnd.koan',
  7763. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  7764. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  7765. 'slt' => 'application/vnd.epson.salt',
  7766. 'sm' => 'application/vnd.stepmania.stepchart',
  7767. 'smf' => 'application/vnd.stardivision.math',
  7768. 'smi' => 'application/smil+xml',
  7769. 'smil' => 'application/smil+xml',
  7770. 'smv' => 'video/x-smv',
  7771. 'smzip' => 'application/vnd.stepmania.package',
  7772. 'snd' => 'audio/basic',
  7773. 'snf' => 'application/x-font-snf',
  7774. 'so' => 'application/octet-stream',
  7775. 'spc' => 'application/x-pkcs7-certificates',
  7776. 'spf' => 'application/vnd.yamaha.smaf-phrase',
  7777. 'spl' => 'application/x-futuresplash',
  7778. 'spot' => 'text/vnd.in3d.spot',
  7779. 'spp' => 'application/scvp-vp-response',
  7780. 'spq' => 'application/scvp-vp-request',
  7781. 'spx' => 'audio/ogg',
  7782. 'sql' => 'application/x-sql',
  7783. 'src' => 'application/x-wais-source',
  7784. 'srt' => 'application/x-subrip',
  7785. 'sru' => 'application/sru+xml',
  7786. 'srx' => 'application/sparql-results+xml',
  7787. 'ssdl' => 'application/ssdl+xml',
  7788. 'sse' => 'application/vnd.kodak-descriptor',
  7789. 'ssf' => 'application/vnd.epson.ssf',
  7790. 'ssml' => 'application/ssml+xml',
  7791. 'st' => 'application/vnd.sailingtracker.track',
  7792. 'stc' => 'application/vnd.sun.xml.calc.template',
  7793. 'std' => 'application/vnd.sun.xml.draw.template',
  7794. 'stf' => 'application/vnd.wt.stf',
  7795. 'sti' => 'application/vnd.sun.xml.impress.template',
  7796. 'stk' => 'application/hyperstudio',
  7797. 'stl' => 'application/vnd.ms-pki.stl',
  7798. 'str' => 'application/vnd.pg.format',
  7799. 'stw' => 'application/vnd.sun.xml.writer.template',
  7800. 'sub' => 'image/vnd.dvb.subtitle',
  7801. 'sub' => 'text/vnd.dvb.subtitle',
  7802. 'sus' => 'application/vnd.sus-calendar',
  7803. 'susp' => 'application/vnd.sus-calendar',
  7804. 'sv4cpio' => 'application/x-sv4cpio',
  7805. 'sv4crc' => 'application/x-sv4crc',
  7806. 'svc' => 'application/vnd.dvb.service',
  7807. 'svd' => 'application/vnd.svd',
  7808. 'svg' => 'image/svg+xml',
  7809. 'svgz' => 'image/svg+xml',
  7810. 'swa' => 'application/x-director',
  7811. 'swf' => 'application/x-shockwave-flash',
  7812. 'swi' => 'application/vnd.aristanetworks.swi',
  7813. 'sxc' => 'application/vnd.sun.xml.calc',
  7814. 'sxd' => 'application/vnd.sun.xml.draw',
  7815. 'sxg' => 'application/vnd.sun.xml.writer.global',
  7816. 'sxi' => 'application/vnd.sun.xml.impress',
  7817. 'sxm' => 'application/vnd.sun.xml.math',
  7818. 'sxw' => 'application/vnd.sun.xml.writer',
  7819. 't' => 'text/troff',
  7820. 't3' => 'application/x-t3vm-image',
  7821. 'taglet' => 'application/vnd.mynfc',
  7822. 'tao' => 'application/vnd.tao.intent-module-archive',
  7823. 'tar' => 'application/x-tar',
  7824. 'tcap' => 'application/vnd.3gpp2.tcap',
  7825. 'tcl' => 'application/x-tcl',
  7826. 'teacher' => 'application/vnd.smart.teacher',
  7827. 'tei' => 'application/tei+xml',
  7828. 'teicorpus' => 'application/tei+xml',
  7829. 'tex' => 'application/x-tex',
  7830. 'texi' => 'application/x-texinfo',
  7831. 'texinfo' => 'application/x-texinfo',
  7832. 'text' => 'text/plain',
  7833. 'tfi' => 'application/thraud+xml',
  7834. 'tfm' => 'application/x-tex-tfm',
  7835. 'tga' => 'image/x-tga',
  7836. 'thmx' => 'application/vnd.ms-officetheme',
  7837. 'tif' => 'image/tiff',
  7838. 'tiff' => 'image/tiff',
  7839. 'tmo' => 'application/vnd.tmobile-livetv',
  7840. 'torrent' => 'application/x-bittorrent',
  7841. 'tpl' => 'application/vnd.groove-tool-template',
  7842. 'tpt' => 'application/vnd.trid.tpt',
  7843. 'tr' => 'text/troff',
  7844. 'tra' => 'application/vnd.trueapp',
  7845. 'trm' => 'application/x-msterminal',
  7846. 'tsd' => 'application/timestamped-data',
  7847. 'tsv' => 'text/tab-separated-values',
  7848. 'ttc' => 'application/x-font-ttf',
  7849. 'ttf' => 'application/x-font-ttf',
  7850. 'ttl' => 'text/turtle',
  7851. 'twd' => 'application/vnd.simtech-mindmapper',
  7852. 'twds' => 'application/vnd.simtech-mindmapper',
  7853. 'txd' => 'application/vnd.genomatix.tuxedo',
  7854. 'txf' => 'application/vnd.mobius.txf',
  7855. 'txt' => 'text/plain',
  7856. 'u32' => 'application/x-authorware-bin',
  7857. 'udeb' => 'application/x-debian-package',
  7858. 'ufd' => 'application/vnd.ufdl',
  7859. 'ufdl' => 'application/vnd.ufdl',
  7860. 'ulx' => 'application/x-glulx',
  7861. 'umj' => 'application/vnd.umajin',
  7862. 'unityweb' => 'application/vnd.unity',
  7863. 'uoml' => 'application/vnd.uoml+xml',
  7864. 'uri' => 'text/uri-list',
  7865. 'uris' => 'text/uri-list',
  7866. 'urls' => 'text/uri-list',
  7867. 'ustar' => 'application/x-ustar',
  7868. 'utz' => 'application/vnd.uiq.theme',
  7869. 'uu' => 'text/x-uuencode',
  7870. 'uva' => 'audio/vnd.dece.audio',
  7871. 'uvd' => 'application/vnd.dece.data',
  7872. 'uvf' => 'application/vnd.dece.data',
  7873. 'uvg' => 'image/vnd.dece.graphic',
  7874. 'uvh' => 'video/vnd.dece.hd',
  7875. 'uvi' => 'image/vnd.dece.graphic',
  7876. 'uvm' => 'video/vnd.dece.mobile',
  7877. 'uvp' => 'video/vnd.dece.pd',
  7878. 'uvs' => 'video/vnd.dece.sd',
  7879. 'uvt' => 'application/vnd.dece.ttml+xml',
  7880. 'uvu' => 'video/vnd.uvvu.mp4',
  7881. 'uvv' => 'video/vnd.dece.video',
  7882. 'uvva' => 'audio/vnd.dece.audio',
  7883. 'uvvd' => 'application/vnd.dece.data',
  7884. 'uvvf' => 'application/vnd.dece.data',
  7885. 'uvvg' => 'image/vnd.dece.graphic',
  7886. 'uvvh' => 'video/vnd.dece.hd',
  7887. 'uvvi' => 'image/vnd.dece.graphic',
  7888. 'uvvm' => 'video/vnd.dece.mobile',
  7889. 'uvvp' => 'video/vnd.dece.pd',
  7890. 'uvvs' => 'video/vnd.dece.sd',
  7891. 'uvvt' => 'application/vnd.dece.ttml+xml',
  7892. 'uvvu' => 'video/vnd.uvvu.mp4',
  7893. 'uvvv' => 'video/vnd.dece.video',
  7894. 'uvvx' => 'application/vnd.dece.unspecified',
  7895. 'uvvz' => 'application/vnd.dece.zip',
  7896. 'uvx' => 'application/vnd.dece.unspecified',
  7897. 'uvz' => 'application/vnd.dece.zip',
  7898. 'vcard' => 'text/vcard',
  7899. 'vcd' => 'application/x-cdlink',
  7900. 'vcf' => 'text/x-vcard',
  7901. 'vcg' => 'application/vnd.groove-vcard',
  7902. 'vcs' => 'text/x-vcalendar',
  7903. 'vcx' => 'application/vnd.vcx',
  7904. 'vis' => 'application/vnd.visionary',
  7905. 'viv' => 'video/vnd.vivo',
  7906. 'vob' => 'video/x-ms-vob',
  7907. 'vor' => 'application/vnd.stardivision.writer',
  7908. 'vox' => 'application/x-authorware-bin',
  7909. 'vrml' => 'model/vrml',
  7910. 'vsd' => 'application/vnd.visio',
  7911. 'vsf' => 'application/vnd.vsf',
  7912. 'vss' => 'application/vnd.visio',
  7913. 'vst' => 'application/vnd.visio',
  7914. 'vsw' => 'application/vnd.visio',
  7915. 'vtu' => 'model/vnd.vtu',
  7916. 'vxml' => 'application/voicexml+xml',
  7917. 'w3d' => 'application/x-director',
  7918. 'wad' => 'application/x-doom',
  7919. 'wav' => 'audio/x-wav',
  7920. 'wax' => 'audio/x-ms-wax',
  7921. 'wbmp' => 'image/vnd.wap.wbmp',
  7922. 'wbs' => 'application/vnd.criticaltools.wbs+xml',
  7923. 'wbxml' => 'application/vnd.wap.wbxml',
  7924. 'wcm' => 'application/vnd.ms-works',
  7925. 'wdb' => 'application/vnd.ms-works',
  7926. 'wdp' => 'image/vnd.ms-photo',
  7927. 'weba' => 'audio/webm',
  7928. 'webm' => 'video/webm',
  7929. 'webp' => 'image/webp',
  7930. 'wg' => 'application/vnd.pmi.widget',
  7931. 'wgt' => 'application/widget',
  7932. 'wks' => 'application/vnd.ms-works',
  7933. 'wm' => 'video/x-ms-wm',
  7934. 'wma' => 'audio/x-ms-wma',
  7935. 'wmd' => 'application/x-ms-wmd',
  7936. 'wmf' => 'application/x-msmetafile',
  7937. 'wml' => 'text/vnd.wap.wml',
  7938. 'wmlc' => 'application/vnd.wap.wmlc',
  7939. 'wmls' => 'text/vnd.wap.wmlscript',
  7940. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  7941. 'wmv' => 'video/x-ms-wmv',
  7942. 'wmx' => 'video/x-ms-wmx',
  7943. 'wmz' => 'application/x-ms-wmz',
  7944. 'wmz' => 'application/x-msmetafile',
  7945. 'woff' => 'application/font-woff',
  7946. 'wpd' => 'application/vnd.wordperfect',
  7947. 'wpl' => 'application/vnd.ms-wpl',
  7948. 'wps' => 'application/vnd.ms-works',
  7949. 'wqd' => 'application/vnd.wqd',
  7950. 'wri' => 'application/x-mswrite',
  7951. 'wrl' => 'model/vrml',
  7952. 'wsdl' => 'application/wsdl+xml',
  7953. 'wspolicy' => 'application/wspolicy+xml',
  7954. 'wtb' => 'application/vnd.webturbo',
  7955. 'wvx' => 'video/x-ms-wvx',
  7956. 'x32' => 'application/x-authorware-bin',
  7957. 'x3d' => 'model/x3d+xml',
  7958. 'x3db' => 'model/x3d+binary',
  7959. 'x3dbz' => 'model/x3d+binary',
  7960. 'x3dv' => 'model/x3d+vrml',
  7961. 'x3dvz' => 'model/x3d+vrml',
  7962. 'x3dz' => 'model/x3d+xml',
  7963. 'xaml' => 'application/xaml+xml',
  7964. 'xap' => 'application/x-silverlight-app',
  7965. 'xar' => 'application/vnd.xara',
  7966. 'xbap' => 'application/x-ms-xbap',
  7967. 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
  7968. 'xbm' => 'image/x-xbitmap',
  7969. 'xdf' => 'application/xcap-diff+xml',
  7970. 'xdm' => 'application/vnd.syncml.dm+xml',
  7971. 'xdp' => 'application/vnd.adobe.xdp+xml',
  7972. 'xdssc' => 'application/dssc+xml',
  7973. 'xdw' => 'application/vnd.fujixerox.docuworks',
  7974. 'xenc' => 'application/xenc+xml',
  7975. 'xer' => 'application/patch-ops-error+xml',
  7976. 'xfdf' => 'application/vnd.adobe.xfdf',
  7977. 'xfdl' => 'application/vnd.xfdl',
  7978. 'xht' => 'application/xhtml+xml',
  7979. 'xhtml' => 'application/xhtml+xml',
  7980. 'xhvml' => 'application/xv+xml',
  7981. 'xif' => 'image/vnd.xiff',
  7982. 'xla' => 'application/vnd.ms-excel',
  7983. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  7984. 'xlc' => 'application/vnd.ms-excel',
  7985. 'xlf' => 'application/x-xliff+xml',
  7986. 'xlm' => 'application/vnd.ms-excel',
  7987. 'xls' => 'application/vnd.ms-excel',
  7988. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  7989. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  7990. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  7991. 'xlt' => 'application/vnd.ms-excel',
  7992. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  7993. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  7994. 'xlw' => 'application/vnd.ms-excel',
  7995. 'xm' => 'audio/xm',
  7996. 'xml' => 'application/xml',
  7997. 'xo' => 'application/vnd.olpc-sugar',
  7998. 'xop' => 'application/xop+xml',
  7999. 'xpi' => 'application/x-xpinstall',
  8000. 'xpl' => 'application/xproc+xml',
  8001. 'xpm' => 'image/x-xpixmap',
  8002. 'xpr' => 'application/vnd.is-xpr',
  8003. 'xps' => 'application/vnd.ms-xpsdocument',
  8004. 'xpw' => 'application/vnd.intercon.formnet',
  8005. 'xpx' => 'application/vnd.intercon.formnet',
  8006. 'xsl' => 'application/xml',
  8007. 'xslt' => 'application/xslt+xml',
  8008. 'xsm' => 'application/vnd.syncml+xml',
  8009. 'xspf' => 'application/xspf+xml',
  8010. 'xul' => 'application/vnd.mozilla.xul+xml',
  8011. 'xvm' => 'application/xv+xml',
  8012. 'xvml' => 'application/xv+xml',
  8013. 'xwd' => 'image/x-xwindowdump',
  8014. 'xyz' => 'chemical/x-xyz',
  8015. 'xz' => 'application/x-xz',
  8016. 'yang' => 'application/yang',
  8017. 'yin' => 'application/yin+xml',
  8018. 'z1' => 'application/x-zmachine',
  8019. 'z2' => 'application/x-zmachine',
  8020. 'z3' => 'application/x-zmachine',
  8021. 'z4' => 'application/x-zmachine',
  8022. 'z5' => 'application/x-zmachine',
  8023. 'z6' => 'application/x-zmachine',
  8024. 'z7' => 'application/x-zmachine',
  8025. 'z8' => 'application/x-zmachine',
  8026. 'zaz' => 'application/vnd.zzazz.deck+xml',
  8027. 'zip' => 'application/zip',
  8028. 'zir' => 'application/vnd.zul',
  8029. 'zirz' => 'application/vnd.zul',
  8030. 'zmm' => 'application/vnd.handheld-entertainment+xml'
  8031. );
  8032. }
  8033. // Always run this
  8034. if(strpos($_SERVER['SCRIPT_NAME'], 'check.php') == false){
  8035. dependCheck();
  8036. }