functions.php 355 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659
  1. <?php
  2. // ===================================
  3. // Define Version
  4. define('INSTALLEDVERSION', '1.61');
  5. // ===================================
  6. $debugOrganizr = true;
  7. if($debugOrganizr == true && file_exists('debug.php')){ require_once('debug.php'); }
  8. use Kryptonit3\Sonarr\Sonarr;
  9. use Kryptonit3\SickRage\SickRage;
  10. //homepage order
  11. function homepageOrder(){
  12. $homepageOrder = array(
  13. "homepageOrdercustomhtml" => homepageOrdercustomhtml,
  14. "homepageOrdernotice" => homepageOrdernotice,
  15. "homepageOrderplexsearch" => homepageOrderplexsearch,
  16. "homepageOrderspeedtest" => homepageOrderspeedtest,
  17. "homepageOrdernzbget" => homepageOrdernzbget,
  18. "homepageOrdersabnzbd" => homepageOrdersabnzbd,
  19. "homepageOrderplexnowplaying" => homepageOrderplexnowplaying,
  20. "homepageOrderplexrecent" => homepageOrderplexrecent,
  21. "homepageOrderplexplaylist" => homepageOrderplexplaylist,
  22. "homepageOrderembynowplaying" => homepageOrderembynowplaying,
  23. "homepageOrderembyrecent" => homepageOrderembyrecent,
  24. "homepageOrderombi" => homepageOrderombi,
  25. "homepageOrdercalendar" => homepageOrdercalendar,
  26. "homepageOrdernoticeguest" => homepageOrdernoticeguest,
  27. "homepageOrdertransmisson" => homepageOrdertransmisson,
  28. );
  29. asort($homepageOrder);
  30. return $homepageOrder;
  31. }
  32. // Debugging output functions
  33. function debug_out($variable, $die = false) {
  34. $trace = debug_backtrace()[0];
  35. echo "<center><img height='200px' src='images/confused.png'></center>";
  36. echo "<center>Look's like something happened, here are the errors and perhaps how to fix them:</center>";
  37. echo '<pre style="white-space: pre-line; background-color: #f2f2f2; border: 2px solid black; border-radius: 5px; padding: 5px; margin: 5px;">'.$trace['file'].':'.$trace['line']."\n\n".print_r($variable, true).'</pre>';
  38. if ($die) { http_response_code(503); die(); }
  39. }
  40. //Cookie Function
  41. function coookie($type, $name, $value = '', $days = -1, $http = true){
  42. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  43. $Secure = true;
  44. $HTTPOnly = true;
  45. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  46. $Secure = true;
  47. $HTTPOnly = true;
  48. } else {
  49. $Secure = false;
  50. $HTTPOnly = false;
  51. }
  52. if(!$http){ $HTTPOnly = false; }
  53. $Path = '/';
  54. $Domain = $_SERVER['HTTP_HOST'];
  55. $Port = strpos($Domain, ':');
  56. if ($Port !== false) $Domain = substr($Domain, 0, $Port);
  57. $Port = strpos($Domain, ':');
  58. $check = substr_count($Domain, '.');
  59. if($check >= 3){
  60. if(is_numeric($Domain[0])){
  61. $Domain = '';
  62. }else{
  63. $Domain = '.'.explode('.',$Domain)[1].'.'.explode('.',$Domain)[2].'.'.explode('.',$Domain)[3];
  64. }
  65. }elseif($check == 2){
  66. $Domain = '.'.explode('.',$Domain)[1].'.'.explode('.',$Domain)[2];
  67. }elseif($check == 1){
  68. $Domain = '.' . $Domain;
  69. }else{
  70. $Domain = '';
  71. }
  72. if($type = 'set'){
  73. $_COOKIE[$name] = $value;
  74. header('Set-Cookie: ' . rawurlencode($name) . '=' . rawurlencode($value)
  75. . (empty($days) ? '' : '; expires=' . gmdate('D, d-M-Y H:i:s', time() + (86400 * $days)) . ' GMT')
  76. . (empty($Path) ? '' : '; path=' . $Path)
  77. . (empty($Domain) ? '' : '; domain=' . $Domain)
  78. . (!$Secure ? '' : '; secure')
  79. . (!$HTTPOnly ? '' : '; HttpOnly'), false);
  80. }elseif($type = 'delete'){
  81. unset($_COOKIE[$name]);
  82. header('Set-Cookie: ' . rawurlencode($name) . '=' . rawurlencode($value)
  83. . (empty($days) ? '' : '; expires=' . gmdate('D, d-M-Y H:i:s', time() - 3600) . ' GMT')
  84. . (empty($Path) ? '' : '; path=' . $Path)
  85. . (empty($Domain) ? '' : '; domain=' . $Domain)
  86. . (!$Secure ? '' : '; secure')
  87. . (!$HTTPOnly ? '' : '; HttpOnly'), false);
  88. }
  89. }
  90. // ==== Auth Plugins START ====
  91. if (function_exists('ldap_connect')) :
  92. // Pass credentials to LDAP backend
  93. function plugin_auth_ldap($username, $password) {
  94. $ldapServers = explode(',',AUTHBACKENDHOST);
  95. foreach($ldapServers as $key => $value) {
  96. // Calculate parts
  97. $digest = parse_url(trim($value));
  98. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:'ldap'));
  99. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  100. $port = (isset($digest['port'])?$digest['port']:(strtolower($scheme)=='ldap'?389:636));
  101. // Reassign
  102. $ldapServers[$key] = $scheme.'://'.$host.':'.$port;
  103. }
  104. // returns true or false
  105. $ldap = ldap_connect(implode(' ',$ldapServers));
  106. if(empty(AUTHBACKENDDOMAINFORMAT)){
  107. if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
  108. writeLog("success", "LDAP authentication success");
  109. return true;
  110. } else {
  111. writeLog("error", "LDAP could not authenticate");
  112. return false;
  113. }
  114. }else{
  115. ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
  116. ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
  117. $bind = @ldap_bind($ldap, sprintf(AUTHBACKENDDOMAINFORMAT, $username), $password);
  118. if ($bind) {
  119. writeLog("success", "LDAP authentication success");
  120. return true;
  121. } else {
  122. writeLog("error", "LDPA could not authenticate");
  123. return false;
  124. }
  125. }
  126. writeLog("error", "LDAP could not authenticate");
  127. return false;
  128. }
  129. else :
  130. // Ldap Auth Missing Dependancy
  131. function plugin_auth_ldap_disabled() {
  132. return 'LDAP - Disabled (Dependancy: php-ldap missing!)';
  133. }
  134. endif;
  135. // Pass credentials to FTP backend
  136. function plugin_auth_ftp($username, $password) {
  137. // Calculate parts
  138. $digest = parse_url(AUTHBACKENDHOST);
  139. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:(function_exists('ftp_ssl_connect')?'ftps':'ftp')));
  140. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  141. $port = (isset($digest['port'])?$digest['port']:21);
  142. // Determine Connection Type
  143. if ($scheme == 'ftps') {
  144. $conn_id = ftp_ssl_connect($host, $port, 20);
  145. } elseif ($scheme == 'ftp') {
  146. $conn_id = ftp_connect($host, $port, 20);
  147. } else {
  148. debug_out('Invalid FTP scheme. Use ftp or ftps');
  149. writeLog("error", "invalid FTP scheme");
  150. return false;
  151. }
  152. // Check if valid FTP connection
  153. if ($conn_id) {
  154. // Attempt login
  155. @$login_result = ftp_login($conn_id, $username, $password);
  156. ftp_close($conn_id);
  157. // Return Result
  158. if ($login_result) {
  159. writeLog("success", "$username authenticated");
  160. return true;
  161. } else {
  162. writeLog("error", "$username could not authenticate");
  163. return false;
  164. }
  165. } else {
  166. return false;
  167. }
  168. return false;
  169. }
  170. // Pass credentials to Emby Backend
  171. function plugin_auth_emby_local($username, $password) {
  172. $embyAddress = qualifyURL(EMBYURL);
  173. $headers = array(
  174. 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"',
  175. 'Content-Type' => 'application/json',
  176. );
  177. $body = array(
  178. 'Username' => $username,
  179. 'Password' => sha1($password),
  180. 'PasswordMd5' => md5($password),
  181. );
  182. $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers);
  183. if (isset($response['content'])) {
  184. $json = json_decode($response['content'], true);
  185. if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
  186. // Login Success - Now Logout Emby Session As We No Longer Need It
  187. $headers = array(
  188. 'X-Mediabrowser-Token' => $json['AccessToken'],
  189. );
  190. $response = post_router($embyAddress.'/Sessions/Logout', array(), $headers);
  191. return true;
  192. }
  193. }
  194. return false;
  195. }
  196. if (function_exists('curl_version')) :
  197. // Authenticate Against Emby Local (first) and Emby Connect
  198. function plugin_auth_emby_all($username, $password) {
  199. $localResult = plugin_auth_emby_local($username, $password);
  200. if ($localResult) {
  201. return $localResult;
  202. } else {
  203. return plugin_auth_emby_connect($username, $password);
  204. }
  205. }
  206. // Authenicate against emby connect
  207. function plugin_auth_emby_connect($username, $password) {
  208. $embyAddress = qualifyURL(EMBYURL);
  209. // Get A User
  210. $connectId = '';
  211. $userIds = json_decode(@file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
  212. if (is_array($userIds)) {
  213. foreach ($userIds as $key => $value) { // Scan for this user
  214. if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
  215. if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
  216. $connectId = $value['ConnectUserId'];
  217. break;
  218. }
  219. }
  220. }
  221. if ($connectId) {
  222. $connectURL = 'https://connect.emby.media/service/user/authenticate';
  223. $headers = array(
  224. 'Accept'=> 'application/json',
  225. 'Content-Type' => 'application/x-www-form-urlencoded',
  226. );
  227. $body = array(
  228. 'nameOrEmail' => $username,
  229. 'rawpw' => $password,
  230. );
  231. $result = curl_post($connectURL, $body, $headers);
  232. if (isset($result['content'])) {
  233. $json = json_decode($result['content'], true);
  234. if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
  235. return array(
  236. 'email' => $json['User']['Email'],
  237. 'image' => $json['User']['ImageUrl'],
  238. );
  239. }
  240. }
  241. }
  242. }
  243. return false;
  244. }
  245. // Pass credentials to Plex Backend
  246. function plugin_auth_plex($username, $password) {
  247. // Quick out
  248. $isAdmin = false;
  249. if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
  250. writeLog("success", "Admin: ".$username." authenticated as plex Admin");
  251. $isAdmin = true;
  252. }
  253. //Get User List
  254. $userURL = 'https://plex.tv/pms/friends/all';
  255. $userHeaders = array(
  256. 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD),
  257. );
  258. libxml_use_internal_errors(true);
  259. $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
  260. if (is_array($userXML) || is_object($userXML)) {
  261. $isUser = false;
  262. $usernameLower = strtolower($username);
  263. foreach($userXML AS $child) {
  264. if(isset($child['username']) && strtolower($child['username']) == $usernameLower) {
  265. $isUser = true;
  266. writeLog("success", $usernameLower." was found in plex friends list");
  267. break;
  268. }
  269. }
  270. if ($isUser || $isAdmin) {
  271. //Login User
  272. $connectURL = 'https://plex.tv/users/sign_in.json';
  273. $headers = array(
  274. 'Accept'=> 'application/json',
  275. 'Content-Type' => 'application/x-www-form-urlencoded',
  276. 'X-Plex-Product' => 'Organizr',
  277. 'X-Plex-Version' => '1.0',
  278. 'X-Plex-Client-Identifier' => '01010101-10101010',
  279. );
  280. $body = array(
  281. 'user[login]' => $username,
  282. 'user[password]' => $password,
  283. );
  284. $result = curl_post($connectURL, $body, $headers);
  285. if (isset($result['content'])) {
  286. $json = json_decode($result['content'], true);
  287. if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && strtolower($json['user']['username']) == $usernameLower) {
  288. writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
  289. return array(
  290. 'email' => $json['user']['email'],
  291. 'image' => $json['user']['thumb'],
  292. 'token' => $json['user']['authToken'],
  293. 'type' => $isAdmin ? 'admin' : 'user',
  294. );
  295. }
  296. }
  297. }else{
  298. writeLog("error", "$username is not an authorized PLEX user or entered invalid password");
  299. }
  300. }else{
  301. writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");
  302. }
  303. return false;
  304. }
  305. else :
  306. // Plex Auth Missing Dependancy
  307. function plugin_auth_plex_disabled() {
  308. return 'Plex - Disabled (Dependancy: php-curl missing!)';
  309. }
  310. // Emby Connect Auth Missing Dependancy
  311. function plugin_auth_emby_connect_disabled() {
  312. return 'Emby Connect - Disabled (Dependancy: php-curl missing!)';
  313. }
  314. // Emby Both Auth Missing Dependancy
  315. function plugin_auth_emby_both_disabled() {
  316. return 'Emby Both - Disabled (Dependancy: php-curl missing!)';
  317. }
  318. endif;
  319. // ==== Auth Plugins END ====
  320. // ==== General Class Definitions START ====
  321. $userLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  322. class setLanguage {
  323. private $language = null;
  324. private $langCode = null;
  325. function __construct($language = false) {
  326. // Default
  327. if (!$language) {
  328. $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  329. }
  330. if (!file_exists("lang/{$language}.ini")) {
  331. $language = 'en';
  332. }
  333. $this->langCode = $language;
  334. $this->language = parse_ini_file("lang/{$language}.ini", false, INI_SCANNER_RAW);
  335. if (file_exists("lang/{$language}.cust.ini")) {
  336. foreach($tmp = parse_ini_file("lang/{$language}.cust.ini", false, INI_SCANNER_RAW) as $k => $v) {
  337. $this->language[$k] = $v;
  338. }
  339. }
  340. }
  341. public function getLang() {
  342. return $this->langCode;
  343. }
  344. public function translate($originalWord) {
  345. $getArg = func_num_args();
  346. if ($getArg > 1) {
  347. $allWords = func_get_args();
  348. array_shift($allWords);
  349. } else {
  350. $allWords = array();
  351. }
  352. $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null;
  353. if (!$translatedWord) {
  354. return ucwords(str_replace("_", " ", strtolower($originalWord)));
  355. //echo "WHOA!!!!!!! $originalWord";
  356. }
  357. $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES);
  358. return vsprintf($translatedWord, $allWords);
  359. }
  360. }
  361. $language = new setLanguage;
  362. // ==== General Class Definitions END ====
  363. // Direct request to curl if it exists, otherwise handle if not HTTPS
  364. function post_router($url, $data, $headers = array(), $referer='') {
  365. if (function_exists('curl_version')) {
  366. return curl_post($url, $data, $headers, $referer);
  367. } else {
  368. return post_request($url, $data, $headers, $referer);
  369. }
  370. }
  371. if (function_exists('curl_version')) :
  372. // Curl Post
  373. function curl_post($url, $data, $headers = array(), $referer='') {
  374. // Initiate cURL
  375. $curlReq = curl_init($url);
  376. // As post request
  377. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST");
  378. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  379. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  380. if(localURL($url)){
  381. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  382. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  383. }
  384. // Format Data
  385. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  386. case 'application/json':
  387. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  388. break;
  389. case 'application/x-www-form-urlencoded':
  390. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  391. break;
  392. default:
  393. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  394. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  395. }
  396. // Format Headers
  397. $cHeaders = array();
  398. foreach ($headers as $k => $v) {
  399. $cHeaders[] = $k.': '.$v;
  400. }
  401. if (count($cHeaders)) {
  402. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  403. }
  404. // Execute
  405. $result = curl_exec($curlReq);
  406. $httpcode = curl_getinfo($curlReq);
  407. // Close
  408. curl_close($curlReq);
  409. // Return
  410. return array('content'=>$result, 'http_code'=>$httpcode);
  411. }
  412. // Curl Put
  413. function curl_put($url, $data, $headers = array(), $referer='') {
  414. // Initiate cURL
  415. $curlReq = curl_init($url);
  416. // As post request
  417. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "PUT");
  418. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  419. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  420. if(localURL($url)){
  421. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  422. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  423. }
  424. // Format Data
  425. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  426. case 'application/json':
  427. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  428. break;
  429. case 'application/x-www-form-urlencoded':
  430. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  431. break;
  432. default:
  433. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  434. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  435. }
  436. // Format Headers
  437. $cHeaders = array();
  438. foreach ($headers as $k => $v) {
  439. $cHeaders[] = $k.': '.$v;
  440. }
  441. if (count($cHeaders)) {
  442. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  443. }
  444. // Execute
  445. $result = curl_exec($curlReq);
  446. $httpcode = curl_getinfo($curlReq);
  447. // Close
  448. curl_close($curlReq);
  449. // Return
  450. return array('content'=>$result, 'http_code'=>$httpcode);
  451. }
  452. //Curl Get Function
  453. function curl_get($url, $headers = array()) {
  454. // Initiate cURL
  455. $curlReq = curl_init($url);
  456. // As post request
  457. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET");
  458. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  459. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  460. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  461. if(localURL($url)){
  462. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  463. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  464. }
  465. // Format Headers
  466. $cHeaders = array();
  467. foreach ($headers as $k => $v) {
  468. $cHeaders[] = $k.': '.$v;
  469. }
  470. if (count($cHeaders)) {
  471. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  472. }
  473. // Execute
  474. $result = curl_exec($curlReq);
  475. // Close
  476. curl_close($curlReq);
  477. // Return
  478. return $result;
  479. }
  480. //Curl Delete Function
  481. function curl_delete($url, $headers = array()) {
  482. // Initiate cURL
  483. $curlReq = curl_init($url);
  484. // As post request
  485. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE");
  486. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  487. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  488. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  489. if(localURL($url)){
  490. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  491. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  492. }
  493. // Format Headers
  494. $cHeaders = array();
  495. foreach ($headers as $k => $v) {
  496. $cHeaders[] = $k.': '.$v;
  497. }
  498. if (count($cHeaders)) {
  499. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  500. }
  501. // Execute
  502. $result = curl_exec($curlReq);
  503. $httpcode = curl_getinfo($curlReq);
  504. // Close
  505. curl_close($curlReq);
  506. // Return
  507. return array('content'=>$result, 'http_code'=>$httpcode);
  508. }
  509. endif;
  510. //Case-Insensitive Function
  511. function in_arrayi($needle, $haystack) {
  512. return in_array(strtolower($needle), array_map('strtolower', $haystack));
  513. }
  514. // HTTP post request (Removes need for curl, probably useless)
  515. function post_request($url, $data, $headers = array(), $referer='') {
  516. // Adapted from http://stackoverflow.com/a/28387011/6810513
  517. // Convert the data array into URL Parameters like a=b&foo=bar etc.
  518. if (isset($headers['Content-Type'])) {
  519. switch ($headers['Content-Type']) {
  520. case 'application/json':
  521. $data = json_encode($data);
  522. break;
  523. case 'application/x-www-form-urlencoded':
  524. $data = http_build_query($data);
  525. break;
  526. }
  527. } else {
  528. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  529. $data = http_build_query($data);
  530. }
  531. // parse the given URL
  532. $urlDigest = parse_url($url);
  533. // extract host and path:
  534. $host = $urlDigest['host'];
  535. $path = $urlDigest['path'];
  536. if ($urlDigest['scheme'] != 'http') {
  537. die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')');
  538. }
  539. // open a socket connection on port 80 - timeout: 30 sec
  540. $fp = fsockopen($host, (isset($urlDigest['port'])?':'.$urlDigest['port']:80), $errno, $errstr, 30);
  541. if ($fp){
  542. // send the request headers:
  543. fputs($fp, "POST $path HTTP/1.1\r\n");
  544. fputs($fp, "Host: $host\r\n");
  545. if ($referer != '')
  546. fputs($fp, "Referer: $referer\r\n");
  547. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  548. foreach($headers as $k => $v) {
  549. fputs($fp, $k.": ".$v."\r\n");
  550. }
  551. fputs($fp, "Connection: close\r\n\r\n");
  552. fputs($fp, $data);
  553. $result = '';
  554. while(!feof($fp)) {
  555. // receive the results of the request
  556. $result .= fgets($fp, 128);
  557. }
  558. }
  559. else {
  560. return array(
  561. 'status' => 'err',
  562. 'error' => "$errstr ($errno)"
  563. );
  564. }
  565. // close the socket connection:
  566. fclose($fp);
  567. // split the result header from the content
  568. $result = explode("\r\n\r\n", $result, 2);
  569. $header = isset($result[0]) ? $result[0] : '';
  570. $content = isset($result[1]) ? $result[1] : '';
  571. // return as structured array:
  572. return array(
  573. 'status' => 'ok',
  574. 'header' => $header,
  575. 'content' => $content,
  576. );
  577. }
  578. // Format item from Emby for Carousel
  579. function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $moreInfo = false) {
  580. // Static Height
  581. $height = 444;
  582. // Get Item Details
  583. $itemDetails = json_decode(@file_get_contents($address.'/Items?Ids='.$item['Id'].'&api_key='.$token),true)['Items'][0];
  584. /*if (substr_count(EMBYURL, ':') == 2) {
  585. $URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  586. }else{
  587. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  588. }*/
  589. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  590. switch ($itemDetails['Type']) {
  591. case 'Episode':
  592. case 'Series':
  593. $title = (isset($itemDetails['SeriesName'])?$itemDetails['SeriesName']:"");
  594. $imageId = (isset($itemDetails['SeriesId'])?$itemDetails['SeriesId']:$itemDetails['Id']);
  595. $width = 300;
  596. $style = '';
  597. $image = 'slick-image-tall';
  598. if(!$nowPlaying){
  599. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  600. $key = $itemDetails['Id'] . "-list";
  601. $itemType = 'season';
  602. }else{
  603. $height = 281;
  604. $width = 500;
  605. $imageId = isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId'] : (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  606. $imageType = isset($itemDetails['ParentThumbItemId']) ? "Thumb" : (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  607. $key = (isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId']."-np" : "none-np");
  608. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  609. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  610. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  611. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  612. $stream = $moreInfo['PlayState']['PlayMethod'];
  613. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  614. $id = $moreInfo['DeviceId'];
  615. $streamInfo = buildStream(array(
  616. 'platform' => (string) $moreInfo['Client'],
  617. 'device' => (string) $moreInfo['DeviceName'],
  618. 'stream' => streamType($stream),
  619. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  620. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  621. ));
  622. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  623. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$itemDetails['Name'].'</h5>';
  624. $bottomTitle = '<small class="zero-m">S'.$itemDetails['ParentIndexNumber'].' · E'.$itemDetails['IndexNumber'].'</small>';
  625. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  626. }
  627. break;
  628. case 'MusicAlbum':
  629. case 'Audio':
  630. $title = $itemDetails['Name'];
  631. $imageId = $itemDetails['Id'];
  632. $width = 444;
  633. $style = '';
  634. $image = 'slick-image-short';
  635. if(!$nowPlaying){
  636. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  637. $key = $itemDetails['Id'] . "-list";
  638. $itemType = 'album';
  639. }else{
  640. $height = 281;
  641. $width = 500;
  642. $imageId = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  643. $imageType = (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  644. $key = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : "no-np") . "-np";
  645. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  646. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  647. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  648. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  649. $stream = $moreInfo['PlayState']['PlayMethod'];
  650. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  651. $id = $moreInfo['DeviceId'];
  652. $streamInfo = buildStream(array(
  653. 'platform' => (string) $moreInfo['Client'],
  654. 'device' => (string) $moreInfo['DeviceName'],
  655. 'stream' => streamType($stream),
  656. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  657. ));
  658. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  659. $topTitle = '<h5 class="text-center zero-m elip">'.$itemDetails['AlbumArtist'].' - '.$itemDetails['Album'].'</h5>';
  660. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  661. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  662. }
  663. break;
  664. case 'TvChannel':
  665. $title = $itemDetails['CurrentProgram']['Name'];
  666. $imageId = $itemDetails['Id'];
  667. $width = 300;
  668. $style = '';
  669. $image = 'slick-image-tall';
  670. if(!$nowPlaying){
  671. $imageType = "Primary";
  672. $key = $itemDetails['Id'] . "-list";
  673. }else{
  674. $height = 281;
  675. $width = 500;
  676. $imageType = "Thumb";
  677. $key = $itemDetails['Id'] . "-np";
  678. $useImage = "images/livetv.png";
  679. $watched = "0";
  680. $stream = $moreInfo['PlayState']['PlayMethod'];
  681. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  682. $id = $moreInfo['DeviceId'];
  683. $streamInfo = buildStream(array(
  684. 'platform' => (string) $moreInfo['Client'],
  685. 'device' => (string) $moreInfo['DeviceName'],
  686. 'stream' => streamType($stream),
  687. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  688. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  689. ));
  690. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  691. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  692. $bottomTitle = '<small class="zero-m">'.$itemDetails['Name'].' - '.$itemDetails['ChannelNumber'].'</small>';
  693. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  694. }
  695. break;
  696. default:
  697. $title = $itemDetails['Name'];
  698. $imageId = $itemDetails['Id'];
  699. $width = 300;
  700. $style = '';
  701. $image = 'slick-image-tall';
  702. if(!$nowPlaying){
  703. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  704. $key = $itemDetails['Id'] . "-list";
  705. $itemType = 'movie';
  706. }else{
  707. $height = 281;
  708. $width = 500;
  709. $imageType = isset($itemDetails['ImageTags']['Thumb']) ? "Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
  710. $key = $itemDetails['Id'] . "-np";
  711. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  712. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  713. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  714. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  715. $stream = $moreInfo['PlayState']['PlayMethod'];
  716. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  717. $id = $moreInfo['DeviceId'];
  718. $streamInfo = buildStream(array(
  719. 'platform' => (string) $moreInfo['Client'],
  720. 'device' => (string) $moreInfo['DeviceName'],
  721. 'stream' => streamType($stream),
  722. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  723. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  724. ));
  725. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  726. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  727. $bottomTitle = '<small class="zero-m">'.$moreInfo['NowPlayingItem']['ProductionYear'].'</small>';
  728. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  729. }
  730. }
  731. // If No Overview
  732. if (!isset($itemDetails['Overview'])) {
  733. $itemDetails['Overview'] = '';
  734. }
  735. $original_image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  736. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  737. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  738. $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'';
  739. }
  740. if($nowPlaying){
  741. if(!$imageType){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  742. if(!$imageId){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  743. }else{
  744. if(!$imageType){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  745. if(!$imageId){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  746. }
  747. if(isset($useImage)){ $image_url = $useImage; }
  748. // Assemble Item And Cache Into Array
  749. if($nowPlaying){
  750. //prettyPrint($itemDetails);
  751. 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>';
  752. }else{
  753. 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>';
  754. }
  755. }
  756. // Format item from Plex for Carousel
  757. function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $playlist = false) {
  758. // Static Height
  759. $height = 444;
  760. $widthOverride = 100;
  761. $playlist = ($playlist) ? " playlist-$playlist" : "";
  762. switch ($item['type']) {
  763. case 'season':
  764. $title = $item['parentTitle'];
  765. $summary = $item['parentSummary'];
  766. $width = 300;
  767. $image = 'slick-image-tall';
  768. $style = '';
  769. if(!$nowPlaying){
  770. $thumb = $item['thumb'];
  771. $key = $item['ratingKey'] . "-list";
  772. }else {
  773. $height = 281;
  774. $width = 500;
  775. $thumb = $item['art'];
  776. $key = $item['ratingKey'] . "-np";
  777. $elapsed = $item['viewOffset'];
  778. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  779. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  780. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  781. $stream = $item->Media->Part->Stream['decision'];
  782. $user = $role == "admin" ? $item->User['title'] : "";
  783. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  784. $streamInfo = buildStream(array(
  785. 'platform' => (string) $item->Player['platform'],
  786. 'device' => (string) $item->Player['device'],
  787. 'stream' => streamType($item->Media->Part['decision']),
  788. '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'].")",
  789. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  790. ));
  791. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  792. }
  793. break;
  794. case 'episode':
  795. $title = $item['grandparentTitle'];
  796. $summary = $item['title'];
  797. $width = 300;
  798. $image = 'slick-image-tall';
  799. $style = '';
  800. if(!$nowPlaying){
  801. $thumb = ($item['parentThumb'] ? $item['parentThumb'] : $item['grandparentThumb']);
  802. $key = $item['ratingKey'] . "-list";
  803. }else {
  804. $height = 281;
  805. $width = 500;
  806. $thumb = $item['art'];
  807. $key = $item['ratingKey'] . "-np";
  808. $elapsed = $item['viewOffset'];
  809. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  810. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  811. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  812. $stream = $item->Media->Part->Stream['decision'];
  813. $user = $role == "admin" ? $item->User['title'] : "";
  814. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  815. $streamInfo = buildStream(array(
  816. 'platform' => (string) $item->Player['platform'],
  817. 'device' => (string) $item->Player['device'],
  818. 'stream' => streamType($item->Media->Part['decision']),
  819. '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'].")",
  820. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  821. ));
  822. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  823. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$item['title'].'</h5>';
  824. $bottomTitle = '<small class="zero-m">S'.$item['parentIndex'].' · E'.$item['index'].'</small>';
  825. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  826. }
  827. break;
  828. case 'clip':
  829. $title = $item['title'];
  830. $summary = $item['summary'];
  831. $width = 300;
  832. $image = 'slick-image-tall';
  833. $style = '';
  834. if(!$nowPlaying){
  835. $thumb = $item['thumb'];
  836. $key = $item['ratingKey'] . "-list";
  837. }else {
  838. $height = 281;
  839. $width = 500;
  840. $thumb = $item['art'];
  841. $key = isset($item['ratingKey']) ? $item['ratingKey'] . "-np" : (isset($item['live']) ? "livetv.png" : ":)");
  842. $useImage = (isset($item['live']) ? "images/livetv.png" : null);
  843. $extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
  844. $elapsed = $item['viewOffset'];
  845. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  846. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  847. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  848. $stream = $item->Media->Part->Stream['decision'];
  849. $user = $role == "admin" ? $item->User['title'] : "";
  850. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  851. $streamInfo = buildStream(array(
  852. 'platform' => (string) $item->Player['platform'],
  853. 'device' => (string) $item->Player['device'],
  854. 'stream' => streamType($item->Media->Part['decision']),
  855. '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'].")",
  856. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  857. ));
  858. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  859. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  860. $bottomTitle = '<small class="zero-m">'.$extraInfo.'</small>';
  861. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  862. }
  863. break;
  864. case 'album':
  865. case 'track':
  866. $title = $item['parentTitle'];
  867. $summary = $item['title'];
  868. $image = 'slick-image-short';
  869. $style = 'left: 160px !important;';
  870. $item['ratingKey'] = $item['parentRatingKey'];
  871. if(!$nowPlaying){
  872. $width = 444;
  873. $thumb = $item['thumb'];
  874. $key = $item['ratingKey'] . "-list";
  875. }else {
  876. $height = 281;
  877. $width = 500;
  878. $thumb = ($item['art']) ? $item['art'] : $item['parentThumb'];
  879. $widthOverride = ($item['art']) ? 100 : 56;
  880. $key = $item['ratingKey'] . "-np";
  881. $elapsed = $item['viewOffset'];
  882. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  883. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  884. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  885. $stream = $item->Media->Part->Stream['decision'];
  886. $user = $role == "admin" ? $item->User['title'] : "";
  887. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  888. $streamInfo = buildStream(array(
  889. 'platform' => (string) $item->Player['platform'],
  890. 'device' => (string) $item->Player['device'],
  891. 'stream' => streamType($item->Media->Part['decision']),
  892. 'audio' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['channels']."ch)",
  893. ));
  894. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  895. $topTitle = '<h5 class="text-center zero-m elip">'.$item['grandparentTitle'].' - '.$item['title'].'</h5>';
  896. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  897. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  898. }
  899. break;
  900. default:
  901. $title = $item['title'];
  902. $summary = $item['summary'];
  903. $image = 'slick-image-tall';
  904. $style = '';
  905. if(!$nowPlaying){
  906. $width = 300;
  907. $thumb = $item['thumb'];
  908. $key = $item['ratingKey'] . "-list";
  909. }else {
  910. $height = 281;
  911. $width = 500;
  912. $thumb = $item['art'];
  913. $key = $item['ratingKey'] . "-np";
  914. $elapsed = $item['viewOffset'];
  915. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  916. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  917. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  918. $stream = $item->Media->Part->Stream['decision'];
  919. $user = $role == "admin" ? $item->User['title'] : "";
  920. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  921. $streamInfo = buildStream(array(
  922. 'platform' => (string) $item->Player['platform'],
  923. 'device' => (string) $item->Player['device'],
  924. 'stream' => streamType($item->Media->Part['decision']),
  925. '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'].")",
  926. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  927. ));
  928. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  929. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  930. $bottomTitle = '<small class="zero-m">'.$item['year'].'</small>';
  931. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  932. }
  933. }
  934. if (PLEXTABURL) {
  935. $address = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  936. }else{
  937. $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  938. }
  939. // If No Overview
  940. if (!isset($itemDetails['Overview'])) { $itemDetails['Overview'] = ''; }
  941. $original_image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  942. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  943. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  944. $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'';
  945. }
  946. if($nowPlaying){
  947. if(!$thumb){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  948. }else{
  949. if(!$thumb){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  950. }
  951. if(isset($useImage)){ $image_url = $useImage; }
  952. $openTab = (PLEXTABNAME) ? "true" : "false";
  953. // Assemble Item And Cache Into Array
  954. if($nowPlaying){
  955. 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>';
  956. }else{
  957. 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>';
  958. }
  959. }
  960. //$hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  961. //Recent Added
  962. function outputRecentAdded($header, $items, $script = false, $array, $type) {
  963. $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">';
  964. if(preg_grep("/item-movie/", $items)){
  965. $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>';
  966. }
  967. if(preg_grep("/item-season/", $items)){
  968. $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>';
  969. }
  970. if(preg_grep("/item-album/", $items)){
  971. $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>';
  972. }
  973. $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>';
  974. $hideMenu .= '</ul></div></div>';
  975. // If None Populate Empty Item
  976. if (!count($items)) {
  977. 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>';
  978. }else{
  979. $className = str_replace(' ', '', $header.' on '.$type);
  980. 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>':'');
  981. }
  982. }
  983. // Create Carousel
  984. function outputNowPlaying($header, $size, $type, $items, $script = false) {
  985. // If None Populate Empty Item
  986. if (!count($items)) {
  987. return '<div id="'.$type.'"></div>'.($script?'<script>'.$script.'</script>':'');
  988. }else{
  989. return '<div id="'.$type.'"><h5 class="zero-m big-box"><strong>'.$header.'</strong></h5>'.implode('',$items).'</div>'.($script?'<script>'.$script.'</script>':'');
  990. }
  991. }
  992. // Get Now Playing Streams From Emby
  993. function getEmbyStreams($size, $showNames, $role) {
  994. $address = qualifyURL(EMBYURL);
  995. $api = json_decode(@file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
  996. if (!is_array($api)) { return 'Could not load!'; }
  997. $playingItems = array();
  998. foreach($api as $key => $value) {
  999. if (isset($value['NowPlayingItem'])) {
  1000. $playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem'], true, $showNames, $role, $value);
  1001. }
  1002. }
  1003. return outputNowPlaying(translate('PLAYING_NOW_ON_EMBY')." ( ".count($playingItems)." Streams )", $size, 'streams-emby', $playingItems, ajaxLoop('emby-streams',NOWPLAYINGREFRESH));
  1004. }
  1005. // Get Now Playing Streams From Plex
  1006. function getPlexStreams($size, $showNames, $role){
  1007. $address = qualifyURL(PLEXURL);
  1008. // Perform API requests
  1009. $api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
  1010. libxml_use_internal_errors(true);
  1011. $api = simplexml_load_string($api);
  1012. if (is_array($api) || is_object($api)){
  1013. if (!$api->head->title){
  1014. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  1015. if (!$getServer) { return 'Could not load!'; }
  1016. // Identify the local machine
  1017. $gotServer = $getServer['machineIdentifier'];
  1018. $items = array();
  1019. foreach($api AS $child) {
  1020. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
  1021. }
  1022. return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." ( ".count($items)." Streams )", $size, 'streams-plex', $items, ajaxLoop('plex-streams',NOWPLAYINGREFRESH));
  1023. }else{
  1024. writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
  1025. }
  1026. }else{
  1027. writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
  1028. }
  1029. }
  1030. // Get Recent Content From Emby
  1031. function getEmbyRecent($array) {
  1032. $address = qualifyURL(EMBYURL);
  1033. $header = translate('RECENT_CONTENT');
  1034. // Currently Logged In User
  1035. $username = false;
  1036. if (isset($GLOBALS['USER'])) {
  1037. $username = strtolower($GLOBALS['USER']->username);
  1038. }
  1039. // Get A User
  1040. $userIds = json_decode(@file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
  1041. if (!is_array($userIds)) { return 'Could not load!'; }
  1042. $showPlayed = true;
  1043. foreach ($userIds as $value) { // Scan for admin user
  1044. if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
  1045. $userId = $value['Id'];
  1046. }
  1047. if ($username && strtolower($value['Name']) == $username) {
  1048. $userId = $value['Id'];
  1049. $showPlayed = false;
  1050. break;
  1051. }
  1052. }
  1053. // Get the latest Items
  1054. $latest = json_decode(@file_get_contents($address.'/Users/'.$userId.'/Items/Latest?EnableImages=false&Limit='.EMBYRECENTITEMS.'&api_key='.EMBYTOKEN.($showPlayed?'':'&IsPlayed=false')),true);
  1055. // For Each Item In Category
  1056. $items = array();
  1057. foreach ($latest as $k => $v) {
  1058. $type = (string) $v['Type'];
  1059. if(@$array[$type] == "true"){
  1060. $items[] = resolveEmbyItem($address, EMBYTOKEN, $v, false, false, false);
  1061. }
  1062. }
  1063. $array["movie"] = $array["Movie"];
  1064. $array["season"] = $array["Episode"];
  1065. $array["album"] = $array["MusicAlbum"];
  1066. unset($array["Movie"]);
  1067. unset($array["Episode"]);
  1068. unset($array["MusicAlbum"]);
  1069. unset($array["Series"]);
  1070. return outputRecentAdded($header, $items, ajaxLoop('emby-recent',RECENTREFRESH,'loadSlick();'), $array, 'Emby');
  1071. }
  1072. // Get Recent Content From Plex
  1073. function getPlexRecent($array){
  1074. $address = qualifyURL(PLEXURL);
  1075. $header = translate('RECENT_CONTENT');
  1076. // Perform Requests
  1077. $api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN);
  1078. libxml_use_internal_errors(true);
  1079. $api = simplexml_load_string($api);
  1080. if (is_array($api) || is_object($api)){
  1081. if (!$api->head->title){
  1082. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  1083. if (!$getServer) { return 'Could not load!'; }
  1084. // Identify the local machine
  1085. $gotServer = $getServer['machineIdentifier'];
  1086. $items = array();
  1087. foreach($api AS $child) {
  1088. $type = (string) $child['type'];
  1089. if($array[$type] == "true"){
  1090. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
  1091. }
  1092. }
  1093. return outputRecentAdded($header, $items, ajaxLoop('plex-recent',RECENTREFRESH,'loadSlick();'), $array, 'Plex');
  1094. }else{
  1095. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check token - if HTTPS, is cert valid");
  1096. }
  1097. }else{
  1098. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check URL - if HTTPS, is cert valid");
  1099. }
  1100. }
  1101. // Get Image From Emby
  1102. function getEmbyImage() {
  1103. $refresh = false;
  1104. $embyAddress = qualifyURL(EMBYURL);
  1105. if (!file_exists('images/cache')) {
  1106. mkdir('images/cache', 0777, true);
  1107. }
  1108. $itemId = $_GET['img'];
  1109. $key = $_GET['key'];
  1110. if(strpos($key, '$') !== false){
  1111. $key = explode('$', $key)[0];
  1112. $refresh = true;
  1113. }
  1114. $itemType = $_GET['type'];
  1115. $imgParams = array();
  1116. if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
  1117. if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
  1118. if(isset($itemId)) {
  1119. $image_src = $embyAddress . '/Items/'.$itemId.'/Images/'.$itemType.'?'.implode('&', $imgParams);
  1120. $cachefile = 'images/cache/'.$key.'.jpg';
  1121. $cachetime = 604800;
  1122. // Serve from the cache if it is younger than $cachetime
  1123. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh !== true) {
  1124. header("Content-type: image/jpeg");
  1125. @readfile($cachefile);
  1126. exit;
  1127. }
  1128. ob_start(); // Start the output buffer
  1129. header('Content-type: image/jpeg');
  1130. //@readfile($image_src);
  1131. echo @curl_get($image_src);
  1132. // Cache the output to a file
  1133. $fp = fopen($cachefile, 'wb');
  1134. fwrite($fp, ob_get_contents());
  1135. fclose($fp);
  1136. ob_end_flush(); // Send the output to the browser
  1137. die();
  1138. } else {
  1139. debug_out('Invalid Request',1);
  1140. }
  1141. }
  1142. // Get Image From Plex
  1143. function getPlexImage() {
  1144. $refresh = false;
  1145. $plexAddress = qualifyURL(PLEXURL);
  1146. if (!file_exists('images/cache')) {
  1147. mkdir('images/cache', 0777, true);
  1148. }
  1149. $image_url = $_GET['img'];
  1150. $key = $_GET['key'];
  1151. if(strpos($key, '$') !== false){
  1152. $key = explode('$', $key)[0];
  1153. $refresh = true;
  1154. }
  1155. $image_height = $_GET['height'];
  1156. $image_width = $_GET['width'];
  1157. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  1158. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  1159. $cachefile = 'images/cache/'.$key.'.jpg';
  1160. $cachetime = 604800;
  1161. // Serve from the cache if it is younger than $cachetime
  1162. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh == false) {
  1163. header("Content-type: image/jpeg");
  1164. @readfile($cachefile);
  1165. exit;
  1166. }
  1167. ob_start(); // Start the output buffer
  1168. header('Content-type: image/jpeg');
  1169. //@readfile($image_src);
  1170. echo @curl_get($image_src);
  1171. // Cache the output to a file
  1172. $fp = fopen($cachefile, 'wb');
  1173. fwrite($fp, ob_get_contents());
  1174. fclose($fp);
  1175. ob_end_flush(); // Send the output to the browser
  1176. die();
  1177. } else {
  1178. echo "Invalid Plex Request";
  1179. }
  1180. }
  1181. // Simplier access to class
  1182. function translate($string) {
  1183. if (isset($GLOBALS['language'])) {
  1184. return $GLOBALS['language']->translate($string);
  1185. } else {
  1186. return '!Translations Not Loaded!';
  1187. }
  1188. }
  1189. // Generate Random string
  1190. function randString($length = 10, $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  1191. $tmp = '';
  1192. for ($i = 0; $i < $length; $i++) {
  1193. $tmp .= substr(str_shuffle($chars), 0, 1);
  1194. }
  1195. return $tmp;
  1196. }
  1197. // Create config file in the return syntax
  1198. function createConfig($array, $path = 'config/config.php', $nest = 0) {
  1199. // Define Initial Value
  1200. $output = array();
  1201. // Sort Items
  1202. ksort($array);
  1203. // Update the current config version
  1204. if (!$nest) {
  1205. // Inject Current Version
  1206. $output[] = "\t'CONFIG_VERSION' => '".(isset($array['apply_CONFIG_VERSION'])?$array['apply_CONFIG_VERSION']:INSTALLEDVERSION)."'";
  1207. }
  1208. unset($array['CONFIG_VERSION']);
  1209. unset($array['apply_CONFIG_VERSION']);
  1210. // Process Settings
  1211. foreach ($array as $k => $v) {
  1212. $allowCommit = true;
  1213. switch (gettype($v)) {
  1214. case 'boolean':
  1215. $item = ($v?'true':'false');
  1216. break;
  1217. case 'integer':
  1218. case 'double':
  1219. case 'integer':
  1220. case 'NULL':
  1221. $item = $v;
  1222. break;
  1223. case 'string':
  1224. $item = "'".str_replace(array('\\',"'"),array('\\\\',"\'"),$v)."'";
  1225. break;
  1226. case 'array':
  1227. $item = createConfig($v, false, $nest+1);
  1228. break;
  1229. default:
  1230. $allowCommit = false;
  1231. }
  1232. if($allowCommit) {
  1233. $output[] = str_repeat("\t",$nest+1)."'$k' => $item";
  1234. }
  1235. }
  1236. // Build output
  1237. $output = (!$nest?"<?php\nreturn ":'')."array(\n".implode(",\n",$output)."\n".str_repeat("\t",$nest).')'.(!$nest?';':'');
  1238. if (!$nest && $path) {
  1239. $pathDigest = pathinfo($path);
  1240. @mkdir($pathDigest['dirname'], 0770, true);
  1241. if (file_exists($path)) {
  1242. rename($path, $pathDigest['dirname'].'/'.$pathDigest['filename'].'.bak.php');
  1243. }
  1244. $file = fopen($path, 'w');
  1245. fwrite($file, $output);
  1246. fclose($file);
  1247. if (file_exists($path)) {
  1248. return true;
  1249. }
  1250. writeLog("error", "config was unable to write");
  1251. return false;
  1252. } else {
  1253. writeLog("success", "config was updated with new values");
  1254. return $output;
  1255. }
  1256. }
  1257. // Load a config file written in the return syntax
  1258. function loadConfig($path = 'config/config.php') {
  1259. // Adapted from http://stackoverflow.com/a/14173339/6810513
  1260. if (!is_file($path)) {
  1261. return null;
  1262. } else {
  1263. return (array) call_user_func(function() use($path) {
  1264. return include($path);
  1265. });
  1266. }
  1267. }
  1268. // Commit new values to the configuration
  1269. function updateConfig($new, $current = false) {
  1270. // Get config if not supplied
  1271. if ($current === false) {
  1272. $current = loadConfig();
  1273. } else if (is_string($current) && is_file($current)) {
  1274. $current = loadConfig($current);
  1275. }
  1276. // Inject Parts
  1277. foreach ($new as $k => $v) {
  1278. $current[$k] = $v;
  1279. }
  1280. // Return Create
  1281. return createConfig($current);
  1282. }
  1283. // Inject Defaults As Needed
  1284. function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
  1285. if (is_string($path)) {
  1286. $loadedDefaults = loadConfig($path);
  1287. } else {
  1288. $loadedDefaults = $path;
  1289. }
  1290. return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
  1291. }
  1292. // support function for fillDefaultConfig()
  1293. function fillDefaultConfig_recurse($current, $defaults) {
  1294. foreach($defaults as $k => $v) {
  1295. if (!isset($current[$k])) {
  1296. $current[$k] = $v;
  1297. } else if (is_array($current[$k]) && is_array($v)) {
  1298. $current[$k] = fillDefaultConfig_recurse($current[$k], $v);
  1299. }
  1300. }
  1301. return $current;
  1302. };
  1303. // Define Scalar Variables (nest non-secular with underscores)
  1304. function defineConfig($array, $anyCase = true, $nest_prefix = false) {
  1305. foreach($array as $k => $v) {
  1306. if (is_scalar($v) && !defined($nest_prefix.$k)) {
  1307. define($nest_prefix.$k, $v, $anyCase);
  1308. } else if (is_array($v)) {
  1309. defineConfig($v, $anyCase, $nest_prefix.$k.'_');
  1310. }
  1311. }
  1312. }
  1313. // This function exists only because I am lazy
  1314. function configLazy($path = 'config/config.php') {
  1315. // Load config or default
  1316. if (file_exists($path)) {
  1317. $config = fillDefaultConfig(loadConfig($path));
  1318. } else {
  1319. $config = loadConfig('config/configDefaults.php');
  1320. }
  1321. if (is_array($config)) {
  1322. defineConfig($config);
  1323. }
  1324. return $config;
  1325. }
  1326. // Qualify URL
  1327. function qualifyURL($url) {
  1328. //local address?
  1329. if(substr($url, 0,1) == "/"){
  1330. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  1331. $protocol = "https://";
  1332. } else {
  1333. $protocol = "http://";
  1334. }
  1335. $url = $protocol.getServer().$url;
  1336. }
  1337. // Get Digest
  1338. $digest = parse_url($url);
  1339. // http/https
  1340. if (!isset($digest['scheme'])) {
  1341. if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096,32400,7878,8989,8182,8081,6789))) {
  1342. $scheme = 'http';
  1343. } else {
  1344. $scheme = 'https';
  1345. }
  1346. } else {
  1347. $scheme = $digest['scheme'];
  1348. }
  1349. // Host
  1350. $host = (isset($digest['host'])?$digest['host']:'');
  1351. // Port
  1352. $port = (isset($digest['port'])?':'.$digest['port']:'');
  1353. // Path
  1354. $path = (isset($digest['path'])?$digest['path']:'');
  1355. // Output
  1356. return $scheme.'://'.$host.$port.$path;
  1357. }
  1358. // Function to be called at top of each to allow upgrading environment as the spec changes
  1359. function upgradeCheck() {
  1360. // Upgrade to 1.31
  1361. if (file_exists('homepageSettings.ini.php')) {
  1362. $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
  1363. $homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
  1364. $databaseConfig = array_merge($databaseConfig, $homepageConfig);
  1365. $databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
  1366. foreach($databaseConfig as $k => $v) {
  1367. if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
  1368. $databaseData .= $k . " = \"" . $v . "\"\r\n";
  1369. }
  1370. write_ini_file($databaseData, 'databaseLocation.ini.php');
  1371. unlink('homepageSettings.ini.php');
  1372. unset($databaseData);
  1373. unset($homepageConfig);
  1374. }
  1375. // Upgrade to 1.32
  1376. if (file_exists('databaseLocation.ini.php')) {
  1377. // Load Existing
  1378. $config = parse_ini_file('databaseLocation.ini.php', true);
  1379. // Refactor
  1380. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['databaseLocation'].'/');
  1381. $config['user_home'] = $config['database_Location'].'users/';
  1382. unset($config['databaseLocation']);
  1383. // Turn Off Emby And Plex Recent
  1384. $config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
  1385. unset($config["embyPort"]);
  1386. $config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
  1387. unset($config["plexPort"]);
  1388. $config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
  1389. unset($config["nzbgetPort"]);
  1390. $config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
  1391. unset($config["sabnzbdPort"]);
  1392. $config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
  1393. unset($config["headphonesPort"]);
  1394. // Write config file
  1395. $config['CONFIG_VERSION'] = '1.32';
  1396. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][pre1.32].bak.php');
  1397. $createConfigSuccess = createConfig($config);
  1398. // Create new config
  1399. if ($createConfigSuccess) {
  1400. if (file_exists('config/config.php')) {
  1401. // Remove Old ini file
  1402. unlink('databaseLocation.ini.php');
  1403. } else {
  1404. debug_out('Something is not right here!');
  1405. }
  1406. } else {
  1407. debug_out('Couldn\'t create updated configuration.' ,1);
  1408. }
  1409. }
  1410. // Upgrade to 1.33
  1411. $config = loadConfig();
  1412. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
  1413. // Fix User Directory
  1414. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['database_Location'].'/');
  1415. $config['user_home'] = $config['database_Location'].'users/';
  1416. unset($config['USER_HOME']);
  1417. // Backend auth merge
  1418. if (isset($config['authBackendPort']) && !isset(parse_url($config['authBackendHost'])['port'])) {
  1419. $config['authBackendHost'] .= ':'.$config['authBackendPort'];
  1420. }
  1421. unset($config['authBackendPort']);
  1422. // If auth is being used move it to embyURL as that is now used in auth functions
  1423. 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')))) {
  1424. $config['embyURL'] = $config['authBackendHost'];
  1425. }
  1426. // Upgrade database to latest version
  1427. updateSQLiteDB($config['database_Location'],'1.32');
  1428. // Update Version and Commit
  1429. $config['apply_CONFIG_VERSION'] = '1.33';
  1430. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.32].bak.php');
  1431. $createConfigSuccess = createConfig($config);
  1432. unset($config);
  1433. }
  1434. // Upgrade to 1.34
  1435. $config = loadConfig();
  1436. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.34')) {
  1437. // Upgrade database to latest version
  1438. updateSQLiteDB($config['database_Location'],'1.33');
  1439. // Update Version and Commit
  1440. $config['CONFIG_VERSION'] = '1.34';
  1441. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.33].bak.php');
  1442. $createConfigSuccess = createConfig($config);
  1443. unset($config);
  1444. }
  1445. // Upgrade to 1.40
  1446. $config = loadConfig();
  1447. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.40')) {
  1448. // Upgrade database to latest version
  1449. updateSQLiteDB($config['database_Location'],'1.38');
  1450. // Update Version and Commit
  1451. $config['CONFIG_VERSION'] = '1.40';
  1452. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.38].bak.php');
  1453. $createConfigSuccess = createConfig($config);
  1454. unset($config);
  1455. }
  1456. // Upgrade to 1.50
  1457. $config = loadConfig();
  1458. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.50')) {
  1459. // Upgrade database to latest version
  1460. updateSQLiteDB($config['database_Location'],'1.40');
  1461. // Update Version and Commit
  1462. $config['CONFIG_VERSION'] = '1.50';
  1463. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.40].bak.php');
  1464. $createConfigSuccess = createConfig($config);
  1465. unset($config);
  1466. }
  1467. // Upgrade to 1.603
  1468. $config = loadConfig();
  1469. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.603')) {
  1470. // Update Version and Commit
  1471. $config['CONFIG_VERSION'] = '1.603';
  1472. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.601].bak.php');
  1473. $createConfigSuccess = createConfig($config);
  1474. unset($config);
  1475. if(file_exists('org.log')){
  1476. copy('org.log', DATABASE_LOCATION.'org.log');
  1477. unlink('org.log');
  1478. }
  1479. if(file_exists('loginLog.json')){
  1480. copy('loginLog.json', DATABASE_LOCATION.'loginLog.json');
  1481. unlink('loginLog.json');
  1482. }
  1483. }
  1484. return true;
  1485. }
  1486. // Get OS from server
  1487. function getOS(){
  1488. if(PHP_SHLIB_SUFFIX == "dll"){
  1489. return "win";
  1490. }else{
  1491. return "nix";
  1492. }
  1493. }
  1494. //Get Error by Server OS
  1495. function getError($os, $error){
  1496. $ini = (!empty(php_ini_loaded_file()) ? php_ini_loaded_file() : "php.ini");
  1497. $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'");
  1498. $errors = array(
  1499. 'pdo_sqlite' => array(
  1500. 'win' => '<b>PDO:SQLite</b> not enabled, uncomment ;extension=php_pdo_sqlite.dll in the file php.ini | '.$ext,
  1501. 'nix' => '<b>PDO:SQLite</b> not enabled, PHP7 -> run sudo apt-get install php7.0-sqlite | PHP5 -> run sudo apt-get install php5-sqlite',
  1502. ),
  1503. 'sqlite3' => array(
  1504. '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',
  1505. 'nix' => '<b>SQLite3</b> not enabled, run sudo apt-get install php-sqlite3',
  1506. ),
  1507. 'curl' => array(
  1508. 'win' => '<b>cURL</b> not enabled, uncomment ;extension=php_curl.dll in the file php.ini | '.$ext,
  1509. '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',
  1510. ),
  1511. 'zip' => array(
  1512. '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',
  1513. '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',
  1514. ),
  1515. );
  1516. return (isset($errors[$error][$os]) ? $errors[$error][$os] : 'No Error Info Found');
  1517. }
  1518. // Check if all software dependancies are met
  1519. function dependCheck() {
  1520. $output = array();
  1521. $i = 1;
  1522. if (!extension_loaded('pdo_sqlite')) { $output["Step $i"] = getError(getOS(),'pdo_sqlite'); $i++; }
  1523. if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; }
  1524. if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; }
  1525. //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
  1526. if ($output) {
  1527. $output["Step $i"] = "<b>Restart PHP and/or Webserver to apply changes</b>"; $i++;
  1528. $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++;
  1529. debug_out($output,1);
  1530. }
  1531. return true;
  1532. }
  1533. // Process file uploads
  1534. function uploadFiles($path, $ext_mask = null) {
  1535. if (isset($_FILES) && count($_FILES)) {
  1536. require_once('class.uploader.php');
  1537. $uploader = new Uploader();
  1538. $data = $uploader->upload($_FILES['files'], array(
  1539. 'limit' => 10,
  1540. 'maxSize' => 10,
  1541. 'extensions' => $ext_mask,
  1542. 'required' => false,
  1543. 'uploadDir' => str_replace('//','/',$path.'/'),
  1544. 'title' => array('name'),
  1545. 'removeFiles' => true,
  1546. 'replace' => true,
  1547. ));
  1548. if($data['isComplete']){
  1549. $files = $data['data'];
  1550. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1551. echo json_encode($files['metas'][0]['name']);
  1552. }
  1553. if($data['hasErrors']){
  1554. $errors = $data['errors'];
  1555. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1556. echo json_encode($errors);
  1557. }
  1558. } else {
  1559. writeLog("error", "image was not uploaded");
  1560. echo json_encode('No files submitted!');
  1561. }
  1562. }
  1563. // Process file uploads
  1564. function uploadAvatar($path, $ext_mask = null) {
  1565. if (isset($_FILES) && count($_FILES)) {
  1566. require_once('class.uploader.php');
  1567. $uploader = new Uploader();
  1568. $data = $uploader->upload($_FILES['files'], array(
  1569. 'limit' => 10,
  1570. 'maxSize' => 10,
  1571. 'extensions' => $ext_mask,
  1572. 'required' => false,
  1573. 'uploadDir' => str_replace('//','/',$path.'/'),
  1574. 'title' => array('name'),
  1575. 'removeFiles' => true,
  1576. 'replace' => true,
  1577. ));
  1578. if($data['isComplete']){
  1579. $files = $data['data'];
  1580. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1581. echo json_encode($files['metas'][0]['name']);
  1582. }
  1583. if($data['hasErrors']){
  1584. $errors = $data['errors'];
  1585. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1586. echo json_encode($errors);
  1587. }
  1588. } else {
  1589. writeLog("error", "image was not uploaded");
  1590. echo json_encode('No files submitted!');
  1591. }
  1592. }
  1593. // Remove file
  1594. function removeFiles($path) {
  1595. if(is_file($path)) {
  1596. writeLog("success", "file was removed");
  1597. unlink($path);
  1598. } else {
  1599. writeLog("error", "file was not removed");
  1600. echo json_encode('No file specified for removal!');
  1601. }
  1602. }
  1603. // Lazy select options
  1604. function resolveSelectOptions($array, $selected = '', $multi = false) {
  1605. $output = array();
  1606. $selectedArr = ($multi?explode('|', $selected):array());
  1607. foreach ($array as $key => $value) {
  1608. if (is_array($value)) {
  1609. if (isset($value['optgroup'])) {
  1610. $output[] = '<optgroup label="'.$key.'">';
  1611. foreach($value['optgroup'] as $k => $v) {
  1612. $output[] = '<option value="'.$v['value'].'"'.($selected===$v['value']||in_array($v['value'],$selectedArr)?' selected':'').(isset($v['disabled']) && $v['disabled']?' disabled':'').'>'.$k.'</option>';
  1613. }
  1614. } else {
  1615. $output[] = '<option value="'.$value['value'].'"'.($selected===$value['value']||in_array($value['value'],$selectedArr)?' selected':'').(isset($value['disabled']) && $value['disabled']?' disabled':'').'>'.$key.'</option>';
  1616. }
  1617. } else {
  1618. $output[] = '<option value="'.$value.'"'.($selected===$value||in_array($value,$selectedArr)?' selected':'').'>'.$key.'</option>';
  1619. }
  1620. }
  1621. return implode('',$output);
  1622. }
  1623. // Check if user is allowed to continue
  1624. function qualifyUser($type, $errOnFail = false) {
  1625. if (!isset($GLOBALS['USER'])) {
  1626. require_once("user.php");
  1627. $GLOBALS['USER'] = new User('registration_callback');
  1628. }
  1629. if (is_bool($type)) {
  1630. if ($type === true) {
  1631. $authorized = ($GLOBALS['USER']->authenticated == true);
  1632. } else {
  1633. $authorized = true;
  1634. }
  1635. } elseif (is_string($type) || is_array($type)) {
  1636. if ($type !== 'false') {
  1637. if (!is_array($type)) {
  1638. $type = explode('|',$type);
  1639. }
  1640. $authorized = ($GLOBALS['USER']->authenticated && in_array($GLOBALS['USER']->role,$type));
  1641. } else {
  1642. $authorized = true;
  1643. }
  1644. } else {
  1645. debug_out('Invalid Syntax!',1);
  1646. }
  1647. if (!$authorized && $errOnFail) {
  1648. if ($GLOBALS['USER']->authenticated) {
  1649. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401');
  1650. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401\'</script>';
  1651. } else {
  1652. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999');
  1653. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999\'</script>';
  1654. }
  1655. debug_out('Not Authorized' ,1);
  1656. } else {
  1657. return $authorized;
  1658. }
  1659. }
  1660. // Build an (optionally) tabbed settings page.
  1661. function buildSettings($array) {
  1662. /*
  1663. array(
  1664. 'title' => '',
  1665. 'id' => '',
  1666. 'fields' => array( See buildField() ),
  1667. 'tabs' => array(
  1668. array(
  1669. 'title' => '',
  1670. 'id' => '',
  1671. 'image' => '',
  1672. 'fields' => array( See buildField() ),
  1673. ),
  1674. ),
  1675. );
  1676. */
  1677. $notifyExplode = explode("-", NOTIFYEFFECT);
  1678. $fieldFunc = function($fieldArr) {
  1679. $fields = '<div class="row">';
  1680. foreach($fieldArr as $key => $value) {
  1681. $isSingle = isset($value['type']);
  1682. if ($isSingle) { $value = array($value); }
  1683. $tmpField = '';
  1684. $sizeLg = max(floor(12/count($value)),2);
  1685. $sizeMd = max(floor(($isSingle?12:6)/count($value)),3);
  1686. foreach($value as $k => $v) {
  1687. $tmpField .= buildField($v, 12, $sizeMd, $sizeLg);
  1688. }
  1689. $fields .= ($isSingle?$tmpField:'<div class="row col-sm-12 content-form">'.$tmpField.'</div>');
  1690. }
  1691. $fields .= '</div>';
  1692. return $fields;
  1693. };
  1694. $fields = (isset($array['fields'])?$fieldFunc($array['fields']):'');
  1695. $tabSelectors = array();
  1696. $tabContent = array();
  1697. if (isset($array['tabs'])) {
  1698. foreach($array['tabs'] as $key => $value) {
  1699. $id = (isset($value['id'])?$value['id']:randString(32));
  1700. $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>';
  1701. $tabContent[$key] = '<div class="tab-pane big-box fade'.($tabContent?'':' active in').'" id="tab-'.$id.'">'.$fieldFunc($value['fields']).'</div>';
  1702. }
  1703. }
  1704. $pageID = (isset($array['id'])?$array['id']:str_replace(array(' ','"',"'"),array('_'),strtolower($array['id'])));
  1705. $extraClick = ($pageID == 'appearance_settings' ? "$('#advanced_settings_form_submit').click();console.log('add theme settings');" : "");
  1706. return '
  1707. <div class="email-body">
  1708. <div class="email-header gray-bg">
  1709. <button type="button" class="btn btn-danger btn-sm waves close-button"><i class="fa fa-close"></i></button>
  1710. <button id="'.$pageID.'_form_submit" class="btn waves btn-labeled btn-success btn btn-sm text-uppercase waves-effect waves-float save-btn-form">
  1711. <span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save
  1712. </button>
  1713. <h1>'.$array['title'].'</h1>
  1714. </div>
  1715. <div class="email-inner small-box">
  1716. <div class="email-inner-section">
  1717. <div class="small-box fade in" id="'.$pageID.'_frame">
  1718. <div class="col-lg-12">
  1719. '.(isset($array['customBeforeForm'])?$array['customBeforeForm']:'').'
  1720. <form class="content-form" name="'.$pageID.'" id="'.$pageID.'_form" onsubmit="return false;">
  1721. '.$fields.($tabContent?'
  1722. <div class="tabbable tabs-with-bg" id="'.$pageID.'_tabs">
  1723. <ul class="nav nav-tabs apps">
  1724. '.implode('', $tabSelectors).'
  1725. </ul>
  1726. <div class="clearfix"></div>
  1727. <div class="tab-content">
  1728. '.implode('', $tabContent).'
  1729. </div>
  1730. </div>':'').'
  1731. </form>
  1732. '.(isset($array['customAfterForm'])?$array['customAfterForm']:'').'
  1733. </div>
  1734. </div>
  1735. </div>
  1736. </div>
  1737. </div>
  1738. <script>
  1739. $(document).ready(function() {
  1740. $(\'#'.$pageID.'_form\').find(\'input, select, textarea\').on(\'change\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1741. var '.$pageID.'Validate = function() { if (this.value && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { $(this).addClass(\'invalid\'); } else { $(this).removeClass(\'invalid\'); } };
  1742. $(\'#'.$pageID.'_form\').find(\'input[pattern]\').each('.$pageID.'Validate).on(\'keyup\', '.$pageID.'Validate);
  1743. $(\'#'.$pageID.'_form\').find(\'select[multiple]\').on(\'change click\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1744. $(\'#'.$pageID.'_form_submit\').on(\'click\', function () {
  1745. var newVals = {};
  1746. var hasVals = false;
  1747. var errorFields = [];
  1748. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').each(function() {
  1749. hasVals = true;
  1750. if (this.type == \'checkbox\') {
  1751. newVals[this.name] = this.checked;
  1752. } else if ($(this).hasClass(\'summernote\')) {
  1753. newVals[$(this).attr(\'name\')] = $(this).siblings(\'.note-editor\').find(\'.panel-body\').html();
  1754. } else {
  1755. if (this.value && this.pattern && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { errorFields.push(this.name); }
  1756. var fieldVal = $(this).val();
  1757. if (typeof fieldVal == \'object\') {
  1758. if (typeof fieldVal.join == \'function\') {
  1759. fieldVal = fieldVal.join(\'|\');
  1760. } else {
  1761. fieldVal = JSON.stringify(fieldVal);
  1762. }
  1763. }
  1764. newVals[this.name] = fieldVal;
  1765. }
  1766. });
  1767. if (errorFields.length) {
  1768. parent.notify(\'Fields have errors: \'+errorFields.join(\', \')+\'!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1769. } else if (hasVals) {
  1770. console.log(newVals);
  1771. ajax_request(\'POST\', \''.(isset($array['submitAction'])?$array['submitAction']:'update-config').'\', newVals, function(data, code) {
  1772. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').removeAttr(\'data-changed\');
  1773. });
  1774. '.$extraClick.'
  1775. } else {
  1776. parent.notify(\'Nothing to update!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1777. }
  1778. return false;
  1779. });
  1780. '.(isset($array['onready'])?$array['onready']:'').'
  1781. });
  1782. </script>
  1783. ';
  1784. }
  1785. // Build Settings Fields
  1786. function buildField($params, $sizeSm = 12, $sizeMd = 12, $sizeLg = 12) {
  1787. /*
  1788. array(
  1789. 'type' => '',
  1790. 'placeholder' => '',
  1791. 'label' => '',
  1792. 'labelTranslate' => '',
  1793. 'assist' => '',
  1794. 'name' => '',
  1795. 'pattern' => '',
  1796. 'options' => array( // For SELECT only
  1797. 'Display' => 'value',
  1798. ),
  1799. )
  1800. */
  1801. // Tags
  1802. $tags = array();
  1803. foreach(array('placeholder','style','disabled','readonly','pattern','min','max','required','onkeypress','onchange','onfocus','onleave','href','onclick','autocomplete') as $value) {
  1804. if (isset($params[$value])) {
  1805. if (is_string($params[$value])) { $tags[] = $value.'="'.$params[$value].'"';
  1806. } else if ($params[$value] === true) { $tags[] = $value; }
  1807. }
  1808. }
  1809. $format = (isset($params['format']) && in_array($params['format'],array(false,'colour','color'))?$params['format']:false);
  1810. $name = (isset($params['name'])?$params['name']:(isset($params['id'])?$params['id']:''));
  1811. $id = (isset($params['id'])?$params['id']:(isset($params['name'])?$params['name'].'_id':randString(32)));
  1812. $val = (isset($params['value'])?$params['value']:'');
  1813. $class = (isset($params['class'])?' '.$params['class']:'');
  1814. $wrapClass = (isset($params['wrapClass'])?$params['wrapClass']:'form-content');
  1815. $assist = (isset($params['assist'])?' - i.e. '.$params['assist']:'');
  1816. $label = (isset($params['labelTranslate'])?translate($params['labelTranslate']):(isset($params['label'])?$params['label']:''));
  1817. $labelOut = '<p class="help-text">'.$label.$assist.'</p>';
  1818. // Field Design
  1819. switch ($params['type']) {
  1820. case 'text':
  1821. case 'number':
  1822. case 'password':
  1823. $field = '<input id="'.$id.'" name="'.$name.'" type="'.$params['type'].'" class="form-control material input-sm'.$class.'" '.implode(' ',$tags).' autocorrect="off" autocapitalize="off" value="'.$val.'">';
  1824. break;
  1825. case 'select':
  1826. case 'dropdown':
  1827. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control material input-sm" '.implode(' ',$tags).'>'.resolveSelectOptions($params['options'], $val).'</select>';
  1828. break;
  1829. case 'select-multi':
  1830. case 'dropdown-multi':
  1831. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control input-sm" '.implode(' ',$tags).' multiple="multiple">'.resolveSelectOptions($params['options'], $val, true).'</select>';
  1832. break;
  1833. case 'check':
  1834. case 'checkbox':
  1835. case 'toggle':
  1836. $checked = ((is_bool($val) && $val) || trim($val) === 'true'?' checked':'');
  1837. $colour = (isset($params['colour'])?$params['colour']:'success');
  1838. $labelOut = '<label for="'.$id.'"></label>'.$label;
  1839. $field = '<input id="'.$id.'" name="'.$name.'" type="checkbox" class="switcher switcher-'.$colour.' '.$class.'" '.implode(' ',$tags).' data-value="'.$val.'"'.$checked.'>';
  1840. break;
  1841. case 'radio':
  1842. $labelOut = '';
  1843. $checked = ((is_bool($val) && $val) || ($val && trim($val) !== 'false')?' checked':'');
  1844. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1845. $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>';
  1846. break;
  1847. case 'date':
  1848. $field = 'Unsupported, planned.';
  1849. break;
  1850. case 'hidden':
  1851. return '<input id="'.$id.'" name="'.$name.'" type="hidden" class="'.$class.'" '.implode(' ',$tags).' value="'.$val.'">';
  1852. break;
  1853. case 'header':
  1854. $labelOut = '';
  1855. $headType = (isset($params['value'])?$params['value']:3);
  1856. $field = '<h'.$headType.' class="'.$class.'" '.implode(' ',$tags).'>'.$label.'</h'.$headType.'>';
  1857. break;
  1858. case 'button':
  1859. $labelOut = '';
  1860. $icon = (isset($params['icon'])?$params['icon']:'flask');
  1861. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1862. $bDropdown = (isset($params['buttonDrop'])?$params['buttonDrop']:'');
  1863. $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>':'');
  1864. break;
  1865. case 'textarea':
  1866. $rows = (isset($params['rows'])?$params['rows']:5);
  1867. $field = '<textarea id="'.$id.'" name="'.$name.'" class="form-control'.$class.'" rows="'.$rows.'" '.implode(' ',$tags).'>'.$val.'</textarea>';
  1868. break;
  1869. case 'custom':
  1870. // Settings
  1871. $settings = array(
  1872. '$id' => $id,
  1873. '$name' => $name,
  1874. '$val' => $val,
  1875. '$label' => $label,
  1876. '$labelOut' => $labelOut,
  1877. );
  1878. // Get HTML
  1879. $html = (isset($params['html'])?$params['html']:'Nothing Specified!');
  1880. // If LabelOut is in html dont print it twice
  1881. $labelOut = (strpos($html,'$label')!==false?'':$labelOut);
  1882. // Replace variables in settings
  1883. $html = preg_replace_callback('/\$\w+\b/', function ($match) use ($settings) { return (isset($settings[$match[0]])?$settings[$match[0]]:'{'.$match[0].' is undefined}'); }, $html);
  1884. // Build Field
  1885. $field = '<div id="'.$id.'_html" class="custom-field">'.$html.'</div>';
  1886. break;
  1887. case 'space':
  1888. $labelOut = '';
  1889. $field = str_repeat('<br>', (isset($params['value'])?$params['value']:1));
  1890. break;
  1891. default:
  1892. $field = 'Unsupported field type';
  1893. break;
  1894. }
  1895. // Field Formats
  1896. switch ($format) {
  1897. case 'colour': // Fuckin Eh, Canada!
  1898. case 'color':
  1899. $labelBef = '<center>'.$label.'</center>';
  1900. $wrapClass = 'gray-bg colour-field';
  1901. $labelAft = '';
  1902. $field = str_replace(' material input-sm','',$field);
  1903. break;
  1904. default:
  1905. $labelBef = '';
  1906. $labelAft = $labelOut;
  1907. }
  1908. return '<div class="'.$wrapClass.' col-sm-'.$sizeSm.' col-md-'.$sizeMd.' col-lg-'.$sizeLg.'">'.$labelBef.$field.$labelAft.'</div>';
  1909. }
  1910. // Tab Settings Generation
  1911. function printTabRow($data) {
  1912. $hidden = false;
  1913. if ($data===false) {
  1914. $hidden = true;
  1915. $data = array( // New Tab Defaults
  1916. 'id' => 'new',
  1917. 'name' => '',
  1918. 'url' => '',
  1919. 'icon' => 'fa-diamond',
  1920. 'iconurl' => '',
  1921. 'active' => 'true',
  1922. 'user' => 'true',
  1923. 'guest' => 'true',
  1924. 'window' => 'false',
  1925. 'splash' => 'true',
  1926. 'ping' => 'false',
  1927. 'ping_url' => '',
  1928. 'defaultz' => '',
  1929. );
  1930. }
  1931. $image = '<span style="font: normal normal normal 30px/1 FontAwesome;" class="fa fa-hand-paper-o"></span>';
  1932. $output = '
  1933. <li id="tab-'.$data['id'].'" class="list-group-item" style="position: relative; left: 0px; top: 0px; '.($hidden?' display: none;':'').'">
  1934. <tab class="content-form form-inline">
  1935. <div class="row">
  1936. '.buildField(array(
  1937. 'type' => 'custom',
  1938. '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>',
  1939. ),12,1,1).'
  1940. '.buildField(array(
  1941. 'type' => 'hidden',
  1942. 'id' => 'tab-'.$data['id'].'-id',
  1943. 'name' => 'id['.$data['id'].']',
  1944. 'value' => $data['id'],
  1945. ),12,2,1).'
  1946. '.buildField(array(
  1947. 'type' => 'text',
  1948. 'id' => 'tab-'.$data['id'].'-name',
  1949. 'name' => 'name['.$data['id'].']',
  1950. 'required' => true,
  1951. 'placeholder' => 'Organizr Homepage',
  1952. 'labelTranslate' => 'TAB_NAME',
  1953. 'value' => $data['name'],
  1954. 'class' => 'darkBold',
  1955. ),12,2,1).'
  1956. '.buildField(array(
  1957. 'type' => 'text',
  1958. 'id' => 'tab-'.$data['id'].'-url',
  1959. 'name' => 'url['.$data['id'].']',
  1960. 'required' => true,
  1961. 'placeholder' => 'homepage.php',
  1962. 'labelTranslate' => 'TAB_URL',
  1963. 'value' => $data['url'],
  1964. 'class' => 'darkBold',
  1965. ),12,2,2).'
  1966. '.buildField(array(
  1967. 'type' => 'text',
  1968. 'id' => 'tab-'.$data['id'].'-iconurl',
  1969. 'name' => 'iconurl['.$data['id'].']',
  1970. 'placeholder' => 'images/organizr.png',
  1971. 'labelTranslate' => 'ICON_URL',
  1972. 'value' => $data['iconurl'],
  1973. 'class' => 'darkBold',
  1974. ),12,2,1).'
  1975. '.buildField(array(
  1976. 'type' => 'text',
  1977. 'id' => 'tab-'.$data['id'].'-icon',
  1978. 'name' => 'icon['.$data['id'].']',
  1979. 'placeholder' => 'fa-icon',
  1980. 'labelTranslate' => 'OR_ICON_NAME',
  1981. 'value' => $data['icon'],
  1982. 'class' => 'iconpickeradd darkBold',
  1983. ),12,1,1).'
  1984. '.buildField(array(
  1985. 'type' => 'text',
  1986. 'id' => 'tab-'.$data['id'].'-ping_url',
  1987. 'name' => 'ping_url['.$data['id'].']',
  1988. 'placeholder' => 'host:port',
  1989. 'labelTranslate' => 'PING_URL',
  1990. 'value' => $data['ping_url'],
  1991. 'class' => 'darkBold',
  1992. ),12,2,1).'
  1993. '.buildField(array(
  1994. 'type' => 'radio',
  1995. 'labelTranslate' => 'DEFAULT',
  1996. 'name' => 'defaultz['.$data['id'].']',
  1997. 'value' => $data['defaultz'],
  1998. 'onclick' => "$('[type=radio][id!=\''+this.id+'\']').each(function() { this.checked=false; });",
  1999. ),12,1,1).'
  2000. '.buildField(array(
  2001. 'type' => 'button',
  2002. 'icon' => 'chevron-down',
  2003. 'buttonType' => 'success',
  2004. 'labelTranslate' => 'MORE',
  2005. 'onclick' => "$(this).parent().parent().parent().find('.slideInUp').toggle()",
  2006. 'class' => 'toggleTabExtra',
  2007. ),12,1,1).'
  2008. '.buildField(array(
  2009. 'type' => 'button',
  2010. 'icon' => 'trash',
  2011. 'buttonType' => 'danger',
  2012. 'labelTranslate' => 'REMOVE',
  2013. 'onclick' => "$(this).parents('li').remove();",
  2014. ),12,1,1).'</div><div id = "tab-'.$data['id'].'-row" class = "row animated slideInUp" style = "display:none;" ><div></div>
  2015. '.buildField(array(
  2016. 'type' => 'checkbox',
  2017. 'labelTranslate' => 'ACTIVE',
  2018. 'name' => 'active['.$data['id'].']',
  2019. 'value' => $data['active'],
  2020. ),12,1,1).'
  2021. '.buildField(array(
  2022. 'type' => 'checkbox',
  2023. 'labelTranslate' => 'USER',
  2024. 'colour' => 'primary',
  2025. 'name' => 'user['.$data['id'].']',
  2026. 'value' => $data['user'],
  2027. ),12,1,1).'
  2028. '.buildField(array(
  2029. 'type' => 'checkbox',
  2030. 'labelTranslate' => 'GUEST',
  2031. 'colour' => 'warning',
  2032. 'name' => 'guest['.$data['id'].']',
  2033. 'value' => $data['guest'],
  2034. ),12,1,1).'
  2035. '.buildField(array(
  2036. 'type' => 'checkbox',
  2037. 'labelTranslate' => 'NO_IFRAME',
  2038. 'colour' => 'danger',
  2039. 'name' => 'window['.$data['id'].']',
  2040. 'value' => $data['window'],
  2041. ),12,1,1).'
  2042. '.buildField(array(
  2043. 'type' => 'checkbox',
  2044. 'labelTranslate' => 'SPLASH',
  2045. 'colour' => 'success',
  2046. 'name' => 'splash['.$data['id'].']',
  2047. 'value' => $data['splash'],
  2048. ),12,1,1).'
  2049. '.buildField(array(
  2050. 'type' => 'checkbox',
  2051. 'labelTranslate' => 'PING',
  2052. 'colour' => 'success',
  2053. 'name' => 'ping['.$data['id'].']',
  2054. 'value' => $data['ping'],
  2055. ),12,1,1).'
  2056. </div>
  2057. </tab>
  2058. </li>
  2059. ';
  2060. return $output;
  2061. }
  2062. // Timezone array
  2063. function timezoneOptions() {
  2064. $output = array();
  2065. $timezones = array();
  2066. $regions = array(
  2067. 'Africa' => DateTimeZone::AFRICA,
  2068. 'America' => DateTimeZone::AMERICA,
  2069. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2070. 'Arctic' => DateTimeZone::ARCTIC,
  2071. 'Asia' => DateTimeZone::ASIA,
  2072. 'Atlantic' => DateTimeZone::ATLANTIC,
  2073. 'Australia' => DateTimeZone::AUSTRALIA,
  2074. 'Europe' => DateTimeZone::EUROPE,
  2075. 'Indian' => DateTimeZone::INDIAN,
  2076. 'Pacific' => DateTimeZone::PACIFIC
  2077. );
  2078. foreach ($regions as $name => $mask) {
  2079. $zones = DateTimeZone::listIdentifiers($mask);
  2080. foreach($zones as $timezone) {
  2081. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2082. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2083. $output[$name]['optgroup'][substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm]['value'] = $timezone;
  2084. }
  2085. }
  2086. return $output;
  2087. }
  2088. // Build Database
  2089. function createSQLiteDB($path = false) {
  2090. if ($path === false) {
  2091. if (DATABASE_LOCATION){
  2092. $path = DATABASE_LOCATION;
  2093. } else {
  2094. debug_out('No Path Specified!');
  2095. }
  2096. }
  2097. if (!is_file($path.'users.db') || filesize($path.'users.db') <= 0) {
  2098. if (!isset($GLOBALS['file_db'])) {
  2099. $GLOBALS['file_db'] = new PDO('sqlite:'.$path.'users.db');
  2100. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2101. }
  2102. // Create Users
  2103. $users = $GLOBALS['file_db']->query('CREATE TABLE `users` (
  2104. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2105. `username` TEXT UNIQUE,
  2106. `password` TEXT,
  2107. `email` TEXT,
  2108. `token` TEXT,
  2109. `role` TEXT,
  2110. `active` TEXT,
  2111. `last` TEXT,
  2112. `auth_service` TEXT DEFAULT \'internal\'
  2113. );');
  2114. // Create Tabs
  2115. $tabs = $GLOBALS['file_db']->query('CREATE TABLE `tabs` (
  2116. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2117. `order` INTEGER,
  2118. `users_id` INTEGER,
  2119. `name` TEXT,
  2120. `url` TEXT,
  2121. `defaultz` TEXT,
  2122. `active` TEXT,
  2123. `user` TEXT,
  2124. `guest` TEXT,
  2125. `icon` TEXT,
  2126. `iconurl` TEXT,
  2127. `window` TEXT,
  2128. `splash` TEXT,
  2129. `ping` TEXT,
  2130. `ping_url` TEXT
  2131. );');
  2132. // Create Options
  2133. $options = $GLOBALS['file_db']->query('CREATE TABLE `options` (
  2134. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2135. `users_id` INTEGER UNIQUE,
  2136. `title` TEXT UNIQUE,
  2137. `topbar` TEXT,
  2138. `bottombar` TEXT,
  2139. `sidebar` TEXT,
  2140. `hoverbg` TEXT,
  2141. `topbartext` TEXT,
  2142. `activetabBG` TEXT,
  2143. `activetabicon` TEXT,
  2144. `activetabtext` TEXT,
  2145. `inactiveicon` TEXT,
  2146. `inactivetext` TEXT,
  2147. `loading` TEXT,
  2148. `hovertext` TEXT
  2149. );');
  2150. // Create Invites
  2151. $invites = $GLOBALS['file_db']->query('CREATE TABLE `invites` (
  2152. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2153. `code` TEXT UNIQUE,
  2154. `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  2155. `email` TEXT,
  2156. `username` TEXT,
  2157. `dateused` TIMESTAMP,
  2158. `usedby` TEXT,
  2159. `ip` TEXT,
  2160. `valid` TEXT
  2161. );');
  2162. writeLog("success", "database created/saved");
  2163. return $users && $tabs && $options && $invites;
  2164. } else {
  2165. writeLog("error", "database was unable to be created/saved");
  2166. return false;
  2167. }
  2168. }
  2169. // Upgrade Database
  2170. function updateSQLiteDB($db_path = false, $oldVerNum = false) {
  2171. if (!$db_path) {
  2172. if (defined('DATABASE_LOCATION')) {
  2173. $db_path = DATABASE_LOCATION;
  2174. } else {
  2175. debug_out('No Path Specified',1);
  2176. }
  2177. }
  2178. if (!isset($GLOBALS['file_db'])) {
  2179. $GLOBALS['file_db'] = new PDO('sqlite:'.$db_path.'users.db');
  2180. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2181. }
  2182. // Cache current DB
  2183. $cache = array();
  2184. foreach($GLOBALS['file_db']->query('SELECT name FROM sqlite_master WHERE type="table";') as $table) {
  2185. foreach($GLOBALS['file_db']->query('SELECT * FROM '.$table['name'].';') as $key => $row) {
  2186. foreach($row as $k => $v) {
  2187. if (is_string($k)) {
  2188. $cache[$table['name']][$key][$k] = $v;
  2189. }
  2190. }
  2191. }
  2192. }
  2193. // Remove Current Database
  2194. $GLOBALS['file_db'] = null;
  2195. $pathDigest = pathinfo($db_path.'users.db');
  2196. if (file_exists($db_path.'users.db')) {
  2197. rename($db_path.'users.db', $pathDigest['dirname'].'/'.$pathDigest['filename'].'['.date('Y-m-d_H-i-s').']'.($oldVerNum?'['.$oldVerNum.']':'').'.bak.db');
  2198. }
  2199. // Create New Database
  2200. $success = createSQLiteDB($db_path);
  2201. // Restore Items
  2202. if ($success) {
  2203. foreach($cache as $table => $tableData) {
  2204. if ($tableData) {
  2205. $queryBase = 'INSERT INTO '.$table.' (`'.implode('`,`',array_keys(current($tableData))).'`) values ';
  2206. $insertValues = array();
  2207. reset($tableData);
  2208. foreach($tableData as $key => $value) {
  2209. $insertValues[] = '('.implode(',',array_map(function($d) {
  2210. return (isset($d)?$GLOBALS['file_db']->quote($d):'null');
  2211. }, $value)).')';
  2212. }
  2213. $GLOBALS['file_db']->query($queryBase.implode(',',$insertValues).';');
  2214. }
  2215. }
  2216. writeLog("success", "database values have been updated");
  2217. return true;
  2218. } else {
  2219. writeLog("error", "database values unable to be updated");
  2220. return false;
  2221. }
  2222. }
  2223. // Commit colours to database
  2224. function updateDBOptions($values) {
  2225. if (!isset($GLOBALS['file_db'])) {
  2226. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2227. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2228. }
  2229. // Commit new values to database
  2230. if ($GLOBALS['file_db']->query('UPDATE options SET '.implode(',',array_map(function($d, $k) {
  2231. return '`'.$k.'` = '.(isset($d)?"'".addslashes($d)."'":'null');
  2232. }, $values, array_keys($values))).';')->rowCount()) {
  2233. return true;
  2234. } else if ($GLOBALS['file_db']->query('INSERT OR IGNORE INTO options (`'.implode('`,`',array_keys($values)).'`) VALUES (\''.implode("','",$values).'\');')->rowCount()) {
  2235. writeLog("success", "database values for options table have been updated");
  2236. return true;
  2237. } else {
  2238. writeLog("error", "database values for options table unable to be updated");
  2239. return false;
  2240. }
  2241. }
  2242. // Send AJAX notification
  2243. function sendNotification($success, $message = false, $send = true) {
  2244. $notifyExplode = explode("-", NOTIFYEFFECT);
  2245. if ($success) {
  2246. $msg = array(
  2247. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_SAVED").'</strong>'),
  2248. 'icon' => 'floppy-o',
  2249. 'type' => 'success',
  2250. 'length' => '5000',
  2251. 'layout' => $notifyExplode[0],
  2252. 'effect' => $notifyExplode[1],
  2253. );
  2254. } else {
  2255. $msg = array(
  2256. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_NOT_SAVED").'</strong>'),
  2257. 'icon' => 'floppy-o',
  2258. 'type' => 'failed',
  2259. 'length' => '5000',
  2260. 'layout' => $notifyExplode[0],
  2261. 'effect' => $notifyExplode[1],
  2262. );
  2263. }
  2264. // Send and kill script?
  2265. if ($send) {
  2266. header('Content-Type: application/json');
  2267. echo json_encode(array('notify'=>$msg));
  2268. die();
  2269. }
  2270. return $msg;
  2271. }
  2272. // Load colours from the database
  2273. function loadAppearance() {
  2274. // Defaults
  2275. $defaults = array(
  2276. 'title' => 'Organizr',
  2277. 'topbartext' => '#66D9EF',
  2278. 'topbar' => '#333333',
  2279. 'bottombar' => '#333333',
  2280. 'sidebar' => '#393939',
  2281. 'hoverbg' => '#AD80FD',
  2282. 'activetabBG' => '#F92671',
  2283. 'activetabicon' => '#FFFFFF',
  2284. 'activetabtext' => '#FFFFFF',
  2285. 'inactiveicon' => '#66D9EF',
  2286. 'inactivetext' => '#66D9EF',
  2287. 'loading' => '#66D9EF',
  2288. 'hovertext' => '#000000',
  2289. );
  2290. if (DATABASE_LOCATION) {
  2291. if(is_file(DATABASE_LOCATION.'users.db') && filesize(DATABASE_LOCATION.'users.db') > 0){
  2292. if (!isset($GLOBALS['file_db'])) {
  2293. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2294. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2295. }
  2296. // Database Lookup
  2297. $options = $GLOBALS['file_db']->query('SELECT * FROM options');
  2298. // Replace defaults with filled options
  2299. foreach($options as $row) {
  2300. foreach($defaults as $key => $value) {
  2301. if (isset($row[$key]) && $row[$key]) {
  2302. $defaults[$key] = $row[$key];
  2303. }
  2304. }
  2305. }
  2306. }
  2307. }
  2308. // Return the Results
  2309. return $defaults;
  2310. }
  2311. // Delete Database
  2312. function deleteDatabase() {
  2313. unset($_COOKIE['Organizr']);
  2314. setcookie('Organizr', '', time() - 3600, '/');
  2315. unset($_COOKIE['OrganizrU']);
  2316. setcookie('OrganizrU', '', time() - 3600, '/');
  2317. $GLOBALS['file_db'] = null;
  2318. unlink(DATABASE_LOCATION.'users.db');
  2319. foreach(glob(substr_replace($userdirpath, "", -1).'/*') as $file) {
  2320. if(is_dir($file)) {
  2321. rmdir($file);
  2322. } elseif (!is_dir($file)) {
  2323. unlink($file);
  2324. }
  2325. }
  2326. rmdir($userdirpath);
  2327. writeLog("success", "database has been deleted");
  2328. return true;
  2329. }
  2330. // Upgrade the installation
  2331. function upgradeInstall($branch = 'master') {
  2332. function downloadFile($url, $path){
  2333. ini_set('max_execution_time',0);
  2334. $folderPath = "upgrade/";
  2335. if(!mkdir($folderPath)){
  2336. writeLog("error", "organizr could not create upgrade folder");
  2337. }
  2338. $newfname = $folderPath . $path;
  2339. $file = fopen ($url, 'rb');
  2340. if ($file) {
  2341. $newf = fopen ($newfname, 'wb');
  2342. if ($newf) {
  2343. while(!feof($file)) {
  2344. fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
  2345. }
  2346. }
  2347. }else{
  2348. writeLog("error", "organizr could not download $url");
  2349. }
  2350. if ($file) {
  2351. fclose($file);
  2352. writeLog("success", "organizr finished downloading the github zip file");
  2353. }else{
  2354. writeLog("error", "organizr could not download the github zip file");
  2355. }
  2356. if ($newf) {
  2357. fclose($newf);
  2358. writeLog("success", "organizr created upgrade zip file from github zip file");
  2359. }else{
  2360. writeLog("error", "organizr could not create upgrade zip file from github zip file");
  2361. }
  2362. }
  2363. function unzipFile($zipFile){
  2364. $zip = new ZipArchive;
  2365. $extractPath = "upgrade/";
  2366. if($zip->open($extractPath . $zipFile) != "true"){
  2367. writeLog("error", "organizr could not unzip upgrade.zip");
  2368. }else{
  2369. writeLog("success", "organizr unzipped upgrade.zip");
  2370. }
  2371. /* Extract Zip File */
  2372. $zip->extractTo($extractPath);
  2373. $zip->close();
  2374. }
  2375. // Function to remove folders and files
  2376. function rrmdir($dir) {
  2377. if (is_dir($dir)) {
  2378. $files = scandir($dir);
  2379. foreach ($files as $file)
  2380. if ($file != "." && $file != "..") rrmdir("$dir/$file");
  2381. rmdir($dir);
  2382. }
  2383. else if (file_exists($dir)) unlink($dir);
  2384. }
  2385. // Function to Copy folders and files
  2386. function rcopy($src, $dst) {
  2387. if (is_dir ( $src )) {
  2388. if (!file_exists($dst)) : mkdir ( $dst ); endif;
  2389. $files = scandir ( $src );
  2390. foreach ( $files as $file )
  2391. if ($file != "." && $file != "..")
  2392. rcopy ( "$src/$file", "$dst/$file" );
  2393. } else if (file_exists ( $src ))
  2394. copy ( $src, $dst );
  2395. }
  2396. $url = 'https://github.com/causefx/Organizr/archive/'.$branch.'.zip';
  2397. $file = "upgrade.zip";
  2398. $source = __DIR__ . '/upgrade/Organizr-'.$branch.'/';
  2399. $cleanup = __DIR__ . "/upgrade/";
  2400. $destination = __DIR__ . "/";
  2401. writeLog("success", "starting organizr upgrade process");
  2402. downloadFile($url, $file);
  2403. unzipFile($file);
  2404. rcopy($source, $destination);
  2405. writeLog("success", "new organizr files copied");
  2406. rrmdir($cleanup);
  2407. writeLog("success", "organizr upgrade folder removed");
  2408. writeLog("success", "organizr has been updated");
  2409. return true;
  2410. }
  2411. // Transmission Items
  2412. function transmissionConnect($list = 'listgroups') {
  2413. $url = qualifyURL(TRANSMISSIONURL);
  2414. $digest = parse_url($url);
  2415. $scheme = (isset($digest['scheme'])) ? $digest['scheme'].'://' : 'http://';
  2416. $host = (isset($digest['host'])) ? $digest['host'] : '';
  2417. $port = (isset($digest['port'])) ? ':'.$digest['port'] : '';
  2418. $path = (isset($digest['path'])) ? $digest['path'] : '';
  2419. $passwordInclude = (TRANSMISSIONUSERNAME != '' && TRANSMISSIONPASSWORD != '') ? TRANSMISSIONUSERNAME.':'.TRANSMISSIONPASSWORD."@" : '';
  2420. $url = $scheme.$passwordInclude.$host.$port.$path.'/rpc';
  2421. $contextopts = array(
  2422. 'http' => array(
  2423. 'user_agent' => 'HTTP_UA',
  2424. 'ignore_errors' => true,
  2425. )
  2426. );
  2427. $context = stream_context_create( $contextopts );
  2428. $fp = @fopen( $url, 'r', false, $context );
  2429. $stream_meta = stream_get_meta_data( $fp );
  2430. fclose( $fp );
  2431. foreach( $stream_meta['wrapper_data'] as $header ){
  2432. if( strpos( $header, 'X-Transmission-Session-Id: ' ) === 0 ){
  2433. $session_id = trim( substr( $header, 27 ) );
  2434. break;
  2435. }
  2436. }
  2437. $headers = array(
  2438. 'X-Transmission-Session-Id' => $session_id,
  2439. 'Content-Type' => 'application/json'
  2440. );
  2441. $data = array(
  2442. 'method' => 'torrent-get',
  2443. 'arguments' => array(
  2444. 'fields' => array(
  2445. "id", "name", "totalSize", "eta", "isFinished", "isStalled", "percentDone", "rateDownload", "status", "downloadDir"
  2446. ),
  2447. ),
  2448. 'tags' => ''
  2449. );
  2450. $api = curl_post($url, $data, $headers);
  2451. $api = json_decode($api['content'], true);
  2452. $gotTorrent = array();
  2453. if (is_array($api) || is_object($api)){
  2454. foreach ($api['arguments']['torrents'] AS $child) {
  2455. $downloadName = htmlentities($child['name'], ENT_QUOTES);
  2456. $downloadDirectory = $child['downloadDir'];
  2457. $downloadPercent = $child['percentDone'] * 100;
  2458. $progressBar = "progress-bar-striped active";
  2459. if($child['status'] == "6"){
  2460. $downloadStatus = "Seeding";
  2461. $downloadHealth = "success";
  2462. }elseif($child['status'] == "4"){
  2463. $downloadStatus = "Downloading";
  2464. $downloadHealth = "danger";
  2465. }elseif($child['status'] == "3"){
  2466. $downloadStatus = "Queued";
  2467. $downloadHealth = "warning";
  2468. }elseif($child['status'] == "0"){
  2469. $downloadStatus = "Complete";
  2470. $downloadHealth = "success";
  2471. }
  2472. $gotTorrent[] = '<tr>
  2473. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2474. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2475. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadDirectory.'</td>
  2476. <td class="col-xs-1 nzbtable nzbtable-row">'.realSize($child['totalSize']).'</td>
  2477. <td class="col-xs-2 nzbtable nzbtable-row">
  2478. <div class="progress">
  2479. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2480. <p class="text-center">'.round($downloadPercent).'%</p>
  2481. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2482. </div>
  2483. </div>
  2484. </td>
  2485. </tr>';
  2486. }
  2487. if ($gotTorrent) {
  2488. return implode('',$gotTorrent);
  2489. } else {
  2490. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2491. }
  2492. }else{
  2493. writeLog("error", "TRANSMISSION ERROR: could not connect - check URL and/or check token and/or Username and Password - if HTTPS, is cert valid");
  2494. }
  2495. }
  2496. // NzbGET Items
  2497. function nzbgetConnect($list = 'listgroups') {
  2498. $url = qualifyURL(NZBGETURL);
  2499. $api = curl_get($url.'/'.NZBGETUSERNAME.':'.NZBGETPASSWORD.'/jsonrpc/'.$list);
  2500. $api = json_decode($api, true);
  2501. $gotNZB = array();
  2502. if (is_array($api) || is_object($api)){
  2503. foreach ($api['result'] AS $child) {
  2504. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  2505. $downloadStatus = $child['Status'];
  2506. $downloadCategory = $child['Category'];
  2507. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  2508. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  2509. if($child['Health'] <= "750"){
  2510. $downloadHealth = "danger";
  2511. }elseif($child['Health'] <= "900"){
  2512. $downloadHealth = "warning";
  2513. }elseif($child['Health'] <= "1000"){
  2514. $downloadHealth = "success";
  2515. }
  2516. $gotNZB[] = '<tr>
  2517. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2518. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2519. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2520. <td class="col-xs-1 nzbtable nzbtable-row">'.realSize(($child['FileSizeMB']*1024)*1024).'</td>
  2521. <td class="col-xs-2 nzbtable nzbtable-row">
  2522. <div class="progress">
  2523. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2524. <p class="text-center">'.round($downloadPercent).'%</p>
  2525. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2526. </div>
  2527. </div>
  2528. </td>
  2529. </tr>';
  2530. }
  2531. if ($gotNZB) {
  2532. return implode('',$gotNZB);
  2533. } else {
  2534. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2535. }
  2536. }else{
  2537. writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Username and Password - if HTTPS, is cert valid");
  2538. }
  2539. }
  2540. // Sabnzbd Items
  2541. function sabnzbdConnect($list = 'queue') {
  2542. $url = qualifyURL(SABNZBDURL);
  2543. $api = @file_get_contents($url.'/api?mode='.$list.'&output=json&apikey='.SABNZBDKEY);
  2544. $api = json_decode($api, true);
  2545. $gotNZB = array();
  2546. if (is_array($api) || is_object($api)){
  2547. foreach ($api[$list]['slots'] AS $child) {
  2548. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  2549. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  2550. $downloadStatus = $child['status'];
  2551. $gotNZB[] = '<tr>
  2552. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2553. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2554. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2555. <td class="col-xs-1 nzbtable nzbtable-row">'.$child['size'].'</td>
  2556. <td class="col-xs-2 nzbtable nzbtable-row">
  2557. <div class="progress">
  2558. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2559. <p class="text-center">'.round($downloadPercent).'%</p>
  2560. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2561. </div>
  2562. </div>
  2563. </td>
  2564. </tr>';
  2565. }
  2566. if ($gotNZB) {
  2567. return implode('',$gotNZB);
  2568. } else {
  2569. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2570. }
  2571. }else{
  2572. writeLog("error", "SABNZBD ERROR: could not connect - check URL and/or check token - if HTTPS, is cert valid");
  2573. }
  2574. }
  2575. // Apply new tab settings
  2576. function updateTabs($tabs) {
  2577. if (!isset($GLOBALS['file_db'])) {
  2578. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2579. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2580. }
  2581. // Validate
  2582. if (!isset($tabs['defaultz'])) { $tabs['defaultz'][current(array_keys($tabs['name']))] = 'true'; }
  2583. if (isset($tabs['name']) && isset($tabs['url']) && is_array($tabs['name'])) {
  2584. // Clear Existing Tabs
  2585. $GLOBALS['file_db']->query("DELETE FROM tabs");
  2586. // Process New Tabs
  2587. $totalValid = 0;
  2588. foreach ($tabs['name'] as $key => $value) {
  2589. // Qualify
  2590. if (!$value || !isset($tabs['url']) || !$tabs['url'][$key]) { continue; }
  2591. $totalValid++;
  2592. $fields = array();
  2593. foreach(array('id','name','url','icon','iconurl','order','ping_url') as $v) {
  2594. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = $tabs[$v][$key]; }
  2595. }
  2596. foreach(array('active','user','guest','defaultz','window','splash','ping') as $v) {
  2597. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = ($tabs[$v][$key]!=='false'?'true':'false'); }
  2598. }
  2599. $GLOBALS['file_db']->query('INSERT INTO tabs (`'.implode('`,`',array_keys($fields)).'`) VALUES (\''.implode("','",$fields).'\');');
  2600. }
  2601. writeLog("success", "tabs successfully saved");
  2602. return $totalValid;
  2603. } else {
  2604. writeLog("error", "tabs could not save");
  2605. return false;
  2606. }
  2607. writeLog("error", "tabs could not save");
  2608. return false;
  2609. }
  2610. // ==============
  2611. function clean($strin) {
  2612. $strout = null;
  2613. for ($i = 0; $i < strlen($strin); $i++) {
  2614. $ord = ord($strin[$i]);
  2615. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  2616. $strout .= "&amp;#{$ord};";
  2617. }
  2618. else {
  2619. switch ($strin[$i]) {
  2620. case '<':
  2621. $strout .= '&lt;';
  2622. break;
  2623. case '>':
  2624. $strout .= '&gt;';
  2625. break;
  2626. case '&':
  2627. $strout .= '&amp;';
  2628. break;
  2629. case '"':
  2630. $strout .= '&quot;';
  2631. break;
  2632. default:
  2633. $strout .= $strin[$i];
  2634. }
  2635. }
  2636. }
  2637. return $strout;
  2638. }
  2639. function registration_callback($username, $email, $userdir){
  2640. global $data;
  2641. $data = array($username, $email, $userdir);
  2642. }
  2643. function printArray($arrayName){
  2644. $messageCount = count($arrayName);
  2645. $i = 0;
  2646. foreach ( $arrayName as $item ) :
  2647. $i++;
  2648. if($i < $messageCount) :
  2649. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  2650. elseif($i = $messageCount) :
  2651. echo "<small class='text-uppercase'>" . $item . "</small>";
  2652. endif;
  2653. endforeach;
  2654. }
  2655. function write_ini_file($content, $path) {
  2656. if (!$handle = fopen($path, 'w')) {
  2657. return false;
  2658. }
  2659. $success = fwrite($handle, trim($content));
  2660. fclose($handle);
  2661. return $success;
  2662. }
  2663. function gotTimezone(){
  2664. $regions = array(
  2665. 'Africa' => DateTimeZone::AFRICA,
  2666. 'America' => DateTimeZone::AMERICA,
  2667. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2668. 'Arctic' => DateTimeZone::ARCTIC,
  2669. 'Asia' => DateTimeZone::ASIA,
  2670. 'Atlantic' => DateTimeZone::ATLANTIC,
  2671. 'Australia' => DateTimeZone::AUSTRALIA,
  2672. 'Europe' => DateTimeZone::EUROPE,
  2673. 'Indian' => DateTimeZone::INDIAN,
  2674. 'Pacific' => DateTimeZone::PACIFIC
  2675. );
  2676. $timezones = array();
  2677. foreach ($regions as $name => $mask) {
  2678. $zones = DateTimeZone::listIdentifiers($mask);
  2679. foreach($zones as $timezone) {
  2680. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2681. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2682. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2683. }
  2684. }
  2685. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  2686. foreach($timezones as $region => $list) {
  2687. print '<optgroup label="' . $region . '">' . "\n";
  2688. foreach($list as $timezone => $name) {
  2689. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  2690. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  2691. }
  2692. print '</optgroup>' . "\n";
  2693. }
  2694. print '</select>';
  2695. }
  2696. function getTimezone(){
  2697. $regions = array(
  2698. 'Africa' => DateTimeZone::AFRICA,
  2699. 'America' => DateTimeZone::AMERICA,
  2700. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2701. 'Arctic' => DateTimeZone::ARCTIC,
  2702. 'Asia' => DateTimeZone::ASIA,
  2703. 'Atlantic' => DateTimeZone::ATLANTIC,
  2704. 'Australia' => DateTimeZone::AUSTRALIA,
  2705. 'Europe' => DateTimeZone::EUROPE,
  2706. 'Indian' => DateTimeZone::INDIAN,
  2707. 'Pacific' => DateTimeZone::PACIFIC
  2708. );
  2709. $timezones = array();
  2710. foreach ($regions as $name => $mask) {
  2711. $zones = DateTimeZone::listIdentifiers($mask);
  2712. foreach($zones as $timezone) {
  2713. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2714. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2715. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2716. }
  2717. }
  2718. print '<select name="timezone" id="timezone" class="form-control material" required>';
  2719. foreach($timezones as $region => $list) {
  2720. print '<optgroup label="' . $region . '">' . "\n";
  2721. foreach($list as $timezone => $name) {
  2722. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  2723. }
  2724. print '</optgroup>' . "\n";
  2725. }
  2726. print '</select>';
  2727. }
  2728. function explosion($string, $position){
  2729. $getWord = explode("|", $string);
  2730. return $getWord[$position];
  2731. }
  2732. function getServerPath() {
  2733. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  2734. $protocol = "https://";
  2735. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  2736. $protocol = "https://";
  2737. } else {
  2738. $protocol = "http://";
  2739. }
  2740. $domain = '';
  2741. if (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], '.') !== false){
  2742. $domain = $_SERVER['SERVER_NAME'];
  2743. }elseif(isset($_SERVER['HTTP_HOST'])){
  2744. if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
  2745. $domain = explode(':', $_SERVER['HTTP_HOST'])[0];
  2746. $port = explode(':', $_SERVER['HTTP_HOST'])[1];
  2747. if ($port == "80" || $port == "443"){
  2748. $domain = $domain;
  2749. }else{
  2750. $domain = $_SERVER['HTTP_HOST'];
  2751. }
  2752. }else{
  2753. $domain = $_SERVER['HTTP_HOST'];
  2754. }
  2755. }
  2756. return $protocol . $domain . str_replace("\\", "/", dirname($_SERVER['REQUEST_URI']));
  2757. }
  2758. function get_browser_name() {
  2759. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  2760. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  2761. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  2762. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  2763. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  2764. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  2765. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  2766. return 'Other';
  2767. }
  2768. function getSickrageCalendarWanted($array){
  2769. $array = json_decode($array, true);
  2770. //$gotCalendar = "";
  2771. $gotCalendar = array();
  2772. $i = 0;
  2773. foreach($array['data']['missed'] AS $child) {
  2774. $i++;
  2775. $seriesName = $child['show_name'];
  2776. $episodeID = $child['tvdbid'];
  2777. $episodeAirDate = $child['airdate'];
  2778. $episodeAirDateTime = explode(" ",$child['airs']);
  2779. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2780. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2781. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2782. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2783. $downloaded = "0";
  2784. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2785. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2786. array_push($gotCalendar, array(
  2787. "id" => "Sick-Miss-".$i,
  2788. "title" => $seriesName,
  2789. "start" => $episodeAirDate,
  2790. "className" => $downloaded." tvID--".$episodeID,
  2791. "imagetype" => "tv",
  2792. ));
  2793. }
  2794. foreach($array['data']['today'] AS $child) {
  2795. $i++;
  2796. $seriesName = $child['show_name'];
  2797. $episodeID = $child['tvdbid'];
  2798. $episodeAirDate = $child['airdate'];
  2799. $episodeAirDateTime = explode(" ",$child['airs']);
  2800. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2801. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2802. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2803. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2804. $downloaded = "0";
  2805. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2806. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2807. array_push($gotCalendar, array(
  2808. "id" => "Sick-Today-".$i,
  2809. "title" => $seriesName,
  2810. "start" => $episodeAirDate,
  2811. "className" => $downloaded." tvID--".$episodeID,
  2812. "imagetype" => "tv",
  2813. ));
  2814. }
  2815. foreach($array['data']['soon'] AS $child) {
  2816. $i++;
  2817. $seriesName = $child['show_name'];
  2818. $episodeID = $child['tvdbid'];
  2819. $episodeAirDate = $child['airdate'];
  2820. $episodeAirDateTime = explode(" ",$child['airs']);
  2821. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2822. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2823. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2824. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2825. $downloaded = "0";
  2826. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2827. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2828. array_push($gotCalendar, array(
  2829. "id" => "Sick-Soon-".$i,
  2830. "title" => $seriesName,
  2831. "start" => $episodeAirDate,
  2832. "className" => $downloaded." tvID--".$episodeID,
  2833. "imagetype" => "tv",
  2834. ));
  2835. }
  2836. foreach($array['data']['later'] AS $child) {
  2837. $i++;
  2838. $seriesName = $child['show_name'];
  2839. $episodeID = $child['tvdbid'];
  2840. $episodeAirDate = $child['airdate'];
  2841. $episodeAirDateTime = explode(" ",$child['airs']);
  2842. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2843. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2844. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2845. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2846. $downloaded = "0";
  2847. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2848. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2849. array_push($gotCalendar, array(
  2850. "id" => "Sick-Later-".$i,
  2851. "title" => $seriesName,
  2852. "start" => $episodeAirDate,
  2853. "className" => $downloaded." tvID--".$episodeID,
  2854. "imagetype" => "tv",
  2855. ));
  2856. }
  2857. if ($i != 0){ return $gotCalendar; }
  2858. }
  2859. function getSickrageCalendarHistory($array){
  2860. $array = json_decode($array, true);
  2861. //$gotCalendar = "";
  2862. $gotCalendar = array();
  2863. $i = 0;
  2864. foreach($array['data'] AS $child) {
  2865. $i++;
  2866. $seriesName = $child['show_name'];
  2867. $episodeID = $child['tvdbid'];
  2868. $episodeAirDate = $child['date'];
  2869. $downloaded = "green-bg";
  2870. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2871. array_push($gotCalendar, array(
  2872. "id" => "Sick-History-".$i,
  2873. "title" => $seriesName,
  2874. "start" => $episodeAirDate,
  2875. "className" => $downloaded." tvID--".$episodeID,
  2876. "imagetype" => "tv",
  2877. ));
  2878. }
  2879. if ($i != 0){ return $gotCalendar; }
  2880. }
  2881. function getSonarrCalendar($array){
  2882. $array = json_decode($array, true);
  2883. //$gotCalendar = "";
  2884. $gotCalendar = array();
  2885. $i = 0;
  2886. foreach($array AS $child) {
  2887. $i++;
  2888. $seriesName = $child['series']['title'];
  2889. $episodeID = $child['series']['tvdbId'];
  2890. if(!isset($episodeID)){ $episodeID = ""; }
  2891. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  2892. if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
  2893. $episodeAirDate = $child['airDateUtc'];
  2894. $episodeAirDate = strtotime($episodeAirDate);
  2895. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2896. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2897. $downloaded = $child['hasFile'];
  2898. 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"; }
  2899. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2900. array_push($gotCalendar, array(
  2901. "id" => "Sonarr-".$i,
  2902. "title" => $seriesName,
  2903. "start" => $episodeAirDate,
  2904. "className" => $downloaded." tvID--".$episodeID,
  2905. "imagetype" => "tv",
  2906. ));
  2907. }
  2908. if ($i != 0){ return $gotCalendar; }
  2909. }
  2910. function getCouchCalendar(){
  2911. $url = qualifyURL(COUCHURL);
  2912. $api = curl_get($url."/api/".COUCHAPI."/media.list");
  2913. $api = json_decode($api, true);
  2914. $i = 0;
  2915. $gotCalendar = array();
  2916. if (is_array($api) || is_object($api)){
  2917. foreach($api['movies'] AS $child) {
  2918. if($child['status'] == "active" || $child['status'] == "done" ){
  2919. $i++;
  2920. $movieName = $child['info']['original_title'];
  2921. $movieID = $child['info']['tmdb_id'];
  2922. if(!isset($movieID)){ $movieID = ""; }
  2923. $physicalRelease = (isset($child['info']['released']) ? $child['info']['released'] : null);
  2924. $backupRelease = (isset($child['info']['release_date']['theater']) ? $child['info']['release_date']['theater'] : null);
  2925. $physicalRelease = (isset($physicalRelease) ? $physicalRelease : $backupRelease);
  2926. $physicalRelease = strtotime($physicalRelease);
  2927. $physicalRelease = date("Y-m-d", $physicalRelease);
  2928. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2929. $downloaded = ($child['status'] == "active") ? "0" : "1";
  2930. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2931. array_push($gotCalendar, array(
  2932. "id" => "CouchPotato-".$i,
  2933. "title" => $movieName,
  2934. "start" => $physicalRelease,
  2935. "className" => $downloaded." movieID--".$movieID,
  2936. "imagetype" => "film",
  2937. ));
  2938. }
  2939. }
  2940. if ($i != 0){ return $gotCalendar; }
  2941. }else{
  2942. writeLog("error", "CouchPotato ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2943. }
  2944. }
  2945. function getRadarrCalendar($array){
  2946. $array = json_decode($array, true);
  2947. $gotCalendar = array();
  2948. $i = 0;
  2949. foreach($array AS $child) {
  2950. if(isset($child['physicalRelease'])){
  2951. $i++;
  2952. $movieName = $child['title'];
  2953. $movieID = $child['tmdbId'];
  2954. if(!isset($movieID)){ $movieID = ""; }
  2955. $physicalRelease = $child['physicalRelease'];
  2956. $physicalRelease = strtotime($physicalRelease);
  2957. $physicalRelease = date("Y-m-d", $physicalRelease);
  2958. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2959. $downloaded = $child['hasFile'];
  2960. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2961. array_push($gotCalendar, array(
  2962. "id" => "Radarr-".$i,
  2963. "title" => $movieName,
  2964. "start" => $physicalRelease,
  2965. "className" => $downloaded." movieID--".$movieID,
  2966. "imagetype" => "film",
  2967. ));
  2968. }
  2969. }
  2970. if ($i != 0){ return $gotCalendar; }
  2971. }
  2972. function getHeadphonesCalendar($url, $key, $list){
  2973. $url = qualifyURL(HEADPHONESURL);
  2974. $api = curl_get($url."/api?apikey=".$key."&cmd=$list");
  2975. $api = json_decode($api, true);
  2976. $i = 0;
  2977. //$gotCalendar = "";
  2978. $gotCalendar = array();;
  2979. if (is_array($api) || is_object($api)){
  2980. foreach($api AS $child) {
  2981. if($child['Status'] == "Wanted" && $list == "getWanted" && $child['ReleaseDate']){
  2982. $i++;
  2983. $albumName = addslashes($child['AlbumTitle']);
  2984. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  2985. $albumDate = (strlen($child['ReleaseDate']) > 4) ? $child['ReleaseDate'] : $child['ReleaseDate']."-01-01";
  2986. $albumID = $child['AlbumID'];
  2987. $albumDate = strtotime($albumDate);
  2988. $albumDate = date("Y-m-d", $albumDate);
  2989. $albumStatus = $child['Status'];
  2990. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2991. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  2992. //$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2993. array_push($gotCalendar, array(
  2994. "id" => "Headphones-".$i,
  2995. "title" => $albumArtist.' - '.$albumName,
  2996. "start" => $albumDate,
  2997. "className" => $albumStatusColor,
  2998. "imagetype" => "music",
  2999. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  3000. ));
  3001. }
  3002. if($child['Status'] == "Processed" && $list == "getHistory"){
  3003. $i++;
  3004. $find = array('_','[', ']', '\n');
  3005. $replace = array(' ','(', ')', ' ');
  3006. $albumName = addslashes(str_replace($find,$replace,$child['FolderName']));
  3007. $albumDate = $child['DateAdded'];
  3008. $albumID = $child['AlbumID'];
  3009. $albumDate = strtotime($albumDate);
  3010. $albumDate = date("Y-m-d", $albumDate);
  3011. $albumStatusColor = "green-bg";
  3012. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  3013. //$gotCalendar .= "{ title: \"$albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  3014. array_push($gotCalendar, array(
  3015. "id" => "Headphones-".$i,
  3016. "title" => $albumName,
  3017. "start" => $albumDate,
  3018. "className" => $albumStatusColor,
  3019. "imagetype" => "music",
  3020. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  3021. ));
  3022. }
  3023. }
  3024. if ($i != 0){ return $gotCalendar; }
  3025. }else{
  3026. writeLog("error", "HEADPHONES $list ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  3027. }
  3028. }
  3029. function checkRootPath($string){
  3030. if($string == "\\" || $string == "/"){
  3031. return "/";
  3032. }else{
  3033. return str_replace("\\", "/", $string) . "/";
  3034. }
  3035. }
  3036. function strip($string){
  3037. $string = strip_tags($string);
  3038. return preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $string));
  3039. }
  3040. function writeLog($type, $message){
  3041. if(file_exists(DATABASE_LOCATION."org.log")){
  3042. if(filesize(DATABASE_LOCATION."org.log") > 500000){
  3043. rename(DATABASE_LOCATION.'org.log',DATABASE_LOCATION.'org['.date('Y-m-d').'].log');
  3044. $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";
  3045. file_put_contents(DATABASE_LOCATION."org.log", $message2, FILE_APPEND | LOCK_EX);
  3046. }
  3047. }
  3048. $message = date("Y-m-d H:i:s")."|".$type."|".strip($message)."\n";
  3049. file_put_contents(DATABASE_LOCATION."org.log", $message, FILE_APPEND | LOCK_EX);
  3050. }
  3051. function readLog(){
  3052. $log = file(DATABASE_LOCATION."org.log",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3053. $log = array_reverse($log);
  3054. foreach($log as $line){
  3055. if(substr_count($line, '|') == 2){
  3056. $line = explode("|", strip($line));
  3057. $line[1] = ($line[1] == "error") ? '<span class="label label-danger">Error</span>' : '<span class="label label-primary">Success</span>';
  3058. echo "<tr><td>".$line[0]."</td><td>".$line[2]."</td><td>".$line[1]."</td></tr>";
  3059. }
  3060. }
  3061. }
  3062. function buildStream($array){
  3063. $result = "";
  3064. if (array_key_exists('platform', $array)) {
  3065. $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>';
  3066. }
  3067. if (array_key_exists('device', $array)) {
  3068. $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>';
  3069. }
  3070. if (array_key_exists('stream', $array)) {
  3071. $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>';
  3072. }
  3073. if (array_key_exists('video', $array)) {
  3074. $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>';
  3075. }
  3076. if (array_key_exists('audio', $array)) {
  3077. $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>';
  3078. }
  3079. return $result;
  3080. }
  3081. function streamType($value){
  3082. if($value == "transcode" || $value == "Transcode"){
  3083. return "Transcode";
  3084. }elseif($value == "copy" || $value == "DirectStream"){
  3085. return "Direct Stream";
  3086. }elseif($value == "directplay" || $value == "DirectPlay"){
  3087. return "Direct Play";
  3088. }else{
  3089. return "Direct Play";
  3090. }
  3091. }
  3092. function getPlatform($platform){
  3093. $allPlatforms = array(
  3094. "Chrome" => "chrome.png",
  3095. "tvOS" => "atv.png",
  3096. "iOS" => "ios.png",
  3097. "Xbox One" => "xbox.png",
  3098. "Mystery 4" => "playstation.png",
  3099. "Samsung" => "samsung.png",
  3100. "Roku" => "roku.png",
  3101. "Emby for iOS" => "ios.png",
  3102. "Emby Mobile" => "emby.png",
  3103. "Emby Theater" => "emby.png",
  3104. "Emby Classic" => "emby.png",
  3105. "Safari" => "safari.png",
  3106. "Android" => "android.png",
  3107. "AndroidTv" => "android.png",
  3108. "Chromecast" => "chromecast.png",
  3109. "Dashboard" => "emby.png",
  3110. "Dlna" => "dlna.png",
  3111. "Windows Phone" => "wp.png",
  3112. "Windows RT" => "win8.png",
  3113. "Kodi" => "kodi.png",
  3114. );
  3115. if (array_key_exists($platform, $allPlatforms)) {
  3116. return $allPlatforms[$platform];
  3117. }else{
  3118. return "pmp.png";
  3119. }
  3120. }
  3121. function getServer(){
  3122. $server = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"];
  3123. return $server;
  3124. }
  3125. function prettyPrint($array) {
  3126. echo "<pre>";
  3127. print_r($array);
  3128. echo "</pre>";
  3129. echo "<br/>";
  3130. }
  3131. function checkFrame($array, $url){
  3132. if(array_key_exists("x-frame-options", $array)){
  3133. if($array['x-frame-options'] == "deny"){
  3134. return false;
  3135. }elseif($array['x-frame-options'] == "sameorgin"){
  3136. $digest = parse_url($url);
  3137. $host = (isset($digest['host'])?$digest['host']:'');
  3138. if(getServer() == $host){
  3139. return true;
  3140. }else{
  3141. return false;
  3142. }
  3143. }
  3144. }else{
  3145. if(!$array){
  3146. return false;
  3147. }
  3148. return true;
  3149. }
  3150. }
  3151. function frameTest($url){
  3152. $array = array_change_key_case(get_headers(qualifyURL($url), 1));
  3153. $url = qualifyURL($url);
  3154. if(checkFrame($array, $url)){
  3155. return true;
  3156. }else{
  3157. return false;
  3158. }
  3159. }
  3160. function sendResult($result, $icon = "floppy-o", $message = false, $success = "WAS_SUCCESSFUL", $fail = "HAS_FAILED", $send = true) {
  3161. $notifyExplode = explode("-", NOTIFYEFFECT);
  3162. if ($result) {
  3163. $msg = array(
  3164. 'html' => ($message?''.$message.' <strong>'.translate($success).'</strong>':'<strong>'.translate($success).'</strong>'),
  3165. 'icon' => $icon,
  3166. 'type' => 'success',
  3167. 'length' => '5000',
  3168. 'layout' => $notifyExplode[0],
  3169. 'effect' => $notifyExplode[1],
  3170. );
  3171. } else {
  3172. $msg = array(
  3173. 'html' => ($message?''.$message.' <strong>'.translate($fail).'</strong>':'<strong>'.translate($fail).'</strong>'),
  3174. 'icon' => $icon,
  3175. 'type' => 'error',
  3176. 'length' => '5000',
  3177. 'layout' => $notifyExplode[0],
  3178. 'effect' => $notifyExplode[1],
  3179. );
  3180. }
  3181. // Send and kill script?
  3182. if ($send) {
  3183. header('Content-Type: application/json');
  3184. echo json_encode(array('notify'=>$msg));
  3185. die();
  3186. }
  3187. return $msg;
  3188. }
  3189. function buildHomepageNotice($layout, $type, $title, $message){
  3190. switch ($layout) {
  3191. case 'elegant':
  3192. return '
  3193. <div id="homepageNotice" class="row">
  3194. <div class="col-lg-12">
  3195. <div class="content-box big-box box-shadow panel-box panel-'.$type.'">
  3196. <div class="content-title i-block">
  3197. <h4 class="zero-m"><strong>'.$title.'</strong></h4>
  3198. <div class="content-tools i-block pull-right">
  3199. <a class="close-btn">
  3200. <i class="fa fa-times"></i>
  3201. </a>
  3202. </div>
  3203. </div>
  3204. '.$message.'
  3205. </div>
  3206. </div>
  3207. </div>
  3208. ';
  3209. break;
  3210. case 'basic':
  3211. return '
  3212. <div id="homepageNotice" class="row">
  3213. <div class="col-lg-12">
  3214. <div class="panel panel-'.$type.'">
  3215. <div class="panel-heading">
  3216. <h3 class="panel-title">'.$title.'</h3>
  3217. </div>
  3218. <div class="panel-body">
  3219. '.$message.'
  3220. </div>
  3221. </div>
  3222. </div>
  3223. </div>
  3224. ';
  3225. break;
  3226. case 'jumbotron';
  3227. return '
  3228. <div id="homepageNotice" class="row">
  3229. <div class="col-lg-12">
  3230. <div class="jumbotron">
  3231. <div class="container">
  3232. <h1>'.$title.'</h1>
  3233. <p>'.$message.'</p>
  3234. </div>
  3235. </div>
  3236. </div>
  3237. </div>
  3238. ';
  3239. }
  3240. }
  3241. function embyArray($array, $type) {
  3242. $key = ($type == "video" ? "Height" : "Channels");
  3243. if (array_key_exists($key, $array)) {
  3244. switch ($type) {
  3245. case "video":
  3246. $codec = $array["Codec"];
  3247. $height = $array["Height"];
  3248. $width = $array["Width"];
  3249. break;
  3250. default:
  3251. $codec = $array["Codec"];
  3252. $channels = $array["Channels"];
  3253. }
  3254. return ($type == "video" ? "(".$codec.") (".$width."x".$height.")" : "(".$codec.") (".$channels."ch)");
  3255. }
  3256. foreach ($array as $element) {
  3257. if (is_array($element)) {
  3258. if (embyArray($element, $type)) {
  3259. return embyArray($element, $type);
  3260. }
  3261. }
  3262. }
  3263. }
  3264. // Get Now Playing Streams From Plex
  3265. function searchPlex($query){
  3266. $address = qualifyURL(PLEXURL);
  3267. $openTab = (PLEXTABNAME) ? "true" : "false";
  3268. // Perform API requests
  3269. $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
  3270. libxml_use_internal_errors(true);
  3271. $api = simplexml_load_string($api);
  3272. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3273. if (!$getServer) { return 'Could not load!'; }
  3274. // Identify the local machine
  3275. $server = $getServer['machineIdentifier'];
  3276. $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>";
  3277. $items = "";
  3278. $albums = $movies = $shows = 0;
  3279. $style = 'style="vertical-align: middle"';
  3280. foreach($api AS $child) {
  3281. if($child['type'] != "artist" && $child['type'] != "episode" && isset($child['librarySectionID'])){
  3282. $time = (string)$child['addedAt'];
  3283. $time = new DateTime("@$time");
  3284. $results = array(
  3285. "title" => (string)$child['title'],
  3286. "image" => (string)$child['thumb'],
  3287. "type" => (string)ucwords($child['type']),
  3288. "year" => (string)$child['year'],
  3289. "key" => (string)$child['ratingKey']."-search",
  3290. "ratingkey" => (string)$child['ratingKey'],
  3291. "genre" => (string)$child->Genre['tag'],
  3292. "added" => $time->format('Y-m-d'),
  3293. "extra" => "",
  3294. );
  3295. switch ($child['type']){
  3296. case "album":
  3297. $push = array(
  3298. "title" => (string)$child['parentTitle']." - ".(string)$child['title'],
  3299. );
  3300. $results = array_replace($results,$push);
  3301. $albums++;
  3302. break;
  3303. case "movie":
  3304. $push = array(
  3305. "extra" => "Content Rating: ".(string)$child['contentRating']."<br/>Movie Rating: ".(string)$child['rating'],
  3306. );
  3307. $results = array_replace($results,$push);
  3308. $movies++;
  3309. break;
  3310. case "show":
  3311. $push = array(
  3312. "extra" => "Seasons: ".(string)$child['childCount']."<br/>Episodes: ".(string)$child['leafCount'],
  3313. );
  3314. $results = array_replace($results,$push);
  3315. $shows++;
  3316. break;
  3317. }
  3318. if (file_exists('images/cache/'.$results['key'].'.jpg')){ $image_url = 'images/cache/'.$results['key'].'.jpg'; }
  3319. if (file_exists('images/cache/'.$results['key'].'.jpg') && (time() - 604800) > filemtime('images/cache/'.$results['key'].'.jpg') || !file_exists('images/cache/'.$results['key'].'.jpg')) {
  3320. $image_url = 'ajax.php?a=plex-image&img='.$results['image'].'&height=150&width=100&key='.$results['key'];
  3321. }
  3322. if(!$results['image']){ $image_url = "images/no-search.png"; $key = "no-search"; }
  3323. if (PLEXTABURL) {
  3324. $link = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3325. }else{
  3326. $link = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3327. }
  3328. $items .= '<tr style="cursor: pointer;" class="openTab" extraTitle="'.$results['title'].'" extraType="'.$child['type'].'" openTab="'.$openTab.'" href="'.$link.'">
  3329. <th scope="row"><img src="'.$image_url.'"></th>
  3330. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
  3331. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
  3332. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
  3333. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
  3334. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
  3335. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['extra'].'</td>
  3336. </tr>';
  3337. }
  3338. }
  3339. $totals = '<div style="margin: 10px;" class="sort-todo pull-right">
  3340. <span class="badge gray-bg"><i class="fa fa-film fa-2x white"></i><strong style="
  3341. font-size: 23px;
  3342. ">&nbsp;'.$movies.'</strong></span>
  3343. <span class="badge gray-bg"><i class="fa fa-tv fa-2x white"></i><strong style="
  3344. font-size: 23px;
  3345. ">&nbsp;'.$shows.'</strong></span>
  3346. <span class="badge gray-bg"><i class="fa fa-music fa-2x white"></i><strong style="
  3347. font-size: 23px;
  3348. ">&nbsp;'.$albums.'</strong></span>
  3349. </div>';
  3350. return (!empty($items) ? $totals.$pre.$items."</div></table>" : "<h2 class='text-center'>No Results for $query</h2>" );
  3351. }
  3352. function getBannedUsers($string){
  3353. if (strpos($string, ',') !== false) {
  3354. $banned = explode(",", $string);
  3355. }else{
  3356. $banned = array($string);
  3357. }
  3358. return $banned;
  3359. }
  3360. function getWhitelist($string){
  3361. if (strpos($string, ',') !== false) {
  3362. $whitelist = explode(",", $string);
  3363. }else{
  3364. $whitelist = array($string);
  3365. }
  3366. foreach($whitelist as &$ip){
  3367. $ip = is_numeric(substr($ip, 0, 1)) ? $ip : gethostbyname($ip);
  3368. }
  3369. return $whitelist;
  3370. }
  3371. function get_client_ip() {
  3372. $ipaddress = '';
  3373. if (isset($_SERVER['HTTP_CLIENT_IP']))
  3374. $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
  3375. else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  3376. $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
  3377. else if(isset($_SERVER['HTTP_X_FORWARDED']))
  3378. $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
  3379. else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
  3380. $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
  3381. else if(isset($_SERVER['HTTP_FORWARDED']))
  3382. $ipaddress = $_SERVER['HTTP_FORWARDED'];
  3383. else if(isset($_SERVER['REMOTE_ADDR']))
  3384. $ipaddress = $_SERVER['REMOTE_ADDR'];
  3385. else
  3386. $ipaddress = 'UNKNOWN';
  3387. return $ipaddress;
  3388. }
  3389. //EMAIL SHIT
  3390. function sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null){
  3391. $mail = new PHPMailer;
  3392. $mail->isSMTP();
  3393. $mail->Host = SMTPHOST;
  3394. $mail->SMTPAuth = SMTPHOSTAUTH;
  3395. $mail->Username = SMTPHOSTUSERNAME;
  3396. $mail->Password = SMTPHOSTPASSWORD;
  3397. $mail->SMTPSecure = SMTPHOSTTYPE;
  3398. $mail->Port = SMTPHOSTPORT;
  3399. $mail->setFrom(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3400. $mail->addReplyTo(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3401. $mail->isHTML(true);
  3402. if($email){
  3403. $mail->addAddress($email, $username);
  3404. }
  3405. if($cc){
  3406. $mail->addCC($cc);
  3407. }
  3408. if($bcc){
  3409. if(strpos($bcc , ',') === false){
  3410. $mail->addBCC($bcc);
  3411. }else{
  3412. $allEmails = explode(",",$bcc);
  3413. foreach($allEmails as $gotEmail){
  3414. $mail->addBCC($gotEmail);
  3415. }
  3416. }
  3417. }
  3418. $mail->Subject = $subject;
  3419. $mail->Body = $body;
  3420. //$mail->send();
  3421. if(!$mail->send()) {
  3422. writeLog("error", "mail failed to send");
  3423. } else {
  3424. writeLog("success", "mail has been sent");
  3425. }
  3426. }
  3427. //EMAIL SHIT
  3428. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  3429. $mail = new PHPMailer;
  3430. $mail->isSMTP();
  3431. $mail->Host = $host;
  3432. $mail->SMTPAuth = $auth;
  3433. $mail->Username = $username;
  3434. $mail->Password = $password;
  3435. $mail->SMTPSecure = $type;
  3436. $mail->Port = $port;
  3437. $mail->setFrom($from, $sendername);
  3438. $mail->addReplyTo($from, $sendername);
  3439. $mail->isHTML(true);
  3440. $mail->addAddress($to, "Organizr Admin");
  3441. $mail->Subject = "Organizr Test E-Mail";
  3442. $mail->Body = "This was just a test!";
  3443. //$mail->send();
  3444. if(!$mail->send()) {
  3445. writeLog("error", "EMAIL TEST: mail failed to send - Error:".$mail->ErrorInfo);
  3446. return false;
  3447. } else {
  3448. writeLog("success", "EMAIL TEST: mail has been sent successfully");
  3449. return true;
  3450. }
  3451. }
  3452. function libraryList(){
  3453. $address = qualifyURL(PLEXURL);
  3454. $headers = array(
  3455. "Accept" => "application/json",
  3456. "X-Plex-Token" => PLEXTOKEN
  3457. );
  3458. libxml_use_internal_errors(true);
  3459. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3460. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3461. $api = simplexml_load_string(@curl_get("https://plex.tv/api/servers/$gotServer/shared_servers", $headers));
  3462. $libraryList = array();
  3463. foreach($api->SharedServer->Section AS $child) {
  3464. $libraryList['libraries'][(string)$child['title']] = (string)$child['id'];
  3465. }
  3466. foreach($api->SharedServer AS $child) {
  3467. if(!empty($child['username'])){
  3468. $username = (string)strtolower($child['username']);
  3469. $email = (string)strtolower($child['email']);
  3470. $libraryList['users'][$username] = (string)$child['id'];
  3471. $libraryList['emails'][$email] = (string)$child['id'];
  3472. $libraryList['both'][$username] = $email;
  3473. }
  3474. }
  3475. return (!empty($libraryList) ? array_change_key_case($libraryList,CASE_LOWER) : null );
  3476. }
  3477. function plexUserShare($username){
  3478. $address = qualifyURL(PLEXURL);
  3479. $headers = array(
  3480. "Accept" => "application/json",
  3481. "Content-Type" => "application/json",
  3482. "X-Plex-Token" => PLEXTOKEN
  3483. );
  3484. libxml_use_internal_errors(true);
  3485. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3486. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3487. $json = array(
  3488. "server_id" => $gotServer,
  3489. "shared_server" => array(
  3490. //"library_section_ids" => "[26527637]",
  3491. "invited_email" => $username
  3492. )
  3493. );
  3494. $api = curl_post("https://plex.tv/api/servers/$gotServer/shared_servers/", $json, $headers);
  3495. switch ($api['http_code']['http_code']){
  3496. case 400:
  3497. writeLog("error", "PLEX INVITE: $username already has access to the shared libraries");
  3498. $result = "$username already has access to the shared libraries";
  3499. break;
  3500. case 401:
  3501. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3502. $result = "Invalid Plex Token";
  3503. break;
  3504. case 200:
  3505. writeLog("success", "PLEX INVITE: $username now has access to your Plex Library");
  3506. $result = "$username now has access to your Plex Library";
  3507. break;
  3508. default:
  3509. writeLog("error", "PLEX INVITE: unknown error");
  3510. $result = false;
  3511. }
  3512. return (!empty($result) ? $result : null );
  3513. }
  3514. function plexUserDelete($username){
  3515. $address = qualifyURL(PLEXURL);
  3516. $headers = array(
  3517. "Accept" => "application/json",
  3518. "Content-Type" => "application/json",
  3519. "X-Plex-Token" => PLEXTOKEN
  3520. );
  3521. libxml_use_internal_errors(true);
  3522. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3523. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3524. $id = (is_numeric($username) ? $id : convertPlexName($username, "id"));
  3525. $api = curl_delete("https://plex.tv/api/servers/$gotServer/shared_servers/$id", $headers);
  3526. switch ($api['http_code']['http_code']){
  3527. case 401:
  3528. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3529. $result = "Invalid Plex Token";
  3530. break;
  3531. case 200:
  3532. writeLog("success", "PLEX INVITE: $username doesn't have access to your Plex Library anymore");
  3533. $result = "$username doesn't have access to your Plex Library anymore";
  3534. break;
  3535. default:
  3536. writeLog("error", "PLEX INVITE: unknown error");
  3537. $result = false;
  3538. }
  3539. return (!empty($result) ? $result : null );
  3540. }
  3541. function convertPlexName($user, $type){
  3542. $array = libraryList();
  3543. switch ($type){
  3544. case "username":
  3545. $plexUser = array_search ($user, $array['users']);
  3546. break;
  3547. case "id":
  3548. if (array_key_exists(strtolower($user), $array['users'])) {
  3549. $plexUser = $array['users'][strtolower($user)];
  3550. }
  3551. break;
  3552. default:
  3553. $plexUser = false;
  3554. }
  3555. return (!empty($plexUser) ? $plexUser : null );
  3556. }
  3557. function randomCode($length = 5, $type = null) {
  3558. switch ($type){
  3559. case "alpha":
  3560. $legend = array_merge(range('A', 'Z'));
  3561. break;
  3562. case "numeric":
  3563. $legend = array_merge(range(0,9));
  3564. break;
  3565. default:
  3566. $legend = array_merge(range(0,9),range('A', 'Z'));
  3567. }
  3568. $code = "";
  3569. for($i=0; $i < $length; $i++) {
  3570. $code .= $legend[mt_rand(0, count($legend) - 1)];
  3571. }
  3572. return $code;
  3573. }
  3574. function inviteCodes($action, $code = null, $usedBy = null) {
  3575. if (!isset($GLOBALS['file_db'])) {
  3576. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  3577. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  3578. }
  3579. $now = date("Y-m-d H:i:s");
  3580. switch ($action) {
  3581. case "get":
  3582. // Start Array
  3583. $result = array();
  3584. // Database Lookup
  3585. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes"');
  3586. // Get Codes
  3587. foreach($invites as $row) {
  3588. array_push($result, $row['code']);
  3589. }
  3590. // Return the Results
  3591. return (!empty($result) ? $result : false );
  3592. break;
  3593. case "check":
  3594. // Start Array
  3595. $result = array();
  3596. // Database Lookup
  3597. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes" AND code = "'.$code.'"');
  3598. // Get Codes
  3599. foreach($invites as $row) {
  3600. $result = $row['code'];
  3601. }
  3602. // Return the Results
  3603. return (!empty($result) ? $result : false );
  3604. break;
  3605. case "use":
  3606. $currentIP = get_client_ip();
  3607. $invites = $GLOBALS['file_db']->query('UPDATE invites SET valid = "No", usedby = "'.$usedBy.'", dateused = "'.$now.'", ip = "'.$currentIP.'" WHERE code = "'.$code.'"');
  3608. if(ENABLEMAIL){
  3609. if (!isset($GLOBALS['USER'])) {
  3610. require_once("user.php");
  3611. $GLOBALS['USER'] = new User('registration_callback');
  3612. }
  3613. $emailTemplate = array(
  3614. 'type' => 'mass',
  3615. 'body' => 'The user: {user} has reddemed the code: {inviteCode} his IP Address was '.$currentIP,
  3616. 'subject' => 'Invite Code '.$code.' Has Been Used',
  3617. 'user' => $usedBy,
  3618. 'password' => null,
  3619. 'inviteCode' => $code,
  3620. );
  3621. $emailTemplate = emailTemplate($emailTemplate);
  3622. $subject = $emailTemplate['subject'];
  3623. $body = buildEmail($emailTemplate);
  3624. sendEmail($GLOBALS['USER']->adminEmail, "Admin", $subject, $body);
  3625. }
  3626. return (!empty($invites) ? true : false );
  3627. break;
  3628. }
  3629. }
  3630. function plexJoin($username, $email, $password){
  3631. $connectURL = 'https://plex.tv/users.json';
  3632. $headers = array(
  3633. 'Accept'=> 'application/json',
  3634. 'Content-Type' => 'application/x-www-form-urlencoded',
  3635. 'X-Plex-Product' => 'Organizr',
  3636. 'X-Plex-Version' => '1.0',
  3637. 'X-Plex-Client-Identifier' => '01010101-10101010',
  3638. );
  3639. $body = array(
  3640. 'user[email]' => $email,
  3641. 'user[username]' => $username,
  3642. 'user[password]' => $password,
  3643. );
  3644. $api = curl_post($connectURL, $body, $headers);
  3645. $json = json_decode($api['content'], true);
  3646. $errors = (!empty($json['errors']) ? true : false);
  3647. $success = (!empty($json['user']) ? true : false);
  3648. //Use This for later
  3649. $usernameError = (!empty($json['errors']['username']) ? $json['errors']['username'][0] : false);
  3650. $emailError = (!empty($json['errors']['email']) ? $json['errors']['email'][0] : false);
  3651. $passwordError = (!empty($json['errors']['password']) ? $json['errors']['password'][0] : false);
  3652. $errorMessage = "";
  3653. if($errors){
  3654. if($usernameError){ $errorMessage .= "[Username Error: ". $usernameError ."]"; }
  3655. if($emailError){ $errorMessage .= "[Email Error: ". $emailError ."]"; }
  3656. if($passwordError){ $errorMessage .= "[Password Error: ". $passwordError ."]"; }
  3657. }
  3658. switch ($api['http_code']['http_code']){
  3659. case 400:
  3660. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." $username already has access to the shared libraries $errorMessage");
  3661. break;
  3662. case 401:
  3663. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." invalid Plex Token $errorMessage");
  3664. break;
  3665. case 422:
  3666. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." user info error $errorMessage");
  3667. break;
  3668. case 429:
  3669. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." too many requests to plex.tv please try later $errorMessage");
  3670. break;
  3671. case 200:
  3672. case 201:
  3673. writeLog("success", "PLEX JOIN: $username now has access to your Plex Library");
  3674. break;
  3675. default:
  3676. writeLog("error", "PLEX JOIN: unknown error, $errorMessage Error: ".$api['http_code']['http_code']);
  3677. }
  3678. //prettyPrint($api);
  3679. //prettyPrint(json_decode($api['content'], true));
  3680. return (!empty($success) && empty($errors) ? true : false );
  3681. }
  3682. function getCert(){
  3683. $url = "http://curl.haxx.se/ca/cacert.pem";
  3684. $file = getcwd()."/config/cacert.pem";
  3685. $directory = getcwd()."/config/";
  3686. @mkdir($directory, 0770, true);
  3687. if(!file_exists($file)){
  3688. file_put_contents( $file, fopen($url, 'r'));
  3689. writeLog("success", "CERT PEM: pem file created");
  3690. }elseif (file_exists($file) && time() - 2592000 > filemtime($file)) {
  3691. file_put_contents( $file, fopen($url, 'r'));
  3692. writeLog("success", "CERT PEM: downloaded new pem file");
  3693. }
  3694. return $file;
  3695. }
  3696. function customCSS(){
  3697. if(CUSTOMCSS == "true") {
  3698. $template_file = "custom.css";
  3699. $file_handle = fopen($template_file, "rb");
  3700. echo "\n";
  3701. echo fread($file_handle, filesize($template_file));
  3702. fclose($file_handle);
  3703. echo "\n";
  3704. }
  3705. }
  3706. function tvdbToken(){
  3707. $headers = array(
  3708. "Accept" => "application/json",
  3709. "Content-Type" => "application/json"
  3710. );
  3711. $json = array(
  3712. "apikey" => "FBE7B62621F4CAD7",
  3713. "userkey" => "328BB46EB1E9A0F5",
  3714. "username" => "causefx"
  3715. );
  3716. $api = curl_post("https://api.thetvdb.com/login", $json, $headers);
  3717. return json_decode($api['content'], true)['token'];
  3718. }
  3719. function tvdbGet($id){
  3720. $headers = array(
  3721. "Accept" => "application/json",
  3722. "Authorization" => "Bearer ".tvdbToken(),
  3723. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3724. "trakt-api-version" => "2"
  3725. );
  3726. $trakt = curl_get("https://api.trakt.tv/search/tvdb/$id?type=show", $headers);
  3727. @$api['trakt'] = json_decode($trakt, true)[0]['show']['ids'];
  3728. if(empty($api['trakt'])){
  3729. $series = curl_get("https://api.thetvdb.com/series/$id", $headers);
  3730. $poster = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=poster", $headers);
  3731. $backdrop = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=fanart", $headers);
  3732. $api['series'] = json_decode($series, true)['data'];
  3733. $api['poster'] = json_decode($poster, true)['data'];
  3734. $api['backdrop'] = json_decode($backdrop, true)['data'];
  3735. }
  3736. return $api;
  3737. }
  3738. function tvdbSearch($name, $type){
  3739. $name = rawurlencode(preg_replace("/\(([^()]*+|(?R))*\)/","", $name));
  3740. $headers = array(
  3741. "Accept" => "application/json",
  3742. "Authorization" => "Bearer ".tvdbToken(),
  3743. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3744. "trakt-api-version" => "2"
  3745. );
  3746. $trakt = curl_get("https://api.trakt.tv/search/$type?query=$name", $headers);
  3747. @$api['trakt'] = json_decode($trakt, true)[0][$type]['ids'];
  3748. return $api;
  3749. }
  3750. function getPlexPlaylists(){
  3751. $address = qualifyURL(PLEXURL);
  3752. // Perform API requests
  3753. $api = @curl_get($address."/playlists?X-Plex-Token=".PLEXTOKEN);
  3754. libxml_use_internal_errors(true);
  3755. $api = simplexml_load_string($api);
  3756. if (is_array($api) || is_object($api)){
  3757. if (!$api->head->title){
  3758. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3759. if (!$getServer) { return 'Could not load!'; }
  3760. // Identify the local machine
  3761. $gotServer = $getServer['machineIdentifier'];
  3762. $output = "";
  3763. $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">';
  3764. foreach($api AS $child) {
  3765. $items = array();
  3766. if ($child['playlistType'] == "video" && strpos(strtolower($child['title']) , 'private') === false){
  3767. $api = @curl_get($address.$child['key']."?X-Plex-Token=".PLEXTOKEN);
  3768. $api = simplexml_load_string($api);
  3769. if (is_array($api) || is_object($api)){
  3770. if (!$api->head->title){
  3771. $className = preg_replace("/(\W)+/", "", $api['title']);
  3772. $hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  3773. foreach($api->Video AS $child){
  3774. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false,false,$className);
  3775. }
  3776. if (count($items)) {
  3777. $output .= ''.implode('',$items).'';
  3778. }
  3779. }
  3780. }
  3781. }
  3782. }
  3783. $hideMenu .= '</ul></div></div>';
  3784. 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>';
  3785. }else{
  3786. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check token - if HTTPS, is cert valid");
  3787. }
  3788. }else{
  3789. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check URL - if HTTPS, is cert valid");
  3790. }
  3791. }
  3792. function readExternalLog($type,$filename,$name = null){
  3793. $log = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3794. $log = array_reverse($log);
  3795. foreach($log as $line){
  3796. if(!empty($line) && $line[0] != " "){
  3797. $line = strip($line);
  3798. if($type == "single"){
  3799. if( strpos( strtolower($line), "ror" ) !== false ) {
  3800. echo "<tr><td class='red-bg'>".$line."</td></tr>";
  3801. }else{
  3802. echo "<tr><td>".$line."</td></tr>";
  3803. }
  3804. }elseif($type == "all"){
  3805. if( strpos( strtolower($line), "ror" ) !== false ) {
  3806. echo "<tr><td class='red-bg'>".$name."</td>";
  3807. echo "<td class='red-bg'>".$line."</td></tr>";
  3808. }else{
  3809. echo "<tr><td>".$name."</td>";
  3810. echo "<td>".$line."</td></tr>";
  3811. }
  3812. }
  3813. }
  3814. }
  3815. }
  3816. function getLogs(){
  3817. $path = __DIR__ ."/logs/";
  3818. @mkdir($path, 0770, true);
  3819. $logs = array();
  3820. $files = array_diff(scandir($path), array('.', '..'));
  3821. foreach($files as $v){
  3822. $title = explode(".", $v)[0];
  3823. $logs[$title] = $path.$v;
  3824. }
  3825. return $logs;
  3826. }
  3827. function getBackups(){
  3828. $path = DATABASE_LOCATION ."backups/";
  3829. @mkdir($path, 0770, true);
  3830. $backups = array();
  3831. $files = array_diff(scandir($path), array('.', '..'));
  3832. return array_reverse($files);
  3833. }
  3834. function getExtension($string) {
  3835. return preg_replace("#(.+)?\.(\w+)(\?.+)?#", "$2", $string);
  3836. }
  3837. function showFile(){
  3838. $file = $_GET['file'];
  3839. $fileType = getExtension($file);
  3840. if($fileType != 'php'){
  3841. header("Content-type: ".mimeTypes()[$fileType]);
  3842. @readfile($file);
  3843. }
  3844. }
  3845. function getCalendar(){
  3846. $sonarr = new Sonarr(SONARRURL, SONARRKEY);
  3847. $radarr = new Sonarr(RADARRURL, RADARRKEY);
  3848. $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
  3849. $startDate = date('Y-m-d',strtotime("-".CALENDARSTARTDAY." days"));
  3850. $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
  3851. $calendarItems = array();
  3852. if (SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)){
  3853. try {
  3854. $sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate));
  3855. if(!empty($sonarrCalendar)) { $calendarItems = array_merge($calendarItems, $sonarrCalendar); }
  3856. } catch (Exception $e) {
  3857. writeLog("error", "SONARR ERROR: ".strip($e->getMessage()));
  3858. }
  3859. }
  3860. if (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)){
  3861. try {
  3862. $radarrCalendar = getRadarrCalendar($radarr->getCalendar($startDate, $endDate));
  3863. if(!empty($radarrCalendar)) { $calendarItems = array_merge($calendarItems, $radarrCalendar); }
  3864. } catch (Exception $e) {
  3865. writeLog("error", "RADARR ERROR: ".strip($e->getMessage()));
  3866. }
  3867. }
  3868. if (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH)){
  3869. $couchCalendar = getCouchCalendar();
  3870. if(!empty($couchCalendar)) { $calendarItems = array_merge($calendarItems, $couchCalendar); }
  3871. }
  3872. if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
  3873. $headphonesHistory = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory");
  3874. $headphonesWanted = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted");
  3875. if(!empty($headphonesHistory)) { $calendarItems = array_merge($calendarItems, $headphonesHistory); }
  3876. if(!empty($headphonesWanted)) { $calendarItems = array_merge($calendarItems, $headphonesWanted); }
  3877. }
  3878. if (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)){
  3879. try {
  3880. $sickrageFuture = getSickrageCalendarWanted($sickrage->future());
  3881. if(!empty($sickrageFuture)) { $calendarItems = array_merge($calendarItems, $sickrageFuture); }
  3882. } catch (Exception $e) {
  3883. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3884. } try {
  3885. $sickrageHistory = getSickrageCalendarHistory($sickrage->history("100","downloaded"));
  3886. if(!empty($sickrageHistory)) { $calendarItems = array_merge($calendarItems, $sickrageHistory); }
  3887. } catch (Exception $e) {
  3888. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3889. }
  3890. }
  3891. return $calendarItems;
  3892. }
  3893. function localURL($url){
  3894. if (strpos($url, 'https') !== false) {
  3895. preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $url, $result);
  3896. $result = (!empty($result) ? true : false);
  3897. return $result;
  3898. }
  3899. }
  3900. function fileArray($files){
  3901. foreach($files as $file){
  3902. if(file_exists($file)){
  3903. $list[] = $file;
  3904. }
  3905. }
  3906. if(!empty($list)){ return $list; }
  3907. }
  3908. function backupDB(){
  3909. if (extension_loaded('ZIP')) {
  3910. $directory = DATABASE_LOCATION."backups/";
  3911. @mkdir($directory, 0770, true);
  3912. $orgFiles = array(
  3913. 'css' => 'custom.css',
  3914. 'temp' => 'cus.sd',
  3915. 'orgLog' => DATABASE_LOCATION.'org.log',
  3916. 'loginLog' => DATABASE_LOCATION.'loginLog.json',
  3917. 'chatDB' => 'chatpack.db',
  3918. 'config' => 'config/config.php',
  3919. 'database' => DATABASE_LOCATION.'users.db'
  3920. );
  3921. $files = fileArray($orgFiles);
  3922. if(!empty($files)){
  3923. writeLog("success", "BACKUP: backup process started");
  3924. $zipname = $directory.'backup['.date('Y-m-d_H-i').']['.INSTALLEDVERSION.'].zip';
  3925. $zip = new ZipArchive;
  3926. $zip->open($zipname, ZipArchive::CREATE);
  3927. foreach ($files as $file) {
  3928. $zip->addFile($file);
  3929. }
  3930. $zip->close();
  3931. writeLog("success", "BACKUP: backup process finished");
  3932. return true;
  3933. }else{
  3934. return false;
  3935. }
  3936. }else{
  3937. return false;
  3938. }
  3939. }
  3940. class Ping {
  3941. private $host;
  3942. private $ttl;
  3943. private $timeout;
  3944. private $port = 80;
  3945. private $data = 'Ping';
  3946. private $commandOutput;
  3947. /**
  3948. * Called when the Ping object is created.
  3949. *
  3950. * @param string $host
  3951. * The host to be pinged.
  3952. * @param int $ttl
  3953. * Time-to-live (TTL) (You may get a 'Time to live exceeded' error if this
  3954. * value is set too low. The TTL value indicates the scope or range in which
  3955. * a packet may be forwarded. By convention:
  3956. * - 0 = same host
  3957. * - 1 = same subnet
  3958. * - 32 = same site
  3959. * - 64 = same region
  3960. * - 128 = same continent
  3961. * - 255 = unrestricted
  3962. * @param int $timeout
  3963. * Timeout (in seconds) used for ping and fsockopen().
  3964. * @throws \Exception if the host is not set.
  3965. */
  3966. public function __construct($host, $ttl = 255, $timeout = 10) {
  3967. if (!isset($host)) {
  3968. throw new \Exception("Error: Host name not supplied.");
  3969. }
  3970. $this->host = $host;
  3971. $this->ttl = $ttl;
  3972. $this->timeout = $timeout;
  3973. }
  3974. /**
  3975. * Set the ttl (in hops).
  3976. *
  3977. * @param int $ttl
  3978. * TTL in hops.
  3979. */
  3980. public function setTtl($ttl) {
  3981. $this->ttl = $ttl;
  3982. }
  3983. /**
  3984. * Get the ttl.
  3985. *
  3986. * @return int
  3987. * The current ttl for Ping.
  3988. */
  3989. public function getTtl() {
  3990. return $this->ttl;
  3991. }
  3992. /**
  3993. * Set the timeout.
  3994. *
  3995. * @param int $timeout
  3996. * Time to wait in seconds.
  3997. */
  3998. public function setTimeout($timeout) {
  3999. $this->timeout = $timeout;
  4000. }
  4001. /**
  4002. * Get the timeout.
  4003. *
  4004. * @return int
  4005. * Current timeout for Ping.
  4006. */
  4007. public function getTimeout() {
  4008. return $this->timeout;
  4009. }
  4010. /**
  4011. * Set the host.
  4012. *
  4013. * @param string $host
  4014. * Host name or IP address.
  4015. */
  4016. public function setHost($host) {
  4017. $this->host = $host;
  4018. }
  4019. /**
  4020. * Get the host.
  4021. *
  4022. * @return string
  4023. * The current hostname for Ping.
  4024. */
  4025. public function getHost() {
  4026. return $this->host;
  4027. }
  4028. /**
  4029. * Set the port (only used for fsockopen method).
  4030. *
  4031. * Since regular pings use ICMP and don't need to worry about the concept of
  4032. * 'ports', this is only used for the fsockopen method, which pings servers by
  4033. * checking port 80 (by default).
  4034. *
  4035. * @param int $port
  4036. * Port to use for fsockopen ping (defaults to 80 if not set).
  4037. */
  4038. public function setPort($port) {
  4039. $this->port = $port;
  4040. }
  4041. /**
  4042. * Get the port (only used for fsockopen method).
  4043. *
  4044. * @return int
  4045. * The port used by fsockopen pings.
  4046. */
  4047. public function getPort() {
  4048. return $this->port;
  4049. }
  4050. /**
  4051. * Return the command output when method=exec.
  4052. * @return string
  4053. */
  4054. public function getCommandOutput(){
  4055. return $this->commandOutput;
  4056. }
  4057. /**
  4058. * Matches an IP on command output and returns.
  4059. * @return string
  4060. */
  4061. public function getIpAddress() {
  4062. $out = array();
  4063. if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $this->commandOutput, $out)){
  4064. return $out[0];
  4065. }
  4066. return null;
  4067. }
  4068. /**
  4069. * Ping a host.
  4070. *
  4071. * @param string $method
  4072. * Method to use when pinging:
  4073. * - exec (default): Pings through the system ping command. Fast and
  4074. * robust, but a security risk if you pass through user-submitted data.
  4075. * - fsockopen: Pings a server on port 80.
  4076. * - socket: Creates a RAW network socket. Only usable in some
  4077. * environments, as creating a SOCK_RAW socket requires root privileges.
  4078. *
  4079. * @throws InvalidArgumentException if $method is not supported.
  4080. *
  4081. * @return mixed
  4082. * Latency as integer, in ms, if host is reachable or FALSE if host is down.
  4083. */
  4084. public function ping($method = 'exec') {
  4085. $latency = false;
  4086. switch ($method) {
  4087. case 'exec':
  4088. $latency = $this->pingExec();
  4089. break;
  4090. case 'fsockopen':
  4091. $latency = $this->pingFsockopen();
  4092. break;
  4093. case 'socket':
  4094. $latency = $this->pingSocket();
  4095. break;
  4096. default:
  4097. throw new \InvalidArgumentException('Unsupported ping method.');
  4098. }
  4099. // Return the latency.
  4100. return $latency;
  4101. }
  4102. /**
  4103. * The exec method uses the possibly insecure exec() function, which passes
  4104. * the input to the system. This is potentially VERY dangerous if you pass in
  4105. * any user-submitted data. Be SURE you sanitize your inputs!
  4106. *
  4107. * @return int
  4108. * Latency, in ms.
  4109. */
  4110. private function pingExec() {
  4111. $latency = false;
  4112. $ttl = escapeshellcmd($this->ttl);
  4113. $timeout = escapeshellcmd($this->timeout);
  4114. $host = escapeshellcmd($this->host);
  4115. // Exec string for Windows-based systems.
  4116. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  4117. // -n = number of pings; -i = ttl; -w = timeout (in milliseconds).
  4118. $exec_string = 'ping -n 1 -i ' . $ttl . ' -w ' . ($timeout * 1000) . ' ' . $host;
  4119. }
  4120. // Exec string for Darwin based systems (OS X).
  4121. else if(strtoupper(PHP_OS) === 'DARWIN') {
  4122. // -n = numeric output; -c = number of pings; -m = ttl; -t = timeout.
  4123. $exec_string = 'ping -n -c 1 -m ' . $ttl . ' -t ' . $timeout . ' ' . $host;
  4124. }
  4125. // Exec string for other UNIX-based systems (Linux).
  4126. else {
  4127. // -n = numeric output; -c = number of pings; -t = ttl; -W = timeout
  4128. $exec_string = 'ping -n -c 1 -t ' . $ttl . ' -W ' . $timeout . ' ' . $host . ' 2>&1';
  4129. }
  4130. exec($exec_string, $output, $return);
  4131. // Strip empty lines and reorder the indexes from 0 (to make results more
  4132. // uniform across OS versions).
  4133. $this->commandOutput = implode($output, '');
  4134. $output = array_values(array_filter($output));
  4135. // If the result line in the output is not empty, parse it.
  4136. if (!empty($output[1])) {
  4137. // Search for a 'time' value in the result line.
  4138. $response = preg_match("/time(?:=|<)(?<time>[\.0-9]+)(?:|\s)ms/", $output[1], $matches);
  4139. // If there's a result and it's greater than 0, return the latency.
  4140. if ($response > 0 && isset($matches['time'])) {
  4141. $latency = round($matches['time'], 2);
  4142. }
  4143. }
  4144. return $latency;
  4145. }
  4146. /**
  4147. * The fsockopen method simply tries to reach the host on a port. This method
  4148. * is often the fastest, but not necessarily the most reliable. Even if a host
  4149. * doesn't respond, fsockopen may still make a connection.
  4150. *
  4151. * @return int
  4152. * Latency, in ms.
  4153. */
  4154. private function pingFsockopen() {
  4155. $start = microtime(true);
  4156. // fsockopen prints a bunch of errors if a host is unreachable. Hide those
  4157. // irrelevant errors and deal with the results instead.
  4158. $fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
  4159. if (!$fp) {
  4160. $latency = false;
  4161. }
  4162. else {
  4163. $latency = microtime(true) - $start;
  4164. $latency = round($latency * 1000, 2);
  4165. }
  4166. return $latency;
  4167. }
  4168. /**
  4169. * The socket method uses raw network packet data to try sending an ICMP ping
  4170. * packet to a server, then measures the response time. Using this method
  4171. * requires the script to be run with root privileges, though, so this method
  4172. * only works reliably on Windows systems and on Linux servers where the
  4173. * script is not being run as a web user.
  4174. *
  4175. * @return int
  4176. * Latency, in ms.
  4177. */
  4178. private function pingSocket() {
  4179. // Create a package.
  4180. $type = "\x08";
  4181. $code = "\x00";
  4182. $checksum = "\x00\x00";
  4183. $identifier = "\x00\x00";
  4184. $seq_number = "\x00\x00";
  4185. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4186. // Calculate the checksum.
  4187. $checksum = $this->calculateChecksum($package);
  4188. // Finalize the package.
  4189. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4190. // Create a socket, connect to server, then read socket and calculate.
  4191. if ($socket = socket_create(AF_INET, SOCK_RAW, 1)) {
  4192. socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array(
  4193. 'sec' => 10,
  4194. 'usec' => 0,
  4195. ));
  4196. // Prevent errors from being printed when host is unreachable.
  4197. @socket_connect($socket, $this->host, null);
  4198. $start = microtime(true);
  4199. // Send the package.
  4200. @socket_send($socket, $package, strlen($package), 0);
  4201. if (socket_read($socket, 255) !== false) {
  4202. $latency = microtime(true) - $start;
  4203. $latency = round($latency * 1000, 2);
  4204. }
  4205. else {
  4206. $latency = false;
  4207. }
  4208. }
  4209. else {
  4210. $latency = false;
  4211. }
  4212. // Close the socket.
  4213. socket_close($socket);
  4214. return $latency;
  4215. }
  4216. /**
  4217. * Calculate a checksum.
  4218. *
  4219. * @param string $data
  4220. * Data for which checksum will be calculated.
  4221. *
  4222. * @return string
  4223. * Binary string checksum of $data.
  4224. */
  4225. private function calculateChecksum($data) {
  4226. if (strlen($data) % 2) {
  4227. $data .= "\x00";
  4228. }
  4229. $bit = unpack('n*', $data);
  4230. $sum = array_sum($bit);
  4231. while ($sum >> 16) {
  4232. $sum = ($sum >> 16) + ($sum & 0xffff);
  4233. }
  4234. return pack('n*', ~$sum);
  4235. }
  4236. }
  4237. function ping($pings, $type = "string") {
  4238. $ping = new Ping("");
  4239. $ping->setTtl(128);
  4240. $ping->setTimeout(2);
  4241. switch ($type){
  4242. case "array":
  4243. $results = [];
  4244. foreach ($pings as $k => $v) {
  4245. if(strpos($v, ':') !== false){
  4246. $domain = explode(':', $v)[0];
  4247. $port = explode(':', $v)[1];
  4248. $ping->setHost($domain);
  4249. $ping->setPort($port);
  4250. $latency = $ping->ping('fsockopen');
  4251. }else{
  4252. $ping->setHost($v);
  4253. $latency = $ping->ping();
  4254. }
  4255. if ($latency || $latency === 0) {
  4256. $results[$k] = $latency;
  4257. } else {
  4258. $results[$k] = 0;
  4259. }
  4260. }
  4261. break;
  4262. case "string":
  4263. if(strpos($pings, ':') !== false){
  4264. $domain = explode(':', $pings)[0];
  4265. $port = explode(':', $pings)[1];
  4266. $ping->setHost($domain);
  4267. $ping->setPort($port);
  4268. $latency = $ping->ping('fsockopen');
  4269. }else{
  4270. $ping->setHost($pings);
  4271. $latency = $ping->ping();
  4272. }
  4273. if ($latency || $latency === 0) {
  4274. $results = $latency;
  4275. } else {
  4276. $results = 0;
  4277. }
  4278. break;
  4279. }
  4280. return $results;
  4281. }
  4282. function getPing($url, $style, $refresh = null){
  4283. if(ping($url) !== 0){
  4284. $class = 'success';
  4285. if(!$refresh){
  4286. $class .= " animated slideInLeft";
  4287. }
  4288. }else{
  4289. $class = "warning";
  4290. if(!$refresh){
  4291. $class .= " animated flash loop-animation-timeout";
  4292. }
  4293. }
  4294. echo '<span class="pingcheck badge ping-'.$class.'" style="position: absolute;z-index: 100;right: 5px; padding: 0px 0px;'.$style.';font-size: 10px;">&nbsp;</span>';
  4295. }
  4296. function speedTestData(){
  4297. $file_db = DATABASE_LOCATION."speedtest.db";
  4298. if(file_exists($file_db)){
  4299. $conn = new PDO("sqlite:$file_db") or die("1");
  4300. $result = $conn->query('SELECT * FROM speedtest_users');
  4301. $conn = null;
  4302. if (is_array($result) || is_object($result)){
  4303. foreach($result as $k => $v){
  4304. $return[$k] = $v;
  4305. }
  4306. return $return;
  4307. }
  4308. }
  4309. }
  4310. function speedTestDisplay($array, $output){
  4311. if (is_array($array) || is_object($array)){
  4312. if($output == "graph"){
  4313. $result = "Morris.Line({element: 'morris-line',data: [";
  4314. foreach($array as $k => $v){
  4315. $result .= "{ y: '".substr($v['timestamp'],0,10)."', a: ".$v['ul'].", b: ".$v['dl'].", c: ".$v['ping']." },";
  4316. }
  4317. $result .= "],xkey: 'y',ykeys: ['a', 'b', 'c'],labels: ['Upload', 'Download', 'Ping'],hideHover: 'auto',resize: true,lineColors: ['#63A8EB','#ccc','#000'] });";
  4318. }elseif($output == "table"){
  4319. $result = "";
  4320. foreach($array as $k => $v){
  4321. $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>";
  4322. }
  4323. }
  4324. return $result;
  4325. }
  4326. }
  4327. function buildMenuPhone($array){
  4328. if (is_array($array) || is_object($array)){
  4329. $result = '
  4330. <div class="content-box profile-sidebar box-shadow">
  4331. <img src="images/organizr-logo-h-d.png" width="100%" style="margin-top: -10px;">
  4332. <div class="profile-usermenu">
  4333. <ul class="nav" id="settings-list">
  4334. ';
  4335. foreach($array as $k => $v){
  4336. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4337. continue;
  4338. }
  4339. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4340. continue;
  4341. }
  4342. /*$result .= '
  4343. <li>
  4344. <a id="'.$v['id'].'" box="'.$v['box'].'">'.$v['name'].'
  4345. <span class="fa-stack fa-fw pull-right" style="margin-top: -5px;margin-right: -10px;">
  4346. <i class="fa fa-'.$v['icon_1'].' fa-stack-2x '.$v['color'].'" style="font-size:null;"></i>
  4347. <i class="fa fa-'.$v['icon_2'].' fa-stack-1x fa-inverse"></i>
  4348. </span>
  4349. </a>
  4350. </li>
  4351. ';*/
  4352. $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>';
  4353. }
  4354. $result .= '</ul></div></div>';
  4355. return $result;
  4356. }
  4357. }
  4358. function buildMenu($array){
  4359. if (is_array($array) || is_object($array)){
  4360. $result = '<div class="settingsList">';
  4361. foreach($array as $k => $v){
  4362. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4363. continue;
  4364. }
  4365. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4366. continue;
  4367. }
  4368. $result .= '
  4369. <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">
  4370. <i class="mdi mdi-'.$v['icon_1'].' fa-fw pull-left" style="padding-left: '.$v['padding'].'px;font-size: 30px"></i>
  4371. <p class="" style="text-align: center;direction: rtl;display:none;margin: 2px;"><strong>'.$v['name'].'</strong></p>
  4372. </button>
  4373. ';
  4374. }
  4375. $result .= '</div>';
  4376. return $result;
  4377. }
  4378. }
  4379. function requestInvite($email, $username){
  4380. //sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null)
  4381. 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."));
  4382. }
  4383. function errormessage($msg) {
  4384. echo "<div style=\"margin-top: 50px;\">";
  4385. echo "<span style=\"color:#d89334;\">error </span>";
  4386. echo $msg;
  4387. echo "</div>";
  4388. }
  4389. function ajaxLoop($ajaxFunction, $refresh, $extraFunction = ''){
  4390. return "
  4391. setInterval(function() {
  4392. $.ajax({
  4393. url: 'ajax.php?a=".$ajaxFunction."',
  4394. timeout: 10000,
  4395. type: 'GET',
  4396. success: function(response) {
  4397. var getDiv = response;
  4398. var loadedID = $(getDiv).attr('id');
  4399. if (typeof loadedID !== 'undefined') {
  4400. var oldElement = $('#'+loadedID).prop('outerHTML');
  4401. var newElement = $(getDiv).prop('outerHTML');
  4402. if(oldElement !== newElement){
  4403. $('#'+loadedID).replaceWith($(getDiv).prop('outerHTML'));
  4404. ".$extraFunction."
  4405. console.log('".$ajaxFunction." has been updated');
  4406. }
  4407. }else{
  4408. console.log('".$ajaxFunction." data was not sufficent or is offline');
  4409. }
  4410. },
  4411. error: function(jqXHR, textStatus, errorThrown) {
  4412. console.error('".$ajaxFunction." could not be updated');
  4413. }
  4414. });
  4415. }, ".$refresh.");
  4416. ";
  4417. }
  4418. function getOrgUsers(){
  4419. $file_db = DATABASE_LOCATION."users.db";
  4420. if(file_exists($file_db)){
  4421. $conn = new PDO("sqlite:$file_db") or die("1");
  4422. $result = $conn->query('SELECT * FROM users');
  4423. $conn = null;
  4424. if (is_array($result) || is_object($result)){
  4425. foreach($result as $k => $v){
  4426. $return[$v['username']] = $v['email'];
  4427. }
  4428. return $return;
  4429. }
  4430. }
  4431. }
  4432. function getEmails($type = 'org'){
  4433. if($type == 'plex'){
  4434. $emails = array_merge(libraryList()['both'],getOrgUsers());
  4435. }elseif($type == 'emby'){
  4436. $emails = getOrgUsers();
  4437. }else{
  4438. $emails = getOrgUsers();
  4439. }
  4440. return $emails;
  4441. }
  4442. function printEmails($emails){
  4443. $result = '';
  4444. foreach($emails as $k => $v){
  4445. $result .= '<option value="'.$v.'">'.$k.'</option>';
  4446. }
  4447. return $result;
  4448. }
  4449. function massEmail($to, $subject, $message){
  4450. if (!isset($GLOBALS['file_db'])) {
  4451. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  4452. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  4453. }
  4454. $emailTemplate = array(
  4455. 'type' => 'mass',
  4456. 'body' => $message,
  4457. 'subject' => $subject,
  4458. 'user' => null,
  4459. 'password' => null,
  4460. 'inviteCode' => null,
  4461. );
  4462. $emailTemplate = emailTemplate($emailTemplate);
  4463. $subject = $emailTemplate['subject'];
  4464. $body = buildEmail($emailTemplate);
  4465. sendEmail(null, null, $subject, $body, $GLOBALS['USER']->adminEmail,$to);
  4466. }
  4467. function q2a($q){
  4468. if (is_array($q) || is_object($q)){
  4469. foreach ($q as $k => $v){
  4470. $a[$k] = $v;
  4471. }
  4472. if(!empty($a)){
  4473. return $a;
  4474. }
  4475. }
  4476. }
  4477. function getOmbiToken($username, $password){
  4478. $headers = array(
  4479. "Accept" => "application/json",
  4480. "Content-Type" => "application/json"
  4481. );
  4482. $json = array(
  4483. "username" => $username,
  4484. "password" => $password,
  4485. "rememberMe" => "true",
  4486. );
  4487. $api = curl_post(OMBIURL."/api/v1/Token", $json, $headers);
  4488. if (isset($api['content'])) {
  4489. return json_decode($api['content'], true)['access_token'];
  4490. }else{
  4491. return false;
  4492. }
  4493. }
  4494. function ombiAction($id, $action, $type){
  4495. $headers = array(
  4496. "Accept" => "application/json",
  4497. "Content-Type" => "application/json",
  4498. "Apikey" => OMBIKEY
  4499. );
  4500. $body = array(
  4501. 'id' => $id,
  4502. );
  4503. switch ($type) {
  4504. case 'season':
  4505. case 'tv':
  4506. $type = 'tv';
  4507. break;
  4508. default:
  4509. $type = 'movie';
  4510. break;
  4511. }
  4512. switch ($action) {
  4513. case 'approve':
  4514. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/approve", $body, $headers);
  4515. break;
  4516. case 'available':
  4517. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/available", $body, $headers);
  4518. break;
  4519. case 'unavailable':
  4520. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/unavailable", $body, $headers);
  4521. break;
  4522. case 'deny':
  4523. $api = curl_put(OMBIURL."/api/v1/Request/".$type."/deny", $body, $headers);
  4524. break;
  4525. case 'delete':
  4526. $api = curl_delete(OMBIURL."/api/v1/Request/".$type."/".$id, $headers);
  4527. break;
  4528. default:
  4529. # code...
  4530. break;
  4531. }
  4532. switch ($api['http_code']['http_code']){
  4533. case 401:
  4534. writeLog("error", "OMBI: Invalid API KEY");
  4535. return false;
  4536. break;
  4537. case 200:
  4538. writeLog("success", "OMBI: action completed successfully for [type: $type - action: $action - id: $id]");
  4539. return true;
  4540. break;
  4541. default:
  4542. writeLog("error", "OMBI: unknown error with request [type: $type - action: $action - id: $id]");
  4543. return false;
  4544. }
  4545. //return (!empty($result) ? $result : null );
  4546. }
  4547. function getOmbiRequests($type = "both"){
  4548. $headers = array(
  4549. "Accept" => "application/json",
  4550. "Apikey" => OMBIKEY,
  4551. );
  4552. $requests = array();
  4553. switch ($type) {
  4554. case 'movie':
  4555. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4556. break;
  4557. case 'tv':
  4558. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4559. break;
  4560. default:
  4561. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4562. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4563. break;
  4564. }
  4565. if(isset($movie)){
  4566. //$movie = array_reverse($movie);
  4567. foreach ($movie as $key => $value) {
  4568. $poster = explode('/',$value['posterPath']);
  4569. $requests[] = array(
  4570. 'id' => $value['theMovieDbId'],
  4571. 'title' => $value['title'],
  4572. 'poster' => (strpos($value['posterPath'], "/") !== false) ? 'https://image.tmdb.org/t/p/w300/'.end($poster) : 'https://image.tmdb.org/t/p/w300/'.$value['posterPath'],
  4573. 'approved' => $value['approved'],
  4574. 'available' => $value['available'],
  4575. 'denied' => $value['denied'],
  4576. 'deniedReason' => $value['deniedReason'],
  4577. 'user' => $value['requestedUser']['userName'],
  4578. 'request_id' => $value['id'],
  4579. 'request_date' => $value['requestedDate'],
  4580. 'release_date' => $value['releaseDate'],
  4581. 'type' => 'movie',
  4582. 'icon' => 'mdi mdi-filmstrip',
  4583. 'color' => 'palette-Deep-Purple-900 bg white',
  4584. );
  4585. }
  4586. }
  4587. if(isset($tv) && (is_array($tv) || is_object($tv))){
  4588. foreach ($tv as $key => $value) {
  4589. if(is_array($value['childRequests'][0])){
  4590. $requests[] = array(
  4591. 'id' => $value['tvDbId'],
  4592. 'title' => $value['title'],
  4593. 'poster' => $value['posterPath'],
  4594. 'approved' => $value['childRequests'][0]['approved'],
  4595. 'available' => $value['childRequests'][0]['available'],
  4596. 'denied' => $value['childRequests'][0]['denied'],
  4597. 'deniedReason' => $value['childRequests'][0]['deniedReason'],
  4598. 'user' => $value['childRequests'][0]['requestedUser']['userName'],
  4599. 'request_id' => $value['id'],
  4600. 'request_date' => $value['childRequests'][0]['requestedDate'],
  4601. 'release_date' => $value['releaseDate'],
  4602. 'type' => 'tv',
  4603. 'icon' => 'mdi mdi-television',
  4604. 'color' => 'grayish-blue-bg',
  4605. );
  4606. }
  4607. }
  4608. }
  4609. return (empty($requests)) ? '' : $requests;
  4610. }
  4611. function convertOmbiString($type, $value){
  4612. switch ($type) {
  4613. case 'approved':
  4614. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4615. $string['icon'] = ($value) ? 'mdi mdi-check' : 'mdi mdi-clock';
  4616. $string['color'] = ($value) ? 'green-bg' : 'yellow-bg';
  4617. break;
  4618. case 'available':
  4619. $string['string'] = ($value) ? 'Available' : 'Not Downloaded';
  4620. $string['icon'] = ($value) ? 'mdi mdi-server' : 'mdi mdi-server-off';
  4621. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4622. break;
  4623. case 'denied':
  4624. $string['string'] = ($value) ? 'Denied' : 'Approved';
  4625. $string['icon'] = ($value) ? 'mdi mdi-emoticon-sad' : 'mdi mdi-emoticon-happy';
  4626. $string['color'] = ($value) ? 'red-bg' : 'green-bg';
  4627. break;
  4628. case 'status':
  4629. switch ($value) {
  4630. case '1':
  4631. $string['string'] = 'Denied';
  4632. $string['icon'] = 'mdi mdi-window-close';
  4633. $string['color'] = 'red-bg';
  4634. break;
  4635. case '2':
  4636. $string['string'] = 'Approved';
  4637. $string['icon'] = 'mdi mdi-check';
  4638. $string['color'] = 'green-bg';
  4639. break;
  4640. case '3':
  4641. $string['string'] = 'Not Approved';
  4642. $string['icon'] = 'mdi mdi-clock';
  4643. $string['color'] = 'yellow-bg';
  4644. break;
  4645. default:
  4646. # code...
  4647. break;
  4648. }
  4649. break;
  4650. default:
  4651. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4652. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4653. break;
  4654. }
  4655. return $string;
  4656. }
  4657. function buildOmbiItem($type, $group, $user, $request){
  4658. if (is_array($request) || is_object($request)){
  4659. $actions = '';
  4660. if($request['denied']){
  4661. $status = 1;
  4662. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4663. }else{
  4664. if($request['approved']){
  4665. $status = 2;
  4666. }else{
  4667. $status = 3;
  4668. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4669. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="deny"><a class="requestAction" href="javascript:void(0)">Deny</a></li>';
  4670. }
  4671. }
  4672. if($request['available']){
  4673. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="unavailable"><a class="requestAction" href="javascript:void(0)">Mark as Unavailable</a></li>';
  4674. }else{
  4675. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="available"><a class="requestAction" href="javascript:void(0)">Mark as Available</a></li>';
  4676. }
  4677. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="delete"><a class="requestAction" href="javascript:void(0)">Delete</a></li>';
  4678. if(isset($group) && $group == 'admin'){
  4679. $actionMenu = '
  4680. <div class="requestOptions">
  4681. <div class="btn-group transparent" role="group">
  4682. <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>
  4683. <ul class="dropdown-menu"><h6 class="text-center requestHeader gray-bg">'.$request['user'].'</h6>'.$actions.'</ul>
  4684. </div>
  4685. </div>
  4686. ';
  4687. }else{
  4688. $actionMenu = '';
  4689. }
  4690. if((isset($group)) && $group == 'admin' || REQUESTEDUSERONLY == 'false'){
  4691. return '
  4692. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4693. '.$actionMenu.'
  4694. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4695. <div class="requestBottom text-center">
  4696. <div data-toggle="tooltip" data-placement="top" data-original-title="'.$request['type'].'" class="zero-m requestGroup '.$request['color'].'">
  4697. <i class="'.$request['icon'].'"></i>
  4698. </div>
  4699. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4700. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4701. </div>
  4702. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4703. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4704. </div>
  4705. </div>
  4706. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4707. </div>';
  4708. }else{
  4709. if(strtolower($request['user']) == strtolower($user)){
  4710. return '
  4711. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4712. '.$actionMenu.'
  4713. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4714. <div class="requestBottom text-center">
  4715. <div data-toggle="tooltip" data-placement="top" data-original-title="'.$request['type'].'" class="zero-m requestGroup '.$request['color'].'">
  4716. <i class="'.$request['icon'].'"></i>
  4717. </div>
  4718. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4719. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4720. </div>
  4721. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4722. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4723. </div>
  4724. </div>
  4725. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4726. </div>';
  4727. }
  4728. }
  4729. }
  4730. }
  4731. function buildOmbiList($group, $user){
  4732. $requests = array();
  4733. $movieList = getOmbiRequests('movie');
  4734. $tvList = getOmbiRequests('tv');
  4735. if(is_array($movieList) && is_array($tvList)){
  4736. $result = array_merge($movieList , $tvList );
  4737. }else{
  4738. if(is_array($movieList)){
  4739. $result = $movieList;
  4740. }elseif(is_array($tvList)){
  4741. $result = $tvList;
  4742. }else{
  4743. $result = false;
  4744. }
  4745. }
  4746. if (is_array($result) || is_object($result)){
  4747. usort($result, function ($item1, $item2) {
  4748. if ($item1['request_date'] == $item2['request_date']) return 0;
  4749. return $item1['request_date'] > $item2['request_date'] ? -1 : 1;
  4750. });
  4751. foreach ($result as $request) {
  4752. if($request['type'] == 'movie'){
  4753. $requests[] = buildOmbiItem('movie', $group, $user, $request);
  4754. }elseif($request['type'] == 'tv'){
  4755. $requests[] = buildOmbiItem('season', $group, $user, $request);
  4756. }
  4757. }
  4758. }
  4759. return outputOmbiRequests("Requested Content", $requests, ajaxLoop('ombi-requests',REQUESTREFRESH,'loadSlick();'), false);
  4760. }
  4761. function outputOmbiRequests($header = "Requested Content", $items, $script = false, $array) {
  4762. $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">';
  4763. if(preg_grep("/item-movie-Approved/", $items)){
  4764. $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>';
  4765. }
  4766. if(preg_grep("/item-movie-Approval-Pending/", $items)){
  4767. $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>';
  4768. }
  4769. if(preg_grep("/item-season-Approved/", $items)){
  4770. $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>';
  4771. }
  4772. if(preg_grep("/item-season-Approval-Pending/", $items)){
  4773. $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>';
  4774. }
  4775. $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>';
  4776. $hideMenu .= '</ul></div></div>';
  4777. // If None Populate Empty Item
  4778. //if (count(array_flip($items)) < 1) {
  4779. if(!array_filter($items)) {
  4780. return '<div id="recentRequests"></div>';
  4781. }else{
  4782. $className = str_replace(' ', '', $header);
  4783. 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>':'');
  4784. }
  4785. }
  4786. function ombiAPI($action){
  4787. $headers = array(
  4788. "Accept" => "application/json",
  4789. "Content-Type" => "application/json",
  4790. "Apikey" => OMBIKEY
  4791. );
  4792. $body = array();
  4793. switch ($action) {
  4794. case 'plex-cache':
  4795. $api = curl_post(OMBIURL."/api/v1/Job/plexcontentcacher", $body, $headers);
  4796. break;
  4797. default:
  4798. break;
  4799. }
  4800. if(is_array($api) || is_object($api)){
  4801. switch ($api['http_code']['http_code']){
  4802. case 200:
  4803. return true;
  4804. break;
  4805. default:
  4806. return false;
  4807. }
  4808. }else{
  4809. return false;
  4810. }
  4811. }
  4812. function loadIcons(){
  4813. $dirname = "images/";
  4814. $images = scandir($dirname);
  4815. $ignore = Array(".", "..", "favicon", "settings", "cache", "platforms", "._.DS_Store", ".DS_Store", "confused.png", "sowwy.png", "sort-btns", "loading.png", "titlelogo.png", "default.svg", "login.png", "no-np.png", "no-list.png", "no-np.psd", "no-list.psd", "themes", "nadaplaying.jpg", "organizr-logo-h-d.png", "organizr-logo-h.png");
  4816. $allIcons = '';
  4817. foreach($images as $curimg){
  4818. if(!in_array($curimg, $ignore)) {
  4819. $allIcons .= '
  4820. <div class="col-xs-2" style="width: 75px; height: 75px; padding-right: 0px;">
  4821. <a data-toggle="tooltip" data-placement="bottom" title="'.$dirname.$curimg.'" class="thumbnail" style="box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);">
  4822. <img style="width: 50px; height: 50px;" data-src="'.$dirname.$curimg.'" alt="thumbnail" class="allIcons lazyload shadow">
  4823. </a>
  4824. </div>
  4825. ';
  4826. }
  4827. }
  4828. return $allIcons;
  4829. }
  4830. function buildHomepageSettings(){
  4831. $homepageOrder = homepageOrder();
  4832. $homepageList = '<h4>Drag Homepage Items to Order Them</h4><div id="homepage-items" class="external-events">';
  4833. $inputList = '<div id="homepage-values" class="row">';
  4834. foreach ($homepageOrder as $key => $val) {
  4835. switch ($key) {
  4836. case 'homepageOrdercustomhtml':
  4837. $class = 'palette-Deep-Purple-100 bg gray';
  4838. $image = 'images/html.png';
  4839. if(empty(HOMEPAGECUSTOMHTML1)){
  4840. $class .= ' faded';
  4841. }
  4842. break;
  4843. case 'homepageOrdernotice':
  4844. $class = 'palette-Cyan-A400 bg gray';
  4845. $image = 'images/pin.png';
  4846. if(empty(HOMEPAGENOTICETITLE) && empty(HOMEPAGENOTICEMESSAGE)){
  4847. $class .= ' faded';
  4848. }
  4849. break;
  4850. case 'homepageOrdernoticeguest':
  4851. $class = 'palette-Cyan-A400 bg gray';
  4852. $image = 'images/pin.png';
  4853. if(empty(HOMEPAGENOTICETITLEGUEST) && empty(HOMEPAGENOTICEMESSAGEGUEST)){
  4854. $class .= ' faded';
  4855. }
  4856. break;
  4857. case 'homepageOrderspeedtest':
  4858. $class = 'red-bg';
  4859. $image = 'images/settings/full-color/png/64px/speedometer.png';
  4860. if(SPEEDTEST !== "true"){
  4861. $class .= ' faded';
  4862. }
  4863. break;
  4864. case 'homepageOrdertransmisson':
  4865. $class = 'green-bg';
  4866. $image = 'images/transmission.png';
  4867. if(empty(TRANSMISSIONURL)){
  4868. $class .= ' faded';
  4869. }
  4870. break;
  4871. case 'homepageOrdernzbget':
  4872. $class = 'green-bg';
  4873. $image = 'images/nzbget.png';
  4874. if(empty(NZBGETURL)){
  4875. $class .= ' faded';
  4876. }
  4877. break;
  4878. case 'homepageOrdersabnzbd':
  4879. $class = 'yellow-bg';
  4880. $image = 'images/sabnzbd.png';
  4881. if(empty(SABNZBDURL)){
  4882. $class .= ' faded';
  4883. }
  4884. break;
  4885. case 'homepageOrderplexsearch':
  4886. case 'homepageOrderplexnowplaying':
  4887. case 'homepageOrderplexrecent':
  4888. case 'homepageOrderplexplaylist':
  4889. $class = 'palette-Amber-A700 bg gray';
  4890. $image = 'images/plex.png';
  4891. if(empty(PLEXURL)){
  4892. $class .= ' faded';
  4893. }
  4894. break;
  4895. case 'homepageOrderembynowplaying':
  4896. case 'homepageOrderembyrecent':
  4897. $class = 'palette-Green-A700 bg gray';
  4898. $image = 'images/emby.png';
  4899. if(empty(EMBYURL)){
  4900. $class .= ' faded';
  4901. }
  4902. break;
  4903. case 'homepageOrderombi':
  4904. $class = 'orange-bg';
  4905. $image = 'images/ombi.png';
  4906. if(empty(OMBIURL)){
  4907. $class .= ' faded';
  4908. }
  4909. break;
  4910. case 'homepageOrdercalendar':
  4911. $class = 'palette-Blue-400 bg gray';
  4912. $image = 'images/calendar.png';
  4913. if(SONARRURL == "" && RADARRURL == "" && HEADPHONESURL == "" && SICKRAGEURL == "" && COUCHURL == "" ){
  4914. $class .= ' faded';
  4915. }
  4916. break;
  4917. default:
  4918. $class = 'blue-bg';
  4919. $image = '';
  4920. break;
  4921. }
  4922. $homepageList .= '
  4923. <div class="col-md-3 sort-homepage"><div class="fc-event '.$class.'">
  4924. <span class="ordinal-position text-uppercase badge badge-gray" data-link="'.$key.'" style="float:left;width: 30px;">'.$val.'</span>
  4925. &nbsp; '.strtoupper(substr($key, 13)).'
  4926. <span class="remove-event"><img style="width: 22px;" src="'.$image.'"></span>
  4927. </div></div>';
  4928. $inputList .= '<input type="hidden" name="'.$key.'">';
  4929. }
  4930. $homepageList .= '</div>';
  4931. $inputList .= '</div>';
  4932. return $homepageList.$inputList;
  4933. }
  4934. function buildHomepage($group, $user){
  4935. $homepageOrder = homepageOrder();
  4936. $homepageBuilt = '';
  4937. foreach ($homepageOrder as $key => $value) {
  4938. $homepageBuilt .= buildHomepageItem($key, $group, $user);
  4939. }
  4940. return $homepageBuilt;
  4941. }
  4942. function realSize($bytes, $decimals = 2) {
  4943. $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
  4944. $factor = floor((strlen($bytes) - 1) / 3);
  4945. return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' '.@$size[$factor];
  4946. }
  4947. function buildHomepageItem($homepageItem, $group, $user){
  4948. $homepageItemBuilt = '';
  4949. switch ($homepageItem) {
  4950. case 'homepageOrderplexsearch':
  4951. if((qualifyUser(PLEXSEARCHAUTH) && PLEXSEARCH == "true" && qualifyUser(PLEXHOMEAUTH))) {
  4952. $homepageItemBuilt .= '
  4953. <div id="searchPlexRow" class="row">
  4954. <div class="col-lg-12">
  4955. <div class="content-box box-shadow big-box todo-list">
  4956. <form id="plexSearchForm" onsubmit="return false;" autocomplete="off">
  4957. <div class="">
  4958. <div class="input-group">
  4959. <div style="border-radius: 25px 0 0 25px; border:0" class="input-group-addon gray-bg"><i class="fa fa-search white"></i></div>
  4960. <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">
  4961. <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>
  4962. <button style="display:none" id="plexSearchForm_submit" class="btn btn-primary waves"></button>
  4963. </div>
  4964. </div>
  4965. </form>
  4966. <div id="resultshere" class="table-responsive"></div>
  4967. </div>
  4968. </div>
  4969. </div>
  4970. ';
  4971. }
  4972. break;
  4973. case 'homepageOrdercustomhtml':
  4974. if (qualifyUser(HOMEPAGECUSTOMHTML1AUTH) && HOMEPAGECUSTOMHTML1) {
  4975. $homepageItemBuilt .= "<div>" . HOMEPAGECUSTOMHTML1 . "</div>";
  4976. }
  4977. break;
  4978. case 'homepageOrdernotice':
  4979. if (qualifyUser(HOMEPAGENOTICEAUTH) && HOMEPAGENOTICETITLE && HOMEPAGENOTICETYPE && HOMEPAGENOTICEMESSAGE && HOMEPAGENOTICELAYOUT) {
  4980. $homepageItemBuilt .= buildHomepageNotice(HOMEPAGENOTICELAYOUT, HOMEPAGENOTICETYPE, HOMEPAGENOTICETITLE, HOMEPAGENOTICEMESSAGE);
  4981. }
  4982. break;
  4983. case 'homepageOrdernoticeguest':
  4984. if ($group == 'guest' && HOMEPAGENOTICETITLEGUEST && HOMEPAGENOTICETYPEGUEST && HOMEPAGENOTICEMESSAGEGUEST && HOMEPAGENOTICELAYOUTGUEST) {
  4985. $homepageItemBuilt .= buildHomepageNotice(HOMEPAGENOTICELAYOUTGUEST, HOMEPAGENOTICETYPEGUEST, HOMEPAGENOTICETITLEGUEST, HOMEPAGENOTICEMESSAGEGUEST);
  4986. }
  4987. break;
  4988. case 'homepageOrderspeedtest':
  4989. if(SPEEDTEST == "true" && qualifyUser(SPEEDTESTAUTH)){
  4990. $homepageItemBuilt .= '
  4991. <style type="text/css">
  4992. .flash {
  4993. animation: flash 0.6s linear infinite;
  4994. }
  4995. @keyframes flash {
  4996. 0% { opacity: 0.6; }
  4997. 50% { opacity: 1; }
  4998. }
  4999. </style>
  5000. <script type="text/javascript">
  5001. var w = null
  5002. function runTest() {
  5003. document.getElementById("startBtn").style.display = "none"
  5004. document.getElementById("testArea").style.display = ""
  5005. document.getElementById("abortBtn").style.display = ""
  5006. w = new Worker("bower_components/speed/speedtest_worker.js")
  5007. var interval = setInterval(function () { w.postMessage("status") }, 100)
  5008. w.onmessage = function (event) {
  5009. var data = event.data.split(";")
  5010. var status = Number(data[0])
  5011. var dl = document.getElementById("download")
  5012. var ul = document.getElementById("upload")
  5013. var ping = document.getElementById("ping")
  5014. var jitter = document.getElementById("jitter")
  5015. dl.className = status === 1 ? "w-name flash" : "w-name"
  5016. ping.className = status === 2 ? "w-name flash" : "w-name"
  5017. jitter.className = ul.className = status === 3 ? "w-name flash" : "w-name"
  5018. if (status >= 4) {
  5019. clearInterval(interval)
  5020. document.getElementById("abortBtn").style.display = "none"
  5021. document.getElementById("startBtn").style.display = ""
  5022. w = null
  5023. }
  5024. if (status === 5) {
  5025. document.getElementById("testArea").style.display = "none"
  5026. }
  5027. dl.textContent = data[1] + " Mbit/s";
  5028. $("#downloadpercent").attr("style", "width: " + data[1] + "%;");
  5029. $("#uploadpercent").attr("style", "width: " + data[2] + "%;");
  5030. $("#pingpercent").attr("style", "width: " + data[3] + "%;");
  5031. $("#jitterpercent").attr("style", "width: " + data[5] + "%;");
  5032. ul.textContent = data[2] + " Mbit/s";
  5033. ping.textContent = data[3] + " ms";
  5034. jitter.textContent = data[5] + " ms";
  5035. }
  5036. w.postMessage(\'start {"telemetry_level":"basic"}\')
  5037. //w.postMessage("start")
  5038. }
  5039. function abortTest() {
  5040. if (w) w.postMessage("abort")
  5041. }
  5042. </script>
  5043. <div class="row" id="testArea" style="display:none">
  5044. <div class="test col-sm-3 col-lg-3">
  5045. <div class="content-box ultra-widget green-bg" data-counter="">
  5046. <div id="downloadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  5047. <div class="w-content">
  5048. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-download"></i></div>
  5049. <div class="w-descr left pull-left text-center">
  5050. <span class="testName text-uppercase w-name">Download</span>
  5051. <br>
  5052. <span class="w-name counter" id="download" ></span>
  5053. </div>
  5054. </div>
  5055. </div>
  5056. </div>
  5057. <div class="test col-sm-3 col-lg-3">
  5058. <div class="content-box ultra-widget red-bg" data-counter="">
  5059. <div id="uploadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  5060. <div class="w-content">
  5061. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-upload"></i></div>
  5062. <div class="w-descr left pull-left text-center">
  5063. <span class="testName text-uppercase w-name">Upload</span>
  5064. <br>
  5065. <span class="w-name counter" id="upload" ></span>
  5066. </div>
  5067. </div>
  5068. </div>
  5069. </div>
  5070. <div class="test col-sm-3 col-lg-3">
  5071. <div class="content-box ultra-widget yellow-bg" data-counter="">
  5072. <div id="pingpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  5073. <div class="w-content">
  5074. <div class="w-icon right pull-right"><i class="mdi mdi-timer"></i></div>
  5075. <div class="w-descr left pull-left text-center">
  5076. <span class="testName text-uppercase w-name">Latency</span>
  5077. <br>
  5078. <span class="w-name counter" id="ping" ></span>
  5079. </div>
  5080. </div>
  5081. </div>
  5082. </div>
  5083. <div class="test col-sm-3 col-lg-3">
  5084. <div class="content-box ultra-widget blue-bg" data-counter="">
  5085. <div id="jitterpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  5086. <div class="w-content">
  5087. <div class="w-icon right pull-right"><i class="mdi mdi-pulse"></i></div>
  5088. <div class="w-descr left pull-left text-center">
  5089. <span class="testName text-uppercase w-name">Jitter</span>
  5090. <br>
  5091. <span class="w-name counter" id="jitter" ></span>
  5092. </div>
  5093. </div>
  5094. </div>
  5095. </div>
  5096. <br/>
  5097. </div>
  5098. <div id="abortBtn" class="row" style="display: none" onclick="javascript:abortTest()">
  5099. <div class="col-lg-12">
  5100. <div class="content-box red-bg" style="cursor: pointer;">
  5101. <h1 style="margin: 10px" class="text-uppercase text-center">Abort Speed Test</h1>
  5102. <div class="clearfix"></div>
  5103. </div>
  5104. </div>
  5105. </div>
  5106. <div id="startBtn" class="row" onclick="javascript:runTest()">
  5107. <div class="col-lg-12">
  5108. <div class="content-box green-bg" style="cursor: pointer;">
  5109. <h1 style="margin: 10px" class="text-uppercase text-center">Run Speed Test</h1>
  5110. <div class="clearfix"></div>
  5111. </div>
  5112. </div>
  5113. </div>
  5114. ';
  5115. }
  5116. break;
  5117. case 'homepageOrdertransmisson':
  5118. if(TRANSMISSIONURL != "" && qualifyUser(TRANSMISSIONHOMEAUTH)){
  5119. $homepageItemBuilt .= buildDownloader('transmission', 'no');
  5120. }
  5121. break;
  5122. case 'homepageOrdernzbget':
  5123. if(NZBGETURL != "" && qualifyUser(NZBGETHOMEAUTH)){
  5124. $homepageItemBuilt .= buildDownloader('nzbget');
  5125. }
  5126. break;
  5127. case 'homepageOrdersabnzbd':
  5128. if(SABNZBDURL != "" && qualifyUser(SABNZBDHOMEAUTH)) {
  5129. $homepageItemBuilt .= buildDownloader('sabnzbd');
  5130. }
  5131. break;
  5132. case 'homepageOrderplexnowplaying':
  5133. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  5134. if(qualifyUser(PLEXPLAYINGNOWAUTH) && PLEXPLAYINGNOW == "true"){
  5135. $homepageItemBuilt .= '<div id="plexRowNowPlaying" class="row">';
  5136. $homepageItemBuilt .= getPlexStreams(12, PLEXSHOWNAMES, $group);
  5137. $homepageItemBuilt .= '</div>';
  5138. }
  5139. }
  5140. break;
  5141. case 'homepageOrderplexrecent':
  5142. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  5143. if(qualifyUser(PLEXRECENTMOVIEAUTH) && PLEXRECENTMOVIE == "true" || qualifyUser(PLEXRECENTTVAUTH) && PLEXRECENTTV == "true" || qualifyUser(PLEXRECENTMUSICAUTH) && PLEXRECENTMUSIC == "true"){
  5144. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  5145. $homepageItemBuilt .= '<div id="plexRow" class="row"><div class="col-lg-12">';
  5146. $homepageItemBuilt .= getPlexRecent($plexArray);
  5147. $homepageItemBuilt .= '</div></div>';
  5148. }
  5149. }
  5150. break;
  5151. case 'homepageOrderplexplaylist':
  5152. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  5153. if(qualifyUser(PLEXPLAYLISTSAUTH) && PLEXPLAYLISTS == "true"){
  5154. $homepageItemBuilt .= '<div id="plexPlaylists" class="row"><div class="col-lg-12">';
  5155. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  5156. $homepageItemBuilt .= getPlexPlaylists($plexArray);
  5157. $homepageItemBuilt .= '</div> </div>';
  5158. }
  5159. }
  5160. break;
  5161. case 'homepageOrderembynowplaying':
  5162. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  5163. if(qualifyUser(EMBYPLAYINGNOWAUTH) && EMBYPLAYINGNOW == "true"){
  5164. $homepageItemBuilt .= '<div id="embyRowNowPlaying" class="row">';
  5165. $homepageItemBuilt .= getEmbyStreams(12, EMBYSHOWNAMES, $group);
  5166. $homepageItemBuilt .= '</div>';
  5167. }
  5168. }
  5169. break;
  5170. case 'homepageOrderembyrecent':
  5171. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  5172. if(qualifyUser(EMBYRECENTMOVIEAUTH) && EMBYRECENTMOVIE == "true" || qualifyUser(EMBYRECENTTVAUTH) && EMBYRECENTTV == "true" || qualifyUser(EMBYRECENTMUSICAUTH) && EMBYRECENTMUSIC == "true"){
  5173. $embyArray = array("Movie" => EMBYRECENTMOVIE, "Episode" => EMBYRECENTTV, "MusicAlbum" => EMBYRECENTMUSIC, "Series" => EMBYRECENTTV);
  5174. $homepageItemBuilt .= '<div id="embyRow" class="row"><div class="col-lg-12">';
  5175. $homepageItemBuilt .= getEmbyRecent($embyArray);
  5176. $homepageItemBuilt .= '</div></div>';
  5177. }
  5178. }
  5179. break;
  5180. case 'homepageOrderombi':
  5181. if (qualifyUser(OMBIAUTH) && OMBIURL) {
  5182. $homepageItemBuilt .= '<div id="ombiRequests" class="row"><div class="col-lg-12">';
  5183. $homepageItemBuilt .= buildOmbiList($group, $user);
  5184. $homepageItemBuilt .= '</div></div>';
  5185. }
  5186. break;
  5187. case 'homepageOrdercalendar':
  5188. if ((SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)) || (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)) || (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)) || (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)) || (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH))) {
  5189. $calendarItems = '';
  5190. if(RADARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="film" href="javascript:void(0)">Movies</a></li>'; }
  5191. if(SONARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="tv" href="javascript:void(0)">TV Shows</a></li>'; }
  5192. if(HEADPHONESURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="music" href="javascript:void(0)">Music</a></li>'; }
  5193. $homepageItemBuilt .= '
  5194. <div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">
  5195. <div class="col-lg-12 content-form form-inline">
  5196. <div class="form-group pull-right">
  5197. <span class="swal-legend label label-primary well-sm">Legend</span>&nbsp;
  5198. <div class="btn-group" role="group">
  5199. <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>
  5200. <ul style="right:0; left: auto" class="dropdown-menu">
  5201. <li><a class="calendarOption" calendarOption="all" href="javascript:void(0)">View All</a></li>
  5202. '.$calendarItems.'
  5203. </ul>
  5204. </div>
  5205. </div>
  5206. </div>
  5207. </div>
  5208. <div id="calendarRow" class="row">
  5209. <div class="col-lg-12">
  5210. <div id="calendar" class="fc-calendar box-shadow fc fc-ltr fc-unthemed"></div>
  5211. </div>
  5212. </div>
  5213. ';
  5214. }
  5215. break;
  5216. default:
  5217. # code...
  5218. break;
  5219. }
  5220. return $homepageItemBuilt;
  5221. }
  5222. function buildAccordion($items){
  5223. $i = 1;
  5224. $variables = '&nbsp; Available Variables: ';
  5225. $accordion = '<div style="margin-bottom: 0px;" class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">';
  5226. foreach ($items as $key => $value) {
  5227. foreach ($value['variables'] as $variable) {
  5228. $variables .= '<mark>'.$variable.'</mark>';
  5229. }
  5230. $accordion .= '
  5231. <div class="panel panel-default">
  5232. <div class="panel-heading" role="tab" id="heading-'.$i.'">
  5233. <h4 class="panel-title" style="text-decoration: none;" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-'.$i.'" aria-expanded="true" aria-controls="collapse-'.$i.'">'.$value['title'].'</h4>
  5234. </div>
  5235. <div id="collapse-'.$i.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-'.$i.'" aria-expanded="true">
  5236. <br/>'.$variables.'<br/></br/>
  5237. <div class="form-content col-sm-12 col-md-12 col-lg-12">
  5238. <input id="'.$value['template'].'Subject_id" name="'.$value['template'].'Subject" type="text" class="form-control material input-sm" autocorrect="off" autocapitalize="off" value="'.$value['subject'].'">
  5239. <p class="help-text">Email Subject</p>
  5240. </div>
  5241. <br/></br/>
  5242. <div class="summernote" name="'.$value['template'].'">'.$value['body'].'</div>
  5243. </div>
  5244. </div>
  5245. ';
  5246. $i++;
  5247. $variables = '&nbsp; Available Variables: ';
  5248. }
  5249. $accordion .= '</div>';
  5250. return $accordion;
  5251. }
  5252. function emailTemplate($emailTemplate){
  5253. $variables = [
  5254. '{user}' => $emailTemplate['user'],
  5255. '{domain}' => DOMAIN,
  5256. '{password}' => $emailTemplate['password'],
  5257. '{inviteCode}' => $emailTemplate['inviteCode'],
  5258. '{fullDomain}' => getServerPath(),
  5259. ];
  5260. $emailTemplate['body'] = strtr($emailTemplate['body'], $variables);
  5261. $emailTemplate['subject'] = strtr($emailTemplate['subject'], $variables);
  5262. return $emailTemplate;
  5263. }
  5264. function buildEmail($email){
  5265. $subject = (isset($email['subject'])) ? $email['subject'] : 'Message from Server';
  5266. $body = (isset($email['body'])) ? $email['body'] : 'Message Error Occured';
  5267. $type = (isset($email['type'])) ? $email['type'] : 'No Type';
  5268. switch ($type) {
  5269. case 'invite':
  5270. $extra = 'invite';
  5271. break;
  5272. case 'reset':
  5273. $extra = 'reset';
  5274. break;
  5275. default:
  5276. $extra = null;
  5277. break;
  5278. }
  5279. include('email.php');
  5280. return $email;
  5281. }
  5282. function buildDownloader($name, $type = 'both'){
  5283. if($type == 'both'){
  5284. $tabs = '
  5285. <ul class="nav nav-tabs pull-right">
  5286. <li class="active"><a href="#downloadQueue-'.$name.'" data-toggle="tab" aria-expanded="true">'.translate("QUEUE").'</a></li>
  5287. <li class=""><a href="#downloadHistory-'.$name.'" data-toggle="tab" aria-expanded="false">'.translate("HISTORY").'</a></li>
  5288. </ul>
  5289. ';
  5290. $bodyHistory = '
  5291. <div class="tab-pane fade" id="downloadHistory-'.$name.'">
  5292. <div class="table-responsive" style="max-height: 300px">
  5293. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  5294. <thead>
  5295. <tr>
  5296. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  5297. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  5298. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  5299. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  5300. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  5301. </tr>
  5302. </thead>
  5303. <tbody class="dl-history '.$name.'"></tbody>
  5304. </table>
  5305. </div>
  5306. </div>
  5307. ';
  5308. }else{
  5309. $tabs = '';
  5310. $bodyHistory = '';
  5311. }
  5312. return '
  5313. <div id="downloadClientRow" class="row">
  5314. <div class="col-xs-12 col-md-12">
  5315. <div class="content-box">
  5316. <div class="tabbable panel with-nav-tabs panel-default">
  5317. <div class="panel-heading">
  5318. <div class="content-tools i-block pull-right">
  5319. <a id="getDownloader" class="repeat-btn">
  5320. <i class="fa fa-repeat"></i>
  5321. </a>
  5322. </div>
  5323. <h3 class="pull-left">'.strtoupper($name).'</h3>
  5324. '.$tabs.'
  5325. <div class="clearfix"></div>
  5326. </div>
  5327. <div class="panel-body">
  5328. <div class="tab-content">
  5329. <div class="tab-pane fade active in" id="downloadQueue-'.$name.'">
  5330. <div class="table-responsive" style="max-height: 300px">
  5331. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  5332. <thead>
  5333. <tr>
  5334. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  5335. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  5336. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  5337. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  5338. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  5339. </tr>
  5340. </thead>
  5341. <tbody class="dl-queue '.$name.'"></tbody>
  5342. </table>
  5343. </div>
  5344. </div>
  5345. '.$bodyHistory.'
  5346. </div>
  5347. </div>
  5348. </div>
  5349. </div>
  5350. </div>
  5351. </div>';
  5352. }
  5353. class Mobile_Detect
  5354. {
  5355. /**
  5356. * Mobile detection type.
  5357. *
  5358. * @deprecated since version 2.6.9
  5359. */
  5360. const DETECTION_TYPE_MOBILE = 'mobile';
  5361. /**
  5362. * Extended detection type.
  5363. *
  5364. * @deprecated since version 2.6.9
  5365. */
  5366. const DETECTION_TYPE_EXTENDED = 'extended';
  5367. /**
  5368. * A frequently used regular expression to extract version #s.
  5369. *
  5370. * @deprecated since version 2.6.9
  5371. */
  5372. const VER = '([\w._\+]+)';
  5373. /**
  5374. * Top-level device.
  5375. */
  5376. const MOBILE_GRADE_A = 'A';
  5377. /**
  5378. * Mid-level device.
  5379. */
  5380. const MOBILE_GRADE_B = 'B';
  5381. /**
  5382. * Low-level device.
  5383. */
  5384. const MOBILE_GRADE_C = 'C';
  5385. /**
  5386. * Stores the version number of the current release.
  5387. */
  5388. const VERSION = '2.8.26';
  5389. /**
  5390. * A type for the version() method indicating a string return value.
  5391. */
  5392. const VERSION_TYPE_STRING = 'text';
  5393. /**
  5394. * A type for the version() method indicating a float return value.
  5395. */
  5396. const VERSION_TYPE_FLOAT = 'float';
  5397. /**
  5398. * A cache for resolved matches
  5399. * @var array
  5400. */
  5401. protected $cache = array();
  5402. /**
  5403. * The User-Agent HTTP header is stored in here.
  5404. * @var string
  5405. */
  5406. protected $userAgent = null;
  5407. /**
  5408. * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
  5409. * @var array
  5410. */
  5411. protected $httpHeaders = array();
  5412. /**
  5413. * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
  5414. * @var array
  5415. */
  5416. protected $cloudfrontHeaders = array();
  5417. /**
  5418. * The matching Regex.
  5419. * This is good for debug.
  5420. * @var string
  5421. */
  5422. protected $matchingRegex = null;
  5423. /**
  5424. * The matches extracted from the regex expression.
  5425. * This is good for debug.
  5426. * @var string
  5427. */
  5428. protected $matchesArray = null;
  5429. /**
  5430. * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
  5431. *
  5432. * @deprecated since version 2.6.9
  5433. *
  5434. * @var string
  5435. */
  5436. protected $detectionType = self::DETECTION_TYPE_MOBILE;
  5437. /**
  5438. * HTTP headers that trigger the 'isMobile' detection
  5439. * to be true.
  5440. *
  5441. * @var array
  5442. */
  5443. protected static $mobileHeaders = array(
  5444. 'HTTP_ACCEPT' => array('matches' => array(
  5445. // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
  5446. 'application/x-obml2d',
  5447. // BlackBerry devices.
  5448. 'application/vnd.rim.html',
  5449. 'text/vnd.wap.wml',
  5450. 'application/vnd.wap.xhtml+xml'
  5451. )),
  5452. 'HTTP_X_WAP_PROFILE' => null,
  5453. 'HTTP_X_WAP_CLIENTID' => null,
  5454. 'HTTP_WAP_CONNECTION' => null,
  5455. 'HTTP_PROFILE' => null,
  5456. // Reported by Opera on Nokia devices (eg. C3).
  5457. 'HTTP_X_OPERAMINI_PHONE_UA' => null,
  5458. 'HTTP_X_NOKIA_GATEWAY_ID' => null,
  5459. 'HTTP_X_ORANGE_ID' => null,
  5460. 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
  5461. 'HTTP_X_HUAWEI_USERID' => null,
  5462. // Reported by Windows Smartphones.
  5463. 'HTTP_UA_OS' => null,
  5464. // Reported by Verizon, Vodafone proxy system.
  5465. 'HTTP_X_MOBILE_GATEWAY' => null,
  5466. // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
  5467. 'HTTP_X_ATT_DEVICEID' => null,
  5468. // Seen this on a HTC.
  5469. 'HTTP_UA_CPU' => array('matches' => array('ARM')),
  5470. );
  5471. /**
  5472. * List of mobile devices (phones).
  5473. *
  5474. * @var array
  5475. */
  5476. protected static $phoneDevices = array(
  5477. 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
  5478. 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
  5479. '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',
  5480. 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
  5481. // @todo: Is 'Dell Streak' a tablet or a phone? ;)
  5482. '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',
  5483. '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',
  5484. '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',
  5485. '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)',
  5486. 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
  5487. 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
  5488. 'NokiaLumia' => 'Lumia [0-9]{3,4}',
  5489. // http://www.micromaxinfo.com/mobiles/smartphones
  5490. // Added because the codes might conflict with Acer Tablets.
  5491. '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',
  5492. // @todo Complete the regex.
  5493. 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
  5494. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
  5495. // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
  5496. // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
  5497. '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',
  5498. // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
  5499. 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
  5500. // http://fr.wikomobile.com
  5501. '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',
  5502. 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
  5503. // Added simvalley mobile just for fun. They have some interesting devices.
  5504. // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
  5505. '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',
  5506. // Wolfgang - a brand that is sold by Aldi supermarkets.
  5507. // http://www.wolfgangmobile.com/
  5508. 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
  5509. 'Alcatel' => 'Alcatel',
  5510. 'Nintendo' => 'Nintendo 3DS',
  5511. // http://en.wikipedia.org/wiki/Amoi
  5512. 'Amoi' => 'Amoi',
  5513. // http://en.wikipedia.org/wiki/INQ
  5514. 'INQ' => 'INQ',
  5515. // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
  5516. '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',
  5517. );
  5518. /**
  5519. * List of tablet devices.
  5520. *
  5521. * @var array
  5522. */
  5523. protected static $tabletDevices = array(
  5524. // @todo: check for mobile friendly emails topic.
  5525. 'iPad' => 'iPad|iPad.*Mobile',
  5526. // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
  5527. // @see #442
  5528. 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
  5529. '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.
  5530. // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
  5531. '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)',
  5532. // Only the Surface tablets with Windows RT are considered mobile.
  5533. // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
  5534. 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
  5535. // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
  5536. 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
  5537. // Watch out for PadFone, see #132.
  5538. // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
  5539. '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',
  5540. 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
  5541. 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
  5542. 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
  5543. 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
  5544. // http://www.acer.ro/ac/ro/RO/content/drivers
  5545. // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
  5546. // http://us.acer.com/ac/en/US/content/group/tablets
  5547. // http://www.acer.de/ac/de/DE/content/models/tablets/
  5548. // Can conflict with Micromax and Motorola phones codes.
  5549. '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',
  5550. // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
  5551. // http://us.toshiba.com/tablets/tablet-finder
  5552. // http://www.toshiba.co.jp/regza/tablet/
  5553. 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
  5554. // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
  5555. // http://www.lg.com/us/tablets
  5556. 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
  5557. 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
  5558. // Prestigio Tablets http://www.prestigio.com/support
  5559. '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',
  5560. // http://support.lenovo.com/en_GB/downloads/default.page?#
  5561. '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|)',
  5562. // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
  5563. 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
  5564. // http://www.yarvik.com/en/matrix/tablets/
  5565. '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',
  5566. 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
  5567. 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
  5568. // http://www.intenso.de/kategorie_en.php?kategorie=33
  5569. // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
  5570. 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
  5571. // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
  5572. 'IRUTablet' => 'M702pro',
  5573. 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
  5574. // http://www.e-boda.ro/tablete-pc.html
  5575. 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
  5576. // http://www.allview.ro/produse/droseries/lista-tablete-pc/
  5577. 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
  5578. // http://wiki.archosfans.com/index.php?title=Main_Page
  5579. // @note Rewrite the regex format after we add more UAs.
  5580. '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',
  5581. // http://www.ainol.com/plugin.php?identifier=ainol&module=product
  5582. 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
  5583. 'NokiaLumiaTablet' => 'Lumia 2520',
  5584. // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
  5585. // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
  5586. // http://www.sony.jp/support/tablet/
  5587. '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',
  5588. // 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
  5589. 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
  5590. // db + http://www.cube-tablet.com/buy-products.html
  5591. 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
  5592. // http://www.cobyusa.com/?p=pcat&pcat_id=3001
  5593. 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
  5594. // http://www.match.net.cn/products.asp
  5595. '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',
  5596. // http://www.msi.com/support
  5597. // @todo Research the Windows Tablets.
  5598. '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',
  5599. // @todo http://www.kyoceramobile.com/support/drivers/
  5600. // 'KyoceraTablet' => null,
  5601. // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
  5602. // 'IntextTablet' => null,
  5603. // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
  5604. // http://www.imp3.net/14/show.php?itemid=20454
  5605. 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
  5606. // http://www.rock-chips.com/index.php?do=prod&pid=2
  5607. 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
  5608. // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
  5609. 'FlyTablet' => 'IQ310|Fly Vision',
  5610. // http://www.bqreaders.com/gb/tablets-prices-sale.html
  5611. 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
  5612. // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
  5613. // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
  5614. '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',
  5615. // Nec or Medias Tab
  5616. 'NecTablet' => '\bN-06D|\bN-08D',
  5617. // Pantech Tablets: http://www.pantechusa.com/phones/
  5618. 'PantechTablet' => 'Pantech.*P4100',
  5619. // Broncho Tablets: http://www.broncho.cn/ (hard to find)
  5620. 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
  5621. // http://versusuk.com/support.html
  5622. 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
  5623. // http://www.zync.in/index.php/our-products/tablet-phablets
  5624. 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
  5625. // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
  5626. 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
  5627. // https://www.nabitablet.com/
  5628. 'NabiTablet' => 'Android.*\bNabi',
  5629. 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
  5630. // French Danew Tablets http://www.danew.com/produits-tablette.php
  5631. 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
  5632. // Texet Tablets and Readers http://www.texet.ru/tablet/
  5633. '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',
  5634. // Avoid detecting 'PLAYSTATION 3' as mobile.
  5635. 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
  5636. // http://www.trekstor.de/surftabs.html
  5637. 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
  5638. // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
  5639. 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
  5640. // http://www.advandigital.com/index.php?link=content-product&jns=JP001
  5641. // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
  5642. '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 ',
  5643. // http://www.danytech.com/category/tablet-pc
  5644. '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',
  5645. // http://www.galapad.net/product.html
  5646. 'GalapadTablet' => 'Android.*\bG1\b',
  5647. // http://www.micromaxinfo.com/tablet/funbook
  5648. 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
  5649. // http://www.karbonnmobiles.com/products_tablet.php
  5650. 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
  5651. // http://www.myallfine.com/Products.asp
  5652. 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
  5653. // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
  5654. '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',
  5655. // http://www.yonesnav.com/products/products.php
  5656. 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
  5657. // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
  5658. // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
  5659. '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',
  5660. // http://www.gloryunion.cn/products.asp
  5661. // http://www.allwinnertech.com/en/apply/mobile.html
  5662. // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
  5663. // @todo: Softwiner tablets?
  5664. // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
  5665. '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
  5666. // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
  5667. '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',
  5668. // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
  5669. // @todo: add more tests.
  5670. 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
  5671. // http://hclmetablet.com/India/index.php
  5672. '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',
  5673. // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
  5674. 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
  5675. // http://www.visture.com/index.asp
  5676. 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
  5677. // http://www.mijncresta.nl/tablet
  5678. 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
  5679. // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
  5680. 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
  5681. // Concorde tab
  5682. 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
  5683. // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
  5684. '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',
  5685. // Modecom Tablets - http://www.modecom.eu/tablets/portal/
  5686. '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',
  5687. // Vonino Tablets - http://www.vonino.eu/tablets
  5688. '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',
  5689. // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
  5690. 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
  5691. // Storex Tablets - http://storex.fr/espace_client/support.html
  5692. // @note: no need to add all the tablet codes since they are guided by the first regex.
  5693. 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
  5694. // Generic Vodafone tablets.
  5695. 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
  5696. // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
  5697. // Aka: http://www.essentielb.fr/
  5698. 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
  5699. // Ross & Moor - http://ross-moor.ru/
  5700. 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
  5701. // i-mobile http://product.i-mobilephone.com/Mobile_Device
  5702. 'iMobileTablet' => 'i-mobile i-note',
  5703. // http://www.tolino.de/de/vergleichen/
  5704. 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
  5705. // AudioSonic - a Kmart brand
  5706. // 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
  5707. 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
  5708. // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
  5709. // @todo: add them gradually to avoid conflicts.
  5710. 'AMPETablet' => 'Android.* A78 ',
  5711. // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
  5712. 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
  5713. // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
  5714. 'TecnoTablet' => 'TECNO P9',
  5715. // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
  5716. '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',
  5717. // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
  5718. '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)',
  5719. // http://www.intracon.eu/tablet
  5720. 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
  5721. // http://www.xoro.de/produkte/
  5722. // @note: Might be the same brand with 'Simply tablets'
  5723. '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',
  5724. // http://www1.viewsonic.com/products/computing/tablets/
  5725. 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
  5726. // http://www.odys.de/web/internet-tablet_en.html
  5727. 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
  5728. // http://www.captiva-power.de/products.html#tablets-en
  5729. 'CaptivaTablet' => 'CAPTIVA PAD',
  5730. // IconBIT - http://www.iconbit.com/products/tablets/
  5731. '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',
  5732. // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
  5733. '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',
  5734. // Onda - http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
  5735. '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]+',
  5736. 'JaytechTablet' => 'TPC-PA762',
  5737. 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
  5738. // http://www.digma.ru/support/download/
  5739. // @todo: Ebooks also (if requested)
  5740. 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
  5741. // http://www.evolioshop.com/ro/tablete-pc.html
  5742. // http://www.evolio.ro/support/downloads_static.html?cat=2
  5743. // @todo: Research some more
  5744. 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
  5745. // @todo http://www.lavamobiles.com/tablets-data-cards
  5746. 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
  5747. // http://www.breezetablet.com/
  5748. 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
  5749. // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
  5750. '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',
  5751. // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
  5752. 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
  5753. // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
  5754. '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',
  5755. // http://www.mi.com/en
  5756. 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
  5757. // http://www.nbru.cn/index.html
  5758. 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
  5759. // http://navroad.com/products/produkty/tablety/
  5760. // http://navroad.com/products/produkty/tablety/
  5761. 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
  5762. // http://leader-online.com/new_site/product-category/tablets/
  5763. // http://www.leader-online.net.au/List/Tablet
  5764. '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',
  5765. // http://www.datawind.com/ubislate/
  5766. 'UbislateTablet' => 'UbiSlate[\s]?7C',
  5767. // http://www.pocketbook-int.com/ru/support
  5768. 'PocketBookTablet' => 'Pocketbook',
  5769. // http://www.kocaso.com/product_tablet.html
  5770. 'KocasoTablet' => '\b(TB-1207)\b',
  5771. // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
  5772. 'HisenseTablet' => '\b(F5281|E2371)\b',
  5773. // http://www.tesco.com/direct/hudl/
  5774. 'Hudl' => 'Hudl HT7S3|Hudl 2',
  5775. // http://www.telstra.com.au/home-phone/thub-2/
  5776. 'TelstraTablet' => 'T-Hub2',
  5777. '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'
  5778. );
  5779. /**
  5780. * List of mobile Operating Systems.
  5781. *
  5782. * @var array
  5783. */
  5784. protected static $operatingSystems = array(
  5785. 'AndroidOS' => 'Android',
  5786. 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
  5787. 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
  5788. 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
  5789. // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
  5790. 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
  5791. // @reference: http://en.wikipedia.org/wiki/Windows_Phone
  5792. // http://wifeng.cn/?r=blog&a=view&id=106
  5793. // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
  5794. // http://msdn.microsoft.com/library/ms537503.aspx
  5795. // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
  5796. 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
  5797. 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
  5798. // http://en.wikipedia.org/wiki/MeeGo
  5799. // @todo: research MeeGo in UAs
  5800. 'MeeGoOS' => 'MeeGo',
  5801. // http://en.wikipedia.org/wiki/Maemo
  5802. // @todo: research Maemo in UAs
  5803. 'MaemoOS' => 'Maemo',
  5804. 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
  5805. 'webOS' => 'webOS|hpwOS',
  5806. 'badaOS' => '\bBada\b',
  5807. 'BREWOS' => 'BREW',
  5808. );
  5809. /**
  5810. * List of mobile User Agents.
  5811. *
  5812. * IMPORTANT: This is a list of only mobile browsers.
  5813. * Mobile Detect 2.x supports only mobile browsers,
  5814. * it was never designed to detect all browsers.
  5815. * The change will come in 2017 in the 3.x release for PHP7.
  5816. *
  5817. * @var array
  5818. */
  5819. protected static $browsers = array(
  5820. //'Vivaldi' => 'Vivaldi',
  5821. // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
  5822. 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
  5823. 'Dolfin' => '\bDolfin\b',
  5824. 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
  5825. 'Skyfire' => 'Skyfire',
  5826. 'Edge' => 'Mobile Safari/[.0-9]* Edge',
  5827. 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
  5828. 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
  5829. 'Bolt' => 'bolt',
  5830. 'TeaShark' => 'teashark',
  5831. 'Blazer' => 'Blazer',
  5832. // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
  5833. 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
  5834. // http://en.wikipedia.org/wiki/Midori_(web_browser)
  5835. //'Midori' => 'midori',
  5836. //'Tizen' => 'Tizen',
  5837. 'UCBrowser' => 'UC.*Browser|UCWEB',
  5838. 'baiduboxapp' => 'baiduboxapp',
  5839. 'baidubrowser' => 'baidubrowser',
  5840. // https://github.com/serbanghita/Mobile-Detect/issues/7
  5841. 'DiigoBrowser' => 'DiigoBrowser',
  5842. // http://www.puffinbrowser.com/index.php
  5843. 'Puffin' => 'Puffin',
  5844. // http://mercury-browser.com/index.html
  5845. 'Mercury' => '\bMercury\b',
  5846. // http://en.wikipedia.org/wiki/Obigo_Browser
  5847. 'ObigoBrowser' => 'Obigo',
  5848. // http://en.wikipedia.org/wiki/NetFront
  5849. 'NetFront' => 'NF-Browser',
  5850. // @reference: http://en.wikipedia.org/wiki/Minimo
  5851. // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
  5852. 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
  5853. // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
  5854. 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
  5855. );
  5856. /**
  5857. * Utilities.
  5858. *
  5859. * @var array
  5860. */
  5861. protected static $utilities = array(
  5862. // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
  5863. // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
  5864. // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
  5865. // https://developers.facebook.com/docs/sharing/best-practices
  5866. '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',
  5867. 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
  5868. 'DesktopMode' => 'WPDesktop',
  5869. 'TV' => 'SonyDTV|HbbTV', // experimental
  5870. 'WebKit' => '(webkit)[ /]([\w.]+)',
  5871. // @todo: Include JXD consoles.
  5872. 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
  5873. 'Watch' => 'SM-V700',
  5874. );
  5875. /**
  5876. * All possible HTTP headers that represent the
  5877. * User-Agent string.
  5878. *
  5879. * @var array
  5880. */
  5881. protected static $uaHttpHeaders = array(
  5882. // The default User-Agent string.
  5883. 'HTTP_USER_AGENT',
  5884. // Header can occur on devices using Opera Mini.
  5885. 'HTTP_X_OPERAMINI_PHONE_UA',
  5886. // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
  5887. 'HTTP_X_DEVICE_USER_AGENT',
  5888. 'HTTP_X_ORIGINAL_USER_AGENT',
  5889. 'HTTP_X_SKYFIRE_PHONE',
  5890. 'HTTP_X_BOLT_PHONE_UA',
  5891. 'HTTP_DEVICE_STOCK_UA',
  5892. 'HTTP_X_UCBROWSER_DEVICE_UA'
  5893. );
  5894. /**
  5895. * The individual segments that could exist in a User-Agent string. VER refers to the regular
  5896. * expression defined in the constant self::VER.
  5897. *
  5898. * @var array
  5899. */
  5900. protected static $properties = array(
  5901. // Build
  5902. 'Mobile' => 'Mobile/[VER]',
  5903. 'Build' => 'Build/[VER]',
  5904. 'Version' => 'Version/[VER]',
  5905. 'VendorID' => 'VendorID/[VER]',
  5906. // Devices
  5907. 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
  5908. 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
  5909. 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
  5910. //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
  5911. 'Kindle' => 'Kindle/[VER]',
  5912. // Browser
  5913. 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
  5914. 'Coast' => array('Coast/[VER]'),
  5915. 'Dolfin' => 'Dolfin/[VER]',
  5916. // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
  5917. 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
  5918. 'Fennec' => 'Fennec/[VER]',
  5919. // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  5920. // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
  5921. 'Edge' => 'Edge/[VER]',
  5922. 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
  5923. // http://en.wikipedia.org/wiki/NetFront
  5924. 'NetFront' => 'NetFront/[VER]',
  5925. 'NokiaBrowser' => 'NokiaBrowser/[VER]',
  5926. 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
  5927. 'Opera Mini' => 'Opera Mini/[VER]',
  5928. 'Opera Mobi' => 'Version/[VER]',
  5929. 'UC Browser' => 'UC Browser[VER]',
  5930. 'MQQBrowser' => 'MQQBrowser/[VER]',
  5931. 'MicroMessenger' => 'MicroMessenger/[VER]',
  5932. 'baiduboxapp' => 'baiduboxapp/[VER]',
  5933. 'baidubrowser' => 'baidubrowser/[VER]',
  5934. 'SamsungBrowser' => 'SamsungBrowser/[VER]',
  5935. 'Iron' => 'Iron/[VER]',
  5936. // @note: Safari 7534.48.3 is actually Version 5.1.
  5937. // @note: On BlackBerry the Version is overwriten by the OS.
  5938. 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
  5939. 'Skyfire' => 'Skyfire/[VER]',
  5940. 'Tizen' => 'Tizen/[VER]',
  5941. 'Webkit' => 'webkit[ /][VER]',
  5942. 'PaleMoon' => 'PaleMoon/[VER]',
  5943. // Engine
  5944. 'Gecko' => 'Gecko/[VER]',
  5945. 'Trident' => 'Trident/[VER]',
  5946. 'Presto' => 'Presto/[VER]',
  5947. 'Goanna' => 'Goanna/[VER]',
  5948. // OS
  5949. 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
  5950. 'Android' => 'Android [VER]',
  5951. 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
  5952. 'BREW' => 'BREW [VER]',
  5953. 'Java' => 'Java/[VER]',
  5954. // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
  5955. // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
  5956. 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
  5957. 'Windows Phone' => 'Windows Phone [VER]',
  5958. 'Windows CE' => 'Windows CE/[VER]',
  5959. // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
  5960. 'Windows NT' => 'Windows NT [VER]',
  5961. 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
  5962. 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
  5963. );
  5964. /**
  5965. * Construct an instance of this class.
  5966. *
  5967. * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
  5968. * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
  5969. * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
  5970. * from the $headers array instead.
  5971. */
  5972. public function __construct(
  5973. array $headers = null,
  5974. $userAgent = null
  5975. ) {
  5976. $this->setHttpHeaders($headers);
  5977. $this->setUserAgent($userAgent);
  5978. }
  5979. /**
  5980. * Get the current script version.
  5981. * This is useful for the demo.php file,
  5982. * so people can check on what version they are testing
  5983. * for mobile devices.
  5984. *
  5985. * @return string The version number in semantic version format.
  5986. */
  5987. public static function getScriptVersion()
  5988. {
  5989. return self::VERSION;
  5990. }
  5991. /**
  5992. * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
  5993. *
  5994. * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
  5995. * the headers. The default null is left for backwards compatibility.
  5996. */
  5997. public function setHttpHeaders($httpHeaders = null)
  5998. {
  5999. // use global _SERVER if $httpHeaders aren't defined
  6000. if (!is_array($httpHeaders) || !count($httpHeaders)) {
  6001. $httpHeaders = $_SERVER;
  6002. }
  6003. // clear existing headers
  6004. $this->httpHeaders = array();
  6005. // Only save HTTP headers. In PHP land, that means only _SERVER vars that
  6006. // start with HTTP_.
  6007. foreach ($httpHeaders as $key => $value) {
  6008. if (substr($key, 0, 5) === 'HTTP_') {
  6009. $this->httpHeaders[$key] = $value;
  6010. }
  6011. }
  6012. // In case we're dealing with CloudFront, we need to know.
  6013. $this->setCfHeaders($httpHeaders);
  6014. }
  6015. /**
  6016. * Retrieves the HTTP headers.
  6017. *
  6018. * @return array
  6019. */
  6020. public function getHttpHeaders()
  6021. {
  6022. return $this->httpHeaders;
  6023. }
  6024. /**
  6025. * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
  6026. * Simply null is returned.
  6027. *
  6028. * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
  6029. * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
  6030. * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
  6031. *
  6032. * @return string|null The value of the header.
  6033. */
  6034. public function getHttpHeader($header)
  6035. {
  6036. // are we using PHP-flavored headers?
  6037. if (strpos($header, '_') === false) {
  6038. $header = str_replace('-', '_', $header);
  6039. $header = strtoupper($header);
  6040. }
  6041. // test the alternate, too
  6042. $altHeader = 'HTTP_' . $header;
  6043. //Test both the regular and the HTTP_ prefix
  6044. if (isset($this->httpHeaders[$header])) {
  6045. return $this->httpHeaders[$header];
  6046. } elseif (isset($this->httpHeaders[$altHeader])) {
  6047. return $this->httpHeaders[$altHeader];
  6048. }
  6049. return null;
  6050. }
  6051. public function getMobileHeaders()
  6052. {
  6053. return self::$mobileHeaders;
  6054. }
  6055. /**
  6056. * Get all possible HTTP headers that
  6057. * can contain the User-Agent string.
  6058. *
  6059. * @return array List of HTTP headers.
  6060. */
  6061. public function getUaHttpHeaders()
  6062. {
  6063. return self::$uaHttpHeaders;
  6064. }
  6065. /**
  6066. * Set CloudFront headers
  6067. * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
  6068. *
  6069. * @param array $cfHeaders List of HTTP headers
  6070. *
  6071. * @return boolean If there were CloudFront headers to be set
  6072. */
  6073. public function setCfHeaders($cfHeaders = null) {
  6074. // use global _SERVER if $cfHeaders aren't defined
  6075. if (!is_array($cfHeaders) || !count($cfHeaders)) {
  6076. $cfHeaders = $_SERVER;
  6077. }
  6078. // clear existing headers
  6079. $this->cloudfrontHeaders = array();
  6080. // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
  6081. // start with cloudfront-.
  6082. $response = false;
  6083. foreach ($cfHeaders as $key => $value) {
  6084. if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
  6085. $this->cloudfrontHeaders[strtoupper($key)] = $value;
  6086. $response = true;
  6087. }
  6088. }
  6089. return $response;
  6090. }
  6091. /**
  6092. * Retrieves the cloudfront headers.
  6093. *
  6094. * @return array
  6095. */
  6096. public function getCfHeaders()
  6097. {
  6098. return $this->cloudfrontHeaders;
  6099. }
  6100. /**
  6101. * Set the User-Agent to be used.
  6102. *
  6103. * @param string $userAgent The user agent string to set.
  6104. *
  6105. * @return string|null
  6106. */
  6107. public function setUserAgent($userAgent = null)
  6108. {
  6109. // Invalidate cache due to #375
  6110. $this->cache = array();
  6111. if (false === empty($userAgent)) {
  6112. return $this->userAgent = $userAgent;
  6113. } else {
  6114. $this->userAgent = null;
  6115. foreach ($this->getUaHttpHeaders() as $altHeader) {
  6116. if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
  6117. $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
  6118. }
  6119. }
  6120. if (!empty($this->userAgent)) {
  6121. return $this->userAgent = trim($this->userAgent);
  6122. }
  6123. }
  6124. if (count($this->getCfHeaders()) > 0) {
  6125. return $this->userAgent = 'Amazon CloudFront';
  6126. }
  6127. return $this->userAgent = null;
  6128. }
  6129. /**
  6130. * Retrieve the User-Agent.
  6131. *
  6132. * @return string|null The user agent if it's set.
  6133. */
  6134. public function getUserAgent()
  6135. {
  6136. return $this->userAgent;
  6137. }
  6138. /**
  6139. * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
  6140. * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
  6141. *
  6142. * @deprecated since version 2.6.9
  6143. *
  6144. * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
  6145. * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
  6146. */
  6147. public function setDetectionType($type = null)
  6148. {
  6149. if ($type === null) {
  6150. $type = self::DETECTION_TYPE_MOBILE;
  6151. }
  6152. if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
  6153. return;
  6154. }
  6155. $this->detectionType = $type;
  6156. }
  6157. public function getMatchingRegex()
  6158. {
  6159. return $this->matchingRegex;
  6160. }
  6161. public function getMatchesArray()
  6162. {
  6163. return $this->matchesArray;
  6164. }
  6165. /**
  6166. * Retrieve the list of known phone devices.
  6167. *
  6168. * @return array List of phone devices.
  6169. */
  6170. public static function getPhoneDevices()
  6171. {
  6172. return self::$phoneDevices;
  6173. }
  6174. /**
  6175. * Retrieve the list of known tablet devices.
  6176. *
  6177. * @return array List of tablet devices.
  6178. */
  6179. public static function getTabletDevices()
  6180. {
  6181. return self::$tabletDevices;
  6182. }
  6183. /**
  6184. * Alias for getBrowsers() method.
  6185. *
  6186. * @return array List of user agents.
  6187. */
  6188. public static function getUserAgents()
  6189. {
  6190. return self::getBrowsers();
  6191. }
  6192. /**
  6193. * Retrieve the list of known browsers. Specifically, the user agents.
  6194. *
  6195. * @return array List of browsers / user agents.
  6196. */
  6197. public static function getBrowsers()
  6198. {
  6199. return self::$browsers;
  6200. }
  6201. /**
  6202. * Retrieve the list of known utilities.
  6203. *
  6204. * @return array List of utilities.
  6205. */
  6206. public static function getUtilities()
  6207. {
  6208. return self::$utilities;
  6209. }
  6210. /**
  6211. * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
  6212. *
  6213. * @deprecated since version 2.6.9
  6214. *
  6215. * @return array All the rules (but not extended).
  6216. */
  6217. public static function getMobileDetectionRules()
  6218. {
  6219. static $rules;
  6220. if (!$rules) {
  6221. $rules = array_merge(
  6222. self::$phoneDevices,
  6223. self::$tabletDevices,
  6224. self::$operatingSystems,
  6225. self::$browsers
  6226. );
  6227. }
  6228. return $rules;
  6229. }
  6230. /**
  6231. * Method gets the mobile detection rules + utilities.
  6232. * The reason this is separate is because utilities rules
  6233. * don't necessary imply mobile. This method is used inside
  6234. * the new $detect->is('stuff') method.
  6235. *
  6236. * @deprecated since version 2.6.9
  6237. *
  6238. * @return array All the rules + extended.
  6239. */
  6240. public function getMobileDetectionRulesExtended()
  6241. {
  6242. static $rules;
  6243. if (!$rules) {
  6244. // Merge all rules together.
  6245. $rules = array_merge(
  6246. self::$phoneDevices,
  6247. self::$tabletDevices,
  6248. self::$operatingSystems,
  6249. self::$browsers,
  6250. self::$utilities
  6251. );
  6252. }
  6253. return $rules;
  6254. }
  6255. /**
  6256. * Retrieve the current set of rules.
  6257. *
  6258. * @deprecated since version 2.6.9
  6259. *
  6260. * @return array
  6261. */
  6262. public function getRules()
  6263. {
  6264. if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
  6265. return self::getMobileDetectionRulesExtended();
  6266. } else {
  6267. return self::getMobileDetectionRules();
  6268. }
  6269. }
  6270. /**
  6271. * Retrieve the list of mobile operating systems.
  6272. *
  6273. * @return array The list of mobile operating systems.
  6274. */
  6275. public static function getOperatingSystems()
  6276. {
  6277. return self::$operatingSystems;
  6278. }
  6279. /**
  6280. * Check the HTTP headers for signs of mobile.
  6281. * This is the fastest mobile check possible; it's used
  6282. * inside isMobile() method.
  6283. *
  6284. * @return bool
  6285. */
  6286. public function checkHttpHeadersForMobile()
  6287. {
  6288. foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
  6289. if (isset($this->httpHeaders[$mobileHeader])) {
  6290. if (is_array($matchType['matches'])) {
  6291. foreach ($matchType['matches'] as $_match) {
  6292. if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
  6293. return true;
  6294. }
  6295. }
  6296. return false;
  6297. } else {
  6298. return true;
  6299. }
  6300. }
  6301. }
  6302. return false;
  6303. }
  6304. /**
  6305. * Magic overloading method.
  6306. *
  6307. * @method boolean is[...]()
  6308. * @param string $name
  6309. * @param array $arguments
  6310. * @return mixed
  6311. * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
  6312. */
  6313. public function __call($name, $arguments)
  6314. {
  6315. // make sure the name starts with 'is', otherwise
  6316. if (substr($name, 0, 2) !== 'is') {
  6317. throw new BadMethodCallException("No such method exists: $name");
  6318. }
  6319. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6320. $key = substr($name, 2);
  6321. return $this->matchUAAgainstKey($key);
  6322. }
  6323. /**
  6324. * Find a detection rule that matches the current User-agent.
  6325. *
  6326. * @param null $userAgent deprecated
  6327. * @return boolean
  6328. */
  6329. protected function matchDetectionRulesAgainstUA($userAgent = null)
  6330. {
  6331. // Begin general search.
  6332. foreach ($this->getRules() as $_regex) {
  6333. if (empty($_regex)) {
  6334. continue;
  6335. }
  6336. if ($this->match($_regex, $userAgent)) {
  6337. return true;
  6338. }
  6339. }
  6340. return false;
  6341. }
  6342. /**
  6343. * Search for a certain key in the rules array.
  6344. * If the key is found then try to match the corresponding
  6345. * regex against the User-Agent.
  6346. *
  6347. * @param string $key
  6348. *
  6349. * @return boolean
  6350. */
  6351. protected function matchUAAgainstKey($key)
  6352. {
  6353. // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
  6354. $key = strtolower($key);
  6355. if (false === isset($this->cache[$key])) {
  6356. // change the keys to lower case
  6357. $_rules = array_change_key_case($this->getRules());
  6358. if (false === empty($_rules[$key])) {
  6359. $this->cache[$key] = $this->match($_rules[$key]);
  6360. }
  6361. if (false === isset($this->cache[$key])) {
  6362. $this->cache[$key] = false;
  6363. }
  6364. }
  6365. return $this->cache[$key];
  6366. }
  6367. /**
  6368. * Check if the device is mobile.
  6369. * Returns true if any type of mobile device detected, including special ones
  6370. * @param null $userAgent deprecated
  6371. * @param null $httpHeaders deprecated
  6372. * @return bool
  6373. */
  6374. public function isMobile($userAgent = null, $httpHeaders = null)
  6375. {
  6376. if ($httpHeaders) {
  6377. $this->setHttpHeaders($httpHeaders);
  6378. }
  6379. if ($userAgent) {
  6380. $this->setUserAgent($userAgent);
  6381. }
  6382. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6383. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6384. $cfHeaders = $this->getCfHeaders();
  6385. if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
  6386. return true;
  6387. }
  6388. }
  6389. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6390. if ($this->checkHttpHeadersForMobile()) {
  6391. return true;
  6392. } else {
  6393. return $this->matchDetectionRulesAgainstUA();
  6394. }
  6395. }
  6396. /**
  6397. * Check if the device is a tablet.
  6398. * Return true if any type of tablet device is detected.
  6399. *
  6400. * @param string $userAgent deprecated
  6401. * @param array $httpHeaders deprecated
  6402. * @return bool
  6403. */
  6404. public function isTablet($userAgent = null, $httpHeaders = null)
  6405. {
  6406. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6407. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6408. $cfHeaders = $this->getCfHeaders();
  6409. if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
  6410. return true;
  6411. }
  6412. }
  6413. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6414. foreach (self::$tabletDevices as $_regex) {
  6415. if ($this->match($_regex, $userAgent)) {
  6416. return true;
  6417. }
  6418. }
  6419. return false;
  6420. }
  6421. /**
  6422. * This method checks for a certain property in the
  6423. * userAgent.
  6424. * @todo: The httpHeaders part is not yet used.
  6425. *
  6426. * @param string $key
  6427. * @param string $userAgent deprecated
  6428. * @param string $httpHeaders deprecated
  6429. * @return bool|int|null
  6430. */
  6431. public function is($key, $userAgent = null, $httpHeaders = null)
  6432. {
  6433. // Set the UA and HTTP headers only if needed (eg. batch mode).
  6434. if ($httpHeaders) {
  6435. $this->setHttpHeaders($httpHeaders);
  6436. }
  6437. if ($userAgent) {
  6438. $this->setUserAgent($userAgent);
  6439. }
  6440. $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
  6441. return $this->matchUAAgainstKey($key);
  6442. }
  6443. /**
  6444. * Some detection rules are relative (not standard),
  6445. * because of the diversity of devices, vendors and
  6446. * their conventions in representing the User-Agent or
  6447. * the HTTP headers.
  6448. *
  6449. * This method will be used to check custom regexes against
  6450. * the User-Agent string.
  6451. *
  6452. * @param $regex
  6453. * @param string $userAgent
  6454. * @return bool
  6455. *
  6456. * @todo: search in the HTTP headers too.
  6457. */
  6458. public function match($regex, $userAgent = null)
  6459. {
  6460. $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
  6461. // If positive match is found, store the results for debug.
  6462. if ($match) {
  6463. $this->matchingRegex = $regex;
  6464. $this->matchesArray = $matches;
  6465. }
  6466. return $match;
  6467. }
  6468. /**
  6469. * Get the properties array.
  6470. *
  6471. * @return array
  6472. */
  6473. public static function getProperties()
  6474. {
  6475. return self::$properties;
  6476. }
  6477. /**
  6478. * Prepare the version number.
  6479. *
  6480. * @todo Remove the error supression from str_replace() call.
  6481. *
  6482. * @param string $ver The string version, like "2.6.21.2152";
  6483. *
  6484. * @return float
  6485. */
  6486. public function prepareVersionNo($ver)
  6487. {
  6488. $ver = str_replace(array('_', ' ', '/'), '.', $ver);
  6489. $arrVer = explode('.', $ver, 2);
  6490. if (isset($arrVer[1])) {
  6491. $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
  6492. }
  6493. return (float) implode('.', $arrVer);
  6494. }
  6495. /**
  6496. * Check the version of the given property in the User-Agent.
  6497. * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
  6498. *
  6499. * @param string $propertyName The name of the property. See self::getProperties() array
  6500. * keys for all possible properties.
  6501. * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
  6502. * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
  6503. * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
  6504. * invalid parameter will default to the this type as well.
  6505. *
  6506. * @return string|float The version of the property we are trying to extract.
  6507. */
  6508. public function version($propertyName, $type = self::VERSION_TYPE_STRING)
  6509. {
  6510. if (empty($propertyName)) {
  6511. return false;
  6512. }
  6513. // set the $type to the default if we don't recognize the type
  6514. if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
  6515. $type = self::VERSION_TYPE_STRING;
  6516. }
  6517. $properties = self::getProperties();
  6518. // Check if the property exists in the properties array.
  6519. if (true === isset($properties[$propertyName])) {
  6520. // Prepare the pattern to be matched.
  6521. // Make sure we always deal with an array (string is converted).
  6522. $properties[$propertyName] = (array) $properties[$propertyName];
  6523. foreach ($properties[$propertyName] as $propertyMatchString) {
  6524. $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
  6525. // Identify and extract the version.
  6526. preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
  6527. if (false === empty($match[1])) {
  6528. $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
  6529. return $version;
  6530. }
  6531. }
  6532. }
  6533. return false;
  6534. }
  6535. /**
  6536. * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
  6537. *
  6538. * @return string One of the self::MOBILE_GRADE_* constants.
  6539. */
  6540. public function mobileGrade()
  6541. {
  6542. $isMobile = $this->isMobile();
  6543. if (
  6544. // 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)
  6545. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6546. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6547. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6548. // 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)
  6549. // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
  6550. // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
  6551. // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
  6552. ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
  6553. // 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)
  6554. $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
  6555. // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
  6556. $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
  6557. // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
  6558. $this->match('Playbook.*Tablet') ||
  6559. // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
  6560. ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
  6561. // Palm WebOS 3.0 - Tested on HP TouchPad
  6562. $this->match('hp.*TouchPad') ||
  6563. // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
  6564. ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
  6565. // Chrome for Android - Tested on Android 4.0, 4.1 device
  6566. ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
  6567. // Skyfire 4.1 - Tested on Android 2.3 device
  6568. ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6569. // Opera Mobile 11.5-12: Tested on Android 2.3
  6570. ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
  6571. // Meego 1.2 - Tested on Nokia 950 and N9
  6572. $this->is('MeeGoOS') ||
  6573. // Tizen (pre-release) - Tested on early hardware
  6574. $this->is('Tizen') ||
  6575. // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
  6576. // @todo: more tests here!
  6577. $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
  6578. // UC Browser - Tested on Android 2.3 device
  6579. ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6580. // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
  6581. ( $this->match('Kindle Fire') ||
  6582. $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
  6583. // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
  6584. $this->is('AndroidOS') && $this->is('NookTablet') ||
  6585. // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
  6586. $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
  6587. // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
  6588. $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
  6589. // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
  6590. $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
  6591. // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
  6592. $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
  6593. // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
  6594. $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
  6595. ){
  6596. return self::MOBILE_GRADE_A;
  6597. }
  6598. if (
  6599. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
  6600. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
  6601. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
  6602. // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
  6603. $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
  6604. //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
  6605. ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
  6606. ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
  6607. // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
  6608. $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
  6609. // @todo: report this (tested on Nokia N71)
  6610. $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
  6611. ){
  6612. return self::MOBILE_GRADE_B;
  6613. }
  6614. if (
  6615. // Blackberry 4.x - Tested on the Curve 8330
  6616. $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
  6617. // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
  6618. $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
  6619. // Tested on original iPhone (3.1), iPhone 3 (3.2)
  6620. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6621. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6622. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6623. // Internet Explorer 7 and older - Tested on Windows XP
  6624. $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
  6625. ){
  6626. return self::MOBILE_GRADE_C;
  6627. }
  6628. // All older smartphone platforms and featurephones - Any device that doesn't support media queries
  6629. // will receive the basic, C grade experience.
  6630. return self::MOBILE_GRADE_C;
  6631. }
  6632. }
  6633. $mobileDetect = new Mobile_Detect;
  6634. $userDevice = ($mobileDetect->isMobile() ? ($mobileDetect->isTablet() ? 'tablet' : 'phone') : 'computer');
  6635. function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  6636. $path = getServerPath();
  6637. return '
  6638. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6639. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  6640. <head>
  6641. <!--[if gte mso 9]><xml>
  6642. <o:OfficeDocumentSettings>
  6643. <o:AllowPNG/>
  6644. <o:PixelsPerInch>96</o:PixelsPerInch>
  6645. </o:OfficeDocumentSettings>
  6646. </xml><![endif]-->
  6647. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6648. <meta name="viewport" content="width=device-width">
  6649. <!--[if !mso]><!-->
  6650. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6651. <!--<![endif]-->
  6652. <title></title>
  6653. <!--[if !mso]><!-- -->
  6654. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
  6655. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  6656. <!--<![endif]-->
  6657. <style type="text/css" id="media-query">
  6658. body {
  6659. margin: 0;
  6660. padding: 0;
  6661. }
  6662. table,
  6663. tr,
  6664. td {
  6665. vertical-align: top;
  6666. border-collapse: collapse;
  6667. }
  6668. .ie-browser table,
  6669. .mso-container table {
  6670. table-layout: fixed;
  6671. }
  6672. * {
  6673. line-height: inherit;
  6674. }
  6675. a[x-apple-data-detectors=true] {
  6676. color: inherit !important;
  6677. text-decoration: none !important;
  6678. }
  6679. [owa] .img-container div,
  6680. [owa] .img-container button {
  6681. display: block !important;
  6682. }
  6683. [owa] .fullwidth button {
  6684. width: 100% !important;
  6685. }
  6686. [owa] .block-grid .col {
  6687. display: table-cell;
  6688. float: none !important;
  6689. vertical-align: top;
  6690. }
  6691. .ie-browser .num12,
  6692. .ie-browser .block-grid,
  6693. [owa] .num12,
  6694. [owa] .block-grid {
  6695. width: 615px !important;
  6696. }
  6697. .ExternalClass,
  6698. .ExternalClass p,
  6699. .ExternalClass span,
  6700. .ExternalClass font,
  6701. .ExternalClass td,
  6702. .ExternalClass div {
  6703. line-height: 100%;
  6704. }
  6705. .ie-browser .mixed-two-up .num4,
  6706. [owa] .mixed-two-up .num4 {
  6707. width: 204px !important;
  6708. }
  6709. .ie-browser .mixed-two-up .num8,
  6710. [owa] .mixed-two-up .num8 {
  6711. width: 408px !important;
  6712. }
  6713. .ie-browser .block-grid.two-up .col,
  6714. [owa] .block-grid.two-up .col {
  6715. width: 307px !important;
  6716. }
  6717. .ie-browser .block-grid.three-up .col,
  6718. [owa] .block-grid.three-up .col {
  6719. width: 205px !important;
  6720. }
  6721. .ie-browser .block-grid.four-up .col,
  6722. [owa] .block-grid.four-up .col {
  6723. width: 153px !important;
  6724. }
  6725. .ie-browser .block-grid.five-up .col,
  6726. [owa] .block-grid.five-up .col {
  6727. width: 123px !important;
  6728. }
  6729. .ie-browser .block-grid.six-up .col,
  6730. [owa] .block-grid.six-up .col {
  6731. width: 102px !important;
  6732. }
  6733. .ie-browser .block-grid.seven-up .col,
  6734. [owa] .block-grid.seven-up .col {
  6735. width: 87px !important;
  6736. }
  6737. .ie-browser .block-grid.eight-up .col,
  6738. [owa] .block-grid.eight-up .col {
  6739. width: 76px !important;
  6740. }
  6741. .ie-browser .block-grid.nine-up .col,
  6742. [owa] .block-grid.nine-up .col {
  6743. width: 68px !important;
  6744. }
  6745. .ie-browser .block-grid.ten-up .col,
  6746. [owa] .block-grid.ten-up .col {
  6747. width: 61px !important;
  6748. }
  6749. .ie-browser .block-grid.eleven-up .col,
  6750. [owa] .block-grid.eleven-up .col {
  6751. width: 55px !important;
  6752. }
  6753. .ie-browser .block-grid.twelve-up .col,
  6754. [owa] .block-grid.twelve-up .col {
  6755. width: 51px !important;
  6756. }
  6757. @media only screen and (min-width: 635px) {
  6758. .block-grid {
  6759. width: 615px !important;
  6760. }
  6761. .block-grid .col {
  6762. display: table-cell;
  6763. Float: none !important;
  6764. vertical-align: top;
  6765. }
  6766. .block-grid .col.num12 {
  6767. width: 615px !important;
  6768. }
  6769. .block-grid.mixed-two-up .col.num4 {
  6770. width: 204px !important;
  6771. }
  6772. .block-grid.mixed-two-up .col.num8 {
  6773. width: 408px !important;
  6774. }
  6775. .block-grid.two-up .col {
  6776. width: 307px !important;
  6777. }
  6778. .block-grid.three-up .col {
  6779. width: 205px !important;
  6780. }
  6781. .block-grid.four-up .col {
  6782. width: 153px !important;
  6783. }
  6784. .block-grid.five-up .col {
  6785. width: 123px !important;
  6786. }
  6787. .block-grid.six-up .col {
  6788. width: 102px !important;
  6789. }
  6790. .block-grid.seven-up .col {
  6791. width: 87px !important;
  6792. }
  6793. .block-grid.eight-up .col {
  6794. width: 76px !important;
  6795. }
  6796. .block-grid.nine-up .col {
  6797. width: 68px !important;
  6798. }
  6799. .block-grid.ten-up .col {
  6800. width: 61px !important;
  6801. }
  6802. .block-grid.eleven-up .col {
  6803. width: 55px !important;
  6804. }
  6805. .block-grid.twelve-up .col {
  6806. width: 51px !important;
  6807. }
  6808. }
  6809. @media (max-width: 635px) {
  6810. .block-grid,
  6811. .col {
  6812. min-width: 320px !important;
  6813. max-width: 100% !important;
  6814. }
  6815. .block-grid {
  6816. width: calc(100% - 40px) !important;
  6817. }
  6818. .col {
  6819. width: 100% !important;
  6820. }
  6821. .col>div {
  6822. margin: 0 auto;
  6823. }
  6824. img.fullwidth {
  6825. max-width: 100% !important;
  6826. }
  6827. }
  6828. </style>
  6829. </head>
  6830. <body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #FFFFFF">
  6831. <!--[if IE]><div class="ie-browser"><![endif]-->
  6832. <!--[if mso]><div class="mso-container"><![endif]-->
  6833. <div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: #FFFFFF">
  6834. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #FFFFFF;"><![endif]-->
  6835. <div style="background-color:#333333;">
  6836. <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;"
  6837. class="block-grid ">
  6838. <div style="border-collapse: collapse;display: table;width: 100%;">
  6839. <!--[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]-->
  6840. <!--[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]-->
  6841. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6842. <div style="background-color: transparent; width: 100% !important;">
  6843. <!--[if (!mso)&(!IE)]><!-->
  6844. <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;">
  6845. <!--<![endif]-->
  6846. <div align="left" class="img-container left fullwidth" style="padding-right: 30px; padding-left: 30px;">
  6847. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px;" align="left"><![endif]-->
  6848. <img class="left fullwidth" align="left" border="0" src="'.$path.'images/organizr-logo-h.png" alt="Image" title="Image"
  6849. 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"
  6850. width="555">
  6851. <!--[if mso]></td></tr></table><![endif]-->
  6852. </div>
  6853. <!--[if (!mso)&(!IE)]><!-->
  6854. </div>
  6855. <!--<![endif]-->
  6856. </div>
  6857. </div>
  6858. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6859. </div>
  6860. </div>
  6861. </div>
  6862. <div style="background-color:#333333;">
  6863. <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;"
  6864. class="block-grid ">
  6865. <div style="border-collapse: collapse;display: table;width: 100%;">
  6866. <!--[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]-->
  6867. <!--[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]-->
  6868. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6869. <div style="background-color: transparent; width: 100% !important;">
  6870. <!--[if (!mso)&(!IE)]><!-->
  6871. <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;">
  6872. <!--<![endif]-->
  6873. <!--[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]-->
  6874. <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;">
  6875. <div style="font-size:12px;line-height:14px;color:#FFFFFF;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6876. <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>
  6877. </span>
  6878. </p>
  6879. </div>
  6880. </div>
  6881. <!--[if mso]></td></tr></table><![endif]-->
  6882. <!--[if (!mso)&(!IE)]><!-->
  6883. </div>
  6884. <!--<![endif]-->
  6885. </div>
  6886. </div>
  6887. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6888. </div>
  6889. </div>
  6890. </div>
  6891. <div style="background-color:#393939;">
  6892. <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;"
  6893. class="block-grid ">
  6894. <div style="border-collapse: collapse;display: table;width: 100%;">
  6895. <!--[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]-->
  6896. <!--[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]-->
  6897. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6898. <div style="background-color: transparent; width: 100% !important;">
  6899. <!--[if (!mso)&(!IE)]><!-->
  6900. <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;">
  6901. <!--<![endif]-->
  6902. <!--[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]-->
  6903. <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;">
  6904. <div style="font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6905. <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>
  6906. </div>
  6907. </div>
  6908. <!--[if mso]></td></tr></table><![endif]-->
  6909. <div style="padding-right: 5px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px;">
  6910. <!--[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]-->
  6911. <div align="center">
  6912. <div style="border-top: 2px solid #66D9EF; width:55%; line-height:2px; height:2px; font-size:2px;">&#160;</div>
  6913. </div>
  6914. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6915. </div>
  6916. <!--[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]-->
  6917. <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;">
  6918. <div style="font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6919. <p style="margin: 0;font-size: 12px;line-height: 14px"><span style="font-size: 28px; line-height: 33px;">Hey '.$user.',</span></p>
  6920. </div>
  6921. </div>
  6922. <!--[if mso]></td></tr></table><![endif]-->
  6923. <!--[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]-->
  6924. <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;">
  6925. <div style="font-size:12px;line-height:22px;font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;color:#FFFFFF;text-align:left;">
  6926. <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>
  6927. </span>
  6928. </p>
  6929. </div>
  6930. </div>
  6931. <!--[if mso]></td></tr></table><![endif]-->
  6932. <div align="center" class="button-container center" style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;">
  6933. <!--[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]-->
  6934. <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">
  6935. <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>
  6936. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6937. </div>
  6938. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6939. </div>
  6940. <!--[if (!mso)&(!IE)]><!-->
  6941. </div>
  6942. <!--<![endif]-->
  6943. </div>
  6944. </div>
  6945. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6946. </div>
  6947. </div>
  6948. </div>
  6949. <div style="background-color:#ffffff;">
  6950. <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;"
  6951. class="block-grid ">
  6952. <div style="border-collapse: collapse;display: table;width: 100%;">
  6953. <!--[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]-->
  6954. <!--[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]-->
  6955. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6956. <div style="background-color: transparent; width: 100% !important;">
  6957. <!--[if (!mso)&(!IE)]><!-->
  6958. <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;">
  6959. <!--<![endif]-->
  6960. <!--[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]-->
  6961. <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;">
  6962. <div style="font-size:12px;line-height:14px;color:#555555;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6963. <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>
  6964. </div>
  6965. </div>
  6966. <!--[if mso]></td></tr></table><![endif]-->
  6967. <div style="padding-right: 20px; padding-left: 20px; padding-top: 15px; padding-bottom: 20px;">
  6968. <!--[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]-->
  6969. <div align="center">
  6970. <div style="border-top: 3px solid #66D9EF; width:40%; line-height:3px; height:3px; font-size:3px;">&#160;</div>
  6971. </div>
  6972. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6973. </div>
  6974. <!--[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]-->
  6975. <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;">
  6976. <div style="font-size:12px;line-height:22px;color:#7E7D7D;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6977. <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>
  6978. </div>
  6979. </div>
  6980. <!--[if mso]></td></tr></table><![endif]-->
  6981. <!--[if (!mso)&(!IE)]><!-->
  6982. </div>
  6983. <!--<![endif]-->
  6984. </div>
  6985. </div>
  6986. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6987. </div>
  6988. </div>
  6989. </div>
  6990. <div style="background-color:#333333;">
  6991. <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;"
  6992. class="block-grid ">
  6993. <div style="border-collapse: collapse;display: table;width: 100%;">
  6994. <!--[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]-->
  6995. <!--[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]-->
  6996. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6997. <div style="background-color: transparent; width: 100% !important;">
  6998. <!--[if (!mso)&(!IE)]><!-->
  6999. <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;">
  7000. <!--<![endif]-->
  7001. <!--[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]-->
  7002. <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;">
  7003. <div style="font-size:12px;line-height:14px;color:#959595;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  7004. <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"
  7005. href="https://github.com/causefx/Organizr" target="_blank" rel="noopener noreferrer">Organizr</a><strong><br></strong></p>
  7006. </div>
  7007. </div>
  7008. <!--[if mso]></td></tr></table><![endif]-->
  7009. <!--[if (!mso)&(!IE)]><!-->
  7010. </div>
  7011. <!--<![endif]-->
  7012. </div>
  7013. </div>
  7014. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  7015. </div>
  7016. </div>
  7017. </div>
  7018. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  7019. </div>
  7020. <!--[if (mso)|(IE)]></div><![endif]-->
  7021. </body>
  7022. </html>
  7023. ';
  7024. }
  7025. function mimeTypes(){
  7026. return array(
  7027. '123' => 'application/vnd.lotus-1-2-3',
  7028. '3dml' => 'text/vnd.in3d.3dml',
  7029. '3ds' => 'image/x-3ds',
  7030. '3g2' => 'video/3gpp2',
  7031. '3gp' => 'video/3gpp',
  7032. '7z' => 'application/x-7z-compressed',
  7033. 'aab' => 'application/x-authorware-bin',
  7034. 'aac' => 'audio/x-aac',
  7035. 'aam' => 'application/x-authorware-map',
  7036. 'aas' => 'application/x-authorware-seg',
  7037. 'abw' => 'application/x-abiword',
  7038. 'ac' => 'application/pkix-attr-cert',
  7039. 'acc' => 'application/vnd.americandynamics.acc',
  7040. 'ace' => 'application/x-ace-compressed',
  7041. 'acu' => 'application/vnd.acucobol',
  7042. 'acutc' => 'application/vnd.acucorp',
  7043. 'adp' => 'audio/adpcm',
  7044. 'aep' => 'application/vnd.audiograph',
  7045. 'afm' => 'application/x-font-type1',
  7046. 'afp' => 'application/vnd.ibm.modcap',
  7047. 'ahead' => 'application/vnd.ahead.space',
  7048. 'ai' => 'application/postscript',
  7049. 'aif' => 'audio/x-aiff',
  7050. 'aifc' => 'audio/x-aiff',
  7051. 'aiff' => 'audio/x-aiff',
  7052. 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
  7053. 'ait' => 'application/vnd.dvb.ait',
  7054. 'ami' => 'application/vnd.amiga.ami',
  7055. 'apk' => 'application/vnd.android.package-archive',
  7056. 'appcache' => 'text/cache-manifest',
  7057. 'application' => 'application/x-ms-application',
  7058. 'apr' => 'application/vnd.lotus-approach',
  7059. 'arc' => 'application/x-freearc',
  7060. 'asc' => 'application/pgp-signature',
  7061. 'asf' => 'video/x-ms-asf',
  7062. 'asm' => 'text/x-asm',
  7063. 'aso' => 'application/vnd.accpac.simply.aso',
  7064. 'asx' => 'video/x-ms-asf',
  7065. 'atc' => 'application/vnd.acucorp',
  7066. 'atom' => 'application/atom+xml',
  7067. 'atomcat' => 'application/atomcat+xml',
  7068. 'atomsvc' => 'application/atomsvc+xml',
  7069. 'atx' => 'application/vnd.antix.game-component',
  7070. 'au' => 'audio/basic',
  7071. 'avi' => 'video/x-msvideo',
  7072. 'aw' => 'application/applixware',
  7073. 'azf' => 'application/vnd.airzip.filesecure.azf',
  7074. 'azs' => 'application/vnd.airzip.filesecure.azs',
  7075. 'azw' => 'application/vnd.amazon.ebook',
  7076. 'bat' => 'application/x-msdownload',
  7077. 'bcpio' => 'application/x-bcpio',
  7078. 'bdf' => 'application/x-font-bdf',
  7079. 'bdm' => 'application/vnd.syncml.dm+wbxml',
  7080. 'bed' => 'application/vnd.realvnc.bed',
  7081. 'bh2' => 'application/vnd.fujitsu.oasysprs',
  7082. 'bin' => 'application/octet-stream',
  7083. 'blb' => 'application/x-blorb',
  7084. 'blorb' => 'application/x-blorb',
  7085. 'bmi' => 'application/vnd.bmi',
  7086. 'bmp' => 'image/bmp',
  7087. 'book' => 'application/vnd.framemaker',
  7088. 'box' => 'application/vnd.previewsystems.box',
  7089. 'boz' => 'application/x-bzip2',
  7090. 'bpk' => 'application/octet-stream',
  7091. 'btif' => 'image/prs.btif',
  7092. 'bz' => 'application/x-bzip',
  7093. 'bz2' => 'application/x-bzip2',
  7094. 'c' => 'text/x-c',
  7095. 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
  7096. 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
  7097. 'c4d' => 'application/vnd.clonk.c4group',
  7098. 'c4f' => 'application/vnd.clonk.c4group',
  7099. 'c4g' => 'application/vnd.clonk.c4group',
  7100. 'c4p' => 'application/vnd.clonk.c4group',
  7101. 'c4u' => 'application/vnd.clonk.c4group',
  7102. 'cab' => 'application/vnd.ms-cab-compressed',
  7103. 'caf' => 'audio/x-caf',
  7104. 'cap' => 'application/vnd.tcpdump.pcap',
  7105. 'car' => 'application/vnd.curl.car',
  7106. 'cat' => 'application/vnd.ms-pki.seccat',
  7107. 'cb7' => 'application/x-cbr',
  7108. 'cba' => 'application/x-cbr',
  7109. 'cbr' => 'application/x-cbr',
  7110. 'cbt' => 'application/x-cbr',
  7111. 'cbz' => 'application/x-cbr',
  7112. 'cc' => 'text/x-c',
  7113. 'cct' => 'application/x-director',
  7114. 'ccxml' => 'application/ccxml+xml',
  7115. 'cdbcmsg' => 'application/vnd.contact.cmsg',
  7116. 'cdf' => 'application/x-netcdf',
  7117. 'cdkey' => 'application/vnd.mediastation.cdkey',
  7118. 'cdmia' => 'application/cdmi-capability',
  7119. 'cdmic' => 'application/cdmi-container',
  7120. 'cdmid' => 'application/cdmi-domain',
  7121. 'cdmio' => 'application/cdmi-object',
  7122. 'cdmiq' => 'application/cdmi-queue',
  7123. 'cdx' => 'chemical/x-cdx',
  7124. 'cdxml' => 'application/vnd.chemdraw+xml',
  7125. 'cdy' => 'application/vnd.cinderella',
  7126. 'cer' => 'application/pkix-cert',
  7127. 'cfs' => 'application/x-cfs-compressed',
  7128. 'cgm' => 'image/cgm',
  7129. 'chat' => 'application/x-chat',
  7130. 'chm' => 'application/vnd.ms-htmlhelp',
  7131. 'chrt' => 'application/vnd.kde.kchart',
  7132. 'cif' => 'chemical/x-cif',
  7133. 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
  7134. 'cil' => 'application/vnd.ms-artgalry',
  7135. 'cla' => 'application/vnd.claymore',
  7136. 'class' => 'application/java-vm',
  7137. 'clkk' => 'application/vnd.crick.clicker.keyboard',
  7138. 'clkp' => 'application/vnd.crick.clicker.palette',
  7139. 'clkt' => 'application/vnd.crick.clicker.template',
  7140. 'clkw' => 'application/vnd.crick.clicker.wordbank',
  7141. 'clkx' => 'application/vnd.crick.clicker',
  7142. 'clp' => 'application/x-msclip',
  7143. 'cmc' => 'application/vnd.cosmocaller',
  7144. 'cmdf' => 'chemical/x-cmdf',
  7145. 'cml' => 'chemical/x-cml',
  7146. 'cmp' => 'application/vnd.yellowriver-custom-menu',
  7147. 'cmx' => 'image/x-cmx',
  7148. 'cod' => 'application/vnd.rim.cod',
  7149. 'com' => 'application/x-msdownload',
  7150. 'conf' => 'text/plain',
  7151. 'cpio' => 'application/x-cpio',
  7152. 'cpp' => 'text/x-c',
  7153. 'cpt' => 'application/mac-compactpro',
  7154. 'crd' => 'application/x-mscardfile',
  7155. 'crl' => 'application/pkix-crl',
  7156. 'crt' => 'application/x-x509-ca-cert',
  7157. 'cryptonote' => 'application/vnd.rig.cryptonote',
  7158. 'csh' => 'application/x-csh',
  7159. 'csml' => 'chemical/x-csml',
  7160. 'csp' => 'application/vnd.commonspace',
  7161. 'css' => 'text/css',
  7162. 'cst' => 'application/x-director',
  7163. 'csv' => 'text/csv',
  7164. 'cu' => 'application/cu-seeme',
  7165. 'curl' => 'text/vnd.curl',
  7166. 'cww' => 'application/prs.cww',
  7167. 'cxt' => 'application/x-director',
  7168. 'cxx' => 'text/x-c',
  7169. 'dae' => 'model/vnd.collada+xml',
  7170. 'daf' => 'application/vnd.mobius.daf',
  7171. 'dart' => 'application/vnd.dart',
  7172. 'dataless' => 'application/vnd.fdsn.seed',
  7173. 'davmount' => 'application/davmount+xml',
  7174. 'dbk' => 'application/docbook+xml',
  7175. 'dcr' => 'application/x-director',
  7176. 'dcurl' => 'text/vnd.curl.dcurl',
  7177. 'dd2' => 'application/vnd.oma.dd2+xml',
  7178. 'ddd' => 'application/vnd.fujixerox.ddd',
  7179. 'deb' => 'application/x-debian-package',
  7180. 'def' => 'text/plain',
  7181. 'deploy' => 'application/octet-stream',
  7182. 'der' => 'application/x-x509-ca-cert',
  7183. 'dfac' => 'application/vnd.dreamfactory',
  7184. 'dgc' => 'application/x-dgc-compressed',
  7185. 'dic' => 'text/x-c',
  7186. 'dir' => 'application/x-director',
  7187. 'dis' => 'application/vnd.mobius.dis',
  7188. 'dist' => 'application/octet-stream',
  7189. 'distz' => 'application/octet-stream',
  7190. 'djv' => 'image/vnd.djvu',
  7191. 'djvu' => 'image/vnd.djvu',
  7192. 'dll' => 'application/x-msdownload',
  7193. 'dmg' => 'application/x-apple-diskimage',
  7194. 'dmp' => 'application/vnd.tcpdump.pcap',
  7195. 'dms' => 'application/octet-stream',
  7196. 'dna' => 'application/vnd.dna',
  7197. 'doc' => 'application/msword',
  7198. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  7199. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  7200. 'dot' => 'application/msword',
  7201. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  7202. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  7203. 'dp' => 'application/vnd.osgi.dp',
  7204. 'dpg' => 'application/vnd.dpgraph',
  7205. 'dra' => 'audio/vnd.dra',
  7206. 'dsc' => 'text/prs.lines.tag',
  7207. 'dssc' => 'application/dssc+der',
  7208. 'dtb' => 'application/x-dtbook+xml',
  7209. 'dtd' => 'application/xml-dtd',
  7210. 'dts' => 'audio/vnd.dts',
  7211. 'dtshd' => 'audio/vnd.dts.hd',
  7212. 'dump' => 'application/octet-stream',
  7213. 'dvb' => 'video/vnd.dvb.file',
  7214. 'dvi' => 'application/x-dvi',
  7215. 'dwf' => 'model/vnd.dwf',
  7216. 'dwg' => 'image/vnd.dwg',
  7217. 'dxf' => 'image/vnd.dxf',
  7218. 'dxp' => 'application/vnd.spotfire.dxp',
  7219. 'dxr' => 'application/x-director',
  7220. 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
  7221. 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
  7222. 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
  7223. 'ecma' => 'application/ecmascript',
  7224. 'edm' => 'application/vnd.novadigm.edm',
  7225. 'edx' => 'application/vnd.novadigm.edx',
  7226. 'efif' => 'application/vnd.picsel',
  7227. 'ei6' => 'application/vnd.pg.osasli',
  7228. 'elc' => 'application/octet-stream',
  7229. 'emf' => 'application/x-msmetafile',
  7230. 'eml' => 'message/rfc822',
  7231. 'emma' => 'application/emma+xml',
  7232. 'emz' => 'application/x-msmetafile',
  7233. 'eol' => 'audio/vnd.digital-winds',
  7234. 'eot' => 'application/vnd.ms-fontobject',
  7235. 'eps' => 'application/postscript',
  7236. 'epub' => 'application/epub+zip',
  7237. 'es3' => 'application/vnd.eszigno3+xml',
  7238. 'esa' => 'application/vnd.osgi.subsystem',
  7239. 'esf' => 'application/vnd.epson.esf',
  7240. 'et3' => 'application/vnd.eszigno3+xml',
  7241. 'etx' => 'text/x-setext',
  7242. 'eva' => 'application/x-eva',
  7243. 'evy' => 'application/x-envoy',
  7244. 'exe' => 'application/x-msdownload',
  7245. 'exi' => 'application/exi',
  7246. 'ext' => 'application/vnd.novadigm.ext',
  7247. 'ez' => 'application/andrew-inset',
  7248. 'ez2' => 'application/vnd.ezpix-album',
  7249. 'ez3' => 'application/vnd.ezpix-package',
  7250. 'f' => 'text/x-fortran',
  7251. 'f4v' => 'video/x-f4v',
  7252. 'f77' => 'text/x-fortran',
  7253. 'f90' => 'text/x-fortran',
  7254. 'fbs' => 'image/vnd.fastbidsheet',
  7255. 'fcdt' => 'application/vnd.adobe.formscentral.fcdt',
  7256. 'fcs' => 'application/vnd.isac.fcs',
  7257. 'fdf' => 'application/vnd.fdf',
  7258. 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
  7259. 'fg5' => 'application/vnd.fujitsu.oasysgp',
  7260. 'fgd' => 'application/x-director',
  7261. 'fh' => 'image/x-freehand',
  7262. 'fh4' => 'image/x-freehand',
  7263. 'fh5' => 'image/x-freehand',
  7264. 'fh7' => 'image/x-freehand',
  7265. 'fhc' => 'image/x-freehand',
  7266. 'fig' => 'application/x-xfig',
  7267. 'flac' => 'audio/x-flac',
  7268. 'fli' => 'video/x-fli',
  7269. 'flo' => 'application/vnd.micrografx.flo',
  7270. 'flv' => 'video/x-flv',
  7271. 'flw' => 'application/vnd.kde.kivio',
  7272. 'flx' => 'text/vnd.fmi.flexstor',
  7273. 'fly' => 'text/vnd.fly',
  7274. 'fm' => 'application/vnd.framemaker',
  7275. 'fnc' => 'application/vnd.frogans.fnc',
  7276. 'for' => 'text/x-fortran',
  7277. 'fpx' => 'image/vnd.fpx',
  7278. 'frame' => 'application/vnd.framemaker',
  7279. 'fsc' => 'application/vnd.fsc.weblaunch',
  7280. 'fst' => 'image/vnd.fst',
  7281. 'ftc' => 'application/vnd.fluxtime.clip',
  7282. 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
  7283. 'fvt' => 'video/vnd.fvt',
  7284. 'fxp' => 'application/vnd.adobe.fxp',
  7285. 'fxpl' => 'application/vnd.adobe.fxp',
  7286. 'fzs' => 'application/vnd.fuzzysheet',
  7287. 'g2w' => 'application/vnd.geoplan',
  7288. 'g3' => 'image/g3fax',
  7289. 'g3w' => 'application/vnd.geospace',
  7290. 'gac' => 'application/vnd.groove-account',
  7291. 'gam' => 'application/x-tads',
  7292. 'gbr' => 'application/rpki-ghostbusters',
  7293. 'gca' => 'application/x-gca-compressed',
  7294. 'gdl' => 'model/vnd.gdl',
  7295. 'geo' => 'application/vnd.dynageo',
  7296. 'gex' => 'application/vnd.geometry-explorer',
  7297. 'ggb' => 'application/vnd.geogebra.file',
  7298. 'ggt' => 'application/vnd.geogebra.tool',
  7299. 'ghf' => 'application/vnd.groove-help',
  7300. 'gif' => 'image/gif',
  7301. 'gim' => 'application/vnd.groove-identity-message',
  7302. 'gml' => 'application/gml+xml',
  7303. 'gmx' => 'application/vnd.gmx',
  7304. 'gnumeric' => 'application/x-gnumeric',
  7305. 'gph' => 'application/vnd.flographit',
  7306. 'gpx' => 'application/gpx+xml',
  7307. 'gqf' => 'application/vnd.grafeq',
  7308. 'gqs' => 'application/vnd.grafeq',
  7309. 'gram' => 'application/srgs',
  7310. 'gramps' => 'application/x-gramps-xml',
  7311. 'gre' => 'application/vnd.geometry-explorer',
  7312. 'grv' => 'application/vnd.groove-injector',
  7313. 'grxml' => 'application/srgs+xml',
  7314. 'gsf' => 'application/x-font-ghostscript',
  7315. 'gtar' => 'application/x-gtar',
  7316. 'gtm' => 'application/vnd.groove-tool-message',
  7317. 'gtw' => 'model/vnd.gtw',
  7318. 'gv' => 'text/vnd.graphviz',
  7319. 'gxf' => 'application/gxf',
  7320. 'gxt' => 'application/vnd.geonext',
  7321. 'h' => 'text/x-c',
  7322. 'h261' => 'video/h261',
  7323. 'h263' => 'video/h263',
  7324. 'h264' => 'video/h264',
  7325. 'hal' => 'application/vnd.hal+xml',
  7326. 'hbci' => 'application/vnd.hbci',
  7327. 'hdf' => 'application/x-hdf',
  7328. 'hh' => 'text/x-c',
  7329. 'hlp' => 'application/winhlp',
  7330. 'hpgl' => 'application/vnd.hp-hpgl',
  7331. 'hpid' => 'application/vnd.hp-hpid',
  7332. 'hps' => 'application/vnd.hp-hps',
  7333. 'hqx' => 'application/mac-binhex40',
  7334. 'htke' => 'application/vnd.kenameaapp',
  7335. 'htm' => 'text/html',
  7336. 'html' => 'text/html',
  7337. 'hvd' => 'application/vnd.yamaha.hv-dic',
  7338. 'hvp' => 'application/vnd.yamaha.hv-voice',
  7339. 'hvs' => 'application/vnd.yamaha.hv-script',
  7340. 'i2g' => 'application/vnd.intergeo',
  7341. 'icc' => 'application/vnd.iccprofile',
  7342. 'ice' => 'x-conference/x-cooltalk',
  7343. 'icm' => 'application/vnd.iccprofile',
  7344. 'ico' => 'image/x-icon',
  7345. 'ics' => 'text/calendar',
  7346. 'ief' => 'image/ief',
  7347. 'ifb' => 'text/calendar',
  7348. 'ifm' => 'application/vnd.shana.informed.formdata',
  7349. 'iges' => 'model/iges',
  7350. 'igl' => 'application/vnd.igloader',
  7351. 'igm' => 'application/vnd.insors.igm',
  7352. 'igs' => 'model/iges',
  7353. 'igx' => 'application/vnd.micrografx.igx',
  7354. 'iif' => 'application/vnd.shana.informed.interchange',
  7355. 'imp' => 'application/vnd.accpac.simply.imp',
  7356. 'ims' => 'application/vnd.ms-ims',
  7357. 'in' => 'text/plain',
  7358. 'ink' => 'application/inkml+xml',
  7359. 'inkml' => 'application/inkml+xml',
  7360. 'install' => 'application/x-install-instructions',
  7361. 'iota' => 'application/vnd.astraea-software.iota',
  7362. 'ipfix' => 'application/ipfix',
  7363. 'ipk' => 'application/vnd.shana.informed.package',
  7364. 'irm' => 'application/vnd.ibm.rights-management',
  7365. 'irp' => 'application/vnd.irepository.package+xml',
  7366. 'iso' => 'application/x-iso9660-image',
  7367. 'itp' => 'application/vnd.shana.informed.formtemplate',
  7368. 'ivp' => 'application/vnd.immervision-ivp',
  7369. 'ivu' => 'application/vnd.immervision-ivu',
  7370. 'jad' => 'text/vnd.sun.j2me.app-descriptor',
  7371. 'jam' => 'application/vnd.jam',
  7372. 'jar' => 'application/java-archive',
  7373. 'java' => 'text/x-java-source',
  7374. 'jisp' => 'application/vnd.jisp',
  7375. 'jlt' => 'application/vnd.hp-jlyt',
  7376. 'jnlp' => 'application/x-java-jnlp-file',
  7377. 'joda' => 'application/vnd.joost.joda-archive',
  7378. 'jpe' => 'image/jpeg',
  7379. 'jpeg' => 'image/jpeg',
  7380. 'jpg' => 'image/jpeg',
  7381. 'jpgm' => 'video/jpm',
  7382. 'jpgv' => 'video/jpeg',
  7383. 'jpm' => 'video/jpm',
  7384. 'js' => 'application/javascript',
  7385. 'json' => 'application/json',
  7386. 'jsonml' => 'application/jsonml+json',
  7387. 'kar' => 'audio/midi',
  7388. 'karbon' => 'application/vnd.kde.karbon',
  7389. 'kfo' => 'application/vnd.kde.kformula',
  7390. 'kia' => 'application/vnd.kidspiration',
  7391. 'kml' => 'application/vnd.google-earth.kml+xml',
  7392. 'kmz' => 'application/vnd.google-earth.kmz',
  7393. 'kne' => 'application/vnd.kinar',
  7394. 'knp' => 'application/vnd.kinar',
  7395. 'kon' => 'application/vnd.kde.kontour',
  7396. 'kpr' => 'application/vnd.kde.kpresenter',
  7397. 'kpt' => 'application/vnd.kde.kpresenter',
  7398. 'kpxx' => 'application/vnd.ds-keypoint',
  7399. 'ksp' => 'application/vnd.kde.kspread',
  7400. 'ktr' => 'application/vnd.kahootz',
  7401. 'ktx' => 'image/ktx',
  7402. 'ktz' => 'application/vnd.kahootz',
  7403. 'kwd' => 'application/vnd.kde.kword',
  7404. 'kwt' => 'application/vnd.kde.kword',
  7405. 'lasxml' => 'application/vnd.las.las+xml',
  7406. 'latex' => 'application/x-latex',
  7407. 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  7408. 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  7409. 'les' => 'application/vnd.hhe.lesson-player',
  7410. 'lha' => 'application/x-lzh-compressed',
  7411. 'link66' => 'application/vnd.route66.link66+xml',
  7412. 'list' => 'text/plain',
  7413. 'list3820' => 'application/vnd.ibm.modcap',
  7414. 'listafp' => 'application/vnd.ibm.modcap',
  7415. 'lnk' => 'application/x-ms-shortcut',
  7416. 'log' => 'text/plain',
  7417. 'lostxml' => 'application/lost+xml',
  7418. 'lrf' => 'application/octet-stream',
  7419. 'lrm' => 'application/vnd.ms-lrm',
  7420. 'ltf' => 'application/vnd.frogans.ltf',
  7421. 'lvp' => 'audio/vnd.lucent.voice',
  7422. 'lwp' => 'application/vnd.lotus-wordpro',
  7423. 'lzh' => 'application/x-lzh-compressed',
  7424. 'm13' => 'application/x-msmediaview',
  7425. 'm14' => 'application/x-msmediaview',
  7426. 'm1v' => 'video/mpeg',
  7427. 'm21' => 'application/mp21',
  7428. 'm2a' => 'audio/mpeg',
  7429. 'm2v' => 'video/mpeg',
  7430. 'm3a' => 'audio/mpeg',
  7431. 'm3u' => 'audio/x-mpegurl',
  7432. 'm3u8' => 'application/vnd.apple.mpegurl',
  7433. 'm4a' => 'audio/mp4',
  7434. 'm4u' => 'video/vnd.mpegurl',
  7435. 'm4v' => 'video/x-m4v',
  7436. 'ma' => 'application/mathematica',
  7437. 'mads' => 'application/mads+xml',
  7438. 'mag' => 'application/vnd.ecowin.chart',
  7439. 'maker' => 'application/vnd.framemaker',
  7440. 'man' => 'text/troff',
  7441. 'mar' => 'application/octet-stream',
  7442. 'mathml' => 'application/mathml+xml',
  7443. 'mb' => 'application/mathematica',
  7444. 'mbk' => 'application/vnd.mobius.mbk',
  7445. 'mbox' => 'application/mbox',
  7446. 'mc1' => 'application/vnd.medcalcdata',
  7447. 'mcd' => 'application/vnd.mcd',
  7448. 'mcurl' => 'text/vnd.curl.mcurl',
  7449. 'mdb' => 'application/x-msaccess',
  7450. 'mdi' => 'image/vnd.ms-modi',
  7451. 'me' => 'text/troff',
  7452. 'mesh' => 'model/mesh',
  7453. 'meta4' => 'application/metalink4+xml',
  7454. 'metalink' => 'application/metalink+xml',
  7455. 'mets' => 'application/mets+xml',
  7456. 'mfm' => 'application/vnd.mfmp',
  7457. 'mft' => 'application/rpki-manifest',
  7458. 'mgp' => 'application/vnd.osgeo.mapguide.package',
  7459. 'mgz' => 'application/vnd.proteus.magazine',
  7460. 'mid' => 'audio/midi',
  7461. 'midi' => 'audio/midi',
  7462. 'mie' => 'application/x-mie',
  7463. 'mif' => 'application/vnd.mif',
  7464. 'mime' => 'message/rfc822',
  7465. 'mj2' => 'video/mj2',
  7466. 'mjp2' => 'video/mj2',
  7467. 'mk3d' => 'video/x-matroska',
  7468. 'mka' => 'audio/x-matroska',
  7469. 'mks' => 'video/x-matroska',
  7470. 'mkv' => 'video/x-matroska',
  7471. 'mlp' => 'application/vnd.dolby.mlp',
  7472. 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
  7473. 'mmf' => 'application/vnd.smaf',
  7474. 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
  7475. 'mng' => 'video/x-mng',
  7476. 'mny' => 'application/x-msmoney',
  7477. 'mobi' => 'application/x-mobipocket-ebook',
  7478. 'mods' => 'application/mods+xml',
  7479. 'mov' => 'video/quicktime',
  7480. 'movie' => 'video/x-sgi-movie',
  7481. 'mp2' => 'audio/mpeg',
  7482. 'mp21' => 'application/mp21',
  7483. 'mp2a' => 'audio/mpeg',
  7484. 'mp3' => 'audio/mpeg',
  7485. 'mp4' => 'video/mp4',
  7486. 'mp4a' => 'audio/mp4',
  7487. 'mp4s' => 'application/mp4',
  7488. 'mp4v' => 'video/mp4',
  7489. 'mpc' => 'application/vnd.mophun.certificate',
  7490. 'mpe' => 'video/mpeg',
  7491. 'mpeg' => 'video/mpeg',
  7492. 'mpg' => 'video/mpeg',
  7493. 'mpg4' => 'video/mp4',
  7494. 'mpga' => 'audio/mpeg',
  7495. 'mpkg' => 'application/vnd.apple.installer+xml',
  7496. 'mpm' => 'application/vnd.blueice.multipass',
  7497. 'mpn' => 'application/vnd.mophun.application',
  7498. 'mpp' => 'application/vnd.ms-project',
  7499. 'mpt' => 'application/vnd.ms-project',
  7500. 'mpy' => 'application/vnd.ibm.minipay',
  7501. 'mqy' => 'application/vnd.mobius.mqy',
  7502. 'mrc' => 'application/marc',
  7503. 'mrcx' => 'application/marcxml+xml',
  7504. 'ms' => 'text/troff',
  7505. 'mscml' => 'application/mediaservercontrol+xml',
  7506. 'mseed' => 'application/vnd.fdsn.mseed',
  7507. 'mseq' => 'application/vnd.mseq',
  7508. 'msf' => 'application/vnd.epson.msf',
  7509. 'msh' => 'model/mesh',
  7510. 'msi' => 'application/x-msdownload',
  7511. 'msl' => 'application/vnd.mobius.msl',
  7512. 'msty' => 'application/vnd.muvee.style',
  7513. 'mts' => 'model/vnd.mts',
  7514. 'mus' => 'application/vnd.musician',
  7515. 'musicxml' => 'application/vnd.recordare.musicxml+xml',
  7516. 'mvb' => 'application/x-msmediaview',
  7517. 'mwf' => 'application/vnd.mfer',
  7518. 'mxf' => 'application/mxf',
  7519. 'mxl' => 'application/vnd.recordare.musicxml',
  7520. 'mxml' => 'application/xv+xml',
  7521. 'mxs' => 'application/vnd.triscape.mxs',
  7522. 'mxu' => 'video/vnd.mpegurl',
  7523. 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  7524. 'n3' => 'text/n3',
  7525. 'nb' => 'application/mathematica',
  7526. 'nbp' => 'application/vnd.wolfram.player',
  7527. 'nc' => 'application/x-netcdf',
  7528. 'ncx' => 'application/x-dtbncx+xml',
  7529. 'nfo' => 'text/x-nfo',
  7530. 'ngdat' => 'application/vnd.nokia.n-gage.data',
  7531. 'nitf' => 'application/vnd.nitf',
  7532. 'nlu' => 'application/vnd.neurolanguage.nlu',
  7533. 'nml' => 'application/vnd.enliven',
  7534. 'nnd' => 'application/vnd.noblenet-directory',
  7535. 'nns' => 'application/vnd.noblenet-sealer',
  7536. 'nnw' => 'application/vnd.noblenet-web',
  7537. 'npx' => 'image/vnd.net-fpx',
  7538. 'nsc' => 'application/x-conference',
  7539. 'nsf' => 'application/vnd.lotus-notes',
  7540. 'ntf' => 'application/vnd.nitf',
  7541. 'nzb' => 'application/x-nzb',
  7542. 'oa2' => 'application/vnd.fujitsu.oasys2',
  7543. 'oa3' => 'application/vnd.fujitsu.oasys3',
  7544. 'oas' => 'application/vnd.fujitsu.oasys',
  7545. 'obd' => 'application/x-msbinder',
  7546. 'obj' => 'application/x-tgif',
  7547. 'oda' => 'application/oda',
  7548. 'odb' => 'application/vnd.oasis.opendocument.database',
  7549. 'odc' => 'application/vnd.oasis.opendocument.chart',
  7550. 'odf' => 'application/vnd.oasis.opendocument.formula',
  7551. 'odft' => 'application/vnd.oasis.opendocument.formula-template',
  7552. 'odg' => 'application/vnd.oasis.opendocument.graphics',
  7553. 'odi' => 'application/vnd.oasis.opendocument.image',
  7554. 'odm' => 'application/vnd.oasis.opendocument.text-master',
  7555. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  7556. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  7557. 'odt' => 'application/vnd.oasis.opendocument.text',
  7558. 'oga' => 'audio/ogg',
  7559. 'ogg' => 'audio/ogg',
  7560. 'ogv' => 'video/ogg',
  7561. 'ogx' => 'application/ogg',
  7562. 'omdoc' => 'application/omdoc+xml',
  7563. 'onepkg' => 'application/onenote',
  7564. 'onetmp' => 'application/onenote',
  7565. 'onetoc' => 'application/onenote',
  7566. 'onetoc2' => 'application/onenote',
  7567. 'opf' => 'application/oebps-package+xml',
  7568. 'opml' => 'text/x-opml',
  7569. 'oprc' => 'application/vnd.palm',
  7570. 'org' => 'application/vnd.lotus-organizer',
  7571. 'osf' => 'application/vnd.yamaha.openscoreformat',
  7572. 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  7573. 'otc' => 'application/vnd.oasis.opendocument.chart-template',
  7574. 'otf' => 'application/x-font-otf',
  7575. 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
  7576. 'oth' => 'application/vnd.oasis.opendocument.text-web',
  7577. 'oti' => 'application/vnd.oasis.opendocument.image-template',
  7578. 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
  7579. 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  7580. 'ott' => 'application/vnd.oasis.opendocument.text-template',
  7581. 'oxps' => 'application/oxps',
  7582. 'oxt' => 'application/vnd.openofficeorg.extension',
  7583. 'p' => 'text/x-pascal',
  7584. 'p10' => 'application/pkcs10',
  7585. 'p12' => 'application/x-pkcs12',
  7586. 'p7b' => 'application/x-pkcs7-certificates',
  7587. 'p7c' => 'application/pkcs7-mime',
  7588. 'p7m' => 'application/pkcs7-mime',
  7589. 'p7r' => 'application/x-pkcs7-certreqresp',
  7590. 'p7s' => 'application/pkcs7-signature',
  7591. 'p8' => 'application/pkcs8',
  7592. 'pas' => 'text/x-pascal',
  7593. 'paw' => 'application/vnd.pawaafile',
  7594. 'pbd' => 'application/vnd.powerbuilder6',
  7595. 'pbm' => 'image/x-portable-bitmap',
  7596. 'pcap' => 'application/vnd.tcpdump.pcap',
  7597. 'pcf' => 'application/x-font-pcf',
  7598. 'pcl' => 'application/vnd.hp-pcl',
  7599. 'pclxl' => 'application/vnd.hp-pclxl',
  7600. 'pct' => 'image/x-pict',
  7601. 'pcurl' => 'application/vnd.curl.pcurl',
  7602. 'pcx' => 'image/x-pcx',
  7603. 'pdb' => 'application/vnd.palm',
  7604. 'pdf' => 'application/pdf',
  7605. 'pfa' => 'application/x-font-type1',
  7606. 'pfb' => 'application/x-font-type1',
  7607. 'pfm' => 'application/x-font-type1',
  7608. 'pfr' => 'application/font-tdpfr',
  7609. 'pfx' => 'application/x-pkcs12',
  7610. 'pgm' => 'image/x-portable-graymap',
  7611. 'pgn' => 'application/x-chess-pgn',
  7612. 'pgp' => 'application/pgp-encrypted',
  7613. 'pic' => 'image/x-pict',
  7614. 'pkg' => 'application/octet-stream',
  7615. 'pki' => 'application/pkixcmp',
  7616. 'pkipath' => 'application/pkix-pkipath',
  7617. 'plb' => 'application/vnd.3gpp.pic-bw-large',
  7618. 'plc' => 'application/vnd.mobius.plc',
  7619. 'plf' => 'application/vnd.pocketlearn',
  7620. 'pls' => 'application/pls+xml',
  7621. 'pml' => 'application/vnd.ctc-posml',
  7622. 'png' => 'image/png',
  7623. 'pnm' => 'image/x-portable-anymap',
  7624. 'portpkg' => 'application/vnd.macports.portpkg',
  7625. 'pot' => 'application/vnd.ms-powerpoint',
  7626. 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
  7627. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  7628. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  7629. 'ppd' => 'application/vnd.cups-ppd',
  7630. 'ppm' => 'image/x-portable-pixmap',
  7631. 'pps' => 'application/vnd.ms-powerpoint',
  7632. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  7633. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  7634. 'ppt' => 'application/vnd.ms-powerpoint',
  7635. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  7636. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  7637. 'pqa' => 'application/vnd.palm',
  7638. 'prc' => 'application/x-mobipocket-ebook',
  7639. 'pre' => 'application/vnd.lotus-freelance',
  7640. 'prf' => 'application/pics-rules',
  7641. 'ps' => 'application/postscript',
  7642. 'psb' => 'application/vnd.3gpp.pic-bw-small',
  7643. 'psd' => 'image/vnd.adobe.photoshop',
  7644. 'psf' => 'application/x-font-linux-psf',
  7645. 'pskcxml' => 'application/pskc+xml',
  7646. 'ptid' => 'application/vnd.pvi.ptid1',
  7647. 'pub' => 'application/x-mspublisher',
  7648. 'pvb' => 'application/vnd.3gpp.pic-bw-var',
  7649. 'pwn' => 'application/vnd.3m.post-it-notes',
  7650. 'pya' => 'audio/vnd.ms-playready.media.pya',
  7651. 'pyv' => 'video/vnd.ms-playready.media.pyv',
  7652. 'qam' => 'application/vnd.epson.quickanime',
  7653. 'qbo' => 'application/vnd.intu.qbo',
  7654. 'qfx' => 'application/vnd.intu.qfx',
  7655. 'qps' => 'application/vnd.publishare-delta-tree',
  7656. 'qt' => 'video/quicktime',
  7657. 'qwd' => 'application/vnd.quark.quarkxpress',
  7658. 'qwt' => 'application/vnd.quark.quarkxpress',
  7659. 'qxb' => 'application/vnd.quark.quarkxpress',
  7660. 'qxd' => 'application/vnd.quark.quarkxpress',
  7661. 'qxl' => 'application/vnd.quark.quarkxpress',
  7662. 'qxt' => 'application/vnd.quark.quarkxpress',
  7663. 'ra' => 'audio/x-pn-realaudio',
  7664. 'ram' => 'audio/x-pn-realaudio',
  7665. 'rar' => 'application/x-rar-compressed',
  7666. 'ras' => 'image/x-cmu-raster',
  7667. 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
  7668. 'rdf' => 'application/rdf+xml',
  7669. 'rdz' => 'application/vnd.data-vision.rdz',
  7670. 'rep' => 'application/vnd.businessobjects',
  7671. 'res' => 'application/x-dtbresource+xml',
  7672. 'rgb' => 'image/x-rgb',
  7673. 'rif' => 'application/reginfo+xml',
  7674. 'rip' => 'audio/vnd.rip',
  7675. 'ris' => 'application/x-research-info-systems',
  7676. 'rl' => 'application/resource-lists+xml',
  7677. 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
  7678. 'rld' => 'application/resource-lists-diff+xml',
  7679. 'rm' => 'application/vnd.rn-realmedia',
  7680. 'rmi' => 'audio/midi',
  7681. 'rmp' => 'audio/x-pn-realaudio-plugin',
  7682. 'rms' => 'application/vnd.jcp.javame.midlet-rms',
  7683. 'rmvb' => 'application/vnd.rn-realmedia-vbr',
  7684. 'rnc' => 'application/relax-ng-compact-syntax',
  7685. 'roa' => 'application/rpki-roa',
  7686. 'roff' => 'text/troff',
  7687. 'rp9' => 'application/vnd.cloanto.rp9',
  7688. 'rpss' => 'application/vnd.nokia.radio-presets',
  7689. 'rpst' => 'application/vnd.nokia.radio-preset',
  7690. 'rq' => 'application/sparql-query',
  7691. 'rs' => 'application/rls-services+xml',
  7692. 'rsd' => 'application/rsd+xml',
  7693. 'rss' => 'application/rss+xml',
  7694. 'rtf' => 'application/rtf',
  7695. 'rtx' => 'text/richtext',
  7696. 's' => 'text/x-asm',
  7697. 's3m' => 'audio/s3m',
  7698. 'saf' => 'application/vnd.yamaha.smaf-audio',
  7699. 'sbml' => 'application/sbml+xml',
  7700. 'sc' => 'application/vnd.ibm.secure-container',
  7701. 'scd' => 'application/x-msschedule',
  7702. 'scm' => 'application/vnd.lotus-screencam',
  7703. 'scq' => 'application/scvp-cv-request',
  7704. 'scs' => 'application/scvp-cv-response',
  7705. 'scurl' => 'text/vnd.curl.scurl',
  7706. 'sda' => 'application/vnd.stardivision.draw',
  7707. 'sdc' => 'application/vnd.stardivision.calc',
  7708. 'sdd' => 'application/vnd.stardivision.impress',
  7709. 'sdkd' => 'application/vnd.solent.sdkm+xml',
  7710. 'sdkm' => 'application/vnd.solent.sdkm+xml',
  7711. 'sdp' => 'application/sdp',
  7712. 'sdw' => 'application/vnd.stardivision.writer',
  7713. 'see' => 'application/vnd.seemail',
  7714. 'seed' => 'application/vnd.fdsn.seed',
  7715. 'sema' => 'application/vnd.sema',
  7716. 'semd' => 'application/vnd.semd',
  7717. 'semf' => 'application/vnd.semf',
  7718. 'ser' => 'application/java-serialized-object',
  7719. 'setpay' => 'application/set-payment-initiation',
  7720. 'setreg' => 'application/set-registration-initiation',
  7721. 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
  7722. 'sfs' => 'application/vnd.spotfire.sfs',
  7723. 'sfv' => 'text/x-sfv',
  7724. 'sgi' => 'image/sgi',
  7725. 'sgl' => 'application/vnd.stardivision.writer-global',
  7726. 'sgm' => 'text/sgml',
  7727. 'sgml' => 'text/sgml',
  7728. 'sh' => 'application/x-sh',
  7729. 'shar' => 'application/x-shar',
  7730. 'shf' => 'application/shf+xml',
  7731. 'sid' => 'image/x-mrsid-image',
  7732. 'sig' => 'application/pgp-signature',
  7733. 'sil' => 'audio/silk',
  7734. 'silo' => 'model/mesh',
  7735. 'sis' => 'application/vnd.symbian.install',
  7736. 'sisx' => 'application/vnd.symbian.install',
  7737. 'sit' => 'application/x-stuffit',
  7738. 'sitx' => 'application/x-stuffitx',
  7739. 'skd' => 'application/vnd.koan',
  7740. 'skm' => 'application/vnd.koan',
  7741. 'skp' => 'application/vnd.koan',
  7742. 'skt' => 'application/vnd.koan',
  7743. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  7744. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  7745. 'slt' => 'application/vnd.epson.salt',
  7746. 'sm' => 'application/vnd.stepmania.stepchart',
  7747. 'smf' => 'application/vnd.stardivision.math',
  7748. 'smi' => 'application/smil+xml',
  7749. 'smil' => 'application/smil+xml',
  7750. 'smv' => 'video/x-smv',
  7751. 'smzip' => 'application/vnd.stepmania.package',
  7752. 'snd' => 'audio/basic',
  7753. 'snf' => 'application/x-font-snf',
  7754. 'so' => 'application/octet-stream',
  7755. 'spc' => 'application/x-pkcs7-certificates',
  7756. 'spf' => 'application/vnd.yamaha.smaf-phrase',
  7757. 'spl' => 'application/x-futuresplash',
  7758. 'spot' => 'text/vnd.in3d.spot',
  7759. 'spp' => 'application/scvp-vp-response',
  7760. 'spq' => 'application/scvp-vp-request',
  7761. 'spx' => 'audio/ogg',
  7762. 'sql' => 'application/x-sql',
  7763. 'src' => 'application/x-wais-source',
  7764. 'srt' => 'application/x-subrip',
  7765. 'sru' => 'application/sru+xml',
  7766. 'srx' => 'application/sparql-results+xml',
  7767. 'ssdl' => 'application/ssdl+xml',
  7768. 'sse' => 'application/vnd.kodak-descriptor',
  7769. 'ssf' => 'application/vnd.epson.ssf',
  7770. 'ssml' => 'application/ssml+xml',
  7771. 'st' => 'application/vnd.sailingtracker.track',
  7772. 'stc' => 'application/vnd.sun.xml.calc.template',
  7773. 'std' => 'application/vnd.sun.xml.draw.template',
  7774. 'stf' => 'application/vnd.wt.stf',
  7775. 'sti' => 'application/vnd.sun.xml.impress.template',
  7776. 'stk' => 'application/hyperstudio',
  7777. 'stl' => 'application/vnd.ms-pki.stl',
  7778. 'str' => 'application/vnd.pg.format',
  7779. 'stw' => 'application/vnd.sun.xml.writer.template',
  7780. 'sub' => 'image/vnd.dvb.subtitle',
  7781. 'sub' => 'text/vnd.dvb.subtitle',
  7782. 'sus' => 'application/vnd.sus-calendar',
  7783. 'susp' => 'application/vnd.sus-calendar',
  7784. 'sv4cpio' => 'application/x-sv4cpio',
  7785. 'sv4crc' => 'application/x-sv4crc',
  7786. 'svc' => 'application/vnd.dvb.service',
  7787. 'svd' => 'application/vnd.svd',
  7788. 'svg' => 'image/svg+xml',
  7789. 'svgz' => 'image/svg+xml',
  7790. 'swa' => 'application/x-director',
  7791. 'swf' => 'application/x-shockwave-flash',
  7792. 'swi' => 'application/vnd.aristanetworks.swi',
  7793. 'sxc' => 'application/vnd.sun.xml.calc',
  7794. 'sxd' => 'application/vnd.sun.xml.draw',
  7795. 'sxg' => 'application/vnd.sun.xml.writer.global',
  7796. 'sxi' => 'application/vnd.sun.xml.impress',
  7797. 'sxm' => 'application/vnd.sun.xml.math',
  7798. 'sxw' => 'application/vnd.sun.xml.writer',
  7799. 't' => 'text/troff',
  7800. 't3' => 'application/x-t3vm-image',
  7801. 'taglet' => 'application/vnd.mynfc',
  7802. 'tao' => 'application/vnd.tao.intent-module-archive',
  7803. 'tar' => 'application/x-tar',
  7804. 'tcap' => 'application/vnd.3gpp2.tcap',
  7805. 'tcl' => 'application/x-tcl',
  7806. 'teacher' => 'application/vnd.smart.teacher',
  7807. 'tei' => 'application/tei+xml',
  7808. 'teicorpus' => 'application/tei+xml',
  7809. 'tex' => 'application/x-tex',
  7810. 'texi' => 'application/x-texinfo',
  7811. 'texinfo' => 'application/x-texinfo',
  7812. 'text' => 'text/plain',
  7813. 'tfi' => 'application/thraud+xml',
  7814. 'tfm' => 'application/x-tex-tfm',
  7815. 'tga' => 'image/x-tga',
  7816. 'thmx' => 'application/vnd.ms-officetheme',
  7817. 'tif' => 'image/tiff',
  7818. 'tiff' => 'image/tiff',
  7819. 'tmo' => 'application/vnd.tmobile-livetv',
  7820. 'torrent' => 'application/x-bittorrent',
  7821. 'tpl' => 'application/vnd.groove-tool-template',
  7822. 'tpt' => 'application/vnd.trid.tpt',
  7823. 'tr' => 'text/troff',
  7824. 'tra' => 'application/vnd.trueapp',
  7825. 'trm' => 'application/x-msterminal',
  7826. 'tsd' => 'application/timestamped-data',
  7827. 'tsv' => 'text/tab-separated-values',
  7828. 'ttc' => 'application/x-font-ttf',
  7829. 'ttf' => 'application/x-font-ttf',
  7830. 'ttl' => 'text/turtle',
  7831. 'twd' => 'application/vnd.simtech-mindmapper',
  7832. 'twds' => 'application/vnd.simtech-mindmapper',
  7833. 'txd' => 'application/vnd.genomatix.tuxedo',
  7834. 'txf' => 'application/vnd.mobius.txf',
  7835. 'txt' => 'text/plain',
  7836. 'u32' => 'application/x-authorware-bin',
  7837. 'udeb' => 'application/x-debian-package',
  7838. 'ufd' => 'application/vnd.ufdl',
  7839. 'ufdl' => 'application/vnd.ufdl',
  7840. 'ulx' => 'application/x-glulx',
  7841. 'umj' => 'application/vnd.umajin',
  7842. 'unityweb' => 'application/vnd.unity',
  7843. 'uoml' => 'application/vnd.uoml+xml',
  7844. 'uri' => 'text/uri-list',
  7845. 'uris' => 'text/uri-list',
  7846. 'urls' => 'text/uri-list',
  7847. 'ustar' => 'application/x-ustar',
  7848. 'utz' => 'application/vnd.uiq.theme',
  7849. 'uu' => 'text/x-uuencode',
  7850. 'uva' => 'audio/vnd.dece.audio',
  7851. 'uvd' => 'application/vnd.dece.data',
  7852. 'uvf' => 'application/vnd.dece.data',
  7853. 'uvg' => 'image/vnd.dece.graphic',
  7854. 'uvh' => 'video/vnd.dece.hd',
  7855. 'uvi' => 'image/vnd.dece.graphic',
  7856. 'uvm' => 'video/vnd.dece.mobile',
  7857. 'uvp' => 'video/vnd.dece.pd',
  7858. 'uvs' => 'video/vnd.dece.sd',
  7859. 'uvt' => 'application/vnd.dece.ttml+xml',
  7860. 'uvu' => 'video/vnd.uvvu.mp4',
  7861. 'uvv' => 'video/vnd.dece.video',
  7862. 'uvva' => 'audio/vnd.dece.audio',
  7863. 'uvvd' => 'application/vnd.dece.data',
  7864. 'uvvf' => 'application/vnd.dece.data',
  7865. 'uvvg' => 'image/vnd.dece.graphic',
  7866. 'uvvh' => 'video/vnd.dece.hd',
  7867. 'uvvi' => 'image/vnd.dece.graphic',
  7868. 'uvvm' => 'video/vnd.dece.mobile',
  7869. 'uvvp' => 'video/vnd.dece.pd',
  7870. 'uvvs' => 'video/vnd.dece.sd',
  7871. 'uvvt' => 'application/vnd.dece.ttml+xml',
  7872. 'uvvu' => 'video/vnd.uvvu.mp4',
  7873. 'uvvv' => 'video/vnd.dece.video',
  7874. 'uvvx' => 'application/vnd.dece.unspecified',
  7875. 'uvvz' => 'application/vnd.dece.zip',
  7876. 'uvx' => 'application/vnd.dece.unspecified',
  7877. 'uvz' => 'application/vnd.dece.zip',
  7878. 'vcard' => 'text/vcard',
  7879. 'vcd' => 'application/x-cdlink',
  7880. 'vcf' => 'text/x-vcard',
  7881. 'vcg' => 'application/vnd.groove-vcard',
  7882. 'vcs' => 'text/x-vcalendar',
  7883. 'vcx' => 'application/vnd.vcx',
  7884. 'vis' => 'application/vnd.visionary',
  7885. 'viv' => 'video/vnd.vivo',
  7886. 'vob' => 'video/x-ms-vob',
  7887. 'vor' => 'application/vnd.stardivision.writer',
  7888. 'vox' => 'application/x-authorware-bin',
  7889. 'vrml' => 'model/vrml',
  7890. 'vsd' => 'application/vnd.visio',
  7891. 'vsf' => 'application/vnd.vsf',
  7892. 'vss' => 'application/vnd.visio',
  7893. 'vst' => 'application/vnd.visio',
  7894. 'vsw' => 'application/vnd.visio',
  7895. 'vtu' => 'model/vnd.vtu',
  7896. 'vxml' => 'application/voicexml+xml',
  7897. 'w3d' => 'application/x-director',
  7898. 'wad' => 'application/x-doom',
  7899. 'wav' => 'audio/x-wav',
  7900. 'wax' => 'audio/x-ms-wax',
  7901. 'wbmp' => 'image/vnd.wap.wbmp',
  7902. 'wbs' => 'application/vnd.criticaltools.wbs+xml',
  7903. 'wbxml' => 'application/vnd.wap.wbxml',
  7904. 'wcm' => 'application/vnd.ms-works',
  7905. 'wdb' => 'application/vnd.ms-works',
  7906. 'wdp' => 'image/vnd.ms-photo',
  7907. 'weba' => 'audio/webm',
  7908. 'webm' => 'video/webm',
  7909. 'webp' => 'image/webp',
  7910. 'wg' => 'application/vnd.pmi.widget',
  7911. 'wgt' => 'application/widget',
  7912. 'wks' => 'application/vnd.ms-works',
  7913. 'wm' => 'video/x-ms-wm',
  7914. 'wma' => 'audio/x-ms-wma',
  7915. 'wmd' => 'application/x-ms-wmd',
  7916. 'wmf' => 'application/x-msmetafile',
  7917. 'wml' => 'text/vnd.wap.wml',
  7918. 'wmlc' => 'application/vnd.wap.wmlc',
  7919. 'wmls' => 'text/vnd.wap.wmlscript',
  7920. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  7921. 'wmv' => 'video/x-ms-wmv',
  7922. 'wmx' => 'video/x-ms-wmx',
  7923. 'wmz' => 'application/x-ms-wmz',
  7924. 'wmz' => 'application/x-msmetafile',
  7925. 'woff' => 'application/font-woff',
  7926. 'wpd' => 'application/vnd.wordperfect',
  7927. 'wpl' => 'application/vnd.ms-wpl',
  7928. 'wps' => 'application/vnd.ms-works',
  7929. 'wqd' => 'application/vnd.wqd',
  7930. 'wri' => 'application/x-mswrite',
  7931. 'wrl' => 'model/vrml',
  7932. 'wsdl' => 'application/wsdl+xml',
  7933. 'wspolicy' => 'application/wspolicy+xml',
  7934. 'wtb' => 'application/vnd.webturbo',
  7935. 'wvx' => 'video/x-ms-wvx',
  7936. 'x32' => 'application/x-authorware-bin',
  7937. 'x3d' => 'model/x3d+xml',
  7938. 'x3db' => 'model/x3d+binary',
  7939. 'x3dbz' => 'model/x3d+binary',
  7940. 'x3dv' => 'model/x3d+vrml',
  7941. 'x3dvz' => 'model/x3d+vrml',
  7942. 'x3dz' => 'model/x3d+xml',
  7943. 'xaml' => 'application/xaml+xml',
  7944. 'xap' => 'application/x-silverlight-app',
  7945. 'xar' => 'application/vnd.xara',
  7946. 'xbap' => 'application/x-ms-xbap',
  7947. 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
  7948. 'xbm' => 'image/x-xbitmap',
  7949. 'xdf' => 'application/xcap-diff+xml',
  7950. 'xdm' => 'application/vnd.syncml.dm+xml',
  7951. 'xdp' => 'application/vnd.adobe.xdp+xml',
  7952. 'xdssc' => 'application/dssc+xml',
  7953. 'xdw' => 'application/vnd.fujixerox.docuworks',
  7954. 'xenc' => 'application/xenc+xml',
  7955. 'xer' => 'application/patch-ops-error+xml',
  7956. 'xfdf' => 'application/vnd.adobe.xfdf',
  7957. 'xfdl' => 'application/vnd.xfdl',
  7958. 'xht' => 'application/xhtml+xml',
  7959. 'xhtml' => 'application/xhtml+xml',
  7960. 'xhvml' => 'application/xv+xml',
  7961. 'xif' => 'image/vnd.xiff',
  7962. 'xla' => 'application/vnd.ms-excel',
  7963. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  7964. 'xlc' => 'application/vnd.ms-excel',
  7965. 'xlf' => 'application/x-xliff+xml',
  7966. 'xlm' => 'application/vnd.ms-excel',
  7967. 'xls' => 'application/vnd.ms-excel',
  7968. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  7969. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  7970. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  7971. 'xlt' => 'application/vnd.ms-excel',
  7972. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  7973. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  7974. 'xlw' => 'application/vnd.ms-excel',
  7975. 'xm' => 'audio/xm',
  7976. 'xml' => 'application/xml',
  7977. 'xo' => 'application/vnd.olpc-sugar',
  7978. 'xop' => 'application/xop+xml',
  7979. 'xpi' => 'application/x-xpinstall',
  7980. 'xpl' => 'application/xproc+xml',
  7981. 'xpm' => 'image/x-xpixmap',
  7982. 'xpr' => 'application/vnd.is-xpr',
  7983. 'xps' => 'application/vnd.ms-xpsdocument',
  7984. 'xpw' => 'application/vnd.intercon.formnet',
  7985. 'xpx' => 'application/vnd.intercon.formnet',
  7986. 'xsl' => 'application/xml',
  7987. 'xslt' => 'application/xslt+xml',
  7988. 'xsm' => 'application/vnd.syncml+xml',
  7989. 'xspf' => 'application/xspf+xml',
  7990. 'xul' => 'application/vnd.mozilla.xul+xml',
  7991. 'xvm' => 'application/xv+xml',
  7992. 'xvml' => 'application/xv+xml',
  7993. 'xwd' => 'image/x-xwindowdump',
  7994. 'xyz' => 'chemical/x-xyz',
  7995. 'xz' => 'application/x-xz',
  7996. 'yang' => 'application/yang',
  7997. 'yin' => 'application/yin+xml',
  7998. 'z1' => 'application/x-zmachine',
  7999. 'z2' => 'application/x-zmachine',
  8000. 'z3' => 'application/x-zmachine',
  8001. 'z4' => 'application/x-zmachine',
  8002. 'z5' => 'application/x-zmachine',
  8003. 'z6' => 'application/x-zmachine',
  8004. 'z7' => 'application/x-zmachine',
  8005. 'z8' => 'application/x-zmachine',
  8006. 'zaz' => 'application/vnd.zzazz.deck+xml',
  8007. 'zip' => 'application/zip',
  8008. 'zir' => 'application/vnd.zul',
  8009. 'zirz' => 'application/vnd.zul',
  8010. 'zmm' => 'application/vnd.handheld-entertainment+xml'
  8011. );
  8012. }
  8013. // Always run this
  8014. if(strpos($_SERVER['SCRIPT_NAME'], 'check.php') == false){
  8015. dependCheck();
  8016. }