functions.php 305 KB

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