functions.php 358 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704
  1. <?php
  2. // ===================================
  3. // Define Version
  4. define('INSTALLEDVERSION', '1.90');
  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", "LDAP could not authenticate");
  123. return false;
  124. }
  125. }
  126. writeLog("error", "LDAP could not authenticate");
  127. return false;
  128. }
  129. else :
  130. // Ldap Auth Missing Dependancy
  131. function plugin_auth_ldap_disabled() {
  132. return 'LDAP - Disabled (Dependancy: php-ldap missing!)';
  133. }
  134. endif;
  135. // Pass credentials to FTP backend
  136. function plugin_auth_ftp($username, $password) {
  137. // Calculate parts
  138. $digest = parse_url(AUTHBACKENDHOST);
  139. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:(function_exists('ftp_ssl_connect')?'ftps':'ftp')));
  140. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  141. $port = (isset($digest['port'])?$digest['port']:21);
  142. // Determine Connection Type
  143. if ($scheme == 'ftps') {
  144. $conn_id = ftp_ssl_connect($host, $port, 20);
  145. } elseif ($scheme == 'ftp') {
  146. $conn_id = ftp_connect($host, $port, 20);
  147. } else {
  148. debug_out('Invalid FTP scheme. Use ftp or ftps');
  149. writeLog("error", "invalid FTP scheme");
  150. return false;
  151. }
  152. // Check if valid FTP connection
  153. if ($conn_id) {
  154. // Attempt login
  155. @$login_result = ftp_login($conn_id, $username, $password);
  156. ftp_close($conn_id);
  157. // Return Result
  158. if ($login_result) {
  159. writeLog("success", "$username authenticated");
  160. return true;
  161. } else {
  162. writeLog("error", "$username could not authenticate");
  163. return false;
  164. }
  165. } else {
  166. return false;
  167. }
  168. return false;
  169. }
  170. // Pass credentials to Emby Backend
  171. function plugin_auth_emby_local($username, $password) {
  172. $embyAddress = qualifyURL(EMBYURL);
  173. $headers = array(
  174. 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"',
  175. 'Content-Type' => 'application/json',
  176. );
  177. $body = array(
  178. 'Username' => $username,
  179. 'Password' => sha1($password),
  180. 'PasswordMd5' => md5($password),
  181. );
  182. $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers);
  183. if (isset($response['content'])) {
  184. $json = json_decode($response['content'], true);
  185. if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
  186. // Login Success - Now Logout Emby Session As We No Longer Need It
  187. $headers = array(
  188. 'X-Mediabrowser-Token' => $json['AccessToken'],
  189. );
  190. $response = post_router($embyAddress.'/Sessions/Logout', array(), $headers);
  191. return true;
  192. }
  193. }
  194. return false;
  195. }
  196. if (function_exists('curl_version')) :
  197. // Authenticate Against Emby Local (first) and Emby Connect
  198. function plugin_auth_emby_all($username, $password) {
  199. $localResult = plugin_auth_emby_local($username, $password);
  200. if ($localResult) {
  201. return $localResult;
  202. } else {
  203. return plugin_auth_emby_connect($username, $password);
  204. }
  205. }
  206. // Authenicate against emby connect
  207. function plugin_auth_emby_connect($username, $password) {
  208. $embyAddress = qualifyURL(EMBYURL);
  209. // Get A User
  210. $connectId = '';
  211. $userIds = json_decode(@file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
  212. if (is_array($userIds)) {
  213. foreach ($userIds as $key => $value) { // Scan for this user
  214. if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
  215. if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
  216. $connectId = $value['ConnectUserId'];
  217. break;
  218. }
  219. }
  220. }
  221. if ($connectId) {
  222. $connectURL = 'https://connect.emby.media/service/user/authenticate';
  223. $headers = array(
  224. 'Accept'=> 'application/json',
  225. 'Content-Type' => 'application/x-www-form-urlencoded',
  226. );
  227. $body = array(
  228. 'nameOrEmail' => $username,
  229. 'rawpw' => $password,
  230. );
  231. $result = curl_post($connectURL, $body, $headers);
  232. if (isset($result['content'])) {
  233. $json = json_decode($result['content'], true);
  234. if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
  235. return array(
  236. 'email' => $json['User']['Email'],
  237. 'image' => $json['User']['ImageUrl'],
  238. );
  239. }
  240. }
  241. }
  242. }
  243. return false;
  244. }
  245. // Pass credentials to Plex Backend
  246. function plugin_auth_plex($username, $password) {
  247. // Quick out
  248. $isAdmin = false;
  249. if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
  250. writeLog("success", "Admin: ".$username." authenticated as plex Admin");
  251. $isAdmin = true;
  252. }
  253. //Get User List
  254. $userURL = 'https://plex.tv/pms/friends/all';
  255. $userHeaders = array(
  256. 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD),
  257. );
  258. libxml_use_internal_errors(true);
  259. $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
  260. if (is_array($userXML) || is_object($userXML)) {
  261. $isUser = false;
  262. $usernameLower = strtolower($username);
  263. foreach($userXML AS $child) {
  264. if(isset($child['username']) && strtolower($child['username']) == $usernameLower || isset($child['email']) && strtolower($child['email']) == $usernameLower) {
  265. $isUser = true;
  266. writeLog("success", $usernameLower." was found in plex friends list");
  267. break;
  268. }
  269. }
  270. if ($isUser || $isAdmin) {
  271. //Login User
  272. $connectURL = 'https://plex.tv/users/sign_in.json';
  273. $headers = array(
  274. 'Accept'=> 'application/json',
  275. 'Content-Type' => 'application/x-www-form-urlencoded',
  276. 'X-Plex-Product' => 'Organizr',
  277. 'X-Plex-Version' => '1.0',
  278. 'X-Plex-Client-Identifier' => '01010101-10101010',
  279. );
  280. $body = array(
  281. 'user[login]' => $username,
  282. 'user[password]' => $password,
  283. );
  284. $result = curl_post($connectURL, $body, $headers);
  285. if (isset($result['content'])) {
  286. $json = json_decode($result['content'], true);
  287. if ((is_array($json) && isset($json['user']) && isset($json['user']['username'])) && strtolower($json['user']['username']) == $usernameLower || strtolower($json['user']['email']) == $usernameLower) {
  288. writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
  289. return array(
  290. 'email' => $json['user']['email'],
  291. 'image' => $json['user']['thumb'],
  292. 'token' => $json['user']['authToken'],
  293. 'type' => $isAdmin ? 'admin' : 'user',
  294. );
  295. }
  296. }else{
  297. writeLog("error", "error occured while trying to sign $username into plex");
  298. }
  299. }else{
  300. writeLog("error", "$username is not an authorized PLEX user or entered invalid password");
  301. }
  302. }else{
  303. writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");
  304. }
  305. return false;
  306. }
  307. else :
  308. // Plex Auth Missing Dependancy
  309. function plugin_auth_plex_disabled() {
  310. return 'Plex - Disabled (Dependancy: php-curl missing!)';
  311. }
  312. // Emby Connect Auth Missing Dependancy
  313. function plugin_auth_emby_connect_disabled() {
  314. return 'Emby Connect - Disabled (Dependancy: php-curl missing!)';
  315. }
  316. // Emby Both Auth Missing Dependancy
  317. function plugin_auth_emby_both_disabled() {
  318. return 'Emby Both - Disabled (Dependancy: php-curl missing!)';
  319. }
  320. endif;
  321. // ==== Auth Plugins END ====
  322. // ==== General Class Definitions START ====
  323. $userLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  324. class setLanguage {
  325. private $language = null;
  326. private $langCode = null;
  327. function __construct($language = false) {
  328. // Default
  329. if (!$language) {
  330. $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  331. }
  332. if (!file_exists("lang/{$language}.ini")) {
  333. $language = 'en';
  334. }
  335. $this->langCode = $language;
  336. $this->language = parse_ini_file("lang/{$language}.ini", false, INI_SCANNER_RAW);
  337. if (file_exists("lang/{$language}.cust.ini")) {
  338. foreach($tmp = parse_ini_file("lang/{$language}.cust.ini", false, INI_SCANNER_RAW) as $k => $v) {
  339. $this->language[$k] = $v;
  340. }
  341. }
  342. }
  343. public function getLang() {
  344. return $this->langCode;
  345. }
  346. public function translate($originalWord) {
  347. $getArg = func_num_args();
  348. if ($getArg > 1) {
  349. $allWords = func_get_args();
  350. array_shift($allWords);
  351. } else {
  352. $allWords = array();
  353. }
  354. $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null;
  355. if (!$translatedWord) {
  356. return ucwords(str_replace("_", " ", strtolower($originalWord)));
  357. //echo "WHOA!!!!!!! $originalWord";
  358. }
  359. $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES);
  360. return vsprintf($translatedWord, $allWords);
  361. }
  362. }
  363. $language = new setLanguage;
  364. // ==== General Class Definitions END ====
  365. // Direct request to curl if it exists, otherwise handle if not HTTPS
  366. function post_router($url, $data, $headers = array(), $referer='') {
  367. if (function_exists('curl_version')) {
  368. return curl_post($url, $data, $headers, $referer);
  369. } else {
  370. return post_request($url, $data, $headers, $referer);
  371. }
  372. }
  373. if (function_exists('curl_version')) :
  374. // Curl Post
  375. function curl_post($url, $data, $headers = array(), $referer='') {
  376. // Initiate cURL
  377. $curlReq = curl_init($url);
  378. // As post request
  379. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST");
  380. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  381. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  382. if(localURL($url)){
  383. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  384. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  385. }
  386. // Format Data
  387. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  388. case 'application/json':
  389. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  390. break;
  391. case 'application/x-www-form-urlencoded':
  392. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  393. break;
  394. default:
  395. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  396. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  397. }
  398. // Format Headers
  399. $cHeaders = array();
  400. foreach ($headers as $k => $v) {
  401. $cHeaders[] = $k.': '.$v;
  402. }
  403. if (count($cHeaders)) {
  404. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  405. }
  406. // Execute
  407. $result = curl_exec($curlReq);
  408. $httpcode = curl_getinfo($curlReq);
  409. // Close
  410. curl_close($curlReq);
  411. // Return
  412. return array('content'=>$result, 'http_code'=>$httpcode);
  413. }
  414. // Curl Put
  415. function curl_put($url, $data, $headers = array(), $referer='') {
  416. // Initiate cURL
  417. $curlReq = curl_init($url);
  418. // As post request
  419. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "PUT");
  420. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  421. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  422. if(localURL($url)){
  423. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  424. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  425. }
  426. // Format Data
  427. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  428. case 'application/json':
  429. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  430. break;
  431. case 'application/x-www-form-urlencoded':
  432. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  433. break;
  434. default:
  435. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  436. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  437. }
  438. // Format Headers
  439. $cHeaders = array();
  440. foreach ($headers as $k => $v) {
  441. $cHeaders[] = $k.': '.$v;
  442. }
  443. if (count($cHeaders)) {
  444. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  445. }
  446. // Execute
  447. $result = curl_exec($curlReq);
  448. $httpcode = curl_getinfo($curlReq);
  449. // Close
  450. curl_close($curlReq);
  451. // Return
  452. return array('content'=>$result, 'http_code'=>$httpcode);
  453. }
  454. //Curl Get Function
  455. function curl_get($url, $headers = array()) {
  456. // Initiate cURL
  457. $curlReq = curl_init($url);
  458. // As post request
  459. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET");
  460. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  461. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  462. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  463. if(localURL($url)){
  464. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  465. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  466. }
  467. // Format Headers
  468. $cHeaders = array();
  469. foreach ($headers as $k => $v) {
  470. $cHeaders[] = $k.': '.$v;
  471. }
  472. if (count($cHeaders)) {
  473. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  474. }
  475. // Execute
  476. $result = curl_exec($curlReq);
  477. // Close
  478. curl_close($curlReq);
  479. // Return
  480. return $result;
  481. }
  482. //Curl Delete Function
  483. function curl_delete($url, $headers = array()) {
  484. // Initiate cURL
  485. $curlReq = curl_init($url);
  486. // As post request
  487. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE");
  488. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  489. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  490. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  491. if(localURL($url)){
  492. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  493. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  494. }
  495. // Format Headers
  496. $cHeaders = array();
  497. foreach ($headers as $k => $v) {
  498. $cHeaders[] = $k.': '.$v;
  499. }
  500. if (count($cHeaders)) {
  501. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  502. }
  503. // Execute
  504. $result = curl_exec($curlReq);
  505. $httpcode = curl_getinfo($curlReq);
  506. // Close
  507. curl_close($curlReq);
  508. // Return
  509. return array('content'=>$result, 'http_code'=>$httpcode);
  510. }
  511. endif;
  512. //Case-Insensitive Function
  513. function in_arrayi($needle, $haystack) {
  514. return in_array(strtolower($needle), array_map('strtolower', $haystack));
  515. }
  516. // HTTP post request (Removes need for curl, probably useless)
  517. function post_request($url, $data, $headers = array(), $referer='') {
  518. // Adapted from http://stackoverflow.com/a/28387011/6810513
  519. // Convert the data array into URL Parameters like a=b&foo=bar etc.
  520. if (isset($headers['Content-Type'])) {
  521. switch ($headers['Content-Type']) {
  522. case 'application/json':
  523. $data = json_encode($data);
  524. break;
  525. case 'application/x-www-form-urlencoded':
  526. $data = http_build_query($data);
  527. break;
  528. }
  529. } else {
  530. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  531. $data = http_build_query($data);
  532. }
  533. // parse the given URL
  534. $urlDigest = parse_url($url);
  535. // extract host and path:
  536. $host = $urlDigest['host'];
  537. $path = $urlDigest['path'];
  538. if ($urlDigest['scheme'] != 'http') {
  539. die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')');
  540. }
  541. // open a socket connection on port 80 - timeout: 30 sec
  542. $fp = fsockopen($host, (isset($urlDigest['port'])?':'.$urlDigest['port']:80), $errno, $errstr, 30);
  543. if ($fp){
  544. // send the request headers:
  545. fputs($fp, "POST $path HTTP/1.1\r\n");
  546. fputs($fp, "Host: $host\r\n");
  547. if ($referer != '')
  548. fputs($fp, "Referer: $referer\r\n");
  549. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  550. foreach($headers as $k => $v) {
  551. fputs($fp, $k.": ".$v."\r\n");
  552. }
  553. fputs($fp, "Connection: close\r\n\r\n");
  554. fputs($fp, $data);
  555. $result = '';
  556. while(!feof($fp)) {
  557. // receive the results of the request
  558. $result .= fgets($fp, 128);
  559. }
  560. }
  561. else {
  562. return array(
  563. 'status' => 'err',
  564. 'error' => "$errstr ($errno)"
  565. );
  566. }
  567. // close the socket connection:
  568. fclose($fp);
  569. // split the result header from the content
  570. $result = explode("\r\n\r\n", $result, 2);
  571. $header = isset($result[0]) ? $result[0] : '';
  572. $content = isset($result[1]) ? $result[1] : '';
  573. // return as structured array:
  574. return array(
  575. 'status' => 'ok',
  576. 'header' => $header,
  577. 'content' => $content,
  578. );
  579. }
  580. // Format item from Emby for Carousel
  581. function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $moreInfo = false) {
  582. // Static Height
  583. $height = 444;
  584. // Get Item Details
  585. $itemDetails = json_decode(@file_get_contents($address.'/Items?Ids='.$item['Id'].'&api_key='.$token),true)['Items'][0];
  586. /*if (substr_count(EMBYURL, ':') == 2) {
  587. $URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  588. }else{
  589. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  590. }*/
  591. $URL = EMBYURL."/web/#!/itemdetails.html?id=".$itemDetails['Id'];
  592. switch ($itemDetails['Type']) {
  593. case 'Episode':
  594. case 'Series':
  595. $title = (isset($itemDetails['SeriesName'])?$itemDetails['SeriesName']:"");
  596. $imageId = (isset($itemDetails['SeriesId'])?$itemDetails['SeriesId']:$itemDetails['Id']);
  597. $width = 300;
  598. $style = '';
  599. $image = 'slick-image-tall';
  600. if(!$nowPlaying){
  601. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  602. $key = $itemDetails['Id'] . "-list";
  603. $itemType = 'season';
  604. }else{
  605. $height = 281;
  606. $width = 500;
  607. $imageId = isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId'] : (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  608. $imageType = isset($itemDetails['ParentThumbItemId']) ? "Thumb" : (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  609. $key = (isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId']."-np" : "none-np");
  610. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  611. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  612. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  613. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  614. $stream = $moreInfo['PlayState']['PlayMethod'];
  615. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  616. $id = $moreInfo['DeviceId'];
  617. $streamInfo = buildStream(array(
  618. 'platform' => (string) $moreInfo['Client'],
  619. 'device' => (string) $moreInfo['DeviceName'],
  620. 'stream' => streamType($stream),
  621. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  622. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  623. ));
  624. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  625. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$itemDetails['Name'].'</h5>';
  626. $bottomTitle = '<small class="zero-m">S'.$itemDetails['ParentIndexNumber'].' · E'.$itemDetails['IndexNumber'].'</small>';
  627. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  628. }
  629. break;
  630. case 'MusicAlbum':
  631. case 'Audio':
  632. $title = $itemDetails['Name'];
  633. $imageId = $itemDetails['Id'];
  634. $width = 444;
  635. $style = '';
  636. $image = 'slick-image-short';
  637. if(!$nowPlaying){
  638. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  639. $key = $itemDetails['Id'] . "-list";
  640. $itemType = 'album';
  641. }else{
  642. $height = 281;
  643. $width = 500;
  644. $imageId = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  645. $imageType = (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  646. $key = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : "no-np") . "-np";
  647. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  648. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  649. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  650. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  651. $stream = $moreInfo['PlayState']['PlayMethod'];
  652. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  653. $id = $moreInfo['DeviceId'];
  654. $streamInfo = buildStream(array(
  655. 'platform' => (string) $moreInfo['Client'],
  656. 'device' => (string) $moreInfo['DeviceName'],
  657. 'stream' => streamType($stream),
  658. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  659. ));
  660. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  661. $topTitle = '<h5 class="text-center zero-m elip">'.$itemDetails['AlbumArtist'].' - '.$itemDetails['Album'].'</h5>';
  662. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  663. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  664. }
  665. break;
  666. case 'TvChannel':
  667. $title = $itemDetails['CurrentProgram']['Name'];
  668. $imageId = $itemDetails['Id'];
  669. $width = 300;
  670. $style = '';
  671. $image = 'slick-image-tall';
  672. if(!$nowPlaying){
  673. $imageType = "Primary";
  674. $key = $itemDetails['Id'] . "-list";
  675. }else{
  676. $height = 281;
  677. $width = 500;
  678. $imageType = "Thumb";
  679. $key = $itemDetails['Id'] . "-np";
  680. $useImage = "images/livetv.png";
  681. $watched = "0";
  682. $stream = $moreInfo['PlayState']['PlayMethod'];
  683. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  684. $id = $moreInfo['DeviceId'];
  685. $streamInfo = buildStream(array(
  686. 'platform' => (string) $moreInfo['Client'],
  687. 'device' => (string) $moreInfo['DeviceName'],
  688. 'stream' => streamType($stream),
  689. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  690. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  691. ));
  692. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  693. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  694. $bottomTitle = '<small class="zero-m">'.$itemDetails['Name'].' - '.$itemDetails['ChannelNumber'].'</small>';
  695. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  696. }
  697. break;
  698. default:
  699. $title = $itemDetails['Name'];
  700. $imageId = $itemDetails['Id'];
  701. $width = 300;
  702. $style = '';
  703. $image = 'slick-image-tall';
  704. if(!$nowPlaying){
  705. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  706. $key = $itemDetails['Id'] . "-list";
  707. $itemType = 'movie';
  708. }else{
  709. $height = 281;
  710. $width = 500;
  711. $imageType = isset($itemDetails['ImageTags']['Thumb']) ? "Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
  712. $key = $itemDetails['Id'] . "-np";
  713. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  714. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  715. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  716. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  717. $stream = $moreInfo['PlayState']['PlayMethod'];
  718. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  719. $id = $moreInfo['DeviceId'];
  720. $streamInfo = buildStream(array(
  721. 'platform' => (string) $moreInfo['Client'],
  722. 'device' => (string) $moreInfo['DeviceName'],
  723. 'stream' => streamType($stream),
  724. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  725. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  726. ));
  727. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  728. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  729. $bottomTitle = '<small class="zero-m">'.$moreInfo['NowPlayingItem']['ProductionYear'].'</small>';
  730. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  731. }
  732. }
  733. // If No Overview
  734. if (!isset($itemDetails['Overview'])) {
  735. $itemDetails['Overview'] = '';
  736. }
  737. $original_image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  738. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  739. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  740. $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'';
  741. }
  742. if($nowPlaying){
  743. if(!$imageType){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  744. if(!$imageId){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  745. }else{
  746. if(!$imageType){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  747. if(!$imageId){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  748. }
  749. if(isset($useImage)){ $image_url = $useImage; }
  750. // Assemble Item And Cache Into Array
  751. if($nowPlaying){
  752. //prettyPrint($itemDetails);
  753. return '<div class="col-sm-6 col-md-3"><div class="thumbnail ultra-widget"><div style="display: none;" np="'.$id.'" class="overlay content-box small-box gray-bg">'.$streamInfo.'</div><span class="refreshNP w-refresh w-p-icon gray" link="'.$id.'"><span class="fa-stack fa-lg" style="font-size: .5em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-info-circle fa-stack-1x fa-inverse"></i></span></span><a href="'.$URL.'" target="_blank"><img style="width: 100%; display:inherit;" src="'.$image_url.'" alt="'.$itemDetails['Name'].'" original-image="'.$original_image_url.'" class="refreshImageSource"></a><div class="progress progress-bar-sm zero-m"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$watched.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$watched.'%"></div><div class="progress-bar palette-Grey-500 bg" style="width: 0%"></div></div><div class="caption"><i style="float:left" class="fa fa-'.$state.'"></i>'.$topTitle.''.$bottomTitle.'</div></div></div>';
  754. }else{
  755. return '<div class="item-'.$itemType.'"><div class="ultra-widget refreshImage"><span class="w-refresh w-p-icon gray"><span class="fa-stack fa-lg" style="font-size: .4em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-refresh fa-stack-1x fa-inverse"></i></span></span></div><a href="'.$URL.'" target="_blank"><img alt="'.$itemDetails['Name'].'" class="'.$image.' refreshImageSource" data-lazy="'.$image_url.'" original-image="'.$original_image_url.'"></a><small class="elip slick-bottom-title">'.$title.'</small></div>';
  756. }
  757. }
  758. // Format item from Plex for Carousel
  759. function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $playlist = false) {
  760. // Static Height
  761. $height = 444;
  762. $widthOverride = 100;
  763. $playlist = ($playlist) ? " playlist-$playlist" : "";
  764. switch ($item['type']) {
  765. case 'season':
  766. $title = $item['parentTitle'];
  767. $summary = $item['parentSummary'];
  768. $width = 300;
  769. $image = 'slick-image-tall';
  770. $style = '';
  771. if(!$nowPlaying){
  772. $thumb = $item['thumb'];
  773. $key = $item['ratingKey'] . "-list";
  774. }else {
  775. $height = 281;
  776. $width = 500;
  777. $thumb = $item['art'];
  778. $key = $item['ratingKey'] . "-np";
  779. $elapsed = $item['viewOffset'];
  780. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  781. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  782. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  783. $stream = $item->Media->Part->Stream['decision'];
  784. $user = $role == "admin" ? $item->User['title'] : "";
  785. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  786. $streamInfo = buildStream(array(
  787. 'platform' => (string) $item->Player['platform'],
  788. 'device' => (string) $item->Player['device'],
  789. 'stream' => streamType($item->Media->Part['decision']),
  790. 'video' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['width']."x".$item->Media->Part->Stream[0]['height'].")",
  791. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  792. ));
  793. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  794. }
  795. break;
  796. case 'episode':
  797. $title = $item['grandparentTitle'];
  798. $summary = $item['title'];
  799. $width = 300;
  800. $image = 'slick-image-tall';
  801. $style = '';
  802. if(!$nowPlaying){
  803. $thumb = ($item['parentThumb'] ? $item['parentThumb'] : $item['grandparentThumb']);
  804. $key = $item['ratingKey'] . "-list";
  805. }else {
  806. $height = 281;
  807. $width = 500;
  808. $thumb = $item['art'];
  809. $key = $item['ratingKey'] . "-np";
  810. $elapsed = $item['viewOffset'];
  811. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  812. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  813. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  814. $stream = $item->Media->Part->Stream['decision'];
  815. $user = $role == "admin" ? $item->User['title'] : "";
  816. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  817. $streamInfo = buildStream(array(
  818. 'platform' => (string) $item->Player['platform'],
  819. 'device' => (string) $item->Player['device'],
  820. 'stream' => streamType($item->Media->Part['decision']),
  821. 'video' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['width']."x".$item->Media->Part->Stream[0]['height'].")",
  822. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  823. ));
  824. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  825. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$item['title'].'</h5>';
  826. $bottomTitle = '<small class="zero-m">S'.$item['parentIndex'].' · E'.$item['index'].'</small>';
  827. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  828. }
  829. break;
  830. case 'clip':
  831. $title = $item['title'];
  832. $summary = $item['summary'];
  833. $width = 300;
  834. $image = 'slick-image-tall';
  835. $style = '';
  836. if(!$nowPlaying){
  837. $thumb = $item['thumb'];
  838. $key = $item['ratingKey'] . "-list";
  839. }else {
  840. $height = 281;
  841. $width = 500;
  842. $thumb = $item['art'];
  843. $key = isset($item['ratingKey']) ? $item['ratingKey'] . "-np" : (isset($item['live']) ? "livetv.png" : ":)");
  844. $useImage = (isset($item['live']) ? "images/livetv.png" : null);
  845. $extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
  846. $elapsed = $item['viewOffset'];
  847. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  848. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  849. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  850. $stream = $item->Media->Part->Stream['decision'];
  851. $user = $role == "admin" ? $item->User['title'] : "";
  852. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  853. $streamInfo = buildStream(array(
  854. 'platform' => (string) $item->Player['platform'],
  855. 'device' => (string) $item->Player['device'],
  856. 'stream' => streamType($item->Media->Part['decision']),
  857. 'video' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['width']."x".$item->Media->Part->Stream[0]['height'].")",
  858. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  859. ));
  860. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  861. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  862. $bottomTitle = '<small class="zero-m">'.$extraInfo.'</small>';
  863. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  864. }
  865. break;
  866. case 'album':
  867. case 'track':
  868. $title = $item['parentTitle'];
  869. $summary = $item['title'];
  870. $image = 'slick-image-short';
  871. $style = 'left: 160px !important;';
  872. $item['ratingKey'] = $item['parentRatingKey'];
  873. if(!$nowPlaying){
  874. $width = 444;
  875. $thumb = $item['thumb'];
  876. $key = $item['ratingKey'] . "-list";
  877. }else {
  878. $height = 281;
  879. $width = 500;
  880. $thumb = ($item['parentThumb']) ? $item['parentThumb'] : $item['art'];
  881. $widthOverride = ($item['parentThumb']) ? 56 : 100;
  882. $key = $item['ratingKey'] . "-np";
  883. $elapsed = $item['viewOffset'];
  884. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  885. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  886. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  887. $stream = $item->Media->Part->Stream['decision'];
  888. $user = $role == "admin" ? $item->User['title'] : "";
  889. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  890. $streamInfo = buildStream(array(
  891. 'platform' => (string) $item->Player['platform'],
  892. 'device' => (string) $item->Player['device'],
  893. 'stream' => streamType($item->Media->Part['decision']),
  894. 'audio' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['channels']."ch)",
  895. ));
  896. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  897. $topTitle = '<h5 class="text-center zero-m elip">'.$item['grandparentTitle'].' - '.$item['title'].'</h5>';
  898. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  899. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  900. }
  901. break;
  902. default:
  903. $title = $item['title'];
  904. $summary = $item['summary'];
  905. $image = 'slick-image-tall';
  906. $style = '';
  907. if(!$nowPlaying){
  908. $width = 300;
  909. $thumb = $item['thumb'];
  910. $key = $item['ratingKey'] . "-list";
  911. }else {
  912. $height = 281;
  913. $width = 500;
  914. $thumb = $item['art'];
  915. $key = $item['ratingKey'] . "-np";
  916. $elapsed = $item['viewOffset'];
  917. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  918. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  919. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  920. $stream = $item->Media->Part->Stream['decision'];
  921. $user = $role == "admin" ? $item->User['title'] : "";
  922. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  923. $streamInfo = buildStream(array(
  924. 'platform' => (string) $item->Player['platform'],
  925. 'device' => (string) $item->Player['device'],
  926. 'stream' => streamType($item->Media->Part['decision']),
  927. 'video' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['width']."x".$item->Media->Part->Stream[0]['height'].")",
  928. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  929. ));
  930. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  931. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  932. $bottomTitle = '<small class="zero-m">'.$item['year'].'</small>';
  933. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  934. }
  935. }
  936. if (PLEXTABURL) {
  937. $address = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  938. }else{
  939. $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  940. }
  941. // If No Overview
  942. if (!isset($itemDetails['Overview'])) { $itemDetails['Overview'] = ''; }
  943. $original_image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  944. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  945. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  946. $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'';
  947. }
  948. if($nowPlaying){
  949. if(!$thumb){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  950. }else{
  951. if(!$thumb){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  952. }
  953. if(isset($useImage)){ $image_url = $useImage; }
  954. $openTab = (PLEXTABNAME) ? "true" : "false";
  955. // Assemble Item And Cache Into Array
  956. if($nowPlaying){
  957. $musicOverlay = ($widthOverride == 56) ? '<img class="" style="width: 55%;display:block;position: absolute;top: 4px;left:5px;overflow: hidden;filter: blur(0px) grayscale(1);" src="'.$image_url.'">
  958. <img class="" style="width: 55%;display:block;position: absolute;top: 4px;right:5px;overflow: hidden;filter: blur(0px) grayscale(1);" src="'.$image_url.'">' : '';
  959. 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">'.$musicOverlay.'<img class="refreshImageSource" style="width: '.$widthOverride.'%; display:block; position: relative" 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>';
  960. }else{
  961. 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>';
  962. }
  963. }
  964. //$hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  965. //Recent Added
  966. function outputRecentAdded($header, $items, $script = false, $array, $type) {
  967. $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">';
  968. if(preg_grep("/item-movie/", $items)){
  969. $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>';
  970. }
  971. if(preg_grep("/item-season/", $items)){
  972. $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>';
  973. }
  974. if(preg_grep("/item-album/", $items)){
  975. $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>';
  976. }
  977. $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>';
  978. $hideMenu .= '</ul></div></div>';
  979. // If None Populate Empty Item
  980. if (!count($items)) {
  981. 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>';
  982. }else{
  983. $className = str_replace(' ', '', $header.' on '.$type);
  984. return '<div id="recentMedia'.$type.'" class="content-box box-shadow big-box"><h5 id="recentContent-title-'.$type.'" style="margin-bottom: -20px" class="text-center"><span>'.$header.'</span></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>':'');
  985. }
  986. }
  987. // Create Carousel
  988. function outputNowPlaying($header, $size, $type, $items, $script = false) {
  989. // If None Populate Empty Item
  990. if (!count($items)) {
  991. return '<div id="'.$type.'"></div>'.($script?'<script>'.$script.'</script>':'');
  992. }else{
  993. return '<div id="'.$type.'"><h5 class="zero-m big-box"><strong>'.$header.'</strong></h5>'.implode('',$items).'</div>'.($script?'<script>'.$script.'</script>':'');
  994. }
  995. }
  996. // Get Now Playing Streams From Emby
  997. function getEmbyStreams($size, $showNames, $role) {
  998. $address = qualifyURL(EMBYURL);
  999. $api = json_decode(@file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
  1000. if (!is_array($api)) { return 'Could not load!'; }
  1001. $playingItems = array();
  1002. foreach($api as $key => $value) {
  1003. if (isset($value['NowPlayingItem'])) {
  1004. $playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem'], true, $showNames, $role, $value);
  1005. }
  1006. }
  1007. return outputNowPlaying(translate('PLAYING_NOW_ON_EMBY')." ( ".count($playingItems)." Streams )", $size, 'streams-emby', $playingItems, ajaxLoop('emby-streams',NOWPLAYINGREFRESH));
  1008. }
  1009. // Get Now Playing Streams From Plex
  1010. function getPlexStreams($size, $showNames, $role){
  1011. $address = qualifyURL(PLEXURL);
  1012. // Perform API requests
  1013. $api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
  1014. libxml_use_internal_errors(true);
  1015. $api = simplexml_load_string($api);
  1016. if (is_array($api) || is_object($api)){
  1017. if (!$api->head->title){
  1018. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  1019. if (!$getServer) { return 'Could not load!'; }
  1020. // Identify the local machine
  1021. $gotServer = $getServer['machineIdentifier'];
  1022. $items = array();
  1023. foreach($api AS $child) {
  1024. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
  1025. }
  1026. return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." ( ".count($items)." Streams )", $size, 'streams-plex', $items, ajaxLoop('plex-streams',NOWPLAYINGREFRESH));
  1027. }else{
  1028. writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
  1029. }
  1030. }else{
  1031. writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
  1032. }
  1033. }
  1034. // Get Recent Content From Emby
  1035. function getEmbyRecent($array) {
  1036. $address = qualifyURL(EMBYURL);
  1037. $header = translate('RECENT_CONTENT');
  1038. // Currently Logged In User
  1039. $username = false;
  1040. if (isset($GLOBALS['USER'])) {
  1041. $username = strtolower($GLOBALS['USER']->username);
  1042. }
  1043. // Get A User
  1044. $userIds = json_decode(@file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
  1045. if (!is_array($userIds)) { return 'Could not load!'; }
  1046. $showPlayed = true;
  1047. foreach ($userIds as $value) { // Scan for admin user
  1048. if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
  1049. $userId = $value['Id'];
  1050. }
  1051. if ($username && strtolower($value['Name']) == $username) {
  1052. $userId = $value['Id'];
  1053. $showPlayed = false;
  1054. break;
  1055. }
  1056. }
  1057. // Get the latest Items
  1058. $latest = json_decode(@file_get_contents($address.'/Users/'.$userId.'/Items/Latest?EnableImages=false&Limit='.EMBYRECENTITEMS.'&api_key='.EMBYTOKEN.($showPlayed?'':'&IsPlayed=false')),true);
  1059. // For Each Item In Category
  1060. $items = array();
  1061. foreach ($latest as $k => $v) {
  1062. $type = (string) $v['Type'];
  1063. if(@$array[$type] == "true"){
  1064. $items[] = resolveEmbyItem($address, EMBYTOKEN, $v, false, false, false);
  1065. }
  1066. }
  1067. $array["movie"] = $array["Movie"];
  1068. $array["season"] = $array["Episode"];
  1069. $array["album"] = $array["MusicAlbum"];
  1070. unset($array["Movie"]);
  1071. unset($array["Episode"]);
  1072. unset($array["MusicAlbum"]);
  1073. unset($array["Series"]);
  1074. return outputRecentAdded($header, $items, ajaxLoop('emby-recent',RECENTREFRESH,'loadSlick();'), $array, 'Emby');
  1075. }
  1076. // Get Recent Content From Plex
  1077. function getPlexRecent($array){
  1078. $address = qualifyURL(PLEXURL);
  1079. $header = translate('RECENT_CONTENT');
  1080. // Perform Requests
  1081. $api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN);
  1082. libxml_use_internal_errors(true);
  1083. $api = simplexml_load_string($api);
  1084. if (is_array($api) || is_object($api)){
  1085. if (!$api->head->title){
  1086. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  1087. if (!$getServer) { return 'Could not load!'; }
  1088. // Identify the local machine
  1089. $gotServer = $getServer['machineIdentifier'];
  1090. $items = array();
  1091. foreach($api AS $child) {
  1092. $type = (string) $child['type'];
  1093. if($array[$type] == "true"){
  1094. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
  1095. }
  1096. }
  1097. return outputRecentAdded($header, $items, ajaxLoop('plex-recent',RECENTREFRESH,'loadSlick();'), $array, 'Plex');
  1098. }else{
  1099. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check token - if HTTPS, is cert valid");
  1100. }
  1101. }else{
  1102. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check URL - if HTTPS, is cert valid");
  1103. }
  1104. }
  1105. // Get Image From Emby
  1106. function getEmbyImage() {
  1107. $refresh = false;
  1108. $embyAddress = qualifyURL(EMBYURL);
  1109. if (!file_exists('images/cache')) {
  1110. mkdir('images/cache', 0777, true);
  1111. }
  1112. $itemId = $_GET['img'];
  1113. $key = $_GET['key'];
  1114. if(strpos($key, '$') !== false){
  1115. $key = explode('$', $key)[0];
  1116. $refresh = true;
  1117. }
  1118. $itemType = $_GET['type'];
  1119. $imgParams = array();
  1120. if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
  1121. if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
  1122. if(isset($itemId)) {
  1123. $image_src = $embyAddress . '/Items/'.$itemId.'/Images/'.$itemType.'?'.implode('&', $imgParams);
  1124. $cachefile = 'images/cache/'.$key.'.jpg';
  1125. $cachetime = 604800;
  1126. // Serve from the cache if it is younger than $cachetime
  1127. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh !== true) {
  1128. header("Content-type: image/jpeg");
  1129. @readfile($cachefile);
  1130. exit;
  1131. }
  1132. ob_start(); // Start the output buffer
  1133. header('Content-type: image/jpeg');
  1134. //@readfile($image_src);
  1135. echo @curl_get($image_src);
  1136. // Cache the output to a file
  1137. $fp = fopen($cachefile, 'wb');
  1138. fwrite($fp, ob_get_contents());
  1139. fclose($fp);
  1140. ob_end_flush(); // Send the output to the browser
  1141. die();
  1142. } else {
  1143. debug_out('Invalid Request',1);
  1144. }
  1145. }
  1146. // Get Image From Plex
  1147. function getPlexImage() {
  1148. $refresh = false;
  1149. $plexAddress = qualifyURL(PLEXURL);
  1150. if (!file_exists('images/cache')) {
  1151. mkdir('images/cache', 0777, true);
  1152. }
  1153. $image_url = $_GET['img'];
  1154. $key = $_GET['key'];
  1155. if(strpos($key, '$') !== false){
  1156. $key = explode('$', $key)[0];
  1157. $refresh = true;
  1158. }
  1159. $image_height = $_GET['height'];
  1160. $image_width = $_GET['width'];
  1161. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  1162. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  1163. $cachefile = 'images/cache/'.$key.'.jpg';
  1164. $cachetime = 604800;
  1165. // Serve from the cache if it is younger than $cachetime
  1166. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh == false) {
  1167. header("Content-type: image/jpeg");
  1168. @readfile($cachefile);
  1169. exit;
  1170. }
  1171. ob_start(); // Start the output buffer
  1172. header('Content-type: image/jpeg');
  1173. //@readfile($image_src);
  1174. echo @curl_get($image_src);
  1175. // Cache the output to a file
  1176. $fp = fopen($cachefile, 'wb');
  1177. fwrite($fp, ob_get_contents());
  1178. fclose($fp);
  1179. ob_end_flush(); // Send the output to the browser
  1180. die();
  1181. } else {
  1182. echo "Invalid Plex Request";
  1183. }
  1184. }
  1185. // Simplier access to class
  1186. function translate($string) {
  1187. if (isset($GLOBALS['language'])) {
  1188. return $GLOBALS['language']->translate($string);
  1189. } else {
  1190. return '!Translations Not Loaded!';
  1191. }
  1192. }
  1193. // Generate Random string
  1194. function randString($length = 10, $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  1195. $tmp = '';
  1196. for ($i = 0; $i < $length; $i++) {
  1197. $tmp .= substr(str_shuffle($chars), 0, 1);
  1198. }
  1199. return $tmp;
  1200. }
  1201. // Create config file in the return syntax
  1202. function createConfig($array, $path = 'config/config.php', $nest = 0) {
  1203. // Define Initial Value
  1204. $output = array();
  1205. // Sort Items
  1206. ksort($array);
  1207. // Update the current config version
  1208. if (!$nest) {
  1209. // Inject Current Version
  1210. $output[] = "\t'CONFIG_VERSION' => '".(isset($array['apply_CONFIG_VERSION'])?$array['apply_CONFIG_VERSION']:INSTALLEDVERSION)."'";
  1211. }
  1212. unset($array['CONFIG_VERSION']);
  1213. unset($array['apply_CONFIG_VERSION']);
  1214. // Process Settings
  1215. foreach ($array as $k => $v) {
  1216. $allowCommit = true;
  1217. switch (gettype($v)) {
  1218. case 'boolean':
  1219. $item = ($v?'true':'false');
  1220. break;
  1221. case 'integer':
  1222. case 'double':
  1223. case 'integer':
  1224. case 'NULL':
  1225. $item = $v;
  1226. break;
  1227. case 'string':
  1228. $item = "'".str_replace(array('\\',"'"),array('\\\\',"\'"),$v)."'";
  1229. break;
  1230. case 'array':
  1231. $item = createConfig($v, false, $nest+1);
  1232. break;
  1233. default:
  1234. $allowCommit = false;
  1235. }
  1236. if($allowCommit) {
  1237. $output[] = str_repeat("\t",$nest+1)."'$k' => $item";
  1238. }
  1239. }
  1240. // Build output
  1241. $output = (!$nest?"<?php\nreturn ":'')."array(\n".implode(",\n",$output)."\n".str_repeat("\t",$nest).')'.(!$nest?';':'');
  1242. if (!$nest && $path) {
  1243. $pathDigest = pathinfo($path);
  1244. @mkdir($pathDigest['dirname'], 0770, true);
  1245. if (file_exists($path)) {
  1246. rename($path, $pathDigest['dirname'].'/'.$pathDigest['filename'].'.bak.php');
  1247. }
  1248. $file = fopen($path, 'w');
  1249. fwrite($file, $output);
  1250. fclose($file);
  1251. if (file_exists($path)) {
  1252. return true;
  1253. }
  1254. writeLog("error", "config was unable to write");
  1255. return false;
  1256. } else {
  1257. writeLog("success", "config was updated with new values");
  1258. return $output;
  1259. }
  1260. }
  1261. // Load a config file written in the return syntax
  1262. function loadConfig($path = 'config/config.php') {
  1263. // Adapted from http://stackoverflow.com/a/14173339/6810513
  1264. if (!is_file($path)) {
  1265. return null;
  1266. } else {
  1267. return (array) call_user_func(function() use($path) {
  1268. return include($path);
  1269. });
  1270. }
  1271. }
  1272. // Commit new values to the configuration
  1273. function updateConfig($new, $current = false) {
  1274. // Get config if not supplied
  1275. if ($current === false) {
  1276. $current = loadConfig();
  1277. } else if (is_string($current) && is_file($current)) {
  1278. $current = loadConfig($current);
  1279. }
  1280. // Inject Parts
  1281. foreach ($new as $k => $v) {
  1282. $current[$k] = $v;
  1283. }
  1284. // Return Create
  1285. return createConfig($current);
  1286. }
  1287. // Inject Defaults As Needed
  1288. function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
  1289. if (is_string($path)) {
  1290. $loadedDefaults = loadConfig($path);
  1291. } else {
  1292. $loadedDefaults = $path;
  1293. }
  1294. return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
  1295. }
  1296. // support function for fillDefaultConfig()
  1297. function fillDefaultConfig_recurse($current, $defaults) {
  1298. foreach($defaults as $k => $v) {
  1299. if (!isset($current[$k])) {
  1300. $current[$k] = $v;
  1301. } else if (is_array($current[$k]) && is_array($v)) {
  1302. $current[$k] = fillDefaultConfig_recurse($current[$k], $v);
  1303. }
  1304. }
  1305. return $current;
  1306. };
  1307. // Define Scalar Variables (nest non-secular with underscores)
  1308. function defineConfig($array, $anyCase = true, $nest_prefix = false) {
  1309. foreach($array as $k => $v) {
  1310. if (is_scalar($v) && !defined($nest_prefix.$k)) {
  1311. define($nest_prefix.$k, $v, $anyCase);
  1312. } else if (is_array($v)) {
  1313. defineConfig($v, $anyCase, $nest_prefix.$k.'_');
  1314. }
  1315. }
  1316. }
  1317. // This function exists only because I am lazy
  1318. function configLazy($path = 'config/config.php') {
  1319. // Load config or default
  1320. if (file_exists($path)) {
  1321. $config = fillDefaultConfig(loadConfig($path));
  1322. } else {
  1323. $config = loadConfig('config/configDefaults.php');
  1324. }
  1325. if (is_array($config)) {
  1326. defineConfig($config);
  1327. }
  1328. return $config;
  1329. }
  1330. // Qualify URL
  1331. function qualifyURL($url) {
  1332. //local address?
  1333. if(substr($url, 0,1) == "/"){
  1334. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  1335. $protocol = "https://";
  1336. } else {
  1337. $protocol = "http://";
  1338. }
  1339. $url = $protocol.getServer().$url;
  1340. }
  1341. // Get Digest
  1342. $digest = parse_url($url);
  1343. // http/https
  1344. if (!isset($digest['scheme'])) {
  1345. if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096,32400,7878,8989,8182,8081,6789))) {
  1346. $scheme = 'http';
  1347. } else {
  1348. $scheme = 'https';
  1349. }
  1350. } else {
  1351. $scheme = $digest['scheme'];
  1352. }
  1353. // Host
  1354. $host = (isset($digest['host'])?$digest['host']:'');
  1355. // Port
  1356. $port = (isset($digest['port'])?':'.$digest['port']:'');
  1357. // Path
  1358. $path = (isset($digest['path'])?$digest['path']:'');
  1359. // Output
  1360. return $scheme.'://'.$host.$port.$path;
  1361. }
  1362. // Function to be called at top of each to allow upgrading environment as the spec changes
  1363. function upgradeCheck() {
  1364. // Upgrade to 1.31
  1365. if (file_exists('homepageSettings.ini.php')) {
  1366. $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
  1367. $homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
  1368. $databaseConfig = array_merge($databaseConfig, $homepageConfig);
  1369. $databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
  1370. foreach($databaseConfig as $k => $v) {
  1371. if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
  1372. $databaseData .= $k . " = \"" . $v . "\"\r\n";
  1373. }
  1374. write_ini_file($databaseData, 'databaseLocation.ini.php');
  1375. unlink('homepageSettings.ini.php');
  1376. unset($databaseData);
  1377. unset($homepageConfig);
  1378. }
  1379. // Upgrade to 1.32
  1380. if (file_exists('databaseLocation.ini.php')) {
  1381. // Load Existing
  1382. $config = parse_ini_file('databaseLocation.ini.php', true);
  1383. // Refactor
  1384. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['databaseLocation'].'/');
  1385. $config['user_home'] = $config['database_Location'].'users/';
  1386. unset($config['databaseLocation']);
  1387. // Turn Off Emby And Plex Recent
  1388. $config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
  1389. unset($config["embyPort"]);
  1390. $config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
  1391. unset($config["plexPort"]);
  1392. $config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
  1393. unset($config["nzbgetPort"]);
  1394. $config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
  1395. unset($config["sabnzbdPort"]);
  1396. $config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
  1397. unset($config["headphonesPort"]);
  1398. // Write config file
  1399. $config['CONFIG_VERSION'] = '1.32';
  1400. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][pre1.32].bak.php');
  1401. $createConfigSuccess = createConfig($config);
  1402. // Create new config
  1403. if ($createConfigSuccess) {
  1404. if (file_exists('config/config.php')) {
  1405. // Remove Old ini file
  1406. unlink('databaseLocation.ini.php');
  1407. } else {
  1408. debug_out('Something is not right here!');
  1409. }
  1410. } else {
  1411. debug_out('Couldn\'t create updated configuration.' ,1);
  1412. }
  1413. }
  1414. // Upgrade to 1.33
  1415. $config = loadConfig();
  1416. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
  1417. // Fix User Directory
  1418. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['database_Location'].'/');
  1419. $config['user_home'] = $config['database_Location'].'users/';
  1420. unset($config['USER_HOME']);
  1421. // Backend auth merge
  1422. if (isset($config['authBackendPort']) && !isset(parse_url($config['authBackendHost'])['port'])) {
  1423. $config['authBackendHost'] .= ':'.$config['authBackendPort'];
  1424. }
  1425. unset($config['authBackendPort']);
  1426. // If auth is being used move it to embyURL as that is now used in auth functions
  1427. 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')))) {
  1428. $config['embyURL'] = $config['authBackendHost'];
  1429. }
  1430. // Upgrade database to latest version
  1431. updateSQLiteDB($config['database_Location'],'1.32');
  1432. // Update Version and Commit
  1433. $config['apply_CONFIG_VERSION'] = '1.33';
  1434. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.32].bak.php');
  1435. $createConfigSuccess = createConfig($config);
  1436. unset($config);
  1437. }
  1438. // Upgrade to 1.34
  1439. $config = loadConfig();
  1440. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.34')) {
  1441. // Upgrade database to latest version
  1442. updateSQLiteDB($config['database_Location'],'1.33');
  1443. // Update Version and Commit
  1444. $config['CONFIG_VERSION'] = '1.34';
  1445. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.33].bak.php');
  1446. $createConfigSuccess = createConfig($config);
  1447. unset($config);
  1448. }
  1449. // Upgrade to 1.40
  1450. $config = loadConfig();
  1451. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.40')) {
  1452. // Upgrade database to latest version
  1453. updateSQLiteDB($config['database_Location'],'1.38');
  1454. // Update Version and Commit
  1455. $config['CONFIG_VERSION'] = '1.40';
  1456. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.38].bak.php');
  1457. $createConfigSuccess = createConfig($config);
  1458. unset($config);
  1459. }
  1460. // Upgrade to 1.50
  1461. $config = loadConfig();
  1462. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.50')) {
  1463. // Upgrade database to latest version
  1464. updateSQLiteDB($config['database_Location'],'1.40');
  1465. // Update Version and Commit
  1466. $config['CONFIG_VERSION'] = '1.50';
  1467. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.40].bak.php');
  1468. $createConfigSuccess = createConfig($config);
  1469. unset($config);
  1470. }
  1471. // Upgrade to 1.603
  1472. $config = loadConfig();
  1473. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.603')) {
  1474. // Update Version and Commit
  1475. $config['CONFIG_VERSION'] = '1.603';
  1476. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.601].bak.php');
  1477. $createConfigSuccess = createConfig($config);
  1478. unset($config);
  1479. if(file_exists('org.log')){
  1480. copy('org.log', DATABASE_LOCATION.'org.log');
  1481. unlink('org.log');
  1482. }
  1483. if(file_exists('loginLog.json')){
  1484. copy('loginLog.json', DATABASE_LOCATION.'loginLog.json');
  1485. unlink('loginLog.json');
  1486. }
  1487. }
  1488. return true;
  1489. }
  1490. // Get OS from server
  1491. function getOS(){
  1492. if(PHP_SHLIB_SUFFIX == "dll"){
  1493. return "win";
  1494. }else{
  1495. return "nix";
  1496. }
  1497. }
  1498. //Get Error by Server OS
  1499. function getError($os, $error){
  1500. $ini = (!empty(php_ini_loaded_file()) ? php_ini_loaded_file() : "php.ini");
  1501. $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'");
  1502. $errors = array(
  1503. 'pdo_sqlite' => array(
  1504. 'win' => '<b>PDO:SQLite</b> not enabled, uncomment ;extension=php_pdo_sqlite.dll in the file php.ini | '.$ext,
  1505. 'nix' => '<b>PDO:SQLite</b> not enabled, PHP7 -> run sudo apt-get install php7.0-sqlite | PHP5 -> run sudo apt-get install php5-sqlite',
  1506. ),
  1507. 'sqlite3' => array(
  1508. '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',
  1509. 'nix' => '<b>SQLite3</b> not enabled, run sudo apt-get install php-sqlite3',
  1510. ),
  1511. 'curl' => array(
  1512. 'win' => '<b>cURL</b> not enabled, uncomment ;extension=php_curl.dll in the file php.ini | '.$ext,
  1513. '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',
  1514. ),
  1515. 'zip' => array(
  1516. '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',
  1517. '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',
  1518. ),
  1519. );
  1520. return (isset($errors[$error][$os]) ? $errors[$error][$os] : 'No Error Info Found');
  1521. }
  1522. // Check if all software dependancies are met
  1523. function dependCheck() {
  1524. $output = array();
  1525. $i = 1;
  1526. if (!extension_loaded('pdo_sqlite')) { $output["Step $i"] = getError(getOS(),'pdo_sqlite'); $i++; }
  1527. if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; }
  1528. if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; }
  1529. //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
  1530. if ($output) {
  1531. $output["Step $i"] = "<b>Restart PHP and/or Webserver to apply changes</b>"; $i++;
  1532. $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++;
  1533. debug_out($output,1);
  1534. }
  1535. return true;
  1536. }
  1537. // Process file uploads
  1538. function uploadFiles($path, $ext_mask = null) {
  1539. if (isset($_FILES) && count($_FILES)) {
  1540. require_once('class.uploader.php');
  1541. $uploader = new Uploader();
  1542. $data = $uploader->upload($_FILES['files'], array(
  1543. 'limit' => 10,
  1544. 'maxSize' => 10,
  1545. 'extensions' => $ext_mask,
  1546. 'required' => false,
  1547. 'uploadDir' => str_replace('//','/',$path.'/'),
  1548. 'title' => array('name'),
  1549. 'removeFiles' => true,
  1550. 'replace' => true,
  1551. ));
  1552. if($data['isComplete']){
  1553. $files = $data['data'];
  1554. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1555. echo json_encode($files['metas'][0]['name']);
  1556. }
  1557. if($data['hasErrors']){
  1558. $errors = $data['errors'];
  1559. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1560. echo json_encode($errors);
  1561. }
  1562. } else {
  1563. writeLog("error", "image was not uploaded");
  1564. echo json_encode('No files submitted!');
  1565. }
  1566. }
  1567. // Process file uploads
  1568. function uploadAvatar($path, $ext_mask = null) {
  1569. if (isset($_FILES) && count($_FILES)) {
  1570. require_once('class.uploader.php');
  1571. $uploader = new Uploader();
  1572. $data = $uploader->upload($_FILES['files'], array(
  1573. 'limit' => 10,
  1574. 'maxSize' => 10,
  1575. 'extensions' => $ext_mask,
  1576. 'required' => false,
  1577. 'uploadDir' => str_replace('//','/',$path.'/'),
  1578. 'title' => array('name'),
  1579. 'removeFiles' => true,
  1580. 'replace' => true,
  1581. ));
  1582. if($data['isComplete']){
  1583. $files = $data['data'];
  1584. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1585. echo json_encode($files['metas'][0]['name']);
  1586. }
  1587. if($data['hasErrors']){
  1588. $errors = $data['errors'];
  1589. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1590. echo json_encode($errors);
  1591. }
  1592. } else {
  1593. writeLog("error", "image was not uploaded");
  1594. echo json_encode('No files submitted!');
  1595. }
  1596. }
  1597. // Remove file
  1598. function removeFiles($path) {
  1599. if(is_file($path)) {
  1600. $fileType = getExtension($path);
  1601. if(in_arrayi($fileType, array('jpg','jpeg','png','json','db','gif'))){
  1602. writeLog("success", "file was removed");
  1603. unlink($path);
  1604. } else{
  1605. writeLog("error", "file was not removed");
  1606. echo json_encode('Invalid File Type');
  1607. }
  1608. } else {
  1609. writeLog("error", "file was not removed");
  1610. echo json_encode('No file specified for removal!');
  1611. }
  1612. }
  1613. // Lazy select options
  1614. function resolveSelectOptions($array, $selected = '', $multi = false) {
  1615. $output = array();
  1616. $selectedArr = ($multi?explode('|', $selected):array());
  1617. foreach ($array as $key => $value) {
  1618. if (is_array($value)) {
  1619. if (isset($value['optgroup'])) {
  1620. $output[] = '<optgroup label="'.$key.'">';
  1621. foreach($value['optgroup'] as $k => $v) {
  1622. $output[] = '<option value="'.$v['value'].'"'.($selected===$v['value']||in_array($v['value'],$selectedArr)?' selected':'').(isset($v['disabled']) && $v['disabled']?' disabled':'').'>'.$k.'</option>';
  1623. }
  1624. } else {
  1625. $output[] = '<option value="'.$value['value'].'"'.($selected===$value['value']||in_array($value['value'],$selectedArr)?' selected':'').(isset($value['disabled']) && $value['disabled']?' disabled':'').'>'.$key.'</option>';
  1626. }
  1627. } else {
  1628. $output[] = '<option value="'.$value.'"'.($selected===$value||in_array($value,$selectedArr)?' selected':'').'>'.$key.'</option>';
  1629. }
  1630. }
  1631. return implode('',$output);
  1632. }
  1633. // Check if user is allowed to continue
  1634. function qualifyUser($type, $errOnFail = false) {
  1635. if (!isset($GLOBALS['USER'])) {
  1636. require_once("user.php");
  1637. $GLOBALS['USER'] = new User('registration_callback');
  1638. }
  1639. if (is_bool($type)) {
  1640. if ($type === true) {
  1641. $authorized = ($GLOBALS['USER']->authenticated == true);
  1642. } else {
  1643. $authorized = true;
  1644. }
  1645. } elseif (is_string($type) || is_array($type)) {
  1646. if ($type !== 'false') {
  1647. if (!is_array($type)) {
  1648. $type = explode('|',$type);
  1649. }
  1650. $authorized = ($GLOBALS['USER']->authenticated && in_array($GLOBALS['USER']->role,$type));
  1651. } else {
  1652. $authorized = true;
  1653. }
  1654. } else {
  1655. debug_out('Invalid Syntax!',1);
  1656. }
  1657. if (!$authorized && $errOnFail) {
  1658. if ($GLOBALS['USER']->authenticated) {
  1659. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401');
  1660. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401\'</script>';
  1661. } else {
  1662. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999');
  1663. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999\'</script>';
  1664. }
  1665. debug_out('Not Authorized' ,1);
  1666. } else {
  1667. return $authorized;
  1668. }
  1669. }
  1670. // Build an (optionally) tabbed settings page.
  1671. function buildSettings($array) {
  1672. /*
  1673. array(
  1674. 'title' => '',
  1675. 'id' => '',
  1676. 'fields' => array( See buildField() ),
  1677. 'tabs' => array(
  1678. array(
  1679. 'title' => '',
  1680. 'id' => '',
  1681. 'image' => '',
  1682. 'fields' => array( See buildField() ),
  1683. ),
  1684. ),
  1685. );
  1686. */
  1687. $notifyExplode = explode("-", NOTIFYEFFECT);
  1688. $fieldFunc = function($fieldArr) {
  1689. $fields = '<div class="row">';
  1690. foreach($fieldArr as $key => $value) {
  1691. $isSingle = isset($value['type']);
  1692. if ($isSingle) { $value = array($value); }
  1693. $tmpField = '';
  1694. $sizeLg = max(floor(12/count($value)),2);
  1695. $sizeMd = max(floor(($isSingle?12:6)/count($value)),3);
  1696. foreach($value as $k => $v) {
  1697. $tmpField .= buildField($v, 12, $sizeMd, $sizeLg);
  1698. }
  1699. $fields .= ($isSingle?$tmpField:'<div class="row col-sm-12 content-form">'.$tmpField.'</div>');
  1700. }
  1701. $fields .= '</div>';
  1702. return $fields;
  1703. };
  1704. $fields = (isset($array['fields'])?$fieldFunc($array['fields']):'');
  1705. $tabSelectors = array();
  1706. $tabContent = array();
  1707. if (isset($array['tabs'])) {
  1708. foreach($array['tabs'] as $key => $value) {
  1709. $id = (isset($value['id'])?$value['id']:randString(32));
  1710. $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>';
  1711. $tabContent[$key] = '<div class="tab-pane big-box fade'.($tabContent?'':' active in').'" id="tab-'.$id.'">'.$fieldFunc($value['fields']).'</div>';
  1712. }
  1713. }
  1714. $pageID = (isset($array['id'])?$array['id']:str_replace(array(' ','"',"'"),array('_'),strtolower($array['id'])));
  1715. $extraClick = ($pageID == 'appearance_settings' ? "$('#advanced_settings_form_submit').click();console.log('add theme settings');" : "");
  1716. return '
  1717. <div class="email-body">
  1718. <div class="email-header gray-bg">
  1719. <button type="button" class="btn btn-danger btn-sm waves close-button"><i class="fa fa-close"></i></button>
  1720. <button id="'.$pageID.'_form_submit" class="btn waves btn-labeled btn-success btn btn-sm text-uppercase waves-effect waves-float save-btn-form">
  1721. <span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save
  1722. </button>
  1723. <h1>'.$array['title'].'</h1>
  1724. </div>
  1725. <div class="email-inner small-box">
  1726. <div class="email-inner-section">
  1727. <div class="small-box fade in" id="'.$pageID.'_frame">
  1728. <div class="col-lg-12">
  1729. '.(isset($array['customBeforeForm'])?$array['customBeforeForm']:'').'
  1730. <form class="content-form" name="'.$pageID.'" id="'.$pageID.'_form" onsubmit="return false;">
  1731. '.$fields.($tabContent?'
  1732. <div class="tabbable tabs-with-bg" id="'.$pageID.'_tabs">
  1733. <ul class="nav nav-tabs apps">
  1734. '.implode('', $tabSelectors).'
  1735. </ul>
  1736. <div class="clearfix"></div>
  1737. <div class="tab-content">
  1738. '.implode('', $tabContent).'
  1739. </div>
  1740. </div>':'').'
  1741. </form>
  1742. '.(isset($array['customAfterForm'])?$array['customAfterForm']:'').'
  1743. </div>
  1744. </div>
  1745. </div>
  1746. </div>
  1747. </div>
  1748. <script>
  1749. $(document).ready(function() {
  1750. $(\'#'.$pageID.'_form\').find(\'input, select, textarea\').on(\'change\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1751. var '.$pageID.'Validate = function() { if (this.value && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { $(this).addClass(\'invalid\'); } else { $(this).removeClass(\'invalid\'); } };
  1752. $(\'#'.$pageID.'_form\').find(\'input[pattern]\').each('.$pageID.'Validate).on(\'keyup\', '.$pageID.'Validate);
  1753. $(\'#'.$pageID.'_form\').find(\'select[multiple]\').on(\'change click\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1754. $(\'#'.$pageID.'_form_submit\').on(\'click\', function () {
  1755. var newVals = {};
  1756. var hasVals = false;
  1757. var errorFields = [];
  1758. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').each(function() {
  1759. hasVals = true;
  1760. if (this.type == \'checkbox\') {
  1761. newVals[this.name] = this.checked;
  1762. } else if ($(this).hasClass(\'summernote\')) {
  1763. newVals[$(this).attr(\'name\')] = $(this).siblings(\'.note-editor\').find(\'.panel-body\').html();
  1764. } else {
  1765. if (this.value && this.pattern && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { errorFields.push(this.name); }
  1766. var fieldVal = $(this).val();
  1767. if (typeof fieldVal == \'object\') {
  1768. if (typeof fieldVal.join == \'function\') {
  1769. fieldVal = fieldVal.join(\'|\');
  1770. } else {
  1771. fieldVal = JSON.stringify(fieldVal);
  1772. }
  1773. }
  1774. newVals[this.name] = fieldVal;
  1775. }
  1776. });
  1777. if (errorFields.length) {
  1778. parent.notify(\'Fields have errors: \'+errorFields.join(\', \')+\'!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1779. } else if (hasVals) {
  1780. console.log(newVals);
  1781. ajax_request(\'POST\', \''.(isset($array['submitAction'])?$array['submitAction']:'update-config').'\', newVals, function(data, code) {
  1782. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').removeAttr(\'data-changed\');
  1783. });
  1784. '.$extraClick.'
  1785. } else {
  1786. parent.notify(\'Nothing to update!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1787. }
  1788. return false;
  1789. });
  1790. '.(isset($array['onready'])?$array['onready']:'').'
  1791. });
  1792. </script>
  1793. ';
  1794. }
  1795. // Build Settings Fields
  1796. function buildField($params, $sizeSm = 12, $sizeMd = 12, $sizeLg = 12) {
  1797. /*
  1798. array(
  1799. 'type' => '',
  1800. 'placeholder' => '',
  1801. 'label' => '',
  1802. 'labelTranslate' => '',
  1803. 'assist' => '',
  1804. 'name' => '',
  1805. 'pattern' => '',
  1806. 'options' => array( // For SELECT only
  1807. 'Display' => 'value',
  1808. ),
  1809. )
  1810. */
  1811. // Tags
  1812. $tags = array();
  1813. foreach(array('placeholder','style','disabled','readonly','pattern','min','max','required','onkeypress','onchange','onfocus','onleave','href','onclick','autocomplete') as $value) {
  1814. if (isset($params[$value])) {
  1815. if (is_string($params[$value])) { $tags[] = $value.'="'.$params[$value].'"';
  1816. } else if ($params[$value] === true) { $tags[] = $value; }
  1817. }
  1818. }
  1819. $format = (isset($params['format']) && in_array($params['format'],array(false,'colour','color'))?$params['format']:false);
  1820. $name = (isset($params['name'])?$params['name']:(isset($params['id'])?$params['id']:''));
  1821. $id = (isset($params['id'])?$params['id']:(isset($params['name'])?$params['name'].'_id':randString(32)));
  1822. $val = (isset($params['value'])?$params['value']:'');
  1823. $class = (isset($params['class'])?' '.$params['class']:'');
  1824. $wrapClass = (isset($params['wrapClass'])?$params['wrapClass']:'form-content');
  1825. $assist = (isset($params['assist'])?' - i.e. '.$params['assist']:'');
  1826. $label = (isset($params['labelTranslate'])?translate($params['labelTranslate']):(isset($params['label'])?$params['label']:''));
  1827. $labelOut = '<p class="help-text">'.$label.$assist.'</p>';
  1828. // Field Design
  1829. switch ($params['type']) {
  1830. case 'text':
  1831. case 'number':
  1832. case 'password':
  1833. $field = '<input id="'.$id.'" name="'.$name.'" type="'.$params['type'].'" class="form-control material input-sm'.$class.'" '.implode(' ',$tags).' autocorrect="off" autocapitalize="off" value="'.$val.'">';
  1834. break;
  1835. case 'select':
  1836. case 'dropdown':
  1837. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control material input-sm" '.implode(' ',$tags).'>'.resolveSelectOptions($params['options'], $val).'</select>';
  1838. break;
  1839. case 'select-multi':
  1840. case 'dropdown-multi':
  1841. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control input-sm" '.implode(' ',$tags).' multiple="multiple">'.resolveSelectOptions($params['options'], $val, true).'</select>';
  1842. break;
  1843. case 'check':
  1844. case 'checkbox':
  1845. case 'toggle':
  1846. $checked = ((is_bool($val) && $val) || trim($val) === 'true'?' checked':'');
  1847. $colour = (isset($params['colour'])?$params['colour']:'success');
  1848. $labelOut = '<label for="'.$id.'"></label>'.$label;
  1849. $field = '<input id="'.$id.'" name="'.$name.'" type="checkbox" class="switcher switcher-'.$colour.' '.$class.'" '.implode(' ',$tags).' data-value="'.$val.'"'.$checked.'>';
  1850. break;
  1851. case 'radio':
  1852. $labelOut = '';
  1853. $checked = ((is_bool($val) && $val) || ($val && trim($val) !== 'false')?' checked':'');
  1854. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1855. $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>';
  1856. break;
  1857. case 'date':
  1858. $field = 'Unsupported, planned.';
  1859. break;
  1860. case 'hidden':
  1861. return '<input id="'.$id.'" name="'.$name.'" type="hidden" class="'.$class.'" '.implode(' ',$tags).' value="'.$val.'">';
  1862. break;
  1863. case 'header':
  1864. $labelOut = '';
  1865. $headType = (isset($params['value'])?$params['value']:3);
  1866. $field = '<h'.$headType.' class="'.$class.'" '.implode(' ',$tags).'>'.$label.'</h'.$headType.'>';
  1867. break;
  1868. case 'button':
  1869. $labelOut = '';
  1870. $icon = (isset($params['icon'])?$params['icon']:'flask');
  1871. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1872. $bDropdown = (isset($params['buttonDrop'])?$params['buttonDrop']:'');
  1873. $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>':'');
  1874. break;
  1875. case 'textarea':
  1876. $rows = (isset($params['rows'])?$params['rows']:5);
  1877. $field = '<textarea id="'.$id.'" name="'.$name.'" class="form-control'.$class.'" rows="'.$rows.'" '.implode(' ',$tags).'>'.$val.'</textarea>';
  1878. break;
  1879. case 'custom':
  1880. // Settings
  1881. $settings = array(
  1882. '$id' => $id,
  1883. '$name' => $name,
  1884. '$val' => $val,
  1885. '$label' => $label,
  1886. '$labelOut' => $labelOut,
  1887. );
  1888. // Get HTML
  1889. $html = (isset($params['html'])?$params['html']:'Nothing Specified!');
  1890. // If LabelOut is in html dont print it twice
  1891. $labelOut = (strpos($html,'$label')!==false?'':$labelOut);
  1892. // Replace variables in settings
  1893. $html = preg_replace_callback('/\$\w+\b/', function ($match) use ($settings) { return (isset($settings[$match[0]])?$settings[$match[0]]:'{'.$match[0].' is undefined}'); }, $html);
  1894. // Build Field
  1895. $field = '<div id="'.$id.'_html" class="custom-field">'.$html.'</div>';
  1896. break;
  1897. case 'space':
  1898. $labelOut = '';
  1899. $field = str_repeat('<br>', (isset($params['value'])?$params['value']:1));
  1900. break;
  1901. default:
  1902. $field = 'Unsupported field type';
  1903. break;
  1904. }
  1905. // Field Formats
  1906. switch ($format) {
  1907. case 'colour': // Fuckin Eh, Canada!
  1908. case 'color':
  1909. $labelBef = '<center>'.$label.'</center>';
  1910. $wrapClass = 'gray-bg colour-field';
  1911. $labelAft = '';
  1912. $field = str_replace(' material input-sm','',$field);
  1913. break;
  1914. default:
  1915. $labelBef = '';
  1916. $labelAft = $labelOut;
  1917. }
  1918. return '<div class="'.$wrapClass.' col-sm-'.$sizeSm.' col-md-'.$sizeMd.' col-lg-'.$sizeLg.'">'.$labelBef.$field.$labelAft.'</div>';
  1919. }
  1920. // Tab Settings Generation
  1921. function printTabRow($data) {
  1922. $hidden = false;
  1923. if ($data===false) {
  1924. $hidden = true;
  1925. $data = array( // New Tab Defaults
  1926. 'id' => 'new',
  1927. 'name' => '',
  1928. 'url' => '',
  1929. 'icon' => 'fa-diamond',
  1930. 'iconurl' => '',
  1931. 'active' => 'true',
  1932. 'user' => 'true',
  1933. 'guest' => 'true',
  1934. 'window' => 'false',
  1935. 'splash' => 'true',
  1936. 'ping' => 'false',
  1937. 'ping_url' => '',
  1938. 'defaultz' => '',
  1939. );
  1940. }
  1941. $image = '<span style="font: normal normal normal 30px/1 FontAwesome;" class="fa fa-hand-paper-o"></span>';
  1942. $output = '
  1943. <li id="tab-'.$data['id'].'" class="list-group-item" style="position: relative; left: 0px; top: 0px; '.($hidden?' display: none;':'').'">
  1944. <tab class="content-form form-inline">
  1945. <div class="row">
  1946. '.buildField(array(
  1947. 'type' => 'custom',
  1948. '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>',
  1949. ),12,1,1).'
  1950. '.buildField(array(
  1951. 'type' => 'hidden',
  1952. 'id' => 'tab-'.$data['id'].'-id',
  1953. 'name' => 'id['.$data['id'].']',
  1954. 'value' => $data['id'],
  1955. ),12,2,1).'
  1956. '.buildField(array(
  1957. 'type' => 'text',
  1958. 'id' => 'tab-'.$data['id'].'-name',
  1959. 'name' => 'name['.$data['id'].']',
  1960. 'required' => true,
  1961. 'placeholder' => 'Organizr Homepage',
  1962. 'labelTranslate' => 'TAB_NAME',
  1963. 'value' => $data['name'],
  1964. 'class' => 'darkBold',
  1965. ),12,2,1).'
  1966. '.buildField(array(
  1967. 'type' => 'text',
  1968. 'id' => 'tab-'.$data['id'].'-url',
  1969. 'name' => 'url['.$data['id'].']',
  1970. 'required' => true,
  1971. 'placeholder' => 'homepage.php',
  1972. 'labelTranslate' => 'TAB_URL',
  1973. 'value' => $data['url'],
  1974. 'class' => 'darkBold',
  1975. ),12,2,2).'
  1976. '.buildField(array(
  1977. 'type' => 'text',
  1978. 'id' => 'tab-'.$data['id'].'-iconurl',
  1979. 'name' => 'iconurl['.$data['id'].']',
  1980. 'placeholder' => 'images/organizr.png',
  1981. 'labelTranslate' => 'ICON_URL',
  1982. 'value' => $data['iconurl'],
  1983. 'class' => 'darkBold',
  1984. ),12,2,1).'
  1985. '.buildField(array(
  1986. 'type' => 'text',
  1987. 'id' => 'tab-'.$data['id'].'-icon',
  1988. 'name' => 'icon['.$data['id'].']',
  1989. 'placeholder' => 'fa-icon',
  1990. 'labelTranslate' => 'OR_ICON_NAME',
  1991. 'value' => $data['icon'],
  1992. 'class' => 'iconpickeradd darkBold',
  1993. ),12,1,1).'
  1994. '.buildField(array(
  1995. 'type' => 'text',
  1996. 'id' => 'tab-'.$data['id'].'-ping_url',
  1997. 'name' => 'ping_url['.$data['id'].']',
  1998. 'placeholder' => 'host:port',
  1999. 'labelTranslate' => 'PING_URL',
  2000. 'value' => $data['ping_url'],
  2001. 'class' => 'darkBold',
  2002. ),12,2,1).'
  2003. '.buildField(array(
  2004. 'type' => 'radio',
  2005. 'labelTranslate' => 'DEFAULT',
  2006. 'name' => 'defaultz['.$data['id'].']',
  2007. 'value' => $data['defaultz'],
  2008. 'onclick' => "$('[type=radio][id!=\''+this.id+'\']').each(function() { this.checked=false; });",
  2009. ),12,1,1).'
  2010. '.buildField(array(
  2011. 'type' => 'button',
  2012. 'icon' => 'chevron-down',
  2013. 'buttonType' => 'success',
  2014. 'labelTranslate' => 'MORE',
  2015. 'onclick' => "$(this).parent().parent().parent().find('.slideInUp').toggle()",
  2016. 'class' => 'toggleTabExtra',
  2017. ),12,1,1).'
  2018. '.buildField(array(
  2019. 'type' => 'button',
  2020. 'icon' => 'trash',
  2021. 'buttonType' => 'danger',
  2022. 'labelTranslate' => 'REMOVE',
  2023. 'onclick' => "$(this).parents('li').remove();",
  2024. ),12,1,1).'</div><div id = "tab-'.$data['id'].'-row" class = "row animated slideInUp" style = "display:none;" ><div></div>
  2025. '.buildField(array(
  2026. 'type' => 'checkbox',
  2027. 'labelTranslate' => 'ACTIVE',
  2028. 'name' => 'active['.$data['id'].']',
  2029. 'value' => $data['active'],
  2030. ),12,1,1).'
  2031. '.buildField(array(
  2032. 'type' => 'checkbox',
  2033. 'labelTranslate' => 'USER',
  2034. 'colour' => 'primary',
  2035. 'name' => 'user['.$data['id'].']',
  2036. 'value' => $data['user'],
  2037. ),12,1,1).'
  2038. '.buildField(array(
  2039. 'type' => 'checkbox',
  2040. 'labelTranslate' => 'GUEST',
  2041. 'colour' => 'warning',
  2042. 'name' => 'guest['.$data['id'].']',
  2043. 'value' => $data['guest'],
  2044. ),12,1,1).'
  2045. '.buildField(array(
  2046. 'type' => 'checkbox',
  2047. 'labelTranslate' => 'NO_IFRAME',
  2048. 'colour' => 'danger',
  2049. 'name' => 'window['.$data['id'].']',
  2050. 'value' => $data['window'],
  2051. ),12,1,1).'
  2052. '.buildField(array(
  2053. 'type' => 'checkbox',
  2054. 'labelTranslate' => 'SPLASH',
  2055. 'colour' => 'success',
  2056. 'name' => 'splash['.$data['id'].']',
  2057. 'value' => $data['splash'],
  2058. ),12,1,1).'
  2059. '.buildField(array(
  2060. 'type' => 'checkbox',
  2061. 'labelTranslate' => 'PING',
  2062. 'colour' => 'success',
  2063. 'name' => 'ping['.$data['id'].']',
  2064. 'value' => $data['ping'],
  2065. ),12,1,1).'
  2066. </div>
  2067. </tab>
  2068. </li>
  2069. ';
  2070. return $output;
  2071. }
  2072. // Timezone array
  2073. function timezoneOptions() {
  2074. $output = array();
  2075. $timezones = array();
  2076. $regions = array(
  2077. 'Africa' => DateTimeZone::AFRICA,
  2078. 'America' => DateTimeZone::AMERICA,
  2079. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2080. 'Arctic' => DateTimeZone::ARCTIC,
  2081. 'Asia' => DateTimeZone::ASIA,
  2082. 'Atlantic' => DateTimeZone::ATLANTIC,
  2083. 'Australia' => DateTimeZone::AUSTRALIA,
  2084. 'Europe' => DateTimeZone::EUROPE,
  2085. 'Indian' => DateTimeZone::INDIAN,
  2086. 'Pacific' => DateTimeZone::PACIFIC
  2087. );
  2088. foreach ($regions as $name => $mask) {
  2089. $zones = DateTimeZone::listIdentifiers($mask);
  2090. foreach($zones as $timezone) {
  2091. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2092. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2093. $output[$name]['optgroup'][substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm]['value'] = $timezone;
  2094. }
  2095. }
  2096. return $output;
  2097. }
  2098. // Build Database
  2099. function createSQLiteDB($path = false) {
  2100. if ($path === false) {
  2101. if (DATABASE_LOCATION){
  2102. $path = DATABASE_LOCATION;
  2103. } else {
  2104. debug_out('No Path Specified!');
  2105. }
  2106. }
  2107. if (!is_file($path.'users.db') || filesize($path.'users.db') <= 0) {
  2108. if (!isset($GLOBALS['file_db'])) {
  2109. $GLOBALS['file_db'] = new PDO('sqlite:'.$path.'users.db');
  2110. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2111. }
  2112. // Create Users
  2113. $users = $GLOBALS['file_db']->query('CREATE TABLE `users` (
  2114. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2115. `username` TEXT UNIQUE,
  2116. `password` TEXT,
  2117. `email` TEXT,
  2118. `token` TEXT,
  2119. `role` TEXT,
  2120. `active` TEXT,
  2121. `last` TEXT,
  2122. `auth_service` TEXT DEFAULT \'internal\'
  2123. );');
  2124. // Create Tabs
  2125. $tabs = $GLOBALS['file_db']->query('CREATE TABLE `tabs` (
  2126. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2127. `order` INTEGER,
  2128. `users_id` INTEGER,
  2129. `name` TEXT,
  2130. `url` TEXT,
  2131. `defaultz` TEXT,
  2132. `active` TEXT,
  2133. `user` TEXT,
  2134. `guest` TEXT,
  2135. `icon` TEXT,
  2136. `iconurl` TEXT,
  2137. `window` TEXT,
  2138. `splash` TEXT,
  2139. `ping` TEXT,
  2140. `ping_url` TEXT
  2141. );');
  2142. // Create Options
  2143. $options = $GLOBALS['file_db']->query('CREATE TABLE `options` (
  2144. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2145. `users_id` INTEGER UNIQUE,
  2146. `title` TEXT UNIQUE,
  2147. `topbar` TEXT,
  2148. `bottombar` TEXT,
  2149. `sidebar` TEXT,
  2150. `hoverbg` TEXT,
  2151. `topbartext` TEXT,
  2152. `activetabBG` TEXT,
  2153. `activetabicon` TEXT,
  2154. `activetabtext` TEXT,
  2155. `inactiveicon` TEXT,
  2156. `inactivetext` TEXT,
  2157. `loading` TEXT,
  2158. `hovertext` TEXT
  2159. );');
  2160. // Create Invites
  2161. $invites = $GLOBALS['file_db']->query('CREATE TABLE `invites` (
  2162. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2163. `code` TEXT UNIQUE,
  2164. `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  2165. `email` TEXT,
  2166. `username` TEXT,
  2167. `dateused` TIMESTAMP,
  2168. `usedby` TEXT,
  2169. `ip` TEXT,
  2170. `valid` TEXT
  2171. );');
  2172. writeLog("success", "database created/saved");
  2173. return $users && $tabs && $options && $invites;
  2174. } else {
  2175. writeLog("error", "database was unable to be created/saved");
  2176. return false;
  2177. }
  2178. }
  2179. // Upgrade Database
  2180. function updateSQLiteDB($db_path = false, $oldVerNum = false) {
  2181. if (!$db_path) {
  2182. if (defined('DATABASE_LOCATION')) {
  2183. $db_path = DATABASE_LOCATION;
  2184. } else {
  2185. debug_out('No Path Specified',1);
  2186. }
  2187. }
  2188. if (!isset($GLOBALS['file_db'])) {
  2189. $GLOBALS['file_db'] = new PDO('sqlite:'.$db_path.'users.db');
  2190. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2191. }
  2192. // Cache current DB
  2193. $cache = array();
  2194. foreach($GLOBALS['file_db']->query('SELECT name FROM sqlite_master WHERE type="table";') as $table) {
  2195. foreach($GLOBALS['file_db']->query('SELECT * FROM '.$table['name'].';') as $key => $row) {
  2196. foreach($row as $k => $v) {
  2197. if (is_string($k)) {
  2198. $cache[$table['name']][$key][$k] = $v;
  2199. }
  2200. }
  2201. }
  2202. }
  2203. // Remove Current Database
  2204. $GLOBALS['file_db'] = null;
  2205. $pathDigest = pathinfo($db_path.'users.db');
  2206. if (file_exists($db_path.'users.db')) {
  2207. rename($db_path.'users.db', $pathDigest['dirname'].'/'.$pathDigest['filename'].'['.date('Y-m-d_H-i-s').']'.($oldVerNum?'['.$oldVerNum.']':'').'.bak.db');
  2208. }
  2209. // Create New Database
  2210. $success = createSQLiteDB($db_path);
  2211. // Restore Items
  2212. if ($success) {
  2213. foreach($cache as $table => $tableData) {
  2214. if ($tableData) {
  2215. $queryBase = 'INSERT INTO '.$table.' (`'.implode('`,`',array_keys(current($tableData))).'`) values ';
  2216. $insertValues = array();
  2217. reset($tableData);
  2218. foreach($tableData as $key => $value) {
  2219. $insertValues[] = '('.implode(',',array_map(function($d) {
  2220. return (isset($d)?$GLOBALS['file_db']->quote($d):'null');
  2221. }, $value)).')';
  2222. }
  2223. $GLOBALS['file_db']->query($queryBase.implode(',',$insertValues).';');
  2224. }
  2225. }
  2226. writeLog("success", "database values have been updated");
  2227. return true;
  2228. } else {
  2229. writeLog("error", "database values unable to be updated");
  2230. return false;
  2231. }
  2232. }
  2233. // Commit colours to database
  2234. function updateDBOptions($values) {
  2235. if (!isset($GLOBALS['file_db'])) {
  2236. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2237. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2238. }
  2239. // Commit new values to database
  2240. if ($GLOBALS['file_db']->query('UPDATE options SET '.implode(',',array_map(function($d, $k) {
  2241. return '`'.$k.'` = '.(isset($d)?"'".addslashes($d)."'":'null');
  2242. }, $values, array_keys($values))).';')->rowCount()) {
  2243. return true;
  2244. } else if ($GLOBALS['file_db']->query('INSERT OR IGNORE INTO options (`'.implode('`,`',array_keys($values)).'`) VALUES (\''.implode("','",$values).'\');')->rowCount()) {
  2245. writeLog("success", "database values for options table have been updated");
  2246. return true;
  2247. } else {
  2248. writeLog("error", "database values for options table unable to be updated");
  2249. return false;
  2250. }
  2251. }
  2252. // Send AJAX notification
  2253. function sendNotification($success, $message = false, $send = true) {
  2254. $notifyExplode = explode("-", NOTIFYEFFECT);
  2255. if ($success) {
  2256. $msg = array(
  2257. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_SAVED").'</strong>'),
  2258. 'icon' => 'floppy-o',
  2259. 'type' => 'success',
  2260. 'length' => '5000',
  2261. 'layout' => $notifyExplode[0],
  2262. 'effect' => $notifyExplode[1],
  2263. );
  2264. } else {
  2265. $msg = array(
  2266. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_NOT_SAVED").'</strong>'),
  2267. 'icon' => 'floppy-o',
  2268. 'type' => 'failed',
  2269. 'length' => '5000',
  2270. 'layout' => $notifyExplode[0],
  2271. 'effect' => $notifyExplode[1],
  2272. );
  2273. }
  2274. // Send and kill script?
  2275. if ($send) {
  2276. header('Content-Type: application/json');
  2277. echo json_encode(array('notify'=>$msg));
  2278. die();
  2279. }
  2280. return $msg;
  2281. }
  2282. // Load colours from the database
  2283. function loadAppearance() {
  2284. // Defaults
  2285. $defaults = array(
  2286. 'title' => 'Organizr',
  2287. 'topbartext' => '#66D9EF',
  2288. 'topbar' => '#333333',
  2289. 'bottombar' => '#333333',
  2290. 'sidebar' => '#393939',
  2291. 'hoverbg' => '#AD80FD',
  2292. 'activetabBG' => '#F92671',
  2293. 'activetabicon' => '#FFFFFF',
  2294. 'activetabtext' => '#FFFFFF',
  2295. 'inactiveicon' => '#66D9EF',
  2296. 'inactivetext' => '#66D9EF',
  2297. 'loading' => '#66D9EF',
  2298. 'hovertext' => '#000000',
  2299. );
  2300. if (DATABASE_LOCATION) {
  2301. if(is_file(DATABASE_LOCATION.'users.db') && filesize(DATABASE_LOCATION.'users.db') > 0){
  2302. if (!isset($GLOBALS['file_db'])) {
  2303. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2304. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2305. }
  2306. // Database Lookup
  2307. $options = $GLOBALS['file_db']->query('SELECT * FROM options');
  2308. // Replace defaults with filled options
  2309. foreach($options as $row) {
  2310. foreach($defaults as $key => $value) {
  2311. if (isset($row[$key]) && $row[$key]) {
  2312. $defaults[$key] = $row[$key];
  2313. }
  2314. }
  2315. }
  2316. }
  2317. }
  2318. // Return the Results
  2319. return $defaults;
  2320. }
  2321. // Delete Database
  2322. function deleteDatabase() {
  2323. unset($_COOKIE['Organizr']);
  2324. setcookie('Organizr', '', time() - 3600, '/');
  2325. unset($_COOKIE['OrganizrU']);
  2326. setcookie('OrganizrU', '', time() - 3600, '/');
  2327. $GLOBALS['file_db'] = null;
  2328. unlink(DATABASE_LOCATION.'users.db');
  2329. foreach(glob(substr_replace($userdirpath, "", -1).'/*') as $file) {
  2330. if(is_dir($file)) {
  2331. rmdir($file);
  2332. } elseif (!is_dir($file)) {
  2333. unlink($file);
  2334. }
  2335. }
  2336. rmdir($userdirpath);
  2337. writeLog("success", "database has been deleted");
  2338. return true;
  2339. }
  2340. // Upgrade the installation
  2341. function upgradeInstall($branch = 'v1-master') {
  2342. if ($branch == 'master'){
  2343. $branch = 'v1-master';
  2344. }
  2345. if ($branch == 'develop'){
  2346. $branch = 'v1-develop';
  2347. }
  2348. if ($branch == 'cero-dev'){
  2349. $branch = 'v1-develop';
  2350. }
  2351. function downloadFile($url, $path){
  2352. ini_set('max_execution_time',0);
  2353. $folderPath = "upgrade/";
  2354. if(!mkdir($folderPath)){
  2355. writeLog("error", "organizr could not create upgrade folder");
  2356. }
  2357. $newfname = $folderPath . $path;
  2358. $file = fopen ($url, 'rb');
  2359. if ($file) {
  2360. $newf = fopen ($newfname, 'wb');
  2361. if ($newf) {
  2362. while(!feof($file)) {
  2363. fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
  2364. }
  2365. }
  2366. }else{
  2367. writeLog("error", "organizr could not download $url");
  2368. }
  2369. if ($file) {
  2370. fclose($file);
  2371. writeLog("success", "organizr finished downloading the github zip file");
  2372. }else{
  2373. writeLog("error", "organizr could not download the github zip file");
  2374. }
  2375. if ($newf) {
  2376. fclose($newf);
  2377. writeLog("success", "organizr created upgrade zip file from github zip file");
  2378. }else{
  2379. writeLog("error", "organizr could not create upgrade zip file from github zip file");
  2380. }
  2381. }
  2382. function unzipFile($zipFile){
  2383. $zip = new ZipArchive;
  2384. $extractPath = "upgrade/";
  2385. if($zip->open($extractPath . $zipFile) != "true"){
  2386. writeLog("error", "organizr could not unzip upgrade.zip");
  2387. }else{
  2388. writeLog("success", "organizr unzipped upgrade.zip");
  2389. }
  2390. /* Extract Zip File */
  2391. $zip->extractTo($extractPath);
  2392. $zip->close();
  2393. }
  2394. // Function to remove folders and files
  2395. function rrmdir($dir) {
  2396. if (is_dir($dir)) {
  2397. $files = scandir($dir);
  2398. foreach ($files as $file)
  2399. if ($file != "." && $file != "..") rrmdir("$dir/$file");
  2400. rmdir($dir);
  2401. }
  2402. else if (file_exists($dir)) unlink($dir);
  2403. }
  2404. // Function to Copy folders and files
  2405. function rcopy($src, $dst) {
  2406. if (is_dir ( $src )) {
  2407. if (!file_exists($dst)) : mkdir ( $dst ); endif;
  2408. $files = scandir ( $src );
  2409. foreach ( $files as $file )
  2410. if ($file != "." && $file != "..")
  2411. rcopy ( "$src/$file", "$dst/$file" );
  2412. } else if (file_exists ( $src ))
  2413. copy ( $src, $dst );
  2414. }
  2415. $url = 'https://github.com/causefx/Organizr/archive/'.$branch.'.zip';
  2416. $file = "upgrade.zip";
  2417. $source = __DIR__ . '/upgrade/Organizr-'.$branch.'/';
  2418. $cleanup = __DIR__ . "/upgrade/";
  2419. $destination = __DIR__ . "/";
  2420. writeLog("success", "starting organizr upgrade process");
  2421. downloadFile($url, $file);
  2422. unzipFile($file);
  2423. rcopy($source, $destination);
  2424. writeLog("success", "new organizr files copied");
  2425. rrmdir($cleanup);
  2426. writeLog("success", "organizr upgrade folder removed");
  2427. writeLog("success", "organizr has been updated");
  2428. return true;
  2429. }
  2430. // Transmission Items
  2431. function transmissionConnect($list = 'listgroups') {
  2432. $url = qualifyURL(TRANSMISSIONURL);
  2433. $digest = parse_url($url);
  2434. $scheme = (isset($digest['scheme'])) ? $digest['scheme'].'://' : 'http://';
  2435. $host = (isset($digest['host'])) ? $digest['host'] : '';
  2436. $port = (isset($digest['port'])) ? ':'.$digest['port'] : '';
  2437. $path = (isset($digest['path'])) ? $digest['path'] : '';
  2438. $passwordInclude = (TRANSMISSIONUSERNAME != '' && TRANSMISSIONPASSWORD != '') ? TRANSMISSIONUSERNAME.':'.TRANSMISSIONPASSWORD."@" : '';
  2439. $url = $scheme.$passwordInclude.$host.$port.$path.'/rpc';
  2440. $contextopts = array(
  2441. 'http' => array(
  2442. 'user_agent' => 'HTTP_UA',
  2443. 'ignore_errors' => true,
  2444. )
  2445. );
  2446. $context = stream_context_create( $contextopts );
  2447. $fp = @fopen( $url, 'r', false, $context );
  2448. $stream_meta = stream_get_meta_data( $fp );
  2449. fclose( $fp );
  2450. foreach( $stream_meta['wrapper_data'] as $header ){
  2451. if( strpos( $header, 'X-Transmission-Session-Id: ' ) === 0 ){
  2452. $session_id = trim( substr( $header, 27 ) );
  2453. break;
  2454. }
  2455. }
  2456. $headers = array(
  2457. 'X-Transmission-Session-Id' => $session_id,
  2458. 'Content-Type' => 'application/json'
  2459. );
  2460. $data = array(
  2461. 'method' => 'torrent-get',
  2462. 'arguments' => array(
  2463. 'fields' => array(
  2464. "id", "name", "totalSize", "eta", "isFinished", "isStalled", "percentDone", "rateDownload", "status", "downloadDir"
  2465. ),
  2466. ),
  2467. 'tags' => ''
  2468. );
  2469. $api = curl_post($url, $data, $headers);
  2470. $api = json_decode($api['content'], true);
  2471. $gotTorrent = array();
  2472. if (is_array($api) || is_object($api)){
  2473. foreach ($api['arguments']['torrents'] AS $child) {
  2474. $downloadName = htmlentities($child['name'], ENT_QUOTES);
  2475. $downloadDirectory = $child['downloadDir'];
  2476. $downloadPercent = $child['percentDone'] * 100;
  2477. $progressBar = "progress-bar-striped active";
  2478. if($child['status'] == "6"){
  2479. $downloadStatus = "Seeding";
  2480. $downloadHealth = "success";
  2481. }elseif($child['status'] == "4"){
  2482. $downloadStatus = "Downloading";
  2483. $downloadHealth = "danger";
  2484. }elseif($child['status'] == "3"){
  2485. $downloadStatus = "Queued";
  2486. $downloadHealth = "warning";
  2487. }elseif($child['status'] == "0"){
  2488. $downloadStatus = "Complete";
  2489. $downloadHealth = "success";
  2490. }
  2491. $gotTorrent[] = '<tr>
  2492. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2493. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2494. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadDirectory.'</td>
  2495. <td class="col-xs-1 nzbtable nzbtable-row">'.realSize($child['totalSize']).'</td>
  2496. <td class="col-xs-2 nzbtable nzbtable-row">
  2497. <div class="progress">
  2498. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2499. <p class="text-center">'.round($downloadPercent).'%</p>
  2500. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2501. </div>
  2502. </div>
  2503. </td>
  2504. </tr>';
  2505. }
  2506. if ($gotTorrent) {
  2507. return implode('',$gotTorrent);
  2508. } else {
  2509. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2510. }
  2511. }else{
  2512. writeLog("error", "TRANSMISSION ERROR: could not connect - check URL and/or check token and/or Username and Password - if HTTPS, is cert valid");
  2513. }
  2514. }
  2515. // NzbGET Items
  2516. function nzbgetConnect($list = 'listgroups') {
  2517. $url = qualifyURL(NZBGETURL);
  2518. $api = curl_get($url.'/'.NZBGETUSERNAME.':'.NZBGETPASSWORD.'/jsonrpc/'.$list);
  2519. $api = json_decode($api, true);
  2520. $gotNZB = array();
  2521. if (is_array($api) || is_object($api)){
  2522. foreach ($api['result'] AS $child) {
  2523. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  2524. $downloadStatus = $child['Status'];
  2525. $downloadCategory = $child['Category'];
  2526. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  2527. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  2528. if($child['Health'] <= "750"){
  2529. $downloadHealth = "danger";
  2530. }elseif($child['Health'] <= "900"){
  2531. $downloadHealth = "warning";
  2532. }elseif($child['Health'] <= "1000"){
  2533. $downloadHealth = "success";
  2534. }
  2535. $gotNZB[] = '<tr>
  2536. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2537. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2538. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2539. <td class="col-xs-1 nzbtable nzbtable-row">'.realSize(($child['FileSizeMB']*1024)*1024).'</td>
  2540. <td class="col-xs-2 nzbtable nzbtable-row">
  2541. <div class="progress">
  2542. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2543. <p class="text-center">'.round($downloadPercent).'%</p>
  2544. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2545. </div>
  2546. </div>
  2547. </td>
  2548. </tr>';
  2549. }
  2550. if ($gotNZB) {
  2551. return implode('',$gotNZB);
  2552. } else {
  2553. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2554. }
  2555. }else{
  2556. writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Username and Password - if HTTPS, is cert valid");
  2557. }
  2558. }
  2559. // Sabnzbd Items
  2560. function sabnzbdConnect($list = 'queue') {
  2561. $url = qualifyURL(SABNZBDURL);
  2562. $api = @file_get_contents($url.'/api?mode='.$list.'&output=json&apikey='.SABNZBDKEY);
  2563. $api = json_decode($api, true);
  2564. $gotNZB = array();
  2565. if (is_array($api) || is_object($api)){
  2566. foreach ($api[$list]['slots'] AS $child) {
  2567. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  2568. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  2569. $downloadStatus = $child['status'];
  2570. $gotNZB[] = '<tr>
  2571. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2572. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2573. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2574. <td class="col-xs-1 nzbtable nzbtable-row">'.$child['size'].'</td>
  2575. <td class="col-xs-2 nzbtable nzbtable-row">
  2576. <div class="progress">
  2577. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2578. <p class="text-center">'.round($downloadPercent).'%</p>
  2579. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2580. </div>
  2581. </div>
  2582. </td>
  2583. </tr>';
  2584. }
  2585. if ($gotNZB) {
  2586. return implode('',$gotNZB);
  2587. } else {
  2588. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2589. }
  2590. }else{
  2591. writeLog("error", "SABNZBD ERROR: could not connect - check URL and/or check token - if HTTPS, is cert valid");
  2592. }
  2593. }
  2594. // Apply new tab settings
  2595. function updateTabs($tabs) {
  2596. if (!isset($GLOBALS['file_db'])) {
  2597. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2598. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2599. }
  2600. // Validate
  2601. if (!isset($tabs['defaultz'])) { $tabs['defaultz'][current(array_keys($tabs['name']))] = 'true'; }
  2602. if (isset($tabs['name']) && isset($tabs['url']) && is_array($tabs['name'])) {
  2603. // Clear Existing Tabs
  2604. $GLOBALS['file_db']->query("DELETE FROM tabs");
  2605. // Process New Tabs
  2606. $totalValid = 0;
  2607. foreach ($tabs['name'] as $key => $value) {
  2608. // Qualify
  2609. if (!$value || !isset($tabs['url']) || !$tabs['url'][$key]) { continue; }
  2610. $totalValid++;
  2611. $fields = array();
  2612. foreach(array('id','name','url','icon','iconurl','order','ping_url') as $v) {
  2613. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = $tabs[$v][$key]; }
  2614. }
  2615. foreach(array('active','user','guest','defaultz','window','splash','ping') as $v) {
  2616. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = ($tabs[$v][$key]!=='false'?'true':'false'); }
  2617. }
  2618. $GLOBALS['file_db']->query('INSERT INTO tabs (`'.implode('`,`',array_keys($fields)).'`) VALUES (\''.implode("','",$fields).'\');');
  2619. }
  2620. writeLog("success", "tabs successfully saved");
  2621. return $totalValid;
  2622. } else {
  2623. writeLog("error", "tabs could not save");
  2624. return false;
  2625. }
  2626. writeLog("error", "tabs could not save");
  2627. return false;
  2628. }
  2629. // ==============
  2630. function clean($strin) {
  2631. $strout = null;
  2632. for ($i = 0; $i < strlen($strin); $i++) {
  2633. $ord = ord($strin[$i]);
  2634. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  2635. $strout .= "&amp;#{$ord};";
  2636. }
  2637. else {
  2638. switch ($strin[$i]) {
  2639. case '<':
  2640. $strout .= '&lt;';
  2641. break;
  2642. case '>':
  2643. $strout .= '&gt;';
  2644. break;
  2645. case '&':
  2646. $strout .= '&amp;';
  2647. break;
  2648. case '"':
  2649. $strout .= '&quot;';
  2650. break;
  2651. default:
  2652. $strout .= $strin[$i];
  2653. }
  2654. }
  2655. }
  2656. return $strout;
  2657. }
  2658. function registration_callback($username, $email, $userdir){
  2659. global $data;
  2660. $data = array($username, $email, $userdir);
  2661. }
  2662. function printArray($arrayName){
  2663. $messageCount = count($arrayName);
  2664. $i = 0;
  2665. foreach ( $arrayName as $item ) :
  2666. $i++;
  2667. if($i < $messageCount) :
  2668. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  2669. elseif($i = $messageCount) :
  2670. echo "<small class='text-uppercase'>" . $item . "</small>";
  2671. endif;
  2672. endforeach;
  2673. }
  2674. function write_ini_file($content, $path) {
  2675. if (!$handle = fopen($path, 'w')) {
  2676. return false;
  2677. }
  2678. $success = fwrite($handle, trim($content));
  2679. fclose($handle);
  2680. return $success;
  2681. }
  2682. function gotTimezone(){
  2683. $regions = array(
  2684. 'Africa' => DateTimeZone::AFRICA,
  2685. 'America' => DateTimeZone::AMERICA,
  2686. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2687. 'Arctic' => DateTimeZone::ARCTIC,
  2688. 'Asia' => DateTimeZone::ASIA,
  2689. 'Atlantic' => DateTimeZone::ATLANTIC,
  2690. 'Australia' => DateTimeZone::AUSTRALIA,
  2691. 'Europe' => DateTimeZone::EUROPE,
  2692. 'Indian' => DateTimeZone::INDIAN,
  2693. 'Pacific' => DateTimeZone::PACIFIC
  2694. );
  2695. $timezones = array();
  2696. foreach ($regions as $name => $mask) {
  2697. $zones = DateTimeZone::listIdentifiers($mask);
  2698. foreach($zones as $timezone) {
  2699. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2700. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2701. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2702. }
  2703. }
  2704. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  2705. foreach($timezones as $region => $list) {
  2706. print '<optgroup label="' . $region . '">' . "\n";
  2707. foreach($list as $timezone => $name) {
  2708. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  2709. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  2710. }
  2711. print '</optgroup>' . "\n";
  2712. }
  2713. print '</select>';
  2714. }
  2715. function getTimezone(){
  2716. $regions = array(
  2717. 'Africa' => DateTimeZone::AFRICA,
  2718. 'America' => DateTimeZone::AMERICA,
  2719. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2720. 'Arctic' => DateTimeZone::ARCTIC,
  2721. 'Asia' => DateTimeZone::ASIA,
  2722. 'Atlantic' => DateTimeZone::ATLANTIC,
  2723. 'Australia' => DateTimeZone::AUSTRALIA,
  2724. 'Europe' => DateTimeZone::EUROPE,
  2725. 'Indian' => DateTimeZone::INDIAN,
  2726. 'Pacific' => DateTimeZone::PACIFIC
  2727. );
  2728. $timezones = array();
  2729. foreach ($regions as $name => $mask) {
  2730. $zones = DateTimeZone::listIdentifiers($mask);
  2731. foreach($zones as $timezone) {
  2732. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2733. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2734. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2735. }
  2736. }
  2737. print '<select name="timezone" id="timezone" class="form-control material" required>';
  2738. foreach($timezones as $region => $list) {
  2739. print '<optgroup label="' . $region . '">' . "\n";
  2740. foreach($list as $timezone => $name) {
  2741. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  2742. }
  2743. print '</optgroup>' . "\n";
  2744. }
  2745. print '</select>';
  2746. }
  2747. function explosion($string, $position){
  2748. $getWord = explode("|", $string);
  2749. return $getWord[$position];
  2750. }
  2751. function getServerPath() {
  2752. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  2753. $protocol = "https://";
  2754. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  2755. $protocol = "https://";
  2756. } else {
  2757. $protocol = "http://";
  2758. }
  2759. $domain = '';
  2760. if (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], '.') !== false){
  2761. $domain = $_SERVER['SERVER_NAME'];
  2762. }elseif(isset($_SERVER['HTTP_HOST'])){
  2763. if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
  2764. $domain = explode(':', $_SERVER['HTTP_HOST'])[0];
  2765. $port = explode(':', $_SERVER['HTTP_HOST'])[1];
  2766. if ($port == "80" || $port == "443"){
  2767. $domain = $domain;
  2768. }else{
  2769. $domain = $_SERVER['HTTP_HOST'];
  2770. }
  2771. }else{
  2772. $domain = $_SERVER['HTTP_HOST'];
  2773. }
  2774. }
  2775. return $protocol . $domain . str_replace("\\", "/", dirname($_SERVER['REQUEST_URI']));
  2776. }
  2777. function get_browser_name() {
  2778. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  2779. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  2780. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  2781. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  2782. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  2783. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  2784. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  2785. return 'Other';
  2786. }
  2787. function getSickrageCalendarWanted($array){
  2788. $array = json_decode($array, true);
  2789. //$gotCalendar = "";
  2790. $gotCalendar = array();
  2791. $i = 0;
  2792. foreach($array['data']['missed'] AS $child) {
  2793. $i++;
  2794. $seriesName = $child['show_name'];
  2795. $episodeID = $child['tvdbid'];
  2796. $episodeAirDate = $child['airdate'];
  2797. $episodeAirDateTime = explode(" ",$child['airs']);
  2798. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2799. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2800. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2801. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2802. $downloaded = "0";
  2803. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2804. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2805. array_push($gotCalendar, array(
  2806. "id" => "Sick-Miss-".$i,
  2807. "title" => $seriesName,
  2808. "start" => $episodeAirDate,
  2809. "className" => $downloaded." tvID--".$episodeID,
  2810. "imagetype" => "tv",
  2811. ));
  2812. }
  2813. foreach($array['data']['today'] AS $child) {
  2814. $i++;
  2815. $seriesName = $child['show_name'];
  2816. $episodeID = $child['tvdbid'];
  2817. $episodeAirDate = $child['airdate'];
  2818. $episodeAirDateTime = explode(" ",$child['airs']);
  2819. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2820. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2821. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2822. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2823. $downloaded = "0";
  2824. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2825. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2826. array_push($gotCalendar, array(
  2827. "id" => "Sick-Today-".$i,
  2828. "title" => $seriesName,
  2829. "start" => $episodeAirDate,
  2830. "className" => $downloaded." tvID--".$episodeID,
  2831. "imagetype" => "tv",
  2832. ));
  2833. }
  2834. foreach($array['data']['soon'] AS $child) {
  2835. $i++;
  2836. $seriesName = $child['show_name'];
  2837. $episodeID = $child['tvdbid'];
  2838. $episodeAirDate = $child['airdate'];
  2839. $episodeAirDateTime = explode(" ",$child['airs']);
  2840. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2841. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2842. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2843. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2844. $downloaded = "0";
  2845. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2846. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2847. array_push($gotCalendar, array(
  2848. "id" => "Sick-Soon-".$i,
  2849. "title" => $seriesName,
  2850. "start" => $episodeAirDate,
  2851. "className" => $downloaded." tvID--".$episodeID,
  2852. "imagetype" => "tv",
  2853. ));
  2854. }
  2855. foreach($array['data']['later'] AS $child) {
  2856. $i++;
  2857. $seriesName = $child['show_name'];
  2858. $episodeID = $child['tvdbid'];
  2859. $episodeAirDate = $child['airdate'];
  2860. $episodeAirDateTime = explode(" ",$child['airs']);
  2861. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2862. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2863. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2864. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2865. $downloaded = "0";
  2866. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2867. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2868. array_push($gotCalendar, array(
  2869. "id" => "Sick-Later-".$i,
  2870. "title" => $seriesName,
  2871. "start" => $episodeAirDate,
  2872. "className" => $downloaded." tvID--".$episodeID,
  2873. "imagetype" => "tv",
  2874. ));
  2875. }
  2876. if ($i != 0){ return $gotCalendar; }
  2877. }
  2878. function getSickrageCalendarHistory($array){
  2879. $array = json_decode($array, true);
  2880. //$gotCalendar = "";
  2881. $gotCalendar = array();
  2882. $i = 0;
  2883. foreach($array['data'] AS $child) {
  2884. $i++;
  2885. $seriesName = $child['show_name'];
  2886. $episodeID = $child['tvdbid'];
  2887. $episodeAirDate = $child['date'];
  2888. $downloaded = "green-bg";
  2889. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2890. array_push($gotCalendar, array(
  2891. "id" => "Sick-History-".$i,
  2892. "title" => $seriesName,
  2893. "start" => $episodeAirDate,
  2894. "className" => $downloaded." tvID--".$episodeID,
  2895. "imagetype" => "tv",
  2896. ));
  2897. }
  2898. if ($i != 0){ return $gotCalendar; }
  2899. }
  2900. function getSonarrCalendar($array){
  2901. $array = json_decode($array, true);
  2902. //$gotCalendar = "";
  2903. $gotCalendar = array();
  2904. $i = 0;
  2905. foreach($array AS $child) {
  2906. $i++;
  2907. $seriesName = $child['series']['title'];
  2908. $episodeID = $child['series']['tvdbId'];
  2909. if(!isset($episodeID)){ $episodeID = ""; }
  2910. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  2911. if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
  2912. $episodeAirDate = $child['airDateUtc'];
  2913. $episodeAirDate = strtotime($episodeAirDate);
  2914. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2915. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2916. $downloaded = $child['hasFile'];
  2917. $monitored = $child['monitored'];
  2918. if($downloaded == "0" && isset($unaired) && $episodePremier == "true"){ $downloaded = "light-blue-bg"; }elseif(isset($unaired) && $monitored == "0"){ $downloaded = "light-gray-bg"; }elseif($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2919. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2920. array_push($gotCalendar, array(
  2921. "id" => "Sonarr-".$i,
  2922. "title" => $seriesName,
  2923. "start" => $episodeAirDate,
  2924. "className" => $downloaded." tvID--".$episodeID,
  2925. "imagetype" => "tv",
  2926. ));
  2927. }
  2928. if ($i != 0){ return $gotCalendar; }
  2929. }
  2930. function getCouchCalendar(){
  2931. $url = qualifyURL(COUCHURL);
  2932. $api = curl_get($url."/api/".COUCHAPI."/media.list");
  2933. $api = json_decode($api, true);
  2934. $i = 0;
  2935. $gotCalendar = array();
  2936. if (is_array($api) || is_object($api)){
  2937. foreach($api['movies'] AS $child) {
  2938. if($child['status'] == "active" || $child['status'] == "done" ){
  2939. $i++;
  2940. $movieName = $child['info']['original_title'];
  2941. $movieID = $child['info']['tmdb_id'];
  2942. if(!isset($movieID)){ $movieID = ""; }
  2943. $physicalRelease = (isset($child['info']['released']) ? $child['info']['released'] : null);
  2944. $backupRelease = (isset($child['info']['release_date']['theater']) ? $child['info']['release_date']['theater'] : null);
  2945. $physicalRelease = (isset($physicalRelease) ? $physicalRelease : $backupRelease);
  2946. $physicalRelease = strtotime($physicalRelease);
  2947. $physicalRelease = date("Y-m-d", $physicalRelease);
  2948. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2949. $downloaded = ($child['status'] == "active") ? "0" : "1";
  2950. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2951. array_push($gotCalendar, array(
  2952. "id" => "CouchPotato-".$i,
  2953. "title" => $movieName,
  2954. "start" => $physicalRelease,
  2955. "className" => $downloaded." movieID--".$movieID,
  2956. "imagetype" => "film",
  2957. ));
  2958. }
  2959. }
  2960. if ($i != 0){ return $gotCalendar; }
  2961. }else{
  2962. writeLog("error", "CouchPotato ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2963. }
  2964. }
  2965. function getRadarrCalendar($array){
  2966. $array = json_decode($array, true);
  2967. $gotCalendar = array();
  2968. $i = 0;
  2969. foreach($array AS $child) {
  2970. if(isset($child['physicalRelease'])){
  2971. $i++;
  2972. $movieName = $child['title'];
  2973. $movieID = $child['tmdbId'];
  2974. if(!isset($movieID)){ $movieID = ""; }
  2975. $physicalRelease = $child['physicalRelease'];
  2976. $physicalRelease = strtotime($physicalRelease);
  2977. $physicalRelease = date("Y-m-d", $physicalRelease);
  2978. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2979. $downloaded = $child['hasFile'];
  2980. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2981. array_push($gotCalendar, array(
  2982. "id" => "Radarr-".$i,
  2983. "title" => $movieName,
  2984. "start" => $physicalRelease,
  2985. "className" => $downloaded." movieID--".$movieID,
  2986. "imagetype" => "film",
  2987. ));
  2988. }
  2989. }
  2990. if ($i != 0){ return $gotCalendar; }
  2991. }
  2992. function getHeadphonesCalendar($url, $key, $list){
  2993. $url = qualifyURL(HEADPHONESURL);
  2994. $api = curl_get($url."/api?apikey=".$key."&cmd=$list");
  2995. $api = json_decode($api, true);
  2996. $i = 0;
  2997. //$gotCalendar = "";
  2998. $gotCalendar = array();;
  2999. if (is_array($api) || is_object($api)){
  3000. foreach($api AS $child) {
  3001. if($child['Status'] == "Wanted" && $list == "getWanted" && $child['ReleaseDate']){
  3002. $i++;
  3003. $albumName = addslashes($child['AlbumTitle']);
  3004. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  3005. $albumDate = (strlen($child['ReleaseDate']) > 4) ? $child['ReleaseDate'] : $child['ReleaseDate']."-01-01";
  3006. $albumID = $child['AlbumID'];
  3007. $albumDate = strtotime($albumDate);
  3008. $albumDate = date("Y-m-d", $albumDate);
  3009. $albumStatus = $child['Status'];
  3010. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  3011. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  3012. //$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  3013. array_push($gotCalendar, array(
  3014. "id" => "Headphones-".$i,
  3015. "title" => $albumArtist.' - '.$albumName,
  3016. "start" => $albumDate,
  3017. "className" => $albumStatusColor,
  3018. "imagetype" => "music",
  3019. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  3020. ));
  3021. }
  3022. if($child['Status'] == "Processed" && $list == "getHistory"){
  3023. $i++;
  3024. $find = array('_','[', ']', '\n');
  3025. $replace = array(' ','(', ')', ' ');
  3026. $albumName = addslashes(str_replace($find,$replace,$child['FolderName']));
  3027. $albumDate = $child['DateAdded'];
  3028. $albumID = $child['AlbumID'];
  3029. $albumDate = strtotime($albumDate);
  3030. $albumDate = date("Y-m-d", $albumDate);
  3031. $albumStatusColor = "green-bg";
  3032. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  3033. //$gotCalendar .= "{ title: \"$albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  3034. array_push($gotCalendar, array(
  3035. "id" => "Headphones-".$i,
  3036. "title" => $albumName,
  3037. "start" => $albumDate,
  3038. "className" => $albumStatusColor,
  3039. "imagetype" => "music",
  3040. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  3041. ));
  3042. }
  3043. }
  3044. if ($i != 0){ return $gotCalendar; }
  3045. }else{
  3046. writeLog("error", "HEADPHONES $list ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  3047. }
  3048. }
  3049. function checkRootPath($string){
  3050. if($string == "\\" || $string == "/"){
  3051. return "/";
  3052. }else{
  3053. return str_replace("\\", "/", $string) . "/";
  3054. }
  3055. }
  3056. function strip($string){
  3057. $string = strip_tags($string);
  3058. return preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $string));
  3059. }
  3060. function writeLog($type, $message){
  3061. if(file_exists(DATABASE_LOCATION."org.log")){
  3062. if(filesize(DATABASE_LOCATION."org.log") > 500000){
  3063. rename(DATABASE_LOCATION.'org.log',DATABASE_LOCATION.'org['.date('Y-m-d').'].log');
  3064. $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";
  3065. file_put_contents(DATABASE_LOCATION."org.log", $message2, FILE_APPEND | LOCK_EX);
  3066. }
  3067. }
  3068. $message = date("Y-m-d H:i:s")."|".$type."|".strip($message)."\n";
  3069. file_put_contents(DATABASE_LOCATION."org.log", $message, FILE_APPEND | LOCK_EX);
  3070. }
  3071. function readLog(){
  3072. $log = file(DATABASE_LOCATION."org.log",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3073. $log = array_reverse($log);
  3074. foreach($log as $line){
  3075. if(substr_count($line, '|') == 2){
  3076. $line = explode("|", strip($line));
  3077. $line[1] = ($line[1] == "error") ? '<span class="label label-danger">Error</span>' : '<span class="label label-primary">Success</span>';
  3078. echo "<tr><td>".$line[0]."</td><td>".$line[2]."</td><td>".$line[1]."</td></tr>";
  3079. }
  3080. }
  3081. }
  3082. function buildStream($array){
  3083. $result = "";
  3084. if (array_key_exists('platform', $array)) {
  3085. $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>';
  3086. }
  3087. if (array_key_exists('device', $array)) {
  3088. $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>';
  3089. }
  3090. if (array_key_exists('stream', $array)) {
  3091. $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>';
  3092. }
  3093. if (array_key_exists('video', $array)) {
  3094. $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>';
  3095. }
  3096. if (array_key_exists('audio', $array)) {
  3097. $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>';
  3098. }
  3099. return $result;
  3100. }
  3101. function streamType($value){
  3102. if($value == "transcode" || $value == "Transcode"){
  3103. return "Transcode";
  3104. }elseif($value == "copy" || $value == "DirectStream"){
  3105. return "Direct Stream";
  3106. }elseif($value == "directplay" || $value == "DirectPlay"){
  3107. return "Direct Play";
  3108. }else{
  3109. return "Direct Play";
  3110. }
  3111. }
  3112. function getPlatform($platform){
  3113. $allPlatforms = array(
  3114. "Chrome" => "chrome.png",
  3115. "tvOS" => "atv.png",
  3116. "iOS" => "ios.png",
  3117. "Xbox One" => "xbox.png",
  3118. "Mystery 4" => "playstation.png",
  3119. "Samsung" => "samsung.png",
  3120. "Roku" => "roku.png",
  3121. "Emby for iOS" => "ios.png",
  3122. "Emby Mobile" => "emby.png",
  3123. "Emby Theater" => "emby.png",
  3124. "Emby Classic" => "emby.png",
  3125. "Safari" => "safari.png",
  3126. "Android" => "android.png",
  3127. "AndroidTv" => "android.png",
  3128. "Chromecast" => "chromecast.png",
  3129. "Dashboard" => "emby.png",
  3130. "Dlna" => "dlna.png",
  3131. "Windows Phone" => "wp.png",
  3132. "Windows RT" => "win8.png",
  3133. "Kodi" => "kodi.png",
  3134. );
  3135. if (array_key_exists($platform, $allPlatforms)) {
  3136. return $allPlatforms[$platform];
  3137. }else{
  3138. return "pmp.png";
  3139. }
  3140. }
  3141. function getServer(){
  3142. $server = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"];
  3143. return $server;
  3144. }
  3145. function prettyPrint($v) {
  3146. $trace = debug_backtrace()[0];
  3147. echo '<pre style="white-space: pre; text-overflow: ellipsis; overflow: hidden; background-color: #f2f2f2; border: 2px solid black; border-radius: 5px; padding: 5px; margin: 5px;">'.$trace['file'].':'.$trace['line'].' '.gettype($v)."\n\n".print_r($v, 1).'</pre><br/>';
  3148. }
  3149. function checkFrame($array, $url){
  3150. if(array_key_exists("x-frame-options", $array)){
  3151. if($array['x-frame-options'] == "deny"){
  3152. return false;
  3153. }elseif($array['x-frame-options'] == "sameorgin"){
  3154. $digest = parse_url($url);
  3155. $host = (isset($digest['host'])?$digest['host']:'');
  3156. if(getServer() == $host){
  3157. return true;
  3158. }else{
  3159. return false;
  3160. }
  3161. }
  3162. }else{
  3163. if(!$array){
  3164. return false;
  3165. }
  3166. return true;
  3167. }
  3168. }
  3169. function frameTest($url){
  3170. $array = array_change_key_case(get_headers(qualifyURL($url), 1));
  3171. $url = qualifyURL($url);
  3172. if(checkFrame($array, $url)){
  3173. return true;
  3174. }else{
  3175. return false;
  3176. }
  3177. }
  3178. function sendResult($result, $icon = "floppy-o", $message = false, $success = "WAS_SUCCESSFUL", $fail = "HAS_FAILED", $send = true) {
  3179. $notifyExplode = explode("-", NOTIFYEFFECT);
  3180. if ($result) {
  3181. $msg = array(
  3182. 'html' => ($message?''.$message.' <strong>'.translate($success).'</strong>':'<strong>'.translate($success).'</strong>'),
  3183. 'icon' => $icon,
  3184. 'type' => 'success',
  3185. 'length' => '5000',
  3186. 'layout' => $notifyExplode[0],
  3187. 'effect' => $notifyExplode[1],
  3188. );
  3189. } else {
  3190. $msg = array(
  3191. 'html' => ($message?''.$message.' <strong>'.translate($fail).'</strong>':'<strong>'.translate($fail).'</strong>'),
  3192. 'icon' => $icon,
  3193. 'type' => 'error',
  3194. 'length' => '5000',
  3195. 'layout' => $notifyExplode[0],
  3196. 'effect' => $notifyExplode[1],
  3197. );
  3198. }
  3199. // Send and kill script?
  3200. if ($send) {
  3201. header('Content-Type: application/json');
  3202. echo json_encode(array('notify'=>$msg));
  3203. die();
  3204. }
  3205. return $msg;
  3206. }
  3207. function buildHomepageNotice($layout, $type, $title, $message){
  3208. switch ($layout) {
  3209. case 'elegant':
  3210. return '
  3211. <div id="homepageNotice" class="row">
  3212. <div class="col-lg-12">
  3213. <div class="content-box big-box box-shadow panel-box panel-'.$type.'">
  3214. <div class="content-title i-block">
  3215. <h4 class="zero-m"><strong>'.$title.'</strong></h4>
  3216. <div class="content-tools i-block pull-right">
  3217. <a class="close-btn">
  3218. <i class="fa fa-times"></i>
  3219. </a>
  3220. </div>
  3221. </div>
  3222. '.$message.'
  3223. </div>
  3224. </div>
  3225. </div>
  3226. ';
  3227. break;
  3228. case 'basic':
  3229. return '
  3230. <div id="homepageNotice" class="row">
  3231. <div class="col-lg-12">
  3232. <div class="panel panel-'.$type.'">
  3233. <div class="panel-heading">
  3234. <h3 class="panel-title">'.$title.'</h3>
  3235. </div>
  3236. <div class="panel-body">
  3237. '.$message.'
  3238. </div>
  3239. </div>
  3240. </div>
  3241. </div>
  3242. ';
  3243. break;
  3244. case 'jumbotron';
  3245. return '
  3246. <div id="homepageNotice" class="row">
  3247. <div class="col-lg-12">
  3248. <div class="jumbotron">
  3249. <div class="container">
  3250. <h1>'.$title.'</h1>
  3251. <p>'.$message.'</p>
  3252. </div>
  3253. </div>
  3254. </div>
  3255. </div>
  3256. ';
  3257. }
  3258. }
  3259. function embyArray($array, $type) {
  3260. $key = ($type == "video" ? "Height" : "Channels");
  3261. if (array_key_exists($key, $array)) {
  3262. switch ($type) {
  3263. case "video":
  3264. $codec = $array["Codec"];
  3265. $height = $array["Height"];
  3266. $width = $array["Width"];
  3267. break;
  3268. default:
  3269. $codec = $array["Codec"];
  3270. $channels = $array["Channels"];
  3271. }
  3272. return ($type == "video" ? "(".$codec.") (".$width."x".$height.")" : "(".$codec.") (".$channels."ch)");
  3273. }
  3274. foreach ($array as $element) {
  3275. if (is_array($element)) {
  3276. if (embyArray($element, $type)) {
  3277. return embyArray($element, $type);
  3278. }
  3279. }
  3280. }
  3281. }
  3282. // Get Now Playing Streams From Plex
  3283. function searchPlex($query){
  3284. $address = qualifyURL(PLEXURL);
  3285. $openTab = (PLEXTABNAME) ? "true" : "false";
  3286. // Perform API requests
  3287. $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
  3288. libxml_use_internal_errors(true);
  3289. $api = simplexml_load_string($api);
  3290. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3291. if (!$getServer) { return 'Could not load!'; }
  3292. // Identify the local machine
  3293. $server = $getServer['machineIdentifier'];
  3294. $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>";
  3295. $items = "";
  3296. $albums = $movies = $shows = 0;
  3297. $style = 'style="vertical-align: middle"';
  3298. foreach($api AS $child) {
  3299. if($child['type'] != "artist" && $child['type'] != "episode" && isset($child['librarySectionID'])){
  3300. $time = (string)$child['addedAt'];
  3301. $time = new DateTime("@$time");
  3302. $results = array(
  3303. "title" => (string)$child['title'],
  3304. "image" => (string)$child['thumb'],
  3305. "type" => (string)ucwords($child['type']),
  3306. "year" => (string)$child['year'],
  3307. "key" => (string)$child['ratingKey']."-search",
  3308. "ratingkey" => (string)$child['ratingKey'],
  3309. "genre" => (string)$child->Genre['tag'],
  3310. "added" => $time->format('Y-m-d'),
  3311. "extra" => "",
  3312. );
  3313. switch ($child['type']){
  3314. case "album":
  3315. $push = array(
  3316. "title" => (string)$child['parentTitle']." - ".(string)$child['title'],
  3317. );
  3318. $results = array_replace($results,$push);
  3319. $albums++;
  3320. break;
  3321. case "movie":
  3322. $push = array(
  3323. "extra" => "Content Rating: ".(string)$child['contentRating']."<br/>Movie Rating: ".(string)$child['rating'],
  3324. );
  3325. $results = array_replace($results,$push);
  3326. $movies++;
  3327. break;
  3328. case "show":
  3329. $push = array(
  3330. "extra" => "Seasons: ".(string)$child['childCount']."<br/>Episodes: ".(string)$child['leafCount'],
  3331. );
  3332. $results = array_replace($results,$push);
  3333. $shows++;
  3334. break;
  3335. }
  3336. if (file_exists('images/cache/'.$results['key'].'.jpg')){ $image_url = 'images/cache/'.$results['key'].'.jpg'; }
  3337. if (file_exists('images/cache/'.$results['key'].'.jpg') && (time() - 604800) > filemtime('images/cache/'.$results['key'].'.jpg') || !file_exists('images/cache/'.$results['key'].'.jpg')) {
  3338. $image_url = 'ajax.php?a=plex-image&img='.$results['image'].'&height=150&width=100&key='.$results['key'];
  3339. }
  3340. if(!$results['image']){ $image_url = "images/no-search.png"; $key = "no-search"; }
  3341. if (PLEXTABURL) {
  3342. $link = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3343. }else{
  3344. $link = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3345. }
  3346. $items .= '<tr style="cursor: pointer;" class="openTab" extraTitle="'.$results['title'].'" extraType="'.$child['type'].'" openTab="'.$openTab.'" href="'.$link.'">
  3347. <th scope="row"><img src="'.$image_url.'"></th>
  3348. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
  3349. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
  3350. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
  3351. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
  3352. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
  3353. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['extra'].'</td>
  3354. </tr>';
  3355. }
  3356. }
  3357. $totals = '<div style="margin: 10px;" class="sort-todo pull-right">
  3358. <span class="badge gray-bg"><i class="fa fa-film fa-2x white"></i><strong style="
  3359. font-size: 23px;
  3360. ">&nbsp;'.$movies.'</strong></span>
  3361. <span class="badge gray-bg"><i class="fa fa-tv fa-2x white"></i><strong style="
  3362. font-size: 23px;
  3363. ">&nbsp;'.$shows.'</strong></span>
  3364. <span class="badge gray-bg"><i class="fa fa-music fa-2x white"></i><strong style="
  3365. font-size: 23px;
  3366. ">&nbsp;'.$albums.'</strong></span>
  3367. </div>';
  3368. return (!empty($items) ? $totals.$pre.$items."</div></table>" : "<h2 class='text-center'>No Results for $query</h2>" );
  3369. }
  3370. function getBannedUsers($string){
  3371. if (strpos($string, ',') !== false) {
  3372. $banned = explode(",", $string);
  3373. }else{
  3374. $banned = array($string);
  3375. }
  3376. return $banned;
  3377. }
  3378. function getWhitelist($string){
  3379. if (strpos($string, ',') !== false) {
  3380. $whitelist = explode(",", $string);
  3381. }else{
  3382. $whitelist = array($string);
  3383. }
  3384. foreach($whitelist as &$ip){
  3385. $ip = is_numeric(substr($ip, 0, 1)) ? $ip : gethostbyname($ip);
  3386. }
  3387. return $whitelist;
  3388. }
  3389. function get_client_ip() {
  3390. $ipaddress = '';
  3391. if (isset($_SERVER['HTTP_CLIENT_IP']))
  3392. $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
  3393. else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  3394. $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
  3395. else if(isset($_SERVER['HTTP_X_FORWARDED']))
  3396. $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
  3397. else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
  3398. $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
  3399. else if(isset($_SERVER['HTTP_FORWARDED']))
  3400. $ipaddress = $_SERVER['HTTP_FORWARDED'];
  3401. else if(isset($_SERVER['REMOTE_ADDR']))
  3402. $ipaddress = $_SERVER['REMOTE_ADDR'];
  3403. else
  3404. $ipaddress = 'UNKNOWN';
  3405. return $ipaddress;
  3406. }
  3407. //EMAIL SHIT
  3408. function sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null){
  3409. $mail = new PHPMailer;
  3410. $mail->isSMTP();
  3411. $mail->Host = SMTPHOST;
  3412. $mail->SMTPAuth = SMTPHOSTAUTH;
  3413. $mail->Username = SMTPHOSTUSERNAME;
  3414. $mail->Password = SMTPHOSTPASSWORD;
  3415. $mail->SMTPSecure = SMTPHOSTTYPE;
  3416. $mail->Port = SMTPHOSTPORT;
  3417. $mail->setFrom(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3418. $mail->addReplyTo(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3419. $mail->isHTML(true);
  3420. if($email){
  3421. $mail->addAddress($email, $username);
  3422. }
  3423. if($cc){
  3424. $mail->addCC($cc);
  3425. }
  3426. if($bcc){
  3427. if(strpos($bcc , ',') === false){
  3428. $mail->addBCC($bcc);
  3429. }else{
  3430. $allEmails = explode(",",$bcc);
  3431. foreach($allEmails as $gotEmail){
  3432. $mail->addBCC($gotEmail);
  3433. }
  3434. }
  3435. }
  3436. $mail->Subject = $subject;
  3437. $mail->Body = $body;
  3438. //$mail->send();
  3439. if(!$mail->send()) {
  3440. writeLog("error", "mail failed to send");
  3441. } else {
  3442. writeLog("success", "mail has been sent");
  3443. }
  3444. }
  3445. //EMAIL SHIT
  3446. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  3447. $mail = new PHPMailer;
  3448. $mail->isSMTP();
  3449. $mail->Host = $host;
  3450. $mail->SMTPAuth = $auth;
  3451. $mail->Username = $username;
  3452. $mail->Password = $password;
  3453. $mail->SMTPSecure = $type;
  3454. $mail->Port = $port;
  3455. $mail->setFrom($from, $sendername);
  3456. $mail->addReplyTo($from, $sendername);
  3457. $mail->isHTML(true);
  3458. $mail->addAddress($to, "Organizr Admin");
  3459. $mail->Subject = "Organizr Test E-Mail";
  3460. $mail->Body = "This was just a test!";
  3461. //$mail->send();
  3462. if(!$mail->send()) {
  3463. writeLog("error", "EMAIL TEST: mail failed to send - Error:".$mail->ErrorInfo);
  3464. return false;
  3465. } else {
  3466. writeLog("success", "EMAIL TEST: mail has been sent successfully");
  3467. return true;
  3468. }
  3469. }
  3470. function libraryList(){
  3471. $address = qualifyURL(PLEXURL);
  3472. $headers = array(
  3473. "Accept" => "application/json",
  3474. "X-Plex-Token" => PLEXTOKEN
  3475. );
  3476. libxml_use_internal_errors(true);
  3477. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3478. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3479. $api = simplexml_load_string(@curl_get("https://plex.tv/api/servers/$gotServer/shared_servers", $headers));
  3480. $libraryList = array();
  3481. foreach($api->SharedServer->Section AS $child) {
  3482. $libraryList['libraries'][(string)$child['title']] = (string)$child['id'];
  3483. }
  3484. foreach($api->SharedServer AS $child) {
  3485. if(!empty($child['username'])){
  3486. $username = (string)strtolower($child['username']);
  3487. $email = (string)strtolower($child['email']);
  3488. $libraryList['users'][$username] = (string)$child['id'];
  3489. $libraryList['emails'][$email] = (string)$child['id'];
  3490. $libraryList['both'][$username] = $email;
  3491. }
  3492. }
  3493. return (!empty($libraryList) ? array_change_key_case($libraryList,CASE_LOWER) : null );
  3494. }
  3495. function plexUserShare($username){
  3496. $address = qualifyURL(PLEXURL);
  3497. $headers = array(
  3498. "Accept" => "application/json",
  3499. "Content-Type" => "application/json",
  3500. "X-Plex-Token" => PLEXTOKEN
  3501. );
  3502. libxml_use_internal_errors(true);
  3503. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3504. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3505. $json = array(
  3506. "server_id" => $gotServer,
  3507. "shared_server" => array(
  3508. //"library_section_ids" => "[26527637]",
  3509. "invited_email" => $username
  3510. )
  3511. );
  3512. $api = curl_post("https://plex.tv/api/servers/$gotServer/shared_servers/", $json, $headers);
  3513. switch ($api['http_code']['http_code']){
  3514. case 400:
  3515. writeLog("error", "PLEX INVITE: $username already has access to the shared libraries");
  3516. $result = "$username already has access to the shared libraries";
  3517. break;
  3518. case 401:
  3519. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3520. $result = "Invalid Plex Token";
  3521. break;
  3522. case 200:
  3523. writeLog("success", "PLEX INVITE: $username now has access to your Plex Library");
  3524. $result = "$username now has access to your Plex Library";
  3525. break;
  3526. default:
  3527. writeLog("error", "PLEX INVITE: unknown error");
  3528. $result = false;
  3529. }
  3530. return (!empty($result) ? $result : null );
  3531. }
  3532. function plexUserDelete($username){
  3533. $address = qualifyURL(PLEXURL);
  3534. $headers = array(
  3535. "Accept" => "application/json",
  3536. "Content-Type" => "application/json",
  3537. "X-Plex-Token" => PLEXTOKEN
  3538. );
  3539. libxml_use_internal_errors(true);
  3540. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3541. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3542. $id = (is_numeric($username) ? $id : convertPlexName($username, "id"));
  3543. $api = curl_delete("https://plex.tv/api/servers/$gotServer/shared_servers/$id", $headers);
  3544. switch ($api['http_code']['http_code']){
  3545. case 401:
  3546. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3547. $result = "Invalid Plex Token";
  3548. break;
  3549. case 200:
  3550. writeLog("success", "PLEX INVITE: $username doesn't have access to your Plex Library anymore");
  3551. $result = "$username doesn't have access to your Plex Library anymore";
  3552. break;
  3553. default:
  3554. writeLog("error", "PLEX INVITE: unknown error");
  3555. $result = false;
  3556. }
  3557. return (!empty($result) ? $result : null );
  3558. }
  3559. function convertPlexName($user, $type){
  3560. $array = libraryList();
  3561. switch ($type){
  3562. case "username":
  3563. $plexUser = array_search ($user, $array['users']);
  3564. break;
  3565. case "id":
  3566. if (array_key_exists(strtolower($user), $array['users'])) {
  3567. $plexUser = $array['users'][strtolower($user)];
  3568. }
  3569. break;
  3570. default:
  3571. $plexUser = false;
  3572. }
  3573. return (!empty($plexUser) ? $plexUser : null );
  3574. }
  3575. function randomCode($length = 5, $type = null) {
  3576. switch ($type){
  3577. case "alpha":
  3578. $legend = array_merge(range('A', 'Z'));
  3579. break;
  3580. case "numeric":
  3581. $legend = array_merge(range(0,9));
  3582. break;
  3583. default:
  3584. $legend = array_merge(range(0,9),range('A', 'Z'));
  3585. }
  3586. $code = "";
  3587. for($i=0; $i < $length; $i++) {
  3588. $code .= $legend[mt_rand(0, count($legend) - 1)];
  3589. }
  3590. return $code;
  3591. }
  3592. function inviteCodes($action, $code = null, $usedBy = null) {
  3593. if (!isset($GLOBALS['file_db'])) {
  3594. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  3595. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  3596. }
  3597. $now = date("Y-m-d H:i:s");
  3598. switch ($action) {
  3599. case "get":
  3600. // Start Array
  3601. $result = array();
  3602. // Database Lookup
  3603. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes"');
  3604. // Get Codes
  3605. foreach($invites as $row) {
  3606. array_push($result, $row['code']);
  3607. }
  3608. // Return the Results
  3609. return (!empty($result) ? $result : false );
  3610. break;
  3611. case "check":
  3612. // Start Array
  3613. $result = array();
  3614. // Database Lookup
  3615. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes" AND code = "'.$code.'"');
  3616. // Get Codes
  3617. foreach($invites as $row) {
  3618. $result = $row['code'];
  3619. }
  3620. // Return the Results
  3621. return (!empty($result) ? $result : false );
  3622. break;
  3623. case "use":
  3624. $currentIP = get_client_ip();
  3625. $invites = $GLOBALS['file_db']->query('UPDATE invites SET valid = "No", usedby = "'.$usedBy.'", dateused = "'.$now.'", ip = "'.$currentIP.'" WHERE code = "'.$code.'"');
  3626. if(ENABLEMAIL){
  3627. if (!isset($GLOBALS['USER'])) {
  3628. require_once("user.php");
  3629. $GLOBALS['USER'] = new User('registration_callback');
  3630. }
  3631. $emailTemplate = array(
  3632. 'type' => 'mass',
  3633. 'body' => 'The user: {user} has reddemed the code: {inviteCode} his IP Address was '.$currentIP,
  3634. 'subject' => 'Invite Code '.$code.' Has Been Used',
  3635. 'user' => $usedBy,
  3636. 'password' => null,
  3637. 'inviteCode' => $code,
  3638. );
  3639. $emailTemplate = emailTemplate($emailTemplate);
  3640. $subject = $emailTemplate['subject'];
  3641. $body = buildEmail($emailTemplate);
  3642. sendEmail($GLOBALS['USER']->adminEmail, "Admin", $subject, $body);
  3643. }
  3644. return (!empty($invites) ? true : false );
  3645. break;
  3646. }
  3647. }
  3648. function plexJoin($username, $email, $password){
  3649. $connectURL = 'https://plex.tv/users.json';
  3650. $headers = array(
  3651. 'Accept'=> 'application/json',
  3652. 'Content-Type' => 'application/x-www-form-urlencoded',
  3653. 'X-Plex-Product' => 'Organizr',
  3654. 'X-Plex-Version' => '1.0',
  3655. 'X-Plex-Client-Identifier' => '01010101-10101010',
  3656. );
  3657. $body = array(
  3658. 'user[email]' => $email,
  3659. 'user[username]' => $username,
  3660. 'user[password]' => $password,
  3661. );
  3662. $api = curl_post($connectURL, $body, $headers);
  3663. $json = json_decode($api['content'], true);
  3664. $errors = (!empty($json['errors']) ? true : false);
  3665. $success = (!empty($json['user']) ? true : false);
  3666. //Use This for later
  3667. $usernameError = (!empty($json['errors']['username']) ? $json['errors']['username'][0] : false);
  3668. $emailError = (!empty($json['errors']['email']) ? $json['errors']['email'][0] : false);
  3669. $passwordError = (!empty($json['errors']['password']) ? $json['errors']['password'][0] : false);
  3670. $errorMessage = "";
  3671. if($errors){
  3672. if($usernameError){ $errorMessage .= "[Username Error: ". $usernameError ."]"; }
  3673. if($emailError){ $errorMessage .= "[Email Error: ". $emailError ."]"; }
  3674. if($passwordError){ $errorMessage .= "[Password Error: ". $passwordError ."]"; }
  3675. }
  3676. switch ($api['http_code']['http_code']){
  3677. case 400:
  3678. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." $username already has access to the shared libraries $errorMessage");
  3679. break;
  3680. case 401:
  3681. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." invalid Plex Token $errorMessage");
  3682. break;
  3683. case 422:
  3684. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." user info error $errorMessage");
  3685. break;
  3686. case 429:
  3687. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." too many requests to plex.tv please try later $errorMessage");
  3688. break;
  3689. case 200:
  3690. case 201:
  3691. writeLog("success", "PLEX JOIN: $username now has access to your Plex Library");
  3692. break;
  3693. default:
  3694. writeLog("error", "PLEX JOIN: unknown error, $errorMessage Error: ".$api['http_code']['http_code']);
  3695. }
  3696. //prettyPrint($api);
  3697. //prettyPrint(json_decode($api['content'], true));
  3698. return (!empty($success) && empty($errors) ? true : false );
  3699. }
  3700. function getCert(){
  3701. $url = "http://curl.haxx.se/ca/cacert.pem";
  3702. $file = getcwd()."/config/cacert.pem";
  3703. $directory = getcwd()."/config/";
  3704. @mkdir($directory, 0770, true);
  3705. if(!file_exists($file)){
  3706. file_put_contents( $file, fopen($url, 'r'));
  3707. writeLog("success", "CERT PEM: pem file created");
  3708. }elseif (file_exists($file) && time() - 2592000 > filemtime($file)) {
  3709. file_put_contents( $file, fopen($url, 'r'));
  3710. writeLog("success", "CERT PEM: downloaded new pem file");
  3711. }
  3712. return $file;
  3713. }
  3714. function customCSS(){
  3715. if(CUSTOMCSS == "true") {
  3716. $template_file = "custom.css";
  3717. $file_handle = fopen($template_file, "rb");
  3718. echo "\n";
  3719. echo fread($file_handle, filesize($template_file));
  3720. fclose($file_handle);
  3721. echo "\n";
  3722. }
  3723. }
  3724. function tvdbToken(){
  3725. $headers = array(
  3726. "Accept" => "application/json",
  3727. "Content-Type" => "application/json"
  3728. );
  3729. $json = array(
  3730. "apikey" => "FBE7B62621F4CAD7",
  3731. "userkey" => "328BB46EB1E9A0F5",
  3732. "username" => "causefx"
  3733. );
  3734. $api = curl_post("https://api.thetvdb.com/login", $json, $headers);
  3735. return json_decode($api['content'], true)['token'];
  3736. }
  3737. function tvdbGet($id){
  3738. $headers = array(
  3739. "Accept" => "application/json",
  3740. "Authorization" => "Bearer ".tvdbToken(),
  3741. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3742. "trakt-api-version" => "2"
  3743. );
  3744. $trakt = curl_get("https://api.trakt.tv/search/tvdb/$id?type=show", $headers);
  3745. @$api['trakt'] = json_decode($trakt, true)[0]['show']['ids'];
  3746. if(empty($api['trakt'])){
  3747. $series = curl_get("https://api.thetvdb.com/series/$id", $headers);
  3748. $poster = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=poster", $headers);
  3749. $backdrop = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=fanart", $headers);
  3750. $api['series'] = json_decode($series, true)['data'];
  3751. $api['poster'] = json_decode($poster, true)['data'];
  3752. $api['backdrop'] = json_decode($backdrop, true)['data'];
  3753. }
  3754. return $api;
  3755. }
  3756. function tvdbSearch($name, $type){
  3757. $name = rawurlencode(preg_replace("/\(([^()]*+|(?R))*\)/","", $name));
  3758. $headers = array(
  3759. "Accept" => "application/json",
  3760. "Authorization" => "Bearer ".tvdbToken(),
  3761. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3762. "trakt-api-version" => "2"
  3763. );
  3764. $trakt = curl_get("https://api.trakt.tv/search/$type?query=$name", $headers);
  3765. @$api['trakt'] = json_decode($trakt, true)[0][$type]['ids'];
  3766. return $api;
  3767. }
  3768. function getPlexPlaylists(){
  3769. $address = qualifyURL(PLEXURL);
  3770. // Perform API requests
  3771. $api = @curl_get($address."/playlists?X-Plex-Token=".PLEXTOKEN);
  3772. libxml_use_internal_errors(true);
  3773. $api = simplexml_load_string($api);
  3774. if (is_array($api) || is_object($api)){
  3775. if (!$api->head->title){
  3776. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3777. if (!$getServer) { return 'Could not load!'; }
  3778. // Identify the local machine
  3779. $gotServer = $getServer['machineIdentifier'];
  3780. $output = "";
  3781. $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">';
  3782. foreach($api AS $child) {
  3783. $items = array();
  3784. if ($child['playlistType'] == "video" && strpos(strtolower($child['title']) , 'private') === false){
  3785. $api = @curl_get($address.$child['key']."?X-Plex-Token=".PLEXTOKEN);
  3786. $api = simplexml_load_string($api);
  3787. if (is_array($api) || is_object($api)){
  3788. if (!$api->head->title){
  3789. $className = preg_replace("/(\W)+/", "", $api['title']);
  3790. $hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  3791. foreach($api->Video AS $child){
  3792. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false,false,$className);
  3793. }
  3794. if (count($items)) {
  3795. $output .= ''.implode('',$items).'';
  3796. }
  3797. }
  3798. }
  3799. }
  3800. }
  3801. $hideMenu .= '</ul></div></div>';
  3802. 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>';
  3803. }else{
  3804. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check token - if HTTPS, is cert valid");
  3805. }
  3806. }else{
  3807. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check URL - if HTTPS, is cert valid");
  3808. }
  3809. }
  3810. function readExternalLog($type,$filename,$name = null){
  3811. $log = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3812. $log = array_reverse($log);
  3813. foreach($log as $line){
  3814. if(!empty($line) && $line[0] != " "){
  3815. $line = strip($line);
  3816. if($type == "single"){
  3817. if( strpos( strtolower($line), "ror" ) !== false ) {
  3818. echo "<tr><td class='red-bg'>".$line."</td></tr>";
  3819. }else{
  3820. echo "<tr><td>".$line."</td></tr>";
  3821. }
  3822. }elseif($type == "all"){
  3823. if( strpos( strtolower($line), "ror" ) !== false ) {
  3824. echo "<tr><td class='red-bg'>".$name."</td>";
  3825. echo "<td class='red-bg'>".$line."</td></tr>";
  3826. }else{
  3827. echo "<tr><td>".$name."</td>";
  3828. echo "<td>".$line."</td></tr>";
  3829. }
  3830. }
  3831. }
  3832. }
  3833. }
  3834. function getLogs(){
  3835. $path = __DIR__ ."/logs/";
  3836. @mkdir($path, 0770, true);
  3837. $logs = array();
  3838. $files = array_diff(scandir($path), array('.', '..'));
  3839. foreach($files as $v){
  3840. $title = explode(".", $v)[0];
  3841. $logs[$title] = $path.$v;
  3842. }
  3843. return $logs;
  3844. }
  3845. function getBackups(){
  3846. $path = DATABASE_LOCATION ."backups/";
  3847. @mkdir($path, 0770, true);
  3848. $backups = array();
  3849. $files = array_diff(scandir($path), array('.', '..'));
  3850. return array_reverse($files);
  3851. }
  3852. function getExtension($string) {
  3853. return preg_replace("#(.+)?\.(\w+)(\?.+)?#", "$2", $string);
  3854. }
  3855. function showFile(){
  3856. $file = $_GET['file'];
  3857. $fileType = getExtension($file);
  3858. if($fileType == 'css' || $fileType == 'js'){
  3859. header("Content-type: ".mimeTypes()[$fileType]);
  3860. @readfile($file);
  3861. }
  3862. }
  3863. function getCalendar(){
  3864. $sonarr = new Sonarr(SONARRURL, SONARRKEY);
  3865. $radarr = new Sonarr(RADARRURL, RADARRKEY);
  3866. $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
  3867. $startDate = date('Y-m-d',strtotime("-".CALENDARSTARTDAY." days"));
  3868. $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
  3869. $calendarItems = array();
  3870. if (SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)){
  3871. try {
  3872. $sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate, SONARRUNMONITORED));
  3873. if(!empty($sonarrCalendar)) { $calendarItems = array_merge($calendarItems, $sonarrCalendar);
  3874. }
  3875. } catch (Exception $e) {
  3876. writeLog("error", "SONARR ERROR: ".strip($e->getMessage()));
  3877. }
  3878. }
  3879. if (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)){
  3880. try {
  3881. $radarrCalendar = getRadarrCalendar($radarr->getCalendar($startDate, $endDate));
  3882. if(!empty($radarrCalendar)) { $calendarItems = array_merge($calendarItems, $radarrCalendar); }
  3883. } catch (Exception $e) {
  3884. writeLog("error", "RADARR ERROR: ".strip($e->getMessage()));
  3885. }
  3886. }
  3887. if (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH)){
  3888. $couchCalendar = getCouchCalendar();
  3889. if(!empty($couchCalendar)) { $calendarItems = array_merge($calendarItems, $couchCalendar); }
  3890. }
  3891. if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
  3892. $headphonesHistory = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory");
  3893. $headphonesWanted = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted");
  3894. if(!empty($headphonesHistory)) { $calendarItems = array_merge($calendarItems, $headphonesHistory); }
  3895. if(!empty($headphonesWanted)) { $calendarItems = array_merge($calendarItems, $headphonesWanted); }
  3896. }
  3897. if (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)){
  3898. try {
  3899. $sickrageFuture = getSickrageCalendarWanted($sickrage->future());
  3900. if(!empty($sickrageFuture)) { $calendarItems = array_merge($calendarItems, $sickrageFuture); }
  3901. } catch (Exception $e) {
  3902. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3903. } try {
  3904. $sickrageHistory = getSickrageCalendarHistory($sickrage->history("100","downloaded"));
  3905. if(!empty($sickrageHistory)) { $calendarItems = array_merge($calendarItems, $sickrageHistory); }
  3906. } catch (Exception $e) {
  3907. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3908. }
  3909. }
  3910. return $calendarItems;
  3911. }
  3912. function localURL($url){
  3913. if (strpos($url, 'https') !== false) {
  3914. preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $url, $result);
  3915. $result = (!empty($result) ? true : false);
  3916. return $result;
  3917. }
  3918. }
  3919. function fileArray($files){
  3920. foreach($files as $file){
  3921. if(file_exists($file)){
  3922. $list[] = $file;
  3923. }
  3924. }
  3925. if(!empty($list)){ return $list; }
  3926. }
  3927. function backupDB(){
  3928. if (extension_loaded('ZIP')) {
  3929. $directory = DATABASE_LOCATION."backups/";
  3930. @mkdir($directory, 0770, true);
  3931. $orgFiles = array(
  3932. 'css' => 'custom.css',
  3933. 'temp' => 'cus.sd',
  3934. 'orgLog' => DATABASE_LOCATION.'org.log',
  3935. 'loginLog' => DATABASE_LOCATION.'loginLog.json',
  3936. 'chatDB' => 'chatpack.db',
  3937. 'config' => 'config/config.php',
  3938. 'database' => DATABASE_LOCATION.'users.db'
  3939. );
  3940. $files = fileArray($orgFiles);
  3941. if(!empty($files)){
  3942. writeLog("success", "BACKUP: backup process started");
  3943. $zipname = $directory.'backup['.date('Y-m-d_H-i').']['.INSTALLEDVERSION.'].zip';
  3944. $zip = new ZipArchive;
  3945. $zip->open($zipname, ZipArchive::CREATE);
  3946. foreach ($files as $file) {
  3947. $zip->addFile($file);
  3948. }
  3949. $zip->close();
  3950. writeLog("success", "BACKUP: backup process finished");
  3951. return true;
  3952. }else{
  3953. return false;
  3954. }
  3955. }else{
  3956. return false;
  3957. }
  3958. }
  3959. class Ping {
  3960. private $host;
  3961. private $ttl;
  3962. private $timeout;
  3963. private $port = 80;
  3964. private $data = 'Ping';
  3965. private $commandOutput;
  3966. /**
  3967. * Called when the Ping object is created.
  3968. *
  3969. * @param string $host
  3970. * The host to be pinged.
  3971. * @param int $ttl
  3972. * Time-to-live (TTL) (You may get a 'Time to live exceeded' error if this
  3973. * value is set too low. The TTL value indicates the scope or range in which
  3974. * a packet may be forwarded. By convention:
  3975. * - 0 = same host
  3976. * - 1 = same subnet
  3977. * - 32 = same site
  3978. * - 64 = same region
  3979. * - 128 = same continent
  3980. * - 255 = unrestricted
  3981. * @param int $timeout
  3982. * Timeout (in seconds) used for ping and fsockopen().
  3983. * @throws \Exception if the host is not set.
  3984. */
  3985. public function __construct($host, $ttl = 255, $timeout = 10) {
  3986. if (!isset($host)) {
  3987. throw new \Exception("Error: Host name not supplied.");
  3988. }
  3989. $this->host = $host;
  3990. $this->ttl = $ttl;
  3991. $this->timeout = $timeout;
  3992. }
  3993. /**
  3994. * Set the ttl (in hops).
  3995. *
  3996. * @param int $ttl
  3997. * TTL in hops.
  3998. */
  3999. public function setTtl($ttl) {
  4000. $this->ttl = $ttl;
  4001. }
  4002. /**
  4003. * Get the ttl.
  4004. *
  4005. * @return int
  4006. * The current ttl for Ping.
  4007. */
  4008. public function getTtl() {
  4009. return $this->ttl;
  4010. }
  4011. /**
  4012. * Set the timeout.
  4013. *
  4014. * @param int $timeout
  4015. * Time to wait in seconds.
  4016. */
  4017. public function setTimeout($timeout) {
  4018. $this->timeout = $timeout;
  4019. }
  4020. /**
  4021. * Get the timeout.
  4022. *
  4023. * @return int
  4024. * Current timeout for Ping.
  4025. */
  4026. public function getTimeout() {
  4027. return $this->timeout;
  4028. }
  4029. /**
  4030. * Set the host.
  4031. *
  4032. * @param string $host
  4033. * Host name or IP address.
  4034. */
  4035. public function setHost($host) {
  4036. $this->host = $host;
  4037. }
  4038. /**
  4039. * Get the host.
  4040. *
  4041. * @return string
  4042. * The current hostname for Ping.
  4043. */
  4044. public function getHost() {
  4045. return $this->host;
  4046. }
  4047. /**
  4048. * Set the port (only used for fsockopen method).
  4049. *
  4050. * Since regular pings use ICMP and don't need to worry about the concept of
  4051. * 'ports', this is only used for the fsockopen method, which pings servers by
  4052. * checking port 80 (by default).
  4053. *
  4054. * @param int $port
  4055. * Port to use for fsockopen ping (defaults to 80 if not set).
  4056. */
  4057. public function setPort($port) {
  4058. $this->port = $port;
  4059. }
  4060. /**
  4061. * Get the port (only used for fsockopen method).
  4062. *
  4063. * @return int
  4064. * The port used by fsockopen pings.
  4065. */
  4066. public function getPort() {
  4067. return $this->port;
  4068. }
  4069. /**
  4070. * Return the command output when method=exec.
  4071. * @return string
  4072. */
  4073. public function getCommandOutput(){
  4074. return $this->commandOutput;
  4075. }
  4076. /**
  4077. * Matches an IP on command output and returns.
  4078. * @return string
  4079. */
  4080. public function getIpAddress() {
  4081. $out = array();
  4082. if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $this->commandOutput, $out)){
  4083. return $out[0];
  4084. }
  4085. return null;
  4086. }
  4087. /**
  4088. * Ping a host.
  4089. *
  4090. * @param string $method
  4091. * Method to use when pinging:
  4092. * - exec (default): Pings through the system ping command. Fast and
  4093. * robust, but a security risk if you pass through user-submitted data.
  4094. * - fsockopen: Pings a server on port 80.
  4095. * - socket: Creates a RAW network socket. Only usable in some
  4096. * environments, as creating a SOCK_RAW socket requires root privileges.
  4097. *
  4098. * @throws InvalidArgumentException if $method is not supported.
  4099. *
  4100. * @return mixed
  4101. * Latency as integer, in ms, if host is reachable or FALSE if host is down.
  4102. */
  4103. public function ping($method = 'exec') {
  4104. $latency = false;
  4105. switch ($method) {
  4106. case 'exec':
  4107. $latency = $this->pingExec();
  4108. break;
  4109. case 'fsockopen':
  4110. $latency = $this->pingFsockopen();
  4111. break;
  4112. case 'socket':
  4113. $latency = $this->pingSocket();
  4114. break;
  4115. default:
  4116. throw new \InvalidArgumentException('Unsupported ping method.');
  4117. }
  4118. // Return the latency.
  4119. return $latency;
  4120. }
  4121. /**
  4122. * The exec method uses the possibly insecure exec() function, which passes
  4123. * the input to the system. This is potentially VERY dangerous if you pass in
  4124. * any user-submitted data. Be SURE you sanitize your inputs!
  4125. *
  4126. * @return int
  4127. * Latency, in ms.
  4128. */
  4129. private function pingExec() {
  4130. $latency = false;
  4131. $ttl = escapeshellcmd($this->ttl);
  4132. $timeout = escapeshellcmd($this->timeout);
  4133. $host = escapeshellcmd($this->host);
  4134. // Exec string for Windows-based systems.
  4135. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  4136. // -n = number of pings; -i = ttl; -w = timeout (in milliseconds).
  4137. $exec_string = 'ping -n 1 -i ' . $ttl . ' -w ' . ($timeout * 1000) . ' ' . $host;
  4138. }
  4139. // Exec string for Darwin based systems (OS X).
  4140. else if(strtoupper(PHP_OS) === 'DARWIN') {
  4141. // -n = numeric output; -c = number of pings; -m = ttl; -t = timeout.
  4142. $exec_string = 'ping -n -c 1 -m ' . $ttl . ' -t ' . $timeout . ' ' . $host;
  4143. }
  4144. // Exec string for other UNIX-based systems (Linux).
  4145. else {
  4146. // -n = numeric output; -c = number of pings; -t = ttl; -W = timeout
  4147. $exec_string = 'ping -n -c 1 -t ' . $ttl . ' -W ' . $timeout . ' ' . $host . ' 2>&1';
  4148. }
  4149. exec($exec_string, $output, $return);
  4150. // Strip empty lines and reorder the indexes from 0 (to make results more
  4151. // uniform across OS versions).
  4152. $this->commandOutput = implode($output, '');
  4153. $output = array_values(array_filter($output));
  4154. // If the result line in the output is not empty, parse it.
  4155. if (!empty($output[1])) {
  4156. // Search for a 'time' value in the result line.
  4157. $response = preg_match("/time(?:=|<)(?<time>[\.0-9]+)(?:|\s)ms/", $output[1], $matches);
  4158. // If there's a result and it's greater than 0, return the latency.
  4159. if ($response > 0 && isset($matches['time'])) {
  4160. $latency = round($matches['time'], 2);
  4161. }
  4162. }
  4163. return $latency;
  4164. }
  4165. /**
  4166. * The fsockopen method simply tries to reach the host on a port. This method
  4167. * is often the fastest, but not necessarily the most reliable. Even if a host
  4168. * doesn't respond, fsockopen may still make a connection.
  4169. *
  4170. * @return int
  4171. * Latency, in ms.
  4172. */
  4173. private function pingFsockopen() {
  4174. $start = microtime(true);
  4175. // fsockopen prints a bunch of errors if a host is unreachable. Hide those
  4176. // irrelevant errors and deal with the results instead.
  4177. $fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
  4178. if (!$fp) {
  4179. $latency = false;
  4180. }
  4181. else {
  4182. $latency = microtime(true) - $start;
  4183. $latency = round($latency * 1000, 2);
  4184. }
  4185. return $latency;
  4186. }
  4187. /**
  4188. * The socket method uses raw network packet data to try sending an ICMP ping
  4189. * packet to a server, then measures the response time. Using this method
  4190. * requires the script to be run with root privileges, though, so this method
  4191. * only works reliably on Windows systems and on Linux servers where the
  4192. * script is not being run as a web user.
  4193. *
  4194. * @return int
  4195. * Latency, in ms.
  4196. */
  4197. private function pingSocket() {
  4198. // Create a package.
  4199. $type = "\x08";
  4200. $code = "\x00";
  4201. $checksum = "\x00\x00";
  4202. $identifier = "\x00\x00";
  4203. $seq_number = "\x00\x00";
  4204. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4205. // Calculate the checksum.
  4206. $checksum = $this->calculateChecksum($package);
  4207. // Finalize the package.
  4208. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4209. // Create a socket, connect to server, then read socket and calculate.
  4210. if ($socket = socket_create(AF_INET, SOCK_RAW, 1)) {
  4211. socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array(
  4212. 'sec' => 10,
  4213. 'usec' => 0,
  4214. ));
  4215. // Prevent errors from being printed when host is unreachable.
  4216. @socket_connect($socket, $this->host, null);
  4217. $start = microtime(true);
  4218. // Send the package.
  4219. @socket_send($socket, $package, strlen($package), 0);
  4220. if (socket_read($socket, 255) !== false) {
  4221. $latency = microtime(true) - $start;
  4222. $latency = round($latency * 1000, 2);
  4223. }
  4224. else {
  4225. $latency = false;
  4226. }
  4227. }
  4228. else {
  4229. $latency = false;
  4230. }
  4231. // Close the socket.
  4232. socket_close($socket);
  4233. return $latency;
  4234. }
  4235. /**
  4236. * Calculate a checksum.
  4237. *
  4238. * @param string $data
  4239. * Data for which checksum will be calculated.
  4240. *
  4241. * @return string
  4242. * Binary string checksum of $data.
  4243. */
  4244. private function calculateChecksum($data) {
  4245. if (strlen($data) % 2) {
  4246. $data .= "\x00";
  4247. }
  4248. $bit = unpack('n*', $data);
  4249. $sum = array_sum($bit);
  4250. while ($sum >> 16) {
  4251. $sum = ($sum >> 16) + ($sum & 0xffff);
  4252. }
  4253. return pack('n*', ~$sum);
  4254. }
  4255. }
  4256. function ping($pings, $type = "string") {
  4257. $ping = new Ping("");
  4258. $ping->setTtl(128);
  4259. $ping->setTimeout(2);
  4260. switch ($type){
  4261. case "array":
  4262. $results = [];
  4263. foreach ($pings as $k => $v) {
  4264. if(strpos($v, ':') !== false){
  4265. $domain = explode(':', $v)[0];
  4266. $port = explode(':', $v)[1];
  4267. $ping->setHost($domain);
  4268. $ping->setPort($port);
  4269. $latency = $ping->ping('fsockopen');
  4270. }else{
  4271. $ping->setHost($v);
  4272. $latency = $ping->ping();
  4273. }
  4274. if ($latency || $latency === 0) {
  4275. $results[$k] = $latency;
  4276. } else {
  4277. $results[$k] = 0;
  4278. }
  4279. }
  4280. break;
  4281. case "string":
  4282. if(strpos($pings, ':') !== false){
  4283. $domain = explode(':', $pings)[0];
  4284. $port = explode(':', $pings)[1];
  4285. $ping->setHost($domain);
  4286. $ping->setPort($port);
  4287. $latency = $ping->ping('fsockopen');
  4288. }else{
  4289. $ping->setHost($pings);
  4290. $latency = $ping->ping();
  4291. }
  4292. if ($latency || $latency === 0) {
  4293. $results = $latency;
  4294. } else {
  4295. $results = 0;
  4296. }
  4297. break;
  4298. }
  4299. return $results;
  4300. }
  4301. function getPing($url, $style, $refresh = null){
  4302. if(ping($url) !== 0){
  4303. $class = 'success';
  4304. if(!$refresh){
  4305. $class .= " animated slideInLeft";
  4306. }
  4307. }else{
  4308. $class = "warning";
  4309. if(!$refresh){
  4310. $class .= " animated flash loop-animation-timeout";
  4311. }
  4312. }
  4313. $style = htmlspecialchars($style, ENT_QUOTES);
  4314. echo '<span class="pingcheck badge ping-'.$class.'" style="position: absolute;z-index: 100;right: 5px; padding: 0px 0px;'.$style.';font-size: 10px;">&nbsp;</span>';
  4315. }
  4316. function speedTestData(){
  4317. $file_db = DATABASE_LOCATION."speedtest.db";
  4318. if(file_exists($file_db)){
  4319. $conn = new PDO("sqlite:$file_db") or die("1");
  4320. $result = $conn->query('SELECT * FROM speedtest_users');
  4321. $conn = null;
  4322. if (is_array($result) || is_object($result)){
  4323. foreach($result as $k => $v){
  4324. $return[$k] = $v;
  4325. }
  4326. return $return;
  4327. }
  4328. }
  4329. }
  4330. function speedTestDisplay($array, $output){
  4331. if (is_array($array) || is_object($array)){
  4332. if($output == "graph"){
  4333. $result = "Morris.Line({element: 'morris-line',data: [";
  4334. foreach($array as $k => $v){
  4335. $result .= "{ y: '".substr($v['timestamp'],0,10)."', a: ".$v['ul'].", b: ".$v['dl'].", c: ".$v['ping']." },";
  4336. }
  4337. $result .= "],xkey: 'y',ykeys: ['a', 'b', 'c'],labels: ['Upload', 'Download', 'Ping'],hideHover: 'auto',resize: true,lineColors: ['#63A8EB','#ccc','#000'] });";
  4338. }elseif($output == "table"){
  4339. $result = "";
  4340. foreach($array as $k => $v){
  4341. $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>";
  4342. }
  4343. }
  4344. return $result;
  4345. }
  4346. }
  4347. function buildMenuPhone($array){
  4348. if (is_array($array) || is_object($array)){
  4349. $result = '
  4350. <div class="content-box profile-sidebar box-shadow">
  4351. <img src="images/organizr-logo-h-d.png" width="100%" style="margin-top: -10px;">
  4352. <div class="profile-usermenu">
  4353. <ul class="nav" id="settings-list">
  4354. ';
  4355. foreach($array as $k => $v){
  4356. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4357. continue;
  4358. }
  4359. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4360. continue;
  4361. }
  4362. /*$result .= '
  4363. <li>
  4364. <a id="'.$v['id'].'" box="'.$v['box'].'">'.$v['name'].'
  4365. <span class="fa-stack fa-fw pull-right" style="margin-top: -5px;margin-right: -10px;">
  4366. <i class="fa fa-'.$v['icon_1'].' fa-stack-2x '.$v['color'].'" style="font-size:null;"></i>
  4367. <i class="fa fa-'.$v['icon_2'].' fa-stack-1x fa-inverse"></i>
  4368. </span>
  4369. </a>
  4370. </li>
  4371. ';*/
  4372. $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>';
  4373. }
  4374. $result .= '</ul></div></div>';
  4375. return $result;
  4376. }
  4377. }
  4378. function buildMenu($array){
  4379. if (is_array($array) || is_object($array)){
  4380. $result = '<div class="settingsList">';
  4381. foreach($array as $k => $v){
  4382. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4383. continue;
  4384. }
  4385. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4386. continue;
  4387. }
  4388. $result .= '
  4389. <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">
  4390. <i class="mdi mdi-'.$v['icon_1'].' fa-fw pull-left" style="padding-left: '.$v['padding'].'px;font-size: 30px"></i>
  4391. <p class="" style="text-align: center;direction: rtl;display:none;margin: 2px;"><strong>'.$v['name'].'</strong></p>
  4392. </button>
  4393. ';
  4394. }
  4395. $result .= '</div>';
  4396. return $result;
  4397. }
  4398. }
  4399. function requestInvite($email, $username){
  4400. //sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null)
  4401. 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."));
  4402. }
  4403. function errormessage($msg) {
  4404. echo "<div style=\"margin-top: 50px;\">";
  4405. echo "<span style=\"color:#d89334;\">error </span>";
  4406. echo $msg;
  4407. echo "</div>";
  4408. }
  4409. function ajaxLoop($ajaxFunction, $refresh, $extraFunction = ''){
  4410. return "
  4411. setInterval(function() {
  4412. $.ajax({
  4413. url: 'ajax.php?a=".$ajaxFunction."',
  4414. timeout: 10000,
  4415. type: 'GET',
  4416. success: function(response) {
  4417. var getDiv = response;
  4418. var loadedID = $(getDiv).attr('id');
  4419. if (typeof loadedID !== 'undefined') {
  4420. var oldElement = $('#'+loadedID).prop('outerHTML');
  4421. var newElement = $(getDiv).prop('outerHTML');
  4422. if(oldElement !== newElement){
  4423. $('#'+loadedID).replaceWith($(getDiv).prop('outerHTML'));
  4424. ".$extraFunction."
  4425. console.log('".$ajaxFunction." has been updated');
  4426. }
  4427. }else{
  4428. console.log('".$ajaxFunction." data was not sufficent or is offline');
  4429. }
  4430. },
  4431. error: function(jqXHR, textStatus, errorThrown) {
  4432. console.error('".$ajaxFunction." could not be updated');
  4433. }
  4434. });
  4435. }, ".$refresh.");
  4436. ";
  4437. }
  4438. function getOrgUsers(){
  4439. $file_db = DATABASE_LOCATION."users.db";
  4440. if(file_exists($file_db)){
  4441. $conn = new PDO("sqlite:$file_db") or die("1");
  4442. $result = $conn->query('SELECT * FROM users');
  4443. $conn = null;
  4444. if (is_array($result) || is_object($result)){
  4445. foreach($result as $k => $v){
  4446. $return[$v['username']] = $v['email'];
  4447. }
  4448. return $return;
  4449. }
  4450. }
  4451. }
  4452. function getEmails($type = 'org'){
  4453. if($type == 'plex'){
  4454. $emails = array_merge(libraryList()['both'],getOrgUsers());
  4455. }elseif($type == 'emby'){
  4456. $emails = getOrgUsers();
  4457. }else{
  4458. $emails = getOrgUsers();
  4459. }
  4460. return $emails;
  4461. }
  4462. function printEmails($emails){
  4463. $result = '';
  4464. foreach($emails as $k => $v){
  4465. $result .= '<option value="'.$v.'">'.$k.'</option>';
  4466. }
  4467. return $result;
  4468. }
  4469. function massEmail($to, $subject, $message){
  4470. if (!isset($GLOBALS['file_db'])) {
  4471. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  4472. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  4473. }
  4474. $emailTemplate = array(
  4475. 'type' => 'mass',
  4476. 'body' => $message,
  4477. 'subject' => $subject,
  4478. 'user' => null,
  4479. 'password' => null,
  4480. 'inviteCode' => null,
  4481. );
  4482. $emailTemplate = emailTemplate($emailTemplate);
  4483. $subject = $emailTemplate['subject'];
  4484. $body = buildEmail($emailTemplate);
  4485. sendEmail(null, null, $subject, $body, $GLOBALS['USER']->adminEmail,$to);
  4486. }
  4487. function q2a($q){
  4488. if (is_array($q) || is_object($q)){
  4489. foreach ($q as $k => $v){
  4490. $a[$k] = $v;
  4491. }
  4492. if(!empty($a)){
  4493. return $a;
  4494. }
  4495. }
  4496. }
  4497. function getOmbiToken($username, $password){
  4498. $headers = array(
  4499. "Accept" => "application/json",
  4500. "Content-Type" => "application/json"
  4501. );
  4502. $json = array(
  4503. "username" => $username,
  4504. "password" => $password,
  4505. "rememberMe" => "true",
  4506. );
  4507. $api = curl_post(OMBIURL."/api/v1/Token", $json, $headers);
  4508. if (isset($api['content'])) {
  4509. return json_decode($api['content'], true)['access_token'];
  4510. }else{
  4511. return false;
  4512. }
  4513. }
  4514. function ombiAction($id, $action, $type){
  4515. $headers = array(
  4516. "Accept" => "application/json",
  4517. "Content-Type" => "application/json",
  4518. "Apikey" => OMBIKEY
  4519. );
  4520. $body = array(
  4521. 'id' => $id,
  4522. );
  4523. switch ($type) {
  4524. case 'season':
  4525. case 'tv':
  4526. $type = 'tv';
  4527. break;
  4528. default:
  4529. $type = 'movie';
  4530. break;
  4531. }
  4532. switch ($action) {
  4533. case 'approve':
  4534. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/approve", $body, $headers);
  4535. break;
  4536. case 'available':
  4537. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/available", $body, $headers);
  4538. break;
  4539. case 'unavailable':
  4540. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/unavailable", $body, $headers);
  4541. break;
  4542. case 'deny':
  4543. $api = curl_put(OMBIURL."/api/v1/Request/".$type."/deny", $body, $headers);
  4544. break;
  4545. case 'delete':
  4546. $api = curl_delete(OMBIURL."/api/v1/Request/".$type."/".$id, $headers);
  4547. break;
  4548. default:
  4549. # code...
  4550. break;
  4551. }
  4552. switch ($api['http_code']['http_code']){
  4553. case 401:
  4554. writeLog("error", "OMBI: Invalid API KEY");
  4555. return false;
  4556. break;
  4557. case 200:
  4558. writeLog("success", "OMBI: action completed successfully for [type: $type - action: $action - id: $id]");
  4559. return true;
  4560. break;
  4561. default:
  4562. writeLog("error", "OMBI: unknown error with request [type: $type - action: $action - id: $id]");
  4563. return false;
  4564. }
  4565. //return (!empty($result) ? $result : null );
  4566. }
  4567. function getOmbiRequests($type = "both"){
  4568. $headers = array(
  4569. "Accept" => "application/json",
  4570. "Apikey" => OMBIKEY,
  4571. );
  4572. $requests = array();
  4573. switch ($type) {
  4574. case 'movie':
  4575. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4576. break;
  4577. case 'tv':
  4578. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4579. break;
  4580. default:
  4581. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4582. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4583. break;
  4584. }
  4585. if(isset($movie)){
  4586. //$movie = array_reverse($movie);
  4587. foreach ($movie as $key => $value) {
  4588. $poster = explode('/',$value['posterPath']);
  4589. $requests[] = array(
  4590. 'id' => $value['theMovieDbId'],
  4591. 'title' => $value['title'],
  4592. 'poster' => (strpos($value['posterPath'], "/") !== false) ? 'https://image.tmdb.org/t/p/w300/'.end($poster) : 'https://image.tmdb.org/t/p/w300/'.$value['posterPath'],
  4593. 'approved' => $value['approved'],
  4594. 'available' => $value['available'],
  4595. 'denied' => $value['denied'],
  4596. 'deniedReason' => $value['deniedReason'],
  4597. 'user' => $value['requestedUser']['userName'],
  4598. 'request_id' => $value['id'],
  4599. 'request_date' => $value['requestedDate'],
  4600. 'release_date' => $value['releaseDate'],
  4601. 'type' => 'movie',
  4602. 'icon' => 'mdi mdi-filmstrip',
  4603. 'color' => 'palette-Deep-Purple-900 bg white',
  4604. );
  4605. }
  4606. }
  4607. if(isset($tv) && (is_array($tv) || is_object($tv))){
  4608. foreach ($tv as $key => $value) {
  4609. if(is_array($value['childRequests'][0])){
  4610. $requests[] = array(
  4611. 'id' => $value['tvDbId'],
  4612. 'title' => $value['title'],
  4613. 'poster' => $value['posterPath'],
  4614. 'approved' => $value['childRequests'][0]['approved'],
  4615. 'available' => $value['childRequests'][0]['available'],
  4616. 'denied' => $value['childRequests'][0]['denied'],
  4617. 'deniedReason' => $value['childRequests'][0]['deniedReason'],
  4618. 'user' => $value['childRequests'][0]['requestedUser']['userName'],
  4619. 'request_id' => $value['id'],
  4620. 'request_date' => $value['childRequests'][0]['requestedDate'],
  4621. 'release_date' => $value['releaseDate'],
  4622. 'type' => 'tv',
  4623. 'icon' => 'mdi mdi-television',
  4624. 'color' => 'grayish-blue-bg',
  4625. );
  4626. }
  4627. }
  4628. }
  4629. return (empty($requests)) ? '' : $requests;
  4630. }
  4631. function convertOmbiString($type, $value){
  4632. switch ($type) {
  4633. case 'approved':
  4634. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4635. $string['icon'] = ($value) ? 'mdi mdi-check' : 'mdi mdi-clock';
  4636. $string['color'] = ($value) ? 'green-bg' : 'yellow-bg';
  4637. break;
  4638. case 'available':
  4639. $string['string'] = ($value) ? 'Available' : 'Not Downloaded';
  4640. $string['icon'] = ($value) ? 'mdi mdi-server' : 'mdi mdi-server-off';
  4641. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4642. break;
  4643. case 'denied':
  4644. $string['string'] = ($value) ? 'Denied' : 'Approved';
  4645. $string['icon'] = ($value) ? 'mdi mdi-emoticon-sad' : 'mdi mdi-emoticon-happy';
  4646. $string['color'] = ($value) ? 'red-bg' : 'green-bg';
  4647. break;
  4648. case 'status':
  4649. switch ($value) {
  4650. case '1':
  4651. $string['string'] = 'Denied';
  4652. $string['icon'] = 'mdi mdi-window-close';
  4653. $string['color'] = 'red-bg';
  4654. break;
  4655. case '2':
  4656. $string['string'] = 'Approved';
  4657. $string['icon'] = 'mdi mdi-check';
  4658. $string['color'] = 'green-bg';
  4659. break;
  4660. case '3':
  4661. $string['string'] = 'Not Approved';
  4662. $string['icon'] = 'mdi mdi-clock';
  4663. $string['color'] = 'yellow-bg';
  4664. break;
  4665. default:
  4666. # code...
  4667. break;
  4668. }
  4669. break;
  4670. default:
  4671. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4672. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4673. break;
  4674. }
  4675. return $string;
  4676. }
  4677. function buildOmbiItem($type, $group, $user, $request){
  4678. if (is_array($request) || is_object($request)){
  4679. $actions = '';
  4680. if($request['denied']){
  4681. $status = 1;
  4682. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4683. }else{
  4684. if($request['approved']){
  4685. $status = 2;
  4686. }else{
  4687. $status = 3;
  4688. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4689. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="deny"><a class="requestAction" href="javascript:void(0)">Deny</a></li>';
  4690. }
  4691. }
  4692. if($request['available']){
  4693. $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>';
  4694. }else{
  4695. $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>';
  4696. }
  4697. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="delete"><a class="requestAction" href="javascript:void(0)">Delete</a></li>';
  4698. if(isset($group) && $group == 'admin'){
  4699. $actionMenu = '
  4700. <div class="requestOptions">
  4701. <div class="btn-group transparent" role="group">
  4702. <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>
  4703. <ul class="dropdown-menu"><h6 class="text-center requestHeader gray-bg">'.$request['user'].'</h6>'.$actions.'</ul>
  4704. </div>
  4705. </div>
  4706. ';
  4707. }else{
  4708. $actionMenu = '';
  4709. }
  4710. if((isset($group)) && $group == 'admin' || REQUESTEDUSERONLY == 'false'){
  4711. return '
  4712. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4713. '.$actionMenu.'
  4714. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4715. <div class="requestBottom text-center">
  4716. <div data-toggle="tooltip" data-placement="top" data-original-title="'.$request['type'].'" class="zero-m requestGroup '.$request['color'].'">
  4717. <i class="'.$request['icon'].'"></i>
  4718. </div>
  4719. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4720. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4721. </div>
  4722. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4723. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4724. </div>
  4725. </div>
  4726. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4727. </div>';
  4728. }else{
  4729. if(strtolower($request['user']) == strtolower($user)){
  4730. return '
  4731. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4732. '.$actionMenu.'
  4733. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4734. <div class="requestBottom text-center">
  4735. <div data-toggle="tooltip" data-placement="top" data-original-title="'.$request['type'].'" class="zero-m requestGroup '.$request['color'].'">
  4736. <i class="'.$request['icon'].'"></i>
  4737. </div>
  4738. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4739. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4740. </div>
  4741. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4742. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4743. </div>
  4744. </div>
  4745. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4746. </div>';
  4747. }
  4748. }
  4749. }
  4750. }
  4751. function buildOmbiList($group, $user){
  4752. $requests = array();
  4753. $movieList = getOmbiRequests('movie');
  4754. $tvList = getOmbiRequests('tv');
  4755. if(is_array($movieList) && is_array($tvList)){
  4756. $result = array_merge($movieList , $tvList );
  4757. }else{
  4758. if(is_array($movieList)){
  4759. $result = $movieList;
  4760. }elseif(is_array($tvList)){
  4761. $result = $tvList;
  4762. }else{
  4763. $result = false;
  4764. }
  4765. }
  4766. if (is_array($result) || is_object($result)){
  4767. usort($result, function ($item1, $item2) {
  4768. if ($item1['request_date'] == $item2['request_date']) return 0;
  4769. return $item1['request_date'] > $item2['request_date'] ? -1 : 1;
  4770. });
  4771. foreach ($result as $request) {
  4772. if($request['type'] == 'movie'){
  4773. $requests[] = buildOmbiItem('movie', $group, $user, $request);
  4774. }elseif($request['type'] == 'tv'){
  4775. $requests[] = buildOmbiItem('season', $group, $user, $request);
  4776. }
  4777. }
  4778. }
  4779. return outputOmbiRequests("Requested Content", $requests, ajaxLoop('ombi-requests',REQUESTREFRESH,'loadSlick();'), false);
  4780. }
  4781. function outputOmbiRequests($header = "Requested Content", $items, $script = false, $array) {
  4782. $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">';
  4783. if(preg_grep("/item-movie-Approved/", $items)){
  4784. $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>';
  4785. }
  4786. if(preg_grep("/item-movie-Approval-Pending/", $items)){
  4787. $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>';
  4788. }
  4789. if(preg_grep("/item-season-Approved/", $items)){
  4790. $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>';
  4791. }
  4792. if(preg_grep("/item-season-Approval-Pending/", $items)){
  4793. $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>';
  4794. }
  4795. $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>';
  4796. $hideMenu .= '</ul></div></div>';
  4797. // If None Populate Empty Item
  4798. //if (count(array_flip($items)) < 1) {
  4799. if(!array_filter($items)) {
  4800. return '<div id="recentRequests"></div>';
  4801. }else{
  4802. $className = str_replace(' ', '', $header);
  4803. return '<div id="recentRequests" class="content-box box-shadow big-box"><h5 id="requestContent-title" style="margin-bottom: -20px" class="text-center"><span>'.$header.'</span></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>':'');
  4804. }
  4805. }
  4806. function ombiAPI($action){
  4807. $headers = array(
  4808. "Accept" => "application/json",
  4809. "Content-Type" => "application/json",
  4810. "Apikey" => OMBIKEY
  4811. );
  4812. $body = array();
  4813. switch ($action) {
  4814. case 'plex-cache':
  4815. $api = curl_post(OMBIURL."/api/v1/Job/plexcontentcacher", $body, $headers);
  4816. break;
  4817. default:
  4818. break;
  4819. }
  4820. if(is_array($api) || is_object($api)){
  4821. switch ($api['http_code']['http_code']){
  4822. case 200:
  4823. return true;
  4824. break;
  4825. default:
  4826. return false;
  4827. }
  4828. }else{
  4829. return false;
  4830. }
  4831. }
  4832. function loadIcons(){
  4833. $dirname = "images/";
  4834. $images = scandir($dirname);
  4835. $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");
  4836. $allIcons = '';
  4837. foreach($images as $curimg){
  4838. if(!in_array($curimg, $ignore)) {
  4839. $allIcons .= '
  4840. <div class="col-xs-2" style="width: 75px; height: 75px; padding-right: 0px;">
  4841. <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);">
  4842. <img style="width: 50px; height: 50px;" data-src="'.$dirname.$curimg.'" alt="thumbnail" class="allIcons lazyload shadow">
  4843. </a>
  4844. </div>
  4845. ';
  4846. }
  4847. }
  4848. return $allIcons;
  4849. }
  4850. function buildHomepageSettings(){
  4851. $homepageOrder = homepageOrder();
  4852. $homepageList = '<h4>Drag Homepage Items to Order Them</h4><div id="homepage-items" class="external-events">';
  4853. $inputList = '<div id="homepage-values" class="row">';
  4854. foreach ($homepageOrder as $key => $val) {
  4855. switch ($key) {
  4856. case 'homepageOrdercustomhtml':
  4857. $class = 'palette-Deep-Purple-100 bg gray';
  4858. $image = 'images/html.png';
  4859. if(empty(HOMEPAGECUSTOMHTML1)){
  4860. $class .= ' faded';
  4861. }
  4862. break;
  4863. case 'homepageOrdernotice':
  4864. $class = 'palette-Cyan-A400 bg gray';
  4865. $image = 'images/pin.png';
  4866. if(empty(HOMEPAGENOTICETITLE) && empty(HOMEPAGENOTICEMESSAGE)){
  4867. $class .= ' faded';
  4868. }
  4869. break;
  4870. case 'homepageOrdernoticeguest':
  4871. $class = 'palette-Cyan-A400 bg gray';
  4872. $image = 'images/pin.png';
  4873. if(empty(HOMEPAGENOTICETITLEGUEST) && empty(HOMEPAGENOTICEMESSAGEGUEST)){
  4874. $class .= ' faded';
  4875. }
  4876. break;
  4877. case 'homepageOrderspeedtest':
  4878. $class = 'red-bg';
  4879. $image = 'images/settings/full-color/png/64px/speedometer.png';
  4880. if(SPEEDTEST !== "true"){
  4881. $class .= ' faded';
  4882. }
  4883. break;
  4884. case 'homepageOrdertransmisson':
  4885. $class = 'green-bg';
  4886. $image = 'images/transmission.png';
  4887. if(empty(TRANSMISSIONURL)){
  4888. $class .= ' faded';
  4889. }
  4890. break;
  4891. case 'homepageOrdernzbget':
  4892. $class = 'green-bg';
  4893. $image = 'images/nzbget.png';
  4894. if(empty(NZBGETURL)){
  4895. $class .= ' faded';
  4896. }
  4897. break;
  4898. case 'homepageOrdersabnzbd':
  4899. $class = 'yellow-bg';
  4900. $image = 'images/sabnzbd.png';
  4901. if(empty(SABNZBDURL)){
  4902. $class .= ' faded';
  4903. }
  4904. break;
  4905. case 'homepageOrderplexsearch':
  4906. case 'homepageOrderplexnowplaying':
  4907. case 'homepageOrderplexrecent':
  4908. case 'homepageOrderplexplaylist':
  4909. $class = 'palette-Amber-A700 bg gray';
  4910. $image = 'images/plex.png';
  4911. if(empty(PLEXURL)){
  4912. $class .= ' faded';
  4913. }
  4914. break;
  4915. case 'homepageOrderembynowplaying':
  4916. case 'homepageOrderembyrecent':
  4917. $class = 'palette-Green-A700 bg gray';
  4918. $image = 'images/emby.png';
  4919. if(empty(EMBYURL)){
  4920. $class .= ' faded';
  4921. }
  4922. break;
  4923. case 'homepageOrderombi':
  4924. $class = 'orange-bg';
  4925. $image = 'images/ombi.png';
  4926. if(empty(OMBIURL)){
  4927. $class .= ' faded';
  4928. }
  4929. break;
  4930. case 'homepageOrdercalendar':
  4931. $class = 'palette-Blue-400 bg gray';
  4932. $image = 'images/calendar.png';
  4933. if(SONARRURL == "" && RADARRURL == "" && HEADPHONESURL == "" && SICKRAGEURL == "" && COUCHURL == "" ){
  4934. $class .= ' faded';
  4935. }
  4936. break;
  4937. default:
  4938. $class = 'blue-bg';
  4939. $image = '';
  4940. break;
  4941. }
  4942. $homepageList .= '
  4943. <div class="col-md-3 sort-homepage"><div class="fc-event '.$class.'">
  4944. <span class="ordinal-position text-uppercase badge badge-gray" data-link="'.$key.'" style="float:left;width: 30px;">'.$val.'</span>
  4945. &nbsp; '.strtoupper(substr($key, 13)).'
  4946. <span class="remove-event"><img style="width: 22px;" src="'.$image.'"></span>
  4947. </div></div>';
  4948. $inputList .= '<input type="hidden" name="'.$key.'">';
  4949. }
  4950. $homepageList .= '</div>';
  4951. $inputList .= '</div>';
  4952. return $homepageList.$inputList;
  4953. }
  4954. function buildHomepage($group, $user){
  4955. $homepageOrder = homepageOrder();
  4956. $homepageBuilt = '';
  4957. foreach ($homepageOrder as $key => $value) {
  4958. $homepageBuilt .= buildHomepageItem($key, $group, $user);
  4959. }
  4960. return $homepageBuilt;
  4961. }
  4962. function realSize($bytes, $decimals = 2) {
  4963. $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
  4964. $factor = floor((strlen($bytes) - 1) / 3);
  4965. return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' '.@$size[$factor];
  4966. }
  4967. function buildHomepageItem($homepageItem, $group, $user){
  4968. $homepageItemBuilt = '';
  4969. switch ($homepageItem) {
  4970. case 'homepageOrderplexsearch':
  4971. if((qualifyUser(PLEXSEARCHAUTH) && PLEXSEARCH == "true" && qualifyUser(PLEXHOMEAUTH))) {
  4972. $homepageItemBuilt .= '
  4973. <div id="searchPlexRow" class="row">
  4974. <div class="col-lg-12">
  4975. <div class="content-box box-shadow big-box todo-list">
  4976. <form id="plexSearchForm" onsubmit="return false;" autocomplete="off">
  4977. <div class="">
  4978. <div class="input-group">
  4979. <div style="border-radius: 25px 0 0 25px; border:0" class="input-group-addon gray-bg"><i class="fa fa-search white"></i></div>
  4980. <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">
  4981. <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>
  4982. <button style="display:none" id="plexSearchForm_submit" class="btn btn-primary waves"></button>
  4983. </div>
  4984. </div>
  4985. </form>
  4986. <div id="resultshere" class="table-responsive"></div>
  4987. </div>
  4988. </div>
  4989. </div>
  4990. ';
  4991. }
  4992. break;
  4993. case 'homepageOrdercustomhtml':
  4994. if (qualifyUser(HOMEPAGECUSTOMHTML1AUTH) && HOMEPAGECUSTOMHTML1) {
  4995. $homepageItemBuilt .= "<div>" . HOMEPAGECUSTOMHTML1 . "</div>";
  4996. }
  4997. break;
  4998. case 'homepageOrdernotice':
  4999. if (qualifyUser(HOMEPAGENOTICEAUTH) && HOMEPAGENOTICETITLE && HOMEPAGENOTICETYPE && HOMEPAGENOTICEMESSAGE && HOMEPAGENOTICELAYOUT) {
  5000. $homepageItemBuilt .= buildHomepageNotice(HOMEPAGENOTICELAYOUT, HOMEPAGENOTICETYPE, HOMEPAGENOTICETITLE, HOMEPAGENOTICEMESSAGE);
  5001. }
  5002. break;
  5003. case 'homepageOrdernoticeguest':
  5004. if ($group == 'guest' && HOMEPAGENOTICETITLEGUEST && HOMEPAGENOTICETYPEGUEST && HOMEPAGENOTICEMESSAGEGUEST && HOMEPAGENOTICELAYOUTGUEST) {
  5005. $homepageItemBuilt .= buildHomepageNotice(HOMEPAGENOTICELAYOUTGUEST, HOMEPAGENOTICETYPEGUEST, HOMEPAGENOTICETITLEGUEST, HOMEPAGENOTICEMESSAGEGUEST);
  5006. }
  5007. break;
  5008. case 'homepageOrderspeedtest':
  5009. if(SPEEDTEST == "true" && qualifyUser(SPEEDTESTAUTH)){
  5010. $homepageItemBuilt .= '
  5011. <style type="text/css">
  5012. .flash {
  5013. animation: flash 0.6s linear infinite;
  5014. }
  5015. @keyframes flash {
  5016. 0% { opacity: 0.6; }
  5017. 50% { opacity: 1; }
  5018. }
  5019. </style>
  5020. <script type="text/javascript">
  5021. var w = null
  5022. function runTest() {
  5023. document.getElementById("startBtn").style.display = "none"
  5024. document.getElementById("testArea").style.display = ""
  5025. document.getElementById("abortBtn").style.display = ""
  5026. w = new Worker("bower_components/speed/speedtest_worker.js")
  5027. var interval = setInterval(function () { w.postMessage("status") }, 100)
  5028. w.onmessage = function (event) {
  5029. var data = event.data.split(";")
  5030. var status = Number(data[0])
  5031. var dl = document.getElementById("download")
  5032. var ul = document.getElementById("upload")
  5033. var ping = document.getElementById("ping")
  5034. var jitter = document.getElementById("jitter")
  5035. dl.className = status === 1 ? "w-name flash" : "w-name"
  5036. ping.className = status === 2 ? "w-name flash" : "w-name"
  5037. jitter.className = ul.className = status === 3 ? "w-name flash" : "w-name"
  5038. if (status >= 4) {
  5039. clearInterval(interval)
  5040. document.getElementById("abortBtn").style.display = "none"
  5041. document.getElementById("startBtn").style.display = ""
  5042. w = null
  5043. }
  5044. if (status === 5) {
  5045. document.getElementById("testArea").style.display = "none"
  5046. }
  5047. dl.textContent = data[1] + " Mbit/s";
  5048. $("#downloadpercent").attr("style", "width: " + data[1] + "%;");
  5049. $("#uploadpercent").attr("style", "width: " + data[2] + "%;");
  5050. $("#pingpercent").attr("style", "width: " + data[3] + "%;");
  5051. $("#jitterpercent").attr("style", "width: " + data[5] + "%;");
  5052. ul.textContent = data[2] + " Mbit/s";
  5053. ping.textContent = data[3] + " ms";
  5054. jitter.textContent = data[5] + " ms";
  5055. }
  5056. w.postMessage(\'start {"telemetry_level":"basic"}\')
  5057. //w.postMessage("start")
  5058. }
  5059. function abortTest() {
  5060. if (w) w.postMessage("abort")
  5061. }
  5062. </script>
  5063. <div class="row" id="testArea" style="display:none">
  5064. <div class="test col-sm-3 col-lg-3">
  5065. <div class="content-box ultra-widget green-bg" data-counter="">
  5066. <div id="downloadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  5067. <div class="w-content">
  5068. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-download"></i></div>
  5069. <div class="w-descr left pull-left text-center">
  5070. <span class="testName text-uppercase w-name">Download</span>
  5071. <br>
  5072. <span class="w-name counter" id="download" ></span>
  5073. </div>
  5074. </div>
  5075. </div>
  5076. </div>
  5077. <div class="test col-sm-3 col-lg-3">
  5078. <div class="content-box ultra-widget red-bg" data-counter="">
  5079. <div id="uploadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  5080. <div class="w-content">
  5081. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-upload"></i></div>
  5082. <div class="w-descr left pull-left text-center">
  5083. <span class="testName text-uppercase w-name">Upload</span>
  5084. <br>
  5085. <span class="w-name counter" id="upload" ></span>
  5086. </div>
  5087. </div>
  5088. </div>
  5089. </div>
  5090. <div class="test col-sm-3 col-lg-3">
  5091. <div class="content-box ultra-widget yellow-bg" data-counter="">
  5092. <div id="pingpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  5093. <div class="w-content">
  5094. <div class="w-icon right pull-right"><i class="mdi mdi-timer"></i></div>
  5095. <div class="w-descr left pull-left text-center">
  5096. <span class="testName text-uppercase w-name">Latency</span>
  5097. <br>
  5098. <span class="w-name counter" id="ping" ></span>
  5099. </div>
  5100. </div>
  5101. </div>
  5102. </div>
  5103. <div class="test col-sm-3 col-lg-3">
  5104. <div class="content-box ultra-widget blue-bg" data-counter="">
  5105. <div id="jitterpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  5106. <div class="w-content">
  5107. <div class="w-icon right pull-right"><i class="mdi mdi-pulse"></i></div>
  5108. <div class="w-descr left pull-left text-center">
  5109. <span class="testName text-uppercase w-name">Jitter</span>
  5110. <br>
  5111. <span class="w-name counter" id="jitter" ></span>
  5112. </div>
  5113. </div>
  5114. </div>
  5115. </div>
  5116. <br/>
  5117. </div>
  5118. <div id="abortBtn" class="row" style="display: none" onclick="javascript:abortTest()">
  5119. <div class="col-lg-12">
  5120. <div class="content-box red-bg" style="cursor: pointer;">
  5121. <h1 style="margin: 10px" class="text-uppercase text-center">Abort Speed Test</h1>
  5122. <div class="clearfix"></div>
  5123. </div>
  5124. </div>
  5125. </div>
  5126. <div id="startBtn" class="row" onclick="javascript:runTest()">
  5127. <div class="col-lg-12">
  5128. <div class="content-box green-bg" style="cursor: pointer;">
  5129. <h1 style="margin: 10px" class="text-uppercase text-center">Run Speed Test</h1>
  5130. <div class="clearfix"></div>
  5131. </div>
  5132. </div>
  5133. </div>
  5134. ';
  5135. }
  5136. break;
  5137. case 'homepageOrdertransmisson':
  5138. if(TRANSMISSIONURL != "" && qualifyUser(TRANSMISSIONHOMEAUTH)){
  5139. $homepageItemBuilt .= buildDownloader('transmission', 'no');
  5140. }
  5141. break;
  5142. case 'homepageOrdernzbget':
  5143. if(NZBGETURL != "" && qualifyUser(NZBGETHOMEAUTH)){
  5144. $homepageItemBuilt .= buildDownloader('nzbget');
  5145. }
  5146. break;
  5147. case 'homepageOrdersabnzbd':
  5148. if(SABNZBDURL != "" && qualifyUser(SABNZBDHOMEAUTH)) {
  5149. $homepageItemBuilt .= buildDownloader('sabnzbd');
  5150. }
  5151. break;
  5152. case 'homepageOrderplexnowplaying':
  5153. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  5154. if(qualifyUser(PLEXPLAYINGNOWAUTH) && PLEXPLAYINGNOW == "true"){
  5155. $homepageItemBuilt .= '<div id="plexRowNowPlaying" class="row">';
  5156. $homepageItemBuilt .= getPlexStreams(12, PLEXSHOWNAMES, $group);
  5157. $homepageItemBuilt .= '</div>';
  5158. }
  5159. }
  5160. break;
  5161. case 'homepageOrderplexrecent':
  5162. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  5163. if(qualifyUser(PLEXRECENTMOVIEAUTH) && PLEXRECENTMOVIE == "true" || qualifyUser(PLEXRECENTTVAUTH) && PLEXRECENTTV == "true" || qualifyUser(PLEXRECENTMUSICAUTH) && PLEXRECENTMUSIC == "true"){
  5164. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  5165. $homepageItemBuilt .= '<div id="plexRow" class="row"><div class="col-lg-12">';
  5166. $homepageItemBuilt .= getPlexRecent($plexArray);
  5167. $homepageItemBuilt .= '</div></div>';
  5168. }
  5169. }
  5170. break;
  5171. case 'homepageOrderplexplaylist':
  5172. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  5173. if(qualifyUser(PLEXPLAYLISTSAUTH) && PLEXPLAYLISTS == "true"){
  5174. $homepageItemBuilt .= '<div id="plexPlaylists" class="row"><div class="col-lg-12">';
  5175. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  5176. $homepageItemBuilt .= getPlexPlaylists($plexArray);
  5177. $homepageItemBuilt .= '</div> </div>';
  5178. }
  5179. }
  5180. break;
  5181. case 'homepageOrderembynowplaying':
  5182. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  5183. if(qualifyUser(EMBYPLAYINGNOWAUTH) && EMBYPLAYINGNOW == "true"){
  5184. $homepageItemBuilt .= '<div id="embyRowNowPlaying" class="row">';
  5185. $homepageItemBuilt .= getEmbyStreams(12, EMBYSHOWNAMES, $group);
  5186. $homepageItemBuilt .= '</div>';
  5187. }
  5188. }
  5189. break;
  5190. case 'homepageOrderembyrecent':
  5191. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  5192. if(qualifyUser(EMBYRECENTMOVIEAUTH) && EMBYRECENTMOVIE == "true" || qualifyUser(EMBYRECENTTVAUTH) && EMBYRECENTTV == "true" || qualifyUser(EMBYRECENTMUSICAUTH) && EMBYRECENTMUSIC == "true"){
  5193. $embyArray = array("Movie" => EMBYRECENTMOVIE, "Episode" => EMBYRECENTTV, "MusicAlbum" => EMBYRECENTMUSIC, "Series" => EMBYRECENTTV);
  5194. $homepageItemBuilt .= '<div id="embyRow" class="row"><div class="col-lg-12">';
  5195. $homepageItemBuilt .= getEmbyRecent($embyArray);
  5196. $homepageItemBuilt .= '</div></div>';
  5197. }
  5198. }
  5199. break;
  5200. case 'homepageOrderombi':
  5201. if (qualifyUser(OMBIAUTH) && OMBIURL) {
  5202. $homepageItemBuilt .= '<div id="ombiRequests" class="row"><div class="col-lg-12">';
  5203. $homepageItemBuilt .= buildOmbiList($group, $user);
  5204. $homepageItemBuilt .= '</div></div>';
  5205. }
  5206. break;
  5207. case 'homepageOrdercalendar':
  5208. if ((SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)) || (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)) || (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)) || (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)) || (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH))) {
  5209. $calendarItems = '';
  5210. if(RADARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="film" href="javascript:void(0)">Movies</a></li>'; }
  5211. if(SONARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="tv" href="javascript:void(0)">TV Shows</a></li>'; }
  5212. if(HEADPHONESURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="music" href="javascript:void(0)">Music</a></li>'; }
  5213. $homepageItemBuilt .= '
  5214. <div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">
  5215. <div class="col-lg-12 content-form form-inline">
  5216. <div class="form-group pull-right">
  5217. <span class="swal-legend label label-primary well-sm">Legend</span>&nbsp;
  5218. <div class="btn-group" role="group">
  5219. <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>
  5220. <ul style="right:0; left: auto" class="dropdown-menu">
  5221. <li><a class="calendarOption" calendarOption="all" href="javascript:void(0)">View All</a></li>
  5222. '.$calendarItems.'
  5223. </ul>
  5224. </div>
  5225. </div>
  5226. </div>
  5227. </div>
  5228. <div id="calendarRow" class="row">
  5229. <div class="col-lg-12">
  5230. <div id="calendar" class="fc-calendar box-shadow fc fc-ltr fc-unthemed"></div>
  5231. </div>
  5232. </div>
  5233. ';
  5234. }
  5235. break;
  5236. default:
  5237. # code...
  5238. break;
  5239. }
  5240. return $homepageItemBuilt;
  5241. }
  5242. function buildAccordion($items){
  5243. $i = 1;
  5244. $variables = '&nbsp; Available Variables: ';
  5245. $accordion = '<div style="margin-bottom: 0px;" class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">';
  5246. foreach ($items as $key => $value) {
  5247. if($value['type'] == 'template' || $value['type'] == 'templateCustom'){
  5248. foreach ($value['variables'] as $variable) {
  5249. $variables .= '<mark>'.$variable.'</mark>';
  5250. }
  5251. $templateCustom = '
  5252. <div class="form-content col-sm-12 col-md-12 col-lg-12">
  5253. <input id="'.$value['template'].'Name_id" name="'.$value['template'].'Name" type="text" class="form-control material input-sm" autocorrect="off" autocapitalize="off" value="'.$value['title'].'">
  5254. <p class="help-text">Custom Template Name</p>
  5255. </div>
  5256. ';
  5257. $accordion .= '
  5258. <div class="panel panel-default">
  5259. <div class="panel-heading" role="tab" id="heading-'.$i.'">
  5260. <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>
  5261. </div>
  5262. <div id="collapse-'.$i.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-'.$i.'" aria-expanded="true">
  5263. <br/>'.$variables.'<br/></br/>
  5264. '.$templateCustom.'
  5265. <div class="form-content col-sm-12 col-md-12 col-lg-12">
  5266. <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'].'">
  5267. <p class="help-text">Email Subject</p>
  5268. </div>
  5269. <br/></br/>
  5270. <div class="summernote" name="'.$value['template'].'">'.$value['body'].'</div>
  5271. </div>
  5272. </div>
  5273. ';
  5274. $i++;
  5275. $variables = '&nbsp; Available Variables: ';
  5276. }else{
  5277. $accordion .= '
  5278. <div class="panel panel-default">
  5279. <div class="panel-heading" role="tab" id="heading-'.$i.'">
  5280. <h4 class="panel-title" style="text-decoration: none;" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-'.$i.'" aria-expanded="true" aria-controls="collapse-'.$i.'">Logo URL For Title</h4>
  5281. </div>
  5282. <div id="collapse-'.$i.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-'.$i.'" aria-expanded="true">
  5283. <div class="form-content col-sm-12 col-md-12 col-lg-12">
  5284. <input id="'.$value['name'].'_id" name="'.$value['name'].'" type="text" class="form-control material input-sm" autocorrect="off" autocapitalize="off" value="'.$value['value'].'">
  5285. <p class="help-text">Logo URL For Title</p>
  5286. </div>
  5287. <br/></br/><br/>
  5288. </div>
  5289. </div>
  5290. ';
  5291. $i++;
  5292. }
  5293. }
  5294. $accordion .= '</div>';
  5295. return $accordion;
  5296. }
  5297. function emailTemplate($emailTemplate){
  5298. $variables = [
  5299. '{user}' => $emailTemplate['user'],
  5300. '{domain}' => DOMAIN,
  5301. '{password}' => $emailTemplate['password'],
  5302. '{inviteCode}' => $emailTemplate['inviteCode'],
  5303. '{fullDomain}' => getServerPath(),
  5304. ];
  5305. $emailTemplate['body'] = strtr($emailTemplate['body'], $variables);
  5306. $emailTemplate['subject'] = strtr($emailTemplate['subject'], $variables);
  5307. return $emailTemplate;
  5308. }
  5309. function buildEmail($email){
  5310. $subject = (isset($email['subject'])) ? $email['subject'] : 'Message from Server';
  5311. $body = (isset($email['body'])) ? $email['body'] : 'Message Error Occured';
  5312. $type = (isset($email['type'])) ? $email['type'] : 'No Type';
  5313. switch ($type) {
  5314. case 'invite':
  5315. $extra = 'invite';
  5316. break;
  5317. case 'reset':
  5318. $extra = 'reset';
  5319. break;
  5320. default:
  5321. $extra = null;
  5322. break;
  5323. }
  5324. include('email.php');
  5325. return $email;
  5326. }
  5327. function buildDownloader($name, $type = 'both'){
  5328. if($type == 'both'){
  5329. $tabs = '
  5330. <ul class="nav nav-tabs pull-right">
  5331. <li class="active"><a href="#downloadQueue-'.$name.'" data-toggle="tab" aria-expanded="true">'.translate("QUEUE").'</a></li>
  5332. <li class=""><a href="#downloadHistory-'.$name.'" data-toggle="tab" aria-expanded="false">'.translate("HISTORY").'</a></li>
  5333. </ul>
  5334. ';
  5335. $bodyHistory = '
  5336. <div class="tab-pane fade" id="downloadHistory-'.$name.'">
  5337. <div class="table-responsive" style="max-height: 300px">
  5338. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  5339. <thead>
  5340. <tr>
  5341. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  5342. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  5343. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  5344. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  5345. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  5346. </tr>
  5347. </thead>
  5348. <tbody class="dl-history '.$name.'"></tbody>
  5349. </table>
  5350. </div>
  5351. </div>
  5352. ';
  5353. }else{
  5354. $tabs = '';
  5355. $bodyHistory = '';
  5356. }
  5357. return '
  5358. <div id="downloadClientRow" class="row">
  5359. <div class="col-xs-12 col-md-12">
  5360. <div class="content-box">
  5361. <div class="tabbable panel with-nav-tabs panel-default">
  5362. <div class="panel-heading">
  5363. <div class="content-tools i-block pull-right">
  5364. <a id="getDownloader" class="repeat-btn">
  5365. <i class="fa fa-repeat"></i>
  5366. </a>
  5367. </div>
  5368. <h3 class="pull-left"><span>'.strtoupper($name).'</span></h3>
  5369. '.$tabs.'
  5370. <div class="clearfix"></div>
  5371. </div>
  5372. <div class="panel-body">
  5373. <div class="tab-content">
  5374. <div class="tab-pane fade active in" id="downloadQueue-'.$name.'">
  5375. <div class="table-responsive" style="max-height: 300px">
  5376. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  5377. <thead>
  5378. <tr>
  5379. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  5380. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  5381. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  5382. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  5383. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  5384. </tr>
  5385. </thead>
  5386. <tbody class="dl-queue '.$name.'"></tbody>
  5387. </table>
  5388. </div>
  5389. </div>
  5390. '.$bodyHistory.'
  5391. </div>
  5392. </div>
  5393. </div>
  5394. </div>
  5395. </div>
  5396. </div>';
  5397. }
  5398. class Mobile_Detect
  5399. {
  5400. /**
  5401. * Mobile detection type.
  5402. *
  5403. * @deprecated since version 2.6.9
  5404. */
  5405. const DETECTION_TYPE_MOBILE = 'mobile';
  5406. /**
  5407. * Extended detection type.
  5408. *
  5409. * @deprecated since version 2.6.9
  5410. */
  5411. const DETECTION_TYPE_EXTENDED = 'extended';
  5412. /**
  5413. * A frequently used regular expression to extract version #s.
  5414. *
  5415. * @deprecated since version 2.6.9
  5416. */
  5417. const VER = '([\w._\+]+)';
  5418. /**
  5419. * Top-level device.
  5420. */
  5421. const MOBILE_GRADE_A = 'A';
  5422. /**
  5423. * Mid-level device.
  5424. */
  5425. const MOBILE_GRADE_B = 'B';
  5426. /**
  5427. * Low-level device.
  5428. */
  5429. const MOBILE_GRADE_C = 'C';
  5430. /**
  5431. * Stores the version number of the current release.
  5432. */
  5433. const VERSION = '2.8.26';
  5434. /**
  5435. * A type for the version() method indicating a string return value.
  5436. */
  5437. const VERSION_TYPE_STRING = 'text';
  5438. /**
  5439. * A type for the version() method indicating a float return value.
  5440. */
  5441. const VERSION_TYPE_FLOAT = 'float';
  5442. /**
  5443. * A cache for resolved matches
  5444. * @var array
  5445. */
  5446. protected $cache = array();
  5447. /**
  5448. * The User-Agent HTTP header is stored in here.
  5449. * @var string
  5450. */
  5451. protected $userAgent = null;
  5452. /**
  5453. * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
  5454. * @var array
  5455. */
  5456. protected $httpHeaders = array();
  5457. /**
  5458. * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
  5459. * @var array
  5460. */
  5461. protected $cloudfrontHeaders = array();
  5462. /**
  5463. * The matching Regex.
  5464. * This is good for debug.
  5465. * @var string
  5466. */
  5467. protected $matchingRegex = null;
  5468. /**
  5469. * The matches extracted from the regex expression.
  5470. * This is good for debug.
  5471. * @var string
  5472. */
  5473. protected $matchesArray = null;
  5474. /**
  5475. * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
  5476. *
  5477. * @deprecated since version 2.6.9
  5478. *
  5479. * @var string
  5480. */
  5481. protected $detectionType = self::DETECTION_TYPE_MOBILE;
  5482. /**
  5483. * HTTP headers that trigger the 'isMobile' detection
  5484. * to be true.
  5485. *
  5486. * @var array
  5487. */
  5488. protected static $mobileHeaders = array(
  5489. 'HTTP_ACCEPT' => array('matches' => array(
  5490. // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
  5491. 'application/x-obml2d',
  5492. // BlackBerry devices.
  5493. 'application/vnd.rim.html',
  5494. 'text/vnd.wap.wml',
  5495. 'application/vnd.wap.xhtml+xml'
  5496. )),
  5497. 'HTTP_X_WAP_PROFILE' => null,
  5498. 'HTTP_X_WAP_CLIENTID' => null,
  5499. 'HTTP_WAP_CONNECTION' => null,
  5500. 'HTTP_PROFILE' => null,
  5501. // Reported by Opera on Nokia devices (eg. C3).
  5502. 'HTTP_X_OPERAMINI_PHONE_UA' => null,
  5503. 'HTTP_X_NOKIA_GATEWAY_ID' => null,
  5504. 'HTTP_X_ORANGE_ID' => null,
  5505. 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
  5506. 'HTTP_X_HUAWEI_USERID' => null,
  5507. // Reported by Windows Smartphones.
  5508. 'HTTP_UA_OS' => null,
  5509. // Reported by Verizon, Vodafone proxy system.
  5510. 'HTTP_X_MOBILE_GATEWAY' => null,
  5511. // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
  5512. 'HTTP_X_ATT_DEVICEID' => null,
  5513. // Seen this on a HTC.
  5514. 'HTTP_UA_CPU' => array('matches' => array('ARM')),
  5515. );
  5516. /**
  5517. * List of mobile devices (phones).
  5518. *
  5519. * @var array
  5520. */
  5521. protected static $phoneDevices = array(
  5522. 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
  5523. 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
  5524. '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',
  5525. 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
  5526. // @todo: Is 'Dell Streak' a tablet or a phone? ;)
  5527. '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',
  5528. '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',
  5529. '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',
  5530. '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)',
  5531. 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
  5532. 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
  5533. 'NokiaLumia' => 'Lumia [0-9]{3,4}',
  5534. // http://www.micromaxinfo.com/mobiles/smartphones
  5535. // Added because the codes might conflict with Acer Tablets.
  5536. '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',
  5537. // @todo Complete the regex.
  5538. 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
  5539. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
  5540. // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
  5541. // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
  5542. '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',
  5543. // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
  5544. 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
  5545. // http://fr.wikomobile.com
  5546. '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',
  5547. 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
  5548. // Added simvalley mobile just for fun. They have some interesting devices.
  5549. // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
  5550. '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',
  5551. // Wolfgang - a brand that is sold by Aldi supermarkets.
  5552. // http://www.wolfgangmobile.com/
  5553. 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
  5554. 'Alcatel' => 'Alcatel',
  5555. 'Nintendo' => 'Nintendo 3DS',
  5556. // http://en.wikipedia.org/wiki/Amoi
  5557. 'Amoi' => 'Amoi',
  5558. // http://en.wikipedia.org/wiki/INQ
  5559. 'INQ' => 'INQ',
  5560. // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
  5561. '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',
  5562. );
  5563. /**
  5564. * List of tablet devices.
  5565. *
  5566. * @var array
  5567. */
  5568. protected static $tabletDevices = array(
  5569. // @todo: check for mobile friendly emails topic.
  5570. 'iPad' => 'iPad|iPad.*Mobile',
  5571. // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
  5572. // @see #442
  5573. 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
  5574. '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.
  5575. // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
  5576. '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)',
  5577. // Only the Surface tablets with Windows RT are considered mobile.
  5578. // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
  5579. 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
  5580. // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
  5581. 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
  5582. // Watch out for PadFone, see #132.
  5583. // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
  5584. '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',
  5585. 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
  5586. 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
  5587. 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
  5588. 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
  5589. // http://www.acer.ro/ac/ro/RO/content/drivers
  5590. // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
  5591. // http://us.acer.com/ac/en/US/content/group/tablets
  5592. // http://www.acer.de/ac/de/DE/content/models/tablets/
  5593. // Can conflict with Micromax and Motorola phones codes.
  5594. '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',
  5595. // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
  5596. // http://us.toshiba.com/tablets/tablet-finder
  5597. // http://www.toshiba.co.jp/regza/tablet/
  5598. 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
  5599. // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
  5600. // http://www.lg.com/us/tablets
  5601. 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
  5602. 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
  5603. // Prestigio Tablets http://www.prestigio.com/support
  5604. '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',
  5605. // http://support.lenovo.com/en_GB/downloads/default.page?#
  5606. '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|)',
  5607. // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
  5608. 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
  5609. // http://www.yarvik.com/en/matrix/tablets/
  5610. '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',
  5611. 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
  5612. 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
  5613. // http://www.intenso.de/kategorie_en.php?kategorie=33
  5614. // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
  5615. 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
  5616. // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
  5617. 'IRUTablet' => 'M702pro',
  5618. 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
  5619. // http://www.e-boda.ro/tablete-pc.html
  5620. 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
  5621. // http://www.allview.ro/produse/droseries/lista-tablete-pc/
  5622. 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
  5623. // http://wiki.archosfans.com/index.php?title=Main_Page
  5624. // @note Rewrite the regex format after we add more UAs.
  5625. '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',
  5626. // http://www.ainol.com/plugin.php?identifier=ainol&module=product
  5627. 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
  5628. 'NokiaLumiaTablet' => 'Lumia 2520',
  5629. // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
  5630. // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
  5631. // http://www.sony.jp/support/tablet/
  5632. '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',
  5633. // 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
  5634. 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
  5635. // db + http://www.cube-tablet.com/buy-products.html
  5636. 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
  5637. // http://www.cobyusa.com/?p=pcat&pcat_id=3001
  5638. 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
  5639. // http://www.match.net.cn/products.asp
  5640. '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',
  5641. // http://www.msi.com/support
  5642. // @todo Research the Windows Tablets.
  5643. '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',
  5644. // @todo http://www.kyoceramobile.com/support/drivers/
  5645. // 'KyoceraTablet' => null,
  5646. // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
  5647. // 'IntextTablet' => null,
  5648. // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
  5649. // http://www.imp3.net/14/show.php?itemid=20454
  5650. 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
  5651. // http://www.rock-chips.com/index.php?do=prod&pid=2
  5652. 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
  5653. // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
  5654. 'FlyTablet' => 'IQ310|Fly Vision',
  5655. // http://www.bqreaders.com/gb/tablets-prices-sale.html
  5656. 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
  5657. // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
  5658. // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
  5659. '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',
  5660. // Nec or Medias Tab
  5661. 'NecTablet' => '\bN-06D|\bN-08D',
  5662. // Pantech Tablets: http://www.pantechusa.com/phones/
  5663. 'PantechTablet' => 'Pantech.*P4100',
  5664. // Broncho Tablets: http://www.broncho.cn/ (hard to find)
  5665. 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
  5666. // http://versusuk.com/support.html
  5667. 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
  5668. // http://www.zync.in/index.php/our-products/tablet-phablets
  5669. 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
  5670. // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
  5671. 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
  5672. // https://www.nabitablet.com/
  5673. 'NabiTablet' => 'Android.*\bNabi',
  5674. 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
  5675. // French Danew Tablets http://www.danew.com/produits-tablette.php
  5676. 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
  5677. // Texet Tablets and Readers http://www.texet.ru/tablet/
  5678. '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',
  5679. // Avoid detecting 'PLAYSTATION 3' as mobile.
  5680. 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
  5681. // http://www.trekstor.de/surftabs.html
  5682. 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
  5683. // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
  5684. 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
  5685. // http://www.advandigital.com/index.php?link=content-product&jns=JP001
  5686. // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
  5687. '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 ',
  5688. // http://www.danytech.com/category/tablet-pc
  5689. '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',
  5690. // http://www.galapad.net/product.html
  5691. 'GalapadTablet' => 'Android.*\bG1\b',
  5692. // http://www.micromaxinfo.com/tablet/funbook
  5693. 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
  5694. // http://www.karbonnmobiles.com/products_tablet.php
  5695. 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
  5696. // http://www.myallfine.com/Products.asp
  5697. 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
  5698. // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
  5699. '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',
  5700. // http://www.yonesnav.com/products/products.php
  5701. 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
  5702. // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
  5703. // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
  5704. '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',
  5705. // http://www.gloryunion.cn/products.asp
  5706. // http://www.allwinnertech.com/en/apply/mobile.html
  5707. // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
  5708. // @todo: Softwiner tablets?
  5709. // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
  5710. '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
  5711. // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
  5712. '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',
  5713. // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
  5714. // @todo: add more tests.
  5715. 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
  5716. // http://hclmetablet.com/India/index.php
  5717. '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',
  5718. // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
  5719. 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
  5720. // http://www.visture.com/index.asp
  5721. 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
  5722. // http://www.mijncresta.nl/tablet
  5723. 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
  5724. // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
  5725. 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
  5726. // Concorde tab
  5727. 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
  5728. // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
  5729. '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',
  5730. // Modecom Tablets - http://www.modecom.eu/tablets/portal/
  5731. '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',
  5732. // Vonino Tablets - http://www.vonino.eu/tablets
  5733. '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',
  5734. // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
  5735. 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
  5736. // Storex Tablets - http://storex.fr/espace_client/support.html
  5737. // @note: no need to add all the tablet codes since they are guided by the first regex.
  5738. 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
  5739. // Generic Vodafone tablets.
  5740. 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
  5741. // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
  5742. // Aka: http://www.essentielb.fr/
  5743. 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
  5744. // Ross & Moor - http://ross-moor.ru/
  5745. 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
  5746. // i-mobile http://product.i-mobilephone.com/Mobile_Device
  5747. 'iMobileTablet' => 'i-mobile i-note',
  5748. // http://www.tolino.de/de/vergleichen/
  5749. 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
  5750. // AudioSonic - a Kmart brand
  5751. // 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
  5752. 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
  5753. // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
  5754. // @todo: add them gradually to avoid conflicts.
  5755. 'AMPETablet' => 'Android.* A78 ',
  5756. // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
  5757. 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
  5758. // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
  5759. 'TecnoTablet' => 'TECNO P9',
  5760. // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
  5761. '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',
  5762. // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
  5763. '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)',
  5764. // http://www.intracon.eu/tablet
  5765. 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
  5766. // http://www.xoro.de/produkte/
  5767. // @note: Might be the same brand with 'Simply tablets'
  5768. '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',
  5769. // http://www1.viewsonic.com/products/computing/tablets/
  5770. 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
  5771. // http://www.odys.de/web/internet-tablet_en.html
  5772. 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
  5773. // http://www.captiva-power.de/products.html#tablets-en
  5774. 'CaptivaTablet' => 'CAPTIVA PAD',
  5775. // IconBIT - http://www.iconbit.com/products/tablets/
  5776. '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',
  5777. // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
  5778. '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',
  5779. // Onda - http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
  5780. '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]+',
  5781. 'JaytechTablet' => 'TPC-PA762',
  5782. 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
  5783. // http://www.digma.ru/support/download/
  5784. // @todo: Ebooks also (if requested)
  5785. 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
  5786. // http://www.evolioshop.com/ro/tablete-pc.html
  5787. // http://www.evolio.ro/support/downloads_static.html?cat=2
  5788. // @todo: Research some more
  5789. 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
  5790. // @todo http://www.lavamobiles.com/tablets-data-cards
  5791. 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
  5792. // http://www.breezetablet.com/
  5793. 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
  5794. // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
  5795. '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',
  5796. // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
  5797. 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
  5798. // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
  5799. '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',
  5800. // http://www.mi.com/en
  5801. 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
  5802. // http://www.nbru.cn/index.html
  5803. 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
  5804. // http://navroad.com/products/produkty/tablety/
  5805. // http://navroad.com/products/produkty/tablety/
  5806. 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
  5807. // http://leader-online.com/new_site/product-category/tablets/
  5808. // http://www.leader-online.net.au/List/Tablet
  5809. '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',
  5810. // http://www.datawind.com/ubislate/
  5811. 'UbislateTablet' => 'UbiSlate[\s]?7C',
  5812. // http://www.pocketbook-int.com/ru/support
  5813. 'PocketBookTablet' => 'Pocketbook',
  5814. // http://www.kocaso.com/product_tablet.html
  5815. 'KocasoTablet' => '\b(TB-1207)\b',
  5816. // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
  5817. 'HisenseTablet' => '\b(F5281|E2371)\b',
  5818. // http://www.tesco.com/direct/hudl/
  5819. 'Hudl' => 'Hudl HT7S3|Hudl 2',
  5820. // http://www.telstra.com.au/home-phone/thub-2/
  5821. 'TelstraTablet' => 'T-Hub2',
  5822. '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'
  5823. );
  5824. /**
  5825. * List of mobile Operating Systems.
  5826. *
  5827. * @var array
  5828. */
  5829. protected static $operatingSystems = array(
  5830. 'AndroidOS' => 'Android',
  5831. 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
  5832. 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
  5833. 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
  5834. // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
  5835. 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
  5836. // @reference: http://en.wikipedia.org/wiki/Windows_Phone
  5837. // http://wifeng.cn/?r=blog&a=view&id=106
  5838. // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
  5839. // http://msdn.microsoft.com/library/ms537503.aspx
  5840. // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
  5841. 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
  5842. 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
  5843. // http://en.wikipedia.org/wiki/MeeGo
  5844. // @todo: research MeeGo in UAs
  5845. 'MeeGoOS' => 'MeeGo',
  5846. // http://en.wikipedia.org/wiki/Maemo
  5847. // @todo: research Maemo in UAs
  5848. 'MaemoOS' => 'Maemo',
  5849. 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
  5850. 'webOS' => 'webOS|hpwOS',
  5851. 'badaOS' => '\bBada\b',
  5852. 'BREWOS' => 'BREW',
  5853. );
  5854. /**
  5855. * List of mobile User Agents.
  5856. *
  5857. * IMPORTANT: This is a list of only mobile browsers.
  5858. * Mobile Detect 2.x supports only mobile browsers,
  5859. * it was never designed to detect all browsers.
  5860. * The change will come in 2017 in the 3.x release for PHP7.
  5861. *
  5862. * @var array
  5863. */
  5864. protected static $browsers = array(
  5865. //'Vivaldi' => 'Vivaldi',
  5866. // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
  5867. 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
  5868. 'Dolfin' => '\bDolfin\b',
  5869. 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
  5870. 'Skyfire' => 'Skyfire',
  5871. 'Edge' => 'Mobile Safari/[.0-9]* Edge',
  5872. 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
  5873. 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
  5874. 'Bolt' => 'bolt',
  5875. 'TeaShark' => 'teashark',
  5876. 'Blazer' => 'Blazer',
  5877. // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
  5878. 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
  5879. // http://en.wikipedia.org/wiki/Midori_(web_browser)
  5880. //'Midori' => 'midori',
  5881. //'Tizen' => 'Tizen',
  5882. 'UCBrowser' => 'UC.*Browser|UCWEB',
  5883. 'baiduboxapp' => 'baiduboxapp',
  5884. 'baidubrowser' => 'baidubrowser',
  5885. // https://github.com/serbanghita/Mobile-Detect/issues/7
  5886. 'DiigoBrowser' => 'DiigoBrowser',
  5887. // http://www.puffinbrowser.com/index.php
  5888. 'Puffin' => 'Puffin',
  5889. // http://mercury-browser.com/index.html
  5890. 'Mercury' => '\bMercury\b',
  5891. // http://en.wikipedia.org/wiki/Obigo_Browser
  5892. 'ObigoBrowser' => 'Obigo',
  5893. // http://en.wikipedia.org/wiki/NetFront
  5894. 'NetFront' => 'NF-Browser',
  5895. // @reference: http://en.wikipedia.org/wiki/Minimo
  5896. // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
  5897. 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
  5898. // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
  5899. 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
  5900. );
  5901. /**
  5902. * Utilities.
  5903. *
  5904. * @var array
  5905. */
  5906. protected static $utilities = array(
  5907. // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
  5908. // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
  5909. // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
  5910. // https://developers.facebook.com/docs/sharing/best-practices
  5911. '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',
  5912. 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
  5913. 'DesktopMode' => 'WPDesktop',
  5914. 'TV' => 'SonyDTV|HbbTV', // experimental
  5915. 'WebKit' => '(webkit)[ /]([\w.]+)',
  5916. // @todo: Include JXD consoles.
  5917. 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
  5918. 'Watch' => 'SM-V700',
  5919. );
  5920. /**
  5921. * All possible HTTP headers that represent the
  5922. * User-Agent string.
  5923. *
  5924. * @var array
  5925. */
  5926. protected static $uaHttpHeaders = array(
  5927. // The default User-Agent string.
  5928. 'HTTP_USER_AGENT',
  5929. // Header can occur on devices using Opera Mini.
  5930. 'HTTP_X_OPERAMINI_PHONE_UA',
  5931. // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
  5932. 'HTTP_X_DEVICE_USER_AGENT',
  5933. 'HTTP_X_ORIGINAL_USER_AGENT',
  5934. 'HTTP_X_SKYFIRE_PHONE',
  5935. 'HTTP_X_BOLT_PHONE_UA',
  5936. 'HTTP_DEVICE_STOCK_UA',
  5937. 'HTTP_X_UCBROWSER_DEVICE_UA'
  5938. );
  5939. /**
  5940. * The individual segments that could exist in a User-Agent string. VER refers to the regular
  5941. * expression defined in the constant self::VER.
  5942. *
  5943. * @var array
  5944. */
  5945. protected static $properties = array(
  5946. // Build
  5947. 'Mobile' => 'Mobile/[VER]',
  5948. 'Build' => 'Build/[VER]',
  5949. 'Version' => 'Version/[VER]',
  5950. 'VendorID' => 'VendorID/[VER]',
  5951. // Devices
  5952. 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
  5953. 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
  5954. 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
  5955. //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
  5956. 'Kindle' => 'Kindle/[VER]',
  5957. // Browser
  5958. 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
  5959. 'Coast' => array('Coast/[VER]'),
  5960. 'Dolfin' => 'Dolfin/[VER]',
  5961. // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
  5962. 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
  5963. 'Fennec' => 'Fennec/[VER]',
  5964. // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  5965. // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
  5966. 'Edge' => 'Edge/[VER]',
  5967. 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
  5968. // http://en.wikipedia.org/wiki/NetFront
  5969. 'NetFront' => 'NetFront/[VER]',
  5970. 'NokiaBrowser' => 'NokiaBrowser/[VER]',
  5971. 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
  5972. 'Opera Mini' => 'Opera Mini/[VER]',
  5973. 'Opera Mobi' => 'Version/[VER]',
  5974. 'UC Browser' => 'UC Browser[VER]',
  5975. 'MQQBrowser' => 'MQQBrowser/[VER]',
  5976. 'MicroMessenger' => 'MicroMessenger/[VER]',
  5977. 'baiduboxapp' => 'baiduboxapp/[VER]',
  5978. 'baidubrowser' => 'baidubrowser/[VER]',
  5979. 'SamsungBrowser' => 'SamsungBrowser/[VER]',
  5980. 'Iron' => 'Iron/[VER]',
  5981. // @note: Safari 7534.48.3 is actually Version 5.1.
  5982. // @note: On BlackBerry the Version is overwriten by the OS.
  5983. 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
  5984. 'Skyfire' => 'Skyfire/[VER]',
  5985. 'Tizen' => 'Tizen/[VER]',
  5986. 'Webkit' => 'webkit[ /][VER]',
  5987. 'PaleMoon' => 'PaleMoon/[VER]',
  5988. // Engine
  5989. 'Gecko' => 'Gecko/[VER]',
  5990. 'Trident' => 'Trident/[VER]',
  5991. 'Presto' => 'Presto/[VER]',
  5992. 'Goanna' => 'Goanna/[VER]',
  5993. // OS
  5994. 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
  5995. 'Android' => 'Android [VER]',
  5996. 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
  5997. 'BREW' => 'BREW [VER]',
  5998. 'Java' => 'Java/[VER]',
  5999. // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
  6000. // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
  6001. 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
  6002. 'Windows Phone' => 'Windows Phone [VER]',
  6003. 'Windows CE' => 'Windows CE/[VER]',
  6004. // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
  6005. 'Windows NT' => 'Windows NT [VER]',
  6006. 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
  6007. 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
  6008. );
  6009. /**
  6010. * Construct an instance of this class.
  6011. *
  6012. * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
  6013. * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
  6014. * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
  6015. * from the $headers array instead.
  6016. */
  6017. public function __construct(
  6018. array $headers = null,
  6019. $userAgent = null
  6020. ) {
  6021. $this->setHttpHeaders($headers);
  6022. $this->setUserAgent($userAgent);
  6023. }
  6024. /**
  6025. * Get the current script version.
  6026. * This is useful for the demo.php file,
  6027. * so people can check on what version they are testing
  6028. * for mobile devices.
  6029. *
  6030. * @return string The version number in semantic version format.
  6031. */
  6032. public static function getScriptVersion()
  6033. {
  6034. return self::VERSION;
  6035. }
  6036. /**
  6037. * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
  6038. *
  6039. * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
  6040. * the headers. The default null is left for backwards compatibility.
  6041. */
  6042. public function setHttpHeaders($httpHeaders = null)
  6043. {
  6044. // use global _SERVER if $httpHeaders aren't defined
  6045. if (!is_array($httpHeaders) || !count($httpHeaders)) {
  6046. $httpHeaders = $_SERVER;
  6047. }
  6048. // clear existing headers
  6049. $this->httpHeaders = array();
  6050. // Only save HTTP headers. In PHP land, that means only _SERVER vars that
  6051. // start with HTTP_.
  6052. foreach ($httpHeaders as $key => $value) {
  6053. if (substr($key, 0, 5) === 'HTTP_') {
  6054. $this->httpHeaders[$key] = $value;
  6055. }
  6056. }
  6057. // In case we're dealing with CloudFront, we need to know.
  6058. $this->setCfHeaders($httpHeaders);
  6059. }
  6060. /**
  6061. * Retrieves the HTTP headers.
  6062. *
  6063. * @return array
  6064. */
  6065. public function getHttpHeaders()
  6066. {
  6067. return $this->httpHeaders;
  6068. }
  6069. /**
  6070. * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
  6071. * Simply null is returned.
  6072. *
  6073. * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
  6074. * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
  6075. * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
  6076. *
  6077. * @return string|null The value of the header.
  6078. */
  6079. public function getHttpHeader($header)
  6080. {
  6081. // are we using PHP-flavored headers?
  6082. if (strpos($header, '_') === false) {
  6083. $header = str_replace('-', '_', $header);
  6084. $header = strtoupper($header);
  6085. }
  6086. // test the alternate, too
  6087. $altHeader = 'HTTP_' . $header;
  6088. //Test both the regular and the HTTP_ prefix
  6089. if (isset($this->httpHeaders[$header])) {
  6090. return $this->httpHeaders[$header];
  6091. } elseif (isset($this->httpHeaders[$altHeader])) {
  6092. return $this->httpHeaders[$altHeader];
  6093. }
  6094. return null;
  6095. }
  6096. public function getMobileHeaders()
  6097. {
  6098. return self::$mobileHeaders;
  6099. }
  6100. /**
  6101. * Get all possible HTTP headers that
  6102. * can contain the User-Agent string.
  6103. *
  6104. * @return array List of HTTP headers.
  6105. */
  6106. public function getUaHttpHeaders()
  6107. {
  6108. return self::$uaHttpHeaders;
  6109. }
  6110. /**
  6111. * Set CloudFront headers
  6112. * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
  6113. *
  6114. * @param array $cfHeaders List of HTTP headers
  6115. *
  6116. * @return boolean If there were CloudFront headers to be set
  6117. */
  6118. public function setCfHeaders($cfHeaders = null) {
  6119. // use global _SERVER if $cfHeaders aren't defined
  6120. if (!is_array($cfHeaders) || !count($cfHeaders)) {
  6121. $cfHeaders = $_SERVER;
  6122. }
  6123. // clear existing headers
  6124. $this->cloudfrontHeaders = array();
  6125. // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
  6126. // start with cloudfront-.
  6127. $response = false;
  6128. foreach ($cfHeaders as $key => $value) {
  6129. if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
  6130. $this->cloudfrontHeaders[strtoupper($key)] = $value;
  6131. $response = true;
  6132. }
  6133. }
  6134. return $response;
  6135. }
  6136. /**
  6137. * Retrieves the cloudfront headers.
  6138. *
  6139. * @return array
  6140. */
  6141. public function getCfHeaders()
  6142. {
  6143. return $this->cloudfrontHeaders;
  6144. }
  6145. /**
  6146. * Set the User-Agent to be used.
  6147. *
  6148. * @param string $userAgent The user agent string to set.
  6149. *
  6150. * @return string|null
  6151. */
  6152. public function setUserAgent($userAgent = null)
  6153. {
  6154. // Invalidate cache due to #375
  6155. $this->cache = array();
  6156. if (false === empty($userAgent)) {
  6157. return $this->userAgent = $userAgent;
  6158. } else {
  6159. $this->userAgent = null;
  6160. foreach ($this->getUaHttpHeaders() as $altHeader) {
  6161. if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
  6162. $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
  6163. }
  6164. }
  6165. if (!empty($this->userAgent)) {
  6166. return $this->userAgent = trim($this->userAgent);
  6167. }
  6168. }
  6169. if (count($this->getCfHeaders()) > 0) {
  6170. return $this->userAgent = 'Amazon CloudFront';
  6171. }
  6172. return $this->userAgent = null;
  6173. }
  6174. /**
  6175. * Retrieve the User-Agent.
  6176. *
  6177. * @return string|null The user agent if it's set.
  6178. */
  6179. public function getUserAgent()
  6180. {
  6181. return $this->userAgent;
  6182. }
  6183. /**
  6184. * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
  6185. * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
  6186. *
  6187. * @deprecated since version 2.6.9
  6188. *
  6189. * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
  6190. * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
  6191. */
  6192. public function setDetectionType($type = null)
  6193. {
  6194. if ($type === null) {
  6195. $type = self::DETECTION_TYPE_MOBILE;
  6196. }
  6197. if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
  6198. return;
  6199. }
  6200. $this->detectionType = $type;
  6201. }
  6202. public function getMatchingRegex()
  6203. {
  6204. return $this->matchingRegex;
  6205. }
  6206. public function getMatchesArray()
  6207. {
  6208. return $this->matchesArray;
  6209. }
  6210. /**
  6211. * Retrieve the list of known phone devices.
  6212. *
  6213. * @return array List of phone devices.
  6214. */
  6215. public static function getPhoneDevices()
  6216. {
  6217. return self::$phoneDevices;
  6218. }
  6219. /**
  6220. * Retrieve the list of known tablet devices.
  6221. *
  6222. * @return array List of tablet devices.
  6223. */
  6224. public static function getTabletDevices()
  6225. {
  6226. return self::$tabletDevices;
  6227. }
  6228. /**
  6229. * Alias for getBrowsers() method.
  6230. *
  6231. * @return array List of user agents.
  6232. */
  6233. public static function getUserAgents()
  6234. {
  6235. return self::getBrowsers();
  6236. }
  6237. /**
  6238. * Retrieve the list of known browsers. Specifically, the user agents.
  6239. *
  6240. * @return array List of browsers / user agents.
  6241. */
  6242. public static function getBrowsers()
  6243. {
  6244. return self::$browsers;
  6245. }
  6246. /**
  6247. * Retrieve the list of known utilities.
  6248. *
  6249. * @return array List of utilities.
  6250. */
  6251. public static function getUtilities()
  6252. {
  6253. return self::$utilities;
  6254. }
  6255. /**
  6256. * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
  6257. *
  6258. * @deprecated since version 2.6.9
  6259. *
  6260. * @return array All the rules (but not extended).
  6261. */
  6262. public static function getMobileDetectionRules()
  6263. {
  6264. static $rules;
  6265. if (!$rules) {
  6266. $rules = array_merge(
  6267. self::$phoneDevices,
  6268. self::$tabletDevices,
  6269. self::$operatingSystems,
  6270. self::$browsers
  6271. );
  6272. }
  6273. return $rules;
  6274. }
  6275. /**
  6276. * Method gets the mobile detection rules + utilities.
  6277. * The reason this is separate is because utilities rules
  6278. * don't necessary imply mobile. This method is used inside
  6279. * the new $detect->is('stuff') method.
  6280. *
  6281. * @deprecated since version 2.6.9
  6282. *
  6283. * @return array All the rules + extended.
  6284. */
  6285. public function getMobileDetectionRulesExtended()
  6286. {
  6287. static $rules;
  6288. if (!$rules) {
  6289. // Merge all rules together.
  6290. $rules = array_merge(
  6291. self::$phoneDevices,
  6292. self::$tabletDevices,
  6293. self::$operatingSystems,
  6294. self::$browsers,
  6295. self::$utilities
  6296. );
  6297. }
  6298. return $rules;
  6299. }
  6300. /**
  6301. * Retrieve the current set of rules.
  6302. *
  6303. * @deprecated since version 2.6.9
  6304. *
  6305. * @return array
  6306. */
  6307. public function getRules()
  6308. {
  6309. if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
  6310. return self::getMobileDetectionRulesExtended();
  6311. } else {
  6312. return self::getMobileDetectionRules();
  6313. }
  6314. }
  6315. /**
  6316. * Retrieve the list of mobile operating systems.
  6317. *
  6318. * @return array The list of mobile operating systems.
  6319. */
  6320. public static function getOperatingSystems()
  6321. {
  6322. return self::$operatingSystems;
  6323. }
  6324. /**
  6325. * Check the HTTP headers for signs of mobile.
  6326. * This is the fastest mobile check possible; it's used
  6327. * inside isMobile() method.
  6328. *
  6329. * @return bool
  6330. */
  6331. public function checkHttpHeadersForMobile()
  6332. {
  6333. foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
  6334. if (isset($this->httpHeaders[$mobileHeader])) {
  6335. if (is_array($matchType['matches'])) {
  6336. foreach ($matchType['matches'] as $_match) {
  6337. if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
  6338. return true;
  6339. }
  6340. }
  6341. return false;
  6342. } else {
  6343. return true;
  6344. }
  6345. }
  6346. }
  6347. return false;
  6348. }
  6349. /**
  6350. * Magic overloading method.
  6351. *
  6352. * @method boolean is[...]()
  6353. * @param string $name
  6354. * @param array $arguments
  6355. * @return mixed
  6356. * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
  6357. */
  6358. public function __call($name, $arguments)
  6359. {
  6360. // make sure the name starts with 'is', otherwise
  6361. if (substr($name, 0, 2) !== 'is') {
  6362. throw new BadMethodCallException("No such method exists: $name");
  6363. }
  6364. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6365. $key = substr($name, 2);
  6366. return $this->matchUAAgainstKey($key);
  6367. }
  6368. /**
  6369. * Find a detection rule that matches the current User-agent.
  6370. *
  6371. * @param null $userAgent deprecated
  6372. * @return boolean
  6373. */
  6374. protected function matchDetectionRulesAgainstUA($userAgent = null)
  6375. {
  6376. // Begin general search.
  6377. foreach ($this->getRules() as $_regex) {
  6378. if (empty($_regex)) {
  6379. continue;
  6380. }
  6381. if ($this->match($_regex, $userAgent)) {
  6382. return true;
  6383. }
  6384. }
  6385. return false;
  6386. }
  6387. /**
  6388. * Search for a certain key in the rules array.
  6389. * If the key is found then try to match the corresponding
  6390. * regex against the User-Agent.
  6391. *
  6392. * @param string $key
  6393. *
  6394. * @return boolean
  6395. */
  6396. protected function matchUAAgainstKey($key)
  6397. {
  6398. // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
  6399. $key = strtolower($key);
  6400. if (false === isset($this->cache[$key])) {
  6401. // change the keys to lower case
  6402. $_rules = array_change_key_case($this->getRules());
  6403. if (false === empty($_rules[$key])) {
  6404. $this->cache[$key] = $this->match($_rules[$key]);
  6405. }
  6406. if (false === isset($this->cache[$key])) {
  6407. $this->cache[$key] = false;
  6408. }
  6409. }
  6410. return $this->cache[$key];
  6411. }
  6412. /**
  6413. * Check if the device is mobile.
  6414. * Returns true if any type of mobile device detected, including special ones
  6415. * @param null $userAgent deprecated
  6416. * @param null $httpHeaders deprecated
  6417. * @return bool
  6418. */
  6419. public function isMobile($userAgent = null, $httpHeaders = null)
  6420. {
  6421. if ($httpHeaders) {
  6422. $this->setHttpHeaders($httpHeaders);
  6423. }
  6424. if ($userAgent) {
  6425. $this->setUserAgent($userAgent);
  6426. }
  6427. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6428. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6429. $cfHeaders = $this->getCfHeaders();
  6430. if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
  6431. return true;
  6432. }
  6433. }
  6434. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6435. if ($this->checkHttpHeadersForMobile()) {
  6436. return true;
  6437. } else {
  6438. return $this->matchDetectionRulesAgainstUA();
  6439. }
  6440. }
  6441. /**
  6442. * Check if the device is a tablet.
  6443. * Return true if any type of tablet device is detected.
  6444. *
  6445. * @param string $userAgent deprecated
  6446. * @param array $httpHeaders deprecated
  6447. * @return bool
  6448. */
  6449. public function isTablet($userAgent = null, $httpHeaders = null)
  6450. {
  6451. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6452. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6453. $cfHeaders = $this->getCfHeaders();
  6454. if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
  6455. return true;
  6456. }
  6457. }
  6458. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6459. foreach (self::$tabletDevices as $_regex) {
  6460. if ($this->match($_regex, $userAgent)) {
  6461. return true;
  6462. }
  6463. }
  6464. return false;
  6465. }
  6466. /**
  6467. * This method checks for a certain property in the
  6468. * userAgent.
  6469. * @todo: The httpHeaders part is not yet used.
  6470. *
  6471. * @param string $key
  6472. * @param string $userAgent deprecated
  6473. * @param string $httpHeaders deprecated
  6474. * @return bool|int|null
  6475. */
  6476. public function is($key, $userAgent = null, $httpHeaders = null)
  6477. {
  6478. // Set the UA and HTTP headers only if needed (eg. batch mode).
  6479. if ($httpHeaders) {
  6480. $this->setHttpHeaders($httpHeaders);
  6481. }
  6482. if ($userAgent) {
  6483. $this->setUserAgent($userAgent);
  6484. }
  6485. $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
  6486. return $this->matchUAAgainstKey($key);
  6487. }
  6488. /**
  6489. * Some detection rules are relative (not standard),
  6490. * because of the diversity of devices, vendors and
  6491. * their conventions in representing the User-Agent or
  6492. * the HTTP headers.
  6493. *
  6494. * This method will be used to check custom regexes against
  6495. * the User-Agent string.
  6496. *
  6497. * @param $regex
  6498. * @param string $userAgent
  6499. * @return bool
  6500. *
  6501. * @todo: search in the HTTP headers too.
  6502. */
  6503. public function match($regex, $userAgent = null)
  6504. {
  6505. $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
  6506. // If positive match is found, store the results for debug.
  6507. if ($match) {
  6508. $this->matchingRegex = $regex;
  6509. $this->matchesArray = $matches;
  6510. }
  6511. return $match;
  6512. }
  6513. /**
  6514. * Get the properties array.
  6515. *
  6516. * @return array
  6517. */
  6518. public static function getProperties()
  6519. {
  6520. return self::$properties;
  6521. }
  6522. /**
  6523. * Prepare the version number.
  6524. *
  6525. * @todo Remove the error supression from str_replace() call.
  6526. *
  6527. * @param string $ver The string version, like "2.6.21.2152";
  6528. *
  6529. * @return float
  6530. */
  6531. public function prepareVersionNo($ver)
  6532. {
  6533. $ver = str_replace(array('_', ' ', '/'), '.', $ver);
  6534. $arrVer = explode('.', $ver, 2);
  6535. if (isset($arrVer[1])) {
  6536. $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
  6537. }
  6538. return (float) implode('.', $arrVer);
  6539. }
  6540. /**
  6541. * Check the version of the given property in the User-Agent.
  6542. * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
  6543. *
  6544. * @param string $propertyName The name of the property. See self::getProperties() array
  6545. * keys for all possible properties.
  6546. * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
  6547. * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
  6548. * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
  6549. * invalid parameter will default to the this type as well.
  6550. *
  6551. * @return string|float The version of the property we are trying to extract.
  6552. */
  6553. public function version($propertyName, $type = self::VERSION_TYPE_STRING)
  6554. {
  6555. if (empty($propertyName)) {
  6556. return false;
  6557. }
  6558. // set the $type to the default if we don't recognize the type
  6559. if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
  6560. $type = self::VERSION_TYPE_STRING;
  6561. }
  6562. $properties = self::getProperties();
  6563. // Check if the property exists in the properties array.
  6564. if (true === isset($properties[$propertyName])) {
  6565. // Prepare the pattern to be matched.
  6566. // Make sure we always deal with an array (string is converted).
  6567. $properties[$propertyName] = (array) $properties[$propertyName];
  6568. foreach ($properties[$propertyName] as $propertyMatchString) {
  6569. $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
  6570. // Identify and extract the version.
  6571. preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
  6572. if (false === empty($match[1])) {
  6573. $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
  6574. return $version;
  6575. }
  6576. }
  6577. }
  6578. return false;
  6579. }
  6580. /**
  6581. * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
  6582. *
  6583. * @return string One of the self::MOBILE_GRADE_* constants.
  6584. */
  6585. public function mobileGrade()
  6586. {
  6587. $isMobile = $this->isMobile();
  6588. if (
  6589. // 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)
  6590. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6591. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6592. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6593. // 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)
  6594. // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
  6595. // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
  6596. // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
  6597. ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
  6598. // 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)
  6599. $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
  6600. // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
  6601. $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
  6602. // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
  6603. $this->match('Playbook.*Tablet') ||
  6604. // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
  6605. ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
  6606. // Palm WebOS 3.0 - Tested on HP TouchPad
  6607. $this->match('hp.*TouchPad') ||
  6608. // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
  6609. ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
  6610. // Chrome for Android - Tested on Android 4.0, 4.1 device
  6611. ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
  6612. // Skyfire 4.1 - Tested on Android 2.3 device
  6613. ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6614. // Opera Mobile 11.5-12: Tested on Android 2.3
  6615. ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
  6616. // Meego 1.2 - Tested on Nokia 950 and N9
  6617. $this->is('MeeGoOS') ||
  6618. // Tizen (pre-release) - Tested on early hardware
  6619. $this->is('Tizen') ||
  6620. // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
  6621. // @todo: more tests here!
  6622. $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
  6623. // UC Browser - Tested on Android 2.3 device
  6624. ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6625. // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
  6626. ( $this->match('Kindle Fire') ||
  6627. $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
  6628. // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
  6629. $this->is('AndroidOS') && $this->is('NookTablet') ||
  6630. // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
  6631. $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
  6632. // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
  6633. $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
  6634. // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
  6635. $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
  6636. // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
  6637. $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
  6638. // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
  6639. $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
  6640. ){
  6641. return self::MOBILE_GRADE_A;
  6642. }
  6643. if (
  6644. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
  6645. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
  6646. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
  6647. // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
  6648. $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
  6649. //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
  6650. ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
  6651. ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
  6652. // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
  6653. $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
  6654. // @todo: report this (tested on Nokia N71)
  6655. $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
  6656. ){
  6657. return self::MOBILE_GRADE_B;
  6658. }
  6659. if (
  6660. // Blackberry 4.x - Tested on the Curve 8330
  6661. $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
  6662. // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
  6663. $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
  6664. // Tested on original iPhone (3.1), iPhone 3 (3.2)
  6665. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6666. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6667. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6668. // Internet Explorer 7 and older - Tested on Windows XP
  6669. $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
  6670. ){
  6671. return self::MOBILE_GRADE_C;
  6672. }
  6673. // All older smartphone platforms and featurephones - Any device that doesn't support media queries
  6674. // will receive the basic, C grade experience.
  6675. return self::MOBILE_GRADE_C;
  6676. }
  6677. }
  6678. $mobileDetect = new Mobile_Detect;
  6679. $userDevice = ($mobileDetect->isMobile() ? ($mobileDetect->isTablet() ? 'tablet' : 'phone') : 'computer');
  6680. function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  6681. $path = getServerPath();
  6682. return '
  6683. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6684. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  6685. <head>
  6686. <!--[if gte mso 9]><xml>
  6687. <o:OfficeDocumentSettings>
  6688. <o:AllowPNG/>
  6689. <o:PixelsPerInch>96</o:PixelsPerInch>
  6690. </o:OfficeDocumentSettings>
  6691. </xml><![endif]-->
  6692. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6693. <meta name="viewport" content="width=device-width">
  6694. <!--[if !mso]><!-->
  6695. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6696. <!--<![endif]-->
  6697. <title></title>
  6698. <!--[if !mso]><!-- -->
  6699. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
  6700. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  6701. <!--<![endif]-->
  6702. <style type="text/css" id="media-query">
  6703. body {
  6704. margin: 0;
  6705. padding: 0;
  6706. }
  6707. table,
  6708. tr,
  6709. td {
  6710. vertical-align: top;
  6711. border-collapse: collapse;
  6712. }
  6713. .ie-browser table,
  6714. .mso-container table {
  6715. table-layout: fixed;
  6716. }
  6717. * {
  6718. line-height: inherit;
  6719. }
  6720. a[x-apple-data-detectors=true] {
  6721. color: inherit !important;
  6722. text-decoration: none !important;
  6723. }
  6724. [owa] .img-container div,
  6725. [owa] .img-container button {
  6726. display: block !important;
  6727. }
  6728. [owa] .fullwidth button {
  6729. width: 100% !important;
  6730. }
  6731. [owa] .block-grid .col {
  6732. display: table-cell;
  6733. float: none !important;
  6734. vertical-align: top;
  6735. }
  6736. .ie-browser .num12,
  6737. .ie-browser .block-grid,
  6738. [owa] .num12,
  6739. [owa] .block-grid {
  6740. width: 615px !important;
  6741. }
  6742. .ExternalClass,
  6743. .ExternalClass p,
  6744. .ExternalClass span,
  6745. .ExternalClass font,
  6746. .ExternalClass td,
  6747. .ExternalClass div {
  6748. line-height: 100%;
  6749. }
  6750. .ie-browser .mixed-two-up .num4,
  6751. [owa] .mixed-two-up .num4 {
  6752. width: 204px !important;
  6753. }
  6754. .ie-browser .mixed-two-up .num8,
  6755. [owa] .mixed-two-up .num8 {
  6756. width: 408px !important;
  6757. }
  6758. .ie-browser .block-grid.two-up .col,
  6759. [owa] .block-grid.two-up .col {
  6760. width: 307px !important;
  6761. }
  6762. .ie-browser .block-grid.three-up .col,
  6763. [owa] .block-grid.three-up .col {
  6764. width: 205px !important;
  6765. }
  6766. .ie-browser .block-grid.four-up .col,
  6767. [owa] .block-grid.four-up .col {
  6768. width: 153px !important;
  6769. }
  6770. .ie-browser .block-grid.five-up .col,
  6771. [owa] .block-grid.five-up .col {
  6772. width: 123px !important;
  6773. }
  6774. .ie-browser .block-grid.six-up .col,
  6775. [owa] .block-grid.six-up .col {
  6776. width: 102px !important;
  6777. }
  6778. .ie-browser .block-grid.seven-up .col,
  6779. [owa] .block-grid.seven-up .col {
  6780. width: 87px !important;
  6781. }
  6782. .ie-browser .block-grid.eight-up .col,
  6783. [owa] .block-grid.eight-up .col {
  6784. width: 76px !important;
  6785. }
  6786. .ie-browser .block-grid.nine-up .col,
  6787. [owa] .block-grid.nine-up .col {
  6788. width: 68px !important;
  6789. }
  6790. .ie-browser .block-grid.ten-up .col,
  6791. [owa] .block-grid.ten-up .col {
  6792. width: 61px !important;
  6793. }
  6794. .ie-browser .block-grid.eleven-up .col,
  6795. [owa] .block-grid.eleven-up .col {
  6796. width: 55px !important;
  6797. }
  6798. .ie-browser .block-grid.twelve-up .col,
  6799. [owa] .block-grid.twelve-up .col {
  6800. width: 51px !important;
  6801. }
  6802. @media only screen and (min-width: 635px) {
  6803. .block-grid {
  6804. width: 615px !important;
  6805. }
  6806. .block-grid .col {
  6807. display: table-cell;
  6808. Float: none !important;
  6809. vertical-align: top;
  6810. }
  6811. .block-grid .col.num12 {
  6812. width: 615px !important;
  6813. }
  6814. .block-grid.mixed-two-up .col.num4 {
  6815. width: 204px !important;
  6816. }
  6817. .block-grid.mixed-two-up .col.num8 {
  6818. width: 408px !important;
  6819. }
  6820. .block-grid.two-up .col {
  6821. width: 307px !important;
  6822. }
  6823. .block-grid.three-up .col {
  6824. width: 205px !important;
  6825. }
  6826. .block-grid.four-up .col {
  6827. width: 153px !important;
  6828. }
  6829. .block-grid.five-up .col {
  6830. width: 123px !important;
  6831. }
  6832. .block-grid.six-up .col {
  6833. width: 102px !important;
  6834. }
  6835. .block-grid.seven-up .col {
  6836. width: 87px !important;
  6837. }
  6838. .block-grid.eight-up .col {
  6839. width: 76px !important;
  6840. }
  6841. .block-grid.nine-up .col {
  6842. width: 68px !important;
  6843. }
  6844. .block-grid.ten-up .col {
  6845. width: 61px !important;
  6846. }
  6847. .block-grid.eleven-up .col {
  6848. width: 55px !important;
  6849. }
  6850. .block-grid.twelve-up .col {
  6851. width: 51px !important;
  6852. }
  6853. }
  6854. @media (max-width: 635px) {
  6855. .block-grid,
  6856. .col {
  6857. min-width: 320px !important;
  6858. max-width: 100% !important;
  6859. }
  6860. .block-grid {
  6861. width: calc(100% - 40px) !important;
  6862. }
  6863. .col {
  6864. width: 100% !important;
  6865. }
  6866. .col>div {
  6867. margin: 0 auto;
  6868. }
  6869. img.fullwidth {
  6870. max-width: 100% !important;
  6871. }
  6872. }
  6873. </style>
  6874. </head>
  6875. <body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #FFFFFF">
  6876. <!--[if IE]><div class="ie-browser"><![endif]-->
  6877. <!--[if mso]><div class="mso-container"><![endif]-->
  6878. <div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: #FFFFFF">
  6879. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #FFFFFF;"><![endif]-->
  6880. <div style="background-color:#333333;">
  6881. <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;"
  6882. class="block-grid ">
  6883. <div style="border-collapse: collapse;display: table;width: 100%;">
  6884. <!--[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]-->
  6885. <!--[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]-->
  6886. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6887. <div style="background-color: transparent; width: 100% !important;">
  6888. <!--[if (!mso)&(!IE)]><!-->
  6889. <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;">
  6890. <!--<![endif]-->
  6891. <div align="left" class="img-container left fullwidth" style="padding-right: 30px; padding-left: 30px;">
  6892. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px;" align="left"><![endif]-->
  6893. <img class="left fullwidth" align="left" border="0" src="'.$path.'images/organizr-logo-h.png" alt="Image" title="Image"
  6894. 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"
  6895. width="555">
  6896. <!--[if mso]></td></tr></table><![endif]-->
  6897. </div>
  6898. <!--[if (!mso)&(!IE)]><!-->
  6899. </div>
  6900. <!--<![endif]-->
  6901. </div>
  6902. </div>
  6903. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6904. </div>
  6905. </div>
  6906. </div>
  6907. <div style="background-color:#333333;">
  6908. <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;"
  6909. class="block-grid ">
  6910. <div style="border-collapse: collapse;display: table;width: 100%;">
  6911. <!--[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]-->
  6912. <!--[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]-->
  6913. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6914. <div style="background-color: transparent; width: 100% !important;">
  6915. <!--[if (!mso)&(!IE)]><!-->
  6916. <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;">
  6917. <!--<![endif]-->
  6918. <!--[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]-->
  6919. <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;">
  6920. <div style="font-size:12px;line-height:14px;color:#FFFFFF;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6921. <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>
  6922. </span>
  6923. </p>
  6924. </div>
  6925. </div>
  6926. <!--[if mso]></td></tr></table><![endif]-->
  6927. <!--[if (!mso)&(!IE)]><!-->
  6928. </div>
  6929. <!--<![endif]-->
  6930. </div>
  6931. </div>
  6932. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6933. </div>
  6934. </div>
  6935. </div>
  6936. <div style="background-color:#393939;">
  6937. <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;"
  6938. class="block-grid ">
  6939. <div style="border-collapse: collapse;display: table;width: 100%;">
  6940. <!--[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]-->
  6941. <!--[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]-->
  6942. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6943. <div style="background-color: transparent; width: 100% !important;">
  6944. <!--[if (!mso)&(!IE)]><!-->
  6945. <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;">
  6946. <!--<![endif]-->
  6947. <!--[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]-->
  6948. <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;">
  6949. <div style="font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6950. <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>
  6951. </div>
  6952. </div>
  6953. <!--[if mso]></td></tr></table><![endif]-->
  6954. <div style="padding-right: 5px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px;">
  6955. <!--[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]-->
  6956. <div align="center">
  6957. <div style="border-top: 2px solid #66D9EF; width:55%; line-height:2px; height:2px; font-size:2px;">&#160;</div>
  6958. </div>
  6959. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6960. </div>
  6961. <!--[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]-->
  6962. <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;">
  6963. <div style="font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6964. <p style="margin: 0;font-size: 12px;line-height: 14px"><span style="font-size: 28px; line-height: 33px;">Hey '.$user.',</span></p>
  6965. </div>
  6966. </div>
  6967. <!--[if mso]></td></tr></table><![endif]-->
  6968. <!--[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]-->
  6969. <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;">
  6970. <div style="font-size:12px;line-height:22px;font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;color:#FFFFFF;text-align:left;">
  6971. <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>
  6972. </span>
  6973. </p>
  6974. </div>
  6975. </div>
  6976. <!--[if mso]></td></tr></table><![endif]-->
  6977. <div align="center" class="button-container center" style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;">
  6978. <!--[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]-->
  6979. <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">
  6980. <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>
  6981. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6982. </div>
  6983. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6984. </div>
  6985. <!--[if (!mso)&(!IE)]><!-->
  6986. </div>
  6987. <!--<![endif]-->
  6988. </div>
  6989. </div>
  6990. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6991. </div>
  6992. </div>
  6993. </div>
  6994. <div style="background-color:#ffffff;">
  6995. <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;"
  6996. class="block-grid ">
  6997. <div style="border-collapse: collapse;display: table;width: 100%;">
  6998. <!--[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]-->
  6999. <!--[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]-->
  7000. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  7001. <div style="background-color: transparent; width: 100% !important;">
  7002. <!--[if (!mso)&(!IE)]><!-->
  7003. <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;">
  7004. <!--<![endif]-->
  7005. <!--[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]-->
  7006. <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;">
  7007. <div style="font-size:12px;line-height:14px;color:#555555;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  7008. <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>
  7009. </div>
  7010. </div>
  7011. <!--[if mso]></td></tr></table><![endif]-->
  7012. <div style="padding-right: 20px; padding-left: 20px; padding-top: 15px; padding-bottom: 20px;">
  7013. <!--[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]-->
  7014. <div align="center">
  7015. <div style="border-top: 3px solid #66D9EF; width:40%; line-height:3px; height:3px; font-size:3px;">&#160;</div>
  7016. </div>
  7017. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  7018. </div>
  7019. <!--[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]-->
  7020. <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;">
  7021. <div style="font-size:12px;line-height:22px;color:#7E7D7D;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  7022. <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>
  7023. </div>
  7024. </div>
  7025. <!--[if mso]></td></tr></table><![endif]-->
  7026. <!--[if (!mso)&(!IE)]><!-->
  7027. </div>
  7028. <!--<![endif]-->
  7029. </div>
  7030. </div>
  7031. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  7032. </div>
  7033. </div>
  7034. </div>
  7035. <div style="background-color:#333333;">
  7036. <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;"
  7037. class="block-grid ">
  7038. <div style="border-collapse: collapse;display: table;width: 100%;">
  7039. <!--[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]-->
  7040. <!--[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]-->
  7041. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  7042. <div style="background-color: transparent; width: 100% !important;">
  7043. <!--[if (!mso)&(!IE)]><!-->
  7044. <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;">
  7045. <!--<![endif]-->
  7046. <!--[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]-->
  7047. <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;">
  7048. <div style="font-size:12px;line-height:14px;color:#959595;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  7049. <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"
  7050. href="https://github.com/causefx/Organizr" target="_blank" rel="noopener noreferrer">Organizr</a><strong><br></strong></p>
  7051. </div>
  7052. </div>
  7053. <!--[if mso]></td></tr></table><![endif]-->
  7054. <!--[if (!mso)&(!IE)]><!-->
  7055. </div>
  7056. <!--<![endif]-->
  7057. </div>
  7058. </div>
  7059. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  7060. </div>
  7061. </div>
  7062. </div>
  7063. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  7064. </div>
  7065. <!--[if (mso)|(IE)]></div><![endif]-->
  7066. </body>
  7067. </html>
  7068. ';
  7069. }
  7070. function mimeTypes(){
  7071. return array(
  7072. '123' => 'application/vnd.lotus-1-2-3',
  7073. '3dml' => 'text/vnd.in3d.3dml',
  7074. '3ds' => 'image/x-3ds',
  7075. '3g2' => 'video/3gpp2',
  7076. '3gp' => 'video/3gpp',
  7077. '7z' => 'application/x-7z-compressed',
  7078. 'aab' => 'application/x-authorware-bin',
  7079. 'aac' => 'audio/x-aac',
  7080. 'aam' => 'application/x-authorware-map',
  7081. 'aas' => 'application/x-authorware-seg',
  7082. 'abw' => 'application/x-abiword',
  7083. 'ac' => 'application/pkix-attr-cert',
  7084. 'acc' => 'application/vnd.americandynamics.acc',
  7085. 'ace' => 'application/x-ace-compressed',
  7086. 'acu' => 'application/vnd.acucobol',
  7087. 'acutc' => 'application/vnd.acucorp',
  7088. 'adp' => 'audio/adpcm',
  7089. 'aep' => 'application/vnd.audiograph',
  7090. 'afm' => 'application/x-font-type1',
  7091. 'afp' => 'application/vnd.ibm.modcap',
  7092. 'ahead' => 'application/vnd.ahead.space',
  7093. 'ai' => 'application/postscript',
  7094. 'aif' => 'audio/x-aiff',
  7095. 'aifc' => 'audio/x-aiff',
  7096. 'aiff' => 'audio/x-aiff',
  7097. 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
  7098. 'ait' => 'application/vnd.dvb.ait',
  7099. 'ami' => 'application/vnd.amiga.ami',
  7100. 'apk' => 'application/vnd.android.package-archive',
  7101. 'appcache' => 'text/cache-manifest',
  7102. 'application' => 'application/x-ms-application',
  7103. 'apr' => 'application/vnd.lotus-approach',
  7104. 'arc' => 'application/x-freearc',
  7105. 'asc' => 'application/pgp-signature',
  7106. 'asf' => 'video/x-ms-asf',
  7107. 'asm' => 'text/x-asm',
  7108. 'aso' => 'application/vnd.accpac.simply.aso',
  7109. 'asx' => 'video/x-ms-asf',
  7110. 'atc' => 'application/vnd.acucorp',
  7111. 'atom' => 'application/atom+xml',
  7112. 'atomcat' => 'application/atomcat+xml',
  7113. 'atomsvc' => 'application/atomsvc+xml',
  7114. 'atx' => 'application/vnd.antix.game-component',
  7115. 'au' => 'audio/basic',
  7116. 'avi' => 'video/x-msvideo',
  7117. 'aw' => 'application/applixware',
  7118. 'azf' => 'application/vnd.airzip.filesecure.azf',
  7119. 'azs' => 'application/vnd.airzip.filesecure.azs',
  7120. 'azw' => 'application/vnd.amazon.ebook',
  7121. 'bat' => 'application/x-msdownload',
  7122. 'bcpio' => 'application/x-bcpio',
  7123. 'bdf' => 'application/x-font-bdf',
  7124. 'bdm' => 'application/vnd.syncml.dm+wbxml',
  7125. 'bed' => 'application/vnd.realvnc.bed',
  7126. 'bh2' => 'application/vnd.fujitsu.oasysprs',
  7127. 'bin' => 'application/octet-stream',
  7128. 'blb' => 'application/x-blorb',
  7129. 'blorb' => 'application/x-blorb',
  7130. 'bmi' => 'application/vnd.bmi',
  7131. 'bmp' => 'image/bmp',
  7132. 'book' => 'application/vnd.framemaker',
  7133. 'box' => 'application/vnd.previewsystems.box',
  7134. 'boz' => 'application/x-bzip2',
  7135. 'bpk' => 'application/octet-stream',
  7136. 'btif' => 'image/prs.btif',
  7137. 'bz' => 'application/x-bzip',
  7138. 'bz2' => 'application/x-bzip2',
  7139. 'c' => 'text/x-c',
  7140. 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
  7141. 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
  7142. 'c4d' => 'application/vnd.clonk.c4group',
  7143. 'c4f' => 'application/vnd.clonk.c4group',
  7144. 'c4g' => 'application/vnd.clonk.c4group',
  7145. 'c4p' => 'application/vnd.clonk.c4group',
  7146. 'c4u' => 'application/vnd.clonk.c4group',
  7147. 'cab' => 'application/vnd.ms-cab-compressed',
  7148. 'caf' => 'audio/x-caf',
  7149. 'cap' => 'application/vnd.tcpdump.pcap',
  7150. 'car' => 'application/vnd.curl.car',
  7151. 'cat' => 'application/vnd.ms-pki.seccat',
  7152. 'cb7' => 'application/x-cbr',
  7153. 'cba' => 'application/x-cbr',
  7154. 'cbr' => 'application/x-cbr',
  7155. 'cbt' => 'application/x-cbr',
  7156. 'cbz' => 'application/x-cbr',
  7157. 'cc' => 'text/x-c',
  7158. 'cct' => 'application/x-director',
  7159. 'ccxml' => 'application/ccxml+xml',
  7160. 'cdbcmsg' => 'application/vnd.contact.cmsg',
  7161. 'cdf' => 'application/x-netcdf',
  7162. 'cdkey' => 'application/vnd.mediastation.cdkey',
  7163. 'cdmia' => 'application/cdmi-capability',
  7164. 'cdmic' => 'application/cdmi-container',
  7165. 'cdmid' => 'application/cdmi-domain',
  7166. 'cdmio' => 'application/cdmi-object',
  7167. 'cdmiq' => 'application/cdmi-queue',
  7168. 'cdx' => 'chemical/x-cdx',
  7169. 'cdxml' => 'application/vnd.chemdraw+xml',
  7170. 'cdy' => 'application/vnd.cinderella',
  7171. 'cer' => 'application/pkix-cert',
  7172. 'cfs' => 'application/x-cfs-compressed',
  7173. 'cgm' => 'image/cgm',
  7174. 'chat' => 'application/x-chat',
  7175. 'chm' => 'application/vnd.ms-htmlhelp',
  7176. 'chrt' => 'application/vnd.kde.kchart',
  7177. 'cif' => 'chemical/x-cif',
  7178. 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
  7179. 'cil' => 'application/vnd.ms-artgalry',
  7180. 'cla' => 'application/vnd.claymore',
  7181. 'class' => 'application/java-vm',
  7182. 'clkk' => 'application/vnd.crick.clicker.keyboard',
  7183. 'clkp' => 'application/vnd.crick.clicker.palette',
  7184. 'clkt' => 'application/vnd.crick.clicker.template',
  7185. 'clkw' => 'application/vnd.crick.clicker.wordbank',
  7186. 'clkx' => 'application/vnd.crick.clicker',
  7187. 'clp' => 'application/x-msclip',
  7188. 'cmc' => 'application/vnd.cosmocaller',
  7189. 'cmdf' => 'chemical/x-cmdf',
  7190. 'cml' => 'chemical/x-cml',
  7191. 'cmp' => 'application/vnd.yellowriver-custom-menu',
  7192. 'cmx' => 'image/x-cmx',
  7193. 'cod' => 'application/vnd.rim.cod',
  7194. 'com' => 'application/x-msdownload',
  7195. 'conf' => 'text/plain',
  7196. 'cpio' => 'application/x-cpio',
  7197. 'cpp' => 'text/x-c',
  7198. 'cpt' => 'application/mac-compactpro',
  7199. 'crd' => 'application/x-mscardfile',
  7200. 'crl' => 'application/pkix-crl',
  7201. 'crt' => 'application/x-x509-ca-cert',
  7202. 'cryptonote' => 'application/vnd.rig.cryptonote',
  7203. 'csh' => 'application/x-csh',
  7204. 'csml' => 'chemical/x-csml',
  7205. 'csp' => 'application/vnd.commonspace',
  7206. 'css' => 'text/css',
  7207. 'cst' => 'application/x-director',
  7208. 'csv' => 'text/csv',
  7209. 'cu' => 'application/cu-seeme',
  7210. 'curl' => 'text/vnd.curl',
  7211. 'cww' => 'application/prs.cww',
  7212. 'cxt' => 'application/x-director',
  7213. 'cxx' => 'text/x-c',
  7214. 'dae' => 'model/vnd.collada+xml',
  7215. 'daf' => 'application/vnd.mobius.daf',
  7216. 'dart' => 'application/vnd.dart',
  7217. 'dataless' => 'application/vnd.fdsn.seed',
  7218. 'davmount' => 'application/davmount+xml',
  7219. 'dbk' => 'application/docbook+xml',
  7220. 'dcr' => 'application/x-director',
  7221. 'dcurl' => 'text/vnd.curl.dcurl',
  7222. 'dd2' => 'application/vnd.oma.dd2+xml',
  7223. 'ddd' => 'application/vnd.fujixerox.ddd',
  7224. 'deb' => 'application/x-debian-package',
  7225. 'def' => 'text/plain',
  7226. 'deploy' => 'application/octet-stream',
  7227. 'der' => 'application/x-x509-ca-cert',
  7228. 'dfac' => 'application/vnd.dreamfactory',
  7229. 'dgc' => 'application/x-dgc-compressed',
  7230. 'dic' => 'text/x-c',
  7231. 'dir' => 'application/x-director',
  7232. 'dis' => 'application/vnd.mobius.dis',
  7233. 'dist' => 'application/octet-stream',
  7234. 'distz' => 'application/octet-stream',
  7235. 'djv' => 'image/vnd.djvu',
  7236. 'djvu' => 'image/vnd.djvu',
  7237. 'dll' => 'application/x-msdownload',
  7238. 'dmg' => 'application/x-apple-diskimage',
  7239. 'dmp' => 'application/vnd.tcpdump.pcap',
  7240. 'dms' => 'application/octet-stream',
  7241. 'dna' => 'application/vnd.dna',
  7242. 'doc' => 'application/msword',
  7243. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  7244. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  7245. 'dot' => 'application/msword',
  7246. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  7247. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  7248. 'dp' => 'application/vnd.osgi.dp',
  7249. 'dpg' => 'application/vnd.dpgraph',
  7250. 'dra' => 'audio/vnd.dra',
  7251. 'dsc' => 'text/prs.lines.tag',
  7252. 'dssc' => 'application/dssc+der',
  7253. 'dtb' => 'application/x-dtbook+xml',
  7254. 'dtd' => 'application/xml-dtd',
  7255. 'dts' => 'audio/vnd.dts',
  7256. 'dtshd' => 'audio/vnd.dts.hd',
  7257. 'dump' => 'application/octet-stream',
  7258. 'dvb' => 'video/vnd.dvb.file',
  7259. 'dvi' => 'application/x-dvi',
  7260. 'dwf' => 'model/vnd.dwf',
  7261. 'dwg' => 'image/vnd.dwg',
  7262. 'dxf' => 'image/vnd.dxf',
  7263. 'dxp' => 'application/vnd.spotfire.dxp',
  7264. 'dxr' => 'application/x-director',
  7265. 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
  7266. 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
  7267. 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
  7268. 'ecma' => 'application/ecmascript',
  7269. 'edm' => 'application/vnd.novadigm.edm',
  7270. 'edx' => 'application/vnd.novadigm.edx',
  7271. 'efif' => 'application/vnd.picsel',
  7272. 'ei6' => 'application/vnd.pg.osasli',
  7273. 'elc' => 'application/octet-stream',
  7274. 'emf' => 'application/x-msmetafile',
  7275. 'eml' => 'message/rfc822',
  7276. 'emma' => 'application/emma+xml',
  7277. 'emz' => 'application/x-msmetafile',
  7278. 'eol' => 'audio/vnd.digital-winds',
  7279. 'eot' => 'application/vnd.ms-fontobject',
  7280. 'eps' => 'application/postscript',
  7281. 'epub' => 'application/epub+zip',
  7282. 'es3' => 'application/vnd.eszigno3+xml',
  7283. 'esa' => 'application/vnd.osgi.subsystem',
  7284. 'esf' => 'application/vnd.epson.esf',
  7285. 'et3' => 'application/vnd.eszigno3+xml',
  7286. 'etx' => 'text/x-setext',
  7287. 'eva' => 'application/x-eva',
  7288. 'evy' => 'application/x-envoy',
  7289. 'exe' => 'application/x-msdownload',
  7290. 'exi' => 'application/exi',
  7291. 'ext' => 'application/vnd.novadigm.ext',
  7292. 'ez' => 'application/andrew-inset',
  7293. 'ez2' => 'application/vnd.ezpix-album',
  7294. 'ez3' => 'application/vnd.ezpix-package',
  7295. 'f' => 'text/x-fortran',
  7296. 'f4v' => 'video/x-f4v',
  7297. 'f77' => 'text/x-fortran',
  7298. 'f90' => 'text/x-fortran',
  7299. 'fbs' => 'image/vnd.fastbidsheet',
  7300. 'fcdt' => 'application/vnd.adobe.formscentral.fcdt',
  7301. 'fcs' => 'application/vnd.isac.fcs',
  7302. 'fdf' => 'application/vnd.fdf',
  7303. 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
  7304. 'fg5' => 'application/vnd.fujitsu.oasysgp',
  7305. 'fgd' => 'application/x-director',
  7306. 'fh' => 'image/x-freehand',
  7307. 'fh4' => 'image/x-freehand',
  7308. 'fh5' => 'image/x-freehand',
  7309. 'fh7' => 'image/x-freehand',
  7310. 'fhc' => 'image/x-freehand',
  7311. 'fig' => 'application/x-xfig',
  7312. 'flac' => 'audio/x-flac',
  7313. 'fli' => 'video/x-fli',
  7314. 'flo' => 'application/vnd.micrografx.flo',
  7315. 'flv' => 'video/x-flv',
  7316. 'flw' => 'application/vnd.kde.kivio',
  7317. 'flx' => 'text/vnd.fmi.flexstor',
  7318. 'fly' => 'text/vnd.fly',
  7319. 'fm' => 'application/vnd.framemaker',
  7320. 'fnc' => 'application/vnd.frogans.fnc',
  7321. 'for' => 'text/x-fortran',
  7322. 'fpx' => 'image/vnd.fpx',
  7323. 'frame' => 'application/vnd.framemaker',
  7324. 'fsc' => 'application/vnd.fsc.weblaunch',
  7325. 'fst' => 'image/vnd.fst',
  7326. 'ftc' => 'application/vnd.fluxtime.clip',
  7327. 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
  7328. 'fvt' => 'video/vnd.fvt',
  7329. 'fxp' => 'application/vnd.adobe.fxp',
  7330. 'fxpl' => 'application/vnd.adobe.fxp',
  7331. 'fzs' => 'application/vnd.fuzzysheet',
  7332. 'g2w' => 'application/vnd.geoplan',
  7333. 'g3' => 'image/g3fax',
  7334. 'g3w' => 'application/vnd.geospace',
  7335. 'gac' => 'application/vnd.groove-account',
  7336. 'gam' => 'application/x-tads',
  7337. 'gbr' => 'application/rpki-ghostbusters',
  7338. 'gca' => 'application/x-gca-compressed',
  7339. 'gdl' => 'model/vnd.gdl',
  7340. 'geo' => 'application/vnd.dynageo',
  7341. 'gex' => 'application/vnd.geometry-explorer',
  7342. 'ggb' => 'application/vnd.geogebra.file',
  7343. 'ggt' => 'application/vnd.geogebra.tool',
  7344. 'ghf' => 'application/vnd.groove-help',
  7345. 'gif' => 'image/gif',
  7346. 'gim' => 'application/vnd.groove-identity-message',
  7347. 'gml' => 'application/gml+xml',
  7348. 'gmx' => 'application/vnd.gmx',
  7349. 'gnumeric' => 'application/x-gnumeric',
  7350. 'gph' => 'application/vnd.flographit',
  7351. 'gpx' => 'application/gpx+xml',
  7352. 'gqf' => 'application/vnd.grafeq',
  7353. 'gqs' => 'application/vnd.grafeq',
  7354. 'gram' => 'application/srgs',
  7355. 'gramps' => 'application/x-gramps-xml',
  7356. 'gre' => 'application/vnd.geometry-explorer',
  7357. 'grv' => 'application/vnd.groove-injector',
  7358. 'grxml' => 'application/srgs+xml',
  7359. 'gsf' => 'application/x-font-ghostscript',
  7360. 'gtar' => 'application/x-gtar',
  7361. 'gtm' => 'application/vnd.groove-tool-message',
  7362. 'gtw' => 'model/vnd.gtw',
  7363. 'gv' => 'text/vnd.graphviz',
  7364. 'gxf' => 'application/gxf',
  7365. 'gxt' => 'application/vnd.geonext',
  7366. 'h' => 'text/x-c',
  7367. 'h261' => 'video/h261',
  7368. 'h263' => 'video/h263',
  7369. 'h264' => 'video/h264',
  7370. 'hal' => 'application/vnd.hal+xml',
  7371. 'hbci' => 'application/vnd.hbci',
  7372. 'hdf' => 'application/x-hdf',
  7373. 'hh' => 'text/x-c',
  7374. 'hlp' => 'application/winhlp',
  7375. 'hpgl' => 'application/vnd.hp-hpgl',
  7376. 'hpid' => 'application/vnd.hp-hpid',
  7377. 'hps' => 'application/vnd.hp-hps',
  7378. 'hqx' => 'application/mac-binhex40',
  7379. 'htke' => 'application/vnd.kenameaapp',
  7380. 'htm' => 'text/html',
  7381. 'html' => 'text/html',
  7382. 'hvd' => 'application/vnd.yamaha.hv-dic',
  7383. 'hvp' => 'application/vnd.yamaha.hv-voice',
  7384. 'hvs' => 'application/vnd.yamaha.hv-script',
  7385. 'i2g' => 'application/vnd.intergeo',
  7386. 'icc' => 'application/vnd.iccprofile',
  7387. 'ice' => 'x-conference/x-cooltalk',
  7388. 'icm' => 'application/vnd.iccprofile',
  7389. 'ico' => 'image/x-icon',
  7390. 'ics' => 'text/calendar',
  7391. 'ief' => 'image/ief',
  7392. 'ifb' => 'text/calendar',
  7393. 'ifm' => 'application/vnd.shana.informed.formdata',
  7394. 'iges' => 'model/iges',
  7395. 'igl' => 'application/vnd.igloader',
  7396. 'igm' => 'application/vnd.insors.igm',
  7397. 'igs' => 'model/iges',
  7398. 'igx' => 'application/vnd.micrografx.igx',
  7399. 'iif' => 'application/vnd.shana.informed.interchange',
  7400. 'imp' => 'application/vnd.accpac.simply.imp',
  7401. 'ims' => 'application/vnd.ms-ims',
  7402. 'in' => 'text/plain',
  7403. 'ink' => 'application/inkml+xml',
  7404. 'inkml' => 'application/inkml+xml',
  7405. 'install' => 'application/x-install-instructions',
  7406. 'iota' => 'application/vnd.astraea-software.iota',
  7407. 'ipfix' => 'application/ipfix',
  7408. 'ipk' => 'application/vnd.shana.informed.package',
  7409. 'irm' => 'application/vnd.ibm.rights-management',
  7410. 'irp' => 'application/vnd.irepository.package+xml',
  7411. 'iso' => 'application/x-iso9660-image',
  7412. 'itp' => 'application/vnd.shana.informed.formtemplate',
  7413. 'ivp' => 'application/vnd.immervision-ivp',
  7414. 'ivu' => 'application/vnd.immervision-ivu',
  7415. 'jad' => 'text/vnd.sun.j2me.app-descriptor',
  7416. 'jam' => 'application/vnd.jam',
  7417. 'jar' => 'application/java-archive',
  7418. 'java' => 'text/x-java-source',
  7419. 'jisp' => 'application/vnd.jisp',
  7420. 'jlt' => 'application/vnd.hp-jlyt',
  7421. 'jnlp' => 'application/x-java-jnlp-file',
  7422. 'joda' => 'application/vnd.joost.joda-archive',
  7423. 'jpe' => 'image/jpeg',
  7424. 'jpeg' => 'image/jpeg',
  7425. 'jpg' => 'image/jpeg',
  7426. 'jpgm' => 'video/jpm',
  7427. 'jpgv' => 'video/jpeg',
  7428. 'jpm' => 'video/jpm',
  7429. 'js' => 'application/javascript',
  7430. 'json' => 'application/json',
  7431. 'jsonml' => 'application/jsonml+json',
  7432. 'kar' => 'audio/midi',
  7433. 'karbon' => 'application/vnd.kde.karbon',
  7434. 'kfo' => 'application/vnd.kde.kformula',
  7435. 'kia' => 'application/vnd.kidspiration',
  7436. 'kml' => 'application/vnd.google-earth.kml+xml',
  7437. 'kmz' => 'application/vnd.google-earth.kmz',
  7438. 'kne' => 'application/vnd.kinar',
  7439. 'knp' => 'application/vnd.kinar',
  7440. 'kon' => 'application/vnd.kde.kontour',
  7441. 'kpr' => 'application/vnd.kde.kpresenter',
  7442. 'kpt' => 'application/vnd.kde.kpresenter',
  7443. 'kpxx' => 'application/vnd.ds-keypoint',
  7444. 'ksp' => 'application/vnd.kde.kspread',
  7445. 'ktr' => 'application/vnd.kahootz',
  7446. 'ktx' => 'image/ktx',
  7447. 'ktz' => 'application/vnd.kahootz',
  7448. 'kwd' => 'application/vnd.kde.kword',
  7449. 'kwt' => 'application/vnd.kde.kword',
  7450. 'lasxml' => 'application/vnd.las.las+xml',
  7451. 'latex' => 'application/x-latex',
  7452. 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  7453. 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  7454. 'les' => 'application/vnd.hhe.lesson-player',
  7455. 'lha' => 'application/x-lzh-compressed',
  7456. 'link66' => 'application/vnd.route66.link66+xml',
  7457. 'list' => 'text/plain',
  7458. 'list3820' => 'application/vnd.ibm.modcap',
  7459. 'listafp' => 'application/vnd.ibm.modcap',
  7460. 'lnk' => 'application/x-ms-shortcut',
  7461. 'log' => 'text/plain',
  7462. 'lostxml' => 'application/lost+xml',
  7463. 'lrf' => 'application/octet-stream',
  7464. 'lrm' => 'application/vnd.ms-lrm',
  7465. 'ltf' => 'application/vnd.frogans.ltf',
  7466. 'lvp' => 'audio/vnd.lucent.voice',
  7467. 'lwp' => 'application/vnd.lotus-wordpro',
  7468. 'lzh' => 'application/x-lzh-compressed',
  7469. 'm13' => 'application/x-msmediaview',
  7470. 'm14' => 'application/x-msmediaview',
  7471. 'm1v' => 'video/mpeg',
  7472. 'm21' => 'application/mp21',
  7473. 'm2a' => 'audio/mpeg',
  7474. 'm2v' => 'video/mpeg',
  7475. 'm3a' => 'audio/mpeg',
  7476. 'm3u' => 'audio/x-mpegurl',
  7477. 'm3u8' => 'application/vnd.apple.mpegurl',
  7478. 'm4a' => 'audio/mp4',
  7479. 'm4u' => 'video/vnd.mpegurl',
  7480. 'm4v' => 'video/x-m4v',
  7481. 'ma' => 'application/mathematica',
  7482. 'mads' => 'application/mads+xml',
  7483. 'mag' => 'application/vnd.ecowin.chart',
  7484. 'maker' => 'application/vnd.framemaker',
  7485. 'man' => 'text/troff',
  7486. 'mar' => 'application/octet-stream',
  7487. 'mathml' => 'application/mathml+xml',
  7488. 'mb' => 'application/mathematica',
  7489. 'mbk' => 'application/vnd.mobius.mbk',
  7490. 'mbox' => 'application/mbox',
  7491. 'mc1' => 'application/vnd.medcalcdata',
  7492. 'mcd' => 'application/vnd.mcd',
  7493. 'mcurl' => 'text/vnd.curl.mcurl',
  7494. 'mdb' => 'application/x-msaccess',
  7495. 'mdi' => 'image/vnd.ms-modi',
  7496. 'me' => 'text/troff',
  7497. 'mesh' => 'model/mesh',
  7498. 'meta4' => 'application/metalink4+xml',
  7499. 'metalink' => 'application/metalink+xml',
  7500. 'mets' => 'application/mets+xml',
  7501. 'mfm' => 'application/vnd.mfmp',
  7502. 'mft' => 'application/rpki-manifest',
  7503. 'mgp' => 'application/vnd.osgeo.mapguide.package',
  7504. 'mgz' => 'application/vnd.proteus.magazine',
  7505. 'mid' => 'audio/midi',
  7506. 'midi' => 'audio/midi',
  7507. 'mie' => 'application/x-mie',
  7508. 'mif' => 'application/vnd.mif',
  7509. 'mime' => 'message/rfc822',
  7510. 'mj2' => 'video/mj2',
  7511. 'mjp2' => 'video/mj2',
  7512. 'mk3d' => 'video/x-matroska',
  7513. 'mka' => 'audio/x-matroska',
  7514. 'mks' => 'video/x-matroska',
  7515. 'mkv' => 'video/x-matroska',
  7516. 'mlp' => 'application/vnd.dolby.mlp',
  7517. 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
  7518. 'mmf' => 'application/vnd.smaf',
  7519. 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
  7520. 'mng' => 'video/x-mng',
  7521. 'mny' => 'application/x-msmoney',
  7522. 'mobi' => 'application/x-mobipocket-ebook',
  7523. 'mods' => 'application/mods+xml',
  7524. 'mov' => 'video/quicktime',
  7525. 'movie' => 'video/x-sgi-movie',
  7526. 'mp2' => 'audio/mpeg',
  7527. 'mp21' => 'application/mp21',
  7528. 'mp2a' => 'audio/mpeg',
  7529. 'mp3' => 'audio/mpeg',
  7530. 'mp4' => 'video/mp4',
  7531. 'mp4a' => 'audio/mp4',
  7532. 'mp4s' => 'application/mp4',
  7533. 'mp4v' => 'video/mp4',
  7534. 'mpc' => 'application/vnd.mophun.certificate',
  7535. 'mpe' => 'video/mpeg',
  7536. 'mpeg' => 'video/mpeg',
  7537. 'mpg' => 'video/mpeg',
  7538. 'mpg4' => 'video/mp4',
  7539. 'mpga' => 'audio/mpeg',
  7540. 'mpkg' => 'application/vnd.apple.installer+xml',
  7541. 'mpm' => 'application/vnd.blueice.multipass',
  7542. 'mpn' => 'application/vnd.mophun.application',
  7543. 'mpp' => 'application/vnd.ms-project',
  7544. 'mpt' => 'application/vnd.ms-project',
  7545. 'mpy' => 'application/vnd.ibm.minipay',
  7546. 'mqy' => 'application/vnd.mobius.mqy',
  7547. 'mrc' => 'application/marc',
  7548. 'mrcx' => 'application/marcxml+xml',
  7549. 'ms' => 'text/troff',
  7550. 'mscml' => 'application/mediaservercontrol+xml',
  7551. 'mseed' => 'application/vnd.fdsn.mseed',
  7552. 'mseq' => 'application/vnd.mseq',
  7553. 'msf' => 'application/vnd.epson.msf',
  7554. 'msh' => 'model/mesh',
  7555. 'msi' => 'application/x-msdownload',
  7556. 'msl' => 'application/vnd.mobius.msl',
  7557. 'msty' => 'application/vnd.muvee.style',
  7558. 'mts' => 'model/vnd.mts',
  7559. 'mus' => 'application/vnd.musician',
  7560. 'musicxml' => 'application/vnd.recordare.musicxml+xml',
  7561. 'mvb' => 'application/x-msmediaview',
  7562. 'mwf' => 'application/vnd.mfer',
  7563. 'mxf' => 'application/mxf',
  7564. 'mxl' => 'application/vnd.recordare.musicxml',
  7565. 'mxml' => 'application/xv+xml',
  7566. 'mxs' => 'application/vnd.triscape.mxs',
  7567. 'mxu' => 'video/vnd.mpegurl',
  7568. 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  7569. 'n3' => 'text/n3',
  7570. 'nb' => 'application/mathematica',
  7571. 'nbp' => 'application/vnd.wolfram.player',
  7572. 'nc' => 'application/x-netcdf',
  7573. 'ncx' => 'application/x-dtbncx+xml',
  7574. 'nfo' => 'text/x-nfo',
  7575. 'ngdat' => 'application/vnd.nokia.n-gage.data',
  7576. 'nitf' => 'application/vnd.nitf',
  7577. 'nlu' => 'application/vnd.neurolanguage.nlu',
  7578. 'nml' => 'application/vnd.enliven',
  7579. 'nnd' => 'application/vnd.noblenet-directory',
  7580. 'nns' => 'application/vnd.noblenet-sealer',
  7581. 'nnw' => 'application/vnd.noblenet-web',
  7582. 'npx' => 'image/vnd.net-fpx',
  7583. 'nsc' => 'application/x-conference',
  7584. 'nsf' => 'application/vnd.lotus-notes',
  7585. 'ntf' => 'application/vnd.nitf',
  7586. 'nzb' => 'application/x-nzb',
  7587. 'oa2' => 'application/vnd.fujitsu.oasys2',
  7588. 'oa3' => 'application/vnd.fujitsu.oasys3',
  7589. 'oas' => 'application/vnd.fujitsu.oasys',
  7590. 'obd' => 'application/x-msbinder',
  7591. 'obj' => 'application/x-tgif',
  7592. 'oda' => 'application/oda',
  7593. 'odb' => 'application/vnd.oasis.opendocument.database',
  7594. 'odc' => 'application/vnd.oasis.opendocument.chart',
  7595. 'odf' => 'application/vnd.oasis.opendocument.formula',
  7596. 'odft' => 'application/vnd.oasis.opendocument.formula-template',
  7597. 'odg' => 'application/vnd.oasis.opendocument.graphics',
  7598. 'odi' => 'application/vnd.oasis.opendocument.image',
  7599. 'odm' => 'application/vnd.oasis.opendocument.text-master',
  7600. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  7601. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  7602. 'odt' => 'application/vnd.oasis.opendocument.text',
  7603. 'oga' => 'audio/ogg',
  7604. 'ogg' => 'audio/ogg',
  7605. 'ogv' => 'video/ogg',
  7606. 'ogx' => 'application/ogg',
  7607. 'omdoc' => 'application/omdoc+xml',
  7608. 'onepkg' => 'application/onenote',
  7609. 'onetmp' => 'application/onenote',
  7610. 'onetoc' => 'application/onenote',
  7611. 'onetoc2' => 'application/onenote',
  7612. 'opf' => 'application/oebps-package+xml',
  7613. 'opml' => 'text/x-opml',
  7614. 'oprc' => 'application/vnd.palm',
  7615. 'org' => 'application/vnd.lotus-organizer',
  7616. 'osf' => 'application/vnd.yamaha.openscoreformat',
  7617. 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  7618. 'otc' => 'application/vnd.oasis.opendocument.chart-template',
  7619. 'otf' => 'application/x-font-otf',
  7620. 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
  7621. 'oth' => 'application/vnd.oasis.opendocument.text-web',
  7622. 'oti' => 'application/vnd.oasis.opendocument.image-template',
  7623. 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
  7624. 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  7625. 'ott' => 'application/vnd.oasis.opendocument.text-template',
  7626. 'oxps' => 'application/oxps',
  7627. 'oxt' => 'application/vnd.openofficeorg.extension',
  7628. 'p' => 'text/x-pascal',
  7629. 'p10' => 'application/pkcs10',
  7630. 'p12' => 'application/x-pkcs12',
  7631. 'p7b' => 'application/x-pkcs7-certificates',
  7632. 'p7c' => 'application/pkcs7-mime',
  7633. 'p7m' => 'application/pkcs7-mime',
  7634. 'p7r' => 'application/x-pkcs7-certreqresp',
  7635. 'p7s' => 'application/pkcs7-signature',
  7636. 'p8' => 'application/pkcs8',
  7637. 'pas' => 'text/x-pascal',
  7638. 'paw' => 'application/vnd.pawaafile',
  7639. 'pbd' => 'application/vnd.powerbuilder6',
  7640. 'pbm' => 'image/x-portable-bitmap',
  7641. 'pcap' => 'application/vnd.tcpdump.pcap',
  7642. 'pcf' => 'application/x-font-pcf',
  7643. 'pcl' => 'application/vnd.hp-pcl',
  7644. 'pclxl' => 'application/vnd.hp-pclxl',
  7645. 'pct' => 'image/x-pict',
  7646. 'pcurl' => 'application/vnd.curl.pcurl',
  7647. 'pcx' => 'image/x-pcx',
  7648. 'pdb' => 'application/vnd.palm',
  7649. 'pdf' => 'application/pdf',
  7650. 'pfa' => 'application/x-font-type1',
  7651. 'pfb' => 'application/x-font-type1',
  7652. 'pfm' => 'application/x-font-type1',
  7653. 'pfr' => 'application/font-tdpfr',
  7654. 'pfx' => 'application/x-pkcs12',
  7655. 'pgm' => 'image/x-portable-graymap',
  7656. 'pgn' => 'application/x-chess-pgn',
  7657. 'pgp' => 'application/pgp-encrypted',
  7658. 'pic' => 'image/x-pict',
  7659. 'pkg' => 'application/octet-stream',
  7660. 'pki' => 'application/pkixcmp',
  7661. 'pkipath' => 'application/pkix-pkipath',
  7662. 'plb' => 'application/vnd.3gpp.pic-bw-large',
  7663. 'plc' => 'application/vnd.mobius.plc',
  7664. 'plf' => 'application/vnd.pocketlearn',
  7665. 'pls' => 'application/pls+xml',
  7666. 'pml' => 'application/vnd.ctc-posml',
  7667. 'png' => 'image/png',
  7668. 'pnm' => 'image/x-portable-anymap',
  7669. 'portpkg' => 'application/vnd.macports.portpkg',
  7670. 'pot' => 'application/vnd.ms-powerpoint',
  7671. 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
  7672. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  7673. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  7674. 'ppd' => 'application/vnd.cups-ppd',
  7675. 'ppm' => 'image/x-portable-pixmap',
  7676. 'pps' => 'application/vnd.ms-powerpoint',
  7677. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  7678. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  7679. 'ppt' => 'application/vnd.ms-powerpoint',
  7680. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  7681. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  7682. 'pqa' => 'application/vnd.palm',
  7683. 'prc' => 'application/x-mobipocket-ebook',
  7684. 'pre' => 'application/vnd.lotus-freelance',
  7685. 'prf' => 'application/pics-rules',
  7686. 'ps' => 'application/postscript',
  7687. 'psb' => 'application/vnd.3gpp.pic-bw-small',
  7688. 'psd' => 'image/vnd.adobe.photoshop',
  7689. 'psf' => 'application/x-font-linux-psf',
  7690. 'pskcxml' => 'application/pskc+xml',
  7691. 'ptid' => 'application/vnd.pvi.ptid1',
  7692. 'pub' => 'application/x-mspublisher',
  7693. 'pvb' => 'application/vnd.3gpp.pic-bw-var',
  7694. 'pwn' => 'application/vnd.3m.post-it-notes',
  7695. 'pya' => 'audio/vnd.ms-playready.media.pya',
  7696. 'pyv' => 'video/vnd.ms-playready.media.pyv',
  7697. 'qam' => 'application/vnd.epson.quickanime',
  7698. 'qbo' => 'application/vnd.intu.qbo',
  7699. 'qfx' => 'application/vnd.intu.qfx',
  7700. 'qps' => 'application/vnd.publishare-delta-tree',
  7701. 'qt' => 'video/quicktime',
  7702. 'qwd' => 'application/vnd.quark.quarkxpress',
  7703. 'qwt' => 'application/vnd.quark.quarkxpress',
  7704. 'qxb' => 'application/vnd.quark.quarkxpress',
  7705. 'qxd' => 'application/vnd.quark.quarkxpress',
  7706. 'qxl' => 'application/vnd.quark.quarkxpress',
  7707. 'qxt' => 'application/vnd.quark.quarkxpress',
  7708. 'ra' => 'audio/x-pn-realaudio',
  7709. 'ram' => 'audio/x-pn-realaudio',
  7710. 'rar' => 'application/x-rar-compressed',
  7711. 'ras' => 'image/x-cmu-raster',
  7712. 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
  7713. 'rdf' => 'application/rdf+xml',
  7714. 'rdz' => 'application/vnd.data-vision.rdz',
  7715. 'rep' => 'application/vnd.businessobjects',
  7716. 'res' => 'application/x-dtbresource+xml',
  7717. 'rgb' => 'image/x-rgb',
  7718. 'rif' => 'application/reginfo+xml',
  7719. 'rip' => 'audio/vnd.rip',
  7720. 'ris' => 'application/x-research-info-systems',
  7721. 'rl' => 'application/resource-lists+xml',
  7722. 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
  7723. 'rld' => 'application/resource-lists-diff+xml',
  7724. 'rm' => 'application/vnd.rn-realmedia',
  7725. 'rmi' => 'audio/midi',
  7726. 'rmp' => 'audio/x-pn-realaudio-plugin',
  7727. 'rms' => 'application/vnd.jcp.javame.midlet-rms',
  7728. 'rmvb' => 'application/vnd.rn-realmedia-vbr',
  7729. 'rnc' => 'application/relax-ng-compact-syntax',
  7730. 'roa' => 'application/rpki-roa',
  7731. 'roff' => 'text/troff',
  7732. 'rp9' => 'application/vnd.cloanto.rp9',
  7733. 'rpss' => 'application/vnd.nokia.radio-presets',
  7734. 'rpst' => 'application/vnd.nokia.radio-preset',
  7735. 'rq' => 'application/sparql-query',
  7736. 'rs' => 'application/rls-services+xml',
  7737. 'rsd' => 'application/rsd+xml',
  7738. 'rss' => 'application/rss+xml',
  7739. 'rtf' => 'application/rtf',
  7740. 'rtx' => 'text/richtext',
  7741. 's' => 'text/x-asm',
  7742. 's3m' => 'audio/s3m',
  7743. 'saf' => 'application/vnd.yamaha.smaf-audio',
  7744. 'sbml' => 'application/sbml+xml',
  7745. 'sc' => 'application/vnd.ibm.secure-container',
  7746. 'scd' => 'application/x-msschedule',
  7747. 'scm' => 'application/vnd.lotus-screencam',
  7748. 'scq' => 'application/scvp-cv-request',
  7749. 'scs' => 'application/scvp-cv-response',
  7750. 'scurl' => 'text/vnd.curl.scurl',
  7751. 'sda' => 'application/vnd.stardivision.draw',
  7752. 'sdc' => 'application/vnd.stardivision.calc',
  7753. 'sdd' => 'application/vnd.stardivision.impress',
  7754. 'sdkd' => 'application/vnd.solent.sdkm+xml',
  7755. 'sdkm' => 'application/vnd.solent.sdkm+xml',
  7756. 'sdp' => 'application/sdp',
  7757. 'sdw' => 'application/vnd.stardivision.writer',
  7758. 'see' => 'application/vnd.seemail',
  7759. 'seed' => 'application/vnd.fdsn.seed',
  7760. 'sema' => 'application/vnd.sema',
  7761. 'semd' => 'application/vnd.semd',
  7762. 'semf' => 'application/vnd.semf',
  7763. 'ser' => 'application/java-serialized-object',
  7764. 'setpay' => 'application/set-payment-initiation',
  7765. 'setreg' => 'application/set-registration-initiation',
  7766. 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
  7767. 'sfs' => 'application/vnd.spotfire.sfs',
  7768. 'sfv' => 'text/x-sfv',
  7769. 'sgi' => 'image/sgi',
  7770. 'sgl' => 'application/vnd.stardivision.writer-global',
  7771. 'sgm' => 'text/sgml',
  7772. 'sgml' => 'text/sgml',
  7773. 'sh' => 'application/x-sh',
  7774. 'shar' => 'application/x-shar',
  7775. 'shf' => 'application/shf+xml',
  7776. 'sid' => 'image/x-mrsid-image',
  7777. 'sig' => 'application/pgp-signature',
  7778. 'sil' => 'audio/silk',
  7779. 'silo' => 'model/mesh',
  7780. 'sis' => 'application/vnd.symbian.install',
  7781. 'sisx' => 'application/vnd.symbian.install',
  7782. 'sit' => 'application/x-stuffit',
  7783. 'sitx' => 'application/x-stuffitx',
  7784. 'skd' => 'application/vnd.koan',
  7785. 'skm' => 'application/vnd.koan',
  7786. 'skp' => 'application/vnd.koan',
  7787. 'skt' => 'application/vnd.koan',
  7788. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  7789. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  7790. 'slt' => 'application/vnd.epson.salt',
  7791. 'sm' => 'application/vnd.stepmania.stepchart',
  7792. 'smf' => 'application/vnd.stardivision.math',
  7793. 'smi' => 'application/smil+xml',
  7794. 'smil' => 'application/smil+xml',
  7795. 'smv' => 'video/x-smv',
  7796. 'smzip' => 'application/vnd.stepmania.package',
  7797. 'snd' => 'audio/basic',
  7798. 'snf' => 'application/x-font-snf',
  7799. 'so' => 'application/octet-stream',
  7800. 'spc' => 'application/x-pkcs7-certificates',
  7801. 'spf' => 'application/vnd.yamaha.smaf-phrase',
  7802. 'spl' => 'application/x-futuresplash',
  7803. 'spot' => 'text/vnd.in3d.spot',
  7804. 'spp' => 'application/scvp-vp-response',
  7805. 'spq' => 'application/scvp-vp-request',
  7806. 'spx' => 'audio/ogg',
  7807. 'sql' => 'application/x-sql',
  7808. 'src' => 'application/x-wais-source',
  7809. 'srt' => 'application/x-subrip',
  7810. 'sru' => 'application/sru+xml',
  7811. 'srx' => 'application/sparql-results+xml',
  7812. 'ssdl' => 'application/ssdl+xml',
  7813. 'sse' => 'application/vnd.kodak-descriptor',
  7814. 'ssf' => 'application/vnd.epson.ssf',
  7815. 'ssml' => 'application/ssml+xml',
  7816. 'st' => 'application/vnd.sailingtracker.track',
  7817. 'stc' => 'application/vnd.sun.xml.calc.template',
  7818. 'std' => 'application/vnd.sun.xml.draw.template',
  7819. 'stf' => 'application/vnd.wt.stf',
  7820. 'sti' => 'application/vnd.sun.xml.impress.template',
  7821. 'stk' => 'application/hyperstudio',
  7822. 'stl' => 'application/vnd.ms-pki.stl',
  7823. 'str' => 'application/vnd.pg.format',
  7824. 'stw' => 'application/vnd.sun.xml.writer.template',
  7825. 'sub' => 'image/vnd.dvb.subtitle',
  7826. 'sub' => 'text/vnd.dvb.subtitle',
  7827. 'sus' => 'application/vnd.sus-calendar',
  7828. 'susp' => 'application/vnd.sus-calendar',
  7829. 'sv4cpio' => 'application/x-sv4cpio',
  7830. 'sv4crc' => 'application/x-sv4crc',
  7831. 'svc' => 'application/vnd.dvb.service',
  7832. 'svd' => 'application/vnd.svd',
  7833. 'svg' => 'image/svg+xml',
  7834. 'svgz' => 'image/svg+xml',
  7835. 'swa' => 'application/x-director',
  7836. 'swf' => 'application/x-shockwave-flash',
  7837. 'swi' => 'application/vnd.aristanetworks.swi',
  7838. 'sxc' => 'application/vnd.sun.xml.calc',
  7839. 'sxd' => 'application/vnd.sun.xml.draw',
  7840. 'sxg' => 'application/vnd.sun.xml.writer.global',
  7841. 'sxi' => 'application/vnd.sun.xml.impress',
  7842. 'sxm' => 'application/vnd.sun.xml.math',
  7843. 'sxw' => 'application/vnd.sun.xml.writer',
  7844. 't' => 'text/troff',
  7845. 't3' => 'application/x-t3vm-image',
  7846. 'taglet' => 'application/vnd.mynfc',
  7847. 'tao' => 'application/vnd.tao.intent-module-archive',
  7848. 'tar' => 'application/x-tar',
  7849. 'tcap' => 'application/vnd.3gpp2.tcap',
  7850. 'tcl' => 'application/x-tcl',
  7851. 'teacher' => 'application/vnd.smart.teacher',
  7852. 'tei' => 'application/tei+xml',
  7853. 'teicorpus' => 'application/tei+xml',
  7854. 'tex' => 'application/x-tex',
  7855. 'texi' => 'application/x-texinfo',
  7856. 'texinfo' => 'application/x-texinfo',
  7857. 'text' => 'text/plain',
  7858. 'tfi' => 'application/thraud+xml',
  7859. 'tfm' => 'application/x-tex-tfm',
  7860. 'tga' => 'image/x-tga',
  7861. 'thmx' => 'application/vnd.ms-officetheme',
  7862. 'tif' => 'image/tiff',
  7863. 'tiff' => 'image/tiff',
  7864. 'tmo' => 'application/vnd.tmobile-livetv',
  7865. 'torrent' => 'application/x-bittorrent',
  7866. 'tpl' => 'application/vnd.groove-tool-template',
  7867. 'tpt' => 'application/vnd.trid.tpt',
  7868. 'tr' => 'text/troff',
  7869. 'tra' => 'application/vnd.trueapp',
  7870. 'trm' => 'application/x-msterminal',
  7871. 'tsd' => 'application/timestamped-data',
  7872. 'tsv' => 'text/tab-separated-values',
  7873. 'ttc' => 'application/x-font-ttf',
  7874. 'ttf' => 'application/x-font-ttf',
  7875. 'ttl' => 'text/turtle',
  7876. 'twd' => 'application/vnd.simtech-mindmapper',
  7877. 'twds' => 'application/vnd.simtech-mindmapper',
  7878. 'txd' => 'application/vnd.genomatix.tuxedo',
  7879. 'txf' => 'application/vnd.mobius.txf',
  7880. 'txt' => 'text/plain',
  7881. 'u32' => 'application/x-authorware-bin',
  7882. 'udeb' => 'application/x-debian-package',
  7883. 'ufd' => 'application/vnd.ufdl',
  7884. 'ufdl' => 'application/vnd.ufdl',
  7885. 'ulx' => 'application/x-glulx',
  7886. 'umj' => 'application/vnd.umajin',
  7887. 'unityweb' => 'application/vnd.unity',
  7888. 'uoml' => 'application/vnd.uoml+xml',
  7889. 'uri' => 'text/uri-list',
  7890. 'uris' => 'text/uri-list',
  7891. 'urls' => 'text/uri-list',
  7892. 'ustar' => 'application/x-ustar',
  7893. 'utz' => 'application/vnd.uiq.theme',
  7894. 'uu' => 'text/x-uuencode',
  7895. 'uva' => 'audio/vnd.dece.audio',
  7896. 'uvd' => 'application/vnd.dece.data',
  7897. 'uvf' => 'application/vnd.dece.data',
  7898. 'uvg' => 'image/vnd.dece.graphic',
  7899. 'uvh' => 'video/vnd.dece.hd',
  7900. 'uvi' => 'image/vnd.dece.graphic',
  7901. 'uvm' => 'video/vnd.dece.mobile',
  7902. 'uvp' => 'video/vnd.dece.pd',
  7903. 'uvs' => 'video/vnd.dece.sd',
  7904. 'uvt' => 'application/vnd.dece.ttml+xml',
  7905. 'uvu' => 'video/vnd.uvvu.mp4',
  7906. 'uvv' => 'video/vnd.dece.video',
  7907. 'uvva' => 'audio/vnd.dece.audio',
  7908. 'uvvd' => 'application/vnd.dece.data',
  7909. 'uvvf' => 'application/vnd.dece.data',
  7910. 'uvvg' => 'image/vnd.dece.graphic',
  7911. 'uvvh' => 'video/vnd.dece.hd',
  7912. 'uvvi' => 'image/vnd.dece.graphic',
  7913. 'uvvm' => 'video/vnd.dece.mobile',
  7914. 'uvvp' => 'video/vnd.dece.pd',
  7915. 'uvvs' => 'video/vnd.dece.sd',
  7916. 'uvvt' => 'application/vnd.dece.ttml+xml',
  7917. 'uvvu' => 'video/vnd.uvvu.mp4',
  7918. 'uvvv' => 'video/vnd.dece.video',
  7919. 'uvvx' => 'application/vnd.dece.unspecified',
  7920. 'uvvz' => 'application/vnd.dece.zip',
  7921. 'uvx' => 'application/vnd.dece.unspecified',
  7922. 'uvz' => 'application/vnd.dece.zip',
  7923. 'vcard' => 'text/vcard',
  7924. 'vcd' => 'application/x-cdlink',
  7925. 'vcf' => 'text/x-vcard',
  7926. 'vcg' => 'application/vnd.groove-vcard',
  7927. 'vcs' => 'text/x-vcalendar',
  7928. 'vcx' => 'application/vnd.vcx',
  7929. 'vis' => 'application/vnd.visionary',
  7930. 'viv' => 'video/vnd.vivo',
  7931. 'vob' => 'video/x-ms-vob',
  7932. 'vor' => 'application/vnd.stardivision.writer',
  7933. 'vox' => 'application/x-authorware-bin',
  7934. 'vrml' => 'model/vrml',
  7935. 'vsd' => 'application/vnd.visio',
  7936. 'vsf' => 'application/vnd.vsf',
  7937. 'vss' => 'application/vnd.visio',
  7938. 'vst' => 'application/vnd.visio',
  7939. 'vsw' => 'application/vnd.visio',
  7940. 'vtu' => 'model/vnd.vtu',
  7941. 'vxml' => 'application/voicexml+xml',
  7942. 'w3d' => 'application/x-director',
  7943. 'wad' => 'application/x-doom',
  7944. 'wav' => 'audio/x-wav',
  7945. 'wax' => 'audio/x-ms-wax',
  7946. 'wbmp' => 'image/vnd.wap.wbmp',
  7947. 'wbs' => 'application/vnd.criticaltools.wbs+xml',
  7948. 'wbxml' => 'application/vnd.wap.wbxml',
  7949. 'wcm' => 'application/vnd.ms-works',
  7950. 'wdb' => 'application/vnd.ms-works',
  7951. 'wdp' => 'image/vnd.ms-photo',
  7952. 'weba' => 'audio/webm',
  7953. 'webm' => 'video/webm',
  7954. 'webp' => 'image/webp',
  7955. 'wg' => 'application/vnd.pmi.widget',
  7956. 'wgt' => 'application/widget',
  7957. 'wks' => 'application/vnd.ms-works',
  7958. 'wm' => 'video/x-ms-wm',
  7959. 'wma' => 'audio/x-ms-wma',
  7960. 'wmd' => 'application/x-ms-wmd',
  7961. 'wmf' => 'application/x-msmetafile',
  7962. 'wml' => 'text/vnd.wap.wml',
  7963. 'wmlc' => 'application/vnd.wap.wmlc',
  7964. 'wmls' => 'text/vnd.wap.wmlscript',
  7965. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  7966. 'wmv' => 'video/x-ms-wmv',
  7967. 'wmx' => 'video/x-ms-wmx',
  7968. 'wmz' => 'application/x-ms-wmz',
  7969. 'wmz' => 'application/x-msmetafile',
  7970. 'woff' => 'application/font-woff',
  7971. 'wpd' => 'application/vnd.wordperfect',
  7972. 'wpl' => 'application/vnd.ms-wpl',
  7973. 'wps' => 'application/vnd.ms-works',
  7974. 'wqd' => 'application/vnd.wqd',
  7975. 'wri' => 'application/x-mswrite',
  7976. 'wrl' => 'model/vrml',
  7977. 'wsdl' => 'application/wsdl+xml',
  7978. 'wspolicy' => 'application/wspolicy+xml',
  7979. 'wtb' => 'application/vnd.webturbo',
  7980. 'wvx' => 'video/x-ms-wvx',
  7981. 'x32' => 'application/x-authorware-bin',
  7982. 'x3d' => 'model/x3d+xml',
  7983. 'x3db' => 'model/x3d+binary',
  7984. 'x3dbz' => 'model/x3d+binary',
  7985. 'x3dv' => 'model/x3d+vrml',
  7986. 'x3dvz' => 'model/x3d+vrml',
  7987. 'x3dz' => 'model/x3d+xml',
  7988. 'xaml' => 'application/xaml+xml',
  7989. 'xap' => 'application/x-silverlight-app',
  7990. 'xar' => 'application/vnd.xara',
  7991. 'xbap' => 'application/x-ms-xbap',
  7992. 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
  7993. 'xbm' => 'image/x-xbitmap',
  7994. 'xdf' => 'application/xcap-diff+xml',
  7995. 'xdm' => 'application/vnd.syncml.dm+xml',
  7996. 'xdp' => 'application/vnd.adobe.xdp+xml',
  7997. 'xdssc' => 'application/dssc+xml',
  7998. 'xdw' => 'application/vnd.fujixerox.docuworks',
  7999. 'xenc' => 'application/xenc+xml',
  8000. 'xer' => 'application/patch-ops-error+xml',
  8001. 'xfdf' => 'application/vnd.adobe.xfdf',
  8002. 'xfdl' => 'application/vnd.xfdl',
  8003. 'xht' => 'application/xhtml+xml',
  8004. 'xhtml' => 'application/xhtml+xml',
  8005. 'xhvml' => 'application/xv+xml',
  8006. 'xif' => 'image/vnd.xiff',
  8007. 'xla' => 'application/vnd.ms-excel',
  8008. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  8009. 'xlc' => 'application/vnd.ms-excel',
  8010. 'xlf' => 'application/x-xliff+xml',
  8011. 'xlm' => 'application/vnd.ms-excel',
  8012. 'xls' => 'application/vnd.ms-excel',
  8013. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  8014. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  8015. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  8016. 'xlt' => 'application/vnd.ms-excel',
  8017. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  8018. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  8019. 'xlw' => 'application/vnd.ms-excel',
  8020. 'xm' => 'audio/xm',
  8021. 'xml' => 'application/xml',
  8022. 'xo' => 'application/vnd.olpc-sugar',
  8023. 'xop' => 'application/xop+xml',
  8024. 'xpi' => 'application/x-xpinstall',
  8025. 'xpl' => 'application/xproc+xml',
  8026. 'xpm' => 'image/x-xpixmap',
  8027. 'xpr' => 'application/vnd.is-xpr',
  8028. 'xps' => 'application/vnd.ms-xpsdocument',
  8029. 'xpw' => 'application/vnd.intercon.formnet',
  8030. 'xpx' => 'application/vnd.intercon.formnet',
  8031. 'xsl' => 'application/xml',
  8032. 'xslt' => 'application/xslt+xml',
  8033. 'xsm' => 'application/vnd.syncml+xml',
  8034. 'xspf' => 'application/xspf+xml',
  8035. 'xul' => 'application/vnd.mozilla.xul+xml',
  8036. 'xvm' => 'application/xv+xml',
  8037. 'xvml' => 'application/xv+xml',
  8038. 'xwd' => 'image/x-xwindowdump',
  8039. 'xyz' => 'chemical/x-xyz',
  8040. 'xz' => 'application/x-xz',
  8041. 'yang' => 'application/yang',
  8042. 'yin' => 'application/yin+xml',
  8043. 'z1' => 'application/x-zmachine',
  8044. 'z2' => 'application/x-zmachine',
  8045. 'z3' => 'application/x-zmachine',
  8046. 'z4' => 'application/x-zmachine',
  8047. 'z5' => 'application/x-zmachine',
  8048. 'z6' => 'application/x-zmachine',
  8049. 'z7' => 'application/x-zmachine',
  8050. 'z8' => 'application/x-zmachine',
  8051. 'zaz' => 'application/vnd.zzazz.deck+xml',
  8052. 'zip' => 'application/zip',
  8053. 'zir' => 'application/vnd.zul',
  8054. 'zirz' => 'application/vnd.zul',
  8055. 'zmm' => 'application/vnd.handheld-entertainment+xml'
  8056. );
  8057. }
  8058. // Always run this
  8059. if(strpos($_SERVER['SCRIPT_NAME'], 'check.php') == false){
  8060. dependCheck();
  8061. }