functions.php 345 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357
  1. <?php
  2. // ===================================
  3. // Define Version
  4. define('INSTALLEDVERSION', '1.5001');
  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 'available':
  4341. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/available", $body, $headers);
  4342. break;
  4343. case 'unavailable':
  4344. $api = curl_post(OMBIURL."/api/v1/Request/".$type."/unavailable", $body, $headers);
  4345. break;
  4346. case 'deny':
  4347. $api = curl_put(OMBIURL."/api/v1/Request/".$type."/deny", $body, $headers);
  4348. break;
  4349. case 'delete':
  4350. $api = curl_delete(OMBIURL."/api/v1/Request/".$type."/".$id, $headers);
  4351. break;
  4352. default:
  4353. # code...
  4354. break;
  4355. }
  4356. switch ($api['http_code']['http_code']){
  4357. case 401:
  4358. writeLog("error", "OMBI: Invalid API KEY");
  4359. return false;
  4360. break;
  4361. case 200:
  4362. writeLog("success", "OMBI: action completed successfully for [type: $type - action: $action - id: $id]");
  4363. return true;
  4364. break;
  4365. default:
  4366. writeLog("error", "OMBI: unknown error with request [type: $type - action: $action - id: $id]");
  4367. return false;
  4368. }
  4369. //return (!empty($result) ? $result : null );
  4370. }
  4371. function getOmbiRequests($type = "both"){
  4372. $headers = array(
  4373. "Accept" => "application/json",
  4374. "Apikey" => OMBIKEY,
  4375. );
  4376. $requests = array();
  4377. switch ($type) {
  4378. case 'movie':
  4379. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4380. break;
  4381. case 'tv':
  4382. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4383. break;
  4384. default:
  4385. $movie = json_decode(curl_get(OMBIURL."/api/v1/Request/movie", $headers), true);
  4386. $tv = json_decode(curl_get(OMBIURL."/api/v1/Request/tv", $headers), true);
  4387. break;
  4388. }
  4389. if(isset($movie)){
  4390. //$movie = array_reverse($movie);
  4391. foreach ($movie as $key => $value) {
  4392. $requests[] = array(
  4393. 'id' => $value['theMovieDbId'],
  4394. 'title' => $value['title'],
  4395. 'poster' => (strpos($value['posterPath'], "http") !== false) ? $value['posterPath'] : 'https://image.tmdb.org/t/p/w300/'.$value['posterPath'],
  4396. 'approved' => $value['approved'],
  4397. 'available' => $value['available'],
  4398. 'denied' => $value['denied'],
  4399. 'deniedReason' => $value['deniedReason'],
  4400. 'user' => $value['requestedUser']['userName'],
  4401. 'request_id' => $value['id'],
  4402. 'request_date' => $value['requestedDate'],
  4403. 'release_date' => $value['releaseDate'],
  4404. 'type' => 'movie',
  4405. 'icon' => 'mdi mdi-filmstrip',
  4406. 'color' => 'palette-Purple-900 bg white',
  4407. );
  4408. }
  4409. }
  4410. if(isset($tv) && (is_array($tv) || is_object($tv))){
  4411. foreach ($tv as $key => $value) {
  4412. if(is_array($value['childRequests'][0])){
  4413. $requests[] = array(
  4414. 'id' => $value['tvDbId'],
  4415. 'title' => $value['title'],
  4416. 'poster' => $value['posterPath'],
  4417. 'approved' => $value['childRequests'][0]['approved'],
  4418. 'available' => $value['childRequests'][0]['available'],
  4419. 'denied' => $value['childRequests'][0]['denied'],
  4420. 'deniedReason' => $value['childRequests'][0]['deniedReason'],
  4421. 'user' => $value['childRequests'][0]['requestedUser']['userName'],
  4422. 'request_id' => $value['id'],
  4423. 'request_date' => $value['childRequests'][0]['requestedDate'],
  4424. 'release_date' => $value['releaseDate'],
  4425. 'type' => 'tv',
  4426. 'icon' => 'mdi mdi-television',
  4427. 'color' => 'grayish-blue-bg',
  4428. );
  4429. }
  4430. }
  4431. }
  4432. return (empty($requests)) ? '' : $requests;
  4433. }
  4434. function convertOmbiString($type, $value){
  4435. switch ($type) {
  4436. case 'approved':
  4437. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4438. $string['icon'] = ($value) ? 'mdi mdi-check' : 'mdi mdi-clock';
  4439. $string['color'] = ($value) ? 'green-bg' : 'yellow-bg';
  4440. break;
  4441. case 'available':
  4442. $string['string'] = ($value) ? 'Available' : 'Not Downloaded';
  4443. $string['icon'] = ($value) ? 'mdi mdi-server' : 'mdi mdi-server-off';
  4444. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4445. break;
  4446. case 'denied':
  4447. $string['string'] = ($value) ? 'Denied' : 'Approved';
  4448. $string['icon'] = ($value) ? 'mdi mdi-emoticon-sad' : 'mdi mdi-emoticon-happy';
  4449. $string['color'] = ($value) ? 'red-bg' : 'green-bg';
  4450. break;
  4451. case 'status':
  4452. switch ($value) {
  4453. case '1':
  4454. $string['string'] = 'Denied';
  4455. $string['icon'] = 'mdi mdi-window-close';
  4456. $string['color'] = 'red-bg';
  4457. break;
  4458. case '2':
  4459. $string['string'] = 'Approved';
  4460. $string['icon'] = 'mdi mdi-check';
  4461. $string['color'] = 'green-bg';
  4462. break;
  4463. case '3':
  4464. $string['string'] = 'Not Approved';
  4465. $string['icon'] = 'mdi mdi-clock';
  4466. $string['color'] = 'yellow-bg';
  4467. break;
  4468. default:
  4469. # code...
  4470. break;
  4471. }
  4472. break;
  4473. default:
  4474. $string['string'] = ($value) ? 'Approved' : 'Approval-Pending';
  4475. $string['color'] = ($value) ? 'green-bg' : 'red-bg';
  4476. break;
  4477. }
  4478. return $string;
  4479. }
  4480. function buildOmbiItem($type, $group, $user, $request){
  4481. if (is_array($request) || is_object($request)){
  4482. $actions = '';
  4483. if($request['denied']){
  4484. $status = 1;
  4485. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4486. }else{
  4487. if($request['approved']){
  4488. $status = 2;
  4489. }else{
  4490. $status = 3;
  4491. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="approve"><a class="requestAction" href="javascript:void(0)">Approve</a></li>';
  4492. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="deny"><a class="requestAction" href="javascript:void(0)">Deny</a></li>';
  4493. }
  4494. }
  4495. if($request['available']){
  4496. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="unavailable"><a class="requestAction" href="javascript:void(0)">Mark as Unavailable</a></li>';
  4497. }else{
  4498. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="available"><a class="requestAction" href="javascript:void(0)">Mark as Available</a></li>';
  4499. }
  4500. $actions .= '<li request-type="'.$type.'" request-id="'.$request['request_id'].'" request-name="delete"><a class="requestAction" href="javascript:void(0)">Delete</a></li>';
  4501. if(isset($group) && $group == 'admin'){
  4502. return '
  4503. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4504. <div class="requestOptions">
  4505. <div class="btn-group transparent" role="group">
  4506. <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>
  4507. <ul class="dropdown-menu"><h6 class="text-center requestHeader gray-bg">'.$request['user'].'</h6>'.$actions.'</ul>
  4508. </div>
  4509. </div>
  4510. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4511. <div class="requestBottom text-center">
  4512. <div data-toggle="tooltip" data-placement="top" data-original-title="'.$request['type'].'" class="zero-m requestGroup '.$request['color'].'">
  4513. <i class="'.$request['icon'].'"></i>
  4514. </div>
  4515. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4516. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4517. </div>
  4518. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4519. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4520. </div>
  4521. </div>
  4522. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4523. </div>';
  4524. }elseif(isset($group) && $group == 'user'){
  4525. if(strtolower($request['user']) == strtolower($user)){
  4526. return '
  4527. <div class="item-'.$type.'-'.convertOmbiString('approved', $request['approved'])['string'].'">
  4528. <a class="openTab" extraTitle="'.$request['title'].'" extraType="'.$type.'" openTab="true"><img alt="" class="slick-image-tall" data-lazy="'.$request['poster'].'"></a>
  4529. <div class="requestBottom text-center">
  4530. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('status', $status)['string'].'" class="zero-m requestGroup '.convertOmbiString('status', $status)['color'].'">
  4531. <i class="'.convertOmbiString('status', $status)['icon'].'"></i>
  4532. </div>
  4533. <div data-toggle="tooltip" data-placement="top" data-original-title="'.convertOmbiString('available', $request['available'])['string'].'" class="zero-m requestGroup '.convertOmbiString('available', $request['available'])['color'].'">
  4534. <i class="'.convertOmbiString('available', $request['available'])['icon'].'"></i>
  4535. </div>
  4536. </div>
  4537. <small class="elip slick-bottom-title">'.$request['title'].'</small>
  4538. </div>';
  4539. }
  4540. }
  4541. }
  4542. }
  4543. function buildOmbiList($group, $user){
  4544. $requests = array();
  4545. $movieList = getOmbiRequests('movie');
  4546. $tvList = getOmbiRequests('tv');
  4547. if(is_array($movieList) && is_array($tvList)){
  4548. $result = array_merge($movieList , $tvList );
  4549. }else{
  4550. if(is_array($movieList)){
  4551. $result = $movieList;
  4552. }elseif(is_array($movieList)){
  4553. $result = $tvList;
  4554. }else{
  4555. $result = false;
  4556. }
  4557. }
  4558. if (is_array($result) || is_object($result)){
  4559. usort($result, function ($item1, $item2) {
  4560. if ($item1['request_date'] == $item2['request_date']) return 0;
  4561. return $item1['request_date'] > $item2['request_date'] ? -1 : 1;
  4562. });
  4563. foreach ($result as $request) {
  4564. if($request['type'] == 'movie'){
  4565. $requests[] = buildOmbiItem('movie', $group, $user, $request);
  4566. }elseif($request['type'] == 'tv'){
  4567. $requests[] = buildOmbiItem('season', $group, $user, $request);
  4568. }
  4569. }
  4570. }
  4571. return outputOmbiRequests("Requested Content", $requests, "
  4572. setInterval(function() {
  4573. $('<div></div>').load('ajax.php?a=ombi-requests',function() {
  4574. var element = $(this).find('#recentRequests');
  4575. var loadedID = element.attr('id');
  4576. $('#recentRequests').replaceWith(element);
  4577. console.log('Loaded updated: '+loadedID);
  4578. loadSlick();
  4579. });
  4580. }, ".RECENTREFRESH.");
  4581. ", false);
  4582. }
  4583. function outputOmbiRequests($header = "Requested Content", $items, $script = false, $array) {
  4584. $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">';
  4585. if(preg_grep("/item-movie-Approved/", $items)){
  4586. $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>';
  4587. }
  4588. if(preg_grep("/item-movie-Approval-Pending/", $items)){
  4589. $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>';
  4590. }
  4591. if(preg_grep("/item-season-Approved/", $items)){
  4592. $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>';
  4593. }
  4594. if(preg_grep("/item-season-Approval-Pending/", $items)){
  4595. $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>';
  4596. }
  4597. $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>';
  4598. $hideMenu .= '</ul></div></div>';
  4599. // If None Populate Empty Item
  4600. if (!count($items)) {
  4601. 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>';
  4602. }else{
  4603. $className = str_replace(' ', '', $header);
  4604. 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>':'');
  4605. }
  4606. }
  4607. function loadIcons(){
  4608. $dirname = "images/";
  4609. $images = scandir($dirname);
  4610. $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");
  4611. $allIcons = '';
  4612. foreach($images as $curimg){
  4613. if(!in_array($curimg, $ignore)) {
  4614. $allIcons .= '
  4615. <div class="col-xs-2" style="width: 75px; height: 75px; padding-right: 0px;">
  4616. <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);">
  4617. <img style="width: 50px; height: 50px;" data-src="'.$dirname.$curimg.'" alt="thumbnail" class="allIcons lazyload shadow">
  4618. </a>
  4619. </div>
  4620. ';
  4621. }
  4622. }
  4623. return $allIcons;
  4624. }
  4625. function buildHomepageSettings(){
  4626. $homepageOrder = homepageOrder();
  4627. $homepageList = '<h4>Drag Homepage Items to Order Them</h4><div id="homepage-items" class="external-events">';
  4628. $inputList = '<div id="homepage-values" class="row">';
  4629. foreach ($homepageOrder as $key => $val) {
  4630. switch ($key) {
  4631. case 'homepageOrdercustomhtml':
  4632. $class = 'palette-Deep-Purple-100 bg gray';
  4633. $image = 'images/html.png';
  4634. if(empty(HOMEPAGECUSTOMHTML1)){
  4635. $class .= ' faded';
  4636. }
  4637. break;
  4638. case 'homepageOrdernotice':
  4639. $class = 'palette-Cyan-A400 bg gray';
  4640. $image = 'images/pin.png';
  4641. if(empty(HOMEPAGENOTICETITLE) && empty(HOMEPAGENOTICEMESSAGE)){
  4642. $class .= ' faded';
  4643. }
  4644. break;
  4645. case 'homepageOrderspeedtest':
  4646. $class = 'red-bg';
  4647. $image = 'images/settings/full-color/png/64px/speedometer.png';
  4648. if(SPEEDTEST !== "true"){
  4649. $class .= ' faded';
  4650. }
  4651. break;
  4652. case 'homepageOrdernzbget':
  4653. $class = 'green-bg';
  4654. $image = 'images/nzbget.png';
  4655. if(empty(NZBGETURL)){
  4656. $class .= ' faded';
  4657. }
  4658. break;
  4659. case 'homepageOrdersabnzbd':
  4660. $class = 'yellow-bg';
  4661. $image = 'images/sabnzbd.png';
  4662. if(empty(SABNZBDURL)){
  4663. $class .= ' faded';
  4664. }
  4665. break;
  4666. case 'homepageOrderplexsearch':
  4667. case 'homepageOrderplexnowplaying':
  4668. case 'homepageOrderplexrecent':
  4669. case 'homepageOrderplexplaylist':
  4670. $class = 'palette-Amber-A700 bg gray';
  4671. $image = 'images/plex.png';
  4672. if(empty(PLEXURL)){
  4673. $class .= ' faded';
  4674. }
  4675. break;
  4676. case 'homepageOrderembynowplaying':
  4677. case 'homepageOrderembyrecent':
  4678. $class = 'palette-Green-A700 bg gray';
  4679. $image = 'images/emby.png';
  4680. if(empty(EMBYURL)){
  4681. $class .= ' faded';
  4682. }
  4683. break;
  4684. case 'homepageOrderombi':
  4685. $class = 'orange-bg';
  4686. $image = 'images/ombi.png';
  4687. if(empty(OMBIURL)){
  4688. $class .= ' faded';
  4689. }
  4690. break;
  4691. case 'homepageOrdercalendar':
  4692. $class = 'palette-Blue-400 bg gray';
  4693. $image = 'images/calendar.png';
  4694. if(SONARRURL == "" && RADARRURL == "" && HEADPHONESURL == "" && SICKRAGEURL == "" && COUCHURL == "" ){
  4695. $class .= ' faded';
  4696. }
  4697. break;
  4698. default:
  4699. $class = 'blue-bg';
  4700. $image = '';
  4701. break;
  4702. }
  4703. $homepageList .= '
  4704. <div class="col-md-3 sort-homepage"><div class="fc-event '.$class.'">
  4705. <span class="ordinal-position text-uppercase badge badge-gray" data-link="'.$key.'" style="float:left;width: 30px;">'.$val.'</span>
  4706. &nbsp; '.strtoupper(substr($key, 13)).'
  4707. <span class="remove-event"><img style="width: 22px;" src="'.$image.'"></span>
  4708. </div></div>';
  4709. $inputList .= '<input type="hidden" name="'.$key.'">';
  4710. }
  4711. $homepageList .= '</div>';
  4712. $inputList .= '</div>';
  4713. return $homepageList.$inputList;
  4714. }
  4715. function buildHomepage($group, $user){
  4716. $homepageOrder = homepageOrder();
  4717. $homepageBuilt = '';
  4718. foreach ($homepageOrder as $key => $value) {
  4719. $homepageBuilt .= buildHomepageItem($key, $group, $user);
  4720. }
  4721. return $homepageBuilt;
  4722. }
  4723. function realSize($bytes, $decimals = 2) {
  4724. $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
  4725. $factor = floor((strlen($bytes) - 1) / 3);
  4726. return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' '.@$size[$factor];
  4727. }
  4728. function buildHomepageItem($homepageItem, $group, $user){
  4729. $homepageItemBuilt = '';
  4730. switch ($homepageItem) {
  4731. case 'homepageOrderplexsearch':
  4732. if((qualifyUser(PLEXSEARCHAUTH) && PLEXSEARCH == "true" && qualifyUser(PLEXHOMEAUTH))) {
  4733. $homepageItemBuilt .= '
  4734. <div id="searchPlexRow" class="row">
  4735. <div class="col-lg-12">
  4736. <div class="content-box box-shadow big-box todo-list">
  4737. <form id="plexSearchForm" onsubmit="return false;" autocomplete="off">
  4738. <div class="">
  4739. <div class="input-group">
  4740. <div style="border-radius: 25px 0 0 25px; border:0" class="input-group-addon gray-bg"><i class="fa fa-search white"></i></div>
  4741. <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">
  4742. <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>
  4743. <button style="display:none" id="plexSearchForm_submit" class="btn btn-primary waves"></button>
  4744. </div>
  4745. </div>
  4746. </form>
  4747. <div id="resultshere" class="table-responsive"></div>
  4748. </div>
  4749. </div>
  4750. </div>
  4751. ';
  4752. }
  4753. break;
  4754. case 'homepageOrdercustomhtml':
  4755. if (qualifyUser(HOMEPAGECUSTOMHTML1AUTH) && HOMEPAGECUSTOMHTML1) {
  4756. $homepageItemBuilt .= "<div>" . HOMEPAGECUSTOMHTML1 . "</div>";
  4757. }
  4758. break;
  4759. case 'homepageOrdernotice':
  4760. if (qualifyUser(HOMEPAGENOTICEAUTH) && HOMEPAGENOTICETITLE && HOMEPAGENOTICETYPE && HOMEPAGENOTICEMESSAGE && HOMEPAGENOTICELAYOUT) {
  4761. $homepageItemBuilt .= buildHomepageNotice(HOMEPAGENOTICELAYOUT, HOMEPAGENOTICETYPE, HOMEPAGENOTICETITLE, HOMEPAGENOTICEMESSAGE);
  4762. }
  4763. break;
  4764. case 'homepageOrderspeedtest':
  4765. if(SPEEDTEST == "true" && qualifyUser(SPEEDTESTAUTH)){
  4766. $homepageItemBuilt .= '
  4767. <style type="text/css">
  4768. .flash {
  4769. animation: flash 0.6s linear infinite;
  4770. }
  4771. @keyframes flash {
  4772. 0% { opacity: 0.6; }
  4773. 50% { opacity: 1; }
  4774. }
  4775. </style>
  4776. <script type="text/javascript">
  4777. var w = null
  4778. function runTest() {
  4779. document.getElementById("startBtn").style.display = "none"
  4780. document.getElementById("testArea").style.display = ""
  4781. document.getElementById("abortBtn").style.display = ""
  4782. w = new Worker("bower_components/speed/speedtest_worker.js")
  4783. var interval = setInterval(function () { w.postMessage("status") }, 100)
  4784. w.onmessage = function (event) {
  4785. var data = event.data.split(";")
  4786. var status = Number(data[0])
  4787. var dl = document.getElementById("download")
  4788. var ul = document.getElementById("upload")
  4789. var ping = document.getElementById("ping")
  4790. var jitter = document.getElementById("jitter")
  4791. dl.className = status === 1 ? "w-name flash" : "w-name"
  4792. ping.className = status === 2 ? "w-name flash" : "w-name"
  4793. jitter.className = ul.className = status === 3 ? "w-name flash" : "w-name"
  4794. if (status >= 4) {
  4795. clearInterval(interval)
  4796. document.getElementById("abortBtn").style.display = "none"
  4797. document.getElementById("startBtn").style.display = ""
  4798. w = null
  4799. }
  4800. if (status === 5) {
  4801. document.getElementById("testArea").style.display = "none"
  4802. }
  4803. dl.textContent = data[1] + " Mbit/s";
  4804. $("#downloadpercent").attr("style", "width: " + data[1] + "%;");
  4805. $("#uploadpercent").attr("style", "width: " + data[2] + "%;");
  4806. $("#pingpercent").attr("style", "width: " + data[3] + "%;");
  4807. $("#jitterpercent").attr("style", "width: " + data[5] + "%;");
  4808. ul.textContent = data[2] + " Mbit/s";
  4809. ping.textContent = data[3] + " ms";
  4810. jitter.textContent = data[5] + " ms";
  4811. }
  4812. w.postMessage(\'start {"telemetry_level":"basic"}\')
  4813. //w.postMessage("start")
  4814. }
  4815. function abortTest() {
  4816. if (w) w.postMessage("abort")
  4817. }
  4818. </script>
  4819. <div class="row" id="testArea" style="display:none">
  4820. <div class="test col-sm-3 col-lg-3">
  4821. <div class="content-box ultra-widget green-bg" data-counter="">
  4822. <div id="downloadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4823. <div class="w-content">
  4824. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-download"></i></div>
  4825. <div class="w-descr left pull-left text-center">
  4826. <span class="testName text-uppercase w-name">Download</span>
  4827. <br>
  4828. <span class="w-name counter" id="download" ></span>
  4829. </div>
  4830. </div>
  4831. </div>
  4832. </div>
  4833. <div class="test col-sm-3 col-lg-3">
  4834. <div class="content-box ultra-widget red-bg" data-counter="">
  4835. <div id="uploadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4836. <div class="w-content">
  4837. <div class="w-icon right pull-right"><i class="mdi mdi-cloud-upload"></i></div>
  4838. <div class="w-descr left pull-left text-center">
  4839. <span class="testName text-uppercase w-name">Upload</span>
  4840. <br>
  4841. <span class="w-name counter" id="upload" ></span>
  4842. </div>
  4843. </div>
  4844. </div>
  4845. </div>
  4846. <div class="test col-sm-3 col-lg-3">
  4847. <div class="content-box ultra-widget yellow-bg" data-counter="">
  4848. <div id="pingpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4849. <div class="w-content">
  4850. <div class="w-icon right pull-right"><i class="mdi mdi-timer"></i></div>
  4851. <div class="w-descr left pull-left text-center">
  4852. <span class="testName text-uppercase w-name">Latency</span>
  4853. <br>
  4854. <span class="w-name counter" id="ping" ></span>
  4855. </div>
  4856. </div>
  4857. </div>
  4858. </div>
  4859. <div class="test col-sm-3 col-lg-3">
  4860. <div class="content-box ultra-widget blue-bg" data-counter="">
  4861. <div id="jitterpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
  4862. <div class="w-content">
  4863. <div class="w-icon right pull-right"><i class="mdi mdi-pulse"></i></div>
  4864. <div class="w-descr left pull-left text-center">
  4865. <span class="testName text-uppercase w-name">Jitter</span>
  4866. <br>
  4867. <span class="w-name counter" id="jitter" ></span>
  4868. </div>
  4869. </div>
  4870. </div>
  4871. </div>
  4872. <br/>
  4873. </div>
  4874. <div id="abortBtn" class="row" style="display: none" onclick="javascript:abortTest()">
  4875. <div class="col-lg-12">
  4876. <div class="content-box red-bg" style="cursor: pointer;">
  4877. <h1 style="margin: 10px" class="text-uppercase text-center">Abort Speed Test</h1>
  4878. <div class="clearfix"></div>
  4879. </div>
  4880. </div>
  4881. </div>
  4882. <div id="startBtn" class="row" onclick="javascript:runTest()">
  4883. <div class="col-lg-12">
  4884. <div class="content-box green-bg" style="cursor: pointer;">
  4885. <h1 style="margin: 10px" class="text-uppercase text-center">Run Speed Test</h1>
  4886. <div class="clearfix"></div>
  4887. </div>
  4888. </div>
  4889. </div>
  4890. ';
  4891. }
  4892. break;
  4893. case 'homepageOrdernzbget':
  4894. if(NZBGETURL != "" && qualifyUser(NZBGETHOMEAUTH)){
  4895. $homepageItemBuilt .= buildDownloader('nzbget');
  4896. }
  4897. break;
  4898. case 'homepageOrdersabnzbd':
  4899. if(SABNZBDURL != "" && qualifyUser(SABNZBDHOMEAUTH)) {
  4900. $homepageItemBuilt .= buildDownloader('sabnzbd');
  4901. }
  4902. break;
  4903. case 'homepageOrderplexnowplaying':
  4904. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4905. if(qualifyUser(PLEXPLAYINGNOWAUTH) && PLEXPLAYINGNOW == "true"){
  4906. $homepageItemBuilt .= '<div id="plexRowNowPlaying" class="row">';
  4907. $homepageItemBuilt .= getPlexStreams(12, PLEXSHOWNAMES, $group);
  4908. $homepageItemBuilt .= '</div>';
  4909. }
  4910. }
  4911. break;
  4912. case 'homepageOrderplexrecent':
  4913. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4914. if(qualifyUser(PLEXRECENTMOVIEAUTH) && PLEXRECENTMOVIE == "true" || qualifyUser(PLEXRECENTTVAUTH) && PLEXRECENTTV == "true" || qualifyUser(PLEXRECENTMUSICAUTH) && PLEXRECENTMUSIC == "true"){
  4915. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  4916. $homepageItemBuilt .= '<div id="plexRow" class="row"><div class="col-lg-12">';
  4917. $homepageItemBuilt .= getPlexRecent($plexArray);
  4918. $homepageItemBuilt .= '</div></div>';
  4919. }
  4920. }
  4921. break;
  4922. case 'homepageOrderplexplaylist':
  4923. if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) {
  4924. if(qualifyUser(PLEXPLAYLISTSAUTH) && PLEXPLAYLISTS == "true"){
  4925. $homepageItemBuilt .= '<div id="plexPlaylists" class="row"><div class="col-lg-12">';
  4926. $plexArray = array("movie" => PLEXRECENTMOVIE, "season" => PLEXRECENTTV, "album" => PLEXRECENTMUSIC);
  4927. $homepageItemBuilt .= getPlexPlaylists($plexArray);
  4928. $homepageItemBuilt .= '</div> </div>';
  4929. }
  4930. }
  4931. break;
  4932. case 'homepageOrderembynowplaying':
  4933. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  4934. if(qualifyUser(EMBYPLAYINGNOWAUTH) && EMBYPLAYINGNOW == "true"){
  4935. $homepageItemBuilt .= '<div id="embyRowNowPlaying" class="row">';
  4936. $homepageItemBuilt .= getEmbyStreams(12, EMBYSHOWNAMES, $group);
  4937. $homepageItemBuilt .= '</div>';
  4938. }
  4939. }
  4940. break;
  4941. case 'homepageOrderembyrecent':
  4942. if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) {
  4943. if(qualifyUser(EMBYRECENTMOVIEAUTH) && EMBYRECENTMOVIE == "true" || qualifyUser(EMBYRECENTTVAUTH) && EMBYRECENTTV == "true" || qualifyUser(EMBYRECENTMUSICAUTH) && EMBYRECENTMUSIC == "true"){
  4944. $embyArray = array("Movie" => EMBYRECENTMOVIE, "Episode" => EMBYRECENTTV, "MusicAlbum" => EMBYRECENTMUSIC, "Series" => EMBYRECENTTV);
  4945. $homepageItemBuilt .= '<div id="embyRow" class="row"><div class="col-lg-12">';
  4946. $homepageItemBuilt .= getEmbyRecent($embyArray);
  4947. $homepageItemBuilt .= '</div></div>';
  4948. }
  4949. }
  4950. break;
  4951. case 'homepageOrderombi':
  4952. if (qualifyUser(OMBIAUTH) && OMBIURL) {
  4953. $homepageItemBuilt .= '<div id="ombiRequests" class="row"><div class="col-lg-12">';
  4954. $homepageItemBuilt .= buildOmbiList($group, $user);
  4955. $homepageItemBuilt .= '</div></div>';
  4956. }
  4957. break;
  4958. case 'homepageOrdercalendar':
  4959. if ((SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)) || (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)) || (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)) || (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)) || (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH))) {
  4960. $calendarItems = '';
  4961. if(RADARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="film" href="javascript:void(0)">Movies</a></li>'; }
  4962. if(SONARRURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="tv" href="javascript:void(0)">TV Shows</a></li>'; }
  4963. if(HEADPHONESURL != ""){ $calendarItems .= '<li><a class="calendarOption" calendarOption="music" href="javascript:void(0)">Music</a></li>'; }
  4964. $homepageItemBuilt .= '
  4965. <div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">
  4966. <div class="col-lg-12 content-form form-inline">
  4967. <div class="form-group pull-right">
  4968. <span class="swal-legend label label-primary well-sm">Legend</span>&nbsp;
  4969. <div class="btn-group" role="group">
  4970. <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>
  4971. <ul style="right:0; left: auto" class="dropdown-menu">
  4972. <li><a class="calendarOption" calendarOption="all" href="javascript:void(0)">View All</a></li>
  4973. '.$calendarItems.'
  4974. </ul>
  4975. </div>
  4976. </div>
  4977. </div>
  4978. </div>
  4979. <div id="calendarRow" class="row">
  4980. <div class="col-lg-12">
  4981. <div id="calendar" class="fc-calendar box-shadow fc fc-ltr fc-unthemed"></div>
  4982. </div>
  4983. </div>
  4984. ';
  4985. }
  4986. break;
  4987. default:
  4988. # code...
  4989. break;
  4990. }
  4991. return $homepageItemBuilt;
  4992. }
  4993. function buildDownloader($name){
  4994. return '
  4995. <div id="downloadClientRow" class="row">
  4996. <div class="col-xs-12 col-md-12">
  4997. <div class="content-box">
  4998. <div class="tabbable panel with-nav-tabs panel-default">
  4999. <div class="panel-heading">
  5000. <div class="content-tools i-block pull-right">
  5001. <a id="getDownloader" class="repeat-btn">
  5002. <i class="fa fa-repeat"></i>
  5003. </a>
  5004. </div>
  5005. <h3 class="pull-left">'.strtoupper($name).'</h3>
  5006. <ul class="nav nav-tabs pull-right">
  5007. <li class="active"><a href="#downloadQueue-'.$name.'" data-toggle="tab" aria-expanded="true">'.translate("QUEUE").'</a></li>
  5008. <li class=""><a href="#downloadHistory-'.$name.'" data-toggle="tab" aria-expanded="false">'.translate("HISTORY").'</a></li>
  5009. </ul>
  5010. <div class="clearfix"></div>
  5011. </div>
  5012. <div class="panel-body">
  5013. <div class="tab-content">
  5014. <div class="tab-pane fade active in" id="downloadQueue-'.$name.'">
  5015. <div class="table-responsive" style="max-height: 300px">
  5016. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  5017. <thead>
  5018. <tr>
  5019. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  5020. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  5021. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  5022. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  5023. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  5024. </tr>
  5025. </thead>
  5026. <tbody class="dl-queue '.$name.'"></tbody>
  5027. </table>
  5028. </div>
  5029. </div>
  5030. <div class="tab-pane fade" id="downloadHistory-'.$name.'">
  5031. <div class="table-responsive" style="max-height: 300px">
  5032. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  5033. <thead>
  5034. <tr>
  5035. <th class="col-xs-7 nzbtable-file-row">'.translate("FILE").'</th>
  5036. <th class="col-xs-2 nzbtable">'.translate("STATUS").'</th>
  5037. <th class="col-xs-1 nzbtable">'.translate("CATEGORY").'</th>
  5038. <th class="col-xs-1 nzbtable">'.translate("SIZE").'</th>
  5039. <th class="col-xs-2 nzbtable">'.translate("PROGRESS").'</th>
  5040. </tr>
  5041. </thead>
  5042. <tbody class="dl-history '.$name.'"></tbody>
  5043. </table>
  5044. </div>
  5045. </div>
  5046. </div>
  5047. </div>
  5048. </div>
  5049. </div>
  5050. </div>
  5051. </div>';
  5052. }
  5053. class Mobile_Detect
  5054. {
  5055. /**
  5056. * Mobile detection type.
  5057. *
  5058. * @deprecated since version 2.6.9
  5059. */
  5060. const DETECTION_TYPE_MOBILE = 'mobile';
  5061. /**
  5062. * Extended detection type.
  5063. *
  5064. * @deprecated since version 2.6.9
  5065. */
  5066. const DETECTION_TYPE_EXTENDED = 'extended';
  5067. /**
  5068. * A frequently used regular expression to extract version #s.
  5069. *
  5070. * @deprecated since version 2.6.9
  5071. */
  5072. const VER = '([\w._\+]+)';
  5073. /**
  5074. * Top-level device.
  5075. */
  5076. const MOBILE_GRADE_A = 'A';
  5077. /**
  5078. * Mid-level device.
  5079. */
  5080. const MOBILE_GRADE_B = 'B';
  5081. /**
  5082. * Low-level device.
  5083. */
  5084. const MOBILE_GRADE_C = 'C';
  5085. /**
  5086. * Stores the version number of the current release.
  5087. */
  5088. const VERSION = '2.8.26';
  5089. /**
  5090. * A type for the version() method indicating a string return value.
  5091. */
  5092. const VERSION_TYPE_STRING = 'text';
  5093. /**
  5094. * A type for the version() method indicating a float return value.
  5095. */
  5096. const VERSION_TYPE_FLOAT = 'float';
  5097. /**
  5098. * A cache for resolved matches
  5099. * @var array
  5100. */
  5101. protected $cache = array();
  5102. /**
  5103. * The User-Agent HTTP header is stored in here.
  5104. * @var string
  5105. */
  5106. protected $userAgent = null;
  5107. /**
  5108. * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
  5109. * @var array
  5110. */
  5111. protected $httpHeaders = array();
  5112. /**
  5113. * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
  5114. * @var array
  5115. */
  5116. protected $cloudfrontHeaders = array();
  5117. /**
  5118. * The matching Regex.
  5119. * This is good for debug.
  5120. * @var string
  5121. */
  5122. protected $matchingRegex = null;
  5123. /**
  5124. * The matches extracted from the regex expression.
  5125. * This is good for debug.
  5126. * @var string
  5127. */
  5128. protected $matchesArray = null;
  5129. /**
  5130. * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
  5131. *
  5132. * @deprecated since version 2.6.9
  5133. *
  5134. * @var string
  5135. */
  5136. protected $detectionType = self::DETECTION_TYPE_MOBILE;
  5137. /**
  5138. * HTTP headers that trigger the 'isMobile' detection
  5139. * to be true.
  5140. *
  5141. * @var array
  5142. */
  5143. protected static $mobileHeaders = array(
  5144. 'HTTP_ACCEPT' => array('matches' => array(
  5145. // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
  5146. 'application/x-obml2d',
  5147. // BlackBerry devices.
  5148. 'application/vnd.rim.html',
  5149. 'text/vnd.wap.wml',
  5150. 'application/vnd.wap.xhtml+xml'
  5151. )),
  5152. 'HTTP_X_WAP_PROFILE' => null,
  5153. 'HTTP_X_WAP_CLIENTID' => null,
  5154. 'HTTP_WAP_CONNECTION' => null,
  5155. 'HTTP_PROFILE' => null,
  5156. // Reported by Opera on Nokia devices (eg. C3).
  5157. 'HTTP_X_OPERAMINI_PHONE_UA' => null,
  5158. 'HTTP_X_NOKIA_GATEWAY_ID' => null,
  5159. 'HTTP_X_ORANGE_ID' => null,
  5160. 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
  5161. 'HTTP_X_HUAWEI_USERID' => null,
  5162. // Reported by Windows Smartphones.
  5163. 'HTTP_UA_OS' => null,
  5164. // Reported by Verizon, Vodafone proxy system.
  5165. 'HTTP_X_MOBILE_GATEWAY' => null,
  5166. // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
  5167. 'HTTP_X_ATT_DEVICEID' => null,
  5168. // Seen this on a HTC.
  5169. 'HTTP_UA_CPU' => array('matches' => array('ARM')),
  5170. );
  5171. /**
  5172. * List of mobile devices (phones).
  5173. *
  5174. * @var array
  5175. */
  5176. protected static $phoneDevices = array(
  5177. 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
  5178. 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
  5179. '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',
  5180. 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
  5181. // @todo: Is 'Dell Streak' a tablet or a phone? ;)
  5182. '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',
  5183. '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',
  5184. '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',
  5185. '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)',
  5186. 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
  5187. 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
  5188. 'NokiaLumia' => 'Lumia [0-9]{3,4}',
  5189. // http://www.micromaxinfo.com/mobiles/smartphones
  5190. // Added because the codes might conflict with Acer Tablets.
  5191. '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',
  5192. // @todo Complete the regex.
  5193. 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
  5194. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
  5195. // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
  5196. // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
  5197. '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',
  5198. // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
  5199. 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
  5200. // http://fr.wikomobile.com
  5201. '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',
  5202. 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
  5203. // Added simvalley mobile just for fun. They have some interesting devices.
  5204. // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
  5205. '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',
  5206. // Wolfgang - a brand that is sold by Aldi supermarkets.
  5207. // http://www.wolfgangmobile.com/
  5208. 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
  5209. 'Alcatel' => 'Alcatel',
  5210. 'Nintendo' => 'Nintendo 3DS',
  5211. // http://en.wikipedia.org/wiki/Amoi
  5212. 'Amoi' => 'Amoi',
  5213. // http://en.wikipedia.org/wiki/INQ
  5214. 'INQ' => 'INQ',
  5215. // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
  5216. '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',
  5217. );
  5218. /**
  5219. * List of tablet devices.
  5220. *
  5221. * @var array
  5222. */
  5223. protected static $tabletDevices = array(
  5224. // @todo: check for mobile friendly emails topic.
  5225. 'iPad' => 'iPad|iPad.*Mobile',
  5226. // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
  5227. // @see #442
  5228. 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
  5229. '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.
  5230. // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
  5231. '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)',
  5232. // Only the Surface tablets with Windows RT are considered mobile.
  5233. // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
  5234. 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
  5235. // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
  5236. 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
  5237. // Watch out for PadFone, see #132.
  5238. // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
  5239. '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',
  5240. 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
  5241. 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
  5242. 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
  5243. 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
  5244. // http://www.acer.ro/ac/ro/RO/content/drivers
  5245. // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
  5246. // http://us.acer.com/ac/en/US/content/group/tablets
  5247. // http://www.acer.de/ac/de/DE/content/models/tablets/
  5248. // Can conflict with Micromax and Motorola phones codes.
  5249. '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',
  5250. // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
  5251. // http://us.toshiba.com/tablets/tablet-finder
  5252. // http://www.toshiba.co.jp/regza/tablet/
  5253. 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
  5254. // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
  5255. // http://www.lg.com/us/tablets
  5256. 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
  5257. 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
  5258. // Prestigio Tablets http://www.prestigio.com/support
  5259. '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',
  5260. // http://support.lenovo.com/en_GB/downloads/default.page?#
  5261. '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|)',
  5262. // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
  5263. 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
  5264. // http://www.yarvik.com/en/matrix/tablets/
  5265. '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',
  5266. 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
  5267. 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
  5268. // http://www.intenso.de/kategorie_en.php?kategorie=33
  5269. // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
  5270. 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
  5271. // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
  5272. 'IRUTablet' => 'M702pro',
  5273. 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
  5274. // http://www.e-boda.ro/tablete-pc.html
  5275. 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
  5276. // http://www.allview.ro/produse/droseries/lista-tablete-pc/
  5277. 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
  5278. // http://wiki.archosfans.com/index.php?title=Main_Page
  5279. // @note Rewrite the regex format after we add more UAs.
  5280. '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',
  5281. // http://www.ainol.com/plugin.php?identifier=ainol&module=product
  5282. 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
  5283. 'NokiaLumiaTablet' => 'Lumia 2520',
  5284. // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
  5285. // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
  5286. // http://www.sony.jp/support/tablet/
  5287. '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',
  5288. // 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
  5289. 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
  5290. // db + http://www.cube-tablet.com/buy-products.html
  5291. 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
  5292. // http://www.cobyusa.com/?p=pcat&pcat_id=3001
  5293. 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
  5294. // http://www.match.net.cn/products.asp
  5295. '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',
  5296. // http://www.msi.com/support
  5297. // @todo Research the Windows Tablets.
  5298. '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',
  5299. // @todo http://www.kyoceramobile.com/support/drivers/
  5300. // 'KyoceraTablet' => null,
  5301. // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
  5302. // 'IntextTablet' => null,
  5303. // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
  5304. // http://www.imp3.net/14/show.php?itemid=20454
  5305. 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
  5306. // http://www.rock-chips.com/index.php?do=prod&pid=2
  5307. 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
  5308. // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
  5309. 'FlyTablet' => 'IQ310|Fly Vision',
  5310. // http://www.bqreaders.com/gb/tablets-prices-sale.html
  5311. 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
  5312. // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
  5313. // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
  5314. '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',
  5315. // Nec or Medias Tab
  5316. 'NecTablet' => '\bN-06D|\bN-08D',
  5317. // Pantech Tablets: http://www.pantechusa.com/phones/
  5318. 'PantechTablet' => 'Pantech.*P4100',
  5319. // Broncho Tablets: http://www.broncho.cn/ (hard to find)
  5320. 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
  5321. // http://versusuk.com/support.html
  5322. 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
  5323. // http://www.zync.in/index.php/our-products/tablet-phablets
  5324. 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
  5325. // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
  5326. 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
  5327. // https://www.nabitablet.com/
  5328. 'NabiTablet' => 'Android.*\bNabi',
  5329. 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
  5330. // French Danew Tablets http://www.danew.com/produits-tablette.php
  5331. 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
  5332. // Texet Tablets and Readers http://www.texet.ru/tablet/
  5333. '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',
  5334. // Avoid detecting 'PLAYSTATION 3' as mobile.
  5335. 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
  5336. // http://www.trekstor.de/surftabs.html
  5337. 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
  5338. // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
  5339. 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
  5340. // http://www.advandigital.com/index.php?link=content-product&jns=JP001
  5341. // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
  5342. '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 ',
  5343. // http://www.danytech.com/category/tablet-pc
  5344. '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',
  5345. // http://www.galapad.net/product.html
  5346. 'GalapadTablet' => 'Android.*\bG1\b',
  5347. // http://www.micromaxinfo.com/tablet/funbook
  5348. 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
  5349. // http://www.karbonnmobiles.com/products_tablet.php
  5350. 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
  5351. // http://www.myallfine.com/Products.asp
  5352. 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
  5353. // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
  5354. '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',
  5355. // http://www.yonesnav.com/products/products.php
  5356. 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
  5357. // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
  5358. // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
  5359. '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',
  5360. // http://www.gloryunion.cn/products.asp
  5361. // http://www.allwinnertech.com/en/apply/mobile.html
  5362. // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
  5363. // @todo: Softwiner tablets?
  5364. // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
  5365. '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
  5366. // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
  5367. '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',
  5368. // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
  5369. // @todo: add more tests.
  5370. 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
  5371. // http://hclmetablet.com/India/index.php
  5372. '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',
  5373. // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
  5374. 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
  5375. // http://www.visture.com/index.asp
  5376. 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
  5377. // http://www.mijncresta.nl/tablet
  5378. 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
  5379. // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
  5380. 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
  5381. // Concorde tab
  5382. 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
  5383. // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
  5384. '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',
  5385. // Modecom Tablets - http://www.modecom.eu/tablets/portal/
  5386. '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',
  5387. // Vonino Tablets - http://www.vonino.eu/tablets
  5388. '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',
  5389. // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
  5390. 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
  5391. // Storex Tablets - http://storex.fr/espace_client/support.html
  5392. // @note: no need to add all the tablet codes since they are guided by the first regex.
  5393. 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
  5394. // Generic Vodafone tablets.
  5395. 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
  5396. // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
  5397. // Aka: http://www.essentielb.fr/
  5398. 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
  5399. // Ross & Moor - http://ross-moor.ru/
  5400. 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
  5401. // i-mobile http://product.i-mobilephone.com/Mobile_Device
  5402. 'iMobileTablet' => 'i-mobile i-note',
  5403. // http://www.tolino.de/de/vergleichen/
  5404. 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
  5405. // AudioSonic - a Kmart brand
  5406. // 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
  5407. 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
  5408. // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
  5409. // @todo: add them gradually to avoid conflicts.
  5410. 'AMPETablet' => 'Android.* A78 ',
  5411. // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
  5412. 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
  5413. // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
  5414. 'TecnoTablet' => 'TECNO P9',
  5415. // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
  5416. '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',
  5417. // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
  5418. '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)',
  5419. // http://www.intracon.eu/tablet
  5420. 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
  5421. // http://www.xoro.de/produkte/
  5422. // @note: Might be the same brand with 'Simply tablets'
  5423. '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',
  5424. // http://www1.viewsonic.com/products/computing/tablets/
  5425. 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
  5426. // http://www.odys.de/web/internet-tablet_en.html
  5427. 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
  5428. // http://www.captiva-power.de/products.html#tablets-en
  5429. 'CaptivaTablet' => 'CAPTIVA PAD',
  5430. // IconBIT - http://www.iconbit.com/products/tablets/
  5431. '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',
  5432. // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
  5433. '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',
  5434. // Onda - http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
  5435. '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]+',
  5436. 'JaytechTablet' => 'TPC-PA762',
  5437. 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
  5438. // http://www.digma.ru/support/download/
  5439. // @todo: Ebooks also (if requested)
  5440. 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
  5441. // http://www.evolioshop.com/ro/tablete-pc.html
  5442. // http://www.evolio.ro/support/downloads_static.html?cat=2
  5443. // @todo: Research some more
  5444. 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
  5445. // @todo http://www.lavamobiles.com/tablets-data-cards
  5446. 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
  5447. // http://www.breezetablet.com/
  5448. 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
  5449. // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
  5450. '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',
  5451. // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
  5452. 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
  5453. // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
  5454. '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',
  5455. // http://www.mi.com/en
  5456. 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
  5457. // http://www.nbru.cn/index.html
  5458. 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
  5459. // http://navroad.com/products/produkty/tablety/
  5460. // http://navroad.com/products/produkty/tablety/
  5461. 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
  5462. // http://leader-online.com/new_site/product-category/tablets/
  5463. // http://www.leader-online.net.au/List/Tablet
  5464. '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',
  5465. // http://www.datawind.com/ubislate/
  5466. 'UbislateTablet' => 'UbiSlate[\s]?7C',
  5467. // http://www.pocketbook-int.com/ru/support
  5468. 'PocketBookTablet' => 'Pocketbook',
  5469. // http://www.kocaso.com/product_tablet.html
  5470. 'KocasoTablet' => '\b(TB-1207)\b',
  5471. // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
  5472. 'HisenseTablet' => '\b(F5281|E2371)\b',
  5473. // http://www.tesco.com/direct/hudl/
  5474. 'Hudl' => 'Hudl HT7S3|Hudl 2',
  5475. // http://www.telstra.com.au/home-phone/thub-2/
  5476. 'TelstraTablet' => 'T-Hub2',
  5477. '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'
  5478. );
  5479. /**
  5480. * List of mobile Operating Systems.
  5481. *
  5482. * @var array
  5483. */
  5484. protected static $operatingSystems = array(
  5485. 'AndroidOS' => 'Android',
  5486. 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
  5487. 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
  5488. 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
  5489. // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
  5490. 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
  5491. // @reference: http://en.wikipedia.org/wiki/Windows_Phone
  5492. // http://wifeng.cn/?r=blog&a=view&id=106
  5493. // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
  5494. // http://msdn.microsoft.com/library/ms537503.aspx
  5495. // https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
  5496. 'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
  5497. 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
  5498. // http://en.wikipedia.org/wiki/MeeGo
  5499. // @todo: research MeeGo in UAs
  5500. 'MeeGoOS' => 'MeeGo',
  5501. // http://en.wikipedia.org/wiki/Maemo
  5502. // @todo: research Maemo in UAs
  5503. 'MaemoOS' => 'Maemo',
  5504. 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
  5505. 'webOS' => 'webOS|hpwOS',
  5506. 'badaOS' => '\bBada\b',
  5507. 'BREWOS' => 'BREW',
  5508. );
  5509. /**
  5510. * List of mobile User Agents.
  5511. *
  5512. * IMPORTANT: This is a list of only mobile browsers.
  5513. * Mobile Detect 2.x supports only mobile browsers,
  5514. * it was never designed to detect all browsers.
  5515. * The change will come in 2017 in the 3.x release for PHP7.
  5516. *
  5517. * @var array
  5518. */
  5519. protected static $browsers = array(
  5520. //'Vivaldi' => 'Vivaldi',
  5521. // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
  5522. 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
  5523. 'Dolfin' => '\bDolfin\b',
  5524. 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
  5525. 'Skyfire' => 'Skyfire',
  5526. 'Edge' => 'Mobile Safari/[.0-9]* Edge',
  5527. 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
  5528. 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
  5529. 'Bolt' => 'bolt',
  5530. 'TeaShark' => 'teashark',
  5531. 'Blazer' => 'Blazer',
  5532. // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
  5533. 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
  5534. // http://en.wikipedia.org/wiki/Midori_(web_browser)
  5535. //'Midori' => 'midori',
  5536. //'Tizen' => 'Tizen',
  5537. 'UCBrowser' => 'UC.*Browser|UCWEB',
  5538. 'baiduboxapp' => 'baiduboxapp',
  5539. 'baidubrowser' => 'baidubrowser',
  5540. // https://github.com/serbanghita/Mobile-Detect/issues/7
  5541. 'DiigoBrowser' => 'DiigoBrowser',
  5542. // http://www.puffinbrowser.com/index.php
  5543. 'Puffin' => 'Puffin',
  5544. // http://mercury-browser.com/index.html
  5545. 'Mercury' => '\bMercury\b',
  5546. // http://en.wikipedia.org/wiki/Obigo_Browser
  5547. 'ObigoBrowser' => 'Obigo',
  5548. // http://en.wikipedia.org/wiki/NetFront
  5549. 'NetFront' => 'NF-Browser',
  5550. // @reference: http://en.wikipedia.org/wiki/Minimo
  5551. // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
  5552. 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
  5553. // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
  5554. 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
  5555. );
  5556. /**
  5557. * Utilities.
  5558. *
  5559. * @var array
  5560. */
  5561. protected static $utilities = array(
  5562. // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
  5563. // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
  5564. // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
  5565. // https://developers.facebook.com/docs/sharing/best-practices
  5566. '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',
  5567. 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
  5568. 'DesktopMode' => 'WPDesktop',
  5569. 'TV' => 'SonyDTV|HbbTV', // experimental
  5570. 'WebKit' => '(webkit)[ /]([\w.]+)',
  5571. // @todo: Include JXD consoles.
  5572. 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
  5573. 'Watch' => 'SM-V700',
  5574. );
  5575. /**
  5576. * All possible HTTP headers that represent the
  5577. * User-Agent string.
  5578. *
  5579. * @var array
  5580. */
  5581. protected static $uaHttpHeaders = array(
  5582. // The default User-Agent string.
  5583. 'HTTP_USER_AGENT',
  5584. // Header can occur on devices using Opera Mini.
  5585. 'HTTP_X_OPERAMINI_PHONE_UA',
  5586. // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
  5587. 'HTTP_X_DEVICE_USER_AGENT',
  5588. 'HTTP_X_ORIGINAL_USER_AGENT',
  5589. 'HTTP_X_SKYFIRE_PHONE',
  5590. 'HTTP_X_BOLT_PHONE_UA',
  5591. 'HTTP_DEVICE_STOCK_UA',
  5592. 'HTTP_X_UCBROWSER_DEVICE_UA'
  5593. );
  5594. /**
  5595. * The individual segments that could exist in a User-Agent string. VER refers to the regular
  5596. * expression defined in the constant self::VER.
  5597. *
  5598. * @var array
  5599. */
  5600. protected static $properties = array(
  5601. // Build
  5602. 'Mobile' => 'Mobile/[VER]',
  5603. 'Build' => 'Build/[VER]',
  5604. 'Version' => 'Version/[VER]',
  5605. 'VendorID' => 'VendorID/[VER]',
  5606. // Devices
  5607. 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
  5608. 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
  5609. 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
  5610. //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
  5611. 'Kindle' => 'Kindle/[VER]',
  5612. // Browser
  5613. 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
  5614. 'Coast' => array('Coast/[VER]'),
  5615. 'Dolfin' => 'Dolfin/[VER]',
  5616. // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
  5617. 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
  5618. 'Fennec' => 'Fennec/[VER]',
  5619. // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  5620. // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
  5621. 'Edge' => 'Edge/[VER]',
  5622. 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
  5623. // http://en.wikipedia.org/wiki/NetFront
  5624. 'NetFront' => 'NetFront/[VER]',
  5625. 'NokiaBrowser' => 'NokiaBrowser/[VER]',
  5626. 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
  5627. 'Opera Mini' => 'Opera Mini/[VER]',
  5628. 'Opera Mobi' => 'Version/[VER]',
  5629. 'UC Browser' => 'UC Browser[VER]',
  5630. 'MQQBrowser' => 'MQQBrowser/[VER]',
  5631. 'MicroMessenger' => 'MicroMessenger/[VER]',
  5632. 'baiduboxapp' => 'baiduboxapp/[VER]',
  5633. 'baidubrowser' => 'baidubrowser/[VER]',
  5634. 'SamsungBrowser' => 'SamsungBrowser/[VER]',
  5635. 'Iron' => 'Iron/[VER]',
  5636. // @note: Safari 7534.48.3 is actually Version 5.1.
  5637. // @note: On BlackBerry the Version is overwriten by the OS.
  5638. 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
  5639. 'Skyfire' => 'Skyfire/[VER]',
  5640. 'Tizen' => 'Tizen/[VER]',
  5641. 'Webkit' => 'webkit[ /][VER]',
  5642. 'PaleMoon' => 'PaleMoon/[VER]',
  5643. // Engine
  5644. 'Gecko' => 'Gecko/[VER]',
  5645. 'Trident' => 'Trident/[VER]',
  5646. 'Presto' => 'Presto/[VER]',
  5647. 'Goanna' => 'Goanna/[VER]',
  5648. // OS
  5649. 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
  5650. 'Android' => 'Android [VER]',
  5651. 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
  5652. 'BREW' => 'BREW [VER]',
  5653. 'Java' => 'Java/[VER]',
  5654. // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
  5655. // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
  5656. 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
  5657. 'Windows Phone' => 'Windows Phone [VER]',
  5658. 'Windows CE' => 'Windows CE/[VER]',
  5659. // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
  5660. 'Windows NT' => 'Windows NT [VER]',
  5661. 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
  5662. 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
  5663. );
  5664. /**
  5665. * Construct an instance of this class.
  5666. *
  5667. * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
  5668. * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
  5669. * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
  5670. * from the $headers array instead.
  5671. */
  5672. public function __construct(
  5673. array $headers = null,
  5674. $userAgent = null
  5675. ) {
  5676. $this->setHttpHeaders($headers);
  5677. $this->setUserAgent($userAgent);
  5678. }
  5679. /**
  5680. * Get the current script version.
  5681. * This is useful for the demo.php file,
  5682. * so people can check on what version they are testing
  5683. * for mobile devices.
  5684. *
  5685. * @return string The version number in semantic version format.
  5686. */
  5687. public static function getScriptVersion()
  5688. {
  5689. return self::VERSION;
  5690. }
  5691. /**
  5692. * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
  5693. *
  5694. * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
  5695. * the headers. The default null is left for backwards compatibility.
  5696. */
  5697. public function setHttpHeaders($httpHeaders = null)
  5698. {
  5699. // use global _SERVER if $httpHeaders aren't defined
  5700. if (!is_array($httpHeaders) || !count($httpHeaders)) {
  5701. $httpHeaders = $_SERVER;
  5702. }
  5703. // clear existing headers
  5704. $this->httpHeaders = array();
  5705. // Only save HTTP headers. In PHP land, that means only _SERVER vars that
  5706. // start with HTTP_.
  5707. foreach ($httpHeaders as $key => $value) {
  5708. if (substr($key, 0, 5) === 'HTTP_') {
  5709. $this->httpHeaders[$key] = $value;
  5710. }
  5711. }
  5712. // In case we're dealing with CloudFront, we need to know.
  5713. $this->setCfHeaders($httpHeaders);
  5714. }
  5715. /**
  5716. * Retrieves the HTTP headers.
  5717. *
  5718. * @return array
  5719. */
  5720. public function getHttpHeaders()
  5721. {
  5722. return $this->httpHeaders;
  5723. }
  5724. /**
  5725. * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
  5726. * Simply null is returned.
  5727. *
  5728. * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
  5729. * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
  5730. * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
  5731. *
  5732. * @return string|null The value of the header.
  5733. */
  5734. public function getHttpHeader($header)
  5735. {
  5736. // are we using PHP-flavored headers?
  5737. if (strpos($header, '_') === false) {
  5738. $header = str_replace('-', '_', $header);
  5739. $header = strtoupper($header);
  5740. }
  5741. // test the alternate, too
  5742. $altHeader = 'HTTP_' . $header;
  5743. //Test both the regular and the HTTP_ prefix
  5744. if (isset($this->httpHeaders[$header])) {
  5745. return $this->httpHeaders[$header];
  5746. } elseif (isset($this->httpHeaders[$altHeader])) {
  5747. return $this->httpHeaders[$altHeader];
  5748. }
  5749. return null;
  5750. }
  5751. public function getMobileHeaders()
  5752. {
  5753. return self::$mobileHeaders;
  5754. }
  5755. /**
  5756. * Get all possible HTTP headers that
  5757. * can contain the User-Agent string.
  5758. *
  5759. * @return array List of HTTP headers.
  5760. */
  5761. public function getUaHttpHeaders()
  5762. {
  5763. return self::$uaHttpHeaders;
  5764. }
  5765. /**
  5766. * Set CloudFront headers
  5767. * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
  5768. *
  5769. * @param array $cfHeaders List of HTTP headers
  5770. *
  5771. * @return boolean If there were CloudFront headers to be set
  5772. */
  5773. public function setCfHeaders($cfHeaders = null) {
  5774. // use global _SERVER if $cfHeaders aren't defined
  5775. if (!is_array($cfHeaders) || !count($cfHeaders)) {
  5776. $cfHeaders = $_SERVER;
  5777. }
  5778. // clear existing headers
  5779. $this->cloudfrontHeaders = array();
  5780. // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
  5781. // start with cloudfront-.
  5782. $response = false;
  5783. foreach ($cfHeaders as $key => $value) {
  5784. if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
  5785. $this->cloudfrontHeaders[strtoupper($key)] = $value;
  5786. $response = true;
  5787. }
  5788. }
  5789. return $response;
  5790. }
  5791. /**
  5792. * Retrieves the cloudfront headers.
  5793. *
  5794. * @return array
  5795. */
  5796. public function getCfHeaders()
  5797. {
  5798. return $this->cloudfrontHeaders;
  5799. }
  5800. /**
  5801. * Set the User-Agent to be used.
  5802. *
  5803. * @param string $userAgent The user agent string to set.
  5804. *
  5805. * @return string|null
  5806. */
  5807. public function setUserAgent($userAgent = null)
  5808. {
  5809. // Invalidate cache due to #375
  5810. $this->cache = array();
  5811. if (false === empty($userAgent)) {
  5812. return $this->userAgent = $userAgent;
  5813. } else {
  5814. $this->userAgent = null;
  5815. foreach ($this->getUaHttpHeaders() as $altHeader) {
  5816. if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
  5817. $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
  5818. }
  5819. }
  5820. if (!empty($this->userAgent)) {
  5821. return $this->userAgent = trim($this->userAgent);
  5822. }
  5823. }
  5824. if (count($this->getCfHeaders()) > 0) {
  5825. return $this->userAgent = 'Amazon CloudFront';
  5826. }
  5827. return $this->userAgent = null;
  5828. }
  5829. /**
  5830. * Retrieve the User-Agent.
  5831. *
  5832. * @return string|null The user agent if it's set.
  5833. */
  5834. public function getUserAgent()
  5835. {
  5836. return $this->userAgent;
  5837. }
  5838. /**
  5839. * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
  5840. * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
  5841. *
  5842. * @deprecated since version 2.6.9
  5843. *
  5844. * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
  5845. * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
  5846. */
  5847. public function setDetectionType($type = null)
  5848. {
  5849. if ($type === null) {
  5850. $type = self::DETECTION_TYPE_MOBILE;
  5851. }
  5852. if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
  5853. return;
  5854. }
  5855. $this->detectionType = $type;
  5856. }
  5857. public function getMatchingRegex()
  5858. {
  5859. return $this->matchingRegex;
  5860. }
  5861. public function getMatchesArray()
  5862. {
  5863. return $this->matchesArray;
  5864. }
  5865. /**
  5866. * Retrieve the list of known phone devices.
  5867. *
  5868. * @return array List of phone devices.
  5869. */
  5870. public static function getPhoneDevices()
  5871. {
  5872. return self::$phoneDevices;
  5873. }
  5874. /**
  5875. * Retrieve the list of known tablet devices.
  5876. *
  5877. * @return array List of tablet devices.
  5878. */
  5879. public static function getTabletDevices()
  5880. {
  5881. return self::$tabletDevices;
  5882. }
  5883. /**
  5884. * Alias for getBrowsers() method.
  5885. *
  5886. * @return array List of user agents.
  5887. */
  5888. public static function getUserAgents()
  5889. {
  5890. return self::getBrowsers();
  5891. }
  5892. /**
  5893. * Retrieve the list of known browsers. Specifically, the user agents.
  5894. *
  5895. * @return array List of browsers / user agents.
  5896. */
  5897. public static function getBrowsers()
  5898. {
  5899. return self::$browsers;
  5900. }
  5901. /**
  5902. * Retrieve the list of known utilities.
  5903. *
  5904. * @return array List of utilities.
  5905. */
  5906. public static function getUtilities()
  5907. {
  5908. return self::$utilities;
  5909. }
  5910. /**
  5911. * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
  5912. *
  5913. * @deprecated since version 2.6.9
  5914. *
  5915. * @return array All the rules (but not extended).
  5916. */
  5917. public static function getMobileDetectionRules()
  5918. {
  5919. static $rules;
  5920. if (!$rules) {
  5921. $rules = array_merge(
  5922. self::$phoneDevices,
  5923. self::$tabletDevices,
  5924. self::$operatingSystems,
  5925. self::$browsers
  5926. );
  5927. }
  5928. return $rules;
  5929. }
  5930. /**
  5931. * Method gets the mobile detection rules + utilities.
  5932. * The reason this is separate is because utilities rules
  5933. * don't necessary imply mobile. This method is used inside
  5934. * the new $detect->is('stuff') method.
  5935. *
  5936. * @deprecated since version 2.6.9
  5937. *
  5938. * @return array All the rules + extended.
  5939. */
  5940. public function getMobileDetectionRulesExtended()
  5941. {
  5942. static $rules;
  5943. if (!$rules) {
  5944. // Merge all rules together.
  5945. $rules = array_merge(
  5946. self::$phoneDevices,
  5947. self::$tabletDevices,
  5948. self::$operatingSystems,
  5949. self::$browsers,
  5950. self::$utilities
  5951. );
  5952. }
  5953. return $rules;
  5954. }
  5955. /**
  5956. * Retrieve the current set of rules.
  5957. *
  5958. * @deprecated since version 2.6.9
  5959. *
  5960. * @return array
  5961. */
  5962. public function getRules()
  5963. {
  5964. if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
  5965. return self::getMobileDetectionRulesExtended();
  5966. } else {
  5967. return self::getMobileDetectionRules();
  5968. }
  5969. }
  5970. /**
  5971. * Retrieve the list of mobile operating systems.
  5972. *
  5973. * @return array The list of mobile operating systems.
  5974. */
  5975. public static function getOperatingSystems()
  5976. {
  5977. return self::$operatingSystems;
  5978. }
  5979. /**
  5980. * Check the HTTP headers for signs of mobile.
  5981. * This is the fastest mobile check possible; it's used
  5982. * inside isMobile() method.
  5983. *
  5984. * @return bool
  5985. */
  5986. public function checkHttpHeadersForMobile()
  5987. {
  5988. foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
  5989. if (isset($this->httpHeaders[$mobileHeader])) {
  5990. if (is_array($matchType['matches'])) {
  5991. foreach ($matchType['matches'] as $_match) {
  5992. if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
  5993. return true;
  5994. }
  5995. }
  5996. return false;
  5997. } else {
  5998. return true;
  5999. }
  6000. }
  6001. }
  6002. return false;
  6003. }
  6004. /**
  6005. * Magic overloading method.
  6006. *
  6007. * @method boolean is[...]()
  6008. * @param string $name
  6009. * @param array $arguments
  6010. * @return mixed
  6011. * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
  6012. */
  6013. public function __call($name, $arguments)
  6014. {
  6015. // make sure the name starts with 'is', otherwise
  6016. if (substr($name, 0, 2) !== 'is') {
  6017. throw new BadMethodCallException("No such method exists: $name");
  6018. }
  6019. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6020. $key = substr($name, 2);
  6021. return $this->matchUAAgainstKey($key);
  6022. }
  6023. /**
  6024. * Find a detection rule that matches the current User-agent.
  6025. *
  6026. * @param null $userAgent deprecated
  6027. * @return boolean
  6028. */
  6029. protected function matchDetectionRulesAgainstUA($userAgent = null)
  6030. {
  6031. // Begin general search.
  6032. foreach ($this->getRules() as $_regex) {
  6033. if (empty($_regex)) {
  6034. continue;
  6035. }
  6036. if ($this->match($_regex, $userAgent)) {
  6037. return true;
  6038. }
  6039. }
  6040. return false;
  6041. }
  6042. /**
  6043. * Search for a certain key in the rules array.
  6044. * If the key is found then try to match the corresponding
  6045. * regex against the User-Agent.
  6046. *
  6047. * @param string $key
  6048. *
  6049. * @return boolean
  6050. */
  6051. protected function matchUAAgainstKey($key)
  6052. {
  6053. // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
  6054. $key = strtolower($key);
  6055. if (false === isset($this->cache[$key])) {
  6056. // change the keys to lower case
  6057. $_rules = array_change_key_case($this->getRules());
  6058. if (false === empty($_rules[$key])) {
  6059. $this->cache[$key] = $this->match($_rules[$key]);
  6060. }
  6061. if (false === isset($this->cache[$key])) {
  6062. $this->cache[$key] = false;
  6063. }
  6064. }
  6065. return $this->cache[$key];
  6066. }
  6067. /**
  6068. * Check if the device is mobile.
  6069. * Returns true if any type of mobile device detected, including special ones
  6070. * @param null $userAgent deprecated
  6071. * @param null $httpHeaders deprecated
  6072. * @return bool
  6073. */
  6074. public function isMobile($userAgent = null, $httpHeaders = null)
  6075. {
  6076. if ($httpHeaders) {
  6077. $this->setHttpHeaders($httpHeaders);
  6078. }
  6079. if ($userAgent) {
  6080. $this->setUserAgent($userAgent);
  6081. }
  6082. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6083. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6084. $cfHeaders = $this->getCfHeaders();
  6085. if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
  6086. return true;
  6087. }
  6088. }
  6089. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6090. if ($this->checkHttpHeadersForMobile()) {
  6091. return true;
  6092. } else {
  6093. return $this->matchDetectionRulesAgainstUA();
  6094. }
  6095. }
  6096. /**
  6097. * Check if the device is a tablet.
  6098. * Return true if any type of tablet device is detected.
  6099. *
  6100. * @param string $userAgent deprecated
  6101. * @param array $httpHeaders deprecated
  6102. * @return bool
  6103. */
  6104. public function isTablet($userAgent = null, $httpHeaders = null)
  6105. {
  6106. // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
  6107. if ($this->getUserAgent() === 'Amazon CloudFront') {
  6108. $cfHeaders = $this->getCfHeaders();
  6109. if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
  6110. return true;
  6111. }
  6112. }
  6113. $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
  6114. foreach (self::$tabletDevices as $_regex) {
  6115. if ($this->match($_regex, $userAgent)) {
  6116. return true;
  6117. }
  6118. }
  6119. return false;
  6120. }
  6121. /**
  6122. * This method checks for a certain property in the
  6123. * userAgent.
  6124. * @todo: The httpHeaders part is not yet used.
  6125. *
  6126. * @param string $key
  6127. * @param string $userAgent deprecated
  6128. * @param string $httpHeaders deprecated
  6129. * @return bool|int|null
  6130. */
  6131. public function is($key, $userAgent = null, $httpHeaders = null)
  6132. {
  6133. // Set the UA and HTTP headers only if needed (eg. batch mode).
  6134. if ($httpHeaders) {
  6135. $this->setHttpHeaders($httpHeaders);
  6136. }
  6137. if ($userAgent) {
  6138. $this->setUserAgent($userAgent);
  6139. }
  6140. $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
  6141. return $this->matchUAAgainstKey($key);
  6142. }
  6143. /**
  6144. * Some detection rules are relative (not standard),
  6145. * because of the diversity of devices, vendors and
  6146. * their conventions in representing the User-Agent or
  6147. * the HTTP headers.
  6148. *
  6149. * This method will be used to check custom regexes against
  6150. * the User-Agent string.
  6151. *
  6152. * @param $regex
  6153. * @param string $userAgent
  6154. * @return bool
  6155. *
  6156. * @todo: search in the HTTP headers too.
  6157. */
  6158. public function match($regex, $userAgent = null)
  6159. {
  6160. $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
  6161. // If positive match is found, store the results for debug.
  6162. if ($match) {
  6163. $this->matchingRegex = $regex;
  6164. $this->matchesArray = $matches;
  6165. }
  6166. return $match;
  6167. }
  6168. /**
  6169. * Get the properties array.
  6170. *
  6171. * @return array
  6172. */
  6173. public static function getProperties()
  6174. {
  6175. return self::$properties;
  6176. }
  6177. /**
  6178. * Prepare the version number.
  6179. *
  6180. * @todo Remove the error supression from str_replace() call.
  6181. *
  6182. * @param string $ver The string version, like "2.6.21.2152";
  6183. *
  6184. * @return float
  6185. */
  6186. public function prepareVersionNo($ver)
  6187. {
  6188. $ver = str_replace(array('_', ' ', '/'), '.', $ver);
  6189. $arrVer = explode('.', $ver, 2);
  6190. if (isset($arrVer[1])) {
  6191. $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
  6192. }
  6193. return (float) implode('.', $arrVer);
  6194. }
  6195. /**
  6196. * Check the version of the given property in the User-Agent.
  6197. * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
  6198. *
  6199. * @param string $propertyName The name of the property. See self::getProperties() array
  6200. * keys for all possible properties.
  6201. * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
  6202. * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
  6203. * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
  6204. * invalid parameter will default to the this type as well.
  6205. *
  6206. * @return string|float The version of the property we are trying to extract.
  6207. */
  6208. public function version($propertyName, $type = self::VERSION_TYPE_STRING)
  6209. {
  6210. if (empty($propertyName)) {
  6211. return false;
  6212. }
  6213. // set the $type to the default if we don't recognize the type
  6214. if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
  6215. $type = self::VERSION_TYPE_STRING;
  6216. }
  6217. $properties = self::getProperties();
  6218. // Check if the property exists in the properties array.
  6219. if (true === isset($properties[$propertyName])) {
  6220. // Prepare the pattern to be matched.
  6221. // Make sure we always deal with an array (string is converted).
  6222. $properties[$propertyName] = (array) $properties[$propertyName];
  6223. foreach ($properties[$propertyName] as $propertyMatchString) {
  6224. $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
  6225. // Identify and extract the version.
  6226. preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
  6227. if (false === empty($match[1])) {
  6228. $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
  6229. return $version;
  6230. }
  6231. }
  6232. }
  6233. return false;
  6234. }
  6235. /**
  6236. * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
  6237. *
  6238. * @return string One of the self::MOBILE_GRADE_* constants.
  6239. */
  6240. public function mobileGrade()
  6241. {
  6242. $isMobile = $this->isMobile();
  6243. if (
  6244. // 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)
  6245. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6246. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6247. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
  6248. // 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)
  6249. // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
  6250. // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
  6251. // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
  6252. ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
  6253. // 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)
  6254. $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
  6255. // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
  6256. $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
  6257. // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
  6258. $this->match('Playbook.*Tablet') ||
  6259. // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
  6260. ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
  6261. // Palm WebOS 3.0 - Tested on HP TouchPad
  6262. $this->match('hp.*TouchPad') ||
  6263. // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
  6264. ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
  6265. // Chrome for Android - Tested on Android 4.0, 4.1 device
  6266. ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
  6267. // Skyfire 4.1 - Tested on Android 2.3 device
  6268. ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6269. // Opera Mobile 11.5-12: Tested on Android 2.3
  6270. ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
  6271. // Meego 1.2 - Tested on Nokia 950 and N9
  6272. $this->is('MeeGoOS') ||
  6273. // Tizen (pre-release) - Tested on early hardware
  6274. $this->is('Tizen') ||
  6275. // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
  6276. // @todo: more tests here!
  6277. $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
  6278. // UC Browser - Tested on Android 2.3 device
  6279. ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
  6280. // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
  6281. ( $this->match('Kindle Fire') ||
  6282. $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
  6283. // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
  6284. $this->is('AndroidOS') && $this->is('NookTablet') ||
  6285. // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
  6286. $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
  6287. // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
  6288. $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
  6289. // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
  6290. $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
  6291. // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
  6292. $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
  6293. // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
  6294. $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
  6295. ){
  6296. return self::MOBILE_GRADE_A;
  6297. }
  6298. if (
  6299. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
  6300. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
  6301. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
  6302. // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
  6303. $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
  6304. //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
  6305. ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
  6306. ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
  6307. // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
  6308. $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
  6309. // @todo: report this (tested on Nokia N71)
  6310. $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
  6311. ){
  6312. return self::MOBILE_GRADE_B;
  6313. }
  6314. if (
  6315. // Blackberry 4.x - Tested on the Curve 8330
  6316. $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
  6317. // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
  6318. $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
  6319. // Tested on original iPhone (3.1), iPhone 3 (3.2)
  6320. $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6321. $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6322. $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
  6323. // Internet Explorer 7 and older - Tested on Windows XP
  6324. $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
  6325. ){
  6326. return self::MOBILE_GRADE_C;
  6327. }
  6328. // All older smartphone platforms and featurephones - Any device that doesn't support media queries
  6329. // will receive the basic, C grade experience.
  6330. return self::MOBILE_GRADE_C;
  6331. }
  6332. }
  6333. $mobileDetect = new Mobile_Detect;
  6334. $userDevice = ($mobileDetect->isMobile() ? ($mobileDetect->isTablet() ? 'tablet' : 'phone') : 'computer');
  6335. function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  6336. $path = getServerPath();
  6337. return '
  6338. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6339. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  6340. <head>
  6341. <!--[if gte mso 9]><xml>
  6342. <o:OfficeDocumentSettings>
  6343. <o:AllowPNG/>
  6344. <o:PixelsPerInch>96</o:PixelsPerInch>
  6345. </o:OfficeDocumentSettings>
  6346. </xml><![endif]-->
  6347. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6348. <meta name="viewport" content="width=device-width">
  6349. <!--[if !mso]><!-->
  6350. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6351. <!--<![endif]-->
  6352. <title></title>
  6353. <!--[if !mso]><!-- -->
  6354. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
  6355. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  6356. <!--<![endif]-->
  6357. <style type="text/css" id="media-query">
  6358. body {
  6359. margin: 0;
  6360. padding: 0;
  6361. }
  6362. table,
  6363. tr,
  6364. td {
  6365. vertical-align: top;
  6366. border-collapse: collapse;
  6367. }
  6368. .ie-browser table,
  6369. .mso-container table {
  6370. table-layout: fixed;
  6371. }
  6372. * {
  6373. line-height: inherit;
  6374. }
  6375. a[x-apple-data-detectors=true] {
  6376. color: inherit !important;
  6377. text-decoration: none !important;
  6378. }
  6379. [owa] .img-container div,
  6380. [owa] .img-container button {
  6381. display: block !important;
  6382. }
  6383. [owa] .fullwidth button {
  6384. width: 100% !important;
  6385. }
  6386. [owa] .block-grid .col {
  6387. display: table-cell;
  6388. float: none !important;
  6389. vertical-align: top;
  6390. }
  6391. .ie-browser .num12,
  6392. .ie-browser .block-grid,
  6393. [owa] .num12,
  6394. [owa] .block-grid {
  6395. width: 615px !important;
  6396. }
  6397. .ExternalClass,
  6398. .ExternalClass p,
  6399. .ExternalClass span,
  6400. .ExternalClass font,
  6401. .ExternalClass td,
  6402. .ExternalClass div {
  6403. line-height: 100%;
  6404. }
  6405. .ie-browser .mixed-two-up .num4,
  6406. [owa] .mixed-two-up .num4 {
  6407. width: 204px !important;
  6408. }
  6409. .ie-browser .mixed-two-up .num8,
  6410. [owa] .mixed-two-up .num8 {
  6411. width: 408px !important;
  6412. }
  6413. .ie-browser .block-grid.two-up .col,
  6414. [owa] .block-grid.two-up .col {
  6415. width: 307px !important;
  6416. }
  6417. .ie-browser .block-grid.three-up .col,
  6418. [owa] .block-grid.three-up .col {
  6419. width: 205px !important;
  6420. }
  6421. .ie-browser .block-grid.four-up .col,
  6422. [owa] .block-grid.four-up .col {
  6423. width: 153px !important;
  6424. }
  6425. .ie-browser .block-grid.five-up .col,
  6426. [owa] .block-grid.five-up .col {
  6427. width: 123px !important;
  6428. }
  6429. .ie-browser .block-grid.six-up .col,
  6430. [owa] .block-grid.six-up .col {
  6431. width: 102px !important;
  6432. }
  6433. .ie-browser .block-grid.seven-up .col,
  6434. [owa] .block-grid.seven-up .col {
  6435. width: 87px !important;
  6436. }
  6437. .ie-browser .block-grid.eight-up .col,
  6438. [owa] .block-grid.eight-up .col {
  6439. width: 76px !important;
  6440. }
  6441. .ie-browser .block-grid.nine-up .col,
  6442. [owa] .block-grid.nine-up .col {
  6443. width: 68px !important;
  6444. }
  6445. .ie-browser .block-grid.ten-up .col,
  6446. [owa] .block-grid.ten-up .col {
  6447. width: 61px !important;
  6448. }
  6449. .ie-browser .block-grid.eleven-up .col,
  6450. [owa] .block-grid.eleven-up .col {
  6451. width: 55px !important;
  6452. }
  6453. .ie-browser .block-grid.twelve-up .col,
  6454. [owa] .block-grid.twelve-up .col {
  6455. width: 51px !important;
  6456. }
  6457. @media only screen and (min-width: 635px) {
  6458. .block-grid {
  6459. width: 615px !important;
  6460. }
  6461. .block-grid .col {
  6462. display: table-cell;
  6463. Float: none !important;
  6464. vertical-align: top;
  6465. }
  6466. .block-grid .col.num12 {
  6467. width: 615px !important;
  6468. }
  6469. .block-grid.mixed-two-up .col.num4 {
  6470. width: 204px !important;
  6471. }
  6472. .block-grid.mixed-two-up .col.num8 {
  6473. width: 408px !important;
  6474. }
  6475. .block-grid.two-up .col {
  6476. width: 307px !important;
  6477. }
  6478. .block-grid.three-up .col {
  6479. width: 205px !important;
  6480. }
  6481. .block-grid.four-up .col {
  6482. width: 153px !important;
  6483. }
  6484. .block-grid.five-up .col {
  6485. width: 123px !important;
  6486. }
  6487. .block-grid.six-up .col {
  6488. width: 102px !important;
  6489. }
  6490. .block-grid.seven-up .col {
  6491. width: 87px !important;
  6492. }
  6493. .block-grid.eight-up .col {
  6494. width: 76px !important;
  6495. }
  6496. .block-grid.nine-up .col {
  6497. width: 68px !important;
  6498. }
  6499. .block-grid.ten-up .col {
  6500. width: 61px !important;
  6501. }
  6502. .block-grid.eleven-up .col {
  6503. width: 55px !important;
  6504. }
  6505. .block-grid.twelve-up .col {
  6506. width: 51px !important;
  6507. }
  6508. }
  6509. @media (max-width: 635px) {
  6510. .block-grid,
  6511. .col {
  6512. min-width: 320px !important;
  6513. max-width: 100% !important;
  6514. }
  6515. .block-grid {
  6516. width: calc(100% - 40px) !important;
  6517. }
  6518. .col {
  6519. width: 100% !important;
  6520. }
  6521. .col>div {
  6522. margin: 0 auto;
  6523. }
  6524. img.fullwidth {
  6525. max-width: 100% !important;
  6526. }
  6527. }
  6528. </style>
  6529. </head>
  6530. <body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #FFFFFF">
  6531. <!--[if IE]><div class="ie-browser"><![endif]-->
  6532. <!--[if mso]><div class="mso-container"><![endif]-->
  6533. <div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: #FFFFFF">
  6534. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #FFFFFF;"><![endif]-->
  6535. <div style="background-color:#333333;">
  6536. <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;"
  6537. class="block-grid ">
  6538. <div style="border-collapse: collapse;display: table;width: 100%;">
  6539. <!--[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]-->
  6540. <!--[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]-->
  6541. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6542. <div style="background-color: transparent; width: 100% !important;">
  6543. <!--[if (!mso)&(!IE)]><!-->
  6544. <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;">
  6545. <!--<![endif]-->
  6546. <div align="left" class="img-container left fullwidth" style="padding-right: 30px; padding-left: 30px;">
  6547. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px;" align="left"><![endif]-->
  6548. <img class="left fullwidth" align="left" border="0" src="'.$path.'images/organizr-logo-h.png" alt="Image" title="Image"
  6549. 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"
  6550. width="555">
  6551. <!--[if mso]></td></tr></table><![endif]-->
  6552. </div>
  6553. <!--[if (!mso)&(!IE)]><!-->
  6554. </div>
  6555. <!--<![endif]-->
  6556. </div>
  6557. </div>
  6558. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6559. </div>
  6560. </div>
  6561. </div>
  6562. <div style="background-color:#333333;">
  6563. <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;"
  6564. class="block-grid ">
  6565. <div style="border-collapse: collapse;display: table;width: 100%;">
  6566. <!--[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]-->
  6567. <!--[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]-->
  6568. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6569. <div style="background-color: transparent; width: 100% !important;">
  6570. <!--[if (!mso)&(!IE)]><!-->
  6571. <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;">
  6572. <!--<![endif]-->
  6573. <!--[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]-->
  6574. <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;">
  6575. <div style="font-size:12px;line-height:14px;color:#FFFFFF;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6576. <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>
  6577. </span>
  6578. </p>
  6579. </div>
  6580. </div>
  6581. <!--[if mso]></td></tr></table><![endif]-->
  6582. <!--[if (!mso)&(!IE)]><!-->
  6583. </div>
  6584. <!--<![endif]-->
  6585. </div>
  6586. </div>
  6587. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6588. </div>
  6589. </div>
  6590. </div>
  6591. <div style="background-color:#393939;">
  6592. <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;"
  6593. class="block-grid ">
  6594. <div style="border-collapse: collapse;display: table;width: 100%;">
  6595. <!--[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]-->
  6596. <!--[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]-->
  6597. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6598. <div style="background-color: transparent; width: 100% !important;">
  6599. <!--[if (!mso)&(!IE)]><!-->
  6600. <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;">
  6601. <!--<![endif]-->
  6602. <!--[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]-->
  6603. <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;">
  6604. <div style="font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6605. <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>
  6606. </div>
  6607. </div>
  6608. <!--[if mso]></td></tr></table><![endif]-->
  6609. <div style="padding-right: 5px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px;">
  6610. <!--[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]-->
  6611. <div align="center">
  6612. <div style="border-top: 2px solid #66D9EF; width:55%; line-height:2px; height:2px; font-size:2px;">&#160;</div>
  6613. </div>
  6614. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6615. </div>
  6616. <!--[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]-->
  6617. <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;">
  6618. <div style="font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  6619. <p style="margin: 0;font-size: 12px;line-height: 14px"><span style="font-size: 28px; line-height: 33px;">Hey '.$user.',</span></p>
  6620. </div>
  6621. </div>
  6622. <!--[if mso]></td></tr></table><![endif]-->
  6623. <!--[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]-->
  6624. <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;">
  6625. <div style="font-size:12px;line-height:22px;font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;color:#FFFFFF;text-align:left;">
  6626. <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>
  6627. </span>
  6628. </p>
  6629. </div>
  6630. </div>
  6631. <!--[if mso]></td></tr></table><![endif]-->
  6632. <div align="center" class="button-container center" style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;">
  6633. <!--[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]-->
  6634. <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">
  6635. <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>
  6636. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6637. </div>
  6638. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  6639. </div>
  6640. <!--[if (!mso)&(!IE)]><!-->
  6641. </div>
  6642. <!--<![endif]-->
  6643. </div>
  6644. </div>
  6645. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6646. </div>
  6647. </div>
  6648. </div>
  6649. <div style="background-color:#ffffff;">
  6650. <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;"
  6651. class="block-grid ">
  6652. <div style="border-collapse: collapse;display: table;width: 100%;">
  6653. <!--[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]-->
  6654. <!--[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]-->
  6655. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6656. <div style="background-color: transparent; width: 100% !important;">
  6657. <!--[if (!mso)&(!IE)]><!-->
  6658. <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;">
  6659. <!--<![endif]-->
  6660. <!--[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]-->
  6661. <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;">
  6662. <div style="font-size:12px;line-height:14px;color:#555555;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6663. <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>
  6664. </div>
  6665. </div>
  6666. <!--[if mso]></td></tr></table><![endif]-->
  6667. <div style="padding-right: 20px; padding-left: 20px; padding-top: 15px; padding-bottom: 20px;">
  6668. <!--[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]-->
  6669. <div align="center">
  6670. <div style="border-top: 3px solid #66D9EF; width:40%; line-height:3px; height:3px; font-size:3px;">&#160;</div>
  6671. </div>
  6672. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  6673. </div>
  6674. <!--[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]-->
  6675. <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;">
  6676. <div style="font-size:12px;line-height:22px;color:#7E7D7D;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6677. <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>
  6678. </div>
  6679. </div>
  6680. <!--[if mso]></td></tr></table><![endif]-->
  6681. <!--[if (!mso)&(!IE)]><!-->
  6682. </div>
  6683. <!--<![endif]-->
  6684. </div>
  6685. </div>
  6686. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6687. </div>
  6688. </div>
  6689. </div>
  6690. <div style="background-color:#333333;">
  6691. <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;"
  6692. class="block-grid ">
  6693. <div style="border-collapse: collapse;display: table;width: 100%;">
  6694. <!--[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]-->
  6695. <!--[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]-->
  6696. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  6697. <div style="background-color: transparent; width: 100% !important;">
  6698. <!--[if (!mso)&(!IE)]><!-->
  6699. <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;">
  6700. <!--<![endif]-->
  6701. <!--[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]-->
  6702. <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;">
  6703. <div style="font-size:12px;line-height:14px;color:#959595;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  6704. <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"
  6705. href="https://github.com/causefx/Organizr" target="_blank" rel="noopener noreferrer">Organizr</a><strong><br></strong></p>
  6706. </div>
  6707. </div>
  6708. <!--[if mso]></td></tr></table><![endif]-->
  6709. <!--[if (!mso)&(!IE)]><!-->
  6710. </div>
  6711. <!--<![endif]-->
  6712. </div>
  6713. </div>
  6714. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  6715. </div>
  6716. </div>
  6717. </div>
  6718. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  6719. </div>
  6720. <!--[if (mso)|(IE)]></div><![endif]-->
  6721. </body>
  6722. </html>
  6723. ';
  6724. }
  6725. function mimeTypes(){
  6726. return array(
  6727. '123' => 'application/vnd.lotus-1-2-3',
  6728. '3dml' => 'text/vnd.in3d.3dml',
  6729. '3ds' => 'image/x-3ds',
  6730. '3g2' => 'video/3gpp2',
  6731. '3gp' => 'video/3gpp',
  6732. '7z' => 'application/x-7z-compressed',
  6733. 'aab' => 'application/x-authorware-bin',
  6734. 'aac' => 'audio/x-aac',
  6735. 'aam' => 'application/x-authorware-map',
  6736. 'aas' => 'application/x-authorware-seg',
  6737. 'abw' => 'application/x-abiword',
  6738. 'ac' => 'application/pkix-attr-cert',
  6739. 'acc' => 'application/vnd.americandynamics.acc',
  6740. 'ace' => 'application/x-ace-compressed',
  6741. 'acu' => 'application/vnd.acucobol',
  6742. 'acutc' => 'application/vnd.acucorp',
  6743. 'adp' => 'audio/adpcm',
  6744. 'aep' => 'application/vnd.audiograph',
  6745. 'afm' => 'application/x-font-type1',
  6746. 'afp' => 'application/vnd.ibm.modcap',
  6747. 'ahead' => 'application/vnd.ahead.space',
  6748. 'ai' => 'application/postscript',
  6749. 'aif' => 'audio/x-aiff',
  6750. 'aifc' => 'audio/x-aiff',
  6751. 'aiff' => 'audio/x-aiff',
  6752. 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
  6753. 'ait' => 'application/vnd.dvb.ait',
  6754. 'ami' => 'application/vnd.amiga.ami',
  6755. 'apk' => 'application/vnd.android.package-archive',
  6756. 'appcache' => 'text/cache-manifest',
  6757. 'application' => 'application/x-ms-application',
  6758. 'apr' => 'application/vnd.lotus-approach',
  6759. 'arc' => 'application/x-freearc',
  6760. 'asc' => 'application/pgp-signature',
  6761. 'asf' => 'video/x-ms-asf',
  6762. 'asm' => 'text/x-asm',
  6763. 'aso' => 'application/vnd.accpac.simply.aso',
  6764. 'asx' => 'video/x-ms-asf',
  6765. 'atc' => 'application/vnd.acucorp',
  6766. 'atom' => 'application/atom+xml',
  6767. 'atomcat' => 'application/atomcat+xml',
  6768. 'atomsvc' => 'application/atomsvc+xml',
  6769. 'atx' => 'application/vnd.antix.game-component',
  6770. 'au' => 'audio/basic',
  6771. 'avi' => 'video/x-msvideo',
  6772. 'aw' => 'application/applixware',
  6773. 'azf' => 'application/vnd.airzip.filesecure.azf',
  6774. 'azs' => 'application/vnd.airzip.filesecure.azs',
  6775. 'azw' => 'application/vnd.amazon.ebook',
  6776. 'bat' => 'application/x-msdownload',
  6777. 'bcpio' => 'application/x-bcpio',
  6778. 'bdf' => 'application/x-font-bdf',
  6779. 'bdm' => 'application/vnd.syncml.dm+wbxml',
  6780. 'bed' => 'application/vnd.realvnc.bed',
  6781. 'bh2' => 'application/vnd.fujitsu.oasysprs',
  6782. 'bin' => 'application/octet-stream',
  6783. 'blb' => 'application/x-blorb',
  6784. 'blorb' => 'application/x-blorb',
  6785. 'bmi' => 'application/vnd.bmi',
  6786. 'bmp' => 'image/bmp',
  6787. 'book' => 'application/vnd.framemaker',
  6788. 'box' => 'application/vnd.previewsystems.box',
  6789. 'boz' => 'application/x-bzip2',
  6790. 'bpk' => 'application/octet-stream',
  6791. 'btif' => 'image/prs.btif',
  6792. 'bz' => 'application/x-bzip',
  6793. 'bz2' => 'application/x-bzip2',
  6794. 'c' => 'text/x-c',
  6795. 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
  6796. 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
  6797. 'c4d' => 'application/vnd.clonk.c4group',
  6798. 'c4f' => 'application/vnd.clonk.c4group',
  6799. 'c4g' => 'application/vnd.clonk.c4group',
  6800. 'c4p' => 'application/vnd.clonk.c4group',
  6801. 'c4u' => 'application/vnd.clonk.c4group',
  6802. 'cab' => 'application/vnd.ms-cab-compressed',
  6803. 'caf' => 'audio/x-caf',
  6804. 'cap' => 'application/vnd.tcpdump.pcap',
  6805. 'car' => 'application/vnd.curl.car',
  6806. 'cat' => 'application/vnd.ms-pki.seccat',
  6807. 'cb7' => 'application/x-cbr',
  6808. 'cba' => 'application/x-cbr',
  6809. 'cbr' => 'application/x-cbr',
  6810. 'cbt' => 'application/x-cbr',
  6811. 'cbz' => 'application/x-cbr',
  6812. 'cc' => 'text/x-c',
  6813. 'cct' => 'application/x-director',
  6814. 'ccxml' => 'application/ccxml+xml',
  6815. 'cdbcmsg' => 'application/vnd.contact.cmsg',
  6816. 'cdf' => 'application/x-netcdf',
  6817. 'cdkey' => 'application/vnd.mediastation.cdkey',
  6818. 'cdmia' => 'application/cdmi-capability',
  6819. 'cdmic' => 'application/cdmi-container',
  6820. 'cdmid' => 'application/cdmi-domain',
  6821. 'cdmio' => 'application/cdmi-object',
  6822. 'cdmiq' => 'application/cdmi-queue',
  6823. 'cdx' => 'chemical/x-cdx',
  6824. 'cdxml' => 'application/vnd.chemdraw+xml',
  6825. 'cdy' => 'application/vnd.cinderella',
  6826. 'cer' => 'application/pkix-cert',
  6827. 'cfs' => 'application/x-cfs-compressed',
  6828. 'cgm' => 'image/cgm',
  6829. 'chat' => 'application/x-chat',
  6830. 'chm' => 'application/vnd.ms-htmlhelp',
  6831. 'chrt' => 'application/vnd.kde.kchart',
  6832. 'cif' => 'chemical/x-cif',
  6833. 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
  6834. 'cil' => 'application/vnd.ms-artgalry',
  6835. 'cla' => 'application/vnd.claymore',
  6836. 'class' => 'application/java-vm',
  6837. 'clkk' => 'application/vnd.crick.clicker.keyboard',
  6838. 'clkp' => 'application/vnd.crick.clicker.palette',
  6839. 'clkt' => 'application/vnd.crick.clicker.template',
  6840. 'clkw' => 'application/vnd.crick.clicker.wordbank',
  6841. 'clkx' => 'application/vnd.crick.clicker',
  6842. 'clp' => 'application/x-msclip',
  6843. 'cmc' => 'application/vnd.cosmocaller',
  6844. 'cmdf' => 'chemical/x-cmdf',
  6845. 'cml' => 'chemical/x-cml',
  6846. 'cmp' => 'application/vnd.yellowriver-custom-menu',
  6847. 'cmx' => 'image/x-cmx',
  6848. 'cod' => 'application/vnd.rim.cod',
  6849. 'com' => 'application/x-msdownload',
  6850. 'conf' => 'text/plain',
  6851. 'cpio' => 'application/x-cpio',
  6852. 'cpp' => 'text/x-c',
  6853. 'cpt' => 'application/mac-compactpro',
  6854. 'crd' => 'application/x-mscardfile',
  6855. 'crl' => 'application/pkix-crl',
  6856. 'crt' => 'application/x-x509-ca-cert',
  6857. 'cryptonote' => 'application/vnd.rig.cryptonote',
  6858. 'csh' => 'application/x-csh',
  6859. 'csml' => 'chemical/x-csml',
  6860. 'csp' => 'application/vnd.commonspace',
  6861. 'css' => 'text/css',
  6862. 'cst' => 'application/x-director',
  6863. 'csv' => 'text/csv',
  6864. 'cu' => 'application/cu-seeme',
  6865. 'curl' => 'text/vnd.curl',
  6866. 'cww' => 'application/prs.cww',
  6867. 'cxt' => 'application/x-director',
  6868. 'cxx' => 'text/x-c',
  6869. 'dae' => 'model/vnd.collada+xml',
  6870. 'daf' => 'application/vnd.mobius.daf',
  6871. 'dart' => 'application/vnd.dart',
  6872. 'dataless' => 'application/vnd.fdsn.seed',
  6873. 'davmount' => 'application/davmount+xml',
  6874. 'dbk' => 'application/docbook+xml',
  6875. 'dcr' => 'application/x-director',
  6876. 'dcurl' => 'text/vnd.curl.dcurl',
  6877. 'dd2' => 'application/vnd.oma.dd2+xml',
  6878. 'ddd' => 'application/vnd.fujixerox.ddd',
  6879. 'deb' => 'application/x-debian-package',
  6880. 'def' => 'text/plain',
  6881. 'deploy' => 'application/octet-stream',
  6882. 'der' => 'application/x-x509-ca-cert',
  6883. 'dfac' => 'application/vnd.dreamfactory',
  6884. 'dgc' => 'application/x-dgc-compressed',
  6885. 'dic' => 'text/x-c',
  6886. 'dir' => 'application/x-director',
  6887. 'dis' => 'application/vnd.mobius.dis',
  6888. 'dist' => 'application/octet-stream',
  6889. 'distz' => 'application/octet-stream',
  6890. 'djv' => 'image/vnd.djvu',
  6891. 'djvu' => 'image/vnd.djvu',
  6892. 'dll' => 'application/x-msdownload',
  6893. 'dmg' => 'application/x-apple-diskimage',
  6894. 'dmp' => 'application/vnd.tcpdump.pcap',
  6895. 'dms' => 'application/octet-stream',
  6896. 'dna' => 'application/vnd.dna',
  6897. 'doc' => 'application/msword',
  6898. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  6899. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  6900. 'dot' => 'application/msword',
  6901. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  6902. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  6903. 'dp' => 'application/vnd.osgi.dp',
  6904. 'dpg' => 'application/vnd.dpgraph',
  6905. 'dra' => 'audio/vnd.dra',
  6906. 'dsc' => 'text/prs.lines.tag',
  6907. 'dssc' => 'application/dssc+der',
  6908. 'dtb' => 'application/x-dtbook+xml',
  6909. 'dtd' => 'application/xml-dtd',
  6910. 'dts' => 'audio/vnd.dts',
  6911. 'dtshd' => 'audio/vnd.dts.hd',
  6912. 'dump' => 'application/octet-stream',
  6913. 'dvb' => 'video/vnd.dvb.file',
  6914. 'dvi' => 'application/x-dvi',
  6915. 'dwf' => 'model/vnd.dwf',
  6916. 'dwg' => 'image/vnd.dwg',
  6917. 'dxf' => 'image/vnd.dxf',
  6918. 'dxp' => 'application/vnd.spotfire.dxp',
  6919. 'dxr' => 'application/x-director',
  6920. 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
  6921. 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
  6922. 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
  6923. 'ecma' => 'application/ecmascript',
  6924. 'edm' => 'application/vnd.novadigm.edm',
  6925. 'edx' => 'application/vnd.novadigm.edx',
  6926. 'efif' => 'application/vnd.picsel',
  6927. 'ei6' => 'application/vnd.pg.osasli',
  6928. 'elc' => 'application/octet-stream',
  6929. 'emf' => 'application/x-msmetafile',
  6930. 'eml' => 'message/rfc822',
  6931. 'emma' => 'application/emma+xml',
  6932. 'emz' => 'application/x-msmetafile',
  6933. 'eol' => 'audio/vnd.digital-winds',
  6934. 'eot' => 'application/vnd.ms-fontobject',
  6935. 'eps' => 'application/postscript',
  6936. 'epub' => 'application/epub+zip',
  6937. 'es3' => 'application/vnd.eszigno3+xml',
  6938. 'esa' => 'application/vnd.osgi.subsystem',
  6939. 'esf' => 'application/vnd.epson.esf',
  6940. 'et3' => 'application/vnd.eszigno3+xml',
  6941. 'etx' => 'text/x-setext',
  6942. 'eva' => 'application/x-eva',
  6943. 'evy' => 'application/x-envoy',
  6944. 'exe' => 'application/x-msdownload',
  6945. 'exi' => 'application/exi',
  6946. 'ext' => 'application/vnd.novadigm.ext',
  6947. 'ez' => 'application/andrew-inset',
  6948. 'ez2' => 'application/vnd.ezpix-album',
  6949. 'ez3' => 'application/vnd.ezpix-package',
  6950. 'f' => 'text/x-fortran',
  6951. 'f4v' => 'video/x-f4v',
  6952. 'f77' => 'text/x-fortran',
  6953. 'f90' => 'text/x-fortran',
  6954. 'fbs' => 'image/vnd.fastbidsheet',
  6955. 'fcdt' => 'application/vnd.adobe.formscentral.fcdt',
  6956. 'fcs' => 'application/vnd.isac.fcs',
  6957. 'fdf' => 'application/vnd.fdf',
  6958. 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
  6959. 'fg5' => 'application/vnd.fujitsu.oasysgp',
  6960. 'fgd' => 'application/x-director',
  6961. 'fh' => 'image/x-freehand',
  6962. 'fh4' => 'image/x-freehand',
  6963. 'fh5' => 'image/x-freehand',
  6964. 'fh7' => 'image/x-freehand',
  6965. 'fhc' => 'image/x-freehand',
  6966. 'fig' => 'application/x-xfig',
  6967. 'flac' => 'audio/x-flac',
  6968. 'fli' => 'video/x-fli',
  6969. 'flo' => 'application/vnd.micrografx.flo',
  6970. 'flv' => 'video/x-flv',
  6971. 'flw' => 'application/vnd.kde.kivio',
  6972. 'flx' => 'text/vnd.fmi.flexstor',
  6973. 'fly' => 'text/vnd.fly',
  6974. 'fm' => 'application/vnd.framemaker',
  6975. 'fnc' => 'application/vnd.frogans.fnc',
  6976. 'for' => 'text/x-fortran',
  6977. 'fpx' => 'image/vnd.fpx',
  6978. 'frame' => 'application/vnd.framemaker',
  6979. 'fsc' => 'application/vnd.fsc.weblaunch',
  6980. 'fst' => 'image/vnd.fst',
  6981. 'ftc' => 'application/vnd.fluxtime.clip',
  6982. 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
  6983. 'fvt' => 'video/vnd.fvt',
  6984. 'fxp' => 'application/vnd.adobe.fxp',
  6985. 'fxpl' => 'application/vnd.adobe.fxp',
  6986. 'fzs' => 'application/vnd.fuzzysheet',
  6987. 'g2w' => 'application/vnd.geoplan',
  6988. 'g3' => 'image/g3fax',
  6989. 'g3w' => 'application/vnd.geospace',
  6990. 'gac' => 'application/vnd.groove-account',
  6991. 'gam' => 'application/x-tads',
  6992. 'gbr' => 'application/rpki-ghostbusters',
  6993. 'gca' => 'application/x-gca-compressed',
  6994. 'gdl' => 'model/vnd.gdl',
  6995. 'geo' => 'application/vnd.dynageo',
  6996. 'gex' => 'application/vnd.geometry-explorer',
  6997. 'ggb' => 'application/vnd.geogebra.file',
  6998. 'ggt' => 'application/vnd.geogebra.tool',
  6999. 'ghf' => 'application/vnd.groove-help',
  7000. 'gif' => 'image/gif',
  7001. 'gim' => 'application/vnd.groove-identity-message',
  7002. 'gml' => 'application/gml+xml',
  7003. 'gmx' => 'application/vnd.gmx',
  7004. 'gnumeric' => 'application/x-gnumeric',
  7005. 'gph' => 'application/vnd.flographit',
  7006. 'gpx' => 'application/gpx+xml',
  7007. 'gqf' => 'application/vnd.grafeq',
  7008. 'gqs' => 'application/vnd.grafeq',
  7009. 'gram' => 'application/srgs',
  7010. 'gramps' => 'application/x-gramps-xml',
  7011. 'gre' => 'application/vnd.geometry-explorer',
  7012. 'grv' => 'application/vnd.groove-injector',
  7013. 'grxml' => 'application/srgs+xml',
  7014. 'gsf' => 'application/x-font-ghostscript',
  7015. 'gtar' => 'application/x-gtar',
  7016. 'gtm' => 'application/vnd.groove-tool-message',
  7017. 'gtw' => 'model/vnd.gtw',
  7018. 'gv' => 'text/vnd.graphviz',
  7019. 'gxf' => 'application/gxf',
  7020. 'gxt' => 'application/vnd.geonext',
  7021. 'h' => 'text/x-c',
  7022. 'h261' => 'video/h261',
  7023. 'h263' => 'video/h263',
  7024. 'h264' => 'video/h264',
  7025. 'hal' => 'application/vnd.hal+xml',
  7026. 'hbci' => 'application/vnd.hbci',
  7027. 'hdf' => 'application/x-hdf',
  7028. 'hh' => 'text/x-c',
  7029. 'hlp' => 'application/winhlp',
  7030. 'hpgl' => 'application/vnd.hp-hpgl',
  7031. 'hpid' => 'application/vnd.hp-hpid',
  7032. 'hps' => 'application/vnd.hp-hps',
  7033. 'hqx' => 'application/mac-binhex40',
  7034. 'htke' => 'application/vnd.kenameaapp',
  7035. 'htm' => 'text/html',
  7036. 'html' => 'text/html',
  7037. 'hvd' => 'application/vnd.yamaha.hv-dic',
  7038. 'hvp' => 'application/vnd.yamaha.hv-voice',
  7039. 'hvs' => 'application/vnd.yamaha.hv-script',
  7040. 'i2g' => 'application/vnd.intergeo',
  7041. 'icc' => 'application/vnd.iccprofile',
  7042. 'ice' => 'x-conference/x-cooltalk',
  7043. 'icm' => 'application/vnd.iccprofile',
  7044. 'ico' => 'image/x-icon',
  7045. 'ics' => 'text/calendar',
  7046. 'ief' => 'image/ief',
  7047. 'ifb' => 'text/calendar',
  7048. 'ifm' => 'application/vnd.shana.informed.formdata',
  7049. 'iges' => 'model/iges',
  7050. 'igl' => 'application/vnd.igloader',
  7051. 'igm' => 'application/vnd.insors.igm',
  7052. 'igs' => 'model/iges',
  7053. 'igx' => 'application/vnd.micrografx.igx',
  7054. 'iif' => 'application/vnd.shana.informed.interchange',
  7055. 'imp' => 'application/vnd.accpac.simply.imp',
  7056. 'ims' => 'application/vnd.ms-ims',
  7057. 'in' => 'text/plain',
  7058. 'ink' => 'application/inkml+xml',
  7059. 'inkml' => 'application/inkml+xml',
  7060. 'install' => 'application/x-install-instructions',
  7061. 'iota' => 'application/vnd.astraea-software.iota',
  7062. 'ipfix' => 'application/ipfix',
  7063. 'ipk' => 'application/vnd.shana.informed.package',
  7064. 'irm' => 'application/vnd.ibm.rights-management',
  7065. 'irp' => 'application/vnd.irepository.package+xml',
  7066. 'iso' => 'application/x-iso9660-image',
  7067. 'itp' => 'application/vnd.shana.informed.formtemplate',
  7068. 'ivp' => 'application/vnd.immervision-ivp',
  7069. 'ivu' => 'application/vnd.immervision-ivu',
  7070. 'jad' => 'text/vnd.sun.j2me.app-descriptor',
  7071. 'jam' => 'application/vnd.jam',
  7072. 'jar' => 'application/java-archive',
  7073. 'java' => 'text/x-java-source',
  7074. 'jisp' => 'application/vnd.jisp',
  7075. 'jlt' => 'application/vnd.hp-jlyt',
  7076. 'jnlp' => 'application/x-java-jnlp-file',
  7077. 'joda' => 'application/vnd.joost.joda-archive',
  7078. 'jpe' => 'image/jpeg',
  7079. 'jpeg' => 'image/jpeg',
  7080. 'jpg' => 'image/jpeg',
  7081. 'jpgm' => 'video/jpm',
  7082. 'jpgv' => 'video/jpeg',
  7083. 'jpm' => 'video/jpm',
  7084. 'js' => 'application/javascript',
  7085. 'json' => 'application/json',
  7086. 'jsonml' => 'application/jsonml+json',
  7087. 'kar' => 'audio/midi',
  7088. 'karbon' => 'application/vnd.kde.karbon',
  7089. 'kfo' => 'application/vnd.kde.kformula',
  7090. 'kia' => 'application/vnd.kidspiration',
  7091. 'kml' => 'application/vnd.google-earth.kml+xml',
  7092. 'kmz' => 'application/vnd.google-earth.kmz',
  7093. 'kne' => 'application/vnd.kinar',
  7094. 'knp' => 'application/vnd.kinar',
  7095. 'kon' => 'application/vnd.kde.kontour',
  7096. 'kpr' => 'application/vnd.kde.kpresenter',
  7097. 'kpt' => 'application/vnd.kde.kpresenter',
  7098. 'kpxx' => 'application/vnd.ds-keypoint',
  7099. 'ksp' => 'application/vnd.kde.kspread',
  7100. 'ktr' => 'application/vnd.kahootz',
  7101. 'ktx' => 'image/ktx',
  7102. 'ktz' => 'application/vnd.kahootz',
  7103. 'kwd' => 'application/vnd.kde.kword',
  7104. 'kwt' => 'application/vnd.kde.kword',
  7105. 'lasxml' => 'application/vnd.las.las+xml',
  7106. 'latex' => 'application/x-latex',
  7107. 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  7108. 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  7109. 'les' => 'application/vnd.hhe.lesson-player',
  7110. 'lha' => 'application/x-lzh-compressed',
  7111. 'link66' => 'application/vnd.route66.link66+xml',
  7112. 'list' => 'text/plain',
  7113. 'list3820' => 'application/vnd.ibm.modcap',
  7114. 'listafp' => 'application/vnd.ibm.modcap',
  7115. 'lnk' => 'application/x-ms-shortcut',
  7116. 'log' => 'text/plain',
  7117. 'lostxml' => 'application/lost+xml',
  7118. 'lrf' => 'application/octet-stream',
  7119. 'lrm' => 'application/vnd.ms-lrm',
  7120. 'ltf' => 'application/vnd.frogans.ltf',
  7121. 'lvp' => 'audio/vnd.lucent.voice',
  7122. 'lwp' => 'application/vnd.lotus-wordpro',
  7123. 'lzh' => 'application/x-lzh-compressed',
  7124. 'm13' => 'application/x-msmediaview',
  7125. 'm14' => 'application/x-msmediaview',
  7126. 'm1v' => 'video/mpeg',
  7127. 'm21' => 'application/mp21',
  7128. 'm2a' => 'audio/mpeg',
  7129. 'm2v' => 'video/mpeg',
  7130. 'm3a' => 'audio/mpeg',
  7131. 'm3u' => 'audio/x-mpegurl',
  7132. 'm3u8' => 'application/vnd.apple.mpegurl',
  7133. 'm4a' => 'audio/mp4',
  7134. 'm4u' => 'video/vnd.mpegurl',
  7135. 'm4v' => 'video/x-m4v',
  7136. 'ma' => 'application/mathematica',
  7137. 'mads' => 'application/mads+xml',
  7138. 'mag' => 'application/vnd.ecowin.chart',
  7139. 'maker' => 'application/vnd.framemaker',
  7140. 'man' => 'text/troff',
  7141. 'mar' => 'application/octet-stream',
  7142. 'mathml' => 'application/mathml+xml',
  7143. 'mb' => 'application/mathematica',
  7144. 'mbk' => 'application/vnd.mobius.mbk',
  7145. 'mbox' => 'application/mbox',
  7146. 'mc1' => 'application/vnd.medcalcdata',
  7147. 'mcd' => 'application/vnd.mcd',
  7148. 'mcurl' => 'text/vnd.curl.mcurl',
  7149. 'mdb' => 'application/x-msaccess',
  7150. 'mdi' => 'image/vnd.ms-modi',
  7151. 'me' => 'text/troff',
  7152. 'mesh' => 'model/mesh',
  7153. 'meta4' => 'application/metalink4+xml',
  7154. 'metalink' => 'application/metalink+xml',
  7155. 'mets' => 'application/mets+xml',
  7156. 'mfm' => 'application/vnd.mfmp',
  7157. 'mft' => 'application/rpki-manifest',
  7158. 'mgp' => 'application/vnd.osgeo.mapguide.package',
  7159. 'mgz' => 'application/vnd.proteus.magazine',
  7160. 'mid' => 'audio/midi',
  7161. 'midi' => 'audio/midi',
  7162. 'mie' => 'application/x-mie',
  7163. 'mif' => 'application/vnd.mif',
  7164. 'mime' => 'message/rfc822',
  7165. 'mj2' => 'video/mj2',
  7166. 'mjp2' => 'video/mj2',
  7167. 'mk3d' => 'video/x-matroska',
  7168. 'mka' => 'audio/x-matroska',
  7169. 'mks' => 'video/x-matroska',
  7170. 'mkv' => 'video/x-matroska',
  7171. 'mlp' => 'application/vnd.dolby.mlp',
  7172. 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
  7173. 'mmf' => 'application/vnd.smaf',
  7174. 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
  7175. 'mng' => 'video/x-mng',
  7176. 'mny' => 'application/x-msmoney',
  7177. 'mobi' => 'application/x-mobipocket-ebook',
  7178. 'mods' => 'application/mods+xml',
  7179. 'mov' => 'video/quicktime',
  7180. 'movie' => 'video/x-sgi-movie',
  7181. 'mp2' => 'audio/mpeg',
  7182. 'mp21' => 'application/mp21',
  7183. 'mp2a' => 'audio/mpeg',
  7184. 'mp3' => 'audio/mpeg',
  7185. 'mp4' => 'video/mp4',
  7186. 'mp4a' => 'audio/mp4',
  7187. 'mp4s' => 'application/mp4',
  7188. 'mp4v' => 'video/mp4',
  7189. 'mpc' => 'application/vnd.mophun.certificate',
  7190. 'mpe' => 'video/mpeg',
  7191. 'mpeg' => 'video/mpeg',
  7192. 'mpg' => 'video/mpeg',
  7193. 'mpg4' => 'video/mp4',
  7194. 'mpga' => 'audio/mpeg',
  7195. 'mpkg' => 'application/vnd.apple.installer+xml',
  7196. 'mpm' => 'application/vnd.blueice.multipass',
  7197. 'mpn' => 'application/vnd.mophun.application',
  7198. 'mpp' => 'application/vnd.ms-project',
  7199. 'mpt' => 'application/vnd.ms-project',
  7200. 'mpy' => 'application/vnd.ibm.minipay',
  7201. 'mqy' => 'application/vnd.mobius.mqy',
  7202. 'mrc' => 'application/marc',
  7203. 'mrcx' => 'application/marcxml+xml',
  7204. 'ms' => 'text/troff',
  7205. 'mscml' => 'application/mediaservercontrol+xml',
  7206. 'mseed' => 'application/vnd.fdsn.mseed',
  7207. 'mseq' => 'application/vnd.mseq',
  7208. 'msf' => 'application/vnd.epson.msf',
  7209. 'msh' => 'model/mesh',
  7210. 'msi' => 'application/x-msdownload',
  7211. 'msl' => 'application/vnd.mobius.msl',
  7212. 'msty' => 'application/vnd.muvee.style',
  7213. 'mts' => 'model/vnd.mts',
  7214. 'mus' => 'application/vnd.musician',
  7215. 'musicxml' => 'application/vnd.recordare.musicxml+xml',
  7216. 'mvb' => 'application/x-msmediaview',
  7217. 'mwf' => 'application/vnd.mfer',
  7218. 'mxf' => 'application/mxf',
  7219. 'mxl' => 'application/vnd.recordare.musicxml',
  7220. 'mxml' => 'application/xv+xml',
  7221. 'mxs' => 'application/vnd.triscape.mxs',
  7222. 'mxu' => 'video/vnd.mpegurl',
  7223. 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  7224. 'n3' => 'text/n3',
  7225. 'nb' => 'application/mathematica',
  7226. 'nbp' => 'application/vnd.wolfram.player',
  7227. 'nc' => 'application/x-netcdf',
  7228. 'ncx' => 'application/x-dtbncx+xml',
  7229. 'nfo' => 'text/x-nfo',
  7230. 'ngdat' => 'application/vnd.nokia.n-gage.data',
  7231. 'nitf' => 'application/vnd.nitf',
  7232. 'nlu' => 'application/vnd.neurolanguage.nlu',
  7233. 'nml' => 'application/vnd.enliven',
  7234. 'nnd' => 'application/vnd.noblenet-directory',
  7235. 'nns' => 'application/vnd.noblenet-sealer',
  7236. 'nnw' => 'application/vnd.noblenet-web',
  7237. 'npx' => 'image/vnd.net-fpx',
  7238. 'nsc' => 'application/x-conference',
  7239. 'nsf' => 'application/vnd.lotus-notes',
  7240. 'ntf' => 'application/vnd.nitf',
  7241. 'nzb' => 'application/x-nzb',
  7242. 'oa2' => 'application/vnd.fujitsu.oasys2',
  7243. 'oa3' => 'application/vnd.fujitsu.oasys3',
  7244. 'oas' => 'application/vnd.fujitsu.oasys',
  7245. 'obd' => 'application/x-msbinder',
  7246. 'obj' => 'application/x-tgif',
  7247. 'oda' => 'application/oda',
  7248. 'odb' => 'application/vnd.oasis.opendocument.database',
  7249. 'odc' => 'application/vnd.oasis.opendocument.chart',
  7250. 'odf' => 'application/vnd.oasis.opendocument.formula',
  7251. 'odft' => 'application/vnd.oasis.opendocument.formula-template',
  7252. 'odg' => 'application/vnd.oasis.opendocument.graphics',
  7253. 'odi' => 'application/vnd.oasis.opendocument.image',
  7254. 'odm' => 'application/vnd.oasis.opendocument.text-master',
  7255. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  7256. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  7257. 'odt' => 'application/vnd.oasis.opendocument.text',
  7258. 'oga' => 'audio/ogg',
  7259. 'ogg' => 'audio/ogg',
  7260. 'ogv' => 'video/ogg',
  7261. 'ogx' => 'application/ogg',
  7262. 'omdoc' => 'application/omdoc+xml',
  7263. 'onepkg' => 'application/onenote',
  7264. 'onetmp' => 'application/onenote',
  7265. 'onetoc' => 'application/onenote',
  7266. 'onetoc2' => 'application/onenote',
  7267. 'opf' => 'application/oebps-package+xml',
  7268. 'opml' => 'text/x-opml',
  7269. 'oprc' => 'application/vnd.palm',
  7270. 'org' => 'application/vnd.lotus-organizer',
  7271. 'osf' => 'application/vnd.yamaha.openscoreformat',
  7272. 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  7273. 'otc' => 'application/vnd.oasis.opendocument.chart-template',
  7274. 'otf' => 'application/x-font-otf',
  7275. 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
  7276. 'oth' => 'application/vnd.oasis.opendocument.text-web',
  7277. 'oti' => 'application/vnd.oasis.opendocument.image-template',
  7278. 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
  7279. 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  7280. 'ott' => 'application/vnd.oasis.opendocument.text-template',
  7281. 'oxps' => 'application/oxps',
  7282. 'oxt' => 'application/vnd.openofficeorg.extension',
  7283. 'p' => 'text/x-pascal',
  7284. 'p10' => 'application/pkcs10',
  7285. 'p12' => 'application/x-pkcs12',
  7286. 'p7b' => 'application/x-pkcs7-certificates',
  7287. 'p7c' => 'application/pkcs7-mime',
  7288. 'p7m' => 'application/pkcs7-mime',
  7289. 'p7r' => 'application/x-pkcs7-certreqresp',
  7290. 'p7s' => 'application/pkcs7-signature',
  7291. 'p8' => 'application/pkcs8',
  7292. 'pas' => 'text/x-pascal',
  7293. 'paw' => 'application/vnd.pawaafile',
  7294. 'pbd' => 'application/vnd.powerbuilder6',
  7295. 'pbm' => 'image/x-portable-bitmap',
  7296. 'pcap' => 'application/vnd.tcpdump.pcap',
  7297. 'pcf' => 'application/x-font-pcf',
  7298. 'pcl' => 'application/vnd.hp-pcl',
  7299. 'pclxl' => 'application/vnd.hp-pclxl',
  7300. 'pct' => 'image/x-pict',
  7301. 'pcurl' => 'application/vnd.curl.pcurl',
  7302. 'pcx' => 'image/x-pcx',
  7303. 'pdb' => 'application/vnd.palm',
  7304. 'pdf' => 'application/pdf',
  7305. 'pfa' => 'application/x-font-type1',
  7306. 'pfb' => 'application/x-font-type1',
  7307. 'pfm' => 'application/x-font-type1',
  7308. 'pfr' => 'application/font-tdpfr',
  7309. 'pfx' => 'application/x-pkcs12',
  7310. 'pgm' => 'image/x-portable-graymap',
  7311. 'pgn' => 'application/x-chess-pgn',
  7312. 'pgp' => 'application/pgp-encrypted',
  7313. 'pic' => 'image/x-pict',
  7314. 'pkg' => 'application/octet-stream',
  7315. 'pki' => 'application/pkixcmp',
  7316. 'pkipath' => 'application/pkix-pkipath',
  7317. 'plb' => 'application/vnd.3gpp.pic-bw-large',
  7318. 'plc' => 'application/vnd.mobius.plc',
  7319. 'plf' => 'application/vnd.pocketlearn',
  7320. 'pls' => 'application/pls+xml',
  7321. 'pml' => 'application/vnd.ctc-posml',
  7322. 'png' => 'image/png',
  7323. 'pnm' => 'image/x-portable-anymap',
  7324. 'portpkg' => 'application/vnd.macports.portpkg',
  7325. 'pot' => 'application/vnd.ms-powerpoint',
  7326. 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
  7327. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  7328. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  7329. 'ppd' => 'application/vnd.cups-ppd',
  7330. 'ppm' => 'image/x-portable-pixmap',
  7331. 'pps' => 'application/vnd.ms-powerpoint',
  7332. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  7333. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  7334. 'ppt' => 'application/vnd.ms-powerpoint',
  7335. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  7336. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  7337. 'pqa' => 'application/vnd.palm',
  7338. 'prc' => 'application/x-mobipocket-ebook',
  7339. 'pre' => 'application/vnd.lotus-freelance',
  7340. 'prf' => 'application/pics-rules',
  7341. 'ps' => 'application/postscript',
  7342. 'psb' => 'application/vnd.3gpp.pic-bw-small',
  7343. 'psd' => 'image/vnd.adobe.photoshop',
  7344. 'psf' => 'application/x-font-linux-psf',
  7345. 'pskcxml' => 'application/pskc+xml',
  7346. 'ptid' => 'application/vnd.pvi.ptid1',
  7347. 'pub' => 'application/x-mspublisher',
  7348. 'pvb' => 'application/vnd.3gpp.pic-bw-var',
  7349. 'pwn' => 'application/vnd.3m.post-it-notes',
  7350. 'pya' => 'audio/vnd.ms-playready.media.pya',
  7351. 'pyv' => 'video/vnd.ms-playready.media.pyv',
  7352. 'qam' => 'application/vnd.epson.quickanime',
  7353. 'qbo' => 'application/vnd.intu.qbo',
  7354. 'qfx' => 'application/vnd.intu.qfx',
  7355. 'qps' => 'application/vnd.publishare-delta-tree',
  7356. 'qt' => 'video/quicktime',
  7357. 'qwd' => 'application/vnd.quark.quarkxpress',
  7358. 'qwt' => 'application/vnd.quark.quarkxpress',
  7359. 'qxb' => 'application/vnd.quark.quarkxpress',
  7360. 'qxd' => 'application/vnd.quark.quarkxpress',
  7361. 'qxl' => 'application/vnd.quark.quarkxpress',
  7362. 'qxt' => 'application/vnd.quark.quarkxpress',
  7363. 'ra' => 'audio/x-pn-realaudio',
  7364. 'ram' => 'audio/x-pn-realaudio',
  7365. 'rar' => 'application/x-rar-compressed',
  7366. 'ras' => 'image/x-cmu-raster',
  7367. 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
  7368. 'rdf' => 'application/rdf+xml',
  7369. 'rdz' => 'application/vnd.data-vision.rdz',
  7370. 'rep' => 'application/vnd.businessobjects',
  7371. 'res' => 'application/x-dtbresource+xml',
  7372. 'rgb' => 'image/x-rgb',
  7373. 'rif' => 'application/reginfo+xml',
  7374. 'rip' => 'audio/vnd.rip',
  7375. 'ris' => 'application/x-research-info-systems',
  7376. 'rl' => 'application/resource-lists+xml',
  7377. 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
  7378. 'rld' => 'application/resource-lists-diff+xml',
  7379. 'rm' => 'application/vnd.rn-realmedia',
  7380. 'rmi' => 'audio/midi',
  7381. 'rmp' => 'audio/x-pn-realaudio-plugin',
  7382. 'rms' => 'application/vnd.jcp.javame.midlet-rms',
  7383. 'rmvb' => 'application/vnd.rn-realmedia-vbr',
  7384. 'rnc' => 'application/relax-ng-compact-syntax',
  7385. 'roa' => 'application/rpki-roa',
  7386. 'roff' => 'text/troff',
  7387. 'rp9' => 'application/vnd.cloanto.rp9',
  7388. 'rpss' => 'application/vnd.nokia.radio-presets',
  7389. 'rpst' => 'application/vnd.nokia.radio-preset',
  7390. 'rq' => 'application/sparql-query',
  7391. 'rs' => 'application/rls-services+xml',
  7392. 'rsd' => 'application/rsd+xml',
  7393. 'rss' => 'application/rss+xml',
  7394. 'rtf' => 'application/rtf',
  7395. 'rtx' => 'text/richtext',
  7396. 's' => 'text/x-asm',
  7397. 's3m' => 'audio/s3m',
  7398. 'saf' => 'application/vnd.yamaha.smaf-audio',
  7399. 'sbml' => 'application/sbml+xml',
  7400. 'sc' => 'application/vnd.ibm.secure-container',
  7401. 'scd' => 'application/x-msschedule',
  7402. 'scm' => 'application/vnd.lotus-screencam',
  7403. 'scq' => 'application/scvp-cv-request',
  7404. 'scs' => 'application/scvp-cv-response',
  7405. 'scurl' => 'text/vnd.curl.scurl',
  7406. 'sda' => 'application/vnd.stardivision.draw',
  7407. 'sdc' => 'application/vnd.stardivision.calc',
  7408. 'sdd' => 'application/vnd.stardivision.impress',
  7409. 'sdkd' => 'application/vnd.solent.sdkm+xml',
  7410. 'sdkm' => 'application/vnd.solent.sdkm+xml',
  7411. 'sdp' => 'application/sdp',
  7412. 'sdw' => 'application/vnd.stardivision.writer',
  7413. 'see' => 'application/vnd.seemail',
  7414. 'seed' => 'application/vnd.fdsn.seed',
  7415. 'sema' => 'application/vnd.sema',
  7416. 'semd' => 'application/vnd.semd',
  7417. 'semf' => 'application/vnd.semf',
  7418. 'ser' => 'application/java-serialized-object',
  7419. 'setpay' => 'application/set-payment-initiation',
  7420. 'setreg' => 'application/set-registration-initiation',
  7421. 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
  7422. 'sfs' => 'application/vnd.spotfire.sfs',
  7423. 'sfv' => 'text/x-sfv',
  7424. 'sgi' => 'image/sgi',
  7425. 'sgl' => 'application/vnd.stardivision.writer-global',
  7426. 'sgm' => 'text/sgml',
  7427. 'sgml' => 'text/sgml',
  7428. 'sh' => 'application/x-sh',
  7429. 'shar' => 'application/x-shar',
  7430. 'shf' => 'application/shf+xml',
  7431. 'sid' => 'image/x-mrsid-image',
  7432. 'sig' => 'application/pgp-signature',
  7433. 'sil' => 'audio/silk',
  7434. 'silo' => 'model/mesh',
  7435. 'sis' => 'application/vnd.symbian.install',
  7436. 'sisx' => 'application/vnd.symbian.install',
  7437. 'sit' => 'application/x-stuffit',
  7438. 'sitx' => 'application/x-stuffitx',
  7439. 'skd' => 'application/vnd.koan',
  7440. 'skm' => 'application/vnd.koan',
  7441. 'skp' => 'application/vnd.koan',
  7442. 'skt' => 'application/vnd.koan',
  7443. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  7444. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  7445. 'slt' => 'application/vnd.epson.salt',
  7446. 'sm' => 'application/vnd.stepmania.stepchart',
  7447. 'smf' => 'application/vnd.stardivision.math',
  7448. 'smi' => 'application/smil+xml',
  7449. 'smil' => 'application/smil+xml',
  7450. 'smv' => 'video/x-smv',
  7451. 'smzip' => 'application/vnd.stepmania.package',
  7452. 'snd' => 'audio/basic',
  7453. 'snf' => 'application/x-font-snf',
  7454. 'so' => 'application/octet-stream',
  7455. 'spc' => 'application/x-pkcs7-certificates',
  7456. 'spf' => 'application/vnd.yamaha.smaf-phrase',
  7457. 'spl' => 'application/x-futuresplash',
  7458. 'spot' => 'text/vnd.in3d.spot',
  7459. 'spp' => 'application/scvp-vp-response',
  7460. 'spq' => 'application/scvp-vp-request',
  7461. 'spx' => 'audio/ogg',
  7462. 'sql' => 'application/x-sql',
  7463. 'src' => 'application/x-wais-source',
  7464. 'srt' => 'application/x-subrip',
  7465. 'sru' => 'application/sru+xml',
  7466. 'srx' => 'application/sparql-results+xml',
  7467. 'ssdl' => 'application/ssdl+xml',
  7468. 'sse' => 'application/vnd.kodak-descriptor',
  7469. 'ssf' => 'application/vnd.epson.ssf',
  7470. 'ssml' => 'application/ssml+xml',
  7471. 'st' => 'application/vnd.sailingtracker.track',
  7472. 'stc' => 'application/vnd.sun.xml.calc.template',
  7473. 'std' => 'application/vnd.sun.xml.draw.template',
  7474. 'stf' => 'application/vnd.wt.stf',
  7475. 'sti' => 'application/vnd.sun.xml.impress.template',
  7476. 'stk' => 'application/hyperstudio',
  7477. 'stl' => 'application/vnd.ms-pki.stl',
  7478. 'str' => 'application/vnd.pg.format',
  7479. 'stw' => 'application/vnd.sun.xml.writer.template',
  7480. 'sub' => 'image/vnd.dvb.subtitle',
  7481. 'sub' => 'text/vnd.dvb.subtitle',
  7482. 'sus' => 'application/vnd.sus-calendar',
  7483. 'susp' => 'application/vnd.sus-calendar',
  7484. 'sv4cpio' => 'application/x-sv4cpio',
  7485. 'sv4crc' => 'application/x-sv4crc',
  7486. 'svc' => 'application/vnd.dvb.service',
  7487. 'svd' => 'application/vnd.svd',
  7488. 'svg' => 'image/svg+xml',
  7489. 'svgz' => 'image/svg+xml',
  7490. 'swa' => 'application/x-director',
  7491. 'swf' => 'application/x-shockwave-flash',
  7492. 'swi' => 'application/vnd.aristanetworks.swi',
  7493. 'sxc' => 'application/vnd.sun.xml.calc',
  7494. 'sxd' => 'application/vnd.sun.xml.draw',
  7495. 'sxg' => 'application/vnd.sun.xml.writer.global',
  7496. 'sxi' => 'application/vnd.sun.xml.impress',
  7497. 'sxm' => 'application/vnd.sun.xml.math',
  7498. 'sxw' => 'application/vnd.sun.xml.writer',
  7499. 't' => 'text/troff',
  7500. 't3' => 'application/x-t3vm-image',
  7501. 'taglet' => 'application/vnd.mynfc',
  7502. 'tao' => 'application/vnd.tao.intent-module-archive',
  7503. 'tar' => 'application/x-tar',
  7504. 'tcap' => 'application/vnd.3gpp2.tcap',
  7505. 'tcl' => 'application/x-tcl',
  7506. 'teacher' => 'application/vnd.smart.teacher',
  7507. 'tei' => 'application/tei+xml',
  7508. 'teicorpus' => 'application/tei+xml',
  7509. 'tex' => 'application/x-tex',
  7510. 'texi' => 'application/x-texinfo',
  7511. 'texinfo' => 'application/x-texinfo',
  7512. 'text' => 'text/plain',
  7513. 'tfi' => 'application/thraud+xml',
  7514. 'tfm' => 'application/x-tex-tfm',
  7515. 'tga' => 'image/x-tga',
  7516. 'thmx' => 'application/vnd.ms-officetheme',
  7517. 'tif' => 'image/tiff',
  7518. 'tiff' => 'image/tiff',
  7519. 'tmo' => 'application/vnd.tmobile-livetv',
  7520. 'torrent' => 'application/x-bittorrent',
  7521. 'tpl' => 'application/vnd.groove-tool-template',
  7522. 'tpt' => 'application/vnd.trid.tpt',
  7523. 'tr' => 'text/troff',
  7524. 'tra' => 'application/vnd.trueapp',
  7525. 'trm' => 'application/x-msterminal',
  7526. 'tsd' => 'application/timestamped-data',
  7527. 'tsv' => 'text/tab-separated-values',
  7528. 'ttc' => 'application/x-font-ttf',
  7529. 'ttf' => 'application/x-font-ttf',
  7530. 'ttl' => 'text/turtle',
  7531. 'twd' => 'application/vnd.simtech-mindmapper',
  7532. 'twds' => 'application/vnd.simtech-mindmapper',
  7533. 'txd' => 'application/vnd.genomatix.tuxedo',
  7534. 'txf' => 'application/vnd.mobius.txf',
  7535. 'txt' => 'text/plain',
  7536. 'u32' => 'application/x-authorware-bin',
  7537. 'udeb' => 'application/x-debian-package',
  7538. 'ufd' => 'application/vnd.ufdl',
  7539. 'ufdl' => 'application/vnd.ufdl',
  7540. 'ulx' => 'application/x-glulx',
  7541. 'umj' => 'application/vnd.umajin',
  7542. 'unityweb' => 'application/vnd.unity',
  7543. 'uoml' => 'application/vnd.uoml+xml',
  7544. 'uri' => 'text/uri-list',
  7545. 'uris' => 'text/uri-list',
  7546. 'urls' => 'text/uri-list',
  7547. 'ustar' => 'application/x-ustar',
  7548. 'utz' => 'application/vnd.uiq.theme',
  7549. 'uu' => 'text/x-uuencode',
  7550. 'uva' => 'audio/vnd.dece.audio',
  7551. 'uvd' => 'application/vnd.dece.data',
  7552. 'uvf' => 'application/vnd.dece.data',
  7553. 'uvg' => 'image/vnd.dece.graphic',
  7554. 'uvh' => 'video/vnd.dece.hd',
  7555. 'uvi' => 'image/vnd.dece.graphic',
  7556. 'uvm' => 'video/vnd.dece.mobile',
  7557. 'uvp' => 'video/vnd.dece.pd',
  7558. 'uvs' => 'video/vnd.dece.sd',
  7559. 'uvt' => 'application/vnd.dece.ttml+xml',
  7560. 'uvu' => 'video/vnd.uvvu.mp4',
  7561. 'uvv' => 'video/vnd.dece.video',
  7562. 'uvva' => 'audio/vnd.dece.audio',
  7563. 'uvvd' => 'application/vnd.dece.data',
  7564. 'uvvf' => 'application/vnd.dece.data',
  7565. 'uvvg' => 'image/vnd.dece.graphic',
  7566. 'uvvh' => 'video/vnd.dece.hd',
  7567. 'uvvi' => 'image/vnd.dece.graphic',
  7568. 'uvvm' => 'video/vnd.dece.mobile',
  7569. 'uvvp' => 'video/vnd.dece.pd',
  7570. 'uvvs' => 'video/vnd.dece.sd',
  7571. 'uvvt' => 'application/vnd.dece.ttml+xml',
  7572. 'uvvu' => 'video/vnd.uvvu.mp4',
  7573. 'uvvv' => 'video/vnd.dece.video',
  7574. 'uvvx' => 'application/vnd.dece.unspecified',
  7575. 'uvvz' => 'application/vnd.dece.zip',
  7576. 'uvx' => 'application/vnd.dece.unspecified',
  7577. 'uvz' => 'application/vnd.dece.zip',
  7578. 'vcard' => 'text/vcard',
  7579. 'vcd' => 'application/x-cdlink',
  7580. 'vcf' => 'text/x-vcard',
  7581. 'vcg' => 'application/vnd.groove-vcard',
  7582. 'vcs' => 'text/x-vcalendar',
  7583. 'vcx' => 'application/vnd.vcx',
  7584. 'vis' => 'application/vnd.visionary',
  7585. 'viv' => 'video/vnd.vivo',
  7586. 'vob' => 'video/x-ms-vob',
  7587. 'vor' => 'application/vnd.stardivision.writer',
  7588. 'vox' => 'application/x-authorware-bin',
  7589. 'vrml' => 'model/vrml',
  7590. 'vsd' => 'application/vnd.visio',
  7591. 'vsf' => 'application/vnd.vsf',
  7592. 'vss' => 'application/vnd.visio',
  7593. 'vst' => 'application/vnd.visio',
  7594. 'vsw' => 'application/vnd.visio',
  7595. 'vtu' => 'model/vnd.vtu',
  7596. 'vxml' => 'application/voicexml+xml',
  7597. 'w3d' => 'application/x-director',
  7598. 'wad' => 'application/x-doom',
  7599. 'wav' => 'audio/x-wav',
  7600. 'wax' => 'audio/x-ms-wax',
  7601. 'wbmp' => 'image/vnd.wap.wbmp',
  7602. 'wbs' => 'application/vnd.criticaltools.wbs+xml',
  7603. 'wbxml' => 'application/vnd.wap.wbxml',
  7604. 'wcm' => 'application/vnd.ms-works',
  7605. 'wdb' => 'application/vnd.ms-works',
  7606. 'wdp' => 'image/vnd.ms-photo',
  7607. 'weba' => 'audio/webm',
  7608. 'webm' => 'video/webm',
  7609. 'webp' => 'image/webp',
  7610. 'wg' => 'application/vnd.pmi.widget',
  7611. 'wgt' => 'application/widget',
  7612. 'wks' => 'application/vnd.ms-works',
  7613. 'wm' => 'video/x-ms-wm',
  7614. 'wma' => 'audio/x-ms-wma',
  7615. 'wmd' => 'application/x-ms-wmd',
  7616. 'wmf' => 'application/x-msmetafile',
  7617. 'wml' => 'text/vnd.wap.wml',
  7618. 'wmlc' => 'application/vnd.wap.wmlc',
  7619. 'wmls' => 'text/vnd.wap.wmlscript',
  7620. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  7621. 'wmv' => 'video/x-ms-wmv',
  7622. 'wmx' => 'video/x-ms-wmx',
  7623. 'wmz' => 'application/x-ms-wmz',
  7624. 'wmz' => 'application/x-msmetafile',
  7625. 'woff' => 'application/font-woff',
  7626. 'wpd' => 'application/vnd.wordperfect',
  7627. 'wpl' => 'application/vnd.ms-wpl',
  7628. 'wps' => 'application/vnd.ms-works',
  7629. 'wqd' => 'application/vnd.wqd',
  7630. 'wri' => 'application/x-mswrite',
  7631. 'wrl' => 'model/vrml',
  7632. 'wsdl' => 'application/wsdl+xml',
  7633. 'wspolicy' => 'application/wspolicy+xml',
  7634. 'wtb' => 'application/vnd.webturbo',
  7635. 'wvx' => 'video/x-ms-wvx',
  7636. 'x32' => 'application/x-authorware-bin',
  7637. 'x3d' => 'model/x3d+xml',
  7638. 'x3db' => 'model/x3d+binary',
  7639. 'x3dbz' => 'model/x3d+binary',
  7640. 'x3dv' => 'model/x3d+vrml',
  7641. 'x3dvz' => 'model/x3d+vrml',
  7642. 'x3dz' => 'model/x3d+xml',
  7643. 'xaml' => 'application/xaml+xml',
  7644. 'xap' => 'application/x-silverlight-app',
  7645. 'xar' => 'application/vnd.xara',
  7646. 'xbap' => 'application/x-ms-xbap',
  7647. 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
  7648. 'xbm' => 'image/x-xbitmap',
  7649. 'xdf' => 'application/xcap-diff+xml',
  7650. 'xdm' => 'application/vnd.syncml.dm+xml',
  7651. 'xdp' => 'application/vnd.adobe.xdp+xml',
  7652. 'xdssc' => 'application/dssc+xml',
  7653. 'xdw' => 'application/vnd.fujixerox.docuworks',
  7654. 'xenc' => 'application/xenc+xml',
  7655. 'xer' => 'application/patch-ops-error+xml',
  7656. 'xfdf' => 'application/vnd.adobe.xfdf',
  7657. 'xfdl' => 'application/vnd.xfdl',
  7658. 'xht' => 'application/xhtml+xml',
  7659. 'xhtml' => 'application/xhtml+xml',
  7660. 'xhvml' => 'application/xv+xml',
  7661. 'xif' => 'image/vnd.xiff',
  7662. 'xla' => 'application/vnd.ms-excel',
  7663. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  7664. 'xlc' => 'application/vnd.ms-excel',
  7665. 'xlf' => 'application/x-xliff+xml',
  7666. 'xlm' => 'application/vnd.ms-excel',
  7667. 'xls' => 'application/vnd.ms-excel',
  7668. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  7669. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  7670. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  7671. 'xlt' => 'application/vnd.ms-excel',
  7672. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  7673. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  7674. 'xlw' => 'application/vnd.ms-excel',
  7675. 'xm' => 'audio/xm',
  7676. 'xml' => 'application/xml',
  7677. 'xo' => 'application/vnd.olpc-sugar',
  7678. 'xop' => 'application/xop+xml',
  7679. 'xpi' => 'application/x-xpinstall',
  7680. 'xpl' => 'application/xproc+xml',
  7681. 'xpm' => 'image/x-xpixmap',
  7682. 'xpr' => 'application/vnd.is-xpr',
  7683. 'xps' => 'application/vnd.ms-xpsdocument',
  7684. 'xpw' => 'application/vnd.intercon.formnet',
  7685. 'xpx' => 'application/vnd.intercon.formnet',
  7686. 'xsl' => 'application/xml',
  7687. 'xslt' => 'application/xslt+xml',
  7688. 'xsm' => 'application/vnd.syncml+xml',
  7689. 'xspf' => 'application/xspf+xml',
  7690. 'xul' => 'application/vnd.mozilla.xul+xml',
  7691. 'xvm' => 'application/xv+xml',
  7692. 'xvml' => 'application/xv+xml',
  7693. 'xwd' => 'image/x-xwindowdump',
  7694. 'xyz' => 'chemical/x-xyz',
  7695. 'xz' => 'application/x-xz',
  7696. 'yang' => 'application/yang',
  7697. 'yin' => 'application/yin+xml',
  7698. 'z1' => 'application/x-zmachine',
  7699. 'z2' => 'application/x-zmachine',
  7700. 'z3' => 'application/x-zmachine',
  7701. 'z4' => 'application/x-zmachine',
  7702. 'z5' => 'application/x-zmachine',
  7703. 'z6' => 'application/x-zmachine',
  7704. 'z7' => 'application/x-zmachine',
  7705. 'z8' => 'application/x-zmachine',
  7706. 'zaz' => 'application/vnd.zzazz.deck+xml',
  7707. 'zip' => 'application/zip',
  7708. 'zir' => 'application/vnd.zul',
  7709. 'zirz' => 'application/vnd.zul',
  7710. 'zmm' => 'application/vnd.handheld-entertainment+xml'
  7711. );
  7712. }
  7713. // Always run this
  7714. if(strpos($_SERVER['SCRIPT_NAME'], 'check.php') == false){
  7715. dependCheck();
  7716. }