functions.php 208 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264
  1. <?php
  2. // ===================================
  3. // Define Version
  4. define('INSTALLEDVERSION', '1.42');
  5. // ===================================
  6. use Kryptonit3\Sonarr\Sonarr;
  7. use Kryptonit3\SickRage\SickRage;
  8. // Debugging output functions
  9. function debug_out($variable, $die = false) {
  10. $trace = debug_backtrace()[0];
  11. echo "<center><img height='200px' src='images/confused.png'></center>";
  12. echo "<center>Look's like something happened, here are the errors and perhaps how to fix them:</center>";
  13. 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>';
  14. if ($die) { http_response_code(503); die(); }
  15. }
  16. // ==== Auth Plugins START ====
  17. if (function_exists('ldap_connect')) :
  18. // Pass credentials to LDAP backend
  19. function plugin_auth_ldap($username, $password) {
  20. $ldapServers = explode(',',AUTHBACKENDHOST);
  21. foreach($ldapServers as $key => $value) {
  22. // Calculate parts
  23. $digest = parse_url(trim($value));
  24. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:'ldap'));
  25. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  26. $port = (isset($digest['port'])?$digest['port']:(strtolower($scheme)=='ldap'?389:636));
  27. // Reassign
  28. $ldapServers[$key] = $scheme.'://'.$host.':'.$port;
  29. }
  30. // returns true or false
  31. $ldap = ldap_connect(implode(' ',$ldapServers));
  32. if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
  33. writeLog("success", "LDAP authentication success");
  34. return true;
  35. } else {
  36. writeLog("error", "LDPA could not authenticate");
  37. return false;
  38. }
  39. writeLog("error", "LDPA could not authenticate");
  40. return false;
  41. }
  42. else :
  43. // Ldap Auth Missing Dependancy
  44. function plugin_auth_ldap_disabled() {
  45. return 'LDAP - Disabled (Dependancy: php-ldap missing!)';
  46. }
  47. endif;
  48. // Pass credentials to FTP backend
  49. function plugin_auth_ftp($username, $password) {
  50. // Calculate parts
  51. $digest = parse_url(AUTHBACKENDHOST);
  52. $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:(function_exists('ftp_ssl_connect')?'ftps':'ftp')));
  53. $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:''));
  54. $port = (isset($digest['port'])?$digest['port']:21);
  55. // Determine Connection Type
  56. if ($scheme == 'ftps') {
  57. $conn_id = ftp_ssl_connect($host, $port, 20);
  58. } elseif ($scheme == 'ftp') {
  59. $conn_id = ftp_connect($host, $port, 20);
  60. } else {
  61. debug_out('Invalid FTP scheme. Use ftp or ftps');
  62. writeLog("error", "invalid FTP scheme");
  63. return false;
  64. }
  65. // Check if valid FTP connection
  66. if ($conn_id) {
  67. // Attempt login
  68. @$login_result = ftp_login($conn_id, $username, $password);
  69. ftp_close($conn_id);
  70. // Return Result
  71. if ($login_result) {
  72. writeLog("success", "$username authenticated");
  73. return true;
  74. } else {
  75. writeLog("error", "$username could not authenticate");
  76. return false;
  77. }
  78. } else {
  79. return false;
  80. }
  81. return false;
  82. }
  83. // Pass credentials to Emby Backend
  84. function plugin_auth_emby_local($username, $password) {
  85. $embyAddress = qualifyURL(EMBYURL);
  86. $headers = array(
  87. 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"',
  88. 'Content-Type' => 'application/json',
  89. );
  90. $body = array(
  91. 'Username' => $username,
  92. 'Password' => sha1($password),
  93. 'PasswordMd5' => md5($password),
  94. );
  95. $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers);
  96. if (isset($response['content'])) {
  97. $json = json_decode($response['content'], true);
  98. if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
  99. // Login Success - Now Logout Emby Session As We No Longer Need It
  100. $headers = array(
  101. 'X-Mediabrowser-Token' => $json['AccessToken'],
  102. );
  103. $response = post_router($embyAddress.'/Sessions/Logout', array(), $headers);
  104. return true;
  105. }
  106. }
  107. return false;
  108. }
  109. if (function_exists('curl_version')) :
  110. // Authenticate Against Emby Local (first) and Emby Connect
  111. function plugin_auth_emby_all($username, $password) {
  112. $localResult = plugin_auth_emby_local($username, $password);
  113. if ($localResult) {
  114. return $localResult;
  115. } else {
  116. return plugin_auth_emby_connect($username, $password);
  117. }
  118. }
  119. // Authenicate against emby connect
  120. function plugin_auth_emby_connect($username, $password) {
  121. $embyAddress = qualifyURL(EMBYURL);
  122. // Get A User
  123. $connectId = '';
  124. $userIds = json_decode(file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
  125. if (is_array($userIds)) {
  126. foreach ($userIds as $key => $value) { // Scan for this user
  127. if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
  128. if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
  129. $connectId = $value['ConnectUserId'];
  130. break;
  131. }
  132. }
  133. }
  134. if ($connectId) {
  135. $connectURL = 'https://connect.emby.media/service/user/authenticate';
  136. $headers = array(
  137. 'Accept'=> 'application/json',
  138. 'Content-Type' => 'application/x-www-form-urlencoded',
  139. );
  140. $body = array(
  141. 'nameOrEmail' => $username,
  142. 'rawpw' => $password,
  143. );
  144. $result = curl_post($connectURL, $body, $headers);
  145. if (isset($result['content'])) {
  146. $json = json_decode($result['content'], true);
  147. if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
  148. return array(
  149. 'email' => $json['User']['Email'],
  150. 'image' => $json['User']['ImageUrl'],
  151. );
  152. }
  153. }
  154. }
  155. }
  156. return false;
  157. }
  158. // Pass credentials to Plex Backend
  159. function plugin_auth_plex($username, $password) {
  160. // Quick out
  161. if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
  162. writeLog("success", $username." authenticated by plex");
  163. return true;
  164. }
  165. //Get User List
  166. $userURL = 'https://plex.tv/pms/friends/all';
  167. $userHeaders = array(
  168. 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD),
  169. );
  170. $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
  171. if (is_array($userXML) || is_object($userXML)) {
  172. $isUser = false;
  173. $usernameLower = strtolower($username);
  174. foreach($userXML AS $child) {
  175. if(isset($child['username']) && strtolower($child['username']) == $usernameLower) {
  176. $isUser = true;
  177. writeLog("success", $usernameLower." was found in plex friends list");
  178. break;
  179. }
  180. }
  181. if ($isUser) {
  182. //Login User
  183. $connectURL = 'https://plex.tv/users/sign_in.json';
  184. $headers = array(
  185. 'Accept'=> 'application/json',
  186. 'Content-Type' => 'application/x-www-form-urlencoded',
  187. 'X-Plex-Product' => 'Organizr',
  188. 'X-Plex-Version' => '1.0',
  189. 'X-Plex-Client-Identifier' => '01010101-10101010',
  190. );
  191. $body = array(
  192. 'user[login]' => $username,
  193. 'user[password]' => $password,
  194. );
  195. $result = curl_post($connectURL, $body, $headers);
  196. if (isset($result['content'])) {
  197. $json = json_decode($result['content'], true);
  198. if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && strtolower($json['user']['username']) == $usernameLower) {
  199. writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
  200. return array(
  201. 'email' => $json['user']['email'],
  202. 'image' => $json['user']['thumb']
  203. );
  204. }
  205. }
  206. }else{
  207. writeLog("error", "$username is not an authorized PLEX user or entered invalid password");
  208. }
  209. }else{
  210. writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");
  211. }
  212. return false;
  213. }
  214. else :
  215. // Plex Auth Missing Dependancy
  216. function plugin_auth_plex_disabled() {
  217. return 'Plex - Disabled (Dependancy: php-curl missing!)';
  218. }
  219. // Emby Connect Auth Missing Dependancy
  220. function plugin_auth_emby_connect_disabled() {
  221. return 'Emby Connect - Disabled (Dependancy: php-curl missing!)';
  222. }
  223. // Emby Both Auth Missing Dependancy
  224. function plugin_auth_emby_both_disabled() {
  225. return 'Emby Both - Disabled (Dependancy: php-curl missing!)';
  226. }
  227. endif;
  228. // ==== Auth Plugins END ====
  229. // ==== General Class Definitions START ====
  230. class setLanguage {
  231. private $language = null;
  232. private $langCode = null;
  233. function __construct($language = false) {
  234. // Default
  235. if (!$language) {
  236. $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  237. }
  238. if (!file_exists("lang/{$language}.ini")) {
  239. $language = 'en';
  240. }
  241. $this->langCode = $language;
  242. $this->language = parse_ini_file("lang/{$language}.ini", false, INI_SCANNER_RAW);
  243. if (file_exists("lang/{$language}.cust.ini")) {
  244. foreach($tmp = parse_ini_file("lang/{$language}.cust.ini", false, INI_SCANNER_RAW) as $k => $v) {
  245. $this->language[$k] = $v;
  246. }
  247. }
  248. }
  249. public function getLang() {
  250. return $this->langCode;
  251. }
  252. public function translate($originalWord) {
  253. $getArg = func_num_args();
  254. if ($getArg > 1) {
  255. $allWords = func_get_args();
  256. array_shift($allWords);
  257. } else {
  258. $allWords = array();
  259. }
  260. $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null;
  261. if (!$translatedWord) {
  262. return ucwords(str_replace("_", " ", strtolower($originalWord)));
  263. }
  264. $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES);
  265. return vsprintf($translatedWord, $allWords);
  266. }
  267. }
  268. $language = new setLanguage;
  269. // ==== General Class Definitions END ====
  270. // Direct request to curl if it exists, otherwise handle if not HTTPS
  271. function post_router($url, $data, $headers = array(), $referer='') {
  272. if (function_exists('curl_version')) {
  273. return curl_post($url, $data, $headers, $referer);
  274. } else {
  275. return post_request($url, $data, $headers, $referer);
  276. }
  277. }
  278. if (function_exists('curl_version')) :
  279. // Curl Post
  280. function curl_post($url, $data, $headers = array(), $referer='') {
  281. // Initiate cURL
  282. $curlReq = curl_init($url);
  283. // As post request
  284. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST");
  285. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  286. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  287. // Format Data
  288. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  289. case 'application/json':
  290. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  291. break;
  292. case 'application/x-www-form-urlencoded';
  293. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  294. break;
  295. default:
  296. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  297. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  298. }
  299. // Format Headers
  300. $cHeaders = array();
  301. foreach ($headers as $k => $v) {
  302. $cHeaders[] = $k.': '.$v;
  303. }
  304. if (count($cHeaders)) {
  305. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  306. }
  307. // Execute
  308. $result = curl_exec($curlReq);
  309. $httpcode = curl_getinfo($curlReq);
  310. // Close
  311. curl_close($curlReq);
  312. // Return
  313. return array('content'=>$result, 'http_code'=>$httpcode);
  314. }
  315. //Curl Get Function
  316. function curl_get($url, $headers = array()) {
  317. // Initiate cURL
  318. $curlReq = curl_init($url);
  319. // As post request
  320. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET");
  321. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  322. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  323. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  324. // Format Headers
  325. $cHeaders = array();
  326. foreach ($headers as $k => $v) {
  327. $cHeaders[] = $k.': '.$v;
  328. }
  329. if (count($cHeaders)) {
  330. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  331. }
  332. // Execute
  333. $result = curl_exec($curlReq);
  334. // Close
  335. curl_close($curlReq);
  336. // Return
  337. return $result;
  338. }
  339. //Curl Delete Function
  340. function curl_delete($url, $headers = array()) {
  341. // Initiate cURL
  342. $curlReq = curl_init($url);
  343. // As post request
  344. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE");
  345. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  346. curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5);
  347. curl_setopt($curlReq, CURLOPT_CAINFO, getCert());
  348. // Format Headers
  349. $cHeaders = array();
  350. foreach ($headers as $k => $v) {
  351. $cHeaders[] = $k.': '.$v;
  352. }
  353. if (count($cHeaders)) {
  354. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  355. }
  356. // Execute
  357. $result = curl_exec($curlReq);
  358. $httpcode = curl_getinfo($curlReq);
  359. // Close
  360. curl_close($curlReq);
  361. // Return
  362. return array('content'=>$result, 'http_code'=>$httpcode);
  363. }
  364. endif;
  365. //Case-Insensitive Function
  366. function in_arrayi($needle, $haystack) {
  367. return in_array(strtolower($needle), array_map('strtolower', $haystack));
  368. }
  369. // HTTP post request (Removes need for curl, probably useless)
  370. function post_request($url, $data, $headers = array(), $referer='') {
  371. // Adapted from http://stackoverflow.com/a/28387011/6810513
  372. // Convert the data array into URL Parameters like a=b&foo=bar etc.
  373. if (isset($headers['Content-Type'])) {
  374. switch ($headers['Content-Type']) {
  375. case 'application/json':
  376. $data = json_encode($data);
  377. break;
  378. case 'application/x-www-form-urlencoded':
  379. $data = http_build_query($data);
  380. break;
  381. }
  382. } else {
  383. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  384. $data = http_build_query($data);
  385. }
  386. // parse the given URL
  387. $urlDigest = parse_url($url);
  388. // extract host and path:
  389. $host = $urlDigest['host'];
  390. $path = $urlDigest['path'];
  391. if ($urlDigest['scheme'] != 'http') {
  392. die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')');
  393. }
  394. // open a socket connection on port 80 - timeout: 30 sec
  395. $fp = fsockopen($host, (isset($urlDigest['port'])?':'.$urlDigest['port']:80), $errno, $errstr, 30);
  396. if ($fp){
  397. // send the request headers:
  398. fputs($fp, "POST $path HTTP/1.1\r\n");
  399. fputs($fp, "Host: $host\r\n");
  400. if ($referer != '')
  401. fputs($fp, "Referer: $referer\r\n");
  402. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  403. foreach($headers as $k => $v) {
  404. fputs($fp, $k.": ".$v."\r\n");
  405. }
  406. fputs($fp, "Connection: close\r\n\r\n");
  407. fputs($fp, $data);
  408. $result = '';
  409. while(!feof($fp)) {
  410. // receive the results of the request
  411. $result .= fgets($fp, 128);
  412. }
  413. }
  414. else {
  415. return array(
  416. 'status' => 'err',
  417. 'error' => "$errstr ($errno)"
  418. );
  419. }
  420. // close the socket connection:
  421. fclose($fp);
  422. // split the result header from the content
  423. $result = explode("\r\n\r\n", $result, 2);
  424. $header = isset($result[0]) ? $result[0] : '';
  425. $content = isset($result[1]) ? $result[1] : '';
  426. // return as structured array:
  427. return array(
  428. 'status' => 'ok',
  429. 'header' => $header,
  430. 'content' => $content,
  431. );
  432. }
  433. // Format item from Emby for Carousel
  434. function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $moreInfo = false) {
  435. // Static Height
  436. $height = 444;
  437. // Get Item Details
  438. $itemDetails = json_decode(file_get_contents($address.'/Items?Ids='.$item['Id'].'&api_key='.$token),true)['Items'][0];
  439. if (substr_count(EMBYURL, ':') == 2) {
  440. $URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  441. }else{
  442. $URL = EMBYURL."/web/itemdetails.html?id=".$itemDetails['Id'];
  443. }
  444. //$URL = "http://app.emby.media/itemdetails.html?id=".$itemDetails['Id'];
  445. switch ($itemDetails['Type']) {
  446. case 'Episode':
  447. $title = (isset($itemDetails['SeriesName'])?$itemDetails['SeriesName']:"");
  448. $imageId = (isset($itemDetails['SeriesId'])?$itemDetails['SeriesId']:$itemDetails['Id']);
  449. $width = 300;
  450. $style = '';
  451. $image = 'slick-image-tall';
  452. if(!$nowPlaying){
  453. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  454. $key = $itemDetails['Id'] . "-list";
  455. }else{
  456. $height = 281;
  457. $width = 500;
  458. $imageId = isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId'] : (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  459. $imageType = isset($itemDetails['ParentThumbItemId']) ? "Thumb" : (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  460. $key = (isset($itemDetails['ParentThumbItemId']) ? $itemDetails['ParentThumbItemId']."-np" : "none-np");
  461. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  462. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  463. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  464. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  465. $stream = $moreInfo['PlayState']['PlayMethod'];
  466. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  467. $id = $moreInfo['DeviceId'];
  468. $streamInfo = buildStream(array(
  469. 'platform' => (string) $moreInfo['Client'],
  470. 'device' => (string) $moreInfo['DeviceName'],
  471. 'stream' => "&nbsp;".streamType($stream),
  472. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  473. 'audio' => "&nbsp;".streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  474. ));
  475. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  476. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$itemDetails['Name'].'</h5>';
  477. $bottomTitle = '<small class="zero-m">S'.$itemDetails['ParentIndexNumber'].' · E'.$itemDetails['IndexNumber'].'</small>';
  478. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  479. }
  480. break;
  481. case 'MusicAlbum':
  482. case 'Audio':
  483. $title = $itemDetails['Name'];
  484. $imageId = $itemDetails['Id'];
  485. $width = 444;
  486. $style = '';
  487. $image = 'slick-image-short';
  488. if(!$nowPlaying){
  489. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  490. $key = $itemDetails['Id'] . "-list";
  491. }else{
  492. $height = 281;
  493. $width = 500;
  494. $imageId = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : false);
  495. $imageType = (isset($itemDetails['ParentBackdropItemId']) ? "Backdrop" : false);
  496. $key = (isset($itemDetails['ParentBackdropItemId']) ? $itemDetails['ParentBackdropItemId'] : "no-np") . "-np";
  497. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  498. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  499. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  500. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  501. $stream = $moreInfo['PlayState']['PlayMethod'];
  502. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  503. $id = $moreInfo['DeviceId'];
  504. $streamInfo = buildStream(array(
  505. 'platform' => (string) $moreInfo['Client'],
  506. 'device' => (string) $moreInfo['DeviceName'],
  507. 'stream' => "&nbsp;".streamType($stream),
  508. 'audio' => "&nbsp;".streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  509. ));
  510. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  511. $topTitle = '<h5 class="text-center zero-m elip">'.$itemDetails['AlbumArtist'].' - '.$itemDetails['Album'].'</h5>';
  512. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  513. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  514. }
  515. break;
  516. case 'TvChannel':
  517. $title = $itemDetails['CurrentProgram']['Name'];
  518. $imageId = $itemDetails['Id'];
  519. $width = 300;
  520. $style = '';
  521. $image = 'slick-image-tall';
  522. if(!$nowPlaying){
  523. $imageType = "Primary";
  524. $key = $itemDetails['Id'] . "-list";
  525. }else{
  526. $height = 281;
  527. $width = 500;
  528. $imageType = "Thumb";
  529. $key = $itemDetails['Id'] . "-np";
  530. $useImage = "images/livetv.png";
  531. $watched = "0";
  532. $stream = $moreInfo['PlayState']['PlayMethod'];
  533. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  534. $id = $moreInfo['DeviceId'];
  535. $streamInfo = buildStream(array(
  536. 'platform' => (string) $moreInfo['Client'],
  537. 'device' => (string) $moreInfo['DeviceName'],
  538. 'stream' => "&nbsp;".streamType($stream),
  539. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  540. 'audio' => "&nbsp;".streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  541. ));
  542. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  543. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  544. $bottomTitle = '<small class="zero-m">'.$itemDetails['Name'].' - '.$itemDetails['ChannelNumber'].'</small>';
  545. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  546. }
  547. break;
  548. default:
  549. $title = $itemDetails['Name'];
  550. $imageId = $itemDetails['Id'];
  551. $width = 300;
  552. $style = '';
  553. $image = 'slick-image-tall';
  554. if(!$nowPlaying){
  555. $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false);
  556. $key = $itemDetails['Id'] . "-list";
  557. }else{
  558. $height = 281;
  559. $width = 500;
  560. $imageType = isset($itemDetails['ImageTags']['Thumb']) ? "Thumb" : (isset($itemDetails['BackdropImageTags']) ? "Backdrop" : false);
  561. $key = $itemDetails['Id'] . "-np";
  562. $elapsed = $moreInfo['PlayState']['PositionTicks'];
  563. $duration = $moreInfo['NowPlayingItem']['RunTimeTicks'];
  564. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  565. //$transcoded = floor($item->TranscodeSession['progress']- $watched);
  566. $stream = $moreInfo['PlayState']['PlayMethod'];
  567. $user = $role == "admin" ? $moreInfo['UserName'] : "";
  568. $id = $moreInfo['DeviceId'];
  569. $streamInfo = buildStream(array(
  570. 'platform' => (string) $moreInfo['Client'],
  571. 'device' => (string) $moreInfo['DeviceName'],
  572. 'stream' => "&nbsp;".streamType($stream),
  573. 'video' => streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "video"),
  574. 'audio' => "&nbsp;".streamType($stream)." ".embyArray($moreInfo['NowPlayingItem']['MediaStreams'], "audio"),
  575. ));
  576. $state = (($moreInfo['PlayState']['IsPaused'] == "1") ? "pause" : "play");
  577. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  578. $bottomTitle = '<small class="zero-m">'.$moreInfo['NowPlayingItem']['ProductionYear'].'</small>';
  579. if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
  580. }
  581. }
  582. // If No Overview
  583. if (!isset($itemDetails['Overview'])) {
  584. $itemDetails['Overview'] = '';
  585. }
  586. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  587. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  588. $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.'';
  589. }
  590. if($nowPlaying){
  591. if(!$imageType){ $image_url = "images/no-np.png"; $key = "no-np"; }
  592. if(!$imageId){ $image_url = "images/no-np.png"; $key = "no-np"; }
  593. }else{
  594. if(!$imageType){ $image_url = "images/no-list.png"; $key = "no-list"; }
  595. if(!$imageId){ $image_url = "images/no-list.png"; $key = "no-list"; }
  596. }
  597. if(isset($useImage)){ $image_url = $useImage; }
  598. // Assemble Item And Cache Into Array
  599. if($nowPlaying){
  600. //prettyPrint($itemDetails);
  601. 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="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'].'"></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>';
  602. }else{
  603. return '<div class="item-'.$itemDetails['Type'].'"><a href="'.$URL.'" target="_blank"><img alt="'.$itemDetails['Name'].'" class="'.$image.'" data-lazy="'.$image_url.'"></a><small style="margin-right: 13px" class="elip">'.$title.'</small></div>';
  604. }
  605. }
  606. // Format item from Plex for Carousel
  607. function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $playlist = false) {
  608. // Static Height
  609. $height = 444;
  610. $playlist = ($playlist) ? " playlist-$playlist" : "";
  611. switch ($item['type']) {
  612. case 'season':
  613. $title = $item['parentTitle'];
  614. $summary = $item['parentSummary'];
  615. $width = 300;
  616. $image = 'slick-image-tall';
  617. $style = '';
  618. if(!$nowPlaying){
  619. $thumb = $item['thumb'];
  620. $key = $item['ratingKey'] . "-list";
  621. }else {
  622. $height = 281;
  623. $width = 500;
  624. $thumb = $item['art'];
  625. $key = $item['ratingKey'] . "-np";
  626. $elapsed = $item['viewOffset'];
  627. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  628. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  629. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  630. $stream = $item->Media->Part->Stream['decision'];
  631. $user = $role == "admin" ? $item->User['title'] : "";
  632. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  633. $streamInfo = buildStream(array(
  634. 'platform' => (string) $item->Player['platform'],
  635. 'device' => (string) $item->Player['device'],
  636. 'stream' => "&nbsp;".streamType($item->Media->Part['decision']),
  637. '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'].")",
  638. 'audio' => "&nbsp;".streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  639. ));
  640. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  641. }
  642. break;
  643. case 'episode':
  644. $title = $item['grandparentTitle'];
  645. $summary = $item['title'];
  646. $width = 300;
  647. $image = 'slick-image-tall';
  648. $style = '';
  649. if(!$nowPlaying){
  650. $thumb = ($item['parentThumb'] ? $item['parentThumb'] : $item['grandparentThumb']);
  651. $key = $item['ratingKey'] . "-list";
  652. }else {
  653. $height = 281;
  654. $width = 500;
  655. $thumb = $item['art'];
  656. $key = $item['ratingKey'] . "-np";
  657. $elapsed = $item['viewOffset'];
  658. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  659. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  660. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  661. $stream = $item->Media->Part->Stream['decision'];
  662. $user = $role == "admin" ? $item->User['title'] : "";
  663. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  664. $streamInfo = buildStream(array(
  665. 'platform' => (string) $item->Player['platform'],
  666. 'device' => (string) $item->Player['device'],
  667. 'stream' => "&nbsp;".streamType($item->Media->Part['decision']),
  668. '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'].")",
  669. 'audio' => "&nbsp;".streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  670. ));
  671. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  672. $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$item['title'].'</h5>';
  673. $bottomTitle = '<small class="zero-m">S'.$item['parentIndex'].' · E'.$item['index'].'</small>';
  674. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  675. }
  676. break;
  677. case 'clip':
  678. $title = $item['title'];
  679. $summary = $item['summary'];
  680. $width = 300;
  681. $image = 'slick-image-tall';
  682. $style = '';
  683. if(!$nowPlaying){
  684. $thumb = $item['thumb'];
  685. $key = $item['ratingKey'] . "-list";
  686. }else {
  687. $height = 281;
  688. $width = 500;
  689. $thumb = $item['art'];
  690. $key = isset($item['ratingKey']) ? $item['ratingKey'] . "-np" : (isset($item['live']) ? "livetv.png" : ":)");
  691. $useImage = (isset($item['live']) ? "images/livetv.png" : null);
  692. $extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
  693. $elapsed = $item['viewOffset'];
  694. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  695. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  696. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  697. $stream = $item->Media->Part->Stream['decision'];
  698. $user = $role == "admin" ? $item->User['title'] : "";
  699. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  700. $streamInfo = buildStream(array(
  701. 'platform' => (string) $item->Player['platform'],
  702. 'device' => (string) $item->Player['device'],
  703. 'stream' => "&nbsp;".streamType($item->Media->Part['decision']),
  704. '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'].")",
  705. 'audio' => "&nbsp;".streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  706. ));
  707. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  708. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  709. $bottomTitle = '<small class="zero-m">'.$extraInfo.'</small>';
  710. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  711. }
  712. break;
  713. case 'album':
  714. case 'track':
  715. $title = $item['parentTitle'];
  716. $summary = $item['title'];
  717. $image = 'slick-image-short';
  718. $style = 'left: 160px !important;';
  719. $item['ratingKey'] = $item['parentRatingKey'];
  720. if(!$nowPlaying){
  721. $width = 444;
  722. $thumb = $item['thumb'];
  723. $key = $item['ratingKey'] . "-list";
  724. }else {
  725. $height = 281;
  726. $width = 500;
  727. $thumb = $item['art'];
  728. $key = $item['ratingKey'] . "-np";
  729. $elapsed = $item['viewOffset'];
  730. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  731. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  732. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  733. $stream = $item->Media->Part->Stream['decision'];
  734. $user = $role == "admin" ? $item->User['title'] : "";
  735. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  736. $streamInfo = buildStream(array(
  737. 'platform' => (string) $item->Player['platform'],
  738. 'device' => (string) $item->Player['device'],
  739. 'stream' => "&nbsp;".streamType($item->Media->Part['decision']),
  740. 'audio' => "&nbsp;".streamType($item->Media->Part->Stream[0]['decision'])." (".$item->Media->Part->Stream[0]['codec'].") (".$item->Media->Part->Stream[0]['channels']."ch)",
  741. ));
  742. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  743. $topTitle = '<h5 class="text-center zero-m elip">'.$item['grandparentTitle'].' - '.$item['title'].'</h5>';
  744. $bottomTitle = '<small class="zero-m">'.$title.'</small>';
  745. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  746. }
  747. break;
  748. default:
  749. $title = $item['title'];
  750. $summary = $item['summary'];
  751. $image = 'slick-image-tall';
  752. $style = '';
  753. if(!$nowPlaying){
  754. $width = 300;
  755. $thumb = $item['thumb'];
  756. $key = $item['ratingKey'] . "-list";
  757. }else {
  758. $height = 281;
  759. $width = 500;
  760. $thumb = $item['art'];
  761. $key = $item['ratingKey'] . "-np";
  762. $elapsed = $item['viewOffset'];
  763. $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
  764. $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
  765. $transcoded = floor($item->TranscodeSession['progress']- $watched);
  766. $stream = $item->Media->Part->Stream['decision'];
  767. $user = $role == "admin" ? $item->User['title'] : "";
  768. $id = str_replace('"', '', $item->Player['machineIdentifier']);
  769. $streamInfo = buildStream(array(
  770. 'platform' => (string) $item->Player['platform'],
  771. 'device' => (string) $item->Player['device'],
  772. 'stream' => "&nbsp;".streamType($item->Media->Part['decision']),
  773. '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'].")",
  774. 'audio' => "&nbsp;".streamType($item->Media->Part->Stream[1]['decision'])." (".$item->Media->Part->Stream[1]['codec'].") (".$item->Media->Part->Stream[1]['channels']."ch)",
  775. ));
  776. $state = (($item->Player['state'] == "paused") ? "pause" : "play");
  777. $topTitle = '<h5 class="text-center zero-m elip">'.$title.'</h5>';
  778. $bottomTitle = '<small class="zero-m">'.$item['year'].'</small>';
  779. if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
  780. }
  781. }
  782. if (substr_count(PLEXURL, '.') != 2) {
  783. $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  784. }else{
  785. $address = PLEXURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  786. }
  787. // If No Overview
  788. if (!isset($itemDetails['Overview'])) { $itemDetails['Overview'] = ''; }
  789. if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; }
  790. if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
  791. $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'';
  792. }
  793. if($nowPlaying){
  794. if(!$thumb){ $image_url = "images/no-np.png"; $key = "no-np"; }
  795. }else{
  796. if(!$thumb){ $image_url = "images/no-list.png"; $key = "no-list"; }
  797. }
  798. if(isset($useImage)){ $image_url = $useImage; }
  799. $openTab = (PLEXTABNAME) ? "true" : "false";
  800. // Assemble Item And Cache Into Array
  801. if($nowPlaying){
  802. 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="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 class="openTab" extraTitle="'.$title.'" extraType="'.$item['type'].'" openTab="'.$openTab.'" href="'.$address.'" target="_blank"><img style="width: 100%; display:inherit;" src="'.$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>';
  803. }else{
  804. return '<div class="item-'.$item['type'].$playlist.'"><a class="openTab" extraTitle="'.$title.'" extraType="'.$item['type'].'" openTab="'.$openTab.'" href="'.$address.'" target="_blank"><img alt="'.$item['Name'].'" class="'.$image.'" data-lazy="'.$image_url.'"></a><small style="margin-right: 13px" class="elip">'.$title.'</small></div>';
  805. }
  806. }
  807. //$hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  808. //Recent Added
  809. function outputRecentAdded($header, $items, $script = false, $array) {
  810. $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">';
  811. if(preg_grep("/item-movie/", $items)){
  812. $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>';
  813. }
  814. if(preg_grep("/item-season/", $items)){
  815. $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>';
  816. }
  817. if(preg_grep("/item-album/", $items)){
  818. $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>';
  819. }
  820. $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>';
  821. $hideMenu .= '</ul></div></div>';
  822. // If None Populate Empty Item
  823. if (!count($items)) {
  824. return '<div id="recentMedia" class="content-box box-shadow big-box"><h5 class="text-center">'.$header.'</h5><p class="text-center">No Media Found</p></div>';
  825. }else{
  826. $className = str_replace(' ', '', $header);
  827. return '<div id="recentMedia" class="content-box box-shadow big-box"><h5 id="recentContent-title" style="margin-bottom: -20px" class="text-center">'.$header.'</h5><div class="recentHeader inbox-pagination '.$className.'">'.$hideMenu.'</div><br/><br/><div class="recentItems-recent" data-name="'.$className.'">'.implode('',$items).'</div></div>'.($script?'<script>'.$script.'</script>':'');
  828. }
  829. }
  830. // Create Carousel
  831. function outputNowPlaying($header, $size, $type, $items, $script = false) {
  832. // If None Populate Empty Item
  833. if (!count($items)) {
  834. return '<div id=streamz></div>'.($script?'<script>'.$script.'</script>':'');
  835. }else{
  836. return '<div id=streamz><h5 class="zero-m big-box"><strong>'.$header.'</strong></h5>'.implode('',$items).'</div>'.($script?'<script>'.$script.'</script>':'');
  837. }
  838. }
  839. // Get Now Playing Streams From Emby
  840. function getEmbyStreams($size, $showNames, $role) {
  841. $address = qualifyURL(EMBYURL);
  842. $api = json_decode(@file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
  843. if (!is_array($api)) { return 'Could not load!'; }
  844. $playingItems = array();
  845. foreach($api as $key => $value) {
  846. if (isset($value['NowPlayingItem'])) {
  847. $playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem'], true, $showNames, $role, $value);
  848. }
  849. }
  850. return outputNowPlaying(translate('PLAYING_NOW_ON_EMBY'), $size, 'streams-emby', $playingItems, "
  851. setInterval(function() {
  852. $('<div></div>').load('ajax.php?a=emby-streams',function() {
  853. var element = $(this).find('[id]');
  854. var loadedID = element.attr('id');
  855. $('#'+loadedID).replaceWith(element);
  856. console.log('Loaded updated: '+loadedID);
  857. });
  858. }, 15000);
  859. ");
  860. }
  861. // Get Now Playing Streams From Plex
  862. function getPlexStreams($size, $showNames, $role){
  863. $address = qualifyURL(PLEXURL);
  864. // Perform API requests
  865. $api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
  866. $api = simplexml_load_string($api);
  867. if (is_array($api) || is_object($api)){
  868. if (!$api->head->title){
  869. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  870. if (!$getServer) { return 'Could not load!'; }
  871. // Identify the local machine
  872. $gotServer = $getServer['machineIdentifier'];
  873. $items = array();
  874. foreach($api AS $child) {
  875. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
  876. }
  877. return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." ( ".count($items)." Streams )", $size, 'streams-plex', $items, "
  878. setInterval(function() {
  879. $('<div></div>').load('ajax.php?a=plex-streams',function() {
  880. var element = $(this).find('[id]');
  881. var loadedID = element.attr('id');
  882. $('#'+loadedID).replaceWith(element);
  883. console.log('Loaded updated: '+loadedID);
  884. });
  885. }, 15000);
  886. ");
  887. }else{
  888. writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
  889. }
  890. }else{
  891. writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
  892. }
  893. }
  894. // Get Recent Content From Emby
  895. function getEmbyRecent($array) {
  896. $address = qualifyURL(EMBYURL);
  897. $header = translate('RECENT_CONTENT');
  898. // Currently Logged In User
  899. $username = false;
  900. if (isset($GLOBALS['USER'])) {
  901. $username = strtolower($GLOBALS['USER']->username);
  902. }
  903. // Get A User
  904. $userIds = json_decode(@file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
  905. if (!is_array($userIds)) { return 'Could not load!'; }
  906. $showPlayed = true;
  907. foreach ($userIds as $value) { // Scan for admin user
  908. if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
  909. $userId = $value['Id'];
  910. }
  911. if ($username && strtolower($value['Name']) == $username) {
  912. $userId = $value['Id'];
  913. $showPlayed = false;
  914. break;
  915. }
  916. }
  917. // Get the latest Items
  918. $latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?EnableImages=false&Limit='.EMBYRECENTITEMS.'&api_key='.EMBYTOKEN.($showPlayed?'':'&IsPlayed=false')),true);
  919. // For Each Item In Category
  920. $items = array();
  921. foreach ($latest as $k => $v) {
  922. $type = (string) $v['Type'];
  923. if(@$array[$type] == "true"){
  924. $items[] = resolveEmbyItem($address, EMBYTOKEN, $v, false, false, false);
  925. }
  926. }
  927. $array["movie"] = $array["Movie"];
  928. $array["season"] = $array["Episode"];
  929. $array["album"] = $array["MusicAlbum"];
  930. unset($array["Movie"]);
  931. unset($array["Episode"]);
  932. unset($array["MusicAlbum"]);
  933. unset($array["Series"]);
  934. return outputRecentAdded($header, $items, "", $array);
  935. }
  936. // Get Recent Content From Plex
  937. function getPlexRecent($array){
  938. $address = qualifyURL(PLEXURL);
  939. $header = translate('RECENT_CONTENT');
  940. // Perform Requests
  941. $api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN);
  942. $api = simplexml_load_string($api);
  943. if (is_array($api) || is_object($api)){
  944. if (!$api->head->title){
  945. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  946. if (!$getServer) { return 'Could not load!'; }
  947. // Identify the local machine
  948. $gotServer = $getServer['machineIdentifier'];
  949. $items = array();
  950. foreach($api AS $child) {
  951. $type = (string) $child['type'];
  952. if($array[$type] == "true"){
  953. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
  954. }
  955. }
  956. return outputRecentAdded($header, $items, "", $array);
  957. }else{
  958. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check token - if HTTPS, is cert valid");
  959. }
  960. }else{
  961. writeLog("error", "PLEX RECENT-ITEMS ERROR: could not connect - check URL - if HTTPS, is cert valid");
  962. }
  963. }
  964. // Get Image From Emby
  965. function getEmbyImage() {
  966. $embyAddress = qualifyURL(EMBYURL);
  967. if (!file_exists('images/cache')) {
  968. mkdir('images/cache', 0777, true);
  969. }
  970. $itemId = $_GET['img'];
  971. $key = $_GET['key'];
  972. $itemType = $_GET['type'];
  973. $imgParams = array();
  974. if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
  975. if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
  976. if(isset($itemId)) {
  977. $image_src = $embyAddress . '/Items/'.$itemId.'/Images/'.$itemType.'?'.implode('&', $imgParams);
  978. $cachefile = 'images/cache/'.$key.'.jpg';
  979. $cachetime = 604800;
  980. // Serve from the cache if it is younger than $cachetime
  981. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
  982. header("Content-type: image/jpeg");
  983. @readfile($cachefile);
  984. exit;
  985. }
  986. ob_start(); // Start the output buffer
  987. header('Content-type: image/jpeg');
  988. @readfile($image_src);
  989. // Cache the output to a file
  990. $fp = fopen($cachefile, 'wb');
  991. fwrite($fp, ob_get_contents());
  992. fclose($fp);
  993. ob_end_flush(); // Send the output to the browser
  994. die();
  995. } else {
  996. debug_out('Invalid Request',1);
  997. }
  998. }
  999. // Get Image From Plex
  1000. function getPlexImage() {
  1001. $plexAddress = qualifyURL(PLEXURL);
  1002. if (!file_exists('images/cache')) {
  1003. mkdir('images/cache', 0777, true);
  1004. }
  1005. $image_url = $_GET['img'];
  1006. $key = $_GET['key'];
  1007. $image_height = $_GET['height'];
  1008. $image_width = $_GET['width'];
  1009. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  1010. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  1011. $cachefile = 'images/cache/'.$key.'.jpg';
  1012. $cachetime = 604800;
  1013. // Serve from the cache if it is younger than $cachetime
  1014. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
  1015. header("Content-type: image/jpeg");
  1016. @readfile($cachefile);
  1017. exit;
  1018. }
  1019. ob_start(); // Start the output buffer
  1020. header('Content-type: image/jpeg');
  1021. @readfile($image_src);
  1022. // Cache the output to a file
  1023. $fp = fopen($cachefile, 'wb');
  1024. fwrite($fp, ob_get_contents());
  1025. fclose($fp);
  1026. ob_end_flush(); // Send the output to the browser
  1027. die();
  1028. } else {
  1029. echo "Invalid Plex Request";
  1030. }
  1031. }
  1032. // Simplier access to class
  1033. function translate($string) {
  1034. if (isset($GLOBALS['language'])) {
  1035. return $GLOBALS['language']->translate($string);
  1036. } else {
  1037. return '!Translations Not Loaded!';
  1038. }
  1039. }
  1040. // Generate Random string
  1041. function randString($length = 10, $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {
  1042. $tmp = '';
  1043. for ($i = 0; $i < $length; $i++) {
  1044. $tmp .= substr(str_shuffle($chars), 0, 1);
  1045. }
  1046. return $tmp;
  1047. }
  1048. // Create config file in the return syntax
  1049. function createConfig($array, $path = 'config/config.php', $nest = 0) {
  1050. // Define Initial Value
  1051. $output = array();
  1052. // Sort Items
  1053. ksort($array);
  1054. // Update the current config version
  1055. if (!$nest) {
  1056. // Inject Current Version
  1057. $output[] = "\t'CONFIG_VERSION' => '".(isset($array['apply_CONFIG_VERSION'])?$array['apply_CONFIG_VERSION']:INSTALLEDVERSION)."'";
  1058. }
  1059. unset($array['CONFIG_VERSION']);
  1060. unset($array['apply_CONFIG_VERSION']);
  1061. // Process Settings
  1062. foreach ($array as $k => $v) {
  1063. $allowCommit = true;
  1064. switch (gettype($v)) {
  1065. case 'boolean':
  1066. $item = ($v?'true':'false');
  1067. break;
  1068. case 'integer':
  1069. case 'double':
  1070. case 'integer':
  1071. case 'NULL':
  1072. $item = $v;
  1073. break;
  1074. case 'string':
  1075. $item = "'".str_replace(array('\\',"'"),array('\\\\',"\'"),$v)."'";
  1076. break;
  1077. case 'array':
  1078. $item = createConfig($v, false, $nest+1);
  1079. break;
  1080. default:
  1081. $allowCommit = false;
  1082. }
  1083. if($allowCommit) {
  1084. $output[] = str_repeat("\t",$nest+1)."'$k' => $item";
  1085. }
  1086. }
  1087. // Build output
  1088. $output = (!$nest?"<?php\nreturn ":'')."array(\n".implode(",\n",$output)."\n".str_repeat("\t",$nest).')'.(!$nest?';':'');
  1089. if (!$nest && $path) {
  1090. $pathDigest = pathinfo($path);
  1091. @mkdir($pathDigest['dirname'], 0770, true);
  1092. if (file_exists($path)) {
  1093. rename($path, $pathDigest['dirname'].'/'.$pathDigest['filename'].'.bak.php');
  1094. }
  1095. $file = fopen($path, 'w');
  1096. fwrite($file, $output);
  1097. fclose($file);
  1098. if (file_exists($path)) {
  1099. return true;
  1100. }
  1101. writeLog("error", "config was unable to write");
  1102. return false;
  1103. } else {
  1104. writeLog("success", "config was updated with new values");
  1105. return $output;
  1106. }
  1107. }
  1108. // Load a config file written in the return syntax
  1109. function loadConfig($path = 'config/config.php') {
  1110. // Adapted from http://stackoverflow.com/a/14173339/6810513
  1111. if (!is_file($path)) {
  1112. return null;
  1113. } else {
  1114. return (array) call_user_func(function() use($path) {
  1115. return include($path);
  1116. });
  1117. }
  1118. }
  1119. // Commit new values to the configuration
  1120. function updateConfig($new, $current = false) {
  1121. // Get config if not supplied
  1122. if ($current === false) {
  1123. $current = loadConfig();
  1124. } else if (is_string($current) && is_file($current)) {
  1125. $current = loadConfig($current);
  1126. }
  1127. // Inject Parts
  1128. foreach ($new as $k => $v) {
  1129. $current[$k] = $v;
  1130. }
  1131. // Return Create
  1132. return createConfig($current);
  1133. }
  1134. // Inject Defaults As Needed
  1135. function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
  1136. if (is_string($path)) {
  1137. $loadedDefaults = loadConfig($path);
  1138. } else {
  1139. $loadedDefaults = $path;
  1140. }
  1141. return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
  1142. }
  1143. // support function for fillDefaultConfig()
  1144. function fillDefaultConfig_recurse($current, $defaults) {
  1145. foreach($defaults as $k => $v) {
  1146. if (!isset($current[$k])) {
  1147. $current[$k] = $v;
  1148. } else if (is_array($current[$k]) && is_array($v)) {
  1149. $current[$k] = fillDefaultConfig_recurse($current[$k], $v);
  1150. }
  1151. }
  1152. return $current;
  1153. };
  1154. // Define Scalar Variables (nest non-secular with underscores)
  1155. function defineConfig($array, $anyCase = true, $nest_prefix = false) {
  1156. foreach($array as $k => $v) {
  1157. if (is_scalar($v) && !defined($nest_prefix.$k)) {
  1158. define($nest_prefix.$k, $v, $anyCase);
  1159. } else if (is_array($v)) {
  1160. defineConfig($v, $anyCase, $nest_prefix.$k.'_');
  1161. }
  1162. }
  1163. }
  1164. // This function exists only because I am lazy
  1165. function configLazy($path = 'config/config.php') {
  1166. // Load config or default
  1167. if (file_exists($path)) {
  1168. $config = fillDefaultConfig(loadConfig($path));
  1169. } else {
  1170. $config = loadConfig('config/configDefaults.php');
  1171. }
  1172. if (is_array($config)) {
  1173. defineConfig($config);
  1174. }
  1175. return $config;
  1176. }
  1177. // Qualify URL
  1178. function qualifyURL($url) {
  1179. //local address?
  1180. if(substr($url, 0,1) == "/"){
  1181. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  1182. $protocol = "https://";
  1183. } else {
  1184. $protocol = "http://";
  1185. }
  1186. $url = $protocol.getServer().$url;
  1187. }
  1188. // Get Digest
  1189. $digest = parse_url($url);
  1190. // http/https
  1191. if (!isset($digest['scheme'])) {
  1192. if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096,32400,7878,8989,8182,8081,6789))) {
  1193. $scheme = 'http';
  1194. } else {
  1195. $scheme = 'https';
  1196. }
  1197. } else {
  1198. $scheme = $digest['scheme'];
  1199. }
  1200. // Host
  1201. $host = (isset($digest['host'])?$digest['host']:'');
  1202. // Port
  1203. $port = (isset($digest['port'])?':'.$digest['port']:'');
  1204. // Path
  1205. $path = (isset($digest['path'])?$digest['path']:'');
  1206. // Output
  1207. return $scheme.'://'.$host.$port.$path;
  1208. }
  1209. // Function to be called at top of each to allow upgrading environment as the spec changes
  1210. function upgradeCheck() {
  1211. // Upgrade to 1.31
  1212. if (file_exists('homepageSettings.ini.php')) {
  1213. $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
  1214. $homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
  1215. $databaseConfig = array_merge($databaseConfig, $homepageConfig);
  1216. $databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
  1217. foreach($databaseConfig as $k => $v) {
  1218. if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
  1219. $databaseData .= $k . " = \"" . $v . "\"\r\n";
  1220. }
  1221. write_ini_file($databaseData, 'databaseLocation.ini.php');
  1222. unlink('homepageSettings.ini.php');
  1223. unset($databaseData);
  1224. unset($homepageConfig);
  1225. }
  1226. // Upgrade to 1.32
  1227. if (file_exists('databaseLocation.ini.php')) {
  1228. // Load Existing
  1229. $config = parse_ini_file('databaseLocation.ini.php', true);
  1230. // Refactor
  1231. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['databaseLocation'].'/');
  1232. $config['user_home'] = $config['database_Location'].'users/';
  1233. unset($config['databaseLocation']);
  1234. // Turn Off Emby And Plex Recent
  1235. $config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
  1236. unset($config["embyPort"]);
  1237. $config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
  1238. unset($config["plexPort"]);
  1239. $config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
  1240. unset($config["nzbgetPort"]);
  1241. $config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
  1242. unset($config["sabnzbdPort"]);
  1243. $config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
  1244. unset($config["headphonesPort"]);
  1245. // Write config file
  1246. $config['CONFIG_VERSION'] = '1.32';
  1247. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][pre1.32].bak.php');
  1248. $createConfigSuccess = createConfig($config);
  1249. // Create new config
  1250. if ($createConfigSuccess) {
  1251. if (file_exists('config/config.php')) {
  1252. // Remove Old ini file
  1253. unlink('databaseLocation.ini.php');
  1254. } else {
  1255. debug_out('Something is not right here!');
  1256. }
  1257. } else {
  1258. debug_out('Couldn\'t create updated configuration.' ,1);
  1259. }
  1260. }
  1261. // Upgrade to 1.33
  1262. $config = loadConfig();
  1263. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
  1264. // Fix User Directory
  1265. $config['database_Location'] = preg_replace('/\/\/$/','/',$config['database_Location'].'/');
  1266. $config['user_home'] = $config['database_Location'].'users/';
  1267. unset($config['USER_HOME']);
  1268. // Backend auth merge
  1269. if (isset($config['authBackendPort']) && !isset(parse_url($config['authBackendHost'])['port'])) {
  1270. $config['authBackendHost'] .= ':'.$config['authBackendPort'];
  1271. }
  1272. unset($config['authBackendPort']);
  1273. // If auth is being used move it to embyURL as that is now used in auth functions
  1274. 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')))) {
  1275. $config['embyURL'] = $config['authBackendHost'];
  1276. }
  1277. // Upgrade database to latest version
  1278. updateSQLiteDB($config['database_Location'],'1.32');
  1279. // Update Version and Commit
  1280. $config['apply_CONFIG_VERSION'] = '1.33';
  1281. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.32].bak.php');
  1282. $createConfigSuccess = createConfig($config);
  1283. unset($config);
  1284. }
  1285. // Upgrade to 1.34
  1286. $config = loadConfig();
  1287. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.34')) {
  1288. // Upgrade database to latest version
  1289. updateSQLiteDB($config['database_Location'],'1.33');
  1290. // Update Version and Commit
  1291. $config['CONFIG_VERSION'] = '1.34';
  1292. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.33].bak.php');
  1293. $createConfigSuccess = createConfig($config);
  1294. unset($config);
  1295. }
  1296. // Upgrade to 1.40
  1297. $config = loadConfig();
  1298. if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.40')) {
  1299. // Upgrade database to latest version
  1300. updateSQLiteDB($config['database_Location'],'1.38');
  1301. // Update Version and Commit
  1302. $config['CONFIG_VERSION'] = '1.40';
  1303. copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.38].bak.php');
  1304. $createConfigSuccess = createConfig($config);
  1305. unset($config);
  1306. }
  1307. return true;
  1308. }
  1309. // Get OS from server
  1310. function getOS(){
  1311. if(PHP_SHLIB_SUFFIX == "dll"){
  1312. return "win";
  1313. }else{
  1314. return "nix";
  1315. }
  1316. }
  1317. //Get Error by Server OS
  1318. function getError($os, $error){
  1319. $ini = (!empty(php_ini_loaded_file()) ? php_ini_loaded_file() : "php.ini");
  1320. $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'");
  1321. $errors = array(
  1322. 'pdo_sqlite' => array(
  1323. 'win' => '<b>PDO:SQLite</b> not enabled, uncomment ;extension=php_pdo_sqlite.dll in the file php.ini | '.$ext,
  1324. 'nix' => '<b>PDO:SQLite</b> not enabled, PHP7 -> run sudo apt-get install php7.0-sqlite | PHP5 -> run sudo apt-get install php5-sqlite',
  1325. ),
  1326. 'sqlite3' => array(
  1327. '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',
  1328. 'nix' => '<b>SQLite3</b> not enabled, run sudo apt-get install php-sqlite3',
  1329. ),
  1330. 'curl' => array(
  1331. 'win' => '<b>cURL</b> not enabled, uncomment ;extension=php_curl.dll in the file php.ini | '.$ext,
  1332. 'nix' => '<b>cURL</b> not enabled, PHP7 -> sudo apt-get install php-curl | PHP5 -> run sudo apt-get install php5.6-curl',
  1333. ),
  1334. 'zip' => array(
  1335. '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',
  1336. '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',
  1337. ),
  1338. );
  1339. return (isset($errors[$error][$os]) ? $errors[$error][$os] : 'No Error Info Found');
  1340. }
  1341. // Check if all software dependancies are met
  1342. function dependCheck() {
  1343. $output = array();
  1344. $i = 1;
  1345. if (!extension_loaded('pdo_sqlite')) { $output["Step $i"] = getError(getOS(),'pdo_sqlite'); $i++; }
  1346. if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; }
  1347. if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; }
  1348. //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
  1349. if ($output) {
  1350. $output["Step $i"] = "<b>Restart PHP and/or Webserver to apply changes</b>"; $i++;
  1351. $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++;
  1352. debug_out($output,1);
  1353. }
  1354. return true;
  1355. }
  1356. // Process file uploads
  1357. function uploadFiles($path, $ext_mask = null) {
  1358. if (isset($_FILES) && count($_FILES)) {
  1359. require_once('class.uploader.php');
  1360. $uploader = new Uploader();
  1361. $data = $uploader->upload($_FILES['files'], array(
  1362. 'limit' => 10,
  1363. 'maxSize' => 10,
  1364. 'extensions' => $ext_mask,
  1365. 'required' => false,
  1366. 'uploadDir' => str_replace('//','/',$path.'/'),
  1367. 'title' => array('name'),
  1368. 'removeFiles' => true,
  1369. 'replace' => true,
  1370. ));
  1371. if($data['isComplete']){
  1372. $files = $data['data'];
  1373. writeLog("success", $files['metas'][0]['name']." was uploaded");
  1374. echo json_encode($files['metas'][0]['name']);
  1375. }
  1376. if($data['hasErrors']){
  1377. $errors = $data['errors'];
  1378. writeLog("error", $files['metas'][0]['name']." was not able to upload");
  1379. echo json_encode($errors);
  1380. }
  1381. } else {
  1382. writeLog("error", "image was not uploaded");
  1383. echo json_encode('No files submitted!');
  1384. }
  1385. }
  1386. // Remove file
  1387. function removeFiles($path) {
  1388. if(is_file($path)) {
  1389. writeLog("success", "image was removed");
  1390. unlink($path);
  1391. } else {
  1392. writeLog("error", "image was not removed");
  1393. echo json_encode('No file specified for removal!');
  1394. }
  1395. }
  1396. // Lazy select options
  1397. function resolveSelectOptions($array, $selected = '', $multi = false) {
  1398. $output = array();
  1399. $selectedArr = ($multi?explode('|', $selected):array());
  1400. foreach ($array as $key => $value) {
  1401. if (is_array($value)) {
  1402. if (isset($value['optgroup'])) {
  1403. $output[] = '<optgroup label="'.$key.'">';
  1404. foreach($value['optgroup'] as $k => $v) {
  1405. $output[] = '<option value="'.$v['value'].'"'.($selected===$v['value']||in_array($v['value'],$selectedArr)?' selected':'').(isset($v['disabled']) && $v['disabled']?' disabled':'').'>'.$k.'</option>';
  1406. }
  1407. } else {
  1408. $output[] = '<option value="'.$value['value'].'"'.($selected===$value['value']||in_array($value['value'],$selectedArr)?' selected':'').(isset($value['disabled']) && $value['disabled']?' disabled':'').'>'.$key.'</option>';
  1409. }
  1410. } else {
  1411. $output[] = '<option value="'.$value.'"'.($selected===$value||in_array($value,$selectedArr)?' selected':'').'>'.$key.'</option>';
  1412. }
  1413. }
  1414. return implode('',$output);
  1415. }
  1416. // Check if user is allowed to continue
  1417. function qualifyUser($type, $errOnFail = false) {
  1418. if (!isset($GLOBALS['USER'])) {
  1419. require_once("user.php");
  1420. $GLOBALS['USER'] = new User('registration_callback');
  1421. }
  1422. if (is_bool($type)) {
  1423. if ($type === true) {
  1424. $authorized = ($GLOBALS['USER']->authenticated == true);
  1425. } else {
  1426. $authorized = true;
  1427. }
  1428. } elseif (is_string($type) || is_array($type)) {
  1429. if ($type !== 'false') {
  1430. if (!is_array($type)) {
  1431. $type = explode('|',$type);
  1432. }
  1433. $authorized = ($GLOBALS['USER']->authenticated && in_array($GLOBALS['USER']->role,$type));
  1434. } else {
  1435. $authorized = true;
  1436. }
  1437. } else {
  1438. debug_out('Invalid Syntax!',1);
  1439. }
  1440. if (!$authorized && $errOnFail) {
  1441. if ($GLOBALS['USER']->authenticated) {
  1442. header('Location: '.dirname($_SERVER['SCRIPT_NAME']).'error.php?error=401');
  1443. echo '<script>window.location.href = \''.dirname($_SERVER['SCRIPT_NAME']).'error.php?error=401\'</script>';
  1444. } else {
  1445. header('Location: '.dirname($_SERVER['SCRIPT_NAME']).'error.php?error=999');
  1446. echo '<script>window.location.href = \''.dirname($_SERVER['SCRIPT_NAME']).'error.php?error=999\'</script>';
  1447. }
  1448. debug_out('Not Authorized' ,1);
  1449. } else {
  1450. return $authorized;
  1451. }
  1452. }
  1453. // Build an (optionally) tabbed settings page.
  1454. function buildSettings($array) {
  1455. /*
  1456. array(
  1457. 'title' => '',
  1458. 'id' => '',
  1459. 'fields' => array( See buildField() ),
  1460. 'tabs' => array(
  1461. array(
  1462. 'title' => '',
  1463. 'id' => '',
  1464. 'image' => '',
  1465. 'fields' => array( See buildField() ),
  1466. ),
  1467. ),
  1468. );
  1469. */
  1470. $notifyExplode = explode("-", NOTIFYEFFECT);
  1471. $fieldFunc = function($fieldArr) {
  1472. $fields = '<div class="row">';
  1473. foreach($fieldArr as $key => $value) {
  1474. $isSingle = isset($value['type']);
  1475. if ($isSingle) { $value = array($value); }
  1476. $tmpField = '';
  1477. $sizeLg = max(floor(12/count($value)),2);
  1478. $sizeMd = max(floor(($isSingle?12:6)/count($value)),3);
  1479. foreach($value as $k => $v) {
  1480. $tmpField .= buildField($v, 12, $sizeMd, $sizeLg);
  1481. }
  1482. $fields .= ($isSingle?$tmpField:'<div class="row col-sm-12 content-form">'.$tmpField.'</div>');
  1483. }
  1484. $fields .= '</div>';
  1485. return $fields;
  1486. };
  1487. $fields = (isset($array['fields'])?$fieldFunc($array['fields']):'');
  1488. $tabSelectors = array();
  1489. $tabContent = array();
  1490. if (isset($array['tabs'])) {
  1491. foreach($array['tabs'] as $key => $value) {
  1492. $id = (isset($value['id'])?$value['id']:randString(32));
  1493. $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>';
  1494. $tabContent[$key] = '<div class="tab-pane big-box fade'.($tabContent?'':' active in').'" id="tab-'.$id.'">'.$fieldFunc($value['fields']).'</div>';
  1495. }
  1496. }
  1497. $pageID = (isset($array['id'])?$array['id']:str_replace(array(' ','"',"'"),array('_'),strtolower($array['id'])));
  1498. return '
  1499. <div class="email-body">
  1500. <div class="email-header gray-bg">
  1501. <button type="button" class="btn btn-danger btn-sm waves close-button"><i class="fa fa-close"></i></button>
  1502. <h1>'.$array['title'].'</h1>
  1503. </div>
  1504. <div class="email-inner small-box">
  1505. <div class="email-inner-section">
  1506. <div class="small-box fade in" id="'.$pageID.'_frame">
  1507. <div class="col-lg-12">
  1508. '.(isset($array['customBeforeForm'])?$array['customBeforeForm']:'').'
  1509. <form class="content-form" name="'.$pageID.'" id="'.$pageID.'_form" onsubmit="return false;">
  1510. <button id="'.$pageID.'_form_submit" class="btn waves btn-labeled btn-success btn btn-sm pull-right text-uppercase waves-effect waves-float">
  1511. <span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save
  1512. </button>
  1513. '.$fields.($tabContent?'
  1514. <div class="tabbable tabs-with-bg" id="'.$pageID.'_tabs">
  1515. <ul class="nav nav-tabs apps">
  1516. '.implode('', $tabSelectors).'
  1517. </ul>
  1518. <div class="clearfix"></div>
  1519. <div class="tab-content">
  1520. '.implode('', $tabContent).'
  1521. </div>
  1522. </div>':'').'
  1523. </form>
  1524. '.(isset($array['customAfterForm'])?$array['customAfterForm']:'').'
  1525. </div>
  1526. </div>
  1527. </div>
  1528. </div>
  1529. </div>
  1530. <script>
  1531. $(document).ready(function() {
  1532. $(\'#'.$pageID.'_form\').find(\'input, select, textarea\').on(\'change\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1533. var '.$pageID.'Validate = function() { if (this.value && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { $(this).addClass(\'invalid\'); } else { $(this).removeClass(\'invalid\'); } };
  1534. $(\'#'.$pageID.'_form\').find(\'input[pattern]\').each('.$pageID.'Validate).on(\'keyup\', '.$pageID.'Validate);
  1535. $(\'#'.$pageID.'_form\').find(\'select[multiple]\').on(\'change click\', function() { $(this).attr(\'data-changed\', \'true\'); });
  1536. $(\'#'.$pageID.'_form_submit\').on(\'click\', function () {
  1537. var newVals = {};
  1538. var hasVals = false;
  1539. var errorFields = [];
  1540. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').each(function() {
  1541. hasVals = true;
  1542. if (this.type == \'checkbox\') {
  1543. newVals[this.name] = this.checked;
  1544. } else if ($(this).hasClass(\'summernote\')) {
  1545. newVals[$(this).attr(\'name\')] = $(this).siblings(\'.note-editor\').find(\'.panel-body\').html();
  1546. } else {
  1547. if (this.value && this.pattern && !RegExp(\'^\'+this.pattern+\'$\').test(this.value)) { errorFields.push(this.name); }
  1548. var fieldVal = $(this).val();
  1549. if (typeof fieldVal == \'object\') {
  1550. if (typeof fieldVal.join == \'function\') {
  1551. fieldVal = fieldVal.join(\'|\');
  1552. } else {
  1553. fieldVal = JSON.stringify(fieldVal);
  1554. }
  1555. }
  1556. newVals[this.name] = fieldVal;
  1557. }
  1558. });
  1559. if (errorFields.length) {
  1560. parent.notify(\'Fields have errors: \'+errorFields.join(\', \')+\'!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1561. } else if (hasVals) {
  1562. console.log(newVals);
  1563. ajax_request(\'POST\', \''.(isset($array['submitAction'])?$array['submitAction']:'update-config').'\', newVals, function(data, code) {
  1564. $(\'#'.$pageID.'_form\').find(\'[data-changed=true][name]\').removeAttr(\'data-changed\');
  1565. });
  1566. } else {
  1567. parent.notify(\'Nothing to update!\', \'bullhorn\', \'error\', 5000, \''.$notifyExplode[0].'\', \''.$notifyExplode[1].'\');
  1568. }
  1569. return false;
  1570. });
  1571. '.(isset($array['onready'])?$array['onready']:'').'
  1572. });
  1573. </script>
  1574. ';
  1575. }
  1576. // Build Settings Fields
  1577. function buildField($params, $sizeSm = 12, $sizeMd = 12, $sizeLg = 12) {
  1578. /*
  1579. array(
  1580. 'type' => '',
  1581. 'placeholder' => '',
  1582. 'label' => '',
  1583. 'labelTranslate' => '',
  1584. 'assist' => '',
  1585. 'name' => '',
  1586. 'pattern' => '',
  1587. 'options' => array( // For SELECT only
  1588. 'Display' => 'value',
  1589. ),
  1590. )
  1591. */
  1592. // Tags
  1593. $tags = array();
  1594. foreach(array('placeholder','style','disabled','readonly','pattern','min','max','required','onkeypress','onchange','onfocus','onleave','href','onclick') as $value) {
  1595. if (isset($params[$value])) {
  1596. if (is_string($params[$value])) { $tags[] = $value.'="'.$params[$value].'"';
  1597. } else if ($params[$value] === true) { $tags[] = $value; }
  1598. }
  1599. }
  1600. $format = (isset($params['format']) && in_array($params['format'],array(false,'colour','color'))?$params['format']:false);
  1601. $name = (isset($params['name'])?$params['name']:(isset($params['id'])?$params['id']:''));
  1602. $id = (isset($params['id'])?$params['id']:(isset($params['name'])?$params['name'].'_id':randString(32)));
  1603. $val = (isset($params['value'])?$params['value']:'');
  1604. $class = (isset($params['class'])?' '.$params['class']:'');
  1605. $wrapClass = (isset($params['wrapClass'])?$params['wrapClass']:'form-content');
  1606. $assist = (isset($params['assist'])?' - i.e. '.$params['assist']:'');
  1607. $label = (isset($params['labelTranslate'])?translate($params['labelTranslate']):(isset($params['label'])?$params['label']:''));
  1608. $labelOut = '<p class="help-text">'.$label.$assist.'</p>';
  1609. // Field Design
  1610. switch ($params['type']) {
  1611. case 'text':
  1612. case 'number':
  1613. case 'password':
  1614. $field = '<input id="'.$id.'" name="'.$name.'" type="'.$params['type'].'" class="form-control material input-sm'.$class.'" '.implode(' ',$tags).' autocorrect="off" autocapitalize="off" value="'.$val.'">';
  1615. break;
  1616. case 'select':
  1617. case 'dropdown':
  1618. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control material input-sm" '.implode(' ',$tags).'>'.resolveSelectOptions($params['options'], $val).'</select>';
  1619. break;
  1620. case 'select-multi':
  1621. case 'dropdown-multi':
  1622. $field = '<select id="'.$id.'" name="'.$name.'" class="form-control input-sm" '.implode(' ',$tags).' multiple="multiple">'.resolveSelectOptions($params['options'], $val, true).'</select>';
  1623. break;
  1624. case 'check':
  1625. case 'checkbox':
  1626. case 'toggle':
  1627. $checked = ((is_bool($val) && $val) || trim($val) === 'true'?' checked':'');
  1628. $colour = (isset($params['colour'])?$params['colour']:'success');
  1629. $labelOut = '<label for="'.$id.'"></label>'.$label;
  1630. $field = '<input id="'.$id.'" name="'.$name.'" type="checkbox" class="switcher switcher-'.$colour.' '.$class.'" '.implode(' ',$tags).' data-value="'.$val.'"'.$checked.'>';
  1631. break;
  1632. case 'radio':
  1633. $labelOut = '';
  1634. $checked = ((is_bool($val) && $val) || ($val && trim($val) !== 'false')?' checked':'');
  1635. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1636. $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>';
  1637. break;
  1638. case 'date':
  1639. $field = 'Unsupported, planned.';
  1640. break;
  1641. case 'hidden':
  1642. return '<input id="'.$id.'" name="'.$name.'" type="hidden" class="'.$class.'" '.implode(' ',$tags).' value="'.$val.'">';
  1643. break;
  1644. case 'header':
  1645. $labelOut = '';
  1646. $headType = (isset($params['value'])?$params['value']:3);
  1647. $field = '<h'.$headType.' class="'.$class.'" '.implode(' ',$tags).'>'.$label.'</h'.$headType.'>';
  1648. break;
  1649. case 'button':
  1650. $labelOut = '';
  1651. $icon = (isset($params['icon'])?$params['icon']:'flask');
  1652. $bType = (isset($params['buttonType'])?$params['buttonType']:'success');
  1653. $bDropdown = (isset($params['buttonDrop'])?$params['buttonDrop']:'');
  1654. $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>'.$label.'</button>'.($bDropdown?$bDropdown.'</div>':'');
  1655. break;
  1656. case 'textarea':
  1657. $rows = (isset($params['rows'])?$params['rows']:5);
  1658. $field = '<textarea id="'.$id.'" name="'.$name.'" class="form-control'.$class.'" rows="'.$rows.'" '.implode(' ',$tags).'>'.$val.'</textarea>';
  1659. break;
  1660. case 'custom':
  1661. // Settings
  1662. $settings = array(
  1663. '$id' => $id,
  1664. '$name' => $name,
  1665. '$val' => $val,
  1666. '$label' => $label,
  1667. '$labelOut' => $labelOut,
  1668. );
  1669. // Get HTML
  1670. $html = (isset($params['html'])?$params['html']:'Nothing Specified!');
  1671. // If LabelOut is in html dont print it twice
  1672. $labelOut = (strpos($html,'$label')!==false?'':$labelOut);
  1673. // Replace variables in settings
  1674. $html = preg_replace_callback('/\$\w+\b/', function ($match) use ($settings) { return (isset($settings[$match[0]])?$settings[$match[0]]:'{'.$match[0].' is undefined}'); }, $html);
  1675. // Build Field
  1676. $field = '<div id="'.$id.'_html" class="custom-field">'.$html.'</div>';
  1677. break;
  1678. case 'space':
  1679. $labelOut = '';
  1680. $field = str_repeat('<br>', (isset($params['value'])?$params['value']:1));
  1681. break;
  1682. default:
  1683. $field = 'Unsupported field type';
  1684. break;
  1685. }
  1686. // Field Formats
  1687. switch ($format) {
  1688. case 'colour': // Fuckin Eh, Canada!
  1689. case 'color':
  1690. $labelBef = '<center>'.$label.'</center>';
  1691. $wrapClass = 'gray-bg colour-field';
  1692. $labelAft = '';
  1693. $field = str_replace(' material input-sm','',$field);
  1694. break;
  1695. default:
  1696. $labelBef = '';
  1697. $labelAft = $labelOut;
  1698. }
  1699. return '<div class="'.$wrapClass.' col-sm-'.$sizeSm.' col-md-'.$sizeMd.' col-lg-'.$sizeLg.'">'.$labelBef.$field.$labelAft.'</div>';
  1700. }
  1701. // Tab Settings Generation
  1702. function printTabRow($data) {
  1703. $hidden = false;
  1704. if ($data===false) {
  1705. $hidden = true;
  1706. $data = array( // New Tab Defaults
  1707. 'id' => 'new',
  1708. 'name' => '',
  1709. 'url' => '',
  1710. 'icon' => 'fa-diamond',
  1711. 'iconurl' => '',
  1712. 'active' => 'true',
  1713. 'user' => 'true',
  1714. 'guest' => 'true',
  1715. 'window' => 'false',
  1716. 'defaultz' => '',
  1717. );
  1718. }
  1719. $image = '<span style="font: normal normal normal 30px/1 FontAwesome;" class="fa fa-hand-paper-o"></span>';
  1720. $output = '
  1721. <li id="tab-'.$data['id'].'" class="list-group-item" style="position: relative; left: 0px; top: 0px; '.($hidden?' display: none;':'').'">
  1722. <tab class="content-form form-inline">
  1723. <div class="row">
  1724. '.buildField(array(
  1725. 'type' => 'custom',
  1726. '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>',
  1727. ),12,1,1).'
  1728. '.buildField(array(
  1729. 'type' => 'hidden',
  1730. 'id' => 'tab-'.$data['id'].'-id',
  1731. 'name' => 'id['.$data['id'].']',
  1732. 'value' => $data['id'],
  1733. ),12,2,1).'
  1734. '.buildField(array(
  1735. 'type' => 'text',
  1736. 'id' => 'tab-'.$data['id'].'-name',
  1737. 'name' => 'name['.$data['id'].']',
  1738. 'required' => true,
  1739. 'placeholder' => 'Organizr Homepage',
  1740. 'labelTranslate' => 'TAB_NAME',
  1741. 'value' => $data['name'],
  1742. ),12,2,1).'
  1743. '.buildField(array(
  1744. 'type' => 'text',
  1745. 'id' => 'tab-'.$data['id'].'-url',
  1746. 'name' => 'url['.$data['id'].']',
  1747. 'required' => true,
  1748. 'placeholder' => 'homepage.php',
  1749. 'labelTranslate' => 'TAB_URL',
  1750. 'value' => $data['url'],
  1751. ),12,2,1).'
  1752. '.buildField(array(
  1753. 'type' => 'text',
  1754. 'id' => 'tab-'.$data['id'].'-iconurl',
  1755. 'name' => 'iconurl['.$data['id'].']',
  1756. 'placeholder' => 'images/organizr.png',
  1757. 'labelTranslate' => 'ICON_URL',
  1758. 'value' => $data['iconurl'],
  1759. ),12,2,1).'
  1760. '.buildField(array(
  1761. 'type' => 'custom',
  1762. 'id' => 'tab-'.$data['id'].'-icon',
  1763. 'name' => 'icon['.$data['id'].']',
  1764. 'html' => '- '.translate('OR').' - <div class="input-group"><input data-placement="bottomRight" class="form-control material icp-auto'.($hidden?'-pend':'').'" id="$id" name="$name" value="$val" type="text" /><span class="input-group-addon"></span></div>',
  1765. 'value' => $data['icon'],
  1766. ),12,1,1).'
  1767. '.buildField(array(
  1768. 'type' => 'checkbox',
  1769. 'labelTranslate' => 'ACTIVE',
  1770. 'name' => 'active['.$data['id'].']',
  1771. 'value' => $data['active'],
  1772. ),12,1,1).'
  1773. '.buildField(array(
  1774. 'type' => 'checkbox',
  1775. 'labelTranslate' => 'USER',
  1776. 'colour' => 'primary',
  1777. 'name' => 'user['.$data['id'].']',
  1778. 'value' => $data['user'],
  1779. ),12,1,1).'
  1780. '.buildField(array(
  1781. 'type' => 'checkbox',
  1782. 'labelTranslate' => 'GUEST',
  1783. 'colour' => 'warning',
  1784. 'name' => 'guest['.$data['id'].']',
  1785. 'value' => $data['guest'],
  1786. ),12,1,1).'
  1787. '.buildField(array(
  1788. 'type' => 'checkbox',
  1789. 'labelTranslate' => 'NO_IFRAME',
  1790. 'colour' => 'danger',
  1791. 'name' => 'window['.$data['id'].']',
  1792. 'value' => $data['window'],
  1793. ),12,1,1).'
  1794. '.buildField(array(
  1795. 'type' => 'radio',
  1796. 'labelTranslate' => 'DEFAULT',
  1797. 'name' => 'defaultz['.$data['id'].']',
  1798. 'value' => $data['defaultz'],
  1799. 'onclick' => "$('[type=radio][id!=\''+this.id+'\']').each(function() { this.checked=false; });",
  1800. ),12,1,1).'
  1801. '.buildField(array(
  1802. 'type' => 'button',
  1803. 'icon' => 'trash',
  1804. 'buttonType' => 'danger',
  1805. 'labelTranslate' => 'REMOVE',
  1806. 'onclick' => "$(this).parents('li').remove();",
  1807. ),12,1,1).'
  1808. </div>
  1809. </tab>
  1810. </li>
  1811. ';
  1812. return $output;
  1813. }
  1814. // Timezone array
  1815. function timezoneOptions() {
  1816. $output = array();
  1817. $timezones = array();
  1818. $regions = array(
  1819. 'Africa' => DateTimeZone::AFRICA,
  1820. 'America' => DateTimeZone::AMERICA,
  1821. 'Antarctica' => DateTimeZone::ANTARCTICA,
  1822. 'Arctic' => DateTimeZone::ARCTIC,
  1823. 'Asia' => DateTimeZone::ASIA,
  1824. 'Atlantic' => DateTimeZone::ATLANTIC,
  1825. 'Australia' => DateTimeZone::AUSTRALIA,
  1826. 'Europe' => DateTimeZone::EUROPE,
  1827. 'Indian' => DateTimeZone::INDIAN,
  1828. 'Pacific' => DateTimeZone::PACIFIC
  1829. );
  1830. foreach ($regions as $name => $mask) {
  1831. $zones = DateTimeZone::listIdentifiers($mask);
  1832. foreach($zones as $timezone) {
  1833. $time = new DateTime(NULL, new DateTimeZone($timezone));
  1834. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  1835. $output[$name]['optgroup'][substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm]['value'] = $timezone;
  1836. }
  1837. }
  1838. return $output;
  1839. }
  1840. // Build Database
  1841. function createSQLiteDB($path = false) {
  1842. if ($path === false) {
  1843. if (DATABASE_LOCATION){
  1844. $path = DATABASE_LOCATION;
  1845. } else {
  1846. debug_out('No Path Specified!');
  1847. }
  1848. }
  1849. if (!is_file($path.'users.db') || filesize($path.'users.db') <= 0) {
  1850. if (!isset($GLOBALS['file_db'])) {
  1851. $GLOBALS['file_db'] = new PDO('sqlite:'.$path.'users.db');
  1852. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  1853. }
  1854. // Create Users
  1855. $users = $GLOBALS['file_db']->query('CREATE TABLE `users` (
  1856. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  1857. `username` TEXT UNIQUE,
  1858. `password` TEXT,
  1859. `email` TEXT,
  1860. `token` TEXT,
  1861. `role` TEXT,
  1862. `active` TEXT,
  1863. `last` TEXT,
  1864. `auth_service` TEXT DEFAULT \'internal\'
  1865. );');
  1866. // Create Tabs
  1867. $tabs = $GLOBALS['file_db']->query('CREATE TABLE `tabs` (
  1868. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  1869. `order` INTEGER,
  1870. `users_id` INTEGER,
  1871. `name` TEXT,
  1872. `url` TEXT,
  1873. `defaultz` TEXT,
  1874. `active` TEXT,
  1875. `user` TEXT,
  1876. `guest` TEXT,
  1877. `icon` TEXT,
  1878. `iconurl` TEXT,
  1879. `window` TEXT
  1880. );');
  1881. // Create Options
  1882. $options = $GLOBALS['file_db']->query('CREATE TABLE `options` (
  1883. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  1884. `users_id` INTEGER UNIQUE,
  1885. `title` TEXT UNIQUE,
  1886. `topbar` TEXT,
  1887. `bottombar` TEXT,
  1888. `sidebar` TEXT,
  1889. `hoverbg` TEXT,
  1890. `topbartext` TEXT,
  1891. `activetabBG` TEXT,
  1892. `activetabicon` TEXT,
  1893. `activetabtext` TEXT,
  1894. `inactiveicon` TEXT,
  1895. `inactivetext` TEXT,
  1896. `loading` TEXT,
  1897. `hovertext` TEXT
  1898. );');
  1899. // Create Invites
  1900. $invites = $GLOBALS['file_db']->query('CREATE TABLE `invites` (
  1901. `id` INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
  1902. `code` TEXT UNIQUE,
  1903. `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  1904. `email` TEXT,
  1905. `username` TEXT,
  1906. `dateused` TIMESTAMP,
  1907. `usedby` TEXT,
  1908. `ip` TEXT,
  1909. `valid` TEXT
  1910. );');
  1911. writeLog("success", "database created/saved");
  1912. return $users && $tabs && $options && $invites;
  1913. } else {
  1914. writeLog("error", "database was unable to be created/saved");
  1915. return false;
  1916. }
  1917. }
  1918. // Upgrade Database
  1919. function updateSQLiteDB($db_path = false, $oldVerNum = false) {
  1920. if (!$db_path) {
  1921. if (defined('DATABASE_LOCATION')) {
  1922. $db_path = DATABASE_LOCATION;
  1923. } else {
  1924. debug_out('No Path Specified',1);
  1925. }
  1926. }
  1927. if (!isset($GLOBALS['file_db'])) {
  1928. $GLOBALS['file_db'] = new PDO('sqlite:'.$db_path.'users.db');
  1929. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  1930. }
  1931. // Cache current DB
  1932. $cache = array();
  1933. foreach($GLOBALS['file_db']->query('SELECT name FROM sqlite_master WHERE type="table";') as $table) {
  1934. foreach($GLOBALS['file_db']->query('SELECT * FROM '.$table['name'].';') as $key => $row) {
  1935. foreach($row as $k => $v) {
  1936. if (is_string($k)) {
  1937. $cache[$table['name']][$key][$k] = $v;
  1938. }
  1939. }
  1940. }
  1941. }
  1942. // Remove Current Database
  1943. $GLOBALS['file_db'] = null;
  1944. $pathDigest = pathinfo($db_path.'users.db');
  1945. if (file_exists($db_path.'users.db')) {
  1946. rename($db_path.'users.db', $pathDigest['dirname'].'/'.$pathDigest['filename'].'['.date('Y-m-d_H-i-s').']'.($oldVerNum?'['.$oldVerNum.']':'').'.bak.db');
  1947. }
  1948. // Create New Database
  1949. $success = createSQLiteDB($db_path);
  1950. // Restore Items
  1951. if ($success) {
  1952. foreach($cache as $table => $tableData) {
  1953. if ($tableData) {
  1954. $queryBase = 'INSERT INTO '.$table.' (`'.implode('`,`',array_keys(current($tableData))).'`) values ';
  1955. $insertValues = array();
  1956. reset($tableData);
  1957. foreach($tableData as $key => $value) {
  1958. $insertValues[] = '('.implode(',',array_map(function($d) {
  1959. return (isset($d)?$GLOBALS['file_db']->quote($d):'null');
  1960. }, $value)).')';
  1961. }
  1962. $GLOBALS['file_db']->query($queryBase.implode(',',$insertValues).';');
  1963. }
  1964. }
  1965. writeLog("success", "database values have been updated");
  1966. return true;
  1967. } else {
  1968. writeLog("error", "database values unable to be updated");
  1969. return false;
  1970. }
  1971. }
  1972. // Commit colours to database
  1973. function updateDBOptions($values) {
  1974. if (!isset($GLOBALS['file_db'])) {
  1975. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  1976. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  1977. }
  1978. // Commit new values to database
  1979. if ($GLOBALS['file_db']->query('UPDATE options SET '.implode(',',array_map(function($d, $k) {
  1980. return '`'.$k.'` = '.(isset($d)?"'".addslashes($d)."'":'null');
  1981. }, $values, array_keys($values))).';')->rowCount()) {
  1982. return true;
  1983. } else if ($GLOBALS['file_db']->query('INSERT OR IGNORE INTO options (`'.implode('`,`',array_keys($values)).'`) VALUES (\''.implode("','",$values).'\');')->rowCount()) {
  1984. writeLog("success", "database values for options table have been updated");
  1985. return true;
  1986. } else {
  1987. writeLog("error", "database values for options table unable to be updated");
  1988. return false;
  1989. }
  1990. }
  1991. // Send AJAX notification
  1992. function sendNotification($success, $message = false, $send = true) {
  1993. $notifyExplode = explode("-", NOTIFYEFFECT);
  1994. if ($success) {
  1995. $msg = array(
  1996. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_SAVED").'</strong>'),
  1997. 'icon' => 'floppy-o',
  1998. 'type' => 'success',
  1999. 'length' => '5000',
  2000. 'layout' => $notifyExplode[0],
  2001. 'effect' => $notifyExplode[1],
  2002. );
  2003. } else {
  2004. $msg = array(
  2005. 'html' => ($message?''.$message:'<strong>'.translate("SETTINGS_NOT_SAVED").'</strong>'),
  2006. 'icon' => 'floppy-o',
  2007. 'type' => 'failed',
  2008. 'length' => '5000',
  2009. 'layout' => $notifyExplode[0],
  2010. 'effect' => $notifyExplode[1],
  2011. );
  2012. }
  2013. // Send and kill script?
  2014. if ($send) {
  2015. header('Content-Type: application/json');
  2016. echo json_encode(array('notify'=>$msg));
  2017. die();
  2018. }
  2019. return $msg;
  2020. }
  2021. // Load colours from the database
  2022. function loadAppearance() {
  2023. // Defaults
  2024. $defaults = array(
  2025. 'title' => 'Organizr',
  2026. 'topbartext' => '#66D9EF',
  2027. 'topbar' => '#333333',
  2028. 'bottombar' => '#333333',
  2029. 'sidebar' => '#393939',
  2030. 'hoverbg' => '#AD80FD',
  2031. 'activetabBG' => '#F92671',
  2032. 'activetabicon' => '#FFFFFF',
  2033. 'activetabtext' => '#FFFFFF',
  2034. 'inactiveicon' => '#66D9EF',
  2035. 'inactivetext' => '#66D9EF',
  2036. 'loading' => '#66D9EF',
  2037. 'hovertext' => '#000000',
  2038. );
  2039. if (DATABASE_LOCATION) {
  2040. if(is_file(DATABASE_LOCATION.'users.db') && filesize(DATABASE_LOCATION.'users.db') > 0){
  2041. if (!isset($GLOBALS['file_db'])) {
  2042. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2043. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2044. }
  2045. // Database Lookup
  2046. $options = $GLOBALS['file_db']->query('SELECT * FROM options');
  2047. // Replace defaults with filled options
  2048. foreach($options as $row) {
  2049. foreach($defaults as $key => $value) {
  2050. if (isset($row[$key]) && $row[$key]) {
  2051. $defaults[$key] = $row[$key];
  2052. }
  2053. }
  2054. }
  2055. }
  2056. }
  2057. // Return the Results
  2058. return $defaults;
  2059. }
  2060. // Delete Database
  2061. function deleteDatabase() {
  2062. unset($_COOKIE['Organizr']);
  2063. setcookie('Organizr', '', time() - 3600, '/');
  2064. unset($_COOKIE['OrganizrU']);
  2065. setcookie('OrganizrU', '', time() - 3600, '/');
  2066. $GLOBALS['file_db'] = null;
  2067. unlink(DATABASE_LOCATION.'users.db');
  2068. foreach(glob(substr_replace($userdirpath, "", -1).'/*') as $file) {
  2069. if(is_dir($file)) {
  2070. rmdir($file);
  2071. } elseif (!is_dir($file)) {
  2072. unlink($file);
  2073. }
  2074. }
  2075. rmdir($userdirpath);
  2076. writeLog("success", "database has been deleted");
  2077. return true;
  2078. }
  2079. // Upgrade the installation
  2080. function upgradeInstall($branch = 'master') {
  2081. function downloadFile($url, $path){
  2082. ini_set('max_execution_time',0);
  2083. $folderPath = "upgrade/";
  2084. if(!mkdir($folderPath)){
  2085. writeLog("error", "organizr could not create upgrade folder");
  2086. }
  2087. $newfname = $folderPath . $path;
  2088. $file = fopen ($url, 'rb');
  2089. if ($file) {
  2090. $newf = fopen ($newfname, 'wb');
  2091. if ($newf) {
  2092. while(!feof($file)) {
  2093. fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
  2094. }
  2095. }
  2096. }else{
  2097. writeLog("error", "organizr could not download $url");
  2098. }
  2099. if ($file) {
  2100. fclose($file);
  2101. writeLog("success", "organizr finished downloading the github zip file");
  2102. }else{
  2103. writeLog("error", "organizr could not download the github zip file");
  2104. }
  2105. if ($newf) {
  2106. fclose($newf);
  2107. writeLog("success", "organizr created upgrade zip file from github zip file");
  2108. }else{
  2109. writeLog("error", "organizr could not create upgrade zip file from github zip file");
  2110. }
  2111. }
  2112. function unzipFile($zipFile){
  2113. $zip = new ZipArchive;
  2114. $extractPath = "upgrade/";
  2115. if($zip->open($extractPath . $zipFile) != "true"){
  2116. writeLog("error", "organizr could not unzip upgrade.zip");
  2117. }else{
  2118. writeLog("success", "organizr unzipped upgrade.zip");
  2119. }
  2120. /* Extract Zip File */
  2121. $zip->extractTo($extractPath);
  2122. $zip->close();
  2123. }
  2124. // Function to remove folders and files
  2125. function rrmdir($dir) {
  2126. if (is_dir($dir)) {
  2127. $files = scandir($dir);
  2128. foreach ($files as $file)
  2129. if ($file != "." && $file != "..") rrmdir("$dir/$file");
  2130. rmdir($dir);
  2131. }
  2132. else if (file_exists($dir)) unlink($dir);
  2133. }
  2134. // Function to Copy folders and files
  2135. function rcopy($src, $dst) {
  2136. if (is_dir ( $src )) {
  2137. if (!file_exists($dst)) : mkdir ( $dst ); endif;
  2138. $files = scandir ( $src );
  2139. foreach ( $files as $file )
  2140. if ($file != "." && $file != "..")
  2141. rcopy ( "$src/$file", "$dst/$file" );
  2142. } else if (file_exists ( $src ))
  2143. copy ( $src, $dst );
  2144. }
  2145. $url = 'https://github.com/causefx/Organizr/archive/'.$branch.'.zip';
  2146. $file = "upgrade.zip";
  2147. $source = __DIR__ . '/upgrade/Organizr-'.$branch.'/';
  2148. $cleanup = __DIR__ . "/upgrade/";
  2149. $destination = __DIR__ . "/";
  2150. writeLog("success", "starting organizr upgrade process");
  2151. downloadFile($url, $file);
  2152. unzipFile($file);
  2153. rcopy($source, $destination);
  2154. writeLog("success", "new organizr files copied");
  2155. rrmdir($cleanup);
  2156. writeLog("success", "organizr upgrade folder removed");
  2157. writeLog("success", "organizr has been updated");
  2158. return true;
  2159. }
  2160. // NzbGET Items
  2161. function nzbgetConnect($list = 'listgroups') {
  2162. $url = qualifyURL(NZBGETURL);
  2163. $api = curl_get($url.'/'.NZBGETUSERNAME.':'.NZBGETPASSWORD.'/jsonrpc/'.$list);
  2164. $api = json_decode($api, true);
  2165. $gotNZB = array();
  2166. if (is_array($api) || is_object($api)){
  2167. foreach ($api['result'] AS $child) {
  2168. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  2169. $downloadStatus = $child['Status'];
  2170. $downloadCategory = $child['Category'];
  2171. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  2172. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  2173. if($child['Health'] <= "750"){
  2174. $downloadHealth = "danger";
  2175. }elseif($child['Health'] <= "900"){
  2176. $downloadHealth = "warning";
  2177. }elseif($child['Health'] <= "1000"){
  2178. $downloadHealth = "success";
  2179. }
  2180. $gotNZB[] = '<tr>
  2181. <td class="col-xs-7 nzbtable-file-row">'.$downloadName.'</td>
  2182. <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
  2183. <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
  2184. <td class="col-xs-2 nzbtable nzbtable-row">
  2185. <div class="progress">
  2186. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2187. <p class="text-center">'.round($downloadPercent).'%</p>
  2188. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2189. </div>
  2190. </div>
  2191. </td>
  2192. </tr>';
  2193. }
  2194. if ($gotNZB) {
  2195. return implode('',$gotNZB);
  2196. } else {
  2197. return '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>';
  2198. }
  2199. }else{
  2200. writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Usernamd and Password - if HTTPS, is cert valid");
  2201. }
  2202. }
  2203. // Sabnzbd Items
  2204. function sabnzbdConnect($list = 'queue') {
  2205. $url = qualifyURL(SABNZBDURL);
  2206. $api = file_get_contents($url.'/api?mode='.$list.'&output=json&apikey='.SABNZBDKEY);
  2207. $api = json_decode($api, true);
  2208. $gotNZB = array();
  2209. foreach ($api[$list]['slots'] AS $child) {
  2210. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  2211. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  2212. $downloadStatus = $child['status'];
  2213. $gotNZB[] = '<tr>
  2214. <td>'.$downloadName.'</td>
  2215. <td>'.$downloadStatus.'</td>
  2216. <td>'.$downloadCategory.'</td>
  2217. <td>
  2218. <div class="progress">
  2219. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  2220. <p class="text-center">'.round($downloadPercent).'%</p>
  2221. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  2222. </div>
  2223. </div>
  2224. </td>
  2225. </tr>';
  2226. }
  2227. if ($gotNZB) {
  2228. return implode('',$gotNZB);
  2229. } else {
  2230. return '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>';
  2231. }
  2232. }
  2233. // Apply new tab settings
  2234. function updateTabs($tabs) {
  2235. if (!isset($GLOBALS['file_db'])) {
  2236. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  2237. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2238. }
  2239. // Validate
  2240. if (!isset($tabs['defaultz'])) { $tabs['defaultz'][current(array_keys($tabs['name']))] = 'true'; }
  2241. if (isset($tabs['name']) && isset($tabs['url']) && is_array($tabs['name'])) {
  2242. // Clear Existing Tabs
  2243. $GLOBALS['file_db']->query("DELETE FROM tabs");
  2244. // Process New Tabs
  2245. $totalValid = 0;
  2246. foreach ($tabs['name'] as $key => $value) {
  2247. // Qualify
  2248. if (!$value || !isset($tabs['url']) || !$tabs['url'][$key]) { continue; }
  2249. $totalValid++;
  2250. $fields = array();
  2251. foreach(array('id','name','url','icon','iconurl','order') as $v) {
  2252. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = $tabs[$v][$key]; }
  2253. }
  2254. foreach(array('active','user','guest','defaultz','window') as $v) {
  2255. if (isset($tabs[$v]) && isset($tabs[$v][$key])) { $fields[$v] = ($tabs[$v][$key]!=='false'?'true':'false'); }
  2256. }
  2257. $GLOBALS['file_db']->query('INSERT INTO tabs (`'.implode('`,`',array_keys($fields)).'`) VALUES (\''.implode("','",$fields).'\');');
  2258. }
  2259. writeLog("success", "tabs successfully saved");
  2260. return $totalValid;
  2261. } else {
  2262. writeLog("error", "tabs could not save");
  2263. return false;
  2264. }
  2265. writeLog("error", "tabs could not save");
  2266. return false;
  2267. }
  2268. // ==============
  2269. function clean($strin) {
  2270. $strout = null;
  2271. for ($i = 0; $i < strlen($strin); $i++) {
  2272. $ord = ord($strin[$i]);
  2273. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  2274. $strout .= "&amp;#{$ord};";
  2275. }
  2276. else {
  2277. switch ($strin[$i]) {
  2278. case '<':
  2279. $strout .= '&lt;';
  2280. break;
  2281. case '>':
  2282. $strout .= '&gt;';
  2283. break;
  2284. case '&':
  2285. $strout .= '&amp;';
  2286. break;
  2287. case '"':
  2288. $strout .= '&quot;';
  2289. break;
  2290. default:
  2291. $strout .= $strin[$i];
  2292. }
  2293. }
  2294. }
  2295. return $strout;
  2296. }
  2297. function registration_callback($username, $email, $userdir){
  2298. global $data;
  2299. $data = array($username, $email, $userdir);
  2300. }
  2301. function printArray($arrayName){
  2302. $messageCount = count($arrayName);
  2303. $i = 0;
  2304. foreach ( $arrayName as $item ) :
  2305. $i++;
  2306. if($i < $messageCount) :
  2307. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  2308. elseif($i = $messageCount) :
  2309. echo "<small class='text-uppercase'>" . $item . "</small>";
  2310. endif;
  2311. endforeach;
  2312. }
  2313. function write_ini_file($content, $path) {
  2314. if (!$handle = fopen($path, 'w')) {
  2315. return false;
  2316. }
  2317. $success = fwrite($handle, trim($content));
  2318. fclose($handle);
  2319. return $success;
  2320. }
  2321. function gotTimezone(){
  2322. $regions = array(
  2323. 'Africa' => DateTimeZone::AFRICA,
  2324. 'America' => DateTimeZone::AMERICA,
  2325. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2326. 'Arctic' => DateTimeZone::ARCTIC,
  2327. 'Asia' => DateTimeZone::ASIA,
  2328. 'Atlantic' => DateTimeZone::ATLANTIC,
  2329. 'Australia' => DateTimeZone::AUSTRALIA,
  2330. 'Europe' => DateTimeZone::EUROPE,
  2331. 'Indian' => DateTimeZone::INDIAN,
  2332. 'Pacific' => DateTimeZone::PACIFIC
  2333. );
  2334. $timezones = array();
  2335. foreach ($regions as $name => $mask) {
  2336. $zones = DateTimeZone::listIdentifiers($mask);
  2337. foreach($zones as $timezone) {
  2338. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2339. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2340. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2341. }
  2342. }
  2343. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  2344. foreach($timezones as $region => $list) {
  2345. print '<optgroup label="' . $region . '">' . "\n";
  2346. foreach($list as $timezone => $name) {
  2347. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  2348. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  2349. }
  2350. print '</optgroup>' . "\n";
  2351. }
  2352. print '</select>';
  2353. }
  2354. function getTimezone(){
  2355. $regions = array(
  2356. 'Africa' => DateTimeZone::AFRICA,
  2357. 'America' => DateTimeZone::AMERICA,
  2358. 'Antarctica' => DateTimeZone::ANTARCTICA,
  2359. 'Arctic' => DateTimeZone::ARCTIC,
  2360. 'Asia' => DateTimeZone::ASIA,
  2361. 'Atlantic' => DateTimeZone::ATLANTIC,
  2362. 'Australia' => DateTimeZone::AUSTRALIA,
  2363. 'Europe' => DateTimeZone::EUROPE,
  2364. 'Indian' => DateTimeZone::INDIAN,
  2365. 'Pacific' => DateTimeZone::PACIFIC
  2366. );
  2367. $timezones = array();
  2368. foreach ($regions as $name => $mask) {
  2369. $zones = DateTimeZone::listIdentifiers($mask);
  2370. foreach($zones as $timezone) {
  2371. $time = new DateTime(NULL, new DateTimeZone($timezone));
  2372. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  2373. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  2374. }
  2375. }
  2376. print '<select name="timezone" id="timezone" class="form-control material" required>';
  2377. foreach($timezones as $region => $list) {
  2378. print '<optgroup label="' . $region . '">' . "\n";
  2379. foreach($list as $timezone => $name) {
  2380. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  2381. }
  2382. print '</optgroup>' . "\n";
  2383. }
  2384. print '</select>';
  2385. }
  2386. function explosion($string, $position){
  2387. $getWord = explode("|", $string);
  2388. return $getWord[$position];
  2389. }
  2390. function getServerPath() {
  2391. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
  2392. $protocol = "https://";
  2393. }elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  2394. $protocol = "https://";
  2395. } else {
  2396. $protocol = "http://";
  2397. }
  2398. $domain = '';
  2399. if (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], '.') !== false){
  2400. $domain = $_SERVER['SERVER_NAME'];
  2401. }elseif(isset($_SERVER['HTTP_HOST'])){
  2402. if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
  2403. $domain = explode(':', $_SERVER['HTTP_HOST'])[0];
  2404. $port = explode(':', $_SERVER['HTTP_HOST'])[1];
  2405. if ($port == "80" || $port == "443"){
  2406. $domain = $domain;
  2407. }else{
  2408. $domain = $_SERVER['HTTP_HOST'];
  2409. }
  2410. }else{
  2411. $domain = $_SERVER['HTTP_HOST'];
  2412. }
  2413. }
  2414. return $protocol . $domain . dirname($_SERVER['REQUEST_URI']);
  2415. }
  2416. function get_browser_name() {
  2417. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  2418. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  2419. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  2420. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  2421. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  2422. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  2423. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  2424. return 'Other';
  2425. }
  2426. function getSickrageCalendarWanted($array){
  2427. $array = json_decode($array, true);
  2428. //$gotCalendar = "";
  2429. $gotCalendar = array();
  2430. $i = 0;
  2431. foreach($array['data']['missed'] AS $child) {
  2432. $i++;
  2433. $seriesName = $child['show_name'];
  2434. $episodeID = $child['tvdbid'];
  2435. $episodeAirDate = $child['airdate'];
  2436. $episodeAirDateTime = explode(" ",$child['airs']);
  2437. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2438. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2439. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2440. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2441. $downloaded = "0";
  2442. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2443. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2444. array_push($gotCalendar, array(
  2445. "id" => "Sick-Miss-".$i,
  2446. "title" => $seriesName,
  2447. "start" => $episodeAirDate,
  2448. "className" => $downloaded." tvID--".$episodeID,
  2449. "imagetype" => "tv",
  2450. ));
  2451. }
  2452. foreach($array['data']['today'] AS $child) {
  2453. $i++;
  2454. $seriesName = $child['show_name'];
  2455. $episodeID = $child['tvdbid'];
  2456. $episodeAirDate = $child['airdate'];
  2457. $episodeAirDateTime = explode(" ",$child['airs']);
  2458. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2459. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2460. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2461. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2462. $downloaded = "0";
  2463. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2464. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2465. array_push($gotCalendar, array(
  2466. "id" => "Sick-Today-".$i,
  2467. "title" => $seriesName,
  2468. "start" => $episodeAirDate,
  2469. "className" => $downloaded." tvID--".$episodeID,
  2470. "imagetype" => "tv",
  2471. ));
  2472. }
  2473. foreach($array['data']['soon'] AS $child) {
  2474. $i++;
  2475. $seriesName = $child['show_name'];
  2476. $episodeID = $child['tvdbid'];
  2477. $episodeAirDate = $child['airdate'];
  2478. $episodeAirDateTime = explode(" ",$child['airs']);
  2479. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2480. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2481. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2482. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2483. $downloaded = "0";
  2484. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2485. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2486. array_push($gotCalendar, array(
  2487. "id" => "Sick-Soon-".$i,
  2488. "title" => $seriesName,
  2489. "start" => $episodeAirDate,
  2490. "className" => $downloaded." tvID--".$episodeID,
  2491. "imagetype" => "tv",
  2492. ));
  2493. }
  2494. foreach($array['data']['later'] AS $child) {
  2495. $i++;
  2496. $seriesName = $child['show_name'];
  2497. $episodeID = $child['tvdbid'];
  2498. $episodeAirDate = $child['airdate'];
  2499. $episodeAirDateTime = explode(" ",$child['airs']);
  2500. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  2501. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  2502. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2503. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2504. $downloaded = "0";
  2505. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  2506. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2507. array_push($gotCalendar, array(
  2508. "id" => "Sick-Later-".$i,
  2509. "title" => $seriesName,
  2510. "start" => $episodeAirDate,
  2511. "className" => $downloaded." tvID--".$episodeID,
  2512. "imagetype" => "tv",
  2513. ));
  2514. }
  2515. if ($i != 0){ return $gotCalendar; }
  2516. }
  2517. function getSickrageCalendarHistory($array){
  2518. $array = json_decode($array, true);
  2519. //$gotCalendar = "";
  2520. $gotCalendar = array();
  2521. $i = 0;
  2522. foreach($array['data'] AS $child) {
  2523. $i++;
  2524. $seriesName = $child['show_name'];
  2525. $episodeID = $child['tvdbid'];
  2526. $episodeAirDate = $child['date'];
  2527. $downloaded = "green-bg";
  2528. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2529. array_push($gotCalendar, array(
  2530. "id" => "Sick-History-".$i,
  2531. "title" => $seriesName,
  2532. "start" => $episodeAirDate,
  2533. "className" => $downloaded." tvID--".$episodeID,
  2534. "imagetype" => "tv",
  2535. ));
  2536. }
  2537. if ($i != 0){ return $gotCalendar; }
  2538. }
  2539. function getSonarrCalendar($array){
  2540. $array = json_decode($array, true);
  2541. //$gotCalendar = "";
  2542. $gotCalendar = array();
  2543. $i = 0;
  2544. foreach($array AS $child) {
  2545. $i++;
  2546. $seriesName = $child['series']['title'];
  2547. $episodeID = $child['series']['tvdbId'];
  2548. if(!isset($episodeID)){ $episodeID = ""; }
  2549. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  2550. if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
  2551. $episodeAirDate = $child['airDateUtc'];
  2552. $episodeAirDate = strtotime($episodeAirDate);
  2553. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  2554. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  2555. $downloaded = $child['hasFile'];
  2556. 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"; }
  2557. //$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
  2558. array_push($gotCalendar, array(
  2559. "id" => "Sonarr-".$i,
  2560. "title" => $seriesName,
  2561. "start" => $episodeAirDate,
  2562. "className" => $downloaded." tvID--".$episodeID,
  2563. "imagetype" => "tv",
  2564. ));
  2565. }
  2566. if ($i != 0){ return $gotCalendar; }
  2567. }
  2568. function getRadarrCalendar($array){
  2569. $array = json_decode($array, true);
  2570. //$gotCalendar = "";
  2571. $gotCalendar = array();
  2572. $i = 0;
  2573. foreach($array AS $child) {
  2574. if(isset($child['inCinemas'])){
  2575. $i++;
  2576. $movieName = $child['title'];
  2577. $movieID = $child['tmdbId'];
  2578. if(!isset($movieID)){ $movieID = ""; }
  2579. if(isset($child['inCinemas']) && isset($child['physicalRelease'])){
  2580. $physicalRelease = $child['physicalRelease'];
  2581. $physicalRelease = strtotime($physicalRelease);
  2582. $physicalRelease = date("Y-m-d", $physicalRelease);
  2583. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2584. $downloaded = $child['hasFile'];
  2585. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  2586. }else{
  2587. $physicalRelease = $child['inCinemas'];
  2588. $downloaded = "light-blue-bg";
  2589. }
  2590. //$gotCalendar .= "{ title: \"$movieName\", start: \"$physicalRelease\", className: \"$downloaded movieID--$movieID\", imagetype: \"film\" }, \n";
  2591. array_push($gotCalendar, array(
  2592. "id" => "Radarr-".$i,
  2593. "title" => $movieName,
  2594. "start" => $physicalRelease,
  2595. "className" => $downloaded." movieID--".$movieID,
  2596. "imagetype" => "film",
  2597. ));
  2598. }
  2599. }
  2600. if ($i != 0){ return $gotCalendar; }
  2601. }
  2602. function getHeadphonesCalendar($url, $key, $list){
  2603. $url = qualifyURL(HEADPHONESURL);
  2604. $api = curl_get($url."/api?apikey=".$key."&cmd=$list");
  2605. $api = json_decode($api, true);
  2606. $i = 0;
  2607. //$gotCalendar = "";
  2608. $gotCalendar = array();;
  2609. if (is_array($api) || is_object($api)){
  2610. foreach($api AS $child) {
  2611. if($child['Status'] == "Wanted" && $list == "getWanted" && $child['ReleaseDate']){
  2612. $i++;
  2613. $albumName = addslashes($child['AlbumTitle']);
  2614. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  2615. $albumDate = (strlen($child['ReleaseDate']) > 4) ? $child['ReleaseDate'] : $child['ReleaseDate']."-01-01";
  2616. $albumID = $child['AlbumID'];
  2617. $albumDate = strtotime($albumDate);
  2618. $albumDate = date("Y-m-d", $albumDate);
  2619. $albumStatus = $child['Status'];
  2620. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2621. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  2622. //$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2623. array_push($gotCalendar, array(
  2624. "id" => "Headphones-".$i,
  2625. "title" => $albumArtist.' - '.$albumName,
  2626. "start" => $albumDate,
  2627. "className" => $albumStatusColor,
  2628. "imagetype" => "music",
  2629. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2630. ));
  2631. }
  2632. if($child['Status'] == "Processed" && $list == "getHistory"){
  2633. $i++;
  2634. $find = array('_','[', ']', '\n');
  2635. $replace = array(' ','(', ')', ' ');
  2636. $albumName = addslashes(str_replace($find,$replace,$child['FolderName']));
  2637. $albumDate = $child['DateAdded'];
  2638. $albumID = $child['AlbumID'];
  2639. $albumDate = strtotime($albumDate);
  2640. $albumDate = date("Y-m-d", $albumDate);
  2641. $albumStatusColor = "green-bg";
  2642. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  2643. //$gotCalendar .= "{ title: \"$albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  2644. array_push($gotCalendar, array(
  2645. "id" => "Headphones-".$i,
  2646. "title" => $albumName,
  2647. "start" => $albumDate,
  2648. "className" => $albumStatusColor,
  2649. "imagetype" => "music",
  2650. 'url' => "https://musicbrainz.org/release-group/".$albumID,
  2651. ));
  2652. }
  2653. }
  2654. if ($i != 0){ return $gotCalendar; }
  2655. }else{
  2656. writeLog("error", "HEADPHONES $list ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
  2657. }
  2658. }
  2659. function checkRootPath($string){
  2660. if($string == "\\" || $string == "/"){
  2661. return "/";
  2662. }else{
  2663. return str_replace("\\", "/", $string) . "/";
  2664. }
  2665. }
  2666. function strip($string){
  2667. $string = strip_tags($string);
  2668. return preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $string));
  2669. }
  2670. function writeLog($type, $message){
  2671. $message = date("Y-m-d H:i:s")."|".$type."|".strip($message)."\n";
  2672. file_put_contents("org.log", $message, FILE_APPEND | LOCK_EX);
  2673. }
  2674. function readLog(){
  2675. $log = file("org.log");
  2676. $log = array_reverse($log);
  2677. foreach($log as $line){
  2678. $line = explode("|", strip($line));
  2679. $line[1] = ($line[1] == "error") ? '<span class="label label-danger">Error</span>' : '<span class="label label-primary">Success</span>';
  2680. echo "<tr><td>".$line[0]."</td><td>".$line[2]."</td><td>".$line[1]."</td></tr>";
  2681. }
  2682. }
  2683. function buildStream($array){
  2684. $result = "";
  2685. if (array_key_exists('platform', $array)) {
  2686. $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>';
  2687. }
  2688. if (array_key_exists('device', $array)) {
  2689. $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"></i>'.$array['device'].'</span></div></div><div class="clearfix"></div>';
  2690. }
  2691. if (array_key_exists('stream', $array)) {
  2692. $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"></i>'.$array['stream'].'</span></div></div><div class="clearfix"></div>';
  2693. }
  2694. if (array_key_exists('video', $array)) {
  2695. $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"></i>'.$array['video'].'</span></div></div><div class="clearfix"></div>';
  2696. }
  2697. if (array_key_exists('audio', $array)) {
  2698. $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"></i>'.$array['audio'].'</span></div></div><div class="clearfix"></div>';
  2699. }
  2700. return $result;
  2701. }
  2702. function streamType($value){
  2703. if($value == "transcode" || $value == "Transcode"){
  2704. return "Transcode";
  2705. }elseif($value == "copy" || $value == "DirectStream"){
  2706. return "Direct Stream";
  2707. }elseif($value == "directplay" || $value == "DirectPlay"){
  2708. return "Direct Play";
  2709. }else{
  2710. return "Direct Play";
  2711. }
  2712. }
  2713. function getPlatform($platform){
  2714. $allPlatforms = array(
  2715. "Chrome" => "chrome.png",
  2716. "tvOS" => "atv.png",
  2717. "iOS" => "ios.png",
  2718. "Xbox One" => "xbox.png",
  2719. "Mystery 4" => "playstation.png",
  2720. "Samsung" => "samsung.png",
  2721. "Roku" => "roku.png",
  2722. "Emby for iOS" => "ios.png",
  2723. "Emby Mobile" => "emby.png",
  2724. "Emby Theater" => "emby.png",
  2725. "Emby Classic" => "emby.png",
  2726. "Safari" => "safari.png",
  2727. "Android" => "android.png",
  2728. "AndroidTv" => "android.png",
  2729. "Chromecast" => "chromecast.png",
  2730. "Dashboard" => "emby.png",
  2731. "Dlna" => "dlna.png",
  2732. "Windows Phone" => "wp.png",
  2733. "Windows RT" => "win8.png",
  2734. "Kodi" => "kodi.png",
  2735. );
  2736. if (array_key_exists($platform, $allPlatforms)) {
  2737. return $allPlatforms[$platform];
  2738. }else{
  2739. return "pmp.png";
  2740. }
  2741. }
  2742. function getServer(){
  2743. $server = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"];
  2744. return $server;
  2745. }
  2746. function prettyPrint($array) {
  2747. echo "<pre>";
  2748. print_r($array);
  2749. echo "</pre>";
  2750. echo "<br/>";
  2751. }
  2752. function checkFrame($array, $url){
  2753. if(array_key_exists("x-frame-options", $array)){
  2754. if($array['x-frame-options'] == "deny"){
  2755. return false;
  2756. }elseif($array['x-frame-options'] == "sameorgin"){
  2757. $digest = parse_url($url);
  2758. $host = (isset($digest['host'])?$digest['host']:'');
  2759. if(getServer() == $host){
  2760. return true;
  2761. }else{
  2762. return false;
  2763. }
  2764. }
  2765. }else{
  2766. if(!$array){
  2767. return false;
  2768. }
  2769. return true;
  2770. }
  2771. }
  2772. function frameTest($url){
  2773. $array = array_change_key_case(get_headers(qualifyURL($url), 1));
  2774. $url = qualifyURL($url);
  2775. if(checkFrame($array, $url)){
  2776. return true;
  2777. }else{
  2778. return false;
  2779. }
  2780. }
  2781. function sendResult($result, $icon = "floppy-o", $message = false, $success = "WAS_SUCCESSFUL", $fail = "HAS_FAILED", $send = true) {
  2782. $notifyExplode = explode("-", NOTIFYEFFECT);
  2783. if ($result) {
  2784. $msg = array(
  2785. 'html' => ($message?''.$message.' <strong>'.translate($success).'</strong>':'<strong>'.translate($success).'</strong>'),
  2786. 'icon' => $icon,
  2787. 'type' => 'success',
  2788. 'length' => '5000',
  2789. 'layout' => $notifyExplode[0],
  2790. 'effect' => $notifyExplode[1],
  2791. );
  2792. } else {
  2793. $msg = array(
  2794. 'html' => ($message?''.$message.' <strong>'.translate($fail).'</strong>':'<strong>'.translate($fail).'</strong>'),
  2795. 'icon' => $icon,
  2796. 'type' => 'error',
  2797. 'length' => '5000',
  2798. 'layout' => $notifyExplode[0],
  2799. 'effect' => $notifyExplode[1],
  2800. );
  2801. }
  2802. // Send and kill script?
  2803. if ($send) {
  2804. header('Content-Type: application/json');
  2805. echo json_encode(array('notify'=>$msg));
  2806. die();
  2807. }
  2808. return $msg;
  2809. }
  2810. function buildHomepageNotice($layout, $type, $title, $message){
  2811. switch ($layout) {
  2812. case 'elegant':
  2813. return '
  2814. <div id="homepageNotice" class="row">
  2815. <div class="col-lg-12">
  2816. <div class="content-box big-box box-shadow panel-box panel-'.$type.'">
  2817. <div class="content-title i-block">
  2818. <h4 class="zero-m"><strong>'.$title.'</strong></h4>
  2819. <div class="content-tools i-block pull-right">
  2820. <a class="close-btn">
  2821. <i class="fa fa-times"></i>
  2822. </a>
  2823. </div>
  2824. </div>
  2825. '.$message.'
  2826. </div>
  2827. </div>
  2828. </div>
  2829. ';
  2830. break;
  2831. case 'basic':
  2832. return '
  2833. <div id="homepageNotice" class="row">
  2834. <div class="col-lg-12">
  2835. <div class="panel panel-'.$type.'">
  2836. <div class="panel-heading">
  2837. <h3 class="panel-title">'.$title.'</h3>
  2838. </div>
  2839. <div class="panel-body">
  2840. '.$message.'
  2841. </div>
  2842. </div>
  2843. </div>
  2844. </div>
  2845. ';
  2846. break;
  2847. case 'jumbotron';
  2848. return '
  2849. <div id="homepageNotice" class="row">
  2850. <div class="col-lg-12">
  2851. <div class="jumbotron">
  2852. <div class="container">
  2853. <h1>'.$title.'</h1>
  2854. <p>'.$message.'</p>
  2855. </div>
  2856. </div>
  2857. </div>
  2858. </div>
  2859. ';
  2860. }
  2861. }
  2862. function embyArray($array, $type) {
  2863. $key = ($type == "video" ? "Height" : "Channels");
  2864. if (array_key_exists($key, $array)) {
  2865. switch ($type) {
  2866. case "video":
  2867. $codec = $array["Codec"];
  2868. $height = $array["Height"];
  2869. $width = $array["Width"];
  2870. break;
  2871. default:
  2872. $codec = $array["Codec"];
  2873. $channels = $array["Channels"];
  2874. }
  2875. return ($type == "video" ? "(".$codec.") (".$width."x".$height.")" : "(".$codec.") (".$channels."ch)");
  2876. }
  2877. foreach ($array as $element) {
  2878. if (is_array($element)) {
  2879. if (embyArray($element, $type)) {
  2880. return embyArray($element, $type);
  2881. }
  2882. }
  2883. }
  2884. }
  2885. // Get Now Playing Streams From Plex
  2886. function searchPlex($query){
  2887. $address = qualifyURL(PLEXURL);
  2888. $openTab = (PLEXTABNAME) ? "true" : "false";
  2889. // Perform API requests
  2890. $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
  2891. $api = simplexml_load_string($api);
  2892. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  2893. if (!$getServer) { return 'Could not load!'; }
  2894. // Identify the local machine
  2895. $server = $getServer['machineIdentifier'];
  2896. $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>";
  2897. $items = "";
  2898. $albums = $movies = $shows = 0;
  2899. $style = 'style="vertical-align: middle"';
  2900. foreach($api AS $child) {
  2901. if($child['type'] != "artist" && $child['type'] != "episode" && isset($child['librarySectionID'])){
  2902. $time = (string)$child['addedAt'];
  2903. $time = new DateTime("@$time");
  2904. $results = array(
  2905. "title" => (string)$child['title'],
  2906. "image" => (string)$child['thumb'],
  2907. "type" => (string)ucwords($child['type']),
  2908. "year" => (string)$child['year'],
  2909. "key" => (string)$child['ratingKey']."-search",
  2910. "ratingkey" => (string)$child['ratingKey'],
  2911. "genre" => (string)$child->Genre['tag'],
  2912. "added" => $time->format('Y-m-d'),
  2913. "extra" => "",
  2914. );
  2915. switch ($child['type']){
  2916. case "album":
  2917. $push = array(
  2918. "title" => (string)$child['parentTitle']." - ".(string)$child['title'],
  2919. );
  2920. $results = array_replace($results,$push);
  2921. $albums++;
  2922. break;
  2923. case "movie":
  2924. $push = array(
  2925. "extra" => "Content Rating: ".(string)$child['contentRating']."<br/>Movie Rating: ".(string)$child['rating'],
  2926. );
  2927. $results = array_replace($results,$push);
  2928. $movies++;
  2929. break;
  2930. case "show":
  2931. $push = array(
  2932. "extra" => "Seasons: ".(string)$child['childCount']."<br/>Episodes: ".(string)$child['leafCount'],
  2933. );
  2934. $results = array_replace($results,$push);
  2935. $shows++;
  2936. break;
  2937. }
  2938. if (file_exists('images/cache/'.$results['key'].'.jpg')){ $image_url = 'images/cache/'.$results['key'].'.jpg'; }
  2939. if (file_exists('images/cache/'.$results['key'].'.jpg') && (time() - 604800) > filemtime('images/cache/'.$results['key'].'.jpg') || !file_exists('images/cache/'.$results['key'].'.jpg')) {
  2940. $image_url = 'ajax.php?a=plex-image&img='.$results['image'].'&height=150&width=100&key='.$results['key'];
  2941. }
  2942. if(!$results['image']){ $image_url = "images/no-search.png"; $key = "no-search"; }
  2943. if (substr_count(PLEXURL, '.') != 2) {
  2944. $link = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  2945. }else{
  2946. $link = PLEXURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
  2947. }
  2948. $items .= '<tr style="cursor: pointer;" class="openTab" openTab="'.$openTab.'" href="'.$link.'">
  2949. <th scope="row"><img src="'.$image_url.'"></th>
  2950. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
  2951. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
  2952. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
  2953. <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
  2954. <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
  2955. <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['extra'].'</td>
  2956. </tr>';
  2957. }
  2958. }
  2959. $totals = '<div style="margin: 10px;" class="sort-todo pull-right">
  2960. <span class="badge gray-bg"><i class="fa fa-film fa-2x white"></i><strong style="
  2961. font-size: 23px;
  2962. ">&nbsp;'.$movies.'</strong></span>
  2963. <span class="badge gray-bg"><i class="fa fa-tv fa-2x white"></i><strong style="
  2964. font-size: 23px;
  2965. ">&nbsp;'.$shows.'</strong></span>
  2966. <span class="badge gray-bg"><i class="fa fa-music fa-2x white"></i><strong style="
  2967. font-size: 23px;
  2968. ">&nbsp;'.$albums.'</strong></span>
  2969. </div>';
  2970. return (!empty($items) ? $totals.$pre.$items."</div></table>" : "<h2 class='text-center'>No Results for $query</h2>" );
  2971. }
  2972. function getBannedUsers($string){
  2973. if (strpos($string, ',') !== false) {
  2974. $banned = explode(",", $string);
  2975. }else{
  2976. $banned = array($string);
  2977. }
  2978. return $banned;
  2979. }
  2980. function getWhitelist($string){
  2981. if (strpos($string, ',') !== false) {
  2982. $whitelist = explode(",", $string);
  2983. }else{
  2984. $whitelist = array($string);
  2985. }
  2986. foreach($whitelist as &$ip){
  2987. $ip = is_numeric(substr($ip, 0, 1)) ? $ip : gethostbyname($ip);
  2988. }
  2989. return $whitelist;
  2990. }
  2991. function get_client_ip() {
  2992. $ipaddress = '';
  2993. if (isset($_SERVER['HTTP_CLIENT_IP']))
  2994. $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
  2995. else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  2996. $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
  2997. else if(isset($_SERVER['HTTP_X_FORWARDED']))
  2998. $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
  2999. else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
  3000. $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
  3001. else if(isset($_SERVER['HTTP_FORWARDED']))
  3002. $ipaddress = $_SERVER['HTTP_FORWARDED'];
  3003. else if(isset($_SERVER['REMOTE_ADDR']))
  3004. $ipaddress = $_SERVER['REMOTE_ADDR'];
  3005. else
  3006. $ipaddress = 'UNKNOWN';
  3007. return $ipaddress;
  3008. }
  3009. //EMAIL SHIT
  3010. function sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null){
  3011. $mail = new PHPMailer;
  3012. $mail->isSMTP();
  3013. $mail->Host = SMTPHOST;
  3014. $mail->SMTPAuth = SMTPHOSTAUTH;
  3015. $mail->Username = SMTPHOSTUSERNAME;
  3016. $mail->Password = SMTPHOSTPASSWORD;
  3017. $mail->SMTPSecure = SMTPHOSTTYPE;
  3018. $mail->Port = SMTPHOSTPORT;
  3019. $mail->setFrom(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3020. $mail->addReplyTo(SMTPHOSTSENDEREMAIL, SMTPHOSTSENDERNAME);
  3021. $mail->isHTML(true);
  3022. $mail->addAddress($email, $username);
  3023. $mail->Subject = $subject;
  3024. $mail->Body = $body;
  3025. //$mail->send();
  3026. if(!$mail->send()) {
  3027. writeLog("error", "mail failed to send");
  3028. } else {
  3029. writeLog("success", "mail has been sent");
  3030. }
  3031. }
  3032. //EMAIL SHIT
  3033. function sendTestEmail($to, $from, $host, $auth, $username, $password, $type, $port, $sendername){
  3034. $mail = new PHPMailer;
  3035. $mail->isSMTP();
  3036. $mail->Host = $host;
  3037. $mail->SMTPAuth = $auth;
  3038. $mail->Username = $username;
  3039. $mail->Password = $password;
  3040. $mail->SMTPSecure = $type;
  3041. $mail->Port = $port;
  3042. $mail->setFrom($from, $sendername);
  3043. $mail->addReplyTo($from, $sendername);
  3044. $mail->isHTML(true);
  3045. $mail->addAddress($to, "Organizr Admin");
  3046. $mail->Subject = "Organizr Test E-Mail";
  3047. $mail->Body = "This was just a test!";
  3048. //$mail->send();
  3049. if(!$mail->send()) {
  3050. writeLog("error", "EMAIL TEST: mail failed to send - Error:".$mail->ErrorInfo);
  3051. return false;
  3052. } else {
  3053. writeLog("success", "EMAIL TEST: mail has been sent successfully");
  3054. return true;
  3055. }
  3056. }
  3057. function libraryList(){
  3058. $address = qualifyURL(PLEXURL);
  3059. $headers = array(
  3060. "Accept" => "application/json",
  3061. "X-Plex-Token" => PLEXTOKEN
  3062. );
  3063. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3064. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3065. $api = simplexml_load_string(@curl_get("https://plex.tv/api/servers/$gotServer/shared_servers", $headers));
  3066. $libraryList = array();
  3067. foreach($api->SharedServer->Section AS $child) {
  3068. $libraryList['libraries'][(string)$child['title']] = (string)$child['id'];
  3069. }
  3070. foreach($api->SharedServer AS $child) {
  3071. if(!empty($child['username'])){
  3072. $username = (string)strtolower($child['username']);
  3073. $email = (string)strtolower($child['email']);
  3074. $libraryList['users'][$username] = (string)$child['id'];
  3075. $libraryList['emails'][$email] = (string)$child['id'];
  3076. }
  3077. }
  3078. return (!empty($libraryList) ? array_change_key_case($libraryList,CASE_LOWER) : null );
  3079. }
  3080. function plexUserShare($username){
  3081. $address = qualifyURL(PLEXURL);
  3082. $headers = array(
  3083. "Accept" => "application/json",
  3084. "Content-Type" => "application/json",
  3085. "X-Plex-Token" => PLEXTOKEN
  3086. );
  3087. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3088. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3089. $json = array(
  3090. "server_id" => $gotServer,
  3091. "shared_server" => array(
  3092. //"library_section_ids" => "[26527637]",
  3093. "invited_email" => $username
  3094. )
  3095. );
  3096. $api = curl_post("https://plex.tv/api/servers/$gotServer/shared_servers/", $json, $headers);
  3097. switch ($api['http_code']['http_code']){
  3098. case 400:
  3099. writeLog("error", "PLEX INVITE: $username already has access to the shared libraries");
  3100. $result = "$username already has access to the shared libraries";
  3101. break;
  3102. case 401:
  3103. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3104. $result = "Invalid Plex Token";
  3105. break;
  3106. case 200:
  3107. writeLog("success", "PLEX INVITE: $username now has access to your Plex Library");
  3108. $result = "$username now has access to your Plex Library";
  3109. break;
  3110. default:
  3111. writeLog("error", "PLEX INVITE: unknown error");
  3112. $result = false;
  3113. }
  3114. return (!empty($result) ? $result : null );
  3115. }
  3116. function plexUserDelete($username){
  3117. $address = qualifyURL(PLEXURL);
  3118. $headers = array(
  3119. "Accept" => "application/json",
  3120. "Content-Type" => "application/json",
  3121. "X-Plex-Token" => PLEXTOKEN
  3122. );
  3123. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3124. if (!$getServer) { return 'Could not load!'; }else { $gotServer = $getServer['machineIdentifier']; }
  3125. $id = (is_numeric($username) ? $id : convertPlexName($username, "id"));
  3126. $api = curl_delete("https://plex.tv/api/servers/$gotServer/shared_servers/$id", $headers);
  3127. switch ($api['http_code']['http_code']){
  3128. case 401:
  3129. writeLog("error", "PLEX INVITE: Invalid Plex Token");
  3130. $result = "Invalid Plex Token";
  3131. break;
  3132. case 200:
  3133. writeLog("success", "PLEX INVITE: $username doesn't have access to your Plex Library anymore");
  3134. $result = "$username doesn't have access to your Plex Library anymore";
  3135. break;
  3136. default:
  3137. writeLog("error", "PLEX INVITE: unknown error");
  3138. $result = false;
  3139. }
  3140. return (!empty($result) ? $result : null );
  3141. }
  3142. function convertPlexName($user, $type){
  3143. $array = libraryList();
  3144. switch ($type){
  3145. case "username":
  3146. $plexUser = array_search ($user, $array['users']);
  3147. break;
  3148. case "id":
  3149. if (array_key_exists(strtolower($user), $array['users'])) {
  3150. $plexUser = $array['users'][strtolower($user)];
  3151. }
  3152. break;
  3153. default:
  3154. $plexUser = false;
  3155. }
  3156. return (!empty($plexUser) ? $plexUser : null );
  3157. }
  3158. function randomCode($length = 5, $type = null) {
  3159. switch ($type){
  3160. case "alpha":
  3161. $legend = array_merge(range('A', 'Z'));
  3162. break;
  3163. case "numeric":
  3164. $legend = array_merge(range(0,9));
  3165. break;
  3166. default:
  3167. $legend = array_merge(range(0,9),range('A', 'Z'));
  3168. }
  3169. $code = "";
  3170. for($i=0; $i < $length; $i++) {
  3171. $code .= $legend[mt_rand(0, count($legend) - 1)];
  3172. }
  3173. return $code;
  3174. }
  3175. function inviteCodes($action, $code = null, $usedBy = null) {
  3176. if (!isset($GLOBALS['file_db'])) {
  3177. $GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  3178. $GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  3179. }
  3180. $now = date("Y-m-d H:i:s");
  3181. switch ($action) {
  3182. case "get":
  3183. // Start Array
  3184. $result = array();
  3185. // Database Lookup
  3186. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes"');
  3187. // Get Codes
  3188. foreach($invites as $row) {
  3189. array_push($result, $row['code']);
  3190. }
  3191. // Return the Results
  3192. return (!empty($result) ? $result : false );
  3193. break;
  3194. case "check":
  3195. // Start Array
  3196. $result = array();
  3197. // Database Lookup
  3198. $invites = $GLOBALS['file_db']->query('SELECT * FROM invites WHERE valid = "Yes" AND code = "'.$code.'"');
  3199. // Get Codes
  3200. foreach($invites as $row) {
  3201. $result = $row['code'];
  3202. }
  3203. // Return the Results
  3204. return (!empty($result) ? $result : false );
  3205. break;
  3206. case "use":
  3207. $currentIP = get_client_ip();
  3208. $invites = $GLOBALS['file_db']->query('UPDATE invites SET valid = "No", usedby = "'.$usedBy.'", dateused = "'.$now.'", ip = "'.$currentIP.'" WHERE code = "'.$code.'"');
  3209. return (!empty($invites) ? true : false );
  3210. break;
  3211. }
  3212. }
  3213. function plexJoin($username, $email, $password){
  3214. $connectURL = 'https://plex.tv/users.json';
  3215. $headers = array(
  3216. 'Accept'=> 'application/json',
  3217. 'Content-Type' => 'application/x-www-form-urlencoded',
  3218. 'X-Plex-Product' => 'Organizr',
  3219. 'X-Plex-Version' => '1.0',
  3220. 'X-Plex-Client-Identifier' => '01010101-10101010',
  3221. );
  3222. $body = array(
  3223. 'user[email]' => $email,
  3224. 'user[username]' => $username,
  3225. 'user[password]' => $password,
  3226. );
  3227. $api = curl_post($connectURL, $body, $headers);
  3228. $json = json_decode($api['content'], true);
  3229. $errors = (!empty($json['errors']) ? true : false);
  3230. $success = (!empty($json['user']) ? true : false);
  3231. //Use This for later
  3232. $usernameError = (!empty($json['errors']['username']) ? $json['errors']['username'][0] : false);
  3233. $emailError = (!empty($json['errors']['email']) ? $json['errors']['email'][0] : false);
  3234. $passwordError = (!empty($json['errors']['password']) ? $json['errors']['password'][0] : false);
  3235. switch ($api['http_code']['http_code']){
  3236. case 400:
  3237. writeLog("error", "PLEX JOIN: $username already has access to the shared libraries");
  3238. break;
  3239. case 401:
  3240. writeLog("error", "PLEX JOIN: invalid Plex Token");
  3241. break;
  3242. case 422:
  3243. writeLog("error", "PLEX JOIN: user info error");
  3244. break;
  3245. case 429:
  3246. writeLog("error", "PLEX JOIN: too many requests to plex.tv please try later");
  3247. break;
  3248. case 200:
  3249. case 201:
  3250. writeLog("success", "PLEX JOIN: $username now has access to your Plex Library");
  3251. break;
  3252. default:
  3253. writeLog("error", "PLEX JOIN: unknown error, Error: ".$api['http_code']['http_code']);
  3254. }
  3255. //prettyPrint($api);
  3256. //prettyPrint(json_decode($api['content'], true));
  3257. return (!empty($success) && empty($errors) ? true : false );
  3258. }
  3259. function getCert(){
  3260. $url = "http://curl.haxx.se/ca/cacert.pem";
  3261. $file = getcwd()."/config/cacert.pem";
  3262. $directory = getcwd()."/config/";
  3263. @mkdir($directory, 0770, true);
  3264. if(!file_exists($file)){
  3265. file_put_contents( $file, fopen($url, 'r'));
  3266. writeLog("success", "CERT PEM: pem file created");
  3267. }elseif (file_exists($file) && time() - 2592000 > filemtime($file)) {
  3268. file_put_contents( $file, fopen($url, 'r'));
  3269. writeLog("success", "CERT PEM: downloaded new pem file");
  3270. }
  3271. return $file;
  3272. }
  3273. function customCSS(){
  3274. if(CUSTOMCSS == "true") {
  3275. $template_file = "custom.css";
  3276. $file_handle = fopen($template_file, "rb");
  3277. echo "\n";
  3278. echo fread($file_handle, filesize($template_file));
  3279. fclose($file_handle);
  3280. echo "\n";
  3281. }
  3282. }
  3283. function tvdbToken(){
  3284. $headers = array(
  3285. "Accept" => "application/json",
  3286. "Content-Type" => "application/json"
  3287. );
  3288. $json = array(
  3289. "apikey" => "FBE7B62621F4CAD7",
  3290. "userkey" => "328BB46EB1E9A0F5",
  3291. "username" => "causefx"
  3292. );
  3293. $api = curl_post("https://api.thetvdb.com/login", $json, $headers);
  3294. return json_decode($api['content'], true)['token'];
  3295. }
  3296. function tvdbGet($id){
  3297. $headers = array(
  3298. "Accept" => "application/json",
  3299. "Authorization" => "Bearer ".tvdbToken(),
  3300. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3301. "trakt-api-version" => "2"
  3302. );
  3303. $trakt = curl_get("https://api.trakt.tv/search/tvdb/$id?type=show", $headers);
  3304. @$api['trakt'] = json_decode($trakt, true)[0]['show']['ids'];
  3305. if(empty($api['trakt'])){
  3306. $series = curl_get("https://api.thetvdb.com/series/$id", $headers);
  3307. $poster = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=poster", $headers);
  3308. $backdrop = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=fanart", $headers);
  3309. $api['series'] = json_decode($series, true)['data'];
  3310. $api['poster'] = json_decode($poster, true)['data'];
  3311. $api['backdrop'] = json_decode($backdrop, true)['data'];
  3312. }
  3313. return $api;
  3314. }
  3315. function tvdbSearch($name, $type){
  3316. $name = rawurlencode(preg_replace("/\(([^()]*+|(?R))*\)/","", $name));
  3317. $headers = array(
  3318. "Accept" => "application/json",
  3319. "Authorization" => "Bearer ".tvdbToken(),
  3320. "trakt-api-key" => "4502cfdf8f7282fe454878ff8583f5636392cdc5fcac30d0cc4565f7173bf443",
  3321. "trakt-api-version" => "2"
  3322. );
  3323. $trakt = curl_get("https://api.trakt.tv/search/$type?query=$name", $headers);
  3324. @$api['trakt'] = json_decode($trakt, true)[0][$type]['ids'];
  3325. return $api;
  3326. }
  3327. function getPlexPlaylists(){
  3328. $address = qualifyURL(PLEXURL);
  3329. // Perform API requests
  3330. $api = @curl_get($address."/playlists?X-Plex-Token=".PLEXTOKEN);
  3331. $api = simplexml_load_string($api);
  3332. if (is_array($api) || is_object($api)){
  3333. if (!$api->head->title){
  3334. $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
  3335. if (!$getServer) { return 'Could not load!'; }
  3336. // Identify the local machine
  3337. $gotServer = $getServer['machineIdentifier'];
  3338. $output = "";
  3339. $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" class="dropdown-menu filter-recent-playlist">';
  3340. foreach($api AS $child) {
  3341. $items = array();
  3342. if ($child['playlistType'] == "video" && strpos(strtolower($child['title']) , 'private') === false){
  3343. $api = @curl_get($address.$child['key']."?X-Plex-Token=".PLEXTOKEN);
  3344. $api = simplexml_load_string($api);
  3345. if (is_array($api) || is_object($api)){
  3346. if (!$api->head->title){
  3347. $className = preg_replace("/(\W)+/", "", $api['title']);
  3348. $hideMenu .= '<li data-filter="playlist-'.$className.'" data-name="'.$api['title'].'"><a class="js-filter-'.$className.'" href="javascript:void(0)">'.$api['title'].'</a></li>';
  3349. foreach($api->Video AS $child){
  3350. $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false,false,$className);
  3351. }
  3352. if (count($items)) {
  3353. $output .= ''.implode('',$items).'';
  3354. }
  3355. }
  3356. }
  3357. }
  3358. }
  3359. $hideMenu .= '</ul></div></div>';
  3360. 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>';
  3361. }else{
  3362. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check token - if HTTPS, is cert valid");
  3363. }
  3364. }else{
  3365. writeLog("error", "PLEX PLAYLIST ERROR: could not connect - check URL - if HTTPS, is cert valid");
  3366. }
  3367. }
  3368. function readExternalLog($type,$filename,$name = null){
  3369. $log = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  3370. $log = array_reverse($log);
  3371. foreach($log as $line){
  3372. if(!empty($line) && $line[0] != " "){
  3373. $line = strip($line);
  3374. if($type == "single"){
  3375. if( strpos( strtolower($line), "ror" ) !== false ) {
  3376. echo "<tr><td class='red-bg'>".$line."</td></tr>";
  3377. }else{
  3378. echo "<tr><td>".$line."</td></tr>";
  3379. }
  3380. }elseif($type == "all"){
  3381. if( strpos( strtolower($line), "ror" ) !== false ) {
  3382. echo "<tr><td class='red-bg'>".$name."</td>";
  3383. echo "<td class='red-bg'>".$line."</td></tr>";
  3384. }else{
  3385. echo "<tr><td>".$name."</td>";
  3386. echo "<td>".$line."</td></tr>";
  3387. }
  3388. }
  3389. }
  3390. }
  3391. }
  3392. function getLogs(){
  3393. $path = __DIR__ ."/logs/";
  3394. @mkdir($path, 0770, true);
  3395. $logs = array();
  3396. $files = array_diff(scandir($path), array('.', '..'));
  3397. foreach($files as $v){
  3398. $title = explode(".", $v)[0];
  3399. $logs[$title] = $path.$v;
  3400. }
  3401. return $logs;
  3402. }
  3403. function getExtension($string) {
  3404. return preg_replace("#(.+)?\.(\w+)(\?.+)?#", "$2", $string);
  3405. }
  3406. function showFile(){
  3407. $file = $_GET['file'];
  3408. $fileType = getExtension($file);
  3409. if($fileType != 'php'){
  3410. header("Content-type: ".mimeTypes()[$fileType]);
  3411. @readfile($file);
  3412. }
  3413. }
  3414. function getCalendar(){
  3415. $sonarr = new Sonarr(SONARRURL, SONARRKEY);
  3416. $radarr = new Sonarr(RADARRURL, RADARRKEY);
  3417. $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
  3418. $startDate = date('Y-m-d',strtotime("-".CALENDARSTARTDAY." days"));
  3419. $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
  3420. //$calendarItems = '';
  3421. $calendarItems = array();
  3422. if (SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)){
  3423. try {
  3424. //$calendarItems .= getSonarrCalendar($sonarr->getCalendar($startDate, $endDate));
  3425. $calendarItems = array_merge($calendarItems, getSonarrCalendar($sonarr->getCalendar($startDate, $endDate)));
  3426. } catch (Exception $e) {
  3427. writeLog("error", "SONARR ERROR: ".strip($e->getMessage()));
  3428. }
  3429. }
  3430. if (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)){
  3431. try {
  3432. //$calendarItems .= getRadarrCalendar($radarr->getCalendar($startDate, $endDate));
  3433. $calendarItems = array_merge($calendarItems, getRadarrCalendar($radarr->getCalendar($startDate, $endDate)));
  3434. } catch (Exception $e) {
  3435. writeLog("error", "RADARR ERROR: ".strip($e->getMessage()));
  3436. }
  3437. }
  3438. if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
  3439. //$calendarItems .= getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory");
  3440. //$calendarItems .= getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted");
  3441. $calendarItems = array_merge($calendarItems, getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory"));
  3442. $calendarItems = array_merge($calendarItems, getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted"));
  3443. }
  3444. if (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)){
  3445. try {
  3446. //$calendarItems .= getSickrageCalendarWanted($sickrage->future());
  3447. $calendarItems = array_merge($calendarItems, getSickrageCalendarWanted($sickrage->future()));
  3448. } catch (Exception $e) {
  3449. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3450. } try {
  3451. //$calendarItems .= getSickrageCalendarHistory($sickrage->history("100","downloaded"));
  3452. $calendarItems = array_merge($calendarItems, getSickrageCalendarHistory($sickrage->history("100","downloaded")));
  3453. } catch (Exception $e) {
  3454. writeLog("error", "SICKRAGE/BEARD ERROR: ".strip($e->getMessage()));
  3455. }
  3456. }
  3457. return $calendarItems;
  3458. }
  3459. function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
  3460. $path = getServerPath();
  3461. return '
  3462. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3463. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  3464. <head>
  3465. <!--[if gte mso 9]><xml>
  3466. <o:OfficeDocumentSettings>
  3467. <o:AllowPNG/>
  3468. <o:PixelsPerInch>96</o:PixelsPerInch>
  3469. </o:OfficeDocumentSettings>
  3470. </xml><![endif]-->
  3471. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  3472. <meta name="viewport" content="width=device-width">
  3473. <!--[if !mso]><!-->
  3474. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  3475. <!--<![endif]-->
  3476. <title></title>
  3477. <!--[if !mso]><!-- -->
  3478. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
  3479. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
  3480. <!--<![endif]-->
  3481. <style type="text/css" id="media-query">
  3482. body {
  3483. margin: 0;
  3484. padding: 0;
  3485. }
  3486. table,
  3487. tr,
  3488. td {
  3489. vertical-align: top;
  3490. border-collapse: collapse;
  3491. }
  3492. .ie-browser table,
  3493. .mso-container table {
  3494. table-layout: fixed;
  3495. }
  3496. * {
  3497. line-height: inherit;
  3498. }
  3499. a[x-apple-data-detectors=true] {
  3500. color: inherit !important;
  3501. text-decoration: none !important;
  3502. }
  3503. [owa] .img-container div,
  3504. [owa] .img-container button {
  3505. display: block !important;
  3506. }
  3507. [owa] .fullwidth button {
  3508. width: 100% !important;
  3509. }
  3510. [owa] .block-grid .col {
  3511. display: table-cell;
  3512. float: none !important;
  3513. vertical-align: top;
  3514. }
  3515. .ie-browser .num12,
  3516. .ie-browser .block-grid,
  3517. [owa] .num12,
  3518. [owa] .block-grid {
  3519. width: 615px !important;
  3520. }
  3521. .ExternalClass,
  3522. .ExternalClass p,
  3523. .ExternalClass span,
  3524. .ExternalClass font,
  3525. .ExternalClass td,
  3526. .ExternalClass div {
  3527. line-height: 100%;
  3528. }
  3529. .ie-browser .mixed-two-up .num4,
  3530. [owa] .mixed-two-up .num4 {
  3531. width: 204px !important;
  3532. }
  3533. .ie-browser .mixed-two-up .num8,
  3534. [owa] .mixed-two-up .num8 {
  3535. width: 408px !important;
  3536. }
  3537. .ie-browser .block-grid.two-up .col,
  3538. [owa] .block-grid.two-up .col {
  3539. width: 307px !important;
  3540. }
  3541. .ie-browser .block-grid.three-up .col,
  3542. [owa] .block-grid.three-up .col {
  3543. width: 205px !important;
  3544. }
  3545. .ie-browser .block-grid.four-up .col,
  3546. [owa] .block-grid.four-up .col {
  3547. width: 153px !important;
  3548. }
  3549. .ie-browser .block-grid.five-up .col,
  3550. [owa] .block-grid.five-up .col {
  3551. width: 123px !important;
  3552. }
  3553. .ie-browser .block-grid.six-up .col,
  3554. [owa] .block-grid.six-up .col {
  3555. width: 102px !important;
  3556. }
  3557. .ie-browser .block-grid.seven-up .col,
  3558. [owa] .block-grid.seven-up .col {
  3559. width: 87px !important;
  3560. }
  3561. .ie-browser .block-grid.eight-up .col,
  3562. [owa] .block-grid.eight-up .col {
  3563. width: 76px !important;
  3564. }
  3565. .ie-browser .block-grid.nine-up .col,
  3566. [owa] .block-grid.nine-up .col {
  3567. width: 68px !important;
  3568. }
  3569. .ie-browser .block-grid.ten-up .col,
  3570. [owa] .block-grid.ten-up .col {
  3571. width: 61px !important;
  3572. }
  3573. .ie-browser .block-grid.eleven-up .col,
  3574. [owa] .block-grid.eleven-up .col {
  3575. width: 55px !important;
  3576. }
  3577. .ie-browser .block-grid.twelve-up .col,
  3578. [owa] .block-grid.twelve-up .col {
  3579. width: 51px !important;
  3580. }
  3581. @media only screen and (min-width: 635px) {
  3582. .block-grid {
  3583. width: 615px !important;
  3584. }
  3585. .block-grid .col {
  3586. display: table-cell;
  3587. Float: none !important;
  3588. vertical-align: top;
  3589. }
  3590. .block-grid .col.num12 {
  3591. width: 615px !important;
  3592. }
  3593. .block-grid.mixed-two-up .col.num4 {
  3594. width: 204px !important;
  3595. }
  3596. .block-grid.mixed-two-up .col.num8 {
  3597. width: 408px !important;
  3598. }
  3599. .block-grid.two-up .col {
  3600. width: 307px !important;
  3601. }
  3602. .block-grid.three-up .col {
  3603. width: 205px !important;
  3604. }
  3605. .block-grid.four-up .col {
  3606. width: 153px !important;
  3607. }
  3608. .block-grid.five-up .col {
  3609. width: 123px !important;
  3610. }
  3611. .block-grid.six-up .col {
  3612. width: 102px !important;
  3613. }
  3614. .block-grid.seven-up .col {
  3615. width: 87px !important;
  3616. }
  3617. .block-grid.eight-up .col {
  3618. width: 76px !important;
  3619. }
  3620. .block-grid.nine-up .col {
  3621. width: 68px !important;
  3622. }
  3623. .block-grid.ten-up .col {
  3624. width: 61px !important;
  3625. }
  3626. .block-grid.eleven-up .col {
  3627. width: 55px !important;
  3628. }
  3629. .block-grid.twelve-up .col {
  3630. width: 51px !important;
  3631. }
  3632. }
  3633. @media (max-width: 635px) {
  3634. .block-grid,
  3635. .col {
  3636. min-width: 320px !important;
  3637. max-width: 100% !important;
  3638. }
  3639. .block-grid {
  3640. width: calc(100% - 40px) !important;
  3641. }
  3642. .col {
  3643. width: 100% !important;
  3644. }
  3645. .col>div {
  3646. margin: 0 auto;
  3647. }
  3648. img.fullwidth {
  3649. max-width: 100% !important;
  3650. }
  3651. }
  3652. </style>
  3653. </head>
  3654. <body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #FFFFFF">
  3655. <!--[if IE]><div class="ie-browser"><![endif]-->
  3656. <!--[if mso]><div class="mso-container"><![endif]-->
  3657. <div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: #FFFFFF">
  3658. <!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #FFFFFF;"><![endif]-->
  3659. <div style="background-color:#333333;">
  3660. <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;"
  3661. class="block-grid ">
  3662. <div style="border-collapse: collapse;display: table;width: 100%;">
  3663. <!--[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]-->
  3664. <!--[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]-->
  3665. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  3666. <div style="background-color: transparent; width: 100% !important;">
  3667. <!--[if (!mso)&(!IE)]><!-->
  3668. <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;">
  3669. <!--<![endif]-->
  3670. <div align="left" class="img-container left fullwidth" style="padding-right: 30px; padding-left: 30px;">
  3671. <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 30px; padding-left: 30px;" align="left"><![endif]-->
  3672. <img class="left fullwidth" align="left" border="0" src="'.$path.'images/organizr-logo-h.png" alt="Image" title="Image"
  3673. 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"
  3674. width="555">
  3675. <!--[if mso]></td></tr></table><![endif]-->
  3676. </div>
  3677. <!--[if (!mso)&(!IE)]><!-->
  3678. </div>
  3679. <!--<![endif]-->
  3680. </div>
  3681. </div>
  3682. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  3683. </div>
  3684. </div>
  3685. </div>
  3686. <div style="background-color:#333333;">
  3687. <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;"
  3688. class="block-grid ">
  3689. <div style="border-collapse: collapse;display: table;width: 100%;">
  3690. <!--[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]-->
  3691. <!--[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]-->
  3692. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  3693. <div style="background-color: transparent; width: 100% !important;">
  3694. <!--[if (!mso)&(!IE)]><!-->
  3695. <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;">
  3696. <!--<![endif]-->
  3697. <!--[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]-->
  3698. <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;">
  3699. <div style="font-size:12px;line-height:14px;color:#FFFFFF;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  3700. <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>
  3701. </span>
  3702. </p>
  3703. </div>
  3704. </div>
  3705. <!--[if mso]></td></tr></table><![endif]-->
  3706. <!--[if (!mso)&(!IE)]><!-->
  3707. </div>
  3708. <!--<![endif]-->
  3709. </div>
  3710. </div>
  3711. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  3712. </div>
  3713. </div>
  3714. </div>
  3715. <div style="background-color:#393939;">
  3716. <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;"
  3717. class="block-grid ">
  3718. <div style="border-collapse: collapse;display: table;width: 100%;">
  3719. <!--[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]-->
  3720. <!--[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]-->
  3721. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  3722. <div style="background-color: transparent; width: 100% !important;">
  3723. <!--[if (!mso)&(!IE)]><!-->
  3724. <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;">
  3725. <!--<![endif]-->
  3726. <!--[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]-->
  3727. <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;">
  3728. <div style="font-family:Ubuntu, Tahoma, Verdana, Segoe, sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  3729. <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>
  3730. </div>
  3731. </div>
  3732. <!--[if mso]></td></tr></table><![endif]-->
  3733. <div style="padding-right: 5px; padding-left: 5px; padding-top: 5px; padding-bottom: 5px;">
  3734. <!--[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]-->
  3735. <div align="center">
  3736. <div style="border-top: 2px solid #66D9EF; width:55%; line-height:2px; height:2px; font-size:2px;">&#160;</div>
  3737. </div>
  3738. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  3739. </div>
  3740. <!--[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]-->
  3741. <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;">
  3742. <div style="font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;font-size:12px;line-height:14px;color:#FFFFFF;text-align:left;">
  3743. <p style="margin: 0;font-size: 12px;line-height: 14px"><span style="font-size: 28px; line-height: 33px;">Hey '.$user.',</span></p>
  3744. </div>
  3745. </div>
  3746. <!--[if mso]></td></tr></table><![endif]-->
  3747. <!--[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]-->
  3748. <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;">
  3749. <div style="font-size:12px;line-height:22px;font-family:\'Lato\',Tahoma,Verdana,Segoe,sans-serif;color:#FFFFFF;text-align:left;">
  3750. <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>
  3751. </span>
  3752. </p>
  3753. </div>
  3754. </div>
  3755. <!--[if mso]></td></tr></table><![endif]-->
  3756. <div align="center" class="button-container center" style="padding-right: 30px; padding-left: 30px; padding-top:15px; padding-bottom:15px;">
  3757. <!--[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]-->
  3758. <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">
  3759. <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>
  3760. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  3761. </div>
  3762. <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
  3763. </div>
  3764. <!--[if (!mso)&(!IE)]><!-->
  3765. </div>
  3766. <!--<![endif]-->
  3767. </div>
  3768. </div>
  3769. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  3770. </div>
  3771. </div>
  3772. </div>
  3773. <div style="background-color:#ffffff;">
  3774. <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;"
  3775. class="block-grid ">
  3776. <div style="border-collapse: collapse;display: table;width: 100%;">
  3777. <!--[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]-->
  3778. <!--[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]-->
  3779. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  3780. <div style="background-color: transparent; width: 100% !important;">
  3781. <!--[if (!mso)&(!IE)]><!-->
  3782. <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;">
  3783. <!--<![endif]-->
  3784. <!--[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]-->
  3785. <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;">
  3786. <div style="font-size:12px;line-height:14px;color:#555555;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  3787. <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>
  3788. </div>
  3789. </div>
  3790. <!--[if mso]></td></tr></table><![endif]-->
  3791. <div style="padding-right: 20px; padding-left: 20px; padding-top: 15px; padding-bottom: 20px;">
  3792. <!--[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]-->
  3793. <div align="center">
  3794. <div style="border-top: 3px solid #66D9EF; width:40%; line-height:3px; height:3px; font-size:3px;">&#160;</div>
  3795. </div>
  3796. <!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
  3797. </div>
  3798. <!--[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]-->
  3799. <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;">
  3800. <div style="font-size:12px;line-height:22px;color:#7E7D7D;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  3801. <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>
  3802. </div>
  3803. </div>
  3804. <!--[if mso]></td></tr></table><![endif]-->
  3805. <!--[if (!mso)&(!IE)]><!-->
  3806. </div>
  3807. <!--<![endif]-->
  3808. </div>
  3809. </div>
  3810. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  3811. </div>
  3812. </div>
  3813. </div>
  3814. <div style="background-color:#333333;">
  3815. <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;"
  3816. class="block-grid ">
  3817. <div style="border-collapse: collapse;display: table;width: 100%;">
  3818. <!--[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]-->
  3819. <!--[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]-->
  3820. <div class="col num12" style="min-width: 320px;max-width: 615px;width: 615px;width: calc(29500% - 180810px);background-color: transparent;">
  3821. <div style="background-color: transparent; width: 100% !important;">
  3822. <!--[if (!mso)&(!IE)]><!-->
  3823. <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;">
  3824. <!--<![endif]-->
  3825. <!--[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]-->
  3826. <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;">
  3827. <div style="font-size:12px;line-height:14px;color:#959595;font-family:\'Lato\', Tahoma, Verdana, Segoe, sans-serif;text-align:left;">
  3828. <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"
  3829. href="https://github.com/causefx/Organizr" target="_blank" rel="noopener noreferrer">Organizr</a><strong><br></strong></p>
  3830. </div>
  3831. </div>
  3832. <!--[if mso]></td></tr></table><![endif]-->
  3833. <!--[if (!mso)&(!IE)]><!-->
  3834. </div>
  3835. <!--<![endif]-->
  3836. </div>
  3837. </div>
  3838. <!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
  3839. </div>
  3840. </div>
  3841. </div>
  3842. <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
  3843. </div>
  3844. <!--[if (mso)|(IE)]></div><![endif]-->
  3845. </body>
  3846. </html>
  3847. ';
  3848. }
  3849. function mimeTypes(){
  3850. return array(
  3851. '123' => 'application/vnd.lotus-1-2-3',
  3852. '3dml' => 'text/vnd.in3d.3dml',
  3853. '3ds' => 'image/x-3ds',
  3854. '3g2' => 'video/3gpp2',
  3855. '3gp' => 'video/3gpp',
  3856. '7z' => 'application/x-7z-compressed',
  3857. 'aab' => 'application/x-authorware-bin',
  3858. 'aac' => 'audio/x-aac',
  3859. 'aam' => 'application/x-authorware-map',
  3860. 'aas' => 'application/x-authorware-seg',
  3861. 'abw' => 'application/x-abiword',
  3862. 'ac' => 'application/pkix-attr-cert',
  3863. 'acc' => 'application/vnd.americandynamics.acc',
  3864. 'ace' => 'application/x-ace-compressed',
  3865. 'acu' => 'application/vnd.acucobol',
  3866. 'acutc' => 'application/vnd.acucorp',
  3867. 'adp' => 'audio/adpcm',
  3868. 'aep' => 'application/vnd.audiograph',
  3869. 'afm' => 'application/x-font-type1',
  3870. 'afp' => 'application/vnd.ibm.modcap',
  3871. 'ahead' => 'application/vnd.ahead.space',
  3872. 'ai' => 'application/postscript',
  3873. 'aif' => 'audio/x-aiff',
  3874. 'aifc' => 'audio/x-aiff',
  3875. 'aiff' => 'audio/x-aiff',
  3876. 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
  3877. 'ait' => 'application/vnd.dvb.ait',
  3878. 'ami' => 'application/vnd.amiga.ami',
  3879. 'apk' => 'application/vnd.android.package-archive',
  3880. 'appcache' => 'text/cache-manifest',
  3881. 'application' => 'application/x-ms-application',
  3882. 'apr' => 'application/vnd.lotus-approach',
  3883. 'arc' => 'application/x-freearc',
  3884. 'asc' => 'application/pgp-signature',
  3885. 'asf' => 'video/x-ms-asf',
  3886. 'asm' => 'text/x-asm',
  3887. 'aso' => 'application/vnd.accpac.simply.aso',
  3888. 'asx' => 'video/x-ms-asf',
  3889. 'atc' => 'application/vnd.acucorp',
  3890. 'atom' => 'application/atom+xml',
  3891. 'atomcat' => 'application/atomcat+xml',
  3892. 'atomsvc' => 'application/atomsvc+xml',
  3893. 'atx' => 'application/vnd.antix.game-component',
  3894. 'au' => 'audio/basic',
  3895. 'avi' => 'video/x-msvideo',
  3896. 'aw' => 'application/applixware',
  3897. 'azf' => 'application/vnd.airzip.filesecure.azf',
  3898. 'azs' => 'application/vnd.airzip.filesecure.azs',
  3899. 'azw' => 'application/vnd.amazon.ebook',
  3900. 'bat' => 'application/x-msdownload',
  3901. 'bcpio' => 'application/x-bcpio',
  3902. 'bdf' => 'application/x-font-bdf',
  3903. 'bdm' => 'application/vnd.syncml.dm+wbxml',
  3904. 'bed' => 'application/vnd.realvnc.bed',
  3905. 'bh2' => 'application/vnd.fujitsu.oasysprs',
  3906. 'bin' => 'application/octet-stream',
  3907. 'blb' => 'application/x-blorb',
  3908. 'blorb' => 'application/x-blorb',
  3909. 'bmi' => 'application/vnd.bmi',
  3910. 'bmp' => 'image/bmp',
  3911. 'book' => 'application/vnd.framemaker',
  3912. 'box' => 'application/vnd.previewsystems.box',
  3913. 'boz' => 'application/x-bzip2',
  3914. 'bpk' => 'application/octet-stream',
  3915. 'btif' => 'image/prs.btif',
  3916. 'bz' => 'application/x-bzip',
  3917. 'bz2' => 'application/x-bzip2',
  3918. 'c' => 'text/x-c',
  3919. 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
  3920. 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
  3921. 'c4d' => 'application/vnd.clonk.c4group',
  3922. 'c4f' => 'application/vnd.clonk.c4group',
  3923. 'c4g' => 'application/vnd.clonk.c4group',
  3924. 'c4p' => 'application/vnd.clonk.c4group',
  3925. 'c4u' => 'application/vnd.clonk.c4group',
  3926. 'cab' => 'application/vnd.ms-cab-compressed',
  3927. 'caf' => 'audio/x-caf',
  3928. 'cap' => 'application/vnd.tcpdump.pcap',
  3929. 'car' => 'application/vnd.curl.car',
  3930. 'cat' => 'application/vnd.ms-pki.seccat',
  3931. 'cb7' => 'application/x-cbr',
  3932. 'cba' => 'application/x-cbr',
  3933. 'cbr' => 'application/x-cbr',
  3934. 'cbt' => 'application/x-cbr',
  3935. 'cbz' => 'application/x-cbr',
  3936. 'cc' => 'text/x-c',
  3937. 'cct' => 'application/x-director',
  3938. 'ccxml' => 'application/ccxml+xml',
  3939. 'cdbcmsg' => 'application/vnd.contact.cmsg',
  3940. 'cdf' => 'application/x-netcdf',
  3941. 'cdkey' => 'application/vnd.mediastation.cdkey',
  3942. 'cdmia' => 'application/cdmi-capability',
  3943. 'cdmic' => 'application/cdmi-container',
  3944. 'cdmid' => 'application/cdmi-domain',
  3945. 'cdmio' => 'application/cdmi-object',
  3946. 'cdmiq' => 'application/cdmi-queue',
  3947. 'cdx' => 'chemical/x-cdx',
  3948. 'cdxml' => 'application/vnd.chemdraw+xml',
  3949. 'cdy' => 'application/vnd.cinderella',
  3950. 'cer' => 'application/pkix-cert',
  3951. 'cfs' => 'application/x-cfs-compressed',
  3952. 'cgm' => 'image/cgm',
  3953. 'chat' => 'application/x-chat',
  3954. 'chm' => 'application/vnd.ms-htmlhelp',
  3955. 'chrt' => 'application/vnd.kde.kchart',
  3956. 'cif' => 'chemical/x-cif',
  3957. 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
  3958. 'cil' => 'application/vnd.ms-artgalry',
  3959. 'cla' => 'application/vnd.claymore',
  3960. 'class' => 'application/java-vm',
  3961. 'clkk' => 'application/vnd.crick.clicker.keyboard',
  3962. 'clkp' => 'application/vnd.crick.clicker.palette',
  3963. 'clkt' => 'application/vnd.crick.clicker.template',
  3964. 'clkw' => 'application/vnd.crick.clicker.wordbank',
  3965. 'clkx' => 'application/vnd.crick.clicker',
  3966. 'clp' => 'application/x-msclip',
  3967. 'cmc' => 'application/vnd.cosmocaller',
  3968. 'cmdf' => 'chemical/x-cmdf',
  3969. 'cml' => 'chemical/x-cml',
  3970. 'cmp' => 'application/vnd.yellowriver-custom-menu',
  3971. 'cmx' => 'image/x-cmx',
  3972. 'cod' => 'application/vnd.rim.cod',
  3973. 'com' => 'application/x-msdownload',
  3974. 'conf' => 'text/plain',
  3975. 'cpio' => 'application/x-cpio',
  3976. 'cpp' => 'text/x-c',
  3977. 'cpt' => 'application/mac-compactpro',
  3978. 'crd' => 'application/x-mscardfile',
  3979. 'crl' => 'application/pkix-crl',
  3980. 'crt' => 'application/x-x509-ca-cert',
  3981. 'cryptonote' => 'application/vnd.rig.cryptonote',
  3982. 'csh' => 'application/x-csh',
  3983. 'csml' => 'chemical/x-csml',
  3984. 'csp' => 'application/vnd.commonspace',
  3985. 'css' => 'text/css',
  3986. 'cst' => 'application/x-director',
  3987. 'csv' => 'text/csv',
  3988. 'cu' => 'application/cu-seeme',
  3989. 'curl' => 'text/vnd.curl',
  3990. 'cww' => 'application/prs.cww',
  3991. 'cxt' => 'application/x-director',
  3992. 'cxx' => 'text/x-c',
  3993. 'dae' => 'model/vnd.collada+xml',
  3994. 'daf' => 'application/vnd.mobius.daf',
  3995. 'dart' => 'application/vnd.dart',
  3996. 'dataless' => 'application/vnd.fdsn.seed',
  3997. 'davmount' => 'application/davmount+xml',
  3998. 'dbk' => 'application/docbook+xml',
  3999. 'dcr' => 'application/x-director',
  4000. 'dcurl' => 'text/vnd.curl.dcurl',
  4001. 'dd2' => 'application/vnd.oma.dd2+xml',
  4002. 'ddd' => 'application/vnd.fujixerox.ddd',
  4003. 'deb' => 'application/x-debian-package',
  4004. 'def' => 'text/plain',
  4005. 'deploy' => 'application/octet-stream',
  4006. 'der' => 'application/x-x509-ca-cert',
  4007. 'dfac' => 'application/vnd.dreamfactory',
  4008. 'dgc' => 'application/x-dgc-compressed',
  4009. 'dic' => 'text/x-c',
  4010. 'dir' => 'application/x-director',
  4011. 'dis' => 'application/vnd.mobius.dis',
  4012. 'dist' => 'application/octet-stream',
  4013. 'distz' => 'application/octet-stream',
  4014. 'djv' => 'image/vnd.djvu',
  4015. 'djvu' => 'image/vnd.djvu',
  4016. 'dll' => 'application/x-msdownload',
  4017. 'dmg' => 'application/x-apple-diskimage',
  4018. 'dmp' => 'application/vnd.tcpdump.pcap',
  4019. 'dms' => 'application/octet-stream',
  4020. 'dna' => 'application/vnd.dna',
  4021. 'doc' => 'application/msword',
  4022. 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
  4023. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  4024. 'dot' => 'application/msword',
  4025. 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
  4026. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  4027. 'dp' => 'application/vnd.osgi.dp',
  4028. 'dpg' => 'application/vnd.dpgraph',
  4029. 'dra' => 'audio/vnd.dra',
  4030. 'dsc' => 'text/prs.lines.tag',
  4031. 'dssc' => 'application/dssc+der',
  4032. 'dtb' => 'application/x-dtbook+xml',
  4033. 'dtd' => 'application/xml-dtd',
  4034. 'dts' => 'audio/vnd.dts',
  4035. 'dtshd' => 'audio/vnd.dts.hd',
  4036. 'dump' => 'application/octet-stream',
  4037. 'dvb' => 'video/vnd.dvb.file',
  4038. 'dvi' => 'application/x-dvi',
  4039. 'dwf' => 'model/vnd.dwf',
  4040. 'dwg' => 'image/vnd.dwg',
  4041. 'dxf' => 'image/vnd.dxf',
  4042. 'dxp' => 'application/vnd.spotfire.dxp',
  4043. 'dxr' => 'application/x-director',
  4044. 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
  4045. 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
  4046. 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
  4047. 'ecma' => 'application/ecmascript',
  4048. 'edm' => 'application/vnd.novadigm.edm',
  4049. 'edx' => 'application/vnd.novadigm.edx',
  4050. 'efif' => 'application/vnd.picsel',
  4051. 'ei6' => 'application/vnd.pg.osasli',
  4052. 'elc' => 'application/octet-stream',
  4053. 'emf' => 'application/x-msmetafile',
  4054. 'eml' => 'message/rfc822',
  4055. 'emma' => 'application/emma+xml',
  4056. 'emz' => 'application/x-msmetafile',
  4057. 'eol' => 'audio/vnd.digital-winds',
  4058. 'eot' => 'application/vnd.ms-fontobject',
  4059. 'eps' => 'application/postscript',
  4060. 'epub' => 'application/epub+zip',
  4061. 'es3' => 'application/vnd.eszigno3+xml',
  4062. 'esa' => 'application/vnd.osgi.subsystem',
  4063. 'esf' => 'application/vnd.epson.esf',
  4064. 'et3' => 'application/vnd.eszigno3+xml',
  4065. 'etx' => 'text/x-setext',
  4066. 'eva' => 'application/x-eva',
  4067. 'evy' => 'application/x-envoy',
  4068. 'exe' => 'application/x-msdownload',
  4069. 'exi' => 'application/exi',
  4070. 'ext' => 'application/vnd.novadigm.ext',
  4071. 'ez' => 'application/andrew-inset',
  4072. 'ez2' => 'application/vnd.ezpix-album',
  4073. 'ez3' => 'application/vnd.ezpix-package',
  4074. 'f' => 'text/x-fortran',
  4075. 'f4v' => 'video/x-f4v',
  4076. 'f77' => 'text/x-fortran',
  4077. 'f90' => 'text/x-fortran',
  4078. 'fbs' => 'image/vnd.fastbidsheet',
  4079. 'fcdt' => 'application/vnd.adobe.formscentral.fcdt',
  4080. 'fcs' => 'application/vnd.isac.fcs',
  4081. 'fdf' => 'application/vnd.fdf',
  4082. 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
  4083. 'fg5' => 'application/vnd.fujitsu.oasysgp',
  4084. 'fgd' => 'application/x-director',
  4085. 'fh' => 'image/x-freehand',
  4086. 'fh4' => 'image/x-freehand',
  4087. 'fh5' => 'image/x-freehand',
  4088. 'fh7' => 'image/x-freehand',
  4089. 'fhc' => 'image/x-freehand',
  4090. 'fig' => 'application/x-xfig',
  4091. 'flac' => 'audio/x-flac',
  4092. 'fli' => 'video/x-fli',
  4093. 'flo' => 'application/vnd.micrografx.flo',
  4094. 'flv' => 'video/x-flv',
  4095. 'flw' => 'application/vnd.kde.kivio',
  4096. 'flx' => 'text/vnd.fmi.flexstor',
  4097. 'fly' => 'text/vnd.fly',
  4098. 'fm' => 'application/vnd.framemaker',
  4099. 'fnc' => 'application/vnd.frogans.fnc',
  4100. 'for' => 'text/x-fortran',
  4101. 'fpx' => 'image/vnd.fpx',
  4102. 'frame' => 'application/vnd.framemaker',
  4103. 'fsc' => 'application/vnd.fsc.weblaunch',
  4104. 'fst' => 'image/vnd.fst',
  4105. 'ftc' => 'application/vnd.fluxtime.clip',
  4106. 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
  4107. 'fvt' => 'video/vnd.fvt',
  4108. 'fxp' => 'application/vnd.adobe.fxp',
  4109. 'fxpl' => 'application/vnd.adobe.fxp',
  4110. 'fzs' => 'application/vnd.fuzzysheet',
  4111. 'g2w' => 'application/vnd.geoplan',
  4112. 'g3' => 'image/g3fax',
  4113. 'g3w' => 'application/vnd.geospace',
  4114. 'gac' => 'application/vnd.groove-account',
  4115. 'gam' => 'application/x-tads',
  4116. 'gbr' => 'application/rpki-ghostbusters',
  4117. 'gca' => 'application/x-gca-compressed',
  4118. 'gdl' => 'model/vnd.gdl',
  4119. 'geo' => 'application/vnd.dynageo',
  4120. 'gex' => 'application/vnd.geometry-explorer',
  4121. 'ggb' => 'application/vnd.geogebra.file',
  4122. 'ggt' => 'application/vnd.geogebra.tool',
  4123. 'ghf' => 'application/vnd.groove-help',
  4124. 'gif' => 'image/gif',
  4125. 'gim' => 'application/vnd.groove-identity-message',
  4126. 'gml' => 'application/gml+xml',
  4127. 'gmx' => 'application/vnd.gmx',
  4128. 'gnumeric' => 'application/x-gnumeric',
  4129. 'gph' => 'application/vnd.flographit',
  4130. 'gpx' => 'application/gpx+xml',
  4131. 'gqf' => 'application/vnd.grafeq',
  4132. 'gqs' => 'application/vnd.grafeq',
  4133. 'gram' => 'application/srgs',
  4134. 'gramps' => 'application/x-gramps-xml',
  4135. 'gre' => 'application/vnd.geometry-explorer',
  4136. 'grv' => 'application/vnd.groove-injector',
  4137. 'grxml' => 'application/srgs+xml',
  4138. 'gsf' => 'application/x-font-ghostscript',
  4139. 'gtar' => 'application/x-gtar',
  4140. 'gtm' => 'application/vnd.groove-tool-message',
  4141. 'gtw' => 'model/vnd.gtw',
  4142. 'gv' => 'text/vnd.graphviz',
  4143. 'gxf' => 'application/gxf',
  4144. 'gxt' => 'application/vnd.geonext',
  4145. 'h' => 'text/x-c',
  4146. 'h261' => 'video/h261',
  4147. 'h263' => 'video/h263',
  4148. 'h264' => 'video/h264',
  4149. 'hal' => 'application/vnd.hal+xml',
  4150. 'hbci' => 'application/vnd.hbci',
  4151. 'hdf' => 'application/x-hdf',
  4152. 'hh' => 'text/x-c',
  4153. 'hlp' => 'application/winhlp',
  4154. 'hpgl' => 'application/vnd.hp-hpgl',
  4155. 'hpid' => 'application/vnd.hp-hpid',
  4156. 'hps' => 'application/vnd.hp-hps',
  4157. 'hqx' => 'application/mac-binhex40',
  4158. 'htke' => 'application/vnd.kenameaapp',
  4159. 'htm' => 'text/html',
  4160. 'html' => 'text/html',
  4161. 'hvd' => 'application/vnd.yamaha.hv-dic',
  4162. 'hvp' => 'application/vnd.yamaha.hv-voice',
  4163. 'hvs' => 'application/vnd.yamaha.hv-script',
  4164. 'i2g' => 'application/vnd.intergeo',
  4165. 'icc' => 'application/vnd.iccprofile',
  4166. 'ice' => 'x-conference/x-cooltalk',
  4167. 'icm' => 'application/vnd.iccprofile',
  4168. 'ico' => 'image/x-icon',
  4169. 'ics' => 'text/calendar',
  4170. 'ief' => 'image/ief',
  4171. 'ifb' => 'text/calendar',
  4172. 'ifm' => 'application/vnd.shana.informed.formdata',
  4173. 'iges' => 'model/iges',
  4174. 'igl' => 'application/vnd.igloader',
  4175. 'igm' => 'application/vnd.insors.igm',
  4176. 'igs' => 'model/iges',
  4177. 'igx' => 'application/vnd.micrografx.igx',
  4178. 'iif' => 'application/vnd.shana.informed.interchange',
  4179. 'imp' => 'application/vnd.accpac.simply.imp',
  4180. 'ims' => 'application/vnd.ms-ims',
  4181. 'in' => 'text/plain',
  4182. 'ink' => 'application/inkml+xml',
  4183. 'inkml' => 'application/inkml+xml',
  4184. 'install' => 'application/x-install-instructions',
  4185. 'iota' => 'application/vnd.astraea-software.iota',
  4186. 'ipfix' => 'application/ipfix',
  4187. 'ipk' => 'application/vnd.shana.informed.package',
  4188. 'irm' => 'application/vnd.ibm.rights-management',
  4189. 'irp' => 'application/vnd.irepository.package+xml',
  4190. 'iso' => 'application/x-iso9660-image',
  4191. 'itp' => 'application/vnd.shana.informed.formtemplate',
  4192. 'ivp' => 'application/vnd.immervision-ivp',
  4193. 'ivu' => 'application/vnd.immervision-ivu',
  4194. 'jad' => 'text/vnd.sun.j2me.app-descriptor',
  4195. 'jam' => 'application/vnd.jam',
  4196. 'jar' => 'application/java-archive',
  4197. 'java' => 'text/x-java-source',
  4198. 'jisp' => 'application/vnd.jisp',
  4199. 'jlt' => 'application/vnd.hp-jlyt',
  4200. 'jnlp' => 'application/x-java-jnlp-file',
  4201. 'joda' => 'application/vnd.joost.joda-archive',
  4202. 'jpe' => 'image/jpeg',
  4203. 'jpeg' => 'image/jpeg',
  4204. 'jpg' => 'image/jpeg',
  4205. 'jpgm' => 'video/jpm',
  4206. 'jpgv' => 'video/jpeg',
  4207. 'jpm' => 'video/jpm',
  4208. 'js' => 'application/javascript',
  4209. 'json' => 'application/json',
  4210. 'jsonml' => 'application/jsonml+json',
  4211. 'kar' => 'audio/midi',
  4212. 'karbon' => 'application/vnd.kde.karbon',
  4213. 'kfo' => 'application/vnd.kde.kformula',
  4214. 'kia' => 'application/vnd.kidspiration',
  4215. 'kml' => 'application/vnd.google-earth.kml+xml',
  4216. 'kmz' => 'application/vnd.google-earth.kmz',
  4217. 'kne' => 'application/vnd.kinar',
  4218. 'knp' => 'application/vnd.kinar',
  4219. 'kon' => 'application/vnd.kde.kontour',
  4220. 'kpr' => 'application/vnd.kde.kpresenter',
  4221. 'kpt' => 'application/vnd.kde.kpresenter',
  4222. 'kpxx' => 'application/vnd.ds-keypoint',
  4223. 'ksp' => 'application/vnd.kde.kspread',
  4224. 'ktr' => 'application/vnd.kahootz',
  4225. 'ktx' => 'image/ktx',
  4226. 'ktz' => 'application/vnd.kahootz',
  4227. 'kwd' => 'application/vnd.kde.kword',
  4228. 'kwt' => 'application/vnd.kde.kword',
  4229. 'lasxml' => 'application/vnd.las.las+xml',
  4230. 'latex' => 'application/x-latex',
  4231. 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  4232. 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  4233. 'les' => 'application/vnd.hhe.lesson-player',
  4234. 'lha' => 'application/x-lzh-compressed',
  4235. 'link66' => 'application/vnd.route66.link66+xml',
  4236. 'list' => 'text/plain',
  4237. 'list3820' => 'application/vnd.ibm.modcap',
  4238. 'listafp' => 'application/vnd.ibm.modcap',
  4239. 'lnk' => 'application/x-ms-shortcut',
  4240. 'log' => 'text/plain',
  4241. 'lostxml' => 'application/lost+xml',
  4242. 'lrf' => 'application/octet-stream',
  4243. 'lrm' => 'application/vnd.ms-lrm',
  4244. 'ltf' => 'application/vnd.frogans.ltf',
  4245. 'lvp' => 'audio/vnd.lucent.voice',
  4246. 'lwp' => 'application/vnd.lotus-wordpro',
  4247. 'lzh' => 'application/x-lzh-compressed',
  4248. 'm13' => 'application/x-msmediaview',
  4249. 'm14' => 'application/x-msmediaview',
  4250. 'm1v' => 'video/mpeg',
  4251. 'm21' => 'application/mp21',
  4252. 'm2a' => 'audio/mpeg',
  4253. 'm2v' => 'video/mpeg',
  4254. 'm3a' => 'audio/mpeg',
  4255. 'm3u' => 'audio/x-mpegurl',
  4256. 'm3u8' => 'application/vnd.apple.mpegurl',
  4257. 'm4a' => 'audio/mp4',
  4258. 'm4u' => 'video/vnd.mpegurl',
  4259. 'm4v' => 'video/x-m4v',
  4260. 'ma' => 'application/mathematica',
  4261. 'mads' => 'application/mads+xml',
  4262. 'mag' => 'application/vnd.ecowin.chart',
  4263. 'maker' => 'application/vnd.framemaker',
  4264. 'man' => 'text/troff',
  4265. 'mar' => 'application/octet-stream',
  4266. 'mathml' => 'application/mathml+xml',
  4267. 'mb' => 'application/mathematica',
  4268. 'mbk' => 'application/vnd.mobius.mbk',
  4269. 'mbox' => 'application/mbox',
  4270. 'mc1' => 'application/vnd.medcalcdata',
  4271. 'mcd' => 'application/vnd.mcd',
  4272. 'mcurl' => 'text/vnd.curl.mcurl',
  4273. 'mdb' => 'application/x-msaccess',
  4274. 'mdi' => 'image/vnd.ms-modi',
  4275. 'me' => 'text/troff',
  4276. 'mesh' => 'model/mesh',
  4277. 'meta4' => 'application/metalink4+xml',
  4278. 'metalink' => 'application/metalink+xml',
  4279. 'mets' => 'application/mets+xml',
  4280. 'mfm' => 'application/vnd.mfmp',
  4281. 'mft' => 'application/rpki-manifest',
  4282. 'mgp' => 'application/vnd.osgeo.mapguide.package',
  4283. 'mgz' => 'application/vnd.proteus.magazine',
  4284. 'mid' => 'audio/midi',
  4285. 'midi' => 'audio/midi',
  4286. 'mie' => 'application/x-mie',
  4287. 'mif' => 'application/vnd.mif',
  4288. 'mime' => 'message/rfc822',
  4289. 'mj2' => 'video/mj2',
  4290. 'mjp2' => 'video/mj2',
  4291. 'mk3d' => 'video/x-matroska',
  4292. 'mka' => 'audio/x-matroska',
  4293. 'mks' => 'video/x-matroska',
  4294. 'mkv' => 'video/x-matroska',
  4295. 'mlp' => 'application/vnd.dolby.mlp',
  4296. 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
  4297. 'mmf' => 'application/vnd.smaf',
  4298. 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
  4299. 'mng' => 'video/x-mng',
  4300. 'mny' => 'application/x-msmoney',
  4301. 'mobi' => 'application/x-mobipocket-ebook',
  4302. 'mods' => 'application/mods+xml',
  4303. 'mov' => 'video/quicktime',
  4304. 'movie' => 'video/x-sgi-movie',
  4305. 'mp2' => 'audio/mpeg',
  4306. 'mp21' => 'application/mp21',
  4307. 'mp2a' => 'audio/mpeg',
  4308. 'mp3' => 'audio/mpeg',
  4309. 'mp4' => 'video/mp4',
  4310. 'mp4a' => 'audio/mp4',
  4311. 'mp4s' => 'application/mp4',
  4312. 'mp4v' => 'video/mp4',
  4313. 'mpc' => 'application/vnd.mophun.certificate',
  4314. 'mpe' => 'video/mpeg',
  4315. 'mpeg' => 'video/mpeg',
  4316. 'mpg' => 'video/mpeg',
  4317. 'mpg4' => 'video/mp4',
  4318. 'mpga' => 'audio/mpeg',
  4319. 'mpkg' => 'application/vnd.apple.installer+xml',
  4320. 'mpm' => 'application/vnd.blueice.multipass',
  4321. 'mpn' => 'application/vnd.mophun.application',
  4322. 'mpp' => 'application/vnd.ms-project',
  4323. 'mpt' => 'application/vnd.ms-project',
  4324. 'mpy' => 'application/vnd.ibm.minipay',
  4325. 'mqy' => 'application/vnd.mobius.mqy',
  4326. 'mrc' => 'application/marc',
  4327. 'mrcx' => 'application/marcxml+xml',
  4328. 'ms' => 'text/troff',
  4329. 'mscml' => 'application/mediaservercontrol+xml',
  4330. 'mseed' => 'application/vnd.fdsn.mseed',
  4331. 'mseq' => 'application/vnd.mseq',
  4332. 'msf' => 'application/vnd.epson.msf',
  4333. 'msh' => 'model/mesh',
  4334. 'msi' => 'application/x-msdownload',
  4335. 'msl' => 'application/vnd.mobius.msl',
  4336. 'msty' => 'application/vnd.muvee.style',
  4337. 'mts' => 'model/vnd.mts',
  4338. 'mus' => 'application/vnd.musician',
  4339. 'musicxml' => 'application/vnd.recordare.musicxml+xml',
  4340. 'mvb' => 'application/x-msmediaview',
  4341. 'mwf' => 'application/vnd.mfer',
  4342. 'mxf' => 'application/mxf',
  4343. 'mxl' => 'application/vnd.recordare.musicxml',
  4344. 'mxml' => 'application/xv+xml',
  4345. 'mxs' => 'application/vnd.triscape.mxs',
  4346. 'mxu' => 'video/vnd.mpegurl',
  4347. 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  4348. 'n3' => 'text/n3',
  4349. 'nb' => 'application/mathematica',
  4350. 'nbp' => 'application/vnd.wolfram.player',
  4351. 'nc' => 'application/x-netcdf',
  4352. 'ncx' => 'application/x-dtbncx+xml',
  4353. 'nfo' => 'text/x-nfo',
  4354. 'ngdat' => 'application/vnd.nokia.n-gage.data',
  4355. 'nitf' => 'application/vnd.nitf',
  4356. 'nlu' => 'application/vnd.neurolanguage.nlu',
  4357. 'nml' => 'application/vnd.enliven',
  4358. 'nnd' => 'application/vnd.noblenet-directory',
  4359. 'nns' => 'application/vnd.noblenet-sealer',
  4360. 'nnw' => 'application/vnd.noblenet-web',
  4361. 'npx' => 'image/vnd.net-fpx',
  4362. 'nsc' => 'application/x-conference',
  4363. 'nsf' => 'application/vnd.lotus-notes',
  4364. 'ntf' => 'application/vnd.nitf',
  4365. 'nzb' => 'application/x-nzb',
  4366. 'oa2' => 'application/vnd.fujitsu.oasys2',
  4367. 'oa3' => 'application/vnd.fujitsu.oasys3',
  4368. 'oas' => 'application/vnd.fujitsu.oasys',
  4369. 'obd' => 'application/x-msbinder',
  4370. 'obj' => 'application/x-tgif',
  4371. 'oda' => 'application/oda',
  4372. 'odb' => 'application/vnd.oasis.opendocument.database',
  4373. 'odc' => 'application/vnd.oasis.opendocument.chart',
  4374. 'odf' => 'application/vnd.oasis.opendocument.formula',
  4375. 'odft' => 'application/vnd.oasis.opendocument.formula-template',
  4376. 'odg' => 'application/vnd.oasis.opendocument.graphics',
  4377. 'odi' => 'application/vnd.oasis.opendocument.image',
  4378. 'odm' => 'application/vnd.oasis.opendocument.text-master',
  4379. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  4380. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  4381. 'odt' => 'application/vnd.oasis.opendocument.text',
  4382. 'oga' => 'audio/ogg',
  4383. 'ogg' => 'audio/ogg',
  4384. 'ogv' => 'video/ogg',
  4385. 'ogx' => 'application/ogg',
  4386. 'omdoc' => 'application/omdoc+xml',
  4387. 'onepkg' => 'application/onenote',
  4388. 'onetmp' => 'application/onenote',
  4389. 'onetoc' => 'application/onenote',
  4390. 'onetoc2' => 'application/onenote',
  4391. 'opf' => 'application/oebps-package+xml',
  4392. 'opml' => 'text/x-opml',
  4393. 'oprc' => 'application/vnd.palm',
  4394. 'org' => 'application/vnd.lotus-organizer',
  4395. 'osf' => 'application/vnd.yamaha.openscoreformat',
  4396. 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
  4397. 'otc' => 'application/vnd.oasis.opendocument.chart-template',
  4398. 'otf' => 'application/x-font-otf',
  4399. 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
  4400. 'oth' => 'application/vnd.oasis.opendocument.text-web',
  4401. 'oti' => 'application/vnd.oasis.opendocument.image-template',
  4402. 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
  4403. 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  4404. 'ott' => 'application/vnd.oasis.opendocument.text-template',
  4405. 'oxps' => 'application/oxps',
  4406. 'oxt' => 'application/vnd.openofficeorg.extension',
  4407. 'p' => 'text/x-pascal',
  4408. 'p10' => 'application/pkcs10',
  4409. 'p12' => 'application/x-pkcs12',
  4410. 'p7b' => 'application/x-pkcs7-certificates',
  4411. 'p7c' => 'application/pkcs7-mime',
  4412. 'p7m' => 'application/pkcs7-mime',
  4413. 'p7r' => 'application/x-pkcs7-certreqresp',
  4414. 'p7s' => 'application/pkcs7-signature',
  4415. 'p8' => 'application/pkcs8',
  4416. 'pas' => 'text/x-pascal',
  4417. 'paw' => 'application/vnd.pawaafile',
  4418. 'pbd' => 'application/vnd.powerbuilder6',
  4419. 'pbm' => 'image/x-portable-bitmap',
  4420. 'pcap' => 'application/vnd.tcpdump.pcap',
  4421. 'pcf' => 'application/x-font-pcf',
  4422. 'pcl' => 'application/vnd.hp-pcl',
  4423. 'pclxl' => 'application/vnd.hp-pclxl',
  4424. 'pct' => 'image/x-pict',
  4425. 'pcurl' => 'application/vnd.curl.pcurl',
  4426. 'pcx' => 'image/x-pcx',
  4427. 'pdb' => 'application/vnd.palm',
  4428. 'pdf' => 'application/pdf',
  4429. 'pfa' => 'application/x-font-type1',
  4430. 'pfb' => 'application/x-font-type1',
  4431. 'pfm' => 'application/x-font-type1',
  4432. 'pfr' => 'application/font-tdpfr',
  4433. 'pfx' => 'application/x-pkcs12',
  4434. 'pgm' => 'image/x-portable-graymap',
  4435. 'pgn' => 'application/x-chess-pgn',
  4436. 'pgp' => 'application/pgp-encrypted',
  4437. 'pic' => 'image/x-pict',
  4438. 'pkg' => 'application/octet-stream',
  4439. 'pki' => 'application/pkixcmp',
  4440. 'pkipath' => 'application/pkix-pkipath',
  4441. 'plb' => 'application/vnd.3gpp.pic-bw-large',
  4442. 'plc' => 'application/vnd.mobius.plc',
  4443. 'plf' => 'application/vnd.pocketlearn',
  4444. 'pls' => 'application/pls+xml',
  4445. 'pml' => 'application/vnd.ctc-posml',
  4446. 'png' => 'image/png',
  4447. 'pnm' => 'image/x-portable-anymap',
  4448. 'portpkg' => 'application/vnd.macports.portpkg',
  4449. 'pot' => 'application/vnd.ms-powerpoint',
  4450. 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
  4451. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
  4452. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  4453. 'ppd' => 'application/vnd.cups-ppd',
  4454. 'ppm' => 'image/x-portable-pixmap',
  4455. 'pps' => 'application/vnd.ms-powerpoint',
  4456. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  4457. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  4458. 'ppt' => 'application/vnd.ms-powerpoint',
  4459. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  4460. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  4461. 'pqa' => 'application/vnd.palm',
  4462. 'prc' => 'application/x-mobipocket-ebook',
  4463. 'pre' => 'application/vnd.lotus-freelance',
  4464. 'prf' => 'application/pics-rules',
  4465. 'ps' => 'application/postscript',
  4466. 'psb' => 'application/vnd.3gpp.pic-bw-small',
  4467. 'psd' => 'image/vnd.adobe.photoshop',
  4468. 'psf' => 'application/x-font-linux-psf',
  4469. 'pskcxml' => 'application/pskc+xml',
  4470. 'ptid' => 'application/vnd.pvi.ptid1',
  4471. 'pub' => 'application/x-mspublisher',
  4472. 'pvb' => 'application/vnd.3gpp.pic-bw-var',
  4473. 'pwn' => 'application/vnd.3m.post-it-notes',
  4474. 'pya' => 'audio/vnd.ms-playready.media.pya',
  4475. 'pyv' => 'video/vnd.ms-playready.media.pyv',
  4476. 'qam' => 'application/vnd.epson.quickanime',
  4477. 'qbo' => 'application/vnd.intu.qbo',
  4478. 'qfx' => 'application/vnd.intu.qfx',
  4479. 'qps' => 'application/vnd.publishare-delta-tree',
  4480. 'qt' => 'video/quicktime',
  4481. 'qwd' => 'application/vnd.quark.quarkxpress',
  4482. 'qwt' => 'application/vnd.quark.quarkxpress',
  4483. 'qxb' => 'application/vnd.quark.quarkxpress',
  4484. 'qxd' => 'application/vnd.quark.quarkxpress',
  4485. 'qxl' => 'application/vnd.quark.quarkxpress',
  4486. 'qxt' => 'application/vnd.quark.quarkxpress',
  4487. 'ra' => 'audio/x-pn-realaudio',
  4488. 'ram' => 'audio/x-pn-realaudio',
  4489. 'rar' => 'application/x-rar-compressed',
  4490. 'ras' => 'image/x-cmu-raster',
  4491. 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
  4492. 'rdf' => 'application/rdf+xml',
  4493. 'rdz' => 'application/vnd.data-vision.rdz',
  4494. 'rep' => 'application/vnd.businessobjects',
  4495. 'res' => 'application/x-dtbresource+xml',
  4496. 'rgb' => 'image/x-rgb',
  4497. 'rif' => 'application/reginfo+xml',
  4498. 'rip' => 'audio/vnd.rip',
  4499. 'ris' => 'application/x-research-info-systems',
  4500. 'rl' => 'application/resource-lists+xml',
  4501. 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
  4502. 'rld' => 'application/resource-lists-diff+xml',
  4503. 'rm' => 'application/vnd.rn-realmedia',
  4504. 'rmi' => 'audio/midi',
  4505. 'rmp' => 'audio/x-pn-realaudio-plugin',
  4506. 'rms' => 'application/vnd.jcp.javame.midlet-rms',
  4507. 'rmvb' => 'application/vnd.rn-realmedia-vbr',
  4508. 'rnc' => 'application/relax-ng-compact-syntax',
  4509. 'roa' => 'application/rpki-roa',
  4510. 'roff' => 'text/troff',
  4511. 'rp9' => 'application/vnd.cloanto.rp9',
  4512. 'rpss' => 'application/vnd.nokia.radio-presets',
  4513. 'rpst' => 'application/vnd.nokia.radio-preset',
  4514. 'rq' => 'application/sparql-query',
  4515. 'rs' => 'application/rls-services+xml',
  4516. 'rsd' => 'application/rsd+xml',
  4517. 'rss' => 'application/rss+xml',
  4518. 'rtf' => 'application/rtf',
  4519. 'rtx' => 'text/richtext',
  4520. 's' => 'text/x-asm',
  4521. 's3m' => 'audio/s3m',
  4522. 'saf' => 'application/vnd.yamaha.smaf-audio',
  4523. 'sbml' => 'application/sbml+xml',
  4524. 'sc' => 'application/vnd.ibm.secure-container',
  4525. 'scd' => 'application/x-msschedule',
  4526. 'scm' => 'application/vnd.lotus-screencam',
  4527. 'scq' => 'application/scvp-cv-request',
  4528. 'scs' => 'application/scvp-cv-response',
  4529. 'scurl' => 'text/vnd.curl.scurl',
  4530. 'sda' => 'application/vnd.stardivision.draw',
  4531. 'sdc' => 'application/vnd.stardivision.calc',
  4532. 'sdd' => 'application/vnd.stardivision.impress',
  4533. 'sdkd' => 'application/vnd.solent.sdkm+xml',
  4534. 'sdkm' => 'application/vnd.solent.sdkm+xml',
  4535. 'sdp' => 'application/sdp',
  4536. 'sdw' => 'application/vnd.stardivision.writer',
  4537. 'see' => 'application/vnd.seemail',
  4538. 'seed' => 'application/vnd.fdsn.seed',
  4539. 'sema' => 'application/vnd.sema',
  4540. 'semd' => 'application/vnd.semd',
  4541. 'semf' => 'application/vnd.semf',
  4542. 'ser' => 'application/java-serialized-object',
  4543. 'setpay' => 'application/set-payment-initiation',
  4544. 'setreg' => 'application/set-registration-initiation',
  4545. 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
  4546. 'sfs' => 'application/vnd.spotfire.sfs',
  4547. 'sfv' => 'text/x-sfv',
  4548. 'sgi' => 'image/sgi',
  4549. 'sgl' => 'application/vnd.stardivision.writer-global',
  4550. 'sgm' => 'text/sgml',
  4551. 'sgml' => 'text/sgml',
  4552. 'sh' => 'application/x-sh',
  4553. 'shar' => 'application/x-shar',
  4554. 'shf' => 'application/shf+xml',
  4555. 'sid' => 'image/x-mrsid-image',
  4556. 'sig' => 'application/pgp-signature',
  4557. 'sil' => 'audio/silk',
  4558. 'silo' => 'model/mesh',
  4559. 'sis' => 'application/vnd.symbian.install',
  4560. 'sisx' => 'application/vnd.symbian.install',
  4561. 'sit' => 'application/x-stuffit',
  4562. 'sitx' => 'application/x-stuffitx',
  4563. 'skd' => 'application/vnd.koan',
  4564. 'skm' => 'application/vnd.koan',
  4565. 'skp' => 'application/vnd.koan',
  4566. 'skt' => 'application/vnd.koan',
  4567. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  4568. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  4569. 'slt' => 'application/vnd.epson.salt',
  4570. 'sm' => 'application/vnd.stepmania.stepchart',
  4571. 'smf' => 'application/vnd.stardivision.math',
  4572. 'smi' => 'application/smil+xml',
  4573. 'smil' => 'application/smil+xml',
  4574. 'smv' => 'video/x-smv',
  4575. 'smzip' => 'application/vnd.stepmania.package',
  4576. 'snd' => 'audio/basic',
  4577. 'snf' => 'application/x-font-snf',
  4578. 'so' => 'application/octet-stream',
  4579. 'spc' => 'application/x-pkcs7-certificates',
  4580. 'spf' => 'application/vnd.yamaha.smaf-phrase',
  4581. 'spl' => 'application/x-futuresplash',
  4582. 'spot' => 'text/vnd.in3d.spot',
  4583. 'spp' => 'application/scvp-vp-response',
  4584. 'spq' => 'application/scvp-vp-request',
  4585. 'spx' => 'audio/ogg',
  4586. 'sql' => 'application/x-sql',
  4587. 'src' => 'application/x-wais-source',
  4588. 'srt' => 'application/x-subrip',
  4589. 'sru' => 'application/sru+xml',
  4590. 'srx' => 'application/sparql-results+xml',
  4591. 'ssdl' => 'application/ssdl+xml',
  4592. 'sse' => 'application/vnd.kodak-descriptor',
  4593. 'ssf' => 'application/vnd.epson.ssf',
  4594. 'ssml' => 'application/ssml+xml',
  4595. 'st' => 'application/vnd.sailingtracker.track',
  4596. 'stc' => 'application/vnd.sun.xml.calc.template',
  4597. 'std' => 'application/vnd.sun.xml.draw.template',
  4598. 'stf' => 'application/vnd.wt.stf',
  4599. 'sti' => 'application/vnd.sun.xml.impress.template',
  4600. 'stk' => 'application/hyperstudio',
  4601. 'stl' => 'application/vnd.ms-pki.stl',
  4602. 'str' => 'application/vnd.pg.format',
  4603. 'stw' => 'application/vnd.sun.xml.writer.template',
  4604. 'sub' => 'image/vnd.dvb.subtitle',
  4605. 'sub' => 'text/vnd.dvb.subtitle',
  4606. 'sus' => 'application/vnd.sus-calendar',
  4607. 'susp' => 'application/vnd.sus-calendar',
  4608. 'sv4cpio' => 'application/x-sv4cpio',
  4609. 'sv4crc' => 'application/x-sv4crc',
  4610. 'svc' => 'application/vnd.dvb.service',
  4611. 'svd' => 'application/vnd.svd',
  4612. 'svg' => 'image/svg+xml',
  4613. 'svgz' => 'image/svg+xml',
  4614. 'swa' => 'application/x-director',
  4615. 'swf' => 'application/x-shockwave-flash',
  4616. 'swi' => 'application/vnd.aristanetworks.swi',
  4617. 'sxc' => 'application/vnd.sun.xml.calc',
  4618. 'sxd' => 'application/vnd.sun.xml.draw',
  4619. 'sxg' => 'application/vnd.sun.xml.writer.global',
  4620. 'sxi' => 'application/vnd.sun.xml.impress',
  4621. 'sxm' => 'application/vnd.sun.xml.math',
  4622. 'sxw' => 'application/vnd.sun.xml.writer',
  4623. 't' => 'text/troff',
  4624. 't3' => 'application/x-t3vm-image',
  4625. 'taglet' => 'application/vnd.mynfc',
  4626. 'tao' => 'application/vnd.tao.intent-module-archive',
  4627. 'tar' => 'application/x-tar',
  4628. 'tcap' => 'application/vnd.3gpp2.tcap',
  4629. 'tcl' => 'application/x-tcl',
  4630. 'teacher' => 'application/vnd.smart.teacher',
  4631. 'tei' => 'application/tei+xml',
  4632. 'teicorpus' => 'application/tei+xml',
  4633. 'tex' => 'application/x-tex',
  4634. 'texi' => 'application/x-texinfo',
  4635. 'texinfo' => 'application/x-texinfo',
  4636. 'text' => 'text/plain',
  4637. 'tfi' => 'application/thraud+xml',
  4638. 'tfm' => 'application/x-tex-tfm',
  4639. 'tga' => 'image/x-tga',
  4640. 'thmx' => 'application/vnd.ms-officetheme',
  4641. 'tif' => 'image/tiff',
  4642. 'tiff' => 'image/tiff',
  4643. 'tmo' => 'application/vnd.tmobile-livetv',
  4644. 'torrent' => 'application/x-bittorrent',
  4645. 'tpl' => 'application/vnd.groove-tool-template',
  4646. 'tpt' => 'application/vnd.trid.tpt',
  4647. 'tr' => 'text/troff',
  4648. 'tra' => 'application/vnd.trueapp',
  4649. 'trm' => 'application/x-msterminal',
  4650. 'tsd' => 'application/timestamped-data',
  4651. 'tsv' => 'text/tab-separated-values',
  4652. 'ttc' => 'application/x-font-ttf',
  4653. 'ttf' => 'application/x-font-ttf',
  4654. 'ttl' => 'text/turtle',
  4655. 'twd' => 'application/vnd.simtech-mindmapper',
  4656. 'twds' => 'application/vnd.simtech-mindmapper',
  4657. 'txd' => 'application/vnd.genomatix.tuxedo',
  4658. 'txf' => 'application/vnd.mobius.txf',
  4659. 'txt' => 'text/plain',
  4660. 'u32' => 'application/x-authorware-bin',
  4661. 'udeb' => 'application/x-debian-package',
  4662. 'ufd' => 'application/vnd.ufdl',
  4663. 'ufdl' => 'application/vnd.ufdl',
  4664. 'ulx' => 'application/x-glulx',
  4665. 'umj' => 'application/vnd.umajin',
  4666. 'unityweb' => 'application/vnd.unity',
  4667. 'uoml' => 'application/vnd.uoml+xml',
  4668. 'uri' => 'text/uri-list',
  4669. 'uris' => 'text/uri-list',
  4670. 'urls' => 'text/uri-list',
  4671. 'ustar' => 'application/x-ustar',
  4672. 'utz' => 'application/vnd.uiq.theme',
  4673. 'uu' => 'text/x-uuencode',
  4674. 'uva' => 'audio/vnd.dece.audio',
  4675. 'uvd' => 'application/vnd.dece.data',
  4676. 'uvf' => 'application/vnd.dece.data',
  4677. 'uvg' => 'image/vnd.dece.graphic',
  4678. 'uvh' => 'video/vnd.dece.hd',
  4679. 'uvi' => 'image/vnd.dece.graphic',
  4680. 'uvm' => 'video/vnd.dece.mobile',
  4681. 'uvp' => 'video/vnd.dece.pd',
  4682. 'uvs' => 'video/vnd.dece.sd',
  4683. 'uvt' => 'application/vnd.dece.ttml+xml',
  4684. 'uvu' => 'video/vnd.uvvu.mp4',
  4685. 'uvv' => 'video/vnd.dece.video',
  4686. 'uvva' => 'audio/vnd.dece.audio',
  4687. 'uvvd' => 'application/vnd.dece.data',
  4688. 'uvvf' => 'application/vnd.dece.data',
  4689. 'uvvg' => 'image/vnd.dece.graphic',
  4690. 'uvvh' => 'video/vnd.dece.hd',
  4691. 'uvvi' => 'image/vnd.dece.graphic',
  4692. 'uvvm' => 'video/vnd.dece.mobile',
  4693. 'uvvp' => 'video/vnd.dece.pd',
  4694. 'uvvs' => 'video/vnd.dece.sd',
  4695. 'uvvt' => 'application/vnd.dece.ttml+xml',
  4696. 'uvvu' => 'video/vnd.uvvu.mp4',
  4697. 'uvvv' => 'video/vnd.dece.video',
  4698. 'uvvx' => 'application/vnd.dece.unspecified',
  4699. 'uvvz' => 'application/vnd.dece.zip',
  4700. 'uvx' => 'application/vnd.dece.unspecified',
  4701. 'uvz' => 'application/vnd.dece.zip',
  4702. 'vcard' => 'text/vcard',
  4703. 'vcd' => 'application/x-cdlink',
  4704. 'vcf' => 'text/x-vcard',
  4705. 'vcg' => 'application/vnd.groove-vcard',
  4706. 'vcs' => 'text/x-vcalendar',
  4707. 'vcx' => 'application/vnd.vcx',
  4708. 'vis' => 'application/vnd.visionary',
  4709. 'viv' => 'video/vnd.vivo',
  4710. 'vob' => 'video/x-ms-vob',
  4711. 'vor' => 'application/vnd.stardivision.writer',
  4712. 'vox' => 'application/x-authorware-bin',
  4713. 'vrml' => 'model/vrml',
  4714. 'vsd' => 'application/vnd.visio',
  4715. 'vsf' => 'application/vnd.vsf',
  4716. 'vss' => 'application/vnd.visio',
  4717. 'vst' => 'application/vnd.visio',
  4718. 'vsw' => 'application/vnd.visio',
  4719. 'vtu' => 'model/vnd.vtu',
  4720. 'vxml' => 'application/voicexml+xml',
  4721. 'w3d' => 'application/x-director',
  4722. 'wad' => 'application/x-doom',
  4723. 'wav' => 'audio/x-wav',
  4724. 'wax' => 'audio/x-ms-wax',
  4725. 'wbmp' => 'image/vnd.wap.wbmp',
  4726. 'wbs' => 'application/vnd.criticaltools.wbs+xml',
  4727. 'wbxml' => 'application/vnd.wap.wbxml',
  4728. 'wcm' => 'application/vnd.ms-works',
  4729. 'wdb' => 'application/vnd.ms-works',
  4730. 'wdp' => 'image/vnd.ms-photo',
  4731. 'weba' => 'audio/webm',
  4732. 'webm' => 'video/webm',
  4733. 'webp' => 'image/webp',
  4734. 'wg' => 'application/vnd.pmi.widget',
  4735. 'wgt' => 'application/widget',
  4736. 'wks' => 'application/vnd.ms-works',
  4737. 'wm' => 'video/x-ms-wm',
  4738. 'wma' => 'audio/x-ms-wma',
  4739. 'wmd' => 'application/x-ms-wmd',
  4740. 'wmf' => 'application/x-msmetafile',
  4741. 'wml' => 'text/vnd.wap.wml',
  4742. 'wmlc' => 'application/vnd.wap.wmlc',
  4743. 'wmls' => 'text/vnd.wap.wmlscript',
  4744. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  4745. 'wmv' => 'video/x-ms-wmv',
  4746. 'wmx' => 'video/x-ms-wmx',
  4747. 'wmz' => 'application/x-ms-wmz',
  4748. 'wmz' => 'application/x-msmetafile',
  4749. 'woff' => 'application/font-woff',
  4750. 'wpd' => 'application/vnd.wordperfect',
  4751. 'wpl' => 'application/vnd.ms-wpl',
  4752. 'wps' => 'application/vnd.ms-works',
  4753. 'wqd' => 'application/vnd.wqd',
  4754. 'wri' => 'application/x-mswrite',
  4755. 'wrl' => 'model/vrml',
  4756. 'wsdl' => 'application/wsdl+xml',
  4757. 'wspolicy' => 'application/wspolicy+xml',
  4758. 'wtb' => 'application/vnd.webturbo',
  4759. 'wvx' => 'video/x-ms-wvx',
  4760. 'x32' => 'application/x-authorware-bin',
  4761. 'x3d' => 'model/x3d+xml',
  4762. 'x3db' => 'model/x3d+binary',
  4763. 'x3dbz' => 'model/x3d+binary',
  4764. 'x3dv' => 'model/x3d+vrml',
  4765. 'x3dvz' => 'model/x3d+vrml',
  4766. 'x3dz' => 'model/x3d+xml',
  4767. 'xaml' => 'application/xaml+xml',
  4768. 'xap' => 'application/x-silverlight-app',
  4769. 'xar' => 'application/vnd.xara',
  4770. 'xbap' => 'application/x-ms-xbap',
  4771. 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
  4772. 'xbm' => 'image/x-xbitmap',
  4773. 'xdf' => 'application/xcap-diff+xml',
  4774. 'xdm' => 'application/vnd.syncml.dm+xml',
  4775. 'xdp' => 'application/vnd.adobe.xdp+xml',
  4776. 'xdssc' => 'application/dssc+xml',
  4777. 'xdw' => 'application/vnd.fujixerox.docuworks',
  4778. 'xenc' => 'application/xenc+xml',
  4779. 'xer' => 'application/patch-ops-error+xml',
  4780. 'xfdf' => 'application/vnd.adobe.xfdf',
  4781. 'xfdl' => 'application/vnd.xfdl',
  4782. 'xht' => 'application/xhtml+xml',
  4783. 'xhtml' => 'application/xhtml+xml',
  4784. 'xhvml' => 'application/xv+xml',
  4785. 'xif' => 'image/vnd.xiff',
  4786. 'xla' => 'application/vnd.ms-excel',
  4787. 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
  4788. 'xlc' => 'application/vnd.ms-excel',
  4789. 'xlf' => 'application/x-xliff+xml',
  4790. 'xlm' => 'application/vnd.ms-excel',
  4791. 'xls' => 'application/vnd.ms-excel',
  4792. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  4793. 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
  4794. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  4795. 'xlt' => 'application/vnd.ms-excel',
  4796. 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
  4797. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  4798. 'xlw' => 'application/vnd.ms-excel',
  4799. 'xm' => 'audio/xm',
  4800. 'xml' => 'application/xml',
  4801. 'xo' => 'application/vnd.olpc-sugar',
  4802. 'xop' => 'application/xop+xml',
  4803. 'xpi' => 'application/x-xpinstall',
  4804. 'xpl' => 'application/xproc+xml',
  4805. 'xpm' => 'image/x-xpixmap',
  4806. 'xpr' => 'application/vnd.is-xpr',
  4807. 'xps' => 'application/vnd.ms-xpsdocument',
  4808. 'xpw' => 'application/vnd.intercon.formnet',
  4809. 'xpx' => 'application/vnd.intercon.formnet',
  4810. 'xsl' => 'application/xml',
  4811. 'xslt' => 'application/xslt+xml',
  4812. 'xsm' => 'application/vnd.syncml+xml',
  4813. 'xspf' => 'application/xspf+xml',
  4814. 'xul' => 'application/vnd.mozilla.xul+xml',
  4815. 'xvm' => 'application/xv+xml',
  4816. 'xvml' => 'application/xv+xml',
  4817. 'xwd' => 'image/x-xwindowdump',
  4818. 'xyz' => 'chemical/x-xyz',
  4819. 'xz' => 'application/x-xz',
  4820. 'yang' => 'application/yang',
  4821. 'yin' => 'application/yin+xml',
  4822. 'z1' => 'application/x-zmachine',
  4823. 'z2' => 'application/x-zmachine',
  4824. 'z3' => 'application/x-zmachine',
  4825. 'z4' => 'application/x-zmachine',
  4826. 'z5' => 'application/x-zmachine',
  4827. 'z6' => 'application/x-zmachine',
  4828. 'z7' => 'application/x-zmachine',
  4829. 'z8' => 'application/x-zmachine',
  4830. 'zaz' => 'application/vnd.zzazz.deck+xml',
  4831. 'zip' => 'application/zip',
  4832. 'zir' => 'application/vnd.zul',
  4833. 'zirz' => 'application/vnd.zul',
  4834. 'zmm' => 'application/vnd.handheld-entertainment+xml'
  4835. );
  4836. }
  4837. // Always run this
  4838. dependCheck();