functions.php 343 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317
  1. <?php
  2. // ===================================
  3. // Define Version
  4. define('INSTALLEDVERSION', '1.50');
  5. // ===================================
  6. use Kryptonit3\Sonarr\Sonarr;
  7. use Kryptonit3\SickRage\SickRage;
  8. //homepage order
  9. function homepageOrder(){
  10. $homepageOrder = array(
  11. "homepageOrdercustomhtml" => homepageOrdercustomhtml,
  12. "homepageOrdernotice" => homepageOrdernotice,
  13. "homepageOrderplexsearch" => homepageOrderplexsearch,
  14. "homepageOrderspeedtest" => homepageOrderspeedtest,
  15. "homepageOrdernzbget" => homepageOrdernzbget,
  16. "homepageOrdersabnzbd" => homepageOrdersabnzbd,
  17. "homepageOrderplexnowplaying" => homepageOrderplexnowplaying,
  18. "homepageOrderplexrecent" => homepageOrderplexrecent,
  19. "homepageOrderplexplaylist" => homepageOrderplexplaylist,
  20. "homepageOrderembynowplaying" => homepageOrderembynowplaying,
  21. "homepageOrderembyrecent" => homepageOrderembyrecent,
  22. "homepageOrderombi" => homepageOrderombi,
  23. "homepageOrdercalendar" => homepageOrdercalendar,
  24. );
  25. asort($homepageOrder);
  26. return $homepageOrder;
  27. }
  28. // Debugging output functions
  29. function debug_out($variable, $die = false) {
  30. $trace = debug_backtrace()[0];
  31. echo "<center><img height='200px' src='images/confused.png'></center>";
  32. echo "<center>Look's like something happened, here are the errors and perhaps how to fix them:</center>";
  33. echo '<pre style="white-space: pre-line; background-color: #f2f2f2; border: 2px solid black; border-radius: 5px; padding: 5px; margin: 5px;">'.$trace['file'].':'.$trace['line']."\n\n".print_r($variable, true).'</pre>';
  34. if ($die) { http_response_code(503); die(); }
  35. }
  36. // ==== Auth Plugins START ====
  37. if (function_exists('ldap_connect')) :
  38. // Pass credentials to LDAP backend
  39. function plugin_auth_ldap($username, $password) {
  40. $ldapServers = explode(',',AUTHBACKENDHOST);
  41. foreach($ldapServers as $key => $value) {
  42. // Calculate parts
  43. $digest = parse_url(trim($value));
  44. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:'ldap'));
  45. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  46. $port = (isset($digest['port'])?$digest['port']:(strtolower($scheme)=='ldap'?389:636));
  47. // Reassign
  48. $ldapServers[$key] = $scheme.'://'.$host.':'.$port;
  49. }
  50. // returns true or false
  51. $ldap = ldap_connect(implode(' ',$ldapServers));
  52. if(empty(AUTHBACKENDDOMAINFORMAT)){
  53. if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
  54. writeLog("success", "LDAP authentication success");
  55. return true;
  56. } else {
  57. writeLog("error", "LDAP could not authenticate");
  58. return false;
  59. }
  60. }else{
  61. ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
  62. ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
  63. $bind = @ldap_bind($ldap, sprintf(AUTHBACKENDDOMAINFORMAT, $username), $password);
  64. if ($bind) {
  65. writeLog("success", "LDAP authentication success");
  66. return true;
  67. } else {
  68. writeLog("error", "LDPA could not authenticate");
  69. return false;
  70. }
  71. }
  72. writeLog("error", "LDAP could not authenticate");
  73. return false;
  74. }
  75. else :
  76. // Ldap Auth Missing Dependancy
  77. function plugin_auth_ldap_disabled() {
  78. return 'LDAP - Disabled (Dependancy: php-ldap missing!)';
  79. }
  80. endif;
  81. // Pass credentials to FTP backend
  82. function plugin_auth_ftp($username, $password) {
  83. // Calculate parts
  84. $digest = parse_url(AUTHBACKENDHOST);
  85. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:(function_exists('ftp_ssl_connect')?'ftps':'ftp')));
  86. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  87. $port = (isset($digest['port'])?$digest['port']:21);
  88. // Determine Connection Type
  89. if ($scheme == 'ftps') {
  90. $conn_id = ftp_ssl_connect($host, $port, 20);
  91. } elseif ($scheme == 'ftp') {
  92. $conn_id = ftp_connect($host, $port, 20);
  93. } else {
  94. debug_out('Invalid FTP scheme. Use ftp or ftps');
  95. writeLog("error", "invalid FTP scheme");
  96. return false;
  97. }
  98. // Check if valid FTP connection
  99. if ($conn_id) {
  100. // Attempt login
  101. @$login_result = ftp_login($conn_id, $username, $password);
  102. ftp_close($conn_id);
  103. // Return Result
  104. if ($login_result) {
  105. writeLog("success", "$username authenticated");
  106. return true;
  107. } else {
  108. writeLog("error", "$username could not authenticate");
  109. return false;
  110. }
  111. } else {
  112. return false;
  113. }
  114. return false;
  115. }
  116. // Pass credentials to Emby Backend
  117. function plugin_auth_emby_local($username, $password) {
  118. $embyAddress = qualifyURL(EMBYURL);
  119. $headers = array(
  120. 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"',
  121. 'Content-Type' => 'application/json',
  122. );
  123. $body = array(
  124. 'Username' => $username,
  125. 'Password' => sha1($password),
  126. 'PasswordMd5' => md5($password),
  127. );
  128. $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers);
  129. if (isset($response['content'])) {
  130. $json = json_decode($response['content'], true);
  131. if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
  132. // Login Success - Now Logout Emby Session As We No Longer Need It
  133. $headers = array(
  134. 'X-Mediabrowser-Token' => $json['AccessToken'],
  135. );
  136. $response = post_router($embyAddress.'/Sessions/Logout', array(), $headers);
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. if (function_exists('curl_version')) :
  143. // Authenticate Against Emby Local (first) and Emby Connect
  144. function plugin_auth_emby_all($username, $password) {
  145. $localResult = plugin_auth_emby_local($username, $password);
  146. if ($localResult) {
  147. return $localResult;
  148. } else {
  149. return plugin_auth_emby_connect($username, $password);
  150. }
  151. }
  152. // Authenicate against emby connect
  153. function plugin_auth_emby_connect($username, $password) {
  154. $embyAddress = qualifyURL(EMBYURL);
  155. // Get A User
  156. $connectId = '';
  157. $userIds = json_decode(file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
  158. if (is_array($userIds)) {
  159. foreach ($userIds as $key => $value) { // Scan for this user
  160. if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
  161. if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
  162. $connectId = $value['ConnectUserId'];
  163. break;
  164. }
  165. }
  166. }
  167. if ($connectId) {
  168. $connectURL = 'https://connect.emby.media/service/user/authenticate';
  169. $headers = array(
  170. 'Accept'=> 'application/json',
  171. 'Content-Type' => 'application/x-www-form-urlencoded',
  172. );
  173. $body = array(
  174. 'nameOrEmail' => $username,
  175. 'rawpw' => $password,
  176. );
  177. $result = curl_post($connectURL, $body, $headers);
  178. if (isset($result['content'])) {
  179. $json = json_decode($result['content'], true);
  180. if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
  181. return array(
  182. 'email' => $json['User']['Email'],
  183. 'image' => $json['User']['ImageUrl'],
  184. );
  185. }
  186. }
  187. }
  188. }
  189. return false;
  190. }
  191. // Pass credentials to Plex Backend
  192. function plugin_auth_plex($username, $password) {
  193. // Quick out
  194. $isAdmin = false;
  195. if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
  196. writeLog("success", "Admin: ".$username." authenticated by plex");
  197. //return true;
  198. $isAdmin = true;
  199. }
  200. //Get User List
  201. $userURL = 'https://plex.tv/pms/friends/all';
  202. $userHeaders = array(
  203. 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD),
  204. );
  205. libxml_use_internal_errors(true);
  206. $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
  207. if (is_array($userXML) || is_object($userXML)) {
  208. $isUser = false;
  209. $usernameLower = strtolower($username);
  210. foreach($userXML AS $child) {
  211. if(isset($child['username']) && strtolower($child['username']) == $usernameLower) {
  212. $isUser = true;
  213. writeLog("success", $usernameLower." was found in plex friends list");
  214. break;
  215. }
  216. }
  217. if ($isUser || $isAdmin) {
  218. //Login User
  219. $connectURL = 'https://plex.tv/users/sign_in.json';
  220. $headers = array(
  221. 'Accept'=> 'application/json',
  222. 'Content-Type' => 'application/x-www-form-urlencoded',
  223. 'X-Plex-Product' => 'Organizr',
  224. 'X-Plex-Version' => '1.0',
  225. 'X-Plex-Client-Identifier' => '01010101-10101010',
  226. );
  227. $body = array(
  228. 'user[login]' => $username,
  229. 'user[password]' => $password,
  230. );
  231. $result = curl_post($connectURL, $body, $headers);
  232. if (isset($result['content'])) {
  233. $json = json_decode($result['content'], true);
  234. if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && strtolower($json['user']['username']) == $usernameLower) {
  235. writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
  236. return array(
  237. 'email' => $json['user']['email'],
  238. 'image' => $json['user']['thumb'],
  239. 'token' => $json['user']['authToken']
  240. );
  241. }
  242. }
  243. }else{
  244. writeLog("error", "$username is not an authorized PLEX user or entered invalid password");
  245. }
  246. }else{
  247. writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");
  248. }
  249. return false;
  250. }
  251. else :
  252. // Plex Auth Missing Dependancy
  253. function plugin_auth_plex_disabled() {
  254. return 'Plex - Disabled (Dependancy: php-curl missing!)';
  255. }
  256. // Emby Connect Auth Missing Dependancy
  257. function plugin_auth_emby_connect_disabled() {
  258. return 'Emby Connect - Disabled (Dependancy: php-curl missing!)';
  259. }
  260. // Emby Both Auth Missing Dependancy
  261. function plugin_auth_emby_both_disabled() {
  262. return 'Emby Both - Disabled (Dependancy: php-curl missing!)';
  263. }
  264. endif;
  265. // ==== Auth Plugins END ====
  266. // ==== General Class Definitions START ====
  267. $userLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  268. class setLanguage {
  269. private $language = null;
  270. private $langCode = null;
  271. function __construct($language = false) {
  272. // Default
  273. if (!$language) {
  274. $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  275. }
  276. if (!file_exists("lang/{$language}.ini")) {
  277. $language = 'en';
  278. }
  279. $this->langCode = $language;
  280. $this->language = parse_ini_file("lang/{$language}.ini", false, INI_SCANNER_RAW);
  281. if (file_exists("lang/{$language}.cust.ini")) {
  282. foreach($tmp = parse_ini_file("lang/{$language}.cust.ini", false, INI_SCANNER_RAW) as $k => $v) {
  283. $this->language[$k] = $v;
  284. }
  285. }
  286. }
  287. public function getLang() {
  288. return $this->langCode;
  289. }
  290. public function translate($originalWord) {
  291. $getArg = func_num_args();
  292. if ($getArg > 1) {
  293. $allWords = func_get_args();
  294. array_shift($allWords);
  295. } else {
  296. $allWords = array();
  297. }
  298. $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null;
  299. if (!$translatedWord) {
  300. return ucwords(str_replace("_", " ", strtolower($originalWord)));
  301. //echo "WHOA!!!!!!! $originalWord";
  302. }
  303. $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES);
  304. return vsprintf($translatedWord, $allWords);
  305. }
  306. }
  307. $language = new setLanguage;
  308. // ==== General Class Definitions END ====
  309. // Direct request to curl if it exists, otherwise handle if not HTTPS
  310. function post_router($url, $data, $headers = array(), $referer='') {
  311. if (function_exists('curl_version')) {
  312. return curl_post($url, $data, $headers, $referer);
  313. } else {
  314. return post_request($url, $data, $headers, $referer);
  315. }
  316. }
  317. if (function_exists('curl_version')) :
  318. // Curl Post
  319. function curl_post($url, $data, $headers = array(), $referer='') {
  320. // Initiate cURL
  321. $curlReq = curl_init($url);
  322. // As post request
  323. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST");
  324. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  325. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  326. if(localURL($url)){
  327. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  328. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  329. }
  330. // Format Data
  331. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  332. case 'application/json':
  333. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  334. break;
  335. case 'application/x-www-form-urlencoded':
  336. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  337. break;
  338. default:
  339. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  340. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  341. }
  342. // Format Headers
  343. $cHeaders = array();
  344. foreach ($headers as $k => $v) {
  345. $cHeaders[] = $k.': '.$v;
  346. }
  347. if (count($cHeaders)) {
  348. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  349. }
  350. // Execute
  351. $result = curl_exec($curlReq);
  352. $httpcode = curl_getinfo($curlReq);
  353. // Close
  354. curl_close($curlReq);
  355. // Return
  356. return array('content'=>$result, 'http_code'=>$httpcode);
  357. }
  358. // Curl Put
  359. function curl_put($url, $data, $headers = array(), $referer='') {
  360. // Initiate cURL
  361. $curlReq = curl_init($url);
  362. // As post request
  363. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "PUT");
  364. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  365. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  366. if(localURL($url)){
  367. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  368. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  369. }
  370. // Format Data
  371. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  372. case 'application/json':
  373. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  374. break;
  375. case 'application/x-www-form-urlencoded':
  376. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  377. break;
  378. default:
  379. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  380. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  381. }
  382. // Format Headers
  383. $cHeaders = array();
  384. foreach ($headers as $k => $v) {
  385. $cHeaders[] = $k.': '.$v;
  386. }
  387. if (count($cHeaders)) {
  388. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  389. }
  390. // Execute
  391. $result = curl_exec($curlReq);
  392. $httpcode = curl_getinfo($curlReq);
  393. // Close
  394. curl_close($curlReq);
  395. // Return
  396. return array('content'=>$result, 'http_code'=>$httpcode);
  397. }
  398. //Curl Get Function
  399. function curl_get($url, $headers = array()) {
  400. // Initiate cURL
  401. $curlReq = curl_init($url);
  402. // As post request
  403. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET");
  404. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  405. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  406. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  407. if(localURL($url)){
  408. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  409. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  410. }
  411. // Format Headers
  412. $cHeaders = array();
  413. foreach ($headers as $k => $v) {
  414. $cHeaders[] = $k.': '.$v;
  415. }
  416. if (count($cHeaders)) {
  417. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  418. }
  419. // Execute
  420. $result = curl_exec($curlReq);
  421. // Close
  422. curl_close($curlReq);
  423. // Return
  424. return $result;
  425. }
  426. //Curl Delete Function
  427. function curl_delete($url, $headers = array()) {
  428. // Initiate cURL
  429. $curlReq = curl_init($url);
  430. // As post request
  431. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE");
  432. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  433. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  434. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  435. if(localURL($url)){
  436. curl_setopt($curlReq, CURLOPT_SSL_VERIFYHOST, 0);
  437. curl_setopt($curlReq, CURLOPT_SSL_VERIFYPEER, 0);
  438. }
  439. // Format Headers
  440. $cHeaders = array();
  441. foreach ($headers as $k => $v) {
  442. $cHeaders[] = $k.': '.$v;
  443. }
  444. if (count($cHeaders)) {
  445. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  446. }
  447. // Execute
  448. $result = curl_exec($curlReq);
  449. $httpcode = curl_getinfo($curlReq);
  450. // Close
  451. curl_close($curlReq);
  452. // Return
  453. return array('content'=>$result, 'http_code'=>$httpcode);
  454. }
  455. endif;
  456. //Case-Insensitive Function
  457. function in_arrayi($needle, $haystack) {
  458. return in_array(strtolower($needle), array_map('strtolower', $haystack));
  459. }
  460. // HTTP post request (Removes need for curl, probably useless)
  461. function post_request($url, $data, $headers = array(), $referer='') {
  462. // Adapted from http://stackoverflow.com/a/28387011/6810513
  463. // Convert the data array into URL Parameters like a=b&foo=bar etc.
  464. if (isset($headers['Content-Type'])) {
  465. switch ($headers['Content-Type']) {
  466. case 'application/json':
  467. $data = json_encode($data);
  468. break;
  469. case 'application/x-www-form-urlencoded':
  470. $data = http_build_query($data);
  471. break;
  472. }
  473. } else {
  474. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  475. $data = http_build_query($data);
  476. }
  477. // parse the given URL
  478. $urlDigest = parse_url($url);
  479. // extract host and path:
  480. $host = $urlDigest['host'];
  481. $path = $urlDigest['path'];
  482. if ($urlDigest['scheme'] != 'http') {
  483. die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')');
  484. }
  485. // open a socket connection on port 80 - timeout: 30 sec
  486. $fp = fsockopen($host, (isset($urlDigest['port'])?':'.$urlDigest['port']:80), $errno, $errstr, 30);
  487. if ($fp){
  488. // send the request headers:
  489. fputs($fp, "POST $path HTTP/1.1\r\n");
  490. fputs($fp, "Host: $host\r\n");
  491. if ($referer != '')
  492. fputs($fp, "Referer: $referer\r\n");
  493. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  494. foreach($headers as $k => $v) {
  495. fputs($fp, $k.": ".$v."\r\n");
  496. }
  497. fputs($fp, "Connection: close\r\n\r\n");
  498. fputs($fp, $data);
  499. $result = '';
  500. while(!feof($fp)) {
  501. // receive the results of the request
  502. $result .= fgets($fp, 128);
  503. }
  504. }
  505. else {
  506. return array(
  507. 'status' => 'err',
  508. 'error' => "$errstr ($errno)"
  509. );
  510. }
  511. // close the socket connection:
  512. fclose($fp);
  513. // split the result header from the content
  514. $result = explode("\r\n\r\n", $result, 2);
  515. $header = isset($result[0]) ? $result[0] : '';
  516. $content = isset($result[1]) ? $result[1] : '';
  517. // return as structured array:
  518. return array(
  519. 'status' => 'ok',
  520. 'header' => $header,
  521. 'content' => $content,
  522. );
  523. }
  524. // Format item from Emby for Carousel
  525. function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $moreInfo = false) {
  526. // Static Height
  527. $height = 444;
  528. // Get Item Details
  529. $itemDetails = json_decode(file_get_contents($address.'/Items?Ids='.$item['Id'].'&api_key='.$token),true)['Items'][0];
  530. /*if (substr_count(EMBYURL, ':') == 2) {
  531. $URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  532. }else{
  533. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  534. }*/
  535. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  536. switch ($itemDetails['Type']) {
  537. case 'Episode':
  538. case 'Series':
  539. $title = (isset($itemDetails['SeriesName'])?$itemDetails['SeriesName']:"");
  540. $imageId = (isset($itemDetails['SeriesId'])?$itemDetails['SeriesId']:$itemDetails['Id']);
  541. $width = 300;
  542. $style = '';
  543. $image = 'slick-image-tall';
  544. if(!$nowPlaying){
  545. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  546. $key = $itemDetails['Id'] . "-list";
  547. $itemType = 'season';
  548. }else{
  549. $height = 281;
  550. $width = 500;
  551. $imageId = isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId'] : (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  552. $imageType = isset($itemDetails['ParentThumbItemId']) ? "Thumb" : (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  553. $key = (isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId']."-np" : "none-np");
  554. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  555. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  556. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  557. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  558. $stream = $moreInfo['PlayState']['PlayMethod'];
  559. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  560. $id = $moreInfo['DeviceId'];
  561. $streamInfo = buildStream(array(
  562. 'platform' => (string) $moreInfo['Client'],
  563. 'device' => (string) $moreInfo['DeviceName'],
  564. 'stream' => streamType($stream),
  565. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  566. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  567. ));
  568. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  569. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$itemDetails['Name'].'</h5>';
  570. $bottomTitle = '<small class="zero-m">S'.$itemDetails['ParentIndexNumber'].' · E'.$itemDetails['IndexNumber'].'</small>';
  571. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  572. }
  573. break;
  574. case 'MusicAlbum':
  575. case 'Audio':
  576. $title = $itemDetails['Name'];
  577. $imageId = $itemDetails['Id'];
  578. $width = 444;
  579. $style = '';
  580. $image = 'slick-image-short';
  581. if(!$nowPlaying){
  582. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  583. $key = $itemDetails['Id'] . "-list";
  584. $itemType = 'album';
  585. }else{
  586. $height = 281;
  587. $width = 500;
  588. $imageId = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  589. $imageType = (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  590. $key = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : "no-np") . "-np";
  591. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  592. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  593. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  594. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  595. $stream = $moreInfo['PlayState']['PlayMethod'];
  596. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  597. $id = $moreInfo['DeviceId'];
  598. $streamInfo = buildStream(array(
  599. 'platform' => (string) $moreInfo['Client'],
  600. 'device' => (string) $moreInfo['DeviceName'],
  601. 'stream' => streamType($stream),
  602. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  603. ));
  604. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  605. $topTitle = '<h5 class="text-center zero-m elip">'.$itemDetails['AlbumArtist'].' - '.$itemDetails['Album'].'</h5>';
  606. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  607. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  608. }
  609. break;
  610. case 'TvChannel':
  611. $title = $itemDetails['CurrentProgram']['Name'];
  612. $imageId = $itemDetails['Id'];
  613. $width = 300;
  614. $style = '';
  615. $image = 'slick-image-tall';
  616. if(!$nowPlaying){
  617. $imageType = "Primary";
  618. $key = $itemDetails['Id'] . "-list";
  619. }else{
  620. $height = 281;
  621. $width = 500;
  622. $imageType = "Thumb";
  623. $key = $itemDetails['Id'] . "-np";
  624. $useImage = "images/livetv.png";
  625. $watched = "0";
  626. $stream = $moreInfo['PlayState']['PlayMethod'];
  627. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  628. $id = $moreInfo['DeviceId'];
  629. $streamInfo = buildStream(array(
  630. 'platform' => (string) $moreInfo['Client'],
  631. 'device' => (string) $moreInfo['DeviceName'],
  632. 'stream' => streamType($stream),
  633. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  634. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  635. ));
  636. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  637. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  638. $bottomTitle = '<small class="zero-m">'.$itemDetails['Name'].' - '.$itemDetails['ChannelNumber'].'</small>';
  639. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  640. }
  641. break;
  642. default:
  643. $title = $itemDetails['Name'];
  644. $imageId = $itemDetails['Id'];
  645. $width = 300;
  646. $style = '';
  647. $image = 'slick-image-tall';
  648. if(!$nowPlaying){
  649. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  650. $key = $itemDetails['Id'] . "-list";
  651. $itemType = 'movie';
  652. }else{
  653. $height = 281;
  654. $width = 500;
  655. $imageType = isset($itemDetails['ImageTags']['Thumb']) ? "Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
  656. $key = $itemDetails['Id'] . "-np";
  657. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  658. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  659. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  660. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  661. $stream = $moreInfo['PlayState']['PlayMethod'];
  662. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  663. $id = $moreInfo['DeviceId'];
  664. $streamInfo = buildStream(array(
  665. 'platform' => (string) $moreInfo['Client'],
  666. 'device' => (string) $moreInfo['DeviceName'],
  667. 'stream' => streamType($stream),
  668. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  669. 'audio' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  670. ));
  671. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  672. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  673. $bottomTitle = '<small class="zero-m">'.$moreInfo['NowPlayingItem']['ProductionYear'].'</small>';
  674. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  675. }
  676. }
  677. // If No Overview
  678. if (!isset($itemDetails['Overview'])) {
  679. $itemDetails['Overview'] = '';
  680. }
  681. $original_image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  682. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  683. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  684. $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'';
  685. }
  686. if($nowPlaying){
  687. if(!$imageType){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  688. if(!$imageId){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  689. }else{
  690. if(!$imageType){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  691. if(!$imageId){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  692. }
  693. if(isset($useImage)){ $image_url = $useImage; }
  694. // Assemble Item And Cache Into Array
  695. if($nowPlaying){
  696. //prettyPrint($itemDetails);
  697. 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>';
  698. }else{
  699. 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>';
  700. }
  701. }
  702. // Format item from Plex for Carousel
  703. function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $playlist = false) {
  704. // Static Height
  705. $height = 444;
  706. $widthOverride = 100;
  707. $playlist = ($playlist) ? " playlist-$playlist" : "";
  708. switch ($item['type']) {
  709. case 'season':
  710. $title = $item['parentTitle'];
  711. $summary = $item['parentSummary'];
  712. $width = 300;
  713. $image = 'slick-image-tall';
  714. $style = '';
  715. if(!$nowPlaying){
  716. $thumb = $item['thumb'];
  717. $key = $item['ratingKey'] . "-list";
  718. }else {
  719. $height = 281;
  720. $width = 500;
  721. $thumb = $item['art'];
  722. $key = $item['ratingKey'] . "-np";
  723. $elapsed = $item['viewOffset'];
  724. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  725. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  726. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  727. $stream = $item->Media->Part->Stream['decision'];
  728. $user = $role == "admin" ? $item->User['title'] : "";
  729. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  730. $streamInfo = buildStream(array(
  731. 'platform' => (string) $item->Player['platform'],
  732. 'device' => (string) $item->Player['device'],
  733. 'stream' => streamType($item->Media->Part['decision']),
  734. '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'].")",
  735. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  736. ));
  737. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  738. }
  739. break;
  740. case 'episode':
  741. $title = $item['grandparentTitle'];
  742. $summary = $item['title'];
  743. $width = 300;
  744. $image = 'slick-image-tall';
  745. $style = '';
  746. if(!$nowPlaying){
  747. $thumb = ($item['parentThumb'] ? $item['parentThumb'] : $item['grandparentThumb']);
  748. $key = $item['ratingKey'] . "-list";
  749. }else {
  750. $height = 281;
  751. $width = 500;
  752. $thumb = $item['art'];
  753. $key = $item['ratingKey'] . "-np";
  754. $elapsed = $item['viewOffset'];
  755. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  756. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  757. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  758. $stream = $item->Media->Part->Stream['decision'];
  759. $user = $role == "admin" ? $item->User['title'] : "";
  760. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  761. $streamInfo = buildStream(array(
  762. 'platform' => (string) $item->Player['platform'],
  763. 'device' => (string) $item->Player['device'],
  764. 'stream' => streamType($item->Media->Part['decision']),
  765. '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'].")",
  766. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  767. ));
  768. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  769. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$item['title'].'</h5>';
  770. $bottomTitle = '<small class="zero-m">S'.$item['parentIndex'].' · E'.$item['index'].'</small>';
  771. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  772. }
  773. break;
  774. case 'clip':
  775. $title = $item['title'];
  776. $summary = $item['summary'];
  777. $width = 300;
  778. $image = 'slick-image-tall';
  779. $style = '';
  780. if(!$nowPlaying){
  781. $thumb = $item['thumb'];
  782. $key = $item['ratingKey'] . "-list";
  783. }else {
  784. $height = 281;
  785. $width = 500;
  786. $thumb = $item['art'];
  787. $key = isset($item['ratingKey']) ? $item['ratingKey'] . "-np" : (isset($item['live']) ? "livetv.png" : ":)");
  788. $useImage = (isset($item['live']) ? "images/livetv.png" : null);
  789. $extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
  790. $elapsed = $item['viewOffset'];
  791. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  792. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  793. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  794. $stream = $item->Media->Part->Stream['decision'];
  795. $user = $role == "admin" ? $item->User['title'] : "";
  796. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  797. $streamInfo = buildStream(array(
  798. 'platform' => (string) $item->Player['platform'],
  799. 'device' => (string) $item->Player['device'],
  800. 'stream' => streamType($item->Media->Part['decision']),
  801. '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'].")",
  802. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  803. ));
  804. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  805. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  806. $bottomTitle = '<small class="zero-m">'.$extraInfo.'</small>';
  807. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  808. }
  809. break;
  810. case 'album':
  811. case 'track':
  812. $title = $item['parentTitle'];
  813. $summary = $item['title'];
  814. $image = 'slick-image-short';
  815. $style = 'left: 160px !important;';
  816. $item['ratingKey'] = $item['parentRatingKey'];
  817. if(!$nowPlaying){
  818. $width = 444;
  819. $thumb = $item['thumb'];
  820. $key = $item['ratingKey'] . "-list";
  821. }else {
  822. $height = 281;
  823. $width = 500;
  824. $thumb = ($item['art']) ? $item['art'] : $item['parentThumb'];
  825. $widthOverride = ($item['art']) ? 100 : 56;
  826. $key = $item['ratingKey'] . "-np";
  827. $elapsed = $item['viewOffset'];
  828. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  829. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  830. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  831. $stream = $item->Media->Part->Stream['decision'];
  832. $user = $role == "admin" ? $item->User['title'] : "";
  833. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  834. $streamInfo = buildStream(array(
  835. 'platform' => (string) $item->Player['platform'],
  836. 'device' => (string) $item->Player['device'],
  837. 'stream' => streamType($item->Media->Part['decision']),
  838. 'audio' => streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['channels']."ch)",
  839. ));
  840. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  841. $topTitle = '<h5 class="text-center zero-m elip">'.$item['grandparentTitle'].' - '.$item['title'].'</h5>';
  842. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  843. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  844. }
  845. break;
  846. default:
  847. $title = $item['title'];
  848. $summary = $item['summary'];
  849. $image = 'slick-image-tall';
  850. $style = '';
  851. if(!$nowPlaying){
  852. $width = 300;
  853. $thumb = $item['thumb'];
  854. $key = $item['ratingKey'] . "-list";
  855. }else {
  856. $height = 281;
  857. $width = 500;
  858. $thumb = $item['art'];
  859. $key = $item['ratingKey'] . "-np";
  860. $elapsed = $item['viewOffset'];
  861. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  862. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  863. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  864. $stream = $item->Media->Part->Stream['decision'];
  865. $user = $role == "admin" ? $item->User['title'] : "";
  866. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  867. $streamInfo = buildStream(array(
  868. 'platform' => (string) $item->Player['platform'],
  869. 'device' => (string) $item->Player['device'],
  870. 'stream' => streamType($item->Media->Part['decision']),
  871. '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'].")",
  872. 'audio' => streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  873. ));
  874. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  875. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  876. $bottomTitle = '<small class="zero-m">'.$item['year'].'</small>';
  877. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  878. }
  879. }
  880. if (PLEXTABURL) {
  881. $address = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  882. }else{
  883. $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  884. }
  885. // If No Overview
  886. if (!isset($itemDetails['Overview'])) { $itemDetails['Overview'] = ''; }
  887. $original_image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'$'.randString();
  888. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  889. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  890. $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'';
  891. }
  892. if($nowPlaying){
  893. if(!$thumb){ $original_image_url = $image_url = "images/no-np.png"; $key = "no-np"; }
  894. }else{
  895. if(!$thumb){ $original_image_url = $image_url = "images/no-list.png"; $key = "no-list"; }
  896. }
  897. if(isset($useImage)){ $image_url = $useImage; }
  898. $openTab = (PLEXTABNAME) ? "true" : "false";
  899. // Assemble Item And Cache Into Array
  900. if($nowPlaying){
  901. return '<div class="col-sm-6 col-md-3"><div class="thumbnail ultra-widget"><div style="display: none;" np="'.$id.'" class="overlay content-box small-box gray-bg">'.$streamInfo.'</div><span class="refreshNP w-refresh w-p-icon gray" link="'.$id.'"><span class="fa-stack fa-lg" style="font-size: .5em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-info-circle fa-stack-1x fa-inverse"></i></span></span><div class="ultra-widget refreshImage"><span class="w-refresh w-p-icon gray"><span class="fa-stack fa-lg" style="font-size: .4em"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-refresh fa-stack-1x fa-inverse"></i></span></span></div><a class="openTab" extraTitle="'.$title.'" extraType="'.$item['type'].'" openTab="'.$openTab.'" href="'.$address.'" target="_blank"><img class="refreshImageSource" style="width: '.$widthOverride.'%; display:block;" src="'.$image_url.'" original-image="'.$original_image_url.'" alt="'.$item['Name'].'"></a><div class="progress progress-bar-sm zero-m"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$watched.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$watched.'%"></div><div class="progress-bar palette-Grey-500 bg" style="width: '.$transcoded.'%"></div></div><div class="caption"><i style="float:left" class="fa fa-'.$state.'"></i>'.$topTitle.''.$bottomTitle.'</div></div></div>';
  902. }else{
  903. 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>';
  904. }
  905. }
  906. //$hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  907. //Recent Added
  908. function outputRecentAdded($header, $items, $script = false, $array, $type) {
  909. $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">';
  910. if(preg_grep("/item-movie/", $items)){
  911. $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>';
  912. }
  913. if(preg_grep("/item-season/", $items)){
  914. $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>';
  915. }
  916. if(preg_grep("/item-album/", $items)){
  917. $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>';
  918. }
  919. $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>';
  920. $hideMenu .= '</ul></div></div>';
  921. // If None Populate Empty Item
  922. if (!count($items)) {
  923. 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>';
  924. }else{
  925. $className = str_replace(' ', '', $header.' on '.$type);
  926. return '<div id="recentMedia'.$type.'" class="content-box box-shadow big-box"><h5 id="recentContent-title-'.$type.'" style="margin-bottom: -20px" class="text-center">'.$header.'</h5><div class="recentHeader inbox-pagination '.$className.'">'.$hideMenu.'</div><br/><br/><div class="recentItems-recent-'.$type.'" data-name="'.$className.'">'.implode('',$items).'</div></div>'.($script?'<script>'.$script.'</script>':'');
  927. }
  928. }
  929. // Create Carousel
  930. function outputNowPlaying($header, $size, $type, $items, $script = false) {
  931. // If None Populate Empty Item
  932. if (!count($items)) {
  933. return '<div id='.$type.'></div>'.($script?'<script>'.$script.'</script>':'');
  934. }else{
  935. return '<div id='.$type.'><h5 class="zero-m big-box"><strong>'.$header.'</strong></h5>'.implode('',$items).'</div>'.($script?'<script>'.$script.'</script>':'');
  936. }
  937. }
  938. // Get Now Playing Streams From Emby
  939. function getEmbyStreams($size, $showNames, $role) {
  940. $address = qualifyURL(EMBYURL);
  941. $api = json_decode(@file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
  942. if (!is_array($api)) { return 'Could not load!'; }
  943. $playingItems = array();
  944. foreach($api as $key => $value) {
  945. if (isset($value['NowPlayingItem'])) {
  946. $playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem'], true, $showNames, $role, $value);
  947. }
  948. }
  949. return outputNowPlaying(translate('PLAYING_NOW_ON_EMBY')." ( ".count($playingItems)." Streams )", $size, 'streams-emby', $playingItems, "
  950. setInterval(function() {
  951. $('<div></div>').load('ajax.php?a=emby-streams',function() {
  952. var element = $(this).find('[id]');
  953. var loadedID = element.attr('id');
  954. $('#'+loadedID).replaceWith(element);
  955. console.log('Loaded updated: '+loadedID);
  956. });
  957. }, ".NOWPLAYINGREFRESH.");
  958. ");
  959. }
  960. // Get Now Playing Streams From Plex
  961. function getPlexStreams($size, $showNames, $role){
  962. $address = qualifyURL(PLEXURL);
  963. // Perform API requests
  964. $api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
  965. libxml_use_internal_errors(true);
  966. $api = simplexml_load_string($api);
  967. if (is_array($api) || is_object($api)){
  968. if (!$api->head->title){
  969. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  970. if (!$getServer) { return 'Could not load!'; }
  971. // Identify the local machine
  972. $gotServer = $getServer['machineIdentifier'];
  973. $items = array();
  974. foreach($api AS $child) {
  975. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
  976. }
  977. return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." ( ".count($items)." Streams )", $size, 'streams-plex', $items, "
  978. setInterval(function() {
  979. $('<div></div>').load('ajax.php?a=plex-streams',function() {
  980. var element = $(this).find('[id]');
  981. var loadedID = element.attr('id');
  982. $('#'+loadedID).replaceWith(element);
  983. console.log('Loaded updated: '+loadedID);
  984. });
  985. }, ".NOWPLAYINGREFRESH.");
  986. ");
  987. }else{
  988. writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
  989. }
  990. }else{
  991. writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
  992. }
  993. }
  994. // Get Recent Content From Emby
  995. function getEmbyRecent($array) {
  996. $address = qualifyURL(EMBYURL);
  997. $header = translate('RECENT_CONTENT');
  998. // Currently Logged In User
  999. $username = false;
  1000. if (isset($GLOBALS['USER'])) {
  1001. $username = strtolower($GLOBALS['USER']->username);
  1002. }
  1003. // Get A User
  1004. $userIds = json_decode(@file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
  1005. if (!is_array($userIds)) { return 'Could not load!'; }
  1006. $showPlayed = true;
  1007. foreach ($userIds as $value) { // Scan for admin user
  1008. if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
  1009. $userId = $value['Id'];
  1010. }
  1011. if ($username && strtolower($value['Name']) == $username) {
  1012. $userId = $value['Id'];
  1013. $showPlayed = false;
  1014. break;
  1015. }
  1016. }
  1017. // Get the latest Items
  1018. $latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?EnableImages=false&Limit='.EMBYRECENTITEMS.'&api_key='.EMBYTOKEN.($showPlayed?'':'&IsPlayed=false')),true);
  1019. // For Each Item In Category
  1020. $items = array();
  1021. foreach ($latest as $k => $v) {
  1022. $type = (string) $v['Type'];
  1023. if(@$array[$type] == "true"){
  1024. $items[] = resolveEmbyItem($address, EMBYTOKEN, $v, false, false, false);
  1025. }
  1026. }
  1027. $array["movie"] = $array["Movie"];
  1028. $array["season"] = $array["Episode"];
  1029. $array["album"] = $array["MusicAlbum"];
  1030. unset($array["Movie"]);
  1031. unset($array["Episode"]);
  1032. unset($array["MusicAlbum"]);
  1033. unset($array["Series"]);
  1034. return outputRecentAdded($header, $items, "
  1035. setInterval(function() {
  1036. $('<div></div>').load('ajax.php?a=emby-recent',function() {
  1037. var element = $(this).find('#recentMediaEmby');
  1038. var loadedID = element.attr('id');
  1039. $('#recentMediaEmby').replaceWith(element);
  1040. console.log('Loaded recent: '+loadedID);
  1041. loadSlick();
  1042. });
  1043. }, ".RECENTREFRESH.");
  1044. ", $array, 'Emby');
  1045. }
  1046. // Get Recent Content From Plex
  1047. function getPlexRecent($array){
  1048. $address = qualifyURL(PLEXURL);
  1049. $header = translate('RECENT_CONTENT');
  1050. // Perform Requests
  1051. $api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN);
  1052. libxml_use_internal_errors(true);
  1053. $api = simplexml_load_string($api);
  1054. if (is_array($api) || is_object($api)){
  1055. if (!$api->head->title){
  1056. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  1057. if (!$getServer) { return 'Could not load!'; }
  1058. // Identify the local machine
  1059. $gotServer = $getServer['machineIdentifier'];
  1060. $items = array();
  1061. foreach($api AS $child) {
  1062. $type = (string) $child['type'];
  1063. if($array[$type] == "true"){
  1064. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
  1065. }
  1066. }
  1067. return outputRecentAdded($header, $items, "
  1068. setInterval(function() {
  1069. $('<div></div>').load('ajax.php?a=plex-recent',function() {
  1070. var element = $(this).find('#recentMediaPlex');
  1071. var loadedID = element.attr('id');
  1072. $('#recentMediaPlex').replaceWith(element);
  1073. console.log('Loaded recent: '+loadedID);
  1074. loadSlick();
  1075. });
  1076. }, ".RECENTREFRESH.");
  1077. ", $array, 'Plex');
  1078. }else{
  1079. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check token - if HTTPS, is cert valid");
  1080. }
  1081. }else{
  1082. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check URL - if HTTPS, is cert valid");
  1083. }
  1084. }
  1085. // Get Image From Emby
  1086. function getEmbyImage() {
  1087. $refresh = false;
  1088. $embyAddress = qualifyURL(EMBYURL);
  1089. if (!file_exists('images/cache')) {
  1090. mkdir('images/cache', 0777, true);
  1091. }
  1092. $itemId = $_GET['img'];
  1093. $key = $_GET['key'];
  1094. if(strpos($key, '$') !== false){
  1095. $key = explode('$', $key)[0];
  1096. $refresh = true;
  1097. }
  1098. $itemType = $_GET['type'];
  1099. $imgParams = array();
  1100. if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
  1101. if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
  1102. if(isset($itemId)) {
  1103. $image_src = $embyAddress . '/Items/'.$itemId.'/Images/'.$itemType.'?'.implode('&', $imgParams);
  1104. $cachefile = 'images/cache/'.$key.'.jpg';
  1105. $cachetime = 604800;
  1106. // Serve from the cache if it is younger than $cachetime
  1107. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh !== true) {
  1108. header("Content-type: image/jpeg");
  1109. @readfile($cachefile);
  1110. exit;
  1111. }
  1112. ob_start(); // Start the output buffer
  1113. header('Content-type: image/jpeg');
  1114. //@readfile($image_src);
  1115. echo @curl_get($image_src);
  1116. // Cache the output to a file
  1117. $fp = fopen($cachefile, 'wb');
  1118. fwrite($fp, ob_get_contents());
  1119. fclose($fp);
  1120. ob_end_flush(); // Send the output to the browser
  1121. die();
  1122. } else {
  1123. debug_out('Invalid Request',1);
  1124. }
  1125. }
  1126. // Get Image From Plex
  1127. function getPlexImage() {
  1128. $refresh = false;
  1129. $plexAddress = qualifyURL(PLEXURL);
  1130. if (!file_exists('images/cache')) {
  1131. mkdir('images/cache', 0777, true);
  1132. }
  1133. $image_url = $_GET['img'];
  1134. $key = $_GET['key'];
  1135. if(strpos($key, '$') !== false){
  1136. $key = explode('$', $key)[0];
  1137. $refresh = true;
  1138. }
  1139. $image_height = $_GET['height'];
  1140. $image_width = $_GET['width'];
  1141. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  1142. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  1143. $cachefile = 'images/cache/'.$key.'.jpg';
  1144. $cachetime = 604800;
  1145. // Serve from the cache if it is younger than $cachetime
  1146. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile) && $refresh == false) {
  1147. header("Content-type: image/jpeg");
  1148. @readfile($cachefile);
  1149. exit;
  1150. }
  1151. ob_start(); // Start the output buffer
  1152. header('Content-type: image/jpeg');
  1153. //@readfile($image_src);
  1154. echo @curl_get($image_src);
  1155. // Cache the output to a file
  1156. $fp = fopen($cachefile, 'wb');
  1157. fwrite($fp, ob_get_contents());
  1158. fclose($fp);
  1159. ob_end_flush(); // Send the output to the browser
  1160. die();
  1161. } else {
  1162. echo "Invalid Plex Request";
  1163. }
  1164. }
  1165. // Simplier access to class
  1166. function translate($string) {
  1167. if (isset($GLOBALS['language'])) {
  1168. return $GLOBALS['language']->translate($string);
  1169. } else {
  1170. return '!Translations Not Loaded!';
  1171. }
  1172. }
  1173. // Generate Random string
  1174. function randString($length = 10, $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  1175. $tmp = '';
  1176. for ($i = 0; $i < $length; $i++) {
  1177. $tmp .= substr(str_shuffle($chars), 0, 1);
  1178. }
  1179. return $tmp;
  1180. }
  1181. // Create config file in the return syntax
  1182. function createConfig($array, $path = 'config/config.php', $nest = 0) {
  1183. // Define Initial Value
  1184. $output = array();
  1185. // Sort Items
  1186. ksort($array);
  1187. // Update the current config version
  1188. if (!$nest) {
  1189. // Inject Current Version
  1190. $output[] = "\t'CONFIG_VERSION' => '".(isset($array['apply_CONFIG_VERSION'])?$array['apply_CONFIG_VERSION']:INSTALLEDVERSION)."'";
  1191. }
  1192. unset($array['CONFIG_VERSION']);
  1193. unset($array['apply_CONFIG_VERSION']);
  1194. // Process Settings
  1195. foreach ($array as $k => $v) {
  1196. $allowCommit = true;
  1197. switch (gettype($v)) {
  1198. case 'boolean':
  1199. $item = ($v?'true':'false');
  1200. break;
  1201. case 'integer':
  1202. case 'double':
  1203. case 'integer':
  1204. case 'NULL':
  1205. $item = $v;
  1206. break;
  1207. case 'string':
  1208. $item = "'".str_replace(array('\\',"'"),array('\\\\',"\'"),$v)."'";
  1209. break;
  1210. case 'array':
  1211. $item = createConfig($v, false, $nest+1);
  1212. break;
  1213. default:
  1214. $allowCommit = false;
  1215. }
  1216. if($allowCommit) {
  1217. $output[] = str_repeat("\t",$nest+1)."'$k' => $item";
  1218. }
  1219. }
  1220. // Build output
  1221. $output = (!$nest?"<?php\nreturn ":'')."array(\n".implode(",\n",$output)."\n".str_repeat("\t",$nest).')'.(!$nest?';':'');
  1222. if (!$nest && $path) {
  1223. $pathDigest = pathinfo($path);
  1224. @mkdir($pathDigest['dirname'], 0770, true);
  1225. if (file_exists($path)) {
  1226. rename($path, $pathDigest['dirname'].'/'.$pathDigest['filename'].'.bak.php');
  1227. }
  1228. $file = fopen($path, 'w');
  1229. fwrite($file, $output);
  1230. fclose($file);
  1231. if (file_exists($path)) {
  1232. return true;
  1233. }
  1234. writeLog("error", "config was unable to write");
  1235. return false;
  1236. } else {
  1237. writeLog("success", "config was updated with new values");
  1238. return $output;
  1239. }
  1240. }
  1241. // Load a config file written in the return syntax
  1242. function loadConfig($path = 'config/config.php') {
  1243. // Adapted from http://stackoverflow.com/a/14173339/6810513
  1244. if (!is_file($path)) {
  1245. return null;
  1246. } else {
  1247. return (array) call_user_func(function() use($path) {
  1248. return include($path);
  1249. });
  1250. }
  1251. }
  1252. // Commit new values to the configuration
  1253. function updateConfig($new, $current = false) {
  1254. // Get config if not supplied
  1255. if ($current === false) {
  1256. $current = loadConfig();
  1257. } else if (is_string($current) && is_file($current)) {
  1258. $current = loadConfig($current);
  1259. }
  1260. // Inject Parts
  1261. foreach ($new as $k => $v) {
  1262. $current[$k] = $v;
  1263. }
  1264. // Return Create
  1265. return createConfig($current);
  1266. }
  1267. // Inject Defaults As Needed
  1268. function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
  1269. if (is_string($path)) {
  1270. $loadedDefaults = loadConfig($path);
  1271. } else {
  1272. $loadedDefaults = $path;
  1273. }
  1274. return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
  1275. }
  1276. // support function for fillDefaultConfig()
  1277. function fillDefaultConfig_recurse($current, $defaults) {
  1278. foreach($defaults as $k => $v) {
  1279. if (!isset($current[$k])) {
  1280. $current[$k] = $v;
  1281. } else if (is_array($current[$k]) && is_array($v)) {
  1282. $current[$k] = fillDefaultConfig_recurse($current[$k], $v);
  1283. }
  1284. }
  1285. return $current;
  1286. };
  1287. // Define Scalar Variables (nest non-secular with underscores)
  1288. function defineConfig($array, $anyCase = true, $nest_prefix = false) {
  1289. foreach($array as $k => $v) {
  1290. if (is_scalar($v) && !defined($nest_prefix.$k)) {
  1291. define($nest_prefix.$k, $v, $anyCase);
  1292. } else if (is_array($v)) {
  1293. defineConfig($v, $anyCase, $nest_prefix.$k.'_');
  1294. }
  1295. }
  1296. }
  1297. // This function exists only because I am lazy
  1298. function configLazy($path = 'config/config.php') {
  1299. // Load config or default
  1300. if (file_exists($path)) {
  1301. $config = fillDefaultConfig(loadConfig($path));
  1302. } else {
  1303. $config = loadConfig('config/configDefaults.php');
  1304. }
  1305. if (is_array($config)) {
  1306. defineConfig($config);
  1307. }
  1308. return $config;
  1309. }
  1310. // Qualify URL
  1311. function qualifyURL($url) {
  1312. //local address?
  1313. if(substr($url, 0,1) == "/"){
  1314. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  1315. $protocol = "https://";
  1316. } else {
  1317. $protocol = "http://";
  1318. }
  1319. $url = $protocol.getServer().$url;
  1320. }
  1321. // Get Digest
  1322. $digest = parse_url($url);
  1323. // http/https
  1324. if (!isset($digest['scheme'])) {
  1325. if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096,32400,7878,8989,8182,8081,6789))) {
  1326. $scheme = 'http';
  1327. } else {
  1328. $scheme = 'https';
  1329. }
  1330. } else {
  1331. $scheme = $digest['scheme'];
  1332. }
  1333. // Host
  1334. $host = (isset($digest['host'])?$digest['host']:'');
  1335. // Port
  1336. $port = (isset($digest['port'])?':'.$digest['port']:'');
  1337. // Path
  1338. $path = (isset($digest['path'])?$digest['path']:'');
  1339. // Output
  1340. return $scheme.'://'.$host.$port.$path;
  1341. }
  1342. // Function to be called at top of each to allow upgrading environment as the spec changes
  1343. function upgradeCheck() {
  1344. // Upgrade to 1.31
  1345. if (file_exists('homepageSettings.ini.php')) {
  1346. $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
  1347. $homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
  1348. $databaseConfig = array_merge($databaseConfig, $homepageConfig);
  1349. $databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
  1350. foreach($databaseConfig as $k => $v) {
  1351. if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
  1352. $databaseData .= $k . " = \"" . $v . "\"\r\n";
  1353. }
  1354. write_ini_file($databaseData, 'databaseLocation.ini.php');
  1355. unlink('homepageSettings.ini.php');
  1356. unset($databaseData);
  1357. unset($homepageConfig);
  1358. }
  1359. // Upgrade to 1.32
  1360. if (file_exists('databaseLocation.ini.php')) {
  1361. // Load Existing
  1362. $config = parse_ini_file('databaseLocation.ini.php', true);
  1363. // Refactor
  1364. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['databaseLocation'].'/');
  1365. $config['user_home'] = $config['database_Location'].'users/';
  1366. unset($config['databaseLocation']);
  1367. // Turn Off Emby And Plex Recent
  1368. $config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
  1369. unset($config["embyPort"]);
  1370. $config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
  1371. unset($config["plexPort"]);
  1372. $config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
  1373. unset($config["nzbgetPort"]);
  1374. $config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
  1375. unset($config["sabnzbdPort"]);
  1376. $config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
  1377. unset($config["headphonesPort"]);
  1378. // Write config file
  1379. $config['CONFIG_VERSION'] = '1.32';
  1380. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][pre1.32].bak.php');
  1381. $createConfigSuccess = createConfig($config);
  1382. // Create new config
  1383. if ($createConfigSuccess) {
  1384. if (file_exists('config/config.php')) {
  1385. // Remove Old ini file
  1386. unlink('databaseLocation.ini.php');
  1387. } else {
  1388. debug_out('Something is not right here!');
  1389. }
  1390. } else {
  1391. debug_out('Couldn\'t create updated configuration.' ,1);
  1392. }
  1393. }
  1394. // Upgrade to 1.33
  1395. $config = loadConfig();
  1396. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
  1397. // Fix User Directory
  1398. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['database_Location'].'/');
  1399. $config['user_home'] = $config['database_Location'].'users/';
  1400. unset($config['USER_HOME']);
  1401. // Backend auth merge
  1402. if (isset($config['authBackendPort']) && !isset(parse_url($config['authBackendHost'])['port'])) {
  1403. $config['authBackendHost'] .= ':'.$config['authBackendPort'];
  1404. }
  1405. unset($config['authBackendPort']);
  1406. // If auth is being used move it to embyURL as that is now used in auth functions
  1407. 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')))) {
  1408. $config['embyURL'] = $config['authBackendHost'];
  1409. }
  1410. // Upgrade database to latest version
  1411. updateSQLiteDB($config['database_Location'],'1.32');
  1412. // Update Version and Commit
  1413. $config['apply_CONFIG_VERSION'] = '1.33';
  1414. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.32].bak.php');
  1415. $createConfigSuccess = createConfig($config);
  1416. unset($config);
  1417. }
  1418. // Upgrade to 1.34
  1419. $config = loadConfig();
  1420. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.34')) {
  1421. // Upgrade database to latest version
  1422. updateSQLiteDB($config['database_Location'],'1.33');
  1423. // Update Version and Commit
  1424. $config['CONFIG_VERSION'] = '1.34';
  1425. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.33].bak.php');
  1426. $createConfigSuccess = createConfig($config);
  1427. unset($config);
  1428. }
  1429. // Upgrade to 1.40
  1430. $config = loadConfig();
  1431. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.40')) {
  1432. // Upgrade database to latest version
  1433. updateSQLiteDB($config['database_Location'],'1.38');
  1434. // Update Version and Commit
  1435. $config['CONFIG_VERSION'] = '1.40';
  1436. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.38].bak.php');
  1437. $createConfigSuccess = createConfig($config);
  1438. unset($config);
  1439. }
  1440. // Upgrade to 1.50
  1441. $config = loadConfig();
  1442. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.50')) {
  1443. // Upgrade database to latest version
  1444. updateSQLiteDB($config['database_Location'],'1.40');
  1445. // Update Version and Commit
  1446. $config['CONFIG_VERSION'] = '1.50';
  1447. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.40].bak.php');
  1448. $createConfigSuccess = createConfig($config);
  1449. unset($config);
  1450. }
  1451. return true;
  1452. }
  1453. // Get OS from server
  1454. function getOS(){
  1455. if(PHP_SHLIB_SUFFIX == "dll"){
  1456. return "win";
  1457. }else{
  1458. return "nix";
  1459. }
  1460. }
  1461. //Get Error by Server OS
  1462. function getError($os, $error){
  1463. $ini = (!empty(php_ini_loaded_file()) ? php_ini_loaded_file() : "php.ini");
  1464. $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'");
  1465. $errors = array(
  1466. 'pdo_sqlite' => array(
  1467. 'win' => '<b>PDO:SQLite</b> not enabled, uncomment ;extension=php_pdo_sqlite.dll in the file php.ini | '.$ext,
  1468. 'nix' => '<b>PDO:SQLite</b> not enabled, PHP7 -> run sudo apt-get install php7.0-sqlite | PHP5 -> run sudo apt-get install php5-sqlite',
  1469. ),
  1470. 'sqlite3' => array(
  1471. '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',
  1472. 'nix' => '<b>SQLite3</b> not enabled, run sudo apt-get install php-sqlite3',
  1473. ),
  1474. 'curl' => array(
  1475. 'win' => '<b>cURL</b> not enabled, uncomment ;extension=php_curl.dll in the file php.ini | '.$ext,
  1476. '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',
  1477. ),
  1478. 'zip' => array(
  1479. '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',
  1480. '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',
  1481. ),
  1482. );
  1483. return (isset($errors[$error][$os]) ? $errors[$error][$os] : 'No Error Info Found');
  1484. }
  1485. // Check if all software dependancies are met
  1486. function dependCheck() {
  1487. $output = array();
  1488. $i = 1;
  1489. if (!extension_loaded('pdo_sqlite')) { $output["Step $i"] = getError(getOS(),'pdo_sqlite'); $i++; }
  1490. if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; }
  1491. if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; }
  1492. //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
  1493. if ($output) {
  1494. $output["Step $i"] = "<b>Restart PHP and/or Webserver to apply changes</b>"; $i++;
  1495. $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++;
  1496. debug_out($output,1);
  1497. }
  1498. return true;
  1499. }
  1500. // Process file uploads
  1501. function uploadFiles($path, $ext_mask = null) {
  1502. if (isset($_FILES) && count($_FILES)) {
  1503. require_once('class.uploader.php');
  1504. $uploader = new Uploader();
  1505. $data = $uploader->upload($_FILES['files'], array(
  1506. 'limit' => 10,
  1507. 'maxSize' => 10,
  1508. 'extensions' => $ext_mask,
  1509. 'required' => false,
  1510. 'uploadDir' => str_replace('//','/',$path.'/'),
  1511. 'title' => array('name'),
  1512. 'removeFiles' => true,
  1513. 'replace' => true,
  1514. ));
  1515. if($data['isComplete']){
  1516. $files = $data['data'];
  1517. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1518. echo json_encode($files['metas'][0]['name']);
  1519. }
  1520. if($data['hasErrors']){
  1521. $errors = $data['errors'];
  1522. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1523. echo json_encode($errors);
  1524. }
  1525. } else {
  1526. writeLog("error", "image was not uploaded");
  1527. echo json_encode('No files submitted!');
  1528. }
  1529. }
  1530. // Process file uploads
  1531. function uploadAvatar($path, $ext_mask = null) {
  1532. if (isset($_FILES) && count($_FILES)) {
  1533. require_once('class.uploader.php');
  1534. $uploader = new Uploader();
  1535. $data = $uploader->upload($_FILES['files'], array(
  1536. 'limit' => 10,
  1537. 'maxSize' => 10,
  1538. 'extensions' => $ext_mask,
  1539. 'required' => false,
  1540. 'uploadDir' => str_replace('//','/',$path.'/'),
  1541. 'title' => array('name'),
  1542. 'removeFiles' => true,
  1543. 'replace' => true,
  1544. ));
  1545. if($data['isComplete']){
  1546. $files = $data['data'];
  1547. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1548. echo json_encode($files['metas'][0]['name']);
  1549. }
  1550. if($data['hasErrors']){
  1551. $errors = $data['errors'];
  1552. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1553. echo json_encode($errors);
  1554. }
  1555. } else {
  1556. writeLog("error", "image was not uploaded");
  1557. echo json_encode('No files submitted!');
  1558. }
  1559. }
  1560. // Remove file
  1561. function removeFiles($path) {
  1562. if(is_file($path)) {
  1563. writeLog("success", "file was removed");
  1564. unlink($path);
  1565. } else {
  1566. writeLog("error", "file was not removed");
  1567. echo json_encode('No file specified for removal!');
  1568. }
  1569. }
  1570. // Lazy select options
  1571. function resolveSelectOptions($array, $selected = '', $multi = false) {
  1572. $output = array();
  1573. $selectedArr = ($multi?explode('|', $selected):array());
  1574. foreach ($array as $key => $value) {
  1575. if (is_array($value)) {
  1576. if (isset($value['optgroup'])) {
  1577. $output[] = '<optgroup label="'.$key.'">';
  1578. foreach($value['optgroup'] as $k => $v) {
  1579. $output[] = '<option value="'.$v['value'].'"'.($selected===$v['value']||in_array($v['value'],$selectedArr)?' selected':'').(isset($v['disabled']) && $v['disabled']?' disabled':'').'>'.$k.'</option>';
  1580. }
  1581. } else {
  1582. $output[] = '<option value="'.$value['value'].'"'.($selected===$value['value']||in_array($value['value'],$selectedArr)?' selected':'').(isset($value['disabled']) && $value['disabled']?' disabled':'').'>'.$key.'</option>';
  1583. }
  1584. } else {
  1585. $output[] = '<option value="'.$value.'"'.($selected===$value||in_array($value,$selectedArr)?' selected':'').'>'.$key.'</option>';
  1586. }
  1587. }
  1588. return implode('',$output);
  1589. }
  1590. // Check if user is allowed to continue
  1591. function qualifyUser($type, $errOnFail = false) {
  1592. if (!isset($GLOBALS['USER'])) {
  1593. require_once("user.php");
  1594. $GLOBALS['USER'] = new User('registration_callback');
  1595. }
  1596. if (is_bool($type)) {
  1597. if ($type === true) {
  1598. $authorized = ($GLOBALS['USER']->authenticated == true);
  1599. } else {
  1600. $authorized = true;
  1601. }
  1602. } elseif (is_string($type) || is_array($type)) {
  1603. if ($type !== 'false') {
  1604. if (!is_array($type)) {
  1605. $type = explode('|',$type);
  1606. }
  1607. $authorized = ($GLOBALS['USER']->authenticated && in_array($GLOBALS['USER']->role,$type));
  1608. } else {
  1609. $authorized = true;
  1610. }
  1611. } else {
  1612. debug_out('Invalid Syntax!',1);
  1613. }
  1614. if (!$authorized && $errOnFail) {
  1615. if ($GLOBALS['USER']->authenticated) {
  1616. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401');
  1617. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401\'</script>';
  1618. } else {
  1619. header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999');
  1620. echo '<script>window.location.href = \''.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=999\'</script>';
  1621. }
  1622. debug_out('Not Authorized' ,1);
  1623. } else {
  1624. return $authorized;
  1625. }
  1626. }
  1627. // Build an (optionally) tabbed settings page.
  1628. function buildSettings($array) {
  1629. /*
  1630. array(
  1631. 'title' => '',
  1632. 'id' => '',
  1633. 'fields' => array( See buildField() ),
  1634. 'tabs' => array(
  1635. array(
  1636. 'title' => '',
  1637. 'id' => '',
  1638. 'image' => '',
  1639. 'fields' => array( See buildField() ),
  1640. ),
  1641. ),
  1642. );
  1643. */
  1644. $notifyExplode = explode("-", NOTIFYEFFECT);
  1645. $fieldFunc = function($fieldArr) {
  1646. $fields = '<div class="row">';
  1647. foreach($fieldArr as $key => $value) {
  1648. $isSingle = isset($value['type']);
  1649. if ($isSingle) { $value = array($value); }
  1650. $tmpField = '';
  1651. $sizeLg = max(floor(12/count($value)),2);
  1652. $sizeMd = max(floor(($isSingle?12:6)/count($value)),3);
  1653. foreach($value as $k => $v) {
  1654. $tmpField .= buildField($v, 12, $sizeMd, $sizeLg);
  1655. }
  1656. $fields .= ($isSingle?$tmpField:'<div class="row col-sm-12 content-form">'.$tmpField.'</div>');
  1657. }
  1658. $fields .= '</div>';
  1659. return $fields;
  1660. };
  1661. $fields = (isset($array['fields'])?$fieldFunc($array['fields']):'');
  1662. $tabSelectors = array();
  1663. $tabContent = array();
  1664. if (isset($array['tabs'])) {
  1665. foreach($array['tabs'] as $key => $value) {
  1666. $id = (isset($value['id'])?$value['id']:randString(32));
  1667. $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>';
  1668. $tabContent[$key] = '<div class="tab-pane big-box fade'.($tabContent?'':' active in').'" id="tab-'.$id.'">'.$fieldFunc($value['fields']).'</div>';
  1669. }
  1670. }
  1671. $pageID = (isset($array['id'])?$array['id']:str_replace(array(' ','"',"'"),array('_'),strtolower($array['id'])));
  1672. $extraClick = ($pageID == 'appearance_settings' ? "$('#advanced_settings_form_submit').click();console.log('add theme settings');" : "");
  1673. return '
  1674. <div class="email-body">
  1675. <div class="email-header gray-bg">
  1676. <button type="button" class="btn btn-danger btn-sm waves close-button"><i class="fa fa-close"></i></button>
  1677. <button id="'.$pageID.'_form_submit" class="btn waves btn-labeled btn-success btn btn-sm text-uppercase waves-effect waves-float save-btn-form">
  1678. <span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save
  1679. </button>
  1680. <h1>'.$array['title'].'</h1>
  1681. </div>
  1682. <div class="email-inner small-box">
  1683. <div class="email-inner-section">
  1684. <div class="small-box fade in" id="'.$pageID.'_frame">
  1685. <div class="col-lg-12">
  1686. '.(isset($array['customBeforeForm'])?$array['customBeforeForm']:'').'
  1687. <form class="content-form" name="'.$pageID.'" id="'.$pageID.'_form" onsubmit="return false;">
  1688. '.$fields.($tabContent?'
  1689. <div class="tabbable tabs-with-bg" id="'.$pageID.'_tabs">
  1690. <ul class="nav nav-tabs apps">
  1691. '.implode('', $tabSelectors).'
  1692. </ul>
  1693. <div class="clearfix"></div>
  1694. <div class="tab-content">
  1695. '.implode('', $tabContent).'
  1696. </div>
  1697. </div>':'').'
  1698. </form>
  1699. '.(isset($array['customAfterForm'])?$array['customAfterForm']:'').'
  1700. </div>
  1701. </div>
  1702. </div>
  1703. </div>
  1704. </div>
  1705. <script>
  1706. $(document).ready(function() {
  1707. $(\'#'.$pageID.'_form\').find(\'input, select, textarea\').on(\'change\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1708. var '.$pageID.'Validate = function() { if (this.value && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { $(this).addClass(\'invalid\'); } else { $(this).removeClass(\'invalid\'); } };
  1709. $(\'#'.$pageID.'_form\').find(\'input[pattern]\').each('.$pageID.'Validate).on(\'keyup\', '.$pageID.'Validate);
  1710. $(\'#'.$pageID.'_form\').find(\'select[multiple]\').on(\'change click\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1711. $(\'#'.$pageID.'_form_submit\').on(\'click\', function () {
  1712. var newVals = {};
  1713. var hasVals = false;
  1714. var errorFields = [];
  1715. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').each(function() {
  1716. hasVals = true;
  1717. if (this.type == \'checkbox\') {
  1718. newVals[this.name] = this.checked;
  1719. } else if ($(this).hasClass(\'summernote\')) {
  1720. newVals[$(this).attr(\'name\')] = $(this).siblings(\'.note-editor\').find(\'.panel-body\').html();
  1721. } else {
  1722. if (this.value && this.pattern && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { errorFields.push(this.name); }
  1723. var fieldVal = $(this).val();
  1724. if (typeof fieldVal == \'object\') {
  1725. if (typeof fieldVal.join == \'function\') {
  1726. fieldVal = fieldVal.join(\'|\');
  1727. } else {
  1728. fieldVal = JSON.stringify(fieldVal);
  1729. }
  1730. }
  1731. newVals[this.name] = fieldVal;
  1732. }
  1733. });
  1734. if (errorFields.length) {
  1735. parent.notify(\'Fields have errors: \'+errorFields.join(\', \')+\'!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1736. } else if (hasVals) {
  1737. console.log(newVals);
  1738. ajax_request(\'POST\', \''.(isset($array['submitAction'])?$array['submitAction']:'update-config').'\', newVals, function(data, code) {
  1739. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').removeAttr(\'data-changed\');
  1740. });
  1741. '.$extraClick.'
  1742. } else {
  1743. parent.notify(\'Nothing to update!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1744. }
  1745. return false;
  1746. });
  1747. '.(isset($array['onready'])?$array['onready']:'').'
  1748. });
  1749. </script>
  1750. ';
  1751. }
  1752. // Build Settings Fields
  1753. function buildField($params, $sizeSm = 12, $sizeMd = 12, $sizeLg = 12) {
  1754. /*
  1755. array(
  1756. 'type' => '',
  1757. 'placeholder' => '',
  1758. 'label' => '',
  1759. 'labelTranslate' => '',
  1760. 'assist' => '',
  1761. 'name' => '',
  1762. 'pattern' => '',
  1763. 'options' => array( // For SELECT only
  1764. 'Display' => 'value',
  1765. ),
  1766. )
  1767. */
  1768. // Tags
  1769. $tags = array();
  1770. foreach(array('placeholder','style','disabled','readonly','pattern','min','max','required','onkeypress','onchange','onfocus','onleave','href','onclick') as $value) {
  1771. if (isset($params[$value])) {
  1772. if (is_string($params[$value])) { $tags[] = $value.'="'.$params[$value].'"';
  1773. } else if ($params[$value] === true) { $tags[] = $value; }
  1774. }
  1775. }
  1776. $format = (isset($params['format']) && in_array($params['format'],array(false,'colour','color'))?$params['format']:false);
  1777. $name = (isset($params['name'])?$params['name']:(isset($params['id'])?$params['id']:''));
  1778. $id = (isset($params['id'])?$params['id']:(isset($params['name'])?$params['name'].'_id':randString(32)));
  1779. $val = (isset($params['value'])?$params['value']:'');
  1780. $class = (isset($params['class'])?' '.$params['class']:'');
  1781. $wrapClass = (isset($params['wrapClass'])?$params['wrapClass']:'form-content');
  1782. $assist = (isset($params['assist'])?' - i.e. '.$params['assist']:'');
  1783. $label = (isset($params['labelTranslate'])?translate($params['labelTranslate']):(isset($params['label'])?$params['label']:''));
  1784. $labelOut = '<p class="help-text">'.$label.$assist.'</p>';
  1785. // Field Design
  1786. switch ($params['type']) {
  1787. case 'text':
  1788. case 'number':
  1789. case 'password':
  1790. $field = '<input id="'.$id.'" name="'.$name.'" type="'.$params['type'].'" class="form-control material input-sm'.$class.'" '.implode(' ',$tags).' autocorrect="off" autocapitalize="off" value="'.$val.'">';
  1791. break;
  1792. case 'select':
  1793. case 'dropdown':
  1794. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control material input-sm" '.implode(' ',$tags).'>'.resolveSelectOptions($params['options'], $val).'</select>';
  1795. break;
  1796. case 'select-multi':
  1797. case 'dropdown-multi':
  1798. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control input-sm" '.implode(' ',$tags).' multiple="multiple">'.resolveSelectOptions($params['options'], $val, true).'</select>';
  1799. break;
  1800. case 'check':
  1801. case 'checkbox':
  1802. case 'toggle':
  1803. $checked = ((is_bool($val) && $val) || trim($val) === 'true'?' checked':'');
  1804. $colour = (isset($params['colour'])?$params['colour']:'success');
  1805. $labelOut = '<label for="'.$id.'"></label>'.$label;
  1806. $field = '<input id="'.$id.'" name="'.$name.'" type="checkbox" class="switcher switcher-'.$colour.' '.$class.'" '.implode(' ',$tags).' data-value="'.$val.'"'.$checked.'>';
  1807. break;
  1808. case 'radio':
  1809. $labelOut = '';
  1810. $checked = ((is_bool($val) && $val) || ($val && trim($val) !== 'false')?' checked':'');
  1811. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1812. $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>';
  1813. break;
  1814. case 'date':
  1815. $field = 'Unsupported, planned.';
  1816. break;
  1817. case 'hidden':
  1818. return '<input id="'.$id.'" name="'.$name.'" type="hidden" class="'.$class.'" '.implode(' ',$tags).' value="'.$val.'">';
  1819. break;
  1820. case 'header':
  1821. $labelOut = '';
  1822. $headType = (isset($params['value'])?$params['value']:3);
  1823. $field = '<h'.$headType.' class="'.$class.'" '.implode(' ',$tags).'>'.$label.'</h'.$headType.'>';
  1824. break;
  1825. case 'button':
  1826. $labelOut = '';
  1827. $icon = (isset($params['icon'])?$params['icon']:'flask');
  1828. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1829. $bDropdown = (isset($params['buttonDrop'])?$params['buttonDrop']:'');
  1830. $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>':'');
  1831. break;
  1832. case 'textarea':
  1833. $rows = (isset($params['rows'])?$params['rows']:5);
  1834. $field = '<textarea id="'.$id.'" name="'.$name.'" class="form-control'.$class.'" rows="'.$rows.'" '.implode(' ',$tags).'>'.$val.'</textarea>';
  1835. break;
  1836. case 'custom':
  1837. // Settings
  1838. $settings = array(
  1839. '$id' => $id,
  1840. '$name' => $name,
  1841. '$val' => $val,
  1842. '$label' => $label,
  1843. '$labelOut' => $labelOut,
  1844. );
  1845. // Get HTML
  1846. $html = (isset($params['html'])?$params['html']:'Nothing Specified!');
  1847. // If LabelOut is in html dont print it twice
  1848. $labelOut = (strpos($html,'$label')!==false?'':$labelOut);
  1849. // Replace variables in settings
  1850. $html = preg_replace_callback('/\$\w+\b/', function ($match) use ($settings) { return (isset($settings[$match[0]])?$settings[$match[0]]:'{'.$match[0].' is undefined}'); }, $html);
  1851. // Build Field
  1852. $field = '<div id="'.$id.'_html" class="custom-field">'.$html.'</div>';
  1853. break;
  1854. case 'space':
  1855. $labelOut = '';
  1856. $field = str_repeat('<br>', (isset($params['value'])?$params['value']:1));
  1857. break;
  1858. default:
  1859. $field = 'Unsupported field type';
  1860. break;
  1861. }
  1862. // Field Formats
  1863. switch ($format) {
  1864. case 'colour': // Fuckin Eh, Canada!
  1865. case 'color':
  1866. $labelBef = '<center>'.$label.'</center>';
  1867. $wrapClass = 'gray-bg colour-field';
  1868. $labelAft = '';
  1869. $field = str_replace(' material input-sm','',$field);
  1870. break;
  1871. default:
  1872. $labelBef = '';
  1873. $labelAft = $labelOut;
  1874. }
  1875. return '<div class="'.$wrapClass.' col-sm-'.$sizeSm.' col-md-'.$sizeMd.' col-lg-'.$sizeLg.'">'.$labelBef.$field.$labelAft.'</div>';
  1876. }
  1877. // Tab Settings Generation
  1878. function printTabRow($data) {
  1879. $hidden = false;
  1880. if ($data===false) {
  1881. $hidden = true;
  1882. $data = array( // New Tab Defaults
  1883. 'id' => 'new',
  1884. 'name' => '',
  1885. 'url' => '',
  1886. 'icon' => 'fa-diamond',
  1887. 'iconurl' => '',
  1888. 'active' => 'true',
  1889. 'user' => 'true',
  1890. 'guest' => 'true',
  1891. 'window' => 'false',
  1892. 'splash' => 'true',
  1893. 'ping' => 'false',
  1894. 'ping_url' => '',
  1895. 'defaultz' => '',
  1896. );
  1897. }
  1898. $image = '<span style="font: normal normal normal 30px/1 FontAwesome;" class="fa fa-hand-paper-o"></span>';
  1899. $output = '
  1900. <li id="tab-'.$data['id'].'" class="list-group-item" style="position: relative; left: 0px; top: 0px; '.($hidden?' display: none;':'').'">
  1901. <tab class="content-form form-inline">
  1902. <div class="row">
  1903. '.buildField(array(
  1904. 'type' => 'custom',
  1905. '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>',
  1906. ),12,1,1).'
  1907. '.buildField(array(
  1908. 'type' => 'hidden',
  1909. 'id' => 'tab-'.$data['id'].'-id',
  1910. 'name' => 'id['.$data['id'].']',
  1911. 'value' => $data['id'],
  1912. ),12,2,1).'
  1913. '.buildField(array(
  1914. 'type' => 'text',
  1915. 'id' => 'tab-'.$data['id'].'-name',
  1916. 'name' => 'name['.$data['id'].']',
  1917. 'required' => true,
  1918. 'placeholder' => 'Organizr Homepage',
  1919. 'labelTranslate' => 'TAB_NAME',
  1920. 'value' => $data['name'],
  1921. 'class' => 'darkBold',
  1922. ),12,2,1).'
  1923. '.buildField(array(
  1924. 'type' => 'text',
  1925. 'id' => 'tab-'.$data['id'].'-url',
  1926. 'name' => 'url['.$data['id'].']',
  1927. 'required' => true,
  1928. 'placeholder' => 'homepage.php',
  1929. 'labelTranslate' => 'TAB_URL',
  1930. 'value' => $data['url'],
  1931. 'class' => 'darkBold',
  1932. ),12,2,2).'
  1933. '.buildField(array(
  1934. 'type' => 'text',
  1935. 'id' => 'tab-'.$data['id'].'-iconurl',
  1936. 'name' => 'iconurl['.$data['id'].']',
  1937. 'placeholder' => 'images/organizr.png',
  1938. 'labelTranslate' => 'ICON_URL',
  1939. 'value' => $data['iconurl'],
  1940. 'class' => 'darkBold',
  1941. ),12,2,1).'
  1942. '.buildField(array(
  1943. 'type' => 'text',
  1944. 'id' => 'tab-'.$data['id'].'-icon',
  1945. 'name' => 'icon['.$data['id'].']',
  1946. 'placeholder' => 'fa-icon',
  1947. 'labelTranslate' => 'OR_ICON_NAME',
  1948. 'value' => $data['icon'],
  1949. 'class' => 'iconpickeradd darkBold',
  1950. ),12,1,1).'
  1951. '.buildField(array(
  1952. 'type' => 'text',
  1953. 'id' => 'tab-'.$data['id'].'-ping_url',
  1954. 'name' => 'ping_url['.$data['id'].']',
  1955. 'placeholder' => 'host:port',
  1956. 'labelTranslate' => 'PING_URL',
  1957. 'value' => $data['ping_url'],
  1958. 'class' => 'darkBold',
  1959. ),12,2,1).'
  1960. '.buildField(array(
  1961. 'type' => 'radio',
  1962. 'labelTranslate' => 'DEFAULT',
  1963. 'name' => 'defaultz['.$data['id'].']',
  1964. 'value' => $data['defaultz'],
  1965. 'onclick' => "$('[type=radio][id!=\''+this.id+'\']').each(function() { this.checked=false; });",
  1966. ),12,1,1).'
  1967. '.buildField(array(
  1968. 'type' => 'button',
  1969. 'icon' => 'chevron-down',
  1970. 'buttonType' => 'success',
  1971. 'labelTranslate' => 'MORE',
  1972. 'onclick' => "$(this).parent().parent().parent().find('.slideInUp').toggle()",
  1973. 'class' => 'toggleTabExtra',
  1974. ),12,1,1).'
  1975. '.buildField(array(
  1976. 'type' => 'button',
  1977. 'icon' => 'trash',
  1978. 'buttonType' => 'danger',
  1979. 'labelTranslate' => 'REMOVE',
  1980. 'onclick' => "$(this).parents('li').remove();",
  1981. ),12,1,1).'</div><div id = "tab-'.$data['id'].'-row" class = "row animated slideInUp" style = "display:none;" ><div></div>
  1982. '.buildField(array(
  1983. 'type' => 'checkbox',
  1984. 'labelTranslate' => 'ACTIVE',
  1985. 'name' => 'active['.$data['id'].']',
  1986. 'value' => $data['active'],
  1987. ),12,1,1).'
  1988. '.buildField(array(
  1989. 'type' => 'checkbox',
  1990. 'labelTranslate' => 'USER',
  1991. 'colour' => 'primary',
  1992. 'name' => 'user['.$data['id'].']',
  1993. 'value' => $data['user'],
  1994. ),12,1,1).'
  1995. '.buildField(array(
  1996. 'type' => 'checkbox',
  1997. 'labelTranslate' => 'GUEST',
  1998. 'colour' => 'warning',
  1999. 'name' => 'guest['.$data['id'].']',
  2000. 'value' => $data['guest'],
  2001. ),12,1,1).'
  2002. '.buildField(array(
  2003. 'type' => 'checkbox',
  2004. 'labelTranslate' => 'NO_IFRAME',
  2005. 'colour' => 'danger',
  2006. 'name' => 'window['.$data['id'].']',
  2007. 'value' => $data['window'],
  2008. ),12,1,1).'
  2009. '.buildField(array(
  2010. 'type' => 'checkbox',
  2011. 'labelTranslate' => 'SPLASH',
  2012. 'colour' => 'success',
  2013. 'name' => 'splash['.$data['id'].']',
  2014. 'value' => $data['splash'],
  2015. ),12,1,1).'
  2016. '.buildField(array(
  2017. 'type' => 'checkbox',
  2018. 'labelTranslate' => 'PING',
  2019. 'colour' => 'success',
  2020. 'name' => 'ping['.$data['id'].']',
  2021. 'value' => $data['ping'],
  2022. ),12,1,1).'
  2023. </div>
  2024. </tab>
  2025. </li>
  2026. ';
  2027. return $output;
  2028. }
  2029. // Timezone array
  2030. function timezoneOptions() {
  2031. $output = array();
  2032. $timezones = array();
  2033. $regions = array(
  2034. 'Africa' => DateTimeZone::AFRICA,
  2035. 'America' => DateTimeZone::AMERICA,
  2036. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2037. 'Arctic' => DateTimeZone::ARCTIC,
  2038. 'Asia' => DateTimeZone::ASIA,
  2039. 'Atlantic' => DateTimeZone::ATLANTIC,
  2040. 'Australia' => DateTimeZone::AUSTRALIA,
  2041. 'Europe' => DateTimeZone::EUROPE,
  2042. 'Indian' => DateTimeZone::INDIAN,
  2043. 'Pacific' => DateTimeZone::PACIFIC
  2044. );
  2045. foreach ($regions as $name => $mask) {
  2046. $zones = DateTimeZone::listIdentifiers($mask);
  2047. foreach($zones as $timezone) {
  2048. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2049. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2050. $output[$name]['optgroup'][substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm]['value'] = $timezone;
  2051. }
  2052. }
  2053. return $output;
  2054. }
  2055. // Build Database
  2056. function createSQLiteDB($path = false) {
  2057. if ($path === false) {
  2058. if (DATABASE_LOCATION){
  2059. $path = DATABASE_LOCATION;
  2060. } else {
  2061. debug_out('No Path Specified!');
  2062. }
  2063. }
  2064. if (!is_file($path.'users.db') || filesize($path.'users.db') <= 0) {
  2065. if (!isset($GLOBALS['file_db'])) {
  2066. $GLOBALS['file_db'] = new PDO('sqlite:'.$path.'users.db');
  2067. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2068. }
  2069. // Create Users
  2070. $users = $GLOBALS['file_db']->query('CREATE TABLE `users` (
  2071. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2072. `username` TEXT UNIQUE,
  2073. `password` TEXT,
  2074. `email` TEXT,
  2075. `token` TEXT,
  2076. `role` TEXT,
  2077. `active` TEXT,
  2078. `last` TEXT,
  2079. `auth_service` TEXT DEFAULT \'internal\'
  2080. );');
  2081. // Create Tabs
  2082. $tabs = $GLOBALS['file_db']->query('CREATE TABLE `tabs` (
  2083. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2084. `order` INTEGER,
  2085. `users_id` INTEGER,
  2086. `name` TEXT,
  2087. `url` TEXT,
  2088. `defaultz` TEXT,
  2089. `active` TEXT,
  2090. `user` TEXT,
  2091. `guest` TEXT,
  2092. `icon` TEXT,
  2093. `iconurl` TEXT,
  2094. `window` TEXT,
  2095. `splash` TEXT,
  2096. `ping` TEXT,
  2097. `ping_url` TEXT
  2098. );');
  2099. // Create Options
  2100. $options = $GLOBALS['file_db']->query('CREATE TABLE `options` (
  2101. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2102. `users_id` INTEGER UNIQUE,
  2103. `title` TEXT UNIQUE,
  2104. `topbar` TEXT,
  2105. `bottombar` TEXT,
  2106. `sidebar` TEXT,
  2107. `hoverbg` TEXT,
  2108. `topbartext` TEXT,
  2109. `activetabBG` TEXT,
  2110. `activetabicon` TEXT,
  2111. `activetabtext` TEXT,
  2112. `inactiveicon` TEXT,
  2113. `inactivetext` TEXT,
  2114. `loading` TEXT,
  2115. `hovertext` TEXT
  2116. );');
  2117. // Create Invites
  2118. $invites = $GLOBALS['file_db']->query('CREATE TABLE `invites` (
  2119. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  2120. `code` TEXT UNIQUE,
  2121. `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  2122. `email` TEXT,
  2123. `username` TEXT,
  2124. `dateused` TIMESTAMP,
  2125. `usedby` TEXT,
  2126. `ip` TEXT,
  2127. `valid` TEXT
  2128. );');
  2129. writeLog("success", "database created/saved");
  2130. return $users && $tabs && $options && $invites;
  2131. } else {
  2132. writeLog("error", "database was unable to be created/saved");
  2133. return false;
  2134. }
  2135. }
  2136. // Upgrade Database
  2137. function updateSQLiteDB($db_path = false, $oldVerNum = false) {
  2138. if (!$db_path) {
  2139. if (defined('DATABASE_LOCATION')) {
  2140. $db_path = DATABASE_LOCATION;
  2141. } else {
  2142. debug_out('No Path Specified',1);
  2143. }
  2144. }
  2145. if (!isset($GLOBALS['file_db'])) {
  2146. $GLOBALS['file_db'] = new PDO('sqlite:'.$db_path.'users.db');
  2147. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2148. }
  2149. // Cache current DB
  2150. $cache = array();
  2151. foreach($GLOBALS['file_db']->query('SELECT name FROM sqlite_master WHERE type="table";') as $table) {
  2152. foreach($GLOBALS['file_db']->query('SELECT * FROM '.$table['name'].';') as $key => $row) {
  2153. foreach($row as $k => $v) {
  2154. if (is_string($k)) {
  2155. $cache[$table['name']][$key][$k] = $v;
  2156. }
  2157. }
  2158. }
  2159. }
  2160. // Remove Current Database
  2161. $GLOBALS['file_db'] = null;
  2162. $pathDigest = pathinfo($db_path.'users.db');
  2163. if (file_exists($db_path.'users.db')) {
  2164. rename($db_path.'users.db', $pathDigest['dirname'].'/'.$pathDigest['filename'].'['.date('Y-m-d_H-i-s').']'.($oldVerNum?'['.$oldVerNum.']':'').'.bak.db');
  2165. }
  2166. // Create New Database
  2167. $success = createSQLiteDB($db_path);
  2168. // Restore Items
  2169. if ($success) {
  2170. foreach($cache as $table => $tableData) {
  2171. if ($tableData) {
  2172. $queryBase = 'INSERT INTO '.$table.' (`'.implode('`,`',array_keys(current($tableData))).'`) values ';
  2173. $insertValues = array();
  2174. reset($tableData);
  2175. foreach($tableData as $key => $value) {
  2176. $insertValues[] = '('.implode(',',array_map(function($d) {
  2177. return (isset($d)?$GLOBALS['file_db']->quote($d):'null');
  2178. }, $value)).')';
  2179. }
  2180. $GLOBALS['file_db']->query($queryBase.implode(',',$insertValues).';');
  2181. }
  2182. }
  2183. writeLog("success", "database values have been updated");
  2184. return true;
  2185. } else {
  2186. writeLog("error", "database values unable to be updated");
  2187. return false;
  2188. }
  2189. }
  2190. // Commit colours to database
  2191. function updateDBOptions($values) {
  2192. if (!isset($GLOBALS['file_db'])) {
  2193. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2194. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2195. }
  2196. // Commit new values to database
  2197. if ($GLOBALS['file_db']->query('UPDATE options SET '.implode(',',array_map(function($d, $k) {
  2198. return '`'.$k.'` = '.(isset($d)?"'".addslashes($d)."'":'null');
  2199. }, $values, array_keys($values))).';')->rowCount()) {
  2200. return true;
  2201. } else if ($GLOBALS['file_db']->query('INSERT OR IGNORE INTO options (`'.implode('`,`',array_keys($values)).'`) VALUES (\''.implode("','",$values).'\');')->rowCount()) {
  2202. writeLog("success", "database values for options table have been updated");
  2203. return true;
  2204. } else {
  2205. writeLog("error", "database values for options table unable to be updated");
  2206. return false;
  2207. }
  2208. }
  2209. // Send AJAX notification
  2210. function sendNotification($success, $message = false, $send = true) {
  2211. $notifyExplode = explode("-", NOTIFYEFFECT);
  2212. if ($success) {
  2213. $msg = array(
  2214. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_SAVED").'</strong>'),
  2215. 'icon' => 'floppy-o',
  2216. 'type' => 'success',
  2217. 'length' => '5000',
  2218. 'layout' => $notifyExplode[0],
  2219. 'effect' => $notifyExplode[1],
  2220. );
  2221. } else {
  2222. $msg = array(
  2223. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_NOT_SAVED").'</strong>'),
  2224. 'icon' => 'floppy-o',
  2225. 'type' => 'failed',
  2226. 'length' => '5000',
  2227. 'layout' => $notifyExplode[0],
  2228. 'effect' => $notifyExplode[1],
  2229. );
  2230. }
  2231. // Send and kill script?
  2232. if ($send) {
  2233. header('Content-Type: application/json');
  2234. echo json_encode(array('notify'=>$msg));
  2235. die();
  2236. }
  2237. return $msg;
  2238. }
  2239. // Load colours from the database
  2240. function loadAppearance() {
  2241. // Defaults
  2242. $defaults = array(
  2243. 'title' => 'Organizr',
  2244. 'topbartext' => '#66D9EF',
  2245. 'topbar' => '#333333',
  2246. 'bottombar' => '#333333',
  2247. 'sidebar' => '#393939',
  2248. 'hoverbg' => '#AD80FD',
  2249. 'activetabBG' => '#F92671',
  2250. 'activetabicon' => '#FFFFFF',
  2251. 'activetabtext' => '#FFFFFF',
  2252. 'inactiveicon' => '#66D9EF',
  2253. 'inactivetext' => '#66D9EF',
  2254. 'loading' => '#66D9EF',
  2255. 'hovertext' => '#000000',
  2256. );
  2257. if (DATABASE_LOCATION) {
  2258. if(is_file(DATABASE_LOCATION.'users.db') && filesize(DATABASE_LOCATION.'users.db') > 0){
  2259. if (!isset($GLOBALS['file_db'])) {
  2260. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2261. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2262. }
  2263. // Database Lookup
  2264. $options = $GLOBALS['file_db']->query('SELECT * FROM options');
  2265. // Replace defaults with filled options
  2266. foreach($options as $row) {
  2267. foreach($defaults as $key => $value) {
  2268. if (isset($row[$key]) && $row[$key]) {
  2269. $defaults[$key] = $row[$key];
  2270. }
  2271. }
  2272. }
  2273. }
  2274. }
  2275. // Return the Results
  2276. return $defaults;
  2277. }
  2278. // Delete Database
  2279. function deleteDatabase() {
  2280. unset($_COOKIE['Organizr']);
  2281. setcookie('Organizr', '', time() - 3600, '/');
  2282. unset($_COOKIE['OrganizrU']);
  2283. setcookie('OrganizrU', '', time() - 3600, '/');
  2284. $GLOBALS['file_db'] = null;
  2285. unlink(DATABASE_LOCATION.'users.db');
  2286. foreach(glob(substr_replace($userdirpath, "", -1).'/*') as $file) {
  2287. if(is_dir($file)) {
  2288. rmdir($file);
  2289. } elseif (!is_dir($file)) {
  2290. unlink($file);
  2291. }
  2292. }
  2293. rmdir($userdirpath);
  2294. writeLog("success", "database has been deleted");
  2295. return true;
  2296. }
  2297. // Upgrade the installation
  2298. function upgradeInstall($branch = 'master') {
  2299. function downloadFile($url, $path){
  2300. ini_set('max_execution_time',0);
  2301. $folderPath = "upgrade/";
  2302. if(!mkdir($folderPath)){
  2303. writeLog("error", "organizr could not create upgrade folder");
  2304. }
  2305. $newfname = $folderPath . $path;
  2306. $file = fopen ($url, 'rb');
  2307. if ($file) {
  2308. $newf = fopen ($newfname, 'wb');
  2309. if ($newf) {
  2310. while(!feof($file)) {
  2311. fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
  2312. }
  2313. }
  2314. }else{
  2315. writeLog("error", "organizr could not download $url");
  2316. }
  2317. if ($file) {
  2318. fclose($file);
  2319. writeLog("success", "organizr finished downloading the github zip file");
  2320. }else{
  2321. writeLog("error", "organizr could not download the github zip file");
  2322. }
  2323. if ($newf) {
  2324. fclose($newf);
  2325. writeLog("success", "organizr created upgrade zip file from github zip file");
  2326. }else{
  2327. writeLog("error", "organizr could not create upgrade zip file from github zip file");
  2328. }
  2329. }
  2330. function unzipFile($zipFile){
  2331. $zip = new ZipArchive;
  2332. $extractPath = "upgrade/";
  2333. if($zip->open($extractPath . $zipFile) != "true"){
  2334. writeLog("error", "organizr could not unzip upgrade.zip");
  2335. }else{
  2336. writeLog("success", "organizr unzipped upgrade.zip");
  2337. }
  2338. /* Extract Zip File */
  2339. $zip->extractTo($extractPath);
  2340. $zip->close();
  2341. }
  2342. // Function to remove folders and files
  2343. function rrmdir($dir) {
  2344. if (is_dir($dir)) {
  2345. $files = scandir($dir);
  2346. foreach ($files as $file)
  2347. if ($file != "." && $file != "..") rrmdir("$dir/$file");
  2348. rmdir($dir);
  2349. }
  2350. else if (file_exists($dir)) unlink($dir);
  2351. }
  2352. // Function to Copy folders and files
  2353. function rcopy($src, $dst) {
  2354. if (is_dir ( $src )) {
  2355. if (!file_exists($dst)) : mkdir ( $dst ); endif;
  2356. $files = scandir ( $src );
  2357. foreach ( $files as $file )
  2358. if ($file != "." && $file != "..")
  2359. rcopy ( "$src/$file", "$dst/$file" );
  2360. } else if (file_exists ( $src ))
  2361. copy ( $src, $dst );
  2362. }
  2363. $url = 'https://github.com/causefx/Organizr/archive/'.$branch.'.zip';
  2364. $file = "upgrade.zip";
  2365. $source = __DIR__ . '/upgrade/Organizr-'.$branch.'/';
  2366. $cleanup = __DIR__ . "/upgrade/";
  2367. $destination = __DIR__ . "/";
  2368. writeLog("success", "starting organizr upgrade process");
  2369. downloadFile($url, $file);
  2370. unzipFile($file);
  2371. rcopy($source, $destination);
  2372. writeLog("success", "new organizr files copied");
  2373. rrmdir($cleanup);
  2374. writeLog("success", "organizr upgrade folder removed");
  2375. writeLog("success", "organizr has been updated");
  2376. return true;
  2377. }
  2378. // NzbGET Items
  2379. function nzbgetConnect($list = 'listgroups') {
  2380. $url = qualifyURL(NZBGETURL);
  2381. $api = curl_get($url.'/'.NZBGETUSERNAME.':'.NZBGETPASSWORD.'/jsonrpc/'.$list);
  2382. $api = json_decode($api, true);
  2383. $gotNZB = array();
  2384. if (is_array($api) || is_object($api)){
  2385. foreach ($api['result'] AS $child) {
  2386. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  2387. $downloadStatus = $child['Status'];
  2388. $downloadCategory = $child['Category'];
  2389. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  2390. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  2391. if($child['Health'] <= "750"){
  2392. $downloadHealth = "danger";
  2393. }elseif($child['Health'] <= "900"){
  2394. $downloadHealth = "warning";
  2395. }elseif($child['Health'] <= "1000"){
  2396. $downloadHealth = "success";
  2397. }
  2398. $gotNZB[] = '<tr>
  2399. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2400. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2401. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2402. <td class="col-xs-1 nzbtable nzbtable-row">'.realSize(($child['FileSizeMB']*1024)*1024).'</td>
  2403. <td class="col-xs-2 nzbtable nzbtable-row">
  2404. <div class="progress">
  2405. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2406. <p class="text-center">'.round($downloadPercent).'%</p>
  2407. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2408. </div>
  2409. </div>
  2410. </td>
  2411. </tr>';
  2412. }
  2413. if ($gotNZB) {
  2414. return implode('',$gotNZB);
  2415. } else {
  2416. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2417. }
  2418. }else{
  2419. writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Username and Password - if HTTPS, is cert valid");
  2420. }
  2421. }
  2422. // Sabnzbd Items
  2423. function sabnzbdConnect($list = 'queue') {
  2424. $url = qualifyURL(SABNZBDURL);
  2425. $api = file_get_contents($url.'/api?mode='.$list.'&output=json&apikey='.SABNZBDKEY);
  2426. $api = json_decode($api, true);
  2427. $gotNZB = array();
  2428. foreach ($api[$list]['slots'] AS $child) {
  2429. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  2430. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  2431. $downloadStatus = $child['status'];
  2432. $gotNZB[] = '<tr>
  2433. <td class="col-xs-6 nzbtable-file-row">'.$downloadName.'</td>
  2434. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2435. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2436. <td class="col-xs-1 nzbtable nzbtable-row">'.$child['size'].'</td>
  2437. <td class="col-xs-2 nzbtable nzbtable-row">
  2438. <div class="progress">
  2439. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2440. <p class="text-center">'.round($downloadPercent).'%</p>
  2441. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2442. </div>
  2443. </div>
  2444. </td>
  2445. </tr>';
  2446. }
  2447. if ($gotNZB) {
  2448. return implode('',$gotNZB);
  2449. } else {
  2450. return '<tr><td colspan="5"><p class="text-center">No Results</p></td></tr>';
  2451. }
  2452. }
  2453. // Apply new tab settings
  2454. function updateTabs($tabs) {
  2455. if (!isset($GLOBALS['file_db'])) {
  2456. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2457. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2458. }
  2459. // Validate
  2460. if (!isset($tabs['defaultz'])) { $tabs['defaultz'][current(array_keys($tabs['name']))] = 'true'; }
  2461. if (isset($tabs['name']) && isset($tabs['url']) && is_array($tabs['name'])) {
  2462. // Clear Existing Tabs
  2463. $GLOBALS['file_db']->query("DELETE FROM tabs");
  2464. // Process New Tabs
  2465. $totalValid = 0;
  2466. foreach ($tabs['name'] as $key => $value) {
  2467. // Qualify
  2468. if (!$value || !isset($tabs['url']) || !$tabs['url'][$key]) { continue; }
  2469. $totalValid++;
  2470. $fields = array();
  2471. foreach(array('id','name','url','icon','iconurl','order','ping_url') as $v) {
  2472. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = $tabs[$v][$key]; }
  2473. }
  2474. foreach(array('active','user','guest','defaultz','window','splash','ping') as $v) {
  2475. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = ($tabs[$v][$key]!=='false'?'true':'false'); }
  2476. }
  2477. $GLOBALS['file_db']->query('INSERT INTO tabs (`'.implode('`,`',array_keys($fields)).'`) VALUES (\''.implode("','",$fields).'\');');
  2478. }
  2479. writeLog("success", "tabs successfully saved");
  2480. return $totalValid;
  2481. } else {
  2482. writeLog("error", "tabs could not save");
  2483. return false;
  2484. }
  2485. writeLog("error", "tabs could not save");
  2486. return false;
  2487. }
  2488. // ==============
  2489. function clean($strin) {
  2490. $strout = null;
  2491. for ($i = 0; $i < strlen($strin); $i++) {
  2492. $ord = ord($strin[$i]);
  2493. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  2494. $strout .= "&amp;#{$ord};";
  2495. }
  2496. else {
  2497. switch ($strin[$i]) {
  2498. case '<':
  2499. $strout .= '&lt;';
  2500. break;
  2501. case '>':
  2502. $strout .= '&gt;';
  2503. break;
  2504. case '&':
  2505. $strout .= '&amp;';
  2506. break;
  2507. case '"':
  2508. $strout .= '&quot;';
  2509. break;
  2510. default:
  2511. $strout .= $strin[$i];
  2512. }
  2513. }
  2514. }
  2515. return $strout;
  2516. }
  2517. function registration_callback($username, $email, $userdir){
  2518. global $data;
  2519. $data = array($username, $email, $userdir);
  2520. }
  2521. function printArray($arrayName){
  2522. $messageCount = count($arrayName);
  2523. $i = 0;
  2524. foreach ( $arrayName as $item ) :
  2525. $i++;
  2526. if($i < $messageCount) :
  2527. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  2528. elseif($i = $messageCount) :
  2529. echo "<small class='text-uppercase'>" . $item . "</small>";
  2530. endif;
  2531. endforeach;
  2532. }
  2533. function write_ini_file($content, $path) {
  2534. if (!$handle = fopen($path, 'w')) {
  2535. return false;
  2536. }
  2537. $success = fwrite($handle, trim($content));
  2538. fclose($handle);
  2539. return $success;
  2540. }
  2541. function gotTimezone(){
  2542. $regions = array(
  2543. 'Africa' => DateTimeZone::AFRICA,
  2544. 'America' => DateTimeZone::AMERICA,
  2545. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2546. 'Arctic' => DateTimeZone::ARCTIC,
  2547. 'Asia' => DateTimeZone::ASIA,
  2548. 'Atlantic' => DateTimeZone::ATLANTIC,
  2549. 'Australia' => DateTimeZone::AUSTRALIA,
  2550. 'Europe' => DateTimeZone::EUROPE,
  2551. 'Indian' => DateTimeZone::INDIAN,
  2552. 'Pacific' => DateTimeZone::PACIFIC
  2553. );
  2554. $timezones = array();
  2555. foreach ($regions as $name => $mask) {
  2556. $zones = DateTimeZone::listIdentifiers($mask);
  2557. foreach($zones as $timezone) {
  2558. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2559. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2560. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2561. }
  2562. }
  2563. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  2564. foreach($timezones as $region => $list) {
  2565. print '<optgroup label="' . $region . '">' . "\n";
  2566. foreach($list as $timezone => $name) {
  2567. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  2568. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  2569. }
  2570. print '</optgroup>' . "\n";
  2571. }
  2572. print '</select>';
  2573. }
  2574. function getTimezone(){
  2575. $regions = array(
  2576. 'Africa' => DateTimeZone::AFRICA,
  2577. 'America' => DateTimeZone::AMERICA,
  2578. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2579. 'Arctic' => DateTimeZone::ARCTIC,
  2580. 'Asia' => DateTimeZone::ASIA,
  2581. 'Atlantic' => DateTimeZone::ATLANTIC,
  2582. 'Australia' => DateTimeZone::AUSTRALIA,
  2583. 'Europe' => DateTimeZone::EUROPE,
  2584. 'Indian' => DateTimeZone::INDIAN,
  2585. 'Pacific' => DateTimeZone::PACIFIC
  2586. );
  2587. $timezones = array();
  2588. foreach ($regions as $name => $mask) {
  2589. $zones = DateTimeZone::listIdentifiers($mask);
  2590. foreach($zones as $timezone) {
  2591. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2592. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2593. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2594. }
  2595. }
  2596. print '<select name="timezone" id="timezone" class="form-control material" required>';
  2597. foreach($timezones as $region => $list) {
  2598. print '<optgroup label="' . $region . '">' . "\n";
  2599. foreach($list as $timezone => $name) {
  2600. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  2601. }
  2602. print '</optgroup>' . "\n";
  2603. }
  2604. print '</select>';
  2605. }
  2606. function explosion($string, $position){
  2607. $getWord = explode("|", $string);
  2608. return $getWord[$position];
  2609. }
  2610. function getServerPath() {
  2611. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  2612. $protocol = "https://";
  2613. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  2614. $protocol = "https://";
  2615. } else {
  2616. $protocol = "http://";
  2617. }
  2618. $domain = '';
  2619. if (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], '.') !== false){
  2620. $domain = $_SERVER['SERVER_NAME'];
  2621. }elseif(isset($_SERVER['HTTP_HOST'])){
  2622. if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
  2623. $domain = explode(':', $_SERVER['HTTP_HOST'])[0];
  2624. $port = explode(':', $_SERVER['HTTP_HOST'])[1];
  2625. if ($port == "80" || $port == "443"){
  2626. $domain = $domain;
  2627. }else{
  2628. $domain = $_SERVER['HTTP_HOST'];
  2629. }
  2630. }else{
  2631. $domain = $_SERVER['HTTP_HOST'];
  2632. }
  2633. }
  2634. return $protocol . $domain . str_replace("\\", "/", dirname($_SERVER['REQUEST_URI']));
  2635. }
  2636. function get_browser_name() {
  2637. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  2638. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  2639. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  2640. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  2641. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  2642. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  2643. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  2644. return 'Other';
  2645. }
  2646. function getSickrageCalendarWanted($array){
  2647. $array = json_decode($array, true);
  2648. //$gotCalendar = "";
  2649. $gotCalendar = array();
  2650. $i = 0;
  2651. foreach($array['data']['missed'] AS $child) {
  2652. $i++;
  2653. $seriesName = $child['show_name'];
  2654. $episodeID = $child['tvdbid'];
  2655. $episodeAirDate = $child['airdate'];
  2656. $episodeAirDateTime = explode(" ",$child['airs']);
  2657. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2658. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2659. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2660. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2661. $downloaded = "0";
  2662. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2663. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2664. array_push($gotCalendar, array(
  2665. "id" => "Sick-Miss-".$i,
  2666. "title" => $seriesName,
  2667. "start" => $episodeAirDate,
  2668. "className" => $downloaded." tvID--".$episodeID,
  2669. "imagetype" => "tv",
  2670. ));
  2671. }
  2672. foreach($array['data']['today'] AS $child) {
  2673. $i++;
  2674. $seriesName = $child['show_name'];
  2675. $episodeID = $child['tvdbid'];
  2676. $episodeAirDate = $child['airdate'];
  2677. $episodeAirDateTime = explode(" ",$child['airs']);
  2678. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2679. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2680. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2681. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2682. $downloaded = "0";
  2683. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2684. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2685. array_push($gotCalendar, array(
  2686. "id" => "Sick-Today-".$i,
  2687. "title" => $seriesName,
  2688. "start" => $episodeAirDate,
  2689. "className" => $downloaded." tvID--".$episodeID,
  2690. "imagetype" => "tv",
  2691. ));
  2692. }
  2693. foreach($array['data']['soon'] AS $child) {
  2694. $i++;
  2695. $seriesName = $child['show_name'];
  2696. $episodeID = $child['tvdbid'];
  2697. $episodeAirDate = $child['airdate'];
  2698. $episodeAirDateTime = explode(" ",$child['airs']);
  2699. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2700. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2701. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2702. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2703. $downloaded = "0";
  2704. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2705. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2706. array_push($gotCalendar, array(
  2707. "id" => "Sick-Soon-".$i,
  2708. "title" => $seriesName,
  2709. "start" => $episodeAirDate,
  2710. "className" => $downloaded." tvID--".$episodeID,
  2711. "imagetype" => "tv",
  2712. ));
  2713. }
  2714. foreach($array['data']['later'] AS $child) {
  2715. $i++;
  2716. $seriesName = $child['show_name'];
  2717. $episodeID = $child['tvdbid'];
  2718. $episodeAirDate = $child['airdate'];
  2719. $episodeAirDateTime = explode(" ",$child['airs']);
  2720. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2721. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2722. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2723. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2724. $downloaded = "0";
  2725. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2726. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2727. array_push($gotCalendar, array(
  2728. "id" => "Sick-Later-".$i,
  2729. "title" => $seriesName,
  2730. "start" => $episodeAirDate,
  2731. "className" => $downloaded." tvID--".$episodeID,
  2732. "imagetype" => "tv",
  2733. ));
  2734. }
  2735. if ($i != 0){ return $gotCalendar; }
  2736. }
  2737. function getSickrageCalendarHistory($array){
  2738. $array = json_decode($array, true);
  2739. //$gotCalendar = "";
  2740. $gotCalendar = array();
  2741. $i = 0;
  2742. foreach($array['data'] AS $child) {
  2743. $i++;
  2744. $seriesName = $child['show_name'];
  2745. $episodeID = $child['tvdbid'];
  2746. $episodeAirDate = $child['date'];
  2747. $downloaded = "green-bg";
  2748. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2749. array_push($gotCalendar, array(
  2750. "id" => "Sick-History-".$i,
  2751. "title" => $seriesName,
  2752. "start" => $episodeAirDate,
  2753. "className" => $downloaded." tvID--".$episodeID,
  2754. "imagetype" => "tv",
  2755. ));
  2756. }
  2757. if ($i != 0){ return $gotCalendar; }
  2758. }
  2759. function getSonarrCalendar($array){
  2760. $array = json_decode($array, true);
  2761. //$gotCalendar = "";
  2762. $gotCalendar = array();
  2763. $i = 0;
  2764. foreach($array AS $child) {
  2765. $i++;
  2766. $seriesName = $child['series']['title'];
  2767. $episodeID = $child['series']['tvdbId'];
  2768. if(!isset($episodeID)){ $episodeID = ""; }
  2769. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  2770. if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
  2771. $episodeAirDate = $child['airDateUtc'];
  2772. $episodeAirDate = strtotime($episodeAirDate);
  2773. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2774. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2775. $downloaded = $child['hasFile'];
  2776. if($downloaded == "0" && isset($unaired) && $episodePremier == "true"){ $downloaded = "light-blue-bg"; }elseif($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2777. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2778. array_push($gotCalendar, array(
  2779. "id" => "Sonarr-".$i,
  2780. "title" => $seriesName,
  2781. "start" => $episodeAirDate,
  2782. "className" => $downloaded." tvID--".$episodeID,
  2783. "imagetype" => "tv",
  2784. ));
  2785. }
  2786. if ($i != 0){ return $gotCalendar; }
  2787. }
  2788. function getCouchCalendar(){
  2789. $url = qualifyURL(COUCHURL);
  2790. $api = curl_get($url."/api/".COUCHAPI."/media.list");
  2791. $api = json_decode($api, true);
  2792. $i = 0;
  2793. $gotCalendar = array();
  2794. if (is_array($api) || is_object($api)){
  2795. foreach($api['movies'] AS $child) {
  2796. if($child['status'] == "active" || $child['status'] == "done" ){
  2797. $i++;
  2798. $movieName = $child['info']['original_title'];
  2799. $movieID = $child['info']['tmdb_id'];
  2800. if(!isset($movieID)){ $movieID = ""; }
  2801. $physicalRelease = (isset($child['info']['released']) ? $child['info']['released'] : null);
  2802. $backupRelease = (isset($child['info']['release_date']['theater']) ? $child['info']['release_date']['theater'] : null);
  2803. $physicalRelease = (isset($physicalRelease) ? $physicalRelease : $backupRelease);
  2804. $physicalRelease = strtotime($physicalRelease);
  2805. $physicalRelease = date("Y-m-d", $physicalRelease);
  2806. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2807. $downloaded = ($child['status'] == "active") ? "0" : "1";
  2808. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2809. array_push($gotCalendar, array(
  2810. "id" => "CouchPotato-".$i,
  2811. "title" => $movieName,
  2812. "start" => $physicalRelease,
  2813. "className" => $downloaded." movieID--".$movieID,
  2814. "imagetype" => "film",
  2815. ));
  2816. }
  2817. }
  2818. if ($i != 0){ return $gotCalendar; }
  2819. }else{
  2820. writeLog("error", "CouchPotato ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2821. }
  2822. }
  2823. function getRadarrCalendar($array){
  2824. $array = json_decode($array, true);
  2825. $gotCalendar = array();
  2826. $i = 0;
  2827. foreach($array AS $child) {
  2828. if(isset($child['physicalRelease'])){
  2829. $i++;
  2830. $movieName = $child['title'];
  2831. $movieID = $child['tmdbId'];
  2832. if(!isset($movieID)){ $movieID = ""; }
  2833. $physicalRelease = $child['physicalRelease'];
  2834. $physicalRelease = strtotime($physicalRelease);
  2835. $physicalRelease = date("Y-m-d", $physicalRelease);
  2836. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2837. $downloaded = $child['hasFile'];
  2838. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2839. array_push($gotCalendar, array(
  2840. "id" => "Radarr-".$i,
  2841. "title" => $movieName,
  2842. "start" => $physicalRelease,
  2843. "className" => $downloaded." movieID--".$movieID,
  2844. "imagetype" => "film",
  2845. ));
  2846. }
  2847. }
  2848. if ($i != 0){ return $gotCalendar; }
  2849. }
  2850. function getHeadphonesCalendar($url, $key, $list){
  2851. $url = qualifyURL(HEADPHONESURL);
  2852. $api = curl_get($url."/api?apikey=".$key."&cmd=$list");
  2853. $api = json_decode($api, true);
  2854. $i = 0;
  2855. //$gotCalendar = "";
  2856. $gotCalendar = array();;
  2857. if (is_array($api) || is_object($api)){
  2858. foreach($api AS $child) {
  2859. if($child['Status'] == "Wanted" && $list == "getWanted" && $child['ReleaseDate']){
  2860. $i++;
  2861. $albumName = addslashes($child['AlbumTitle']);
  2862. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  2863. $albumDate = (strlen($child['ReleaseDate']) > 4) ? $child['ReleaseDate'] : $child['ReleaseDate']."-01-01";
  2864. $albumID = $child['AlbumID'];
  2865. $albumDate = strtotime($albumDate);
  2866. $albumDate = date("Y-m-d", $albumDate);
  2867. $albumStatus = $child['Status'];
  2868. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2869. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  2870. //$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2871. array_push($gotCalendar, array(
  2872. "id" => "Headphones-".$i,
  2873. "title" => $albumArtist.' - '.$albumName,
  2874. "start" => $albumDate,
  2875. "className" => $albumStatusColor,
  2876. "imagetype" => "music",
  2877. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2878. ));
  2879. }
  2880. if($child['Status'] == "Processed" && $list == "getHistory"){
  2881. $i++;
  2882. $find = array('_','[', ']', '\n');
  2883. $replace = array(' ','(', ')', ' ');
  2884. $albumName = addslashes(str_replace($find,$replace,$child['FolderName']));
  2885. $albumDate = $child['DateAdded'];
  2886. $albumID = $child['AlbumID'];
  2887. $albumDate = strtotime($albumDate);
  2888. $albumDate = date("Y-m-d", $albumDate);
  2889. $albumStatusColor = "green-bg";
  2890. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2891. //$gotCalendar .= "{ title: \"$albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2892. array_push($gotCalendar, array(
  2893. "id" => "Headphones-".$i,
  2894. "title" => $albumName,
  2895. "start" => $albumDate,
  2896. "className" => $albumStatusColor,
  2897. "imagetype" => "music",
  2898. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2899. ));
  2900. }
  2901. }
  2902. if ($i != 0){ return $gotCalendar; }
  2903. }else{
  2904. writeLog("error", "HEADPHONES $list ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2905. }
  2906. }
  2907. function checkRootPath($string){
  2908. if($string == "\\" || $string == "/"){
  2909. return "/";
  2910. }else{
  2911. return str_replace("\\", "/", $string) . "/";
  2912. }
  2913. }
  2914. function strip($string){
  2915. $string = strip_tags($string);
  2916. return preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $string));
  2917. }
  2918. function writeLog($type, $message){
  2919. if(file_exists("org.log")){
  2920. if(filesize("org.log") > 500000){
  2921. rename('org.log','org['.date('Y-m-d').'].log');
  2922. $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";
  2923. file_put_contents("org.log", $message2, FILE_APPEND | LOCK_EX);
  2924. }
  2925. }
  2926. $message = date("Y-m-d H:i:s")."|".$type."|".strip($message)."\n";
  2927. file_put_contents("org.log", $message, FILE_APPEND | LOCK_EX);
  2928. }
  2929. function readLog(){
  2930. $log = file("org.log",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  2931. $log = array_reverse($log);
  2932. foreach($log as $line){
  2933. if(substr_count($line, '|') == 2){
  2934. $line = explode("|", strip($line));
  2935. $line[1] = ($line[1] == "error") ? '<span class="label label-danger">Error</span>' : '<span class="label label-primary">Success</span>';
  2936. echo "<tr><td>".$line[0]."</td><td>".$line[2]."</td><td>".$line[1]."</td></tr>";
  2937. }
  2938. }
  2939. }
  2940. function buildStream($array){
  2941. $result = "";
  2942. if (array_key_exists('platform', $array)) {
  2943. $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>';
  2944. }
  2945. if (array_key_exists('device', $array)) {
  2946. $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>';
  2947. }
  2948. if (array_key_exists('stream', $array)) {
  2949. $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>';
  2950. }
  2951. if (array_key_exists('video', $array)) {
  2952. $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>';
  2953. }
  2954. if (array_key_exists('audio', $array)) {
  2955. $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>';
  2956. }
  2957. return $result;
  2958. }
  2959. function streamType($value){
  2960. if($value == "transcode" || $value == "Transcode"){
  2961. return "Transcode";
  2962. }elseif($value == "copy" || $value == "DirectStream"){
  2963. return "Direct Stream";
  2964. }elseif($value == "directplay" || $value == "DirectPlay"){
  2965. return "Direct Play";
  2966. }else{
  2967. return "Direct Play";
  2968. }
  2969. }
  2970. function getPlatform($platform){
  2971. $allPlatforms = array(
  2972. "Chrome" => "chrome.png",
  2973. "tvOS" => "atv.png",
  2974. "iOS" => "ios.png",
  2975. "Xbox One" => "xbox.png",
  2976. "Mystery 4" => "playstation.png",
  2977. "Samsung" => "samsung.png",
  2978. "Roku" => "roku.png",
  2979. "Emby for iOS" => "ios.png",
  2980. "Emby Mobile" => "emby.png",
  2981. "Emby Theater" => "emby.png",
  2982. "Emby Classic" => "emby.png",
  2983. "Safari" => "safari.png",
  2984. "Android" => "android.png",
  2985. "AndroidTv" => "android.png",
  2986. "Chromecast" => "chromecast.png",
  2987. "Dashboard" => "emby.png",
  2988. "Dlna" => "dlna.png",
  2989. "Windows Phone" => "wp.png",
  2990. "Windows RT" => "win8.png",
  2991. "Kodi" => "kodi.png",
  2992. );
  2993. if (array_key_exists($platform, $allPlatforms)) {
  2994. return $allPlatforms[$platform];
  2995. }else{
  2996. return "pmp.png";
  2997. }
  2998. }
  2999. function getServer(){
  3000. $server = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"];
  3001. return $server;
  3002. }
  3003. function prettyPrint($array) {
  3004. echo "<pre>";
  3005. print_r($array);
  3006. echo "</pre>";
  3007. echo "<br/>";
  3008. }
  3009. function checkFrame($array, $url){
  3010. if(array_key_exists("x-frame-options", $array)){
  3011. if($array['x-frame-options'] == "deny"){
  3012. return false;
  3013. }elseif($array['x-frame-options'] == "sameorgin"){
  3014. $digest = parse_url($url);
  3015. $host = (isset($digest['host'])?$digest['host']:'');
  3016. if(getServer() == $host){
  3017. return true;
  3018. }else{
  3019. return false;
  3020. }
  3021. }
  3022. }else{
  3023. if(!$array){
  3024. return false;
  3025. }
  3026. return true;
  3027. }
  3028. }
  3029. function frameTest($url){
  3030. $array = array_change_key_case(get_headers(qualifyURL($url), 1));
  3031. $url = qualifyURL($url);
  3032. if(checkFrame($array, $url)){
  3033. return true;
  3034. }else{
  3035. return false;
  3036. }
  3037. }
  3038. function sendResult($result, $icon = "floppy-o", $message = false, $success = "WAS_SUCCESSFUL", $fail = "HAS_FAILED", $send = true) {
  3039. $notifyExplode = explode("-", NOTIFYEFFECT);
  3040. if ($result) {
  3041. $msg = array(
  3042. 'html' => ($message?''.$message.' <strong>'.translate($success).'</strong>':'<strong>'.translate($success).'</strong>'),
  3043. 'icon' => $icon,
  3044. 'type' => 'success',
  3045. 'length' => '5000',
  3046. 'layout' => $notifyExplode[0],
  3047. 'effect' => $notifyExplode[1],
  3048. );
  3049. } else {
  3050. $msg = array(
  3051. 'html' => ($message?''.$message.' <strong>'.translate($fail).'</strong>':'<strong>'.translate($fail).'</strong>'),
  3052. 'icon' => $icon,
  3053. 'type' => 'error',
  3054. 'length' => '5000',
  3055. 'layout' => $notifyExplode[0],
  3056. 'effect' => $notifyExplode[1],
  3057. );
  3058. }
  3059. // Send and kill script?
  3060. if ($send) {
  3061. header('Content-Type: application/json');
  3062. echo json_encode(array('notify'=>$msg));
  3063. die();
  3064. }
  3065. return $msg;
  3066. }
  3067. function buildHomepageNotice($layout, $type, $title, $message){
  3068. switch ($layout) {
  3069. case 'elegant':
  3070. return '
  3071. <div id="homepageNotice" class="row">
  3072. <div class="col-lg-12">
  3073. <div class="content-box big-box box-shadow panel-box panel-'.$type.'">
  3074. <div class="content-title i-block">
  3075. <h4 class="zero-m"><strong>'.$title.'</strong></h4>
  3076. <div class="content-tools i-block pull-right">
  3077. <a class="close-btn">
  3078. <i class="fa fa-times"></i>
  3079. </a>
  3080. </div>
  3081. </div>
  3082. '.$message.'
  3083. </div>
  3084. </div>
  3085. </div>
  3086. ';
  3087. break;
  3088. case 'basic':
  3089. return '
  3090. <div id="homepageNotice" class="row">
  3091. <div class="col-lg-12">
  3092. <div class="panel panel-'.$type.'">
  3093. <div class="panel-heading">
  3094. <h3 class="panel-title">'.$title.'</h3>
  3095. </div>
  3096. <div class="panel-body">
  3097. '.$message.'
  3098. </div>
  3099. </div>
  3100. </div>
  3101. </div>
  3102. ';
  3103. break;
  3104. case 'jumbotron';
  3105. return '
  3106. <div id="homepageNotice" class="row">
  3107. <div class="col-lg-12">
  3108. <div class="jumbotron">
  3109. <div class="container">
  3110. <h1>'.$title.'</h1>
  3111. <p>'.$message.'</p>
  3112. </div>
  3113. </div>
  3114. </div>
  3115. </div>
  3116. ';
  3117. }
  3118. }
  3119. function embyArray($array, $type) {
  3120. $key = ($type == "video" ? "Height" : "Channels");
  3121. if (array_key_exists($key, $array)) {
  3122. switch ($type) {
  3123. case "video":
  3124. $codec = $array["Codec"];
  3125. $height = $array["Height"];
  3126. $width = $array["Width"];
  3127. break;
  3128. default:
  3129. $codec = $array["Codec"];
  3130. $channels = $array["Channels"];
  3131. }
  3132. return ($type == "video" ? "(".$codec.") (".$width."x".$height.")" : "(".$codec.") (".$channels."ch)");
  3133. }
  3134. foreach ($array as $element) {
  3135. if (is_array($element)) {
  3136. if (embyArray($element, $type)) {
  3137. return embyArray($element, $type);
  3138. }
  3139. }
  3140. }
  3141. }
  3142. // Get Now Playing Streams From Plex
  3143. function searchPlex($query){
  3144. $address = qualifyURL(PLEXURL);
  3145. $openTab = (PLEXTABNAME) ? "true" : "false";
  3146. // Perform API requests
  3147. $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
  3148. libxml_use_internal_errors(true);
  3149. $api = simplexml_load_string($api);
  3150. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3151. if (!$getServer) { return 'Could not load!'; }
  3152. // Identify the local machine
  3153. $server = $getServer['machineIdentifier'];
  3154. $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>";
  3155. $items = "";
  3156. $albums = $movies = $shows = 0;
  3157. $style = 'style="vertical-align: middle"';
  3158. foreach($api AS $child) {
  3159. if($child['type'] != "artist" && $child['type'] != "episode" && isset($child['librarySectionID'])){
  3160. $time = (string)$child['addedAt'];
  3161. $time = new DateTime("@$time");
  3162. $results = array(
  3163. "title" => (string)$child['title'],
  3164. "image" => (string)$child['thumb'],
  3165. "type" => (string)ucwords($child['type']),
  3166. "year" => (string)$child['year'],
  3167. "key" => (string)$child['ratingKey']."-search",
  3168. "ratingkey" => (string)$child['ratingKey'],
  3169. "genre" => (string)$child->Genre['tag'],
  3170. "added" => $time->format('Y-m-d'),
  3171. "extra" => "",
  3172. );
  3173. switch ($child['type']){
  3174. case "album":
  3175. $push = array(
  3176. "title" => (string)$child['parentTitle']." - ".(string)$child['title'],
  3177. );
  3178. $results = array_replace($results,$push);
  3179. $albums++;
  3180. break;
  3181. case "movie":
  3182. $push = array(
  3183. "extra" => "Content Rating: ".(string)$child['contentRating']."<br/>Movie Rating: ".(string)$child['rating'],
  3184. );
  3185. $results = array_replace($results,$push);
  3186. $movies++;
  3187. break;
  3188. case "show":
  3189. $push = array(
  3190. "extra" => "Seasons: ".(string)$child['childCount']."<br/>Episodes: ".(string)$child['leafCount'],
  3191. );
  3192. $results = array_replace($results,$push);
  3193. $shows++;
  3194. break;
  3195. }
  3196. if (file_exists('images/cache/'.$results['key'].'.jpg')){ $image_url = 'images/cache/'.$results['key'].'.jpg'; }
  3197. if (file_exists('images/cache/'.$results['key'].'.jpg') && (time() - 604800) > filemtime('images/cache/'.$results['key'].'.jpg') || !file_exists('images/cache/'.$results['key'].'.jpg')) {
  3198. $image_url = 'ajax.php?a=plex-image&img='.$results['image'].'&height=150&width=100&key='.$results['key'];
  3199. }
  3200. if(!$results['image']){ $image_url = "images/no-search.png"; $key = "no-search"; }
  3201. if (PLEXTABURL) {
  3202. $link = PLEXTABURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3203. }else{
  3204. $link = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  3205. }
  3206. $items .= '<tr style="cursor: pointer;" class="openTab" extraTitle="'.$results['title'].'" extraType="'.$child['type'].'" openTab="'.$openTab.'" href="'.$link.'">
  3207. <th scope="row"><img src="'.$image_url.'"></th>
  3208. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
  3209. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
  3210. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
  3211. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
  3212. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
  3213. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['extra'].'</td>
  3214. </tr>';
  3215. }
  3216. }
  3217. $totals = '<div style="margin: 10px;" class="sort-todo pull-right">
  3218. <span class="badge gray-bg"><i class="fa fa-film fa-2x white"></i><strong style="
  3219. font-size: 23px;
  3220. ">&nbsp;'.$movies.'</strong></span>
  3221. <span class="badge gray-bg"><i class="fa fa-tv fa-2x white"></i><strong style="
  3222. font-size: 23px;
  3223. ">&nbsp;'.$shows.'</strong></span>
  3224. <span class="badge gray-bg"><i class="fa fa-music fa-2x white"></i><strong style="
  3225. font-size: 23px;
  3226. ">&nbsp;'.$albums.'</strong></span>
  3227. </div>';
  3228. return (!empty($items) ? $totals.$pre.$items."</div></table>" : "<h2 class='text-center'>No Results for $query</h2>" );
  3229. }
  3230. function getBannedUsers($string){
  3231. if (strpos($string, ',') !== false) {
  3232. $banned = explode(",", $string);
  3233. }else{
  3234. $banned = array($string);
  3235. }
  3236. return $banned;
  3237. }
  3238. function getWhitelist($string){
  3239. if (strpos($string, ',') !== false) {
  3240. $whitelist = explode(",", $string);
  3241. }else{
  3242. $whitelist = array($string);
  3243. }
  3244. foreach($whitelist as &$ip){
  3245. $ip = is_numeric(substr($ip, 0, 1)) ? $ip : gethostbyname($ip);
  3246. }
  3247. return $whitelist;
  3248. }
  3249. function get_client_ip() {
  3250. $ipaddress = '';
  3251. if (isset($_SERVER['HTTP_CLIENT_IP']))
  3252. $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
  3253. else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  3254. $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
  3255. else if(isset($_SERVER['HTTP_X_FORWARDED']))
  3256. $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
  3257. else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
  3258. $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
  3259. else if(isset($_SERVER['HTTP_FORWARDED']))
  3260. $ipaddress = $_SERVER['HTTP_FORWARDED'];
  3261. else if(isset($_SERVER['REMOTE_ADDR']))
  3262. $ipaddress = $_SERVER['REMOTE_ADDR'];
  3263. else
  3264. $ipaddress = 'UNKNOWN';
  3265. return $ipaddress;
  3266. }
  3267. //EMAIL SHIT
  3268. function sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null){
  3269. $mail = new PHPMailer;
  3270. $mail->isSMTP();
  3271. $mail->Host = SMTPHOST;
  3272. $mail->SMTPAuth = SMTPHOSTAUTH;
  3273. $mail->Username = SMTPHOSTUSERNAME;
  3274. $mail->Password = SMTPHOSTPASSWORD;
  3275. $mail->SMTPSecure = SMTPHOSTTYPE;
  3276. $mail->Port = SMTPHOSTPORT;
  3277. $mail->setFrom(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3278. $mail->addReplyTo(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3279. $mail->isHTML(true);
  3280. if($email){
  3281. $mail->addAddress($email, $username);
  3282. }
  3283. if($cc){
  3284. $mail->addCC($cc);
  3285. }
  3286. if($bcc){
  3287. if(strpos($bcc , ',') === false){
  3288. $mail->addBCC($bcc);
  3289. }else{
  3290. $allEmails = explode(",",$bcc);
  3291. foreach($allEmails as $gotEmail){
  3292. $mail->addBCC($gotEmail);
  3293. }
  3294. }
  3295. }
  3296. $mail->Subject = $subject;
  3297. $mail->Body = $body;
  3298. //$mail->send();
  3299. if(!$mail->send()) {
  3300. writeLog("error", "mail failed to send");
  3301. } else {
  3302. writeLog("success", "mail has been sent");
  3303. }
  3304. }
  3305. //EMAIL SHIT
  3306. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  3307. $mail = new PHPMailer;
  3308. $mail->isSMTP();
  3309. $mail->Host = $host;
  3310. $mail->SMTPAuth = $auth;
  3311. $mail->Username = $username;
  3312. $mail->Password = $password;
  3313. $mail->SMTPSecure = $type;
  3314. $mail->Port = $port;
  3315. $mail->setFrom($from, $sendername);
  3316. $mail->addReplyTo($from, $sendername);
  3317. $mail->isHTML(true);
  3318. $mail->addAddress($to, "Organizr Admin");
  3319. $mail->Subject = "Organizr Test E-Mail";
  3320. $mail->Body = "This was just a test!";
  3321. //$mail->send();
  3322. if(!$mail->send()) {
  3323. writeLog("error", "EMAIL TEST: mail failed to send - Error:".$mail->ErrorInfo);
  3324. return false;
  3325. } else {
  3326. writeLog("success", "EMAIL TEST: mail has been sent successfully");
  3327. return true;
  3328. }
  3329. }
  3330. function libraryList(){
  3331. $address = qualifyURL(PLEXURL);
  3332. $headers = array(
  3333. "Accept" => "application/json",
  3334. "X-Plex-Token" => PLEXTOKEN
  3335. );
  3336. libxml_use_internal_errors(true);
  3337. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3338. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3339. $api = simplexml_load_string(@curl_get("https://plex.tv/api/servers/$gotServer/shared_servers", $headers));
  3340. $libraryList = array();
  3341. foreach($api->SharedServer->Section AS $child) {
  3342. $libraryList['libraries'][(string)$child['title']] = (string)$child['id'];
  3343. }
  3344. foreach($api->SharedServer AS $child) {
  3345. if(!empty($child['username'])){
  3346. $username = (string)strtolower($child['username']);
  3347. $email = (string)strtolower($child['email']);
  3348. $libraryList['users'][$username] = (string)$child['id'];
  3349. $libraryList['emails'][$email] = (string)$child['id'];
  3350. $libraryList['both'][$username] = $email;
  3351. }
  3352. }
  3353. return (!empty($libraryList) ? array_change_key_case($libraryList,CASE_LOWER) : null );
  3354. }
  3355. function plexUserShare($username){
  3356. $address = qualifyURL(PLEXURL);
  3357. $headers = array(
  3358. "Accept" => "application/json",
  3359. "Content-Type" => "application/json",
  3360. "X-Plex-Token" => PLEXTOKEN
  3361. );
  3362. libxml_use_internal_errors(true);
  3363. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3364. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3365. $json = array(
  3366. "server_id" => $gotServer,
  3367. "shared_server" => array(
  3368. //"library_section_ids" => "[26527637]",
  3369. "invited_email" => $username
  3370. )
  3371. );
  3372. $api = curl_post("https://plex.tv/api/servers/$gotServer/shared_servers/", $json, $headers);
  3373. switch ($api['http_code']['http_code']){
  3374. case 400:
  3375. writeLog("error", "PLEX INVITE: $username already has access to the shared libraries");
  3376. $result = "$username already has access to the shared libraries";
  3377. break;
  3378. case 401:
  3379. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3380. $result = "Invalid Plex Token";
  3381. break;
  3382. case 200:
  3383. writeLog("success", "PLEX INVITE: $username now has access to your Plex Library");
  3384. $result = "$username now has access to your Plex Library";
  3385. break;
  3386. default:
  3387. writeLog("error", "PLEX INVITE: unknown error");
  3388. $result = false;
  3389. }
  3390. return (!empty($result) ? $result : null );
  3391. }
  3392. function plexUserDelete($username){
  3393. $address = qualifyURL(PLEXURL);
  3394. $headers = array(
  3395. "Accept" => "application/json",
  3396. "Content-Type" => "application/json",
  3397. "X-Plex-Token" => PLEXTOKEN
  3398. );
  3399. libxml_use_internal_errors(true);
  3400. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3401. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3402. $id = (is_numeric($username) ? $id : convertPlexName($username, "id"));
  3403. $api = curl_delete("https://plex.tv/api/servers/$gotServer/shared_servers/$id", $headers);
  3404. switch ($api['http_code']['http_code']){
  3405. case 401:
  3406. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3407. $result = "Invalid Plex Token";
  3408. break;
  3409. case 200:
  3410. writeLog("success", "PLEX INVITE: $username doesn't have access to your Plex Library anymore");
  3411. $result = "$username doesn't have access to your Plex Library anymore";
  3412. break;
  3413. default:
  3414. writeLog("error", "PLEX INVITE: unknown error");
  3415. $result = false;
  3416. }
  3417. return (!empty($result) ? $result : null );
  3418. }
  3419. function convertPlexName($user, $type){
  3420. $array = libraryList();
  3421. switch ($type){
  3422. case "username":
  3423. $plexUser = array_search ($user, $array['users']);
  3424. break;
  3425. case "id":
  3426. if (array_key_exists(strtolower($user), $array['users'])) {
  3427. $plexUser = $array['users'][strtolower($user)];
  3428. }
  3429. break;
  3430. default:
  3431. $plexUser = false;
  3432. }
  3433. return (!empty($plexUser) ? $plexUser : null );
  3434. }
  3435. function randomCode($length = 5, $type = null) {
  3436. switch ($type){
  3437. case "alpha":
  3438. $legend = array_merge(range('A', 'Z'));
  3439. break;
  3440. case "numeric":
  3441. $legend = array_merge(range(0,9));
  3442. break;
  3443. default:
  3444. $legend = array_merge(range(0,9),range('A', 'Z'));
  3445. }
  3446. $code = "";
  3447. for($i=0; $i < $length; $i++) {
  3448. $code .= $legend[mt_rand(0, count($legend) - 1)];
  3449. }
  3450. return $code;
  3451. }
  3452. function inviteCodes($action, $code = null, $usedBy = null) {
  3453. if (!isset($GLOBALS['file_db'])) {
  3454. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  3455. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  3456. }
  3457. $now = date("Y-m-d H:i:s");
  3458. switch ($action) {
  3459. case "get":
  3460. // Start Array
  3461. $result = array();
  3462. // Database Lookup
  3463. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes"');
  3464. // Get Codes
  3465. foreach($invites as $row) {
  3466. array_push($result, $row['code']);
  3467. }
  3468. // Return the Results
  3469. return (!empty($result) ? $result : false );
  3470. break;
  3471. case "check":
  3472. // Start Array
  3473. $result = array();
  3474. // Database Lookup
  3475. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes" AND code = "'.$code.'"');
  3476. // Get Codes
  3477. foreach($invites as $row) {
  3478. $result = $row['code'];
  3479. }
  3480. // Return the Results
  3481. return (!empty($result) ? $result : false );
  3482. break;
  3483. case "use":
  3484. $currentIP = get_client_ip();
  3485. $invites = $GLOBALS['file_db']->query('UPDATE invites SET valid = "No", usedby = "'.$usedBy.'", dateused = "'.$now.'", ip = "'.$currentIP.'" WHERE code = "'.$code.'"');
  3486. if(ENABLEMAIL){
  3487. if (!isset($GLOBALS['USER'])) {
  3488. require_once("user.php");
  3489. $GLOBALS['USER'] = new User('registration_callback');
  3490. }
  3491. sendEmail($GLOBALS['USER']->adminEmail, "Admin", "Plex Invite Used", orgEmail("PLEX Invite Used", "Look who joined the cool club", "Admin", "Hey, The User: $usedBy has redeemd their invite code: [$code], their IP Address was: $currentIP", null, null, "What Next?", "Well, That is up to you. You can go check on them if you like."));
  3492. }
  3493. return (!empty($invites) ? true : false );
  3494. break;
  3495. }
  3496. }
  3497. function plexJoin($username, $email, $password){
  3498. $connectURL = 'https://plex.tv/users.json';
  3499. $headers = array(
  3500. 'Accept'=> 'application/json',
  3501. 'Content-Type' => 'application/x-www-form-urlencoded',
  3502. 'X-Plex-Product' => 'Organizr',
  3503. 'X-Plex-Version' => '1.0',
  3504. 'X-Plex-Client-Identifier' => '01010101-10101010',
  3505. );
  3506. $body = array(
  3507. 'user[email]' => $email,
  3508. 'user[username]' => $username,
  3509. 'user[password]' => $password,
  3510. );
  3511. $api = curl_post($connectURL, $body, $headers);
  3512. $json = json_decode($api['content'], true);
  3513. $errors = (!empty($json['errors']) ? true : false);
  3514. $success = (!empty($json['user']) ? true : false);
  3515. //Use This for later
  3516. $usernameError = (!empty($json['errors']['username']) ? $json['errors']['username'][0] : false);
  3517. $emailError = (!empty($json['errors']['email']) ? $json['errors']['email'][0] : false);
  3518. $passwordError = (!empty($json['errors']['password']) ? $json['errors']['password'][0] : false);
  3519. $errorMessage = "";
  3520. if($errors){
  3521. if($usernameError){ $errorMessage .= "[Username Error: ". $usernameError ."]"; }
  3522. if($emailError){ $errorMessage .= "[Email Error: ". $emailError ."]"; }
  3523. if($passwordError){ $errorMessage .= "[Password Error: ". $passwordError ."]"; }
  3524. }
  3525. switch ($api['http_code']['http_code']){
  3526. case 400:
  3527. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." $username already has access to the shared libraries $errorMessage");
  3528. break;
  3529. case 401:
  3530. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." invalid Plex Token $errorMessage");
  3531. break;
  3532. case 422:
  3533. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." user info error $errorMessage");
  3534. break;
  3535. case 429:
  3536. writeLog("error", "PLEX JOIN: Error: ".$api['http_code']['http_code']." too many requests to plex.tv please try later $errorMessage");
  3537. break;
  3538. case 200:
  3539. case 201:
  3540. writeLog("success", "PLEX JOIN: $username now has access to your Plex Library");
  3541. break;
  3542. default:
  3543. writeLog("error", "PLEX JOIN: unknown error, $errorMessage Error: ".$api['http_code']['http_code']);
  3544. }
  3545. //prettyPrint($api);
  3546. //prettyPrint(json_decode($api['content'], true));
  3547. return (!empty($success) && empty($errors) ? true : false );
  3548. }
  3549. function getCert(){
  3550. $url = "http://curl.haxx.se/ca/cacert.pem";
  3551. $file = getcwd()."/config/cacert.pem";
  3552. $directory = getcwd()."/config/";
  3553. @mkdir($directory, 0770, true);
  3554. if(!file_exists($file)){
  3555. file_put_contents( $file, fopen($url, 'r'));
  3556. writeLog("success", "CERT PEM: pem file created");
  3557. }elseif (file_exists($file) && time() - 2592000 > filemtime($file)) {
  3558. file_put_contents( $file, fopen($url, 'r'));
  3559. writeLog("success", "CERT PEM: downloaded new pem file");
  3560. }
  3561. return $file;
  3562. }
  3563. function customCSS(){
  3564. if(CUSTOMCSS == "true") {
  3565. $template_file = "custom.css";
  3566. $file_handle = fopen($template_file, "rb");
  3567. echo "\n";
  3568. echo fread($file_handle, filesize($template_file));
  3569. fclose($file_handle);
  3570. echo "\n";
  3571. }
  3572. }
  3573. function tvdbToken(){
  3574. $headers = array(
  3575. "Accept" => "application/json",
  3576. "Content-Type" => "application/json"
  3577. );
  3578. $json = array(
  3579. "apikey" => "FBE7B62621F4CAD7",
  3580. "userkey" => "328BB46EB1E9A0F5",
  3581. "username" => "causefx"
  3582. );
  3583. $api = curl_post("https://api.thetvdb.com/login", $json, $headers);
  3584. return json_decode($api['content'], true)['token'];
  3585. }
  3586. function tvdbGet($id){
  3587. $headers = array(
  3588. "Accept" => "application/json",
  3589. "Authorization" => "Bearer ".tvdbToken(),
  3590. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3591. "trakt-api-version" => "2"
  3592. );
  3593. $trakt = curl_get("https://api.trakt.tv/search/tvdb/$id?type=show", $headers);
  3594. @$api['trakt'] = json_decode($trakt, true)[0]['show']['ids'];
  3595. if(empty($api['trakt'])){
  3596. $series = curl_get("https://api.thetvdb.com/series/$id", $headers);
  3597. $poster = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=poster", $headers);
  3598. $backdrop = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=fanart", $headers);
  3599. $api['series'] = json_decode($series, true)['data'];
  3600. $api['poster'] = json_decode($poster, true)['data'];
  3601. $api['backdrop'] = json_decode($backdrop, true)['data'];
  3602. }
  3603. return $api;
  3604. }
  3605. function tvdbSearch($name, $type){
  3606. $name = rawurlencode(preg_replace("/\(([^()]*+|(?R))*\)/","", $name));
  3607. $headers = array(
  3608. "Accept" => "application/json",
  3609. "Authorization" => "Bearer ".tvdbToken(),
  3610. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3611. "trakt-api-version" => "2"
  3612. );
  3613. $trakt = curl_get("https://api.trakt.tv/search/$type?query=$name", $headers);
  3614. @$api['trakt'] = json_decode($trakt, true)[0][$type]['ids'];
  3615. return $api;
  3616. }
  3617. function getPlexPlaylists(){
  3618. $address = qualifyURL(PLEXURL);
  3619. // Perform API requests
  3620. $api = @curl_get($address."/playlists?X-Plex-Token=".PLEXTOKEN);
  3621. libxml_use_internal_errors(true);
  3622. $api = simplexml_load_string($api);
  3623. if (is_array($api) || is_object($api)){
  3624. if (!$api->head->title){
  3625. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3626. if (!$getServer) { return 'Could not load!'; }
  3627. // Identify the local machine
  3628. $gotServer = $getServer['machineIdentifier'];
  3629. $output = "";
  3630. $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">';
  3631. foreach($api AS $child) {
  3632. $items = array();
  3633. if ($child['playlistType'] == "video" && strpos(strtolower($child['title']) , 'private') === false){
  3634. $api = @curl_get($address.$child['key']."?X-Plex-Token=".PLEXTOKEN);
  3635. $api = simplexml_load_string($api);
  3636. if (is_array($api) || is_object($api)){
  3637. if (!$api->head->title){
  3638. $className = preg_replace("/(\W)+/", "", $api['title']);
  3639. $hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  3640. foreach($api->Video AS $child){
  3641. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false,false,$className);
  3642. }
  3643. if (count($items)) {
  3644. $output .= ''.implode('',$items).'';
  3645. }
  3646. }
  3647. }
  3648. }
  3649. }
  3650. $hideMenu .= '</ul></div></div>';
  3651. 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>';
  3652. }else{
  3653. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check token - if HTTPS, is cert valid");
  3654. }
  3655. }else{
  3656. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check URL - if HTTPS, is cert valid");
  3657. }
  3658. }
  3659. function readExternalLog($type,$filename,$name = null){
  3660. $log = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3661. $log = array_reverse($log);
  3662. foreach($log as $line){
  3663. if(!empty($line) && $line[0] != " "){
  3664. $line = strip($line);
  3665. if($type == "single"){
  3666. if( strpos( strtolower($line), "ror" ) !== false ) {
  3667. echo "<tr><td class='red-bg'>".$line."</td></tr>";
  3668. }else{
  3669. echo "<tr><td>".$line."</td></tr>";
  3670. }
  3671. }elseif($type == "all"){
  3672. if( strpos( strtolower($line), "ror" ) !== false ) {
  3673. echo "<tr><td class='red-bg'>".$name."</td>";
  3674. echo "<td class='red-bg'>".$line."</td></tr>";
  3675. }else{
  3676. echo "<tr><td>".$name."</td>";
  3677. echo "<td>".$line."</td></tr>";
  3678. }
  3679. }
  3680. }
  3681. }
  3682. }
  3683. function getLogs(){
  3684. $path = __DIR__ ."/logs/";
  3685. @mkdir($path, 0770, true);
  3686. $logs = array();
  3687. $files = array_diff(scandir($path), array('.', '..'));
  3688. foreach($files as $v){
  3689. $title = explode(".", $v)[0];
  3690. $logs[$title] = $path.$v;
  3691. }
  3692. return $logs;
  3693. }
  3694. function getBackups(){
  3695. $path = DATABASE_LOCATION ."backups/";
  3696. @mkdir($path, 0770, true);
  3697. $backups = array();
  3698. $files = array_diff(scandir($path), array('.', '..'));
  3699. return array_reverse($files);
  3700. }
  3701. function getExtension($string) {
  3702. return preg_replace("#(.+)?\.(\w+)(\?.+)?#", "$2", $string);
  3703. }
  3704. function showFile(){
  3705. $file = $_GET['file'];
  3706. $fileType = getExtension($file);
  3707. if($fileType != 'php'){
  3708. header("Content-type: ".mimeTypes()[$fileType]);
  3709. @readfile($file);
  3710. }
  3711. }
  3712. function getCalendar(){
  3713. $sonarr = new Sonarr(SONARRURL, SONARRKEY);
  3714. $radarr = new Sonarr(RADARRURL, RADARRKEY);
  3715. $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
  3716. $startDate = date('Y-m-d',strtotime("-".CALENDARSTARTDAY." days"));
  3717. $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
  3718. $calendarItems = array();
  3719. if (SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)){
  3720. try {
  3721. $sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate));
  3722. if(!empty($sonarrCalendar)) { $calendarItems = array_merge($calendarItems, $sonarrCalendar); }
  3723. } catch (Exception $e) {
  3724. writeLog("error", "SONARR ERROR: ".strip($e->getMessage()));
  3725. }
  3726. }
  3727. if (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)){
  3728. try {
  3729. $radarrCalendar = getRadarrCalendar($radarr->getCalendar($startDate, $endDate));
  3730. if(!empty($radarrCalendar)) { $calendarItems = array_merge($calendarItems, $radarrCalendar); }
  3731. } catch (Exception $e) {
  3732. writeLog("error", "RADARR ERROR: ".strip($e->getMessage()));
  3733. }
  3734. }
  3735. if (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH)){
  3736. $couchCalendar = getCouchCalendar();
  3737. if(!empty($couchCalendar)) { $calendarItems = array_merge($calendarItems, $couchCalendar); }
  3738. }
  3739. if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
  3740. $headphonesHistory = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory");
  3741. $headphonesWanted = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted");
  3742. if(!empty($headphonesHistory)) { $calendarItems = array_merge($calendarItems, $headphonesHistory); }
  3743. if(!empty($headphonesWanted)) { $calendarItems = array_merge($calendarItems, $headphonesWanted); }
  3744. }
  3745. if (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)){
  3746. try {
  3747. $sickrageFuture = getSickrageCalendarWanted($sickrage->future());
  3748. if(!empty($sickrageFuture)) { $calendarItems = array_merge($calendarItems, $sickrageFuture); }
  3749. } catch (Exception $e) {
  3750. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3751. } try {
  3752. $sickrageHistory = getSickrageCalendarHistory($sickrage->history("100","downloaded"));
  3753. if(!empty($sickrageHistory)) { $calendarItems = array_merge($calendarItems, $sickrageHistory); }
  3754. } catch (Exception $e) {
  3755. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3756. }
  3757. }
  3758. return $calendarItems;
  3759. }
  3760. function localURL($url){
  3761. if (strpos($url, 'https') !== false) {
  3762. preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $url, $result);
  3763. $result = (!empty($result) ? true : false);
  3764. return $result;
  3765. }
  3766. }
  3767. function fileArray($files){
  3768. foreach($files as $file){
  3769. if(file_exists($file)){
  3770. $list[] = $file;
  3771. }
  3772. }
  3773. if(!empty($list)){ return $list; }
  3774. }
  3775. function backupDB(){
  3776. if (extension_loaded('ZIP')) {
  3777. $directory = DATABASE_LOCATION."backups/";
  3778. @mkdir($directory, 0770, true);
  3779. $orgFiles = array(
  3780. 'css' => 'custom.css',
  3781. 'temp' => 'cus.sd',
  3782. 'orgLog' => 'org.log',
  3783. 'loginLog' => 'loginLog.json',
  3784. 'chatDB' => 'chatpack.db',
  3785. 'config' => 'config/config.php',
  3786. 'database' => DATABASE_LOCATION.'users.db'
  3787. );
  3788. $files = fileArray($orgFiles);
  3789. if(!empty($files)){
  3790. writeLog("success", "BACKUP: backup process started");
  3791. $zipname = $directory.'backup['.date('Y-m-d_H-i').']['.INSTALLEDVERSION.'].zip';
  3792. $zip = new ZipArchive;
  3793. $zip->open($zipname, ZipArchive::CREATE);
  3794. foreach ($files as $file) {
  3795. $zip->addFile($file);
  3796. }
  3797. $zip->close();
  3798. writeLog("success", "BACKUP: backup process finished");
  3799. return true;
  3800. }else{
  3801. return false;
  3802. }
  3803. }else{
  3804. return false;
  3805. }
  3806. }
  3807. class Ping {
  3808. private $host;
  3809. private $ttl;
  3810. private $timeout;
  3811. private $port = 80;
  3812. private $data = 'Ping';
  3813. private $commandOutput;
  3814. /**
  3815. * Called when the Ping object is created.
  3816. *
  3817. * @param string $host
  3818. * The host to be pinged.
  3819. * @param int $ttl
  3820. * Time-to-live (TTL) (You may get a 'Time to live exceeded' error if this
  3821. * value is set too low. The TTL value indicates the scope or range in which
  3822. * a packet may be forwarded. By convention:
  3823. * - 0 = same host
  3824. * - 1 = same subnet
  3825. * - 32 = same site
  3826. * - 64 = same region
  3827. * - 128 = same continent
  3828. * - 255 = unrestricted
  3829. * @param int $timeout
  3830. * Timeout (in seconds) used for ping and fsockopen().
  3831. * @throws \Exception if the host is not set.
  3832. */
  3833. public function __construct($host, $ttl = 255, $timeout = 10) {
  3834. if (!isset($host)) {
  3835. throw new \Exception("Error: Host name not supplied.");
  3836. }
  3837. $this->host = $host;
  3838. $this->ttl = $ttl;
  3839. $this->timeout = $timeout;
  3840. }
  3841. /**
  3842. * Set the ttl (in hops).
  3843. *
  3844. * @param int $ttl
  3845. * TTL in hops.
  3846. */
  3847. public function setTtl($ttl) {
  3848. $this->ttl = $ttl;
  3849. }
  3850. /**
  3851. * Get the ttl.
  3852. *
  3853. * @return int
  3854. * The current ttl for Ping.
  3855. */
  3856. public function getTtl() {
  3857. return $this->ttl;
  3858. }
  3859. /**
  3860. * Set the timeout.
  3861. *
  3862. * @param int $timeout
  3863. * Time to wait in seconds.
  3864. */
  3865. public function setTimeout($timeout) {
  3866. $this->timeout = $timeout;
  3867. }
  3868. /**
  3869. * Get the timeout.
  3870. *
  3871. * @return int
  3872. * Current timeout for Ping.
  3873. */
  3874. public function getTimeout() {
  3875. return $this->timeout;
  3876. }
  3877. /**
  3878. * Set the host.
  3879. *
  3880. * @param string $host
  3881. * Host name or IP address.
  3882. */
  3883. public function setHost($host) {
  3884. $this->host = $host;
  3885. }
  3886. /**
  3887. * Get the host.
  3888. *
  3889. * @return string
  3890. * The current hostname for Ping.
  3891. */
  3892. public function getHost() {
  3893. return $this->host;
  3894. }
  3895. /**
  3896. * Set the port (only used for fsockopen method).
  3897. *
  3898. * Since regular pings use ICMP and don't need to worry about the concept of
  3899. * 'ports', this is only used for the fsockopen method, which pings servers by
  3900. * checking port 80 (by default).
  3901. *
  3902. * @param int $port
  3903. * Port to use for fsockopen ping (defaults to 80 if not set).
  3904. */
  3905. public function setPort($port) {
  3906. $this->port = $port;
  3907. }
  3908. /**
  3909. * Get the port (only used for fsockopen method).
  3910. *
  3911. * @return int
  3912. * The port used by fsockopen pings.
  3913. */
  3914. public function getPort() {
  3915. return $this->port;
  3916. }
  3917. /**
  3918. * Return the command output when method=exec.
  3919. * @return string
  3920. */
  3921. public function getCommandOutput(){
  3922. return $this->commandOutput;
  3923. }
  3924. /**
  3925. * Matches an IP on command output and returns.
  3926. * @return string
  3927. */
  3928. public function getIpAddress() {
  3929. $out = array();
  3930. if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $this->commandOutput, $out)){
  3931. return $out[0];
  3932. }
  3933. return null;
  3934. }
  3935. /**
  3936. * Ping a host.
  3937. *
  3938. * @param string $method
  3939. * Method to use when pinging:
  3940. * - exec (default): Pings through the system ping command. Fast and
  3941. * robust, but a security risk if you pass through user-submitted data.
  3942. * - fsockopen: Pings a server on port 80.
  3943. * - socket: Creates a RAW network socket. Only usable in some
  3944. * environments, as creating a SOCK_RAW socket requires root privileges.
  3945. *
  3946. * @throws InvalidArgumentException if $method is not supported.
  3947. *
  3948. * @return mixed
  3949. * Latency as integer, in ms, if host is reachable or FALSE if host is down.
  3950. */
  3951. public function ping($method = 'exec') {
  3952. $latency = false;
  3953. switch ($method) {
  3954. case 'exec':
  3955. $latency = $this->pingExec();
  3956. break;
  3957. case 'fsockopen':
  3958. $latency = $this->pingFsockopen();
  3959. break;
  3960. case 'socket':
  3961. $latency = $this->pingSocket();
  3962. break;
  3963. default:
  3964. throw new \InvalidArgumentException('Unsupported ping method.');
  3965. }
  3966. // Return the latency.
  3967. return $latency;
  3968. }
  3969. /**
  3970. * The exec method uses the possibly insecure exec() function, which passes
  3971. * the input to the system. This is potentially VERY dangerous if you pass in
  3972. * any user-submitted data. Be SURE you sanitize your inputs!
  3973. *
  3974. * @return int
  3975. * Latency, in ms.
  3976. */
  3977. private function pingExec() {
  3978. $latency = false;
  3979. $ttl = escapeshellcmd($this->ttl);
  3980. $timeout = escapeshellcmd($this->timeout);
  3981. $host = escapeshellcmd($this->host);
  3982. // Exec string for Windows-based systems.
  3983. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  3984. // -n = number of pings; -i = ttl; -w = timeout (in milliseconds).
  3985. $exec_string = 'ping -n 1 -i ' . $ttl . ' -w ' . ($timeout * 1000) . ' ' . $host;
  3986. }
  3987. // Exec string for Darwin based systems (OS X).
  3988. else if(strtoupper(PHP_OS) === 'DARWIN') {
  3989. // -n = numeric output; -c = number of pings; -m = ttl; -t = timeout.
  3990. $exec_string = 'ping -n -c 1 -m ' . $ttl . ' -t ' . $timeout . ' ' . $host;
  3991. }
  3992. // Exec string for other UNIX-based systems (Linux).
  3993. else {
  3994. // -n = numeric output; -c = number of pings; -t = ttl; -W = timeout
  3995. $exec_string = 'ping -n -c 1 -t ' . $ttl . ' -W ' . $timeout . ' ' . $host . ' 2>&1';
  3996. }
  3997. exec($exec_string, $output, $return);
  3998. // Strip empty lines and reorder the indexes from 0 (to make results more
  3999. // uniform across OS versions).
  4000. $this->commandOutput = implode($output, '');
  4001. $output = array_values(array_filter($output));
  4002. // If the result line in the output is not empty, parse it.
  4003. if (!empty($output[1])) {
  4004. // Search for a 'time' value in the result line.
  4005. $response = preg_match("/time(?:=|<)(?<time>[\.0-9]+)(?:|\s)ms/", $output[1], $matches);
  4006. // If there's a result and it's greater than 0, return the latency.
  4007. if ($response > 0 && isset($matches['time'])) {
  4008. $latency = round($matches['time'], 2);
  4009. }
  4010. }
  4011. return $latency;
  4012. }
  4013. /**
  4014. * The fsockopen method simply tries to reach the host on a port. This method
  4015. * is often the fastest, but not necessarily the most reliable. Even if a host
  4016. * doesn't respond, fsockopen may still make a connection.
  4017. *
  4018. * @return int
  4019. * Latency, in ms.
  4020. */
  4021. private function pingFsockopen() {
  4022. $start = microtime(true);
  4023. // fsockopen prints a bunch of errors if a host is unreachable. Hide those
  4024. // irrelevant errors and deal with the results instead.
  4025. $fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
  4026. if (!$fp) {
  4027. $latency = false;
  4028. }
  4029. else {
  4030. $latency = microtime(true) - $start;
  4031. $latency = round($latency * 1000, 2);
  4032. }
  4033. return $latency;
  4034. }
  4035. /**
  4036. * The socket method uses raw network packet data to try sending an ICMP ping
  4037. * packet to a server, then measures the response time. Using this method
  4038. * requires the script to be run with root privileges, though, so this method
  4039. * only works reliably on Windows systems and on Linux servers where the
  4040. * script is not being run as a web user.
  4041. *
  4042. * @return int
  4043. * Latency, in ms.
  4044. */
  4045. private function pingSocket() {
  4046. // Create a package.
  4047. $type = "\x08";
  4048. $code = "\x00";
  4049. $checksum = "\x00\x00";
  4050. $identifier = "\x00\x00";
  4051. $seq_number = "\x00\x00";
  4052. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4053. // Calculate the checksum.
  4054. $checksum = $this->calculateChecksum($package);
  4055. // Finalize the package.
  4056. $package = $type . $code . $checksum . $identifier . $seq_number . $this->data;
  4057. // Create a socket, connect to server, then read socket and calculate.
  4058. if ($socket = socket_create(AF_INET, SOCK_RAW, 1)) {
  4059. socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array(
  4060. 'sec' => 10,
  4061. 'usec' => 0,
  4062. ));
  4063. // Prevent errors from being printed when host is unreachable.
  4064. @socket_connect($socket, $this->host, null);
  4065. $start = microtime(true);
  4066. // Send the package.
  4067. @socket_send($socket, $package, strlen($package), 0);
  4068. if (socket_read($socket, 255) !== false) {
  4069. $latency = microtime(true) - $start;
  4070. $latency = round($latency * 1000, 2);
  4071. }
  4072. else {
  4073. $latency = false;
  4074. }
  4075. }
  4076. else {
  4077. $latency = false;
  4078. }
  4079. // Close the socket.
  4080. socket_close($socket);
  4081. return $latency;
  4082. }
  4083. /**
  4084. * Calculate a checksum.
  4085. *
  4086. * @param string $data
  4087. * Data for which checksum will be calculated.
  4088. *
  4089. * @return string
  4090. * Binary string checksum of $data.
  4091. */
  4092. private function calculateChecksum($data) {
  4093. if (strlen($data) % 2) {
  4094. $data .= "\x00";
  4095. }
  4096. $bit = unpack('n*', $data);
  4097. $sum = array_sum($bit);
  4098. while ($sum >> 16) {
  4099. $sum = ($sum >> 16) + ($sum & 0xffff);
  4100. }
  4101. return pack('n*', ~$sum);
  4102. }
  4103. }
  4104. function ping($pings, $type = "string") {
  4105. $ping = new Ping("");
  4106. $ping->setTtl(128);
  4107. $ping->setTimeout(2);
  4108. switch ($type){
  4109. case "array":
  4110. $results = [];
  4111. foreach ($pings as $k => $v) {
  4112. if(strpos($v, ':') !== false){
  4113. $domain = explode(':', $v)[0];
  4114. $port = explode(':', $v)[1];
  4115. $ping->setHost($domain);
  4116. $ping->setPort($port);
  4117. $latency = $ping->ping('fsockopen');
  4118. }else{
  4119. $ping->setHost($v);
  4120. $latency = $ping->ping();
  4121. }
  4122. if ($latency || $latency === 0) {
  4123. $results[$k] = $latency;
  4124. } else {
  4125. $results[$k] = 0;
  4126. }
  4127. }
  4128. break;
  4129. case "string":
  4130. if(strpos($pings, ':') !== false){
  4131. $domain = explode(':', $pings)[0];
  4132. $port = explode(':', $pings)[1];
  4133. $ping->setHost($domain);
  4134. $ping->setPort($port);
  4135. $latency = $ping->ping('fsockopen');
  4136. }else{
  4137. $ping->setHost($pings);
  4138. $latency = $ping->ping();
  4139. }
  4140. if ($latency || $latency === 0) {
  4141. $results = $latency;
  4142. } else {
  4143. $results = 0;
  4144. }
  4145. break;
  4146. }
  4147. return $results;
  4148. }
  4149. function getPing($url, $style, $refresh = null){
  4150. if(ping($url) !== 0){
  4151. $class = 'success';
  4152. if(!$refresh){
  4153. $class .= " animated slideInLeft";
  4154. }
  4155. }else{
  4156. $class = "warning";
  4157. if(!$refresh){
  4158. $class .= " animated flash loop-animation-timeout";
  4159. }
  4160. }
  4161. echo '<span class="pingcheck badge ping-'.$class.'" style="position: absolute;z-index: 100;right: 5px; padding: 0px 0px;'.$style.';font-size: 10px;">&nbsp;</span>';
  4162. }
  4163. function speedTestData(){
  4164. $file_db = DATABASE_LOCATION."speedtest.db";
  4165. if(file_exists($file_db)){
  4166. $conn = new PDO("sqlite:$file_db") or die("1");
  4167. $result = $conn->query('SELECT * FROM speedtest_users');
  4168. $conn = null;
  4169. if (is_array($result) || is_object($result)){
  4170. foreach($result as $k => $v){
  4171. $return[$k] = $v;
  4172. }
  4173. return $return;
  4174. }
  4175. }
  4176. }
  4177. function speedTestDisplay($array, $output){
  4178. if (is_array($array) || is_object($array)){
  4179. if($output == "graph"){
  4180. $result = "Morris.Line({element: 'morris-line',data: [";
  4181. foreach($array as $k => $v){
  4182. $result .= "{ y: '".substr($v['timestamp'],0,10)."', a: ".$v['ul'].", b: ".$v['dl'].", c: ".$v['ping']." },";
  4183. }
  4184. $result .= "],xkey: 'y',ykeys: ['a', 'b', 'c'],labels: ['Upload', 'Download', 'Ping'],hideHover: 'auto',resize: true,lineColors: ['#63A8EB','#ccc','#000'] });";
  4185. }elseif($output == "table"){
  4186. $result = "";
  4187. foreach($array as $k => $v){
  4188. $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>";
  4189. }
  4190. }
  4191. return $result;
  4192. }
  4193. }
  4194. function buildMenuPhone($array){
  4195. if (is_array($array) || is_object($array)){
  4196. $result = '
  4197. <div class="content-box profile-sidebar box-shadow">
  4198. <img src="images/organizr-logo-h-d.png" width="100%" style="margin-top: -10px;">
  4199. <div class="profile-usermenu">
  4200. <ul class="nav" id="settings-list">
  4201. ';
  4202. foreach($array as $k => $v){
  4203. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4204. continue;
  4205. }
  4206. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4207. continue;
  4208. }
  4209. /*$result .= '
  4210. <li>
  4211. <a id="'.$v['id'].'" box="'.$v['box'].'">'.$v['name'].'
  4212. <span class="fa-stack fa-fw pull-right" style="margin-top: -5px;margin-right: -10px;">
  4213. <i class="fa fa-'.$v['icon_1'].' fa-stack-2x '.$v['color'].'" style="font-size:null;"></i>
  4214. <i class="fa fa-'.$v['icon_2'].' fa-stack-1x fa-inverse"></i>
  4215. </span>
  4216. </a>
  4217. </li>
  4218. ';*/
  4219. $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>';
  4220. }
  4221. $result .= '</ul></div></div>';
  4222. return $result;
  4223. }
  4224. }
  4225. function buildMenu($array){
  4226. if (is_array($array) || is_object($array)){
  4227. $result = '<div class="settingsList">';
  4228. foreach($array as $k => $v){
  4229. if($v['id'] == 'open-invites' && empty(PLEXURL)){
  4230. continue;
  4231. }
  4232. if($v['id'] == 'open-email' && ENABLEMAIL !== "true"){
  4233. continue;
  4234. }
  4235. $result .= '
  4236. <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">
  4237. <i class="mdi mdi-'.$v['icon_1'].' fa-fw pull-left" style="padding-left: '.$v['padding'].'px;font-size: 30px"></i>
  4238. <p class="" style="text-align: center;direction: rtl;display:none;margin: 2px;"><strong>'.$v['name'].'</strong></p>
  4239. </button>
  4240. ';
  4241. }
  4242. $result .= '</div>';
  4243. return $result;
  4244. }
  4245. }
  4246. function requestInvite($email, $username){
  4247. //sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null){
  4248. //orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  4249. 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."));
  4250. }
  4251. function errormessage($msg) {
  4252. echo "<div style=\"margin-top: 50px;\">";
  4253. echo "<span style=\"color:#d89334;\">error </span>";
  4254. echo $msg;
  4255. echo "</div>";
  4256. }
  4257. function getOrgUsers(){
  4258. $file_db = DATABASE_LOCATION."users.db";
  4259. if(file_exists($file_db)){
  4260. $conn = new PDO("sqlite:$file_db") or die("1");
  4261. $result = $conn->query('SELECT * FROM users');
  4262. $conn = null;
  4263. if (is_array($result) || is_object($result)){
  4264. foreach($result as $k => $v){
  4265. $return[$v['username']] = $v['email'];
  4266. }
  4267. return $return;
  4268. }
  4269. }
  4270. }
  4271. function getEmails($type = 'org'){
  4272. if($type == 'plex'){
  4273. $emails = array_merge(libraryList()['both'],getOrgUsers());
  4274. }elseif($type == 'emby'){
  4275. $emails = getOrgUsers();
  4276. }else{
  4277. $emails = getOrgUsers();
  4278. }
  4279. return $emails;
  4280. }
  4281. function printEmails($emails){
  4282. $result = '';
  4283. foreach($emails as $k => $v){
  4284. $result .= '<option value="'.$v.'">'.$k.'</option>';
  4285. }
  4286. return $result;
  4287. }
  4288. function massEmail($to, $subject, $message){
  4289. if (!isset($GLOBALS['file_db'])) {
  4290. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  4291. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  4292. }
  4293. sendEmail(null, null, $subject, orgEmail("Message From Admin", "Important Information", "There", $message, null, null, "Thank You!", "Thanks for taking the time to read this message from me."),$GLOBALS['USER']->adminEmail,$to);
  4294. }
  4295. function q2a($q){
  4296. if (is_array($q) || is_object($q)){
  4297. foreach ($q as $k => $v){
  4298. $a[$k] = $v;
  4299. }
  4300. if(!empty($a)){
  4301. return $a;
  4302. }
  4303. }
  4304. }
  4305. function getOmbiToken($username, $password){
  4306. $headers = array(
  4307. "Accept" => "application/json",
  4308. "Content-Type" => "application/json"
  4309. );
  4310. $json = array(
  4311. "username" => $username,
  4312. "password" => $password,
  4313. "rememberMe" => "true",
  4314. );
  4315. $api = curl_post(OMBIURL."/api/v1/Token", $json, $headers);
  4316. return json_decode($api['content'], true)['access_token'];
  4317. }
  4318. function ombiAction($id, $action, $type){
  4319. $headers = array(
  4320. "Accept" => "application/json",
  4321. "Content-Type" => "application/json",
  4322. "Apikey" => OMBIKEY
  4323. );
  4324. $body = array(
  4325. 'id' => $id,
  4326. );
  4327. switch ($type) {
  4328. case 'season':
  4329. case 'tv':
  4330. $type = 'tv';
  4331. break;
  4332. default:
  4333. $type = 'movie';
  4334. break;
  4335. }
  4336. switch ($action) {
  4337. case 'approve':
  4338. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/approve", $body, $headers);
  4339. break;
  4340. case 'deny':
  4341. $api = curl_put(OMBIURL."/api/v1/Request/".$type."/deny", $body, $headers);
  4342. break;
  4343. case 'delete':
  4344. $api = curl_delete(OMBIURL."/api/v1/Request/".$type."/".$id, $headers);
  4345. break;
  4346. default:
  4347. # code...
  4348. break;
  4349. }
  4350. switch ($api['http_code']['http_code']){
  4351. case 401:
  4352. writeLog("error", "OMBI: Invalid API KEY");
  4353. return false;
  4354. break;
  4355. case 200:
  4356. writeLog("success", "OMBI: action completed successfully for [type: $type - action: $action - id: $id]");
  4357. return true;
  4358. break;
  4359. default:
  4360. writeLog("error", "OMBI: unknown error with request [type: $type - action: $action - id: $id]");
  4361. return false;
  4362. }
  4363. //return (!empty($result) ? $result : null );
  4364. }
  4365. function getOmbiRequests($type = "both"){
  4366. $headers = array(
  4367. "Accept" => "application/json",
  4368. "Apikey" => OMBIKEY,
  4369. );
  4370. $requests = array();
  4371. switch ($type) {
  4372. case 'movie':
  4373. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4374. break;
  4375. case 'tv':
  4376. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4377. break;
  4378. default:
  4379. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4380. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4381. break;
  4382. }
  4383. if(isset($movie)){
  4384. foreach ($movie as $key => $value) {
  4385. $requests['movie'][] = array(
  4386. 'id' => $value['theMovieDbId'],
  4387. 'title' => $value['title'],
  4388. 'poster' => (strpos($value['posterPath'], "http") !== false) ? $value['posterPath'] : 'https://image.tmdb.org/t/p/w300/'.$value['posterPath'],
  4389. 'approved' => $value['approved'],
  4390. 'available' => $value['available'],
  4391. 'denied' => $value['denied'],
  4392. 'deniedReason' => $value['deniedReason'],
  4393. 'user' => $value['requestedUser']['userName'],
  4394. 'request_id' => $value['id'],
  4395. );
  4396. }
  4397. }
  4398. if(isset($tv) && (is_array($tv) || is_object($tv))){
  4399. foreach ($tv as $key => $value) {
  4400. $requests['tv'][] = array(
  4401. 'id' => $value['tvDbId'],
  4402. 'title' => $value['title'],
  4403. 'poster' => $value['posterPath'],
  4404. 'approved' => $value['childRequests'][0]['approved'],
  4405. 'available' => $value['childRequests'][0]['available'],
  4406. 'denied' => $value['childRequests'][0]['denied'],
  4407. 'deniedReason' => $value['childRequests'][0]['deniedReason'],
  4408. 'user' => $value['childRequests'][0]['requestedUser']['userName'],
  4409. 'request_id' => $value['id'],
  4410. );
  4411. }
  4412. }
  4413. return (empty($requests)) ? '' : $requests;
  4414. }
  4415. function convertOmbiString($type, $value){
  4416. switch ($type) {
  4417. case 'approved':
  4418. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4419. $string['icon'] = ($value) ? 'mdi mdi-check' : 'mdi mdi-clock';
  4420. $string['color'] = ($value) ? 'green-bg' : 'yellow-bg';
  4421. break;
  4422. case 'available':
  4423. $string['string'] = ($value) ? 'Available' : 'Not Downloaded';
  4424. $string['icon'] = ($value) ? 'mdi mdi-server' : 'mdi mdi-server-off';
  4425. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4426. break;
  4427. case 'denied':
  4428. $string['string'] = ($value) ? 'Denied' : 'Approved';
  4429. $string['icon'] = ($value) ? 'mdi mdi-emoticon-sad' : 'mdi mdi-emoticon-happy';
  4430. $string['color'] = ($value) ? 'red-bg' : 'green-bg';
  4431. break;
  4432. case 'status':
  4433. switch ($value) {
  4434. case '1':
  4435. $string['string'] = 'Denied';
  4436. $string['icon'] = 'mdi mdi-window-close';
  4437. $string['color'] = 'red-bg';
  4438. break;
  4439. case '2':
  4440. $string['string'] = 'Approved';
  4441. $string['icon'] = 'mdi mdi-check';
  4442. $string['color'] = 'green-bg';
  4443. break;
  4444. case '3':
  4445. $string['string'] = 'Not Approved';
  4446. $string['icon'] = 'mdi mdi-clock';
  4447. $string['color'] = 'yellow-bg';
  4448. break;
  4449. default:
  4450. # code...
  4451. break;
  4452. }
  4453. break;
  4454. default:
  4455. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4456. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4457. break;
  4458. }
  4459. return $string;
  4460. }
  4461. function buildOmbiItem($type, $group, $user, $request){
  4462. if (is_array($request) || is_object($request)){
  4463. $actions = '';
  4464. if($request['denied']){
  4465. $status = 1;
  4466. //$actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4467. }else{
  4468. if($request['approved']){
  4469. $status = 2;
  4470. }else{
  4471. $status = 3;
  4472. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4473. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="deny"><a class="requestAction" href="javascript:void(0)">Deny</a></li>';
  4474. }
  4475. }
  4476. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="delete"><a class="requestAction" href="javascript:void(0)">Delete</a></li>';
  4477. if(isset($group) && $group == 'admin'){
  4478. return '
  4479. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4480. <div class="requestOptions">
  4481. <div class="btn-group transparent" role="group">
  4482. <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>
  4483. <ul class="dropdown-menu"><h6 class="text-center">'.$request['user'].'</h6>'.$actions.'</ul>
  4484. </div>
  4485. </div>
  4486. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4487. <div class="requestBottom text-center">
  4488. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4489. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4490. </div>
  4491. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4492. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4493. </div>
  4494. </div>
  4495. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4496. </div>';
  4497. }elseif(isset($group) && $group == 'user'){
  4498. if(strtolower($request['user']) == strtolower($user)){
  4499. return '
  4500. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4501. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4502. <div class="requestBottom text-center">
  4503. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4504. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4505. </div>
  4506. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4507. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4508. </div>
  4509. </div>
  4510. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4511. </div>';
  4512. }
  4513. }
  4514. }
  4515. }
  4516. function buildOmbiList($group, $user){
  4517. $requests = array();
  4518. $openTab = 'true';
  4519. $movieList = getOmbiRequests('movie');
  4520. $tvList = getOmbiRequests('tv');
  4521. if (is_array($movieList) || is_object($movieList)){
  4522. foreach ($movieList['movie'] as $request) {
  4523. $requests[] = buildOmbiItem('movie', $group, $user, $request);
  4524. }
  4525. }
  4526. if (is_array($tvList) || is_object($tvList)){
  4527. foreach ($tvList['tv'] as $request) {
  4528. $requests[] = buildOmbiItem('season', $group, $user, $request);
  4529. }
  4530. }
  4531. return outputOmbiRequests("Requested Content", $requests, "
  4532. setInterval(function() {
  4533. $('<div></div>').load('ajax.php?a=ombi-requests',function() {
  4534. var element = $(this).find('#recentRequests');
  4535. var loadedID = element.attr('id');
  4536. $('#recentRequests').replaceWith(element);
  4537. console.log('Loaded updated: '+loadedID);
  4538. loadSlick();
  4539. });
  4540. }, ".RECENTREFRESH.");
  4541. ", false);
  4542. }
  4543. function outputOmbiRequests($header = "Requested Content", $items, $script = false, $array) {
  4544. $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">';
  4545. if(preg_grep("/item-movie-Approved/", $items)){
  4546. $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>';
  4547. }
  4548. if(preg_grep("/item-movie-Approval-Pending/", $items)){
  4549. $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>';
  4550. }
  4551. if(preg_grep("/item-season-Approved/", $items)){
  4552. $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>';
  4553. }
  4554. if(preg_grep("/item-season-Approval-Pending/", $items)){
  4555. $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>';
  4556. }
  4557. $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>';
  4558. $hideMenu .= '</ul></div></div>';
  4559. // If None Populate Empty Item
  4560. if (!count($items)) {
  4561. return '<div id="recentRequests" class="content-box box-shadow big-box"><h5 class="text-center">'.$header.'</h5><p class="text-center">No Requests Found</p></div>';
  4562. }else{
  4563. $className = str_replace(' ', '', $header);
  4564. return '<div id="recentRequests" class="content-box box-shadow big-box"><h5 id="requestContent-title" style="margin-bottom: -20px" class="text-center">'.$header.'</h5><div class="recentHeader inbox-pagination '.$className.'">'.$hideMenu.'</div><br/><br/><div class="recentItems-request" data-name="'.$className.'">'.implode('',$items).'</div></div>'.($script?'<script>'.$script.'</script>':'');
  4565. }
  4566. }
  4567. function loadIcons(){
  4568. $dirname = "images/";
  4569. $images = scandir($dirname);
  4570. $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");
  4571. $allIcons = '';
  4572. foreach($images as $curimg){
  4573. if(!in_array($curimg, $ignore)) {
  4574. $allIcons .= '
  4575. <div class="col-xs-2" style="width: 75px; height: 75px; padding-right: 0px;">
  4576. <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);">
  4577. <img style="width: 50px; height: 50px;" data-src="'.$dirname.$curimg.'" alt="thumbnail" class="allIcons lazyload">
  4578. </a>
  4579. </div>
  4580. ';
  4581. }
  4582. }
  4583. return $allIcons;
  4584. }
  4585. function buildHomepageSettings(){
  4586. $homepageOrder = homepageOrder();
  4587. $homepageList = '<h4>Drag Homepage Items to Order Them</h4><div id="homepage-items" class="external-events">';
  4588. $inputList = '<div id="homepage-values" class="row">';
  4589. foreach ($homepageOrder as $key => $val) {
  4590. switch ($key) {
  4591. case 'homepageOrdercustomhtml':
  4592. $class = 'palette-Deep-Purple-100 bg gray';
  4593. $image = 'images/html.png';
  4594. if(empty(HOMEPAGECUSTOMHTML1)){
  4595. $class .= ' faded';
  4596. }
  4597. break;
  4598. case 'homepageOrdernotice':
  4599. $class = 'palette-Cyan-A400 bg gray';
  4600. $image = 'images/pin.png';
  4601. if(empty(HOMEPAGENOTICETITLE) && empty(HOMEPAGENOTICEMESSAGE)){
  4602. $class .= ' faded';
  4603. }
  4604. break;
  4605. case 'homepageOrderspeedtest':
  4606. $class = 'red-bg';
  4607. $image = 'images/settings/full-color/png/64px/speedometer.png';
  4608. if(SPEEDTEST !== "true"){
  4609. $class .= ' faded';
  4610. }
  4611. break;
  4612. case 'homepageOrdernzbget':
  4613. $class = 'green-bg';
  4614. $image = 'images/nzbget.png';
  4615. if(empty(NZBGETURL)){
  4616. $class .= ' faded';
  4617. }
  4618. break;
  4619. case 'homepageOrdersabnzbd':
  4620. $class = 'yellow-bg';
  4621. $image = 'images/sabnzbd.png';
  4622. if(empty(SABNZBDURL)){
  4623. $class .= ' faded';
  4624. }
  4625. break;
  4626. case 'homepageOrderplexsearch':
  4627. case 'homepageOrderplexnowplaying':
  4628. case 'homepageOrderplexrecent':
  4629. case 'homepageOrderplexplaylist':
  4630. $class = 'palette-Amber-A700 bg gray';
  4631. $image = 'images/plex.png';
  4632. if(empty(PLEXURL)){
  4633. $class .= ' faded';
  4634. }
  4635. break;
  4636. case 'homepageOrderembynowplaying':
  4637. case 'homepageOrderembyrecent':
  4638. $class = 'palette-Green-A700 bg gray';
  4639. $image = 'images/emby.png';
  4640. if(empty(EMBYURL)){
  4641. $class .= ' faded';
  4642. }
  4643. break;
  4644. case 'homepageOrderombi':
  4645. $class = 'orange-bg';
  4646. $image = 'images/ombi.png';
  4647. if(empty(OMBIURL)){
  4648. $class .= ' faded';
  4649. }
  4650. break;
  4651. case 'homepageOrdercalendar':
  4652. $class = 'palette-Blue-400 bg gray';
  4653. $image = 'images/calendar.png';
  4654. if(SONARRURL == "" && RADARRURL == "" && HEADPHONESURL == "" && SICKRAGEURL == "" && COUCHURL == "" ){
  4655. $class .= ' faded';
  4656. }
  4657. break;
  4658. default:
  4659. $class = 'blue-bg';
  4660. $image = '';
  4661. break;
  4662. }
  4663. $homepageList .= '
  4664. <div class="col-md-3 sort-homepage"><div class="fc-event '.$class.'">
  4665. <span class="ordinal-position text-uppercase badge badge-gray" data-link="'.$key.'" style="float:left;width: 30px;">'.$val.'</span>
  4666. &nbsp; '.strtoupper(substr($key, 13)).'
  4667. <span class="remove-event"><img style="width: 22px;" src="'.$image.'"></span>
  4668. </div></div>';
  4669. $inputList .= '<input type="hidden" name="'.$key.'">';
  4670. }
  4671. $homepageList .= '</div>';
  4672. $inputList .= '</div>';
  4673. return $homepageList.$inputList;
  4674. }
  4675. function buildHomepage($group, $user){
  4676. $homepageOrder = homepageOrder();
  4677. $homepageBuilt = '';
  4678. foreach ($homepageOrder as $key => $value) {
  4679. $homepageBuilt .= buildHomepageItem($key, $group, $user);
  4680. }
  4681. return $homepageBuilt;
  4682. }
  4683. function realSize($bytes, $decimals = 2) {
  4684. $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
  4685. $factor = floor((strlen($bytes) - 1) / 3);
  4686. return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' '.@$size[$factor];
  4687. }
  4688. function buildHomepageItem($homepageItem, $group, $user){
  4689. $homepageItemBuilt = '';
  4690. switch ($homepageItem) {
  4691. case 'homepageOrderplexsearch':
  4692. if((qualifyUser(PLEXSEARCHAUTH) && PLEXSEARCH == "true" && qualifyUser(PLEXHOMEAUTH))) {
  4693. $homepageItemBuilt .= '
  4694. <div id="searchPlexRow" class="row">
  4695. <div class="col-lg-12">
  4696. <div class="content-box box-shadow big-box todo-list">
  4697. <form id="plexSearchForm" onsubmit="return false;" autocomplete="off">
  4698. <div class="">
  4699. <div class="input-group">
  4700. <div style="border-radius: 25px 0 0 25px; border:0" class="input-group-addon gray-bg"><i class="fa fa-search white"></i></div>
  4701. <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">
  4702. <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>
  4703. <button style="display:none" id="plexSearchForm_submit" class="btn btn-primary waves"></button>
  4704. </div>
  4705. </div>
  4706. </form>
  4707. <div id="resultshere" class="table-responsive"></div>
  4708. </div>
  4709. </div>
  4710. </div>
  4711. ';
  4712. }
  4713. break;
  4714. case 'homepageOrdercustomhtml':
  4715. if (qualifyUser(HOMEPAGECUSTOMHTML1AUTH) && HOMEPAGECUSTOMHTML1) {
  4716. $homepageItemBuilt .= "<div>" . HOMEPAGECUSTOMHTML1 . "</div>";
  4717. }
  4718. break;
  4719. case 'homepageOrdernotice':
  4720. if (qualifyUser(HOMEPAGENOTICEAUTH) && HOMEPAGENOTICETITLE && HOMEPAGENOTICETYPE && HOMEPAGENOTICEMESSAGE && HOMEPAGENOTICELAYOUT) {
  4721. $homepageItemBuilt .= buildHomepageNotice(HOMEPAGENOTICELAYOUT, HOMEPAGENOTICETYPE, HOMEPAGENOTICETITLE, HOMEPAGENOTICEMESSAGE);
  4722. }
  4723. break;
  4724. case 'homepageOrderspeedtest':
  4725. if(SPEEDTEST == "true" && qualifyUser(SPEEDTESTAUTH)){
  4726. $homepageItemBuilt .= '
  4727. <style type="text/css">
  4728. .flash {
  4729. animation: flash 0.6s linear infinite;
  4730. }
  4731. @keyframes flash {
  4732. 0% { opacity: 0.6; }
  4733. 50% { opacity: 1; }
  4734. }
  4735. </style>
  4736. <script type="text/javascript">
  4737. var w = null
  4738. function runTest() {
  4739. document.getElementById("startBtn").style.display = "none"
  4740. document.getElementById("testArea").style.display = ""
  4741. document.getElementById("abortBtn").style.display = ""
  4742. w = new Worker("bower_components/speed/speedtest_worker.js")
  4743. var interval = setInterval(function () { w.postMessage("status") }, 100)
  4744. w.onmessage = function (event) {
  4745. var data = event.data.split(";")
  4746. var status = Number(data[0])
  4747. var dl = document.getElementById("download")
  4748. var ul = document.getElementById("upload")
  4749. var ping = document.getElementById("ping")
  4750. var jitter = document.getElementById("jitter")
  4751. dl.className = status === 1 ? "w-name flash" : "w-name"
  4752. ping.className = status === 2 ? "w-name flash" : "w-name"
  4753. jitter.className = ul.className = status === 3 ? "w-name flash" : "w-name"
  4754. if (status >= 4) {
  4755. clearInterval(interval)
  4756. document.getElementById("abortBtn").style.display = "none"
  4757. document.getElementById("startBtn").style.display = ""
  4758. w = null
  4759. }
  4760. if (status === 5) {
  4761. document.getElementById("testArea").style.display = "none"
  4762. }
  4763. dl.textContent = data[1] + " Mbit/s";
  4764. $("#downloadpercent").attr("style", "width: " + data[1] + "%;");
  4765. $("#uploadpercent").attr("style", "width: " + data[2] + "%;");
  4766. $("#pingpercent").attr("style", "width: " + data[3] + "%;");
  4767. $("#jitterpercent").attr("style", "width: " + data[5] + "%;");
  4768. ul.textContent = data[2] + " Mbit/s";
  4769. ping.textContent = data[3] + " ms";
  4770. jitter.textContent = data[5] + " ms";
  4771. }
  4772. w.postMessage(\'start {"telemetry_level":"basic"}\')
  4773. //w.postMessage("start")
  4774. }
  4775. function abortTest() {
  4776. if (w) w.postMessage("abort")
  4777. }
  4778. </script>
  4779. <div class="row" id="testArea" style="display:none">
  4780. <div class="test col-sm-3 col-lg-3">
  4781. <div class="content-box ultra-widget green-bg" data-counter="">
  4782. <div id="downloadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4783. <div class="w-content">
  4784. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-download"></i></div>
  4785. <div class="w-descr left pull-left text-center">
  4786. <span class="testName text-uppercase w-name">Download</span>
  4787. <br>
  4788. <span class="w-name counter" id="download" ></span>
  4789. </div>
  4790. </div>
  4791. </div>
  4792. </div>
  4793. <div class="test col-sm-3 col-lg-3">
  4794. <div class="content-box ultra-widget red-bg" data-counter="">
  4795. <div id="uploadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4796. <div class="w-content">
  4797. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-upload"></i></div>
  4798. <div class="w-descr left pull-left text-center">
  4799. <span class="testName text-uppercase w-name">Upload</span>
  4800. <br>
  4801. <span class="w-name counter" id="upload" ></span>
  4802. </div>
  4803. </div>
  4804. </div>
  4805. </div>
  4806. <div class="test col-sm-3 col-lg-3">
  4807. <div class="content-box ultra-widget yellow-bg" data-counter="">
  4808. <div id="pingpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4809. <div class="w-content">
  4810. <div class="w-icon right pull-right"><i class="mdi mdi-timer"></i></div>
  4811. <div class="w-descr left pull-left text-center">
  4812. <span class="testName text-uppercase w-name">Latency</span>
  4813. <br>
  4814. <span class="w-name counter" id="ping" ></span>
  4815. </div>
  4816. </div>
  4817. </div>
  4818. </div>
  4819. <div class="test col-sm-3 col-lg-3">
  4820. <div class="content-box ultra-widget blue-bg" data-counter="">
  4821. <div id="jitterpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4822. <div class="w-content">
  4823. <div class="w-icon right pull-right"><i class="mdi mdi-pulse"></i></div>
  4824. <div class="w-descr left pull-left text-center">
  4825. <span class="testName text-uppercase w-name">Jitter</span>
  4826. <br>
  4827. <span class="w-name counter" id="jitter" ></span>
  4828. </div>
  4829. </div>
  4830. </div>
  4831. </div>
  4832. <br/>
  4833. </div>
  4834. <div id="abortBtn" class="row" style="display: none" onclick="javascript:abortTest()">
  4835. <div class="col-lg-12">
  4836. <div class="content-box red-bg" style="cursor: pointer;">
  4837. <h1 style="margin: 10px" class="text-uppercase text-center">Abort Speed Test</h1>
  4838. <div class="clearfix"></div>
  4839. </div>
  4840. </div>
  4841. </div>
  4842. <div id="startBtn" class="row" onclick="javascript:runTest()">
  4843. <div class="col-lg-12">
  4844. <div class="content-box green-bg" style="cursor: pointer;">
  4845. <h1 style="margin: 10px" class="text-uppercase text-center">Run Speed Test</h1>
  4846. <div class="clearfix"></div>
  4847. </div>
  4848. </div>
  4849. </div>
  4850. ';
  4851. }
  4852. break;
  4853. case 'homepageOrdernzbget':
  4854. if(NZBGETURL != "" && qualifyUser(NZBGETHOMEAUTH)){
  4855. $homepageItemBuilt .= buildDownloader('nzbget');
  4856. }
  4857. break;
  4858. case 'homepageOrdersabnzbd':
  4859. if(SABNZBDURL != "" && qualifyUser(SABNZBDHOMEAUTH)) {
  4860. $homepageItemBuilt .= buildDownloader('sabnzbd');
  4861. }
  4862. break;
  4863. case 'homepageOrderplexnowplaying':
  4864. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4865. if(qualifyUser(PLEXPLAYINGNOWAUTH) && PLEXPLAYINGNOW == "true"){
  4866. $homepageItemBuilt .= '<div id="plexRowNowPlaying" class="row">';
  4867. $homepageItemBuilt .= getPlexStreams(12, PLEXSHOWNAMES, $group);
  4868. $homepageItemBuilt .= '</div>';
  4869. }
  4870. }
  4871. break;
  4872. case 'homepageOrderplexrecent':
  4873. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4874. if(qualifyUser(PLEXRECENTMOVIEAUTH) && PLEXRECENTMOVIE == "true" || qualifyUser(PLEXRECENTTVAUTH) && PLEXRECENTTV == "true" || qualifyUser(PLEXRECENTMUSICAUTH) && PLEXRECENTMUSIC == "true"){
  4875. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  4876. $homepageItemBuilt .= '<div id="plexRow" class="row"><div class="col-lg-12">';
  4877. $homepageItemBuilt .= getPlexRecent($plexArray);
  4878. $homepageItemBuilt .= '</div></div>';
  4879. }
  4880. }
  4881. break;
  4882. case 'homepageOrderplexplaylist':
  4883. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4884. if(qualifyUser(PLEXPLAYLISTSAUTH) && PLEXPLAYLISTS == "true"){
  4885. $homepageItemBuilt .= '<div id="plexPlaylists" class="row"><div class="col-lg-12">';
  4886. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  4887. $homepageItemBuilt .= getPlexPlaylists($plexArray);
  4888. $homepageItemBuilt .= '</div> </div>';
  4889. }
  4890. }
  4891. break;
  4892. case 'homepageOrderembynowplaying':
  4893. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  4894. if(qualifyUser(EMBYPLAYINGNOWAUTH) && EMBYPLAYINGNOW == "true"){
  4895. $homepageItemBuilt .= '<div id="embyRowNowPlaying" class="row">';
  4896. $homepageItemBuilt .= getEmbyStreams(12, EMBYSHOWNAMES, $group);
  4897. $homepageItemBuilt .= '</div>';
  4898. }
  4899. }
  4900. break;
  4901. case 'homepageOrderembyrecent':
  4902. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  4903. if(qualifyUser(EMBYRECENTMOVIEAUTH) && EMBYRECENTMOVIE == "true" || qualifyUser(EMBYRECENTTVAUTH) && EMBYRECENTTV == "true" || qualifyUser(EMBYRECENTMUSICAUTH) && EMBYRECENTMUSIC == "true"){
  4904. $embyArray = array("Movie" => EMBYRECENTMOVIE, "Episode" => EMBYRECENTTV, "MusicAlbum" => EMBYRECENTMUSIC, "Series" => EMBYRECENTTV);
  4905. $homepageItemBuilt .= '<div id="embyRow" class="row"><div class="col-lg-12">';
  4906. $homepageItemBuilt .= getEmbyRecent($embyArray);
  4907. $homepageItemBuilt .= '</div></div>';
  4908. }
  4909. }
  4910. break;
  4911. case 'homepageOrderombi':
  4912. if (qualifyUser(OMBIAUTH) && OMBIURL) {
  4913. $homepageItemBuilt .= '<div id="ombiRequests" class="row"><div class="col-lg-12">';
  4914. $homepageItemBuilt .= buildOmbiList($group, $user);
  4915. $homepageItemBuilt .= '</div></div>';
  4916. }
  4917. break;
  4918. case 'homepageOrdercalendar':
  4919. if ((SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)) || (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)) || (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)) || (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)) || (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH))) {
  4920. $calendarItems = '';
  4921. if(RADARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="film" href="javascript:void(0)">Movies</a></li>'; }
  4922. if(SONARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="tv" href="javascript:void(0)">TV Shows</a></li>'; }
  4923. if(HEADPHONESURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="music" href="javascript:void(0)">Music</a></li>'; }
  4924. $homepageItemBuilt .= '
  4925. <div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">
  4926. <div class="col-lg-12 content-form form-inline">
  4927. <div class="form-group pull-right">
  4928. <span class="swal-legend label label-primary well-sm">Legend</span>&nbsp;
  4929. <div class="btn-group" role="group">
  4930. <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>
  4931. <ul style="right:0; left: auto" class="dropdown-menu">
  4932. <li><a class="calendarOption" calendarOption="all" href="javascript:void(0)">View All</a></li>
  4933. '.$calendarItems.'
  4934. </ul>
  4935. </div>
  4936. </div>
  4937. </div>
  4938. </div>
  4939. <div id="calendarRow" class="row">
  4940. <div class="col-lg-12">
  4941. <div id="calendar" class="fc-calendar box-shadow fc fc-ltr fc-unthemed"></div>
  4942. </div>
  4943. </div>
  4944. ';
  4945. }
  4946. break;
  4947. default:
  4948. # code...
  4949. break;
  4950. }
  4951. return $homepageItemBuilt;
  4952. }
  4953. function buildDownloader($name){
  4954. return '
  4955. <div id="downloadClientRow" class="row">
  4956. <div class="col-xs-12 col-md-12">
  4957. <div class="content-box">
  4958. <div class="tabbable panel with-nav-tabs panel-default">
  4959. <div class="panel-heading">
  4960. <div class="content-tools i-block pull-right">
  4961. <a id="getDownloader" class="repeat-btn">
  4962. <i class="fa fa-repeat"></i>
  4963. </a>
  4964. </div>
  4965. <h3 class="pull-left">'.strtoupper($name).'</h3>
  4966. <ul class="nav nav-tabs pull-right">
  4967. <li class="active"><a href="#downloadQueue-'.$name.'" data-toggle="tab" aria-expanded="true">'.translate("QUEUE").'</a></li>
  4968. <li class=""><a href="#downloadHistory-'.$name.'" data-toggle="tab" aria-expanded="false">'.translate("HISTORY").'</a></li>
  4969. </ul>
  4970. <div class="clearfix"></div>
  4971. </div>
  4972. <div class="panel-body">
  4973. <div class="tab-content">
  4974. <div class="tab-pane fade active in" id="downloadQueue-'.$name.'">
  4975. <div class="table-responsive" style="max-height: 300px">
  4976. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  4977. <thead>
  4978. <tr>
  4979. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  4980. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  4981. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  4982. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  4983. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  4984. </tr>
  4985. </thead>
  4986. <tbody class="dl-queue '.$name.'"></tbody>
  4987. </table>
  4988. </div>
  4989. </div>
  4990. <div class="tab-pane fade" id="downloadHistory-'.$name.'">
  4991. <div class="table-responsive" style="max-height: 300px">
  4992. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  4993. <thead>
  4994. <tr>
  4995. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  4996. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  4997. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  4998. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  4999. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  5000. </tr>
  5001. </thead>
  5002. <tbody class="dl-history '.$name.'"></tbody>
  5003. </table>
  5004. </div>
  5005. </div>
  5006. </div>
  5007. </div>
  5008. </div>
  5009. </div>
  5010. </div>
  5011. </div>';
  5012. }
  5013. class Mobile_Detect
  5014. {
  5015. /**
  5016. * Mobile detection type.
  5017. *
  5018. * @deprecated since version 2.6.9
  5019. */
  5020. const DETECTION_TYPE_MOBILE = 'mobile';
  5021. /**
  5022. * Extended detection type.
  5023. *
  5024. * @deprecated since version 2.6.9
  5025. */
  5026. const DETECTION_TYPE_EXTENDED = 'extended';
  5027. /**
  5028. * A frequently used regular expression to extract version #s.
  5029. *
  5030. * @deprecated since version 2.6.9
  5031. */
  5032. const VER = '([\w._\+]+)';
  5033. /**
  5034. * Top-level device.
  5035. */
  5036. const MOBILE_GRADE_A = 'A';
  5037. /**
  5038. * Mid-level device.
  5039. */
  5040. const MOBILE_GRADE_B = 'B';
  5041. /**
  5042. * Low-level device.
  5043. */
  5044. const MOBILE_GRADE_C = 'C';
  5045. /**
  5046. * Stores the version number of the current release.
  5047. */
  5048. const VERSION = '2.8.26';
  5049. /**
  5050. * A type for the version() method indicating a string return value.
  5051. */
  5052. const VERSION_TYPE_STRING = 'text';
  5053. /**
  5054. * A type for the version() method indicating a float return value.
  5055. */
  5056. const VERSION_TYPE_FLOAT = 'float';
  5057. /**
  5058. * A cache for resolved matches
  5059. * @var array
  5060. */
  5061. protected $cache = array();
  5062. /**
  5063. * The User-Agent HTTP header is stored in here.
  5064. * @var string
  5065. */
  5066. protected $userAgent = null;
  5067. /**
  5068. * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
  5069. * @var array
  5070. */
  5071. protected $httpHeaders = array();
  5072. /**
  5073. * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
  5074. * @var array
  5075. */
  5076. protected $cloudfrontHeaders = array();
  5077. /**
  5078. * The matching Regex.
  5079. * This is good for debug.
  5080. * @var string
  5081. */
  5082. protected $matchingRegex = null;
  5083. /**
  5084. * The matches extracted from the regex expression.
  5085. * This is good for debug.
  5086. * @var string
  5087. */
  5088. protected $matchesArray = null;
  5089. /**
  5090. * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
  5091. *
  5092. * @deprecated since version 2.6.9
  5093. *
  5094. * @var string
  5095. */
  5096. protected $detectionType = self::DETECTION_TYPE_MOBILE;
  5097. /**
  5098. * HTTP headers that trigger the 'isMobile' detection
  5099. * to be true.
  5100. *
  5101. * @var array
  5102. */
  5103. protected static $mobileHeaders = array(
  5104. 'HTTP_ACCEPT' => array('matches' => array(
  5105. // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
  5106. 'application/x-obml2d',
  5107. // BlackBerry devices.
  5108. 'application/vnd.rim.html',
  5109. 'text/vnd.wap.wml',
  5110. 'application/vnd.wap.xhtml+xml'
  5111. )),
  5112. 'HTTP_X_WAP_PROFILE' => null,
  5113. 'HTTP_X_WAP_CLIENTID' => null,
  5114. 'HTTP_WAP_CONNECTION' => null,
  5115. 'HTTP_PROFILE' => null,
  5116. // Reported by Opera on Nokia devices (eg. C3).
  5117. 'HTTP_X_OPERAMINI_PHONE_UA' => null,
  5118. 'HTTP_X_NOKIA_GATEWAY_ID' => null,
  5119. 'HTTP_X_ORANGE_ID' => null,
  5120. 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
  5121. 'HTTP_X_HUAWEI_USERID' => null,
  5122. // Reported by Windows Smartphones.
  5123. 'HTTP_UA_OS' => null,
  5124. // Reported by Verizon, Vodafone proxy system.
  5125. 'HTTP_X_MOBILE_GATEWAY' => null,
  5126. // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
  5127. 'HTTP_X_ATT_DEVICEID' => null,
  5128. // Seen this on a HTC.
  5129. 'HTTP_UA_CPU' => array('matches' => array('ARM')),
  5130. );
  5131. /**
  5132. * List of mobile devices (phones).
  5133. *
  5134. * @var array
  5135. */
  5136. protected static $phoneDevices = array(
  5137. 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
  5138. 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
  5139. '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',
  5140. 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
  5141. // @todo: Is 'Dell Streak' a tablet or a phone? ;)
  5142. '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',
  5143. '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',
  5144. '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',
  5145. '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)',
  5146. 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
  5147. 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
  5148. 'NokiaLumia' => 'Lumia [0-9]{3,4}',
  5149. // http://www.micromaxinfo.com/mobiles/smartphones
  5150. // Added because the codes might conflict with Acer Tablets.
  5151. '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',
  5152. // @todo Complete the regex.
  5153. 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
  5154. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
  5155. // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
  5156. // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
  5157. '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',
  5158. // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
  5159. 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
  5160. // http://fr.wikomobile.com
  5161. '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',
  5162. 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
  5163. // Added simvalley mobile just for fun. They have some interesting devices.
  5164. // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
  5165. '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',
  5166. // Wolfgang - a brand that is sold by Aldi supermarkets.
  5167. // http://www.wolfgangmobile.com/
  5168. 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
  5169. 'Alcatel' => 'Alcatel',
  5170. 'Nintendo' => 'Nintendo 3DS',
  5171. // http://en.wikipedia.org/wiki/Amoi
  5172. 'Amoi' => 'Amoi',
  5173. // http://en.wikipedia.org/wiki/INQ
  5174. 'INQ' => 'INQ',
  5175. // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
  5176. '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',
  5177. );
  5178. /**
  5179. * List of tablet devices.
  5180. *
  5181. * @var array
  5182. */
  5183. protected static $tabletDevices = array(
  5184. // @todo: check for mobile friendly emails topic.
  5185. 'iPad' => 'iPad|iPad.*Mobile',
  5186. // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
  5187. // @see #442
  5188. 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
  5189. '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.
  5190. // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
  5191. '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)',
  5192. // Only the Surface tablets with Windows RT are considered mobile.
  5193. // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
  5194. 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
  5195. // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
  5196. 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
  5197. // Watch out for PadFone, see #132.
  5198. // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
  5199. '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',
  5200. 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
  5201. 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
  5202. 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
  5203. 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
  5204. // http://www.acer.ro/ac/ro/RO/content/drivers
  5205. // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
  5206. // http://us.acer.com/ac/en/US/content/group/tablets
  5207. // http://www.acer.de/ac/de/DE/content/models/tablets/
  5208. // Can conflict with Micromax and Motorola phones codes.
  5209. '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',
  5210. // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
  5211. // http://us.toshiba.com/tablets/tablet-finder
  5212. // http://www.toshiba.co.jp/regza/tablet/
  5213. 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
  5214. // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
  5215. // http://www.lg.com/us/tablets
  5216. 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
  5217. 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
  5218. // Prestigio Tablets http://www.prestigio.com/support
  5219. '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',
  5220. // http://support.lenovo.com/en_GB/downloads/default.page?#
  5221. '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|)',
  5222. // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
  5223. 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
  5224. // http://www.yarvik.com/en/matrix/tablets/
  5225. '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',
  5226. 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
  5227. 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
  5228. // http://www.intenso.de/kategorie_en.php?kategorie=33
  5229. // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
  5230. 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
  5231. // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
  5232. 'IRUTablet' => 'M702pro',
  5233. 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
  5234. // http://www.e-boda.ro/tablete-pc.html
  5235. 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
  5236. // http://www.allview.ro/produse/droseries/lista-tablete-pc/
  5237. 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
  5238. // http://wiki.archosfans.com/index.php?title=Main_Page
  5239. // @note Rewrite the regex format after we add more UAs.
  5240. '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',
  5241. // http://www.ainol.com/plugin.php?identifier=ainol&module=product
  5242. 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
  5243. 'NokiaLumiaTablet' => 'Lumia 2520',
  5244. // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
  5245. // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
  5246. // http://www.sony.jp/support/tablet/
  5247. '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',
  5248. // 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
  5249. 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
  5250. // db + http://www.cube-tablet.com/buy-products.html
  5251. 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
  5252. // http://www.cobyusa.com/?p=pcat&pcat_id=3001
  5253. 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
  5254. // http://www.match.net.cn/products.asp
  5255. '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',
  5256. // http://www.msi.com/support
  5257. // @todo Research the Windows Tablets.
  5258. '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',
  5259. // @todo http://www.kyoceramobile.com/support/drivers/
  5260. // 'KyoceraTablet' => null,
  5261. // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
  5262. // 'IntextTablet' => null,
  5263. // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
  5264. // http://www.imp3.net/14/show.php?itemid=20454
  5265. 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
  5266. // http://www.rock-chips.com/index.php?do=prod&pid=2
  5267. 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
  5268. // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
  5269. 'FlyTablet' => 'IQ310|Fly Vision',
  5270. // http://www.bqreaders.com/gb/tablets-prices-sale.html
  5271. 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
  5272. // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
  5273. // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
  5274. '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',
  5275. // Nec or Medias Tab
  5276. 'NecTablet' => '\bN-06D|\bN-08D',
  5277. // Pantech Tablets: http://www.pantechusa.com/phones/
  5278. 'PantechTablet' => 'Pantech.*P4100',
  5279. // Broncho Tablets: http://www.broncho.cn/ (hard to find)
  5280. 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
  5281. // http://versusuk.com/support.html
  5282. 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
  5283. // http://www.zync.in/index.php/our-products/tablet-phablets
  5284. 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
  5285. // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
  5286. 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
  5287. // https://www.nabitablet.com/
  5288. 'NabiTablet' => 'Android.*\bNabi',
  5289. 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
  5290. // French Danew Tablets http://www.danew.com/produits-tablette.php
  5291. 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
  5292. // Texet Tablets and Readers http://www.texet.ru/tablet/
  5293. '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',
  5294. // Avoid detecting 'PLAYSTATION 3' as mobile.
  5295. 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
  5296. // http://www.trekstor.de/surftabs.html
  5297. 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
  5298. // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
  5299. 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
  5300. // http://www.advandigital.com/index.php?link=content-product&jns=JP001
  5301. // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
  5302. '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 ',
  5303. // http://www.danytech.com/category/tablet-pc
  5304. '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',
  5305. // http://www.galapad.net/product.html
  5306. 'GalapadTablet' => 'Android.*\bG1\b',
  5307. // http://www.micromaxinfo.com/tablet/funbook
  5308. 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
  5309. // http://www.karbonnmobiles.com/products_tablet.php
  5310. 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
  5311. // http://www.myallfine.com/Products.asp
  5312. 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
  5313. // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
  5314. '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',
  5315. // http://www.yonesnav.com/products/products.php
  5316. 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
  5317. // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
  5318. // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
  5319. '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',
  5320. // http://www.gloryunion.cn/products.asp
  5321. // http://www.allwinnertech.com/en/apply/mobile.html
  5322. // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
  5323. // @todo: Softwiner tablets?
  5324. // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
  5325. '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
  5326. // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
  5327. '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',
  5328. // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
  5329. // @todo: add more tests.
  5330. 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
  5331. // http://hclmetablet.com/India/index.php
  5332. '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',
  5333. // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
  5334. 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
  5335. // http://www.visture.com/index.asp
  5336. 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
  5337. // http://www.mijncresta.nl/tablet
  5338. 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
  5339. // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
  5340. 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
  5341. // Concorde tab
  5342. 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
  5343. // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
  5344. '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',
  5345. // Modecom Tablets - http://www.modecom.eu/tablets/portal/
  5346. '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',
  5347. // Vonino Tablets - http://www.vonino.eu/tablets
  5348. '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',
  5349. // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
  5350. 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
  5351. // Storex Tablets - http://storex.fr/espace_client/support.html
  5352. // @note: no need to add all the tablet codes since they are guided by the first regex.
  5353. 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
  5354. // Generic Vodafone tablets.
  5355. 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
  5356. // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
  5357. // Aka: http://www.essentielb.fr/
  5358. 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
  5359. // Ross & Moor - http://ross-moor.ru/
  5360. 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
  5361. // i-mobile http://product.i-mobilephone.com/Mobile_Device
  5362. 'iMobileTablet' => 'i-mobile i-note',
  5363. // http://www.tolino.de/de/vergleichen/
  5364. 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
  5365. // AudioSonic - a Kmart brand
  5366. // 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
  5367. 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
  5368. // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
  5369. // @todo: add them gradually to avoid conflicts.
  5370. 'AMPETablet' => 'Android.* A78 ',
  5371. // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
  5372. 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
  5373. // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
  5374. 'TecnoTablet' => 'TECNO P9',
  5375. // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
  5376. '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',
  5377. // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
  5378. '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)',
  5379. // http://www.intracon.eu/tablet
  5380. 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
  5381. // http://www.xoro.de/produkte/
  5382. // @note: Might be the same brand with 'Simply tablets'
  5383. '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',
  5384. // http://www1.viewsonic.com/products/computing/tablets/
  5385. 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
  5386. // http://www.odys.de/web/internet-tablet_en.html
  5387. 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
  5388. // http://www.captiva-power.de/products.html#tablets-en
  5389. 'CaptivaTablet' => 'CAPTIVA PAD',
  5390. // IconBIT - http://www.iconbit.com/products/tablets/
  5391. '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',
  5392. // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
  5393. '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',
  5394. // Onda - http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
  5395. '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]+',
  5396. 'JaytechTablet' => 'TPC-PA762',
  5397. 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
  5398. // http://www.digma.ru/support/download/
  5399. // @todo: Ebooks also (if requested)
  5400. 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
  5401. // http://www.evolioshop.com/ro/tablete-pc.html
  5402. // http://www.evolio.ro/support/downloads_static.html?cat=2
  5403. // @todo: Research some more
  5404. 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
  5405. // @todo http://www.lavamobiles.com/tablets-data-cards
  5406. 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
  5407. // http://www.breezetablet.com/
  5408. 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
  5409. // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
  5410. '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',
  5411. // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
  5412. 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
  5413. // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
  5414. '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',
  5415. // http://www.mi.com/en
  5416. 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
  5417. // http://www.nbru.cn/index.html
  5418. 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
  5419. // http://navroad.com/products/produkty/tablety/
  5420. // http://navroad.com/products/produkty/tablety/
  5421. 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
  5422. // http://leader-online.com/new_site/product-category/tablets/
  5423. // http://www.leader-online.net.au/List/Tablet
  5424. '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',
  5425. // http://www.datawind.com/ubislate/
  5426. 'UbislateTablet' => 'UbiSlate[\s]?7C',
  5427. // http://www.pocketbook-int.com/ru/support
  5428. 'PocketBookTablet' => 'Pocketbook',
  5429. // http://www.kocaso.com/product_tablet.html
  5430. 'KocasoTablet' => '\b(TB-1207)\b',
  5431. // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
  5432. 'HisenseTablet' => '\b(F5281|E2371)\b',
  5433. // http://www.tesco.com/direct/hudl/
  5434. 'Hudl' => 'Hudl HT7S3|Hudl 2',
  5435. // http://www.telstra.com.au/home-phone/thub-2/
  5436. 'TelstraTablet' => 'T-Hub2',
  5437. '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'
  5438. );
  5439. /**
  5440. * List of mobile Operating Systems.
  5441. *
  5442. * @var array
  5443. */
  5444. protected static $operatingSystems = array(
  5445. 'AndroidOS' => 'Android',
  5446. 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
  5447. 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
  5448. 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
  5449. // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
  5450. 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
  5451. // @reference: http://en.wikipedia.org/wiki/Windows_Phone
  5452. // http://wifeng.cn/?r=blog&a=view&id=106
  5453. // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
  5454. // http://msdn.microsoft.com/library/ms537503.aspx
  5455. // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
  5456. 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
  5457. 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
  5458. // http://en.wikipedia.org/wiki/MeeGo
  5459. // @todo: research MeeGo in UAs
  5460. 'MeeGoOS' => 'MeeGo',
  5461. // http://en.wikipedia.org/wiki/Maemo
  5462. // @todo: research Maemo in UAs
  5463. 'MaemoOS' => 'Maemo',
  5464. 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
  5465. 'webOS' => 'webOS|hpwOS',
  5466. 'badaOS' => '\bBada\b',
  5467. 'BREWOS' => 'BREW',
  5468. );
  5469. /**
  5470. * List of mobile User Agents.
  5471. *
  5472. * IMPORTANT: This is a list of only mobile browsers.
  5473. * Mobile Detect 2.x supports only mobile browsers,
  5474. * it was never designed to detect all browsers.
  5475. * The change will come in 2017 in the 3.x release for PHP7.
  5476. *
  5477. * @var array
  5478. */
  5479. protected static $browsers = array(
  5480. //'Vivaldi' => 'Vivaldi',
  5481. // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
  5482. 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
  5483. 'Dolfin' => '\bDolfin\b',
  5484. 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
  5485. 'Skyfire' => 'Skyfire',
  5486. 'Edge' => 'Mobile Safari/[.0-9]* Edge',
  5487. 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
  5488. 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
  5489. 'Bolt' => 'bolt',
  5490. 'TeaShark' => 'teashark',
  5491. 'Blazer' => 'Blazer',
  5492. // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
  5493. 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
  5494. // http://en.wikipedia.org/wiki/Midori_(web_browser)
  5495. //'Midori' => 'midori',
  5496. //'Tizen' => 'Tizen',
  5497. 'UCBrowser' => 'UC.*Browser|UCWEB',
  5498. 'baiduboxapp' => 'baiduboxapp',
  5499. 'baidubrowser' => 'baidubrowser',
  5500. // https://github.com/serbanghita/Mobile-Detect/issues/7
  5501. 'DiigoBrowser' => 'DiigoBrowser',
  5502. // http://www.puffinbrowser.com/index.php
  5503. 'Puffin' => 'Puffin',
  5504. // http://mercury-browser.com/index.html
  5505. 'Mercury' => '\bMercury\b',
  5506. // http://en.wikipedia.org/wiki/Obigo_Browser
  5507. 'ObigoBrowser' => 'Obigo',
  5508. // http://en.wikipedia.org/wiki/NetFront
  5509. 'NetFront' => 'NF-Browser',
  5510. // @reference: http://en.wikipedia.org/wiki/Minimo
  5511. // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
  5512. 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
  5513. // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
  5514. 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
  5515. );
  5516. /**
  5517. * Utilities.
  5518. *
  5519. * @var array
  5520. */
  5521. protected static $utilities = array(
  5522. // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
  5523. // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
  5524. // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
  5525. // https://developers.facebook.com/docs/sharing/best-practices
  5526. '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',
  5527. 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
  5528. 'DesktopMode' => 'WPDesktop',
  5529. 'TV' => 'SonyDTV|HbbTV', // experimental
  5530. 'WebKit' => '(webkit)[ /]([\w.]+)',
  5531. // @todo: Include JXD consoles.
  5532. 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
  5533. 'Watch' => 'SM-V700',
  5534. );
  5535. /**
  5536. * All possible HTTP headers that represent the
  5537. * User-Agent string.
  5538. *
  5539. * @var array
  5540. */
  5541. protected static $uaHttpHeaders = array(
  5542. // The default User-Agent string.
  5543. 'HTTP_USER_AGENT',
  5544. // Header can occur on devices using Opera Mini.
  5545. 'HTTP_X_OPERAMINI_PHONE_UA',
  5546. // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
  5547. 'HTTP_X_DEVICE_USER_AGENT',
  5548. 'HTTP_X_ORIGINAL_USER_AGENT',
  5549. 'HTTP_X_SKYFIRE_PHONE',
  5550. 'HTTP_X_BOLT_PHONE_UA',
  5551. 'HTTP_DEVICE_STOCK_UA',
  5552. 'HTTP_X_UCBROWSER_DEVICE_UA'
  5553. );
  5554. /**
  5555. * The individual segments that could exist in a User-Agent string. VER refers to the regular
  5556. * expression defined in the constant self::VER.
  5557. *
  5558. * @var array
  5559. */
  5560. protected static $properties = array(
  5561. // Build
  5562. 'Mobile' => 'Mobile/[VER]',
  5563. 'Build' => 'Build/[VER]',
  5564. 'Version' => 'Version/[VER]',
  5565. 'VendorID' => 'VendorID/[VER]',
  5566. // Devices
  5567. 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
  5568. 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
  5569. 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
  5570. //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
  5571. 'Kindle' => 'Kindle/[VER]',
  5572. // Browser
  5573. 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
  5574. 'Coast' => array('Coast/[VER]'),
  5575. 'Dolfin' => 'Dolfin/[VER]',
  5576. // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
  5577. 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
  5578. 'Fennec' => 'Fennec/[VER]',
  5579. // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  5580. // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
  5581. 'Edge' => 'Edge/[VER]',
  5582. 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
  5583. // http://en.wikipedia.org/wiki/NetFront
  5584. 'NetFront' => 'NetFront/[VER]',
  5585. 'NokiaBrowser' => 'NokiaBrowser/[VER]',
  5586. 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
  5587. 'Opera Mini' => 'Opera Mini/[VER]',
  5588. 'Opera Mobi' => 'Version/[VER]',
  5589. 'UC Browser' => 'UC Browser[VER]',
  5590. 'MQQBrowser' => 'MQQBrowser/[VER]',
  5591. 'MicroMessenger' => 'MicroMessenger/[VER]',
  5592. 'baiduboxapp' => 'baiduboxapp/[VER]',
  5593. 'baidubrowser' => 'baidubrowser/[VER]',
  5594. 'SamsungBrowser' => 'SamsungBrowser/[VER]',
  5595. 'Iron' => 'Iron/[VER]',
  5596. // @note: Safari 7534.48.3 is actually Version 5.1.
  5597. // @note: On BlackBerry the Version is overwriten by the OS.
  5598. 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
  5599. 'Skyfire' => 'Skyfire/[VER]',
  5600. 'Tizen' => 'Tizen/[VER]',
  5601. 'Webkit' => 'webkit[ /][VER]',
  5602. 'PaleMoon' => 'PaleMoon/[VER]',
  5603. // Engine
  5604. 'Gecko' => 'Gecko/[VER]',
  5605. 'Trident' => 'Trident/[VER]',
  5606. 'Presto' => 'Presto/[VER]',
  5607. 'Goanna' => 'Goanna/[VER]',
  5608. // OS
  5609. 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
  5610. 'Android' => 'Android [VER]',
  5611. 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
  5612. 'BREW' => 'BREW [VER]',
  5613. 'Java' => 'Java/[VER]',
  5614. // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
  5615. // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
  5616. 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
  5617. 'Windows Phone' => 'Windows Phone [VER]',
  5618. 'Windows CE' => 'Windows CE/[VER]',
  5619. // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
  5620. 'Windows NT' => 'Windows NT [VER]',
  5621. 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
  5622. 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
  5623. );
  5624. /**
  5625. * Construct an instance of this class.
  5626. *
  5627. * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
  5628. * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
  5629. * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
  5630. * from the $headers array instead.
  5631. */
  5632. public function __construct(
  5633. array $headers = null,
  5634. $userAgent = null
  5635. ) {
  5636. $this->setHttpHeaders($headers);
  5637. $this->setUserAgent($userAgent);
  5638. }
  5639. /**
  5640. * Get the current script version.
  5641. * This is useful for the demo.php file,
  5642. * so people can check on what version they are testing
  5643. * for mobile devices.
  5644. *
  5645. * @return string The version number in semantic version format.
  5646. */
  5647. public static function getScriptVersion()
  5648. {
  5649. return self::VERSION;
  5650. }
  5651. /**
  5652. * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
  5653. *
  5654. * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
  5655. * the headers. The default null is left for backwards compatibility.
  5656. */
  5657. public function setHttpHeaders($httpHeaders = null)
  5658. {
  5659. // use global _SERVER if $httpHeaders aren't defined
  5660. if (!is_array($httpHeaders) || !count($httpHeaders)) {
  5661. $httpHeaders = $_SERVER;
  5662. }
  5663. // clear existing headers
  5664. $this->httpHeaders = array();
  5665. // Only save HTTP headers. In PHP land, that means only _SERVER vars that
  5666. // start with HTTP_.
  5667. foreach ($httpHeaders as $key => $value) {
  5668. if (substr($key, 0, 5) === 'HTTP_') {
  5669. $this->httpHeaders[$key] = $value;
  5670. }
  5671. }
  5672. // In case we're dealing with CloudFront, we need to know.
  5673. $this->setCfHeaders($httpHeaders);
  5674. }
  5675. /**
  5676. * Retrieves the HTTP headers.
  5677. *
  5678. * @return array
  5679. */
  5680. public function getHttpHeaders()
  5681. {
  5682. return $this->httpHeaders;
  5683. }
  5684. /**
  5685. * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
  5686. * Simply null is returned.
  5687. *
  5688. * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
  5689. * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
  5690. * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
  5691. *
  5692. * @return string|null The value of the header.
  5693. */
  5694. public function getHttpHeader($header)
  5695. {
  5696. // are we using PHP-flavored headers?
  5697. if (strpos($header, '_') === false) {
  5698. $header = str_replace('-', '_', $header);
  5699. $header = strtoupper($header);
  5700. }
  5701. // test the alternate, too
  5702. $altHeader = 'HTTP_' . $header;
  5703. //Test both the regular and the HTTP_ prefix
  5704. if (isset($this->httpHeaders[$header])) {
  5705. return $this->httpHeaders[$header];
  5706. } elseif (isset($this->httpHeaders[$altHeader])) {
  5707. return $this->httpHeaders[$altHeader];
  5708. }
  5709. return null;
  5710. }
  5711. public function getMobileHeaders()
  5712. {
  5713. return self::$mobileHeaders;
  5714. }
  5715. /**
  5716. * Get all possible HTTP headers that
  5717. * can contain the User-Agent string.
  5718. *
  5719. * @return array List of HTTP headers.
  5720. */
  5721. public function getUaHttpHeaders()
  5722. {
  5723. return self::$uaHttpHeaders;
  5724. }
  5725. /**
  5726. * Set CloudFront headers
  5727. * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
  5728. *
  5729. * @param array $cfHeaders List of HTTP headers
  5730. *
  5731. * @return boolean If there were CloudFront headers to be set
  5732. */
  5733. public function setCfHeaders($cfHeaders = null) {
  5734. // use global _SERVER if $cfHeaders aren't defined
  5735. if (!is_array($cfHeaders) || !count($cfHeaders)) {
  5736. $cfHeaders = $_SERVER;
  5737. }
  5738. // clear existing headers
  5739. $this->cloudfrontHeaders = array();
  5740. // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
  5741. // start with cloudfront-.
  5742. $response = false;
  5743. foreach ($cfHeaders as $key => $value) {
  5744. if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
  5745. $this->cloudfrontHeaders[strtoupper($key)] = $value;
  5746. $response = true;
  5747. }
  5748. }
  5749. return $response;
  5750. }
  5751. /**
  5752. * Retrieves the cloudfront headers.
  5753. *
  5754. * @return array
  5755. */
  5756. public function getCfHeaders()
  5757. {
  5758. return $this->cloudfrontHeaders;
  5759. }
  5760. /**
  5761. * Set the User-Agent to be used.
  5762. *
  5763. * @param string $userAgent The user agent string to set.
  5764. *
  5765. * @return string|null
  5766. */
  5767. public function setUserAgent($userAgent = null)
  5768. {
  5769. // Invalidate cache due to #375
  5770. $this->cache = array();
  5771. if (false === empty($userAgent)) {
  5772. return $this->userAgent = $userAgent;
  5773. } else {
  5774. $this->userAgent = null;
  5775. foreach ($this->getUaHttpHeaders() as $altHeader) {
  5776. if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
  5777. $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
  5778. }
  5779. }
  5780. if (!empty($this->userAgent)) {
  5781. return $this->userAgent = trim($this->userAgent);
  5782. }
  5783. }
  5784. if (count($this->getCfHeaders()) > 0) {
  5785. return $this->userAgent = 'Amazon CloudFront';
  5786. }
  5787. return $this->userAgent = null;
  5788. }
  5789. /**
  5790. * Retrieve the User-Agent.
  5791. *
  5792. * @return string|null The user agent if it's set.
  5793. */
  5794. public function getUserAgent()
  5795. {
  5796. return $this->userAgent;
  5797. }
  5798. /**
  5799. * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
  5800. * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
  5801. *
  5802. * @deprecated since version 2.6.9
  5803. *
  5804. * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
  5805. * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
  5806. */
  5807. public function setDetectionType($type = null)
  5808. {
  5809. if ($type === null) {
  5810. $type = self::DETECTION_TYPE_MOBILE;
  5811. }
  5812. if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
  5813. return;
  5814. }
  5815. $this->detectionType = $type;
  5816. }
  5817. public function getMatchingRegex()
  5818. {
  5819. return $this->matchingRegex;
  5820. }
  5821. public function getMatchesArray()
  5822. {
  5823. return $this->matchesArray;
  5824. }
  5825. /**
  5826. * Retrieve the list of known phone devices.
  5827. *
  5828. * @return array List of phone devices.
  5829. */
  5830. public static function getPhoneDevices()
  5831. {
  5832. return self::$phoneDevices;
  5833. }
  5834. /**
  5835. * Retrieve the list of known tablet devices.
  5836. *
  5837. * @return array List of tablet devices.
  5838. */
  5839. public static function getTabletDevices()
  5840. {
  5841. return self::$tabletDevices;
  5842. }
  5843. /**
  5844. * Alias for getBrowsers() method.
  5845. *
  5846. * @return array List of user agents.
  5847. */
  5848. public static function getUserAgents()
  5849. {
  5850. return self::getBrowsers();
  5851. }
  5852. /**
  5853. * Retrieve the list of known browsers. Specifically, the user agents.
  5854. *
  5855. * @return array List of browsers / user agents.
  5856. */
  5857. public static function getBrowsers()
  5858. {
  5859. return self::$browsers;
  5860. }
  5861. /**
  5862. * Retrieve the list of known utilities.
  5863. *
  5864. * @return array List of utilities.
  5865. */
  5866. public static function getUtilities()
  5867. {
  5868. return self::$utilities;
  5869. }
  5870. /**
  5871. * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
  5872. *
  5873. * @deprecated since version 2.6.9
  5874. *
  5875. * @return array All the rules (but not extended).
  5876. */
  5877. public static function getMobileDetectionRules()
  5878. {
  5879. static $rules;
  5880. if (!$rules) {
  5881. $rules = array_merge(
  5882. self::$phoneDevices,
  5883. self::$tabletDevices,
  5884. self::$operatingSystems,
  5885. self::$browsers
  5886. );
  5887. }
  5888. return $rules;
  5889. }
  5890. /**
  5891. * Method gets the mobile detection rules + utilities.
  5892. * The reason this is separate is because utilities rules
  5893. * don't necessary imply mobile. This method is used inside
  5894. * the new $detect->is('stuff') method.
  5895. *
  5896. * @deprecated since version 2.6.9
  5897. *
  5898. * @return array All the rules + extended.
  5899. */
  5900. public function getMobileDetectionRulesExtended()
  5901. {
  5902. static $rules;
  5903. if (!$rules) {
  5904. // Merge all rules together.
  5905. $rules = array_merge(
  5906. self::$phoneDevices,
  5907. self::$tabletDevices,
  5908. self::$operatingSystems,
  5909. self::$browsers,
  5910. self::$utilities
  5911. );
  5912. }
  5913. return $rules;
  5914. }
  5915. /**
  5916. * Retrieve the current set of rules.
  5917. *
  5918. * @deprecated since version 2.6.9
  5919. *
  5920. * @return array
  5921. */
  5922. public function getRules()
  5923. {
  5924. if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
  5925. return self::getMobileDetectionRulesExtended();
  5926. } else {
  5927. return self::getMobileDetectionRules();
  5928. }
  5929. }
  5930. /**
  5931. * Retrieve the list of mobile operating systems.
  5932. *
  5933. * @return array The list of mobile operating systems.
  5934. */
  5935. public static function getOperatingSystems()
  5936. {
  5937. return self::$operatingSystems;
  5938. }
  5939. /**
  5940. * Check the HTTP headers for signs of mobile.
  5941. * This is the fastest mobile check possible; it's used
  5942. * inside isMobile() method.
  5943. *
  5944. * @return bool
  5945. */
  5946. public function checkHttpHeadersForMobile()
  5947. {
  5948. foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
  5949. if (isset($this->httpHeaders[$mobileHeader])) {
  5950. if (is_array($matchType['matches'])) {
  5951. foreach ($matchType['matches'] as $_match) {
  5952. if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
  5953. return true;
  5954. }
  5955. }
  5956. return false;
  5957. } else {
  5958. return true;
  5959. }
  5960. }
  5961. }
  5962. return false;
  5963. }
  5964. /**
  5965. * Magic overloading method.
  5966. *
  5967. * @method boolean is[...]()
  5968. * @param string $name
  5969. * @param array $arguments
  5970. * @return mixed
  5971. * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
  5972. */
  5973. public function __call($name, $arguments)
  5974. {
  5975. // make sure the name starts with 'is', otherwise
  5976. if (substr($name, 0, 2) !== 'is') {
  5977. throw new BadMethodCallException("No such method exists: $name");
  5978. }
  5979. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  5980. $key = substr($name, 2);
  5981. return $this->matchUAAgainstKey($key);
  5982. }
  5983. /**
  5984. * Find a detection rule that matches the current User-agent.
  5985. *
  5986. * @param null $userAgent deprecated
  5987. * @return boolean
  5988. */
  5989. protected function matchDetectionRulesAgainstUA($userAgent = null)
  5990. {
  5991. // Begin general search.
  5992. foreach ($this->getRules() as $_regex) {
  5993. if (empty($_regex)) {
  5994. continue;
  5995. }
  5996. if ($this->match($_regex, $userAgent)) {
  5997. return true;
  5998. }
  5999. }
  6000. return false;
  6001. }
  6002. /**
  6003. * Search for a certain key in the rules array.
  6004. * If the key is found then try to match the corresponding
  6005. * regex against the User-Agent.
  6006. *
  6007. * @param string $key
  6008. *
  6009. * @return boolean
  6010. */
  6011. protected function matchUAAgainstKey($key)
  6012. {
  6013. // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
  6014. $key = strtolower($key);
  6015. if (false === isset($this->cache[$key])) {
  6016. // change the keys to lower case
  6017. $_rules = array_change_key_case($this->getRules());
  6018. if (false === empty($_rules[$key])) {
  6019. $this->cache[$key] = $this->match($_rules[$key]);
  6020. }
  6021. if (false === isset($this->cache[$key])) {
  6022. $this->cache[$key] = false;
  6023. }
  6024. }
  6025. return $this->cache[$key];
  6026. }
  6027. /**
  6028. * Check if the device is mobile.
  6029. * Returns true if any type of mobile device detected, including special ones
  6030. * @param null $userAgent deprecated
  6031. * @param null $httpHeaders deprecated
  6032. * @return bool
  6033. */
  6034. public function isMobile($userAgent = null, $httpHeaders = null)
  6035. {
  6036. if ($httpHeaders) {
  6037. $this->setHttpHeaders($httpHeaders);
  6038. }
  6039. if ($userAgent) {
  6040. $this->setUserAgent($userAgent);
  6041. }
  6042. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6043. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6044. $cfHeaders = $this->getCfHeaders();
  6045. if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
  6046. return true;
  6047. }
  6048. }
  6049. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6050. if ($this->checkHttpHeadersForMobile()) {
  6051. return true;
  6052. } else {
  6053. return $this->matchDetectionRulesAgainstUA();
  6054. }
  6055. }
  6056. /**
  6057. * Check if the device is a tablet.
  6058. * Return true if any type of tablet device is detected.
  6059. *
  6060. * @param string $userAgent deprecated
  6061. * @param array $httpHeaders deprecated
  6062. * @return bool
  6063. */
  6064. public function isTablet($userAgent = null, $httpHeaders = null)
  6065. {
  6066. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6067. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6068. $cfHeaders = $this->getCfHeaders();
  6069. if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
  6070. return true;
  6071. }
  6072. }
  6073. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6074. foreach (self::$tabletDevices as $_regex) {
  6075. if ($this->match($_regex, $userAgent)) {
  6076. return true;
  6077. }
  6078. }
  6079. return false;
  6080. }
  6081. /**
  6082. * This method checks for a certain property in the
  6083. * userAgent.
  6084. * @todo: The httpHeaders part is not yet used.
  6085. *
  6086. * @param string $key
  6087. * @param string $userAgent deprecated
  6088. * @param string $httpHeaders deprecated
  6089. * @return bool|int|null
  6090. */
  6091. public function is($key, $userAgent = null, $httpHeaders = null)
  6092. {
  6093. // Set the UA and HTTP headers only if needed (eg. batch mode).
  6094. if ($httpHeaders) {
  6095. $this->setHttpHeaders($httpHeaders);
  6096. }
  6097. if ($userAgent) {
  6098. $this->setUserAgent($userAgent);
  6099. }
  6100. $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
  6101. return $this->matchUAAgainstKey($key);
  6102. }
  6103. /**
  6104. * Some detection rules are relative (not standard),
  6105. * because of the diversity of devices, vendors and
  6106. * their conventions in representing the User-Agent or
  6107. * the HTTP headers.
  6108. *
  6109. * This method will be used to check custom regexes against
  6110. * the User-Agent string.
  6111. *
  6112. * @param $regex
  6113. * @param string $userAgent
  6114. * @return bool
  6115. *
  6116. * @todo: search in the HTTP headers too.
  6117. */
  6118. public function match($regex, $userAgent = null)
  6119. {
  6120. $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
  6121. // If positive match is found, store the results for debug.
  6122. if ($match) {
  6123. $this->matchingRegex = $regex;
  6124. $this->matchesArray = $matches;
  6125. }
  6126. return $match;
  6127. }
  6128. /**
  6129. * Get the properties array.
  6130. *
  6131. * @return array
  6132. */
  6133. public static function getProperties()
  6134. {
  6135. return self::$properties;
  6136. }
  6137. /**
  6138. * Prepare the version number.
  6139. *
  6140. * @todo Remove the error supression from str_replace() call.
  6141. *
  6142. * @param string $ver The string version, like "2.6.21.2152";
  6143. *
  6144. * @return float
  6145. */
  6146. public function prepareVersionNo($ver)
  6147. {
  6148. $ver = str_replace(array('_', ' ', '/'), '.', $ver);
  6149. $arrVer = explode('.', $ver, 2);
  6150. if (isset($arrVer[1])) {
  6151. $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
  6152. }
  6153. return (float) implode('.', $arrVer);
  6154. }
  6155. /**
  6156. * Check the version of the given property in the User-Agent.
  6157. * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
  6158. *
  6159. * @param string $propertyName The name of the property. See self::getProperties() array
  6160. * keys for all possible properties.
  6161. * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
  6162. * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
  6163. * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
  6164. * invalid parameter will default to the this type as well.
  6165. *
  6166. * @return string|float The version of the property we are trying to extract.
  6167. */
  6168. public function version($propertyName, $type = self::VERSION_TYPE_STRING)
  6169. {
  6170. if (empty($propertyName)) {
  6171. return false;
  6172. }
  6173. // set the $type to the default if we don't recognize the type
  6174. if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
  6175. $type = self::VERSION_TYPE_STRING;
  6176. }
  6177. $properties = self::getProperties();
  6178. // Check if the property exists in the properties array.
  6179. if (true === isset($properties[$propertyName])) {
  6180. // Prepare the pattern to be matched.
  6181. // Make sure we always deal with an array (string is converted).
  6182. $properties[$propertyName] = (array) $properties[$propertyName];
  6183. foreach ($properties[$propertyName] as $propertyMatchString) {
  6184. $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
  6185. // Identify and extract the version.
  6186. preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
  6187. if (false === empty($match[1])) {
  6188. $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
  6189. return $version;
  6190. }
  6191. }
  6192. }
  6193. return false;
  6194. }
  6195. /**
  6196. * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
  6197. *
  6198. * @return string One of the self::MOBILE_GRADE_* constants.
  6199. */
  6200. public function mobileGrade()
  6201. {
  6202. $isMobile = $this->isMobile();
  6203. if (
  6204. // 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)
  6205. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6206. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6207. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6208. // 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)
  6209. // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
  6210. // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
  6211. // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
  6212. ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
  6213. // 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)
  6214. $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
  6215. // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
  6216. $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
  6217. // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
  6218. $this->match('Playbook.*Tablet') ||
  6219. // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
  6220. ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
  6221. // Palm WebOS 3.0 - Tested on HP TouchPad
  6222. $this->match('hp.*TouchPad') ||
  6223. // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
  6224. ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
  6225. // Chrome for Android - Tested on Android 4.0, 4.1 device
  6226. ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
  6227. // Skyfire 4.1 - Tested on Android 2.3 device
  6228. ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6229. // Opera Mobile 11.5-12: Tested on Android 2.3
  6230. ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
  6231. // Meego 1.2 - Tested on Nokia 950 and N9
  6232. $this->is('MeeGoOS') ||
  6233. // Tizen (pre-release) - Tested on early hardware
  6234. $this->is('Tizen') ||
  6235. // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
  6236. // @todo: more tests here!
  6237. $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
  6238. // UC Browser - Tested on Android 2.3 device
  6239. ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6240. // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
  6241. ( $this->match('Kindle Fire') ||
  6242. $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
  6243. // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
  6244. $this->is('AndroidOS') && $this->is('NookTablet') ||
  6245. // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
  6246. $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
  6247. // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
  6248. $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
  6249. // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
  6250. $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
  6251. // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
  6252. $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
  6253. // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
  6254. $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
  6255. ){
  6256. return self::MOBILE_GRADE_A;
  6257. }
  6258. if (
  6259. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
  6260. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
  6261. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
  6262. // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
  6263. $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
  6264. //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
  6265. ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
  6266. ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
  6267. // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
  6268. $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
  6269. // @todo: report this (tested on Nokia N71)
  6270. $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
  6271. ){
  6272. return self::MOBILE_GRADE_B;
  6273. }
  6274. if (
  6275. // Blackberry 4.x - Tested on the Curve 8330
  6276. $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
  6277. // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
  6278. $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
  6279. // Tested on original iPhone (3.1), iPhone 3 (3.2)
  6280. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6281. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6282. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6283. // Internet Explorer 7 and older - Tested on Windows XP
  6284. $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
  6285. ){
  6286. return self::MOBILE_GRADE_C;
  6287. }
  6288. // All older smartphone platforms and featurephones - Any device that doesn't support media queries
  6289. // will receive the basic, C grade experience.
  6290. return self::MOBILE_GRADE_C;
  6291. }
  6292. }
  6293. $mobileDetect = new Mobile_Detect;
  6294. $userDevice = ($mobileDetect->isMobile() ? ($mobileDetect->isTablet() ? 'tablet' : 'phone') : 'computer');
  6295. function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  6296. $path = getServerPath();
  6297. return '
  6298. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6299. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  6300. <head>
  6301. <!--[if gte mso 9]><xml>
  6302. <o:OfficeDocumentSettings>
  6303. <o:AllowPNG/>
  6304. <o:PixelsPerInch>96</o:PixelsPerInch>
  6305. </o:OfficeDocumentSettings>
  6306. </xml><![endif]-->
  6307. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6308. <meta name="viewport" content="width=device-width">
  6309. <!--[if !mso]><!-->
  6310. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6311. <!--<![endif]-->
  6312. <title></title>
  6313. <!--[if !mso]><!-- -->
  6314. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
  6315. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  6316. <!--<![endif]-->
  6317. <style type="text/css" id="media-query">
  6318. body {
  6319. margin: 0;
  6320. padding: 0;
  6321. }
  6322. table,
  6323. tr,
  6324. td {
  6325. vertical-align: top;
  6326. border-collapse: collapse;
  6327. }
  6328. .ie-browser table,
  6329. .mso-container table {
  6330. table-layout: fixed;
  6331. }
  6332. * {
  6333. line-height: inherit;
  6334. }
  6335. a[x-apple-data-detectors=true] {
  6336. color: inherit !important;
  6337. text-decoration: none !important;
  6338. }
  6339. [owa] .img-container div,
  6340. [owa] .img-container button {
  6341. display: block !important;
  6342. }
  6343. [owa] .fullwidth button {
  6344. width: 100% !important;
  6345. }
  6346. [owa] .block-grid .col {
  6347. display: table-cell;
  6348. float: none !important;
  6349. vertical-align: top;
  6350. }
  6351. .ie-browser .num12,
  6352. .ie-browser .block-grid,
  6353. [owa] .num12,
  6354. [owa] .block-grid {
  6355. width: 615px !important;
  6356. }
  6357. .ExternalClass,
  6358. .ExternalClass p,
  6359. .ExternalClass span,
  6360. .ExternalClass font,
  6361. .ExternalClass td,
  6362. .ExternalClass div {
  6363. line-height: 100%;
  6364. }
  6365. .ie-browser .mixed-two-up .num4,
  6366. [owa] .mixed-two-up .num4 {
  6367. width: 204px !important;
  6368. }
  6369. .ie-browser .mixed-two-up .num8,
  6370. [owa] .mixed-two-up .num8 {
  6371. width: 408px !important;
  6372. }
  6373. .ie-browser .block-grid.two-up .col,
  6374. [owa] .block-grid.two-up .col {
  6375. width: 307px !important;
  6376. }
  6377. .ie-browser .block-grid.three-up .col,
  6378. [owa] .block-grid.three-up .col {
  6379. width: 205px !important;
  6380. }
  6381. .ie-browser .block-grid.four-up .col,
  6382. [owa] .block-grid.four-up .col {
  6383. width: 153px !important;
  6384. }
  6385. .ie-browser .block-grid.five-up .col,
  6386. [owa] .block-grid.five-up .col {
  6387. width: 123px !important;
  6388. }
  6389. .ie-browser .block-grid.six-up .col,
  6390. [owa] .block-grid.six-up .col {
  6391. width: 102px !important;
  6392. }
  6393. .ie-browser .block-grid.seven-up .col,
  6394. [owa] .block-grid.seven-up .col {
  6395. width: 87px !important;
  6396. }
  6397. .ie-browser .block-grid.eight-up .col,
  6398. [owa] .block-grid.eight-up .col {
  6399. width: 76px !important;
  6400. }
  6401. .ie-browser .block-grid.nine-up .col,
  6402. [owa] .block-grid.nine-up .col {
  6403. width: 68px !important;
  6404. }
  6405. .ie-browser .block-grid.ten-up .col,
  6406. [owa] .block-grid.ten-up .col {
  6407. width: 61px !important;
  6408. }
  6409. .ie-browser .block-grid.eleven-up .col,
  6410. [owa] .block-grid.eleven-up .col {
  6411. width: 55px !important;
  6412. }
  6413. .ie-browser .block-grid.twelve-up .col,
  6414. [owa] .block-grid.twelve-up .col {
  6415. width: 51px !important;
  6416. }
  6417. @media only screen and (min-width: 635px) {
  6418. .block-grid {
  6419. width: 615px !important;
  6420. }
  6421. .block-grid .col {
  6422. display: table-cell;
  6423. Float: none !important;
  6424. vertical-align: top;
  6425. }
  6426. .block-grid .col.num12 {
  6427. width: 615px !important;
  6428. }
  6429. .block-grid.mixed-two-up .col.num4 {
  6430. width: 204px !important;
  6431. }
  6432. .block-grid.mixed-two-up .col.num8 {
  6433. width: 408px !important;
  6434. }
  6435. .block-grid.two-up .col {
  6436. width: 307px !important;
  6437. }
  6438. .block-grid.three-up .col {
  6439. width: 205px !important;
  6440. }
  6441. .block-grid.four-up .col {
  6442. width: 153px !important;
  6443. }
  6444. .block-grid.five-up .col {
  6445. width: 123px !important;
  6446. }
  6447. .block-grid.six-up .col {
  6448. width: 102px !important;
  6449. }
  6450. .block-grid.seven-up .col {
  6451. width: 87px !important;
  6452. }
  6453. .block-grid.eight-up .col {
  6454. width: 76px !important;
  6455. }
  6456. .block-grid.nine-up .col {
  6457. width: 68px !important;
  6458. }
  6459. .block-grid.ten-up .col {
  6460. width: 61px !important;
  6461. }
  6462. .block-grid.eleven-up .col {
  6463. width: 55px !important;
  6464. }
  6465. .block-grid.twelve-up .col {
  6466. width: 51px !important;
  6467. }
  6468. }
  6469. @media (max-width: 635px) {
  6470. .block-grid,
  6471. .col {
  6472. min-width: 320px !important;
  6473. max-width: 100% !important;
  6474. }
  6475. .block-grid {
  6476. width: calc(100% - 40px) !important;
  6477. }
  6478. .col {
  6479. width: 100% !important;
  6480. }
  6481. .col>div {
  6482. margin: 0 auto;
  6483. }
  6484. img.fullwidth {
  6485. max-width: 100% !important;
  6486. }
  6487. }
  6488. </style>
  6489. </head>
  6490. <body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #FFFFFF">
  6491. <!--[if IE]><div class="ie-browser"><![endif]-->
  6492. <!--[if mso]><div class="mso-container"><![endif]-->
  6493. <div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: #FFFFFF">
  6494. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #FFFFFF;"><![endif]-->
  6495. <div style="background-color:#333333;">
  6496. <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;"
  6497. class="block-grid ">
  6498. <div style="border-collapse: collapse;display: table;width: 100%;">
  6499. <!--[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]-->
  6500. <!--[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]-->
  6501. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6502. <div style="background-color: transparent; width: 100% !important;">
  6503. <!--[if (!mso)&(!IE)]><!-->
  6504. <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;">
  6505. <!--<![endif]-->
  6506. <div align="left" class="img-container left fullwidth" style="padding-right: 30px; padding-left: 30px;">
  6507. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px;" align="left"><![endif]-->
  6508. <img class="left fullwidth" align="left" border="0" src="'.$path.'images/organizr-logo-h.png" alt="Image" title="Image"
  6509. 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"
  6510. width="555">
  6511. <!--[if mso]></td></tr></table><![endif]-->
  6512. </div>
  6513. <!--[if (!mso)&(!IE)]><!-->
  6514. </div>
  6515. <!--<![endif]-->
  6516. </div>
  6517. </div>
  6518. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6519. </div>
  6520. </div>
  6521. </div>
  6522. <div style="background-color:#333333;">
  6523. <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;"
  6524. class="block-grid ">
  6525. <div style="border-collapse: collapse;display: table;width: 100%;">
  6526. <!--[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]-->
  6527. <!--[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]-->
  6528. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6529. <div style="background-color: transparent; width: 100% !important;">
  6530. <!--[if (!mso)&(!IE)]><!-->
  6531. <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;">
  6532. <!--<![endif]-->
  6533. <!--[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]-->
  6534. <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;">
  6535. <div style="font-size:12px;line-height:14px;color:#FFFFFF;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6536. <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>
  6537. </span>
  6538. </p>
  6539. </div>
  6540. </div>
  6541. <!--[if mso]></td></tr></table><![endif]-->
  6542. <!--[if (!mso)&(!IE)]><!-->
  6543. </div>
  6544. <!--<![endif]-->
  6545. </div>
  6546. </div>
  6547. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6548. </div>
  6549. </div>
  6550. </div>
  6551. <div style="background-color:#393939;">
  6552. <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;"
  6553. class="block-grid ">
  6554. <div style="border-collapse: collapse;display: table;width: 100%;">
  6555. <!--[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]-->
  6556. <!--[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]-->
  6557. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6558. <div style="background-color: transparent; width: 100% !important;">
  6559. <!--[if (!mso)&(!IE)]><!-->
  6560. <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;">
  6561. <!--<![endif]-->
  6562. <!--[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]-->
  6563. <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;">
  6564. <div style="font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6565. <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>
  6566. </div>
  6567. </div>
  6568. <!--[if mso]></td></tr></table><![endif]-->
  6569. <div style="padding-right: 5px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px;">
  6570. <!--[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]-->
  6571. <div align="center">
  6572. <div style="border-top: 2px solid #66D9EF; width:55%; line-height:2px; height:2px; font-size:2px;">&#160;</div>
  6573. </div>
  6574. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6575. </div>
  6576. <!--[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]-->
  6577. <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;">
  6578. <div style="font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6579. <p style="margin: 0;font-size: 12px;line-height: 14px"><span style="font-size: 28px; line-height: 33px;">Hey '.$user.',</span></p>
  6580. </div>
  6581. </div>
  6582. <!--[if mso]></td></tr></table><![endif]-->
  6583. <!--[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]-->
  6584. <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;">
  6585. <div style="font-size:12px;line-height:22px;font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;color:#FFFFFF;text-align:left;">
  6586. <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>
  6587. </span>
  6588. </p>
  6589. </div>
  6590. </div>
  6591. <!--[if mso]></td></tr></table><![endif]-->
  6592. <div align="center" class="button-container center" style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;">
  6593. <!--[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]-->
  6594. <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">
  6595. <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>
  6596. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6597. </div>
  6598. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6599. </div>
  6600. <!--[if (!mso)&(!IE)]><!-->
  6601. </div>
  6602. <!--<![endif]-->
  6603. </div>
  6604. </div>
  6605. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6606. </div>
  6607. </div>
  6608. </div>
  6609. <div style="background-color:#ffffff;">
  6610. <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;"
  6611. class="block-grid ">
  6612. <div style="border-collapse: collapse;display: table;width: 100%;">
  6613. <!--[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]-->
  6614. <!--[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]-->
  6615. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6616. <div style="background-color: transparent; width: 100% !important;">
  6617. <!--[if (!mso)&(!IE)]><!-->
  6618. <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;">
  6619. <!--<![endif]-->
  6620. <!--[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]-->
  6621. <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;">
  6622. <div style="font-size:12px;line-height:14px;color:#555555;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6623. <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>
  6624. </div>
  6625. </div>
  6626. <!--[if mso]></td></tr></table><![endif]-->
  6627. <div style="padding-right: 20px; padding-left: 20px; padding-top: 15px; padding-bottom: 20px;">
  6628. <!--[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]-->
  6629. <div align="center">
  6630. <div style="border-top: 3px solid #66D9EF; width:40%; line-height:3px; height:3px; font-size:3px;">&#160;</div>
  6631. </div>
  6632. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6633. </div>
  6634. <!--[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]-->
  6635. <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;">
  6636. <div style="font-size:12px;line-height:22px;color:#7E7D7D;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6637. <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>
  6638. </div>
  6639. </div>
  6640. <!--[if mso]></td></tr></table><![endif]-->
  6641. <!--[if (!mso)&(!IE)]><!-->
  6642. </div>
  6643. <!--<![endif]-->
  6644. </div>
  6645. </div>
  6646. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6647. </div>
  6648. </div>
  6649. </div>
  6650. <div style="background-color:#333333;">
  6651. <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;"
  6652. class="block-grid ">
  6653. <div style="border-collapse: collapse;display: table;width: 100%;">
  6654. <!--[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]-->
  6655. <!--[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]-->
  6656. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6657. <div style="background-color: transparent; width: 100% !important;">
  6658. <!--[if (!mso)&(!IE)]><!-->
  6659. <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;">
  6660. <!--<![endif]-->
  6661. <!--[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]-->
  6662. <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;">
  6663. <div style="font-size:12px;line-height:14px;color:#959595;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6664. <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"
  6665. href="https://github.com/causefx/Organizr" target="_blank" rel="noopener noreferrer">Organizr</a><strong><br></strong></p>
  6666. </div>
  6667. </div>
  6668. <!--[if mso]></td></tr></table><![endif]-->
  6669. <!--[if (!mso)&(!IE)]><!-->
  6670. </div>
  6671. <!--<![endif]-->
  6672. </div>
  6673. </div>
  6674. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6675. </div>
  6676. </div>
  6677. </div>
  6678. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  6679. </div>
  6680. <!--[if (mso)|(IE)]></div><![endif]-->
  6681. </body>
  6682. </html>
  6683. ';
  6684. }
  6685. function mimeTypes(){
  6686. return array(
  6687. '123' => 'application/vnd.lotus-1-2-3',
  6688. '3dml' => 'text/vnd.in3d.3dml',
  6689. '3ds' => 'image/x-3ds',
  6690. '3g2' => 'video/3gpp2',
  6691. '3gp' => 'video/3gpp',
  6692. '7z' => 'application/x-7z-compressed',
  6693. 'aab' => 'application/x-authorware-bin',
  6694. 'aac' => 'audio/x-aac',
  6695. 'aam' => 'application/x-authorware-map',
  6696. 'aas' => 'application/x-authorware-seg',
  6697. 'abw' => 'application/x-abiword',
  6698. 'ac' => 'application/pkix-attr-cert',
  6699. 'acc' => 'application/vnd.americandynamics.acc',
  6700. 'ace' => 'application/x-ace-compressed',
  6701. 'acu' => 'application/vnd.acucobol',
  6702. 'acutc' => 'application/vnd.acucorp',
  6703. 'adp' => 'audio/adpcm',
  6704. 'aep' => 'application/vnd.audiograph',
  6705. 'afm' => 'application/x-font-type1',
  6706. 'afp' => 'application/vnd.ibm.modcap',
  6707. 'ahead' => 'application/vnd.ahead.space',
  6708. 'ai' => 'application/postscript',
  6709. 'aif' => 'audio/x-aiff',
  6710. 'aifc' => 'audio/x-aiff',
  6711. 'aiff' => 'audio/x-aiff',
  6712. 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
  6713. 'ait' => 'application/vnd.dvb.ait',
  6714. 'ami' => 'application/vnd.amiga.ami',
  6715. 'apk' => 'application/vnd.android.package-archive',
  6716. 'appcache' => 'text/cache-manifest',
  6717. 'application' => 'application/x-ms-application',
  6718. 'apr' => 'application/vnd.lotus-approach',
  6719. 'arc' => 'application/x-freearc',
  6720. 'asc' => 'application/pgp-signature',
  6721. 'asf' => 'video/x-ms-asf',
  6722. 'asm' => 'text/x-asm',
  6723. 'aso' => 'application/vnd.accpac.simply.aso',
  6724. 'asx' => 'video/x-ms-asf',
  6725. 'atc' => 'application/vnd.acucorp',
  6726. 'atom' => 'application/atom+xml',
  6727. 'atomcat' => 'application/atomcat+xml',
  6728. 'atomsvc' => 'application/atomsvc+xml',
  6729. 'atx' => 'application/vnd.antix.game-component',
  6730. 'au' => 'audio/basic',
  6731. 'avi' => 'video/x-msvideo',
  6732. 'aw' => 'application/applixware',
  6733. 'azf' => 'application/vnd.airzip.filesecure.azf',
  6734. 'azs' => 'application/vnd.airzip.filesecure.azs',
  6735. 'azw' => 'application/vnd.amazon.ebook',
  6736. 'bat' => 'application/x-msdownload',
  6737. 'bcpio' => 'application/x-bcpio',
  6738. 'bdf' => 'application/x-font-bdf',
  6739. 'bdm' => 'application/vnd.syncml.dm+wbxml',
  6740. 'bed' => 'application/vnd.realvnc.bed',
  6741. 'bh2' => 'application/vnd.fujitsu.oasysprs',
  6742. 'bin' => 'application/octet-stream',
  6743. 'blb' => 'application/x-blorb',
  6744. 'blorb' => 'application/x-blorb',
  6745. 'bmi' => 'application/vnd.bmi',
  6746. 'bmp' => 'image/bmp',
  6747. 'book' => 'application/vnd.framemaker',
  6748. 'box' => 'application/vnd.previewsystems.box',
  6749. 'boz' => 'application/x-bzip2',
  6750. 'bpk' => 'application/octet-stream',
  6751. 'btif' => 'image/prs.btif',
  6752. 'bz' => 'application/x-bzip',
  6753. 'bz2' => 'application/x-bzip2',
  6754. 'c' => 'text/x-c',
  6755. 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
  6756. 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
  6757. 'c4d' => 'application/vnd.clonk.c4group',
  6758. 'c4f' => 'application/vnd.clonk.c4group',
  6759. 'c4g' => 'application/vnd.clonk.c4group',
  6760. 'c4p' => 'application/vnd.clonk.c4group',
  6761. 'c4u' => 'application/vnd.clonk.c4group',
  6762. 'cab' => 'application/vnd.ms-cab-compressed',
  6763. 'caf' => 'audio/x-caf',
  6764. 'cap' => 'application/vnd.tcpdump.pcap',
  6765. 'car' => 'application/vnd.curl.car',
  6766. 'cat' => 'application/vnd.ms-pki.seccat',
  6767. 'cb7' => 'application/x-cbr',
  6768. 'cba' => 'application/x-cbr',
  6769. 'cbr' => 'application/x-cbr',
  6770. 'cbt' => 'application/x-cbr',
  6771. 'cbz' => 'application/x-cbr',
  6772. 'cc' => 'text/x-c',
  6773. 'cct' => 'application/x-director',
  6774. 'ccxml' => 'application/ccxml+xml',
  6775. 'cdbcmsg' => 'application/vnd.contact.cmsg',
  6776. 'cdf' => 'application/x-netcdf',
  6777. 'cdkey' => 'application/vnd.mediastation.cdkey',
  6778. 'cdmia' => 'application/cdmi-capability',
  6779. 'cdmic' => 'application/cdmi-container',
  6780. 'cdmid' => 'application/cdmi-domain',
  6781. 'cdmio' => 'application/cdmi-object',
  6782. 'cdmiq' => 'application/cdmi-queue',
  6783. 'cdx' => 'chemical/x-cdx',
  6784. 'cdxml' => 'application/vnd.chemdraw+xml',
  6785. 'cdy' => 'application/vnd.cinderella',
  6786. 'cer' => 'application/pkix-cert',
  6787. 'cfs' => 'application/x-cfs-compressed',
  6788. 'cgm' => 'image/cgm',
  6789. 'chat' => 'application/x-chat',
  6790. 'chm' => 'application/vnd.ms-htmlhelp',
  6791. 'chrt' => 'application/vnd.kde.kchart',
  6792. 'cif' => 'chemical/x-cif',
  6793. 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
  6794. 'cil' => 'application/vnd.ms-artgalry',
  6795. 'cla' => 'application/vnd.claymore',
  6796. 'class' => 'application/java-vm',
  6797. 'clkk' => 'application/vnd.crick.clicker.keyboard',
  6798. 'clkp' => 'application/vnd.crick.clicker.palette',
  6799. 'clkt' => 'application/vnd.crick.clicker.template',
  6800. 'clkw' => 'application/vnd.crick.clicker.wordbank',
  6801. 'clkx' => 'application/vnd.crick.clicker',
  6802. 'clp' => 'application/x-msclip',
  6803. 'cmc' => 'application/vnd.cosmocaller',
  6804. 'cmdf' => 'chemical/x-cmdf',
  6805. 'cml' => 'chemical/x-cml',
  6806. 'cmp' => 'application/vnd.yellowriver-custom-menu',
  6807. 'cmx' => 'image/x-cmx',
  6808. 'cod' => 'application/vnd.rim.cod',
  6809. 'com' => 'application/x-msdownload',
  6810. 'conf' => 'text/plain',
  6811. 'cpio' => 'application/x-cpio',
  6812. 'cpp' => 'text/x-c',
  6813. 'cpt' => 'application/mac-compactpro',
  6814. 'crd' => 'application/x-mscardfile',
  6815. 'crl' => 'application/pkix-crl',
  6816. 'crt' => 'application/x-x509-ca-cert',
  6817. 'cryptonote' => 'application/vnd.rig.cryptonote',
  6818. 'csh' => 'application/x-csh',
  6819. 'csml' => 'chemical/x-csml',
  6820. 'csp' => 'application/vnd.commonspace',
  6821. 'css' => 'text/css',
  6822. 'cst' => 'application/x-director',
  6823. 'csv' => 'text/csv',
  6824. 'cu' => 'application/cu-seeme',
  6825. 'curl' => 'text/vnd.curl',
  6826. 'cww' => 'application/prs.cww',
  6827. 'cxt' => 'application/x-director',
  6828. 'cxx' => 'text/x-c',
  6829. 'dae' => 'model/vnd.collada+xml',
  6830. 'daf' => 'application/vnd.mobius.daf',
  6831. 'dart' => 'application/vnd.dart',
  6832. 'dataless' => 'application/vnd.fdsn.seed',
  6833. 'davmount' => 'application/davmount+xml',
  6834. 'dbk' => 'application/docbook+xml',
  6835. 'dcr' => 'application/x-director',
  6836. 'dcurl' => 'text/vnd.curl.dcurl',
  6837. 'dd2' => 'application/vnd.oma.dd2+xml',
  6838. 'ddd' => 'application/vnd.fujixerox.ddd',
  6839. 'deb' => 'application/x-debian-package',
  6840. 'def' => 'text/plain',
  6841. 'deploy' => 'application/octet-stream',
  6842. 'der' => 'application/x-x509-ca-cert',
  6843. 'dfac' => 'application/vnd.dreamfactory',
  6844. 'dgc' => 'application/x-dgc-compressed',
  6845. 'dic' => 'text/x-c',
  6846. 'dir' => 'application/x-director',
  6847. 'dis' => 'application/vnd.mobius.dis',
  6848. 'dist' => 'application/octet-stream',
  6849. 'distz' => 'application/octet-stream',
  6850. 'djv' => 'image/vnd.djvu',
  6851. 'djvu' => 'image/vnd.djvu',
  6852. 'dll' => 'application/x-msdownload',
  6853. 'dmg' => 'application/x-apple-diskimage',
  6854. 'dmp' => 'application/vnd.tcpdump.pcap',
  6855. 'dms' => 'application/octet-stream',
  6856. 'dna' => 'application/vnd.dna',
  6857. 'doc' => 'application/msword',
  6858. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  6859. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  6860. 'dot' => 'application/msword',
  6861. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  6862. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  6863. 'dp' => 'application/vnd.osgi.dp',
  6864. 'dpg' => 'application/vnd.dpgraph',
  6865. 'dra' => 'audio/vnd.dra',
  6866. 'dsc' => 'text/prs.lines.tag',
  6867. 'dssc' => 'application/dssc+der',
  6868. 'dtb' => 'application/x-dtbook+xml',
  6869. 'dtd' => 'application/xml-dtd',
  6870. 'dts' => 'audio/vnd.dts',
  6871. 'dtshd' => 'audio/vnd.dts.hd',
  6872. 'dump' => 'application/octet-stream',
  6873. 'dvb' => 'video/vnd.dvb.file',
  6874. 'dvi' => 'application/x-dvi',
  6875. 'dwf' => 'model/vnd.dwf',
  6876. 'dwg' => 'image/vnd.dwg',
  6877. 'dxf' => 'image/vnd.dxf',
  6878. 'dxp' => 'application/vnd.spotfire.dxp',
  6879. 'dxr' => 'application/x-director',
  6880. 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
  6881. 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
  6882. 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
  6883. 'ecma' => 'application/ecmascript',
  6884. 'edm' => 'application/vnd.novadigm.edm',
  6885. 'edx' => 'application/vnd.novadigm.edx',
  6886. 'efif' => 'application/vnd.picsel',
  6887. 'ei6' => 'application/vnd.pg.osasli',
  6888. 'elc' => 'application/octet-stream',
  6889. 'emf' => 'application/x-msmetafile',
  6890. 'eml' => 'message/rfc822',
  6891. 'emma' => 'application/emma+xml',
  6892. 'emz' => 'application/x-msmetafile',
  6893. 'eol' => 'audio/vnd.digital-winds',
  6894. 'eot' => 'application/vnd.ms-fontobject',
  6895. 'eps' => 'application/postscript',
  6896. 'epub' => 'application/epub+zip',
  6897. 'es3' => 'application/vnd.eszigno3+xml',
  6898. 'esa' => 'application/vnd.osgi.subsystem',
  6899. 'esf' => 'application/vnd.epson.esf',
  6900. 'et3' => 'application/vnd.eszigno3+xml',
  6901. 'etx' => 'text/x-setext',
  6902. 'eva' => 'application/x-eva',
  6903. 'evy' => 'application/x-envoy',
  6904. 'exe' => 'application/x-msdownload',
  6905. 'exi' => 'application/exi',
  6906. 'ext' => 'application/vnd.novadigm.ext',
  6907. 'ez' => 'application/andrew-inset',
  6908. 'ez2' => 'application/vnd.ezpix-album',
  6909. 'ez3' => 'application/vnd.ezpix-package',
  6910. 'f' => 'text/x-fortran',
  6911. 'f4v' => 'video/x-f4v',
  6912. 'f77' => 'text/x-fortran',
  6913. 'f90' => 'text/x-fortran',
  6914. 'fbs' => 'image/vnd.fastbidsheet',
  6915. 'fcdt' => 'application/vnd.adobe.formscentral.fcdt',
  6916. 'fcs' => 'application/vnd.isac.fcs',
  6917. 'fdf' => 'application/vnd.fdf',
  6918. 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
  6919. 'fg5' => 'application/vnd.fujitsu.oasysgp',
  6920. 'fgd' => 'application/x-director',
  6921. 'fh' => 'image/x-freehand',
  6922. 'fh4' => 'image/x-freehand',
  6923. 'fh5' => 'image/x-freehand',
  6924. 'fh7' => 'image/x-freehand',
  6925. 'fhc' => 'image/x-freehand',
  6926. 'fig' => 'application/x-xfig',
  6927. 'flac' => 'audio/x-flac',
  6928. 'fli' => 'video/x-fli',
  6929. 'flo' => 'application/vnd.micrografx.flo',
  6930. 'flv' => 'video/x-flv',
  6931. 'flw' => 'application/vnd.kde.kivio',
  6932. 'flx' => 'text/vnd.fmi.flexstor',
  6933. 'fly' => 'text/vnd.fly',
  6934. 'fm' => 'application/vnd.framemaker',
  6935. 'fnc' => 'application/vnd.frogans.fnc',
  6936. 'for' => 'text/x-fortran',
  6937. 'fpx' => 'image/vnd.fpx',
  6938. 'frame' => 'application/vnd.framemaker',
  6939. 'fsc' => 'application/vnd.fsc.weblaunch',
  6940. 'fst' => 'image/vnd.fst',
  6941. 'ftc' => 'application/vnd.fluxtime.clip',
  6942. 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
  6943. 'fvt' => 'video/vnd.fvt',
  6944. 'fxp' => 'application/vnd.adobe.fxp',
  6945. 'fxpl' => 'application/vnd.adobe.fxp',
  6946. 'fzs' => 'application/vnd.fuzzysheet',
  6947. 'g2w' => 'application/vnd.geoplan',
  6948. 'g3' => 'image/g3fax',
  6949. 'g3w' => 'application/vnd.geospace',
  6950. 'gac' => 'application/vnd.groove-account',
  6951. 'gam' => 'application/x-tads',
  6952. 'gbr' => 'application/rpki-ghostbusters',
  6953. 'gca' => 'application/x-gca-compressed',
  6954. 'gdl' => 'model/vnd.gdl',
  6955. 'geo' => 'application/vnd.dynageo',
  6956. 'gex' => 'application/vnd.geometry-explorer',
  6957. 'ggb' => 'application/vnd.geogebra.file',
  6958. 'ggt' => 'application/vnd.geogebra.tool',
  6959. 'ghf' => 'application/vnd.groove-help',
  6960. 'gif' => 'image/gif',
  6961. 'gim' => 'application/vnd.groove-identity-message',
  6962. 'gml' => 'application/gml+xml',
  6963. 'gmx' => 'application/vnd.gmx',
  6964. 'gnumeric' => 'application/x-gnumeric',
  6965. 'gph' => 'application/vnd.flographit',
  6966. 'gpx' => 'application/gpx+xml',
  6967. 'gqf' => 'application/vnd.grafeq',
  6968. 'gqs' => 'application/vnd.grafeq',
  6969. 'gram' => 'application/srgs',
  6970. 'gramps' => 'application/x-gramps-xml',
  6971. 'gre' => 'application/vnd.geometry-explorer',
  6972. 'grv' => 'application/vnd.groove-injector',
  6973. 'grxml' => 'application/srgs+xml',
  6974. 'gsf' => 'application/x-font-ghostscript',
  6975. 'gtar' => 'application/x-gtar',
  6976. 'gtm' => 'application/vnd.groove-tool-message',
  6977. 'gtw' => 'model/vnd.gtw',
  6978. 'gv' => 'text/vnd.graphviz',
  6979. 'gxf' => 'application/gxf',
  6980. 'gxt' => 'application/vnd.geonext',
  6981. 'h' => 'text/x-c',
  6982. 'h261' => 'video/h261',
  6983. 'h263' => 'video/h263',
  6984. 'h264' => 'video/h264',
  6985. 'hal' => 'application/vnd.hal+xml',
  6986. 'hbci' => 'application/vnd.hbci',
  6987. 'hdf' => 'application/x-hdf',
  6988. 'hh' => 'text/x-c',
  6989. 'hlp' => 'application/winhlp',
  6990. 'hpgl' => 'application/vnd.hp-hpgl',
  6991. 'hpid' => 'application/vnd.hp-hpid',
  6992. 'hps' => 'application/vnd.hp-hps',
  6993. 'hqx' => 'application/mac-binhex40',
  6994. 'htke' => 'application/vnd.kenameaapp',
  6995. 'htm' => 'text/html',
  6996. 'html' => 'text/html',
  6997. 'hvd' => 'application/vnd.yamaha.hv-dic',
  6998. 'hvp' => 'application/vnd.yamaha.hv-voice',
  6999. 'hvs' => 'application/vnd.yamaha.hv-script',
  7000. 'i2g' => 'application/vnd.intergeo',
  7001. 'icc' => 'application/vnd.iccprofile',
  7002. 'ice' => 'x-conference/x-cooltalk',
  7003. 'icm' => 'application/vnd.iccprofile',
  7004. 'ico' => 'image/x-icon',
  7005. 'ics' => 'text/calendar',
  7006. 'ief' => 'image/ief',
  7007. 'ifb' => 'text/calendar',
  7008. 'ifm' => 'application/vnd.shana.informed.formdata',
  7009. 'iges' => 'model/iges',
  7010. 'igl' => 'application/vnd.igloader',
  7011. 'igm' => 'application/vnd.insors.igm',
  7012. 'igs' => 'model/iges',
  7013. 'igx' => 'application/vnd.micrografx.igx',
  7014. 'iif' => 'application/vnd.shana.informed.interchange',
  7015. 'imp' => 'application/vnd.accpac.simply.imp',
  7016. 'ims' => 'application/vnd.ms-ims',
  7017. 'in' => 'text/plain',
  7018. 'ink' => 'application/inkml+xml',
  7019. 'inkml' => 'application/inkml+xml',
  7020. 'install' => 'application/x-install-instructions',
  7021. 'iota' => 'application/vnd.astraea-software.iota',
  7022. 'ipfix' => 'application/ipfix',
  7023. 'ipk' => 'application/vnd.shana.informed.package',
  7024. 'irm' => 'application/vnd.ibm.rights-management',
  7025. 'irp' => 'application/vnd.irepository.package+xml',
  7026. 'iso' => 'application/x-iso9660-image',
  7027. 'itp' => 'application/vnd.shana.informed.formtemplate',
  7028. 'ivp' => 'application/vnd.immervision-ivp',
  7029. 'ivu' => 'application/vnd.immervision-ivu',
  7030. 'jad' => 'text/vnd.sun.j2me.app-descriptor',
  7031. 'jam' => 'application/vnd.jam',
  7032. 'jar' => 'application/java-archive',
  7033. 'java' => 'text/x-java-source',
  7034. 'jisp' => 'application/vnd.jisp',
  7035. 'jlt' => 'application/vnd.hp-jlyt',
  7036. 'jnlp' => 'application/x-java-jnlp-file',
  7037. 'joda' => 'application/vnd.joost.joda-archive',
  7038. 'jpe' => 'image/jpeg',
  7039. 'jpeg' => 'image/jpeg',
  7040. 'jpg' => 'image/jpeg',
  7041. 'jpgm' => 'video/jpm',
  7042. 'jpgv' => 'video/jpeg',
  7043. 'jpm' => 'video/jpm',
  7044. 'js' => 'application/javascript',
  7045. 'json' => 'application/json',
  7046. 'jsonml' => 'application/jsonml+json',
  7047. 'kar' => 'audio/midi',
  7048. 'karbon' => 'application/vnd.kde.karbon',
  7049. 'kfo' => 'application/vnd.kde.kformula',
  7050. 'kia' => 'application/vnd.kidspiration',
  7051. 'kml' => 'application/vnd.google-earth.kml+xml',
  7052. 'kmz' => 'application/vnd.google-earth.kmz',
  7053. 'kne' => 'application/vnd.kinar',
  7054. 'knp' => 'application/vnd.kinar',
  7055. 'kon' => 'application/vnd.kde.kontour',
  7056. 'kpr' => 'application/vnd.kde.kpresenter',
  7057. 'kpt' => 'application/vnd.kde.kpresenter',
  7058. 'kpxx' => 'application/vnd.ds-keypoint',
  7059. 'ksp' => 'application/vnd.kde.kspread',
  7060. 'ktr' => 'application/vnd.kahootz',
  7061. 'ktx' => 'image/ktx',
  7062. 'ktz' => 'application/vnd.kahootz',
  7063. 'kwd' => 'application/vnd.kde.kword',
  7064. 'kwt' => 'application/vnd.kde.kword',
  7065. 'lasxml' => 'application/vnd.las.las+xml',
  7066. 'latex' => 'application/x-latex',
  7067. 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  7068. 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  7069. 'les' => 'application/vnd.hhe.lesson-player',
  7070. 'lha' => 'application/x-lzh-compressed',
  7071. 'link66' => 'application/vnd.route66.link66+xml',
  7072. 'list' => 'text/plain',
  7073. 'list3820' => 'application/vnd.ibm.modcap',
  7074. 'listafp' => 'application/vnd.ibm.modcap',
  7075. 'lnk' => 'application/x-ms-shortcut',
  7076. 'log' => 'text/plain',
  7077. 'lostxml' => 'application/lost+xml',
  7078. 'lrf' => 'application/octet-stream',
  7079. 'lrm' => 'application/vnd.ms-lrm',
  7080. 'ltf' => 'application/vnd.frogans.ltf',
  7081. 'lvp' => 'audio/vnd.lucent.voice',
  7082. 'lwp' => 'application/vnd.lotus-wordpro',
  7083. 'lzh' => 'application/x-lzh-compressed',
  7084. 'm13' => 'application/x-msmediaview',
  7085. 'm14' => 'application/x-msmediaview',
  7086. 'm1v' => 'video/mpeg',
  7087. 'm21' => 'application/mp21',
  7088. 'm2a' => 'audio/mpeg',
  7089. 'm2v' => 'video/mpeg',
  7090. 'm3a' => 'audio/mpeg',
  7091. 'm3u' => 'audio/x-mpegurl',
  7092. 'm3u8' => 'application/vnd.apple.mpegurl',
  7093. 'm4a' => 'audio/mp4',
  7094. 'm4u' => 'video/vnd.mpegurl',
  7095. 'm4v' => 'video/x-m4v',
  7096. 'ma' => 'application/mathematica',
  7097. 'mads' => 'application/mads+xml',
  7098. 'mag' => 'application/vnd.ecowin.chart',
  7099. 'maker' => 'application/vnd.framemaker',
  7100. 'man' => 'text/troff',
  7101. 'mar' => 'application/octet-stream',
  7102. 'mathml' => 'application/mathml+xml',
  7103. 'mb' => 'application/mathematica',
  7104. 'mbk' => 'application/vnd.mobius.mbk',
  7105. 'mbox' => 'application/mbox',
  7106. 'mc1' => 'application/vnd.medcalcdata',
  7107. 'mcd' => 'application/vnd.mcd',
  7108. 'mcurl' => 'text/vnd.curl.mcurl',
  7109. 'mdb' => 'application/x-msaccess',
  7110. 'mdi' => 'image/vnd.ms-modi',
  7111. 'me' => 'text/troff',
  7112. 'mesh' => 'model/mesh',
  7113. 'meta4' => 'application/metalink4+xml',
  7114. 'metalink' => 'application/metalink+xml',
  7115. 'mets' => 'application/mets+xml',
  7116. 'mfm' => 'application/vnd.mfmp',
  7117. 'mft' => 'application/rpki-manifest',
  7118. 'mgp' => 'application/vnd.osgeo.mapguide.package',
  7119. 'mgz' => 'application/vnd.proteus.magazine',
  7120. 'mid' => 'audio/midi',
  7121. 'midi' => 'audio/midi',
  7122. 'mie' => 'application/x-mie',
  7123. 'mif' => 'application/vnd.mif',
  7124. 'mime' => 'message/rfc822',
  7125. 'mj2' => 'video/mj2',
  7126. 'mjp2' => 'video/mj2',
  7127. 'mk3d' => 'video/x-matroska',
  7128. 'mka' => 'audio/x-matroska',
  7129. 'mks' => 'video/x-matroska',
  7130. 'mkv' => 'video/x-matroska',
  7131. 'mlp' => 'application/vnd.dolby.mlp',
  7132. 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
  7133. 'mmf' => 'application/vnd.smaf',
  7134. 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
  7135. 'mng' => 'video/x-mng',
  7136. 'mny' => 'application/x-msmoney',
  7137. 'mobi' => 'application/x-mobipocket-ebook',
  7138. 'mods' => 'application/mods+xml',
  7139. 'mov' => 'video/quicktime',
  7140. 'movie' => 'video/x-sgi-movie',
  7141. 'mp2' => 'audio/mpeg',
  7142. 'mp21' => 'application/mp21',
  7143. 'mp2a' => 'audio/mpeg',
  7144. 'mp3' => 'audio/mpeg',
  7145. 'mp4' => 'video/mp4',
  7146. 'mp4a' => 'audio/mp4',
  7147. 'mp4s' => 'application/mp4',
  7148. 'mp4v' => 'video/mp4',
  7149. 'mpc' => 'application/vnd.mophun.certificate',
  7150. 'mpe' => 'video/mpeg',
  7151. 'mpeg' => 'video/mpeg',
  7152. 'mpg' => 'video/mpeg',
  7153. 'mpg4' => 'video/mp4',
  7154. 'mpga' => 'audio/mpeg',
  7155. 'mpkg' => 'application/vnd.apple.installer+xml',
  7156. 'mpm' => 'application/vnd.blueice.multipass',
  7157. 'mpn' => 'application/vnd.mophun.application',
  7158. 'mpp' => 'application/vnd.ms-project',
  7159. 'mpt' => 'application/vnd.ms-project',
  7160. 'mpy' => 'application/vnd.ibm.minipay',
  7161. 'mqy' => 'application/vnd.mobius.mqy',
  7162. 'mrc' => 'application/marc',
  7163. 'mrcx' => 'application/marcxml+xml',
  7164. 'ms' => 'text/troff',
  7165. 'mscml' => 'application/mediaservercontrol+xml',
  7166. 'mseed' => 'application/vnd.fdsn.mseed',
  7167. 'mseq' => 'application/vnd.mseq',
  7168. 'msf' => 'application/vnd.epson.msf',
  7169. 'msh' => 'model/mesh',
  7170. 'msi' => 'application/x-msdownload',
  7171. 'msl' => 'application/vnd.mobius.msl',
  7172. 'msty' => 'application/vnd.muvee.style',
  7173. 'mts' => 'model/vnd.mts',
  7174. 'mus' => 'application/vnd.musician',
  7175. 'musicxml' => 'application/vnd.recordare.musicxml+xml',
  7176. 'mvb' => 'application/x-msmediaview',
  7177. 'mwf' => 'application/vnd.mfer',
  7178. 'mxf' => 'application/mxf',
  7179. 'mxl' => 'application/vnd.recordare.musicxml',
  7180. 'mxml' => 'application/xv+xml',
  7181. 'mxs' => 'application/vnd.triscape.mxs',
  7182. 'mxu' => 'video/vnd.mpegurl',
  7183. 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  7184. 'n3' => 'text/n3',
  7185. 'nb' => 'application/mathematica',
  7186. 'nbp' => 'application/vnd.wolfram.player',
  7187. 'nc' => 'application/x-netcdf',
  7188. 'ncx' => 'application/x-dtbncx+xml',
  7189. 'nfo' => 'text/x-nfo',
  7190. 'ngdat' => 'application/vnd.nokia.n-gage.data',
  7191. 'nitf' => 'application/vnd.nitf',
  7192. 'nlu' => 'application/vnd.neurolanguage.nlu',
  7193. 'nml' => 'application/vnd.enliven',
  7194. 'nnd' => 'application/vnd.noblenet-directory',
  7195. 'nns' => 'application/vnd.noblenet-sealer',
  7196. 'nnw' => 'application/vnd.noblenet-web',
  7197. 'npx' => 'image/vnd.net-fpx',
  7198. 'nsc' => 'application/x-conference',
  7199. 'nsf' => 'application/vnd.lotus-notes',
  7200. 'ntf' => 'application/vnd.nitf',
  7201. 'nzb' => 'application/x-nzb',
  7202. 'oa2' => 'application/vnd.fujitsu.oasys2',
  7203. 'oa3' => 'application/vnd.fujitsu.oasys3',
  7204. 'oas' => 'application/vnd.fujitsu.oasys',
  7205. 'obd' => 'application/x-msbinder',
  7206. 'obj' => 'application/x-tgif',
  7207. 'oda' => 'application/oda',
  7208. 'odb' => 'application/vnd.oasis.opendocument.database',
  7209. 'odc' => 'application/vnd.oasis.opendocument.chart',
  7210. 'odf' => 'application/vnd.oasis.opendocument.formula',
  7211. 'odft' => 'application/vnd.oasis.opendocument.formula-template',
  7212. 'odg' => 'application/vnd.oasis.opendocument.graphics',
  7213. 'odi' => 'application/vnd.oasis.opendocument.image',
  7214. 'odm' => 'application/vnd.oasis.opendocument.text-master',
  7215. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  7216. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  7217. 'odt' => 'application/vnd.oasis.opendocument.text',
  7218. 'oga' => 'audio/ogg',
  7219. 'ogg' => 'audio/ogg',
  7220. 'ogv' => 'video/ogg',
  7221. 'ogx' => 'application/ogg',
  7222. 'omdoc' => 'application/omdoc+xml',
  7223. 'onepkg' => 'application/onenote',
  7224. 'onetmp' => 'application/onenote',
  7225. 'onetoc' => 'application/onenote',
  7226. 'onetoc2' => 'application/onenote',
  7227. 'opf' => 'application/oebps-package+xml',
  7228. 'opml' => 'text/x-opml',
  7229. 'oprc' => 'application/vnd.palm',
  7230. 'org' => 'application/vnd.lotus-organizer',
  7231. 'osf' => 'application/vnd.yamaha.openscoreformat',
  7232. 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  7233. 'otc' => 'application/vnd.oasis.opendocument.chart-template',
  7234. 'otf' => 'application/x-font-otf',
  7235. 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
  7236. 'oth' => 'application/vnd.oasis.opendocument.text-web',
  7237. 'oti' => 'application/vnd.oasis.opendocument.image-template',
  7238. 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
  7239. 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  7240. 'ott' => 'application/vnd.oasis.opendocument.text-template',
  7241. 'oxps' => 'application/oxps',
  7242. 'oxt' => 'application/vnd.openofficeorg.extension',
  7243. 'p' => 'text/x-pascal',
  7244. 'p10' => 'application/pkcs10',
  7245. 'p12' => 'application/x-pkcs12',
  7246. 'p7b' => 'application/x-pkcs7-certificates',
  7247. 'p7c' => 'application/pkcs7-mime',
  7248. 'p7m' => 'application/pkcs7-mime',
  7249. 'p7r' => 'application/x-pkcs7-certreqresp',
  7250. 'p7s' => 'application/pkcs7-signature',
  7251. 'p8' => 'application/pkcs8',
  7252. 'pas' => 'text/x-pascal',
  7253. 'paw' => 'application/vnd.pawaafile',
  7254. 'pbd' => 'application/vnd.powerbuilder6',
  7255. 'pbm' => 'image/x-portable-bitmap',
  7256. 'pcap' => 'application/vnd.tcpdump.pcap',
  7257. 'pcf' => 'application/x-font-pcf',
  7258. 'pcl' => 'application/vnd.hp-pcl',
  7259. 'pclxl' => 'application/vnd.hp-pclxl',
  7260. 'pct' => 'image/x-pict',
  7261. 'pcurl' => 'application/vnd.curl.pcurl',
  7262. 'pcx' => 'image/x-pcx',
  7263. 'pdb' => 'application/vnd.palm',
  7264. 'pdf' => 'application/pdf',
  7265. 'pfa' => 'application/x-font-type1',
  7266. 'pfb' => 'application/x-font-type1',
  7267. 'pfm' => 'application/x-font-type1',
  7268. 'pfr' => 'application/font-tdpfr',
  7269. 'pfx' => 'application/x-pkcs12',
  7270. 'pgm' => 'image/x-portable-graymap',
  7271. 'pgn' => 'application/x-chess-pgn',
  7272. 'pgp' => 'application/pgp-encrypted',
  7273. 'pic' => 'image/x-pict',
  7274. 'pkg' => 'application/octet-stream',
  7275. 'pki' => 'application/pkixcmp',
  7276. 'pkipath' => 'application/pkix-pkipath',
  7277. 'plb' => 'application/vnd.3gpp.pic-bw-large',
  7278. 'plc' => 'application/vnd.mobius.plc',
  7279. 'plf' => 'application/vnd.pocketlearn',
  7280. 'pls' => 'application/pls+xml',
  7281. 'pml' => 'application/vnd.ctc-posml',
  7282. 'png' => 'image/png',
  7283. 'pnm' => 'image/x-portable-anymap',
  7284. 'portpkg' => 'application/vnd.macports.portpkg',
  7285. 'pot' => 'application/vnd.ms-powerpoint',
  7286. 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
  7287. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  7288. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  7289. 'ppd' => 'application/vnd.cups-ppd',
  7290. 'ppm' => 'image/x-portable-pixmap',
  7291. 'pps' => 'application/vnd.ms-powerpoint',
  7292. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  7293. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  7294. 'ppt' => 'application/vnd.ms-powerpoint',
  7295. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  7296. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  7297. 'pqa' => 'application/vnd.palm',
  7298. 'prc' => 'application/x-mobipocket-ebook',
  7299. 'pre' => 'application/vnd.lotus-freelance',
  7300. 'prf' => 'application/pics-rules',
  7301. 'ps' => 'application/postscript',
  7302. 'psb' => 'application/vnd.3gpp.pic-bw-small',
  7303. 'psd' => 'image/vnd.adobe.photoshop',
  7304. 'psf' => 'application/x-font-linux-psf',
  7305. 'pskcxml' => 'application/pskc+xml',
  7306. 'ptid' => 'application/vnd.pvi.ptid1',
  7307. 'pub' => 'application/x-mspublisher',
  7308. 'pvb' => 'application/vnd.3gpp.pic-bw-var',
  7309. 'pwn' => 'application/vnd.3m.post-it-notes',
  7310. 'pya' => 'audio/vnd.ms-playready.media.pya',
  7311. 'pyv' => 'video/vnd.ms-playready.media.pyv',
  7312. 'qam' => 'application/vnd.epson.quickanime',
  7313. 'qbo' => 'application/vnd.intu.qbo',
  7314. 'qfx' => 'application/vnd.intu.qfx',
  7315. 'qps' => 'application/vnd.publishare-delta-tree',
  7316. 'qt' => 'video/quicktime',
  7317. 'qwd' => 'application/vnd.quark.quarkxpress',
  7318. 'qwt' => 'application/vnd.quark.quarkxpress',
  7319. 'qxb' => 'application/vnd.quark.quarkxpress',
  7320. 'qxd' => 'application/vnd.quark.quarkxpress',
  7321. 'qxl' => 'application/vnd.quark.quarkxpress',
  7322. 'qxt' => 'application/vnd.quark.quarkxpress',
  7323. 'ra' => 'audio/x-pn-realaudio',
  7324. 'ram' => 'audio/x-pn-realaudio',
  7325. 'rar' => 'application/x-rar-compressed',
  7326. 'ras' => 'image/x-cmu-raster',
  7327. 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
  7328. 'rdf' => 'application/rdf+xml',
  7329. 'rdz' => 'application/vnd.data-vision.rdz',
  7330. 'rep' => 'application/vnd.businessobjects',
  7331. 'res' => 'application/x-dtbresource+xml',
  7332. 'rgb' => 'image/x-rgb',
  7333. 'rif' => 'application/reginfo+xml',
  7334. 'rip' => 'audio/vnd.rip',
  7335. 'ris' => 'application/x-research-info-systems',
  7336. 'rl' => 'application/resource-lists+xml',
  7337. 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
  7338. 'rld' => 'application/resource-lists-diff+xml',
  7339. 'rm' => 'application/vnd.rn-realmedia',
  7340. 'rmi' => 'audio/midi',
  7341. 'rmp' => 'audio/x-pn-realaudio-plugin',
  7342. 'rms' => 'application/vnd.jcp.javame.midlet-rms',
  7343. 'rmvb' => 'application/vnd.rn-realmedia-vbr',
  7344. 'rnc' => 'application/relax-ng-compact-syntax',
  7345. 'roa' => 'application/rpki-roa',
  7346. 'roff' => 'text/troff',
  7347. 'rp9' => 'application/vnd.cloanto.rp9',
  7348. 'rpss' => 'application/vnd.nokia.radio-presets',
  7349. 'rpst' => 'application/vnd.nokia.radio-preset',
  7350. 'rq' => 'application/sparql-query',
  7351. 'rs' => 'application/rls-services+xml',
  7352. 'rsd' => 'application/rsd+xml',
  7353. 'rss' => 'application/rss+xml',
  7354. 'rtf' => 'application/rtf',
  7355. 'rtx' => 'text/richtext',
  7356. 's' => 'text/x-asm',
  7357. 's3m' => 'audio/s3m',
  7358. 'saf' => 'application/vnd.yamaha.smaf-audio',
  7359. 'sbml' => 'application/sbml+xml',
  7360. 'sc' => 'application/vnd.ibm.secure-container',
  7361. 'scd' => 'application/x-msschedule',
  7362. 'scm' => 'application/vnd.lotus-screencam',
  7363. 'scq' => 'application/scvp-cv-request',
  7364. 'scs' => 'application/scvp-cv-response',
  7365. 'scurl' => 'text/vnd.curl.scurl',
  7366. 'sda' => 'application/vnd.stardivision.draw',
  7367. 'sdc' => 'application/vnd.stardivision.calc',
  7368. 'sdd' => 'application/vnd.stardivision.impress',
  7369. 'sdkd' => 'application/vnd.solent.sdkm+xml',
  7370. 'sdkm' => 'application/vnd.solent.sdkm+xml',
  7371. 'sdp' => 'application/sdp',
  7372. 'sdw' => 'application/vnd.stardivision.writer',
  7373. 'see' => 'application/vnd.seemail',
  7374. 'seed' => 'application/vnd.fdsn.seed',
  7375. 'sema' => 'application/vnd.sema',
  7376. 'semd' => 'application/vnd.semd',
  7377. 'semf' => 'application/vnd.semf',
  7378. 'ser' => 'application/java-serialized-object',
  7379. 'setpay' => 'application/set-payment-initiation',
  7380. 'setreg' => 'application/set-registration-initiation',
  7381. 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
  7382. 'sfs' => 'application/vnd.spotfire.sfs',
  7383. 'sfv' => 'text/x-sfv',
  7384. 'sgi' => 'image/sgi',
  7385. 'sgl' => 'application/vnd.stardivision.writer-global',
  7386. 'sgm' => 'text/sgml',
  7387. 'sgml' => 'text/sgml',
  7388. 'sh' => 'application/x-sh',
  7389. 'shar' => 'application/x-shar',
  7390. 'shf' => 'application/shf+xml',
  7391. 'sid' => 'image/x-mrsid-image',
  7392. 'sig' => 'application/pgp-signature',
  7393. 'sil' => 'audio/silk',
  7394. 'silo' => 'model/mesh',
  7395. 'sis' => 'application/vnd.symbian.install',
  7396. 'sisx' => 'application/vnd.symbian.install',
  7397. 'sit' => 'application/x-stuffit',
  7398. 'sitx' => 'application/x-stuffitx',
  7399. 'skd' => 'application/vnd.koan',
  7400. 'skm' => 'application/vnd.koan',
  7401. 'skp' => 'application/vnd.koan',
  7402. 'skt' => 'application/vnd.koan',
  7403. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  7404. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  7405. 'slt' => 'application/vnd.epson.salt',
  7406. 'sm' => 'application/vnd.stepmania.stepchart',
  7407. 'smf' => 'application/vnd.stardivision.math',
  7408. 'smi' => 'application/smil+xml',
  7409. 'smil' => 'application/smil+xml',
  7410. 'smv' => 'video/x-smv',
  7411. 'smzip' => 'application/vnd.stepmania.package',
  7412. 'snd' => 'audio/basic',
  7413. 'snf' => 'application/x-font-snf',
  7414. 'so' => 'application/octet-stream',
  7415. 'spc' => 'application/x-pkcs7-certificates',
  7416. 'spf' => 'application/vnd.yamaha.smaf-phrase',
  7417. 'spl' => 'application/x-futuresplash',
  7418. 'spot' => 'text/vnd.in3d.spot',
  7419. 'spp' => 'application/scvp-vp-response',
  7420. 'spq' => 'application/scvp-vp-request',
  7421. 'spx' => 'audio/ogg',
  7422. 'sql' => 'application/x-sql',
  7423. 'src' => 'application/x-wais-source',
  7424. 'srt' => 'application/x-subrip',
  7425. 'sru' => 'application/sru+xml',
  7426. 'srx' => 'application/sparql-results+xml',
  7427. 'ssdl' => 'application/ssdl+xml',
  7428. 'sse' => 'application/vnd.kodak-descriptor',
  7429. 'ssf' => 'application/vnd.epson.ssf',
  7430. 'ssml' => 'application/ssml+xml',
  7431. 'st' => 'application/vnd.sailingtracker.track',
  7432. 'stc' => 'application/vnd.sun.xml.calc.template',
  7433. 'std' => 'application/vnd.sun.xml.draw.template',
  7434. 'stf' => 'application/vnd.wt.stf',
  7435. 'sti' => 'application/vnd.sun.xml.impress.template',
  7436. 'stk' => 'application/hyperstudio',
  7437. 'stl' => 'application/vnd.ms-pki.stl',
  7438. 'str' => 'application/vnd.pg.format',
  7439. 'stw' => 'application/vnd.sun.xml.writer.template',
  7440. 'sub' => 'image/vnd.dvb.subtitle',
  7441. 'sub' => 'text/vnd.dvb.subtitle',
  7442. 'sus' => 'application/vnd.sus-calendar',
  7443. 'susp' => 'application/vnd.sus-calendar',
  7444. 'sv4cpio' => 'application/x-sv4cpio',
  7445. 'sv4crc' => 'application/x-sv4crc',
  7446. 'svc' => 'application/vnd.dvb.service',
  7447. 'svd' => 'application/vnd.svd',
  7448. 'svg' => 'image/svg+xml',
  7449. 'svgz' => 'image/svg+xml',
  7450. 'swa' => 'application/x-director',
  7451. 'swf' => 'application/x-shockwave-flash',
  7452. 'swi' => 'application/vnd.aristanetworks.swi',
  7453. 'sxc' => 'application/vnd.sun.xml.calc',
  7454. 'sxd' => 'application/vnd.sun.xml.draw',
  7455. 'sxg' => 'application/vnd.sun.xml.writer.global',
  7456. 'sxi' => 'application/vnd.sun.xml.impress',
  7457. 'sxm' => 'application/vnd.sun.xml.math',
  7458. 'sxw' => 'application/vnd.sun.xml.writer',
  7459. 't' => 'text/troff',
  7460. 't3' => 'application/x-t3vm-image',
  7461. 'taglet' => 'application/vnd.mynfc',
  7462. 'tao' => 'application/vnd.tao.intent-module-archive',
  7463. 'tar' => 'application/x-tar',
  7464. 'tcap' => 'application/vnd.3gpp2.tcap',
  7465. 'tcl' => 'application/x-tcl',
  7466. 'teacher' => 'application/vnd.smart.teacher',
  7467. 'tei' => 'application/tei+xml',
  7468. 'teicorpus' => 'application/tei+xml',
  7469. 'tex' => 'application/x-tex',
  7470. 'texi' => 'application/x-texinfo',
  7471. 'texinfo' => 'application/x-texinfo',
  7472. 'text' => 'text/plain',
  7473. 'tfi' => 'application/thraud+xml',
  7474. 'tfm' => 'application/x-tex-tfm',
  7475. 'tga' => 'image/x-tga',
  7476. 'thmx' => 'application/vnd.ms-officetheme',
  7477. 'tif' => 'image/tiff',
  7478. 'tiff' => 'image/tiff',
  7479. 'tmo' => 'application/vnd.tmobile-livetv',
  7480. 'torrent' => 'application/x-bittorrent',
  7481. 'tpl' => 'application/vnd.groove-tool-template',
  7482. 'tpt' => 'application/vnd.trid.tpt',
  7483. 'tr' => 'text/troff',
  7484. 'tra' => 'application/vnd.trueapp',
  7485. 'trm' => 'application/x-msterminal',
  7486. 'tsd' => 'application/timestamped-data',
  7487. 'tsv' => 'text/tab-separated-values',
  7488. 'ttc' => 'application/x-font-ttf',
  7489. 'ttf' => 'application/x-font-ttf',
  7490. 'ttl' => 'text/turtle',
  7491. 'twd' => 'application/vnd.simtech-mindmapper',
  7492. 'twds' => 'application/vnd.simtech-mindmapper',
  7493. 'txd' => 'application/vnd.genomatix.tuxedo',
  7494. 'txf' => 'application/vnd.mobius.txf',
  7495. 'txt' => 'text/plain',
  7496. 'u32' => 'application/x-authorware-bin',
  7497. 'udeb' => 'application/x-debian-package',
  7498. 'ufd' => 'application/vnd.ufdl',
  7499. 'ufdl' => 'application/vnd.ufdl',
  7500. 'ulx' => 'application/x-glulx',
  7501. 'umj' => 'application/vnd.umajin',
  7502. 'unityweb' => 'application/vnd.unity',
  7503. 'uoml' => 'application/vnd.uoml+xml',
  7504. 'uri' => 'text/uri-list',
  7505. 'uris' => 'text/uri-list',
  7506. 'urls' => 'text/uri-list',
  7507. 'ustar' => 'application/x-ustar',
  7508. 'utz' => 'application/vnd.uiq.theme',
  7509. 'uu' => 'text/x-uuencode',
  7510. 'uva' => 'audio/vnd.dece.audio',
  7511. 'uvd' => 'application/vnd.dece.data',
  7512. 'uvf' => 'application/vnd.dece.data',
  7513. 'uvg' => 'image/vnd.dece.graphic',
  7514. 'uvh' => 'video/vnd.dece.hd',
  7515. 'uvi' => 'image/vnd.dece.graphic',
  7516. 'uvm' => 'video/vnd.dece.mobile',
  7517. 'uvp' => 'video/vnd.dece.pd',
  7518. 'uvs' => 'video/vnd.dece.sd',
  7519. 'uvt' => 'application/vnd.dece.ttml+xml',
  7520. 'uvu' => 'video/vnd.uvvu.mp4',
  7521. 'uvv' => 'video/vnd.dece.video',
  7522. 'uvva' => 'audio/vnd.dece.audio',
  7523. 'uvvd' => 'application/vnd.dece.data',
  7524. 'uvvf' => 'application/vnd.dece.data',
  7525. 'uvvg' => 'image/vnd.dece.graphic',
  7526. 'uvvh' => 'video/vnd.dece.hd',
  7527. 'uvvi' => 'image/vnd.dece.graphic',
  7528. 'uvvm' => 'video/vnd.dece.mobile',
  7529. 'uvvp' => 'video/vnd.dece.pd',
  7530. 'uvvs' => 'video/vnd.dece.sd',
  7531. 'uvvt' => 'application/vnd.dece.ttml+xml',
  7532. 'uvvu' => 'video/vnd.uvvu.mp4',
  7533. 'uvvv' => 'video/vnd.dece.video',
  7534. 'uvvx' => 'application/vnd.dece.unspecified',
  7535. 'uvvz' => 'application/vnd.dece.zip',
  7536. 'uvx' => 'application/vnd.dece.unspecified',
  7537. 'uvz' => 'application/vnd.dece.zip',
  7538. 'vcard' => 'text/vcard',
  7539. 'vcd' => 'application/x-cdlink',
  7540. 'vcf' => 'text/x-vcard',
  7541. 'vcg' => 'application/vnd.groove-vcard',
  7542. 'vcs' => 'text/x-vcalendar',
  7543. 'vcx' => 'application/vnd.vcx',
  7544. 'vis' => 'application/vnd.visionary',
  7545. 'viv' => 'video/vnd.vivo',
  7546. 'vob' => 'video/x-ms-vob',
  7547. 'vor' => 'application/vnd.stardivision.writer',
  7548. 'vox' => 'application/x-authorware-bin',
  7549. 'vrml' => 'model/vrml',
  7550. 'vsd' => 'application/vnd.visio',
  7551. 'vsf' => 'application/vnd.vsf',
  7552. 'vss' => 'application/vnd.visio',
  7553. 'vst' => 'application/vnd.visio',
  7554. 'vsw' => 'application/vnd.visio',
  7555. 'vtu' => 'model/vnd.vtu',
  7556. 'vxml' => 'application/voicexml+xml',
  7557. 'w3d' => 'application/x-director',
  7558. 'wad' => 'application/x-doom',
  7559. 'wav' => 'audio/x-wav',
  7560. 'wax' => 'audio/x-ms-wax',
  7561. 'wbmp' => 'image/vnd.wap.wbmp',
  7562. 'wbs' => 'application/vnd.criticaltools.wbs+xml',
  7563. 'wbxml' => 'application/vnd.wap.wbxml',
  7564. 'wcm' => 'application/vnd.ms-works',
  7565. 'wdb' => 'application/vnd.ms-works',
  7566. 'wdp' => 'image/vnd.ms-photo',
  7567. 'weba' => 'audio/webm',
  7568. 'webm' => 'video/webm',
  7569. 'webp' => 'image/webp',
  7570. 'wg' => 'application/vnd.pmi.widget',
  7571. 'wgt' => 'application/widget',
  7572. 'wks' => 'application/vnd.ms-works',
  7573. 'wm' => 'video/x-ms-wm',
  7574. 'wma' => 'audio/x-ms-wma',
  7575. 'wmd' => 'application/x-ms-wmd',
  7576. 'wmf' => 'application/x-msmetafile',
  7577. 'wml' => 'text/vnd.wap.wml',
  7578. 'wmlc' => 'application/vnd.wap.wmlc',
  7579. 'wmls' => 'text/vnd.wap.wmlscript',
  7580. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  7581. 'wmv' => 'video/x-ms-wmv',
  7582. 'wmx' => 'video/x-ms-wmx',
  7583. 'wmz' => 'application/x-ms-wmz',
  7584. 'wmz' => 'application/x-msmetafile',
  7585. 'woff' => 'application/font-woff',
  7586. 'wpd' => 'application/vnd.wordperfect',
  7587. 'wpl' => 'application/vnd.ms-wpl',
  7588. 'wps' => 'application/vnd.ms-works',
  7589. 'wqd' => 'application/vnd.wqd',
  7590. 'wri' => 'application/x-mswrite',
  7591. 'wrl' => 'model/vrml',
  7592. 'wsdl' => 'application/wsdl+xml',
  7593. 'wspolicy' => 'application/wspolicy+xml',
  7594. 'wtb' => 'application/vnd.webturbo',
  7595. 'wvx' => 'video/x-ms-wvx',
  7596. 'x32' => 'application/x-authorware-bin',
  7597. 'x3d' => 'model/x3d+xml',
  7598. 'x3db' => 'model/x3d+binary',
  7599. 'x3dbz' => 'model/x3d+binary',
  7600. 'x3dv' => 'model/x3d+vrml',
  7601. 'x3dvz' => 'model/x3d+vrml',
  7602. 'x3dz' => 'model/x3d+xml',
  7603. 'xaml' => 'application/xaml+xml',
  7604. 'xap' => 'application/x-silverlight-app',
  7605. 'xar' => 'application/vnd.xara',
  7606. 'xbap' => 'application/x-ms-xbap',
  7607. 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
  7608. 'xbm' => 'image/x-xbitmap',
  7609. 'xdf' => 'application/xcap-diff+xml',
  7610. 'xdm' => 'application/vnd.syncml.dm+xml',
  7611. 'xdp' => 'application/vnd.adobe.xdp+xml',
  7612. 'xdssc' => 'application/dssc+xml',
  7613. 'xdw' => 'application/vnd.fujixerox.docuworks',
  7614. 'xenc' => 'application/xenc+xml',
  7615. 'xer' => 'application/patch-ops-error+xml',
  7616. 'xfdf' => 'application/vnd.adobe.xfdf',
  7617. 'xfdl' => 'application/vnd.xfdl',
  7618. 'xht' => 'application/xhtml+xml',
  7619. 'xhtml' => 'application/xhtml+xml',
  7620. 'xhvml' => 'application/xv+xml',
  7621. 'xif' => 'image/vnd.xiff',
  7622. 'xla' => 'application/vnd.ms-excel',
  7623. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  7624. 'xlc' => 'application/vnd.ms-excel',
  7625. 'xlf' => 'application/x-xliff+xml',
  7626. 'xlm' => 'application/vnd.ms-excel',
  7627. 'xls' => 'application/vnd.ms-excel',
  7628. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  7629. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  7630. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  7631. 'xlt' => 'application/vnd.ms-excel',
  7632. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  7633. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  7634. 'xlw' => 'application/vnd.ms-excel',
  7635. 'xm' => 'audio/xm',
  7636. 'xml' => 'application/xml',
  7637. 'xo' => 'application/vnd.olpc-sugar',
  7638. 'xop' => 'application/xop+xml',
  7639. 'xpi' => 'application/x-xpinstall',
  7640. 'xpl' => 'application/xproc+xml',
  7641. 'xpm' => 'image/x-xpixmap',
  7642. 'xpr' => 'application/vnd.is-xpr',
  7643. 'xps' => 'application/vnd.ms-xpsdocument',
  7644. 'xpw' => 'application/vnd.intercon.formnet',
  7645. 'xpx' => 'application/vnd.intercon.formnet',
  7646. 'xsl' => 'application/xml',
  7647. 'xslt' => 'application/xslt+xml',
  7648. 'xsm' => 'application/vnd.syncml+xml',
  7649. 'xspf' => 'application/xspf+xml',
  7650. 'xul' => 'application/vnd.mozilla.xul+xml',
  7651. 'xvm' => 'application/xv+xml',
  7652. 'xvml' => 'application/xv+xml',
  7653. 'xwd' => 'image/x-xwindowdump',
  7654. 'xyz' => 'chemical/x-xyz',
  7655. 'xz' => 'application/x-xz',
  7656. 'yang' => 'application/yang',
  7657. 'yin' => 'application/yin+xml',
  7658. 'z1' => 'application/x-zmachine',
  7659. 'z2' => 'application/x-zmachine',
  7660. 'z3' => 'application/x-zmachine',
  7661. 'z4' => 'application/x-zmachine',
  7662. 'z5' => 'application/x-zmachine',
  7663. 'z6' => 'application/x-zmachine',
  7664. 'z7' => 'application/x-zmachine',
  7665. 'z8' => 'application/x-zmachine',
  7666. 'zaz' => 'application/vnd.zzazz.deck+xml',
  7667. 'zip' => 'application/zip',
  7668. 'zir' => 'application/vnd.zul',
  7669. 'zirz' => 'application/vnd.zul',
  7670. 'zmm' => 'application/vnd.handheld-entertainment+xml'
  7671. );
  7672. }
  7673. // Always run this
  7674. if(strpos($_SERVER['SCRIPT_NAME'], 'check.php') == false){
  7675. dependCheck();
  7676. }