functions.php 304 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340
  1. <?php
  2. // ===================================
  3. // Define Version
  4. define('INSTALLEDVERSION', '1.50');
  5. // ===================================
  6. use Kryptonit3\Sonarr\Sonarr;
  7. use Kryptonit3\SickRage\SickRage;
  8. // Debugging output functions
  9. function debug_out($variable, $die = false) {
  10. $trace = debug_backtrace()[0];
  11. echo "<center><img height='200px' src='images/confused.png'></center>";
  12. echo "<center>Look's like something happened, here are the errors and perhaps how to fix them:</center>";
  13. echo '<pre style="white-space: pre-line; background-color: #f2f2f2; border: 2px solid black; border-radius: 5px; padding: 5px; margin: 5px;">'.$trace['file'].':'.$trace['line']."\n\n".print_r($variable, true).'</pre>';
  14. if ($die) { http_response_code(503); die(); }
  15. }
  16. // ==== Auth Plugins START ====
  17. if (function_exists('ldap_connect')) :
  18. // Pass credentials to LDAP backend
  19. function plugin_auth_ldap($username, $password) {
  20. $ldapServers = explode(',',AUTHBACKENDHOST);
  21. foreach($ldapServers as $key => $value) {
  22. // Calculate parts
  23. $digest = parse_url(trim($value));
  24. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:'ldap'));
  25. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  26. $port = (isset($digest['port'])?$digest['port']:(strtolower($scheme)=='ldap'?389:636));
  27. // Reassign
  28. $ldapServers[$key] = $scheme.'://'.$host.':'.$port;
  29. }
  30. // returns true or false
  31. $ldap = ldap_connect(implode(' ',$ldapServers));
  32. if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
  33. writeLog("success", "LDAP authentication success");
  34. return true;
  35. } else {
  36. writeLog("error", "LDPA could not authenticate");
  37. return false;
  38. }
  39. writeLog("error", "LDPA could not authenticate");
  40. return false;
  41. }
  42. else :
  43. // Ldap Auth Missing Dependancy
  44. function plugin_auth_ldap_disabled() {
  45. return 'LDAP - Disabled (Dependancy: php-ldap missing!)';
  46. }
  47. endif;
  48. // Pass credentials to FTP backend
  49. function plugin_auth_ftp($username, $password) {
  50. // Calculate parts
  51. $digest = parse_url(AUTHBACKENDHOST);
  52. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:(function_exists('ftp_ssl_connect')?'ftps':'ftp')));
  53. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  54. $port = (isset($digest['port'])?$digest['port']:21);
  55. // Determine Connection Type
  56. if ($scheme == 'ftps') {
  57. $conn_id = ftp_ssl_connect($host, $port, 20);
  58. } elseif ($scheme == 'ftp') {
  59. $conn_id = ftp_connect($host, $port, 20);
  60. } else {
  61. debug_out('Invalid FTP scheme. Use ftp or ftps');
  62. writeLog("error", "invalid FTP scheme");
  63. return false;
  64. }
  65. // Check if valid FTP connection
  66. if ($conn_id) {
  67. // Attempt login
  68. @$login_result = ftp_login($conn_id, $username, $password);
  69. ftp_close($conn_id);
  70. // Return Result
  71. if ($login_result) {
  72. writeLog("success", "$username authenticated");
  73. return true;
  74. } else {
  75. writeLog("error", "$username could not authenticate");
  76. return false;
  77. }
  78. } else {
  79. return false;
  80. }
  81. return false;
  82. }
  83. // Pass credentials to Emby Backend
  84. function plugin_auth_emby_local($username, $password) {
  85. $embyAddress = qualifyURL(EMBYURL);
  86. $headers = array(
  87. 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"',
  88. 'Content-Type' => 'application/json',
  89. );
  90. $body = array(
  91. 'Username' => $username,
  92. 'Password' => sha1($password),
  93. 'PasswordMd5' => md5($password),
  94. );
  95. $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers);
  96. if (isset($response['content'])) {
  97. $json = json_decode($response['content'], true);
  98. if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
  99. // Login Success - Now Logout Emby Session As We No Longer Need It
  100. $headers = array(
  101. 'X-Mediabrowser-Token' => $json['AccessToken'],
  102. );
  103. $response = post_router($embyAddress.'/Sessions/Logout', array(), $headers);
  104. return true;
  105. }
  106. }
  107. return false;
  108. }
  109. if (function_exists('curl_version')) :
  110. // Authenticate Against Emby Local (first) and Emby Connect
  111. function plugin_auth_emby_all($username, $password) {
  112. $localResult = plugin_auth_emby_local($username, $password);
  113. if ($localResult) {
  114. return $localResult;
  115. } else {
  116. return plugin_auth_emby_connect($username, $password);
  117. }
  118. }
  119. // Authenicate against emby connect
  120. function plugin_auth_emby_connect($username, $password) {
  121. $embyAddress = qualifyURL(EMBYURL);
  122. // Get A User
  123. $connectId = '';
  124. $userIds = json_decode(file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
  125. if (is_array($userIds)) {
  126. foreach ($userIds as $key => $value) { // Scan for this user
  127. if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
  128. if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
  129. $connectId = $value['ConnectUserId'];
  130. break;
  131. }
  132. }
  133. }
  134. if ($connectId) {
  135. $connectURL = 'https://connect.emby.media/service/user/authenticate';
  136. $headers = array(
  137. 'Accept'=> 'application/json',
  138. 'Content-Type' => 'application/x-www-form-urlencoded',
  139. );
  140. $body = array(
  141. 'nameOrEmail' => $username,
  142. 'rawpw' => $password,
  143. );
  144. $result = curl_post($connectURL, $body, $headers);
  145. if (isset($result['content'])) {
  146. $json = json_decode($result['content'], true);
  147. if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
  148. return array(
  149. 'email' => $json['User']['Email'],
  150. 'image' => $json['User']['ImageUrl'],
  151. );
  152. }
  153. }
  154. }
  155. }
  156. return false;
  157. }
  158. // Pass credentials to Plex Backend
  159. function plugin_auth_plex($username, $password) {
  160. // Quick out
  161. if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
  162. writeLog("success", $username." authenticated by plex");
  163. return true;
  164. }
  165. //Get User List
  166. $userURL = 'https://plex.tv/pms/friends/all';
  167. $userHeaders = array(
  168. 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD),
  169. );
  170. $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
  171. if (is_array($userXML) || is_object($userXML)) {
  172. $isUser = false;
  173. $usernameLower = strtolower($username);
  174. foreach($userXML AS $child) {
  175. if(isset($child['username']) && strtolower($child['username']) == $usernameLower) {
  176. $isUser = true;
  177. writeLog("success", $usernameLower." was found in plex friends list");
  178. break;
  179. }
  180. }
  181. if ($isUser) {
  182. //Login User
  183. $connectURL = 'https://plex.tv/users/sign_in.json';
  184. $headers = array(
  185. 'Accept'=> 'application/json',
  186. 'Content-Type' => 'application/x-www-form-urlencoded',
  187. 'X-Plex-Product' => 'Organizr',
  188. 'X-Plex-Version' => '1.0',
  189. 'X-Plex-Client-Identifier' => '01010101-10101010',
  190. );
  191. $body = array(
  192. 'user[login]' => $username,
  193. 'user[password]' => $password,
  194. );
  195. $result = curl_post($connectURL, $body, $headers);
  196. if (isset($result['content'])) {
  197. $json = json_decode($result['content'], true);
  198. if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && strtolower($json['user']['username']) == $usernameLower) {
  199. writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
  200. return array(
  201. 'email' => $json['user']['email'],
  202. 'image' => $json['user']['thumb']
  203. );
  204. }
  205. }
  206. }else{
  207. writeLog("error", "$username is not an authorized PLEX user or entered invalid password");
  208. }
  209. }else{
  210. writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");
  211. }
  212. return false;
  213. }
  214. else :
  215. // Plex Auth Missing Dependancy
  216. function plugin_auth_plex_disabled() {
  217. return 'Plex - Disabled (Dependancy: php-curl missing!)';
  218. }
  219. // Emby Connect Auth Missing Dependancy
  220. function plugin_auth_emby_connect_disabled() {
  221. return 'Emby Connect - Disabled (Dependancy: php-curl missing!)';
  222. }
  223. // Emby Both Auth Missing Dependancy
  224. function plugin_auth_emby_both_disabled() {
  225. return 'Emby Both - Disabled (Dependancy: php-curl missing!)';
  226. }
  227. endif;
  228. // ==== Auth Plugins END ====
  229. // ==== General Class Definitions START ====
  230. class setLanguage {
  231. private $language = null;
  232. private $langCode = null;
  233. function __construct($language = false) {
  234. // Default
  235. if (!$language) {
  236. $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  237. }
  238. if (!file_exists("lang/{$language}.ini")) {
  239. $language = 'en';
  240. }
  241. $this->langCode = $language;
  242. $this->language = parse_ini_file("lang/{$language}.ini", false, INI_SCANNER_RAW);
  243. if (file_exists("lang/{$language}.cust.ini")) {
  244. foreach($tmp = parse_ini_file("lang/{$language}.cust.ini", false, INI_SCANNER_RAW) as $k => $v) {
  245. $this->language[$k] = $v;
  246. }
  247. }
  248. }
  249. public function getLang() {
  250. return $this->langCode;
  251. }
  252. public function translate($originalWord) {
  253. $getArg = func_num_args();
  254. if ($getArg > 1) {
  255. $allWords = func_get_args();
  256. array_shift($allWords);
  257. } else {
  258. $allWords = array();
  259. }
  260. $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null;
  261. if (!$translatedWord) {
  262. return ucwords(str_replace("_", " ", strtolower($originalWord)));
  263. //echo "WHOA!!!!!!! $originalWord";
  264. }
  265. $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES);
  266. return vsprintf($translatedWord, $allWords);
  267. }
  268. }
  269. $language = new setLanguage;
  270. // ==== General Class Definitions END ====
  271. // Direct request to curl if it exists, otherwise handle if not HTTPS
  272. function post_router($url, $data, $headers = array(), $referer='') {
  273. if (function_exists('curl_version')) {
  274. return curl_post($url, $data, $headers, $referer);
  275. } else {
  276. return post_request($url, $data, $headers, $referer);
  277. }
  278. }
  279. if (function_exists('curl_version')) :
  280. // Curl Post
  281. function curl_post($url, $data, $headers = array(), $referer='') {
  282. // Initiate cURL
  283. $curlReq = curl_init($url);
  284. // As post request
  285. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST");
  286. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  287. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  288. if(localURL($url)){
  289. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  290. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  291. }
  292. // Format Data
  293. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  294. case 'application/json':
  295. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  296. break;
  297. case 'application/x-www-form-urlencoded';
  298. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  299. break;
  300. default:
  301. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  302. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  303. }
  304. // Format Headers
  305. $cHeaders = array();
  306. foreach ($headers as $k => $v) {
  307. $cHeaders[] = $k.': '.$v;
  308. }
  309. if (count($cHeaders)) {
  310. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  311. }
  312. // Execute
  313. $result = curl_exec($curlReq);
  314. $httpcode = curl_getinfo($curlReq);
  315. // Close
  316. curl_close($curlReq);
  317. // Return
  318. return array('content'=>$result, 'http_code'=>$httpcode);
  319. }
  320. //Curl Get Function
  321. function curl_get($url, $headers = array()) {
  322. // Initiate cURL
  323. $curlReq = curl_init($url);
  324. // As post request
  325. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET");
  326. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  327. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  328. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  329. if(localURL($url)){
  330. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  331. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  332. }
  333. // Format Headers
  334. $cHeaders = array();
  335. foreach ($headers as $k => $v) {
  336. $cHeaders[] = $k.': '.$v;
  337. }
  338. if (count($cHeaders)) {
  339. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  340. }
  341. // Execute
  342. $result = curl_exec($curlReq);
  343. // Close
  344. curl_close($curlReq);
  345. // Return
  346. return $result;
  347. }
  348. //Curl Delete Function
  349. function curl_delete($url, $headers = array()) {
  350. // Initiate cURL
  351. $curlReq = curl_init($url);
  352. // As post request
  353. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE");
  354. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  355. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  356. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  357. if(localURL($url)){
  358. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  359. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  360. }
  361. // Format Headers
  362. $cHeaders = array();
  363. foreach ($headers as $k => $v) {
  364. $cHeaders[] = $k.': '.$v;
  365. }
  366. if (count($cHeaders)) {
  367. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  368. }
  369. // Execute
  370. $result = curl_exec($curlReq);
  371. $httpcode = curl_getinfo($curlReq);
  372. // Close
  373. curl_close($curlReq);
  374. // Return
  375. return array('content'=>$result, 'http_code'=>$httpcode);
  376. }
  377. endif;
  378. //Case-Insensitive Function
  379. function in_arrayi($needle, $haystack) {
  380. return in_array(strtolower($needle), array_map('strtolower', $haystack));
  381. }
  382. // HTTP post request (Removes need for curl, probably useless)
  383. function post_request($url, $data, $headers = array(), $referer='') {
  384. // Adapted from http://stackoverflow.com/a/28387011/6810513
  385. // Convert the data array into URL Parameters like a=b&foo=bar etc.
  386. if (isset($headers['Content-Type'])) {
  387. switch ($headers['Content-Type']) {
  388. case 'application/json':
  389. $data = json_encode($data);
  390. break;
  391. case 'application/x-www-form-urlencoded':
  392. $data = http_build_query($data);
  393. break;
  394. }
  395. } else {
  396. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  397. $data = http_build_query($data);
  398. }
  399. // parse the given URL
  400. $urlDigest = parse_url($url);
  401. // extract host and path:
  402. $host = $urlDigest['host'];
  403. $path = $urlDigest['path'];
  404. if ($urlDigest['scheme'] != 'http') {
  405. die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')');
  406. }
  407. // open a socket connection on port 80 - timeout: 30 sec
  408. $fp = fsockopen($host, (isset($urlDigest['port'])?':'.$urlDigest['port']:80), $errno, $errstr, 30);
  409. if ($fp){
  410. // send the request headers:
  411. fputs($fp, "POST $path HTTP/1.1\r\n");
  412. fputs($fp, "Host: $host\r\n");
  413. if ($referer != '')
  414. fputs($fp, "Referer: $referer\r\n");
  415. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  416. foreach($headers as $k => $v) {
  417. fputs($fp, $k.": ".$v."\r\n");
  418. }
  419. fputs($fp, "Connection: close\r\n\r\n");
  420. fputs($fp, $data);
  421. $result = '';
  422. while(!feof($fp)) {
  423. // receive the results of the request
  424. $result .= fgets($fp, 128);
  425. }
  426. }
  427. else {
  428. return array(
  429. 'status' => 'err',
  430. 'error' => "$errstr ($errno)"
  431. );
  432. }
  433. // close the socket connection:
  434. fclose($fp);
  435. // split the result header from the content
  436. $result = explode("\r\n\r\n", $result, 2);
  437. $header = isset($result[0]) ? $result[0] : '';
  438. $content = isset($result[1]) ? $result[1] : '';
  439. // return as structured array:
  440. return array(
  441. 'status' => 'ok',
  442. 'header' => $header,
  443. 'content' => $content,
  444. );
  445. }
  446. // Format item from Emby for Carousel
  447. function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $moreInfo = false) {
  448. // Static Height
  449. $height = 444;
  450. // Get Item Details
  451. $itemDetails = json_decode(file_get_contents($address.'/Items?Ids='.$item['Id'].'&api_key='.$token),true)['Items'][0];
  452. if (substr_count(EMBYURL, ':') == 2) {
  453. $URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  454. }else{
  455. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  456. }
  457. //$URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  458. switch ($itemDetails['Type']) {
  459. case 'Episode':
  460. $title = (isset($itemDetails['SeriesName'])?$itemDetails['SeriesName']:"");
  461. $imageId = (isset($itemDetails['SeriesId'])?$itemDetails['SeriesId']:$itemDetails['Id']);
  462. $width = 300;
  463. $style = '';
  464. $image = 'slick-image-tall';
  465. if(!$nowPlaying){
  466. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  467. $key = $itemDetails['Id'] . "-list";
  468. }else{
  469. $height = 281;
  470. $width = 500;
  471. $imageId = isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId'] : (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  472. $imageType = isset($itemDetails['ParentThumbItemId']) ? "Thumb" : (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  473. $key = (isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId']."-np" : "none-np");
  474. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  475. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  476. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  477. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  478. $stream = $moreInfo['PlayState']['PlayMethod'];
  479. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  480. $id = $moreInfo['DeviceId'];
  481. $streamInfo = buildStream(array(
  482. 'platform' => (string) $moreInfo['Client'],
  483. 'device' => (string) $moreInfo['DeviceName'],
  484. 'stream' => streamType($stream),
  485. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  486. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  487. ));
  488. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  489. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$itemDetails['Name'].'</h5>';
  490. $bottomTitle = '<small class="zero-m">S'.$itemDetails['ParentIndexNumber'].' · E'.$itemDetails['IndexNumber'].'</small>';
  491. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  492. }
  493. break;
  494. case 'MusicAlbum':
  495. case 'Audio':
  496. $title = $itemDetails['Name'];
  497. $imageId = $itemDetails['Id'];
  498. $width = 444;
  499. $style = '';
  500. $image = 'slick-image-short';
  501. if(!$nowPlaying){
  502. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  503. $key = $itemDetails['Id'] . "-list";
  504. }else{
  505. $height = 281;
  506. $width = 500;
  507. $imageId = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  508. $imageType = (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  509. $key = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : "no-np") . "-np";
  510. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  511. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  512. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  513. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  514. $stream = $moreInfo['PlayState']['PlayMethod'];
  515. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  516. $id = $moreInfo['DeviceId'];
  517. $streamInfo = buildStream(array(
  518. 'platform' => (string) $moreInfo['Client'],
  519. 'device' => (string) $moreInfo['DeviceName'],
  520. 'stream' => streamType($stream),
  521. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  522. ));
  523. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  524. $topTitle = '<h5 class="text-center zero-m elip">'.$itemDetails['AlbumArtist'].' - '.$itemDetails['Album'].'</h5>';
  525. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  526. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  527. }
  528. break;
  529. case 'TvChannel':
  530. $title = $itemDetails['CurrentProgram']['Name'];
  531. $imageId = $itemDetails['Id'];
  532. $width = 300;
  533. $style = '';
  534. $image = 'slick-image-tall';
  535. if(!$nowPlaying){
  536. $imageType = "Primary";
  537. $key = $itemDetails['Id'] . "-list";
  538. }else{
  539. $height = 281;
  540. $width = 500;
  541. $imageType = "Thumb";
  542. $key = $itemDetails['Id'] . "-np";
  543. $useImage = "images/livetv.png";
  544. $watched = "0";
  545. $stream = $moreInfo['PlayState']['PlayMethod'];
  546. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  547. $id = $moreInfo['DeviceId'];
  548. $streamInfo = buildStream(array(
  549. 'platform' => (string) $moreInfo['Client'],
  550. 'device' => (string) $moreInfo['DeviceName'],
  551. 'stream' => streamType($stream),
  552. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  553. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  554. ));
  555. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  556. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  557. $bottomTitle = '<small class="zero-m">'.$itemDetails['Name'].' - '.$itemDetails['ChannelNumber'].'</small>';
  558. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  559. }
  560. break;
  561. default:
  562. $title = $itemDetails['Name'];
  563. $imageId = $itemDetails['Id'];
  564. $width = 300;
  565. $style = '';
  566. $image = 'slick-image-tall';
  567. if(!$nowPlaying){
  568. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  569. $key = $itemDetails['Id'] . "-list";
  570. }else{
  571. $height = 281;
  572. $width = 500;
  573. $imageType = isset($itemDetails['ImageTags']['Thumb']) ? "Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
  574. $key = $itemDetails['Id'] . "-np";
  575. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  576. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  577. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  578. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  579. $stream = $moreInfo['PlayState']['PlayMethod'];
  580. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  581. $id = $moreInfo['DeviceId'];
  582. $streamInfo = buildStream(array(
  583. 'platform' => (string) $moreInfo['Client'],
  584. 'device' => (string) $moreInfo['DeviceName'],
  585. 'stream' => streamType($stream),
  586. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  587. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  588. ));
  589. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  590. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  591. $bottomTitle = '<small class="zero-m">'.$moreInfo['NowPlayingItem']['ProductionYear'].'</small>';
  592. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  593. }
  594. }
  595. // If No Overview
  596. if (!isset($itemDetails['Overview'])) {
  597. $itemDetails['Overview'] = '';
  598. }
  599. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  600. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  601. $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'';
  602. }
  603. if($nowPlaying){
  604. if(!$imageType){ $image_url = "images/no-np.png"; $key = "no-np"; }
  605. if(!$imageId){ $image_url = "images/no-np.png"; $key = "no-np"; }
  606. }else{
  607. if(!$imageType){ $image_url = "images/no-list.png"; $key = "no-list"; }
  608. if(!$imageId){ $image_url = "images/no-list.png"; $key = "no-list"; }
  609. }
  610. if(isset($useImage)){ $image_url = $useImage; }
  611. // Assemble Item And Cache Into Array
  612. if($nowPlaying){
  613. //prettyPrint($itemDetails);
  614. return '<div class="col-sm-6 col-md-3"><div class="thumbnail ultra-widget"><div style="display: none;" np="'.$id.'" class="overlay content-box small-box gray-bg">'.$streamInfo.'</div><span class="w-refresh w-p-icon gray" link="'.$id.'"><span class="fa-stack fa-lg" style="font-size: .5em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-info-circle fa-stack-1x fa-inverse"></i></span></span><a href="'.$URL.'" target="_blank"><img style="width: 100%; display:inherit;" src="'.$image_url.'" alt="'.$itemDetails['Name'].'"></a><div class="progress progress-bar-sm zero-m"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$watched.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$watched.'%"></div><div class="progress-bar palette-Grey-500 bg" style="width: 0%"></div></div><div class="caption"><i style="float:left" class="fa fa-'.$state.'"></i>'.$topTitle.''.$bottomTitle.'</div></div></div>';
  615. }else{
  616. return '<div class="item-'.$itemDetails['Type'].'"><a href="'.$URL.'" target="_blank"><img alt="'.$itemDetails['Name'].'" class="'.$image.'" data-lazy="'.$image_url.'"></a><small style="margin-right: 13px" class="elip">'.$title.'</small></div>';
  617. }
  618. }
  619. // Format item from Plex for Carousel
  620. function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $playlist = false) {
  621. // Static Height
  622. $height = 444;
  623. $playlist = ($playlist) ? " playlist-$playlist" : "";
  624. switch ($item['type']) {
  625. case 'season':
  626. $title = $item['parentTitle'];
  627. $summary = $item['parentSummary'];
  628. $width = 300;
  629. $image = 'slick-image-tall';
  630. $style = '';
  631. if(!$nowPlaying){
  632. $thumb = $item['thumb'];
  633. $key = $item['ratingKey'] . "-list";
  634. }else {
  635. $height = 281;
  636. $width = 500;
  637. $thumb = $item['art'];
  638. $key = $item['ratingKey'] . "-np";
  639. $elapsed = $item['viewOffset'];
  640. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  641. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  642. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  643. $stream = $item->Media->Part->Stream['decision'];
  644. $user = $role == "admin" ? $item->User['title'] : "";
  645. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  646. $streamInfo = buildStream(array(
  647. 'platform' => (string) $item->Player['platform'],
  648. 'device' => (string) $item->Player['device'],
  649. 'stream' => streamType($item->Media->Part['decision']),
  650. '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'].")",
  651. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  652. ));
  653. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  654. }
  655. break;
  656. case 'episode':
  657. $title = $item['grandparentTitle'];
  658. $summary = $item['title'];
  659. $width = 300;
  660. $image = 'slick-image-tall';
  661. $style = '';
  662. if(!$nowPlaying){
  663. $thumb = ($item['parentThumb'] ? $item['parentThumb'] : $item['grandparentThumb']);
  664. $key = $item['ratingKey'] . "-list";
  665. }else {
  666. $height = 281;
  667. $width = 500;
  668. $thumb = $item['art'];
  669. $key = $item['ratingKey'] . "-np";
  670. $elapsed = $item['viewOffset'];
  671. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  672. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  673. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  674. $stream = $item->Media->Part->Stream['decision'];
  675. $user = $role == "admin" ? $item->User['title'] : "";
  676. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  677. $streamInfo = buildStream(array(
  678. 'platform' => (string) $item->Player['platform'],
  679. 'device' => (string) $item->Player['device'],
  680. 'stream' => streamType($item->Media->Part['decision']),
  681. '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'].")",
  682. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  683. ));
  684. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  685. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$item['title'].'</h5>';
  686. $bottomTitle = '<small class="zero-m">S'.$item['parentIndex'].' · E'.$item['index'].'</small>';
  687. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  688. }
  689. break;
  690. case 'clip':
  691. $title = $item['title'];
  692. $summary = $item['summary'];
  693. $width = 300;
  694. $image = 'slick-image-tall';
  695. $style = '';
  696. if(!$nowPlaying){
  697. $thumb = $item['thumb'];
  698. $key = $item['ratingKey'] . "-list";
  699. }else {
  700. $height = 281;
  701. $width = 500;
  702. $thumb = $item['art'];
  703. $key = isset($item['ratingKey']) ? $item['ratingKey'] . "-np" : (isset($item['live']) ? "livetv.png" : ":)");
  704. $useImage = (isset($item['live']) ? "images/livetv.png" : null);
  705. $extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
  706. $elapsed = $item['viewOffset'];
  707. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  708. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  709. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  710. $stream = $item->Media->Part->Stream['decision'];
  711. $user = $role == "admin" ? $item->User['title'] : "";
  712. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  713. $streamInfo = buildStream(array(
  714. 'platform' => (string) $item->Player['platform'],
  715. 'device' => (string) $item->Player['device'],
  716. 'stream' => streamType($item->Media->Part['decision']),
  717. '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'].")",
  718. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  719. ));
  720. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  721. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  722. $bottomTitle = '<small class="zero-m">'.$extraInfo.'</small>';
  723. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  724. }
  725. break;
  726. case 'album':
  727. case 'track':
  728. $title = $item['parentTitle'];
  729. $summary = $item['title'];
  730. $image = 'slick-image-short';
  731. $style = 'left: 160px !important;';
  732. $item['ratingKey'] = $item['parentRatingKey'];
  733. if(!$nowPlaying){
  734. $width = 444;
  735. $thumb = $item['thumb'];
  736. $key = $item['ratingKey'] . "-list";
  737. }else {
  738. $height = 281;
  739. $width = 500;
  740. $thumb = $item['art'];
  741. $key = $item['ratingKey'] . "-np";
  742. $elapsed = $item['viewOffset'];
  743. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  744. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  745. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  746. $stream = $item->Media->Part->Stream['decision'];
  747. $user = $role == "admin" ? $item->User['title'] : "";
  748. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  749. $streamInfo = buildStream(array(
  750. 'platform' => (string) $item->Player['platform'],
  751. 'device' => (string) $item->Player['device'],
  752. 'stream' => streamType($item->Media->Part['decision']),
  753. 'audio' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['channels']."ch)",
  754. ));
  755. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  756. $topTitle = '<h5 class="text-center zero-m elip">'.$item['grandparentTitle'].' - '.$item['title'].'</h5>';
  757. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  758. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  759. }
  760. break;
  761. default:
  762. $title = $item['title'];
  763. $summary = $item['summary'];
  764. $image = 'slick-image-tall';
  765. $style = '';
  766. if(!$nowPlaying){
  767. $width = 300;
  768. $thumb = $item['thumb'];
  769. $key = $item['ratingKey'] . "-list";
  770. }else {
  771. $height = 281;
  772. $width = 500;
  773. $thumb = $item['art'];
  774. $key = $item['ratingKey'] . "-np";
  775. $elapsed = $item['viewOffset'];
  776. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  777. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  778. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  779. $stream = $item->Media->Part->Stream['decision'];
  780. $user = $role == "admin" ? $item->User['title'] : "";
  781. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  782. $streamInfo = buildStream(array(
  783. 'platform' => (string) $item->Player['platform'],
  784. 'device' => (string) $item->Player['device'],
  785. 'stream' => streamType($item->Media->Part['decision']),
  786. 'video' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['width']."x".$item->Media->Part->Stream[0]['height'].")",
  787. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  788. ));
  789. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  790. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  791. $bottomTitle = '<small class="zero-m">'.$item['year'].'</small>';
  792. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  793. }
  794. }
  795. if (substr_count(PLEXURL, '.') != 2) {
  796. $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  797. }else{
  798. $address = PLEXURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  799. }
  800. // If No Overview
  801. if (!isset($itemDetails['Overview'])) { $itemDetails['Overview'] = ''; }
  802. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  803. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  804. $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'';
  805. }
  806. if($nowPlaying){
  807. if(!$thumb){ $image_url = "images/no-np.png"; $key = "no-np"; }
  808. }else{
  809. if(!$thumb){ $image_url = "images/no-list.png"; $key = "no-list"; }
  810. }
  811. if(isset($useImage)){ $image_url = $useImage; }
  812. $openTab = (PLEXTABNAME) ? "true" : "false";
  813. // Assemble Item And Cache Into Array
  814. if($nowPlaying){
  815. return '<div class="col-sm-6 col-md-3"><div class="thumbnail ultra-widget"><div style="display: none;" np="'.$id.'" class="overlay content-box small-box gray-bg">'.$streamInfo.'</div><span class="w-refresh w-p-icon gray" link="'.$id.'"><span class="fa-stack fa-lg" style="font-size: .5em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-info-circle fa-stack-1x fa-inverse"></i></span></span><a class="openTab" extraTitle="'.$title.'" extraType="'.$item['type'].'" openTab="'.$openTab.'" href="'.$address.'" target="_blank"><img style="width: 100%; display:inherit;" src="'.$image_url.'" alt="'.$item['Name'].'"></a><div class="progress progress-bar-sm zero-m"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$watched.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$watched.'%"></div><div class="progress-bar palette-Grey-500 bg" style="width: '.$transcoded.'%"></div></div><div class="caption"><i style="float:left" class="fa fa-'.$state.'"></i>'.$topTitle.''.$bottomTitle.'</div></div></div>';
  816. }else{
  817. return '<div class="item-'.$item['type'].$playlist.'"><a class="openTab" extraTitle="'.$title.'" extraType="'.$item['type'].'" openTab="'.$openTab.'" href="'.$address.'" target="_blank"><img alt="'.$item['Name'].'" class="'.$image.'" data-lazy="'.$image_url.'"></a><small style="margin-right: 13px" class="elip">'.$title.'</small></div>';
  818. }
  819. }
  820. //$hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  821. //Recent Added
  822. function outputRecentAdded($header, $items, $script = false, $array) {
  823. $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">';
  824. if(preg_grep("/item-movie/", $items)){
  825. $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>';
  826. }
  827. if(preg_grep("/item-season/", $items)){
  828. $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>';
  829. }
  830. if(preg_grep("/item-album/", $items)){
  831. $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>';
  832. }
  833. $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>';
  834. $hideMenu .= '</ul></div></div>';
  835. // If None Populate Empty Item
  836. if (!count($items)) {
  837. return '<div id="recentMedia" class="content-box box-shadow big-box"><h5 class="text-center">'.$header.'</h5><p class="text-center">No Media Found</p></div>';
  838. }else{
  839. $className = str_replace(' ', '', $header);
  840. return '<div id="recentMedia" class="content-box box-shadow big-box"><h5 id="recentContent-title" style="margin-bottom: -20px" class="text-center">'.$header.'</h5><div class="recentHeader inbox-pagination '.$className.'">'.$hideMenu.'</div><br/><br/><div class="recentItems-recent" data-name="'.$className.'">'.implode('',$items).'</div></div>'.($script?'<script>'.$script.'</script>':'');
  841. }
  842. }
  843. // Create Carousel
  844. function outputNowPlaying($header, $size, $type, $items, $script = false) {
  845. // If None Populate Empty Item
  846. if (!count($items)) {
  847. return '<div id=streamz></div>'.($script?'<script>'.$script.'</script>':'');
  848. }else{
  849. return '<div id=streamz><h5 class="zero-m big-box"><strong>'.$header.'</strong></h5>'.implode('',$items).'</div>'.($script?'<script>'.$script.'</script>':'');
  850. }
  851. }
  852. // Get Now Playing Streams From Emby
  853. function getEmbyStreams($size, $showNames, $role) {
  854. $address = qualifyURL(EMBYURL);
  855. $api = json_decode(@file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
  856. if (!is_array($api)) { return 'Could not load!'; }
  857. $playingItems = array();
  858. foreach($api as $key => $value) {
  859. if (isset($value['NowPlayingItem'])) {
  860. $playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem'], true, $showNames, $role, $value);
  861. }
  862. }
  863. return outputNowPlaying(translate('PLAYING_NOW_ON_EMBY'), $size, 'streams-emby', $playingItems, "
  864. setInterval(function() {
  865. $('<div></div>').load('ajax.php?a=emby-streams',function() {
  866. var element = $(this).find('[id]');
  867. var loadedID = element.attr('id');
  868. $('#'+loadedID).replaceWith(element);
  869. console.log('Loaded updated: '+loadedID);
  870. });
  871. }, 15000);
  872. ");
  873. }
  874. // Get Now Playing Streams From Plex
  875. function getPlexStreams($size, $showNames, $role){
  876. $address = qualifyURL(PLEXURL);
  877. // Perform API requests
  878. $api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
  879. $api = simplexml_load_string($api);
  880. if (is_array($api) || is_object($api)){
  881. if (!$api->head->title){
  882. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  883. if (!$getServer) { return 'Could not load!'; }
  884. // Identify the local machine
  885. $gotServer = $getServer['machineIdentifier'];
  886. $items = array();
  887. foreach($api AS $child) {
  888. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
  889. }
  890. return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." ( ".count($items)." Streams )", $size, 'streams-plex', $items, "
  891. setInterval(function() {
  892. $('<div></div>').load('ajax.php?a=plex-streams',function() {
  893. var element = $(this).find('[id]');
  894. var loadedID = element.attr('id');
  895. $('#'+loadedID).replaceWith(element);
  896. console.log('Loaded updated: '+loadedID);
  897. });
  898. }, 15000);
  899. ");
  900. }else{
  901. writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
  902. }
  903. }else{
  904. writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
  905. }
  906. }
  907. // Get Recent Content From Emby
  908. function getEmbyRecent($array) {
  909. $address = qualifyURL(EMBYURL);
  910. $header = translate('RECENT_CONTENT');
  911. // Currently Logged In User
  912. $username = false;
  913. if (isset($GLOBALS['USER'])) {
  914. $username = strtolower($GLOBALS['USER']->username);
  915. }
  916. // Get A User
  917. $userIds = json_decode(@file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
  918. if (!is_array($userIds)) { return 'Could not load!'; }
  919. $showPlayed = true;
  920. foreach ($userIds as $value) { // Scan for admin user
  921. if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
  922. $userId = $value['Id'];
  923. }
  924. if ($username && strtolower($value['Name']) == $username) {
  925. $userId = $value['Id'];
  926. $showPlayed = false;
  927. break;
  928. }
  929. }
  930. // Get the latest Items
  931. $latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?EnableImages=false&Limit='.EMBYRECENTITEMS.'&api_key='.EMBYTOKEN.($showPlayed?'':'&IsPlayed=false')),true);
  932. // For Each Item In Category
  933. $items = array();
  934. foreach ($latest as $k => $v) {
  935. $type = (string) $v['Type'];
  936. if(@$array[$type] == "true"){
  937. $items[] = resolveEmbyItem($address, EMBYTOKEN, $v, false, false, false);
  938. }
  939. }
  940. $array["movie"] = $array["Movie"];
  941. $array["season"] = $array["Episode"];
  942. $array["album"] = $array["MusicAlbum"];
  943. unset($array["Movie"]);
  944. unset($array["Episode"]);
  945. unset($array["MusicAlbum"]);
  946. unset($array["Series"]);
  947. return outputRecentAdded($header, $items, "", $array);
  948. }
  949. // Get Recent Content From Plex
  950. function getPlexRecent($array){
  951. $address = qualifyURL(PLEXURL);
  952. $header = translate('RECENT_CONTENT');
  953. // Perform Requests
  954. $api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN);
  955. $api = simplexml_load_string($api);
  956. if (is_array($api) || is_object($api)){
  957. if (!$api->head->title){
  958. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  959. if (!$getServer) { return 'Could not load!'; }
  960. // Identify the local machine
  961. $gotServer = $getServer['machineIdentifier'];
  962. $items = array();
  963. foreach($api AS $child) {
  964. $type = (string) $child['type'];
  965. if($array[$type] == "true"){
  966. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
  967. }
  968. }
  969. return outputRecentAdded($header, $items, "", $array);
  970. }else{
  971. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check token - if HTTPS, is cert valid");
  972. }
  973. }else{
  974. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check URL - if HTTPS, is cert valid");
  975. }
  976. }
  977. // Get Image From Emby
  978. function getEmbyImage() {
  979. $embyAddress = qualifyURL(EMBYURL);
  980. if (!file_exists('images/cache')) {
  981. mkdir('images/cache', 0777, true);
  982. }
  983. $itemId = $_GET['img'];
  984. $key = $_GET['key'];
  985. $itemType = $_GET['type'];
  986. $imgParams = array();
  987. if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
  988. if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
  989. if(isset($itemId)) {
  990. $image_src = $embyAddress . '/Items/'.$itemId.'/Images/'.$itemType.'?'.implode('&', $imgParams);
  991. $cachefile = 'images/cache/'.$key.'.jpg';
  992. $cachetime = 604800;
  993. // Serve from the cache if it is younger than $cachetime
  994. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
  995. header("Content-type: image/jpeg");
  996. @readfile($cachefile);
  997. exit;
  998. }
  999. ob_start(); // Start the output buffer
  1000. header('Content-type: image/jpeg');
  1001. @readfile($image_src);
  1002. // Cache the output to a file
  1003. $fp = fopen($cachefile, 'wb');
  1004. fwrite($fp, ob_get_contents());
  1005. fclose($fp);
  1006. ob_end_flush(); // Send the output to the browser
  1007. die();
  1008. } else {
  1009. debug_out('Invalid Request',1);
  1010. }
  1011. }
  1012. // Get Image From Plex
  1013. function getPlexImage() {
  1014. $plexAddress = qualifyURL(PLEXURL);
  1015. if (!file_exists('images/cache')) {
  1016. mkdir('images/cache', 0777, true);
  1017. }
  1018. $image_url = $_GET['img'];
  1019. $key = $_GET['key'];
  1020. $image_height = $_GET['height'];
  1021. $image_width = $_GET['width'];
  1022. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  1023. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  1024. $cachefile = 'images/cache/'.$key.'.jpg';
  1025. $cachetime = 604800;
  1026. // Serve from the cache if it is younger than $cachetime
  1027. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
  1028. header("Content-type: image/jpeg");
  1029. @readfile($cachefile);
  1030. exit;
  1031. }
  1032. ob_start(); // Start the output buffer
  1033. header('Content-type: image/jpeg');
  1034. @readfile($image_src);
  1035. // Cache the output to a file
  1036. $fp = fopen($cachefile, 'wb');
  1037. fwrite($fp, ob_get_contents());
  1038. fclose($fp);
  1039. ob_end_flush(); // Send the output to the browser
  1040. die();
  1041. } else {
  1042. echo "Invalid Plex Request";
  1043. }
  1044. }
  1045. // Simplier access to class
  1046. function translate($string) {
  1047. if (isset($GLOBALS['language'])) {
  1048. return $GLOBALS['language']->translate($string);
  1049. } else {
  1050. return '!Translations Not Loaded!';
  1051. }
  1052. }
  1053. // Generate Random string
  1054. function randString($length = 10, $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  1055. $tmp = '';
  1056. for ($i = 0; $i < $length; $i++) {
  1057. $tmp .= substr(str_shuffle($chars), 0, 1);
  1058. }
  1059. return $tmp;
  1060. }
  1061. // Create config file in the return syntax
  1062. function createConfig($array, $path = 'config/config.php', $nest = 0) {
  1063. // Define Initial Value
  1064. $output = array();
  1065. // Sort Items
  1066. ksort($array);
  1067. // Update the current config version
  1068. if (!$nest) {
  1069. // Inject Current Version
  1070. $output[] = "\t'CONFIG_VERSION' => '".(isset($array['apply_CONFIG_VERSION'])?$array['apply_CONFIG_VERSION']:INSTALLEDVERSION)."'";
  1071. }
  1072. unset($array['CONFIG_VERSION']);
  1073. unset($array['apply_CONFIG_VERSION']);
  1074. // Process Settings
  1075. foreach ($array as $k => $v) {
  1076. $allowCommit = true;
  1077. switch (gettype($v)) {
  1078. case 'boolean':
  1079. $item = ($v?'true':'false');
  1080. break;
  1081. case 'integer':
  1082. case 'double':
  1083. case 'integer':
  1084. case 'NULL':
  1085. $item = $v;
  1086. break;
  1087. case 'string':
  1088. $item = "'".str_replace(array('\\',"'"),array('\\\\',"\'"),$v)."'";
  1089. break;
  1090. case 'array':
  1091. $item = createConfig($v, false, $nest+1);
  1092. break;
  1093. default:
  1094. $allowCommit = false;
  1095. }
  1096. if($allowCommit) {
  1097. $output[] = str_repeat("\t",$nest+1)."'$k' => $item";
  1098. }
  1099. }
  1100. // Build output
  1101. $output = (!$nest?"<?php\nreturn ":'')."array(\n".implode(",\n",$output)."\n".str_repeat("\t",$nest).')'.(!$nest?';':'');
  1102. if (!$nest && $path) {
  1103. $pathDigest = pathinfo($path);
  1104. @mkdir($pathDigest['dirname'], 0770, true);
  1105. if (file_exists($path)) {
  1106. rename($path, $pathDigest['dirname'].'/'.$pathDigest['filename'].'.bak.php');
  1107. }
  1108. $file = fopen($path, 'w');
  1109. fwrite($file, $output);
  1110. fclose($file);
  1111. if (file_exists($path)) {
  1112. return true;
  1113. }
  1114. writeLog("error", "config was unable to write");
  1115. return false;
  1116. } else {
  1117. writeLog("success", "config was updated with new values");
  1118. return $output;
  1119. }
  1120. }
  1121. // Load a config file written in the return syntax
  1122. function loadConfig($path = 'config/config.php') {
  1123. // Adapted from http://stackoverflow.com/a/14173339/6810513
  1124. if (!is_file($path)) {
  1125. return null;
  1126. } else {
  1127. return (array) call_user_func(function() use($path) {
  1128. return include($path);
  1129. });
  1130. }
  1131. }
  1132. // Commit new values to the configuration
  1133. function updateConfig($new, $current = false) {
  1134. // Get config if not supplied
  1135. if ($current === false) {
  1136. $current = loadConfig();
  1137. } else if (is_string($current) && is_file($current)) {
  1138. $current = loadConfig($current);
  1139. }
  1140. // Inject Parts
  1141. foreach ($new as $k => $v) {
  1142. $current[$k] = $v;
  1143. }
  1144. // Return Create
  1145. return createConfig($current);
  1146. }
  1147. // Inject Defaults As Needed
  1148. function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
  1149. if (is_string($path)) {
  1150. $loadedDefaults = loadConfig($path);
  1151. } else {
  1152. $loadedDefaults = $path;
  1153. }
  1154. return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
  1155. }
  1156. // support function for fillDefaultConfig()
  1157. function fillDefaultConfig_recurse($current, $defaults) {
  1158. foreach($defaults as $k => $v) {
  1159. if (!isset($current[$k])) {
  1160. $current[$k] = $v;
  1161. } else if (is_array($current[$k]) && is_array($v)) {
  1162. $current[$k] = fillDefaultConfig_recurse($current[$k], $v);
  1163. }
  1164. }
  1165. return $current;
  1166. };
  1167. // Define Scalar Variables (nest non-secular with underscores)
  1168. function defineConfig($array, $anyCase = true, $nest_prefix = false) {
  1169. foreach($array as $k => $v) {
  1170. if (is_scalar($v) && !defined($nest_prefix.$k)) {
  1171. define($nest_prefix.$k, $v, $anyCase);
  1172. } else if (is_array($v)) {
  1173. defineConfig($v, $anyCase, $nest_prefix.$k.'_');
  1174. }
  1175. }
  1176. }
  1177. // This function exists only because I am lazy
  1178. function configLazy($path = 'config/config.php') {
  1179. // Load config or default
  1180. if (file_exists($path)) {
  1181. $config = fillDefaultConfig(loadConfig($path));
  1182. } else {
  1183. $config = loadConfig('config/configDefaults.php');
  1184. }
  1185. if (is_array($config)) {
  1186. defineConfig($config);
  1187. }
  1188. return $config;
  1189. }
  1190. // Qualify URL
  1191. function qualifyURL($url) {
  1192. //local address?
  1193. if(substr($url, 0,1) == "/"){
  1194. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  1195. $protocol = "https://";
  1196. } else {
  1197. $protocol = "http://";
  1198. }
  1199. $url = $protocol.getServer().$url;
  1200. }
  1201. // Get Digest
  1202. $digest = parse_url($url);
  1203. // http/https
  1204. if (!isset($digest['scheme'])) {
  1205. if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096,32400,7878,8989,8182,8081,6789))) {
  1206. $scheme = 'http';
  1207. } else {
  1208. $scheme = 'https';
  1209. }
  1210. } else {
  1211. $scheme = $digest['scheme'];
  1212. }
  1213. // Host
  1214. $host = (isset($digest['host'])?$digest['host']:'');
  1215. // Port
  1216. $port = (isset($digest['port'])?':'.$digest['port']:'');
  1217. // Path
  1218. $path = (isset($digest['path'])?$digest['path']:'');
  1219. // Output
  1220. return $scheme.'://'.$host.$port.$path;
  1221. }
  1222. // Function to be called at top of each to allow upgrading environment as the spec changes
  1223. function upgradeCheck() {
  1224. // Upgrade to 1.31
  1225. if (file_exists('homepageSettings.ini.php')) {
  1226. $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
  1227. $homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
  1228. $databaseConfig = array_merge($databaseConfig, $homepageConfig);
  1229. $databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
  1230. foreach($databaseConfig as $k => $v) {
  1231. if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
  1232. $databaseData .= $k . " = \"" . $v . "\"\r\n";
  1233. }
  1234. write_ini_file($databaseData, 'databaseLocation.ini.php');
  1235. unlink('homepageSettings.ini.php');
  1236. unset($databaseData);
  1237. unset($homepageConfig);
  1238. }
  1239. // Upgrade to 1.32
  1240. if (file_exists('databaseLocation.ini.php')) {
  1241. // Load Existing
  1242. $config = parse_ini_file('databaseLocation.ini.php', true);
  1243. // Refactor
  1244. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['databaseLocation'].'/');
  1245. $config['user_home'] = $config['database_Location'].'users/';
  1246. unset($config['databaseLocation']);
  1247. // Turn Off Emby And Plex Recent
  1248. $config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
  1249. unset($config["embyPort"]);
  1250. $config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
  1251. unset($config["plexPort"]);
  1252. $config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
  1253. unset($config["nzbgetPort"]);
  1254. $config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
  1255. unset($config["sabnzbdPort"]);
  1256. $config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
  1257. unset($config["headphonesPort"]);
  1258. // Write config file
  1259. $config['CONFIG_VERSION'] = '1.32';
  1260. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][pre1.32].bak.php');
  1261. $createConfigSuccess = createConfig($config);
  1262. // Create new config
  1263. if ($createConfigSuccess) {
  1264. if (file_exists('config/config.php')) {
  1265. // Remove Old ini file
  1266. unlink('databaseLocation.ini.php');
  1267. } else {
  1268. debug_out('Something is not right here!');
  1269. }
  1270. } else {
  1271. debug_out('Couldn\'t create updated configuration.' ,1);
  1272. }
  1273. }
  1274. // Upgrade to 1.33
  1275. $config = loadConfig();
  1276. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
  1277. // Fix User Directory
  1278. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['database_Location'].'/');
  1279. $config['user_home'] = $config['database_Location'].'users/';
  1280. unset($config['USER_HOME']);
  1281. // Backend auth merge
  1282. if (isset($config['authBackendPort']) && !isset(parse_url($config['authBackendHost'])['port'])) {
  1283. $config['authBackendHost'] .= ':'.$config['authBackendPort'];
  1284. }
  1285. unset($config['authBackendPort']);
  1286. // If auth is being used move it to embyURL as that is now used in auth functions
  1287. 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')))) {
  1288. $config['embyURL'] = $config['authBackendHost'];
  1289. }
  1290. // Upgrade database to latest version
  1291. updateSQLiteDB($config['database_Location'],'1.32');
  1292. // Update Version and Commit
  1293. $config['apply_CONFIG_VERSION'] = '1.33';
  1294. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.32].bak.php');
  1295. $createConfigSuccess = createConfig($config);
  1296. unset($config);
  1297. }
  1298. // Upgrade to 1.34
  1299. $config = loadConfig();
  1300. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.34')) {
  1301. // Upgrade database to latest version
  1302. updateSQLiteDB($config['database_Location'],'1.33');
  1303. // Update Version and Commit
  1304. $config['CONFIG_VERSION'] = '1.34';
  1305. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.33].bak.php');
  1306. $createConfigSuccess = createConfig($config);
  1307. unset($config);
  1308. }
  1309. // Upgrade to 1.40
  1310. $config = loadConfig();
  1311. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.40')) {
  1312. // Upgrade database to latest version
  1313. updateSQLiteDB($config['database_Location'],'1.38');
  1314. // Update Version and Commit
  1315. $config['CONFIG_VERSION'] = '1.40';
  1316. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.38].bak.php');
  1317. $createConfigSuccess = createConfig($config);
  1318. unset($config);
  1319. }
  1320. // Upgrade to 1.50
  1321. $config = loadConfig();
  1322. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.50')) {
  1323. // Upgrade database to latest version
  1324. updateSQLiteDB($config['database_Location'],'1.40');
  1325. // Update Version and Commit
  1326. $config['CONFIG_VERSION'] = '1.50';
  1327. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.40].bak.php');
  1328. $createConfigSuccess = createConfig($config);
  1329. unset($config);
  1330. }
  1331. return true;
  1332. }
  1333. // Get OS from server
  1334. function getOS(){
  1335. if(PHP_SHLIB_SUFFIX == "dll"){
  1336. return "win";
  1337. }else{
  1338. return "nix";
  1339. }
  1340. }
  1341. //Get Error by Server OS
  1342. function getError($os, $error){
  1343. $ini = (!empty(php_ini_loaded_file()) ? php_ini_loaded_file() : "php.ini");
  1344. $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'");
  1345. $errors = array(
  1346. 'pdo_sqlite' => array(
  1347. 'win' => '<b>PDO:SQLite</b> not enabled, uncomment ;extension=php_pdo_sqlite.dll in the file php.ini | '.$ext,
  1348. 'nix' => '<b>PDO:SQLite</b> not enabled, PHP7 -> run sudo apt-get install php7.0-sqlite | PHP5 -> run sudo apt-get install php5-sqlite',
  1349. ),
  1350. 'sqlite3' => array(
  1351. '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',
  1352. 'nix' => '<b>SQLite3</b> not enabled, run sudo apt-get install php-sqlite3',
  1353. ),
  1354. 'curl' => array(
  1355. 'win' => '<b>cURL</b> not enabled, uncomment ;extension=php_curl.dll in the file php.ini | '.$ext,
  1356. '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',
  1357. ),
  1358. 'zip' => array(
  1359. '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',
  1360. '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',
  1361. ),
  1362. );
  1363. return (isset($errors[$error][$os]) ? $errors[$error][$os] : 'No Error Info Found');
  1364. }
  1365. // Check if all software dependancies are met
  1366. function dependCheck() {
  1367. $output = array();
  1368. $i = 1;
  1369. if (!extension_loaded('pdo_sqlite')) { $output["Step $i"] = getError(getOS(),'pdo_sqlite'); $i++; }
  1370. if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; }
  1371. if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; }
  1372. //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
  1373. if ($output) {
  1374. $output["Step $i"] = "<b>Restart PHP and/or Webserver to apply changes</b>"; $i++;
  1375. $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++;
  1376. debug_out($output,1);
  1377. }
  1378. return true;
  1379. }
  1380. // Process file uploads
  1381. function uploadFiles($path, $ext_mask = null) {
  1382. if (isset($_FILES) && count($_FILES)) {
  1383. require_once('class.uploader.php');
  1384. $uploader = new Uploader();
  1385. $data = $uploader->upload($_FILES['files'], array(
  1386. 'limit' => 10,
  1387. 'maxSize' => 10,
  1388. 'extensions' => $ext_mask,
  1389. 'required' => false,
  1390. 'uploadDir' => str_replace('//','/',$path.'/'),
  1391. 'title' => array('name'),
  1392. 'removeFiles' => true,
  1393. 'replace' => true,
  1394. ));
  1395. if($data['isComplete']){
  1396. $files = $data['data'];
  1397. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1398. echo json_encode($files['metas'][0]['name']);
  1399. }
  1400. if($data['hasErrors']){
  1401. $errors = $data['errors'];
  1402. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1403. echo json_encode($errors);
  1404. }
  1405. } else {
  1406. writeLog("error", "image was not uploaded");
  1407. echo json_encode('No files submitted!');
  1408. }
  1409. }
  1410. // Process file uploads
  1411. function uploadAvatar($path, $ext_mask = null) {
  1412. if (isset($_FILES) && count($_FILES)) {
  1413. require_once('class.uploader.php');
  1414. $uploader = new Uploader();
  1415. $data = $uploader->upload($_FILES['files'], array(
  1416. 'limit' => 10,
  1417. 'maxSize' => 10,
  1418. 'extensions' => $ext_mask,
  1419. 'required' => false,
  1420. 'uploadDir' => str_replace('//','/',$path.'/'),
  1421. 'title' => array('name'),
  1422. 'removeFiles' => true,
  1423. 'replace' => true,
  1424. ));
  1425. if($data['isComplete']){
  1426. $files = $data['data'];
  1427. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1428. echo json_encode($files['metas'][0]['name']);
  1429. }
  1430. if($data['hasErrors']){
  1431. $errors = $data['errors'];
  1432. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1433. echo json_encode($errors);
  1434. }
  1435. } else {
  1436. writeLog("error", "image was not uploaded");
  1437. echo json_encode('No files submitted!');
  1438. }
  1439. }
  1440. // Remove file
  1441. function removeFiles($path) {
  1442. if(is_file($path)) {
  1443. writeLog("success", "image was removed");
  1444. unlink($path);
  1445. } else {
  1446. writeLog("error", "image was not removed");
  1447. echo json_encode('No file specified for removal!');
  1448. }
  1449. }
  1450. // Lazy select options
  1451. function resolveSelectOptions($array, $selected = '', $multi = false) {
  1452. $output = array();
  1453. $selectedArr = ($multi?explode('|', $selected):array());
  1454. foreach ($array as $key => $value) {
  1455. if (is_array($value)) {
  1456. if (isset($value['optgroup'])) {
  1457. $output[] = '<optgroup label="'.$key.'">';
  1458. foreach($value['optgroup'] as $k => $v) {
  1459. $output[] = '<option value="'.$v['value'].'"'.($selected===$v['value']||in_array($v['value'],$selectedArr)?' selected':'').(isset($v['disabled']) && $v['disabled']?' disabled':'').'>'.$k.'</option>';
  1460. }
  1461. } else {
  1462. $output[] = '<option value="'.$value['value'].'"'.($selected===$value['value']||in_array($value['value'],$selectedArr)?' selected':'').(isset($value['disabled']) && $value['disabled']?' disabled':'').'>'.$key.'</option>';
  1463. }
  1464. } else {
  1465. $output[] = '<option value="'.$value.'"'.($selected===$value||in_array($value,$selectedArr)?' selected':'').'>'.$key.'</option>';
  1466. }
  1467. }
  1468. return implode('',$output);
  1469. }
  1470. // Check if user is allowed to continue
  1471. function qualifyUser($type, $errOnFail = false) {
  1472. if (!isset($GLOBALS['USER'])) {
  1473. require_once("user.php");
  1474. $GLOBALS['USER'] = new User('registration_callback');
  1475. }
  1476. if (is_bool($type)) {
  1477. if ($type === true) {
  1478. $authorized = ($GLOBALS['USER']->authenticated == true);
  1479. } else {
  1480. $authorized = true;
  1481. }
  1482. } elseif (is_string($type) || is_array($type)) {
  1483. if ($type !== 'false') {
  1484. if (!is_array($type)) {
  1485. $type = explode('|',$type);
  1486. }
  1487. $authorized = ($GLOBALS['USER']->authenticated && in_array($GLOBALS['USER']->role,$type));
  1488. } else {
  1489. $authorized = true;
  1490. }
  1491. } else {
  1492. debug_out('Invalid Syntax!',1);
  1493. }
  1494. if (!$authorized && $errOnFail) {
  1495. if ($GLOBALS['USER']->authenticated) {
  1496. header('Location: '.dirname($_SERVER['SCRIPT_NAME']).'error.php?error=401');
  1497. echo '<script>window.location.href = \''.dirname($_SERVER['SCRIPT_NAME']).'error.php?error=401\'</script>';
  1498. } else {
  1499. header('Location: '.dirname($_SERVER['SCRIPT_NAME']).'error.php?error=999');
  1500. echo '<script>window.location.href = \''.dirname($_SERVER['SCRIPT_NAME']).'error.php?error=999\'</script>';
  1501. }
  1502. debug_out('Not Authorized' ,1);
  1503. } else {
  1504. return $authorized;
  1505. }
  1506. }
  1507. // Build an (optionally) tabbed settings page.
  1508. function buildSettings($array) {
  1509. /*
  1510. array(
  1511. 'title' => '',
  1512. 'id' => '',
  1513. 'fields' => array( See buildField() ),
  1514. 'tabs' => array(
  1515. array(
  1516. 'title' => '',
  1517. 'id' => '',
  1518. 'image' => '',
  1519. 'fields' => array( See buildField() ),
  1520. ),
  1521. ),
  1522. );
  1523. */
  1524. $notifyExplode = explode("-", NOTIFYEFFECT);
  1525. $fieldFunc = function($fieldArr) {
  1526. $fields = '<div class="row">';
  1527. foreach($fieldArr as $key => $value) {
  1528. $isSingle = isset($value['type']);
  1529. if ($isSingle) { $value = array($value); }
  1530. $tmpField = '';
  1531. $sizeLg = max(floor(12/count($value)),2);
  1532. $sizeMd = max(floor(($isSingle?12:6)/count($value)),3);
  1533. foreach($value as $k => $v) {
  1534. $tmpField .= buildField($v, 12, $sizeMd, $sizeLg);
  1535. }
  1536. $fields .= ($isSingle?$tmpField:'<div class="row col-sm-12 content-form">'.$tmpField.'</div>');
  1537. }
  1538. $fields .= '</div>';
  1539. return $fields;
  1540. };
  1541. $fields = (isset($array['fields'])?$fieldFunc($array['fields']):'');
  1542. $tabSelectors = array();
  1543. $tabContent = array();
  1544. if (isset($array['tabs'])) {
  1545. foreach($array['tabs'] as $key => $value) {
  1546. $id = (isset($value['id'])?$value['id']:randString(32));
  1547. $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>';
  1548. $tabContent[$key] = '<div class="tab-pane big-box fade'.($tabContent?'':' active in').'" id="tab-'.$id.'">'.$fieldFunc($value['fields']).'</div>';
  1549. }
  1550. }
  1551. $pageID = (isset($array['id'])?$array['id']:str_replace(array(' ','"',"'"),array('_'),strtolower($array['id'])));
  1552. return '
  1553. <div class="email-body">
  1554. <div class="email-header gray-bg">
  1555. <button type="button" class="btn btn-danger btn-sm waves close-button"><i class="fa fa-close"></i></button>
  1556. <h1>'.$array['title'].'</h1>
  1557. </div>
  1558. <div class="email-inner small-box">
  1559. <div class="email-inner-section">
  1560. <div class="small-box fade in" id="'.$pageID.'_frame">
  1561. <div class="col-lg-12">
  1562. '.(isset($array['customBeforeForm'])?$array['customBeforeForm']:'').'
  1563. <form class="content-form" name="'.$pageID.'" id="'.$pageID.'_form" onsubmit="return false;">
  1564. <button id="'.$pageID.'_form_submit" class="btn waves btn-labeled btn-success btn btn-sm pull-right text-uppercase waves-effect waves-float">
  1565. <span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save
  1566. </button>
  1567. '.$fields.($tabContent?'
  1568. <div class="tabbable tabs-with-bg" id="'.$pageID.'_tabs">
  1569. <ul class="nav nav-tabs apps">
  1570. '.implode('', $tabSelectors).'
  1571. </ul>
  1572. <div class="clearfix"></div>
  1573. <div class="tab-content">
  1574. '.implode('', $tabContent).'
  1575. </div>
  1576. </div>':'').'
  1577. </form>
  1578. '.(isset($array['customAfterForm'])?$array['customAfterForm']:'').'
  1579. </div>
  1580. </div>
  1581. </div>
  1582. </div>
  1583. </div>
  1584. <script>
  1585. $(document).ready(function() {
  1586. $(\'#'.$pageID.'_form\').find(\'input, select, textarea\').on(\'change\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1587. var '.$pageID.'Validate = function() { if (this.value && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { $(this).addClass(\'invalid\'); } else { $(this).removeClass(\'invalid\'); } };
  1588. $(\'#'.$pageID.'_form\').find(\'input[pattern]\').each('.$pageID.'Validate).on(\'keyup\', '.$pageID.'Validate);
  1589. $(\'#'.$pageID.'_form\').find(\'select[multiple]\').on(\'change click\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1590. $(\'#'.$pageID.'_form_submit\').on(\'click\', function () {
  1591. var newVals = {};
  1592. var hasVals = false;
  1593. var errorFields = [];
  1594. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').each(function() {
  1595. hasVals = true;
  1596. if (this.type == \'checkbox\') {
  1597. newVals[this.name] = this.checked;
  1598. } else if ($(this).hasClass(\'summernote\')) {
  1599. newVals[$(this).attr(\'name\')] = $(this).siblings(\'.note-editor\').find(\'.panel-body\').html();
  1600. } else {
  1601. if (this.value && this.pattern && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { errorFields.push(this.name); }
  1602. var fieldVal = $(this).val();
  1603. if (typeof fieldVal == \'object\') {
  1604. if (typeof fieldVal.join == \'function\') {
  1605. fieldVal = fieldVal.join(\'|\');
  1606. } else {
  1607. fieldVal = JSON.stringify(fieldVal);
  1608. }
  1609. }
  1610. newVals[this.name] = fieldVal;
  1611. }
  1612. });
  1613. if (errorFields.length) {
  1614. parent.notify(\'Fields have errors: \'+errorFields.join(\', \')+\'!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1615. } else if (hasVals) {
  1616. console.log(newVals);
  1617. ajax_request(\'POST\', \''.(isset($array['submitAction'])?$array['submitAction']:'update-config').'\', newVals, function(data, code) {
  1618. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').removeAttr(\'data-changed\');
  1619. });
  1620. } else {
  1621. parent.notify(\'Nothing to update!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1622. }
  1623. return false;
  1624. });
  1625. '.(isset($array['onready'])?$array['onready']:'').'
  1626. });
  1627. </script>
  1628. ';
  1629. }
  1630. // Build Settings Fields
  1631. function buildField($params, $sizeSm = 12, $sizeMd = 12, $sizeLg = 12) {
  1632. /*
  1633. array(
  1634. 'type' => '',
  1635. 'placeholder' => '',
  1636. 'label' => '',
  1637. 'labelTranslate' => '',
  1638. 'assist' => '',
  1639. 'name' => '',
  1640. 'pattern' => '',
  1641. 'options' => array( // For SELECT only
  1642. 'Display' => 'value',
  1643. ),
  1644. )
  1645. */
  1646. // Tags
  1647. $tags = array();
  1648. foreach(array('placeholder','style','disabled','readonly','pattern','min','max','required','onkeypress','onchange','onfocus','onleave','href','onclick') as $value) {
  1649. if (isset($params[$value])) {
  1650. if (is_string($params[$value])) { $tags[] = $value.'="'.$params[$value].'"';
  1651. } else if ($params[$value] === true) { $tags[] = $value; }
  1652. }
  1653. }
  1654. $format = (isset($params['format']) && in_array($params['format'],array(false,'colour','color'))?$params['format']:false);
  1655. $name = (isset($params['name'])?$params['name']:(isset($params['id'])?$params['id']:''));
  1656. $id = (isset($params['id'])?$params['id']:(isset($params['name'])?$params['name'].'_id':randString(32)));
  1657. $val = (isset($params['value'])?$params['value']:'');
  1658. $class = (isset($params['class'])?' '.$params['class']:'');
  1659. $wrapClass = (isset($params['wrapClass'])?$params['wrapClass']:'form-content');
  1660. $assist = (isset($params['assist'])?' - i.e. '.$params['assist']:'');
  1661. $label = (isset($params['labelTranslate'])?translate($params['labelTranslate']):(isset($params['label'])?$params['label']:''));
  1662. $labelOut = '<p class="help-text">'.$label.$assist.'</p>';
  1663. // Field Design
  1664. switch ($params['type']) {
  1665. case 'text':
  1666. case 'number':
  1667. case 'password':
  1668. $field = '<input id="'.$id.'" name="'.$name.'" type="'.$params['type'].'" class="form-control material input-sm'.$class.'" '.implode(' ',$tags).' autocorrect="off" autocapitalize="off" value="'.$val.'">';
  1669. break;
  1670. case 'select':
  1671. case 'dropdown':
  1672. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control material input-sm" '.implode(' ',$tags).'>'.resolveSelectOptions($params['options'], $val).'</select>';
  1673. break;
  1674. case 'select-multi':
  1675. case 'dropdown-multi':
  1676. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control input-sm" '.implode(' ',$tags).' multiple="multiple">'.resolveSelectOptions($params['options'], $val, true).'</select>';
  1677. break;
  1678. case 'check':
  1679. case 'checkbox':
  1680. case 'toggle':
  1681. $checked = ((is_bool($val) && $val) || trim($val) === 'true'?' checked':'');
  1682. $colour = (isset($params['colour'])?$params['colour']:'success');
  1683. $labelOut = '<label for="'.$id.'"></label>'.$label;
  1684. $field = '<input id="'.$id.'" name="'.$name.'" type="checkbox" class="switcher switcher-'.$colour.' '.$class.'" '.implode(' ',$tags).' data-value="'.$val.'"'.$checked.'>';
  1685. break;
  1686. case 'radio':
  1687. $labelOut = '';
  1688. $checked = ((is_bool($val) && $val) || ($val && trim($val) !== 'false')?' checked':'');
  1689. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1690. $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>';
  1691. break;
  1692. case 'date':
  1693. $field = 'Unsupported, planned.';
  1694. break;
  1695. case 'hidden':
  1696. return '<input id="'.$id.'" name="'.$name.'" type="hidden" class="'.$class.'" '.implode(' ',$tags).' value="'.$val.'">';
  1697. break;
  1698. case 'header':
  1699. $labelOut = '';
  1700. $headType = (isset($params['value'])?$params['value']:3);
  1701. $field = '<h'.$headType.' class="'.$class.'" '.implode(' ',$tags).'>'.$label.'</h'.$headType.'>';
  1702. break;
  1703. case 'button':
  1704. $labelOut = '';
  1705. $icon = (isset($params['icon'])?$params['icon']:'flask');
  1706. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1707. $bDropdown = (isset($params['buttonDrop'])?$params['buttonDrop']:'');
  1708. $field = ($bDropdown?'<div class="btn-group">':'').'<button id="'.$id.'" type="button" class="btn waves btn-labeled btn-'.$bType.' btn-sm text-uppercase waves-effect waves-float'.$class.''.($bDropdown?' dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"':'"').' '.implode(' ',$tags).'><span class="btn-label"><i class="fa fa-'.$icon.'"></i></span>'.$label.'</button>'.($bDropdown?$bDropdown.'</div>':'');
  1709. break;
  1710. case 'textarea':
  1711. $rows = (isset($params['rows'])?$params['rows']:5);
  1712. $field = '<textarea id="'.$id.'" name="'.$name.'" class="form-control'.$class.'" rows="'.$rows.'" '.implode(' ',$tags).'>'.$val.'</textarea>';
  1713. break;
  1714. case 'custom':
  1715. // Settings
  1716. $settings = array(
  1717. '$id' => $id,
  1718. '$name' => $name,
  1719. '$val' => $val,
  1720. '$label' => $label,
  1721. '$labelOut' => $labelOut,
  1722. );
  1723. // Get HTML
  1724. $html = (isset($params['html'])?$params['html']:'Nothing Specified!');
  1725. // If LabelOut is in html dont print it twice
  1726. $labelOut = (strpos($html,'$label')!==false?'':$labelOut);
  1727. // Replace variables in settings
  1728. $html = preg_replace_callback('/\$\w+\b/', function ($match) use ($settings) { return (isset($settings[$match[0]])?$settings[$match[0]]:'{'.$match[0].' is undefined}'); }, $html);
  1729. // Build Field
  1730. $field = '<div id="'.$id.'_html" class="custom-field">'.$html.'</div>';
  1731. break;
  1732. case 'space':
  1733. $labelOut = '';
  1734. $field = str_repeat('<br>', (isset($params['value'])?$params['value']:1));
  1735. break;
  1736. default:
  1737. $field = 'Unsupported field type';
  1738. break;
  1739. }
  1740. // Field Formats
  1741. switch ($format) {
  1742. case 'colour': // Fuckin Eh, Canada!
  1743. case 'color':
  1744. $labelBef = '<center>'.$label.'</center>';
  1745. $wrapClass = 'gray-bg colour-field';
  1746. $labelAft = '';
  1747. $field = str_replace(' material input-sm','',$field);
  1748. break;
  1749. default:
  1750. $labelBef = '';
  1751. $labelAft = $labelOut;
  1752. }
  1753. return '<div class="'.$wrapClass.' col-sm-'.$sizeSm.' col-md-'.$sizeMd.' col-lg-'.$sizeLg.'">'.$labelBef.$field.$labelAft.'</div>';
  1754. }
  1755. // Tab Settings Generation
  1756. function printTabRow($data) {
  1757. $hidden = false;
  1758. if ($data===false) {
  1759. $hidden = true;
  1760. $data = array( // New Tab Defaults
  1761. 'id' => 'new',
  1762. 'name' => '',
  1763. 'url' => '',
  1764. 'icon' => 'fa-diamond',
  1765. 'iconurl' => '',
  1766. 'active' => 'true',
  1767. 'user' => 'true',
  1768. 'guest' => 'true',
  1769. 'window' => 'false',
  1770. 'splash' => 'true',
  1771. 'ping' => 'false',
  1772. 'ping_url' => '',
  1773. 'defaultz' => '',
  1774. );
  1775. }
  1776. $image = '<span style="font: normal normal normal 30px/1 FontAwesome;" class="fa fa-hand-paper-o"></span>';
  1777. $output = '
  1778. <li id="tab-'.$data['id'].'" class="list-group-item" style="position: relative; left: 0px; top: 0px; '.($hidden?' display: none;':'').'">
  1779. <tab class="content-form form-inline">
  1780. <div class="row">
  1781. '.buildField(array(
  1782. 'type' => 'custom',
  1783. '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>',
  1784. ),12,1,1).'
  1785. '.buildField(array(
  1786. 'type' => 'hidden',
  1787. 'id' => 'tab-'.$data['id'].'-id',
  1788. 'name' => 'id['.$data['id'].']',
  1789. 'value' => $data['id'],
  1790. ),12,2,1).'
  1791. '.buildField(array(
  1792. 'type' => 'text',
  1793. 'id' => 'tab-'.$data['id'].'-name',
  1794. 'name' => 'name['.$data['id'].']',
  1795. 'required' => true,
  1796. 'placeholder' => 'Organizr Homepage',
  1797. 'labelTranslate' => 'TAB_NAME',
  1798. 'value' => $data['name'],
  1799. ),12,2,1).'
  1800. '.buildField(array(
  1801. 'type' => 'text',
  1802. 'id' => 'tab-'.$data['id'].'-url',
  1803. 'name' => 'url['.$data['id'].']',
  1804. 'required' => true,
  1805. 'placeholder' => 'homepage.php',
  1806. 'labelTranslate' => 'TAB_URL',
  1807. 'value' => $data['url'],
  1808. ),12,2,1).'
  1809. '.buildField(array(
  1810. 'type' => 'text',
  1811. 'id' => 'tab-'.$data['id'].'-iconurl',
  1812. 'name' => 'iconurl['.$data['id'].']',
  1813. 'placeholder' => 'images/organizr.png',
  1814. 'labelTranslate' => 'ICON_URL',
  1815. 'value' => $data['iconurl'],
  1816. ),12,2,1).'
  1817. '.buildField(array(
  1818. 'type' => 'custom',
  1819. 'id' => 'tab-'.$data['id'].'-icon',
  1820. 'name' => 'icon['.$data['id'].']',
  1821. 'html' => '- '.translate('OR').' - <div class="input-group"><input data-placement="bottomRight" class="form-control material icp-auto'.($hidden?'-pend':'').'" id="$id" name="$name" value="$val" type="text" /><span class="input-group-addon"></span></div>',
  1822. 'value' => $data['icon'],
  1823. ),12,1,1).'
  1824. '.buildField(array(
  1825. 'type' => 'text',
  1826. 'id' => 'tab-'.$data['id'].'-ping_url',
  1827. 'name' => 'ping_url['.$data['id'].']',
  1828. 'placeholder' => 'host:port',
  1829. 'labelTranslate' => 'PING_URL',
  1830. 'value' => $data['ping_url'],
  1831. ),12,2,1).'
  1832. '.buildField(array(
  1833. 'type' => 'radio',
  1834. 'labelTranslate' => 'DEFAULT',
  1835. 'name' => 'defaultz['.$data['id'].']',
  1836. 'value' => $data['defaultz'],
  1837. 'onclick' => "$('[type=radio][id!=\''+this.id+'\']').each(function() { this.checked=false; });",
  1838. ),12,1,1).'
  1839. '.buildField(array(
  1840. 'type' => 'button',
  1841. 'icon' => 'caret-square-o-down',
  1842. 'buttonType' => 'success',
  1843. 'labelTranslate' => 'MORE',
  1844. 'onclick' => "$('#tab-".$data['id']."-row').toggle();",
  1845. ),12,1,1).'
  1846. '.buildField(array(
  1847. 'type' => 'button',
  1848. 'icon' => 'trash',
  1849. 'buttonType' => 'danger',
  1850. 'labelTranslate' => 'REMOVE',
  1851. 'onclick' => "$(this).parents('li').remove();",
  1852. ),12,1,1).'</div><div id = "tab-'.$data['id'].'-row" class = "row animated slideInUp" style = "display:none;" ><div></div>
  1853. '.buildField(array(
  1854. 'type' => 'checkbox',
  1855. 'labelTranslate' => 'ACTIVE',
  1856. 'name' => 'active['.$data['id'].']',
  1857. 'value' => $data['active'],
  1858. ),12,1,1).'
  1859. '.buildField(array(
  1860. 'type' => 'checkbox',
  1861. 'labelTranslate' => 'USER',
  1862. 'colour' => 'primary',
  1863. 'name' => 'user['.$data['id'].']',
  1864. 'value' => $data['user'],
  1865. ),12,1,1).'
  1866. '.buildField(array(
  1867. 'type' => 'checkbox',
  1868. 'labelTranslate' => 'GUEST',
  1869. 'colour' => 'warning',
  1870. 'name' => 'guest['.$data['id'].']',
  1871. 'value' => $data['guest'],
  1872. ),12,1,1).'
  1873. '.buildField(array(
  1874. 'type' => 'checkbox',
  1875. 'labelTranslate' => 'NO_IFRAME',
  1876. 'colour' => 'danger',
  1877. 'name' => 'window['.$data['id'].']',
  1878. 'value' => $data['window'],
  1879. ),12,1,1).'
  1880. '.buildField(array(
  1881. 'type' => 'checkbox',
  1882. 'labelTranslate' => 'SPLASH',
  1883. 'colour' => 'success',
  1884. 'name' => 'splash['.$data['id'].']',
  1885. 'value' => $data['splash'],
  1886. ),12,1,1).'
  1887. '.buildField(array(
  1888. 'type' => 'checkbox',
  1889. 'labelTranslate' => 'PING',
  1890. 'colour' => 'success',
  1891. 'name' => 'ping['.$data['id'].']',
  1892. 'value' => $data['ping'],
  1893. ),12,1,1).'
  1894. </div>
  1895. </tab>
  1896. </li>
  1897. ';
  1898. return $output;
  1899. }
  1900. // Timezone array
  1901. function timezoneOptions() {
  1902. $output = array();
  1903. $timezones = array();
  1904. $regions = array(
  1905. 'Africa' => DateTimeZone::AFRICA,
  1906. 'America' => DateTimeZone::AMERICA,
  1907. 'Antarctica' => DateTimeZone::ANTARCTICA,
  1908. 'Arctic' => DateTimeZone::ARCTIC,
  1909. 'Asia' => DateTimeZone::ASIA,
  1910. 'Atlantic' => DateTimeZone::ATLANTIC,
  1911. 'Australia' => DateTimeZone::AUSTRALIA,
  1912. 'Europe' => DateTimeZone::EUROPE,
  1913. 'Indian' => DateTimeZone::INDIAN,
  1914. 'Pacific' => DateTimeZone::PACIFIC
  1915. );
  1916. foreach ($regions as $name => $mask) {
  1917. $zones = DateTimeZone::listIdentifiers($mask);
  1918. foreach($zones as $timezone) {
  1919. $time = new DateTime(NULL, new DateTimeZone($timezone));
  1920. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  1921. $output[$name]['optgroup'][substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm]['value'] = $timezone;
  1922. }
  1923. }
  1924. return $output;
  1925. }
  1926. // Build Database
  1927. function createSQLiteDB($path = false) {
  1928. if ($path === false) {
  1929. if (DATABASE_LOCATION){
  1930. $path = DATABASE_LOCATION;
  1931. } else {
  1932. debug_out('No Path Specified!');
  1933. }
  1934. }
  1935. if (!is_file($path.'users.db') || filesize($path.'users.db') <= 0) {
  1936. if (!isset($GLOBALS['file_db'])) {
  1937. $GLOBALS['file_db'] = new PDO('sqlite:'.$path.'users.db');
  1938. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  1939. }
  1940. // Create Users
  1941. $users = $GLOBALS['file_db']->query('CREATE TABLE `users` (
  1942. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  1943. `username` TEXT UNIQUE,
  1944. `password` TEXT,
  1945. `email` TEXT,
  1946. `token` TEXT,
  1947. `role` TEXT,
  1948. `active` TEXT,
  1949. `last` TEXT,
  1950. `auth_service` TEXT DEFAULT \'internal\'
  1951. );');
  1952. // Create Tabs
  1953. $tabs = $GLOBALS['file_db']->query('CREATE TABLE `tabs` (
  1954. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  1955. `order` INTEGER,
  1956. `users_id` INTEGER,
  1957. `name` TEXT,
  1958. `url` TEXT,
  1959. `defaultz` TEXT,
  1960. `active` TEXT,
  1961. `user` TEXT,
  1962. `guest` TEXT,
  1963. `icon` TEXT,
  1964. `iconurl` TEXT,
  1965. `window` TEXT,
  1966. `splash` TEXT,
  1967. `ping` TEXT,
  1968. `ping_url` TEXT
  1969. );');
  1970. // Create Options
  1971. $options = $GLOBALS['file_db']->query('CREATE TABLE `options` (
  1972. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  1973. `users_id` INTEGER UNIQUE,
  1974. `title` TEXT UNIQUE,
  1975. `topbar` TEXT,
  1976. `bottombar` TEXT,
  1977. `sidebar` TEXT,
  1978. `hoverbg` TEXT,
  1979. `topbartext` TEXT,
  1980. `activetabBG` TEXT,
  1981. `activetabicon` TEXT,
  1982. `activetabtext` TEXT,
  1983. `inactiveicon` TEXT,
  1984. `inactivetext` TEXT,
  1985. `loading` TEXT,
  1986. `hovertext` TEXT
  1987. );');
  1988. // Create Invites
  1989. $invites = $GLOBALS['file_db']->query('CREATE TABLE `invites` (
  1990. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  1991. `code` TEXT UNIQUE,
  1992. `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  1993. `email` TEXT,
  1994. `username` TEXT,
  1995. `dateused` TIMESTAMP,
  1996. `usedby` TEXT,
  1997. `ip` TEXT,
  1998. `valid` TEXT
  1999. );');
  2000. writeLog("success", "database created/saved");
  2001. return $users && $tabs && $options && $invites;
  2002. } else {
  2003. writeLog("error", "database was unable to be created/saved");
  2004. return false;
  2005. }
  2006. }
  2007. // Upgrade Database
  2008. function updateSQLiteDB($db_path = false, $oldVerNum = false) {
  2009. if (!$db_path) {
  2010. if (defined('DATABASE_LOCATION')) {
  2011. $db_path = DATABASE_LOCATION;
  2012. } else {
  2013. debug_out('No Path Specified',1);
  2014. }
  2015. }
  2016. if (!isset($GLOBALS['file_db'])) {
  2017. $GLOBALS['file_db'] = new PDO('sqlite:'.$db_path.'users.db');
  2018. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2019. }
  2020. // Cache current DB
  2021. $cache = array();
  2022. foreach($GLOBALS['file_db']->query('SELECT name FROM sqlite_master WHERE type="table";') as $table) {
  2023. foreach($GLOBALS['file_db']->query('SELECT * FROM '.$table['name'].';') as $key => $row) {
  2024. foreach($row as $k => $v) {
  2025. if (is_string($k)) {
  2026. $cache[$table['name']][$key][$k] = $v;
  2027. }
  2028. }
  2029. }
  2030. }
  2031. // Remove Current Database
  2032. $GLOBALS['file_db'] = null;
  2033. $pathDigest = pathinfo($db_path.'users.db');
  2034. if (file_exists($db_path.'users.db')) {
  2035. rename($db_path.'users.db', $pathDigest['dirname'].'/'.$pathDigest['filename'].'['.date('Y-m-d_H-i-s').']'.($oldVerNum?'['.$oldVerNum.']':'').'.bak.db');
  2036. }
  2037. // Create New Database
  2038. $success = createSQLiteDB($db_path);
  2039. // Restore Items
  2040. if ($success) {
  2041. foreach($cache as $table => $tableData) {
  2042. if ($tableData) {
  2043. $queryBase = 'INSERT INTO '.$table.' (`'.implode('`,`',array_keys(current($tableData))).'`) values ';
  2044. $insertValues = array();
  2045. reset($tableData);
  2046. foreach($tableData as $key => $value) {
  2047. $insertValues[] = '('.implode(',',array_map(function($d) {
  2048. return (isset($d)?$GLOBALS['file_db']->quote($d):'null');
  2049. }, $value)).')';
  2050. }
  2051. $GLOBALS['file_db']->query($queryBase.implode(',',$insertValues).';');
  2052. }
  2053. }
  2054. writeLog("success", "database values have been updated");
  2055. return true;
  2056. } else {
  2057. writeLog("error", "database values unable to be updated");
  2058. return false;
  2059. }
  2060. }
  2061. // Commit colours to database
  2062. function updateDBOptions($values) {
  2063. if (!isset($GLOBALS['file_db'])) {
  2064. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2065. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2066. }
  2067. // Commit new values to database
  2068. if ($GLOBALS['file_db']->query('UPDATE options SET '.implode(',',array_map(function($d, $k) {
  2069. return '`'.$k.'` = '.(isset($d)?"'".addslashes($d)."'":'null');
  2070. }, $values, array_keys($values))).';')->rowCount()) {
  2071. return true;
  2072. } else if ($GLOBALS['file_db']->query('INSERT OR IGNORE INTO options (`'.implode('`,`',array_keys($values)).'`) VALUES (\''.implode("','",$values).'\');')->rowCount()) {
  2073. writeLog("success", "database values for options table have been updated");
  2074. return true;
  2075. } else {
  2076. writeLog("error", "database values for options table unable to be updated");
  2077. return false;
  2078. }
  2079. }
  2080. // Send AJAX notification
  2081. function sendNotification($success, $message = false, $send = true) {
  2082. $notifyExplode = explode("-", NOTIFYEFFECT);
  2083. if ($success) {
  2084. $msg = array(
  2085. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_SAVED").'</strong>'),
  2086. 'icon' => 'floppy-o',
  2087. 'type' => 'success',
  2088. 'length' => '5000',
  2089. 'layout' => $notifyExplode[0],
  2090. 'effect' => $notifyExplode[1],
  2091. );
  2092. } else {
  2093. $msg = array(
  2094. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_NOT_SAVED").'</strong>'),
  2095. 'icon' => 'floppy-o',
  2096. 'type' => 'failed',
  2097. 'length' => '5000',
  2098. 'layout' => $notifyExplode[0],
  2099. 'effect' => $notifyExplode[1],
  2100. );
  2101. }
  2102. // Send and kill script?
  2103. if ($send) {
  2104. header('Content-Type: application/json');
  2105. echo json_encode(array('notify'=>$msg));
  2106. die();
  2107. }
  2108. return $msg;
  2109. }
  2110. // Load colours from the database
  2111. function loadAppearance() {
  2112. // Defaults
  2113. $defaults = array(
  2114. 'title' => 'Organizr',
  2115. 'topbartext' => '#66D9EF',
  2116. 'topbar' => '#333333',
  2117. 'bottombar' => '#333333',
  2118. 'sidebar' => '#393939',
  2119. 'hoverbg' => '#AD80FD',
  2120. 'activetabBG' => '#F92671',
  2121. 'activetabicon' => '#FFFFFF',
  2122. 'activetabtext' => '#FFFFFF',
  2123. 'inactiveicon' => '#66D9EF',
  2124. 'inactivetext' => '#66D9EF',
  2125. 'loading' => '#66D9EF',
  2126. 'hovertext' => '#000000',
  2127. );
  2128. if (DATABASE_LOCATION) {
  2129. if(is_file(DATABASE_LOCATION.'users.db') && filesize(DATABASE_LOCATION.'users.db') > 0){
  2130. if (!isset($GLOBALS['file_db'])) {
  2131. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2132. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2133. }
  2134. // Database Lookup
  2135. $options = $GLOBALS['file_db']->query('SELECT * FROM options');
  2136. // Replace defaults with filled options
  2137. foreach($options as $row) {
  2138. foreach($defaults as $key => $value) {
  2139. if (isset($row[$key]) && $row[$key]) {
  2140. $defaults[$key] = $row[$key];
  2141. }
  2142. }
  2143. }
  2144. }
  2145. }
  2146. // Return the Results
  2147. return $defaults;
  2148. }
  2149. // Delete Database
  2150. function deleteDatabase() {
  2151. unset($_COOKIE['Organizr']);
  2152. setcookie('Organizr', '', time() - 3600, '/');
  2153. unset($_COOKIE['OrganizrU']);
  2154. setcookie('OrganizrU', '', time() - 3600, '/');
  2155. $GLOBALS['file_db'] = null;
  2156. unlink(DATABASE_LOCATION.'users.db');
  2157. foreach(glob(substr_replace($userdirpath, "", -1).'/*') as $file) {
  2158. if(is_dir($file)) {
  2159. rmdir($file);
  2160. } elseif (!is_dir($file)) {
  2161. unlink($file);
  2162. }
  2163. }
  2164. rmdir($userdirpath);
  2165. writeLog("success", "database has been deleted");
  2166. return true;
  2167. }
  2168. // Upgrade the installation
  2169. function upgradeInstall($branch = 'master') {
  2170. function downloadFile($url, $path){
  2171. ini_set('max_execution_time',0);
  2172. $folderPath = "upgrade/";
  2173. if(!mkdir($folderPath)){
  2174. writeLog("error", "organizr could not create upgrade folder");
  2175. }
  2176. $newfname = $folderPath . $path;
  2177. $file = fopen ($url, 'rb');
  2178. if ($file) {
  2179. $newf = fopen ($newfname, 'wb');
  2180. if ($newf) {
  2181. while(!feof($file)) {
  2182. fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
  2183. }
  2184. }
  2185. }else{
  2186. writeLog("error", "organizr could not download $url");
  2187. }
  2188. if ($file) {
  2189. fclose($file);
  2190. writeLog("success", "organizr finished downloading the github zip file");
  2191. }else{
  2192. writeLog("error", "organizr could not download the github zip file");
  2193. }
  2194. if ($newf) {
  2195. fclose($newf);
  2196. writeLog("success", "organizr created upgrade zip file from github zip file");
  2197. }else{
  2198. writeLog("error", "organizr could not create upgrade zip file from github zip file");
  2199. }
  2200. }
  2201. function unzipFile($zipFile){
  2202. $zip = new ZipArchive;
  2203. $extractPath = "upgrade/";
  2204. if($zip->open($extractPath . $zipFile) != "true"){
  2205. writeLog("error", "organizr could not unzip upgrade.zip");
  2206. }else{
  2207. writeLog("success", "organizr unzipped upgrade.zip");
  2208. }
  2209. /* Extract Zip File */
  2210. $zip->extractTo($extractPath);
  2211. $zip->close();
  2212. }
  2213. // Function to remove folders and files
  2214. function rrmdir($dir) {
  2215. if (is_dir($dir)) {
  2216. $files = scandir($dir);
  2217. foreach ($files as $file)
  2218. if ($file != "." && $file != "..") rrmdir("$dir/$file");
  2219. rmdir($dir);
  2220. }
  2221. else if (file_exists($dir)) unlink($dir);
  2222. }
  2223. // Function to Copy folders and files
  2224. function rcopy($src, $dst) {
  2225. if (is_dir ( $src )) {
  2226. if (!file_exists($dst)) : mkdir ( $dst ); endif;
  2227. $files = scandir ( $src );
  2228. foreach ( $files as $file )
  2229. if ($file != "." && $file != "..")
  2230. rcopy ( "$src/$file", "$dst/$file" );
  2231. } else if (file_exists ( $src ))
  2232. copy ( $src, $dst );
  2233. }
  2234. $url = 'https://github.com/causefx/Organizr/archive/'.$branch.'.zip';
  2235. $file = "upgrade.zip";
  2236. $source = __DIR__ . '/upgrade/Organizr-'.$branch.'/';
  2237. $cleanup = __DIR__ . "/upgrade/";
  2238. $destination = __DIR__ . "/";
  2239. writeLog("success", "starting organizr upgrade process");
  2240. downloadFile($url, $file);
  2241. unzipFile($file);
  2242. rcopy($source, $destination);
  2243. writeLog("success", "new organizr files copied");
  2244. rrmdir($cleanup);
  2245. writeLog("success", "organizr upgrade folder removed");
  2246. writeLog("success", "organizr has been updated");
  2247. return true;
  2248. }
  2249. // NzbGET Items
  2250. function nzbgetConnect($list = 'listgroups') {
  2251. $url = qualifyURL(NZBGETURL);
  2252. $api = curl_get($url.'/'.NZBGETUSERNAME.':'.NZBGETPASSWORD.'/jsonrpc/'.$list);
  2253. $api = json_decode($api, true);
  2254. $gotNZB = array();
  2255. if (is_array($api) || is_object($api)){
  2256. foreach ($api['result'] AS $child) {
  2257. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  2258. $downloadStatus = $child['Status'];
  2259. $downloadCategory = $child['Category'];
  2260. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  2261. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  2262. if($child['Health'] <= "750"){
  2263. $downloadHealth = "danger";
  2264. }elseif($child['Health'] <= "900"){
  2265. $downloadHealth = "warning";
  2266. }elseif($child['Health'] <= "1000"){
  2267. $downloadHealth = "success";
  2268. }
  2269. $gotNZB[] = '<tr>
  2270. <td class="col-xs-7 nzbtable-file-row">'.$downloadName.'</td>
  2271. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2272. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2273. <td class="col-xs-2 nzbtable nzbtable-row">
  2274. <div class="progress">
  2275. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2276. <p class="text-center">'.round($downloadPercent).'%</p>
  2277. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2278. </div>
  2279. </div>
  2280. </td>
  2281. </tr>';
  2282. }
  2283. if ($gotNZB) {
  2284. return implode('',$gotNZB);
  2285. } else {
  2286. return '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>';
  2287. }
  2288. }else{
  2289. writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Usernamd and Password - if HTTPS, is cert valid");
  2290. }
  2291. }
  2292. // Sabnzbd Items
  2293. function sabnzbdConnect($list = 'queue') {
  2294. $url = qualifyURL(SABNZBDURL);
  2295. $api = file_get_contents($url.'/api?mode='.$list.'&output=json&apikey='.SABNZBDKEY);
  2296. $api = json_decode($api, true);
  2297. $gotNZB = array();
  2298. foreach ($api[$list]['slots'] AS $child) {
  2299. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  2300. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  2301. $downloadStatus = $child['status'];
  2302. $gotNZB[] = '<tr>
  2303. <td class="col-xs-7 nzbtable-file-row">'.$downloadName.'</td>
  2304. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2305. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2306. <td class="col-xs-2 nzbtable nzbtable-row">
  2307. <div class="progress">
  2308. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2309. <p class="text-center">'.round($downloadPercent).'%</p>
  2310. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2311. </div>
  2312. </div>
  2313. </td>
  2314. </tr>';
  2315. }
  2316. if ($gotNZB) {
  2317. return implode('',$gotNZB);
  2318. } else {
  2319. return '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>';
  2320. }
  2321. }
  2322. // Apply new tab settings
  2323. function updateTabs($tabs) {
  2324. if (!isset($GLOBALS['file_db'])) {
  2325. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2326. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2327. }
  2328. // Validate
  2329. if (!isset($tabs['defaultz'])) { $tabs['defaultz'][current(array_keys($tabs['name']))] = 'true'; }
  2330. if (isset($tabs['name']) && isset($tabs['url']) && is_array($tabs['name'])) {
  2331. // Clear Existing Tabs
  2332. $GLOBALS['file_db']->query("DELETE FROM tabs");
  2333. // Process New Tabs
  2334. $totalValid = 0;
  2335. foreach ($tabs['name'] as $key => $value) {
  2336. // Qualify
  2337. if (!$value || !isset($tabs['url']) || !$tabs['url'][$key]) { continue; }
  2338. $totalValid++;
  2339. $fields = array();
  2340. foreach(array('id','name','url','icon','iconurl','order','ping_url') as $v) {
  2341. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = $tabs[$v][$key]; }
  2342. }
  2343. foreach(array('active','user','guest','defaultz','window','splash','ping') as $v) {
  2344. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = ($tabs[$v][$key]!=='false'?'true':'false'); }
  2345. }
  2346. $GLOBALS['file_db']->query('INSERT INTO tabs (`'.implode('`,`',array_keys($fields)).'`) VALUES (\''.implode("','",$fields).'\');');
  2347. }
  2348. writeLog("success", "tabs successfully saved");
  2349. return $totalValid;
  2350. } else {
  2351. writeLog("error", "tabs could not save");
  2352. return false;
  2353. }
  2354. writeLog("error", "tabs could not save");
  2355. return false;
  2356. }
  2357. // ==============
  2358. function clean($strin) {
  2359. $strout = null;
  2360. for ($i = 0; $i < strlen($strin); $i++) {
  2361. $ord = ord($strin[$i]);
  2362. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  2363. $strout .= "&amp;#{$ord};";
  2364. }
  2365. else {
  2366. switch ($strin[$i]) {
  2367. case '<':
  2368. $strout .= '&lt;';
  2369. break;
  2370. case '>':
  2371. $strout .= '&gt;';
  2372. break;
  2373. case '&':
  2374. $strout .= '&amp;';
  2375. break;
  2376. case '"':
  2377. $strout .= '&quot;';
  2378. break;
  2379. default:
  2380. $strout .= $strin[$i];
  2381. }
  2382. }
  2383. }
  2384. return $strout;
  2385. }
  2386. function registration_callback($username, $email, $userdir){
  2387. global $data;
  2388. $data = array($username, $email, $userdir);
  2389. }
  2390. function printArray($arrayName){
  2391. $messageCount = count($arrayName);
  2392. $i = 0;
  2393. foreach ( $arrayName as $item ) :
  2394. $i++;
  2395. if($i < $messageCount) :
  2396. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  2397. elseif($i = $messageCount) :
  2398. echo "<small class='text-uppercase'>" . $item . "</small>";
  2399. endif;
  2400. endforeach;
  2401. }
  2402. function write_ini_file($content, $path) {
  2403. if (!$handle = fopen($path, 'w')) {
  2404. return false;
  2405. }
  2406. $success = fwrite($handle, trim($content));
  2407. fclose($handle);
  2408. return $success;
  2409. }
  2410. function gotTimezone(){
  2411. $regions = array(
  2412. 'Africa' => DateTimeZone::AFRICA,
  2413. 'America' => DateTimeZone::AMERICA,
  2414. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2415. 'Arctic' => DateTimeZone::ARCTIC,
  2416. 'Asia' => DateTimeZone::ASIA,
  2417. 'Atlantic' => DateTimeZone::ATLANTIC,
  2418. 'Australia' => DateTimeZone::AUSTRALIA,
  2419. 'Europe' => DateTimeZone::EUROPE,
  2420. 'Indian' => DateTimeZone::INDIAN,
  2421. 'Pacific' => DateTimeZone::PACIFIC
  2422. );
  2423. $timezones = array();
  2424. foreach ($regions as $name => $mask) {
  2425. $zones = DateTimeZone::listIdentifiers($mask);
  2426. foreach($zones as $timezone) {
  2427. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2428. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2429. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2430. }
  2431. }
  2432. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  2433. foreach($timezones as $region => $list) {
  2434. print '<optgroup label="' . $region . '">' . "\n";
  2435. foreach($list as $timezone => $name) {
  2436. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  2437. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  2438. }
  2439. print '</optgroup>' . "\n";
  2440. }
  2441. print '</select>';
  2442. }
  2443. function getTimezone(){
  2444. $regions = array(
  2445. 'Africa' => DateTimeZone::AFRICA,
  2446. 'America' => DateTimeZone::AMERICA,
  2447. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2448. 'Arctic' => DateTimeZone::ARCTIC,
  2449. 'Asia' => DateTimeZone::ASIA,
  2450. 'Atlantic' => DateTimeZone::ATLANTIC,
  2451. 'Australia' => DateTimeZone::AUSTRALIA,
  2452. 'Europe' => DateTimeZone::EUROPE,
  2453. 'Indian' => DateTimeZone::INDIAN,
  2454. 'Pacific' => DateTimeZone::PACIFIC
  2455. );
  2456. $timezones = array();
  2457. foreach ($regions as $name => $mask) {
  2458. $zones = DateTimeZone::listIdentifiers($mask);
  2459. foreach($zones as $timezone) {
  2460. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2461. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2462. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2463. }
  2464. }
  2465. print '<select name="timezone" id="timezone" class="form-control material" required>';
  2466. foreach($timezones as $region => $list) {
  2467. print '<optgroup label="' . $region . '">' . "\n";
  2468. foreach($list as $timezone => $name) {
  2469. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  2470. }
  2471. print '</optgroup>' . "\n";
  2472. }
  2473. print '</select>';
  2474. }
  2475. function explosion($string, $position){
  2476. $getWord = explode("|", $string);
  2477. return $getWord[$position];
  2478. }
  2479. function getServerPath() {
  2480. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  2481. $protocol = "https://";
  2482. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  2483. $protocol = "https://";
  2484. } else {
  2485. $protocol = "http://";
  2486. }
  2487. $domain = '';
  2488. if (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], '.') !== false){
  2489. $domain = $_SERVER['SERVER_NAME'];
  2490. }elseif(isset($_SERVER['HTTP_HOST'])){
  2491. if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
  2492. $domain = explode(':', $_SERVER['HTTP_HOST'])[0];
  2493. $port = explode(':', $_SERVER['HTTP_HOST'])[1];
  2494. if ($port == "80" || $port == "443"){
  2495. $domain = $domain;
  2496. }else{
  2497. $domain = $_SERVER['HTTP_HOST'];
  2498. }
  2499. }else{
  2500. $domain = $_SERVER['HTTP_HOST'];
  2501. }
  2502. }
  2503. return $protocol . $domain . dirname($_SERVER['REQUEST_URI']);
  2504. }
  2505. function get_browser_name() {
  2506. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  2507. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  2508. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  2509. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  2510. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  2511. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  2512. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  2513. return 'Other';
  2514. }
  2515. function getSickrageCalendarWanted($array){
  2516. $array = json_decode($array, true);
  2517. //$gotCalendar = "";
  2518. $gotCalendar = array();
  2519. $i = 0;
  2520. foreach($array['data']['missed'] AS $child) {
  2521. $i++;
  2522. $seriesName = $child['show_name'];
  2523. $episodeID = $child['tvdbid'];
  2524. $episodeAirDate = $child['airdate'];
  2525. $episodeAirDateTime = explode(" ",$child['airs']);
  2526. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2527. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2528. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2529. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2530. $downloaded = "0";
  2531. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2532. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2533. array_push($gotCalendar, array(
  2534. "id" => "Sick-Miss-".$i,
  2535. "title" => $seriesName,
  2536. "start" => $episodeAirDate,
  2537. "className" => $downloaded." tvID--".$episodeID,
  2538. "imagetype" => "tv",
  2539. ));
  2540. }
  2541. foreach($array['data']['today'] AS $child) {
  2542. $i++;
  2543. $seriesName = $child['show_name'];
  2544. $episodeID = $child['tvdbid'];
  2545. $episodeAirDate = $child['airdate'];
  2546. $episodeAirDateTime = explode(" ",$child['airs']);
  2547. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2548. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2549. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2550. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2551. $downloaded = "0";
  2552. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2553. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2554. array_push($gotCalendar, array(
  2555. "id" => "Sick-Today-".$i,
  2556. "title" => $seriesName,
  2557. "start" => $episodeAirDate,
  2558. "className" => $downloaded." tvID--".$episodeID,
  2559. "imagetype" => "tv",
  2560. ));
  2561. }
  2562. foreach($array['data']['soon'] AS $child) {
  2563. $i++;
  2564. $seriesName = $child['show_name'];
  2565. $episodeID = $child['tvdbid'];
  2566. $episodeAirDate = $child['airdate'];
  2567. $episodeAirDateTime = explode(" ",$child['airs']);
  2568. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2569. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2570. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2571. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2572. $downloaded = "0";
  2573. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2574. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2575. array_push($gotCalendar, array(
  2576. "id" => "Sick-Soon-".$i,
  2577. "title" => $seriesName,
  2578. "start" => $episodeAirDate,
  2579. "className" => $downloaded." tvID--".$episodeID,
  2580. "imagetype" => "tv",
  2581. ));
  2582. }
  2583. foreach($array['data']['later'] AS $child) {
  2584. $i++;
  2585. $seriesName = $child['show_name'];
  2586. $episodeID = $child['tvdbid'];
  2587. $episodeAirDate = $child['airdate'];
  2588. $episodeAirDateTime = explode(" ",$child['airs']);
  2589. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2590. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2591. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2592. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2593. $downloaded = "0";
  2594. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2595. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2596. array_push($gotCalendar, array(
  2597. "id" => "Sick-Later-".$i,
  2598. "title" => $seriesName,
  2599. "start" => $episodeAirDate,
  2600. "className" => $downloaded." tvID--".$episodeID,
  2601. "imagetype" => "tv",
  2602. ));
  2603. }
  2604. if ($i != 0){ return $gotCalendar; }
  2605. }
  2606. function getSickrageCalendarHistory($array){
  2607. $array = json_decode($array, true);
  2608. //$gotCalendar = "";
  2609. $gotCalendar = array();
  2610. $i = 0;
  2611. foreach($array['data'] AS $child) {
  2612. $i++;
  2613. $seriesName = $child['show_name'];
  2614. $episodeID = $child['tvdbid'];
  2615. $episodeAirDate = $child['date'];
  2616. $downloaded = "green-bg";
  2617. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2618. array_push($gotCalendar, array(
  2619. "id" => "Sick-History-".$i,
  2620. "title" => $seriesName,
  2621. "start" => $episodeAirDate,
  2622. "className" => $downloaded." tvID--".$episodeID,
  2623. "imagetype" => "tv",
  2624. ));
  2625. }
  2626. if ($i != 0){ return $gotCalendar; }
  2627. }
  2628. function getSonarrCalendar($array){
  2629. $array = json_decode($array, true);
  2630. //$gotCalendar = "";
  2631. $gotCalendar = array();
  2632. $i = 0;
  2633. foreach($array AS $child) {
  2634. $i++;
  2635. $seriesName = $child['series']['title'];
  2636. $episodeID = $child['series']['tvdbId'];
  2637. if(!isset($episodeID)){ $episodeID = ""; }
  2638. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  2639. if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
  2640. $episodeAirDate = $child['airDateUtc'];
  2641. $episodeAirDate = strtotime($episodeAirDate);
  2642. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2643. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2644. $downloaded = $child['hasFile'];
  2645. 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"; }
  2646. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2647. array_push($gotCalendar, array(
  2648. "id" => "Sonarr-".$i,
  2649. "title" => $seriesName,
  2650. "start" => $episodeAirDate,
  2651. "className" => $downloaded." tvID--".$episodeID,
  2652. "imagetype" => "tv",
  2653. ));
  2654. }
  2655. if ($i != 0){ return $gotCalendar; }
  2656. }
  2657. function getRadarrCalendar($array){
  2658. $array = json_decode($array, true);
  2659. $gotCalendar = array();
  2660. $i = 0;
  2661. foreach($array AS $child) {
  2662. if(isset($child['physicalRelease'])){
  2663. $i++;
  2664. $movieName = $child['title'];
  2665. $movieID = $child['tmdbId'];
  2666. if(!isset($movieID)){ $movieID = ""; }
  2667. $physicalRelease = $child['physicalRelease'];
  2668. $physicalRelease = strtotime($physicalRelease);
  2669. $physicalRelease = date("Y-m-d", $physicalRelease);
  2670. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2671. $downloaded = $child['hasFile'];
  2672. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2673. array_push($gotCalendar, array(
  2674. "id" => "Radarr-".$i,
  2675. "title" => $movieName,
  2676. "start" => $physicalRelease,
  2677. "className" => $downloaded." movieID--".$movieID,
  2678. "imagetype" => "film",
  2679. ));
  2680. }
  2681. }
  2682. if ($i != 0){ return $gotCalendar; }
  2683. }
  2684. function getHeadphonesCalendar($url, $key, $list){
  2685. $url = qualifyURL(HEADPHONESURL);
  2686. $api = curl_get($url."/api?apikey=".$key."&cmd=$list");
  2687. $api = json_decode($api, true);
  2688. $i = 0;
  2689. //$gotCalendar = "";
  2690. $gotCalendar = array();;
  2691. if (is_array($api) || is_object($api)){
  2692. foreach($api AS $child) {
  2693. if($child['Status'] == "Wanted" && $list == "getWanted" && $child['ReleaseDate']){
  2694. $i++;
  2695. $albumName = addslashes($child['AlbumTitle']);
  2696. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  2697. $albumDate = (strlen($child['ReleaseDate']) > 4) ? $child['ReleaseDate'] : $child['ReleaseDate']."-01-01";
  2698. $albumID = $child['AlbumID'];
  2699. $albumDate = strtotime($albumDate);
  2700. $albumDate = date("Y-m-d", $albumDate);
  2701. $albumStatus = $child['Status'];
  2702. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2703. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  2704. //$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2705. array_push($gotCalendar, array(
  2706. "id" => "Headphones-".$i,
  2707. "title" => $albumArtist.' - '.$albumName,
  2708. "start" => $albumDate,
  2709. "className" => $albumStatusColor,
  2710. "imagetype" => "music",
  2711. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2712. ));
  2713. }
  2714. if($child['Status'] == "Processed" && $list == "getHistory"){
  2715. $i++;
  2716. $find = array('_','[', ']', '\n');
  2717. $replace = array(' ','(', ')', ' ');
  2718. $albumName = addslashes(str_replace($find,$replace,$child['FolderName']));
  2719. $albumDate = $child['DateAdded'];
  2720. $albumID = $child['AlbumID'];
  2721. $albumDate = strtotime($albumDate);
  2722. $albumDate = date("Y-m-d", $albumDate);
  2723. $albumStatusColor = "green-bg";
  2724. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2725. //$gotCalendar .= "{ title: \"$albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2726. array_push($gotCalendar, array(
  2727. "id" => "Headphones-".$i,
  2728. "title" => $albumName,
  2729. "start" => $albumDate,
  2730. "className" => $albumStatusColor,
  2731. "imagetype" => "music",
  2732. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2733. ));
  2734. }
  2735. }
  2736. if ($i != 0){ return $gotCalendar; }
  2737. }else{
  2738. writeLog("error", "HEADPHONES $list ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2739. }
  2740. }
  2741. function checkRootPath($string){
  2742. if($string == "\\" || $string == "/"){
  2743. return "/";
  2744. }else{
  2745. return str_replace("\\", "/", $string) . "/";
  2746. }
  2747. }
  2748. function strip($string){
  2749. $string = strip_tags($string);
  2750. return preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $string));
  2751. }
  2752. function writeLog($type, $message){
  2753. if(filesize("org.log") > 500000){
  2754. rename('org.log','org['.date('Y-m-d').'].log');
  2755. $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";
  2756. file_put_contents("org.log", $message2, FILE_APPEND | LOCK_EX);
  2757. }
  2758. $message = date("Y-m-d H:i:s")."|".$type."|".strip($message)."\n";
  2759. file_put_contents("org.log", $message, FILE_APPEND | LOCK_EX);
  2760. }
  2761. function readLog(){
  2762. $log = file("org.log",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  2763. $log = array_reverse($log);
  2764. foreach($log as $line){
  2765. if(substr_count($line, '|') == 2){
  2766. $line = explode("|", strip($line));
  2767. $line[1] = ($line[1] == "error") ? '<span class="label label-danger">Error</span>' : '<span class="label label-primary">Success</span>';
  2768. echo "<tr><td>".$line[0]."</td><td>".$line[2]."</td><td>".$line[1]."</td></tr>";
  2769. }
  2770. }
  2771. }
  2772. function buildStream($array){
  2773. $result = "";
  2774. if (array_key_exists('platform', $array)) {
  2775. $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>';
  2776. }
  2777. if (array_key_exists('device', $array)) {
  2778. $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>';
  2779. }
  2780. if (array_key_exists('stream', $array)) {
  2781. $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>';
  2782. }
  2783. if (array_key_exists('video', $array)) {
  2784. $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>';
  2785. }
  2786. if (array_key_exists('audio', $array)) {
  2787. $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>';
  2788. }
  2789. return $result;
  2790. }
  2791. function streamType($value){
  2792. if($value == "transcode" || $value == "Transcode"){
  2793. return "Transcode";
  2794. }elseif($value == "copy" || $value == "DirectStream"){
  2795. return "Direct Stream";
  2796. }elseif($value == "directplay" || $value == "DirectPlay"){
  2797. return "Direct Play";
  2798. }else{
  2799. return "Direct Play";
  2800. }
  2801. }
  2802. function getPlatform($platform){
  2803. $allPlatforms = array(
  2804. "Chrome" => "chrome.png",
  2805. "tvOS" => "atv.png",
  2806. "iOS" => "ios.png",
  2807. "Xbox One" => "xbox.png",
  2808. "Mystery 4" => "playstation.png",
  2809. "Samsung" => "samsung.png",
  2810. "Roku" => "roku.png",
  2811. "Emby for iOS" => "ios.png",
  2812. "Emby Mobile" => "emby.png",
  2813. "Emby Theater" => "emby.png",
  2814. "Emby Classic" => "emby.png",
  2815. "Safari" => "safari.png",
  2816. "Android" => "android.png",
  2817. "AndroidTv" => "android.png",
  2818. "Chromecast" => "chromecast.png",
  2819. "Dashboard" => "emby.png",
  2820. "Dlna" => "dlna.png",
  2821. "Windows Phone" => "wp.png",
  2822. "Windows RT" => "win8.png",
  2823. "Kodi" => "kodi.png",
  2824. );
  2825. if (array_key_exists($platform, $allPlatforms)) {
  2826. return $allPlatforms[$platform];
  2827. }else{
  2828. return "pmp.png";
  2829. }
  2830. }
  2831. function getServer(){
  2832. $server = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"];
  2833. return $server;
  2834. }
  2835. function prettyPrint($array) {
  2836. echo "<pre>";
  2837. print_r($array);
  2838. echo "</pre>";
  2839. echo "<br/>";
  2840. }
  2841. function checkFrame($array, $url){
  2842. if(array_key_exists("x-frame-options", $array)){
  2843. if($array['x-frame-options'] == "deny"){
  2844. return false;
  2845. }elseif($array['x-frame-options'] == "sameorgin"){
  2846. $digest = parse_url($url);
  2847. $host = (isset($digest['host'])?$digest['host']:'');
  2848. if(getServer() == $host){
  2849. return true;
  2850. }else{
  2851. return false;
  2852. }
  2853. }
  2854. }else{
  2855. if(!$array){
  2856. return false;
  2857. }
  2858. return true;
  2859. }
  2860. }
  2861. function frameTest($url){
  2862. $array = array_change_key_case(get_headers(qualifyURL($url), 1));
  2863. $url = qualifyURL($url);
  2864. if(checkFrame($array, $url)){
  2865. return true;
  2866. }else{
  2867. return false;
  2868. }
  2869. }
  2870. function sendResult($result, $icon = "floppy-o", $message = false, $success = "WAS_SUCCESSFUL", $fail = "HAS_FAILED", $send = true) {
  2871. $notifyExplode = explode("-", NOTIFYEFFECT);
  2872. if ($result) {
  2873. $msg = array(
  2874. 'html' => ($message?''.$message.' <strong>'.translate($success).'</strong>':'<strong>'.translate($success).'</strong>'),
  2875. 'icon' => $icon,
  2876. 'type' => 'success',
  2877. 'length' => '5000',
  2878. 'layout' => $notifyExplode[0],
  2879. 'effect' => $notifyExplode[1],
  2880. );
  2881. } else {
  2882. $msg = array(
  2883. 'html' => ($message?''.$message.' <strong>'.translate($fail).'</strong>':'<strong>'.translate($fail).'</strong>'),
  2884. 'icon' => $icon,
  2885. 'type' => 'error',
  2886. 'length' => '5000',
  2887. 'layout' => $notifyExplode[0],
  2888. 'effect' => $notifyExplode[1],
  2889. );
  2890. }
  2891. // Send and kill script?
  2892. if ($send) {
  2893. header('Content-Type: application/json');
  2894. echo json_encode(array('notify'=>$msg));
  2895. die();
  2896. }
  2897. return $msg;
  2898. }
  2899. function buildHomepageNotice($layout, $type, $title, $message){
  2900. switch ($layout) {
  2901. case 'elegant':
  2902. return '
  2903. <div id="homepageNotice" class="row">
  2904. <div class="col-lg-12">
  2905. <div class="content-box big-box box-shadow panel-box panel-'.$type.'">
  2906. <div class="content-title i-block">
  2907. <h4 class="zero-m"><strong>'.$title.'</strong></h4>
  2908. <div class="content-tools i-block pull-right">
  2909. <a class="close-btn">
  2910. <i class="fa fa-times"></i>
  2911. </a>
  2912. </div>
  2913. </div>
  2914. '.$message.'
  2915. </div>
  2916. </div>
  2917. </div>
  2918. ';
  2919. break;
  2920. case 'basic':
  2921. return '
  2922. <div id="homepageNotice" class="row">
  2923. <div class="col-lg-12">
  2924. <div class="panel panel-'.$type.'">
  2925. <div class="panel-heading">
  2926. <h3 class="panel-title">'.$title.'</h3>
  2927. </div>
  2928. <div class="panel-body">
  2929. '.$message.'
  2930. </div>
  2931. </div>
  2932. </div>
  2933. </div>
  2934. ';
  2935. break;
  2936. case 'jumbotron';
  2937. return '
  2938. <div id="homepageNotice" class="row">
  2939. <div class="col-lg-12">
  2940. <div class="jumbotron">
  2941. <div class="container">
  2942. <h1>'.$title.'</h1>
  2943. <p>'.$message.'</p>
  2944. </div>
  2945. </div>
  2946. </div>
  2947. </div>
  2948. ';
  2949. }
  2950. }
  2951. function embyArray($array, $type) {
  2952. $key = ($type == "video" ? "Height" : "Channels");
  2953. if (array_key_exists($key, $array)) {
  2954. switch ($type) {
  2955. case "video":
  2956. $codec = $array["Codec"];
  2957. $height = $array["Height"];
  2958. $width = $array["Width"];
  2959. break;
  2960. default:
  2961. $codec = $array["Codec"];
  2962. $channels = $array["Channels"];
  2963. }
  2964. return ($type == "video" ? "(".$codec.") (".$width."x".$height.")" : "(".$codec.") (".$channels."ch)");
  2965. }
  2966. foreach ($array as $element) {
  2967. if (is_array($element)) {
  2968. if (embyArray($element, $type)) {
  2969. return embyArray($element, $type);
  2970. }
  2971. }
  2972. }
  2973. }
  2974. // Get Now Playing Streams From Plex
  2975. function searchPlex($query){
  2976. $address = qualifyURL(PLEXURL);
  2977. $openTab = (PLEXTABNAME) ? "true" : "false";
  2978. // Perform API requests
  2979. $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
  2980. $api = simplexml_load_string($api);
  2981. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  2982. if (!$getServer) { return 'Could not load!'; }
  2983. // Identify the local machine
  2984. $server = $getServer['machineIdentifier'];
  2985. $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>";
  2986. $items = "";
  2987. $albums = $movies = $shows = 0;
  2988. $style = 'style="vertical-align: middle"';
  2989. foreach($api AS $child) {
  2990. if($child['type'] != "artist" && $child['type'] != "episode" && isset($child['librarySectionID'])){
  2991. $time = (string)$child['addedAt'];
  2992. $time = new DateTime("@$time");
  2993. $results = array(
  2994. "title" => (string)$child['title'],
  2995. "image" => (string)$child['thumb'],
  2996. "type" => (string)ucwords($child['type']),
  2997. "year" => (string)$child['year'],
  2998. "key" => (string)$child['ratingKey']."-search",
  2999. "ratingkey" => (string)$child['ratingKey'],
  3000. "genre" => (string)$child->Genre['tag'],
  3001. "added" => $time->format('Y-m-d'),
  3002. "extra" => "",
  3003. );
  3004. switch ($child['type']){
  3005. case "album":
  3006. $push = array(
  3007. "title" => (string)$child['parentTitle']." - ".(string)$child['title'],
  3008. );
  3009. $results = array_replace($results,$push);
  3010. $albums++;
  3011. break;
  3012. case "movie":
  3013. $push = array(
  3014. "extra" => "Content Rating: ".(string)$child['contentRating']."<br/>Movie Rating: ".(string)$child['rating'],
  3015. );
  3016. $results = array_replace($results,$push);
  3017. $movies++;
  3018. break;
  3019. case "show":
  3020. $push = array(
  3021. "extra" => "Seasons: ".(string)$child['childCount']."<br/>Episodes: ".(string)$child['leafCount'],
  3022. );
  3023. $results = array_replace($results,$push);
  3024. $shows++;
  3025. break;
  3026. }
  3027. if (file_exists('images/cache/'.$results['key'].'.jpg')){ $image_url = 'images/cache/'.$results['key'].'.jpg'; }
  3028. if (file_exists('images/cache/'.$results['key'].'.jpg') && (time() - 604800) > filemtime('images/cache/'.$results['key'].'.jpg') || !file_exists('images/cache/'.$results['key'].'.jpg')) {
  3029. $image_url = 'ajax.php?a=plex-image&img='.$results['image'].'&height=150&width=100&key='.$results['key'];
  3030. }
  3031. if(!$results['image']){ $image_url = "images/no-search.png"; $key = "no-search"; }
  3032. if (substr_count(PLEXURL, '.') != 2) {
  3033. $link = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3034. }else{
  3035. $link = PLEXURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3036. }
  3037. $items .= '<tr style="cursor: pointer;" class="openTab" extraTitle="'.$results['title'].'" extraType="'.$child['type'].'" openTab="'.$openTab.'" href="'.$link.'">
  3038. <th scope="row"><img src="'.$image_url.'"></th>
  3039. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
  3040. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
  3041. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
  3042. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
  3043. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
  3044. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['extra'].'</td>
  3045. </tr>';
  3046. }
  3047. }
  3048. $totals = '<div style="margin: 10px;" class="sort-todo pull-right">
  3049. <span class="badge gray-bg"><i class="fa fa-film fa-2x white"></i><strong style="
  3050. font-size: 23px;
  3051. ">&nbsp;'.$movies.'</strong></span>
  3052. <span class="badge gray-bg"><i class="fa fa-tv fa-2x white"></i><strong style="
  3053. font-size: 23px;
  3054. ">&nbsp;'.$shows.'</strong></span>
  3055. <span class="badge gray-bg"><i class="fa fa-music fa-2x white"></i><strong style="
  3056. font-size: 23px;
  3057. ">&nbsp;'.$albums.'</strong></span>
  3058. </div>';
  3059. return (!empty($items) ? $totals.$pre.$items."</div></table>" : "<h2 class='text-center'>No Results for $query</h2>" );
  3060. }
  3061. function getBannedUsers($string){
  3062. if (strpos($string, ',') !== false) {
  3063. $banned = explode(",", $string);
  3064. }else{
  3065. $banned = array($string);
  3066. }
  3067. return $banned;
  3068. }
  3069. function getWhitelist($string){
  3070. if (strpos($string, ',') !== false) {
  3071. $whitelist = explode(",", $string);
  3072. }else{
  3073. $whitelist = array($string);
  3074. }
  3075. foreach($whitelist as &$ip){
  3076. $ip = is_numeric(substr($ip, 0, 1)) ? $ip : gethostbyname($ip);
  3077. }
  3078. return $whitelist;
  3079. }
  3080. function get_client_ip() {
  3081. $ipaddress = '';
  3082. if (isset($_SERVER['HTTP_CLIENT_IP']))
  3083. $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
  3084. else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  3085. $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
  3086. else if(isset($_SERVER['HTTP_X_FORWARDED']))
  3087. $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
  3088. else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
  3089. $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
  3090. else if(isset($_SERVER['HTTP_FORWARDED']))
  3091. $ipaddress = $_SERVER['HTTP_FORWARDED'];
  3092. else if(isset($_SERVER['REMOTE_ADDR']))
  3093. $ipaddress = $_SERVER['REMOTE_ADDR'];
  3094. else
  3095. $ipaddress = 'UNKNOWN';
  3096. return $ipaddress;
  3097. }
  3098. //EMAIL SHIT
  3099. function sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null){
  3100. $mail = new PHPMailer;
  3101. $mail->isSMTP();
  3102. $mail->Host = SMTPHOST;
  3103. $mail->SMTPAuth = SMTPHOSTAUTH;
  3104. $mail->Username = SMTPHOSTUSERNAME;
  3105. $mail->Password = SMTPHOSTPASSWORD;
  3106. $mail->SMTPSecure = SMTPHOSTTYPE;
  3107. $mail->Port = SMTPHOSTPORT;
  3108. $mail->setFrom(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3109. $mail->addReplyTo(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3110. $mail->isHTML(true);
  3111. $mail->addAddress($email, $username);
  3112. $mail->Subject = $subject;
  3113. $mail->Body = $body;
  3114. //$mail->send();
  3115. if(!$mail->send()) {
  3116. writeLog("error", "mail failed to send");
  3117. } else {
  3118. writeLog("success", "mail has been sent");
  3119. }
  3120. }
  3121. //EMAIL SHIT
  3122. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  3123. $mail = new PHPMailer;
  3124. $mail->isSMTP();
  3125. $mail->Host = $host;
  3126. $mail->SMTPAuth = $auth;
  3127. $mail->Username = $username;
  3128. $mail->Password = $password;
  3129. $mail->SMTPSecure = $type;
  3130. $mail->Port = $port;
  3131. $mail->setFrom($from, $sendername);
  3132. $mail->addReplyTo($from, $sendername);
  3133. $mail->isHTML(true);
  3134. $mail->addAddress($to, "Organizr Admin");
  3135. $mail->Subject = "Organizr Test E-Mail";
  3136. $mail->Body = "This was just a test!";
  3137. //$mail->send();
  3138. if(!$mail->send()) {
  3139. writeLog("error", "EMAIL TEST: mail failed to send - Error:".$mail->ErrorInfo);
  3140. return false;
  3141. } else {
  3142. writeLog("success", "EMAIL TEST: mail has been sent successfully");
  3143. return true;
  3144. }
  3145. }
  3146. function libraryList(){
  3147. $address = qualifyURL(PLEXURL);
  3148. $headers = array(
  3149. "Accept" => "application/json",
  3150. "X-Plex-Token" => PLEXTOKEN
  3151. );
  3152. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3153. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3154. $api = simplexml_load_string(@curl_get("https://plex.tv/api/servers/$gotServer/shared_servers", $headers));
  3155. $libraryList = array();
  3156. foreach($api->SharedServer->Section AS $child) {
  3157. $libraryList['libraries'][(string)$child['title']] = (string)$child['id'];
  3158. }
  3159. foreach($api->SharedServer AS $child) {
  3160. if(!empty($child['username'])){
  3161. $username = (string)strtolower($child['username']);
  3162. $email = (string)strtolower($child['email']);
  3163. $libraryList['users'][$username] = (string)$child['id'];
  3164. $libraryList['emails'][$email] = (string)$child['id'];
  3165. }
  3166. }
  3167. return (!empty($libraryList) ? array_change_key_case($libraryList,CASE_LOWER) : null );
  3168. }
  3169. function plexUserShare($username){
  3170. $address = qualifyURL(PLEXURL);
  3171. $headers = array(
  3172. "Accept" => "application/json",
  3173. "Content-Type" => "application/json",
  3174. "X-Plex-Token" => PLEXTOKEN
  3175. );
  3176. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3177. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3178. $json = array(
  3179. "server_id" => $gotServer,
  3180. "shared_server" => array(
  3181. //"library_section_ids" => "[26527637]",
  3182. "invited_email" => $username
  3183. )
  3184. );
  3185. $api = curl_post("https://plex.tv/api/servers/$gotServer/shared_servers/", $json, $headers);
  3186. switch ($api['http_code']['http_code']){
  3187. case 400:
  3188. writeLog("error", "PLEX INVITE: $username already has access to the shared libraries");
  3189. $result = "$username already has access to the shared libraries";
  3190. break;
  3191. case 401:
  3192. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3193. $result = "Invalid Plex Token";
  3194. break;
  3195. case 200:
  3196. writeLog("success", "PLEX INVITE: $username now has access to your Plex Library");
  3197. $result = "$username now has access to your Plex Library";
  3198. break;
  3199. default:
  3200. writeLog("error", "PLEX INVITE: unknown error");
  3201. $result = false;
  3202. }
  3203. return (!empty($result) ? $result : null );
  3204. }
  3205. function plexUserDelete($username){
  3206. $address = qualifyURL(PLEXURL);
  3207. $headers = array(
  3208. "Accept" => "application/json",
  3209. "Content-Type" => "application/json",
  3210. "X-Plex-Token" => PLEXTOKEN
  3211. );
  3212. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3213. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3214. $id = (is_numeric($username) ? $id : convertPlexName($username, "id"));
  3215. $api = curl_delete("https://plex.tv/api/servers/$gotServer/shared_servers/$id", $headers);
  3216. switch ($api['http_code']['http_code']){
  3217. case 401:
  3218. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3219. $result = "Invalid Plex Token";
  3220. break;
  3221. case 200:
  3222. writeLog("success", "PLEX INVITE: $username doesn't have access to your Plex Library anymore");
  3223. $result = "$username doesn't have access to your Plex Library anymore";
  3224. break;
  3225. default:
  3226. writeLog("error", "PLEX INVITE: unknown error");
  3227. $result = false;
  3228. }
  3229. return (!empty($result) ? $result : null );
  3230. }
  3231. function convertPlexName($user, $type){
  3232. $array = libraryList();
  3233. switch ($type){
  3234. case "username":
  3235. $plexUser = array_search ($user, $array['users']);
  3236. break;
  3237. case "id":
  3238. if (array_key_exists(strtolower($user), $array['users'])) {
  3239. $plexUser = $array['users'][strtolower($user)];
  3240. }
  3241. break;
  3242. default:
  3243. $plexUser = false;
  3244. }
  3245. return (!empty($plexUser) ? $plexUser : null );
  3246. }
  3247. function randomCode($length = 5, $type = null) {
  3248. switch ($type){
  3249. case "alpha":
  3250. $legend = array_merge(range('A', 'Z'));
  3251. break;
  3252. case "numeric":
  3253. $legend = array_merge(range(0,9));
  3254. break;
  3255. default:
  3256. $legend = array_merge(range(0,9),range('A', 'Z'));
  3257. }
  3258. $code = "";
  3259. for($i=0; $i < $length; $i++) {
  3260. $code .= $legend[mt_rand(0, count($legend) - 1)];
  3261. }
  3262. return $code;
  3263. }
  3264. function inviteCodes($action, $code = null, $usedBy = null) {
  3265. if (!isset($GLOBALS['file_db'])) {
  3266. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  3267. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  3268. }
  3269. $now = date("Y-m-d H:i:s");
  3270. switch ($action) {
  3271. case "get":
  3272. // Start Array
  3273. $result = array();
  3274. // Database Lookup
  3275. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes"');
  3276. // Get Codes
  3277. foreach($invites as $row) {
  3278. array_push($result, $row['code']);
  3279. }
  3280. // Return the Results
  3281. return (!empty($result) ? $result : false );
  3282. break;
  3283. case "check":
  3284. // Start Array
  3285. $result = array();
  3286. // Database Lookup
  3287. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes" AND code = "'.$code.'"');
  3288. // Get Codes
  3289. foreach($invites as $row) {
  3290. $result = $row['code'];
  3291. }
  3292. // Return the Results
  3293. return (!empty($result) ? $result : false );
  3294. break;
  3295. case "use":
  3296. $currentIP = get_client_ip();
  3297. $invites = $GLOBALS['file_db']->query('UPDATE invites SET valid = "No", usedby = "'.$usedBy.'", dateused = "'.$now.'", ip = "'.$currentIP.'" WHERE code = "'.$code.'"');
  3298. if(ENABLEMAIL){
  3299. if (!isset($GLOBALS['USER'])) {
  3300. require_once("user.php");
  3301. $GLOBALS['USER'] = new User('registration_callback');
  3302. }
  3303. sendEmail($GLOBALS['USER']->adminEmail, "Admin", "Plex Invite Used", orgEmail("PLEX Invite Used", "Look who joined the cool club", "Admin", "Hey, The User: $usedBy has redeemd their invite code: [$code], their IP Address was: $currentIP", null, null, "What Next?", "Well, That is up to you. You can go check on them if you like."));
  3304. }
  3305. return (!empty($invites) ? true : false );
  3306. break;
  3307. }
  3308. }
  3309. function plexJoin($username, $email, $password){
  3310. $connectURL = 'https://plex.tv/users.json';
  3311. $headers = array(
  3312. 'Accept'=> 'application/json',
  3313. 'Content-Type' => 'application/x-www-form-urlencoded',
  3314. 'X-Plex-Product' => 'Organizr',
  3315. 'X-Plex-Version' => '1.0',
  3316. 'X-Plex-Client-Identifier' => '01010101-10101010',
  3317. );
  3318. $body = array(
  3319. 'user[email]' => $email,
  3320. 'user[username]' => $username,
  3321. 'user[password]' => $password,
  3322. );
  3323. $api = curl_post($connectURL, $body, $headers);
  3324. $json = json_decode($api['content'], true);
  3325. $errors = (!empty($json['errors']) ? true : false);
  3326. $success = (!empty($json['user']) ? true : false);
  3327. //Use This for later
  3328. $usernameError = (!empty($json['errors']['username']) ? $json['errors']['username'][0] : false);
  3329. $emailError = (!empty($json['errors']['email']) ? $json['errors']['email'][0] : false);
  3330. $passwordError = (!empty($json['errors']['password']) ? $json['errors']['password'][0] : false);
  3331. $errorMessage = "";
  3332. if($errors){
  3333. if($usernameError){ $errorMessage .= "[Username Error: ". $usernameError ."]"; }
  3334. if($emailError){ $errorMessage .= "[Email Error: ". $emailError ."]"; }
  3335. if($passwordError){ $errorMessage .= "[Password Error: ". $passwordError ."]"; }
  3336. }
  3337. switch ($api['http_code']['http_code']){
  3338. case 400:
  3339. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." $username already has access to the shared libraries $errorMessage");
  3340. break;
  3341. case 401:
  3342. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." invalid Plex Token $errorMessage");
  3343. break;
  3344. case 422:
  3345. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." user info error $errorMessage");
  3346. break;
  3347. case 429:
  3348. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." too many requests to plex.tv please try later $errorMessage");
  3349. break;
  3350. case 200:
  3351. case 201:
  3352. writeLog("success", "PLEX JOIN: $username now has access to your Plex Library");
  3353. break;
  3354. default:
  3355. writeLog("error", "PLEX JOIN: unknown error, $errorMessage Error: ".$api['http_code']['http_code']);
  3356. }
  3357. //prettyPrint($api);
  3358. //prettyPrint(json_decode($api['content'], true));
  3359. return (!empty($success) && empty($errors) ? true : false );
  3360. }
  3361. function getCert(){
  3362. $url = "http://curl.haxx.se/ca/cacert.pem";
  3363. $file = getcwd()."/config/cacert.pem";
  3364. $directory = getcwd()."/config/";
  3365. @mkdir($directory, 0770, true);
  3366. if(!file_exists($file)){
  3367. file_put_contents( $file, fopen($url, 'r'));
  3368. writeLog("success", "CERT PEM: pem file created");
  3369. }elseif (file_exists($file) && time() - 2592000 > filemtime($file)) {
  3370. file_put_contents( $file, fopen($url, 'r'));
  3371. writeLog("success", "CERT PEM: downloaded new pem file");
  3372. }
  3373. return $file;
  3374. }
  3375. function customCSS(){
  3376. if(CUSTOMCSS == "true") {
  3377. $template_file = "custom.css";
  3378. $file_handle = fopen($template_file, "rb");
  3379. echo "\n";
  3380. echo fread($file_handle, filesize($template_file));
  3381. fclose($file_handle);
  3382. echo "\n";
  3383. }
  3384. }
  3385. function tvdbToken(){
  3386. $headers = array(
  3387. "Accept" => "application/json",
  3388. "Content-Type" => "application/json"
  3389. );
  3390. $json = array(
  3391. "apikey" => "FBE7B62621F4CAD7",
  3392. "userkey" => "328BB46EB1E9A0F5",
  3393. "username" => "causefx"
  3394. );
  3395. $api = curl_post("https://api.thetvdb.com/login", $json, $headers);
  3396. return json_decode($api['content'], true)['token'];
  3397. }
  3398. function tvdbGet($id){
  3399. $headers = array(
  3400. "Accept" => "application/json",
  3401. "Authorization" => "Bearer ".tvdbToken(),
  3402. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3403. "trakt-api-version" => "2"
  3404. );
  3405. $trakt = curl_get("https://api.trakt.tv/search/tvdb/$id?type=show", $headers);
  3406. @$api['trakt'] = json_decode($trakt, true)[0]['show']['ids'];
  3407. if(empty($api['trakt'])){
  3408. $series = curl_get("https://api.thetvdb.com/series/$id", $headers);
  3409. $poster = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=poster", $headers);
  3410. $backdrop = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=fanart", $headers);
  3411. $api['series'] = json_decode($series, true)['data'];
  3412. $api['poster'] = json_decode($poster, true)['data'];
  3413. $api['backdrop'] = json_decode($backdrop, true)['data'];
  3414. }
  3415. return $api;
  3416. }
  3417. function tvdbSearch($name, $type){
  3418. $name = rawurlencode(preg_replace("/\(([^()]*+|(?R))*\)/","", $name));
  3419. $headers = array(
  3420. "Accept" => "application/json",
  3421. "Authorization" => "Bearer ".tvdbToken(),
  3422. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3423. "trakt-api-version" => "2"
  3424. );
  3425. $trakt = curl_get("https://api.trakt.tv/search/$type?query=$name", $headers);
  3426. @$api['trakt'] = json_decode($trakt, true)[0][$type]['ids'];
  3427. return $api;
  3428. }
  3429. function getPlexPlaylists(){
  3430. $address = qualifyURL(PLEXURL);
  3431. // Perform API requests
  3432. $api = @curl_get($address."/playlists?X-Plex-Token=".PLEXTOKEN);
  3433. $api = simplexml_load_string($api);
  3434. if (is_array($api) || is_object($api)){
  3435. if (!$api->head->title){
  3436. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3437. if (!$getServer) { return 'Could not load!'; }
  3438. // Identify the local machine
  3439. $gotServer = $getServer['machineIdentifier'];
  3440. $output = "";
  3441. $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">';
  3442. foreach($api AS $child) {
  3443. $items = array();
  3444. if ($child['playlistType'] == "video" && strpos(strtolower($child['title']) , 'private') === false){
  3445. $api = @curl_get($address.$child['key']."?X-Plex-Token=".PLEXTOKEN);
  3446. $api = simplexml_load_string($api);
  3447. if (is_array($api) || is_object($api)){
  3448. if (!$api->head->title){
  3449. $className = preg_replace("/(\W)+/", "", $api['title']);
  3450. $hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  3451. foreach($api->Video AS $child){
  3452. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false,false,$className);
  3453. }
  3454. if (count($items)) {
  3455. $output .= ''.implode('',$items).'';
  3456. }
  3457. }
  3458. }
  3459. }
  3460. }
  3461. $hideMenu .= '</ul></div></div>';
  3462. 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>';
  3463. }else{
  3464. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check token - if HTTPS, is cert valid");
  3465. }
  3466. }else{
  3467. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check URL - if HTTPS, is cert valid");
  3468. }
  3469. }
  3470. function readExternalLog($type,$filename,$name = null){
  3471. $log = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3472. $log = array_reverse($log);
  3473. foreach($log as $line){
  3474. if(!empty($line) && $line[0] != " "){
  3475. $line = strip($line);
  3476. if($type == "single"){
  3477. if( strpos( strtolower($line), "ror" ) !== false ) {
  3478. echo "<tr><td class='red-bg'>".$line."</td></tr>";
  3479. }else{
  3480. echo "<tr><td>".$line."</td></tr>";
  3481. }
  3482. }elseif($type == "all"){
  3483. if( strpos( strtolower($line), "ror" ) !== false ) {
  3484. echo "<tr><td class='red-bg'>".$name."</td>";
  3485. echo "<td class='red-bg'>".$line."</td></tr>";
  3486. }else{
  3487. echo "<tr><td>".$name."</td>";
  3488. echo "<td>".$line."</td></tr>";
  3489. }
  3490. }
  3491. }
  3492. }
  3493. }
  3494. function getLogs(){
  3495. $path = __DIR__ ."/logs/";
  3496. @mkdir($path, 0770, true);
  3497. $logs = array();
  3498. $files = array_diff(scandir($path), array('.', '..'));
  3499. foreach($files as $v){
  3500. $title = explode(".", $v)[0];
  3501. $logs[$title] = $path.$v;
  3502. }
  3503. return $logs;
  3504. }
  3505. function getBackups(){
  3506. $path = DATABASE_LOCATION ."backups/";
  3507. @mkdir($path, 0770, true);
  3508. $backups = array();
  3509. $files = array_diff(scandir($path), array('.', '..'));
  3510. return array_reverse($files);
  3511. }
  3512. function getExtension($string) {
  3513. return preg_replace("#(.+)?\.(\w+)(\?.+)?#", "$2", $string);
  3514. }
  3515. function showFile(){
  3516. $file = $_GET['file'];
  3517. $fileType = getExtension($file);
  3518. if($fileType != 'php'){
  3519. header("Content-type: ".mimeTypes()[$fileType]);
  3520. @readfile($file);
  3521. }
  3522. }
  3523. function getCalendar(){
  3524. $sonarr = new Sonarr(SONARRURL, SONARRKEY);
  3525. $radarr = new Sonarr(RADARRURL, RADARRKEY);
  3526. $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
  3527. $startDate = date('Y-m-d',strtotime("-".CALENDARSTARTDAY." days"));
  3528. $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
  3529. $calendarItems = array();
  3530. if (SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)){
  3531. try {
  3532. $sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate));
  3533. if(!empty($sonarrCalendar)) { $calendarItems = array_merge($calendarItems, $sonarrCalendar); }
  3534. } catch (Exception $e) {
  3535. writeLog("error", "SONARR ERROR: ".strip($e->getMessage()));
  3536. }
  3537. }
  3538. if (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)){
  3539. try {
  3540. $radarrCalendar = getRadarrCalendar($radarr->getCalendar($startDate, $endDate));
  3541. if(!empty($radarrCalendar)) { $calendarItems = array_merge($calendarItems, $radarrCalendar); }
  3542. } catch (Exception $e) {
  3543. writeLog("error", "RADARR ERROR: ".strip($e->getMessage()));
  3544. }
  3545. }
  3546. if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
  3547. $headphonesHistory = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory");
  3548. $headphonesWanted = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted");
  3549. if(!empty($headphonesHistory)) { $calendarItems = array_merge($calendarItems, $headphonesHistory); }
  3550. if(!empty($headphonesWanted)) { $calendarItems = array_merge($calendarItems, $headphonesWanted); }
  3551. }
  3552. if (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)){
  3553. try {
  3554. $sickrageFuture = getSickrageCalendarWanted($sickrage->future());
  3555. if(!empty($sickrageFuture)) { $calendarItems = array_merge($calendarItems, $sickrageFuture); }
  3556. } catch (Exception $e) {
  3557. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3558. } try {
  3559. $sickrageHistory = getSickrageCalendarHistory($sickrage->history("100","downloaded"));
  3560. if(!empty($sickrageHistory)) { $calendarItems = array_merge($calendarItems, $sickrageHistory); }
  3561. } catch (Exception $e) {
  3562. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3563. }
  3564. }
  3565. return $calendarItems;
  3566. }
  3567. function localURL($url){
  3568. if (strpos($url, 'https') !== false) {
  3569. preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $url, $result);
  3570. $result = (!empty($result) ? true : false);
  3571. return $result;
  3572. }
  3573. }
  3574. function fileArray($files){
  3575. foreach($files as $file){
  3576. if(file_exists($file)){
  3577. $list[] = $file;
  3578. }
  3579. }
  3580. if(!empty($list)){ return $list; }
  3581. }
  3582. function backupDB(){
  3583. if (extension_loaded('ZIP')) {
  3584. $directory = DATABASE_LOCATION."backups/";
  3585. @mkdir($directory, 0770, true);
  3586. $orgFiles = array(
  3587. 'css' => 'custom.css',
  3588. 'temp' => 'cus.sd',
  3589. 'orgLog' => 'org.log',
  3590. 'loginLog' => 'loginLog.json',
  3591. 'chatDB' => 'chatpack.db',
  3592. 'config' => 'config/config.php',
  3593. 'database' => DATABASE_LOCATION.'users.db'
  3594. );
  3595. $files = fileArray($orgFiles);
  3596. if(!empty($files)){
  3597. writeLog("success", "BACKUP: backup process started");
  3598. $zipname = $directory.'backup['.date('Y-m-d_H-i').']['.INSTALLEDVERSION.'].zip';
  3599. $zip = new ZipArchive;
  3600. $zip->open($zipname, ZipArchive::CREATE);
  3601. foreach ($files as $file) {
  3602. $zip->addFile($file);
  3603. }
  3604. $zip->close();
  3605. writeLog("success", "BACKUP: backup process finished");
  3606. return true;
  3607. }else{
  3608. return false;
  3609. }
  3610. }else{
  3611. return false;
  3612. }
  3613. }
  3614. class Ping {
  3615. private $host;
  3616. private $ttl;
  3617. private $timeout;
  3618. private $port = 80;
  3619. private $data = 'Ping';
  3620. private $commandOutput;
  3621. /**
  3622. * Called when the Ping object is created.
  3623. *
  3624. * @param string $host
  3625. * The host to be pinged.
  3626. * @param int $ttl
  3627. * Time-to-live (TTL) (You may get a 'Time to live exceeded' error if this
  3628. * value is set too low. The TTL value indicates the scope or range in which
  3629. * a packet may be forwarded. By convention:
  3630. * - 0 = same host
  3631. * - 1 = same subnet
  3632. * - 32 = same site
  3633. * - 64 = same region
  3634. * - 128 = same continent
  3635. * - 255 = unrestricted
  3636. * @param int $timeout
  3637. * Timeout (in seconds) used for ping and fsockopen().
  3638. * @throws \Exception if the host is not set.
  3639. */
  3640. public function __construct($host, $ttl = 255, $timeout = 10) {
  3641. if (!isset($host)) {
  3642. throw new \Exception("Error: Host name not supplied.");
  3643. }
  3644. $this->host = $host;
  3645. $this->ttl = $ttl;
  3646. $this->timeout = $timeout;
  3647. }
  3648. /**
  3649. * Set the ttl (in hops).
  3650. *
  3651. * @param int $ttl
  3652. * TTL in hops.
  3653. */
  3654. public function setTtl($ttl) {
  3655. $this->ttl = $ttl;
  3656. }
  3657. /**
  3658. * Get the ttl.
  3659. *
  3660. * @return int
  3661. * The current ttl for Ping.
  3662. */
  3663. public function getTtl() {
  3664. return $this->ttl;
  3665. }
  3666. /**
  3667. * Set the timeout.
  3668. *
  3669. * @param int $timeout
  3670. * Time to wait in seconds.
  3671. */
  3672. public function setTimeout($timeout) {
  3673. $this->timeout = $timeout;
  3674. }
  3675. /**
  3676. * Get the timeout.
  3677. *
  3678. * @return int
  3679. * Current timeout for Ping.
  3680. */
  3681. public function getTimeout() {
  3682. return $this->timeout;
  3683. }
  3684. /**
  3685. * Set the host.
  3686. *
  3687. * @param string $host
  3688. * Host name or IP address.
  3689. */
  3690. public function setHost($host) {
  3691. $this->host = $host;
  3692. }
  3693. /**
  3694. * Get the host.
  3695. *
  3696. * @return string
  3697. * The current hostname for Ping.
  3698. */
  3699. public function getHost() {
  3700. return $this->host;
  3701. }
  3702. /**
  3703. * Set the port (only used for fsockopen method).
  3704. *
  3705. * Since regular pings use ICMP and don't need to worry about the concept of
  3706. * 'ports', this is only used for the fsockopen method, which pings servers by
  3707. * checking port 80 (by default).
  3708. *
  3709. * @param int $port
  3710. * Port to use for fsockopen ping (defaults to 80 if not set).
  3711. */
  3712. public function setPort($port) {
  3713. $this->port = $port;
  3714. }
  3715. /**
  3716. * Get the port (only used for fsockopen method).
  3717. *
  3718. * @return int
  3719. * The port used by fsockopen pings.
  3720. */
  3721. public function getPort() {
  3722. return $this->port;
  3723. }
  3724. /**
  3725. * Return the command output when method=exec.
  3726. * @return string
  3727. */
  3728. public function getCommandOutput(){
  3729. return $this->commandOutput;
  3730. }
  3731. /**
  3732. * Matches an IP on command output and returns.
  3733. * @return string
  3734. */
  3735. public function getIpAddress() {
  3736. $out = array();
  3737. if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $this->commandOutput, $out)){
  3738. return $out[0];
  3739. }
  3740. return null;
  3741. }
  3742. /**
  3743. * Ping a host.
  3744. *
  3745. * @param string $method
  3746. * Method to use when pinging:
  3747. * - exec (default): Pings through the system ping command. Fast and
  3748. * robust, but a security risk if you pass through user-submitted data.
  3749. * - fsockopen: Pings a server on port 80.
  3750. * - socket: Creates a RAW network socket. Only usable in some
  3751. * environments, as creating a SOCK_RAW socket requires root privileges.
  3752. *
  3753. * @throws InvalidArgumentException if $method is not supported.
  3754. *
  3755. * @return mixed
  3756. * Latency as integer, in ms, if host is reachable or FALSE if host is down.
  3757. */
  3758. public function ping($method = 'exec') {
  3759. $latency = false;
  3760. switch ($method) {
  3761. case 'exec':
  3762. $latency = $this->pingExec();
  3763. break;
  3764. case 'fsockopen':
  3765. $latency = $this->pingFsockopen();
  3766. break;
  3767. case 'socket':
  3768. $latency = $this->pingSocket();
  3769. break;
  3770. default:
  3771. throw new \InvalidArgumentException('Unsupported ping method.');
  3772. }
  3773. // Return the latency.
  3774. return $latency;
  3775. }
  3776. /**
  3777. * The exec method uses the possibly insecure exec() function, which passes
  3778. * the input to the system. This is potentially VERY dangerous if you pass in
  3779. * any user-submitted data. Be SURE you sanitize your inputs!
  3780. *
  3781. * @return int
  3782. * Latency, in ms.
  3783. */
  3784. private function pingExec() {
  3785. $latency = false;
  3786. $ttl = escapeshellcmd($this->ttl);
  3787. $timeout = escapeshellcmd($this->timeout);
  3788. $host = escapeshellcmd($this->host);
  3789. // Exec string for Windows-based systems.
  3790. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  3791. // -n = number of pings; -i = ttl; -w = timeout (in milliseconds).
  3792. $exec_string = 'ping -n 1 -i ' . $ttl . ' -w ' . ($timeout * 1000) . ' ' . $host;
  3793. }
  3794. // Exec string for Darwin based systems (OS X).
  3795. else if(strtoupper(PHP_OS) === 'DARWIN') {
  3796. // -n = numeric output; -c = number of pings; -m = ttl; -t = timeout.
  3797. $exec_string = 'ping -n -c 1 -m ' . $ttl . ' -t ' . $timeout . ' ' . $host;
  3798. }
  3799. // Exec string for other UNIX-based systems (Linux).
  3800. else {
  3801. // -n = numeric output; -c = number of pings; -t = ttl; -W = timeout
  3802. $exec_string = 'ping -n -c 1 -t ' . $ttl . ' -W ' . $timeout . ' ' . $host . ' 2>&1';
  3803. }
  3804. exec($exec_string, $output, $return);
  3805. // Strip empty lines and reorder the indexes from 0 (to make results more
  3806. // uniform across OS versions).
  3807. $this->commandOutput = implode($output, '');
  3808. $output = array_values(array_filter($output));
  3809. // If the result line in the output is not empty, parse it.
  3810. if (!empty($output[1])) {
  3811. // Search for a 'time' value in the result line.
  3812. $response = preg_match("/time(?:=|<)(?<time>[\.0-9]+)(?:|\s)ms/", $output[1], $matches);
  3813. // If there's a result and it's greater than 0, return the latency.
  3814. if ($response > 0 && isset($matches['time'])) {
  3815. $latency = round($matches['time'], 2);
  3816. }
  3817. }
  3818. return $latency;
  3819. }
  3820. /**
  3821. * The fsockopen method simply tries to reach the host on a port. This method
  3822. * is often the fastest, but not necessarily the most reliable. Even if a host
  3823. * doesn't respond, fsockopen may still make a connection.
  3824. *
  3825. * @return int
  3826. * Latency, in ms.
  3827. */
  3828. private function pingFsockopen() {
  3829. $start = microtime(true);
  3830. // fsockopen prints a bunch of errors if a host is unreachable. Hide those
  3831. // irrelevant errors and deal with the results instead.
  3832. $fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
  3833. if (!$fp) {
  3834. $latency = false;
  3835. }
  3836. else {
  3837. $latency = microtime(true) - $start;
  3838. $latency = round($latency * 1000, 2);
  3839. }
  3840. return $latency;
  3841. }
  3842. /**
  3843. * The socket method uses raw network packet data to try sending an ICMP ping
  3844. * packet to a server, then measures the response time. Using this method
  3845. * requires the script to be run with root privileges, though, so this method
  3846. * only works reliably on Windows systems and on Linux servers where the
  3847. * script is not being run as a web user.
  3848. *
  3849. * @return int
  3850. * Latency, in ms.
  3851. */
  3852. private function pingSocket() {
  3853. // Create a package.
  3854. $type = "\x08";
  3855. $code = "\x00";
  3856. $checksum = "\x00\x00";
  3857. $identifier = "\x00\x00";
  3858. $seq_number = "\x00\x00";
  3859. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  3860. // Calculate the checksum.
  3861. $checksum = $this->calculateChecksum($package);
  3862. // Finalize the package.
  3863. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  3864. // Create a socket, connect to server, then read socket and calculate.
  3865. if ($socket = socket_create(AF_INET, SOCK_RAW, 1)) {
  3866. socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array(
  3867. 'sec' => 10,
  3868. 'usec' => 0,
  3869. ));
  3870. // Prevent errors from being printed when host is unreachable.
  3871. @socket_connect($socket, $this->host, null);
  3872. $start = microtime(true);
  3873. // Send the package.
  3874. @socket_send($socket, $package, strlen($package), 0);
  3875. if (socket_read($socket, 255) !== false) {
  3876. $latency = microtime(true) - $start;
  3877. $latency = round($latency * 1000, 2);
  3878. }
  3879. else {
  3880. $latency = false;
  3881. }
  3882. }
  3883. else {
  3884. $latency = false;
  3885. }
  3886. // Close the socket.
  3887. socket_close($socket);
  3888. return $latency;
  3889. }
  3890. /**
  3891. * Calculate a checksum.
  3892. *
  3893. * @param string $data
  3894. * Data for which checksum will be calculated.
  3895. *
  3896. * @return string
  3897. * Binary string checksum of $data.
  3898. */
  3899. private function calculateChecksum($data) {
  3900. if (strlen($data) % 2) {
  3901. $data .= "\x00";
  3902. }
  3903. $bit = unpack('n*', $data);
  3904. $sum = array_sum($bit);
  3905. while ($sum >> 16) {
  3906. $sum = ($sum >> 16) + ($sum & 0xffff);
  3907. }
  3908. return pack('n*', ~$sum);
  3909. }
  3910. }
  3911. function ping($pings, $type = "string") {
  3912. $ping = new Ping("");
  3913. $ping->setTtl(128);
  3914. $ping->setTimeout(2);
  3915. switch ($type){
  3916. case "array":
  3917. $results = [];
  3918. foreach ($pings as $k => $v) {
  3919. if(strpos($v, ':') !== false){
  3920. $domain = explode(':', $v)[0];
  3921. $port = explode(':', $v)[1];
  3922. $ping->setHost($domain);
  3923. $ping->setPort($port);
  3924. $latency = $ping->ping('fsockopen');
  3925. }else{
  3926. $ping->setHost($v);
  3927. $latency = $ping->ping();
  3928. }
  3929. if ($latency || $latency === 0) {
  3930. $results[$k] = $latency;
  3931. } else {
  3932. $results[$k] = 0;
  3933. }
  3934. }
  3935. break;
  3936. case "string":
  3937. if(strpos($pings, ':') !== false){
  3938. $domain = explode(':', $pings)[0];
  3939. $port = explode(':', $pings)[1];
  3940. $ping->setHost($domain);
  3941. $ping->setPort($port);
  3942. $latency = $ping->ping('fsockopen');
  3943. }else{
  3944. $ping->setHost($pings);
  3945. $latency = $ping->ping();
  3946. }
  3947. if ($latency || $latency === 0) {
  3948. $results = $latency;
  3949. } else {
  3950. $results = 0;
  3951. }
  3952. break;
  3953. }
  3954. return $results;
  3955. }
  3956. function getPing($url, $style, $refresh = null){
  3957. if(ping($url) !== 0){
  3958. $class = 'success';
  3959. if(!$refresh){
  3960. $class .= " animated slideInLeft";
  3961. }
  3962. }else{
  3963. $class = "warning";
  3964. if(!$refresh){
  3965. $class .= " animated flash loop-animation-timeout";
  3966. }
  3967. }
  3968. echo '<span class="badge ping-'.$class.'" style="position: absolute;z-index: 100;right: 5px; padding: 0px 0px;'.$style.';font-size: 10px;">&nbsp;</span>';
  3969. }
  3970. function speedTestData(){
  3971. $file_db = DATABASE_LOCATION."speedtest.db";
  3972. if(file_exists($file_db)){
  3973. $conn = new PDO("sqlite:$file_db") or die("1");
  3974. $result = $conn->query('SELECT * FROM speedtest_users');
  3975. $conn = null;
  3976. if (is_array($result) || is_object($result)){
  3977. foreach($result as $k => $v){
  3978. $return[$k] = $v;
  3979. }
  3980. return $return;
  3981. }
  3982. }
  3983. }
  3984. function speedTestDisplay($array, $output){
  3985. if (is_array($array) || is_object($array)){
  3986. if($output == "graph"){
  3987. $result = "Morris.Line({element: 'morris-line',data: [";
  3988. foreach($array as $k => $v){
  3989. $result .= "{ y: '".substr($v['timestamp'],0,10)."', a: ".$v['ul'].", b: ".$v['dl'].", c: ".$v['ping']." },";
  3990. }
  3991. $result .= "],xkey: 'y',ykeys: ['a', 'b', 'c'],labels: ['Upload', 'Download', 'Ping'],hideHover: 'auto',resize: true,lineColors: ['#63A8EB','#ccc','#000'] });";
  3992. }elseif($output == "table"){
  3993. $result = "";
  3994. foreach($array as $k => $v){
  3995. $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>";
  3996. }
  3997. }
  3998. return $result;
  3999. }
  4000. }
  4001. function buildMenuPhone($array){
  4002. if (is_array($array) || is_object($array)){
  4003. $result = '
  4004. <div class="content-box profile-sidebar box-shadow">
  4005. <img src="images/organizr-logo-h-d.png" width="100%" style="margin-top: -10px;">
  4006. <div class="profile-usermenu">
  4007. <ul class="nav" id="settings-list">
  4008. ';
  4009. foreach($array as $k => $v){
  4010. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4011. continue;
  4012. }
  4013. /*$result .= '
  4014. <li>
  4015. <a id="'.$v['id'].'" box="'.$v['box'].'">'.$v['name'].'
  4016. <span class="fa-stack fa-fw pull-right" style="margin-top: -5px;margin-right: -10px;">
  4017. <i class="fa fa-'.$v['icon_1'].' fa-stack-2x '.$v['color'].'" style="font-size:null;"></i>
  4018. <i class="fa fa-'.$v['icon_2'].' fa-stack-1x fa-inverse"></i>
  4019. </span>
  4020. </a>
  4021. </li>
  4022. ';*/
  4023. $result .= '<li><a id="'.$v['id'].'" box="'.$v['box'].'"><i class="fa fa-'.$v['icon_2'].' '.$v['color'].' pull-right"></i>'.$v['name'].'</a></li>';
  4024. }
  4025. $result .= '</ul></div></div>';
  4026. return $result;
  4027. }
  4028. }
  4029. function buildMenu($array){
  4030. if (is_array($array) || is_object($array)){
  4031. $result = '<div class="settingsList">';
  4032. foreach($array as $k => $v){
  4033. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4034. continue;
  4035. }
  4036. $result .= '
  4037. <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">
  4038. <i class="fa fa-'.$v['icon_2'].' fa-fw pull-left" style="padding-left: '.$v['padding'].'px;font-size: 25px"></i>
  4039. <p class="" style="text-align: center;direction: rtl;display:none;margin: 2px;"><strong>'.$v['name'].'</strong></p>
  4040. </button>
  4041. ';
  4042. }
  4043. $result .= '</div>';
  4044. return $result;
  4045. }
  4046. }
  4047. function requestInvite($email, $username){
  4048. //sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null){
  4049. //orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  4050. 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."));
  4051. }
  4052. function errormessage($msg) {
  4053. echo "<div style=\"margin-top: 50px;\">";
  4054. echo "<span style=\"color:#d89334;\">error </span>";
  4055. echo $msg;
  4056. echo "</div>";
  4057. }
  4058. class Mobile_Detect
  4059. {
  4060. /**
  4061. * Mobile detection type.
  4062. *
  4063. * @deprecated since version 2.6.9
  4064. */
  4065. const DETECTION_TYPE_MOBILE = 'mobile';
  4066. /**
  4067. * Extended detection type.
  4068. *
  4069. * @deprecated since version 2.6.9
  4070. */
  4071. const DETECTION_TYPE_EXTENDED = 'extended';
  4072. /**
  4073. * A frequently used regular expression to extract version #s.
  4074. *
  4075. * @deprecated since version 2.6.9
  4076. */
  4077. const VER = '([\w._\+]+)';
  4078. /**
  4079. * Top-level device.
  4080. */
  4081. const MOBILE_GRADE_A = 'A';
  4082. /**
  4083. * Mid-level device.
  4084. */
  4085. const MOBILE_GRADE_B = 'B';
  4086. /**
  4087. * Low-level device.
  4088. */
  4089. const MOBILE_GRADE_C = 'C';
  4090. /**
  4091. * Stores the version number of the current release.
  4092. */
  4093. const VERSION = '2.8.26';
  4094. /**
  4095. * A type for the version() method indicating a string return value.
  4096. */
  4097. const VERSION_TYPE_STRING = 'text';
  4098. /**
  4099. * A type for the version() method indicating a float return value.
  4100. */
  4101. const VERSION_TYPE_FLOAT = 'float';
  4102. /**
  4103. * A cache for resolved matches
  4104. * @var array
  4105. */
  4106. protected $cache = array();
  4107. /**
  4108. * The User-Agent HTTP header is stored in here.
  4109. * @var string
  4110. */
  4111. protected $userAgent = null;
  4112. /**
  4113. * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
  4114. * @var array
  4115. */
  4116. protected $httpHeaders = array();
  4117. /**
  4118. * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
  4119. * @var array
  4120. */
  4121. protected $cloudfrontHeaders = array();
  4122. /**
  4123. * The matching Regex.
  4124. * This is good for debug.
  4125. * @var string
  4126. */
  4127. protected $matchingRegex = null;
  4128. /**
  4129. * The matches extracted from the regex expression.
  4130. * This is good for debug.
  4131. * @var string
  4132. */
  4133. protected $matchesArray = null;
  4134. /**
  4135. * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
  4136. *
  4137. * @deprecated since version 2.6.9
  4138. *
  4139. * @var string
  4140. */
  4141. protected $detectionType = self::DETECTION_TYPE_MOBILE;
  4142. /**
  4143. * HTTP headers that trigger the 'isMobile' detection
  4144. * to be true.
  4145. *
  4146. * @var array
  4147. */
  4148. protected static $mobileHeaders = array(
  4149. 'HTTP_ACCEPT' => array('matches' => array(
  4150. // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
  4151. 'application/x-obml2d',
  4152. // BlackBerry devices.
  4153. 'application/vnd.rim.html',
  4154. 'text/vnd.wap.wml',
  4155. 'application/vnd.wap.xhtml+xml'
  4156. )),
  4157. 'HTTP_X_WAP_PROFILE' => null,
  4158. 'HTTP_X_WAP_CLIENTID' => null,
  4159. 'HTTP_WAP_CONNECTION' => null,
  4160. 'HTTP_PROFILE' => null,
  4161. // Reported by Opera on Nokia devices (eg. C3).
  4162. 'HTTP_X_OPERAMINI_PHONE_UA' => null,
  4163. 'HTTP_X_NOKIA_GATEWAY_ID' => null,
  4164. 'HTTP_X_ORANGE_ID' => null,
  4165. 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
  4166. 'HTTP_X_HUAWEI_USERID' => null,
  4167. // Reported by Windows Smartphones.
  4168. 'HTTP_UA_OS' => null,
  4169. // Reported by Verizon, Vodafone proxy system.
  4170. 'HTTP_X_MOBILE_GATEWAY' => null,
  4171. // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
  4172. 'HTTP_X_ATT_DEVICEID' => null,
  4173. // Seen this on a HTC.
  4174. 'HTTP_UA_CPU' => array('matches' => array('ARM')),
  4175. );
  4176. /**
  4177. * List of mobile devices (phones).
  4178. *
  4179. * @var array
  4180. */
  4181. protected static $phoneDevices = array(
  4182. 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
  4183. 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
  4184. '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',
  4185. 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
  4186. // @todo: Is 'Dell Streak' a tablet or a phone? ;)
  4187. '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',
  4188. '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',
  4189. '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',
  4190. '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)',
  4191. 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
  4192. 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
  4193. 'NokiaLumia' => 'Lumia [0-9]{3,4}',
  4194. // http://www.micromaxinfo.com/mobiles/smartphones
  4195. // Added because the codes might conflict with Acer Tablets.
  4196. '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',
  4197. // @todo Complete the regex.
  4198. 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
  4199. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
  4200. // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
  4201. // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
  4202. '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',
  4203. // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
  4204. 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
  4205. // http://fr.wikomobile.com
  4206. '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',
  4207. 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
  4208. // Added simvalley mobile just for fun. They have some interesting devices.
  4209. // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
  4210. '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',
  4211. // Wolfgang - a brand that is sold by Aldi supermarkets.
  4212. // http://www.wolfgangmobile.com/
  4213. 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
  4214. 'Alcatel' => 'Alcatel',
  4215. 'Nintendo' => 'Nintendo 3DS',
  4216. // http://en.wikipedia.org/wiki/Amoi
  4217. 'Amoi' => 'Amoi',
  4218. // http://en.wikipedia.org/wiki/INQ
  4219. 'INQ' => 'INQ',
  4220. // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
  4221. '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',
  4222. );
  4223. /**
  4224. * List of tablet devices.
  4225. *
  4226. * @var array
  4227. */
  4228. protected static $tabletDevices = array(
  4229. // @todo: check for mobile friendly emails topic.
  4230. 'iPad' => 'iPad|iPad.*Mobile',
  4231. // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
  4232. // @see #442
  4233. 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
  4234. '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.
  4235. // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
  4236. '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)',
  4237. // Only the Surface tablets with Windows RT are considered mobile.
  4238. // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
  4239. 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
  4240. // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
  4241. 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
  4242. // Watch out for PadFone, see #132.
  4243. // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
  4244. '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',
  4245. 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
  4246. 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
  4247. 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
  4248. 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
  4249. // http://www.acer.ro/ac/ro/RO/content/drivers
  4250. // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
  4251. // http://us.acer.com/ac/en/US/content/group/tablets
  4252. // http://www.acer.de/ac/de/DE/content/models/tablets/
  4253. // Can conflict with Micromax and Motorola phones codes.
  4254. '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',
  4255. // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
  4256. // http://us.toshiba.com/tablets/tablet-finder
  4257. // http://www.toshiba.co.jp/regza/tablet/
  4258. 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
  4259. // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
  4260. // http://www.lg.com/us/tablets
  4261. 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
  4262. 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
  4263. // Prestigio Tablets http://www.prestigio.com/support
  4264. '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',
  4265. // http://support.lenovo.com/en_GB/downloads/default.page?#
  4266. '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|)',
  4267. // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
  4268. 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
  4269. // http://www.yarvik.com/en/matrix/tablets/
  4270. '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',
  4271. 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
  4272. 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
  4273. // http://www.intenso.de/kategorie_en.php?kategorie=33
  4274. // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
  4275. 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
  4276. // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
  4277. 'IRUTablet' => 'M702pro',
  4278. 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
  4279. // http://www.e-boda.ro/tablete-pc.html
  4280. 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
  4281. // http://www.allview.ro/produse/droseries/lista-tablete-pc/
  4282. 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
  4283. // http://wiki.archosfans.com/index.php?title=Main_Page
  4284. // @note Rewrite the regex format after we add more UAs.
  4285. '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',
  4286. // http://www.ainol.com/plugin.php?identifier=ainol&module=product
  4287. 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
  4288. 'NokiaLumiaTablet' => 'Lumia 2520',
  4289. // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
  4290. // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
  4291. // http://www.sony.jp/support/tablet/
  4292. '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',
  4293. // 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
  4294. 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
  4295. // db + http://www.cube-tablet.com/buy-products.html
  4296. 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
  4297. // http://www.cobyusa.com/?p=pcat&pcat_id=3001
  4298. 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
  4299. // http://www.match.net.cn/products.asp
  4300. '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',
  4301. // http://www.msi.com/support
  4302. // @todo Research the Windows Tablets.
  4303. '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',
  4304. // @todo http://www.kyoceramobile.com/support/drivers/
  4305. // 'KyoceraTablet' => null,
  4306. // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
  4307. // 'IntextTablet' => null,
  4308. // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
  4309. // http://www.imp3.net/14/show.php?itemid=20454
  4310. 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
  4311. // http://www.rock-chips.com/index.php?do=prod&pid=2
  4312. 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
  4313. // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
  4314. 'FlyTablet' => 'IQ310|Fly Vision',
  4315. // http://www.bqreaders.com/gb/tablets-prices-sale.html
  4316. 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
  4317. // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
  4318. // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
  4319. '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',
  4320. // Nec or Medias Tab
  4321. 'NecTablet' => '\bN-06D|\bN-08D',
  4322. // Pantech Tablets: http://www.pantechusa.com/phones/
  4323. 'PantechTablet' => 'Pantech.*P4100',
  4324. // Broncho Tablets: http://www.broncho.cn/ (hard to find)
  4325. 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
  4326. // http://versusuk.com/support.html
  4327. 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
  4328. // http://www.zync.in/index.php/our-products/tablet-phablets
  4329. 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
  4330. // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
  4331. 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
  4332. // https://www.nabitablet.com/
  4333. 'NabiTablet' => 'Android.*\bNabi',
  4334. 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
  4335. // French Danew Tablets http://www.danew.com/produits-tablette.php
  4336. 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
  4337. // Texet Tablets and Readers http://www.texet.ru/tablet/
  4338. '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',
  4339. // Avoid detecting 'PLAYSTATION 3' as mobile.
  4340. 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
  4341. // http://www.trekstor.de/surftabs.html
  4342. 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
  4343. // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
  4344. 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
  4345. // http://www.advandigital.com/index.php?link=content-product&jns=JP001
  4346. // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
  4347. '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 ',
  4348. // http://www.danytech.com/category/tablet-pc
  4349. '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',
  4350. // http://www.galapad.net/product.html
  4351. 'GalapadTablet' => 'Android.*\bG1\b',
  4352. // http://www.micromaxinfo.com/tablet/funbook
  4353. 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
  4354. // http://www.karbonnmobiles.com/products_tablet.php
  4355. 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
  4356. // http://www.myallfine.com/Products.asp
  4357. 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
  4358. // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
  4359. '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',
  4360. // http://www.yonesnav.com/products/products.php
  4361. 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
  4362. // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
  4363. // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
  4364. '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',
  4365. // http://www.gloryunion.cn/products.asp
  4366. // http://www.allwinnertech.com/en/apply/mobile.html
  4367. // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
  4368. // @todo: Softwiner tablets?
  4369. // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
  4370. '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
  4371. // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
  4372. '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',
  4373. // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
  4374. // @todo: add more tests.
  4375. 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
  4376. // http://hclmetablet.com/India/index.php
  4377. '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',
  4378. // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
  4379. 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
  4380. // http://www.visture.com/index.asp
  4381. 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
  4382. // http://www.mijncresta.nl/tablet
  4383. 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
  4384. // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
  4385. 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
  4386. // Concorde tab
  4387. 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
  4388. // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
  4389. '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',
  4390. // Modecom Tablets - http://www.modecom.eu/tablets/portal/
  4391. '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',
  4392. // Vonino Tablets - http://www.vonino.eu/tablets
  4393. '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',
  4394. // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
  4395. 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
  4396. // Storex Tablets - http://storex.fr/espace_client/support.html
  4397. // @note: no need to add all the tablet codes since they are guided by the first regex.
  4398. 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
  4399. // Generic Vodafone tablets.
  4400. 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
  4401. // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
  4402. // Aka: http://www.essentielb.fr/
  4403. 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
  4404. // Ross & Moor - http://ross-moor.ru/
  4405. 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
  4406. // i-mobile http://product.i-mobilephone.com/Mobile_Device
  4407. 'iMobileTablet' => 'i-mobile i-note',
  4408. // http://www.tolino.de/de/vergleichen/
  4409. 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
  4410. // AudioSonic - a Kmart brand
  4411. // 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
  4412. 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
  4413. // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
  4414. // @todo: add them gradually to avoid conflicts.
  4415. 'AMPETablet' => 'Android.* A78 ',
  4416. // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
  4417. 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
  4418. // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
  4419. 'TecnoTablet' => 'TECNO P9',
  4420. // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
  4421. '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',
  4422. // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
  4423. '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)',
  4424. // http://www.intracon.eu/tablet
  4425. 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
  4426. // http://www.xoro.de/produkte/
  4427. // @note: Might be the same brand with 'Simply tablets'
  4428. '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',
  4429. // http://www1.viewsonic.com/products/computing/tablets/
  4430. 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
  4431. // http://www.odys.de/web/internet-tablet_en.html
  4432. 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
  4433. // http://www.captiva-power.de/products.html#tablets-en
  4434. 'CaptivaTablet' => 'CAPTIVA PAD',
  4435. // IconBIT - http://www.iconbit.com/products/tablets/
  4436. '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',
  4437. // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
  4438. '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',
  4439. // Onda - http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
  4440. '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]+',
  4441. 'JaytechTablet' => 'TPC-PA762',
  4442. 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
  4443. // http://www.digma.ru/support/download/
  4444. // @todo: Ebooks also (if requested)
  4445. 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
  4446. // http://www.evolioshop.com/ro/tablete-pc.html
  4447. // http://www.evolio.ro/support/downloads_static.html?cat=2
  4448. // @todo: Research some more
  4449. 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
  4450. // @todo http://www.lavamobiles.com/tablets-data-cards
  4451. 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
  4452. // http://www.breezetablet.com/
  4453. 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
  4454. // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
  4455. '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',
  4456. // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
  4457. 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
  4458. // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
  4459. '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',
  4460. // http://www.mi.com/en
  4461. 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
  4462. // http://www.nbru.cn/index.html
  4463. 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
  4464. // http://navroad.com/products/produkty/tablety/
  4465. // http://navroad.com/products/produkty/tablety/
  4466. 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
  4467. // http://leader-online.com/new_site/product-category/tablets/
  4468. // http://www.leader-online.net.au/List/Tablet
  4469. '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',
  4470. // http://www.datawind.com/ubislate/
  4471. 'UbislateTablet' => 'UbiSlate[\s]?7C',
  4472. // http://www.pocketbook-int.com/ru/support
  4473. 'PocketBookTablet' => 'Pocketbook',
  4474. // http://www.kocaso.com/product_tablet.html
  4475. 'KocasoTablet' => '\b(TB-1207)\b',
  4476. // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
  4477. 'HisenseTablet' => '\b(F5281|E2371)\b',
  4478. // http://www.tesco.com/direct/hudl/
  4479. 'Hudl' => 'Hudl HT7S3|Hudl 2',
  4480. // http://www.telstra.com.au/home-phone/thub-2/
  4481. 'TelstraTablet' => 'T-Hub2',
  4482. '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'
  4483. );
  4484. /**
  4485. * List of mobile Operating Systems.
  4486. *
  4487. * @var array
  4488. */
  4489. protected static $operatingSystems = array(
  4490. 'AndroidOS' => 'Android',
  4491. 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
  4492. 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
  4493. 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
  4494. // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
  4495. 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
  4496. // @reference: http://en.wikipedia.org/wiki/Windows_Phone
  4497. // http://wifeng.cn/?r=blog&a=view&id=106
  4498. // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
  4499. // http://msdn.microsoft.com/library/ms537503.aspx
  4500. // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
  4501. 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
  4502. 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
  4503. // http://en.wikipedia.org/wiki/MeeGo
  4504. // @todo: research MeeGo in UAs
  4505. 'MeeGoOS' => 'MeeGo',
  4506. // http://en.wikipedia.org/wiki/Maemo
  4507. // @todo: research Maemo in UAs
  4508. 'MaemoOS' => 'Maemo',
  4509. 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
  4510. 'webOS' => 'webOS|hpwOS',
  4511. 'badaOS' => '\bBada\b',
  4512. 'BREWOS' => 'BREW',
  4513. );
  4514. /**
  4515. * List of mobile User Agents.
  4516. *
  4517. * IMPORTANT: This is a list of only mobile browsers.
  4518. * Mobile Detect 2.x supports only mobile browsers,
  4519. * it was never designed to detect all browsers.
  4520. * The change will come in 2017 in the 3.x release for PHP7.
  4521. *
  4522. * @var array
  4523. */
  4524. protected static $browsers = array(
  4525. //'Vivaldi' => 'Vivaldi',
  4526. // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
  4527. 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
  4528. 'Dolfin' => '\bDolfin\b',
  4529. 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
  4530. 'Skyfire' => 'Skyfire',
  4531. 'Edge' => 'Mobile Safari/[.0-9]* Edge',
  4532. 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
  4533. 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
  4534. 'Bolt' => 'bolt',
  4535. 'TeaShark' => 'teashark',
  4536. 'Blazer' => 'Blazer',
  4537. // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
  4538. 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
  4539. // http://en.wikipedia.org/wiki/Midori_(web_browser)
  4540. //'Midori' => 'midori',
  4541. //'Tizen' => 'Tizen',
  4542. 'UCBrowser' => 'UC.*Browser|UCWEB',
  4543. 'baiduboxapp' => 'baiduboxapp',
  4544. 'baidubrowser' => 'baidubrowser',
  4545. // https://github.com/serbanghita/Mobile-Detect/issues/7
  4546. 'DiigoBrowser' => 'DiigoBrowser',
  4547. // http://www.puffinbrowser.com/index.php
  4548. 'Puffin' => 'Puffin',
  4549. // http://mercury-browser.com/index.html
  4550. 'Mercury' => '\bMercury\b',
  4551. // http://en.wikipedia.org/wiki/Obigo_Browser
  4552. 'ObigoBrowser' => 'Obigo',
  4553. // http://en.wikipedia.org/wiki/NetFront
  4554. 'NetFront' => 'NF-Browser',
  4555. // @reference: http://en.wikipedia.org/wiki/Minimo
  4556. // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
  4557. 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
  4558. // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
  4559. 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
  4560. );
  4561. /**
  4562. * Utilities.
  4563. *
  4564. * @var array
  4565. */
  4566. protected static $utilities = array(
  4567. // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
  4568. // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
  4569. // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
  4570. // https://developers.facebook.com/docs/sharing/best-practices
  4571. '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',
  4572. 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
  4573. 'DesktopMode' => 'WPDesktop',
  4574. 'TV' => 'SonyDTV|HbbTV', // experimental
  4575. 'WebKit' => '(webkit)[ /]([\w.]+)',
  4576. // @todo: Include JXD consoles.
  4577. 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
  4578. 'Watch' => 'SM-V700',
  4579. );
  4580. /**
  4581. * All possible HTTP headers that represent the
  4582. * User-Agent string.
  4583. *
  4584. * @var array
  4585. */
  4586. protected static $uaHttpHeaders = array(
  4587. // The default User-Agent string.
  4588. 'HTTP_USER_AGENT',
  4589. // Header can occur on devices using Opera Mini.
  4590. 'HTTP_X_OPERAMINI_PHONE_UA',
  4591. // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
  4592. 'HTTP_X_DEVICE_USER_AGENT',
  4593. 'HTTP_X_ORIGINAL_USER_AGENT',
  4594. 'HTTP_X_SKYFIRE_PHONE',
  4595. 'HTTP_X_BOLT_PHONE_UA',
  4596. 'HTTP_DEVICE_STOCK_UA',
  4597. 'HTTP_X_UCBROWSER_DEVICE_UA'
  4598. );
  4599. /**
  4600. * The individual segments that could exist in a User-Agent string. VER refers to the regular
  4601. * expression defined in the constant self::VER.
  4602. *
  4603. * @var array
  4604. */
  4605. protected static $properties = array(
  4606. // Build
  4607. 'Mobile' => 'Mobile/[VER]',
  4608. 'Build' => 'Build/[VER]',
  4609. 'Version' => 'Version/[VER]',
  4610. 'VendorID' => 'VendorID/[VER]',
  4611. // Devices
  4612. 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
  4613. 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
  4614. 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
  4615. //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
  4616. 'Kindle' => 'Kindle/[VER]',
  4617. // Browser
  4618. 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
  4619. 'Coast' => array('Coast/[VER]'),
  4620. 'Dolfin' => 'Dolfin/[VER]',
  4621. // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
  4622. 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
  4623. 'Fennec' => 'Fennec/[VER]',
  4624. // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  4625. // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
  4626. 'Edge' => 'Edge/[VER]',
  4627. 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
  4628. // http://en.wikipedia.org/wiki/NetFront
  4629. 'NetFront' => 'NetFront/[VER]',
  4630. 'NokiaBrowser' => 'NokiaBrowser/[VER]',
  4631. 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
  4632. 'Opera Mini' => 'Opera Mini/[VER]',
  4633. 'Opera Mobi' => 'Version/[VER]',
  4634. 'UC Browser' => 'UC Browser[VER]',
  4635. 'MQQBrowser' => 'MQQBrowser/[VER]',
  4636. 'MicroMessenger' => 'MicroMessenger/[VER]',
  4637. 'baiduboxapp' => 'baiduboxapp/[VER]',
  4638. 'baidubrowser' => 'baidubrowser/[VER]',
  4639. 'SamsungBrowser' => 'SamsungBrowser/[VER]',
  4640. 'Iron' => 'Iron/[VER]',
  4641. // @note: Safari 7534.48.3 is actually Version 5.1.
  4642. // @note: On BlackBerry the Version is overwriten by the OS.
  4643. 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
  4644. 'Skyfire' => 'Skyfire/[VER]',
  4645. 'Tizen' => 'Tizen/[VER]',
  4646. 'Webkit' => 'webkit[ /][VER]',
  4647. 'PaleMoon' => 'PaleMoon/[VER]',
  4648. // Engine
  4649. 'Gecko' => 'Gecko/[VER]',
  4650. 'Trident' => 'Trident/[VER]',
  4651. 'Presto' => 'Presto/[VER]',
  4652. 'Goanna' => 'Goanna/[VER]',
  4653. // OS
  4654. 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
  4655. 'Android' => 'Android [VER]',
  4656. 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
  4657. 'BREW' => 'BREW [VER]',
  4658. 'Java' => 'Java/[VER]',
  4659. // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
  4660. // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
  4661. 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
  4662. 'Windows Phone' => 'Windows Phone [VER]',
  4663. 'Windows CE' => 'Windows CE/[VER]',
  4664. // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
  4665. 'Windows NT' => 'Windows NT [VER]',
  4666. 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
  4667. 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
  4668. );
  4669. /**
  4670. * Construct an instance of this class.
  4671. *
  4672. * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
  4673. * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
  4674. * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
  4675. * from the $headers array instead.
  4676. */
  4677. public function __construct(
  4678. array $headers = null,
  4679. $userAgent = null
  4680. ) {
  4681. $this->setHttpHeaders($headers);
  4682. $this->setUserAgent($userAgent);
  4683. }
  4684. /**
  4685. * Get the current script version.
  4686. * This is useful for the demo.php file,
  4687. * so people can check on what version they are testing
  4688. * for mobile devices.
  4689. *
  4690. * @return string The version number in semantic version format.
  4691. */
  4692. public static function getScriptVersion()
  4693. {
  4694. return self::VERSION;
  4695. }
  4696. /**
  4697. * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
  4698. *
  4699. * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
  4700. * the headers. The default null is left for backwards compatibility.
  4701. */
  4702. public function setHttpHeaders($httpHeaders = null)
  4703. {
  4704. // use global _SERVER if $httpHeaders aren't defined
  4705. if (!is_array($httpHeaders) || !count($httpHeaders)) {
  4706. $httpHeaders = $_SERVER;
  4707. }
  4708. // clear existing headers
  4709. $this->httpHeaders = array();
  4710. // Only save HTTP headers. In PHP land, that means only _SERVER vars that
  4711. // start with HTTP_.
  4712. foreach ($httpHeaders as $key => $value) {
  4713. if (substr($key, 0, 5) === 'HTTP_') {
  4714. $this->httpHeaders[$key] = $value;
  4715. }
  4716. }
  4717. // In case we're dealing with CloudFront, we need to know.
  4718. $this->setCfHeaders($httpHeaders);
  4719. }
  4720. /**
  4721. * Retrieves the HTTP headers.
  4722. *
  4723. * @return array
  4724. */
  4725. public function getHttpHeaders()
  4726. {
  4727. return $this->httpHeaders;
  4728. }
  4729. /**
  4730. * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
  4731. * Simply null is returned.
  4732. *
  4733. * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
  4734. * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
  4735. * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
  4736. *
  4737. * @return string|null The value of the header.
  4738. */
  4739. public function getHttpHeader($header)
  4740. {
  4741. // are we using PHP-flavored headers?
  4742. if (strpos($header, '_') === false) {
  4743. $header = str_replace('-', '_', $header);
  4744. $header = strtoupper($header);
  4745. }
  4746. // test the alternate, too
  4747. $altHeader = 'HTTP_' . $header;
  4748. //Test both the regular and the HTTP_ prefix
  4749. if (isset($this->httpHeaders[$header])) {
  4750. return $this->httpHeaders[$header];
  4751. } elseif (isset($this->httpHeaders[$altHeader])) {
  4752. return $this->httpHeaders[$altHeader];
  4753. }
  4754. return null;
  4755. }
  4756. public function getMobileHeaders()
  4757. {
  4758. return self::$mobileHeaders;
  4759. }
  4760. /**
  4761. * Get all possible HTTP headers that
  4762. * can contain the User-Agent string.
  4763. *
  4764. * @return array List of HTTP headers.
  4765. */
  4766. public function getUaHttpHeaders()
  4767. {
  4768. return self::$uaHttpHeaders;
  4769. }
  4770. /**
  4771. * Set CloudFront headers
  4772. * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
  4773. *
  4774. * @param array $cfHeaders List of HTTP headers
  4775. *
  4776. * @return boolean If there were CloudFront headers to be set
  4777. */
  4778. public function setCfHeaders($cfHeaders = null) {
  4779. // use global _SERVER if $cfHeaders aren't defined
  4780. if (!is_array($cfHeaders) || !count($cfHeaders)) {
  4781. $cfHeaders = $_SERVER;
  4782. }
  4783. // clear existing headers
  4784. $this->cloudfrontHeaders = array();
  4785. // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
  4786. // start with cloudfront-.
  4787. $response = false;
  4788. foreach ($cfHeaders as $key => $value) {
  4789. if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
  4790. $this->cloudfrontHeaders[strtoupper($key)] = $value;
  4791. $response = true;
  4792. }
  4793. }
  4794. return $response;
  4795. }
  4796. /**
  4797. * Retrieves the cloudfront headers.
  4798. *
  4799. * @return array
  4800. */
  4801. public function getCfHeaders()
  4802. {
  4803. return $this->cloudfrontHeaders;
  4804. }
  4805. /**
  4806. * Set the User-Agent to be used.
  4807. *
  4808. * @param string $userAgent The user agent string to set.
  4809. *
  4810. * @return string|null
  4811. */
  4812. public function setUserAgent($userAgent = null)
  4813. {
  4814. // Invalidate cache due to #375
  4815. $this->cache = array();
  4816. if (false === empty($userAgent)) {
  4817. return $this->userAgent = $userAgent;
  4818. } else {
  4819. $this->userAgent = null;
  4820. foreach ($this->getUaHttpHeaders() as $altHeader) {
  4821. if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
  4822. $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
  4823. }
  4824. }
  4825. if (!empty($this->userAgent)) {
  4826. return $this->userAgent = trim($this->userAgent);
  4827. }
  4828. }
  4829. if (count($this->getCfHeaders()) > 0) {
  4830. return $this->userAgent = 'Amazon CloudFront';
  4831. }
  4832. return $this->userAgent = null;
  4833. }
  4834. /**
  4835. * Retrieve the User-Agent.
  4836. *
  4837. * @return string|null The user agent if it's set.
  4838. */
  4839. public function getUserAgent()
  4840. {
  4841. return $this->userAgent;
  4842. }
  4843. /**
  4844. * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
  4845. * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
  4846. *
  4847. * @deprecated since version 2.6.9
  4848. *
  4849. * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
  4850. * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
  4851. */
  4852. public function setDetectionType($type = null)
  4853. {
  4854. if ($type === null) {
  4855. $type = self::DETECTION_TYPE_MOBILE;
  4856. }
  4857. if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
  4858. return;
  4859. }
  4860. $this->detectionType = $type;
  4861. }
  4862. public function getMatchingRegex()
  4863. {
  4864. return $this->matchingRegex;
  4865. }
  4866. public function getMatchesArray()
  4867. {
  4868. return $this->matchesArray;
  4869. }
  4870. /**
  4871. * Retrieve the list of known phone devices.
  4872. *
  4873. * @return array List of phone devices.
  4874. */
  4875. public static function getPhoneDevices()
  4876. {
  4877. return self::$phoneDevices;
  4878. }
  4879. /**
  4880. * Retrieve the list of known tablet devices.
  4881. *
  4882. * @return array List of tablet devices.
  4883. */
  4884. public static function getTabletDevices()
  4885. {
  4886. return self::$tabletDevices;
  4887. }
  4888. /**
  4889. * Alias for getBrowsers() method.
  4890. *
  4891. * @return array List of user agents.
  4892. */
  4893. public static function getUserAgents()
  4894. {
  4895. return self::getBrowsers();
  4896. }
  4897. /**
  4898. * Retrieve the list of known browsers. Specifically, the user agents.
  4899. *
  4900. * @return array List of browsers / user agents.
  4901. */
  4902. public static function getBrowsers()
  4903. {
  4904. return self::$browsers;
  4905. }
  4906. /**
  4907. * Retrieve the list of known utilities.
  4908. *
  4909. * @return array List of utilities.
  4910. */
  4911. public static function getUtilities()
  4912. {
  4913. return self::$utilities;
  4914. }
  4915. /**
  4916. * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
  4917. *
  4918. * @deprecated since version 2.6.9
  4919. *
  4920. * @return array All the rules (but not extended).
  4921. */
  4922. public static function getMobileDetectionRules()
  4923. {
  4924. static $rules;
  4925. if (!$rules) {
  4926. $rules = array_merge(
  4927. self::$phoneDevices,
  4928. self::$tabletDevices,
  4929. self::$operatingSystems,
  4930. self::$browsers
  4931. );
  4932. }
  4933. return $rules;
  4934. }
  4935. /**
  4936. * Method gets the mobile detection rules + utilities.
  4937. * The reason this is separate is because utilities rules
  4938. * don't necessary imply mobile. This method is used inside
  4939. * the new $detect->is('stuff') method.
  4940. *
  4941. * @deprecated since version 2.6.9
  4942. *
  4943. * @return array All the rules + extended.
  4944. */
  4945. public function getMobileDetectionRulesExtended()
  4946. {
  4947. static $rules;
  4948. if (!$rules) {
  4949. // Merge all rules together.
  4950. $rules = array_merge(
  4951. self::$phoneDevices,
  4952. self::$tabletDevices,
  4953. self::$operatingSystems,
  4954. self::$browsers,
  4955. self::$utilities
  4956. );
  4957. }
  4958. return $rules;
  4959. }
  4960. /**
  4961. * Retrieve the current set of rules.
  4962. *
  4963. * @deprecated since version 2.6.9
  4964. *
  4965. * @return array
  4966. */
  4967. public function getRules()
  4968. {
  4969. if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
  4970. return self::getMobileDetectionRulesExtended();
  4971. } else {
  4972. return self::getMobileDetectionRules();
  4973. }
  4974. }
  4975. /**
  4976. * Retrieve the list of mobile operating systems.
  4977. *
  4978. * @return array The list of mobile operating systems.
  4979. */
  4980. public static function getOperatingSystems()
  4981. {
  4982. return self::$operatingSystems;
  4983. }
  4984. /**
  4985. * Check the HTTP headers for signs of mobile.
  4986. * This is the fastest mobile check possible; it's used
  4987. * inside isMobile() method.
  4988. *
  4989. * @return bool
  4990. */
  4991. public function checkHttpHeadersForMobile()
  4992. {
  4993. foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
  4994. if (isset($this->httpHeaders[$mobileHeader])) {
  4995. if (is_array($matchType['matches'])) {
  4996. foreach ($matchType['matches'] as $_match) {
  4997. if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
  4998. return true;
  4999. }
  5000. }
  5001. return false;
  5002. } else {
  5003. return true;
  5004. }
  5005. }
  5006. }
  5007. return false;
  5008. }
  5009. /**
  5010. * Magic overloading method.
  5011. *
  5012. * @method boolean is[...]()
  5013. * @param string $name
  5014. * @param array $arguments
  5015. * @return mixed
  5016. * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
  5017. */
  5018. public function __call($name, $arguments)
  5019. {
  5020. // make sure the name starts with 'is', otherwise
  5021. if (substr($name, 0, 2) !== 'is') {
  5022. throw new BadMethodCallException("No such method exists: $name");
  5023. }
  5024. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5025. $key = substr($name, 2);
  5026. return $this->matchUAAgainstKey($key);
  5027. }
  5028. /**
  5029. * Find a detection rule that matches the current User-agent.
  5030. *
  5031. * @param null $userAgent deprecated
  5032. * @return boolean
  5033. */
  5034. protected function matchDetectionRulesAgainstUA($userAgent = null)
  5035. {
  5036. // Begin general search.
  5037. foreach ($this->getRules() as $_regex) {
  5038. if (empty($_regex)) {
  5039. continue;
  5040. }
  5041. if ($this->match($_regex, $userAgent)) {
  5042. return true;
  5043. }
  5044. }
  5045. return false;
  5046. }
  5047. /**
  5048. * Search for a certain key in the rules array.
  5049. * If the key is found then try to match the corresponding
  5050. * regex against the User-Agent.
  5051. *
  5052. * @param string $key
  5053. *
  5054. * @return boolean
  5055. */
  5056. protected function matchUAAgainstKey($key)
  5057. {
  5058. // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
  5059. $key = strtolower($key);
  5060. if (false === isset($this->cache[$key])) {
  5061. // change the keys to lower case
  5062. $_rules = array_change_key_case($this->getRules());
  5063. if (false === empty($_rules[$key])) {
  5064. $this->cache[$key] = $this->match($_rules[$key]);
  5065. }
  5066. if (false === isset($this->cache[$key])) {
  5067. $this->cache[$key] = false;
  5068. }
  5069. }
  5070. return $this->cache[$key];
  5071. }
  5072. /**
  5073. * Check if the device is mobile.
  5074. * Returns true if any type of mobile device detected, including special ones
  5075. * @param null $userAgent deprecated
  5076. * @param null $httpHeaders deprecated
  5077. * @return bool
  5078. */
  5079. public function isMobile($userAgent = null, $httpHeaders = null)
  5080. {
  5081. if ($httpHeaders) {
  5082. $this->setHttpHeaders($httpHeaders);
  5083. }
  5084. if ($userAgent) {
  5085. $this->setUserAgent($userAgent);
  5086. }
  5087. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  5088. if ($this->getUserAgent() === 'Amazon CloudFront') {
  5089. $cfHeaders = $this->getCfHeaders();
  5090. if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
  5091. return true;
  5092. }
  5093. }
  5094. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5095. if ($this->checkHttpHeadersForMobile()) {
  5096. return true;
  5097. } else {
  5098. return $this->matchDetectionRulesAgainstUA();
  5099. }
  5100. }
  5101. /**
  5102. * Check if the device is a tablet.
  5103. * Return true if any type of tablet device is detected.
  5104. *
  5105. * @param string $userAgent deprecated
  5106. * @param array $httpHeaders deprecated
  5107. * @return bool
  5108. */
  5109. public function isTablet($userAgent = null, $httpHeaders = null)
  5110. {
  5111. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  5112. if ($this->getUserAgent() === 'Amazon CloudFront') {
  5113. $cfHeaders = $this->getCfHeaders();
  5114. if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
  5115. return true;
  5116. }
  5117. }
  5118. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5119. foreach (self::$tabletDevices as $_regex) {
  5120. if ($this->match($_regex, $userAgent)) {
  5121. return true;
  5122. }
  5123. }
  5124. return false;
  5125. }
  5126. /**
  5127. * This method checks for a certain property in the
  5128. * userAgent.
  5129. * @todo: The httpHeaders part is not yet used.
  5130. *
  5131. * @param string $key
  5132. * @param string $userAgent deprecated
  5133. * @param string $httpHeaders deprecated
  5134. * @return bool|int|null
  5135. */
  5136. public function is($key, $userAgent = null, $httpHeaders = null)
  5137. {
  5138. // Set the UA and HTTP headers only if needed (eg. batch mode).
  5139. if ($httpHeaders) {
  5140. $this->setHttpHeaders($httpHeaders);
  5141. }
  5142. if ($userAgent) {
  5143. $this->setUserAgent($userAgent);
  5144. }
  5145. $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
  5146. return $this->matchUAAgainstKey($key);
  5147. }
  5148. /**
  5149. * Some detection rules are relative (not standard),
  5150. * because of the diversity of devices, vendors and
  5151. * their conventions in representing the User-Agent or
  5152. * the HTTP headers.
  5153. *
  5154. * This method will be used to check custom regexes against
  5155. * the User-Agent string.
  5156. *
  5157. * @param $regex
  5158. * @param string $userAgent
  5159. * @return bool
  5160. *
  5161. * @todo: search in the HTTP headers too.
  5162. */
  5163. public function match($regex, $userAgent = null)
  5164. {
  5165. $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
  5166. // If positive match is found, store the results for debug.
  5167. if ($match) {
  5168. $this->matchingRegex = $regex;
  5169. $this->matchesArray = $matches;
  5170. }
  5171. return $match;
  5172. }
  5173. /**
  5174. * Get the properties array.
  5175. *
  5176. * @return array
  5177. */
  5178. public static function getProperties()
  5179. {
  5180. return self::$properties;
  5181. }
  5182. /**
  5183. * Prepare the version number.
  5184. *
  5185. * @todo Remove the error supression from str_replace() call.
  5186. *
  5187. * @param string $ver The string version, like "2.6.21.2152";
  5188. *
  5189. * @return float
  5190. */
  5191. public function prepareVersionNo($ver)
  5192. {
  5193. $ver = str_replace(array('_', ' ', '/'), '.', $ver);
  5194. $arrVer = explode('.', $ver, 2);
  5195. if (isset($arrVer[1])) {
  5196. $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
  5197. }
  5198. return (float) implode('.', $arrVer);
  5199. }
  5200. /**
  5201. * Check the version of the given property in the User-Agent.
  5202. * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
  5203. *
  5204. * @param string $propertyName The name of the property. See self::getProperties() array
  5205. * keys for all possible properties.
  5206. * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
  5207. * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
  5208. * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
  5209. * invalid parameter will default to the this type as well.
  5210. *
  5211. * @return string|float The version of the property we are trying to extract.
  5212. */
  5213. public function version($propertyName, $type = self::VERSION_TYPE_STRING)
  5214. {
  5215. if (empty($propertyName)) {
  5216. return false;
  5217. }
  5218. // set the $type to the default if we don't recognize the type
  5219. if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
  5220. $type = self::VERSION_TYPE_STRING;
  5221. }
  5222. $properties = self::getProperties();
  5223. // Check if the property exists in the properties array.
  5224. if (true === isset($properties[$propertyName])) {
  5225. // Prepare the pattern to be matched.
  5226. // Make sure we always deal with an array (string is converted).
  5227. $properties[$propertyName] = (array) $properties[$propertyName];
  5228. foreach ($properties[$propertyName] as $propertyMatchString) {
  5229. $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
  5230. // Identify and extract the version.
  5231. preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
  5232. if (false === empty($match[1])) {
  5233. $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
  5234. return $version;
  5235. }
  5236. }
  5237. }
  5238. return false;
  5239. }
  5240. /**
  5241. * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
  5242. *
  5243. * @return string One of the self::MOBILE_GRADE_* constants.
  5244. */
  5245. public function mobileGrade()
  5246. {
  5247. $isMobile = $this->isMobile();
  5248. if (
  5249. // 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)
  5250. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  5251. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  5252. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  5253. // 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)
  5254. // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
  5255. // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
  5256. // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
  5257. ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
  5258. // 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)
  5259. $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
  5260. // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
  5261. $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
  5262. // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
  5263. $this->match('Playbook.*Tablet') ||
  5264. // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
  5265. ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
  5266. // Palm WebOS 3.0 - Tested on HP TouchPad
  5267. $this->match('hp.*TouchPad') ||
  5268. // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
  5269. ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
  5270. // Chrome for Android - Tested on Android 4.0, 4.1 device
  5271. ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
  5272. // Skyfire 4.1 - Tested on Android 2.3 device
  5273. ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  5274. // Opera Mobile 11.5-12: Tested on Android 2.3
  5275. ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
  5276. // Meego 1.2 - Tested on Nokia 950 and N9
  5277. $this->is('MeeGoOS') ||
  5278. // Tizen (pre-release) - Tested on early hardware
  5279. $this->is('Tizen') ||
  5280. // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
  5281. // @todo: more tests here!
  5282. $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
  5283. // UC Browser - Tested on Android 2.3 device
  5284. ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  5285. // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
  5286. ( $this->match('Kindle Fire') ||
  5287. $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
  5288. // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
  5289. $this->is('AndroidOS') && $this->is('NookTablet') ||
  5290. // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
  5291. $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
  5292. // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
  5293. $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
  5294. // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
  5295. $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
  5296. // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
  5297. $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
  5298. // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
  5299. $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
  5300. ){
  5301. return self::MOBILE_GRADE_A;
  5302. }
  5303. if (
  5304. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
  5305. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
  5306. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
  5307. // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
  5308. $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
  5309. //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
  5310. ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
  5311. ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
  5312. // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
  5313. $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
  5314. // @todo: report this (tested on Nokia N71)
  5315. $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
  5316. ){
  5317. return self::MOBILE_GRADE_B;
  5318. }
  5319. if (
  5320. // Blackberry 4.x - Tested on the Curve 8330
  5321. $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
  5322. // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
  5323. $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
  5324. // Tested on original iPhone (3.1), iPhone 3 (3.2)
  5325. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  5326. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  5327. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  5328. // Internet Explorer 7 and older - Tested on Windows XP
  5329. $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
  5330. ){
  5331. return self::MOBILE_GRADE_C;
  5332. }
  5333. // All older smartphone platforms and featurephones - Any device that doesn't support media queries
  5334. // will receive the basic, C grade experience.
  5335. return self::MOBILE_GRADE_C;
  5336. }
  5337. }
  5338. $mobileDetect = new Mobile_Detect;
  5339. $userDevice = ($mobileDetect->isMobile() ? ($mobileDetect->isTablet() ? 'tablet' : 'phone') : 'computer');
  5340. function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  5341. $path = getServerPath();
  5342. return '
  5343. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5344. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  5345. <head>
  5346. <!--[if gte mso 9]><xml>
  5347. <o:OfficeDocumentSettings>
  5348. <o:AllowPNG/>
  5349. <o:PixelsPerInch>96</o:PixelsPerInch>
  5350. </o:OfficeDocumentSettings>
  5351. </xml><![endif]-->
  5352. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5353. <meta name="viewport" content="width=device-width">
  5354. <!--[if !mso]><!-->
  5355. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5356. <!--<![endif]-->
  5357. <title></title>
  5358. <!--[if !mso]><!-- -->
  5359. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
  5360. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  5361. <!--<![endif]-->
  5362. <style type="text/css" id="media-query">
  5363. body {
  5364. margin: 0;
  5365. padding: 0;
  5366. }
  5367. table,
  5368. tr,
  5369. td {
  5370. vertical-align: top;
  5371. border-collapse: collapse;
  5372. }
  5373. .ie-browser table,
  5374. .mso-container table {
  5375. table-layout: fixed;
  5376. }
  5377. * {
  5378. line-height: inherit;
  5379. }
  5380. a[x-apple-data-detectors=true] {
  5381. color: inherit !important;
  5382. text-decoration: none !important;
  5383. }
  5384. [owa] .img-container div,
  5385. [owa] .img-container button {
  5386. display: block !important;
  5387. }
  5388. [owa] .fullwidth button {
  5389. width: 100% !important;
  5390. }
  5391. [owa] .block-grid .col {
  5392. display: table-cell;
  5393. float: none !important;
  5394. vertical-align: top;
  5395. }
  5396. .ie-browser .num12,
  5397. .ie-browser .block-grid,
  5398. [owa] .num12,
  5399. [owa] .block-grid {
  5400. width: 615px !important;
  5401. }
  5402. .ExternalClass,
  5403. .ExternalClass p,
  5404. .ExternalClass span,
  5405. .ExternalClass font,
  5406. .ExternalClass td,
  5407. .ExternalClass div {
  5408. line-height: 100%;
  5409. }
  5410. .ie-browser .mixed-two-up .num4,
  5411. [owa] .mixed-two-up .num4 {
  5412. width: 204px !important;
  5413. }
  5414. .ie-browser .mixed-two-up .num8,
  5415. [owa] .mixed-two-up .num8 {
  5416. width: 408px !important;
  5417. }
  5418. .ie-browser .block-grid.two-up .col,
  5419. [owa] .block-grid.two-up .col {
  5420. width: 307px !important;
  5421. }
  5422. .ie-browser .block-grid.three-up .col,
  5423. [owa] .block-grid.three-up .col {
  5424. width: 205px !important;
  5425. }
  5426. .ie-browser .block-grid.four-up .col,
  5427. [owa] .block-grid.four-up .col {
  5428. width: 153px !important;
  5429. }
  5430. .ie-browser .block-grid.five-up .col,
  5431. [owa] .block-grid.five-up .col {
  5432. width: 123px !important;
  5433. }
  5434. .ie-browser .block-grid.six-up .col,
  5435. [owa] .block-grid.six-up .col {
  5436. width: 102px !important;
  5437. }
  5438. .ie-browser .block-grid.seven-up .col,
  5439. [owa] .block-grid.seven-up .col {
  5440. width: 87px !important;
  5441. }
  5442. .ie-browser .block-grid.eight-up .col,
  5443. [owa] .block-grid.eight-up .col {
  5444. width: 76px !important;
  5445. }
  5446. .ie-browser .block-grid.nine-up .col,
  5447. [owa] .block-grid.nine-up .col {
  5448. width: 68px !important;
  5449. }
  5450. .ie-browser .block-grid.ten-up .col,
  5451. [owa] .block-grid.ten-up .col {
  5452. width: 61px !important;
  5453. }
  5454. .ie-browser .block-grid.eleven-up .col,
  5455. [owa] .block-grid.eleven-up .col {
  5456. width: 55px !important;
  5457. }
  5458. .ie-browser .block-grid.twelve-up .col,
  5459. [owa] .block-grid.twelve-up .col {
  5460. width: 51px !important;
  5461. }
  5462. @media only screen and (min-width: 635px) {
  5463. .block-grid {
  5464. width: 615px !important;
  5465. }
  5466. .block-grid .col {
  5467. display: table-cell;
  5468. Float: none !important;
  5469. vertical-align: top;
  5470. }
  5471. .block-grid .col.num12 {
  5472. width: 615px !important;
  5473. }
  5474. .block-grid.mixed-two-up .col.num4 {
  5475. width: 204px !important;
  5476. }
  5477. .block-grid.mixed-two-up .col.num8 {
  5478. width: 408px !important;
  5479. }
  5480. .block-grid.two-up .col {
  5481. width: 307px !important;
  5482. }
  5483. .block-grid.three-up .col {
  5484. width: 205px !important;
  5485. }
  5486. .block-grid.four-up .col {
  5487. width: 153px !important;
  5488. }
  5489. .block-grid.five-up .col {
  5490. width: 123px !important;
  5491. }
  5492. .block-grid.six-up .col {
  5493. width: 102px !important;
  5494. }
  5495. .block-grid.seven-up .col {
  5496. width: 87px !important;
  5497. }
  5498. .block-grid.eight-up .col {
  5499. width: 76px !important;
  5500. }
  5501. .block-grid.nine-up .col {
  5502. width: 68px !important;
  5503. }
  5504. .block-grid.ten-up .col {
  5505. width: 61px !important;
  5506. }
  5507. .block-grid.eleven-up .col {
  5508. width: 55px !important;
  5509. }
  5510. .block-grid.twelve-up .col {
  5511. width: 51px !important;
  5512. }
  5513. }
  5514. @media (max-width: 635px) {
  5515. .block-grid,
  5516. .col {
  5517. min-width: 320px !important;
  5518. max-width: 100% !important;
  5519. }
  5520. .block-grid {
  5521. width: calc(100% - 40px) !important;
  5522. }
  5523. .col {
  5524. width: 100% !important;
  5525. }
  5526. .col>div {
  5527. margin: 0 auto;
  5528. }
  5529. img.fullwidth {
  5530. max-width: 100% !important;
  5531. }
  5532. }
  5533. </style>
  5534. </head>
  5535. <body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #FFFFFF">
  5536. <!--[if IE]><div class="ie-browser"><![endif]-->
  5537. <!--[if mso]><div class="mso-container"><![endif]-->
  5538. <div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: #FFFFFF">
  5539. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #FFFFFF;"><![endif]-->
  5540. <div style="background-color:#333333;">
  5541. <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;"
  5542. class="block-grid ">
  5543. <div style="border-collapse: collapse;display: table;width: 100%;">
  5544. <!--[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]-->
  5545. <!--[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]-->
  5546. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  5547. <div style="background-color: transparent; width: 100% !important;">
  5548. <!--[if (!mso)&(!IE)]><!-->
  5549. <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;">
  5550. <!--<![endif]-->
  5551. <div align="left" class="img-container left fullwidth" style="padding-right: 30px; padding-left: 30px;">
  5552. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px;" align="left"><![endif]-->
  5553. <img class="left fullwidth" align="left" border="0" src="'.$path.'images/organizr-logo-h.png" alt="Image" title="Image"
  5554. 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"
  5555. width="555">
  5556. <!--[if mso]></td></tr></table><![endif]-->
  5557. </div>
  5558. <!--[if (!mso)&(!IE)]><!-->
  5559. </div>
  5560. <!--<![endif]-->
  5561. </div>
  5562. </div>
  5563. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  5564. </div>
  5565. </div>
  5566. </div>
  5567. <div style="background-color:#333333;">
  5568. <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;"
  5569. class="block-grid ">
  5570. <div style="border-collapse: collapse;display: table;width: 100%;">
  5571. <!--[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]-->
  5572. <!--[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]-->
  5573. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  5574. <div style="background-color: transparent; width: 100% !important;">
  5575. <!--[if (!mso)&(!IE)]><!-->
  5576. <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;">
  5577. <!--<![endif]-->
  5578. <!--[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]-->
  5579. <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;">
  5580. <div style="font-size:12px;line-height:14px;color:#FFFFFF;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  5581. <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>
  5582. </span>
  5583. </p>
  5584. </div>
  5585. </div>
  5586. <!--[if mso]></td></tr></table><![endif]-->
  5587. <!--[if (!mso)&(!IE)]><!-->
  5588. </div>
  5589. <!--<![endif]-->
  5590. </div>
  5591. </div>
  5592. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  5593. </div>
  5594. </div>
  5595. </div>
  5596. <div style="background-color:#393939;">
  5597. <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;"
  5598. class="block-grid ">
  5599. <div style="border-collapse: collapse;display: table;width: 100%;">
  5600. <!--[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]-->
  5601. <!--[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]-->
  5602. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  5603. <div style="background-color: transparent; width: 100% !important;">
  5604. <!--[if (!mso)&(!IE)]><!-->
  5605. <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;">
  5606. <!--<![endif]-->
  5607. <!--[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]-->
  5608. <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;">
  5609. <div style="font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  5610. <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>
  5611. </div>
  5612. </div>
  5613. <!--[if mso]></td></tr></table><![endif]-->
  5614. <div style="padding-right: 5px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px;">
  5615. <!--[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]-->
  5616. <div align="center">
  5617. <div style="border-top: 2px solid #66D9EF; width:55%; line-height:2px; height:2px; font-size:2px;">&#160;</div>
  5618. </div>
  5619. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  5620. </div>
  5621. <!--[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]-->
  5622. <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;">
  5623. <div style="font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  5624. <p style="margin: 0;font-size: 12px;line-height: 14px"><span style="font-size: 28px; line-height: 33px;">Hey '.$user.',</span></p>
  5625. </div>
  5626. </div>
  5627. <!--[if mso]></td></tr></table><![endif]-->
  5628. <!--[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]-->
  5629. <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;">
  5630. <div style="font-size:12px;line-height:22px;font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;color:#FFFFFF;text-align:left;">
  5631. <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>
  5632. </span>
  5633. </p>
  5634. </div>
  5635. </div>
  5636. <!--[if mso]></td></tr></table><![endif]-->
  5637. <div align="center" class="button-container center" style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;">
  5638. <!--[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]-->
  5639. <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">
  5640. <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>
  5641. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  5642. </div>
  5643. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  5644. </div>
  5645. <!--[if (!mso)&(!IE)]><!-->
  5646. </div>
  5647. <!--<![endif]-->
  5648. </div>
  5649. </div>
  5650. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  5651. </div>
  5652. </div>
  5653. </div>
  5654. <div style="background-color:#ffffff;">
  5655. <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;"
  5656. class="block-grid ">
  5657. <div style="border-collapse: collapse;display: table;width: 100%;">
  5658. <!--[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]-->
  5659. <!--[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]-->
  5660. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  5661. <div style="background-color: transparent; width: 100% !important;">
  5662. <!--[if (!mso)&(!IE)]><!-->
  5663. <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;">
  5664. <!--<![endif]-->
  5665. <!--[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]-->
  5666. <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;">
  5667. <div style="font-size:12px;line-height:14px;color:#555555;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  5668. <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>
  5669. </div>
  5670. </div>
  5671. <!--[if mso]></td></tr></table><![endif]-->
  5672. <div style="padding-right: 20px; padding-left: 20px; padding-top: 15px; padding-bottom: 20px;">
  5673. <!--[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]-->
  5674. <div align="center">
  5675. <div style="border-top: 3px solid #66D9EF; width:40%; line-height:3px; height:3px; font-size:3px;">&#160;</div>
  5676. </div>
  5677. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  5678. </div>
  5679. <!--[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]-->
  5680. <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;">
  5681. <div style="font-size:12px;line-height:22px;color:#7E7D7D;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  5682. <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>
  5683. </div>
  5684. </div>
  5685. <!--[if mso]></td></tr></table><![endif]-->
  5686. <!--[if (!mso)&(!IE)]><!-->
  5687. </div>
  5688. <!--<![endif]-->
  5689. </div>
  5690. </div>
  5691. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  5692. </div>
  5693. </div>
  5694. </div>
  5695. <div style="background-color:#333333;">
  5696. <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;"
  5697. class="block-grid ">
  5698. <div style="border-collapse: collapse;display: table;width: 100%;">
  5699. <!--[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]-->
  5700. <!--[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]-->
  5701. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  5702. <div style="background-color: transparent; width: 100% !important;">
  5703. <!--[if (!mso)&(!IE)]><!-->
  5704. <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;">
  5705. <!--<![endif]-->
  5706. <!--[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]-->
  5707. <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;">
  5708. <div style="font-size:12px;line-height:14px;color:#959595;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  5709. <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"
  5710. href="https://github.com/causefx/Organizr" target="_blank" rel="noopener noreferrer">Organizr</a><strong><br></strong></p>
  5711. </div>
  5712. </div>
  5713. <!--[if mso]></td></tr></table><![endif]-->
  5714. <!--[if (!mso)&(!IE)]><!-->
  5715. </div>
  5716. <!--<![endif]-->
  5717. </div>
  5718. </div>
  5719. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  5720. </div>
  5721. </div>
  5722. </div>
  5723. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  5724. </div>
  5725. <!--[if (mso)|(IE)]></div><![endif]-->
  5726. </body>
  5727. </html>
  5728. ';
  5729. }
  5730. function mimeTypes(){
  5731. return array(
  5732. '123' => 'application/vnd.lotus-1-2-3',
  5733. '3dml' => 'text/vnd.in3d.3dml',
  5734. '3ds' => 'image/x-3ds',
  5735. '3g2' => 'video/3gpp2',
  5736. '3gp' => 'video/3gpp',
  5737. '7z' => 'application/x-7z-compressed',
  5738. 'aab' => 'application/x-authorware-bin',
  5739. 'aac' => 'audio/x-aac',
  5740. 'aam' => 'application/x-authorware-map',
  5741. 'aas' => 'application/x-authorware-seg',
  5742. 'abw' => 'application/x-abiword',
  5743. 'ac' => 'application/pkix-attr-cert',
  5744. 'acc' => 'application/vnd.americandynamics.acc',
  5745. 'ace' => 'application/x-ace-compressed',
  5746. 'acu' => 'application/vnd.acucobol',
  5747. 'acutc' => 'application/vnd.acucorp',
  5748. 'adp' => 'audio/adpcm',
  5749. 'aep' => 'application/vnd.audiograph',
  5750. 'afm' => 'application/x-font-type1',
  5751. 'afp' => 'application/vnd.ibm.modcap',
  5752. 'ahead' => 'application/vnd.ahead.space',
  5753. 'ai' => 'application/postscript',
  5754. 'aif' => 'audio/x-aiff',
  5755. 'aifc' => 'audio/x-aiff',
  5756. 'aiff' => 'audio/x-aiff',
  5757. 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
  5758. 'ait' => 'application/vnd.dvb.ait',
  5759. 'ami' => 'application/vnd.amiga.ami',
  5760. 'apk' => 'application/vnd.android.package-archive',
  5761. 'appcache' => 'text/cache-manifest',
  5762. 'application' => 'application/x-ms-application',
  5763. 'apr' => 'application/vnd.lotus-approach',
  5764. 'arc' => 'application/x-freearc',
  5765. 'asc' => 'application/pgp-signature',
  5766. 'asf' => 'video/x-ms-asf',
  5767. 'asm' => 'text/x-asm',
  5768. 'aso' => 'application/vnd.accpac.simply.aso',
  5769. 'asx' => 'video/x-ms-asf',
  5770. 'atc' => 'application/vnd.acucorp',
  5771. 'atom' => 'application/atom+xml',
  5772. 'atomcat' => 'application/atomcat+xml',
  5773. 'atomsvc' => 'application/atomsvc+xml',
  5774. 'atx' => 'application/vnd.antix.game-component',
  5775. 'au' => 'audio/basic',
  5776. 'avi' => 'video/x-msvideo',
  5777. 'aw' => 'application/applixware',
  5778. 'azf' => 'application/vnd.airzip.filesecure.azf',
  5779. 'azs' => 'application/vnd.airzip.filesecure.azs',
  5780. 'azw' => 'application/vnd.amazon.ebook',
  5781. 'bat' => 'application/x-msdownload',
  5782. 'bcpio' => 'application/x-bcpio',
  5783. 'bdf' => 'application/x-font-bdf',
  5784. 'bdm' => 'application/vnd.syncml.dm+wbxml',
  5785. 'bed' => 'application/vnd.realvnc.bed',
  5786. 'bh2' => 'application/vnd.fujitsu.oasysprs',
  5787. 'bin' => 'application/octet-stream',
  5788. 'blb' => 'application/x-blorb',
  5789. 'blorb' => 'application/x-blorb',
  5790. 'bmi' => 'application/vnd.bmi',
  5791. 'bmp' => 'image/bmp',
  5792. 'book' => 'application/vnd.framemaker',
  5793. 'box' => 'application/vnd.previewsystems.box',
  5794. 'boz' => 'application/x-bzip2',
  5795. 'bpk' => 'application/octet-stream',
  5796. 'btif' => 'image/prs.btif',
  5797. 'bz' => 'application/x-bzip',
  5798. 'bz2' => 'application/x-bzip2',
  5799. 'c' => 'text/x-c',
  5800. 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
  5801. 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
  5802. 'c4d' => 'application/vnd.clonk.c4group',
  5803. 'c4f' => 'application/vnd.clonk.c4group',
  5804. 'c4g' => 'application/vnd.clonk.c4group',
  5805. 'c4p' => 'application/vnd.clonk.c4group',
  5806. 'c4u' => 'application/vnd.clonk.c4group',
  5807. 'cab' => 'application/vnd.ms-cab-compressed',
  5808. 'caf' => 'audio/x-caf',
  5809. 'cap' => 'application/vnd.tcpdump.pcap',
  5810. 'car' => 'application/vnd.curl.car',
  5811. 'cat' => 'application/vnd.ms-pki.seccat',
  5812. 'cb7' => 'application/x-cbr',
  5813. 'cba' => 'application/x-cbr',
  5814. 'cbr' => 'application/x-cbr',
  5815. 'cbt' => 'application/x-cbr',
  5816. 'cbz' => 'application/x-cbr',
  5817. 'cc' => 'text/x-c',
  5818. 'cct' => 'application/x-director',
  5819. 'ccxml' => 'application/ccxml+xml',
  5820. 'cdbcmsg' => 'application/vnd.contact.cmsg',
  5821. 'cdf' => 'application/x-netcdf',
  5822. 'cdkey' => 'application/vnd.mediastation.cdkey',
  5823. 'cdmia' => 'application/cdmi-capability',
  5824. 'cdmic' => 'application/cdmi-container',
  5825. 'cdmid' => 'application/cdmi-domain',
  5826. 'cdmio' => 'application/cdmi-object',
  5827. 'cdmiq' => 'application/cdmi-queue',
  5828. 'cdx' => 'chemical/x-cdx',
  5829. 'cdxml' => 'application/vnd.chemdraw+xml',
  5830. 'cdy' => 'application/vnd.cinderella',
  5831. 'cer' => 'application/pkix-cert',
  5832. 'cfs' => 'application/x-cfs-compressed',
  5833. 'cgm' => 'image/cgm',
  5834. 'chat' => 'application/x-chat',
  5835. 'chm' => 'application/vnd.ms-htmlhelp',
  5836. 'chrt' => 'application/vnd.kde.kchart',
  5837. 'cif' => 'chemical/x-cif',
  5838. 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
  5839. 'cil' => 'application/vnd.ms-artgalry',
  5840. 'cla' => 'application/vnd.claymore',
  5841. 'class' => 'application/java-vm',
  5842. 'clkk' => 'application/vnd.crick.clicker.keyboard',
  5843. 'clkp' => 'application/vnd.crick.clicker.palette',
  5844. 'clkt' => 'application/vnd.crick.clicker.template',
  5845. 'clkw' => 'application/vnd.crick.clicker.wordbank',
  5846. 'clkx' => 'application/vnd.crick.clicker',
  5847. 'clp' => 'application/x-msclip',
  5848. 'cmc' => 'application/vnd.cosmocaller',
  5849. 'cmdf' => 'chemical/x-cmdf',
  5850. 'cml' => 'chemical/x-cml',
  5851. 'cmp' => 'application/vnd.yellowriver-custom-menu',
  5852. 'cmx' => 'image/x-cmx',
  5853. 'cod' => 'application/vnd.rim.cod',
  5854. 'com' => 'application/x-msdownload',
  5855. 'conf' => 'text/plain',
  5856. 'cpio' => 'application/x-cpio',
  5857. 'cpp' => 'text/x-c',
  5858. 'cpt' => 'application/mac-compactpro',
  5859. 'crd' => 'application/x-mscardfile',
  5860. 'crl' => 'application/pkix-crl',
  5861. 'crt' => 'application/x-x509-ca-cert',
  5862. 'cryptonote' => 'application/vnd.rig.cryptonote',
  5863. 'csh' => 'application/x-csh',
  5864. 'csml' => 'chemical/x-csml',
  5865. 'csp' => 'application/vnd.commonspace',
  5866. 'css' => 'text/css',
  5867. 'cst' => 'application/x-director',
  5868. 'csv' => 'text/csv',
  5869. 'cu' => 'application/cu-seeme',
  5870. 'curl' => 'text/vnd.curl',
  5871. 'cww' => 'application/prs.cww',
  5872. 'cxt' => 'application/x-director',
  5873. 'cxx' => 'text/x-c',
  5874. 'dae' => 'model/vnd.collada+xml',
  5875. 'daf' => 'application/vnd.mobius.daf',
  5876. 'dart' => 'application/vnd.dart',
  5877. 'dataless' => 'application/vnd.fdsn.seed',
  5878. 'davmount' => 'application/davmount+xml',
  5879. 'dbk' => 'application/docbook+xml',
  5880. 'dcr' => 'application/x-director',
  5881. 'dcurl' => 'text/vnd.curl.dcurl',
  5882. 'dd2' => 'application/vnd.oma.dd2+xml',
  5883. 'ddd' => 'application/vnd.fujixerox.ddd',
  5884. 'deb' => 'application/x-debian-package',
  5885. 'def' => 'text/plain',
  5886. 'deploy' => 'application/octet-stream',
  5887. 'der' => 'application/x-x509-ca-cert',
  5888. 'dfac' => 'application/vnd.dreamfactory',
  5889. 'dgc' => 'application/x-dgc-compressed',
  5890. 'dic' => 'text/x-c',
  5891. 'dir' => 'application/x-director',
  5892. 'dis' => 'application/vnd.mobius.dis',
  5893. 'dist' => 'application/octet-stream',
  5894. 'distz' => 'application/octet-stream',
  5895. 'djv' => 'image/vnd.djvu',
  5896. 'djvu' => 'image/vnd.djvu',
  5897. 'dll' => 'application/x-msdownload',
  5898. 'dmg' => 'application/x-apple-diskimage',
  5899. 'dmp' => 'application/vnd.tcpdump.pcap',
  5900. 'dms' => 'application/octet-stream',
  5901. 'dna' => 'application/vnd.dna',
  5902. 'doc' => 'application/msword',
  5903. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  5904. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  5905. 'dot' => 'application/msword',
  5906. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  5907. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  5908. 'dp' => 'application/vnd.osgi.dp',
  5909. 'dpg' => 'application/vnd.dpgraph',
  5910. 'dra' => 'audio/vnd.dra',
  5911. 'dsc' => 'text/prs.lines.tag',
  5912. 'dssc' => 'application/dssc+der',
  5913. 'dtb' => 'application/x-dtbook+xml',
  5914. 'dtd' => 'application/xml-dtd',
  5915. 'dts' => 'audio/vnd.dts',
  5916. 'dtshd' => 'audio/vnd.dts.hd',
  5917. 'dump' => 'application/octet-stream',
  5918. 'dvb' => 'video/vnd.dvb.file',
  5919. 'dvi' => 'application/x-dvi',
  5920. 'dwf' => 'model/vnd.dwf',
  5921. 'dwg' => 'image/vnd.dwg',
  5922. 'dxf' => 'image/vnd.dxf',
  5923. 'dxp' => 'application/vnd.spotfire.dxp',
  5924. 'dxr' => 'application/x-director',
  5925. 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
  5926. 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
  5927. 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
  5928. 'ecma' => 'application/ecmascript',
  5929. 'edm' => 'application/vnd.novadigm.edm',
  5930. 'edx' => 'application/vnd.novadigm.edx',
  5931. 'efif' => 'application/vnd.picsel',
  5932. 'ei6' => 'application/vnd.pg.osasli',
  5933. 'elc' => 'application/octet-stream',
  5934. 'emf' => 'application/x-msmetafile',
  5935. 'eml' => 'message/rfc822',
  5936. 'emma' => 'application/emma+xml',
  5937. 'emz' => 'application/x-msmetafile',
  5938. 'eol' => 'audio/vnd.digital-winds',
  5939. 'eot' => 'application/vnd.ms-fontobject',
  5940. 'eps' => 'application/postscript',
  5941. 'epub' => 'application/epub+zip',
  5942. 'es3' => 'application/vnd.eszigno3+xml',
  5943. 'esa' => 'application/vnd.osgi.subsystem',
  5944. 'esf' => 'application/vnd.epson.esf',
  5945. 'et3' => 'application/vnd.eszigno3+xml',
  5946. 'etx' => 'text/x-setext',
  5947. 'eva' => 'application/x-eva',
  5948. 'evy' => 'application/x-envoy',
  5949. 'exe' => 'application/x-msdownload',
  5950. 'exi' => 'application/exi',
  5951. 'ext' => 'application/vnd.novadigm.ext',
  5952. 'ez' => 'application/andrew-inset',
  5953. 'ez2' => 'application/vnd.ezpix-album',
  5954. 'ez3' => 'application/vnd.ezpix-package',
  5955. 'f' => 'text/x-fortran',
  5956. 'f4v' => 'video/x-f4v',
  5957. 'f77' => 'text/x-fortran',
  5958. 'f90' => 'text/x-fortran',
  5959. 'fbs' => 'image/vnd.fastbidsheet',
  5960. 'fcdt' => 'application/vnd.adobe.formscentral.fcdt',
  5961. 'fcs' => 'application/vnd.isac.fcs',
  5962. 'fdf' => 'application/vnd.fdf',
  5963. 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
  5964. 'fg5' => 'application/vnd.fujitsu.oasysgp',
  5965. 'fgd' => 'application/x-director',
  5966. 'fh' => 'image/x-freehand',
  5967. 'fh4' => 'image/x-freehand',
  5968. 'fh5' => 'image/x-freehand',
  5969. 'fh7' => 'image/x-freehand',
  5970. 'fhc' => 'image/x-freehand',
  5971. 'fig' => 'application/x-xfig',
  5972. 'flac' => 'audio/x-flac',
  5973. 'fli' => 'video/x-fli',
  5974. 'flo' => 'application/vnd.micrografx.flo',
  5975. 'flv' => 'video/x-flv',
  5976. 'flw' => 'application/vnd.kde.kivio',
  5977. 'flx' => 'text/vnd.fmi.flexstor',
  5978. 'fly' => 'text/vnd.fly',
  5979. 'fm' => 'application/vnd.framemaker',
  5980. 'fnc' => 'application/vnd.frogans.fnc',
  5981. 'for' => 'text/x-fortran',
  5982. 'fpx' => 'image/vnd.fpx',
  5983. 'frame' => 'application/vnd.framemaker',
  5984. 'fsc' => 'application/vnd.fsc.weblaunch',
  5985. 'fst' => 'image/vnd.fst',
  5986. 'ftc' => 'application/vnd.fluxtime.clip',
  5987. 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
  5988. 'fvt' => 'video/vnd.fvt',
  5989. 'fxp' => 'application/vnd.adobe.fxp',
  5990. 'fxpl' => 'application/vnd.adobe.fxp',
  5991. 'fzs' => 'application/vnd.fuzzysheet',
  5992. 'g2w' => 'application/vnd.geoplan',
  5993. 'g3' => 'image/g3fax',
  5994. 'g3w' => 'application/vnd.geospace',
  5995. 'gac' => 'application/vnd.groove-account',
  5996. 'gam' => 'application/x-tads',
  5997. 'gbr' => 'application/rpki-ghostbusters',
  5998. 'gca' => 'application/x-gca-compressed',
  5999. 'gdl' => 'model/vnd.gdl',
  6000. 'geo' => 'application/vnd.dynageo',
  6001. 'gex' => 'application/vnd.geometry-explorer',
  6002. 'ggb' => 'application/vnd.geogebra.file',
  6003. 'ggt' => 'application/vnd.geogebra.tool',
  6004. 'ghf' => 'application/vnd.groove-help',
  6005. 'gif' => 'image/gif',
  6006. 'gim' => 'application/vnd.groove-identity-message',
  6007. 'gml' => 'application/gml+xml',
  6008. 'gmx' => 'application/vnd.gmx',
  6009. 'gnumeric' => 'application/x-gnumeric',
  6010. 'gph' => 'application/vnd.flographit',
  6011. 'gpx' => 'application/gpx+xml',
  6012. 'gqf' => 'application/vnd.grafeq',
  6013. 'gqs' => 'application/vnd.grafeq',
  6014. 'gram' => 'application/srgs',
  6015. 'gramps' => 'application/x-gramps-xml',
  6016. 'gre' => 'application/vnd.geometry-explorer',
  6017. 'grv' => 'application/vnd.groove-injector',
  6018. 'grxml' => 'application/srgs+xml',
  6019. 'gsf' => 'application/x-font-ghostscript',
  6020. 'gtar' => 'application/x-gtar',
  6021. 'gtm' => 'application/vnd.groove-tool-message',
  6022. 'gtw' => 'model/vnd.gtw',
  6023. 'gv' => 'text/vnd.graphviz',
  6024. 'gxf' => 'application/gxf',
  6025. 'gxt' => 'application/vnd.geonext',
  6026. 'h' => 'text/x-c',
  6027. 'h261' => 'video/h261',
  6028. 'h263' => 'video/h263',
  6029. 'h264' => 'video/h264',
  6030. 'hal' => 'application/vnd.hal+xml',
  6031. 'hbci' => 'application/vnd.hbci',
  6032. 'hdf' => 'application/x-hdf',
  6033. 'hh' => 'text/x-c',
  6034. 'hlp' => 'application/winhlp',
  6035. 'hpgl' => 'application/vnd.hp-hpgl',
  6036. 'hpid' => 'application/vnd.hp-hpid',
  6037. 'hps' => 'application/vnd.hp-hps',
  6038. 'hqx' => 'application/mac-binhex40',
  6039. 'htke' => 'application/vnd.kenameaapp',
  6040. 'htm' => 'text/html',
  6041. 'html' => 'text/html',
  6042. 'hvd' => 'application/vnd.yamaha.hv-dic',
  6043. 'hvp' => 'application/vnd.yamaha.hv-voice',
  6044. 'hvs' => 'application/vnd.yamaha.hv-script',
  6045. 'i2g' => 'application/vnd.intergeo',
  6046. 'icc' => 'application/vnd.iccprofile',
  6047. 'ice' => 'x-conference/x-cooltalk',
  6048. 'icm' => 'application/vnd.iccprofile',
  6049. 'ico' => 'image/x-icon',
  6050. 'ics' => 'text/calendar',
  6051. 'ief' => 'image/ief',
  6052. 'ifb' => 'text/calendar',
  6053. 'ifm' => 'application/vnd.shana.informed.formdata',
  6054. 'iges' => 'model/iges',
  6055. 'igl' => 'application/vnd.igloader',
  6056. 'igm' => 'application/vnd.insors.igm',
  6057. 'igs' => 'model/iges',
  6058. 'igx' => 'application/vnd.micrografx.igx',
  6059. 'iif' => 'application/vnd.shana.informed.interchange',
  6060. 'imp' => 'application/vnd.accpac.simply.imp',
  6061. 'ims' => 'application/vnd.ms-ims',
  6062. 'in' => 'text/plain',
  6063. 'ink' => 'application/inkml+xml',
  6064. 'inkml' => 'application/inkml+xml',
  6065. 'install' => 'application/x-install-instructions',
  6066. 'iota' => 'application/vnd.astraea-software.iota',
  6067. 'ipfix' => 'application/ipfix',
  6068. 'ipk' => 'application/vnd.shana.informed.package',
  6069. 'irm' => 'application/vnd.ibm.rights-management',
  6070. 'irp' => 'application/vnd.irepository.package+xml',
  6071. 'iso' => 'application/x-iso9660-image',
  6072. 'itp' => 'application/vnd.shana.informed.formtemplate',
  6073. 'ivp' => 'application/vnd.immervision-ivp',
  6074. 'ivu' => 'application/vnd.immervision-ivu',
  6075. 'jad' => 'text/vnd.sun.j2me.app-descriptor',
  6076. 'jam' => 'application/vnd.jam',
  6077. 'jar' => 'application/java-archive',
  6078. 'java' => 'text/x-java-source',
  6079. 'jisp' => 'application/vnd.jisp',
  6080. 'jlt' => 'application/vnd.hp-jlyt',
  6081. 'jnlp' => 'application/x-java-jnlp-file',
  6082. 'joda' => 'application/vnd.joost.joda-archive',
  6083. 'jpe' => 'image/jpeg',
  6084. 'jpeg' => 'image/jpeg',
  6085. 'jpg' => 'image/jpeg',
  6086. 'jpgm' => 'video/jpm',
  6087. 'jpgv' => 'video/jpeg',
  6088. 'jpm' => 'video/jpm',
  6089. 'js' => 'application/javascript',
  6090. 'json' => 'application/json',
  6091. 'jsonml' => 'application/jsonml+json',
  6092. 'kar' => 'audio/midi',
  6093. 'karbon' => 'application/vnd.kde.karbon',
  6094. 'kfo' => 'application/vnd.kde.kformula',
  6095. 'kia' => 'application/vnd.kidspiration',
  6096. 'kml' => 'application/vnd.google-earth.kml+xml',
  6097. 'kmz' => 'application/vnd.google-earth.kmz',
  6098. 'kne' => 'application/vnd.kinar',
  6099. 'knp' => 'application/vnd.kinar',
  6100. 'kon' => 'application/vnd.kde.kontour',
  6101. 'kpr' => 'application/vnd.kde.kpresenter',
  6102. 'kpt' => 'application/vnd.kde.kpresenter',
  6103. 'kpxx' => 'application/vnd.ds-keypoint',
  6104. 'ksp' => 'application/vnd.kde.kspread',
  6105. 'ktr' => 'application/vnd.kahootz',
  6106. 'ktx' => 'image/ktx',
  6107. 'ktz' => 'application/vnd.kahootz',
  6108. 'kwd' => 'application/vnd.kde.kword',
  6109. 'kwt' => 'application/vnd.kde.kword',
  6110. 'lasxml' => 'application/vnd.las.las+xml',
  6111. 'latex' => 'application/x-latex',
  6112. 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  6113. 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  6114. 'les' => 'application/vnd.hhe.lesson-player',
  6115. 'lha' => 'application/x-lzh-compressed',
  6116. 'link66' => 'application/vnd.route66.link66+xml',
  6117. 'list' => 'text/plain',
  6118. 'list3820' => 'application/vnd.ibm.modcap',
  6119. 'listafp' => 'application/vnd.ibm.modcap',
  6120. 'lnk' => 'application/x-ms-shortcut',
  6121. 'log' => 'text/plain',
  6122. 'lostxml' => 'application/lost+xml',
  6123. 'lrf' => 'application/octet-stream',
  6124. 'lrm' => 'application/vnd.ms-lrm',
  6125. 'ltf' => 'application/vnd.frogans.ltf',
  6126. 'lvp' => 'audio/vnd.lucent.voice',
  6127. 'lwp' => 'application/vnd.lotus-wordpro',
  6128. 'lzh' => 'application/x-lzh-compressed',
  6129. 'm13' => 'application/x-msmediaview',
  6130. 'm14' => 'application/x-msmediaview',
  6131. 'm1v' => 'video/mpeg',
  6132. 'm21' => 'application/mp21',
  6133. 'm2a' => 'audio/mpeg',
  6134. 'm2v' => 'video/mpeg',
  6135. 'm3a' => 'audio/mpeg',
  6136. 'm3u' => 'audio/x-mpegurl',
  6137. 'm3u8' => 'application/vnd.apple.mpegurl',
  6138. 'm4a' => 'audio/mp4',
  6139. 'm4u' => 'video/vnd.mpegurl',
  6140. 'm4v' => 'video/x-m4v',
  6141. 'ma' => 'application/mathematica',
  6142. 'mads' => 'application/mads+xml',
  6143. 'mag' => 'application/vnd.ecowin.chart',
  6144. 'maker' => 'application/vnd.framemaker',
  6145. 'man' => 'text/troff',
  6146. 'mar' => 'application/octet-stream',
  6147. 'mathml' => 'application/mathml+xml',
  6148. 'mb' => 'application/mathematica',
  6149. 'mbk' => 'application/vnd.mobius.mbk',
  6150. 'mbox' => 'application/mbox',
  6151. 'mc1' => 'application/vnd.medcalcdata',
  6152. 'mcd' => 'application/vnd.mcd',
  6153. 'mcurl' => 'text/vnd.curl.mcurl',
  6154. 'mdb' => 'application/x-msaccess',
  6155. 'mdi' => 'image/vnd.ms-modi',
  6156. 'me' => 'text/troff',
  6157. 'mesh' => 'model/mesh',
  6158. 'meta4' => 'application/metalink4+xml',
  6159. 'metalink' => 'application/metalink+xml',
  6160. 'mets' => 'application/mets+xml',
  6161. 'mfm' => 'application/vnd.mfmp',
  6162. 'mft' => 'application/rpki-manifest',
  6163. 'mgp' => 'application/vnd.osgeo.mapguide.package',
  6164. 'mgz' => 'application/vnd.proteus.magazine',
  6165. 'mid' => 'audio/midi',
  6166. 'midi' => 'audio/midi',
  6167. 'mie' => 'application/x-mie',
  6168. 'mif' => 'application/vnd.mif',
  6169. 'mime' => 'message/rfc822',
  6170. 'mj2' => 'video/mj2',
  6171. 'mjp2' => 'video/mj2',
  6172. 'mk3d' => 'video/x-matroska',
  6173. 'mka' => 'audio/x-matroska',
  6174. 'mks' => 'video/x-matroska',
  6175. 'mkv' => 'video/x-matroska',
  6176. 'mlp' => 'application/vnd.dolby.mlp',
  6177. 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
  6178. 'mmf' => 'application/vnd.smaf',
  6179. 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
  6180. 'mng' => 'video/x-mng',
  6181. 'mny' => 'application/x-msmoney',
  6182. 'mobi' => 'application/x-mobipocket-ebook',
  6183. 'mods' => 'application/mods+xml',
  6184. 'mov' => 'video/quicktime',
  6185. 'movie' => 'video/x-sgi-movie',
  6186. 'mp2' => 'audio/mpeg',
  6187. 'mp21' => 'application/mp21',
  6188. 'mp2a' => 'audio/mpeg',
  6189. 'mp3' => 'audio/mpeg',
  6190. 'mp4' => 'video/mp4',
  6191. 'mp4a' => 'audio/mp4',
  6192. 'mp4s' => 'application/mp4',
  6193. 'mp4v' => 'video/mp4',
  6194. 'mpc' => 'application/vnd.mophun.certificate',
  6195. 'mpe' => 'video/mpeg',
  6196. 'mpeg' => 'video/mpeg',
  6197. 'mpg' => 'video/mpeg',
  6198. 'mpg4' => 'video/mp4',
  6199. 'mpga' => 'audio/mpeg',
  6200. 'mpkg' => 'application/vnd.apple.installer+xml',
  6201. 'mpm' => 'application/vnd.blueice.multipass',
  6202. 'mpn' => 'application/vnd.mophun.application',
  6203. 'mpp' => 'application/vnd.ms-project',
  6204. 'mpt' => 'application/vnd.ms-project',
  6205. 'mpy' => 'application/vnd.ibm.minipay',
  6206. 'mqy' => 'application/vnd.mobius.mqy',
  6207. 'mrc' => 'application/marc',
  6208. 'mrcx' => 'application/marcxml+xml',
  6209. 'ms' => 'text/troff',
  6210. 'mscml' => 'application/mediaservercontrol+xml',
  6211. 'mseed' => 'application/vnd.fdsn.mseed',
  6212. 'mseq' => 'application/vnd.mseq',
  6213. 'msf' => 'application/vnd.epson.msf',
  6214. 'msh' => 'model/mesh',
  6215. 'msi' => 'application/x-msdownload',
  6216. 'msl' => 'application/vnd.mobius.msl',
  6217. 'msty' => 'application/vnd.muvee.style',
  6218. 'mts' => 'model/vnd.mts',
  6219. 'mus' => 'application/vnd.musician',
  6220. 'musicxml' => 'application/vnd.recordare.musicxml+xml',
  6221. 'mvb' => 'application/x-msmediaview',
  6222. 'mwf' => 'application/vnd.mfer',
  6223. 'mxf' => 'application/mxf',
  6224. 'mxl' => 'application/vnd.recordare.musicxml',
  6225. 'mxml' => 'application/xv+xml',
  6226. 'mxs' => 'application/vnd.triscape.mxs',
  6227. 'mxu' => 'video/vnd.mpegurl',
  6228. 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  6229. 'n3' => 'text/n3',
  6230. 'nb' => 'application/mathematica',
  6231. 'nbp' => 'application/vnd.wolfram.player',
  6232. 'nc' => 'application/x-netcdf',
  6233. 'ncx' => 'application/x-dtbncx+xml',
  6234. 'nfo' => 'text/x-nfo',
  6235. 'ngdat' => 'application/vnd.nokia.n-gage.data',
  6236. 'nitf' => 'application/vnd.nitf',
  6237. 'nlu' => 'application/vnd.neurolanguage.nlu',
  6238. 'nml' => 'application/vnd.enliven',
  6239. 'nnd' => 'application/vnd.noblenet-directory',
  6240. 'nns' => 'application/vnd.noblenet-sealer',
  6241. 'nnw' => 'application/vnd.noblenet-web',
  6242. 'npx' => 'image/vnd.net-fpx',
  6243. 'nsc' => 'application/x-conference',
  6244. 'nsf' => 'application/vnd.lotus-notes',
  6245. 'ntf' => 'application/vnd.nitf',
  6246. 'nzb' => 'application/x-nzb',
  6247. 'oa2' => 'application/vnd.fujitsu.oasys2',
  6248. 'oa3' => 'application/vnd.fujitsu.oasys3',
  6249. 'oas' => 'application/vnd.fujitsu.oasys',
  6250. 'obd' => 'application/x-msbinder',
  6251. 'obj' => 'application/x-tgif',
  6252. 'oda' => 'application/oda',
  6253. 'odb' => 'application/vnd.oasis.opendocument.database',
  6254. 'odc' => 'application/vnd.oasis.opendocument.chart',
  6255. 'odf' => 'application/vnd.oasis.opendocument.formula',
  6256. 'odft' => 'application/vnd.oasis.opendocument.formula-template',
  6257. 'odg' => 'application/vnd.oasis.opendocument.graphics',
  6258. 'odi' => 'application/vnd.oasis.opendocument.image',
  6259. 'odm' => 'application/vnd.oasis.opendocument.text-master',
  6260. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  6261. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  6262. 'odt' => 'application/vnd.oasis.opendocument.text',
  6263. 'oga' => 'audio/ogg',
  6264. 'ogg' => 'audio/ogg',
  6265. 'ogv' => 'video/ogg',
  6266. 'ogx' => 'application/ogg',
  6267. 'omdoc' => 'application/omdoc+xml',
  6268. 'onepkg' => 'application/onenote',
  6269. 'onetmp' => 'application/onenote',
  6270. 'onetoc' => 'application/onenote',
  6271. 'onetoc2' => 'application/onenote',
  6272. 'opf' => 'application/oebps-package+xml',
  6273. 'opml' => 'text/x-opml',
  6274. 'oprc' => 'application/vnd.palm',
  6275. 'org' => 'application/vnd.lotus-organizer',
  6276. 'osf' => 'application/vnd.yamaha.openscoreformat',
  6277. 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  6278. 'otc' => 'application/vnd.oasis.opendocument.chart-template',
  6279. 'otf' => 'application/x-font-otf',
  6280. 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
  6281. 'oth' => 'application/vnd.oasis.opendocument.text-web',
  6282. 'oti' => 'application/vnd.oasis.opendocument.image-template',
  6283. 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
  6284. 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  6285. 'ott' => 'application/vnd.oasis.opendocument.text-template',
  6286. 'oxps' => 'application/oxps',
  6287. 'oxt' => 'application/vnd.openofficeorg.extension',
  6288. 'p' => 'text/x-pascal',
  6289. 'p10' => 'application/pkcs10',
  6290. 'p12' => 'application/x-pkcs12',
  6291. 'p7b' => 'application/x-pkcs7-certificates',
  6292. 'p7c' => 'application/pkcs7-mime',
  6293. 'p7m' => 'application/pkcs7-mime',
  6294. 'p7r' => 'application/x-pkcs7-certreqresp',
  6295. 'p7s' => 'application/pkcs7-signature',
  6296. 'p8' => 'application/pkcs8',
  6297. 'pas' => 'text/x-pascal',
  6298. 'paw' => 'application/vnd.pawaafile',
  6299. 'pbd' => 'application/vnd.powerbuilder6',
  6300. 'pbm' => 'image/x-portable-bitmap',
  6301. 'pcap' => 'application/vnd.tcpdump.pcap',
  6302. 'pcf' => 'application/x-font-pcf',
  6303. 'pcl' => 'application/vnd.hp-pcl',
  6304. 'pclxl' => 'application/vnd.hp-pclxl',
  6305. 'pct' => 'image/x-pict',
  6306. 'pcurl' => 'application/vnd.curl.pcurl',
  6307. 'pcx' => 'image/x-pcx',
  6308. 'pdb' => 'application/vnd.palm',
  6309. 'pdf' => 'application/pdf',
  6310. 'pfa' => 'application/x-font-type1',
  6311. 'pfb' => 'application/x-font-type1',
  6312. 'pfm' => 'application/x-font-type1',
  6313. 'pfr' => 'application/font-tdpfr',
  6314. 'pfx' => 'application/x-pkcs12',
  6315. 'pgm' => 'image/x-portable-graymap',
  6316. 'pgn' => 'application/x-chess-pgn',
  6317. 'pgp' => 'application/pgp-encrypted',
  6318. 'pic' => 'image/x-pict',
  6319. 'pkg' => 'application/octet-stream',
  6320. 'pki' => 'application/pkixcmp',
  6321. 'pkipath' => 'application/pkix-pkipath',
  6322. 'plb' => 'application/vnd.3gpp.pic-bw-large',
  6323. 'plc' => 'application/vnd.mobius.plc',
  6324. 'plf' => 'application/vnd.pocketlearn',
  6325. 'pls' => 'application/pls+xml',
  6326. 'pml' => 'application/vnd.ctc-posml',
  6327. 'png' => 'image/png',
  6328. 'pnm' => 'image/x-portable-anymap',
  6329. 'portpkg' => 'application/vnd.macports.portpkg',
  6330. 'pot' => 'application/vnd.ms-powerpoint',
  6331. 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
  6332. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  6333. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  6334. 'ppd' => 'application/vnd.cups-ppd',
  6335. 'ppm' => 'image/x-portable-pixmap',
  6336. 'pps' => 'application/vnd.ms-powerpoint',
  6337. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  6338. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  6339. 'ppt' => 'application/vnd.ms-powerpoint',
  6340. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  6341. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  6342. 'pqa' => 'application/vnd.palm',
  6343. 'prc' => 'application/x-mobipocket-ebook',
  6344. 'pre' => 'application/vnd.lotus-freelance',
  6345. 'prf' => 'application/pics-rules',
  6346. 'ps' => 'application/postscript',
  6347. 'psb' => 'application/vnd.3gpp.pic-bw-small',
  6348. 'psd' => 'image/vnd.adobe.photoshop',
  6349. 'psf' => 'application/x-font-linux-psf',
  6350. 'pskcxml' => 'application/pskc+xml',
  6351. 'ptid' => 'application/vnd.pvi.ptid1',
  6352. 'pub' => 'application/x-mspublisher',
  6353. 'pvb' => 'application/vnd.3gpp.pic-bw-var',
  6354. 'pwn' => 'application/vnd.3m.post-it-notes',
  6355. 'pya' => 'audio/vnd.ms-playready.media.pya',
  6356. 'pyv' => 'video/vnd.ms-playready.media.pyv',
  6357. 'qam' => 'application/vnd.epson.quickanime',
  6358. 'qbo' => 'application/vnd.intu.qbo',
  6359. 'qfx' => 'application/vnd.intu.qfx',
  6360. 'qps' => 'application/vnd.publishare-delta-tree',
  6361. 'qt' => 'video/quicktime',
  6362. 'qwd' => 'application/vnd.quark.quarkxpress',
  6363. 'qwt' => 'application/vnd.quark.quarkxpress',
  6364. 'qxb' => 'application/vnd.quark.quarkxpress',
  6365. 'qxd' => 'application/vnd.quark.quarkxpress',
  6366. 'qxl' => 'application/vnd.quark.quarkxpress',
  6367. 'qxt' => 'application/vnd.quark.quarkxpress',
  6368. 'ra' => 'audio/x-pn-realaudio',
  6369. 'ram' => 'audio/x-pn-realaudio',
  6370. 'rar' => 'application/x-rar-compressed',
  6371. 'ras' => 'image/x-cmu-raster',
  6372. 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
  6373. 'rdf' => 'application/rdf+xml',
  6374. 'rdz' => 'application/vnd.data-vision.rdz',
  6375. 'rep' => 'application/vnd.businessobjects',
  6376. 'res' => 'application/x-dtbresource+xml',
  6377. 'rgb' => 'image/x-rgb',
  6378. 'rif' => 'application/reginfo+xml',
  6379. 'rip' => 'audio/vnd.rip',
  6380. 'ris' => 'application/x-research-info-systems',
  6381. 'rl' => 'application/resource-lists+xml',
  6382. 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
  6383. 'rld' => 'application/resource-lists-diff+xml',
  6384. 'rm' => 'application/vnd.rn-realmedia',
  6385. 'rmi' => 'audio/midi',
  6386. 'rmp' => 'audio/x-pn-realaudio-plugin',
  6387. 'rms' => 'application/vnd.jcp.javame.midlet-rms',
  6388. 'rmvb' => 'application/vnd.rn-realmedia-vbr',
  6389. 'rnc' => 'application/relax-ng-compact-syntax',
  6390. 'roa' => 'application/rpki-roa',
  6391. 'roff' => 'text/troff',
  6392. 'rp9' => 'application/vnd.cloanto.rp9',
  6393. 'rpss' => 'application/vnd.nokia.radio-presets',
  6394. 'rpst' => 'application/vnd.nokia.radio-preset',
  6395. 'rq' => 'application/sparql-query',
  6396. 'rs' => 'application/rls-services+xml',
  6397. 'rsd' => 'application/rsd+xml',
  6398. 'rss' => 'application/rss+xml',
  6399. 'rtf' => 'application/rtf',
  6400. 'rtx' => 'text/richtext',
  6401. 's' => 'text/x-asm',
  6402. 's3m' => 'audio/s3m',
  6403. 'saf' => 'application/vnd.yamaha.smaf-audio',
  6404. 'sbml' => 'application/sbml+xml',
  6405. 'sc' => 'application/vnd.ibm.secure-container',
  6406. 'scd' => 'application/x-msschedule',
  6407. 'scm' => 'application/vnd.lotus-screencam',
  6408. 'scq' => 'application/scvp-cv-request',
  6409. 'scs' => 'application/scvp-cv-response',
  6410. 'scurl' => 'text/vnd.curl.scurl',
  6411. 'sda' => 'application/vnd.stardivision.draw',
  6412. 'sdc' => 'application/vnd.stardivision.calc',
  6413. 'sdd' => 'application/vnd.stardivision.impress',
  6414. 'sdkd' => 'application/vnd.solent.sdkm+xml',
  6415. 'sdkm' => 'application/vnd.solent.sdkm+xml',
  6416. 'sdp' => 'application/sdp',
  6417. 'sdw' => 'application/vnd.stardivision.writer',
  6418. 'see' => 'application/vnd.seemail',
  6419. 'seed' => 'application/vnd.fdsn.seed',
  6420. 'sema' => 'application/vnd.sema',
  6421. 'semd' => 'application/vnd.semd',
  6422. 'semf' => 'application/vnd.semf',
  6423. 'ser' => 'application/java-serialized-object',
  6424. 'setpay' => 'application/set-payment-initiation',
  6425. 'setreg' => 'application/set-registration-initiation',
  6426. 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
  6427. 'sfs' => 'application/vnd.spotfire.sfs',
  6428. 'sfv' => 'text/x-sfv',
  6429. 'sgi' => 'image/sgi',
  6430. 'sgl' => 'application/vnd.stardivision.writer-global',
  6431. 'sgm' => 'text/sgml',
  6432. 'sgml' => 'text/sgml',
  6433. 'sh' => 'application/x-sh',
  6434. 'shar' => 'application/x-shar',
  6435. 'shf' => 'application/shf+xml',
  6436. 'sid' => 'image/x-mrsid-image',
  6437. 'sig' => 'application/pgp-signature',
  6438. 'sil' => 'audio/silk',
  6439. 'silo' => 'model/mesh',
  6440. 'sis' => 'application/vnd.symbian.install',
  6441. 'sisx' => 'application/vnd.symbian.install',
  6442. 'sit' => 'application/x-stuffit',
  6443. 'sitx' => 'application/x-stuffitx',
  6444. 'skd' => 'application/vnd.koan',
  6445. 'skm' => 'application/vnd.koan',
  6446. 'skp' => 'application/vnd.koan',
  6447. 'skt' => 'application/vnd.koan',
  6448. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  6449. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  6450. 'slt' => 'application/vnd.epson.salt',
  6451. 'sm' => 'application/vnd.stepmania.stepchart',
  6452. 'smf' => 'application/vnd.stardivision.math',
  6453. 'smi' => 'application/smil+xml',
  6454. 'smil' => 'application/smil+xml',
  6455. 'smv' => 'video/x-smv',
  6456. 'smzip' => 'application/vnd.stepmania.package',
  6457. 'snd' => 'audio/basic',
  6458. 'snf' => 'application/x-font-snf',
  6459. 'so' => 'application/octet-stream',
  6460. 'spc' => 'application/x-pkcs7-certificates',
  6461. 'spf' => 'application/vnd.yamaha.smaf-phrase',
  6462. 'spl' => 'application/x-futuresplash',
  6463. 'spot' => 'text/vnd.in3d.spot',
  6464. 'spp' => 'application/scvp-vp-response',
  6465. 'spq' => 'application/scvp-vp-request',
  6466. 'spx' => 'audio/ogg',
  6467. 'sql' => 'application/x-sql',
  6468. 'src' => 'application/x-wais-source',
  6469. 'srt' => 'application/x-subrip',
  6470. 'sru' => 'application/sru+xml',
  6471. 'srx' => 'application/sparql-results+xml',
  6472. 'ssdl' => 'application/ssdl+xml',
  6473. 'sse' => 'application/vnd.kodak-descriptor',
  6474. 'ssf' => 'application/vnd.epson.ssf',
  6475. 'ssml' => 'application/ssml+xml',
  6476. 'st' => 'application/vnd.sailingtracker.track',
  6477. 'stc' => 'application/vnd.sun.xml.calc.template',
  6478. 'std' => 'application/vnd.sun.xml.draw.template',
  6479. 'stf' => 'application/vnd.wt.stf',
  6480. 'sti' => 'application/vnd.sun.xml.impress.template',
  6481. 'stk' => 'application/hyperstudio',
  6482. 'stl' => 'application/vnd.ms-pki.stl',
  6483. 'str' => 'application/vnd.pg.format',
  6484. 'stw' => 'application/vnd.sun.xml.writer.template',
  6485. 'sub' => 'image/vnd.dvb.subtitle',
  6486. 'sub' => 'text/vnd.dvb.subtitle',
  6487. 'sus' => 'application/vnd.sus-calendar',
  6488. 'susp' => 'application/vnd.sus-calendar',
  6489. 'sv4cpio' => 'application/x-sv4cpio',
  6490. 'sv4crc' => 'application/x-sv4crc',
  6491. 'svc' => 'application/vnd.dvb.service',
  6492. 'svd' => 'application/vnd.svd',
  6493. 'svg' => 'image/svg+xml',
  6494. 'svgz' => 'image/svg+xml',
  6495. 'swa' => 'application/x-director',
  6496. 'swf' => 'application/x-shockwave-flash',
  6497. 'swi' => 'application/vnd.aristanetworks.swi',
  6498. 'sxc' => 'application/vnd.sun.xml.calc',
  6499. 'sxd' => 'application/vnd.sun.xml.draw',
  6500. 'sxg' => 'application/vnd.sun.xml.writer.global',
  6501. 'sxi' => 'application/vnd.sun.xml.impress',
  6502. 'sxm' => 'application/vnd.sun.xml.math',
  6503. 'sxw' => 'application/vnd.sun.xml.writer',
  6504. 't' => 'text/troff',
  6505. 't3' => 'application/x-t3vm-image',
  6506. 'taglet' => 'application/vnd.mynfc',
  6507. 'tao' => 'application/vnd.tao.intent-module-archive',
  6508. 'tar' => 'application/x-tar',
  6509. 'tcap' => 'application/vnd.3gpp2.tcap',
  6510. 'tcl' => 'application/x-tcl',
  6511. 'teacher' => 'application/vnd.smart.teacher',
  6512. 'tei' => 'application/tei+xml',
  6513. 'teicorpus' => 'application/tei+xml',
  6514. 'tex' => 'application/x-tex',
  6515. 'texi' => 'application/x-texinfo',
  6516. 'texinfo' => 'application/x-texinfo',
  6517. 'text' => 'text/plain',
  6518. 'tfi' => 'application/thraud+xml',
  6519. 'tfm' => 'application/x-tex-tfm',
  6520. 'tga' => 'image/x-tga',
  6521. 'thmx' => 'application/vnd.ms-officetheme',
  6522. 'tif' => 'image/tiff',
  6523. 'tiff' => 'image/tiff',
  6524. 'tmo' => 'application/vnd.tmobile-livetv',
  6525. 'torrent' => 'application/x-bittorrent',
  6526. 'tpl' => 'application/vnd.groove-tool-template',
  6527. 'tpt' => 'application/vnd.trid.tpt',
  6528. 'tr' => 'text/troff',
  6529. 'tra' => 'application/vnd.trueapp',
  6530. 'trm' => 'application/x-msterminal',
  6531. 'tsd' => 'application/timestamped-data',
  6532. 'tsv' => 'text/tab-separated-values',
  6533. 'ttc' => 'application/x-font-ttf',
  6534. 'ttf' => 'application/x-font-ttf',
  6535. 'ttl' => 'text/turtle',
  6536. 'twd' => 'application/vnd.simtech-mindmapper',
  6537. 'twds' => 'application/vnd.simtech-mindmapper',
  6538. 'txd' => 'application/vnd.genomatix.tuxedo',
  6539. 'txf' => 'application/vnd.mobius.txf',
  6540. 'txt' => 'text/plain',
  6541. 'u32' => 'application/x-authorware-bin',
  6542. 'udeb' => 'application/x-debian-package',
  6543. 'ufd' => 'application/vnd.ufdl',
  6544. 'ufdl' => 'application/vnd.ufdl',
  6545. 'ulx' => 'application/x-glulx',
  6546. 'umj' => 'application/vnd.umajin',
  6547. 'unityweb' => 'application/vnd.unity',
  6548. 'uoml' => 'application/vnd.uoml+xml',
  6549. 'uri' => 'text/uri-list',
  6550. 'uris' => 'text/uri-list',
  6551. 'urls' => 'text/uri-list',
  6552. 'ustar' => 'application/x-ustar',
  6553. 'utz' => 'application/vnd.uiq.theme',
  6554. 'uu' => 'text/x-uuencode',
  6555. 'uva' => 'audio/vnd.dece.audio',
  6556. 'uvd' => 'application/vnd.dece.data',
  6557. 'uvf' => 'application/vnd.dece.data',
  6558. 'uvg' => 'image/vnd.dece.graphic',
  6559. 'uvh' => 'video/vnd.dece.hd',
  6560. 'uvi' => 'image/vnd.dece.graphic',
  6561. 'uvm' => 'video/vnd.dece.mobile',
  6562. 'uvp' => 'video/vnd.dece.pd',
  6563. 'uvs' => 'video/vnd.dece.sd',
  6564. 'uvt' => 'application/vnd.dece.ttml+xml',
  6565. 'uvu' => 'video/vnd.uvvu.mp4',
  6566. 'uvv' => 'video/vnd.dece.video',
  6567. 'uvva' => 'audio/vnd.dece.audio',
  6568. 'uvvd' => 'application/vnd.dece.data',
  6569. 'uvvf' => 'application/vnd.dece.data',
  6570. 'uvvg' => 'image/vnd.dece.graphic',
  6571. 'uvvh' => 'video/vnd.dece.hd',
  6572. 'uvvi' => 'image/vnd.dece.graphic',
  6573. 'uvvm' => 'video/vnd.dece.mobile',
  6574. 'uvvp' => 'video/vnd.dece.pd',
  6575. 'uvvs' => 'video/vnd.dece.sd',
  6576. 'uvvt' => 'application/vnd.dece.ttml+xml',
  6577. 'uvvu' => 'video/vnd.uvvu.mp4',
  6578. 'uvvv' => 'video/vnd.dece.video',
  6579. 'uvvx' => 'application/vnd.dece.unspecified',
  6580. 'uvvz' => 'application/vnd.dece.zip',
  6581. 'uvx' => 'application/vnd.dece.unspecified',
  6582. 'uvz' => 'application/vnd.dece.zip',
  6583. 'vcard' => 'text/vcard',
  6584. 'vcd' => 'application/x-cdlink',
  6585. 'vcf' => 'text/x-vcard',
  6586. 'vcg' => 'application/vnd.groove-vcard',
  6587. 'vcs' => 'text/x-vcalendar',
  6588. 'vcx' => 'application/vnd.vcx',
  6589. 'vis' => 'application/vnd.visionary',
  6590. 'viv' => 'video/vnd.vivo',
  6591. 'vob' => 'video/x-ms-vob',
  6592. 'vor' => 'application/vnd.stardivision.writer',
  6593. 'vox' => 'application/x-authorware-bin',
  6594. 'vrml' => 'model/vrml',
  6595. 'vsd' => 'application/vnd.visio',
  6596. 'vsf' => 'application/vnd.vsf',
  6597. 'vss' => 'application/vnd.visio',
  6598. 'vst' => 'application/vnd.visio',
  6599. 'vsw' => 'application/vnd.visio',
  6600. 'vtu' => 'model/vnd.vtu',
  6601. 'vxml' => 'application/voicexml+xml',
  6602. 'w3d' => 'application/x-director',
  6603. 'wad' => 'application/x-doom',
  6604. 'wav' => 'audio/x-wav',
  6605. 'wax' => 'audio/x-ms-wax',
  6606. 'wbmp' => 'image/vnd.wap.wbmp',
  6607. 'wbs' => 'application/vnd.criticaltools.wbs+xml',
  6608. 'wbxml' => 'application/vnd.wap.wbxml',
  6609. 'wcm' => 'application/vnd.ms-works',
  6610. 'wdb' => 'application/vnd.ms-works',
  6611. 'wdp' => 'image/vnd.ms-photo',
  6612. 'weba' => 'audio/webm',
  6613. 'webm' => 'video/webm',
  6614. 'webp' => 'image/webp',
  6615. 'wg' => 'application/vnd.pmi.widget',
  6616. 'wgt' => 'application/widget',
  6617. 'wks' => 'application/vnd.ms-works',
  6618. 'wm' => 'video/x-ms-wm',
  6619. 'wma' => 'audio/x-ms-wma',
  6620. 'wmd' => 'application/x-ms-wmd',
  6621. 'wmf' => 'application/x-msmetafile',
  6622. 'wml' => 'text/vnd.wap.wml',
  6623. 'wmlc' => 'application/vnd.wap.wmlc',
  6624. 'wmls' => 'text/vnd.wap.wmlscript',
  6625. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  6626. 'wmv' => 'video/x-ms-wmv',
  6627. 'wmx' => 'video/x-ms-wmx',
  6628. 'wmz' => 'application/x-ms-wmz',
  6629. 'wmz' => 'application/x-msmetafile',
  6630. 'woff' => 'application/font-woff',
  6631. 'wpd' => 'application/vnd.wordperfect',
  6632. 'wpl' => 'application/vnd.ms-wpl',
  6633. 'wps' => 'application/vnd.ms-works',
  6634. 'wqd' => 'application/vnd.wqd',
  6635. 'wri' => 'application/x-mswrite',
  6636. 'wrl' => 'model/vrml',
  6637. 'wsdl' => 'application/wsdl+xml',
  6638. 'wspolicy' => 'application/wspolicy+xml',
  6639. 'wtb' => 'application/vnd.webturbo',
  6640. 'wvx' => 'video/x-ms-wvx',
  6641. 'x32' => 'application/x-authorware-bin',
  6642. 'x3d' => 'model/x3d+xml',
  6643. 'x3db' => 'model/x3d+binary',
  6644. 'x3dbz' => 'model/x3d+binary',
  6645. 'x3dv' => 'model/x3d+vrml',
  6646. 'x3dvz' => 'model/x3d+vrml',
  6647. 'x3dz' => 'model/x3d+xml',
  6648. 'xaml' => 'application/xaml+xml',
  6649. 'xap' => 'application/x-silverlight-app',
  6650. 'xar' => 'application/vnd.xara',
  6651. 'xbap' => 'application/x-ms-xbap',
  6652. 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
  6653. 'xbm' => 'image/x-xbitmap',
  6654. 'xdf' => 'application/xcap-diff+xml',
  6655. 'xdm' => 'application/vnd.syncml.dm+xml',
  6656. 'xdp' => 'application/vnd.adobe.xdp+xml',
  6657. 'xdssc' => 'application/dssc+xml',
  6658. 'xdw' => 'application/vnd.fujixerox.docuworks',
  6659. 'xenc' => 'application/xenc+xml',
  6660. 'xer' => 'application/patch-ops-error+xml',
  6661. 'xfdf' => 'application/vnd.adobe.xfdf',
  6662. 'xfdl' => 'application/vnd.xfdl',
  6663. 'xht' => 'application/xhtml+xml',
  6664. 'xhtml' => 'application/xhtml+xml',
  6665. 'xhvml' => 'application/xv+xml',
  6666. 'xif' => 'image/vnd.xiff',
  6667. 'xla' => 'application/vnd.ms-excel',
  6668. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  6669. 'xlc' => 'application/vnd.ms-excel',
  6670. 'xlf' => 'application/x-xliff+xml',
  6671. 'xlm' => 'application/vnd.ms-excel',
  6672. 'xls' => 'application/vnd.ms-excel',
  6673. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  6674. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  6675. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  6676. 'xlt' => 'application/vnd.ms-excel',
  6677. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  6678. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  6679. 'xlw' => 'application/vnd.ms-excel',
  6680. 'xm' => 'audio/xm',
  6681. 'xml' => 'application/xml',
  6682. 'xo' => 'application/vnd.olpc-sugar',
  6683. 'xop' => 'application/xop+xml',
  6684. 'xpi' => 'application/x-xpinstall',
  6685. 'xpl' => 'application/xproc+xml',
  6686. 'xpm' => 'image/x-xpixmap',
  6687. 'xpr' => 'application/vnd.is-xpr',
  6688. 'xps' => 'application/vnd.ms-xpsdocument',
  6689. 'xpw' => 'application/vnd.intercon.formnet',
  6690. 'xpx' => 'application/vnd.intercon.formnet',
  6691. 'xsl' => 'application/xml',
  6692. 'xslt' => 'application/xslt+xml',
  6693. 'xsm' => 'application/vnd.syncml+xml',
  6694. 'xspf' => 'application/xspf+xml',
  6695. 'xul' => 'application/vnd.mozilla.xul+xml',
  6696. 'xvm' => 'application/xv+xml',
  6697. 'xvml' => 'application/xv+xml',
  6698. 'xwd' => 'image/x-xwindowdump',
  6699. 'xyz' => 'chemical/x-xyz',
  6700. 'xz' => 'application/x-xz',
  6701. 'yang' => 'application/yang',
  6702. 'yin' => 'application/yin+xml',
  6703. 'z1' => 'application/x-zmachine',
  6704. 'z2' => 'application/x-zmachine',
  6705. 'z3' => 'application/x-zmachine',
  6706. 'z4' => 'application/x-zmachine',
  6707. 'z5' => 'application/x-zmachine',
  6708. 'z6' => 'application/x-zmachine',
  6709. 'z7' => 'application/x-zmachine',
  6710. 'z8' => 'application/x-zmachine',
  6711. 'zaz' => 'application/vnd.zzazz.deck+xml',
  6712. 'zip' => 'application/zip',
  6713. 'zir' => 'application/vnd.zul',
  6714. 'zirz' => 'application/vnd.zul',
  6715. 'zmm' => 'application/vnd.handheld-entertainment+xml'
  6716. );
  6717. }
  6718. // Always run this
  6719. dependCheck();