functions.php 341 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254
  1. <?php
  2. // ===================================
  3. // Define Version
  4. define('INSTALLEDVERSION', '1.50');
  5. // ===================================
  6. use Kryptonit3\Sonarr\Sonarr;
  7. use Kryptonit3\SickRage\SickRage;
  8. //homepage order
  9. function homepageOrder(){
  10. $homepageOrder = array(
  11. "homepageOrdercustomhtml" => homepageOrdercustomhtml,
  12. "homepageOrdernotice" => homepageOrdernotice,
  13. "homepageOrderplexsearch" => homepageOrderplexsearch,
  14. "homepageOrderspeedtest" => homepageOrderspeedtest,
  15. "homepageOrdernzbget" => homepageOrdernzbget,
  16. "homepageOrdersabnzbd" => homepageOrdersabnzbd,
  17. "homepageOrderplexnowplaying" => homepageOrderplexnowplaying,
  18. "homepageOrderplexrecent" => homepageOrderplexrecent,
  19. "homepageOrderplexplaylist" => homepageOrderplexplaylist,
  20. "homepageOrderembynowplaying" => homepageOrderembynowplaying,
  21. "homepageOrderembyrecent" => homepageOrderembyrecent,
  22. "homepageOrderombi" => homepageOrderombi,
  23. "homepageOrdercalendar" => homepageOrdercalendar,
  24. );
  25. asort($homepageOrder);
  26. return $homepageOrder;
  27. }
  28. // Debugging output functions
  29. function debug_out($variable, $die = false) {
  30. $trace = debug_backtrace()[0];
  31. echo "<center><img height='200px' src='images/confused.png'></center>";
  32. echo "<center>Look's like something happened, here are the errors and perhaps how to fix them:</center>";
  33. 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>';
  34. if ($die) { http_response_code(503); die(); }
  35. }
  36. // ==== Auth Plugins START ====
  37. if (function_exists('ldap_connect')) :
  38. // Pass credentials to LDAP backend
  39. function plugin_auth_ldap($username, $password) {
  40. $ldapServers = explode(',',AUTHBACKENDHOST);
  41. foreach($ldapServers as $key => $value) {
  42. // Calculate parts
  43. $digest = parse_url(trim($value));
  44. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:'ldap'));
  45. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  46. $port = (isset($digest['port'])?$digest['port']:(strtolower($scheme)=='ldap'?389:636));
  47. // Reassign
  48. $ldapServers[$key] = $scheme.'://'.$host.':'.$port;
  49. }
  50. // returns true or false
  51. $ldap = ldap_connect(implode(' ',$ldapServers));
  52. if(empty(AUTHBACKENDDOMAINFORMAT)){
  53. if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
  54. writeLog("success", "LDAP authentication success");
  55. return true;
  56. } else {
  57. writeLog("error", "LDAP could not authenticate");
  58. return false;
  59. }
  60. }else{
  61. ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
  62. ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
  63. $bind = @ldap_bind($ldap, sprintf(AUTHBACKENDDOMAINFORMAT, $username), $password);
  64. if ($bind) {
  65. writeLog("success", "LDAP authentication success");
  66. return true;
  67. } else {
  68. writeLog("error", "LDPA could not authenticate");
  69. return false;
  70. }
  71. }
  72. writeLog("error", "LDAP could not authenticate");
  73. return false;
  74. }
  75. else :
  76. // Ldap Auth Missing Dependancy
  77. function plugin_auth_ldap_disabled() {
  78. return 'LDAP - Disabled (Dependancy: php-ldap missing!)';
  79. }
  80. endif;
  81. // Pass credentials to FTP backend
  82. function plugin_auth_ftp($username, $password) {
  83. // Calculate parts
  84. $digest = parse_url(AUTHBACKENDHOST);
  85. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:(function_exists('ftp_ssl_connect')?'ftps':'ftp')));
  86. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  87. $port = (isset($digest['port'])?$digest['port']:21);
  88. // Determine Connection Type
  89. if ($scheme == 'ftps') {
  90. $conn_id = ftp_ssl_connect($host, $port, 20);
  91. } elseif ($scheme == 'ftp') {
  92. $conn_id = ftp_connect($host, $port, 20);
  93. } else {
  94. debug_out('Invalid FTP scheme. Use ftp or ftps');
  95. writeLog("error", "invalid FTP scheme");
  96. return false;
  97. }
  98. // Check if valid FTP connection
  99. if ($conn_id) {
  100. // Attempt login
  101. @$login_result = ftp_login($conn_id, $username, $password);
  102. ftp_close($conn_id);
  103. // Return Result
  104. if ($login_result) {
  105. writeLog("success", "$username authenticated");
  106. return true;
  107. } else {
  108. writeLog("error", "$username could not authenticate");
  109. return false;
  110. }
  111. } else {
  112. return false;
  113. }
  114. return false;
  115. }
  116. // Pass credentials to Emby Backend
  117. function plugin_auth_emby_local($username, $password) {
  118. $embyAddress = qualifyURL(EMBYURL);
  119. $headers = array(
  120. 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"',
  121. 'Content-Type' => 'application/json',
  122. );
  123. $body = array(
  124. 'Username' => $username,
  125. 'Password' => sha1($password),
  126. 'PasswordMd5' => md5($password),
  127. );
  128. $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers);
  129. if (isset($response['content'])) {
  130. $json = json_decode($response['content'], true);
  131. if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
  132. // Login Success - Now Logout Emby Session As We No Longer Need It
  133. $headers = array(
  134. 'X-Mediabrowser-Token' => $json['AccessToken'],
  135. );
  136. $response = post_router($embyAddress.'/Sessions/Logout', array(), $headers);
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. if (function_exists('curl_version')) :
  143. // Authenticate Against Emby Local (first) and Emby Connect
  144. function plugin_auth_emby_all($username, $password) {
  145. $localResult = plugin_auth_emby_local($username, $password);
  146. if ($localResult) {
  147. return $localResult;
  148. } else {
  149. return plugin_auth_emby_connect($username, $password);
  150. }
  151. }
  152. // Authenicate against emby connect
  153. function plugin_auth_emby_connect($username, $password) {
  154. $embyAddress = qualifyURL(EMBYURL);
  155. // Get A User
  156. $connectId = '';
  157. $userIds = json_decode(file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
  158. if (is_array($userIds)) {
  159. foreach ($userIds as $key => $value) { // Scan for this user
  160. if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
  161. if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
  162. $connectId = $value['ConnectUserId'];
  163. break;
  164. }
  165. }
  166. }
  167. if ($connectId) {
  168. $connectURL = 'https://connect.emby.media/service/user/authenticate';
  169. $headers = array(
  170. 'Accept'=> 'application/json',
  171. 'Content-Type' => 'application/x-www-form-urlencoded',
  172. );
  173. $body = array(
  174. 'nameOrEmail' => $username,
  175. 'rawpw' => $password,
  176. );
  177. $result = curl_post($connectURL, $body, $headers);
  178. if (isset($result['content'])) {
  179. $json = json_decode($result['content'], true);
  180. if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
  181. return array(
  182. 'email' => $json['User']['Email'],
  183. 'image' => $json['User']['ImageUrl'],
  184. );
  185. }
  186. }
  187. }
  188. }
  189. return false;
  190. }
  191. // Pass credentials to Plex Backend
  192. function plugin_auth_plex($username, $password) {
  193. // Quick out
  194. $isAdmin = false;
  195. if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
  196. writeLog("success", "Admin: ".$username." authenticated by plex");
  197. //return true;
  198. $isAdmin = true;
  199. }
  200. //Get User List
  201. $userURL = 'https://plex.tv/pms/friends/all';
  202. $userHeaders = array(
  203. 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD),
  204. );
  205. libxml_use_internal_errors(true);
  206. $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
  207. if (is_array($userXML) || is_object($userXML)) {
  208. $isUser = false;
  209. $usernameLower = strtolower($username);
  210. foreach($userXML AS $child) {
  211. if(isset($child['username']) && strtolower($child['username']) == $usernameLower) {
  212. $isUser = true;
  213. writeLog("success", $usernameLower." was found in plex friends list");
  214. break;
  215. }
  216. }
  217. if ($isUser || $isAdmin) {
  218. //Login User
  219. $connectURL = 'https://plex.tv/users/sign_in.json';
  220. $headers = array(
  221. 'Accept'=> 'application/json',
  222. 'Content-Type' => 'application/x-www-form-urlencoded',
  223. 'X-Plex-Product' => 'Organizr',
  224. 'X-Plex-Version' => '1.0',
  225. 'X-Plex-Client-Identifier' => '01010101-10101010',
  226. );
  227. $body = array(
  228. 'user[login]' => $username,
  229. 'user[password]' => $password,
  230. );
  231. $result = curl_post($connectURL, $body, $headers);
  232. if (isset($result['content'])) {
  233. $json = json_decode($result['content'], true);
  234. if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && strtolower($json['user']['username']) == $usernameLower) {
  235. writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
  236. return array(
  237. 'email' => $json['user']['email'],
  238. 'image' => $json['user']['thumb'],
  239. 'token' => $json['user']['authToken']
  240. );
  241. }
  242. }
  243. }else{
  244. writeLog("error", "$username is not an authorized PLEX user or entered invalid password");
  245. }
  246. }else{
  247. writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");
  248. }
  249. return false;
  250. }
  251. else :
  252. // Plex Auth Missing Dependancy
  253. function plugin_auth_plex_disabled() {
  254. return 'Plex - Disabled (Dependancy: php-curl missing!)';
  255. }
  256. // Emby Connect Auth Missing Dependancy
  257. function plugin_auth_emby_connect_disabled() {
  258. return 'Emby Connect - Disabled (Dependancy: php-curl missing!)';
  259. }
  260. // Emby Both Auth Missing Dependancy
  261. function plugin_auth_emby_both_disabled() {
  262. return 'Emby Both - Disabled (Dependancy: php-curl missing!)';
  263. }
  264. endif;
  265. // ==== Auth Plugins END ====
  266. // ==== General Class Definitions START ====
  267. $userLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  268. class setLanguage {
  269. private $language = null;
  270. private $langCode = null;
  271. function __construct($language = false) {
  272. // Default
  273. if (!$language) {
  274. $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  275. }
  276. if (!file_exists("lang/{$language}.ini")) {
  277. $language = 'en';
  278. }
  279. $this->langCode = $language;
  280. $this->language = parse_ini_file("lang/{$language}.ini", false, INI_SCANNER_RAW);
  281. if (file_exists("lang/{$language}.cust.ini")) {
  282. foreach($tmp = parse_ini_file("lang/{$language}.cust.ini", false, INI_SCANNER_RAW) as $k => $v) {
  283. $this->language[$k] = $v;
  284. }
  285. }
  286. }
  287. public function getLang() {
  288. return $this->langCode;
  289. }
  290. public function translate($originalWord) {
  291. $getArg = func_num_args();
  292. if ($getArg > 1) {
  293. $allWords = func_get_args();
  294. array_shift($allWords);
  295. } else {
  296. $allWords = array();
  297. }
  298. $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null;
  299. if (!$translatedWord) {
  300. return ucwords(str_replace("_", " ", strtolower($originalWord)));
  301. //echo "WHOA!!!!!!! $originalWord";
  302. }
  303. $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES);
  304. return vsprintf($translatedWord, $allWords);
  305. }
  306. }
  307. $language = new setLanguage;
  308. // ==== General Class Definitions END ====
  309. // Direct request to curl if it exists, otherwise handle if not HTTPS
  310. function post_router($url, $data, $headers = array(), $referer='') {
  311. if (function_exists('curl_version')) {
  312. return curl_post($url, $data, $headers, $referer);
  313. } else {
  314. return post_request($url, $data, $headers, $referer);
  315. }
  316. }
  317. if (function_exists('curl_version')) :
  318. // Curl Post
  319. function curl_post($url, $data, $headers = array(), $referer='') {
  320. // Initiate cURL
  321. $curlReq = curl_init($url);
  322. // As post request
  323. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST");
  324. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  325. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  326. if(localURL($url)){
  327. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  328. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  329. }
  330. // Format Data
  331. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  332. case 'application/json':
  333. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  334. break;
  335. case 'application/x-www-form-urlencoded':
  336. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  337. break;
  338. default:
  339. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  340. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  341. }
  342. // Format Headers
  343. $cHeaders = array();
  344. foreach ($headers as $k => $v) {
  345. $cHeaders[] = $k.': '.$v;
  346. }
  347. if (count($cHeaders)) {
  348. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  349. }
  350. // Execute
  351. $result = curl_exec($curlReq);
  352. $httpcode = curl_getinfo($curlReq);
  353. // Close
  354. curl_close($curlReq);
  355. // Return
  356. return array('content'=>$result, 'http_code'=>$httpcode);
  357. }
  358. //Curl Get Function
  359. function curl_get($url, $headers = array()) {
  360. // Initiate cURL
  361. $curlReq = curl_init($url);
  362. // As post request
  363. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET");
  364. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  365. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  366. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  367. if(localURL($url)){
  368. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  369. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  370. }
  371. // Format Headers
  372. $cHeaders = array();
  373. foreach ($headers as $k => $v) {
  374. $cHeaders[] = $k.': '.$v;
  375. }
  376. if (count($cHeaders)) {
  377. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  378. }
  379. // Execute
  380. $result = curl_exec($curlReq);
  381. // Close
  382. curl_close($curlReq);
  383. // Return
  384. return $result;
  385. }
  386. //Curl Delete Function
  387. function curl_delete($url, $headers = array()) {
  388. // Initiate cURL
  389. $curlReq = curl_init($url);
  390. // As post request
  391. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE");
  392. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  393. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  394. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  395. if(localURL($url)){
  396. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  397. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  398. }
  399. // Format Headers
  400. $cHeaders = array();
  401. foreach ($headers as $k => $v) {
  402. $cHeaders[] = $k.': '.$v;
  403. }
  404. if (count($cHeaders)) {
  405. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  406. }
  407. // Execute
  408. $result = curl_exec($curlReq);
  409. $httpcode = curl_getinfo($curlReq);
  410. // Close
  411. curl_close($curlReq);
  412. // Return
  413. return array('content'=>$result, 'http_code'=>$httpcode);
  414. }
  415. endif;
  416. //Case-Insensitive Function
  417. function in_arrayi($needle, $haystack) {
  418. return in_array(strtolower($needle), array_map('strtolower', $haystack));
  419. }
  420. // HTTP post request (Removes need for curl, probably useless)
  421. function post_request($url, $data, $headers = array(), $referer='') {
  422. // Adapted from http://stackoverflow.com/a/28387011/6810513
  423. // Convert the data array into URL Parameters like a=b&foo=bar etc.
  424. if (isset($headers['Content-Type'])) {
  425. switch ($headers['Content-Type']) {
  426. case 'application/json':
  427. $data = json_encode($data);
  428. break;
  429. case 'application/x-www-form-urlencoded':
  430. $data = http_build_query($data);
  431. break;
  432. }
  433. } else {
  434. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  435. $data = http_build_query($data);
  436. }
  437. // parse the given URL
  438. $urlDigest = parse_url($url);
  439. // extract host and path:
  440. $host = $urlDigest['host'];
  441. $path = $urlDigest['path'];
  442. if ($urlDigest['scheme'] != 'http') {
  443. die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')');
  444. }
  445. // open a socket connection on port 80 - timeout: 30 sec
  446. $fp = fsockopen($host, (isset($urlDigest['port'])?':'.$urlDigest['port']:80), $errno, $errstr, 30);
  447. if ($fp){
  448. // send the request headers:
  449. fputs($fp, "POST $path HTTP/1.1\r\n");
  450. fputs($fp, "Host: $host\r\n");
  451. if ($referer != '')
  452. fputs($fp, "Referer: $referer\r\n");
  453. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  454. foreach($headers as $k => $v) {
  455. fputs($fp, $k.": ".$v."\r\n");
  456. }
  457. fputs($fp, "Connection: close\r\n\r\n");
  458. fputs($fp, $data);
  459. $result = '';
  460. while(!feof($fp)) {
  461. // receive the results of the request
  462. $result .= fgets($fp, 128);
  463. }
  464. }
  465. else {
  466. return array(
  467. 'status' => 'err',
  468. 'error' => "$errstr ($errno)"
  469. );
  470. }
  471. // close the socket connection:
  472. fclose($fp);
  473. // split the result header from the content
  474. $result = explode("\r\n\r\n", $result, 2);
  475. $header = isset($result[0]) ? $result[0] : '';
  476. $content = isset($result[1]) ? $result[1] : '';
  477. // return as structured array:
  478. return array(
  479. 'status' => 'ok',
  480. 'header' => $header,
  481. 'content' => $content,
  482. );
  483. }
  484. // Format item from Emby for Carousel
  485. function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $moreInfo = false) {
  486. // Static Height
  487. $height = 444;
  488. // Get Item Details
  489. $itemDetails = json_decode(file_get_contents($address.'/Items?Ids='.$item['Id'].'&api_key='.$token),true)['Items'][0];
  490. /*if (substr_count(EMBYURL, ':') == 2) {
  491. $URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  492. }else{
  493. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  494. }*/
  495. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  496. switch ($itemDetails['Type']) {
  497. case 'Episode':
  498. $title = (isset($itemDetails['SeriesName'])?$itemDetails['SeriesName']:"");
  499. $imageId = (isset($itemDetails['SeriesId'])?$itemDetails['SeriesId']:$itemDetails['Id']);
  500. $width = 300;
  501. $style = '';
  502. $image = 'slick-image-tall';
  503. if(!$nowPlaying){
  504. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  505. $key = $itemDetails['Id'] . "-list";
  506. $itemType = 'season';
  507. }else{
  508. $height = 281;
  509. $width = 500;
  510. $imageId = isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId'] : (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  511. $imageType = isset($itemDetails['ParentThumbItemId']) ? "Thumb" : (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  512. $key = (isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId']."-np" : "none-np");
  513. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  514. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  515. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  516. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  517. $stream = $moreInfo['PlayState']['PlayMethod'];
  518. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  519. $id = $moreInfo['DeviceId'];
  520. $streamInfo = buildStream(array(
  521. 'platform' => (string) $moreInfo['Client'],
  522. 'device' => (string) $moreInfo['DeviceName'],
  523. 'stream' => streamType($stream),
  524. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  525. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  526. ));
  527. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  528. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$itemDetails['Name'].'</h5>';
  529. $bottomTitle = '<small class="zero-m">S'.$itemDetails['ParentIndexNumber'].' · E'.$itemDetails['IndexNumber'].'</small>';
  530. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  531. }
  532. break;
  533. case 'MusicAlbum':
  534. case 'Audio':
  535. $title = $itemDetails['Name'];
  536. $imageId = $itemDetails['Id'];
  537. $width = 444;
  538. $style = '';
  539. $image = 'slick-image-short';
  540. if(!$nowPlaying){
  541. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  542. $key = $itemDetails['Id'] . "-list";
  543. $itemType = 'album';
  544. }else{
  545. $height = 281;
  546. $width = 500;
  547. $imageId = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  548. $imageType = (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  549. $key = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : "no-np") . "-np";
  550. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  551. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  552. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  553. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  554. $stream = $moreInfo['PlayState']['PlayMethod'];
  555. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  556. $id = $moreInfo['DeviceId'];
  557. $streamInfo = buildStream(array(
  558. 'platform' => (string) $moreInfo['Client'],
  559. 'device' => (string) $moreInfo['DeviceName'],
  560. 'stream' => streamType($stream),
  561. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  562. ));
  563. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  564. $topTitle = '<h5 class="text-center zero-m elip">'.$itemDetails['AlbumArtist'].' - '.$itemDetails['Album'].'</h5>';
  565. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  566. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  567. }
  568. break;
  569. case 'TvChannel':
  570. $title = $itemDetails['CurrentProgram']['Name'];
  571. $imageId = $itemDetails['Id'];
  572. $width = 300;
  573. $style = '';
  574. $image = 'slick-image-tall';
  575. if(!$nowPlaying){
  576. $imageType = "Primary";
  577. $key = $itemDetails['Id'] . "-list";
  578. }else{
  579. $height = 281;
  580. $width = 500;
  581. $imageType = "Thumb";
  582. $key = $itemDetails['Id'] . "-np";
  583. $useImage = "images/livetv.png";
  584. $watched = "0";
  585. $stream = $moreInfo['PlayState']['PlayMethod'];
  586. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  587. $id = $moreInfo['DeviceId'];
  588. $streamInfo = buildStream(array(
  589. 'platform' => (string) $moreInfo['Client'],
  590. 'device' => (string) $moreInfo['DeviceName'],
  591. 'stream' => streamType($stream),
  592. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  593. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  594. ));
  595. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  596. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  597. $bottomTitle = '<small class="zero-m">'.$itemDetails['Name'].' - '.$itemDetails['ChannelNumber'].'</small>';
  598. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  599. }
  600. break;
  601. default:
  602. $title = $itemDetails['Name'];
  603. $imageId = $itemDetails['Id'];
  604. $width = 300;
  605. $style = '';
  606. $image = 'slick-image-tall';
  607. if(!$nowPlaying){
  608. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  609. $key = $itemDetails['Id'] . "-list";
  610. $itemType = 'movie';
  611. }else{
  612. $height = 281;
  613. $width = 500;
  614. $imageType = isset($itemDetails['ImageTags']['Thumb']) ? "Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
  615. $key = $itemDetails['Id'] . "-np";
  616. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  617. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  618. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  619. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  620. $stream = $moreInfo['PlayState']['PlayMethod'];
  621. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  622. $id = $moreInfo['DeviceId'];
  623. $streamInfo = buildStream(array(
  624. 'platform' => (string) $moreInfo['Client'],
  625. 'device' => (string) $moreInfo['DeviceName'],
  626. 'stream' => streamType($stream),
  627. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  628. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  629. ));
  630. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  631. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  632. $bottomTitle = '<small class="zero-m">'.$moreInfo['NowPlayingItem']['ProductionYear'].'</small>';
  633. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  634. }
  635. }
  636. // If No Overview
  637. if (!isset($itemDetails['Overview'])) {
  638. $itemDetails['Overview'] = '';
  639. }
  640. $original_image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  641. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  642. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  643. $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'';
  644. }
  645. if($nowPlaying){
  646. if(!$imageType){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  647. if(!$imageId){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  648. }else{
  649. if(!$imageType){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  650. if(!$imageId){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  651. }
  652. if(isset($useImage)){ $image_url = $useImage; }
  653. // Assemble Item And Cache Into Array
  654. if($nowPlaying){
  655. //prettyPrint($itemDetails);
  656. return '<div class="col-sm-6 col-md-3"><div class="thumbnail ultra-widget"><div style="display: none;" np="'.$id.'" class="overlay content-box small-box gray-bg">'.$streamInfo.'</div><span class="refreshNP w-refresh w-p-icon gray" link="'.$id.'"><span class="fa-stack fa-lg" style="font-size: .5em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-info-circle fa-stack-1x fa-inverse"></i></span></span><a href="'.$URL.'" target="_blank"><img style="width: 100%; display:inherit;" src="'.$image_url.'" alt="'.$itemDetails['Name'].'" original-image="'.$original_image_url.'" class="refreshImageSource"></a><div class="progress progress-bar-sm zero-m"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$watched.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$watched.'%"></div><div class="progress-bar palette-Grey-500 bg" style="width: 0%"></div></div><div class="caption"><i style="float:left" class="fa fa-'.$state.'"></i>'.$topTitle.''.$bottomTitle.'</div></div></div>';
  657. }else{
  658. return '<div class="item-'.$itemType.'"><div class="ultra-widget refreshImage"><span class="w-refresh w-p-icon gray"><span class="fa-stack fa-lg" style="font-size: .4em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-refresh fa-stack-1x fa-inverse"></i></span></span></div><a href="'.$URL.'" target="_blank"><img alt="'.$itemDetails['Name'].'" class="'.$image.' refreshImageSource" data-lazy="'.$image_url.'" original-image="'.$original_image_url.'"></a><small class="elip slick-bottom-title">'.$title.'</small></div>';
  659. }
  660. }
  661. // Format item from Plex for Carousel
  662. function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $playlist = false) {
  663. // Static Height
  664. $height = 444;
  665. $widthOverride = 100;
  666. $playlist = ($playlist) ? " playlist-$playlist" : "";
  667. switch ($item['type']) {
  668. case 'season':
  669. $title = $item['parentTitle'];
  670. $summary = $item['parentSummary'];
  671. $width = 300;
  672. $image = 'slick-image-tall';
  673. $style = '';
  674. if(!$nowPlaying){
  675. $thumb = $item['thumb'];
  676. $key = $item['ratingKey'] . "-list";
  677. }else {
  678. $height = 281;
  679. $width = 500;
  680. $thumb = $item['art'];
  681. $key = $item['ratingKey'] . "-np";
  682. $elapsed = $item['viewOffset'];
  683. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  684. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  685. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  686. $stream = $item->Media->Part->Stream['decision'];
  687. $user = $role == "admin" ? $item->User['title'] : "";
  688. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  689. $streamInfo = buildStream(array(
  690. 'platform' => (string) $item->Player['platform'],
  691. 'device' => (string) $item->Player['device'],
  692. 'stream' => streamType($item->Media->Part['decision']),
  693. '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'].")",
  694. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  695. ));
  696. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  697. }
  698. break;
  699. case 'episode':
  700. $title = $item['grandparentTitle'];
  701. $summary = $item['title'];
  702. $width = 300;
  703. $image = 'slick-image-tall';
  704. $style = '';
  705. if(!$nowPlaying){
  706. $thumb = ($item['parentThumb'] ? $item['parentThumb'] : $item['grandparentThumb']);
  707. $key = $item['ratingKey'] . "-list";
  708. }else {
  709. $height = 281;
  710. $width = 500;
  711. $thumb = $item['art'];
  712. $key = $item['ratingKey'] . "-np";
  713. $elapsed = $item['viewOffset'];
  714. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  715. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  716. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  717. $stream = $item->Media->Part->Stream['decision'];
  718. $user = $role == "admin" ? $item->User['title'] : "";
  719. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  720. $streamInfo = buildStream(array(
  721. 'platform' => (string) $item->Player['platform'],
  722. 'device' => (string) $item->Player['device'],
  723. 'stream' => streamType($item->Media->Part['decision']),
  724. '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'].")",
  725. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  726. ));
  727. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  728. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$item['title'].'</h5>';
  729. $bottomTitle = '<small class="zero-m">S'.$item['parentIndex'].' · E'.$item['index'].'</small>';
  730. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  731. }
  732. break;
  733. case 'clip':
  734. $title = $item['title'];
  735. $summary = $item['summary'];
  736. $width = 300;
  737. $image = 'slick-image-tall';
  738. $style = '';
  739. if(!$nowPlaying){
  740. $thumb = $item['thumb'];
  741. $key = $item['ratingKey'] . "-list";
  742. }else {
  743. $height = 281;
  744. $width = 500;
  745. $thumb = $item['art'];
  746. $key = isset($item['ratingKey']) ? $item['ratingKey'] . "-np" : (isset($item['live']) ? "livetv.png" : ":)");
  747. $useImage = (isset($item['live']) ? "images/livetv.png" : null);
  748. $extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
  749. $elapsed = $item['viewOffset'];
  750. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  751. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  752. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  753. $stream = $item->Media->Part->Stream['decision'];
  754. $user = $role == "admin" ? $item->User['title'] : "";
  755. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  756. $streamInfo = buildStream(array(
  757. 'platform' => (string) $item->Player['platform'],
  758. 'device' => (string) $item->Player['device'],
  759. 'stream' => streamType($item->Media->Part['decision']),
  760. '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'].")",
  761. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  762. ));
  763. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  764. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  765. $bottomTitle = '<small class="zero-m">'.$extraInfo.'</small>';
  766. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  767. }
  768. break;
  769. case 'album':
  770. case 'track':
  771. $title = $item['parentTitle'];
  772. $summary = $item['title'];
  773. $image = 'slick-image-short';
  774. $style = 'left: 160px !important;';
  775. $item['ratingKey'] = $item['parentRatingKey'];
  776. if(!$nowPlaying){
  777. $width = 444;
  778. $thumb = $item['thumb'];
  779. $key = $item['ratingKey'] . "-list";
  780. }else {
  781. $height = 281;
  782. $width = 500;
  783. $thumb = ($item['art']) ? $item['art'] : $item['parentThumb'];
  784. $widthOverride = ($item['art']) ? 100 : 56;
  785. $key = $item['ratingKey'] . "-np";
  786. $elapsed = $item['viewOffset'];
  787. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  788. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  789. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  790. $stream = $item->Media->Part->Stream['decision'];
  791. $user = $role == "admin" ? $item->User['title'] : "";
  792. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  793. $streamInfo = buildStream(array(
  794. 'platform' => (string) $item->Player['platform'],
  795. 'device' => (string) $item->Player['device'],
  796. 'stream' => streamType($item->Media->Part['decision']),
  797. 'audio' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['channels']."ch)",
  798. ));
  799. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  800. $topTitle = '<h5 class="text-center zero-m elip">'.$item['grandparentTitle'].' - '.$item['title'].'</h5>';
  801. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  802. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  803. }
  804. break;
  805. default:
  806. $title = $item['title'];
  807. $summary = $item['summary'];
  808. $image = 'slick-image-tall';
  809. $style = '';
  810. if(!$nowPlaying){
  811. $width = 300;
  812. $thumb = $item['thumb'];
  813. $key = $item['ratingKey'] . "-list";
  814. }else {
  815. $height = 281;
  816. $width = 500;
  817. $thumb = $item['art'];
  818. $key = $item['ratingKey'] . "-np";
  819. $elapsed = $item['viewOffset'];
  820. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  821. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  822. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  823. $stream = $item->Media->Part->Stream['decision'];
  824. $user = $role == "admin" ? $item->User['title'] : "";
  825. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  826. $streamInfo = buildStream(array(
  827. 'platform' => (string) $item->Player['platform'],
  828. 'device' => (string) $item->Player['device'],
  829. 'stream' => streamType($item->Media->Part['decision']),
  830. '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'].")",
  831. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  832. ));
  833. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  834. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  835. $bottomTitle = '<small class="zero-m">'.$item['year'].'</small>';
  836. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  837. }
  838. }
  839. if (PLEXTABURL) {
  840. $address = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  841. }else{
  842. $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  843. }
  844. // If No Overview
  845. if (!isset($itemDetails['Overview'])) { $itemDetails['Overview'] = ''; }
  846. $original_image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  847. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  848. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  849. $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'';
  850. }
  851. if($nowPlaying){
  852. if(!$thumb){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  853. }else{
  854. if(!$thumb){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  855. }
  856. if(isset($useImage)){ $image_url = $useImage; }
  857. $openTab = (PLEXTABNAME) ? "true" : "false";
  858. // Assemble Item And Cache Into Array
  859. if($nowPlaying){
  860. return '<div class="col-sm-6 col-md-3"><div class="thumbnail ultra-widget"><div style="display: none;" np="'.$id.'" class="overlay content-box small-box gray-bg">'.$streamInfo.'</div><span class="refreshNP w-refresh w-p-icon gray" link="'.$id.'"><span class="fa-stack fa-lg" style="font-size: .5em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-info-circle fa-stack-1x fa-inverse"></i></span></span><div class="ultra-widget refreshImage"><span class="w-refresh w-p-icon gray"><span class="fa-stack fa-lg" style="font-size: .4em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-refresh fa-stack-1x fa-inverse"></i></span></span></div><a class="openTab" extraTitle="'.$title.'" extraType="'.$item['type'].'" openTab="'.$openTab.'" href="'.$address.'" target="_blank"><img class="refreshImageSource" style="width: '.$widthOverride.'%; display:block;" src="'.$image_url.'" original-image="'.$original_image_url.'" alt="'.$item['Name'].'"></a><div class="progress progress-bar-sm zero-m"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$watched.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$watched.'%"></div><div class="progress-bar palette-Grey-500 bg" style="width: '.$transcoded.'%"></div></div><div class="caption"><i style="float:left" class="fa fa-'.$state.'"></i>'.$topTitle.''.$bottomTitle.'</div></div></div>';
  861. }else{
  862. return '<div class="item-'.$item['type'].$playlist.'"><div style="" class="ultra-widget refreshImage"><span class="w-refresh w-p-icon gray"><span class="fa-stack fa-lg" style="font-size: .4em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-refresh fa-stack-1x fa-inverse"></i></span></span></div><a class="openTab" extraTitle="'.$title.'" extraType="'.$item['type'].'" openTab="'.$openTab.'" href="'.$address.'" target="_blank"><img alt="'.$item['Name'].'" class="'.$image.' refreshImageSource" data-lazy="'.$image_url.'" original-image="'.$original_image_url.'"></a><small class="elip slick-bottom-title">'.$title.'</small></div>';
  863. }
  864. }
  865. //$hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  866. //Recent Added
  867. function outputRecentAdded($header, $items, $script = false, $array, $type) {
  868. $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">';
  869. if(preg_grep("/item-movie/", $items)){
  870. $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>';
  871. }
  872. if(preg_grep("/item-season/", $items)){
  873. $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>';
  874. }
  875. if(preg_grep("/item-album/", $items)){
  876. $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>';
  877. }
  878. $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>';
  879. $hideMenu .= '</ul></div></div>';
  880. // If None Populate Empty Item
  881. if (!count($items)) {
  882. return '<div id="recentMedia'.$type.'" class="content-box box-shadow big-box"><h5 class="text-center">'.$header.'</h5><p class="text-center">No Media Found</p></div>';
  883. }else{
  884. $className = str_replace(' ', '', $header.' on '.$type);
  885. return '<div id="recentMedia'.$type.'" class="content-box box-shadow big-box"><h5 id="recentContent-title-'.$type.'" style="margin-bottom: -20px" class="text-center">'.$header.'</h5><div class="recentHeader inbox-pagination '.$className.'">'.$hideMenu.'</div><br/><br/><div class="recentItems-recent-'.$type.'" data-name="'.$className.'">'.implode('',$items).'</div></div>'.($script?'<script>'.$script.'</script>':'');
  886. }
  887. }
  888. // Create Carousel
  889. function outputNowPlaying($header, $size, $type, $items, $script = false) {
  890. // If None Populate Empty Item
  891. if (!count($items)) {
  892. return '<div id='.$type.'></div>'.($script?'<script>'.$script.'</script>':'');
  893. }else{
  894. return '<div id='.$type.'><h5 class="zero-m big-box"><strong>'.$header.'</strong></h5>'.implode('',$items).'</div>'.($script?'<script>'.$script.'</script>':'');
  895. }
  896. }
  897. // Get Now Playing Streams From Emby
  898. function getEmbyStreams($size, $showNames, $role) {
  899. $address = qualifyURL(EMBYURL);
  900. $api = json_decode(@file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
  901. if (!is_array($api)) { return 'Could not load!'; }
  902. $playingItems = array();
  903. foreach($api as $key => $value) {
  904. if (isset($value['NowPlayingItem'])) {
  905. $playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem'], true, $showNames, $role, $value);
  906. }
  907. }
  908. return outputNowPlaying(translate('PLAYING_NOW_ON_EMBY')." ( ".count($playingItems)." Streams )", $size, 'streams-emby', $playingItems, "
  909. setInterval(function() {
  910. $('<div></div>').load('ajax.php?a=emby-streams',function() {
  911. var element = $(this).find('[id]');
  912. var loadedID = element.attr('id');
  913. $('#'+loadedID).replaceWith(element);
  914. console.log('Loaded updated: '+loadedID);
  915. });
  916. }, ".NOWPLAYINGREFRESH.");
  917. ");
  918. }
  919. // Get Now Playing Streams From Plex
  920. function getPlexStreams($size, $showNames, $role){
  921. $address = qualifyURL(PLEXURL);
  922. // Perform API requests
  923. $api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
  924. libxml_use_internal_errors(true);
  925. $api = simplexml_load_string($api);
  926. if (is_array($api) || is_object($api)){
  927. if (!$api->head->title){
  928. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  929. if (!$getServer) { return 'Could not load!'; }
  930. // Identify the local machine
  931. $gotServer = $getServer['machineIdentifier'];
  932. $items = array();
  933. foreach($api AS $child) {
  934. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
  935. }
  936. return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." ( ".count($items)." Streams )", $size, 'streams-plex', $items, "
  937. setInterval(function() {
  938. $('<div></div>').load('ajax.php?a=plex-streams',function() {
  939. var element = $(this).find('[id]');
  940. var loadedID = element.attr('id');
  941. $('#'+loadedID).replaceWith(element);
  942. console.log('Loaded updated: '+loadedID);
  943. });
  944. }, ".NOWPLAYINGREFRESH.");
  945. ");
  946. }else{
  947. writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
  948. }
  949. }else{
  950. writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
  951. }
  952. }
  953. // Get Recent Content From Emby
  954. function getEmbyRecent($array) {
  955. $address = qualifyURL(EMBYURL);
  956. $header = translate('RECENT_CONTENT');
  957. // Currently Logged In User
  958. $username = false;
  959. if (isset($GLOBALS['USER'])) {
  960. $username = strtolower($GLOBALS['USER']->username);
  961. }
  962. // Get A User
  963. $userIds = json_decode(@file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
  964. if (!is_array($userIds)) { return 'Could not load!'; }
  965. $showPlayed = true;
  966. foreach ($userIds as $value) { // Scan for admin user
  967. if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
  968. $userId = $value['Id'];
  969. }
  970. if ($username && strtolower($value['Name']) == $username) {
  971. $userId = $value['Id'];
  972. $showPlayed = false;
  973. break;
  974. }
  975. }
  976. // Get the latest Items
  977. $latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?EnableImages=false&Limit='.EMBYRECENTITEMS.'&api_key='.EMBYTOKEN.($showPlayed?'':'&IsPlayed=false')),true);
  978. // For Each Item In Category
  979. $items = array();
  980. foreach ($latest as $k => $v) {
  981. $type = (string) $v['Type'];
  982. if(@$array[$type] == "true"){
  983. $items[] = resolveEmbyItem($address, EMBYTOKEN, $v, false, false, false);
  984. }
  985. }
  986. $array["movie"] = $array["Movie"];
  987. $array["season"] = $array["Episode"];
  988. $array["album"] = $array["MusicAlbum"];
  989. unset($array["Movie"]);
  990. unset($array["Episode"]);
  991. unset($array["MusicAlbum"]);
  992. unset($array["Series"]);
  993. return outputRecentAdded($header, $items, "
  994. setInterval(function() {
  995. $('<div></div>').load('ajax.php?a=emby-recent',function() {
  996. var element = $(this).find('#recentMediaEmby');
  997. var loadedID = element.attr('id');
  998. $('#recentMediaEmby').replaceWith(element);
  999. console.log('Loaded recent: '+loadedID);
  1000. loadSlick();
  1001. });
  1002. }, ".RECENTREFRESH.");
  1003. ", $array, 'Emby');
  1004. }
  1005. // Get Recent Content From Plex
  1006. function getPlexRecent($array){
  1007. $address = qualifyURL(PLEXURL);
  1008. $header = translate('RECENT_CONTENT');
  1009. // Perform Requests
  1010. $api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN);
  1011. libxml_use_internal_errors(true);
  1012. $api = simplexml_load_string($api);
  1013. if (is_array($api) || is_object($api)){
  1014. if (!$api->head->title){
  1015. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  1016. if (!$getServer) { return 'Could not load!'; }
  1017. // Identify the local machine
  1018. $gotServer = $getServer['machineIdentifier'];
  1019. $items = array();
  1020. foreach($api AS $child) {
  1021. $type = (string) $child['type'];
  1022. if($array[$type] == "true"){
  1023. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
  1024. }
  1025. }
  1026. return outputRecentAdded($header, $items, "
  1027. setInterval(function() {
  1028. $('<div></div>').load('ajax.php?a=plex-recent',function() {
  1029. var element = $(this).find('#recentMediaPlex');
  1030. var loadedID = element.attr('id');
  1031. $('#recentMediaPlex').replaceWith(element);
  1032. console.log('Loaded recent: '+loadedID);
  1033. loadSlick();
  1034. });
  1035. }, ".RECENTREFRESH.");
  1036. ", $array, 'Plex');
  1037. }else{
  1038. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check token - if HTTPS, is cert valid");
  1039. }
  1040. }else{
  1041. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check URL - if HTTPS, is cert valid");
  1042. }
  1043. }
  1044. // Get Image From Emby
  1045. function getEmbyImage() {
  1046. $refresh = false;
  1047. $embyAddress = qualifyURL(EMBYURL);
  1048. if (!file_exists('images/cache')) {
  1049. mkdir('images/cache', 0777, true);
  1050. }
  1051. $itemId = $_GET['img'];
  1052. $key = $_GET['key'];
  1053. if(strpos($key, '$') !== false){
  1054. $key = explode('$', $key)[0];
  1055. $refresh = true;
  1056. }
  1057. $itemType = $_GET['type'];
  1058. $imgParams = array();
  1059. if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
  1060. if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
  1061. if(isset($itemId)) {
  1062. $image_src = $embyAddress . '/Items/'.$itemId.'/Images/'.$itemType.'?'.implode('&', $imgParams);
  1063. $cachefile = 'images/cache/'.$key.'.jpg';
  1064. $cachetime = 604800;
  1065. // Serve from the cache if it is younger than $cachetime
  1066. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh !== true) {
  1067. header("Content-type: image/jpeg");
  1068. @readfile($cachefile);
  1069. exit;
  1070. }
  1071. ob_start(); // Start the output buffer
  1072. header('Content-type: image/jpeg');
  1073. @readfile($image_src);
  1074. // Cache the output to a file
  1075. $fp = fopen($cachefile, 'wb');
  1076. fwrite($fp, ob_get_contents());
  1077. fclose($fp);
  1078. ob_end_flush(); // Send the output to the browser
  1079. die();
  1080. } else {
  1081. debug_out('Invalid Request',1);
  1082. }
  1083. }
  1084. // Get Image From Plex
  1085. function getPlexImage() {
  1086. $refresh = false;
  1087. $plexAddress = qualifyURL(PLEXURL);
  1088. if (!file_exists('images/cache')) {
  1089. mkdir('images/cache', 0777, true);
  1090. }
  1091. $image_url = $_GET['img'];
  1092. $key = $_GET['key'];
  1093. if(strpos($key, '$') !== false){
  1094. $key = explode('$', $key)[0];
  1095. $refresh = true;
  1096. }
  1097. $image_height = $_GET['height'];
  1098. $image_width = $_GET['width'];
  1099. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  1100. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  1101. $cachefile = 'images/cache/'.$key.'.jpg';
  1102. $cachetime = 604800;
  1103. // Serve from the cache if it is younger than $cachetime
  1104. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh == false) {
  1105. header("Content-type: image/jpeg");
  1106. @readfile($cachefile);
  1107. exit;
  1108. }
  1109. ob_start(); // Start the output buffer
  1110. header('Content-type: image/jpeg');
  1111. @readfile($image_src);
  1112. // Cache the output to a file
  1113. $fp = fopen($cachefile, 'wb');
  1114. fwrite($fp, ob_get_contents());
  1115. fclose($fp);
  1116. ob_end_flush(); // Send the output to the browser
  1117. die();
  1118. } else {
  1119. echo "Invalid Plex Request";
  1120. }
  1121. }
  1122. // Simplier access to class
  1123. function translate($string) {
  1124. if (isset($GLOBALS['language'])) {
  1125. return $GLOBALS['language']->translate($string);
  1126. } else {
  1127. return '!Translations Not Loaded!';
  1128. }
  1129. }
  1130. // Generate Random string
  1131. function randString($length = 10, $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  1132. $tmp = '';
  1133. for ($i = 0; $i < $length; $i++) {
  1134. $tmp .= substr(str_shuffle($chars), 0, 1);
  1135. }
  1136. return $tmp;
  1137. }
  1138. // Create config file in the return syntax
  1139. function createConfig($array, $path = 'config/config.php', $nest = 0) {
  1140. // Define Initial Value
  1141. $output = array();
  1142. // Sort Items
  1143. ksort($array);
  1144. // Update the current config version
  1145. if (!$nest) {
  1146. // Inject Current Version
  1147. $output[] = "\t'CONFIG_VERSION' => '".(isset($array['apply_CONFIG_VERSION'])?$array['apply_CONFIG_VERSION']:INSTALLEDVERSION)."'";
  1148. }
  1149. unset($array['CONFIG_VERSION']);
  1150. unset($array['apply_CONFIG_VERSION']);
  1151. // Process Settings
  1152. foreach ($array as $k => $v) {
  1153. $allowCommit = true;
  1154. switch (gettype($v)) {
  1155. case 'boolean':
  1156. $item = ($v?'true':'false');
  1157. break;
  1158. case 'integer':
  1159. case 'double':
  1160. case 'integer':
  1161. case 'NULL':
  1162. $item = $v;
  1163. break;
  1164. case 'string':
  1165. $item = "'".str_replace(array('\\',"'"),array('\\\\',"\'"),$v)."'";
  1166. break;
  1167. case 'array':
  1168. $item = createConfig($v, false, $nest+1);
  1169. break;
  1170. default:
  1171. $allowCommit = false;
  1172. }
  1173. if($allowCommit) {
  1174. $output[] = str_repeat("\t",$nest+1)."'$k' => $item";
  1175. }
  1176. }
  1177. // Build output
  1178. $output = (!$nest?"<?php\nreturn ":'')."array(\n".implode(",\n",$output)."\n".str_repeat("\t",$nest).')'.(!$nest?';':'');
  1179. if (!$nest && $path) {
  1180. $pathDigest = pathinfo($path);
  1181. @mkdir($pathDigest['dirname'], 0770, true);
  1182. if (file_exists($path)) {
  1183. rename($path, $pathDigest['dirname'].'/'.$pathDigest['filename'].'.bak.php');
  1184. }
  1185. $file = fopen($path, 'w');
  1186. fwrite($file, $output);
  1187. fclose($file);
  1188. if (file_exists($path)) {
  1189. return true;
  1190. }
  1191. writeLog("error", "config was unable to write");
  1192. return false;
  1193. } else {
  1194. writeLog("success", "config was updated with new values");
  1195. return $output;
  1196. }
  1197. }
  1198. // Load a config file written in the return syntax
  1199. function loadConfig($path = 'config/config.php') {
  1200. // Adapted from http://stackoverflow.com/a/14173339/6810513
  1201. if (!is_file($path)) {
  1202. return null;
  1203. } else {
  1204. return (array) call_user_func(function() use($path) {
  1205. return include($path);
  1206. });
  1207. }
  1208. }
  1209. // Commit new values to the configuration
  1210. function updateConfig($new, $current = false) {
  1211. // Get config if not supplied
  1212. if ($current === false) {
  1213. $current = loadConfig();
  1214. } else if (is_string($current) && is_file($current)) {
  1215. $current = loadConfig($current);
  1216. }
  1217. // Inject Parts
  1218. foreach ($new as $k => $v) {
  1219. $current[$k] = $v;
  1220. }
  1221. // Return Create
  1222. return createConfig($current);
  1223. }
  1224. // Inject Defaults As Needed
  1225. function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
  1226. if (is_string($path)) {
  1227. $loadedDefaults = loadConfig($path);
  1228. } else {
  1229. $loadedDefaults = $path;
  1230. }
  1231. return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
  1232. }
  1233. // support function for fillDefaultConfig()
  1234. function fillDefaultConfig_recurse($current, $defaults) {
  1235. foreach($defaults as $k => $v) {
  1236. if (!isset($current[$k])) {
  1237. $current[$k] = $v;
  1238. } else if (is_array($current[$k]) && is_array($v)) {
  1239. $current[$k] = fillDefaultConfig_recurse($current[$k], $v);
  1240. }
  1241. }
  1242. return $current;
  1243. };
  1244. // Define Scalar Variables (nest non-secular with underscores)
  1245. function defineConfig($array, $anyCase = true, $nest_prefix = false) {
  1246. foreach($array as $k => $v) {
  1247. if (is_scalar($v) && !defined($nest_prefix.$k)) {
  1248. define($nest_prefix.$k, $v, $anyCase);
  1249. } else if (is_array($v)) {
  1250. defineConfig($v, $anyCase, $nest_prefix.$k.'_');
  1251. }
  1252. }
  1253. }
  1254. // This function exists only because I am lazy
  1255. function configLazy($path = 'config/config.php') {
  1256. // Load config or default
  1257. if (file_exists($path)) {
  1258. $config = fillDefaultConfig(loadConfig($path));
  1259. } else {
  1260. $config = loadConfig('config/configDefaults.php');
  1261. }
  1262. if (is_array($config)) {
  1263. defineConfig($config);
  1264. }
  1265. return $config;
  1266. }
  1267. // Qualify URL
  1268. function qualifyURL($url) {
  1269. //local address?
  1270. if(substr($url, 0,1) == "/"){
  1271. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  1272. $protocol = "https://";
  1273. } else {
  1274. $protocol = "http://";
  1275. }
  1276. $url = $protocol.getServer().$url;
  1277. }
  1278. // Get Digest
  1279. $digest = parse_url($url);
  1280. // http/https
  1281. if (!isset($digest['scheme'])) {
  1282. if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096,32400,7878,8989,8182,8081,6789))) {
  1283. $scheme = 'http';
  1284. } else {
  1285. $scheme = 'https';
  1286. }
  1287. } else {
  1288. $scheme = $digest['scheme'];
  1289. }
  1290. // Host
  1291. $host = (isset($digest['host'])?$digest['host']:'');
  1292. // Port
  1293. $port = (isset($digest['port'])?':'.$digest['port']:'');
  1294. // Path
  1295. $path = (isset($digest['path'])?$digest['path']:'');
  1296. // Output
  1297. return $scheme.'://'.$host.$port.$path;
  1298. }
  1299. // Function to be called at top of each to allow upgrading environment as the spec changes
  1300. function upgradeCheck() {
  1301. // Upgrade to 1.31
  1302. if (file_exists('homepageSettings.ini.php')) {
  1303. $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
  1304. $homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
  1305. $databaseConfig = array_merge($databaseConfig, $homepageConfig);
  1306. $databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
  1307. foreach($databaseConfig as $k => $v) {
  1308. if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
  1309. $databaseData .= $k . " = \"" . $v . "\"\r\n";
  1310. }
  1311. write_ini_file($databaseData, 'databaseLocation.ini.php');
  1312. unlink('homepageSettings.ini.php');
  1313. unset($databaseData);
  1314. unset($homepageConfig);
  1315. }
  1316. // Upgrade to 1.32
  1317. if (file_exists('databaseLocation.ini.php')) {
  1318. // Load Existing
  1319. $config = parse_ini_file('databaseLocation.ini.php', true);
  1320. // Refactor
  1321. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['databaseLocation'].'/');
  1322. $config['user_home'] = $config['database_Location'].'users/';
  1323. unset($config['databaseLocation']);
  1324. // Turn Off Emby And Plex Recent
  1325. $config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
  1326. unset($config["embyPort"]);
  1327. $config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
  1328. unset($config["plexPort"]);
  1329. $config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
  1330. unset($config["nzbgetPort"]);
  1331. $config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
  1332. unset($config["sabnzbdPort"]);
  1333. $config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
  1334. unset($config["headphonesPort"]);
  1335. // Write config file
  1336. $config['CONFIG_VERSION'] = '1.32';
  1337. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][pre1.32].bak.php');
  1338. $createConfigSuccess = createConfig($config);
  1339. // Create new config
  1340. if ($createConfigSuccess) {
  1341. if (file_exists('config/config.php')) {
  1342. // Remove Old ini file
  1343. unlink('databaseLocation.ini.php');
  1344. } else {
  1345. debug_out('Something is not right here!');
  1346. }
  1347. } else {
  1348. debug_out('Couldn\'t create updated configuration.' ,1);
  1349. }
  1350. }
  1351. // Upgrade to 1.33
  1352. $config = loadConfig();
  1353. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
  1354. // Fix User Directory
  1355. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['database_Location'].'/');
  1356. $config['user_home'] = $config['database_Location'].'users/';
  1357. unset($config['USER_HOME']);
  1358. // Backend auth merge
  1359. if (isset($config['authBackendPort']) && !isset(parse_url($config['authBackendHost'])['port'])) {
  1360. $config['authBackendHost'] .= ':'.$config['authBackendPort'];
  1361. }
  1362. unset($config['authBackendPort']);
  1363. // If auth is being used move it to embyURL as that is now used in auth functions
  1364. 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')))) {
  1365. $config['embyURL'] = $config['authBackendHost'];
  1366. }
  1367. // Upgrade database to latest version
  1368. updateSQLiteDB($config['database_Location'],'1.32');
  1369. // Update Version and Commit
  1370. $config['apply_CONFIG_VERSION'] = '1.33';
  1371. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.32].bak.php');
  1372. $createConfigSuccess = createConfig($config);
  1373. unset($config);
  1374. }
  1375. // Upgrade to 1.34
  1376. $config = loadConfig();
  1377. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.34')) {
  1378. // Upgrade database to latest version
  1379. updateSQLiteDB($config['database_Location'],'1.33');
  1380. // Update Version and Commit
  1381. $config['CONFIG_VERSION'] = '1.34';
  1382. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.33].bak.php');
  1383. $createConfigSuccess = createConfig($config);
  1384. unset($config);
  1385. }
  1386. // Upgrade to 1.40
  1387. $config = loadConfig();
  1388. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.40')) {
  1389. // Upgrade database to latest version
  1390. updateSQLiteDB($config['database_Location'],'1.38');
  1391. // Update Version and Commit
  1392. $config['CONFIG_VERSION'] = '1.40';
  1393. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.38].bak.php');
  1394. $createConfigSuccess = createConfig($config);
  1395. unset($config);
  1396. }
  1397. // Upgrade to 1.50
  1398. $config = loadConfig();
  1399. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.50')) {
  1400. // Upgrade database to latest version
  1401. updateSQLiteDB($config['database_Location'],'1.40');
  1402. // Update Version and Commit
  1403. $config['CONFIG_VERSION'] = '1.50';
  1404. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.40].bak.php');
  1405. $createConfigSuccess = createConfig($config);
  1406. unset($config);
  1407. }
  1408. return true;
  1409. }
  1410. // Get OS from server
  1411. function getOS(){
  1412. if(PHP_SHLIB_SUFFIX == "dll"){
  1413. return "win";
  1414. }else{
  1415. return "nix";
  1416. }
  1417. }
  1418. //Get Error by Server OS
  1419. function getError($os, $error){
  1420. $ini = (!empty(php_ini_loaded_file()) ? php_ini_loaded_file() : "php.ini");
  1421. $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'");
  1422. $errors = array(
  1423. 'pdo_sqlite' => array(
  1424. 'win' => '<b>PDO:SQLite</b> not enabled, uncomment ;extension=php_pdo_sqlite.dll in the file php.ini | '.$ext,
  1425. 'nix' => '<b>PDO:SQLite</b> not enabled, PHP7 -> run sudo apt-get install php7.0-sqlite | PHP5 -> run sudo apt-get install php5-sqlite',
  1426. ),
  1427. 'sqlite3' => array(
  1428. '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',
  1429. 'nix' => '<b>SQLite3</b> not enabled, run sudo apt-get install php-sqlite3',
  1430. ),
  1431. 'curl' => array(
  1432. 'win' => '<b>cURL</b> not enabled, uncomment ;extension=php_curl.dll in the file php.ini | '.$ext,
  1433. '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',
  1434. ),
  1435. 'zip' => array(
  1436. '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',
  1437. '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',
  1438. ),
  1439. );
  1440. return (isset($errors[$error][$os]) ? $errors[$error][$os] : 'No Error Info Found');
  1441. }
  1442. // Check if all software dependancies are met
  1443. function dependCheck() {
  1444. $output = array();
  1445. $i = 1;
  1446. if (!extension_loaded('pdo_sqlite')) { $output["Step $i"] = getError(getOS(),'pdo_sqlite'); $i++; }
  1447. if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; }
  1448. if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; }
  1449. //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
  1450. if ($output) {
  1451. $output["Step $i"] = "<b>Restart PHP and/or Webserver to apply changes</b>"; $i++;
  1452. $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++;
  1453. debug_out($output,1);
  1454. }
  1455. return true;
  1456. }
  1457. // Process file uploads
  1458. function uploadFiles($path, $ext_mask = null) {
  1459. if (isset($_FILES) && count($_FILES)) {
  1460. require_once('class.uploader.php');
  1461. $uploader = new Uploader();
  1462. $data = $uploader->upload($_FILES['files'], array(
  1463. 'limit' => 10,
  1464. 'maxSize' => 10,
  1465. 'extensions' => $ext_mask,
  1466. 'required' => false,
  1467. 'uploadDir' => str_replace('//','/',$path.'/'),
  1468. 'title' => array('name'),
  1469. 'removeFiles' => true,
  1470. 'replace' => true,
  1471. ));
  1472. if($data['isComplete']){
  1473. $files = $data['data'];
  1474. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1475. echo json_encode($files['metas'][0]['name']);
  1476. }
  1477. if($data['hasErrors']){
  1478. $errors = $data['errors'];
  1479. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1480. echo json_encode($errors);
  1481. }
  1482. } else {
  1483. writeLog("error", "image was not uploaded");
  1484. echo json_encode('No files submitted!');
  1485. }
  1486. }
  1487. // Process file uploads
  1488. function uploadAvatar($path, $ext_mask = null) {
  1489. if (isset($_FILES) && count($_FILES)) {
  1490. require_once('class.uploader.php');
  1491. $uploader = new Uploader();
  1492. $data = $uploader->upload($_FILES['files'], array(
  1493. 'limit' => 10,
  1494. 'maxSize' => 10,
  1495. 'extensions' => $ext_mask,
  1496. 'required' => false,
  1497. 'uploadDir' => str_replace('//','/',$path.'/'),
  1498. 'title' => array('name'),
  1499. 'removeFiles' => true,
  1500. 'replace' => true,
  1501. ));
  1502. if($data['isComplete']){
  1503. $files = $data['data'];
  1504. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1505. echo json_encode($files['metas'][0]['name']);
  1506. }
  1507. if($data['hasErrors']){
  1508. $errors = $data['errors'];
  1509. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1510. echo json_encode($errors);
  1511. }
  1512. } else {
  1513. writeLog("error", "image was not uploaded");
  1514. echo json_encode('No files submitted!');
  1515. }
  1516. }
  1517. // Remove file
  1518. function removeFiles($path) {
  1519. if(is_file($path)) {
  1520. writeLog("success", "file was removed");
  1521. unlink($path);
  1522. } else {
  1523. writeLog("error", "file was not removed");
  1524. echo json_encode('No file specified for removal!');
  1525. }
  1526. }
  1527. // Lazy select options
  1528. function resolveSelectOptions($array, $selected = '', $multi = false) {
  1529. $output = array();
  1530. $selectedArr = ($multi?explode('|', $selected):array());
  1531. foreach ($array as $key => $value) {
  1532. if (is_array($value)) {
  1533. if (isset($value['optgroup'])) {
  1534. $output[] = '<optgroup label="'.$key.'">';
  1535. foreach($value['optgroup'] as $k => $v) {
  1536. $output[] = '<option value="'.$v['value'].'"'.($selected===$v['value']||in_array($v['value'],$selectedArr)?' selected':'').(isset($v['disabled']) && $v['disabled']?' disabled':'').'>'.$k.'</option>';
  1537. }
  1538. } else {
  1539. $output[] = '<option value="'.$value['value'].'"'.($selected===$value['value']||in_array($value['value'],$selectedArr)?' selected':'').(isset($value['disabled']) && $value['disabled']?' disabled':'').'>'.$key.'</option>';
  1540. }
  1541. } else {
  1542. $output[] = '<option value="'.$value.'"'.($selected===$value||in_array($value,$selectedArr)?' selected':'').'>'.$key.'</option>';
  1543. }
  1544. }
  1545. return implode('',$output);
  1546. }
  1547. // Check if user is allowed to continue
  1548. function qualifyUser($type, $errOnFail = false) {
  1549. if (!isset($GLOBALS['USER'])) {
  1550. require_once("user.php");
  1551. $GLOBALS['USER'] = new User('registration_callback');
  1552. }
  1553. if (is_bool($type)) {
  1554. if ($type === true) {
  1555. $authorized = ($GLOBALS['USER']->authenticated == true);
  1556. } else {
  1557. $authorized = true;
  1558. }
  1559. } elseif (is_string($type) || is_array($type)) {
  1560. if ($type !== 'false') {
  1561. if (!is_array($type)) {
  1562. $type = explode('|',$type);
  1563. }
  1564. $authorized = ($GLOBALS['USER']->authenticated && in_array($GLOBALS['USER']->role,$type));
  1565. } else {
  1566. $authorized = true;
  1567. }
  1568. } else {
  1569. debug_out('Invalid Syntax!',1);
  1570. }
  1571. if (!$authorized && $errOnFail) {
  1572. if ($GLOBALS['USER']->authenticated) {
  1573. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401');
  1574. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401\'</script>';
  1575. } else {
  1576. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999');
  1577. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999\'</script>';
  1578. }
  1579. debug_out('Not Authorized' ,1);
  1580. } else {
  1581. return $authorized;
  1582. }
  1583. }
  1584. // Build an (optionally) tabbed settings page.
  1585. function buildSettings($array) {
  1586. /*
  1587. array(
  1588. 'title' => '',
  1589. 'id' => '',
  1590. 'fields' => array( See buildField() ),
  1591. 'tabs' => array(
  1592. array(
  1593. 'title' => '',
  1594. 'id' => '',
  1595. 'image' => '',
  1596. 'fields' => array( See buildField() ),
  1597. ),
  1598. ),
  1599. );
  1600. */
  1601. $notifyExplode = explode("-", NOTIFYEFFECT);
  1602. $fieldFunc = function($fieldArr) {
  1603. $fields = '<div class="row">';
  1604. foreach($fieldArr as $key => $value) {
  1605. $isSingle = isset($value['type']);
  1606. if ($isSingle) { $value = array($value); }
  1607. $tmpField = '';
  1608. $sizeLg = max(floor(12/count($value)),2);
  1609. $sizeMd = max(floor(($isSingle?12:6)/count($value)),3);
  1610. foreach($value as $k => $v) {
  1611. $tmpField .= buildField($v, 12, $sizeMd, $sizeLg);
  1612. }
  1613. $fields .= ($isSingle?$tmpField:'<div class="row col-sm-12 content-form">'.$tmpField.'</div>');
  1614. }
  1615. $fields .= '</div>';
  1616. return $fields;
  1617. };
  1618. $fields = (isset($array['fields'])?$fieldFunc($array['fields']):'');
  1619. $tabSelectors = array();
  1620. $tabContent = array();
  1621. if (isset($array['tabs'])) {
  1622. foreach($array['tabs'] as $key => $value) {
  1623. $id = (isset($value['id'])?$value['id']:randString(32));
  1624. $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>';
  1625. $tabContent[$key] = '<div class="tab-pane big-box fade'.($tabContent?'':' active in').'" id="tab-'.$id.'">'.$fieldFunc($value['fields']).'</div>';
  1626. }
  1627. }
  1628. $pageID = (isset($array['id'])?$array['id']:str_replace(array(' ','"',"'"),array('_'),strtolower($array['id'])));
  1629. $extraClick = ($pageID == 'appearance_settings' ? "$('#advanced_settings_form_submit').click();console.log('add theme settings');" : "");
  1630. return '
  1631. <div class="email-body">
  1632. <div class="email-header gray-bg">
  1633. <button type="button" class="btn btn-danger btn-sm waves close-button"><i class="fa fa-close"></i></button>
  1634. <button id="'.$pageID.'_form_submit" class="btn waves btn-labeled btn-success btn btn-sm text-uppercase waves-effect waves-float save-btn-form">
  1635. <span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save
  1636. </button>
  1637. <h1>'.$array['title'].'</h1>
  1638. </div>
  1639. <div class="email-inner small-box">
  1640. <div class="email-inner-section">
  1641. <div class="small-box fade in" id="'.$pageID.'_frame">
  1642. <div class="col-lg-12">
  1643. '.(isset($array['customBeforeForm'])?$array['customBeforeForm']:'').'
  1644. <form class="content-form" name="'.$pageID.'" id="'.$pageID.'_form" onsubmit="return false;">
  1645. '.$fields.($tabContent?'
  1646. <div class="tabbable tabs-with-bg" id="'.$pageID.'_tabs">
  1647. <ul class="nav nav-tabs apps">
  1648. '.implode('', $tabSelectors).'
  1649. </ul>
  1650. <div class="clearfix"></div>
  1651. <div class="tab-content">
  1652. '.implode('', $tabContent).'
  1653. </div>
  1654. </div>':'').'
  1655. </form>
  1656. '.(isset($array['customAfterForm'])?$array['customAfterForm']:'').'
  1657. </div>
  1658. </div>
  1659. </div>
  1660. </div>
  1661. </div>
  1662. <script>
  1663. $(document).ready(function() {
  1664. $(\'#'.$pageID.'_form\').find(\'input, select, textarea\').on(\'change\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1665. var '.$pageID.'Validate = function() { if (this.value && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { $(this).addClass(\'invalid\'); } else { $(this).removeClass(\'invalid\'); } };
  1666. $(\'#'.$pageID.'_form\').find(\'input[pattern]\').each('.$pageID.'Validate).on(\'keyup\', '.$pageID.'Validate);
  1667. $(\'#'.$pageID.'_form\').find(\'select[multiple]\').on(\'change click\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1668. $(\'#'.$pageID.'_form_submit\').on(\'click\', function () {
  1669. var newVals = {};
  1670. var hasVals = false;
  1671. var errorFields = [];
  1672. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').each(function() {
  1673. hasVals = true;
  1674. if (this.type == \'checkbox\') {
  1675. newVals[this.name] = this.checked;
  1676. } else if ($(this).hasClass(\'summernote\')) {
  1677. newVals[$(this).attr(\'name\')] = $(this).siblings(\'.note-editor\').find(\'.panel-body\').html();
  1678. } else {
  1679. if (this.value && this.pattern && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { errorFields.push(this.name); }
  1680. var fieldVal = $(this).val();
  1681. if (typeof fieldVal == \'object\') {
  1682. if (typeof fieldVal.join == \'function\') {
  1683. fieldVal = fieldVal.join(\'|\');
  1684. } else {
  1685. fieldVal = JSON.stringify(fieldVal);
  1686. }
  1687. }
  1688. newVals[this.name] = fieldVal;
  1689. }
  1690. });
  1691. if (errorFields.length) {
  1692. parent.notify(\'Fields have errors: \'+errorFields.join(\', \')+\'!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1693. } else if (hasVals) {
  1694. console.log(newVals);
  1695. ajax_request(\'POST\', \''.(isset($array['submitAction'])?$array['submitAction']:'update-config').'\', newVals, function(data, code) {
  1696. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').removeAttr(\'data-changed\');
  1697. });
  1698. '.$extraClick.'
  1699. } else {
  1700. parent.notify(\'Nothing to update!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1701. }
  1702. return false;
  1703. });
  1704. '.(isset($array['onready'])?$array['onready']:'').'
  1705. });
  1706. </script>
  1707. ';
  1708. }
  1709. // Build Settings Fields
  1710. function buildField($params, $sizeSm = 12, $sizeMd = 12, $sizeLg = 12) {
  1711. /*
  1712. array(
  1713. 'type' => '',
  1714. 'placeholder' => '',
  1715. 'label' => '',
  1716. 'labelTranslate' => '',
  1717. 'assist' => '',
  1718. 'name' => '',
  1719. 'pattern' => '',
  1720. 'options' => array( // For SELECT only
  1721. 'Display' => 'value',
  1722. ),
  1723. )
  1724. */
  1725. // Tags
  1726. $tags = array();
  1727. foreach(array('placeholder','style','disabled','readonly','pattern','min','max','required','onkeypress','onchange','onfocus','onleave','href','onclick') as $value) {
  1728. if (isset($params[$value])) {
  1729. if (is_string($params[$value])) { $tags[] = $value.'="'.$params[$value].'"';
  1730. } else if ($params[$value] === true) { $tags[] = $value; }
  1731. }
  1732. }
  1733. $format = (isset($params['format']) && in_array($params['format'],array(false,'colour','color'))?$params['format']:false);
  1734. $name = (isset($params['name'])?$params['name']:(isset($params['id'])?$params['id']:''));
  1735. $id = (isset($params['id'])?$params['id']:(isset($params['name'])?$params['name'].'_id':randString(32)));
  1736. $val = (isset($params['value'])?$params['value']:'');
  1737. $class = (isset($params['class'])?' '.$params['class']:'');
  1738. $wrapClass = (isset($params['wrapClass'])?$params['wrapClass']:'form-content');
  1739. $assist = (isset($params['assist'])?' - i.e. '.$params['assist']:'');
  1740. $label = (isset($params['labelTranslate'])?translate($params['labelTranslate']):(isset($params['label'])?$params['label']:''));
  1741. $labelOut = '<p class="help-text">'.$label.$assist.'</p>';
  1742. // Field Design
  1743. switch ($params['type']) {
  1744. case 'text':
  1745. case 'number':
  1746. case 'password':
  1747. $field = '<input id="'.$id.'" name="'.$name.'" type="'.$params['type'].'" class="form-control material input-sm'.$class.'" '.implode(' ',$tags).' autocorrect="off" autocapitalize="off" value="'.$val.'">';
  1748. break;
  1749. case 'select':
  1750. case 'dropdown':
  1751. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control material input-sm" '.implode(' ',$tags).'>'.resolveSelectOptions($params['options'], $val).'</select>';
  1752. break;
  1753. case 'select-multi':
  1754. case 'dropdown-multi':
  1755. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control input-sm" '.implode(' ',$tags).' multiple="multiple">'.resolveSelectOptions($params['options'], $val, true).'</select>';
  1756. break;
  1757. case 'check':
  1758. case 'checkbox':
  1759. case 'toggle':
  1760. $checked = ((is_bool($val) && $val) || trim($val) === 'true'?' checked':'');
  1761. $colour = (isset($params['colour'])?$params['colour']:'success');
  1762. $labelOut = '<label for="'.$id.'"></label>'.$label;
  1763. $field = '<input id="'.$id.'" name="'.$name.'" type="checkbox" class="switcher switcher-'.$colour.' '.$class.'" '.implode(' ',$tags).' data-value="'.$val.'"'.$checked.'>';
  1764. break;
  1765. case 'radio':
  1766. $labelOut = '';
  1767. $checked = ((is_bool($val) && $val) || ($val && trim($val) !== 'false')?' checked':'');
  1768. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1769. $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>';
  1770. break;
  1771. case 'date':
  1772. $field = 'Unsupported, planned.';
  1773. break;
  1774. case 'hidden':
  1775. return '<input id="'.$id.'" name="'.$name.'" type="hidden" class="'.$class.'" '.implode(' ',$tags).' value="'.$val.'">';
  1776. break;
  1777. case 'header':
  1778. $labelOut = '';
  1779. $headType = (isset($params['value'])?$params['value']:3);
  1780. $field = '<h'.$headType.' class="'.$class.'" '.implode(' ',$tags).'>'.$label.'</h'.$headType.'>';
  1781. break;
  1782. case 'button':
  1783. $labelOut = '';
  1784. $icon = (isset($params['icon'])?$params['icon']:'flask');
  1785. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1786. $bDropdown = (isset($params['buttonDrop'])?$params['buttonDrop']:'');
  1787. $field = ($bDropdown?'<div class="btn-group">':'').'<button id="'.$id.'" type="button" class="btn waves btn-labeled btn-'.$bType.' btn-sm text-uppercase waves-effect waves-float'.$class.''.($bDropdown?' dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"':'"').' '.implode(' ',$tags).'><span class="btn-label"><i class="fa fa-'.$icon.'"></i></span><span class="btn-text">'.$label.'</span></button>'.($bDropdown?$bDropdown.'</div>':'');
  1788. break;
  1789. case 'textarea':
  1790. $rows = (isset($params['rows'])?$params['rows']:5);
  1791. $field = '<textarea id="'.$id.'" name="'.$name.'" class="form-control'.$class.'" rows="'.$rows.'" '.implode(' ',$tags).'>'.$val.'</textarea>';
  1792. break;
  1793. case 'custom':
  1794. // Settings
  1795. $settings = array(
  1796. '$id' => $id,
  1797. '$name' => $name,
  1798. '$val' => $val,
  1799. '$label' => $label,
  1800. '$labelOut' => $labelOut,
  1801. );
  1802. // Get HTML
  1803. $html = (isset($params['html'])?$params['html']:'Nothing Specified!');
  1804. // If LabelOut is in html dont print it twice
  1805. $labelOut = (strpos($html,'$label')!==false?'':$labelOut);
  1806. // Replace variables in settings
  1807. $html = preg_replace_callback('/\$\w+\b/', function ($match) use ($settings) { return (isset($settings[$match[0]])?$settings[$match[0]]:'{'.$match[0].' is undefined}'); }, $html);
  1808. // Build Field
  1809. $field = '<div id="'.$id.'_html" class="custom-field">'.$html.'</div>';
  1810. break;
  1811. case 'space':
  1812. $labelOut = '';
  1813. $field = str_repeat('<br>', (isset($params['value'])?$params['value']:1));
  1814. break;
  1815. default:
  1816. $field = 'Unsupported field type';
  1817. break;
  1818. }
  1819. // Field Formats
  1820. switch ($format) {
  1821. case 'colour': // Fuckin Eh, Canada!
  1822. case 'color':
  1823. $labelBef = '<center>'.$label.'</center>';
  1824. $wrapClass = 'gray-bg colour-field';
  1825. $labelAft = '';
  1826. $field = str_replace(' material input-sm','',$field);
  1827. break;
  1828. default:
  1829. $labelBef = '';
  1830. $labelAft = $labelOut;
  1831. }
  1832. return '<div class="'.$wrapClass.' col-sm-'.$sizeSm.' col-md-'.$sizeMd.' col-lg-'.$sizeLg.'">'.$labelBef.$field.$labelAft.'</div>';
  1833. }
  1834. // Tab Settings Generation
  1835. function printTabRow($data) {
  1836. $hidden = false;
  1837. if ($data===false) {
  1838. $hidden = true;
  1839. $data = array( // New Tab Defaults
  1840. 'id' => 'new',
  1841. 'name' => '',
  1842. 'url' => '',
  1843. 'icon' => 'fa-diamond',
  1844. 'iconurl' => '',
  1845. 'active' => 'true',
  1846. 'user' => 'true',
  1847. 'guest' => 'true',
  1848. 'window' => 'false',
  1849. 'splash' => 'true',
  1850. 'ping' => 'false',
  1851. 'ping_url' => '',
  1852. 'defaultz' => '',
  1853. );
  1854. }
  1855. $image = '<span style="font: normal normal normal 30px/1 FontAwesome;" class="fa fa-hand-paper-o"></span>';
  1856. $output = '
  1857. <li id="tab-'.$data['id'].'" class="list-group-item" style="position: relative; left: 0px; top: 0px; '.($hidden?' display: none;':'').'">
  1858. <tab class="content-form form-inline">
  1859. <div class="row">
  1860. '.buildField(array(
  1861. 'type' => 'custom',
  1862. '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>',
  1863. ),12,1,1).'
  1864. '.buildField(array(
  1865. 'type' => 'hidden',
  1866. 'id' => 'tab-'.$data['id'].'-id',
  1867. 'name' => 'id['.$data['id'].']',
  1868. 'value' => $data['id'],
  1869. ),12,2,1).'
  1870. '.buildField(array(
  1871. 'type' => 'text',
  1872. 'id' => 'tab-'.$data['id'].'-name',
  1873. 'name' => 'name['.$data['id'].']',
  1874. 'required' => true,
  1875. 'placeholder' => 'Organizr Homepage',
  1876. 'labelTranslate' => 'TAB_NAME',
  1877. 'value' => $data['name'],
  1878. 'class' => 'darkBold',
  1879. ),12,2,1).'
  1880. '.buildField(array(
  1881. 'type' => 'text',
  1882. 'id' => 'tab-'.$data['id'].'-url',
  1883. 'name' => 'url['.$data['id'].']',
  1884. 'required' => true,
  1885. 'placeholder' => 'homepage.php',
  1886. 'labelTranslate' => 'TAB_URL',
  1887. 'value' => $data['url'],
  1888. 'class' => 'darkBold',
  1889. ),12,2,2).'
  1890. '.buildField(array(
  1891. 'type' => 'text',
  1892. 'id' => 'tab-'.$data['id'].'-iconurl',
  1893. 'name' => 'iconurl['.$data['id'].']',
  1894. 'placeholder' => 'images/organizr.png',
  1895. 'labelTranslate' => 'ICON_URL',
  1896. 'value' => $data['iconurl'],
  1897. 'class' => 'darkBold',
  1898. ),12,2,1).'
  1899. '.buildField(array(
  1900. 'type' => 'text',
  1901. 'id' => 'tab-'.$data['id'].'-icon',
  1902. 'name' => 'icon['.$data['id'].']',
  1903. 'placeholder' => 'fa-icon',
  1904. 'labelTranslate' => 'OR_ICON_NAME',
  1905. 'value' => $data['icon'],
  1906. 'class' => 'iconpickeradd darkBold',
  1907. ),12,1,1).'
  1908. '.buildField(array(
  1909. 'type' => 'text',
  1910. 'id' => 'tab-'.$data['id'].'-ping_url',
  1911. 'name' => 'ping_url['.$data['id'].']',
  1912. 'placeholder' => 'host:port',
  1913. 'labelTranslate' => 'PING_URL',
  1914. 'value' => $data['ping_url'],
  1915. 'class' => 'darkBold',
  1916. ),12,2,1).'
  1917. '.buildField(array(
  1918. 'type' => 'radio',
  1919. 'labelTranslate' => 'DEFAULT',
  1920. 'name' => 'defaultz['.$data['id'].']',
  1921. 'value' => $data['defaultz'],
  1922. 'onclick' => "$('[type=radio][id!=\''+this.id+'\']').each(function() { this.checked=false; });",
  1923. ),12,1,1).'
  1924. '.buildField(array(
  1925. 'type' => 'button',
  1926. 'icon' => 'chevron-down',
  1927. 'buttonType' => 'success',
  1928. 'labelTranslate' => 'MORE',
  1929. 'onclick' => "$(this).parent().parent().parent().find('.slideInUp').toggle()",
  1930. 'class' => 'toggleTabExtra',
  1931. ),12,1,1).'
  1932. '.buildField(array(
  1933. 'type' => 'button',
  1934. 'icon' => 'trash',
  1935. 'buttonType' => 'danger',
  1936. 'labelTranslate' => 'REMOVE',
  1937. 'onclick' => "$(this).parents('li').remove();",
  1938. ),12,1,1).'</div><div id = "tab-'.$data['id'].'-row" class = "row animated slideInUp" style = "display:none;" ><div></div>
  1939. '.buildField(array(
  1940. 'type' => 'checkbox',
  1941. 'labelTranslate' => 'ACTIVE',
  1942. 'name' => 'active['.$data['id'].']',
  1943. 'value' => $data['active'],
  1944. ),12,1,1).'
  1945. '.buildField(array(
  1946. 'type' => 'checkbox',
  1947. 'labelTranslate' => 'USER',
  1948. 'colour' => 'primary',
  1949. 'name' => 'user['.$data['id'].']',
  1950. 'value' => $data['user'],
  1951. ),12,1,1).'
  1952. '.buildField(array(
  1953. 'type' => 'checkbox',
  1954. 'labelTranslate' => 'GUEST',
  1955. 'colour' => 'warning',
  1956. 'name' => 'guest['.$data['id'].']',
  1957. 'value' => $data['guest'],
  1958. ),12,1,1).'
  1959. '.buildField(array(
  1960. 'type' => 'checkbox',
  1961. 'labelTranslate' => 'NO_IFRAME',
  1962. 'colour' => 'danger',
  1963. 'name' => 'window['.$data['id'].']',
  1964. 'value' => $data['window'],
  1965. ),12,1,1).'
  1966. '.buildField(array(
  1967. 'type' => 'checkbox',
  1968. 'labelTranslate' => 'SPLASH',
  1969. 'colour' => 'success',
  1970. 'name' => 'splash['.$data['id'].']',
  1971. 'value' => $data['splash'],
  1972. ),12,1,1).'
  1973. '.buildField(array(
  1974. 'type' => 'checkbox',
  1975. 'labelTranslate' => 'PING',
  1976. 'colour' => 'success',
  1977. 'name' => 'ping['.$data['id'].']',
  1978. 'value' => $data['ping'],
  1979. ),12,1,1).'
  1980. </div>
  1981. </tab>
  1982. </li>
  1983. ';
  1984. return $output;
  1985. }
  1986. // Timezone array
  1987. function timezoneOptions() {
  1988. $output = array();
  1989. $timezones = array();
  1990. $regions = array(
  1991. 'Africa' => DateTimeZone::AFRICA,
  1992. 'America' => DateTimeZone::AMERICA,
  1993. 'Antarctica' => DateTimeZone::ANTARCTICA,
  1994. 'Arctic' => DateTimeZone::ARCTIC,
  1995. 'Asia' => DateTimeZone::ASIA,
  1996. 'Atlantic' => DateTimeZone::ATLANTIC,
  1997. 'Australia' => DateTimeZone::AUSTRALIA,
  1998. 'Europe' => DateTimeZone::EUROPE,
  1999. 'Indian' => DateTimeZone::INDIAN,
  2000. 'Pacific' => DateTimeZone::PACIFIC
  2001. );
  2002. foreach ($regions as $name => $mask) {
  2003. $zones = DateTimeZone::listIdentifiers($mask);
  2004. foreach($zones as $timezone) {
  2005. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2006. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2007. $output[$name]['optgroup'][substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm]['value'] = $timezone;
  2008. }
  2009. }
  2010. return $output;
  2011. }
  2012. // Build Database
  2013. function createSQLiteDB($path = false) {
  2014. if ($path === false) {
  2015. if (DATABASE_LOCATION){
  2016. $path = DATABASE_LOCATION;
  2017. } else {
  2018. debug_out('No Path Specified!');
  2019. }
  2020. }
  2021. if (!is_file($path.'users.db') || filesize($path.'users.db') <= 0) {
  2022. if (!isset($GLOBALS['file_db'])) {
  2023. $GLOBALS['file_db'] = new PDO('sqlite:'.$path.'users.db');
  2024. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2025. }
  2026. // Create Users
  2027. $users = $GLOBALS['file_db']->query('CREATE TABLE `users` (
  2028. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2029. `username` TEXT UNIQUE,
  2030. `password` TEXT,
  2031. `email` TEXT,
  2032. `token` TEXT,
  2033. `role` TEXT,
  2034. `active` TEXT,
  2035. `last` TEXT,
  2036. `auth_service` TEXT DEFAULT \'internal\'
  2037. );');
  2038. // Create Tabs
  2039. $tabs = $GLOBALS['file_db']->query('CREATE TABLE `tabs` (
  2040. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2041. `order` INTEGER,
  2042. `users_id` INTEGER,
  2043. `name` TEXT,
  2044. `url` TEXT,
  2045. `defaultz` TEXT,
  2046. `active` TEXT,
  2047. `user` TEXT,
  2048. `guest` TEXT,
  2049. `icon` TEXT,
  2050. `iconurl` TEXT,
  2051. `window` TEXT,
  2052. `splash` TEXT,
  2053. `ping` TEXT,
  2054. `ping_url` TEXT
  2055. );');
  2056. // Create Options
  2057. $options = $GLOBALS['file_db']->query('CREATE TABLE `options` (
  2058. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2059. `users_id` INTEGER UNIQUE,
  2060. `title` TEXT UNIQUE,
  2061. `topbar` TEXT,
  2062. `bottombar` TEXT,
  2063. `sidebar` TEXT,
  2064. `hoverbg` TEXT,
  2065. `topbartext` TEXT,
  2066. `activetabBG` TEXT,
  2067. `activetabicon` TEXT,
  2068. `activetabtext` TEXT,
  2069. `inactiveicon` TEXT,
  2070. `inactivetext` TEXT,
  2071. `loading` TEXT,
  2072. `hovertext` TEXT
  2073. );');
  2074. // Create Invites
  2075. $invites = $GLOBALS['file_db']->query('CREATE TABLE `invites` (
  2076. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2077. `code` TEXT UNIQUE,
  2078. `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  2079. `email` TEXT,
  2080. `username` TEXT,
  2081. `dateused` TIMESTAMP,
  2082. `usedby` TEXT,
  2083. `ip` TEXT,
  2084. `valid` TEXT
  2085. );');
  2086. writeLog("success", "database created/saved");
  2087. return $users && $tabs && $options && $invites;
  2088. } else {
  2089. writeLog("error", "database was unable to be created/saved");
  2090. return false;
  2091. }
  2092. }
  2093. // Upgrade Database
  2094. function updateSQLiteDB($db_path = false, $oldVerNum = false) {
  2095. if (!$db_path) {
  2096. if (defined('DATABASE_LOCATION')) {
  2097. $db_path = DATABASE_LOCATION;
  2098. } else {
  2099. debug_out('No Path Specified',1);
  2100. }
  2101. }
  2102. if (!isset($GLOBALS['file_db'])) {
  2103. $GLOBALS['file_db'] = new PDO('sqlite:'.$db_path.'users.db');
  2104. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2105. }
  2106. // Cache current DB
  2107. $cache = array();
  2108. foreach($GLOBALS['file_db']->query('SELECT name FROM sqlite_master WHERE type="table";') as $table) {
  2109. foreach($GLOBALS['file_db']->query('SELECT * FROM '.$table['name'].';') as $key => $row) {
  2110. foreach($row as $k => $v) {
  2111. if (is_string($k)) {
  2112. $cache[$table['name']][$key][$k] = $v;
  2113. }
  2114. }
  2115. }
  2116. }
  2117. // Remove Current Database
  2118. $GLOBALS['file_db'] = null;
  2119. $pathDigest = pathinfo($db_path.'users.db');
  2120. if (file_exists($db_path.'users.db')) {
  2121. rename($db_path.'users.db', $pathDigest['dirname'].'/'.$pathDigest['filename'].'['.date('Y-m-d_H-i-s').']'.($oldVerNum?'['.$oldVerNum.']':'').'.bak.db');
  2122. }
  2123. // Create New Database
  2124. $success = createSQLiteDB($db_path);
  2125. // Restore Items
  2126. if ($success) {
  2127. foreach($cache as $table => $tableData) {
  2128. if ($tableData) {
  2129. $queryBase = 'INSERT INTO '.$table.' (`'.implode('`,`',array_keys(current($tableData))).'`) values ';
  2130. $insertValues = array();
  2131. reset($tableData);
  2132. foreach($tableData as $key => $value) {
  2133. $insertValues[] = '('.implode(',',array_map(function($d) {
  2134. return (isset($d)?$GLOBALS['file_db']->quote($d):'null');
  2135. }, $value)).')';
  2136. }
  2137. $GLOBALS['file_db']->query($queryBase.implode(',',$insertValues).';');
  2138. }
  2139. }
  2140. writeLog("success", "database values have been updated");
  2141. return true;
  2142. } else {
  2143. writeLog("error", "database values unable to be updated");
  2144. return false;
  2145. }
  2146. }
  2147. // Commit colours to database
  2148. function updateDBOptions($values) {
  2149. if (!isset($GLOBALS['file_db'])) {
  2150. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2151. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2152. }
  2153. // Commit new values to database
  2154. if ($GLOBALS['file_db']->query('UPDATE options SET '.implode(',',array_map(function($d, $k) {
  2155. return '`'.$k.'` = '.(isset($d)?"'".addslashes($d)."'":'null');
  2156. }, $values, array_keys($values))).';')->rowCount()) {
  2157. return true;
  2158. } else if ($GLOBALS['file_db']->query('INSERT OR IGNORE INTO options (`'.implode('`,`',array_keys($values)).'`) VALUES (\''.implode("','",$values).'\');')->rowCount()) {
  2159. writeLog("success", "database values for options table have been updated");
  2160. return true;
  2161. } else {
  2162. writeLog("error", "database values for options table unable to be updated");
  2163. return false;
  2164. }
  2165. }
  2166. // Send AJAX notification
  2167. function sendNotification($success, $message = false, $send = true) {
  2168. $notifyExplode = explode("-", NOTIFYEFFECT);
  2169. if ($success) {
  2170. $msg = array(
  2171. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_SAVED").'</strong>'),
  2172. 'icon' => 'floppy-o',
  2173. 'type' => 'success',
  2174. 'length' => '5000',
  2175. 'layout' => $notifyExplode[0],
  2176. 'effect' => $notifyExplode[1],
  2177. );
  2178. } else {
  2179. $msg = array(
  2180. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_NOT_SAVED").'</strong>'),
  2181. 'icon' => 'floppy-o',
  2182. 'type' => 'failed',
  2183. 'length' => '5000',
  2184. 'layout' => $notifyExplode[0],
  2185. 'effect' => $notifyExplode[1],
  2186. );
  2187. }
  2188. // Send and kill script?
  2189. if ($send) {
  2190. header('Content-Type: application/json');
  2191. echo json_encode(array('notify'=>$msg));
  2192. die();
  2193. }
  2194. return $msg;
  2195. }
  2196. // Load colours from the database
  2197. function loadAppearance() {
  2198. // Defaults
  2199. $defaults = array(
  2200. 'title' => 'Organizr',
  2201. 'topbartext' => '#66D9EF',
  2202. 'topbar' => '#333333',
  2203. 'bottombar' => '#333333',
  2204. 'sidebar' => '#393939',
  2205. 'hoverbg' => '#AD80FD',
  2206. 'activetabBG' => '#F92671',
  2207. 'activetabicon' => '#FFFFFF',
  2208. 'activetabtext' => '#FFFFFF',
  2209. 'inactiveicon' => '#66D9EF',
  2210. 'inactivetext' => '#66D9EF',
  2211. 'loading' => '#66D9EF',
  2212. 'hovertext' => '#000000',
  2213. );
  2214. if (DATABASE_LOCATION) {
  2215. if(is_file(DATABASE_LOCATION.'users.db') && filesize(DATABASE_LOCATION.'users.db') > 0){
  2216. if (!isset($GLOBALS['file_db'])) {
  2217. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2218. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2219. }
  2220. // Database Lookup
  2221. $options = $GLOBALS['file_db']->query('SELECT * FROM options');
  2222. // Replace defaults with filled options
  2223. foreach($options as $row) {
  2224. foreach($defaults as $key => $value) {
  2225. if (isset($row[$key]) && $row[$key]) {
  2226. $defaults[$key] = $row[$key];
  2227. }
  2228. }
  2229. }
  2230. }
  2231. }
  2232. // Return the Results
  2233. return $defaults;
  2234. }
  2235. // Delete Database
  2236. function deleteDatabase() {
  2237. unset($_COOKIE['Organizr']);
  2238. setcookie('Organizr', '', time() - 3600, '/');
  2239. unset($_COOKIE['OrganizrU']);
  2240. setcookie('OrganizrU', '', time() - 3600, '/');
  2241. $GLOBALS['file_db'] = null;
  2242. unlink(DATABASE_LOCATION.'users.db');
  2243. foreach(glob(substr_replace($userdirpath, "", -1).'/*') as $file) {
  2244. if(is_dir($file)) {
  2245. rmdir($file);
  2246. } elseif (!is_dir($file)) {
  2247. unlink($file);
  2248. }
  2249. }
  2250. rmdir($userdirpath);
  2251. writeLog("success", "database has been deleted");
  2252. return true;
  2253. }
  2254. // Upgrade the installation
  2255. function upgradeInstall($branch = 'master') {
  2256. function downloadFile($url, $path){
  2257. ini_set('max_execution_time',0);
  2258. $folderPath = "upgrade/";
  2259. if(!mkdir($folderPath)){
  2260. writeLog("error", "organizr could not create upgrade folder");
  2261. }
  2262. $newfname = $folderPath . $path;
  2263. $file = fopen ($url, 'rb');
  2264. if ($file) {
  2265. $newf = fopen ($newfname, 'wb');
  2266. if ($newf) {
  2267. while(!feof($file)) {
  2268. fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
  2269. }
  2270. }
  2271. }else{
  2272. writeLog("error", "organizr could not download $url");
  2273. }
  2274. if ($file) {
  2275. fclose($file);
  2276. writeLog("success", "organizr finished downloading the github zip file");
  2277. }else{
  2278. writeLog("error", "organizr could not download the github zip file");
  2279. }
  2280. if ($newf) {
  2281. fclose($newf);
  2282. writeLog("success", "organizr created upgrade zip file from github zip file");
  2283. }else{
  2284. writeLog("error", "organizr could not create upgrade zip file from github zip file");
  2285. }
  2286. }
  2287. function unzipFile($zipFile){
  2288. $zip = new ZipArchive;
  2289. $extractPath = "upgrade/";
  2290. if($zip->open($extractPath . $zipFile) != "true"){
  2291. writeLog("error", "organizr could not unzip upgrade.zip");
  2292. }else{
  2293. writeLog("success", "organizr unzipped upgrade.zip");
  2294. }
  2295. /* Extract Zip File */
  2296. $zip->extractTo($extractPath);
  2297. $zip->close();
  2298. }
  2299. // Function to remove folders and files
  2300. function rrmdir($dir) {
  2301. if (is_dir($dir)) {
  2302. $files = scandir($dir);
  2303. foreach ($files as $file)
  2304. if ($file != "." && $file != "..") rrmdir("$dir/$file");
  2305. rmdir($dir);
  2306. }
  2307. else if (file_exists($dir)) unlink($dir);
  2308. }
  2309. // Function to Copy folders and files
  2310. function rcopy($src, $dst) {
  2311. if (is_dir ( $src )) {
  2312. if (!file_exists($dst)) : mkdir ( $dst ); endif;
  2313. $files = scandir ( $src );
  2314. foreach ( $files as $file )
  2315. if ($file != "." && $file != "..")
  2316. rcopy ( "$src/$file", "$dst/$file" );
  2317. } else if (file_exists ( $src ))
  2318. copy ( $src, $dst );
  2319. }
  2320. $url = 'https://github.com/causefx/Organizr/archive/'.$branch.'.zip';
  2321. $file = "upgrade.zip";
  2322. $source = __DIR__ . '/upgrade/Organizr-'.$branch.'/';
  2323. $cleanup = __DIR__ . "/upgrade/";
  2324. $destination = __DIR__ . "/";
  2325. writeLog("success", "starting organizr upgrade process");
  2326. downloadFile($url, $file);
  2327. unzipFile($file);
  2328. rcopy($source, $destination);
  2329. writeLog("success", "new organizr files copied");
  2330. rrmdir($cleanup);
  2331. writeLog("success", "organizr upgrade folder removed");
  2332. writeLog("success", "organizr has been updated");
  2333. return true;
  2334. }
  2335. // NzbGET Items
  2336. function nzbgetConnect($list = 'listgroups') {
  2337. $url = qualifyURL(NZBGETURL);
  2338. $api = curl_get($url.'/'.NZBGETUSERNAME.':'.NZBGETPASSWORD.'/jsonrpc/'.$list);
  2339. $api = json_decode($api, true);
  2340. $gotNZB = array();
  2341. if (is_array($api) || is_object($api)){
  2342. foreach ($api['result'] AS $child) {
  2343. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  2344. $downloadStatus = $child['Status'];
  2345. $downloadCategory = $child['Category'];
  2346. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  2347. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  2348. if($child['Health'] <= "750"){
  2349. $downloadHealth = "danger";
  2350. }elseif($child['Health'] <= "900"){
  2351. $downloadHealth = "warning";
  2352. }elseif($child['Health'] <= "1000"){
  2353. $downloadHealth = "success";
  2354. }
  2355. $gotNZB[] = '<tr>
  2356. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2357. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2358. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2359. <td class="col-xs-1 nzbtable nzbtable-row">'.realSize(($child['FileSizeMB']*1024)*1024).'</td>
  2360. <td class="col-xs-2 nzbtable nzbtable-row">
  2361. <div class="progress">
  2362. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2363. <p class="text-center">'.round($downloadPercent).'%</p>
  2364. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2365. </div>
  2366. </div>
  2367. </td>
  2368. </tr>';
  2369. }
  2370. if ($gotNZB) {
  2371. return implode('',$gotNZB);
  2372. } else {
  2373. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2374. }
  2375. }else{
  2376. writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Username and Password - if HTTPS, is cert valid");
  2377. }
  2378. }
  2379. // Sabnzbd Items
  2380. function sabnzbdConnect($list = 'queue') {
  2381. $url = qualifyURL(SABNZBDURL);
  2382. $api = file_get_contents($url.'/api?mode='.$list.'&output=json&apikey='.SABNZBDKEY);
  2383. $api = json_decode($api, true);
  2384. $gotNZB = array();
  2385. foreach ($api[$list]['slots'] AS $child) {
  2386. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  2387. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  2388. $downloadStatus = $child['status'];
  2389. $gotNZB[] = '<tr>
  2390. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2391. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2392. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2393. <td class="col-xs-1 nzbtable nzbtable-row">'.$child['size'].'</td>
  2394. <td class="col-xs-2 nzbtable nzbtable-row">
  2395. <div class="progress">
  2396. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2397. <p class="text-center">'.round($downloadPercent).'%</p>
  2398. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2399. </div>
  2400. </div>
  2401. </td>
  2402. </tr>';
  2403. }
  2404. if ($gotNZB) {
  2405. return implode('',$gotNZB);
  2406. } else {
  2407. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2408. }
  2409. }
  2410. // Apply new tab settings
  2411. function updateTabs($tabs) {
  2412. if (!isset($GLOBALS['file_db'])) {
  2413. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2414. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2415. }
  2416. // Validate
  2417. if (!isset($tabs['defaultz'])) { $tabs['defaultz'][current(array_keys($tabs['name']))] = 'true'; }
  2418. if (isset($tabs['name']) && isset($tabs['url']) && is_array($tabs['name'])) {
  2419. // Clear Existing Tabs
  2420. $GLOBALS['file_db']->query("DELETE FROM tabs");
  2421. // Process New Tabs
  2422. $totalValid = 0;
  2423. foreach ($tabs['name'] as $key => $value) {
  2424. // Qualify
  2425. if (!$value || !isset($tabs['url']) || !$tabs['url'][$key]) { continue; }
  2426. $totalValid++;
  2427. $fields = array();
  2428. foreach(array('id','name','url','icon','iconurl','order','ping_url') as $v) {
  2429. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = $tabs[$v][$key]; }
  2430. }
  2431. foreach(array('active','user','guest','defaultz','window','splash','ping') as $v) {
  2432. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = ($tabs[$v][$key]!=='false'?'true':'false'); }
  2433. }
  2434. $GLOBALS['file_db']->query('INSERT INTO tabs (`'.implode('`,`',array_keys($fields)).'`) VALUES (\''.implode("','",$fields).'\');');
  2435. }
  2436. writeLog("success", "tabs successfully saved");
  2437. return $totalValid;
  2438. } else {
  2439. writeLog("error", "tabs could not save");
  2440. return false;
  2441. }
  2442. writeLog("error", "tabs could not save");
  2443. return false;
  2444. }
  2445. // ==============
  2446. function clean($strin) {
  2447. $strout = null;
  2448. for ($i = 0; $i < strlen($strin); $i++) {
  2449. $ord = ord($strin[$i]);
  2450. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  2451. $strout .= "&amp;#{$ord};";
  2452. }
  2453. else {
  2454. switch ($strin[$i]) {
  2455. case '<':
  2456. $strout .= '&lt;';
  2457. break;
  2458. case '>':
  2459. $strout .= '&gt;';
  2460. break;
  2461. case '&':
  2462. $strout .= '&amp;';
  2463. break;
  2464. case '"':
  2465. $strout .= '&quot;';
  2466. break;
  2467. default:
  2468. $strout .= $strin[$i];
  2469. }
  2470. }
  2471. }
  2472. return $strout;
  2473. }
  2474. function registration_callback($username, $email, $userdir){
  2475. global $data;
  2476. $data = array($username, $email, $userdir);
  2477. }
  2478. function printArray($arrayName){
  2479. $messageCount = count($arrayName);
  2480. $i = 0;
  2481. foreach ( $arrayName as $item ) :
  2482. $i++;
  2483. if($i < $messageCount) :
  2484. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  2485. elseif($i = $messageCount) :
  2486. echo "<small class='text-uppercase'>" . $item . "</small>";
  2487. endif;
  2488. endforeach;
  2489. }
  2490. function write_ini_file($content, $path) {
  2491. if (!$handle = fopen($path, 'w')) {
  2492. return false;
  2493. }
  2494. $success = fwrite($handle, trim($content));
  2495. fclose($handle);
  2496. return $success;
  2497. }
  2498. function gotTimezone(){
  2499. $regions = array(
  2500. 'Africa' => DateTimeZone::AFRICA,
  2501. 'America' => DateTimeZone::AMERICA,
  2502. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2503. 'Arctic' => DateTimeZone::ARCTIC,
  2504. 'Asia' => DateTimeZone::ASIA,
  2505. 'Atlantic' => DateTimeZone::ATLANTIC,
  2506. 'Australia' => DateTimeZone::AUSTRALIA,
  2507. 'Europe' => DateTimeZone::EUROPE,
  2508. 'Indian' => DateTimeZone::INDIAN,
  2509. 'Pacific' => DateTimeZone::PACIFIC
  2510. );
  2511. $timezones = array();
  2512. foreach ($regions as $name => $mask) {
  2513. $zones = DateTimeZone::listIdentifiers($mask);
  2514. foreach($zones as $timezone) {
  2515. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2516. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2517. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2518. }
  2519. }
  2520. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  2521. foreach($timezones as $region => $list) {
  2522. print '<optgroup label="' . $region . '">' . "\n";
  2523. foreach($list as $timezone => $name) {
  2524. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  2525. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  2526. }
  2527. print '</optgroup>' . "\n";
  2528. }
  2529. print '</select>';
  2530. }
  2531. function getTimezone(){
  2532. $regions = array(
  2533. 'Africa' => DateTimeZone::AFRICA,
  2534. 'America' => DateTimeZone::AMERICA,
  2535. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2536. 'Arctic' => DateTimeZone::ARCTIC,
  2537. 'Asia' => DateTimeZone::ASIA,
  2538. 'Atlantic' => DateTimeZone::ATLANTIC,
  2539. 'Australia' => DateTimeZone::AUSTRALIA,
  2540. 'Europe' => DateTimeZone::EUROPE,
  2541. 'Indian' => DateTimeZone::INDIAN,
  2542. 'Pacific' => DateTimeZone::PACIFIC
  2543. );
  2544. $timezones = array();
  2545. foreach ($regions as $name => $mask) {
  2546. $zones = DateTimeZone::listIdentifiers($mask);
  2547. foreach($zones as $timezone) {
  2548. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2549. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2550. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2551. }
  2552. }
  2553. print '<select name="timezone" id="timezone" class="form-control material" required>';
  2554. foreach($timezones as $region => $list) {
  2555. print '<optgroup label="' . $region . '">' . "\n";
  2556. foreach($list as $timezone => $name) {
  2557. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  2558. }
  2559. print '</optgroup>' . "\n";
  2560. }
  2561. print '</select>';
  2562. }
  2563. function explosion($string, $position){
  2564. $getWord = explode("|", $string);
  2565. return $getWord[$position];
  2566. }
  2567. function getServerPath() {
  2568. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  2569. $protocol = "https://";
  2570. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  2571. $protocol = "https://";
  2572. } else {
  2573. $protocol = "http://";
  2574. }
  2575. $domain = '';
  2576. if (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], '.') !== false){
  2577. $domain = $_SERVER['SERVER_NAME'];
  2578. }elseif(isset($_SERVER['HTTP_HOST'])){
  2579. if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
  2580. $domain = explode(':', $_SERVER['HTTP_HOST'])[0];
  2581. $port = explode(':', $_SERVER['HTTP_HOST'])[1];
  2582. if ($port == "80" || $port == "443"){
  2583. $domain = $domain;
  2584. }else{
  2585. $domain = $_SERVER['HTTP_HOST'];
  2586. }
  2587. }else{
  2588. $domain = $_SERVER['HTTP_HOST'];
  2589. }
  2590. }
  2591. return $protocol . $domain . str_replace("\\", "/", dirname($_SERVER['REQUEST_URI']));
  2592. }
  2593. function get_browser_name() {
  2594. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  2595. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  2596. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  2597. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  2598. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  2599. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  2600. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  2601. return 'Other';
  2602. }
  2603. function getSickrageCalendarWanted($array){
  2604. $array = json_decode($array, true);
  2605. //$gotCalendar = "";
  2606. $gotCalendar = array();
  2607. $i = 0;
  2608. foreach($array['data']['missed'] AS $child) {
  2609. $i++;
  2610. $seriesName = $child['show_name'];
  2611. $episodeID = $child['tvdbid'];
  2612. $episodeAirDate = $child['airdate'];
  2613. $episodeAirDateTime = explode(" ",$child['airs']);
  2614. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2615. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2616. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2617. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2618. $downloaded = "0";
  2619. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2620. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2621. array_push($gotCalendar, array(
  2622. "id" => "Sick-Miss-".$i,
  2623. "title" => $seriesName,
  2624. "start" => $episodeAirDate,
  2625. "className" => $downloaded." tvID--".$episodeID,
  2626. "imagetype" => "tv",
  2627. ));
  2628. }
  2629. foreach($array['data']['today'] AS $child) {
  2630. $i++;
  2631. $seriesName = $child['show_name'];
  2632. $episodeID = $child['tvdbid'];
  2633. $episodeAirDate = $child['airdate'];
  2634. $episodeAirDateTime = explode(" ",$child['airs']);
  2635. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2636. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2637. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2638. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2639. $downloaded = "0";
  2640. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2641. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2642. array_push($gotCalendar, array(
  2643. "id" => "Sick-Today-".$i,
  2644. "title" => $seriesName,
  2645. "start" => $episodeAirDate,
  2646. "className" => $downloaded." tvID--".$episodeID,
  2647. "imagetype" => "tv",
  2648. ));
  2649. }
  2650. foreach($array['data']['soon'] AS $child) {
  2651. $i++;
  2652. $seriesName = $child['show_name'];
  2653. $episodeID = $child['tvdbid'];
  2654. $episodeAirDate = $child['airdate'];
  2655. $episodeAirDateTime = explode(" ",$child['airs']);
  2656. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2657. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2658. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2659. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2660. $downloaded = "0";
  2661. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2662. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2663. array_push($gotCalendar, array(
  2664. "id" => "Sick-Soon-".$i,
  2665. "title" => $seriesName,
  2666. "start" => $episodeAirDate,
  2667. "className" => $downloaded." tvID--".$episodeID,
  2668. "imagetype" => "tv",
  2669. ));
  2670. }
  2671. foreach($array['data']['later'] AS $child) {
  2672. $i++;
  2673. $seriesName = $child['show_name'];
  2674. $episodeID = $child['tvdbid'];
  2675. $episodeAirDate = $child['airdate'];
  2676. $episodeAirDateTime = explode(" ",$child['airs']);
  2677. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2678. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2679. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2680. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2681. $downloaded = "0";
  2682. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2683. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2684. array_push($gotCalendar, array(
  2685. "id" => "Sick-Later-".$i,
  2686. "title" => $seriesName,
  2687. "start" => $episodeAirDate,
  2688. "className" => $downloaded." tvID--".$episodeID,
  2689. "imagetype" => "tv",
  2690. ));
  2691. }
  2692. if ($i != 0){ return $gotCalendar; }
  2693. }
  2694. function getSickrageCalendarHistory($array){
  2695. $array = json_decode($array, true);
  2696. //$gotCalendar = "";
  2697. $gotCalendar = array();
  2698. $i = 0;
  2699. foreach($array['data'] AS $child) {
  2700. $i++;
  2701. $seriesName = $child['show_name'];
  2702. $episodeID = $child['tvdbid'];
  2703. $episodeAirDate = $child['date'];
  2704. $downloaded = "green-bg";
  2705. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2706. array_push($gotCalendar, array(
  2707. "id" => "Sick-History-".$i,
  2708. "title" => $seriesName,
  2709. "start" => $episodeAirDate,
  2710. "className" => $downloaded." tvID--".$episodeID,
  2711. "imagetype" => "tv",
  2712. ));
  2713. }
  2714. if ($i != 0){ return $gotCalendar; }
  2715. }
  2716. function getSonarrCalendar($array){
  2717. $array = json_decode($array, true);
  2718. //$gotCalendar = "";
  2719. $gotCalendar = array();
  2720. $i = 0;
  2721. foreach($array AS $child) {
  2722. $i++;
  2723. $seriesName = $child['series']['title'];
  2724. $episodeID = $child['series']['tvdbId'];
  2725. if(!isset($episodeID)){ $episodeID = ""; }
  2726. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  2727. if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
  2728. $episodeAirDate = $child['airDateUtc'];
  2729. $episodeAirDate = strtotime($episodeAirDate);
  2730. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2731. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2732. $downloaded = $child['hasFile'];
  2733. 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"; }
  2734. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2735. array_push($gotCalendar, array(
  2736. "id" => "Sonarr-".$i,
  2737. "title" => $seriesName,
  2738. "start" => $episodeAirDate,
  2739. "className" => $downloaded." tvID--".$episodeID,
  2740. "imagetype" => "tv",
  2741. ));
  2742. }
  2743. if ($i != 0){ return $gotCalendar; }
  2744. }
  2745. function getCouchCalendar(){
  2746. $url = qualifyURL(COUCHURL);
  2747. $api = curl_get($url."/api/".COUCHAPI."/media.list");
  2748. $api = json_decode($api, true);
  2749. $i = 0;
  2750. $gotCalendar = array();
  2751. if (is_array($api) || is_object($api)){
  2752. foreach($api['movies'] AS $child) {
  2753. if($child['status'] == "active" || $child['status'] == "done" ){
  2754. $i++;
  2755. $movieName = $child['info']['original_title'];
  2756. $movieID = $child['info']['tmdb_id'];
  2757. if(!isset($movieID)){ $movieID = ""; }
  2758. $physicalRelease = (isset($child['info']['released']) ? $child['info']['released'] : null);
  2759. $backupRelease = (isset($child['info']['release_date']['theater']) ? $child['info']['release_date']['theater'] : null);
  2760. $physicalRelease = (isset($physicalRelease) ? $physicalRelease : $backupRelease);
  2761. $physicalRelease = strtotime($physicalRelease);
  2762. $physicalRelease = date("Y-m-d", $physicalRelease);
  2763. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2764. $downloaded = ($child['status'] == "active") ? "0" : "1";
  2765. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2766. array_push($gotCalendar, array(
  2767. "id" => "CouchPotato-".$i,
  2768. "title" => $movieName,
  2769. "start" => $physicalRelease,
  2770. "className" => $downloaded." movieID--".$movieID,
  2771. "imagetype" => "film",
  2772. ));
  2773. }
  2774. }
  2775. if ($i != 0){ return $gotCalendar; }
  2776. }else{
  2777. writeLog("error", "CouchPotato ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2778. }
  2779. }
  2780. function getRadarrCalendar($array){
  2781. $array = json_decode($array, true);
  2782. $gotCalendar = array();
  2783. $i = 0;
  2784. foreach($array AS $child) {
  2785. if(isset($child['physicalRelease'])){
  2786. $i++;
  2787. $movieName = $child['title'];
  2788. $movieID = $child['tmdbId'];
  2789. if(!isset($movieID)){ $movieID = ""; }
  2790. $physicalRelease = $child['physicalRelease'];
  2791. $physicalRelease = strtotime($physicalRelease);
  2792. $physicalRelease = date("Y-m-d", $physicalRelease);
  2793. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2794. $downloaded = $child['hasFile'];
  2795. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2796. array_push($gotCalendar, array(
  2797. "id" => "Radarr-".$i,
  2798. "title" => $movieName,
  2799. "start" => $physicalRelease,
  2800. "className" => $downloaded." movieID--".$movieID,
  2801. "imagetype" => "film",
  2802. ));
  2803. }
  2804. }
  2805. if ($i != 0){ return $gotCalendar; }
  2806. }
  2807. function getHeadphonesCalendar($url, $key, $list){
  2808. $url = qualifyURL(HEADPHONESURL);
  2809. $api = curl_get($url."/api?apikey=".$key."&cmd=$list");
  2810. $api = json_decode($api, true);
  2811. $i = 0;
  2812. //$gotCalendar = "";
  2813. $gotCalendar = array();;
  2814. if (is_array($api) || is_object($api)){
  2815. foreach($api AS $child) {
  2816. if($child['Status'] == "Wanted" && $list == "getWanted" && $child['ReleaseDate']){
  2817. $i++;
  2818. $albumName = addslashes($child['AlbumTitle']);
  2819. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  2820. $albumDate = (strlen($child['ReleaseDate']) > 4) ? $child['ReleaseDate'] : $child['ReleaseDate']."-01-01";
  2821. $albumID = $child['AlbumID'];
  2822. $albumDate = strtotime($albumDate);
  2823. $albumDate = date("Y-m-d", $albumDate);
  2824. $albumStatus = $child['Status'];
  2825. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2826. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  2827. //$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2828. array_push($gotCalendar, array(
  2829. "id" => "Headphones-".$i,
  2830. "title" => $albumArtist.' - '.$albumName,
  2831. "start" => $albumDate,
  2832. "className" => $albumStatusColor,
  2833. "imagetype" => "music",
  2834. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2835. ));
  2836. }
  2837. if($child['Status'] == "Processed" && $list == "getHistory"){
  2838. $i++;
  2839. $find = array('_','[', ']', '\n');
  2840. $replace = array(' ','(', ')', ' ');
  2841. $albumName = addslashes(str_replace($find,$replace,$child['FolderName']));
  2842. $albumDate = $child['DateAdded'];
  2843. $albumID = $child['AlbumID'];
  2844. $albumDate = strtotime($albumDate);
  2845. $albumDate = date("Y-m-d", $albumDate);
  2846. $albumStatusColor = "green-bg";
  2847. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2848. //$gotCalendar .= "{ title: \"$albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2849. array_push($gotCalendar, array(
  2850. "id" => "Headphones-".$i,
  2851. "title" => $albumName,
  2852. "start" => $albumDate,
  2853. "className" => $albumStatusColor,
  2854. "imagetype" => "music",
  2855. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2856. ));
  2857. }
  2858. }
  2859. if ($i != 0){ return $gotCalendar; }
  2860. }else{
  2861. writeLog("error", "HEADPHONES $list ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2862. }
  2863. }
  2864. function checkRootPath($string){
  2865. if($string == "\\" || $string == "/"){
  2866. return "/";
  2867. }else{
  2868. return str_replace("\\", "/", $string) . "/";
  2869. }
  2870. }
  2871. function strip($string){
  2872. $string = strip_tags($string);
  2873. return preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $string));
  2874. }
  2875. function writeLog($type, $message){
  2876. if(file_exists("org.log")){
  2877. if(filesize("org.log") > 500000){
  2878. rename('org.log','org['.date('Y-m-d').'].log');
  2879. $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";
  2880. file_put_contents("org.log", $message2, FILE_APPEND | LOCK_EX);
  2881. }
  2882. }
  2883. $message = date("Y-m-d H:i:s")."|".$type."|".strip($message)."\n";
  2884. file_put_contents("org.log", $message, FILE_APPEND | LOCK_EX);
  2885. }
  2886. function readLog(){
  2887. $log = file("org.log",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  2888. $log = array_reverse($log);
  2889. foreach($log as $line){
  2890. if(substr_count($line, '|') == 2){
  2891. $line = explode("|", strip($line));
  2892. $line[1] = ($line[1] == "error") ? '<span class="label label-danger">Error</span>' : '<span class="label label-primary">Success</span>';
  2893. echo "<tr><td>".$line[0]."</td><td>".$line[2]."</td><td>".$line[1]."</td></tr>";
  2894. }
  2895. }
  2896. }
  2897. function buildStream($array){
  2898. $result = "";
  2899. if (array_key_exists('platform', $array)) {
  2900. $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>';
  2901. }
  2902. if (array_key_exists('device', $array)) {
  2903. $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>';
  2904. }
  2905. if (array_key_exists('stream', $array)) {
  2906. $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>';
  2907. }
  2908. if (array_key_exists('video', $array)) {
  2909. $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>';
  2910. }
  2911. if (array_key_exists('audio', $array)) {
  2912. $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>';
  2913. }
  2914. return $result;
  2915. }
  2916. function streamType($value){
  2917. if($value == "transcode" || $value == "Transcode"){
  2918. return "Transcode";
  2919. }elseif($value == "copy" || $value == "DirectStream"){
  2920. return "Direct Stream";
  2921. }elseif($value == "directplay" || $value == "DirectPlay"){
  2922. return "Direct Play";
  2923. }else{
  2924. return "Direct Play";
  2925. }
  2926. }
  2927. function getPlatform($platform){
  2928. $allPlatforms = array(
  2929. "Chrome" => "chrome.png",
  2930. "tvOS" => "atv.png",
  2931. "iOS" => "ios.png",
  2932. "Xbox One" => "xbox.png",
  2933. "Mystery 4" => "playstation.png",
  2934. "Samsung" => "samsung.png",
  2935. "Roku" => "roku.png",
  2936. "Emby for iOS" => "ios.png",
  2937. "Emby Mobile" => "emby.png",
  2938. "Emby Theater" => "emby.png",
  2939. "Emby Classic" => "emby.png",
  2940. "Safari" => "safari.png",
  2941. "Android" => "android.png",
  2942. "AndroidTv" => "android.png",
  2943. "Chromecast" => "chromecast.png",
  2944. "Dashboard" => "emby.png",
  2945. "Dlna" => "dlna.png",
  2946. "Windows Phone" => "wp.png",
  2947. "Windows RT" => "win8.png",
  2948. "Kodi" => "kodi.png",
  2949. );
  2950. if (array_key_exists($platform, $allPlatforms)) {
  2951. return $allPlatforms[$platform];
  2952. }else{
  2953. return "pmp.png";
  2954. }
  2955. }
  2956. function getServer(){
  2957. $server = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"];
  2958. return $server;
  2959. }
  2960. function prettyPrint($array) {
  2961. echo "<pre>";
  2962. print_r($array);
  2963. echo "</pre>";
  2964. echo "<br/>";
  2965. }
  2966. function checkFrame($array, $url){
  2967. if(array_key_exists("x-frame-options", $array)){
  2968. if($array['x-frame-options'] == "deny"){
  2969. return false;
  2970. }elseif($array['x-frame-options'] == "sameorgin"){
  2971. $digest = parse_url($url);
  2972. $host = (isset($digest['host'])?$digest['host']:'');
  2973. if(getServer() == $host){
  2974. return true;
  2975. }else{
  2976. return false;
  2977. }
  2978. }
  2979. }else{
  2980. if(!$array){
  2981. return false;
  2982. }
  2983. return true;
  2984. }
  2985. }
  2986. function frameTest($url){
  2987. $array = array_change_key_case(get_headers(qualifyURL($url), 1));
  2988. $url = qualifyURL($url);
  2989. if(checkFrame($array, $url)){
  2990. return true;
  2991. }else{
  2992. return false;
  2993. }
  2994. }
  2995. function sendResult($result, $icon = "floppy-o", $message = false, $success = "WAS_SUCCESSFUL", $fail = "HAS_FAILED", $send = true) {
  2996. $notifyExplode = explode("-", NOTIFYEFFECT);
  2997. if ($result) {
  2998. $msg = array(
  2999. 'html' => ($message?''.$message.' <strong>'.translate($success).'</strong>':'<strong>'.translate($success).'</strong>'),
  3000. 'icon' => $icon,
  3001. 'type' => 'success',
  3002. 'length' => '5000',
  3003. 'layout' => $notifyExplode[0],
  3004. 'effect' => $notifyExplode[1],
  3005. );
  3006. } else {
  3007. $msg = array(
  3008. 'html' => ($message?''.$message.' <strong>'.translate($fail).'</strong>':'<strong>'.translate($fail).'</strong>'),
  3009. 'icon' => $icon,
  3010. 'type' => 'error',
  3011. 'length' => '5000',
  3012. 'layout' => $notifyExplode[0],
  3013. 'effect' => $notifyExplode[1],
  3014. );
  3015. }
  3016. // Send and kill script?
  3017. if ($send) {
  3018. header('Content-Type: application/json');
  3019. echo json_encode(array('notify'=>$msg));
  3020. die();
  3021. }
  3022. return $msg;
  3023. }
  3024. function buildHomepageNotice($layout, $type, $title, $message){
  3025. switch ($layout) {
  3026. case 'elegant':
  3027. return '
  3028. <div id="homepageNotice" class="row">
  3029. <div class="col-lg-12">
  3030. <div class="content-box big-box box-shadow panel-box panel-'.$type.'">
  3031. <div class="content-title i-block">
  3032. <h4 class="zero-m"><strong>'.$title.'</strong></h4>
  3033. <div class="content-tools i-block pull-right">
  3034. <a class="close-btn">
  3035. <i class="fa fa-times"></i>
  3036. </a>
  3037. </div>
  3038. </div>
  3039. '.$message.'
  3040. </div>
  3041. </div>
  3042. </div>
  3043. ';
  3044. break;
  3045. case 'basic':
  3046. return '
  3047. <div id="homepageNotice" class="row">
  3048. <div class="col-lg-12">
  3049. <div class="panel panel-'.$type.'">
  3050. <div class="panel-heading">
  3051. <h3 class="panel-title">'.$title.'</h3>
  3052. </div>
  3053. <div class="panel-body">
  3054. '.$message.'
  3055. </div>
  3056. </div>
  3057. </div>
  3058. </div>
  3059. ';
  3060. break;
  3061. case 'jumbotron';
  3062. return '
  3063. <div id="homepageNotice" class="row">
  3064. <div class="col-lg-12">
  3065. <div class="jumbotron">
  3066. <div class="container">
  3067. <h1>'.$title.'</h1>
  3068. <p>'.$message.'</p>
  3069. </div>
  3070. </div>
  3071. </div>
  3072. </div>
  3073. ';
  3074. }
  3075. }
  3076. function embyArray($array, $type) {
  3077. $key = ($type == "video" ? "Height" : "Channels");
  3078. if (array_key_exists($key, $array)) {
  3079. switch ($type) {
  3080. case "video":
  3081. $codec = $array["Codec"];
  3082. $height = $array["Height"];
  3083. $width = $array["Width"];
  3084. break;
  3085. default:
  3086. $codec = $array["Codec"];
  3087. $channels = $array["Channels"];
  3088. }
  3089. return ($type == "video" ? "(".$codec.") (".$width."x".$height.")" : "(".$codec.") (".$channels."ch)");
  3090. }
  3091. foreach ($array as $element) {
  3092. if (is_array($element)) {
  3093. if (embyArray($element, $type)) {
  3094. return embyArray($element, $type);
  3095. }
  3096. }
  3097. }
  3098. }
  3099. // Get Now Playing Streams From Plex
  3100. function searchPlex($query){
  3101. $address = qualifyURL(PLEXURL);
  3102. $openTab = (PLEXTABNAME) ? "true" : "false";
  3103. // Perform API requests
  3104. $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
  3105. libxml_use_internal_errors(true);
  3106. $api = simplexml_load_string($api);
  3107. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3108. if (!$getServer) { return 'Could not load!'; }
  3109. // Identify the local machine
  3110. $server = $getServer['machineIdentifier'];
  3111. $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>";
  3112. $items = "";
  3113. $albums = $movies = $shows = 0;
  3114. $style = 'style="vertical-align: middle"';
  3115. foreach($api AS $child) {
  3116. if($child['type'] != "artist" && $child['type'] != "episode" && isset($child['librarySectionID'])){
  3117. $time = (string)$child['addedAt'];
  3118. $time = new DateTime("@$time");
  3119. $results = array(
  3120. "title" => (string)$child['title'],
  3121. "image" => (string)$child['thumb'],
  3122. "type" => (string)ucwords($child['type']),
  3123. "year" => (string)$child['year'],
  3124. "key" => (string)$child['ratingKey']."-search",
  3125. "ratingkey" => (string)$child['ratingKey'],
  3126. "genre" => (string)$child->Genre['tag'],
  3127. "added" => $time->format('Y-m-d'),
  3128. "extra" => "",
  3129. );
  3130. switch ($child['type']){
  3131. case "album":
  3132. $push = array(
  3133. "title" => (string)$child['parentTitle']." - ".(string)$child['title'],
  3134. );
  3135. $results = array_replace($results,$push);
  3136. $albums++;
  3137. break;
  3138. case "movie":
  3139. $push = array(
  3140. "extra" => "Content Rating: ".(string)$child['contentRating']."<br/>Movie Rating: ".(string)$child['rating'],
  3141. );
  3142. $results = array_replace($results,$push);
  3143. $movies++;
  3144. break;
  3145. case "show":
  3146. $push = array(
  3147. "extra" => "Seasons: ".(string)$child['childCount']."<br/>Episodes: ".(string)$child['leafCount'],
  3148. );
  3149. $results = array_replace($results,$push);
  3150. $shows++;
  3151. break;
  3152. }
  3153. if (file_exists('images/cache/'.$results['key'].'.jpg')){ $image_url = 'images/cache/'.$results['key'].'.jpg'; }
  3154. if (file_exists('images/cache/'.$results['key'].'.jpg') && (time() - 604800) > filemtime('images/cache/'.$results['key'].'.jpg') || !file_exists('images/cache/'.$results['key'].'.jpg')) {
  3155. $image_url = 'ajax.php?a=plex-image&img='.$results['image'].'&height=150&width=100&key='.$results['key'];
  3156. }
  3157. if(!$results['image']){ $image_url = "images/no-search.png"; $key = "no-search"; }
  3158. if (substr_count(PLEXURL, '.') != 2) {
  3159. $link = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3160. }else{
  3161. $link = PLEXURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3162. }
  3163. $items .= '<tr style="cursor: pointer;" class="openTab" extraTitle="'.$results['title'].'" extraType="'.$child['type'].'" openTab="'.$openTab.'" href="'.$link.'">
  3164. <th scope="row"><img src="'.$image_url.'"></th>
  3165. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
  3166. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
  3167. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
  3168. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
  3169. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
  3170. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['extra'].'</td>
  3171. </tr>';
  3172. }
  3173. }
  3174. $totals = '<div style="margin: 10px;" class="sort-todo pull-right">
  3175. <span class="badge gray-bg"><i class="fa fa-film fa-2x white"></i><strong style="
  3176. font-size: 23px;
  3177. ">&nbsp;'.$movies.'</strong></span>
  3178. <span class="badge gray-bg"><i class="fa fa-tv fa-2x white"></i><strong style="
  3179. font-size: 23px;
  3180. ">&nbsp;'.$shows.'</strong></span>
  3181. <span class="badge gray-bg"><i class="fa fa-music fa-2x white"></i><strong style="
  3182. font-size: 23px;
  3183. ">&nbsp;'.$albums.'</strong></span>
  3184. </div>';
  3185. return (!empty($items) ? $totals.$pre.$items."</div></table>" : "<h2 class='text-center'>No Results for $query</h2>" );
  3186. }
  3187. function getBannedUsers($string){
  3188. if (strpos($string, ',') !== false) {
  3189. $banned = explode(",", $string);
  3190. }else{
  3191. $banned = array($string);
  3192. }
  3193. return $banned;
  3194. }
  3195. function getWhitelist($string){
  3196. if (strpos($string, ',') !== false) {
  3197. $whitelist = explode(",", $string);
  3198. }else{
  3199. $whitelist = array($string);
  3200. }
  3201. foreach($whitelist as &$ip){
  3202. $ip = is_numeric(substr($ip, 0, 1)) ? $ip : gethostbyname($ip);
  3203. }
  3204. return $whitelist;
  3205. }
  3206. function get_client_ip() {
  3207. $ipaddress = '';
  3208. if (isset($_SERVER['HTTP_CLIENT_IP']))
  3209. $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
  3210. else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  3211. $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
  3212. else if(isset($_SERVER['HTTP_X_FORWARDED']))
  3213. $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
  3214. else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
  3215. $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
  3216. else if(isset($_SERVER['HTTP_FORWARDED']))
  3217. $ipaddress = $_SERVER['HTTP_FORWARDED'];
  3218. else if(isset($_SERVER['REMOTE_ADDR']))
  3219. $ipaddress = $_SERVER['REMOTE_ADDR'];
  3220. else
  3221. $ipaddress = 'UNKNOWN';
  3222. return $ipaddress;
  3223. }
  3224. //EMAIL SHIT
  3225. function sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null){
  3226. $mail = new PHPMailer;
  3227. $mail->isSMTP();
  3228. $mail->Host = SMTPHOST;
  3229. $mail->SMTPAuth = SMTPHOSTAUTH;
  3230. $mail->Username = SMTPHOSTUSERNAME;
  3231. $mail->Password = SMTPHOSTPASSWORD;
  3232. $mail->SMTPSecure = SMTPHOSTTYPE;
  3233. $mail->Port = SMTPHOSTPORT;
  3234. $mail->setFrom(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3235. $mail->addReplyTo(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3236. $mail->isHTML(true);
  3237. if($email){
  3238. $mail->addAddress($email, $username);
  3239. }
  3240. if($cc){
  3241. $mail->addCC($cc);
  3242. }
  3243. if($bcc){
  3244. if(strpos($bcc , ',') === false){
  3245. $mail->addBCC($bcc);
  3246. }else{
  3247. $allEmails = explode(",",$bcc);
  3248. foreach($allEmails as $gotEmail){
  3249. $mail->addBCC($gotEmail);
  3250. }
  3251. }
  3252. }
  3253. $mail->Subject = $subject;
  3254. $mail->Body = $body;
  3255. //$mail->send();
  3256. if(!$mail->send()) {
  3257. writeLog("error", "mail failed to send");
  3258. } else {
  3259. writeLog("success", "mail has been sent");
  3260. }
  3261. }
  3262. //EMAIL SHIT
  3263. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  3264. $mail = new PHPMailer;
  3265. $mail->isSMTP();
  3266. $mail->Host = $host;
  3267. $mail->SMTPAuth = $auth;
  3268. $mail->Username = $username;
  3269. $mail->Password = $password;
  3270. $mail->SMTPSecure = $type;
  3271. $mail->Port = $port;
  3272. $mail->setFrom($from, $sendername);
  3273. $mail->addReplyTo($from, $sendername);
  3274. $mail->isHTML(true);
  3275. $mail->addAddress($to, "Organizr Admin");
  3276. $mail->Subject = "Organizr Test E-Mail";
  3277. $mail->Body = "This was just a test!";
  3278. //$mail->send();
  3279. if(!$mail->send()) {
  3280. writeLog("error", "EMAIL TEST: mail failed to send - Error:".$mail->ErrorInfo);
  3281. return false;
  3282. } else {
  3283. writeLog("success", "EMAIL TEST: mail has been sent successfully");
  3284. return true;
  3285. }
  3286. }
  3287. function libraryList(){
  3288. $address = qualifyURL(PLEXURL);
  3289. $headers = array(
  3290. "Accept" => "application/json",
  3291. "X-Plex-Token" => PLEXTOKEN
  3292. );
  3293. libxml_use_internal_errors(true);
  3294. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3295. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3296. $api = simplexml_load_string(@curl_get("https://plex.tv/api/servers/$gotServer/shared_servers", $headers));
  3297. $libraryList = array();
  3298. foreach($api->SharedServer->Section AS $child) {
  3299. $libraryList['libraries'][(string)$child['title']] = (string)$child['id'];
  3300. }
  3301. foreach($api->SharedServer AS $child) {
  3302. if(!empty($child['username'])){
  3303. $username = (string)strtolower($child['username']);
  3304. $email = (string)strtolower($child['email']);
  3305. $libraryList['users'][$username] = (string)$child['id'];
  3306. $libraryList['emails'][$email] = (string)$child['id'];
  3307. $libraryList['both'][$username] = $email;
  3308. }
  3309. }
  3310. return (!empty($libraryList) ? array_change_key_case($libraryList,CASE_LOWER) : null );
  3311. }
  3312. function plexUserShare($username){
  3313. $address = qualifyURL(PLEXURL);
  3314. $headers = array(
  3315. "Accept" => "application/json",
  3316. "Content-Type" => "application/json",
  3317. "X-Plex-Token" => PLEXTOKEN
  3318. );
  3319. libxml_use_internal_errors(true);
  3320. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3321. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3322. $json = array(
  3323. "server_id" => $gotServer,
  3324. "shared_server" => array(
  3325. //"library_section_ids" => "[26527637]",
  3326. "invited_email" => $username
  3327. )
  3328. );
  3329. $api = curl_post("https://plex.tv/api/servers/$gotServer/shared_servers/", $json, $headers);
  3330. switch ($api['http_code']['http_code']){
  3331. case 400:
  3332. writeLog("error", "PLEX INVITE: $username already has access to the shared libraries");
  3333. $result = "$username already has access to the shared libraries";
  3334. break;
  3335. case 401:
  3336. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3337. $result = "Invalid Plex Token";
  3338. break;
  3339. case 200:
  3340. writeLog("success", "PLEX INVITE: $username now has access to your Plex Library");
  3341. $result = "$username now has access to your Plex Library";
  3342. break;
  3343. default:
  3344. writeLog("error", "PLEX INVITE: unknown error");
  3345. $result = false;
  3346. }
  3347. return (!empty($result) ? $result : null );
  3348. }
  3349. function plexUserDelete($username){
  3350. $address = qualifyURL(PLEXURL);
  3351. $headers = array(
  3352. "Accept" => "application/json",
  3353. "Content-Type" => "application/json",
  3354. "X-Plex-Token" => PLEXTOKEN
  3355. );
  3356. libxml_use_internal_errors(true);
  3357. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3358. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3359. $id = (is_numeric($username) ? $id : convertPlexName($username, "id"));
  3360. $api = curl_delete("https://plex.tv/api/servers/$gotServer/shared_servers/$id", $headers);
  3361. switch ($api['http_code']['http_code']){
  3362. case 401:
  3363. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3364. $result = "Invalid Plex Token";
  3365. break;
  3366. case 200:
  3367. writeLog("success", "PLEX INVITE: $username doesn't have access to your Plex Library anymore");
  3368. $result = "$username doesn't have access to your Plex Library anymore";
  3369. break;
  3370. default:
  3371. writeLog("error", "PLEX INVITE: unknown error");
  3372. $result = false;
  3373. }
  3374. return (!empty($result) ? $result : null );
  3375. }
  3376. function convertPlexName($user, $type){
  3377. $array = libraryList();
  3378. switch ($type){
  3379. case "username":
  3380. $plexUser = array_search ($user, $array['users']);
  3381. break;
  3382. case "id":
  3383. if (array_key_exists(strtolower($user), $array['users'])) {
  3384. $plexUser = $array['users'][strtolower($user)];
  3385. }
  3386. break;
  3387. default:
  3388. $plexUser = false;
  3389. }
  3390. return (!empty($plexUser) ? $plexUser : null );
  3391. }
  3392. function randomCode($length = 5, $type = null) {
  3393. switch ($type){
  3394. case "alpha":
  3395. $legend = array_merge(range('A', 'Z'));
  3396. break;
  3397. case "numeric":
  3398. $legend = array_merge(range(0,9));
  3399. break;
  3400. default:
  3401. $legend = array_merge(range(0,9),range('A', 'Z'));
  3402. }
  3403. $code = "";
  3404. for($i=0; $i < $length; $i++) {
  3405. $code .= $legend[mt_rand(0, count($legend) - 1)];
  3406. }
  3407. return $code;
  3408. }
  3409. function inviteCodes($action, $code = null, $usedBy = null) {
  3410. if (!isset($GLOBALS['file_db'])) {
  3411. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  3412. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  3413. }
  3414. $now = date("Y-m-d H:i:s");
  3415. switch ($action) {
  3416. case "get":
  3417. // Start Array
  3418. $result = array();
  3419. // Database Lookup
  3420. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes"');
  3421. // Get Codes
  3422. foreach($invites as $row) {
  3423. array_push($result, $row['code']);
  3424. }
  3425. // Return the Results
  3426. return (!empty($result) ? $result : false );
  3427. break;
  3428. case "check":
  3429. // Start Array
  3430. $result = array();
  3431. // Database Lookup
  3432. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes" AND code = "'.$code.'"');
  3433. // Get Codes
  3434. foreach($invites as $row) {
  3435. $result = $row['code'];
  3436. }
  3437. // Return the Results
  3438. return (!empty($result) ? $result : false );
  3439. break;
  3440. case "use":
  3441. $currentIP = get_client_ip();
  3442. $invites = $GLOBALS['file_db']->query('UPDATE invites SET valid = "No", usedby = "'.$usedBy.'", dateused = "'.$now.'", ip = "'.$currentIP.'" WHERE code = "'.$code.'"');
  3443. if(ENABLEMAIL){
  3444. if (!isset($GLOBALS['USER'])) {
  3445. require_once("user.php");
  3446. $GLOBALS['USER'] = new User('registration_callback');
  3447. }
  3448. 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."));
  3449. }
  3450. return (!empty($invites) ? true : false );
  3451. break;
  3452. }
  3453. }
  3454. function plexJoin($username, $email, $password){
  3455. $connectURL = 'https://plex.tv/users.json';
  3456. $headers = array(
  3457. 'Accept'=> 'application/json',
  3458. 'Content-Type' => 'application/x-www-form-urlencoded',
  3459. 'X-Plex-Product' => 'Organizr',
  3460. 'X-Plex-Version' => '1.0',
  3461. 'X-Plex-Client-Identifier' => '01010101-10101010',
  3462. );
  3463. $body = array(
  3464. 'user[email]' => $email,
  3465. 'user[username]' => $username,
  3466. 'user[password]' => $password,
  3467. );
  3468. $api = curl_post($connectURL, $body, $headers);
  3469. $json = json_decode($api['content'], true);
  3470. $errors = (!empty($json['errors']) ? true : false);
  3471. $success = (!empty($json['user']) ? true : false);
  3472. //Use This for later
  3473. $usernameError = (!empty($json['errors']['username']) ? $json['errors']['username'][0] : false);
  3474. $emailError = (!empty($json['errors']['email']) ? $json['errors']['email'][0] : false);
  3475. $passwordError = (!empty($json['errors']['password']) ? $json['errors']['password'][0] : false);
  3476. $errorMessage = "";
  3477. if($errors){
  3478. if($usernameError){ $errorMessage .= "[Username Error: ". $usernameError ."]"; }
  3479. if($emailError){ $errorMessage .= "[Email Error: ". $emailError ."]"; }
  3480. if($passwordError){ $errorMessage .= "[Password Error: ". $passwordError ."]"; }
  3481. }
  3482. switch ($api['http_code']['http_code']){
  3483. case 400:
  3484. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." $username already has access to the shared libraries $errorMessage");
  3485. break;
  3486. case 401:
  3487. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." invalid Plex Token $errorMessage");
  3488. break;
  3489. case 422:
  3490. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." user info error $errorMessage");
  3491. break;
  3492. case 429:
  3493. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." too many requests to plex.tv please try later $errorMessage");
  3494. break;
  3495. case 200:
  3496. case 201:
  3497. writeLog("success", "PLEX JOIN: $username now has access to your Plex Library");
  3498. break;
  3499. default:
  3500. writeLog("error", "PLEX JOIN: unknown error, $errorMessage Error: ".$api['http_code']['http_code']);
  3501. }
  3502. //prettyPrint($api);
  3503. //prettyPrint(json_decode($api['content'], true));
  3504. return (!empty($success) && empty($errors) ? true : false );
  3505. }
  3506. function getCert(){
  3507. $url = "http://curl.haxx.se/ca/cacert.pem";
  3508. $file = getcwd()."/config/cacert.pem";
  3509. $directory = getcwd()."/config/";
  3510. @mkdir($directory, 0770, true);
  3511. if(!file_exists($file)){
  3512. file_put_contents( $file, fopen($url, 'r'));
  3513. writeLog("success", "CERT PEM: pem file created");
  3514. }elseif (file_exists($file) && time() - 2592000 > filemtime($file)) {
  3515. file_put_contents( $file, fopen($url, 'r'));
  3516. writeLog("success", "CERT PEM: downloaded new pem file");
  3517. }
  3518. return $file;
  3519. }
  3520. function customCSS(){
  3521. if(CUSTOMCSS == "true") {
  3522. $template_file = "custom.css";
  3523. $file_handle = fopen($template_file, "rb");
  3524. echo "\n";
  3525. echo fread($file_handle, filesize($template_file));
  3526. fclose($file_handle);
  3527. echo "\n";
  3528. }
  3529. }
  3530. function tvdbToken(){
  3531. $headers = array(
  3532. "Accept" => "application/json",
  3533. "Content-Type" => "application/json"
  3534. );
  3535. $json = array(
  3536. "apikey" => "FBE7B62621F4CAD7",
  3537. "userkey" => "328BB46EB1E9A0F5",
  3538. "username" => "causefx"
  3539. );
  3540. $api = curl_post("https://api.thetvdb.com/login", $json, $headers);
  3541. return json_decode($api['content'], true)['token'];
  3542. }
  3543. function tvdbGet($id){
  3544. $headers = array(
  3545. "Accept" => "application/json",
  3546. "Authorization" => "Bearer ".tvdbToken(),
  3547. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3548. "trakt-api-version" => "2"
  3549. );
  3550. $trakt = curl_get("https://api.trakt.tv/search/tvdb/$id?type=show", $headers);
  3551. @$api['trakt'] = json_decode($trakt, true)[0]['show']['ids'];
  3552. if(empty($api['trakt'])){
  3553. $series = curl_get("https://api.thetvdb.com/series/$id", $headers);
  3554. $poster = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=poster", $headers);
  3555. $backdrop = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=fanart", $headers);
  3556. $api['series'] = json_decode($series, true)['data'];
  3557. $api['poster'] = json_decode($poster, true)['data'];
  3558. $api['backdrop'] = json_decode($backdrop, true)['data'];
  3559. }
  3560. return $api;
  3561. }
  3562. function tvdbSearch($name, $type){
  3563. $name = rawurlencode(preg_replace("/\(([^()]*+|(?R))*\)/","", $name));
  3564. $headers = array(
  3565. "Accept" => "application/json",
  3566. "Authorization" => "Bearer ".tvdbToken(),
  3567. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3568. "trakt-api-version" => "2"
  3569. );
  3570. $trakt = curl_get("https://api.trakt.tv/search/$type?query=$name", $headers);
  3571. @$api['trakt'] = json_decode($trakt, true)[0][$type]['ids'];
  3572. return $api;
  3573. }
  3574. function getPlexPlaylists(){
  3575. $address = qualifyURL(PLEXURL);
  3576. // Perform API requests
  3577. $api = @curl_get($address."/playlists?X-Plex-Token=".PLEXTOKEN);
  3578. libxml_use_internal_errors(true);
  3579. $api = simplexml_load_string($api);
  3580. if (is_array($api) || is_object($api)){
  3581. if (!$api->head->title){
  3582. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3583. if (!$getServer) { return 'Could not load!'; }
  3584. // Identify the local machine
  3585. $gotServer = $getServer['machineIdentifier'];
  3586. $output = "";
  3587. $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">';
  3588. foreach($api AS $child) {
  3589. $items = array();
  3590. if ($child['playlistType'] == "video" && strpos(strtolower($child['title']) , 'private') === false){
  3591. $api = @curl_get($address.$child['key']."?X-Plex-Token=".PLEXTOKEN);
  3592. $api = simplexml_load_string($api);
  3593. if (is_array($api) || is_object($api)){
  3594. if (!$api->head->title){
  3595. $className = preg_replace("/(\W)+/", "", $api['title']);
  3596. $hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  3597. foreach($api->Video AS $child){
  3598. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false,false,$className);
  3599. }
  3600. if (count($items)) {
  3601. $output .= ''.implode('',$items).'';
  3602. }
  3603. }
  3604. }
  3605. }
  3606. }
  3607. $hideMenu .= '</ul></div></div>';
  3608. 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>';
  3609. }else{
  3610. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check token - if HTTPS, is cert valid");
  3611. }
  3612. }else{
  3613. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check URL - if HTTPS, is cert valid");
  3614. }
  3615. }
  3616. function readExternalLog($type,$filename,$name = null){
  3617. $log = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3618. $log = array_reverse($log);
  3619. foreach($log as $line){
  3620. if(!empty($line) && $line[0] != " "){
  3621. $line = strip($line);
  3622. if($type == "single"){
  3623. if( strpos( strtolower($line), "ror" ) !== false ) {
  3624. echo "<tr><td class='red-bg'>".$line."</td></tr>";
  3625. }else{
  3626. echo "<tr><td>".$line."</td></tr>";
  3627. }
  3628. }elseif($type == "all"){
  3629. if( strpos( strtolower($line), "ror" ) !== false ) {
  3630. echo "<tr><td class='red-bg'>".$name."</td>";
  3631. echo "<td class='red-bg'>".$line."</td></tr>";
  3632. }else{
  3633. echo "<tr><td>".$name."</td>";
  3634. echo "<td>".$line."</td></tr>";
  3635. }
  3636. }
  3637. }
  3638. }
  3639. }
  3640. function getLogs(){
  3641. $path = __DIR__ ."/logs/";
  3642. @mkdir($path, 0770, true);
  3643. $logs = array();
  3644. $files = array_diff(scandir($path), array('.', '..'));
  3645. foreach($files as $v){
  3646. $title = explode(".", $v)[0];
  3647. $logs[$title] = $path.$v;
  3648. }
  3649. return $logs;
  3650. }
  3651. function getBackups(){
  3652. $path = DATABASE_LOCATION ."backups/";
  3653. @mkdir($path, 0770, true);
  3654. $backups = array();
  3655. $files = array_diff(scandir($path), array('.', '..'));
  3656. return array_reverse($files);
  3657. }
  3658. function getExtension($string) {
  3659. return preg_replace("#(.+)?\.(\w+)(\?.+)?#", "$2", $string);
  3660. }
  3661. function showFile(){
  3662. $file = $_GET['file'];
  3663. $fileType = getExtension($file);
  3664. if($fileType != 'php'){
  3665. header("Content-type: ".mimeTypes()[$fileType]);
  3666. @readfile($file);
  3667. }
  3668. }
  3669. function getCalendar(){
  3670. $sonarr = new Sonarr(SONARRURL, SONARRKEY);
  3671. $radarr = new Sonarr(RADARRURL, RADARRKEY);
  3672. $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
  3673. $startDate = date('Y-m-d',strtotime("-".CALENDARSTARTDAY." days"));
  3674. $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
  3675. $calendarItems = array();
  3676. if (SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)){
  3677. try {
  3678. $sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate));
  3679. if(!empty($sonarrCalendar)) { $calendarItems = array_merge($calendarItems, $sonarrCalendar); }
  3680. } catch (Exception $e) {
  3681. writeLog("error", "SONARR ERROR: ".strip($e->getMessage()));
  3682. }
  3683. }
  3684. if (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)){
  3685. try {
  3686. $radarrCalendar = getRadarrCalendar($radarr->getCalendar($startDate, $endDate));
  3687. if(!empty($radarrCalendar)) { $calendarItems = array_merge($calendarItems, $radarrCalendar); }
  3688. } catch (Exception $e) {
  3689. writeLog("error", "RADARR ERROR: ".strip($e->getMessage()));
  3690. }
  3691. }
  3692. if (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH)){
  3693. $couchCalendar = getCouchCalendar();
  3694. if(!empty($couchCalendar)) { $calendarItems = array_merge($calendarItems, $couchCalendar); }
  3695. }
  3696. if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
  3697. $headphonesHistory = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory");
  3698. $headphonesWanted = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted");
  3699. if(!empty($headphonesHistory)) { $calendarItems = array_merge($calendarItems, $headphonesHistory); }
  3700. if(!empty($headphonesWanted)) { $calendarItems = array_merge($calendarItems, $headphonesWanted); }
  3701. }
  3702. if (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)){
  3703. try {
  3704. $sickrageFuture = getSickrageCalendarWanted($sickrage->future());
  3705. if(!empty($sickrageFuture)) { $calendarItems = array_merge($calendarItems, $sickrageFuture); }
  3706. } catch (Exception $e) {
  3707. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3708. } try {
  3709. $sickrageHistory = getSickrageCalendarHistory($sickrage->history("100","downloaded"));
  3710. if(!empty($sickrageHistory)) { $calendarItems = array_merge($calendarItems, $sickrageHistory); }
  3711. } catch (Exception $e) {
  3712. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3713. }
  3714. }
  3715. return $calendarItems;
  3716. }
  3717. function localURL($url){
  3718. if (strpos($url, 'https') !== false) {
  3719. preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $url, $result);
  3720. $result = (!empty($result) ? true : false);
  3721. return $result;
  3722. }
  3723. }
  3724. function fileArray($files){
  3725. foreach($files as $file){
  3726. if(file_exists($file)){
  3727. $list[] = $file;
  3728. }
  3729. }
  3730. if(!empty($list)){ return $list; }
  3731. }
  3732. function backupDB(){
  3733. if (extension_loaded('ZIP')) {
  3734. $directory = DATABASE_LOCATION."backups/";
  3735. @mkdir($directory, 0770, true);
  3736. $orgFiles = array(
  3737. 'css' => 'custom.css',
  3738. 'temp' => 'cus.sd',
  3739. 'orgLog' => 'org.log',
  3740. 'loginLog' => 'loginLog.json',
  3741. 'chatDB' => 'chatpack.db',
  3742. 'config' => 'config/config.php',
  3743. 'database' => DATABASE_LOCATION.'users.db'
  3744. );
  3745. $files = fileArray($orgFiles);
  3746. if(!empty($files)){
  3747. writeLog("success", "BACKUP: backup process started");
  3748. $zipname = $directory.'backup['.date('Y-m-d_H-i').']['.INSTALLEDVERSION.'].zip';
  3749. $zip = new ZipArchive;
  3750. $zip->open($zipname, ZipArchive::CREATE);
  3751. foreach ($files as $file) {
  3752. $zip->addFile($file);
  3753. }
  3754. $zip->close();
  3755. writeLog("success", "BACKUP: backup process finished");
  3756. return true;
  3757. }else{
  3758. return false;
  3759. }
  3760. }else{
  3761. return false;
  3762. }
  3763. }
  3764. class Ping {
  3765. private $host;
  3766. private $ttl;
  3767. private $timeout;
  3768. private $port = 80;
  3769. private $data = 'Ping';
  3770. private $commandOutput;
  3771. /**
  3772. * Called when the Ping object is created.
  3773. *
  3774. * @param string $host
  3775. * The host to be pinged.
  3776. * @param int $ttl
  3777. * Time-to-live (TTL) (You may get a 'Time to live exceeded' error if this
  3778. * value is set too low. The TTL value indicates the scope or range in which
  3779. * a packet may be forwarded. By convention:
  3780. * - 0 = same host
  3781. * - 1 = same subnet
  3782. * - 32 = same site
  3783. * - 64 = same region
  3784. * - 128 = same continent
  3785. * - 255 = unrestricted
  3786. * @param int $timeout
  3787. * Timeout (in seconds) used for ping and fsockopen().
  3788. * @throws \Exception if the host is not set.
  3789. */
  3790. public function __construct($host, $ttl = 255, $timeout = 10) {
  3791. if (!isset($host)) {
  3792. throw new \Exception("Error: Host name not supplied.");
  3793. }
  3794. $this->host = $host;
  3795. $this->ttl = $ttl;
  3796. $this->timeout = $timeout;
  3797. }
  3798. /**
  3799. * Set the ttl (in hops).
  3800. *
  3801. * @param int $ttl
  3802. * TTL in hops.
  3803. */
  3804. public function setTtl($ttl) {
  3805. $this->ttl = $ttl;
  3806. }
  3807. /**
  3808. * Get the ttl.
  3809. *
  3810. * @return int
  3811. * The current ttl for Ping.
  3812. */
  3813. public function getTtl() {
  3814. return $this->ttl;
  3815. }
  3816. /**
  3817. * Set the timeout.
  3818. *
  3819. * @param int $timeout
  3820. * Time to wait in seconds.
  3821. */
  3822. public function setTimeout($timeout) {
  3823. $this->timeout = $timeout;
  3824. }
  3825. /**
  3826. * Get the timeout.
  3827. *
  3828. * @return int
  3829. * Current timeout for Ping.
  3830. */
  3831. public function getTimeout() {
  3832. return $this->timeout;
  3833. }
  3834. /**
  3835. * Set the host.
  3836. *
  3837. * @param string $host
  3838. * Host name or IP address.
  3839. */
  3840. public function setHost($host) {
  3841. $this->host = $host;
  3842. }
  3843. /**
  3844. * Get the host.
  3845. *
  3846. * @return string
  3847. * The current hostname for Ping.
  3848. */
  3849. public function getHost() {
  3850. return $this->host;
  3851. }
  3852. /**
  3853. * Set the port (only used for fsockopen method).
  3854. *
  3855. * Since regular pings use ICMP and don't need to worry about the concept of
  3856. * 'ports', this is only used for the fsockopen method, which pings servers by
  3857. * checking port 80 (by default).
  3858. *
  3859. * @param int $port
  3860. * Port to use for fsockopen ping (defaults to 80 if not set).
  3861. */
  3862. public function setPort($port) {
  3863. $this->port = $port;
  3864. }
  3865. /**
  3866. * Get the port (only used for fsockopen method).
  3867. *
  3868. * @return int
  3869. * The port used by fsockopen pings.
  3870. */
  3871. public function getPort() {
  3872. return $this->port;
  3873. }
  3874. /**
  3875. * Return the command output when method=exec.
  3876. * @return string
  3877. */
  3878. public function getCommandOutput(){
  3879. return $this->commandOutput;
  3880. }
  3881. /**
  3882. * Matches an IP on command output and returns.
  3883. * @return string
  3884. */
  3885. public function getIpAddress() {
  3886. $out = array();
  3887. if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $this->commandOutput, $out)){
  3888. return $out[0];
  3889. }
  3890. return null;
  3891. }
  3892. /**
  3893. * Ping a host.
  3894. *
  3895. * @param string $method
  3896. * Method to use when pinging:
  3897. * - exec (default): Pings through the system ping command. Fast and
  3898. * robust, but a security risk if you pass through user-submitted data.
  3899. * - fsockopen: Pings a server on port 80.
  3900. * - socket: Creates a RAW network socket. Only usable in some
  3901. * environments, as creating a SOCK_RAW socket requires root privileges.
  3902. *
  3903. * @throws InvalidArgumentException if $method is not supported.
  3904. *
  3905. * @return mixed
  3906. * Latency as integer, in ms, if host is reachable or FALSE if host is down.
  3907. */
  3908. public function ping($method = 'exec') {
  3909. $latency = false;
  3910. switch ($method) {
  3911. case 'exec':
  3912. $latency = $this->pingExec();
  3913. break;
  3914. case 'fsockopen':
  3915. $latency = $this->pingFsockopen();
  3916. break;
  3917. case 'socket':
  3918. $latency = $this->pingSocket();
  3919. break;
  3920. default:
  3921. throw new \InvalidArgumentException('Unsupported ping method.');
  3922. }
  3923. // Return the latency.
  3924. return $latency;
  3925. }
  3926. /**
  3927. * The exec method uses the possibly insecure exec() function, which passes
  3928. * the input to the system. This is potentially VERY dangerous if you pass in
  3929. * any user-submitted data. Be SURE you sanitize your inputs!
  3930. *
  3931. * @return int
  3932. * Latency, in ms.
  3933. */
  3934. private function pingExec() {
  3935. $latency = false;
  3936. $ttl = escapeshellcmd($this->ttl);
  3937. $timeout = escapeshellcmd($this->timeout);
  3938. $host = escapeshellcmd($this->host);
  3939. // Exec string for Windows-based systems.
  3940. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  3941. // -n = number of pings; -i = ttl; -w = timeout (in milliseconds).
  3942. $exec_string = 'ping -n 1 -i ' . $ttl . ' -w ' . ($timeout * 1000) . ' ' . $host;
  3943. }
  3944. // Exec string for Darwin based systems (OS X).
  3945. else if(strtoupper(PHP_OS) === 'DARWIN') {
  3946. // -n = numeric output; -c = number of pings; -m = ttl; -t = timeout.
  3947. $exec_string = 'ping -n -c 1 -m ' . $ttl . ' -t ' . $timeout . ' ' . $host;
  3948. }
  3949. // Exec string for other UNIX-based systems (Linux).
  3950. else {
  3951. // -n = numeric output; -c = number of pings; -t = ttl; -W = timeout
  3952. $exec_string = 'ping -n -c 1 -t ' . $ttl . ' -W ' . $timeout . ' ' . $host . ' 2>&1';
  3953. }
  3954. exec($exec_string, $output, $return);
  3955. // Strip empty lines and reorder the indexes from 0 (to make results more
  3956. // uniform across OS versions).
  3957. $this->commandOutput = implode($output, '');
  3958. $output = array_values(array_filter($output));
  3959. // If the result line in the output is not empty, parse it.
  3960. if (!empty($output[1])) {
  3961. // Search for a 'time' value in the result line.
  3962. $response = preg_match("/time(?:=|<)(?<time>[\.0-9]+)(?:|\s)ms/", $output[1], $matches);
  3963. // If there's a result and it's greater than 0, return the latency.
  3964. if ($response > 0 && isset($matches['time'])) {
  3965. $latency = round($matches['time'], 2);
  3966. }
  3967. }
  3968. return $latency;
  3969. }
  3970. /**
  3971. * The fsockopen method simply tries to reach the host on a port. This method
  3972. * is often the fastest, but not necessarily the most reliable. Even if a host
  3973. * doesn't respond, fsockopen may still make a connection.
  3974. *
  3975. * @return int
  3976. * Latency, in ms.
  3977. */
  3978. private function pingFsockopen() {
  3979. $start = microtime(true);
  3980. // fsockopen prints a bunch of errors if a host is unreachable. Hide those
  3981. // irrelevant errors and deal with the results instead.
  3982. $fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
  3983. if (!$fp) {
  3984. $latency = false;
  3985. }
  3986. else {
  3987. $latency = microtime(true) - $start;
  3988. $latency = round($latency * 1000, 2);
  3989. }
  3990. return $latency;
  3991. }
  3992. /**
  3993. * The socket method uses raw network packet data to try sending an ICMP ping
  3994. * packet to a server, then measures the response time. Using this method
  3995. * requires the script to be run with root privileges, though, so this method
  3996. * only works reliably on Windows systems and on Linux servers where the
  3997. * script is not being run as a web user.
  3998. *
  3999. * @return int
  4000. * Latency, in ms.
  4001. */
  4002. private function pingSocket() {
  4003. // Create a package.
  4004. $type = "\x08";
  4005. $code = "\x00";
  4006. $checksum = "\x00\x00";
  4007. $identifier = "\x00\x00";
  4008. $seq_number = "\x00\x00";
  4009. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4010. // Calculate the checksum.
  4011. $checksum = $this->calculateChecksum($package);
  4012. // Finalize the package.
  4013. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4014. // Create a socket, connect to server, then read socket and calculate.
  4015. if ($socket = socket_create(AF_INET, SOCK_RAW, 1)) {
  4016. socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array(
  4017. 'sec' => 10,
  4018. 'usec' => 0,
  4019. ));
  4020. // Prevent errors from being printed when host is unreachable.
  4021. @socket_connect($socket, $this->host, null);
  4022. $start = microtime(true);
  4023. // Send the package.
  4024. @socket_send($socket, $package, strlen($package), 0);
  4025. if (socket_read($socket, 255) !== false) {
  4026. $latency = microtime(true) - $start;
  4027. $latency = round($latency * 1000, 2);
  4028. }
  4029. else {
  4030. $latency = false;
  4031. }
  4032. }
  4033. else {
  4034. $latency = false;
  4035. }
  4036. // Close the socket.
  4037. socket_close($socket);
  4038. return $latency;
  4039. }
  4040. /**
  4041. * Calculate a checksum.
  4042. *
  4043. * @param string $data
  4044. * Data for which checksum will be calculated.
  4045. *
  4046. * @return string
  4047. * Binary string checksum of $data.
  4048. */
  4049. private function calculateChecksum($data) {
  4050. if (strlen($data) % 2) {
  4051. $data .= "\x00";
  4052. }
  4053. $bit = unpack('n*', $data);
  4054. $sum = array_sum($bit);
  4055. while ($sum >> 16) {
  4056. $sum = ($sum >> 16) + ($sum & 0xffff);
  4057. }
  4058. return pack('n*', ~$sum);
  4059. }
  4060. }
  4061. function ping($pings, $type = "string") {
  4062. $ping = new Ping("");
  4063. $ping->setTtl(128);
  4064. $ping->setTimeout(2);
  4065. switch ($type){
  4066. case "array":
  4067. $results = [];
  4068. foreach ($pings as $k => $v) {
  4069. if(strpos($v, ':') !== false){
  4070. $domain = explode(':', $v)[0];
  4071. $port = explode(':', $v)[1];
  4072. $ping->setHost($domain);
  4073. $ping->setPort($port);
  4074. $latency = $ping->ping('fsockopen');
  4075. }else{
  4076. $ping->setHost($v);
  4077. $latency = $ping->ping();
  4078. }
  4079. if ($latency || $latency === 0) {
  4080. $results[$k] = $latency;
  4081. } else {
  4082. $results[$k] = 0;
  4083. }
  4084. }
  4085. break;
  4086. case "string":
  4087. if(strpos($pings, ':') !== false){
  4088. $domain = explode(':', $pings)[0];
  4089. $port = explode(':', $pings)[1];
  4090. $ping->setHost($domain);
  4091. $ping->setPort($port);
  4092. $latency = $ping->ping('fsockopen');
  4093. }else{
  4094. $ping->setHost($pings);
  4095. $latency = $ping->ping();
  4096. }
  4097. if ($latency || $latency === 0) {
  4098. $results = $latency;
  4099. } else {
  4100. $results = 0;
  4101. }
  4102. break;
  4103. }
  4104. return $results;
  4105. }
  4106. function getPing($url, $style, $refresh = null){
  4107. if(ping($url) !== 0){
  4108. $class = 'success';
  4109. if(!$refresh){
  4110. $class .= " animated slideInLeft";
  4111. }
  4112. }else{
  4113. $class = "warning";
  4114. if(!$refresh){
  4115. $class .= " animated flash loop-animation-timeout";
  4116. }
  4117. }
  4118. echo '<span class="pingcheck badge ping-'.$class.'" style="position: absolute;z-index: 100;right: 5px; padding: 0px 0px;'.$style.';font-size: 10px;">&nbsp;</span>';
  4119. }
  4120. function speedTestData(){
  4121. $file_db = DATABASE_LOCATION."speedtest.db";
  4122. if(file_exists($file_db)){
  4123. $conn = new PDO("sqlite:$file_db") or die("1");
  4124. $result = $conn->query('SELECT * FROM speedtest_users');
  4125. $conn = null;
  4126. if (is_array($result) || is_object($result)){
  4127. foreach($result as $k => $v){
  4128. $return[$k] = $v;
  4129. }
  4130. return $return;
  4131. }
  4132. }
  4133. }
  4134. function speedTestDisplay($array, $output){
  4135. if (is_array($array) || is_object($array)){
  4136. if($output == "graph"){
  4137. $result = "Morris.Line({element: 'morris-line',data: [";
  4138. foreach($array as $k => $v){
  4139. $result .= "{ y: '".substr($v['timestamp'],0,10)."', a: ".$v['ul'].", b: ".$v['dl'].", c: ".$v['ping']." },";
  4140. }
  4141. $result .= "],xkey: 'y',ykeys: ['a', 'b', 'c'],labels: ['Upload', 'Download', 'Ping'],hideHover: 'auto',resize: true,lineColors: ['#63A8EB','#ccc','#000'] });";
  4142. }elseif($output == "table"){
  4143. $result = "";
  4144. foreach($array as $k => $v){
  4145. $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>";
  4146. }
  4147. }
  4148. return $result;
  4149. }
  4150. }
  4151. function buildMenuPhone($array){
  4152. if (is_array($array) || is_object($array)){
  4153. $result = '
  4154. <div class="content-box profile-sidebar box-shadow">
  4155. <img src="images/organizr-logo-h-d.png" width="100%" style="margin-top: -10px;">
  4156. <div class="profile-usermenu">
  4157. <ul class="nav" id="settings-list">
  4158. ';
  4159. foreach($array as $k => $v){
  4160. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4161. continue;
  4162. }
  4163. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4164. continue;
  4165. }
  4166. /*$result .= '
  4167. <li>
  4168. <a id="'.$v['id'].'" box="'.$v['box'].'">'.$v['name'].'
  4169. <span class="fa-stack fa-fw pull-right" style="margin-top: -5px;margin-right: -10px;">
  4170. <i class="fa fa-'.$v['icon_1'].' fa-stack-2x '.$v['color'].'" style="font-size:null;"></i>
  4171. <i class="fa fa-'.$v['icon_2'].' fa-stack-1x fa-inverse"></i>
  4172. </span>
  4173. </a>
  4174. </li>
  4175. ';*/
  4176. $result .= '<li><a id="'.$v['id'].'" box="'.$v['box'].'"><i class="fa fa-'.$v['icon_2'].' '.$v['color'].' fa-fw pull-right"></i>'.$v['name'].'</a></li>';
  4177. }
  4178. $result .= '</ul></div></div>';
  4179. return $result;
  4180. }
  4181. }
  4182. function buildMenu($array){
  4183. if (is_array($array) || is_object($array)){
  4184. $result = '<div class="settingsList">';
  4185. foreach($array as $k => $v){
  4186. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4187. continue;
  4188. }
  4189. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4190. continue;
  4191. }
  4192. $result .= '
  4193. <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">
  4194. <i class="mdi mdi-'.$v['icon_1'].' fa-fw pull-left" style="padding-left: '.$v['padding'].'px;font-size: 30px"></i>
  4195. <p class="" style="text-align: center;direction: rtl;display:none;margin: 2px;"><strong>'.$v['name'].'</strong></p>
  4196. </button>
  4197. ';
  4198. }
  4199. $result .= '</div>';
  4200. return $result;
  4201. }
  4202. }
  4203. function requestInvite($email, $username){
  4204. //sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null){
  4205. //orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  4206. 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."));
  4207. }
  4208. function errormessage($msg) {
  4209. echo "<div style=\"margin-top: 50px;\">";
  4210. echo "<span style=\"color:#d89334;\">error </span>";
  4211. echo $msg;
  4212. echo "</div>";
  4213. }
  4214. function getOrgUsers(){
  4215. $file_db = DATABASE_LOCATION."users.db";
  4216. if(file_exists($file_db)){
  4217. $conn = new PDO("sqlite:$file_db") or die("1");
  4218. $result = $conn->query('SELECT * FROM users');
  4219. $conn = null;
  4220. if (is_array($result) || is_object($result)){
  4221. foreach($result as $k => $v){
  4222. $return[$v['username']] = $v['email'];
  4223. }
  4224. return $return;
  4225. }
  4226. }
  4227. }
  4228. function getEmails($type = 'org'){
  4229. if($type == 'plex'){
  4230. $emails = array_merge(libraryList()['both'],getOrgUsers());
  4231. }elseif($type == 'emby'){
  4232. $emails = getOrgUsers();
  4233. }else{
  4234. $emails = getOrgUsers();
  4235. }
  4236. return $emails;
  4237. }
  4238. function printEmails($emails){
  4239. $result = '';
  4240. foreach($emails as $k => $v){
  4241. $result .= '<option value="'.$v.'">'.$k.'</option>';
  4242. }
  4243. return $result;
  4244. }
  4245. function massEmail($to, $subject, $message){
  4246. if (!isset($GLOBALS['file_db'])) {
  4247. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  4248. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  4249. }
  4250. sendEmail(null, null, $subject, orgEmail("Message From Admin", "Important Information", "There", $message, null, null, "Thank You!", "Thanks for taking the time to read this message from me."),$GLOBALS['USER']->adminEmail,$to);
  4251. }
  4252. function q2a($q){
  4253. if (is_array($q) || is_object($q)){
  4254. foreach ($q as $k => $v){
  4255. $a[$k] = $v;
  4256. }
  4257. if(!empty($a)){
  4258. return $a;
  4259. }
  4260. }
  4261. }
  4262. function getOmbiToken($username, $password){
  4263. $headers = array(
  4264. "Accept" => "application/json",
  4265. "Content-Type" => "application/json"
  4266. );
  4267. $json = array(
  4268. "username" => $username,
  4269. "password" => $password,
  4270. "rememberMe" => "true",
  4271. );
  4272. $api = curl_post(OMBIURL."/api/v1/Token", $json, $headers);
  4273. return json_decode($api['content'], true)['access_token'];
  4274. }
  4275. function ombiAction($id, $action, $type){
  4276. $headers = array(
  4277. "Accept" => "application/json",
  4278. "Content-Type" => "application/json",
  4279. "Apikey" => OMBIKEY
  4280. );
  4281. $body = array(
  4282. 'id' => $id,
  4283. );
  4284. switch ($type) {
  4285. case 'season':
  4286. case 'tv':
  4287. $type = 'tv';
  4288. break;
  4289. default:
  4290. $type = 'movie';
  4291. break;
  4292. }
  4293. switch ($action) {
  4294. case 'approve':
  4295. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/approve", $body, $headers);
  4296. break;
  4297. case 'deny':
  4298. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/deny", $body, $headers);
  4299. break;
  4300. case 'delete':
  4301. $api = curl_delete(OMBIURL."/api/v1/Request/".$type."/".$id, $headers);
  4302. break;
  4303. default:
  4304. # code...
  4305. break;
  4306. }
  4307. switch ($api['http_code']['http_code']){
  4308. case 401:
  4309. writeLog("error", "OMBI: Invalid API KEY");
  4310. return false;
  4311. break;
  4312. case 200:
  4313. writeLog("success", "OMBI: action completed successfully");
  4314. return true;
  4315. break;
  4316. default:
  4317. writeLog("error", "OMBI: unknown error with request [type: $type | action: $action | id: $id]");
  4318. return false;
  4319. }
  4320. //return (!empty($result) ? $result : null );
  4321. }
  4322. function getOmbiRequests($type = "both"){
  4323. $headers = array(
  4324. "Accept" => "application/json",
  4325. "Apikey" => OMBIKEY,
  4326. );
  4327. $requests = array();
  4328. switch ($type) {
  4329. case 'movie':
  4330. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4331. break;
  4332. case 'tv':
  4333. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4334. break;
  4335. default:
  4336. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4337. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4338. break;
  4339. }
  4340. if(isset($movie)){
  4341. foreach ($movie as $key => $value) {
  4342. $requests['movie'][] = array(
  4343. 'id' => $value['theMovieDbId'],
  4344. 'title' => $value['title'],
  4345. 'poster' => (strpos($value['posterPath'], "http") !== false) ? $value['posterPath'] : 'https://image.tmdb.org/t/p/w300/'.$value['posterPath'],
  4346. 'approved' => $value['approved'],
  4347. 'available' => $value['available'],
  4348. 'denied' => $value['denied'],
  4349. 'deniedReason' => $value['deniedReason'],
  4350. 'user' => $value['requestedUser']['userName'],
  4351. 'request_id' => $value['id'],
  4352. );
  4353. }
  4354. }
  4355. if(isset($tv) && (is_array($tv) || is_object($tv))){
  4356. foreach ($tv as $key => $value) {
  4357. $requests['tv'][] = array(
  4358. 'id' => $value['tvDbId'],
  4359. 'title' => $value['title'],
  4360. 'poster' => $value['posterPath'],
  4361. 'approved' => $value['childRequests'][0]['approved'],
  4362. 'available' => $key['childRequests'][0]['available'],
  4363. 'denied' => $key['childRequests'][0]['denied'],
  4364. 'deniedReason' => $key['childRequests'][0]['deniedReason'],
  4365. 'user' => $value['childRequests'][0]['requestedUser']['userName'],
  4366. 'request_id' => $value['id'],
  4367. );
  4368. }
  4369. }
  4370. return (empty($requests)) ? '' : $requests;
  4371. }
  4372. function convertOmbiString($type, $value){
  4373. switch ($type) {
  4374. case 'approved':
  4375. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4376. $string['icon'] = ($value) ? 'mdi mdi-check' : 'mdi mdi-clock';
  4377. $string['color'] = ($value) ? 'green-bg' : 'yellow-bg';
  4378. break;
  4379. case 'available':
  4380. $string['string'] = ($value) ? 'Available' : 'Not Downloaded';
  4381. $string['icon'] = ($value) ? 'mdi mdi-server' : 'mdi mdi-server-off';
  4382. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4383. break;
  4384. case 'denied':
  4385. $string['string'] = ($value) ? 'Denied' : 'Approved';
  4386. $string['icon'] = ($value) ? 'mdi mdi-emoticon-sad' : 'mdi mdi-emoticon-happy';
  4387. $string['color'] = ($value) ? 'red-bg' : 'green-bg';
  4388. break;
  4389. case 'status':
  4390. switch ($value) {
  4391. case '1':
  4392. $string['string'] = 'Denied';
  4393. $string['icon'] = 'mdi mdi-window-close';
  4394. $string['color'] = 'red-bg';
  4395. break;
  4396. case '2':
  4397. $string['string'] = 'Approved';
  4398. $string['icon'] = 'mdi mdi-check';
  4399. $string['color'] = 'green-bg';
  4400. break;
  4401. case '3':
  4402. $string['string'] = 'Not Approved';
  4403. $string['icon'] = 'mdi mdi-clock';
  4404. $string['color'] = 'yellow-bg';
  4405. break;
  4406. default:
  4407. # code...
  4408. break;
  4409. }
  4410. break;
  4411. default:
  4412. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4413. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4414. break;
  4415. }
  4416. return $string;
  4417. }
  4418. function buildOmbiItem($type, $group, $user, $request){
  4419. if (is_array($request) || is_object($request)){
  4420. $actions = '';
  4421. if($request['denied']){
  4422. $status = 1;
  4423. //$actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4424. }else{
  4425. if($request['approved']){
  4426. $status = 2;
  4427. }else{
  4428. $status = 3;
  4429. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4430. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="deny"><a class="requestAction" href="javascript:void(0)">Deny</a></li>';
  4431. }
  4432. }
  4433. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="delete"><a class="requestAction" href="javascript:void(0)">Delete</a></li>';
  4434. if(isset($group) && $group == 'admin'){
  4435. return '
  4436. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4437. <div class="requestOptions">
  4438. <div class="btn-group transparent" role="group">
  4439. <button type="button" class="btn waves btn-success btn-sm dropdown-toggle waves-effect waves-float transparent" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="mdi mdi-dots-vertical mdi-24px"></i></button>
  4440. <ul class="dropdown-menu"><h6 class="text-center">'.$request['user'].'</h6>'.$actions.'</ul>
  4441. </div>
  4442. </div>
  4443. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4444. <div class="requestBottom text-center">
  4445. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4446. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4447. </div>
  4448. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4449. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4450. </div>
  4451. </div>
  4452. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4453. </div>';
  4454. }elseif(isset($group) && $group == 'user'){
  4455. if(strtolower($request['user']) == strtolower($user)){
  4456. return '
  4457. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4458. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4459. <div class="requestBottom text-center">
  4460. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4461. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4462. </div>
  4463. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4464. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4465. </div>
  4466. </div>
  4467. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4468. </div>';
  4469. }
  4470. }
  4471. }
  4472. }
  4473. function buildOmbiList($group, $user){
  4474. $requests = array();
  4475. $openTab = 'true';
  4476. $movieList = getOmbiRequests('movie');
  4477. $tvList = getOmbiRequests('tv');
  4478. if (is_array($movieList) || is_object($movieList)){
  4479. foreach ($movieList['movie'] as $request) {
  4480. $requests[] = buildOmbiItem('movie', $group, $user, $request);
  4481. }
  4482. }
  4483. if (is_array($tvList) || is_object($tvList)){
  4484. foreach ($tvList['tv'] as $request) {
  4485. $requests[] = buildOmbiItem('season', $group, $user, $request);
  4486. }
  4487. }
  4488. return outputOmbiRequests("Requested Content", $requests, "
  4489. setInterval(function() {
  4490. $('<div></div>').load('ajax.php?a=ombi-requests',function() {
  4491. var element = $(this).find('#recentRequests');
  4492. var loadedID = element.attr('id');
  4493. $('#recentRequests').replaceWith(element);
  4494. console.log('Loaded updated: '+loadedID);
  4495. loadSlick();
  4496. });
  4497. }, ".RECENTREFRESH.");
  4498. ", false);
  4499. }
  4500. function outputOmbiRequests($header = "Requested Content", $items, $script = false, $array) {
  4501. $hideMenu = '<div class="pull-right"><div class="btn-group" role="group"><button type="button" class="btn waves btn-default btn-sm dropdown-toggle waves-effect waves-float" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Filter &nbsp;<span class="caret"></span></button><ul style="right:0; left: auto" class="dropdown-menu filter-request-event">';
  4502. if(preg_grep("/item-movie-Approved/", $items)){
  4503. $hideMenu .= '<li data-filter="item-movie-Approved" data-name="Approved Movies" data-filter-on="false"><a class="js-filter-movie" href="javascript:void(0)">Approved Movies</a></li>';
  4504. }
  4505. if(preg_grep("/item-movie-Approval-Pending/", $items)){
  4506. $hideMenu .= '<li data-filter="item-movie-Approval-Pending" data-name="Approval Pending Movies" data-filter-on="false"><a class="js-filter-movie" href="javascript:void(0)">Approval Pending Movies</a></li>';
  4507. }
  4508. if(preg_grep("/item-season-Approved/", $items)){
  4509. $hideMenu .= '<li data-filter="item-season-Approved" data-name="Approved TV Shows" data-filter-on="false"><a class="js-filter-season" href="javascript:void(0)">Approved Shows</a></li>';
  4510. }
  4511. if(preg_grep("/item-season-Approval-Pending/", $items)){
  4512. $hideMenu .= '<li data-filter="item-season-Approval-Pending" data-name="Approval Pending TV Shows" data-filter-on="false"><a class="js-filter-season" href="javascript:void(0)">Approval Pending Shows</a></li>';
  4513. }
  4514. $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>';
  4515. $hideMenu .= '</ul></div></div>';
  4516. // If None Populate Empty Item
  4517. if (!count($items)) {
  4518. return '<div id="recentRequests" class="content-box box-shadow big-box"><h5 class="text-center">'.$header.'</h5><p class="text-center">No Requests Found</p></div>';
  4519. }else{
  4520. $className = str_replace(' ', '', $header);
  4521. return '<div id="recentRequests" class="content-box box-shadow big-box"><h5 id="requestContent-title" style="margin-bottom: -20px" class="text-center">'.$header.'</h5><div class="recentHeader inbox-pagination '.$className.'">'.$hideMenu.'</div><br/><br/><div class="recentItems-request" data-name="'.$className.'">'.implode('',$items).'</div></div>'.($script?'<script>'.$script.'</script>':'');
  4522. }
  4523. }
  4524. function buildHomepageSettings(){
  4525. $homepageOrder = homepageOrder();
  4526. $homepageList = '<h4>Drag Homepage Items to Order Them</h4><div id="homepage-items" class="external-events">';
  4527. $inputList = '<div id="homepage-values" class="row">';
  4528. foreach ($homepageOrder as $key => $val) {
  4529. switch ($key) {
  4530. case 'homepageOrdercustomhtml':
  4531. $class = 'palette-Deep-Purple-100 bg gray';
  4532. $image = 'images/html.png';
  4533. if(empty(HOMEPAGECUSTOMHTML1)){
  4534. $class .= ' faded';
  4535. }
  4536. break;
  4537. case 'homepageOrdernotice':
  4538. $class = 'palette-Cyan-A400 bg gray';
  4539. $image = 'images/pin.png';
  4540. if(empty(HOMEPAGENOTICETITLE) && empty(HOMEPAGENOTICEMESSAGE)){
  4541. $class .= ' faded';
  4542. }
  4543. break;
  4544. case 'homepageOrderspeedtest':
  4545. $class = 'red-bg';
  4546. $image = 'images/settings/full-color/png/64px/speedometer.png';
  4547. if(SPEEDTEST !== "true"){
  4548. $class .= ' faded';
  4549. }
  4550. break;
  4551. case 'homepageOrdernzbget':
  4552. $class = 'green-bg';
  4553. $image = 'images/nzbget.png';
  4554. if(empty(NZBGETURL)){
  4555. $class .= ' faded';
  4556. }
  4557. break;
  4558. case 'homepageOrdersabnzbd':
  4559. $class = 'yellow-bg';
  4560. $image = 'images/sabnzbd.png';
  4561. if(empty(SABNZBDURL)){
  4562. $class .= ' faded';
  4563. }
  4564. break;
  4565. case 'homepageOrderplexsearch':
  4566. case 'homepageOrderplexnowplaying':
  4567. case 'homepageOrderplexrecent':
  4568. case 'homepageOrderplexplaylist':
  4569. $class = 'palette-Amber-A700 bg gray';
  4570. $image = 'images/plex.png';
  4571. if(empty(PLEXURL)){
  4572. $class .= ' faded';
  4573. }
  4574. break;
  4575. case 'homepageOrderembynowplaying':
  4576. case 'homepageOrderembyrecent':
  4577. $class = 'palette-Green-A700 bg gray';
  4578. $image = 'images/emby.png';
  4579. if(empty(EMBYURL)){
  4580. $class .= ' faded';
  4581. }
  4582. break;
  4583. case 'homepageOrderombi':
  4584. $class = 'orange-bg';
  4585. $image = 'images/ombi.png';
  4586. if(empty(OMBIURL)){
  4587. $class .= ' faded';
  4588. }
  4589. break;
  4590. case 'homepageOrdercalendar':
  4591. $class = 'palette-Blue-400 bg gray';
  4592. $image = 'images/calendar.png';
  4593. if(SONARRURL == "" && RADARRURL == "" && HEADPHONESURL == "" && SICKRAGEURL == "" && COUCHURL == "" ){
  4594. $class .= ' faded';
  4595. }
  4596. break;
  4597. default:
  4598. $class = 'blue-bg';
  4599. $image = '';
  4600. break;
  4601. }
  4602. $homepageList .= '
  4603. <div class="col-md-3 sort-homepage"><div class="fc-event '.$class.'">
  4604. <span class="ordinal-position text-uppercase badge badge-gray" data-link="'.$key.'" style="float:left;width: 30px;">'.$val.'</span>
  4605. &nbsp; '.strtoupper(substr($key, 13)).'
  4606. <span class="remove-event"><img style="width: 22px;" src="'.$image.'"></span>
  4607. </div></div>';
  4608. $inputList .= '<input type="hidden" name="'.$key.'">';
  4609. }
  4610. $homepageList .= '</div>';
  4611. $inputList .= '</div>';
  4612. return $homepageList.$inputList;
  4613. }
  4614. function buildHomepage($group, $user){
  4615. $homepageOrder = homepageOrder();
  4616. $homepageBuilt = '';
  4617. foreach ($homepageOrder as $key => $value) {
  4618. $homepageBuilt .= buildHomepageItem($key, $group, $user);
  4619. }
  4620. return $homepageBuilt;
  4621. }
  4622. function realSize($bytes, $decimals = 2) {
  4623. $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
  4624. $factor = floor((strlen($bytes) - 1) / 3);
  4625. return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' '.@$size[$factor];
  4626. }
  4627. function buildHomepageItem($homepageItem, $group, $user){
  4628. $homepageItemBuilt = '';
  4629. switch ($homepageItem) {
  4630. case 'homepageOrderplexsearch':
  4631. if((qualifyUser(PLEXSEARCHAUTH) && PLEXSEARCH == "true" && qualifyUser(PLEXHOMEAUTH))) {
  4632. $homepageItemBuilt .= '
  4633. <div id="searchPlexRow" class="row">
  4634. <div class="col-lg-12">
  4635. <div class="content-box box-shadow big-box todo-list">
  4636. <form id="plexSearchForm" onsubmit="return false;" autocomplete="off">
  4637. <div class="">
  4638. <div class="input-group">
  4639. <div style="border-radius: 25px 0 0 25px; border:0" class="input-group-addon gray-bg"><i class="fa fa-search white"></i></div>
  4640. <input id="searchInput" type="text" style="border-radius: 0;" autocomplete="off" name="search-title" class="form-control input-group-addon gray-bg" placeholder="Media Search">
  4641. <div id="clearSearch" style="border-radius: 0 25px 25px 0;border:0; cursor: pointer;" class="input-group-addon gray-bg"><i class="fa fa-close white"></i></div>
  4642. <button style="display:none" id="plexSearchForm_submit" class="btn btn-primary waves"></button>
  4643. </div>
  4644. </div>
  4645. </form>
  4646. <div id="resultshere" class="table-responsive"></div>
  4647. </div>
  4648. </div>
  4649. </div>
  4650. ';
  4651. }
  4652. break;
  4653. case 'homepageOrdercustomhtml':
  4654. if (qualifyUser(HOMEPAGECUSTOMHTML1AUTH) && HOMEPAGECUSTOMHTML1) {
  4655. $homepageItemBuilt .= "<div>" . HOMEPAGECUSTOMHTML1 . "</div>";
  4656. }
  4657. break;
  4658. case 'homepageOrdernotice':
  4659. if (qualifyUser(HOMEPAGENOTICEAUTH) && HOMEPAGENOTICETITLE && HOMEPAGENOTICETYPE && HOMEPAGENOTICEMESSAGE && HOMEPAGENOTICELAYOUT) {
  4660. $homepageItemBuilt .= buildHomepageNotice(HOMEPAGENOTICELAYOUT, HOMEPAGENOTICETYPE, HOMEPAGENOTICETITLE, HOMEPAGENOTICEMESSAGE);
  4661. }
  4662. break;
  4663. case 'homepageOrderspeedtest':
  4664. if(SPEEDTEST == "true" && qualifyUser(SPEEDTESTAUTH)){
  4665. $homepageItemBuilt .= '
  4666. <style type="text/css">
  4667. .flash {
  4668. animation: flash 0.6s linear infinite;
  4669. }
  4670. @keyframes flash {
  4671. 0% { opacity: 0.6; }
  4672. 50% { opacity: 1; }
  4673. }
  4674. </style>
  4675. <script type="text/javascript">
  4676. var w = null
  4677. function runTest() {
  4678. document.getElementById("startBtn").style.display = "none"
  4679. document.getElementById("testArea").style.display = ""
  4680. document.getElementById("abortBtn").style.display = ""
  4681. w = new Worker("bower_components/speed/speedtest_worker.js")
  4682. var interval = setInterval(function () { w.postMessage("status") }, 100)
  4683. w.onmessage = function (event) {
  4684. var data = event.data.split(";")
  4685. var status = Number(data[0])
  4686. var dl = document.getElementById("download")
  4687. var ul = document.getElementById("upload")
  4688. var ping = document.getElementById("ping")
  4689. var jitter = document.getElementById("jitter")
  4690. dl.className = status === 1 ? "w-name flash" : "w-name"
  4691. ping.className = status === 2 ? "w-name flash" : "w-name"
  4692. jitter.className = ul.className = status === 3 ? "w-name flash" : "w-name"
  4693. if (status >= 4) {
  4694. clearInterval(interval)
  4695. document.getElementById("abortBtn").style.display = "none"
  4696. document.getElementById("startBtn").style.display = ""
  4697. w = null
  4698. }
  4699. if (status === 5) {
  4700. document.getElementById("testArea").style.display = "none"
  4701. }
  4702. dl.textContent = data[1] + " Mbit/s";
  4703. $("#downloadpercent").attr("style", "width: " + data[1] + "%;");
  4704. $("#uploadpercent").attr("style", "width: " + data[2] + "%;");
  4705. $("#pingpercent").attr("style", "width: " + data[3] + "%;");
  4706. $("#jitterpercent").attr("style", "width: " + data[5] + "%;");
  4707. ul.textContent = data[2] + " Mbit/s";
  4708. ping.textContent = data[3] + " ms";
  4709. jitter.textContent = data[5] + " ms";
  4710. }
  4711. w.postMessage(\'start {"telemetry_level":"basic"}\')
  4712. //w.postMessage("start")
  4713. }
  4714. function abortTest() {
  4715. if (w) w.postMessage("abort")
  4716. }
  4717. </script>
  4718. <div class="row" id="testArea" style="display:none">
  4719. <div class="test col-sm-3 col-lg-3">
  4720. <div class="content-box ultra-widget green-bg" data-counter="">
  4721. <div id="downloadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4722. <div class="w-content">
  4723. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-download"></i></div>
  4724. <div class="w-descr left pull-left text-center">
  4725. <span class="testName text-uppercase w-name">Download</span>
  4726. <br>
  4727. <span class="w-name counter" id="download" ></span>
  4728. </div>
  4729. </div>
  4730. </div>
  4731. </div>
  4732. <div class="test col-sm-3 col-lg-3">
  4733. <div class="content-box ultra-widget red-bg" data-counter="">
  4734. <div id="uploadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4735. <div class="w-content">
  4736. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-upload"></i></div>
  4737. <div class="w-descr left pull-left text-center">
  4738. <span class="testName text-uppercase w-name">Upload</span>
  4739. <br>
  4740. <span class="w-name counter" id="upload" ></span>
  4741. </div>
  4742. </div>
  4743. </div>
  4744. </div>
  4745. <div class="test col-sm-3 col-lg-3">
  4746. <div class="content-box ultra-widget yellow-bg" data-counter="">
  4747. <div id="pingpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4748. <div class="w-content">
  4749. <div class="w-icon right pull-right"><i class="mdi mdi-timer"></i></div>
  4750. <div class="w-descr left pull-left text-center">
  4751. <span class="testName text-uppercase w-name">Latency</span>
  4752. <br>
  4753. <span class="w-name counter" id="ping" ></span>
  4754. </div>
  4755. </div>
  4756. </div>
  4757. </div>
  4758. <div class="test col-sm-3 col-lg-3">
  4759. <div class="content-box ultra-widget blue-bg" data-counter="">
  4760. <div id="jitterpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4761. <div class="w-content">
  4762. <div class="w-icon right pull-right"><i class="mdi mdi-pulse"></i></div>
  4763. <div class="w-descr left pull-left text-center">
  4764. <span class="testName text-uppercase w-name">Jitter</span>
  4765. <br>
  4766. <span class="w-name counter" id="jitter" ></span>
  4767. </div>
  4768. </div>
  4769. </div>
  4770. </div>
  4771. <br/>
  4772. </div>
  4773. <div id="abortBtn" class="row" style="display: none" onclick="javascript:abortTest()">
  4774. <div class="col-lg-12">
  4775. <div class="content-box red-bg" style="cursor: pointer;">
  4776. <h1 style="margin: 10px" class="text-uppercase text-center">Abort Speed Test</h1>
  4777. <div class="clearfix"></div>
  4778. </div>
  4779. </div>
  4780. </div>
  4781. <div id="startBtn" class="row" onclick="javascript:runTest()">
  4782. <div class="col-lg-12">
  4783. <div class="content-box green-bg" style="cursor: pointer;">
  4784. <h1 style="margin: 10px" class="text-uppercase text-center">Run Speed Test</h1>
  4785. <div class="clearfix"></div>
  4786. </div>
  4787. </div>
  4788. </div>
  4789. ';
  4790. }
  4791. break;
  4792. case 'homepageOrdernzbget':
  4793. if(NZBGETURL != "" && qualifyUser(NZBGETHOMEAUTH)){
  4794. $homepageItemBuilt .= buildDownloader('nzbget');
  4795. }
  4796. break;
  4797. case 'homepageOrdersabnzbd':
  4798. if(SABNZBDURL != "" && qualifyUser(SABNZBDHOMEAUTH)) {
  4799. $homepageItemBuilt .= buildDownloader('sabnzbd');
  4800. }
  4801. break;
  4802. case 'homepageOrderplexnowplaying':
  4803. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4804. if(qualifyUser(PLEXPLAYINGNOWAUTH) && PLEXPLAYINGNOW == "true"){
  4805. $homepageItemBuilt .= '<div id="plexRowNowPlaying" class="row">';
  4806. $homepageItemBuilt .= getPlexStreams(12, PLEXSHOWNAMES, $group);
  4807. $homepageItemBuilt .= '</div>';
  4808. }
  4809. }
  4810. break;
  4811. case 'homepageOrderplexrecent':
  4812. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4813. if(qualifyUser(PLEXRECENTMOVIEAUTH) && PLEXRECENTMOVIE == "true" || qualifyUser(PLEXRECENTTVAUTH) && PLEXRECENTTV == "true" || qualifyUser(PLEXRECENTMUSICAUTH) && PLEXRECENTMUSIC == "true"){
  4814. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  4815. $homepageItemBuilt .= '<div id="plexRow" class="row"><div class="col-lg-12">';
  4816. $homepageItemBuilt .= getPlexRecent($plexArray);
  4817. $homepageItemBuilt .= '</div></div>';
  4818. }
  4819. }
  4820. break;
  4821. case 'homepageOrderplexplaylist':
  4822. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4823. if(qualifyUser(PLEXPLAYLISTSAUTH) && PLEXPLAYLISTS == "true"){
  4824. $homepageItemBuilt .= '<div id="plexPlaylists" class="row"><div class="col-lg-12">';
  4825. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  4826. $homepageItemBuilt .= getPlexPlaylists($plexArray);
  4827. $homepageItemBuilt .= '</div> </div>';
  4828. }
  4829. }
  4830. break;
  4831. case 'homepageOrderembynowplaying':
  4832. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  4833. if(qualifyUser(EMBYPLAYINGNOWAUTH) && EMBYPLAYINGNOW == "true"){
  4834. $homepageItemBuilt .= '<div id="embyRowNowPlaying" class="row">';
  4835. $homepageItemBuilt .= getEmbyStreams(12, EMBYSHOWNAMES, $group);
  4836. $homepageItemBuilt .= '</div>';
  4837. }
  4838. }
  4839. break;
  4840. case 'homepageOrderembyrecent':
  4841. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  4842. if(qualifyUser(EMBYRECENTMOVIEAUTH) && EMBYRECENTMOVIE == "true" || qualifyUser(EMBYRECENTTVAUTH) && EMBYRECENTTV == "true" || qualifyUser(EMBYRECENTMUSICAUTH) && EMBYRECENTMUSIC == "true"){
  4843. $embyArray = array("Movie" => EMBYRECENTMOVIE, "Episode" => EMBYRECENTTV, "MusicAlbum" => EMBYRECENTMUSIC, "Series" => EMBYRECENTTV);
  4844. $homepageItemBuilt .= '<div id="embyRow" class="row"><div class="col-lg-12">';
  4845. $homepageItemBuilt .= getEmbyRecent($embyArray);
  4846. $homepageItemBuilt .= '</div></div>';
  4847. }
  4848. }
  4849. break;
  4850. case 'homepageOrderombi':
  4851. if (qualifyUser(OMBIAUTH) && OMBIURL) {
  4852. $homepageItemBuilt .= '<div id="ombiRequests" class="row"><div class="col-lg-12">';
  4853. $homepageItemBuilt .= buildOmbiList($group, $user);
  4854. $homepageItemBuilt .= '</div></div>';
  4855. }
  4856. break;
  4857. case 'homepageOrdercalendar':
  4858. if ((SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)) || (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)) || (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)) || (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)) || (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH))) {
  4859. $calendarItems = '';
  4860. if(RADARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="film" href="javascript:void(0)">Movies</a></li>'; }
  4861. if(SONARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="tv" href="javascript:void(0)">TV Shows</a></li>'; }
  4862. if(HEADPHONESURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="music" href="javascript:void(0)">Music</a></li>'; }
  4863. $homepageItemBuilt .= '
  4864. <div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">
  4865. <div class="col-lg-12 content-form form-inline">
  4866. <div class="form-group pull-right">
  4867. <span class="swal-legend label label-primary well-sm">Legend</span>&nbsp;
  4868. <div class="btn-group" role="group">
  4869. <button id="calendarSelected" style="margin-right: 0px;" type="button" class="btn waves btn-default btn-sm dropdown-toggle waves-effect waves-float" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">View All&nbsp;<span class="caret"></span></button>
  4870. <ul style="right:0; left: auto" class="dropdown-menu">
  4871. <li><a class="calendarOption" calendarOption="all" href="javascript:void(0)">View All</a></li>
  4872. '.$calendarItems.'
  4873. </ul>
  4874. </div>
  4875. </div>
  4876. </div>
  4877. </div>
  4878. <div id="calendarRow" class="row">
  4879. <div class="col-lg-12">
  4880. <div id="calendar" class="fc-calendar box-shadow fc fc-ltr fc-unthemed"></div>
  4881. </div>
  4882. </div>
  4883. ';
  4884. }
  4885. break;
  4886. default:
  4887. # code...
  4888. break;
  4889. }
  4890. return $homepageItemBuilt;
  4891. }
  4892. function buildDownloader($name){
  4893. return '
  4894. <div id="downloadClientRow" class="row">
  4895. <div class="col-xs-12 col-md-12">
  4896. <div class="content-box">
  4897. <div class="tabbable panel with-nav-tabs panel-default">
  4898. <div class="panel-heading">
  4899. <div class="content-tools i-block pull-right">
  4900. <a id="getDownloader" class="repeat-btn">
  4901. <i class="fa fa-repeat"></i>
  4902. </a>
  4903. </div>
  4904. <h3 class="pull-left">'.strtoupper($name).'</h3>
  4905. <ul class="nav nav-tabs pull-right">
  4906. <li class="active"><a href="#downloadQueue-'.$name.'" data-toggle="tab" aria-expanded="true">'.translate("QUEUE").'</a></li>
  4907. <li class=""><a href="#downloadHistory-'.$name.'" data-toggle="tab" aria-expanded="false">'.translate("HISTORY").'</a></li>
  4908. </ul>
  4909. <div class="clearfix"></div>
  4910. </div>
  4911. <div class="panel-body">
  4912. <div class="tab-content">
  4913. <div class="tab-pane fade active in" id="downloadQueue-'.$name.'">
  4914. <div class="table-responsive" style="max-height: 300px">
  4915. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  4916. <thead>
  4917. <tr>
  4918. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  4919. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  4920. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  4921. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  4922. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  4923. </tr>
  4924. </thead>
  4925. <tbody class="dl-queue '.$name.'"></tbody>
  4926. </table>
  4927. </div>
  4928. </div>
  4929. <div class="tab-pane fade" id="downloadHistory-'.$name.'">
  4930. <div class="table-responsive" style="max-height: 300px">
  4931. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  4932. <thead>
  4933. <tr>
  4934. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  4935. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  4936. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  4937. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  4938. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  4939. </tr>
  4940. </thead>
  4941. <tbody class="dl-history '.$name.'"></tbody>
  4942. </table>
  4943. </div>
  4944. </div>
  4945. </div>
  4946. </div>
  4947. </div>
  4948. </div>
  4949. </div>
  4950. </div>';
  4951. }
  4952. class Mobile_Detect
  4953. {
  4954. /**
  4955. * Mobile detection type.
  4956. *
  4957. * @deprecated since version 2.6.9
  4958. */
  4959. const DETECTION_TYPE_MOBILE = 'mobile';
  4960. /**
  4961. * Extended detection type.
  4962. *
  4963. * @deprecated since version 2.6.9
  4964. */
  4965. const DETECTION_TYPE_EXTENDED = 'extended';
  4966. /**
  4967. * A frequently used regular expression to extract version #s.
  4968. *
  4969. * @deprecated since version 2.6.9
  4970. */
  4971. const VER = '([\w._\+]+)';
  4972. /**
  4973. * Top-level device.
  4974. */
  4975. const MOBILE_GRADE_A = 'A';
  4976. /**
  4977. * Mid-level device.
  4978. */
  4979. const MOBILE_GRADE_B = 'B';
  4980. /**
  4981. * Low-level device.
  4982. */
  4983. const MOBILE_GRADE_C = 'C';
  4984. /**
  4985. * Stores the version number of the current release.
  4986. */
  4987. const VERSION = '2.8.26';
  4988. /**
  4989. * A type for the version() method indicating a string return value.
  4990. */
  4991. const VERSION_TYPE_STRING = 'text';
  4992. /**
  4993. * A type for the version() method indicating a float return value.
  4994. */
  4995. const VERSION_TYPE_FLOAT = 'float';
  4996. /**
  4997. * A cache for resolved matches
  4998. * @var array
  4999. */
  5000. protected $cache = array();
  5001. /**
  5002. * The User-Agent HTTP header is stored in here.
  5003. * @var string
  5004. */
  5005. protected $userAgent = null;
  5006. /**
  5007. * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
  5008. * @var array
  5009. */
  5010. protected $httpHeaders = array();
  5011. /**
  5012. * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
  5013. * @var array
  5014. */
  5015. protected $cloudfrontHeaders = array();
  5016. /**
  5017. * The matching Regex.
  5018. * This is good for debug.
  5019. * @var string
  5020. */
  5021. protected $matchingRegex = null;
  5022. /**
  5023. * The matches extracted from the regex expression.
  5024. * This is good for debug.
  5025. * @var string
  5026. */
  5027. protected $matchesArray = null;
  5028. /**
  5029. * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
  5030. *
  5031. * @deprecated since version 2.6.9
  5032. *
  5033. * @var string
  5034. */
  5035. protected $detectionType = self::DETECTION_TYPE_MOBILE;
  5036. /**
  5037. * HTTP headers that trigger the 'isMobile' detection
  5038. * to be true.
  5039. *
  5040. * @var array
  5041. */
  5042. protected static $mobileHeaders = array(
  5043. 'HTTP_ACCEPT' => array('matches' => array(
  5044. // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
  5045. 'application/x-obml2d',
  5046. // BlackBerry devices.
  5047. 'application/vnd.rim.html',
  5048. 'text/vnd.wap.wml',
  5049. 'application/vnd.wap.xhtml+xml'
  5050. )),
  5051. 'HTTP_X_WAP_PROFILE' => null,
  5052. 'HTTP_X_WAP_CLIENTID' => null,
  5053. 'HTTP_WAP_CONNECTION' => null,
  5054. 'HTTP_PROFILE' => null,
  5055. // Reported by Opera on Nokia devices (eg. C3).
  5056. 'HTTP_X_OPERAMINI_PHONE_UA' => null,
  5057. 'HTTP_X_NOKIA_GATEWAY_ID' => null,
  5058. 'HTTP_X_ORANGE_ID' => null,
  5059. 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
  5060. 'HTTP_X_HUAWEI_USERID' => null,
  5061. // Reported by Windows Smartphones.
  5062. 'HTTP_UA_OS' => null,
  5063. // Reported by Verizon, Vodafone proxy system.
  5064. 'HTTP_X_MOBILE_GATEWAY' => null,
  5065. // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
  5066. 'HTTP_X_ATT_DEVICEID' => null,
  5067. // Seen this on a HTC.
  5068. 'HTTP_UA_CPU' => array('matches' => array('ARM')),
  5069. );
  5070. /**
  5071. * List of mobile devices (phones).
  5072. *
  5073. * @var array
  5074. */
  5075. protected static $phoneDevices = array(
  5076. 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
  5077. 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
  5078. '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',
  5079. 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
  5080. // @todo: Is 'Dell Streak' a tablet or a phone? ;)
  5081. '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',
  5082. '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',
  5083. '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',
  5084. '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)',
  5085. 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
  5086. 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
  5087. 'NokiaLumia' => 'Lumia [0-9]{3,4}',
  5088. // http://www.micromaxinfo.com/mobiles/smartphones
  5089. // Added because the codes might conflict with Acer Tablets.
  5090. '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',
  5091. // @todo Complete the regex.
  5092. 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
  5093. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
  5094. // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
  5095. // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
  5096. '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',
  5097. // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
  5098. 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
  5099. // http://fr.wikomobile.com
  5100. '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',
  5101. 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
  5102. // Added simvalley mobile just for fun. They have some interesting devices.
  5103. // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
  5104. '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',
  5105. // Wolfgang - a brand that is sold by Aldi supermarkets.
  5106. // http://www.wolfgangmobile.com/
  5107. 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
  5108. 'Alcatel' => 'Alcatel',
  5109. 'Nintendo' => 'Nintendo 3DS',
  5110. // http://en.wikipedia.org/wiki/Amoi
  5111. 'Amoi' => 'Amoi',
  5112. // http://en.wikipedia.org/wiki/INQ
  5113. 'INQ' => 'INQ',
  5114. // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
  5115. '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',
  5116. );
  5117. /**
  5118. * List of tablet devices.
  5119. *
  5120. * @var array
  5121. */
  5122. protected static $tabletDevices = array(
  5123. // @todo: check for mobile friendly emails topic.
  5124. 'iPad' => 'iPad|iPad.*Mobile',
  5125. // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
  5126. // @see #442
  5127. 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
  5128. '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.
  5129. // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
  5130. '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)',
  5131. // Only the Surface tablets with Windows RT are considered mobile.
  5132. // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
  5133. 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
  5134. // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
  5135. 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
  5136. // Watch out for PadFone, see #132.
  5137. // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
  5138. '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',
  5139. 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
  5140. 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
  5141. 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
  5142. 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
  5143. // http://www.acer.ro/ac/ro/RO/content/drivers
  5144. // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
  5145. // http://us.acer.com/ac/en/US/content/group/tablets
  5146. // http://www.acer.de/ac/de/DE/content/models/tablets/
  5147. // Can conflict with Micromax and Motorola phones codes.
  5148. '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',
  5149. // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
  5150. // http://us.toshiba.com/tablets/tablet-finder
  5151. // http://www.toshiba.co.jp/regza/tablet/
  5152. 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
  5153. // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
  5154. // http://www.lg.com/us/tablets
  5155. 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
  5156. 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
  5157. // Prestigio Tablets http://www.prestigio.com/support
  5158. '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',
  5159. // http://support.lenovo.com/en_GB/downloads/default.page?#
  5160. '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|)',
  5161. // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
  5162. 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
  5163. // http://www.yarvik.com/en/matrix/tablets/
  5164. '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',
  5165. 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
  5166. 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
  5167. // http://www.intenso.de/kategorie_en.php?kategorie=33
  5168. // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
  5169. 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
  5170. // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
  5171. 'IRUTablet' => 'M702pro',
  5172. 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
  5173. // http://www.e-boda.ro/tablete-pc.html
  5174. 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
  5175. // http://www.allview.ro/produse/droseries/lista-tablete-pc/
  5176. 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
  5177. // http://wiki.archosfans.com/index.php?title=Main_Page
  5178. // @note Rewrite the regex format after we add more UAs.
  5179. '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',
  5180. // http://www.ainol.com/plugin.php?identifier=ainol&module=product
  5181. 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
  5182. 'NokiaLumiaTablet' => 'Lumia 2520',
  5183. // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
  5184. // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
  5185. // http://www.sony.jp/support/tablet/
  5186. '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',
  5187. // 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
  5188. 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
  5189. // db + http://www.cube-tablet.com/buy-products.html
  5190. 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
  5191. // http://www.cobyusa.com/?p=pcat&pcat_id=3001
  5192. 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
  5193. // http://www.match.net.cn/products.asp
  5194. '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',
  5195. // http://www.msi.com/support
  5196. // @todo Research the Windows Tablets.
  5197. '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',
  5198. // @todo http://www.kyoceramobile.com/support/drivers/
  5199. // 'KyoceraTablet' => null,
  5200. // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
  5201. // 'IntextTablet' => null,
  5202. // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
  5203. // http://www.imp3.net/14/show.php?itemid=20454
  5204. 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
  5205. // http://www.rock-chips.com/index.php?do=prod&pid=2
  5206. 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
  5207. // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
  5208. 'FlyTablet' => 'IQ310|Fly Vision',
  5209. // http://www.bqreaders.com/gb/tablets-prices-sale.html
  5210. 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
  5211. // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
  5212. // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
  5213. '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',
  5214. // Nec or Medias Tab
  5215. 'NecTablet' => '\bN-06D|\bN-08D',
  5216. // Pantech Tablets: http://www.pantechusa.com/phones/
  5217. 'PantechTablet' => 'Pantech.*P4100',
  5218. // Broncho Tablets: http://www.broncho.cn/ (hard to find)
  5219. 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
  5220. // http://versusuk.com/support.html
  5221. 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
  5222. // http://www.zync.in/index.php/our-products/tablet-phablets
  5223. 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
  5224. // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
  5225. 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
  5226. // https://www.nabitablet.com/
  5227. 'NabiTablet' => 'Android.*\bNabi',
  5228. 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
  5229. // French Danew Tablets http://www.danew.com/produits-tablette.php
  5230. 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
  5231. // Texet Tablets and Readers http://www.texet.ru/tablet/
  5232. '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',
  5233. // Avoid detecting 'PLAYSTATION 3' as mobile.
  5234. 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
  5235. // http://www.trekstor.de/surftabs.html
  5236. 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
  5237. // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
  5238. 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
  5239. // http://www.advandigital.com/index.php?link=content-product&jns=JP001
  5240. // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
  5241. '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 ',
  5242. // http://www.danytech.com/category/tablet-pc
  5243. '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',
  5244. // http://www.galapad.net/product.html
  5245. 'GalapadTablet' => 'Android.*\bG1\b',
  5246. // http://www.micromaxinfo.com/tablet/funbook
  5247. 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
  5248. // http://www.karbonnmobiles.com/products_tablet.php
  5249. 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
  5250. // http://www.myallfine.com/Products.asp
  5251. 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
  5252. // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
  5253. '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',
  5254. // http://www.yonesnav.com/products/products.php
  5255. 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
  5256. // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
  5257. // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
  5258. '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',
  5259. // http://www.gloryunion.cn/products.asp
  5260. // http://www.allwinnertech.com/en/apply/mobile.html
  5261. // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
  5262. // @todo: Softwiner tablets?
  5263. // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
  5264. '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
  5265. // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
  5266. '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',
  5267. // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
  5268. // @todo: add more tests.
  5269. 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
  5270. // http://hclmetablet.com/India/index.php
  5271. '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',
  5272. // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
  5273. 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
  5274. // http://www.visture.com/index.asp
  5275. 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
  5276. // http://www.mijncresta.nl/tablet
  5277. 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
  5278. // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
  5279. 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
  5280. // Concorde tab
  5281. 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
  5282. // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
  5283. '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',
  5284. // Modecom Tablets - http://www.modecom.eu/tablets/portal/
  5285. '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',
  5286. // Vonino Tablets - http://www.vonino.eu/tablets
  5287. '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',
  5288. // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
  5289. 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
  5290. // Storex Tablets - http://storex.fr/espace_client/support.html
  5291. // @note: no need to add all the tablet codes since they are guided by the first regex.
  5292. 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
  5293. // Generic Vodafone tablets.
  5294. 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
  5295. // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
  5296. // Aka: http://www.essentielb.fr/
  5297. 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
  5298. // Ross & Moor - http://ross-moor.ru/
  5299. 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
  5300. // i-mobile http://product.i-mobilephone.com/Mobile_Device
  5301. 'iMobileTablet' => 'i-mobile i-note',
  5302. // http://www.tolino.de/de/vergleichen/
  5303. 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
  5304. // AudioSonic - a Kmart brand
  5305. // 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
  5306. 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
  5307. // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
  5308. // @todo: add them gradually to avoid conflicts.
  5309. 'AMPETablet' => 'Android.* A78 ',
  5310. // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
  5311. 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
  5312. // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
  5313. 'TecnoTablet' => 'TECNO P9',
  5314. // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
  5315. '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',
  5316. // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
  5317. '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)',
  5318. // http://www.intracon.eu/tablet
  5319. 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
  5320. // http://www.xoro.de/produkte/
  5321. // @note: Might be the same brand with 'Simply tablets'
  5322. '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',
  5323. // http://www1.viewsonic.com/products/computing/tablets/
  5324. 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
  5325. // http://www.odys.de/web/internet-tablet_en.html
  5326. 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
  5327. // http://www.captiva-power.de/products.html#tablets-en
  5328. 'CaptivaTablet' => 'CAPTIVA PAD',
  5329. // IconBIT - http://www.iconbit.com/products/tablets/
  5330. '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',
  5331. // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
  5332. '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',
  5333. // Onda - http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
  5334. '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]+',
  5335. 'JaytechTablet' => 'TPC-PA762',
  5336. 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
  5337. // http://www.digma.ru/support/download/
  5338. // @todo: Ebooks also (if requested)
  5339. 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
  5340. // http://www.evolioshop.com/ro/tablete-pc.html
  5341. // http://www.evolio.ro/support/downloads_static.html?cat=2
  5342. // @todo: Research some more
  5343. 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
  5344. // @todo http://www.lavamobiles.com/tablets-data-cards
  5345. 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
  5346. // http://www.breezetablet.com/
  5347. 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
  5348. // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
  5349. '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',
  5350. // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
  5351. 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
  5352. // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
  5353. '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',
  5354. // http://www.mi.com/en
  5355. 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
  5356. // http://www.nbru.cn/index.html
  5357. 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
  5358. // http://navroad.com/products/produkty/tablety/
  5359. // http://navroad.com/products/produkty/tablety/
  5360. 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
  5361. // http://leader-online.com/new_site/product-category/tablets/
  5362. // http://www.leader-online.net.au/List/Tablet
  5363. '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',
  5364. // http://www.datawind.com/ubislate/
  5365. 'UbislateTablet' => 'UbiSlate[\s]?7C',
  5366. // http://www.pocketbook-int.com/ru/support
  5367. 'PocketBookTablet' => 'Pocketbook',
  5368. // http://www.kocaso.com/product_tablet.html
  5369. 'KocasoTablet' => '\b(TB-1207)\b',
  5370. // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
  5371. 'HisenseTablet' => '\b(F5281|E2371)\b',
  5372. // http://www.tesco.com/direct/hudl/
  5373. 'Hudl' => 'Hudl HT7S3|Hudl 2',
  5374. // http://www.telstra.com.au/home-phone/thub-2/
  5375. 'TelstraTablet' => 'T-Hub2',
  5376. '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'
  5377. );
  5378. /**
  5379. * List of mobile Operating Systems.
  5380. *
  5381. * @var array
  5382. */
  5383. protected static $operatingSystems = array(
  5384. 'AndroidOS' => 'Android',
  5385. 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
  5386. 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
  5387. 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
  5388. // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
  5389. 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
  5390. // @reference: http://en.wikipedia.org/wiki/Windows_Phone
  5391. // http://wifeng.cn/?r=blog&a=view&id=106
  5392. // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
  5393. // http://msdn.microsoft.com/library/ms537503.aspx
  5394. // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
  5395. 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
  5396. 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
  5397. // http://en.wikipedia.org/wiki/MeeGo
  5398. // @todo: research MeeGo in UAs
  5399. 'MeeGoOS' => 'MeeGo',
  5400. // http://en.wikipedia.org/wiki/Maemo
  5401. // @todo: research Maemo in UAs
  5402. 'MaemoOS' => 'Maemo',
  5403. 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
  5404. 'webOS' => 'webOS|hpwOS',
  5405. 'badaOS' => '\bBada\b',
  5406. 'BREWOS' => 'BREW',
  5407. );
  5408. /**
  5409. * List of mobile User Agents.
  5410. *
  5411. * IMPORTANT: This is a list of only mobile browsers.
  5412. * Mobile Detect 2.x supports only mobile browsers,
  5413. * it was never designed to detect all browsers.
  5414. * The change will come in 2017 in the 3.x release for PHP7.
  5415. *
  5416. * @var array
  5417. */
  5418. protected static $browsers = array(
  5419. //'Vivaldi' => 'Vivaldi',
  5420. // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
  5421. 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
  5422. 'Dolfin' => '\bDolfin\b',
  5423. 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
  5424. 'Skyfire' => 'Skyfire',
  5425. 'Edge' => 'Mobile Safari/[.0-9]* Edge',
  5426. 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
  5427. 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
  5428. 'Bolt' => 'bolt',
  5429. 'TeaShark' => 'teashark',
  5430. 'Blazer' => 'Blazer',
  5431. // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
  5432. 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
  5433. // http://en.wikipedia.org/wiki/Midori_(web_browser)
  5434. //'Midori' => 'midori',
  5435. //'Tizen' => 'Tizen',
  5436. 'UCBrowser' => 'UC.*Browser|UCWEB',
  5437. 'baiduboxapp' => 'baiduboxapp',
  5438. 'baidubrowser' => 'baidubrowser',
  5439. // https://github.com/serbanghita/Mobile-Detect/issues/7
  5440. 'DiigoBrowser' => 'DiigoBrowser',
  5441. // http://www.puffinbrowser.com/index.php
  5442. 'Puffin' => 'Puffin',
  5443. // http://mercury-browser.com/index.html
  5444. 'Mercury' => '\bMercury\b',
  5445. // http://en.wikipedia.org/wiki/Obigo_Browser
  5446. 'ObigoBrowser' => 'Obigo',
  5447. // http://en.wikipedia.org/wiki/NetFront
  5448. 'NetFront' => 'NF-Browser',
  5449. // @reference: http://en.wikipedia.org/wiki/Minimo
  5450. // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
  5451. 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
  5452. // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
  5453. 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
  5454. );
  5455. /**
  5456. * Utilities.
  5457. *
  5458. * @var array
  5459. */
  5460. protected static $utilities = array(
  5461. // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
  5462. // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
  5463. // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
  5464. // https://developers.facebook.com/docs/sharing/best-practices
  5465. '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',
  5466. 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
  5467. 'DesktopMode' => 'WPDesktop',
  5468. 'TV' => 'SonyDTV|HbbTV', // experimental
  5469. 'WebKit' => '(webkit)[ /]([\w.]+)',
  5470. // @todo: Include JXD consoles.
  5471. 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
  5472. 'Watch' => 'SM-V700',
  5473. );
  5474. /**
  5475. * All possible HTTP headers that represent the
  5476. * User-Agent string.
  5477. *
  5478. * @var array
  5479. */
  5480. protected static $uaHttpHeaders = array(
  5481. // The default User-Agent string.
  5482. 'HTTP_USER_AGENT',
  5483. // Header can occur on devices using Opera Mini.
  5484. 'HTTP_X_OPERAMINI_PHONE_UA',
  5485. // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
  5486. 'HTTP_X_DEVICE_USER_AGENT',
  5487. 'HTTP_X_ORIGINAL_USER_AGENT',
  5488. 'HTTP_X_SKYFIRE_PHONE',
  5489. 'HTTP_X_BOLT_PHONE_UA',
  5490. 'HTTP_DEVICE_STOCK_UA',
  5491. 'HTTP_X_UCBROWSER_DEVICE_UA'
  5492. );
  5493. /**
  5494. * The individual segments that could exist in a User-Agent string. VER refers to the regular
  5495. * expression defined in the constant self::VER.
  5496. *
  5497. * @var array
  5498. */
  5499. protected static $properties = array(
  5500. // Build
  5501. 'Mobile' => 'Mobile/[VER]',
  5502. 'Build' => 'Build/[VER]',
  5503. 'Version' => 'Version/[VER]',
  5504. 'VendorID' => 'VendorID/[VER]',
  5505. // Devices
  5506. 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
  5507. 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
  5508. 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
  5509. //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
  5510. 'Kindle' => 'Kindle/[VER]',
  5511. // Browser
  5512. 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
  5513. 'Coast' => array('Coast/[VER]'),
  5514. 'Dolfin' => 'Dolfin/[VER]',
  5515. // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
  5516. 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
  5517. 'Fennec' => 'Fennec/[VER]',
  5518. // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  5519. // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
  5520. 'Edge' => 'Edge/[VER]',
  5521. 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
  5522. // http://en.wikipedia.org/wiki/NetFront
  5523. 'NetFront' => 'NetFront/[VER]',
  5524. 'NokiaBrowser' => 'NokiaBrowser/[VER]',
  5525. 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
  5526. 'Opera Mini' => 'Opera Mini/[VER]',
  5527. 'Opera Mobi' => 'Version/[VER]',
  5528. 'UC Browser' => 'UC Browser[VER]',
  5529. 'MQQBrowser' => 'MQQBrowser/[VER]',
  5530. 'MicroMessenger' => 'MicroMessenger/[VER]',
  5531. 'baiduboxapp' => 'baiduboxapp/[VER]',
  5532. 'baidubrowser' => 'baidubrowser/[VER]',
  5533. 'SamsungBrowser' => 'SamsungBrowser/[VER]',
  5534. 'Iron' => 'Iron/[VER]',
  5535. // @note: Safari 7534.48.3 is actually Version 5.1.
  5536. // @note: On BlackBerry the Version is overwriten by the OS.
  5537. 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
  5538. 'Skyfire' => 'Skyfire/[VER]',
  5539. 'Tizen' => 'Tizen/[VER]',
  5540. 'Webkit' => 'webkit[ /][VER]',
  5541. 'PaleMoon' => 'PaleMoon/[VER]',
  5542. // Engine
  5543. 'Gecko' => 'Gecko/[VER]',
  5544. 'Trident' => 'Trident/[VER]',
  5545. 'Presto' => 'Presto/[VER]',
  5546. 'Goanna' => 'Goanna/[VER]',
  5547. // OS
  5548. 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
  5549. 'Android' => 'Android [VER]',
  5550. 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
  5551. 'BREW' => 'BREW [VER]',
  5552. 'Java' => 'Java/[VER]',
  5553. // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
  5554. // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
  5555. 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
  5556. 'Windows Phone' => 'Windows Phone [VER]',
  5557. 'Windows CE' => 'Windows CE/[VER]',
  5558. // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
  5559. 'Windows NT' => 'Windows NT [VER]',
  5560. 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
  5561. 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
  5562. );
  5563. /**
  5564. * Construct an instance of this class.
  5565. *
  5566. * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
  5567. * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
  5568. * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
  5569. * from the $headers array instead.
  5570. */
  5571. public function __construct(
  5572. array $headers = null,
  5573. $userAgent = null
  5574. ) {
  5575. $this->setHttpHeaders($headers);
  5576. $this->setUserAgent($userAgent);
  5577. }
  5578. /**
  5579. * Get the current script version.
  5580. * This is useful for the demo.php file,
  5581. * so people can check on what version they are testing
  5582. * for mobile devices.
  5583. *
  5584. * @return string The version number in semantic version format.
  5585. */
  5586. public static function getScriptVersion()
  5587. {
  5588. return self::VERSION;
  5589. }
  5590. /**
  5591. * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
  5592. *
  5593. * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
  5594. * the headers. The default null is left for backwards compatibility.
  5595. */
  5596. public function setHttpHeaders($httpHeaders = null)
  5597. {
  5598. // use global _SERVER if $httpHeaders aren't defined
  5599. if (!is_array($httpHeaders) || !count($httpHeaders)) {
  5600. $httpHeaders = $_SERVER;
  5601. }
  5602. // clear existing headers
  5603. $this->httpHeaders = array();
  5604. // Only save HTTP headers. In PHP land, that means only _SERVER vars that
  5605. // start with HTTP_.
  5606. foreach ($httpHeaders as $key => $value) {
  5607. if (substr($key, 0, 5) === 'HTTP_') {
  5608. $this->httpHeaders[$key] = $value;
  5609. }
  5610. }
  5611. // In case we're dealing with CloudFront, we need to know.
  5612. $this->setCfHeaders($httpHeaders);
  5613. }
  5614. /**
  5615. * Retrieves the HTTP headers.
  5616. *
  5617. * @return array
  5618. */
  5619. public function getHttpHeaders()
  5620. {
  5621. return $this->httpHeaders;
  5622. }
  5623. /**
  5624. * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
  5625. * Simply null is returned.
  5626. *
  5627. * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
  5628. * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
  5629. * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
  5630. *
  5631. * @return string|null The value of the header.
  5632. */
  5633. public function getHttpHeader($header)
  5634. {
  5635. // are we using PHP-flavored headers?
  5636. if (strpos($header, '_') === false) {
  5637. $header = str_replace('-', '_', $header);
  5638. $header = strtoupper($header);
  5639. }
  5640. // test the alternate, too
  5641. $altHeader = 'HTTP_' . $header;
  5642. //Test both the regular and the HTTP_ prefix
  5643. if (isset($this->httpHeaders[$header])) {
  5644. return $this->httpHeaders[$header];
  5645. } elseif (isset($this->httpHeaders[$altHeader])) {
  5646. return $this->httpHeaders[$altHeader];
  5647. }
  5648. return null;
  5649. }
  5650. public function getMobileHeaders()
  5651. {
  5652. return self::$mobileHeaders;
  5653. }
  5654. /**
  5655. * Get all possible HTTP headers that
  5656. * can contain the User-Agent string.
  5657. *
  5658. * @return array List of HTTP headers.
  5659. */
  5660. public function getUaHttpHeaders()
  5661. {
  5662. return self::$uaHttpHeaders;
  5663. }
  5664. /**
  5665. * Set CloudFront headers
  5666. * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
  5667. *
  5668. * @param array $cfHeaders List of HTTP headers
  5669. *
  5670. * @return boolean If there were CloudFront headers to be set
  5671. */
  5672. public function setCfHeaders($cfHeaders = null) {
  5673. // use global _SERVER if $cfHeaders aren't defined
  5674. if (!is_array($cfHeaders) || !count($cfHeaders)) {
  5675. $cfHeaders = $_SERVER;
  5676. }
  5677. // clear existing headers
  5678. $this->cloudfrontHeaders = array();
  5679. // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
  5680. // start with cloudfront-.
  5681. $response = false;
  5682. foreach ($cfHeaders as $key => $value) {
  5683. if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
  5684. $this->cloudfrontHeaders[strtoupper($key)] = $value;
  5685. $response = true;
  5686. }
  5687. }
  5688. return $response;
  5689. }
  5690. /**
  5691. * Retrieves the cloudfront headers.
  5692. *
  5693. * @return array
  5694. */
  5695. public function getCfHeaders()
  5696. {
  5697. return $this->cloudfrontHeaders;
  5698. }
  5699. /**
  5700. * Set the User-Agent to be used.
  5701. *
  5702. * @param string $userAgent The user agent string to set.
  5703. *
  5704. * @return string|null
  5705. */
  5706. public function setUserAgent($userAgent = null)
  5707. {
  5708. // Invalidate cache due to #375
  5709. $this->cache = array();
  5710. if (false === empty($userAgent)) {
  5711. return $this->userAgent = $userAgent;
  5712. } else {
  5713. $this->userAgent = null;
  5714. foreach ($this->getUaHttpHeaders() as $altHeader) {
  5715. if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
  5716. $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
  5717. }
  5718. }
  5719. if (!empty($this->userAgent)) {
  5720. return $this->userAgent = trim($this->userAgent);
  5721. }
  5722. }
  5723. if (count($this->getCfHeaders()) > 0) {
  5724. return $this->userAgent = 'Amazon CloudFront';
  5725. }
  5726. return $this->userAgent = null;
  5727. }
  5728. /**
  5729. * Retrieve the User-Agent.
  5730. *
  5731. * @return string|null The user agent if it's set.
  5732. */
  5733. public function getUserAgent()
  5734. {
  5735. return $this->userAgent;
  5736. }
  5737. /**
  5738. * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
  5739. * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
  5740. *
  5741. * @deprecated since version 2.6.9
  5742. *
  5743. * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
  5744. * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
  5745. */
  5746. public function setDetectionType($type = null)
  5747. {
  5748. if ($type === null) {
  5749. $type = self::DETECTION_TYPE_MOBILE;
  5750. }
  5751. if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
  5752. return;
  5753. }
  5754. $this->detectionType = $type;
  5755. }
  5756. public function getMatchingRegex()
  5757. {
  5758. return $this->matchingRegex;
  5759. }
  5760. public function getMatchesArray()
  5761. {
  5762. return $this->matchesArray;
  5763. }
  5764. /**
  5765. * Retrieve the list of known phone devices.
  5766. *
  5767. * @return array List of phone devices.
  5768. */
  5769. public static function getPhoneDevices()
  5770. {
  5771. return self::$phoneDevices;
  5772. }
  5773. /**
  5774. * Retrieve the list of known tablet devices.
  5775. *
  5776. * @return array List of tablet devices.
  5777. */
  5778. public static function getTabletDevices()
  5779. {
  5780. return self::$tabletDevices;
  5781. }
  5782. /**
  5783. * Alias for getBrowsers() method.
  5784. *
  5785. * @return array List of user agents.
  5786. */
  5787. public static function getUserAgents()
  5788. {
  5789. return self::getBrowsers();
  5790. }
  5791. /**
  5792. * Retrieve the list of known browsers. Specifically, the user agents.
  5793. *
  5794. * @return array List of browsers / user agents.
  5795. */
  5796. public static function getBrowsers()
  5797. {
  5798. return self::$browsers;
  5799. }
  5800. /**
  5801. * Retrieve the list of known utilities.
  5802. *
  5803. * @return array List of utilities.
  5804. */
  5805. public static function getUtilities()
  5806. {
  5807. return self::$utilities;
  5808. }
  5809. /**
  5810. * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
  5811. *
  5812. * @deprecated since version 2.6.9
  5813. *
  5814. * @return array All the rules (but not extended).
  5815. */
  5816. public static function getMobileDetectionRules()
  5817. {
  5818. static $rules;
  5819. if (!$rules) {
  5820. $rules = array_merge(
  5821. self::$phoneDevices,
  5822. self::$tabletDevices,
  5823. self::$operatingSystems,
  5824. self::$browsers
  5825. );
  5826. }
  5827. return $rules;
  5828. }
  5829. /**
  5830. * Method gets the mobile detection rules + utilities.
  5831. * The reason this is separate is because utilities rules
  5832. * don't necessary imply mobile. This method is used inside
  5833. * the new $detect->is('stuff') method.
  5834. *
  5835. * @deprecated since version 2.6.9
  5836. *
  5837. * @return array All the rules + extended.
  5838. */
  5839. public function getMobileDetectionRulesExtended()
  5840. {
  5841. static $rules;
  5842. if (!$rules) {
  5843. // Merge all rules together.
  5844. $rules = array_merge(
  5845. self::$phoneDevices,
  5846. self::$tabletDevices,
  5847. self::$operatingSystems,
  5848. self::$browsers,
  5849. self::$utilities
  5850. );
  5851. }
  5852. return $rules;
  5853. }
  5854. /**
  5855. * Retrieve the current set of rules.
  5856. *
  5857. * @deprecated since version 2.6.9
  5858. *
  5859. * @return array
  5860. */
  5861. public function getRules()
  5862. {
  5863. if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
  5864. return self::getMobileDetectionRulesExtended();
  5865. } else {
  5866. return self::getMobileDetectionRules();
  5867. }
  5868. }
  5869. /**
  5870. * Retrieve the list of mobile operating systems.
  5871. *
  5872. * @return array The list of mobile operating systems.
  5873. */
  5874. public static function getOperatingSystems()
  5875. {
  5876. return self::$operatingSystems;
  5877. }
  5878. /**
  5879. * Check the HTTP headers for signs of mobile.
  5880. * This is the fastest mobile check possible; it's used
  5881. * inside isMobile() method.
  5882. *
  5883. * @return bool
  5884. */
  5885. public function checkHttpHeadersForMobile()
  5886. {
  5887. foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
  5888. if (isset($this->httpHeaders[$mobileHeader])) {
  5889. if (is_array($matchType['matches'])) {
  5890. foreach ($matchType['matches'] as $_match) {
  5891. if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
  5892. return true;
  5893. }
  5894. }
  5895. return false;
  5896. } else {
  5897. return true;
  5898. }
  5899. }
  5900. }
  5901. return false;
  5902. }
  5903. /**
  5904. * Magic overloading method.
  5905. *
  5906. * @method boolean is[...]()
  5907. * @param string $name
  5908. * @param array $arguments
  5909. * @return mixed
  5910. * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
  5911. */
  5912. public function __call($name, $arguments)
  5913. {
  5914. // make sure the name starts with 'is', otherwise
  5915. if (substr($name, 0, 2) !== 'is') {
  5916. throw new BadMethodCallException("No such method exists: $name");
  5917. }
  5918. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5919. $key = substr($name, 2);
  5920. return $this->matchUAAgainstKey($key);
  5921. }
  5922. /**
  5923. * Find a detection rule that matches the current User-agent.
  5924. *
  5925. * @param null $userAgent deprecated
  5926. * @return boolean
  5927. */
  5928. protected function matchDetectionRulesAgainstUA($userAgent = null)
  5929. {
  5930. // Begin general search.
  5931. foreach ($this->getRules() as $_regex) {
  5932. if (empty($_regex)) {
  5933. continue;
  5934. }
  5935. if ($this->match($_regex, $userAgent)) {
  5936. return true;
  5937. }
  5938. }
  5939. return false;
  5940. }
  5941. /**
  5942. * Search for a certain key in the rules array.
  5943. * If the key is found then try to match the corresponding
  5944. * regex against the User-Agent.
  5945. *
  5946. * @param string $key
  5947. *
  5948. * @return boolean
  5949. */
  5950. protected function matchUAAgainstKey($key)
  5951. {
  5952. // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
  5953. $key = strtolower($key);
  5954. if (false === isset($this->cache[$key])) {
  5955. // change the keys to lower case
  5956. $_rules = array_change_key_case($this->getRules());
  5957. if (false === empty($_rules[$key])) {
  5958. $this->cache[$key] = $this->match($_rules[$key]);
  5959. }
  5960. if (false === isset($this->cache[$key])) {
  5961. $this->cache[$key] = false;
  5962. }
  5963. }
  5964. return $this->cache[$key];
  5965. }
  5966. /**
  5967. * Check if the device is mobile.
  5968. * Returns true if any type of mobile device detected, including special ones
  5969. * @param null $userAgent deprecated
  5970. * @param null $httpHeaders deprecated
  5971. * @return bool
  5972. */
  5973. public function isMobile($userAgent = null, $httpHeaders = null)
  5974. {
  5975. if ($httpHeaders) {
  5976. $this->setHttpHeaders($httpHeaders);
  5977. }
  5978. if ($userAgent) {
  5979. $this->setUserAgent($userAgent);
  5980. }
  5981. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  5982. if ($this->getUserAgent() === 'Amazon CloudFront') {
  5983. $cfHeaders = $this->getCfHeaders();
  5984. if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
  5985. return true;
  5986. }
  5987. }
  5988. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5989. if ($this->checkHttpHeadersForMobile()) {
  5990. return true;
  5991. } else {
  5992. return $this->matchDetectionRulesAgainstUA();
  5993. }
  5994. }
  5995. /**
  5996. * Check if the device is a tablet.
  5997. * Return true if any type of tablet device is detected.
  5998. *
  5999. * @param string $userAgent deprecated
  6000. * @param array $httpHeaders deprecated
  6001. * @return bool
  6002. */
  6003. public function isTablet($userAgent = null, $httpHeaders = null)
  6004. {
  6005. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6006. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6007. $cfHeaders = $this->getCfHeaders();
  6008. if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
  6009. return true;
  6010. }
  6011. }
  6012. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6013. foreach (self::$tabletDevices as $_regex) {
  6014. if ($this->match($_regex, $userAgent)) {
  6015. return true;
  6016. }
  6017. }
  6018. return false;
  6019. }
  6020. /**
  6021. * This method checks for a certain property in the
  6022. * userAgent.
  6023. * @todo: The httpHeaders part is not yet used.
  6024. *
  6025. * @param string $key
  6026. * @param string $userAgent deprecated
  6027. * @param string $httpHeaders deprecated
  6028. * @return bool|int|null
  6029. */
  6030. public function is($key, $userAgent = null, $httpHeaders = null)
  6031. {
  6032. // Set the UA and HTTP headers only if needed (eg. batch mode).
  6033. if ($httpHeaders) {
  6034. $this->setHttpHeaders($httpHeaders);
  6035. }
  6036. if ($userAgent) {
  6037. $this->setUserAgent($userAgent);
  6038. }
  6039. $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
  6040. return $this->matchUAAgainstKey($key);
  6041. }
  6042. /**
  6043. * Some detection rules are relative (not standard),
  6044. * because of the diversity of devices, vendors and
  6045. * their conventions in representing the User-Agent or
  6046. * the HTTP headers.
  6047. *
  6048. * This method will be used to check custom regexes against
  6049. * the User-Agent string.
  6050. *
  6051. * @param $regex
  6052. * @param string $userAgent
  6053. * @return bool
  6054. *
  6055. * @todo: search in the HTTP headers too.
  6056. */
  6057. public function match($regex, $userAgent = null)
  6058. {
  6059. $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
  6060. // If positive match is found, store the results for debug.
  6061. if ($match) {
  6062. $this->matchingRegex = $regex;
  6063. $this->matchesArray = $matches;
  6064. }
  6065. return $match;
  6066. }
  6067. /**
  6068. * Get the properties array.
  6069. *
  6070. * @return array
  6071. */
  6072. public static function getProperties()
  6073. {
  6074. return self::$properties;
  6075. }
  6076. /**
  6077. * Prepare the version number.
  6078. *
  6079. * @todo Remove the error supression from str_replace() call.
  6080. *
  6081. * @param string $ver The string version, like "2.6.21.2152";
  6082. *
  6083. * @return float
  6084. */
  6085. public function prepareVersionNo($ver)
  6086. {
  6087. $ver = str_replace(array('_', ' ', '/'), '.', $ver);
  6088. $arrVer = explode('.', $ver, 2);
  6089. if (isset($arrVer[1])) {
  6090. $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
  6091. }
  6092. return (float) implode('.', $arrVer);
  6093. }
  6094. /**
  6095. * Check the version of the given property in the User-Agent.
  6096. * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
  6097. *
  6098. * @param string $propertyName The name of the property. See self::getProperties() array
  6099. * keys for all possible properties.
  6100. * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
  6101. * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
  6102. * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
  6103. * invalid parameter will default to the this type as well.
  6104. *
  6105. * @return string|float The version of the property we are trying to extract.
  6106. */
  6107. public function version($propertyName, $type = self::VERSION_TYPE_STRING)
  6108. {
  6109. if (empty($propertyName)) {
  6110. return false;
  6111. }
  6112. // set the $type to the default if we don't recognize the type
  6113. if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
  6114. $type = self::VERSION_TYPE_STRING;
  6115. }
  6116. $properties = self::getProperties();
  6117. // Check if the property exists in the properties array.
  6118. if (true === isset($properties[$propertyName])) {
  6119. // Prepare the pattern to be matched.
  6120. // Make sure we always deal with an array (string is converted).
  6121. $properties[$propertyName] = (array) $properties[$propertyName];
  6122. foreach ($properties[$propertyName] as $propertyMatchString) {
  6123. $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
  6124. // Identify and extract the version.
  6125. preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
  6126. if (false === empty($match[1])) {
  6127. $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
  6128. return $version;
  6129. }
  6130. }
  6131. }
  6132. return false;
  6133. }
  6134. /**
  6135. * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
  6136. *
  6137. * @return string One of the self::MOBILE_GRADE_* constants.
  6138. */
  6139. public function mobileGrade()
  6140. {
  6141. $isMobile = $this->isMobile();
  6142. if (
  6143. // 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)
  6144. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6145. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6146. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6147. // 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)
  6148. // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
  6149. // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
  6150. // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
  6151. ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
  6152. // 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)
  6153. $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
  6154. // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
  6155. $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
  6156. // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
  6157. $this->match('Playbook.*Tablet') ||
  6158. // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
  6159. ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
  6160. // Palm WebOS 3.0 - Tested on HP TouchPad
  6161. $this->match('hp.*TouchPad') ||
  6162. // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
  6163. ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
  6164. // Chrome for Android - Tested on Android 4.0, 4.1 device
  6165. ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
  6166. // Skyfire 4.1 - Tested on Android 2.3 device
  6167. ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6168. // Opera Mobile 11.5-12: Tested on Android 2.3
  6169. ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
  6170. // Meego 1.2 - Tested on Nokia 950 and N9
  6171. $this->is('MeeGoOS') ||
  6172. // Tizen (pre-release) - Tested on early hardware
  6173. $this->is('Tizen') ||
  6174. // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
  6175. // @todo: more tests here!
  6176. $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
  6177. // UC Browser - Tested on Android 2.3 device
  6178. ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6179. // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
  6180. ( $this->match('Kindle Fire') ||
  6181. $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
  6182. // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
  6183. $this->is('AndroidOS') && $this->is('NookTablet') ||
  6184. // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
  6185. $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
  6186. // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
  6187. $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
  6188. // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
  6189. $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
  6190. // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
  6191. $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
  6192. // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
  6193. $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
  6194. ){
  6195. return self::MOBILE_GRADE_A;
  6196. }
  6197. if (
  6198. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
  6199. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
  6200. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
  6201. // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
  6202. $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
  6203. //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
  6204. ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
  6205. ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
  6206. // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
  6207. $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
  6208. // @todo: report this (tested on Nokia N71)
  6209. $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
  6210. ){
  6211. return self::MOBILE_GRADE_B;
  6212. }
  6213. if (
  6214. // Blackberry 4.x - Tested on the Curve 8330
  6215. $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
  6216. // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
  6217. $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
  6218. // Tested on original iPhone (3.1), iPhone 3 (3.2)
  6219. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6220. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6221. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6222. // Internet Explorer 7 and older - Tested on Windows XP
  6223. $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
  6224. ){
  6225. return self::MOBILE_GRADE_C;
  6226. }
  6227. // All older smartphone platforms and featurephones - Any device that doesn't support media queries
  6228. // will receive the basic, C grade experience.
  6229. return self::MOBILE_GRADE_C;
  6230. }
  6231. }
  6232. $mobileDetect = new Mobile_Detect;
  6233. $userDevice = ($mobileDetect->isMobile() ? ($mobileDetect->isTablet() ? 'tablet' : 'phone') : 'computer');
  6234. function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  6235. $path = getServerPath();
  6236. return '
  6237. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6238. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  6239. <head>
  6240. <!--[if gte mso 9]><xml>
  6241. <o:OfficeDocumentSettings>
  6242. <o:AllowPNG/>
  6243. <o:PixelsPerInch>96</o:PixelsPerInch>
  6244. </o:OfficeDocumentSettings>
  6245. </xml><![endif]-->
  6246. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6247. <meta name="viewport" content="width=device-width">
  6248. <!--[if !mso]><!-->
  6249. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6250. <!--<![endif]-->
  6251. <title></title>
  6252. <!--[if !mso]><!-- -->
  6253. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
  6254. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  6255. <!--<![endif]-->
  6256. <style type="text/css" id="media-query">
  6257. body {
  6258. margin: 0;
  6259. padding: 0;
  6260. }
  6261. table,
  6262. tr,
  6263. td {
  6264. vertical-align: top;
  6265. border-collapse: collapse;
  6266. }
  6267. .ie-browser table,
  6268. .mso-container table {
  6269. table-layout: fixed;
  6270. }
  6271. * {
  6272. line-height: inherit;
  6273. }
  6274. a[x-apple-data-detectors=true] {
  6275. color: inherit !important;
  6276. text-decoration: none !important;
  6277. }
  6278. [owa] .img-container div,
  6279. [owa] .img-container button {
  6280. display: block !important;
  6281. }
  6282. [owa] .fullwidth button {
  6283. width: 100% !important;
  6284. }
  6285. [owa] .block-grid .col {
  6286. display: table-cell;
  6287. float: none !important;
  6288. vertical-align: top;
  6289. }
  6290. .ie-browser .num12,
  6291. .ie-browser .block-grid,
  6292. [owa] .num12,
  6293. [owa] .block-grid {
  6294. width: 615px !important;
  6295. }
  6296. .ExternalClass,
  6297. .ExternalClass p,
  6298. .ExternalClass span,
  6299. .ExternalClass font,
  6300. .ExternalClass td,
  6301. .ExternalClass div {
  6302. line-height: 100%;
  6303. }
  6304. .ie-browser .mixed-two-up .num4,
  6305. [owa] .mixed-two-up .num4 {
  6306. width: 204px !important;
  6307. }
  6308. .ie-browser .mixed-two-up .num8,
  6309. [owa] .mixed-two-up .num8 {
  6310. width: 408px !important;
  6311. }
  6312. .ie-browser .block-grid.two-up .col,
  6313. [owa] .block-grid.two-up .col {
  6314. width: 307px !important;
  6315. }
  6316. .ie-browser .block-grid.three-up .col,
  6317. [owa] .block-grid.three-up .col {
  6318. width: 205px !important;
  6319. }
  6320. .ie-browser .block-grid.four-up .col,
  6321. [owa] .block-grid.four-up .col {
  6322. width: 153px !important;
  6323. }
  6324. .ie-browser .block-grid.five-up .col,
  6325. [owa] .block-grid.five-up .col {
  6326. width: 123px !important;
  6327. }
  6328. .ie-browser .block-grid.six-up .col,
  6329. [owa] .block-grid.six-up .col {
  6330. width: 102px !important;
  6331. }
  6332. .ie-browser .block-grid.seven-up .col,
  6333. [owa] .block-grid.seven-up .col {
  6334. width: 87px !important;
  6335. }
  6336. .ie-browser .block-grid.eight-up .col,
  6337. [owa] .block-grid.eight-up .col {
  6338. width: 76px !important;
  6339. }
  6340. .ie-browser .block-grid.nine-up .col,
  6341. [owa] .block-grid.nine-up .col {
  6342. width: 68px !important;
  6343. }
  6344. .ie-browser .block-grid.ten-up .col,
  6345. [owa] .block-grid.ten-up .col {
  6346. width: 61px !important;
  6347. }
  6348. .ie-browser .block-grid.eleven-up .col,
  6349. [owa] .block-grid.eleven-up .col {
  6350. width: 55px !important;
  6351. }
  6352. .ie-browser .block-grid.twelve-up .col,
  6353. [owa] .block-grid.twelve-up .col {
  6354. width: 51px !important;
  6355. }
  6356. @media only screen and (min-width: 635px) {
  6357. .block-grid {
  6358. width: 615px !important;
  6359. }
  6360. .block-grid .col {
  6361. display: table-cell;
  6362. Float: none !important;
  6363. vertical-align: top;
  6364. }
  6365. .block-grid .col.num12 {
  6366. width: 615px !important;
  6367. }
  6368. .block-grid.mixed-two-up .col.num4 {
  6369. width: 204px !important;
  6370. }
  6371. .block-grid.mixed-two-up .col.num8 {
  6372. width: 408px !important;
  6373. }
  6374. .block-grid.two-up .col {
  6375. width: 307px !important;
  6376. }
  6377. .block-grid.three-up .col {
  6378. width: 205px !important;
  6379. }
  6380. .block-grid.four-up .col {
  6381. width: 153px !important;
  6382. }
  6383. .block-grid.five-up .col {
  6384. width: 123px !important;
  6385. }
  6386. .block-grid.six-up .col {
  6387. width: 102px !important;
  6388. }
  6389. .block-grid.seven-up .col {
  6390. width: 87px !important;
  6391. }
  6392. .block-grid.eight-up .col {
  6393. width: 76px !important;
  6394. }
  6395. .block-grid.nine-up .col {
  6396. width: 68px !important;
  6397. }
  6398. .block-grid.ten-up .col {
  6399. width: 61px !important;
  6400. }
  6401. .block-grid.eleven-up .col {
  6402. width: 55px !important;
  6403. }
  6404. .block-grid.twelve-up .col {
  6405. width: 51px !important;
  6406. }
  6407. }
  6408. @media (max-width: 635px) {
  6409. .block-grid,
  6410. .col {
  6411. min-width: 320px !important;
  6412. max-width: 100% !important;
  6413. }
  6414. .block-grid {
  6415. width: calc(100% - 40px) !important;
  6416. }
  6417. .col {
  6418. width: 100% !important;
  6419. }
  6420. .col>div {
  6421. margin: 0 auto;
  6422. }
  6423. img.fullwidth {
  6424. max-width: 100% !important;
  6425. }
  6426. }
  6427. </style>
  6428. </head>
  6429. <body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #FFFFFF">
  6430. <!--[if IE]><div class="ie-browser"><![endif]-->
  6431. <!--[if mso]><div class="mso-container"><![endif]-->
  6432. <div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: #FFFFFF">
  6433. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #FFFFFF;"><![endif]-->
  6434. <div style="background-color:#333333;">
  6435. <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;"
  6436. class="block-grid ">
  6437. <div style="border-collapse: collapse;display: table;width: 100%;">
  6438. <!--[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]-->
  6439. <!--[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]-->
  6440. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6441. <div style="background-color: transparent; width: 100% !important;">
  6442. <!--[if (!mso)&(!IE)]><!-->
  6443. <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;">
  6444. <!--<![endif]-->
  6445. <div align="left" class="img-container left fullwidth" style="padding-right: 30px; padding-left: 30px;">
  6446. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px;" align="left"><![endif]-->
  6447. <img class="left fullwidth" align="left" border="0" src="'.$path.'images/organizr-logo-h.png" alt="Image" title="Image"
  6448. 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"
  6449. width="555">
  6450. <!--[if mso]></td></tr></table><![endif]-->
  6451. </div>
  6452. <!--[if (!mso)&(!IE)]><!-->
  6453. </div>
  6454. <!--<![endif]-->
  6455. </div>
  6456. </div>
  6457. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6458. </div>
  6459. </div>
  6460. </div>
  6461. <div style="background-color:#333333;">
  6462. <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;"
  6463. class="block-grid ">
  6464. <div style="border-collapse: collapse;display: table;width: 100%;">
  6465. <!--[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]-->
  6466. <!--[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]-->
  6467. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6468. <div style="background-color: transparent; width: 100% !important;">
  6469. <!--[if (!mso)&(!IE)]><!-->
  6470. <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;">
  6471. <!--<![endif]-->
  6472. <!--[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]-->
  6473. <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;">
  6474. <div style="font-size:12px;line-height:14px;color:#FFFFFF;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6475. <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>
  6476. </span>
  6477. </p>
  6478. </div>
  6479. </div>
  6480. <!--[if mso]></td></tr></table><![endif]-->
  6481. <!--[if (!mso)&(!IE)]><!-->
  6482. </div>
  6483. <!--<![endif]-->
  6484. </div>
  6485. </div>
  6486. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6487. </div>
  6488. </div>
  6489. </div>
  6490. <div style="background-color:#393939;">
  6491. <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;"
  6492. class="block-grid ">
  6493. <div style="border-collapse: collapse;display: table;width: 100%;">
  6494. <!--[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]-->
  6495. <!--[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]-->
  6496. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6497. <div style="background-color: transparent; width: 100% !important;">
  6498. <!--[if (!mso)&(!IE)]><!-->
  6499. <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;">
  6500. <!--<![endif]-->
  6501. <!--[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]-->
  6502. <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;">
  6503. <div style="font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6504. <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>
  6505. </div>
  6506. </div>
  6507. <!--[if mso]></td></tr></table><![endif]-->
  6508. <div style="padding-right: 5px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px;">
  6509. <!--[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]-->
  6510. <div align="center">
  6511. <div style="border-top: 2px solid #66D9EF; width:55%; line-height:2px; height:2px; font-size:2px;">&#160;</div>
  6512. </div>
  6513. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6514. </div>
  6515. <!--[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]-->
  6516. <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;">
  6517. <div style="font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6518. <p style="margin: 0;font-size: 12px;line-height: 14px"><span style="font-size: 28px; line-height: 33px;">Hey '.$user.',</span></p>
  6519. </div>
  6520. </div>
  6521. <!--[if mso]></td></tr></table><![endif]-->
  6522. <!--[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]-->
  6523. <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;">
  6524. <div style="font-size:12px;line-height:22px;font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;color:#FFFFFF;text-align:left;">
  6525. <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>
  6526. </span>
  6527. </p>
  6528. </div>
  6529. </div>
  6530. <!--[if mso]></td></tr></table><![endif]-->
  6531. <div align="center" class="button-container center" style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;">
  6532. <!--[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]-->
  6533. <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">
  6534. <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>
  6535. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6536. </div>
  6537. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6538. </div>
  6539. <!--[if (!mso)&(!IE)]><!-->
  6540. </div>
  6541. <!--<![endif]-->
  6542. </div>
  6543. </div>
  6544. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6545. </div>
  6546. </div>
  6547. </div>
  6548. <div style="background-color:#ffffff;">
  6549. <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;"
  6550. class="block-grid ">
  6551. <div style="border-collapse: collapse;display: table;width: 100%;">
  6552. <!--[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]-->
  6553. <!--[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]-->
  6554. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6555. <div style="background-color: transparent; width: 100% !important;">
  6556. <!--[if (!mso)&(!IE)]><!-->
  6557. <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;">
  6558. <!--<![endif]-->
  6559. <!--[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]-->
  6560. <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;">
  6561. <div style="font-size:12px;line-height:14px;color:#555555;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6562. <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>
  6563. </div>
  6564. </div>
  6565. <!--[if mso]></td></tr></table><![endif]-->
  6566. <div style="padding-right: 20px; padding-left: 20px; padding-top: 15px; padding-bottom: 20px;">
  6567. <!--[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]-->
  6568. <div align="center">
  6569. <div style="border-top: 3px solid #66D9EF; width:40%; line-height:3px; height:3px; font-size:3px;">&#160;</div>
  6570. </div>
  6571. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6572. </div>
  6573. <!--[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]-->
  6574. <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;">
  6575. <div style="font-size:12px;line-height:22px;color:#7E7D7D;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6576. <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>
  6577. </div>
  6578. </div>
  6579. <!--[if mso]></td></tr></table><![endif]-->
  6580. <!--[if (!mso)&(!IE)]><!-->
  6581. </div>
  6582. <!--<![endif]-->
  6583. </div>
  6584. </div>
  6585. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6586. </div>
  6587. </div>
  6588. </div>
  6589. <div style="background-color:#333333;">
  6590. <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;"
  6591. class="block-grid ">
  6592. <div style="border-collapse: collapse;display: table;width: 100%;">
  6593. <!--[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]-->
  6594. <!--[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]-->
  6595. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6596. <div style="background-color: transparent; width: 100% !important;">
  6597. <!--[if (!mso)&(!IE)]><!-->
  6598. <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;">
  6599. <!--<![endif]-->
  6600. <!--[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]-->
  6601. <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;">
  6602. <div style="font-size:12px;line-height:14px;color:#959595;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6603. <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"
  6604. href="https://github.com/causefx/Organizr" target="_blank" rel="noopener noreferrer">Organizr</a><strong><br></strong></p>
  6605. </div>
  6606. </div>
  6607. <!--[if mso]></td></tr></table><![endif]-->
  6608. <!--[if (!mso)&(!IE)]><!-->
  6609. </div>
  6610. <!--<![endif]-->
  6611. </div>
  6612. </div>
  6613. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6614. </div>
  6615. </div>
  6616. </div>
  6617. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  6618. </div>
  6619. <!--[if (mso)|(IE)]></div><![endif]-->
  6620. </body>
  6621. </html>
  6622. ';
  6623. }
  6624. function mimeTypes(){
  6625. return array(
  6626. '123' => 'application/vnd.lotus-1-2-3',
  6627. '3dml' => 'text/vnd.in3d.3dml',
  6628. '3ds' => 'image/x-3ds',
  6629. '3g2' => 'video/3gpp2',
  6630. '3gp' => 'video/3gpp',
  6631. '7z' => 'application/x-7z-compressed',
  6632. 'aab' => 'application/x-authorware-bin',
  6633. 'aac' => 'audio/x-aac',
  6634. 'aam' => 'application/x-authorware-map',
  6635. 'aas' => 'application/x-authorware-seg',
  6636. 'abw' => 'application/x-abiword',
  6637. 'ac' => 'application/pkix-attr-cert',
  6638. 'acc' => 'application/vnd.americandynamics.acc',
  6639. 'ace' => 'application/x-ace-compressed',
  6640. 'acu' => 'application/vnd.acucobol',
  6641. 'acutc' => 'application/vnd.acucorp',
  6642. 'adp' => 'audio/adpcm',
  6643. 'aep' => 'application/vnd.audiograph',
  6644. 'afm' => 'application/x-font-type1',
  6645. 'afp' => 'application/vnd.ibm.modcap',
  6646. 'ahead' => 'application/vnd.ahead.space',
  6647. 'ai' => 'application/postscript',
  6648. 'aif' => 'audio/x-aiff',
  6649. 'aifc' => 'audio/x-aiff',
  6650. 'aiff' => 'audio/x-aiff',
  6651. 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
  6652. 'ait' => 'application/vnd.dvb.ait',
  6653. 'ami' => 'application/vnd.amiga.ami',
  6654. 'apk' => 'application/vnd.android.package-archive',
  6655. 'appcache' => 'text/cache-manifest',
  6656. 'application' => 'application/x-ms-application',
  6657. 'apr' => 'application/vnd.lotus-approach',
  6658. 'arc' => 'application/x-freearc',
  6659. 'asc' => 'application/pgp-signature',
  6660. 'asf' => 'video/x-ms-asf',
  6661. 'asm' => 'text/x-asm',
  6662. 'aso' => 'application/vnd.accpac.simply.aso',
  6663. 'asx' => 'video/x-ms-asf',
  6664. 'atc' => 'application/vnd.acucorp',
  6665. 'atom' => 'application/atom+xml',
  6666. 'atomcat' => 'application/atomcat+xml',
  6667. 'atomsvc' => 'application/atomsvc+xml',
  6668. 'atx' => 'application/vnd.antix.game-component',
  6669. 'au' => 'audio/basic',
  6670. 'avi' => 'video/x-msvideo',
  6671. 'aw' => 'application/applixware',
  6672. 'azf' => 'application/vnd.airzip.filesecure.azf',
  6673. 'azs' => 'application/vnd.airzip.filesecure.azs',
  6674. 'azw' => 'application/vnd.amazon.ebook',
  6675. 'bat' => 'application/x-msdownload',
  6676. 'bcpio' => 'application/x-bcpio',
  6677. 'bdf' => 'application/x-font-bdf',
  6678. 'bdm' => 'application/vnd.syncml.dm+wbxml',
  6679. 'bed' => 'application/vnd.realvnc.bed',
  6680. 'bh2' => 'application/vnd.fujitsu.oasysprs',
  6681. 'bin' => 'application/octet-stream',
  6682. 'blb' => 'application/x-blorb',
  6683. 'blorb' => 'application/x-blorb',
  6684. 'bmi' => 'application/vnd.bmi',
  6685. 'bmp' => 'image/bmp',
  6686. 'book' => 'application/vnd.framemaker',
  6687. 'box' => 'application/vnd.previewsystems.box',
  6688. 'boz' => 'application/x-bzip2',
  6689. 'bpk' => 'application/octet-stream',
  6690. 'btif' => 'image/prs.btif',
  6691. 'bz' => 'application/x-bzip',
  6692. 'bz2' => 'application/x-bzip2',
  6693. 'c' => 'text/x-c',
  6694. 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
  6695. 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
  6696. 'c4d' => 'application/vnd.clonk.c4group',
  6697. 'c4f' => 'application/vnd.clonk.c4group',
  6698. 'c4g' => 'application/vnd.clonk.c4group',
  6699. 'c4p' => 'application/vnd.clonk.c4group',
  6700. 'c4u' => 'application/vnd.clonk.c4group',
  6701. 'cab' => 'application/vnd.ms-cab-compressed',
  6702. 'caf' => 'audio/x-caf',
  6703. 'cap' => 'application/vnd.tcpdump.pcap',
  6704. 'car' => 'application/vnd.curl.car',
  6705. 'cat' => 'application/vnd.ms-pki.seccat',
  6706. 'cb7' => 'application/x-cbr',
  6707. 'cba' => 'application/x-cbr',
  6708. 'cbr' => 'application/x-cbr',
  6709. 'cbt' => 'application/x-cbr',
  6710. 'cbz' => 'application/x-cbr',
  6711. 'cc' => 'text/x-c',
  6712. 'cct' => 'application/x-director',
  6713. 'ccxml' => 'application/ccxml+xml',
  6714. 'cdbcmsg' => 'application/vnd.contact.cmsg',
  6715. 'cdf' => 'application/x-netcdf',
  6716. 'cdkey' => 'application/vnd.mediastation.cdkey',
  6717. 'cdmia' => 'application/cdmi-capability',
  6718. 'cdmic' => 'application/cdmi-container',
  6719. 'cdmid' => 'application/cdmi-domain',
  6720. 'cdmio' => 'application/cdmi-object',
  6721. 'cdmiq' => 'application/cdmi-queue',
  6722. 'cdx' => 'chemical/x-cdx',
  6723. 'cdxml' => 'application/vnd.chemdraw+xml',
  6724. 'cdy' => 'application/vnd.cinderella',
  6725. 'cer' => 'application/pkix-cert',
  6726. 'cfs' => 'application/x-cfs-compressed',
  6727. 'cgm' => 'image/cgm',
  6728. 'chat' => 'application/x-chat',
  6729. 'chm' => 'application/vnd.ms-htmlhelp',
  6730. 'chrt' => 'application/vnd.kde.kchart',
  6731. 'cif' => 'chemical/x-cif',
  6732. 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
  6733. 'cil' => 'application/vnd.ms-artgalry',
  6734. 'cla' => 'application/vnd.claymore',
  6735. 'class' => 'application/java-vm',
  6736. 'clkk' => 'application/vnd.crick.clicker.keyboard',
  6737. 'clkp' => 'application/vnd.crick.clicker.palette',
  6738. 'clkt' => 'application/vnd.crick.clicker.template',
  6739. 'clkw' => 'application/vnd.crick.clicker.wordbank',
  6740. 'clkx' => 'application/vnd.crick.clicker',
  6741. 'clp' => 'application/x-msclip',
  6742. 'cmc' => 'application/vnd.cosmocaller',
  6743. 'cmdf' => 'chemical/x-cmdf',
  6744. 'cml' => 'chemical/x-cml',
  6745. 'cmp' => 'application/vnd.yellowriver-custom-menu',
  6746. 'cmx' => 'image/x-cmx',
  6747. 'cod' => 'application/vnd.rim.cod',
  6748. 'com' => 'application/x-msdownload',
  6749. 'conf' => 'text/plain',
  6750. 'cpio' => 'application/x-cpio',
  6751. 'cpp' => 'text/x-c',
  6752. 'cpt' => 'application/mac-compactpro',
  6753. 'crd' => 'application/x-mscardfile',
  6754. 'crl' => 'application/pkix-crl',
  6755. 'crt' => 'application/x-x509-ca-cert',
  6756. 'cryptonote' => 'application/vnd.rig.cryptonote',
  6757. 'csh' => 'application/x-csh',
  6758. 'csml' => 'chemical/x-csml',
  6759. 'csp' => 'application/vnd.commonspace',
  6760. 'css' => 'text/css',
  6761. 'cst' => 'application/x-director',
  6762. 'csv' => 'text/csv',
  6763. 'cu' => 'application/cu-seeme',
  6764. 'curl' => 'text/vnd.curl',
  6765. 'cww' => 'application/prs.cww',
  6766. 'cxt' => 'application/x-director',
  6767. 'cxx' => 'text/x-c',
  6768. 'dae' => 'model/vnd.collada+xml',
  6769. 'daf' => 'application/vnd.mobius.daf',
  6770. 'dart' => 'application/vnd.dart',
  6771. 'dataless' => 'application/vnd.fdsn.seed',
  6772. 'davmount' => 'application/davmount+xml',
  6773. 'dbk' => 'application/docbook+xml',
  6774. 'dcr' => 'application/x-director',
  6775. 'dcurl' => 'text/vnd.curl.dcurl',
  6776. 'dd2' => 'application/vnd.oma.dd2+xml',
  6777. 'ddd' => 'application/vnd.fujixerox.ddd',
  6778. 'deb' => 'application/x-debian-package',
  6779. 'def' => 'text/plain',
  6780. 'deploy' => 'application/octet-stream',
  6781. 'der' => 'application/x-x509-ca-cert',
  6782. 'dfac' => 'application/vnd.dreamfactory',
  6783. 'dgc' => 'application/x-dgc-compressed',
  6784. 'dic' => 'text/x-c',
  6785. 'dir' => 'application/x-director',
  6786. 'dis' => 'application/vnd.mobius.dis',
  6787. 'dist' => 'application/octet-stream',
  6788. 'distz' => 'application/octet-stream',
  6789. 'djv' => 'image/vnd.djvu',
  6790. 'djvu' => 'image/vnd.djvu',
  6791. 'dll' => 'application/x-msdownload',
  6792. 'dmg' => 'application/x-apple-diskimage',
  6793. 'dmp' => 'application/vnd.tcpdump.pcap',
  6794. 'dms' => 'application/octet-stream',
  6795. 'dna' => 'application/vnd.dna',
  6796. 'doc' => 'application/msword',
  6797. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  6798. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  6799. 'dot' => 'application/msword',
  6800. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  6801. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  6802. 'dp' => 'application/vnd.osgi.dp',
  6803. 'dpg' => 'application/vnd.dpgraph',
  6804. 'dra' => 'audio/vnd.dra',
  6805. 'dsc' => 'text/prs.lines.tag',
  6806. 'dssc' => 'application/dssc+der',
  6807. 'dtb' => 'application/x-dtbook+xml',
  6808. 'dtd' => 'application/xml-dtd',
  6809. 'dts' => 'audio/vnd.dts',
  6810. 'dtshd' => 'audio/vnd.dts.hd',
  6811. 'dump' => 'application/octet-stream',
  6812. 'dvb' => 'video/vnd.dvb.file',
  6813. 'dvi' => 'application/x-dvi',
  6814. 'dwf' => 'model/vnd.dwf',
  6815. 'dwg' => 'image/vnd.dwg',
  6816. 'dxf' => 'image/vnd.dxf',
  6817. 'dxp' => 'application/vnd.spotfire.dxp',
  6818. 'dxr' => 'application/x-director',
  6819. 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
  6820. 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
  6821. 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
  6822. 'ecma' => 'application/ecmascript',
  6823. 'edm' => 'application/vnd.novadigm.edm',
  6824. 'edx' => 'application/vnd.novadigm.edx',
  6825. 'efif' => 'application/vnd.picsel',
  6826. 'ei6' => 'application/vnd.pg.osasli',
  6827. 'elc' => 'application/octet-stream',
  6828. 'emf' => 'application/x-msmetafile',
  6829. 'eml' => 'message/rfc822',
  6830. 'emma' => 'application/emma+xml',
  6831. 'emz' => 'application/x-msmetafile',
  6832. 'eol' => 'audio/vnd.digital-winds',
  6833. 'eot' => 'application/vnd.ms-fontobject',
  6834. 'eps' => 'application/postscript',
  6835. 'epub' => 'application/epub+zip',
  6836. 'es3' => 'application/vnd.eszigno3+xml',
  6837. 'esa' => 'application/vnd.osgi.subsystem',
  6838. 'esf' => 'application/vnd.epson.esf',
  6839. 'et3' => 'application/vnd.eszigno3+xml',
  6840. 'etx' => 'text/x-setext',
  6841. 'eva' => 'application/x-eva',
  6842. 'evy' => 'application/x-envoy',
  6843. 'exe' => 'application/x-msdownload',
  6844. 'exi' => 'application/exi',
  6845. 'ext' => 'application/vnd.novadigm.ext',
  6846. 'ez' => 'application/andrew-inset',
  6847. 'ez2' => 'application/vnd.ezpix-album',
  6848. 'ez3' => 'application/vnd.ezpix-package',
  6849. 'f' => 'text/x-fortran',
  6850. 'f4v' => 'video/x-f4v',
  6851. 'f77' => 'text/x-fortran',
  6852. 'f90' => 'text/x-fortran',
  6853. 'fbs' => 'image/vnd.fastbidsheet',
  6854. 'fcdt' => 'application/vnd.adobe.formscentral.fcdt',
  6855. 'fcs' => 'application/vnd.isac.fcs',
  6856. 'fdf' => 'application/vnd.fdf',
  6857. 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
  6858. 'fg5' => 'application/vnd.fujitsu.oasysgp',
  6859. 'fgd' => 'application/x-director',
  6860. 'fh' => 'image/x-freehand',
  6861. 'fh4' => 'image/x-freehand',
  6862. 'fh5' => 'image/x-freehand',
  6863. 'fh7' => 'image/x-freehand',
  6864. 'fhc' => 'image/x-freehand',
  6865. 'fig' => 'application/x-xfig',
  6866. 'flac' => 'audio/x-flac',
  6867. 'fli' => 'video/x-fli',
  6868. 'flo' => 'application/vnd.micrografx.flo',
  6869. 'flv' => 'video/x-flv',
  6870. 'flw' => 'application/vnd.kde.kivio',
  6871. 'flx' => 'text/vnd.fmi.flexstor',
  6872. 'fly' => 'text/vnd.fly',
  6873. 'fm' => 'application/vnd.framemaker',
  6874. 'fnc' => 'application/vnd.frogans.fnc',
  6875. 'for' => 'text/x-fortran',
  6876. 'fpx' => 'image/vnd.fpx',
  6877. 'frame' => 'application/vnd.framemaker',
  6878. 'fsc' => 'application/vnd.fsc.weblaunch',
  6879. 'fst' => 'image/vnd.fst',
  6880. 'ftc' => 'application/vnd.fluxtime.clip',
  6881. 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
  6882. 'fvt' => 'video/vnd.fvt',
  6883. 'fxp' => 'application/vnd.adobe.fxp',
  6884. 'fxpl' => 'application/vnd.adobe.fxp',
  6885. 'fzs' => 'application/vnd.fuzzysheet',
  6886. 'g2w' => 'application/vnd.geoplan',
  6887. 'g3' => 'image/g3fax',
  6888. 'g3w' => 'application/vnd.geospace',
  6889. 'gac' => 'application/vnd.groove-account',
  6890. 'gam' => 'application/x-tads',
  6891. 'gbr' => 'application/rpki-ghostbusters',
  6892. 'gca' => 'application/x-gca-compressed',
  6893. 'gdl' => 'model/vnd.gdl',
  6894. 'geo' => 'application/vnd.dynageo',
  6895. 'gex' => 'application/vnd.geometry-explorer',
  6896. 'ggb' => 'application/vnd.geogebra.file',
  6897. 'ggt' => 'application/vnd.geogebra.tool',
  6898. 'ghf' => 'application/vnd.groove-help',
  6899. 'gif' => 'image/gif',
  6900. 'gim' => 'application/vnd.groove-identity-message',
  6901. 'gml' => 'application/gml+xml',
  6902. 'gmx' => 'application/vnd.gmx',
  6903. 'gnumeric' => 'application/x-gnumeric',
  6904. 'gph' => 'application/vnd.flographit',
  6905. 'gpx' => 'application/gpx+xml',
  6906. 'gqf' => 'application/vnd.grafeq',
  6907. 'gqs' => 'application/vnd.grafeq',
  6908. 'gram' => 'application/srgs',
  6909. 'gramps' => 'application/x-gramps-xml',
  6910. 'gre' => 'application/vnd.geometry-explorer',
  6911. 'grv' => 'application/vnd.groove-injector',
  6912. 'grxml' => 'application/srgs+xml',
  6913. 'gsf' => 'application/x-font-ghostscript',
  6914. 'gtar' => 'application/x-gtar',
  6915. 'gtm' => 'application/vnd.groove-tool-message',
  6916. 'gtw' => 'model/vnd.gtw',
  6917. 'gv' => 'text/vnd.graphviz',
  6918. 'gxf' => 'application/gxf',
  6919. 'gxt' => 'application/vnd.geonext',
  6920. 'h' => 'text/x-c',
  6921. 'h261' => 'video/h261',
  6922. 'h263' => 'video/h263',
  6923. 'h264' => 'video/h264',
  6924. 'hal' => 'application/vnd.hal+xml',
  6925. 'hbci' => 'application/vnd.hbci',
  6926. 'hdf' => 'application/x-hdf',
  6927. 'hh' => 'text/x-c',
  6928. 'hlp' => 'application/winhlp',
  6929. 'hpgl' => 'application/vnd.hp-hpgl',
  6930. 'hpid' => 'application/vnd.hp-hpid',
  6931. 'hps' => 'application/vnd.hp-hps',
  6932. 'hqx' => 'application/mac-binhex40',
  6933. 'htke' => 'application/vnd.kenameaapp',
  6934. 'htm' => 'text/html',
  6935. 'html' => 'text/html',
  6936. 'hvd' => 'application/vnd.yamaha.hv-dic',
  6937. 'hvp' => 'application/vnd.yamaha.hv-voice',
  6938. 'hvs' => 'application/vnd.yamaha.hv-script',
  6939. 'i2g' => 'application/vnd.intergeo',
  6940. 'icc' => 'application/vnd.iccprofile',
  6941. 'ice' => 'x-conference/x-cooltalk',
  6942. 'icm' => 'application/vnd.iccprofile',
  6943. 'ico' => 'image/x-icon',
  6944. 'ics' => 'text/calendar',
  6945. 'ief' => 'image/ief',
  6946. 'ifb' => 'text/calendar',
  6947. 'ifm' => 'application/vnd.shana.informed.formdata',
  6948. 'iges' => 'model/iges',
  6949. 'igl' => 'application/vnd.igloader',
  6950. 'igm' => 'application/vnd.insors.igm',
  6951. 'igs' => 'model/iges',
  6952. 'igx' => 'application/vnd.micrografx.igx',
  6953. 'iif' => 'application/vnd.shana.informed.interchange',
  6954. 'imp' => 'application/vnd.accpac.simply.imp',
  6955. 'ims' => 'application/vnd.ms-ims',
  6956. 'in' => 'text/plain',
  6957. 'ink' => 'application/inkml+xml',
  6958. 'inkml' => 'application/inkml+xml',
  6959. 'install' => 'application/x-install-instructions',
  6960. 'iota' => 'application/vnd.astraea-software.iota',
  6961. 'ipfix' => 'application/ipfix',
  6962. 'ipk' => 'application/vnd.shana.informed.package',
  6963. 'irm' => 'application/vnd.ibm.rights-management',
  6964. 'irp' => 'application/vnd.irepository.package+xml',
  6965. 'iso' => 'application/x-iso9660-image',
  6966. 'itp' => 'application/vnd.shana.informed.formtemplate',
  6967. 'ivp' => 'application/vnd.immervision-ivp',
  6968. 'ivu' => 'application/vnd.immervision-ivu',
  6969. 'jad' => 'text/vnd.sun.j2me.app-descriptor',
  6970. 'jam' => 'application/vnd.jam',
  6971. 'jar' => 'application/java-archive',
  6972. 'java' => 'text/x-java-source',
  6973. 'jisp' => 'application/vnd.jisp',
  6974. 'jlt' => 'application/vnd.hp-jlyt',
  6975. 'jnlp' => 'application/x-java-jnlp-file',
  6976. 'joda' => 'application/vnd.joost.joda-archive',
  6977. 'jpe' => 'image/jpeg',
  6978. 'jpeg' => 'image/jpeg',
  6979. 'jpg' => 'image/jpeg',
  6980. 'jpgm' => 'video/jpm',
  6981. 'jpgv' => 'video/jpeg',
  6982. 'jpm' => 'video/jpm',
  6983. 'js' => 'application/javascript',
  6984. 'json' => 'application/json',
  6985. 'jsonml' => 'application/jsonml+json',
  6986. 'kar' => 'audio/midi',
  6987. 'karbon' => 'application/vnd.kde.karbon',
  6988. 'kfo' => 'application/vnd.kde.kformula',
  6989. 'kia' => 'application/vnd.kidspiration',
  6990. 'kml' => 'application/vnd.google-earth.kml+xml',
  6991. 'kmz' => 'application/vnd.google-earth.kmz',
  6992. 'kne' => 'application/vnd.kinar',
  6993. 'knp' => 'application/vnd.kinar',
  6994. 'kon' => 'application/vnd.kde.kontour',
  6995. 'kpr' => 'application/vnd.kde.kpresenter',
  6996. 'kpt' => 'application/vnd.kde.kpresenter',
  6997. 'kpxx' => 'application/vnd.ds-keypoint',
  6998. 'ksp' => 'application/vnd.kde.kspread',
  6999. 'ktr' => 'application/vnd.kahootz',
  7000. 'ktx' => 'image/ktx',
  7001. 'ktz' => 'application/vnd.kahootz',
  7002. 'kwd' => 'application/vnd.kde.kword',
  7003. 'kwt' => 'application/vnd.kde.kword',
  7004. 'lasxml' => 'application/vnd.las.las+xml',
  7005. 'latex' => 'application/x-latex',
  7006. 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  7007. 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  7008. 'les' => 'application/vnd.hhe.lesson-player',
  7009. 'lha' => 'application/x-lzh-compressed',
  7010. 'link66' => 'application/vnd.route66.link66+xml',
  7011. 'list' => 'text/plain',
  7012. 'list3820' => 'application/vnd.ibm.modcap',
  7013. 'listafp' => 'application/vnd.ibm.modcap',
  7014. 'lnk' => 'application/x-ms-shortcut',
  7015. 'log' => 'text/plain',
  7016. 'lostxml' => 'application/lost+xml',
  7017. 'lrf' => 'application/octet-stream',
  7018. 'lrm' => 'application/vnd.ms-lrm',
  7019. 'ltf' => 'application/vnd.frogans.ltf',
  7020. 'lvp' => 'audio/vnd.lucent.voice',
  7021. 'lwp' => 'application/vnd.lotus-wordpro',
  7022. 'lzh' => 'application/x-lzh-compressed',
  7023. 'm13' => 'application/x-msmediaview',
  7024. 'm14' => 'application/x-msmediaview',
  7025. 'm1v' => 'video/mpeg',
  7026. 'm21' => 'application/mp21',
  7027. 'm2a' => 'audio/mpeg',
  7028. 'm2v' => 'video/mpeg',
  7029. 'm3a' => 'audio/mpeg',
  7030. 'm3u' => 'audio/x-mpegurl',
  7031. 'm3u8' => 'application/vnd.apple.mpegurl',
  7032. 'm4a' => 'audio/mp4',
  7033. 'm4u' => 'video/vnd.mpegurl',
  7034. 'm4v' => 'video/x-m4v',
  7035. 'ma' => 'application/mathematica',
  7036. 'mads' => 'application/mads+xml',
  7037. 'mag' => 'application/vnd.ecowin.chart',
  7038. 'maker' => 'application/vnd.framemaker',
  7039. 'man' => 'text/troff',
  7040. 'mar' => 'application/octet-stream',
  7041. 'mathml' => 'application/mathml+xml',
  7042. 'mb' => 'application/mathematica',
  7043. 'mbk' => 'application/vnd.mobius.mbk',
  7044. 'mbox' => 'application/mbox',
  7045. 'mc1' => 'application/vnd.medcalcdata',
  7046. 'mcd' => 'application/vnd.mcd',
  7047. 'mcurl' => 'text/vnd.curl.mcurl',
  7048. 'mdb' => 'application/x-msaccess',
  7049. 'mdi' => 'image/vnd.ms-modi',
  7050. 'me' => 'text/troff',
  7051. 'mesh' => 'model/mesh',
  7052. 'meta4' => 'application/metalink4+xml',
  7053. 'metalink' => 'application/metalink+xml',
  7054. 'mets' => 'application/mets+xml',
  7055. 'mfm' => 'application/vnd.mfmp',
  7056. 'mft' => 'application/rpki-manifest',
  7057. 'mgp' => 'application/vnd.osgeo.mapguide.package',
  7058. 'mgz' => 'application/vnd.proteus.magazine',
  7059. 'mid' => 'audio/midi',
  7060. 'midi' => 'audio/midi',
  7061. 'mie' => 'application/x-mie',
  7062. 'mif' => 'application/vnd.mif',
  7063. 'mime' => 'message/rfc822',
  7064. 'mj2' => 'video/mj2',
  7065. 'mjp2' => 'video/mj2',
  7066. 'mk3d' => 'video/x-matroska',
  7067. 'mka' => 'audio/x-matroska',
  7068. 'mks' => 'video/x-matroska',
  7069. 'mkv' => 'video/x-matroska',
  7070. 'mlp' => 'application/vnd.dolby.mlp',
  7071. 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
  7072. 'mmf' => 'application/vnd.smaf',
  7073. 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
  7074. 'mng' => 'video/x-mng',
  7075. 'mny' => 'application/x-msmoney',
  7076. 'mobi' => 'application/x-mobipocket-ebook',
  7077. 'mods' => 'application/mods+xml',
  7078. 'mov' => 'video/quicktime',
  7079. 'movie' => 'video/x-sgi-movie',
  7080. 'mp2' => 'audio/mpeg',
  7081. 'mp21' => 'application/mp21',
  7082. 'mp2a' => 'audio/mpeg',
  7083. 'mp3' => 'audio/mpeg',
  7084. 'mp4' => 'video/mp4',
  7085. 'mp4a' => 'audio/mp4',
  7086. 'mp4s' => 'application/mp4',
  7087. 'mp4v' => 'video/mp4',
  7088. 'mpc' => 'application/vnd.mophun.certificate',
  7089. 'mpe' => 'video/mpeg',
  7090. 'mpeg' => 'video/mpeg',
  7091. 'mpg' => 'video/mpeg',
  7092. 'mpg4' => 'video/mp4',
  7093. 'mpga' => 'audio/mpeg',
  7094. 'mpkg' => 'application/vnd.apple.installer+xml',
  7095. 'mpm' => 'application/vnd.blueice.multipass',
  7096. 'mpn' => 'application/vnd.mophun.application',
  7097. 'mpp' => 'application/vnd.ms-project',
  7098. 'mpt' => 'application/vnd.ms-project',
  7099. 'mpy' => 'application/vnd.ibm.minipay',
  7100. 'mqy' => 'application/vnd.mobius.mqy',
  7101. 'mrc' => 'application/marc',
  7102. 'mrcx' => 'application/marcxml+xml',
  7103. 'ms' => 'text/troff',
  7104. 'mscml' => 'application/mediaservercontrol+xml',
  7105. 'mseed' => 'application/vnd.fdsn.mseed',
  7106. 'mseq' => 'application/vnd.mseq',
  7107. 'msf' => 'application/vnd.epson.msf',
  7108. 'msh' => 'model/mesh',
  7109. 'msi' => 'application/x-msdownload',
  7110. 'msl' => 'application/vnd.mobius.msl',
  7111. 'msty' => 'application/vnd.muvee.style',
  7112. 'mts' => 'model/vnd.mts',
  7113. 'mus' => 'application/vnd.musician',
  7114. 'musicxml' => 'application/vnd.recordare.musicxml+xml',
  7115. 'mvb' => 'application/x-msmediaview',
  7116. 'mwf' => 'application/vnd.mfer',
  7117. 'mxf' => 'application/mxf',
  7118. 'mxl' => 'application/vnd.recordare.musicxml',
  7119. 'mxml' => 'application/xv+xml',
  7120. 'mxs' => 'application/vnd.triscape.mxs',
  7121. 'mxu' => 'video/vnd.mpegurl',
  7122. 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  7123. 'n3' => 'text/n3',
  7124. 'nb' => 'application/mathematica',
  7125. 'nbp' => 'application/vnd.wolfram.player',
  7126. 'nc' => 'application/x-netcdf',
  7127. 'ncx' => 'application/x-dtbncx+xml',
  7128. 'nfo' => 'text/x-nfo',
  7129. 'ngdat' => 'application/vnd.nokia.n-gage.data',
  7130. 'nitf' => 'application/vnd.nitf',
  7131. 'nlu' => 'application/vnd.neurolanguage.nlu',
  7132. 'nml' => 'application/vnd.enliven',
  7133. 'nnd' => 'application/vnd.noblenet-directory',
  7134. 'nns' => 'application/vnd.noblenet-sealer',
  7135. 'nnw' => 'application/vnd.noblenet-web',
  7136. 'npx' => 'image/vnd.net-fpx',
  7137. 'nsc' => 'application/x-conference',
  7138. 'nsf' => 'application/vnd.lotus-notes',
  7139. 'ntf' => 'application/vnd.nitf',
  7140. 'nzb' => 'application/x-nzb',
  7141. 'oa2' => 'application/vnd.fujitsu.oasys2',
  7142. 'oa3' => 'application/vnd.fujitsu.oasys3',
  7143. 'oas' => 'application/vnd.fujitsu.oasys',
  7144. 'obd' => 'application/x-msbinder',
  7145. 'obj' => 'application/x-tgif',
  7146. 'oda' => 'application/oda',
  7147. 'odb' => 'application/vnd.oasis.opendocument.database',
  7148. 'odc' => 'application/vnd.oasis.opendocument.chart',
  7149. 'odf' => 'application/vnd.oasis.opendocument.formula',
  7150. 'odft' => 'application/vnd.oasis.opendocument.formula-template',
  7151. 'odg' => 'application/vnd.oasis.opendocument.graphics',
  7152. 'odi' => 'application/vnd.oasis.opendocument.image',
  7153. 'odm' => 'application/vnd.oasis.opendocument.text-master',
  7154. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  7155. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  7156. 'odt' => 'application/vnd.oasis.opendocument.text',
  7157. 'oga' => 'audio/ogg',
  7158. 'ogg' => 'audio/ogg',
  7159. 'ogv' => 'video/ogg',
  7160. 'ogx' => 'application/ogg',
  7161. 'omdoc' => 'application/omdoc+xml',
  7162. 'onepkg' => 'application/onenote',
  7163. 'onetmp' => 'application/onenote',
  7164. 'onetoc' => 'application/onenote',
  7165. 'onetoc2' => 'application/onenote',
  7166. 'opf' => 'application/oebps-package+xml',
  7167. 'opml' => 'text/x-opml',
  7168. 'oprc' => 'application/vnd.palm',
  7169. 'org' => 'application/vnd.lotus-organizer',
  7170. 'osf' => 'application/vnd.yamaha.openscoreformat',
  7171. 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  7172. 'otc' => 'application/vnd.oasis.opendocument.chart-template',
  7173. 'otf' => 'application/x-font-otf',
  7174. 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
  7175. 'oth' => 'application/vnd.oasis.opendocument.text-web',
  7176. 'oti' => 'application/vnd.oasis.opendocument.image-template',
  7177. 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
  7178. 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  7179. 'ott' => 'application/vnd.oasis.opendocument.text-template',
  7180. 'oxps' => 'application/oxps',
  7181. 'oxt' => 'application/vnd.openofficeorg.extension',
  7182. 'p' => 'text/x-pascal',
  7183. 'p10' => 'application/pkcs10',
  7184. 'p12' => 'application/x-pkcs12',
  7185. 'p7b' => 'application/x-pkcs7-certificates',
  7186. 'p7c' => 'application/pkcs7-mime',
  7187. 'p7m' => 'application/pkcs7-mime',
  7188. 'p7r' => 'application/x-pkcs7-certreqresp',
  7189. 'p7s' => 'application/pkcs7-signature',
  7190. 'p8' => 'application/pkcs8',
  7191. 'pas' => 'text/x-pascal',
  7192. 'paw' => 'application/vnd.pawaafile',
  7193. 'pbd' => 'application/vnd.powerbuilder6',
  7194. 'pbm' => 'image/x-portable-bitmap',
  7195. 'pcap' => 'application/vnd.tcpdump.pcap',
  7196. 'pcf' => 'application/x-font-pcf',
  7197. 'pcl' => 'application/vnd.hp-pcl',
  7198. 'pclxl' => 'application/vnd.hp-pclxl',
  7199. 'pct' => 'image/x-pict',
  7200. 'pcurl' => 'application/vnd.curl.pcurl',
  7201. 'pcx' => 'image/x-pcx',
  7202. 'pdb' => 'application/vnd.palm',
  7203. 'pdf' => 'application/pdf',
  7204. 'pfa' => 'application/x-font-type1',
  7205. 'pfb' => 'application/x-font-type1',
  7206. 'pfm' => 'application/x-font-type1',
  7207. 'pfr' => 'application/font-tdpfr',
  7208. 'pfx' => 'application/x-pkcs12',
  7209. 'pgm' => 'image/x-portable-graymap',
  7210. 'pgn' => 'application/x-chess-pgn',
  7211. 'pgp' => 'application/pgp-encrypted',
  7212. 'pic' => 'image/x-pict',
  7213. 'pkg' => 'application/octet-stream',
  7214. 'pki' => 'application/pkixcmp',
  7215. 'pkipath' => 'application/pkix-pkipath',
  7216. 'plb' => 'application/vnd.3gpp.pic-bw-large',
  7217. 'plc' => 'application/vnd.mobius.plc',
  7218. 'plf' => 'application/vnd.pocketlearn',
  7219. 'pls' => 'application/pls+xml',
  7220. 'pml' => 'application/vnd.ctc-posml',
  7221. 'png' => 'image/png',
  7222. 'pnm' => 'image/x-portable-anymap',
  7223. 'portpkg' => 'application/vnd.macports.portpkg',
  7224. 'pot' => 'application/vnd.ms-powerpoint',
  7225. 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
  7226. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  7227. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  7228. 'ppd' => 'application/vnd.cups-ppd',
  7229. 'ppm' => 'image/x-portable-pixmap',
  7230. 'pps' => 'application/vnd.ms-powerpoint',
  7231. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  7232. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  7233. 'ppt' => 'application/vnd.ms-powerpoint',
  7234. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  7235. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  7236. 'pqa' => 'application/vnd.palm',
  7237. 'prc' => 'application/x-mobipocket-ebook',
  7238. 'pre' => 'application/vnd.lotus-freelance',
  7239. 'prf' => 'application/pics-rules',
  7240. 'ps' => 'application/postscript',
  7241. 'psb' => 'application/vnd.3gpp.pic-bw-small',
  7242. 'psd' => 'image/vnd.adobe.photoshop',
  7243. 'psf' => 'application/x-font-linux-psf',
  7244. 'pskcxml' => 'application/pskc+xml',
  7245. 'ptid' => 'application/vnd.pvi.ptid1',
  7246. 'pub' => 'application/x-mspublisher',
  7247. 'pvb' => 'application/vnd.3gpp.pic-bw-var',
  7248. 'pwn' => 'application/vnd.3m.post-it-notes',
  7249. 'pya' => 'audio/vnd.ms-playready.media.pya',
  7250. 'pyv' => 'video/vnd.ms-playready.media.pyv',
  7251. 'qam' => 'application/vnd.epson.quickanime',
  7252. 'qbo' => 'application/vnd.intu.qbo',
  7253. 'qfx' => 'application/vnd.intu.qfx',
  7254. 'qps' => 'application/vnd.publishare-delta-tree',
  7255. 'qt' => 'video/quicktime',
  7256. 'qwd' => 'application/vnd.quark.quarkxpress',
  7257. 'qwt' => 'application/vnd.quark.quarkxpress',
  7258. 'qxb' => 'application/vnd.quark.quarkxpress',
  7259. 'qxd' => 'application/vnd.quark.quarkxpress',
  7260. 'qxl' => 'application/vnd.quark.quarkxpress',
  7261. 'qxt' => 'application/vnd.quark.quarkxpress',
  7262. 'ra' => 'audio/x-pn-realaudio',
  7263. 'ram' => 'audio/x-pn-realaudio',
  7264. 'rar' => 'application/x-rar-compressed',
  7265. 'ras' => 'image/x-cmu-raster',
  7266. 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
  7267. 'rdf' => 'application/rdf+xml',
  7268. 'rdz' => 'application/vnd.data-vision.rdz',
  7269. 'rep' => 'application/vnd.businessobjects',
  7270. 'res' => 'application/x-dtbresource+xml',
  7271. 'rgb' => 'image/x-rgb',
  7272. 'rif' => 'application/reginfo+xml',
  7273. 'rip' => 'audio/vnd.rip',
  7274. 'ris' => 'application/x-research-info-systems',
  7275. 'rl' => 'application/resource-lists+xml',
  7276. 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
  7277. 'rld' => 'application/resource-lists-diff+xml',
  7278. 'rm' => 'application/vnd.rn-realmedia',
  7279. 'rmi' => 'audio/midi',
  7280. 'rmp' => 'audio/x-pn-realaudio-plugin',
  7281. 'rms' => 'application/vnd.jcp.javame.midlet-rms',
  7282. 'rmvb' => 'application/vnd.rn-realmedia-vbr',
  7283. 'rnc' => 'application/relax-ng-compact-syntax',
  7284. 'roa' => 'application/rpki-roa',
  7285. 'roff' => 'text/troff',
  7286. 'rp9' => 'application/vnd.cloanto.rp9',
  7287. 'rpss' => 'application/vnd.nokia.radio-presets',
  7288. 'rpst' => 'application/vnd.nokia.radio-preset',
  7289. 'rq' => 'application/sparql-query',
  7290. 'rs' => 'application/rls-services+xml',
  7291. 'rsd' => 'application/rsd+xml',
  7292. 'rss' => 'application/rss+xml',
  7293. 'rtf' => 'application/rtf',
  7294. 'rtx' => 'text/richtext',
  7295. 's' => 'text/x-asm',
  7296. 's3m' => 'audio/s3m',
  7297. 'saf' => 'application/vnd.yamaha.smaf-audio',
  7298. 'sbml' => 'application/sbml+xml',
  7299. 'sc' => 'application/vnd.ibm.secure-container',
  7300. 'scd' => 'application/x-msschedule',
  7301. 'scm' => 'application/vnd.lotus-screencam',
  7302. 'scq' => 'application/scvp-cv-request',
  7303. 'scs' => 'application/scvp-cv-response',
  7304. 'scurl' => 'text/vnd.curl.scurl',
  7305. 'sda' => 'application/vnd.stardivision.draw',
  7306. 'sdc' => 'application/vnd.stardivision.calc',
  7307. 'sdd' => 'application/vnd.stardivision.impress',
  7308. 'sdkd' => 'application/vnd.solent.sdkm+xml',
  7309. 'sdkm' => 'application/vnd.solent.sdkm+xml',
  7310. 'sdp' => 'application/sdp',
  7311. 'sdw' => 'application/vnd.stardivision.writer',
  7312. 'see' => 'application/vnd.seemail',
  7313. 'seed' => 'application/vnd.fdsn.seed',
  7314. 'sema' => 'application/vnd.sema',
  7315. 'semd' => 'application/vnd.semd',
  7316. 'semf' => 'application/vnd.semf',
  7317. 'ser' => 'application/java-serialized-object',
  7318. 'setpay' => 'application/set-payment-initiation',
  7319. 'setreg' => 'application/set-registration-initiation',
  7320. 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
  7321. 'sfs' => 'application/vnd.spotfire.sfs',
  7322. 'sfv' => 'text/x-sfv',
  7323. 'sgi' => 'image/sgi',
  7324. 'sgl' => 'application/vnd.stardivision.writer-global',
  7325. 'sgm' => 'text/sgml',
  7326. 'sgml' => 'text/sgml',
  7327. 'sh' => 'application/x-sh',
  7328. 'shar' => 'application/x-shar',
  7329. 'shf' => 'application/shf+xml',
  7330. 'sid' => 'image/x-mrsid-image',
  7331. 'sig' => 'application/pgp-signature',
  7332. 'sil' => 'audio/silk',
  7333. 'silo' => 'model/mesh',
  7334. 'sis' => 'application/vnd.symbian.install',
  7335. 'sisx' => 'application/vnd.symbian.install',
  7336. 'sit' => 'application/x-stuffit',
  7337. 'sitx' => 'application/x-stuffitx',
  7338. 'skd' => 'application/vnd.koan',
  7339. 'skm' => 'application/vnd.koan',
  7340. 'skp' => 'application/vnd.koan',
  7341. 'skt' => 'application/vnd.koan',
  7342. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  7343. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  7344. 'slt' => 'application/vnd.epson.salt',
  7345. 'sm' => 'application/vnd.stepmania.stepchart',
  7346. 'smf' => 'application/vnd.stardivision.math',
  7347. 'smi' => 'application/smil+xml',
  7348. 'smil' => 'application/smil+xml',
  7349. 'smv' => 'video/x-smv',
  7350. 'smzip' => 'application/vnd.stepmania.package',
  7351. 'snd' => 'audio/basic',
  7352. 'snf' => 'application/x-font-snf',
  7353. 'so' => 'application/octet-stream',
  7354. 'spc' => 'application/x-pkcs7-certificates',
  7355. 'spf' => 'application/vnd.yamaha.smaf-phrase',
  7356. 'spl' => 'application/x-futuresplash',
  7357. 'spot' => 'text/vnd.in3d.spot',
  7358. 'spp' => 'application/scvp-vp-response',
  7359. 'spq' => 'application/scvp-vp-request',
  7360. 'spx' => 'audio/ogg',
  7361. 'sql' => 'application/x-sql',
  7362. 'src' => 'application/x-wais-source',
  7363. 'srt' => 'application/x-subrip',
  7364. 'sru' => 'application/sru+xml',
  7365. 'srx' => 'application/sparql-results+xml',
  7366. 'ssdl' => 'application/ssdl+xml',
  7367. 'sse' => 'application/vnd.kodak-descriptor',
  7368. 'ssf' => 'application/vnd.epson.ssf',
  7369. 'ssml' => 'application/ssml+xml',
  7370. 'st' => 'application/vnd.sailingtracker.track',
  7371. 'stc' => 'application/vnd.sun.xml.calc.template',
  7372. 'std' => 'application/vnd.sun.xml.draw.template',
  7373. 'stf' => 'application/vnd.wt.stf',
  7374. 'sti' => 'application/vnd.sun.xml.impress.template',
  7375. 'stk' => 'application/hyperstudio',
  7376. 'stl' => 'application/vnd.ms-pki.stl',
  7377. 'str' => 'application/vnd.pg.format',
  7378. 'stw' => 'application/vnd.sun.xml.writer.template',
  7379. 'sub' => 'image/vnd.dvb.subtitle',
  7380. 'sub' => 'text/vnd.dvb.subtitle',
  7381. 'sus' => 'application/vnd.sus-calendar',
  7382. 'susp' => 'application/vnd.sus-calendar',
  7383. 'sv4cpio' => 'application/x-sv4cpio',
  7384. 'sv4crc' => 'application/x-sv4crc',
  7385. 'svc' => 'application/vnd.dvb.service',
  7386. 'svd' => 'application/vnd.svd',
  7387. 'svg' => 'image/svg+xml',
  7388. 'svgz' => 'image/svg+xml',
  7389. 'swa' => 'application/x-director',
  7390. 'swf' => 'application/x-shockwave-flash',
  7391. 'swi' => 'application/vnd.aristanetworks.swi',
  7392. 'sxc' => 'application/vnd.sun.xml.calc',
  7393. 'sxd' => 'application/vnd.sun.xml.draw',
  7394. 'sxg' => 'application/vnd.sun.xml.writer.global',
  7395. 'sxi' => 'application/vnd.sun.xml.impress',
  7396. 'sxm' => 'application/vnd.sun.xml.math',
  7397. 'sxw' => 'application/vnd.sun.xml.writer',
  7398. 't' => 'text/troff',
  7399. 't3' => 'application/x-t3vm-image',
  7400. 'taglet' => 'application/vnd.mynfc',
  7401. 'tao' => 'application/vnd.tao.intent-module-archive',
  7402. 'tar' => 'application/x-tar',
  7403. 'tcap' => 'application/vnd.3gpp2.tcap',
  7404. 'tcl' => 'application/x-tcl',
  7405. 'teacher' => 'application/vnd.smart.teacher',
  7406. 'tei' => 'application/tei+xml',
  7407. 'teicorpus' => 'application/tei+xml',
  7408. 'tex' => 'application/x-tex',
  7409. 'texi' => 'application/x-texinfo',
  7410. 'texinfo' => 'application/x-texinfo',
  7411. 'text' => 'text/plain',
  7412. 'tfi' => 'application/thraud+xml',
  7413. 'tfm' => 'application/x-tex-tfm',
  7414. 'tga' => 'image/x-tga',
  7415. 'thmx' => 'application/vnd.ms-officetheme',
  7416. 'tif' => 'image/tiff',
  7417. 'tiff' => 'image/tiff',
  7418. 'tmo' => 'application/vnd.tmobile-livetv',
  7419. 'torrent' => 'application/x-bittorrent',
  7420. 'tpl' => 'application/vnd.groove-tool-template',
  7421. 'tpt' => 'application/vnd.trid.tpt',
  7422. 'tr' => 'text/troff',
  7423. 'tra' => 'application/vnd.trueapp',
  7424. 'trm' => 'application/x-msterminal',
  7425. 'tsd' => 'application/timestamped-data',
  7426. 'tsv' => 'text/tab-separated-values',
  7427. 'ttc' => 'application/x-font-ttf',
  7428. 'ttf' => 'application/x-font-ttf',
  7429. 'ttl' => 'text/turtle',
  7430. 'twd' => 'application/vnd.simtech-mindmapper',
  7431. 'twds' => 'application/vnd.simtech-mindmapper',
  7432. 'txd' => 'application/vnd.genomatix.tuxedo',
  7433. 'txf' => 'application/vnd.mobius.txf',
  7434. 'txt' => 'text/plain',
  7435. 'u32' => 'application/x-authorware-bin',
  7436. 'udeb' => 'application/x-debian-package',
  7437. 'ufd' => 'application/vnd.ufdl',
  7438. 'ufdl' => 'application/vnd.ufdl',
  7439. 'ulx' => 'application/x-glulx',
  7440. 'umj' => 'application/vnd.umajin',
  7441. 'unityweb' => 'application/vnd.unity',
  7442. 'uoml' => 'application/vnd.uoml+xml',
  7443. 'uri' => 'text/uri-list',
  7444. 'uris' => 'text/uri-list',
  7445. 'urls' => 'text/uri-list',
  7446. 'ustar' => 'application/x-ustar',
  7447. 'utz' => 'application/vnd.uiq.theme',
  7448. 'uu' => 'text/x-uuencode',
  7449. 'uva' => 'audio/vnd.dece.audio',
  7450. 'uvd' => 'application/vnd.dece.data',
  7451. 'uvf' => 'application/vnd.dece.data',
  7452. 'uvg' => 'image/vnd.dece.graphic',
  7453. 'uvh' => 'video/vnd.dece.hd',
  7454. 'uvi' => 'image/vnd.dece.graphic',
  7455. 'uvm' => 'video/vnd.dece.mobile',
  7456. 'uvp' => 'video/vnd.dece.pd',
  7457. 'uvs' => 'video/vnd.dece.sd',
  7458. 'uvt' => 'application/vnd.dece.ttml+xml',
  7459. 'uvu' => 'video/vnd.uvvu.mp4',
  7460. 'uvv' => 'video/vnd.dece.video',
  7461. 'uvva' => 'audio/vnd.dece.audio',
  7462. 'uvvd' => 'application/vnd.dece.data',
  7463. 'uvvf' => 'application/vnd.dece.data',
  7464. 'uvvg' => 'image/vnd.dece.graphic',
  7465. 'uvvh' => 'video/vnd.dece.hd',
  7466. 'uvvi' => 'image/vnd.dece.graphic',
  7467. 'uvvm' => 'video/vnd.dece.mobile',
  7468. 'uvvp' => 'video/vnd.dece.pd',
  7469. 'uvvs' => 'video/vnd.dece.sd',
  7470. 'uvvt' => 'application/vnd.dece.ttml+xml',
  7471. 'uvvu' => 'video/vnd.uvvu.mp4',
  7472. 'uvvv' => 'video/vnd.dece.video',
  7473. 'uvvx' => 'application/vnd.dece.unspecified',
  7474. 'uvvz' => 'application/vnd.dece.zip',
  7475. 'uvx' => 'application/vnd.dece.unspecified',
  7476. 'uvz' => 'application/vnd.dece.zip',
  7477. 'vcard' => 'text/vcard',
  7478. 'vcd' => 'application/x-cdlink',
  7479. 'vcf' => 'text/x-vcard',
  7480. 'vcg' => 'application/vnd.groove-vcard',
  7481. 'vcs' => 'text/x-vcalendar',
  7482. 'vcx' => 'application/vnd.vcx',
  7483. 'vis' => 'application/vnd.visionary',
  7484. 'viv' => 'video/vnd.vivo',
  7485. 'vob' => 'video/x-ms-vob',
  7486. 'vor' => 'application/vnd.stardivision.writer',
  7487. 'vox' => 'application/x-authorware-bin',
  7488. 'vrml' => 'model/vrml',
  7489. 'vsd' => 'application/vnd.visio',
  7490. 'vsf' => 'application/vnd.vsf',
  7491. 'vss' => 'application/vnd.visio',
  7492. 'vst' => 'application/vnd.visio',
  7493. 'vsw' => 'application/vnd.visio',
  7494. 'vtu' => 'model/vnd.vtu',
  7495. 'vxml' => 'application/voicexml+xml',
  7496. 'w3d' => 'application/x-director',
  7497. 'wad' => 'application/x-doom',
  7498. 'wav' => 'audio/x-wav',
  7499. 'wax' => 'audio/x-ms-wax',
  7500. 'wbmp' => 'image/vnd.wap.wbmp',
  7501. 'wbs' => 'application/vnd.criticaltools.wbs+xml',
  7502. 'wbxml' => 'application/vnd.wap.wbxml',
  7503. 'wcm' => 'application/vnd.ms-works',
  7504. 'wdb' => 'application/vnd.ms-works',
  7505. 'wdp' => 'image/vnd.ms-photo',
  7506. 'weba' => 'audio/webm',
  7507. 'webm' => 'video/webm',
  7508. 'webp' => 'image/webp',
  7509. 'wg' => 'application/vnd.pmi.widget',
  7510. 'wgt' => 'application/widget',
  7511. 'wks' => 'application/vnd.ms-works',
  7512. 'wm' => 'video/x-ms-wm',
  7513. 'wma' => 'audio/x-ms-wma',
  7514. 'wmd' => 'application/x-ms-wmd',
  7515. 'wmf' => 'application/x-msmetafile',
  7516. 'wml' => 'text/vnd.wap.wml',
  7517. 'wmlc' => 'application/vnd.wap.wmlc',
  7518. 'wmls' => 'text/vnd.wap.wmlscript',
  7519. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  7520. 'wmv' => 'video/x-ms-wmv',
  7521. 'wmx' => 'video/x-ms-wmx',
  7522. 'wmz' => 'application/x-ms-wmz',
  7523. 'wmz' => 'application/x-msmetafile',
  7524. 'woff' => 'application/font-woff',
  7525. 'wpd' => 'application/vnd.wordperfect',
  7526. 'wpl' => 'application/vnd.ms-wpl',
  7527. 'wps' => 'application/vnd.ms-works',
  7528. 'wqd' => 'application/vnd.wqd',
  7529. 'wri' => 'application/x-mswrite',
  7530. 'wrl' => 'model/vrml',
  7531. 'wsdl' => 'application/wsdl+xml',
  7532. 'wspolicy' => 'application/wspolicy+xml',
  7533. 'wtb' => 'application/vnd.webturbo',
  7534. 'wvx' => 'video/x-ms-wvx',
  7535. 'x32' => 'application/x-authorware-bin',
  7536. 'x3d' => 'model/x3d+xml',
  7537. 'x3db' => 'model/x3d+binary',
  7538. 'x3dbz' => 'model/x3d+binary',
  7539. 'x3dv' => 'model/x3d+vrml',
  7540. 'x3dvz' => 'model/x3d+vrml',
  7541. 'x3dz' => 'model/x3d+xml',
  7542. 'xaml' => 'application/xaml+xml',
  7543. 'xap' => 'application/x-silverlight-app',
  7544. 'xar' => 'application/vnd.xara',
  7545. 'xbap' => 'application/x-ms-xbap',
  7546. 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
  7547. 'xbm' => 'image/x-xbitmap',
  7548. 'xdf' => 'application/xcap-diff+xml',
  7549. 'xdm' => 'application/vnd.syncml.dm+xml',
  7550. 'xdp' => 'application/vnd.adobe.xdp+xml',
  7551. 'xdssc' => 'application/dssc+xml',
  7552. 'xdw' => 'application/vnd.fujixerox.docuworks',
  7553. 'xenc' => 'application/xenc+xml',
  7554. 'xer' => 'application/patch-ops-error+xml',
  7555. 'xfdf' => 'application/vnd.adobe.xfdf',
  7556. 'xfdl' => 'application/vnd.xfdl',
  7557. 'xht' => 'application/xhtml+xml',
  7558. 'xhtml' => 'application/xhtml+xml',
  7559. 'xhvml' => 'application/xv+xml',
  7560. 'xif' => 'image/vnd.xiff',
  7561. 'xla' => 'application/vnd.ms-excel',
  7562. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  7563. 'xlc' => 'application/vnd.ms-excel',
  7564. 'xlf' => 'application/x-xliff+xml',
  7565. 'xlm' => 'application/vnd.ms-excel',
  7566. 'xls' => 'application/vnd.ms-excel',
  7567. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  7568. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  7569. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  7570. 'xlt' => 'application/vnd.ms-excel',
  7571. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  7572. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  7573. 'xlw' => 'application/vnd.ms-excel',
  7574. 'xm' => 'audio/xm',
  7575. 'xml' => 'application/xml',
  7576. 'xo' => 'application/vnd.olpc-sugar',
  7577. 'xop' => 'application/xop+xml',
  7578. 'xpi' => 'application/x-xpinstall',
  7579. 'xpl' => 'application/xproc+xml',
  7580. 'xpm' => 'image/x-xpixmap',
  7581. 'xpr' => 'application/vnd.is-xpr',
  7582. 'xps' => 'application/vnd.ms-xpsdocument',
  7583. 'xpw' => 'application/vnd.intercon.formnet',
  7584. 'xpx' => 'application/vnd.intercon.formnet',
  7585. 'xsl' => 'application/xml',
  7586. 'xslt' => 'application/xslt+xml',
  7587. 'xsm' => 'application/vnd.syncml+xml',
  7588. 'xspf' => 'application/xspf+xml',
  7589. 'xul' => 'application/vnd.mozilla.xul+xml',
  7590. 'xvm' => 'application/xv+xml',
  7591. 'xvml' => 'application/xv+xml',
  7592. 'xwd' => 'image/x-xwindowdump',
  7593. 'xyz' => 'chemical/x-xyz',
  7594. 'xz' => 'application/x-xz',
  7595. 'yang' => 'application/yang',
  7596. 'yin' => 'application/yin+xml',
  7597. 'z1' => 'application/x-zmachine',
  7598. 'z2' => 'application/x-zmachine',
  7599. 'z3' => 'application/x-zmachine',
  7600. 'z4' => 'application/x-zmachine',
  7601. 'z5' => 'application/x-zmachine',
  7602. 'z6' => 'application/x-zmachine',
  7603. 'z7' => 'application/x-zmachine',
  7604. 'z8' => 'application/x-zmachine',
  7605. 'zaz' => 'application/vnd.zzazz.deck+xml',
  7606. 'zip' => 'application/zip',
  7607. 'zir' => 'application/vnd.zul',
  7608. 'zirz' => 'application/vnd.zul',
  7609. 'zmm' => 'application/vnd.handheld-entertainment+xml'
  7610. );
  7611. }
  7612. // Always run this
  7613. if(strpos($_SERVER['SCRIPT_NAME'], 'check.php') == false){
  7614. dependCheck();
  7615. }