filemanager.php 194 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632
  1. <?php
  2. //Default Configuration
  3. $CONFIG = '{"lang":"en","error_reporting":false,"show_hidden":false,"hide_Cols":false,"calc_folder":false}';
  4. /**
  5. * H3K | Tiny File Manager V2.4.3
  6. * CCP Programmers | ccpprogrammers@gmail.com
  7. * https://tinyfilemanager.github.io
  8. */
  9. //TFM version
  10. define('VERSION', '2.4.3');
  11. //Application Title
  12. define('APP_TITLE', '超级蚂蚁');
  13. // --- EDIT BELOW CONFIGURATION CAREFULLY ---
  14. define('DOCUMENT_ROOT',$_SERVER['DOCUMENT_ROOT']);
  15. /*
  16. #################################################################################################################
  17. This is an OPTIONAL configuration file.
  18. The role of this file is to make updating of "tinyfilemanager.php" easier.
  19. So you can:
  20. -Feel free to remove completely this file and configure "tinyfilemanager.php" as a single file application.
  21. or
  22. -Put inside this file all the static configuration you want and forgot to configure "tinyfilemanager.php".
  23. #################################################################################################################
  24. */
  25. // Auth with login/password
  26. // set true/false to enable/disable it
  27. // Is independent from IP white- and blacklisting
  28. $use_auth = true;
  29. // Login user name and password
  30. // Users: array('Username' => 'Password', 'Username2' => 'Password2', ...)
  31. // Generate secure password hash - https://tinyfilemanager.github.io/docs/pwd.html
  32. $auth_users = array(
  33. 'dev' => 'a9d5de7d15a202a7',
  34. 'admin' => '6nnBG%bnqk',
  35. 'other' => 'superant',
  36. 'firebase' => 'firebase',
  37. 'share' => 'share',
  38. 'activity' => 'activity',
  39. 'announcement' => 'announcement',
  40. 'clientErrorLogFiles' => 'clientErrorLogFiles',
  41. 'cardImgManage' => 'cardImgManage',
  42. );
  43. $max_upload_size = [
  44. 'dev' => 5,
  45. 'admin' => 5,
  46. 'other' => 5,
  47. 'firebase' => 0.5,
  48. 'share' => 0.5,
  49. 'activity' => 0.5,
  50. 'announcement' => 0.5,
  51. ];
  52. //set application theme
  53. //options - 'light' and 'dark'
  54. $theme = 'light';
  55. define('FM_THEME', $theme);
  56. // Readonly users
  57. // e.g. array('users', 'guest', ...)
  58. $readonly_users = [
  59. ];
  60. $delete_users = [
  61. 'admin',
  62. 'share'
  63. ];
  64. // Enable highlight.js (https://highlightjs.org/) on view's page
  65. $use_highlightjs = true;
  66. // highlight.js style
  67. // for dark theme use 'ir-black'
  68. $highlightjs_style = 'vs';
  69. // Enable ace.js (https://ace.c9.io/) on view's page
  70. $edit_files = true;
  71. // Default timezone for date() and time()
  72. // Doc - http://php.net/manual/en/timezones.php
  73. $default_timezone = 'Etc/UTC'; // UTC
  74. // Root path for file manager
  75. // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
  76. $root_path = $_SERVER['DOCUMENT_ROOT'];
  77. // Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
  78. // Will not working if $root_path will be outside of server document root
  79. $root_url = '';
  80. // Server hostname. Can set manually if wrong
  81. $http_host = $_SERVER['HTTP_HOST'];
  82. // user specific directories
  83. // array('Username' => 'Directory path', 'Username2' => 'Directory path', ...)
  84. $directories_users = [
  85. 'dev' => 'public/game/',
  86. 'firebase' => 'public/game/image/firebase/',
  87. 'share' => 'img/feed/',
  88. 'activity' => 'public/game/image/activity_2/',
  89. 'announcement' => 'public/game/image/announcement/',
  90. 'clientErrorLogFiles' => 'deBUG/clientErrorLogFiles/',
  91. 'cardImgManage' => 'public/game/image/newcard/',
  92. ];
  93. // input encoding for iconv
  94. $iconv_input_encoding = 'UTF-8';
  95. // date() format for file modification date
  96. // Doc - https://www.php.net/manual/en/function.date.php
  97. $datetime_format = 'Y-m-d H:i';
  98. // Allowed file extensions for create and rename files
  99. // e.g. 'txt,html,css,js'
  100. $allowed_file_extensions = '';
  101. // Allowed file extensions for upload files
  102. // e.g. 'gif,png,jpg,html,txt'
  103. $allowed_upload_extensions = '';
  104. // Favicon path. This can be either a full url to an .PNG image, or a path based on the document root.
  105. // full path, e.g http://example.com/favicon.png
  106. // local path, e.g images/icons/favicon.png
  107. $favicon_path = '?img=favicon';
  108. // Files and folders to excluded from listing
  109. // e.g. array('myfile.html', 'personal-folder', '*.php', ...)
  110. $exclude_items = array();
  111. // Online office Docs Viewer
  112. // Availabe rules are 'google', 'microsoft' or false
  113. // google => View documents using Google Docs Viewer
  114. // microsoft => View documents using Microsoft Web Apps Viewer
  115. // false => disable online doc viewer
  116. $online_viewer = 'google';
  117. // Sticky Nav bar
  118. // true => enable sticky header
  119. // false => disable sticky header
  120. $sticky_navbar = true;
  121. // Possible rules are 'OFF', 'AND' or 'OR'
  122. // OFF => Don't check connection IP, defaults to OFF
  123. // AND => Connection must be on the whitelist, and not on the blacklist
  124. // OR => Connection must be on the whitelist, or not on the blacklist
  125. $ip_ruleset = 'OFF';
  126. // Should users be notified of their block?
  127. $ip_silent = true;
  128. // IP-addresses, both ipv4 and ipv6
  129. $ip_whitelist = array(
  130. '127.0.0.1', // local ipv4
  131. '::1' // local ipv6
  132. );
  133. // IP-addresses, both ipv4 and ipv6
  134. $ip_blacklist = array(
  135. '0.0.0.0', // non-routable meta ipv4
  136. '::' // non-routable meta ipv6
  137. );
  138. // --- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL ---
  139. // max upload file size
  140. $max_upload_size_bytes = 0.2;//单位MB
  141. // private key and session name to store to the session
  142. if ( !defined( 'FM_SESSION_ID')) {
  143. define('FM_SESSION_ID', 'filemanager_'.$_GET['fm_usr']);
  144. }
  145. // Configuration
  146. $cfg = new FM_Config();
  147. // Default language
  148. $lang = isset($cfg->data['lang']) ? $cfg->data['lang'] : 'en';
  149. // Show or hide files and folders that starts with a dot
  150. $show_hidden_files = isset($cfg->data['show_hidden']) ? $cfg->data['show_hidden'] : true;
  151. // PHP error reporting - false = Turns off Errors, true = Turns on Errors
  152. $report_errors = isset($cfg->data['error_reporting']) ? $cfg->data['error_reporting'] : true;
  153. // Hide Permissions and Owner cols in file-listing
  154. $hide_Cols = isset($cfg->data['hide_Cols']) ? $cfg->data['hide_Cols'] : true;
  155. // Show directory size: true or speedup output: false
  156. $calc_folder = isset($cfg->data['calc_folder']) ? $cfg->data['calc_folder'] : true;
  157. //available languages
  158. $lang_list = array(
  159. 'en' => 'English'
  160. );
  161. if ($report_errors == true) {
  162. @ini_set('error_reporting', E_ALL);
  163. @ini_set('display_errors', 1);
  164. } else {
  165. @ini_set('error_reporting', E_ALL);
  166. @ini_set('display_errors', 0);
  167. }
  168. // if fm included
  169. if (defined('FM_EMBED')) {
  170. $use_auth = false;
  171. $sticky_navbar = false;
  172. } else {
  173. @set_time_limit(600);
  174. date_default_timezone_set($default_timezone);
  175. ini_set('default_charset', 'UTF-8');
  176. if (version_compare(PHP_VERSION, '5.6.0', '<') && function_exists('mb_internal_encoding')) {
  177. mb_internal_encoding('UTF-8');
  178. }
  179. if (function_exists('mb_regex_encoding')) {
  180. mb_regex_encoding('UTF-8');
  181. }
  182. session_cache_limiter('');
  183. session_name(FM_SESSION_ID );
  184. function session_error_handling_function($code, $msg, $file, $line) {
  185. // Permission denied for default session, try to create a new one
  186. if ($code == 2) {
  187. session_abort();
  188. session_id(session_create_id());
  189. @session_start();
  190. }
  191. }
  192. set_error_handler('session_error_handling_function');
  193. session_start();
  194. restore_error_handler();
  195. }
  196. if (empty($auth_users)) {
  197. $use_auth = false;
  198. }
  199. if($_SESSION[FM_SESSION_ID]['logged'] == "share"){
  200. $directories_users["share"] = $directories_users["share"].$_SESSION[FM_SESSION_ID]['shareCountry']."/";
  201. }else if($_SESSION[FM_SESSION_ID]['logged'] == "activity"){
  202. $directories_users["activity"] = $directories_users["activity"].$_SESSION[FM_SESSION_ID]['activityPath']."/";
  203. }
  204. if(!empty($max_upload_size[$_SESSION[FM_SESSION_ID]['logged']])){
  205. $max_upload_size_bytes = $max_upload_size[$_SESSION[FM_SESSION_ID]['logged']];
  206. }
  207. // max upload file size
  208. define('MAX_UPLOAD_SIZE', $max_upload_size_bytes);
  209. $is_https = isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https';
  210. // update $root_url based on user specific directories
  211. if (isset($_SESSION[FM_SESSION_ID]['logged']) && !empty($directories_users[$_SESSION[FM_SESSION_ID]['logged']])) {
  212. $wd = fm_clean_path(dirname($_SERVER['PHP_SELF']));
  213. $root_url = $root_url.$wd.DIRECTORY_SEPARATOR.$directories_users[$_SESSION[FM_SESSION_ID]['logged']];
  214. }
  215. // clean $root_url
  216. $root_url = fm_clean_path($root_url);
  217. // abs path for site
  218. defined('FM_ROOT_URL') || define('FM_ROOT_URL', ($is_https ? 'https' : 'http') . '://' . $http_host . (!empty($root_url) ? '/' . $root_url : ''));
  219. defined('FM_SELF_URL') || define('FM_SELF_URL', ($is_https ? 'https' : 'http') . '://' . $http_host . $_SERVER['PHP_SELF']);
  220. // logout
  221. if (isset($_GET['logout'])) {
  222. unset($_SESSION[FM_SESSION_ID]['logged']);
  223. fm_redirect(FM_SELF_URL);
  224. }
  225. // Show image here
  226. if (isset($_GET['img'])) {
  227. fm_show_image($_GET['img']);
  228. }
  229. // Validate connection IP
  230. if($ip_ruleset != 'OFF'){
  231. $clientIp = $_SERVER['REMOTE_ADDR'];
  232. $proceed = false;
  233. $whitelisted = in_array($clientIp, $ip_whitelist);
  234. $blacklisted = in_array($clientIp, $ip_blacklist);
  235. if($ip_ruleset == 'AND'){
  236. if($whitelisted == true && $blacklisted == false){
  237. $proceed = true;
  238. }
  239. } else
  240. if($ip_ruleset == 'OR'){
  241. if($whitelisted == true || $blacklisted == false){
  242. $proceed = true;
  243. }
  244. }
  245. if($proceed == false){
  246. trigger_error('User connection denied from: ' . $clientIp, E_USER_WARNING);
  247. if($ip_silent == false){
  248. fm_set_msg('Access denied. IP restriction applicable', 'error');
  249. fm_show_header_login();
  250. fm_show_message();
  251. }
  252. exit();
  253. }
  254. }
  255. function login($auth_users){
  256. // Logging In
  257. if (function_exists('password_verify')) {
  258. if (isset($auth_users[$_GET['fm_usr']]) && isset($_GET['fm_pwd']) && $_GET['fm_pwd'] == $auth_users[$_GET['fm_usr']]) {
  259. $_SESSION[FM_SESSION_ID]['logged'] = $_GET['fm_usr'];
  260. $_SESSION[FM_SESSION_ID]['userName'] = $_GET['userName'];
  261. if(!empty($_GET['shareCountry'])){
  262. $_SESSION[FM_SESSION_ID]['shareCountry'] = $_GET['shareCountry'];
  263. }
  264. if(!empty($_GET['activityPath'])){
  265. $_SESSION[FM_SESSION_ID]['activityPath'] = $_GET['activityPath'];
  266. }
  267. fm_set_msg(lng('You are logged in'));
  268. fm_redirect(FM_SELF_URL . '?fm_usr=' . $_GET['fm_usr'] . '&p=');
  269. } else {
  270. unset($_SESSION[FM_SESSION_ID]['logged']);
  271. fm_set_msg(lng('Login failed. Invalid username or password'), 'error');
  272. fm_redirect(FM_SELF_URL);
  273. }
  274. } else {
  275. fm_set_msg(lng('password_hash not supported, Upgrade PHP version'), 'error');;
  276. }
  277. }
  278. // Auth
  279. if ($use_auth) {
  280. if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_ID]['logged']])) {
  281. if (isset($_GET['fm_usr'], $_GET['fm_pwd'])) {
  282. login($auth_users);
  283. }
  284. } elseif (isset($_GET['fm_usr'], $_GET['fm_pwd'])) {
  285. login($auth_users);
  286. } else {
  287. // Form
  288. unset($_SESSION[FM_SESSION_ID]['logged']);
  289. die();
  290. fm_show_header_login();
  291. ?>
  292. <section class="h-100">
  293. <div class="container h-100">
  294. <div class="row justify-content-md-center h-100">
  295. <div class="card-wrapper">
  296. <div class="card fat <?php echo fm_get_theme(); ?>">
  297. <div class="card-body">
  298. <form class="form-signin" action="" method="post" autocomplete="off">
  299. <div class="form-group">
  300. <div class="brand">
  301. <svg version="1.0" xmlns="http://www.w3.org/2000/svg" M1008 width="100%" height="80px" viewBox="0 0 238.000000 140.000000" aria-label="H3K Tiny File Manager">
  302. <g transform="translate(0.000000,140.000000) scale(0.100000,-0.100000)" fill="#000000" stroke="none">
  303. <path d="M160 700 l0 -600 110 0 110 0 0 260 0 260 70 0 70 0 0 -260 0 -260 110 0 110 0 0 600 0 600 -110 0 -110 0 0 -260 0 -260 -70 0 -70 0 0 260 0 260 -110 0 -110 0 0 -600z"/>
  304. <path fill="#003500" d="M1008 1227 l-108 -72 0 -117 0 -118 110 0 110 0 0 110 0 110 70 0 70 0 0 -180 0 -180 -125 0 c-69 0 -125 -3 -125 -6 0 -3 23 -39 52 -80 l52 -74 73 0 73 0 0 -185 0 -185 -70 0 -70 0 0 115 0 115 -110 0 -110 0 0 -190 0 -190 181 0 181 0 109 73 108 72 1 181 0 181 -69 48 -68 49 68 50 69 49 0 249 0 248 -182 -1 -183 0 -107 -72z"/>
  305. <path d="M1640 700 l0 -600 110 0 110 0 0 208 0 208 35 34 35 34 35 -34 35 -34 0 -208 0 -208 110 0 110 0 0 212 0 213 -87 87 -88 88 88 88 87 87 0 213 0 212 -110 0 -110 0 0 -208 0 -208 -70 -69 -70 -69 0 277 0 277 -110 0 -110 0 0 -600z"/></g>
  306. </svg>
  307. </div>
  308. <div class="text-center">
  309. <h1 class="card-title"><?php echo APP_TITLE; ?></h1>
  310. </div>
  311. </div>
  312. <hr />
  313. <div class="form-group">
  314. <label for="fm_usr"><?php echo lng('Username'); ?></label>
  315. <input type="text" class="form-control" id="fm_usr" name="fm_usr" required autofocus>
  316. </div>
  317. <div class="form-group">
  318. <label for="fm_pwd"><?php echo lng('Password'); ?></label>
  319. <input type="password" class="form-control" id="fm_pwd" name="fm_pwd" required>
  320. </div>
  321. <div class="form-group">
  322. <?php fm_show_message(); ?>
  323. </div>
  324. <div class="form-group">
  325. <button type="submit" class="btn btn-success btn-block mt-4" role="button">
  326. <?php echo lng('Login'); ?>
  327. </button>
  328. </div>
  329. </form>
  330. </div>
  331. </div>
  332. <div class="footer text-center">
  333. &mdash;&mdash; &copy;
  334. <a href="https://tinyfilemanager.github.io/" target="_blank" class="text-muted" data-version="<?php echo VERSION; ?>">CCP Programmers</a> &mdash;&mdash;
  335. </div>
  336. </div>
  337. </div>
  338. </div>
  339. </section>
  340. <?php
  341. fm_show_footer_login();
  342. exit;
  343. }
  344. }
  345. // update root path
  346. if ($use_auth && isset($_SESSION[FM_SESSION_ID]['logged'])) {
  347. $root_path = isset($directories_users[$_SESSION[FM_SESSION_ID]['logged']]) ? $directories_users[$_SESSION[FM_SESSION_ID]['logged']] : $root_path;
  348. }
  349. // clean and check $root_path
  350. $root_path = rtrim($root_path, '\\/');
  351. $root_path = str_replace('\\', '/', $root_path);
  352. if (!@is_dir($root_path)) {
  353. echo "<h1>Root path \"{$root_path}\" not found!</h1>";
  354. exit;
  355. }
  356. defined('FM_SHOW_HIDDEN') || define('FM_SHOW_HIDDEN', $show_hidden_files);
  357. defined('FM_ROOT_PATH') || define('FM_ROOT_PATH', $root_path);
  358. defined('FM_LANG') || define('FM_LANG', $lang);
  359. defined('FM_FILE_EXTENSION') || define('FM_FILE_EXTENSION', $allowed_file_extensions);
  360. defined('FM_UPLOAD_EXTENSION') || define('FM_UPLOAD_EXTENSION', $allowed_upload_extensions);
  361. defined('FM_EXCLUDE_ITEMS') || define('FM_EXCLUDE_ITEMS', $exclude_items);
  362. defined('FM_DOC_VIEWER') || define('FM_DOC_VIEWER', $online_viewer);
  363. define('FM_READONLY', $use_auth && !empty($readonly_users) && isset($_SESSION[FM_SESSION_ID]['logged']) && in_array($_SESSION[FM_SESSION_ID]['logged'], $readonly_users));
  364. define('FM_DELETE', $use_auth && !empty($delete_users) && isset($_SESSION[FM_SESSION_ID]['logged']) && in_array($_SESSION[FM_SESSION_ID]['logged'], $delete_users));
  365. define('FM_IS_WIN', DIRECTORY_SEPARATOR == '\\');
  366. // always use ?p=
  367. if (!isset($_GET['p']) && empty($_FILES)) {
  368. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=');
  369. }
  370. // get path
  371. $p = isset($_GET['p']) ? $_GET['p'] : (isset($_POST['p']) ? $_POST['p'] : '');
  372. // clean path
  373. $p = fm_clean_path($p);
  374. // for ajax request - save
  375. $input = file_get_contents('php://input');
  376. $_POST = (strpos($input, 'ajax') != FALSE && strpos($input, 'save') != FALSE) ? json_decode($input, true) : $_POST;
  377. // instead globals vars
  378. define('FM_PATH', $p);
  379. define('FM_USE_AUTH', $use_auth);
  380. define('FM_EDIT_FILE', $edit_files);
  381. defined('FM_ICONV_INPUT_ENC') || define('FM_ICONV_INPUT_ENC', $iconv_input_encoding);
  382. defined('FM_USE_HIGHLIGHTJS') || define('FM_USE_HIGHLIGHTJS', $use_highlightjs);
  383. defined('FM_HIGHLIGHTJS_STYLE') || define('FM_HIGHLIGHTJS_STYLE', $highlightjs_style);
  384. defined('FM_DATETIME_FORMAT') || define('FM_DATETIME_FORMAT', $datetime_format);
  385. unset($p, $use_auth, $iconv_input_encoding, $use_highlightjs, $highlightjs_style);
  386. /*************************** ACTIONS ***************************/
  387. // AJAX Request
  388. if (isset($_POST['ajax']) && !FM_READONLY) {
  389. // save
  390. if (isset($_POST['type']) && $_POST['type'] == "save") {
  391. // get current path
  392. $path = FM_ROOT_PATH;
  393. if (FM_PATH != '') {
  394. $path .= '/' . FM_PATH;
  395. }
  396. // check path
  397. if (!is_dir($path)) {
  398. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=');
  399. }
  400. $file = $_GET['edit'];
  401. $file = fm_clean_path($file);
  402. $file = str_replace('/', '', $file);
  403. if ($file == '' || !is_file($path . '/' . $file)) {
  404. fm_set_msg('File not found', 'error');
  405. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  406. }
  407. header('X-XSS-Protection:0');
  408. $file_path = $path . '/' . $file;
  409. $writedata = $_POST['content'];
  410. $fd = fopen($file_path, "w");
  411. $write_results = @fwrite($fd, $writedata);
  412. fclose($fd);
  413. if ($write_results === false){
  414. header("HTTP/1.1 500 Internal Server Error");
  415. die("Could Not Write File! - Check Permissions / Ownership");
  416. }
  417. die(true);
  418. }
  419. //search : get list of files from the current folder
  420. if(isset($_POST['type']) && $_POST['type']=="search") {
  421. $dir = FM_ROOT_PATH;
  422. $response = scan(fm_clean_path($_POST['path']), $_POST['content']);
  423. echo json_encode($response);
  424. exit();
  425. }
  426. // backup files
  427. if (isset($_POST['type']) && $_POST['type'] == "backup" && !empty($_POST['file'])) {
  428. $fileName = $_POST['file'];
  429. $fullPath = FM_ROOT_PATH . '/';
  430. if (!empty($_POST['path'])) {
  431. $relativeDirPath = fm_clean_path($_POST['path']);
  432. $fullPath .= "{$relativeDirPath}/";
  433. }
  434. $date = date("dMy-His");
  435. $newFileName = "{$fileName}-{$date}.bak";
  436. $fullyQualifiedFileName = $fullPath . $fileName;
  437. try {
  438. if (!file_exists($fullyQualifiedFileName)) {
  439. throw new Exception("File {$fileName} not found");
  440. }
  441. if (copy($fullyQualifiedFileName, $fullPath . $newFileName)) {
  442. echo "Backup {$newFileName} created";
  443. } else {
  444. throw new Exception("Could not copy file {$fileName}");
  445. }
  446. } catch (Exception $e) {
  447. echo $e->getMessage();
  448. }
  449. }
  450. // Save Config
  451. if (isset($_POST['type']) && $_POST['type'] == "settings") {
  452. global $cfg, $lang, $report_errors, $show_hidden_files, $lang_list, $hide_Cols, $calc_folder;
  453. $newLng = $_POST['js-language'];
  454. fm_get_translations([]);
  455. if (!array_key_exists($newLng, $lang_list)) {
  456. $newLng = 'en';
  457. }
  458. $erp = isset($_POST['js-error-report']) && $_POST['js-error-report'] == "true" ? true : false;
  459. $shf = isset($_POST['js-show-hidden']) && $_POST['js-show-hidden'] == "true" ? true : false;
  460. $hco = isset($_POST['js-hide-cols']) && $_POST['js-hide-cols'] == "true" ? true : false;
  461. $caf = isset($_POST['js-calc-folder']) && $_POST['js-calc-folder'] == "true" ? true : false;
  462. if ($cfg->data['lang'] != $newLng) {
  463. $cfg->data['lang'] = $newLng;
  464. $lang = $newLng;
  465. }
  466. if ($cfg->data['error_reporting'] != $erp) {
  467. $cfg->data['error_reporting'] = $erp;
  468. $report_errors = $erp;
  469. }
  470. if ($cfg->data['show_hidden'] != $shf) {
  471. $cfg->data['show_hidden'] = $shf;
  472. $show_hidden_files = $shf;
  473. }
  474. if ($cfg->data['show_hidden'] != $shf) {
  475. $cfg->data['show_hidden'] = $shf;
  476. $show_hidden_files = $shf;
  477. }
  478. if ($cfg->data['hide_Cols'] != $hco) {
  479. $cfg->data['hide_Cols'] = $hco;
  480. $hide_Cols = $hco;
  481. }
  482. if ($cfg->data['calc_folder'] != $caf) {
  483. $cfg->data['calc_folder'] = $caf;
  484. $calc_folder = $caf;
  485. }
  486. $cfg->save();
  487. echo true;
  488. }
  489. // new password hash
  490. if (isset($_POST['type']) && $_POST['type'] == "pwdhash") {
  491. $res = isset($_POST['inputPassword2']) && !empty($_POST['inputPassword2']) ? password_hash($_POST['inputPassword2'], PASSWORD_DEFAULT) : '';
  492. echo $res;
  493. }
  494. //upload using url
  495. if(isset($_POST['type']) && $_POST['type'] == "upload" && !empty($_REQUEST["uploadurl"])) {
  496. $path = FM_ROOT_PATH;
  497. if (FM_PATH != '') {
  498. $path .= '/' . FM_PATH;
  499. }
  500. $url = !empty($_REQUEST["uploadurl"]) && preg_match("|^http(s)?://.+$|", stripslashes($_REQUEST["uploadurl"])) ? stripslashes($_REQUEST["uploadurl"]) : null;
  501. $use_curl = false;
  502. $temp_file = tempnam(sys_get_temp_dir(), "upload-");
  503. $fileinfo = new stdClass();
  504. $fileinfo->name = trim(basename($url), ".\x00..\x20");
  505. $allowed = (FM_UPLOAD_EXTENSION) ? explode(',', FM_UPLOAD_EXTENSION) : false;
  506. $ext = strtolower(pathinfo($fileinfo->name, PATHINFO_EXTENSION));
  507. $isFileAllowed = ($allowed) ? in_array($ext, $allowed) : true;
  508. function event_callback ($message) {
  509. global $callback;
  510. echo json_encode($message);
  511. }
  512. function get_file_path () {
  513. global $path, $fileinfo, $temp_file;
  514. return $path."/".basename($fileinfo->name);
  515. }
  516. $err = false;
  517. if(!$isFileAllowed) {
  518. $err = array("message" => "File extension is not allowed");
  519. event_callback(array("fail" => $err));
  520. exit();
  521. }
  522. if (!$url) {
  523. $success = false;
  524. } else if ($use_curl) {
  525. @$fp = fopen($temp_file, "w");
  526. @$ch = curl_init($url);
  527. curl_setopt($ch, CURLOPT_NOPROGRESS, false );
  528. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  529. curl_setopt($ch, CURLOPT_FILE, $fp);
  530. @$success = curl_exec($ch);
  531. $curl_info = curl_getinfo($ch);
  532. if (!$success) {
  533. $err = array("message" => curl_error($ch));
  534. }
  535. @curl_close($ch);
  536. fclose($fp);
  537. $fileinfo->size = $curl_info["size_download"];
  538. $fileinfo->type = $curl_info["content_type"];
  539. } else {
  540. $ctx = stream_context_create();
  541. @$success = copy($url, $temp_file, $ctx);
  542. if (!$success) {
  543. $err = error_get_last();
  544. }
  545. }
  546. if ($success) {
  547. $success = rename($temp_file, get_file_path());
  548. }
  549. if ($success) {
  550. event_callback(array("done" => $fileinfo));
  551. } else {
  552. unlink($temp_file);
  553. if (!$err) {
  554. $err = array("message" => "Invalid url parameter");
  555. }
  556. event_callback(array("fail" => $err));
  557. }
  558. }
  559. exit();
  560. }
  561. // Delete file / folder
  562. if (isset($_GET['del']) && !FM_READONLY) {
  563. $del = str_replace( '/', '', fm_clean_path( $_GET['del'] ) );
  564. if ($del != '' && $del != '..' && $del != '.') {
  565. $path = FM_ROOT_PATH;
  566. if (FM_PATH != '') {
  567. $path .= '/' . FM_PATH;
  568. }
  569. $is_dir = is_dir($path . '/' . $del);
  570. if (fm_rdelete($path . '/' . $del)) {
  571. $msg = $is_dir ? 'Folder <b>%s</b> deleted' : 'File <b>%s</b> deleted';
  572. fm_set_msg(sprintf($msg, fm_enc($del)));
  573. } else {
  574. $msg = $is_dir ? 'Folder <b>%s</b> not deleted' : 'File <b>%s</b> not deleted';
  575. fm_set_msg(sprintf($msg, fm_enc($del)), 'error');
  576. }
  577. } else {
  578. fm_set_msg('Invalid file or folder name', 'error');
  579. }
  580. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  581. }
  582. // Create folder
  583. if (isset($_GET['new']) && isset($_GET['type']) && !FM_READONLY) {
  584. $type = $_GET['type'];
  585. $new = str_replace( '/', '', fm_clean_path( strip_tags( $_GET['new'] ) ) );
  586. if (fm_isvalid_filename($new) && $new != '' && $new != '..' && $new != '.') {
  587. $path = FM_ROOT_PATH;
  588. if (FM_PATH != '') {
  589. $path .= '/' . FM_PATH;
  590. }
  591. if ($_GET['type'] == "file") {
  592. if (!file_exists($path . '/' . $new)) {
  593. if(fm_is_valid_ext($new)) {
  594. @fopen($path . '/' . $new, 'w') or die('Cannot open file: ' . $new);
  595. fm_set_msg(sprintf(lng('File').' <b>%s</b> '.lng('Created'), fm_enc($new)));
  596. } else {
  597. fm_set_msg('File extension is not allowed', 'error');
  598. }
  599. } else {
  600. fm_set_msg(sprintf('File <b>%s</b> already exists', fm_enc($new)), 'alert');
  601. }
  602. } else {
  603. if (fm_mkdir($path . '/' . $new, false) === true) {
  604. fm_set_msg(sprintf(lng('Folder').' <b>%s</b> '.lng('Created'), $new));
  605. } elseif (fm_mkdir($path . '/' . $new, false) === $path . '/' . $new) {
  606. fm_set_msg(sprintf('Folder <b>%s</b> already exists', fm_enc($new)), 'alert');
  607. } else {
  608. fm_set_msg(sprintf('Folder <b>%s</b> not created', fm_enc($new)), 'error');
  609. }
  610. }
  611. } else {
  612. fm_set_msg('Invalid characters in file or folder name', 'error');
  613. }
  614. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  615. }
  616. // Copy folder / file
  617. if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) {
  618. // from
  619. $copy = $_GET['copy'];
  620. $copy = fm_clean_path($copy);
  621. // empty path
  622. if ($copy == '') {
  623. fm_set_msg('Source path not defined', 'error');
  624. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  625. }
  626. // abs path from
  627. $from = FM_ROOT_PATH . '/' . $copy;
  628. // abs path to
  629. $dest = FM_ROOT_PATH;
  630. if (FM_PATH != '') {
  631. $dest .= '/' . FM_PATH;
  632. }
  633. $dest .= '/' . basename($from);
  634. // move?
  635. $move = isset($_GET['move']);
  636. // copy/move/duplicate
  637. if ($from != $dest) {
  638. $msg_from = trim(FM_PATH . '/' . basename($from), '/');
  639. if ($move) { // Move and to != from so just perform move
  640. $rename = fm_rename($from, $dest);
  641. if ($rename) {
  642. fm_set_msg(sprintf('Moved from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($msg_from)));
  643. } elseif ($rename === null) {
  644. fm_set_msg('File or folder with this path already exists', 'alert');
  645. } else {
  646. fm_set_msg(sprintf('Error while moving from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($msg_from)), 'error');
  647. }
  648. } else { // Not move and to != from so copy with original name
  649. if (fm_rcopy($from, $dest)) {
  650. fm_set_msg(sprintf('Copied from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($msg_from)));
  651. } else {
  652. fm_set_msg(sprintf('Error while copying from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($msg_from)), 'error');
  653. }
  654. }
  655. } else {
  656. if (!$move){ //Not move and to = from so duplicate
  657. $msg_from = trim(FM_PATH . '/' . basename($from), '/');
  658. $fn_parts = pathinfo($from);
  659. $extension_suffix = '';
  660. if(!is_dir($from)){
  661. $extension_suffix = '.'.$fn_parts['extension'];
  662. }
  663. //Create new name for duplicate
  664. $fn_duplicate = $fn_parts['dirname'].'/'.$fn_parts['filename'].'-'.date('YmdHis').$extension_suffix;
  665. $loop_count = 0;
  666. $max_loop = 1000;
  667. // Check if a file with the duplicate name already exists, if so, make new name (edge case...)
  668. while(file_exists($fn_duplicate) & $loop_count < $max_loop){
  669. $fn_parts = pathinfo($fn_duplicate);
  670. $fn_duplicate = $fn_parts['dirname'].'/'.$fn_parts['filename'].'-copy'.$extension_suffix;
  671. $loop_count++;
  672. }
  673. if (fm_rcopy($from, $fn_duplicate, False)) {
  674. fm_set_msg(sprintf('Copyied from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($fn_duplicate)));
  675. } else {
  676. fm_set_msg(sprintf('Error while copying from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($fn_duplicate)), 'error');
  677. }
  678. }
  679. else{
  680. fm_set_msg('Paths must be not equal', 'alert');
  681. }
  682. }
  683. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  684. }
  685. // Mass copy files/ folders
  686. if (isset($_POST['file'], $_POST['copy_to'], $_POST['finish']) && !FM_READONLY) {
  687. // from
  688. $path = FM_ROOT_PATH;
  689. if (FM_PATH != '') {
  690. $path .= '/' . FM_PATH;
  691. }
  692. // to
  693. $copy_to_path = FM_ROOT_PATH;
  694. $copy_to = fm_clean_path($_POST['copy_to']);
  695. if ($copy_to != '') {
  696. $copy_to_path .= '/' . $copy_to;
  697. }
  698. if ($path == $copy_to_path) {
  699. fm_set_msg('Paths must be not equal', 'alert');
  700. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  701. }
  702. if (!is_dir($copy_to_path)) {
  703. if (!fm_mkdir($copy_to_path, true)) {
  704. fm_set_msg('Unable to create destination folder', 'error');
  705. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  706. }
  707. }
  708. // move?
  709. $move = isset($_POST['move']);
  710. // copy/move
  711. $errors = 0;
  712. $files = $_POST['file'];
  713. if (is_array($files) && count($files)) {
  714. foreach ($files as $f) {
  715. if ($f != '') {
  716. // abs path from
  717. $from = $path . '/' . $f;
  718. // abs path to
  719. $dest = $copy_to_path . '/' . $f;
  720. // do
  721. if ($move) {
  722. $rename = fm_rename($from, $dest);
  723. if ($rename === false) {
  724. $errors++;
  725. }
  726. } else {
  727. if (!fm_rcopy($from, $dest)) {
  728. $errors++;
  729. }
  730. }
  731. }
  732. }
  733. if ($errors == 0) {
  734. $msg = $move ? 'Selected files and folders moved' : 'Selected files and folders copied';
  735. fm_set_msg($msg);
  736. } else {
  737. $msg = $move ? 'Error while moving items' : 'Error while copying items';
  738. fm_set_msg($msg, 'error');
  739. }
  740. } else {
  741. fm_set_msg('Nothing selected', 'alert');
  742. }
  743. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  744. }
  745. // Rename
  746. if (isset($_GET['ren'], $_GET['to']) && !FM_READONLY) {
  747. // old name
  748. $old = $_GET['ren'];
  749. $old = fm_clean_path($old);
  750. $old = str_replace('/', '', $old);
  751. // new name
  752. $new = $_GET['to'];
  753. $new = fm_clean_path(strip_tags($new));
  754. $new = str_replace('/', '', $new);
  755. // path
  756. $path = FM_ROOT_PATH;
  757. if (FM_PATH != '') {
  758. $path .= '/' . FM_PATH;
  759. }
  760. // rename
  761. if (fm_isvalid_filename($new) && $old != '' && $new != '') {
  762. if (fm_rename($path . '/' . $old, $path . '/' . $new)) {
  763. fm_set_msg(sprintf('Renamed from <b>%s</b> to <b>%s</b>', fm_enc($old), fm_enc($new)));
  764. } else {
  765. fm_set_msg(sprintf('Error while renaming from <b>%s</b> to <b>%s</b>', fm_enc($old), fm_enc($new)), 'error');
  766. }
  767. } else {
  768. fm_set_msg('Invalid characters in file name', 'error');
  769. }
  770. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  771. }
  772. // Download
  773. if (isset($_GET['dl'])) {
  774. $dl = $_GET['dl'];
  775. $dl = fm_clean_path($dl);
  776. $dl = str_replace('/', '', $dl);
  777. $path = FM_ROOT_PATH;
  778. if (FM_PATH != '') {
  779. $path .= '/' . FM_PATH;
  780. }
  781. if ($dl != '' && is_file($path . '/' . $dl)) {
  782. fm_download_file($path . '/' . $dl, $dl, 1024);
  783. exit;
  784. } else {
  785. fm_set_msg('File not found', 'error');
  786. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  787. }
  788. }
  789. // Upload
  790. if (!empty($_FILES) && !FM_READONLY) {
  791. $override_file_name = false;
  792. $f = $_FILES;
  793. $path = FM_ROOT_PATH;
  794. $ds = DIRECTORY_SEPARATOR;
  795. if (FM_PATH != '') {
  796. $path .= '/' . FM_PATH;
  797. }
  798. $errors = 0;
  799. $uploads = 0;
  800. $allowed = (FM_UPLOAD_EXTENSION) ? explode(',', FM_UPLOAD_EXTENSION) : false;
  801. $response = array (
  802. 'status' => 'error',
  803. 'info' => 'Oops! Try again'
  804. );
  805. $filename = $f['file']['name'];
  806. $tmp_name = $f['file']['tmp_name'];
  807. $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
  808. $isFileAllowed = ($allowed) ? in_array($ext, $allowed) : true;
  809. $targetPath = $path . $ds;
  810. if ( is_writable($targetPath) ) {
  811. $fullPath = $path . '/' . $_REQUEST['fullpath'];
  812. $folder = substr($fullPath, 0, strrpos($fullPath, "/"));
  813. if(file_exists ($fullPath)){
  814. if(!$override_file_name) {
  815. /**
  816. * 修改名称
  817. */
  818. // $ext_1 = $ext ? '.'.$ext : '';
  819. // $fullPath = str_replace($ext_1, '', $fullPath) .'_'. date('ymdHis'). $ext_1;
  820. /**
  821. * 移动到回收站
  822. */
  823. $removePath = str_replace(DOCUMENT_ROOT,"",$fullPath);
  824. fm_rdelete(DOCUMENT_ROOT."/".$removePath);
  825. }
  826. }
  827. if (!is_dir($folder)) {
  828. $old = umask(0);
  829. mkdir($folder, 0777, true);
  830. umask($old);
  831. }
  832. if (empty($f['file']['error']) && !empty($tmp_name) && $tmp_name != 'none' && $isFileAllowed) {
  833. if (move_uploaded_file($tmp_name, $fullPath)) {
  834. // Be sure that the file has been uploaded
  835. if ( file_exists($fullPath) ) {
  836. $response = array (
  837. 'status' => 'success',
  838. 'info' => "file upload successful"
  839. );
  840. } else {
  841. $response = array (
  842. 'status' => 'error',
  843. 'info' => 'Couldn\'t upload the requested file.'
  844. );
  845. }
  846. } else {
  847. $response = array (
  848. 'status' => 'error',
  849. 'info' => "Error while uploading files. Uploaded files $uploads",
  850. );
  851. }
  852. }
  853. } else {
  854. $response = array (
  855. 'status' => 'error',
  856. 'info' => 'The specified folder for upload isn\'t writeable.'
  857. );
  858. }
  859. // Return the response
  860. echo json_encode($response);
  861. exit();
  862. }
  863. // Mass deleting
  864. if (isset($_POST['group'], $_POST['delete']) && !FM_READONLY) {
  865. $path = FM_ROOT_PATH;
  866. if (FM_PATH != '') {
  867. $path .= '/' . FM_PATH;
  868. }
  869. $errors = 0;
  870. $files = $_POST['file'];
  871. if (is_array($files) && count($files)) {
  872. foreach ($files as $f) {
  873. if ($f != '') {
  874. $new_path = $path . '/' . $f;
  875. if (!fm_rdelete($new_path)) {
  876. $errors++;
  877. }
  878. }
  879. }
  880. if ($errors == 0) {
  881. fm_set_msg('Selected files and folder deleted');
  882. } else {
  883. fm_set_msg('Error while deleting items', 'error');
  884. }
  885. } else {
  886. fm_set_msg('Nothing selected', 'alert');
  887. }
  888. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  889. }
  890. // Pack files
  891. if (isset($_POST['group']) && (isset($_POST['zip']) || isset($_POST['tar'])) && !FM_READONLY) {
  892. $path = FM_ROOT_PATH;
  893. $ext = 'zip';
  894. if (FM_PATH != '') {
  895. $path .= '/' . FM_PATH;
  896. }
  897. //set pack type
  898. $ext = isset($_POST['tar']) ? 'tar' : 'zip';
  899. if (($ext == "zip" && !class_exists('ZipArchive')) || ($ext == "tar" && !class_exists('PharData'))) {
  900. fm_set_msg('Operations with archives are not available', 'error');
  901. fm_redirect(FM_SELF_URL . 'fm_usr='.$_GET['fm_usr'].'&=' . urlencode(FM_PATH));
  902. }
  903. $files = $_POST['file'];
  904. if (!empty($files)) {
  905. chdir($path);
  906. if (count($files) == 1) {
  907. $one_file = reset($files);
  908. $one_file = basename($one_file);
  909. $zipname = $one_file . '_' . date('ymd_His') . '.'.$ext;
  910. } else {
  911. $zipname = 'archive_' . date('ymd_His') . '.'.$ext;
  912. }
  913. if($ext == 'zip') {
  914. $zipper = new FM_Zipper();
  915. $res = $zipper->create($zipname, $files);
  916. } elseif ($ext == 'tar') {
  917. $tar = new FM_Zipper_Tar();
  918. $res = $tar->create($zipname, $files);
  919. }
  920. if ($res) {
  921. fm_set_msg(sprintf('Archive <b>%s</b> created', fm_enc($zipname)));
  922. } else {
  923. fm_set_msg('Archive not created', 'error');
  924. }
  925. } else {
  926. fm_set_msg('Nothing selected', 'alert');
  927. }
  928. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  929. }
  930. // Unpack
  931. if (isset($_GET['unzip']) && !FM_READONLY) {
  932. $unzip = $_GET['unzip'];
  933. $unzip = fm_clean_path($unzip);
  934. $unzip = str_replace('/', '', $unzip);
  935. $isValid = false;
  936. $path = FM_ROOT_PATH;
  937. if (FM_PATH != '') {
  938. $path .= '/' . FM_PATH;
  939. }
  940. if ($unzip != '' && is_file($path . '/' . $unzip)) {
  941. $zip_path = $path . '/' . $unzip;
  942. $ext = pathinfo($zip_path, PATHINFO_EXTENSION);
  943. $isValid = true;
  944. } else {
  945. fm_set_msg('File not found', 'error');
  946. }
  947. if (($ext == "zip" && !class_exists('ZipArchive')) || ($ext == "tar" && !class_exists('PharData'))) {
  948. fm_set_msg('Operations with archives are not available', 'error');
  949. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  950. }
  951. if ($isValid) {
  952. //to folder
  953. $tofolder = '';
  954. if (isset($_GET['tofolder'])) {
  955. $tofolder = pathinfo($zip_path, PATHINFO_FILENAME);
  956. if (fm_mkdir($path . '/' . $tofolder, true)) {
  957. $path .= '/' . $tofolder;
  958. }
  959. }
  960. if($ext == "zip") {
  961. $zipper = new FM_Zipper();
  962. $res = $zipper->unzip($zip_path, $path);
  963. } elseif ($ext == "tar") {
  964. try {
  965. $gzipper = new PharData($zip_path);
  966. if (@$gzipper->extractTo($path,null, true)) {
  967. $res = true;
  968. } else {
  969. $res = false;
  970. }
  971. } catch (Exception $e) {
  972. //TODO:: need to handle the error
  973. $res = true;
  974. }
  975. }
  976. if ($res) {
  977. fm_set_msg('Archive unpacked');
  978. } else {
  979. fm_set_msg('Archive not unpacked', 'error');
  980. }
  981. } else {
  982. fm_set_msg('File not found', 'error');
  983. }
  984. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  985. }
  986. // Change Perms (not for Windows)
  987. if (isset($_POST['chmod']) && !FM_READONLY && !FM_IS_WIN) {
  988. $path = FM_ROOT_PATH;
  989. if (FM_PATH != '') {
  990. $path .= '/' . FM_PATH;
  991. }
  992. $file = $_POST['chmod'];
  993. $file = fm_clean_path($file);
  994. $file = str_replace('/', '', $file);
  995. if ($file == '' || (!is_file($path . '/' . $file) && !is_dir($path . '/' . $file))) {
  996. fm_set_msg('File not found', 'error');
  997. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  998. }
  999. $mode = 0;
  1000. if (!empty($_POST['ur'])) {
  1001. $mode |= 0400;
  1002. }
  1003. if (!empty($_POST['uw'])) {
  1004. $mode |= 0200;
  1005. }
  1006. if (!empty($_POST['ux'])) {
  1007. $mode |= 0100;
  1008. }
  1009. if (!empty($_POST['gr'])) {
  1010. $mode |= 0040;
  1011. }
  1012. if (!empty($_POST['gw'])) {
  1013. $mode |= 0020;
  1014. }
  1015. if (!empty($_POST['gx'])) {
  1016. $mode |= 0010;
  1017. }
  1018. if (!empty($_POST['or'])) {
  1019. $mode |= 0004;
  1020. }
  1021. if (!empty($_POST['ow'])) {
  1022. $mode |= 0002;
  1023. }
  1024. if (!empty($_POST['ox'])) {
  1025. $mode |= 0001;
  1026. }
  1027. if (@chmod($path . '/' . $file, $mode)) {
  1028. fm_set_msg('Permissions changed');
  1029. } else {
  1030. fm_set_msg('Permissions not changed', 'error');
  1031. }
  1032. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  1033. }
  1034. /*************************** /ACTIONS ***************************/
  1035. // get current path
  1036. $path = FM_ROOT_PATH;
  1037. if (FM_PATH != '') {
  1038. $path .= '/' . FM_PATH;
  1039. }
  1040. // check path
  1041. if (!is_dir($path)) {
  1042. fm_redirect(FM_SELF_URL . '?fm_usr='.$_GET['fm_usr'].'&p=');
  1043. }
  1044. // get parent folder
  1045. $parent = fm_get_parent_path(FM_PATH);
  1046. $objects = is_readable($path) ? scandir($path) : array();
  1047. $folders = array();
  1048. $files = array();
  1049. $current_path = array_slice(explode("/",$path), -1)[0];
  1050. if (is_array($objects) && fm_is_exclude_items($current_path)) {
  1051. foreach ($objects as $file) {
  1052. if ($file == '.' || $file == '..') {
  1053. continue;
  1054. }
  1055. if (!FM_SHOW_HIDDEN && substr($file, 0, 1) === '.') {
  1056. continue;
  1057. }
  1058. $new_path = $path . '/' . $file;
  1059. if (@is_file($new_path) && fm_is_exclude_items($file)) {
  1060. $files[] = $file;
  1061. } elseif (@is_dir($new_path) && $file != '.' && $file != '..' && fm_is_exclude_items($file)) {
  1062. $folders[] = $file;
  1063. }
  1064. }
  1065. }
  1066. if (!empty($files)) {
  1067. natcasesort($files);
  1068. }
  1069. if (!empty($folders)) {
  1070. natcasesort($folders);
  1071. }
  1072. // upload form
  1073. if (isset($_GET['upload']) && !FM_READONLY) {
  1074. fm_show_header(); // HEADER
  1075. fm_show_nav_path(FM_PATH); // current path
  1076. //get the allowed file extensions
  1077. function getUploadExt() {
  1078. $extArr = explode(',', FM_UPLOAD_EXTENSION);
  1079. if(FM_UPLOAD_EXTENSION && $extArr) {
  1080. array_walk($extArr, function(&$x) {$x = ".$x";});
  1081. return implode(',', $extArr);
  1082. }
  1083. return '';
  1084. }
  1085. ?>
  1086. <link href="/public/filemanager/js/dropzone.min.css" rel="stylesheet">
  1087. <div class="path">
  1088. <div class="card mb-2 fm-upload-wrapper <?php echo fm_get_theme(); ?>">
  1089. <div class="card-header">
  1090. <ul class="nav nav-tabs card-header-tabs">
  1091. <li class="nav-item">
  1092. <a class="nav-link active" href="#fileUploader" data-target="#fileUploader"><i class="fa fa-arrow-circle-o-up"></i> <?php echo lng('UploadingFiles') ?></a>
  1093. </li>
  1094. <li class="nav-item">
  1095. <a class="nav-link" href="#urlUploader" class="js-url-upload" data-target="#urlUploader"><i class="fa fa-link"></i> Upload from URL</a>
  1096. </li>
  1097. </ul>
  1098. </div>
  1099. <div class="card-body">
  1100. <p class="card-text">
  1101. <a href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=<?php echo FM_PATH ?>" class="float-right"><i class="fa fa-chevron-circle-left go-back"></i> <?php echo lng('Back')?></a>
  1102. <?php echo lng('DestinationFolder') ?>: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH)) ?>
  1103. </p>
  1104. <form action="<?php echo htmlspecialchars(FM_SELF_URL) . '?fm_usr='. $_GET['fm_usr'].'&p=' . fm_enc(FM_PATH) ?>" class="dropzone card-tabs-container" id="fileUploader" enctype="multipart/form-data">
  1105. <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
  1106. <input type="hidden" name="fullpath" id="fullpath" value="<?php echo fm_enc(FM_PATH) ?>">
  1107. <div class="fallback">
  1108. <input name="file" type="file" multiple/>
  1109. </div>
  1110. </form>
  1111. <div class="upload-url-wrapper card-tabs-container hidden" id="urlUploader">
  1112. <form id="js-form-url-upload" class="form-inline" onsubmit="return upload_from_url(this);" method="POST" action="">
  1113. <input type="hidden" name="type" value="upload" aria-label="hidden" aria-hidden="true">
  1114. <input type="url" placeholder="URL" name="uploadurl" required class="form-control" style="width: 80%">
  1115. <button type="submit" class="btn btn-primary ml-3"><?php echo lng('Upload') ?></button>
  1116. <div class="lds-facebook"><div></div><div></div><div></div></div>
  1117. </form>
  1118. <div id="js-url-upload__list" class="col-9 mt-3"></div>
  1119. </div>
  1120. </div>
  1121. </div>
  1122. </div>
  1123. <script src="/public/filemanager/js/dropzone.min.js"></script>
  1124. <script>
  1125. Dropzone.options.fileUploader = {
  1126. timeout: 120000,
  1127. maxFilesize: <?php echo MAX_UPLOAD_SIZE; ?>,
  1128. acceptedFiles : "<?php echo getUploadExt() ?>",
  1129. init: function () {
  1130. this.on("addedfile", function(file) {
  1131. if(file.name.indexOf(".png") != -1 || file.name.indexOf(".jpg") != -1 || file.name.indexOf(".PNG") != -1 || file.name.indexOf(".JPG") != -1){
  1132. var mbS = (file.size/1024).toFixed(2);
  1133. toast('上传图片注意大小=》该文件大小 ('+mbS+')KB');
  1134. }
  1135. }).on("sending", function (file, xhr, formData) {
  1136. let _path = (file.fullPath) ? file.fullPath : file.name;
  1137. document.getElementById("fullpath").value = _path;
  1138. xhr.ontimeout = (function() {
  1139. toast('Error: Server Timeout');
  1140. });
  1141. }).on("success", function (res) {
  1142. let _response = JSON.parse(res.xhr.response);
  1143. if(_response.status == "error") {
  1144. toast(_response.info);
  1145. }
  1146. }).on("error", function(file, response) {
  1147. toast(response);
  1148. });
  1149. }
  1150. }
  1151. </script>
  1152. <?php
  1153. fm_show_footer();
  1154. exit;
  1155. }
  1156. // copy form POST
  1157. if (isset($_POST['copy']) && !FM_READONLY) {
  1158. $copy_files = isset($_POST['file']) ? $_POST['file'] : null;
  1159. if (!is_array($copy_files) || empty($copy_files)) {
  1160. fm_set_msg('Nothing selected', 'alert');
  1161. fm_redirect(FM_SELF_URL . '?fm_usr='. $_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  1162. }
  1163. fm_show_header(); // HEADER
  1164. fm_show_nav_path(FM_PATH); // current path
  1165. ?>
  1166. <div class="path">
  1167. <div class="card <?php echo fm_get_theme(); ?>">
  1168. <div class="card-header">
  1169. <h6><?php echo lng('Copying') ?></h6>
  1170. </div>
  1171. <div class="card-body">
  1172. <form action="" method="post">
  1173. <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
  1174. <input type="hidden" name="finish" value="1">
  1175. <?php
  1176. foreach ($copy_files as $cf) {
  1177. echo '<input type="hidden" name="file[]" value="' . fm_enc($cf) . '">' . PHP_EOL;
  1178. }
  1179. ?>
  1180. <p class="break-word"><?php echo lng('Files') ?>: <b><?php echo implode('</b>, <b>', $copy_files) ?></b></p>
  1181. <p class="break-word"><?php echo lng('SourceFolder') ?>: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH)) ?><br>
  1182. <label for="inp_copy_to"><?php echo lng('DestinationFolder') ?>:</label>
  1183. <?php echo FM_ROOT_PATH ?>/<input type="text" name="copy_to" id="inp_copy_to" value="<?php echo fm_enc(FM_PATH) ?>">
  1184. </p>
  1185. <p class="custom-checkbox custom-control"><input type="checkbox" name="move" value="1" id="js-move-files" class="custom-control-input"><label for="js-move-files" class="custom-control-label" style="vertical-align: sub"> <?php echo lng('Move') ?></label></p>
  1186. <p>
  1187. <button type="submit" class="btn btn-success"><i class="fa fa-check-circle"></i> <?php echo lng('Copy') ?></button> &nbsp;
  1188. <b><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(FM_PATH) ?>" class="btn btn-outline-primary"><i class="fa fa-times-circle"></i> <?php echo lng('Cancel') ?></a></b>
  1189. </p>
  1190. </form>
  1191. </div>
  1192. </div>
  1193. </div>
  1194. <?php
  1195. fm_show_footer();
  1196. exit;
  1197. }
  1198. // copy form
  1199. if (isset($_GET['copy']) && !isset($_GET['finish']) && !FM_READONLY) {
  1200. $copy = $_GET['copy'];
  1201. $copy = fm_clean_path($copy);
  1202. if ($copy == '' || !file_exists(FM_ROOT_PATH . '/' . $copy)) {
  1203. fm_set_msg('File not found', 'error');
  1204. fm_redirect(FM_SELF_URL . '?fm_usr='. $_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  1205. }
  1206. fm_show_header(); // HEADER
  1207. fm_show_nav_path(FM_PATH); // current path
  1208. ?>
  1209. <div class="path">
  1210. <p><b>Copying</b></p>
  1211. <p class="break-word">
  1212. Source path: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . $copy)) ?><br>
  1213. Destination folder: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH)) ?>
  1214. </p>
  1215. <p>
  1216. <b><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(FM_PATH) ?>&amp;copy=<?php echo urlencode($copy) ?>&amp;finish=1"><i class="fa fa-check-circle"></i> Copy</a></b> &nbsp;
  1217. <b><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(FM_PATH) ?>&amp;copy=<?php echo urlencode($copy) ?>&amp;finish=1&amp;move=1"><i class="fa fa-check-circle"></i> Move</a></b> &nbsp;
  1218. <b><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(FM_PATH) ?>"><i class="fa fa-times-circle"></i> Cancel</a></b>
  1219. </p>
  1220. <p><i>Select folder</i></p>
  1221. <ul class="folders break-word">
  1222. <?php
  1223. if ($parent !== false) {
  1224. ?>
  1225. <li><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode($parent) ?>&amp;copy=<?php echo urlencode($copy) ?>"><i class="fa fa-chevron-circle-left"></i> ..</a></li>
  1226. <?php
  1227. }
  1228. foreach ($folders as $f) {
  1229. ?>
  1230. <li>
  1231. <a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>&amp;copy=<?php echo urlencode($copy) ?>"><i class="fa fa-folder-o"></i> <?php echo fm_convert_win($f) ?></a></li>
  1232. <?php
  1233. }
  1234. ?>
  1235. </ul>
  1236. </div>
  1237. <?php
  1238. fm_show_footer();
  1239. exit;
  1240. }
  1241. if (isset($_GET['settings']) && !FM_READONLY) {
  1242. fm_show_header(); // HEADER
  1243. fm_show_nav_path(FM_PATH); // current path
  1244. global $cfg, $lang, $lang_list;
  1245. ?>
  1246. <div class="col-md-8 offset-md-2 pt-3">
  1247. <div class="card mb-2 <?php echo fm_get_theme(); ?>">
  1248. <h6 class="card-header">
  1249. <i class="fa fa-cog"></i> <?php echo lng('Settings') ?>
  1250. <a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo FM_PATH ?>" class="float-right"><i class="fa fa-window-close"></i> <?php echo lng('Cancel')?></a>
  1251. </h6>
  1252. <div class="card-body">
  1253. <form id="js-settings-form" action="" method="post" data-type="ajax" onsubmit="return save_settings(this)">
  1254. <input type="hidden" name="type" value="settings" aria-label="hidden" aria-hidden="true">
  1255. <div class="form-group row">
  1256. <label for="js-language" class="col-sm-3 col-form-label"><?php echo lng('Language') ?></label>
  1257. <div class="col-sm-5">
  1258. <select class="form-control" id="js-language" name="js-language">
  1259. <?php
  1260. function getSelected($l) {
  1261. global $lang;
  1262. return ($lang == $l) ? 'selected' : '';
  1263. }
  1264. foreach ($lang_list as $k => $v) {
  1265. echo "<option value='$k' ".getSelected($k).">$v</option>";
  1266. }
  1267. ?>
  1268. </select>
  1269. </div>
  1270. </div>
  1271. <?php
  1272. //get ON/OFF and active class
  1273. function getChecked($conf, $val, $txt) {
  1274. if($conf== 1 && $val ==1) {
  1275. return $txt;
  1276. } else if($conf == '' && $val == '') {
  1277. return $txt;
  1278. } else {
  1279. return '';
  1280. }
  1281. }
  1282. ?>
  1283. <div class="form-group row">
  1284. <label for="js-err-rpt-1" class="col-sm-3 col-form-label"><?php echo lng('ErrorReporting') ?></label>
  1285. <div class="col-sm-9">
  1286. <div class="btn-group btn-group-toggle" data-toggle="buttons">
  1287. <label class="btn btn-secondary <?php echo getChecked($report_errors, 1, 'active') ?>">
  1288. <input type="radio" name="js-error-report" id="js-err-rpt-1" autocomplete="off" value="true" <?php echo getChecked($report_errors, 1, 'checked') ?> > ON
  1289. </label>
  1290. <label class="btn btn-secondary <?php echo getChecked($report_errors, '', 'active') ?>">
  1291. <input type="radio" name="js-error-report" id="js-err-rpt-0" autocomplete="off" value="false" <?php echo getChecked($report_errors, '', 'checked') ?> > OFF
  1292. </label>
  1293. </div>
  1294. </div>
  1295. </div>
  1296. <div class="form-group row">
  1297. <label for="js-hdn-1" class="col-sm-3 col-form-label"><?php echo lng('ShowHiddenFiles') ?></label>
  1298. <div class="col-sm-9">
  1299. <div class="btn-group btn-group-toggle" data-toggle="buttons">
  1300. <label class="btn btn-secondary <?php echo getChecked($show_hidden_files, 1, 'active') ?>">
  1301. <input type="radio" name="js-show-hidden" id="js-hdn-1" autocomplete="off" value="true" <?php echo getChecked($show_hidden_files, 1, 'checked') ?> > ON
  1302. </label>
  1303. <label class="btn btn-secondary <?php echo getChecked($show_hidden_files, '', 'active') ?>">
  1304. <input type="radio" name="js-show-hidden" id="js-hdn-0" autocomplete="off" value="false" <?php echo getChecked($show_hidden_files, '', 'checked') ?> > OFF
  1305. </label>
  1306. </div>
  1307. </div>
  1308. </div>
  1309. <div class="form-group row">
  1310. <label for="js-hid-1" class="col-sm-3 col-form-label"><?php echo lng('HideColumns') ?></label>
  1311. <div class="col-sm-9">
  1312. <div class="btn-group btn-group-toggle" data-toggle="buttons">
  1313. <label class="btn btn-secondary <?php echo getChecked($hide_Cols, 1, 'active') ?>">
  1314. <input type="radio" name="js-hide-cols" id="js-hid-1" autocomplete="off" value="true" <?php echo getChecked($hide_Cols, 1, 'checked') ?> > ON
  1315. </label>
  1316. <label class="btn btn-secondary <?php echo getChecked($hide_Cols, '', 'active') ?>">
  1317. <input type="radio" name="js-hide-cols" id="js-hid-0" autocomplete="off" value="false" <?php echo getChecked($hide_Cols, '', 'checked') ?> > OFF
  1318. </label>
  1319. </div>
  1320. </div>
  1321. </div>
  1322. <div class="form-group row">
  1323. <label for="js-dir-1" class="col-sm-3 col-form-label"><?php echo lng('CalculateFolderSize') ?></label>
  1324. <div class="col-sm-9">
  1325. <div class="btn-group btn-group-toggle" data-toggle="buttons">
  1326. <label class="btn btn-secondary <?php echo getChecked($calc_folder, 1, 'active') ?>">
  1327. <input type="radio" name="js-calc-folder" id="js-dir-1" autocomplete="off" value="true" <?php echo getChecked($calc_folder, 1, 'checked') ?> > ON
  1328. </label>
  1329. <label class="btn btn-secondary <?php echo getChecked($calc_folder, '', 'active') ?>">
  1330. <input type="radio" name="js-calc-folder" id="js-dir-0" autocomplete="off" value="false" <?php echo getChecked($calc_folder, '', 'checked') ?> > OFF
  1331. </label>
  1332. </div>
  1333. </div>
  1334. </div>
  1335. <div class="form-group row">
  1336. <div class="col-sm-10">
  1337. <button type="submit" class="btn btn-success"> <i class="fa fa-check-circle"></i> <?php echo lng('Save'); ?></button>
  1338. </div>
  1339. </div>
  1340. </form>
  1341. </div>
  1342. </div>
  1343. </div>
  1344. <?php
  1345. fm_show_footer();
  1346. exit;
  1347. }
  1348. if (isset($_GET['help'])) {
  1349. fm_show_header(); // HEADER
  1350. fm_show_nav_path(FM_PATH); // current path
  1351. global $cfg, $lang;
  1352. ?>
  1353. <div class="col-md-8 offset-md-2 pt-3">
  1354. <div class="card mb-2 <?php echo fm_get_theme(); ?>">
  1355. <h6 class="card-header">
  1356. <i class="fa fa-exclamation-circle"></i> <?php echo lng('Help') ?>
  1357. <a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo FM_PATH ?>" class="float-right"><i class="fa fa-window-close"></i> <?php echo lng('Cancel')?></a>
  1358. </h6>
  1359. <div class="card-body">
  1360. <div class="row">
  1361. <div class="col-xs-12 col-sm-6">
  1362. <p><h3><a href="https://github.com/prasathmani/tinyfilemanager" target="_blank" class="app-v-title"> Tiny File Manager <?php echo VERSION; ?></a></h3></p>
  1363. <p>Author: Prasath Mani</p>
  1364. <p>Mail Us: <a href="mailto:ccpprogrammers@gmail.com">ccpprogrammers[at]gmail.com</a> </p>
  1365. </div>
  1366. <div class="col-xs-12 col-sm-6">
  1367. <div class="card">
  1368. <ul class="list-group list-group-flush">
  1369. <li class="list-group-item"><a href="https://github.com/prasathmani/tinyfilemanager/wiki" target="_blank"><i class="fa fa-question-circle"></i> <?php echo lng('Help Documents') ?> </a> </li>
  1370. <li class="list-group-item"><a href="https://github.com/prasathmani/tinyfilemanager/issues" target="_blank"><i class="fa fa-bug"></i> <?php echo lng('Report Issue') ?></a></li>
  1371. <li class="list-group-item"><a href="javascript:latest_release_info('<?php echo VERSION; ?>');"><i class="fa fa-link"> </i> <?php echo lng('Check Latest Version') ?></a></li>
  1372. <?php if(!FM_READONLY) { ?>
  1373. <li class="list-group-item"><a href="javascript:show_new_pwd();"><i class="fa fa-lock"></i> <?php echo lng('Generate new password hash') ?></a></li>
  1374. <?php } ?>
  1375. </ul>
  1376. </div>
  1377. </div>
  1378. </div>
  1379. <div class="row js-new-pwd hidden mt-2">
  1380. <div class="col-12">
  1381. <form class="form-inline" onsubmit="return new_password_hash(this)" method="POST" action="">
  1382. <input type="hidden" name="type" value="pwdhash" aria-label="hidden" aria-hidden="true">
  1383. <div class="form-group mb-2">
  1384. <label for="staticEmail2"><?php echo lng('Generate new password hash') ?></label>
  1385. </div>
  1386. <div class="form-group mx-sm-3 mb-2">
  1387. <label for="inputPassword2" class="sr-only"><?php echo lng('Password') ?></label>
  1388. <input type="text" class="form-control btn-sm" id="inputPassword2" name="inputPassword2" placeholder="Password" required>
  1389. </div>
  1390. <button type="submit" class="btn btn-success btn-sm mb-2"><?php echo lng('Generate') ?></button>
  1391. </form>
  1392. <textarea class="form-control" rows="2" readonly id="js-pwd-result"></textarea>
  1393. </div>
  1394. </div>
  1395. </div>
  1396. </div>
  1397. </div>
  1398. <?php
  1399. fm_show_footer();
  1400. exit;
  1401. }
  1402. // file viewer
  1403. if (isset($_GET['view'])) {
  1404. $file = $_GET['view'];
  1405. $quickView = (isset($_GET['quickView']) && $_GET['quickView'] == 1) ? true : false;
  1406. $file = fm_clean_path($file, false);
  1407. $file = str_replace('/', '', $file);
  1408. if ($file == '' || !is_file($path . '/' . $file) || in_array($file, $GLOBALS['exclude_items'])) {
  1409. fm_set_msg('File not found', 'error');
  1410. fm_redirect(FM_SELF_URL . '?fm_usr='. $_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  1411. }
  1412. if(!$quickView) {
  1413. fm_show_header(); // HEADER
  1414. fm_show_nav_path(FM_PATH); // current path
  1415. }
  1416. $file_url = FM_ROOT_URL . fm_convert_win((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file);
  1417. $file_path = $path . '/' . $file;
  1418. $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
  1419. $mime_type = fm_get_mime_type($file_path);
  1420. $filesize_raw = fm_get_size($file_path);
  1421. $filesize = fm_get_filesize($filesize_raw);
  1422. $is_zip = false;
  1423. $is_gzip = false;
  1424. $is_image = false;
  1425. $is_audio = false;
  1426. $is_video = false;
  1427. $is_text = false;
  1428. $is_onlineViewer = false;
  1429. $view_title = 'File';
  1430. $filenames = false; // for zip
  1431. $content = ''; // for text
  1432. $online_viewer = strtolower(FM_DOC_VIEWER);
  1433. if($online_viewer && $online_viewer !== 'false' && in_array($ext, fm_get_onlineViewer_exts())){
  1434. $is_onlineViewer = true;
  1435. }
  1436. elseif ($ext == 'zip' || $ext == 'tar') {
  1437. $is_zip = true;
  1438. $view_title = 'Archive';
  1439. $filenames = fm_get_zif_info($file_path, $ext);
  1440. } elseif (in_array($ext, fm_get_image_exts())) {
  1441. $is_image = true;
  1442. $view_title = 'Image';
  1443. } elseif (in_array($ext, fm_get_audio_exts())) {
  1444. $is_audio = true;
  1445. $view_title = 'Audio';
  1446. } elseif (in_array($ext, fm_get_video_exts())) {
  1447. $is_video = true;
  1448. $view_title = 'Video';
  1449. } elseif (in_array($ext, fm_get_text_exts()) || substr($mime_type, 0, 4) == 'text' || in_array($mime_type, fm_get_text_mimes())) {
  1450. $is_text = true;
  1451. $content = file_get_contents($file_path);
  1452. }
  1453. ?>
  1454. <div class="row">
  1455. <div class="col-12">
  1456. <?php if(!$quickView) { ?>
  1457. <p class="break-word"><b><?php echo $view_title ?> "<?php echo fm_enc(fm_convert_win($file)) ?>"</b></p>
  1458. <p class="break-word">
  1459. Full path: <?php echo fm_enc(fm_convert_win($file_path)) ?><br>
  1460. File size: <?php echo ($filesize_raw <= 1000) ? "$filesize_raw bytes" : $filesize; ?><br>
  1461. MIME-type: <?php echo $mime_type ?><br>
  1462. <?php
  1463. // ZIP info
  1464. if (($is_zip || $is_gzip) && $filenames !== false) {
  1465. $total_files = 0;
  1466. $total_comp = 0;
  1467. $total_uncomp = 0;
  1468. foreach ($filenames as $fn) {
  1469. if (!$fn['folder']) {
  1470. $total_files++;
  1471. }
  1472. $total_comp += $fn['compressed_size'];
  1473. $total_uncomp += $fn['filesize'];
  1474. }
  1475. ?>
  1476. Files in archive: <?php echo $total_files ?><br>
  1477. Total size: <?php echo fm_get_filesize($total_uncomp) ?><br>
  1478. Size in archive: <?php echo fm_get_filesize($total_comp) ?><br>
  1479. Compression: <?php echo round(($total_comp / $total_uncomp) * 100) ?>%<br>
  1480. <?php
  1481. }
  1482. // Image info
  1483. if ($is_image) {
  1484. $image_size = getimagesize($file_path);
  1485. echo 'Image sizes: ' . (isset($image_size[0]) ? $image_size[0] : '0') . ' x ' . (isset($image_size[1]) ? $image_size[1] : '0') . '<br>';
  1486. }
  1487. // Text info
  1488. if ($is_text) {
  1489. $is_utf8 = fm_is_utf8($content);
  1490. if (function_exists('iconv')) {
  1491. if (!$is_utf8) {
  1492. $content = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $content);
  1493. }
  1494. }
  1495. echo 'Charset: ' . ($is_utf8 ? 'utf-8' : '8 bit') . '<br>';
  1496. }
  1497. ?>
  1498. </p>
  1499. <p>
  1500. <b><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(FM_PATH) ?>&amp;dl=<?php echo urlencode($file) ?>"><i class="fa fa-cloud-download"></i> <?php echo lng('Download') ?></a></b> &nbsp;
  1501. <b><a href="<?php echo fm_enc($file_url) ?>" target="_blank"><i class="fa fa-external-link-square"></i> <?php echo lng('Open') ?></a></b>
  1502. &nbsp;
  1503. <?php
  1504. // ZIP actions
  1505. if (!FM_READONLY && ($is_zip || $is_gzip) && $filenames !== false) {
  1506. $zip_name = pathinfo($file_path, PATHINFO_FILENAME);
  1507. ?>
  1508. <b><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(FM_PATH) ?>&amp;unzip=<?php echo urlencode($file) ?>"><i class="fa fa-check-circle"></i> <?php echo lng('UnZip') ?></a></b> &nbsp;
  1509. <b><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(FM_PATH) ?>&amp;unzip=<?php echo urlencode($file) ?>&amp;tofolder=1" title="UnZip to <?php echo fm_enc($zip_name) ?>"><i class="fa fa-check-circle"></i>
  1510. <?php echo lng('UnZipToFolder') ?></a></b> &nbsp;
  1511. <?php
  1512. }
  1513. if ($is_text && !FM_READONLY) {
  1514. ?>
  1515. <b><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(trim(FM_PATH)) ?>&amp;edit=<?php echo urlencode($file) ?>" class="edit-file"><i class="fa fa-pencil-square"></i> <?php echo lng('Edit') ?>
  1516. </a></b> &nbsp;
  1517. <b><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(trim(FM_PATH)) ?>&amp;edit=<?php echo urlencode($file) ?>&env=ace"
  1518. class="edit-file"><i class="fa fa-pencil-square-o"></i> <?php echo lng('AdvancedEditor') ?>
  1519. </a></b> &nbsp;
  1520. <?php } ?>
  1521. <b><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(FM_PATH) ?>"><i class="fa fa-chevron-circle-left go-back"></i> <?php echo lng('Back') ?></a></b>
  1522. </p>
  1523. <?php
  1524. }
  1525. if($is_onlineViewer) {
  1526. if($online_viewer == 'google') {
  1527. echo '<iframe src="https://docs.google.com/viewer?embedded=true&hl=en&url=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px"></iframe>';
  1528. } else if($online_viewer == 'microsoft') {
  1529. echo '<iframe src="https://view.officeapps.live.com/op/embed.aspx?src=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px"></iframe>';
  1530. }
  1531. } elseif ($is_zip) {
  1532. // ZIP content
  1533. if ($filenames !== false) {
  1534. echo '<code class="maxheight">';
  1535. foreach ($filenames as $fn) {
  1536. if ($fn['folder']) {
  1537. echo '<b>' . fm_enc($fn['name']) . '</b><br>';
  1538. } else {
  1539. echo $fn['name'] . ' (' . fm_get_filesize($fn['filesize']) . ')<br>';
  1540. }
  1541. }
  1542. echo '</code>';
  1543. } else {
  1544. echo '<p>Error while fetching archive info</p>';
  1545. }
  1546. } elseif ($is_image) {
  1547. // Image content
  1548. if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico', 'svg'))) {
  1549. echo '<p><img src="' . fm_enc($file_url) . '" alt="" class="preview-img"></p>';
  1550. }
  1551. } elseif ($is_audio) {
  1552. // Audio content
  1553. echo '<p><audio src="' . fm_enc($file_url) . '" controls preload="metadata"></audio></p>';
  1554. } elseif ($is_video) {
  1555. // Video content
  1556. echo '<div class="preview-video"><video src="' . fm_enc($file_url) . '" width="640" height="360" controls preload="metadata"></video></div>';
  1557. } elseif ($is_text) {
  1558. if (FM_USE_HIGHLIGHTJS) {
  1559. // highlight
  1560. $hljs_classes = array(
  1561. 'shtml' => 'xml',
  1562. 'htaccess' => 'apache',
  1563. 'phtml' => 'php',
  1564. 'lock' => 'json',
  1565. 'svg' => 'xml',
  1566. );
  1567. $hljs_class = isset($hljs_classes[$ext]) ? 'lang-' . $hljs_classes[$ext] : 'lang-' . $ext;
  1568. if (empty($ext) || in_array(strtolower($file), fm_get_text_names()) || preg_match('#\.min\.(css|js)$#i', $file)) {
  1569. $hljs_class = 'nohighlight';
  1570. }
  1571. $content = '<pre class="with-hljs" style="height: 100%"><code style="height: 100%" class="' . $hljs_class . '">' . fm_enc($content) . '</code></pre>';
  1572. } elseif (in_array($ext, array('php', 'php4', 'php5', 'phtml', 'phps'))) {
  1573. // php highlight
  1574. $content = highlight_string($content, true);
  1575. } else {
  1576. $content = '<pre>' . fm_enc($content) . '</pre>';
  1577. }
  1578. echo $content;
  1579. }
  1580. ?>
  1581. </div>
  1582. </div>
  1583. <?php
  1584. if(!$quickView) {
  1585. fm_show_footer();
  1586. }
  1587. exit;
  1588. }
  1589. // file editor
  1590. if (isset($_GET['edit'])) {
  1591. $file = $_GET['edit'];
  1592. $file = fm_clean_path($file, false);
  1593. $file = str_replace('/', '', $file);
  1594. if ($file == '' || !is_file($path . '/' . $file)) {
  1595. fm_set_msg('File not found', 'error');
  1596. fm_redirect(FM_SELF_URL . '?fm_usr='. $_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  1597. }
  1598. header('X-XSS-Protection:0');
  1599. fm_show_header(); // HEADER
  1600. fm_show_nav_path(FM_PATH); // current path
  1601. $file_url = FM_ROOT_URL . fm_convert_win((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file);
  1602. $file_path = $path . '/' . $file;
  1603. // normal editer
  1604. $isNormalEditor = true;
  1605. if (isset($_GET['env'])) {
  1606. if ($_GET['env'] == "ace") {
  1607. $isNormalEditor = false;
  1608. }
  1609. }
  1610. // Save File
  1611. if (isset($_POST['savedata'])) {
  1612. $writedata = $_POST['savedata'];
  1613. $fd = fopen($file_path, "w");
  1614. @fwrite($fd, $writedata);
  1615. fclose($fd);
  1616. fm_set_msg('File Saved Successfully');
  1617. }
  1618. $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
  1619. $mime_type = fm_get_mime_type($file_path);
  1620. $filesize = filesize($file_path);
  1621. $is_text = false;
  1622. $content = ''; // for text
  1623. if (in_array($ext, fm_get_text_exts()) || substr($mime_type, 0, 4) == 'text' || in_array($mime_type, fm_get_text_mimes())) {
  1624. $is_text = true;
  1625. $content = file_get_contents($file_path);
  1626. }
  1627. ?>
  1628. <div class="path">
  1629. <div class="row">
  1630. <div class="col-xs-12 col-sm-5 col-lg-6 pt-1">
  1631. <div class="btn-toolbar" role="toolbar">
  1632. <?php if (!$isNormalEditor) { ?>
  1633. <div class="btn-group js-ace-toolbar">
  1634. <button data-cmd="none" data-option="fullscreen" class="btn btn-sm btn-outline-secondary" id="js-ace-fullscreen" title="Fullscreen"><i class="fa fa-expand" title="Fullscreen"></i></button>
  1635. <button data-cmd="find" class="btn btn-sm btn-outline-secondary" id="js-ace-search" title="Search"><i class="fa fa-search" title="Search"></i></button>
  1636. <button data-cmd="undo" class="btn btn-sm btn-outline-secondary" id="js-ace-undo" title="Undo"><i class="fa fa-undo" title="Undo"></i></button>
  1637. <button data-cmd="redo" class="btn btn-sm btn-outline-secondary" id="js-ace-redo" title="Redo"><i class="fa fa-repeat" title="Redo"></i></button>
  1638. <button data-cmd="none" data-option="wrap" class="btn btn-sm btn-outline-secondary" id="js-ace-wordWrap" title="Word Wrap"><i class="fa fa-text-width" title="Word Wrap"></i></button>
  1639. <button data-cmd="none" data-option="help" class="btn btn-sm btn-outline-secondary" id="js-ace-goLine" title="Help"><i class="fa fa-question" title="Help"></i></button>
  1640. <select id="js-ace-mode" data-type="mode" title="Select Document Type" class="btn-outline-secondary border-left-0 d-none d-md-block"><option>-- Select Mode --</option></select>
  1641. <select id="js-ace-theme" data-type="theme" title="Select Theme" class="btn-outline-secondary border-left-0 d-none d-lg-block"><option>-- Select Theme --</option></select>
  1642. <select id="js-ace-fontSize" data-type="fontSize" title="Selct Font Size" class="btn-outline-secondary border-left-0 d-none d-lg-block"><option>-- Select Font Size --</option></select>
  1643. </div>
  1644. <?php } ?>
  1645. </div>
  1646. </div>
  1647. <div class="edit-file-actions col-xs-12 col-sm-7 col-lg-6 text-right pt-1">
  1648. <a title="Back" class="btn btn-sm btn-outline-primary" href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(trim(FM_PATH)) ?>&amp;view=<?php echo urlencode($file) ?>"><i class="fa fa-reply-all"></i> <?php echo lng('Back') ?></a>
  1649. <a title="Backup" class="btn btn-sm btn-outline-primary" href="javascript:void(0);" onclick="backup('<?php echo urlencode(trim(FM_PATH)) ?>','<?php echo urlencode($file) ?>')"><i class="fa fa-database"></i> <?php echo lng('BackUp') ?></a>
  1650. <?php if ($is_text) { ?>
  1651. <?php if ($isNormalEditor) { ?>
  1652. <a title="Advanced" class="btn btn-sm btn-outline-primary" href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(trim(FM_PATH)) ?>&amp;edit=<?php echo urlencode($file) ?>&amp;env=ace"><i class="fa fa-pencil-square-o"></i> <?php echo lng('AdvancedEditor') ?></a>
  1653. <button type="button" class="btn btn-sm btn-outline-primary name="Save" data-url="<?php echo fm_enc($file_url) ?>" onclick="edit_save(this,'nrl')"><i class="fa fa-floppy-o"></i> Save
  1654. </button>
  1655. <?php } else { ?>
  1656. <a title="Plain Editor" class="btn btn-sm btn-outline-primary" href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(trim(FM_PATH)) ?>&amp;edit=<?php echo urlencode($file) ?>"><i class="fa fa-text-height"></i> <?php echo lng('NormalEditor') ?></a>
  1657. <button type="button" class="btn btn-sm btn-outline-primary" name="Save" data-url="<?php echo fm_enc($file_url) ?>" onclick="edit_save(this,'ace')"><i class="fa fa-floppy-o"></i> <?php echo lng('Save') ?>
  1658. </button>
  1659. <?php } ?>
  1660. <?php } ?>
  1661. </div>
  1662. </div>
  1663. <?php
  1664. if ($is_text && $isNormalEditor) {
  1665. echo '<textarea class="mt-2" id="normal-editor" rows="33" cols="120" style="width: 99.5%;">' . htmlspecialchars($content) . '</textarea>';
  1666. } elseif ($is_text) {
  1667. echo '<div id="editor" contenteditable="true">' . htmlspecialchars($content) . '</div>';
  1668. } else {
  1669. fm_set_msg('FILE EXTENSION HAS NOT SUPPORTED', 'error');
  1670. }
  1671. ?>
  1672. </div>
  1673. <?php
  1674. fm_show_footer();
  1675. exit;
  1676. }
  1677. // chmod (not for Windows)
  1678. if (isset($_GET['chmod']) && !FM_READONLY && !FM_IS_WIN) {
  1679. $file = $_GET['chmod'];
  1680. $file = fm_clean_path($file);
  1681. $file = str_replace('/', '', $file);
  1682. if ($file == '' || (!is_file($path . '/' . $file) && !is_dir($path . '/' . $file))) {
  1683. fm_set_msg('File not found', 'error');
  1684. fm_redirect(FM_SELF_URL . '?fm_usr='. $_GET['fm_usr'].'&p=' . urlencode(FM_PATH));
  1685. }
  1686. fm_show_header(); // HEADER
  1687. fm_show_nav_path(FM_PATH); // current path
  1688. $file_url = FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file;
  1689. $file_path = $path . '/' . $file;
  1690. $mode = fileperms($path . '/' . $file);
  1691. ?>
  1692. <div class="path">
  1693. <div class="card mb-2 <?php echo fm_get_theme(); ?>">
  1694. <h6 class="card-header">
  1695. <?php echo lng('ChangePermissions') ?>
  1696. </h6>
  1697. <div class="card-body">
  1698. <p class="card-text">
  1699. Full path: <?php echo $file_path ?><br>
  1700. </p>
  1701. <form action="" method="post">
  1702. <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
  1703. <input type="hidden" name="chmod" value="<?php echo fm_enc($file) ?>">
  1704. <table class="table compact-table <?php echo fm_get_theme(); ?>">
  1705. <tr>
  1706. <td></td>
  1707. <td><b><?php echo lng('Owner') ?></b></td>
  1708. <td><b><?php echo lng('Group') ?></b></td>
  1709. <td><b><?php echo lng('Other') ?></b></td>
  1710. </tr>
  1711. <tr>
  1712. <td style="text-align: right"><b><?php echo lng('Read') ?></b></td>
  1713. <td><label><input type="checkbox" name="ur" value="1"<?php echo ($mode & 00400) ? ' checked' : '' ?>></label></td>
  1714. <td><label><input type="checkbox" name="gr" value="1"<?php echo ($mode & 00040) ? ' checked' : '' ?>></label></td>
  1715. <td><label><input type="checkbox" name="or" value="1"<?php echo ($mode & 00004) ? ' checked' : '' ?>></label></td>
  1716. </tr>
  1717. <tr>
  1718. <td style="text-align: right"><b><?php echo lng('Write') ?></b></td>
  1719. <td><label><input type="checkbox" name="uw" value="1"<?php echo ($mode & 00200) ? ' checked' : '' ?>></label></td>
  1720. <td><label><input type="checkbox" name="gw" value="1"<?php echo ($mode & 00020) ? ' checked' : '' ?>></label></td>
  1721. <td><label><input type="checkbox" name="ow" value="1"<?php echo ($mode & 00002) ? ' checked' : '' ?>></label></td>
  1722. </tr>
  1723. <tr>
  1724. <td style="text-align: right"><b><?php echo lng('Execute') ?></b></td>
  1725. <td><label><input type="checkbox" name="ux" value="1"<?php echo ($mode & 00100) ? ' checked' : '' ?>></label></td>
  1726. <td><label><input type="checkbox" name="gx" value="1"<?php echo ($mode & 00010) ? ' checked' : '' ?>></label></td>
  1727. <td><label><input type="checkbox" name="ox" value="1"<?php echo ($mode & 00001) ? ' checked' : '' ?>></label></td>
  1728. </tr>
  1729. </table>
  1730. <p>
  1731. <button type="submit" class="btn btn-success"><i class="fa fa-check-circle"></i> <?php echo lng('Change') ?></button> &nbsp;
  1732. <b><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode(FM_PATH) ?>" class="btn btn-outline-primary"><i class="fa fa-times-circle"></i> <?php echo lng('Cancel') ?></a></b>
  1733. </p>
  1734. </form>
  1735. </div>
  1736. </div>
  1737. </div>
  1738. <?php
  1739. fm_show_footer();
  1740. exit;
  1741. }
  1742. //--- FILEMANAGER MAIN
  1743. fm_show_header(); // HEADER
  1744. fm_show_nav_path(FM_PATH); // current path
  1745. // messages
  1746. fm_show_message();
  1747. $num_files = count($files);
  1748. $num_folders = count($folders);
  1749. $all_files_size = 0;
  1750. $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white";
  1751. ?>
  1752. <form action="" method="post" class="pt-3">
  1753. <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
  1754. <input type="hidden" name="group" value="1">
  1755. <div class="table-responsive">
  1756. <table class="table table-bordered table-hover table-sm <?php echo $tableTheme; ?>" id="main-table">
  1757. <thead class="thead-white">
  1758. <tr>
  1759. <?php if (!FM_READONLY): ?>
  1760. <th style="width:3%" class="custom-checkbox-header">
  1761. <div class="custom-control custom-checkbox">
  1762. <input type="checkbox" class="custom-control-input" id="js-select-all-items" onclick="checkbox_toggle()">
  1763. <label class="custom-control-label" for="js-select-all-items"></label>
  1764. </div>
  1765. </th><?php endif; ?>
  1766. <th><?php echo lng('Name') ?></th>
  1767. <th><?php echo lng('Size') ?></th>
  1768. <th><?php echo lng('Modified') ?></th>
  1769. <?php if (!FM_IS_WIN && !$hide_Cols): ?>
  1770. <th><?php echo lng('Perms') ?></th>
  1771. <th><?php echo lng('Owner') ?></th><?php endif; ?>
  1772. <th><?php echo lng('Actions') ?></th>
  1773. </tr>
  1774. </thead>
  1775. <?php
  1776. // link to parent folder
  1777. if ($parent !== false) {
  1778. ?>
  1779. <tr><?php if (!FM_READONLY): ?>
  1780. <td class="nosort"></td><?php endif; ?>
  1781. <td class="border-0"><a href="?fm_usr=<?php echo $_GET['fm_usr'] ?>&p=<?php echo urlencode($parent) ?>"><i class="fa fa-chevron-circle-left go-back"></i> ..</a></td>
  1782. <td class="border-0"></td>
  1783. <td class="border-0"></td>
  1784. <td class="border-0"></td>
  1785. <?php if (!FM_IS_WIN && !$hide_Cols) { ?>
  1786. <td class="border-0"></td>
  1787. <td class="border-0"></td>
  1788. <?php } ?>
  1789. </tr>
  1790. <?php
  1791. }
  1792. $ii = 3399;
  1793. foreach ($folders as $f) {
  1794. $is_link = is_link($path . '/' . $f);
  1795. $img = $is_link ? 'icon-link_folder' : 'fa fa-folder-o';
  1796. $modif_raw = filemtime($path . '/' . $f);
  1797. $modif = date(FM_DATETIME_FORMAT, $modif_raw);
  1798. if ($calc_folder) {
  1799. $filesize_raw = fm_get_directorysize($path . '/' . $f);
  1800. $filesize = fm_get_filesize($filesize_raw);
  1801. }
  1802. else {
  1803. $filesize_raw = "";
  1804. $filesize = lng('Folder');
  1805. }
  1806. $perms = substr(decoct(fileperms($path . '/' . $f)), -4);
  1807. if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
  1808. $owner = posix_getpwuid(fileowner($path . '/' . $f));
  1809. $group = posix_getgrgid(filegroup($path . '/' . $f));
  1810. } else {
  1811. $owner = array('name' => '?');
  1812. $group = array('name' => '?');
  1813. }
  1814. ?>
  1815. <tr>
  1816. <?php if (!FM_READONLY): ?>
  1817. <td class="custom-checkbox-td">
  1818. <div class="custom-control custom-checkbox">
  1819. <input type="checkbox" class="custom-control-input" id="<?php echo $ii ?>" name="file[]" value="<?php echo fm_enc($f) ?>">
  1820. <label class="custom-control-label" for="<?php echo $ii ?>"></label>
  1821. </div>
  1822. </td><?php endif; ?>
  1823. <td>
  1824. <div class="filename"><a href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="<?php echo $img ?>"></i> <?php echo fm_convert_win(fm_enc($f)) ?>
  1825. </a><?php echo($is_link ? ' &rarr; <i>' . readlink($path . '/' . $f) . '</i>' : '') ?></div>
  1826. </td>
  1827. <td data-sort="a-<?php echo str_pad($filesize_raw, 18, "0", STR_PAD_LEFT);?>">
  1828. <?php echo $filesize; ?>
  1829. </td>
  1830. <td data-sort="a-<?php echo $modif_raw;?>"><?php echo $modif ?></td>
  1831. <?php if (!FM_IS_WIN && !$hide_Cols): ?>
  1832. <td><?php if (!FM_READONLY): ?><a title="Change Permissions" href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=<?php echo urlencode(FM_PATH) ?>&amp;chmod=<?php echo urlencode($f) ?>"><?php echo $perms ?></a><?php else: ?><?php echo $perms ?><?php endif; ?>
  1833. </td>
  1834. <td><?php echo $owner['name'] . ':' . $group['name'] ?></td>
  1835. <?php endif; ?>
  1836. <td class="inline-actions"><?php if (!FM_READONLY): ?>
  1837. <?php if (FM_DELETE): ?>
  1838. <a title="<?php echo lng('Delete')?>" href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=<?php echo urlencode(FM_PATH) ?>&amp;del=<?php echo urlencode($f) ?>" onclick="return confirm('<?php echo lng('Delete').' '.lng('Folder').'?'; ?>\n \n ( <?php echo urlencode($f) ?> )');"> <i class="fa fa-trash-o" aria-hidden="true"></i></a>
  1839. <?php endif; ?>
  1840. <a title="<?php echo lng('Rename')?>" href="#" onclick="rename('<?php echo fm_enc(FM_PATH) ?>', '<?php echo fm_enc(addslashes($f)) ?>');return false;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a>
  1841. <a title="<?php echo lng('CopyTo')?>..." href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=&amp;copy=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="fa fa-files-o" aria-hidden="true"></i></a>
  1842. <?php endif; ?>
  1843. <a title="<?php echo lng('DirectLink')?>" href="<?php echo fm_enc(FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f . '/') ?>" target="_blank"><i class="fa fa-link" aria-hidden="true"></i></a>
  1844. <a title="刷新CDN" class="refreshCdn" href="#" data-href="<?php echo fm_enc((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f . '/') ?>" ><i class="fa fa-refresh " aria-hidden="true"></i></a>
  1845. <!--只有bundle包目录可以同步到正式-->
  1846. <?php if( checkSyncPermission($_GET['p'], $f) ): ?>
  1847. <a title="同步到正式" class="asyncProd" href="#" data-href="<?php echo fm_enc((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f . '/') ?>" ><i class="fa fa-retweet " aria-hidden="true"></i></a>
  1848. <?php endif; ?>
  1849. <!--只有bundle包目录可以同步到正式-->
  1850. <?php if(in_array(urldecode($_GET['p']), [
  1851. 'crazycoin/activity'
  1852. , 'crazycoin/activity'
  1853. ])): ?>
  1854. <a title="更新资源JSON配置" class="refreshJsonConfig" href="#" data-type="<?=$f?>" data-href="<?php echo fm_enc((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f . '/') ?>" ><i class="fa fa-check-square-o " aria-hidden="true"></i></a>
  1855. <?php endif; ?>
  1856. </td>
  1857. </tr>
  1858. <?php
  1859. flush();
  1860. $ii++;
  1861. }
  1862. $ik = 6070;
  1863. foreach ($files as $f) {
  1864. $is_link = is_link($path . '/' . $f);
  1865. $img = $is_link ? 'fa fa-file-text-o' : fm_get_file_icon_class($path . '/' . $f);
  1866. $modif_raw = filemtime($path . '/' . $f);
  1867. $modif = date(FM_DATETIME_FORMAT, $modif_raw);
  1868. $filesize_raw = fm_get_size($path . '/' . $f);
  1869. $filesize = fm_get_filesize($filesize_raw);
  1870. $filelink = '?fm_usr=<?php echo $_GET[\'fm_usr\']?>&p=' . urlencode(FM_PATH) . '&amp;view=' . urlencode($f);
  1871. $all_files_size += $filesize_raw;
  1872. $perms = substr(decoct(fileperms($path . '/' . $f)), -4);
  1873. if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
  1874. $owner = posix_getpwuid(fileowner($path . '/' . $f));
  1875. $group = posix_getgrgid(filegroup($path . '/' . $f));
  1876. } else {
  1877. $owner = array('name' => '?');
  1878. $group = array('name' => '?');
  1879. }
  1880. ?>
  1881. <tr>
  1882. <?php if (!FM_READONLY): ?>
  1883. <td class="custom-checkbox-td">
  1884. <div class="custom-control custom-checkbox">
  1885. <input type="checkbox" class="custom-control-input" id="<?php echo $ik ?>" name="file[]" value="<?php echo fm_enc($f) ?>">
  1886. <label class="custom-control-label" for="<?php echo $ik ?>"></label>
  1887. </div>
  1888. </td><?php endif; ?>
  1889. <td>
  1890. <div class="filename">
  1891. <?php
  1892. if (in_array(strtolower(pathinfo($f, PATHINFO_EXTENSION)), array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico', 'svg'))): ?>
  1893. <?php $imagePreview = fm_enc(FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f); ?>
  1894. <a href="<?php echo $filelink ?>" data-preview-image="<?php echo $imagePreview."?time=".time() ?>" title="<?php echo $f ?>">
  1895. <?php else: ?>
  1896. <a href="<?php echo $filelink ?>" title="<?php echo $f ?>">
  1897. <?php endif; ?>
  1898. <i class="<?php echo $img ?>"></i> <?php echo fm_convert_win($f) ?>
  1899. </a>
  1900. <?php echo($is_link ? ' &rarr; <i>' . readlink($path . '/' . $f) . '</i>' : '') ?>
  1901. </div>
  1902. </td>
  1903. <td data-sort=b-"<?php echo str_pad($filesize_raw, 18, "0", STR_PAD_LEFT); ?>"><span title="<?php printf('%s bytes', $filesize_raw) ?>">
  1904. <?php echo $filesize; ?>
  1905. </span></td>
  1906. <td data-sort="b-<?php echo $modif_raw;?>"><?php echo $modif ?></td>
  1907. <?php if (!FM_IS_WIN && !$hide_Cols): ?>
  1908. <td><?php if (!FM_READONLY): ?><a title="<?php echo 'Change Permissions' ?>" href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=<?php echo urlencode(FM_PATH) ?>&amp;chmod=<?php echo urlencode($f) ?>"><?php echo $perms ?></a><?php else: ?><?php echo $perms ?><?php endif; ?>
  1909. </td>
  1910. <td><?php echo fm_enc($owner['name'] . ':' . $group['name']) ?></td>
  1911. <?php endif; ?>
  1912. <td class="inline-actions">
  1913. <a title="<?php echo lng('Preview') ?>" href="<?php echo $filelink.'&quickView=1'; ?>" data-toggle="lightbox" data-gallery="tiny-gallery" data-title="<?php echo fm_convert_win($f) ?>" data-max-width="100%" data-width="100%"><i class="fa fa-eye"></i></a>
  1914. <?php if (!FM_READONLY): ?>
  1915. <?php if (FM_DELETE): ?>
  1916. <a title="<?php echo lng('Delete') ?>" href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=<?php echo urlencode(FM_PATH) ?>&amp;del=<?php echo urlencode($f) ?>" onclick="return confirm('<?php echo lng('Delete').' '.lng('File').'?'; ?>\n \n ( <?php echo urlencode($f) ?> )');"> <i class="fa fa-trash-o"></i></a>
  1917. <?php endif; ?>
  1918. <a title="<?php echo lng('Rename') ?>" href="#" onclick="rename('<?php echo fm_enc(FM_PATH) ?>', '<?php echo fm_enc(addslashes($f)) ?>');return false;"><i class="fa fa-pencil-square-o"></i></a>
  1919. <a title="<?php echo lng('CopyTo') ?>..."
  1920. href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=<?php echo urlencode(FM_PATH) ?>&amp;copy=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="fa fa-files-o"></i></a>
  1921. <?php endif; ?>
  1922. <a title="<?php echo lng('DirectLink') ?>" href="<?php echo fm_enc(FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f) ?>" target="_blank"><i class="fa fa-link"></i></a>
  1923. <a title="<?php echo lng('Download') ?>" href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=<?php echo urlencode(FM_PATH) ?>&amp;dl=<?php echo urlencode($f) ?>"><i class="fa fa-download"></i></a>
  1924. <!--只有bundle包目录可以同步到正式-->
  1925. <?php if( checkSyncPermission($_GET['p'], $f) ): ?>
  1926. <a title="同步到正式" class="asyncProd" href="#" data-href="<?php echo fm_enc((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f) ?>" ><i class="fa fa-retweet " aria-hidden="true"></i></a>
  1927. <?php endif; ?>
  1928. </td>
  1929. </tr>
  1930. <?php
  1931. flush();
  1932. $ik++;
  1933. }
  1934. if (empty($folders) && empty($files)) {
  1935. ?>
  1936. <tfoot>
  1937. <tr><?php if (!FM_READONLY): ?>
  1938. <td></td><?php endif; ?>
  1939. <td colspan="<?php echo (!FM_IS_WIN && !$hide_Cols) ? '6' : '4' ?>"><em><?php echo 'Folder is empty' ?></em></td>
  1940. </tr>
  1941. </tfoot>
  1942. <?php
  1943. } else {
  1944. ?>
  1945. <tfoot>
  1946. <tr><?php if (!FM_READONLY): ?>
  1947. <td class="gray"></td><?php endif; ?>
  1948. <td class="gray" colspan="<?php echo (!FM_IS_WIN && !$hide_Cols) ? '6' : '4' ?>">
  1949. <?php echo lng('FullSize').': <span class="badge badge-light">'.fm_get_filesize($all_files_size).'</span>' ?>
  1950. <?php echo lng('File').': <span class="badge badge-light">'.$num_files.'</span>' ?>
  1951. <?php echo lng('Folder').': <span class="badge badge-light">'.$num_folders.'</span>' ?>
  1952. <?php echo lng('MemoryUsed').': <span class="badge badge-light">'.fm_get_filesize(@memory_get_usage(true)).'</span>' ?>
  1953. <?php echo lng('PartitionSize').': <span class="badge badge-light">'.fm_get_filesize(@disk_free_space($path)) .'</span> '.lng('FreeOf').' <span class="badge badge-light">'.fm_get_filesize(@disk_total_space($path)).'</span>'; ?>
  1954. </td>
  1955. </tr>
  1956. </tfoot>
  1957. <?php
  1958. }
  1959. ?>
  1960. </table>
  1961. </div>
  1962. <div class="row">
  1963. <?php if (!FM_READONLY): ?>
  1964. <div class="col-xs-12 col-sm-9">
  1965. <ul class="list-inline footer-action">
  1966. <li class="list-inline-item"> <a href="#/select-all" class="btn btn-small btn-outline-primary btn-2" onclick="select_all();return false;"><i class="fa fa-check-square"></i> <?php echo lng('SelectAll') ?> </a></li>
  1967. <li class="list-inline-item"><a href="#/unselect-all" class="btn btn-small btn-outline-primary btn-2" onclick="unselect_all();return false;"><i class="fa fa-window-close"></i> <?php echo lng('UnSelectAll') ?> </a></li>
  1968. <li class="list-inline-item"><a href="#/invert-all" class="btn btn-small btn-outline-primary btn-2" onclick="invert_all();return false;"><i class="fa fa-th-list"></i> <?php echo lng('InvertSelection') ?> </a></li>
  1969. <?php if (FM_DELETE): ?>
  1970. <li class="list-inline-item"><input type="submit" class="hidden" name="delete" id="a-delete" value="Delete" onclick="return confirm('Delete selected files and folders?')"><a href="javascript:document.getElementById('a-delete').click();" class="btn btn-small btn-outline-primary btn-2"><i class="fa fa-trash"></i> <?php echo lng('Delete') ?> </a></li>
  1971. <?php endif; ?>
  1972. <li class="list-inline-item"><input type="submit" class="hidden" name="zip" id="a-zip" value="zip" onclick="return confirm('Create archive?')"><a href="javascript:document.getElementById('a-zip').click();" class="btn btn-small btn-outline-primary btn-2"><i class="fa fa-file-archive-o"></i> <?php echo lng('Zip') ?> </a></li>
  1973. <li class="list-inline-item"><input type="submit" class="hidden" name="tar" id="a-tar" value="tar" onclick="return confirm('Create archive?')"><a href="javascript:document.getElementById('a-tar').click();" class="btn btn-small btn-outline-primary btn-2"><i class="fa fa-file-archive-o"></i> <?php echo lng('Tar') ?> </a></li>
  1974. <li class="list-inline-item"><input type="submit" class="hidden" name="copy" id="a-copy" value="Copy"><a href="javascript:document.getElementById('a-copy').click();" class="btn btn-small btn-outline-primary btn-2"><i class="fa fa-files-o"></i> <?php echo lng('Copy') ?> </a></li>
  1975. </ul>
  1976. </div>
  1977. <div class="col-3 d-none d-sm-block"><a href="https://tinyfilemanager.github.io" target="_blank" class="float-right text-muted">Tiny File Manager <?php echo VERSION; ?></a></div>
  1978. <?php else: ?>
  1979. <div class="col-12"><a href="https://tinyfilemanager.github.io" target="_blank" class="float-right text-muted">Tiny File Manager <?php echo VERSION; ?></a></div>
  1980. <?php endif; ?>
  1981. </div>
  1982. </form>
  1983. <?php
  1984. fm_show_footer();
  1985. //--- END
  1986. // Functions
  1987. function checkSyncPermission($path, $file){
  1988. if(empty($file))return false;
  1989. if(in_array($file, ['Android', 'iOS']))return false;
  1990. if(empty($path))return false;
  1991. if(strpos($path, 'crazycoin/') !== 0)return false;
  1992. if(strpos($path,'crazycoin/cfg') === false)return true;
  1993. return false;
  1994. }
  1995. /**
  1996. * Check if the filename is allowed.
  1997. * @param string $filename
  1998. * @return bool
  1999. */
  2000. function fm_is_file_allowed($filename)
  2001. {
  2002. // By default, no file is allowed
  2003. $allowed = false;
  2004. if (FM_EXTENSION) {
  2005. $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
  2006. if (in_array($ext, explode(',', strtolower(FM_EXTENSION)))) {
  2007. $allowed = true;
  2008. }
  2009. }
  2010. return $allowed;
  2011. }
  2012. /**
  2013. * Delete file or folder (recursively)
  2014. * @param string $path
  2015. * @return bool
  2016. */
  2017. function fm_rdelete_backup($path)
  2018. {
  2019. if (is_link($path)) {
  2020. return unlink($path);
  2021. } elseif (is_dir($path)) {
  2022. $objects = scandir($path);
  2023. $ok = true;
  2024. if (is_array($objects)) {
  2025. foreach ($objects as $file) {
  2026. if ($file != '.' && $file != '..') {
  2027. if (!fm_rdelete($path . '/' . $file)) {
  2028. $ok = false;
  2029. }
  2030. }
  2031. }
  2032. }
  2033. return ($ok) ? rmdir($path) : false;
  2034. } elseif (is_file($path)) {
  2035. return unlink($path);
  2036. }
  2037. return false;
  2038. }
  2039. /**
  2040. * Delete file or folder (recursively)
  2041. * @param string $path
  2042. * @return bool
  2043. */
  2044. function fm_rdelete($path){
  2045. $name = $_SESSION[FM_SESSION_ID]['userName'];
  2046. if (is_link($path)) {
  2047. $fileName = explode('/',$path);
  2048. if(count($fileName) > 0){
  2049. return rename($path,DOCUMENT_ROOT."/public/RecycleBin/".time()."_".$name."_".str_replace("/","-",$path));
  2050. }
  2051. return false;
  2052. } elseif (is_dir($path)) {
  2053. $objects = scandir($path);
  2054. $ok = true;
  2055. if (is_array($objects)) {
  2056. foreach ($objects as $file) {
  2057. if ($file != '.' && $file != '..') {
  2058. if (!fm_rdelete($path . '/' . $file)) {
  2059. $ok = false;
  2060. }
  2061. }
  2062. }
  2063. }
  2064. return ($ok) ? rmdir($path) : false;
  2065. } elseif (is_file($path)) {
  2066. $fileName = explode('/',$path);
  2067. if(count($fileName) > 0){
  2068. return rename($path,DOCUMENT_ROOT."/public/RecycleBin/".time()."_".$name."_".str_replace("/","-",$path));
  2069. }
  2070. return false;
  2071. }
  2072. return false;
  2073. }
  2074. /**
  2075. * Recursive chmod
  2076. * @param string $path
  2077. * @param int $filemode
  2078. * @param int $dirmode
  2079. * @return bool
  2080. * @todo Will use in mass chmod
  2081. */
  2082. function fm_rchmod($path, $filemode, $dirmode)
  2083. {
  2084. if (is_dir($path)) {
  2085. if (!chmod($path, $dirmode)) {
  2086. return false;
  2087. }
  2088. $objects = scandir($path);
  2089. if (is_array($objects)) {
  2090. foreach ($objects as $file) {
  2091. if ($file != '.' && $file != '..') {
  2092. if (!fm_rchmod($path . '/' . $file, $filemode, $dirmode)) {
  2093. return false;
  2094. }
  2095. }
  2096. }
  2097. }
  2098. return true;
  2099. } elseif (is_link($path)) {
  2100. return true;
  2101. } elseif (is_file($path)) {
  2102. return chmod($path, $filemode);
  2103. }
  2104. return false;
  2105. }
  2106. /**
  2107. * Check the file extension which is allowed or not
  2108. * @param string $filename
  2109. * @return bool
  2110. */
  2111. function fm_is_valid_ext($filename)
  2112. {
  2113. $allowed = (FM_FILE_EXTENSION) ? explode(',', FM_FILE_EXTENSION) : false;
  2114. $ext = pathinfo($filename, PATHINFO_EXTENSION);
  2115. $isFileAllowed = ($allowed) ? in_array($ext, $allowed) : true;
  2116. return ($isFileAllowed) ? true : false;
  2117. }
  2118. /**
  2119. * Safely rename
  2120. * @param string $old
  2121. * @param string $new
  2122. * @return bool|null
  2123. */
  2124. function fm_rename($old, $new)
  2125. {
  2126. $isFileAllowed = fm_is_valid_ext($new);
  2127. if(!$isFileAllowed) return false;
  2128. return (!file_exists($new) && file_exists($old)) ? rename($old, $new) : null;
  2129. }
  2130. /**
  2131. * Copy file or folder (recursively).
  2132. * @param string $path
  2133. * @param string $dest
  2134. * @param bool $upd Update files
  2135. * @param bool $force Create folder with same names instead file
  2136. * @return bool
  2137. */
  2138. function fm_rcopy($path, $dest, $upd = true, $force = true)
  2139. {
  2140. if (is_dir($path)) {
  2141. if (!fm_mkdir($dest, $force)) {
  2142. return false;
  2143. }
  2144. $objects = scandir($path);
  2145. $ok = true;
  2146. if (is_array($objects)) {
  2147. foreach ($objects as $file) {
  2148. if ($file != '.' && $file != '..') {
  2149. if (!fm_rcopy($path . '/' . $file, $dest . '/' . $file)) {
  2150. $ok = false;
  2151. }
  2152. }
  2153. }
  2154. }
  2155. return $ok;
  2156. } elseif (is_file($path)) {
  2157. return fm_copy($path, $dest, $upd);
  2158. }
  2159. return false;
  2160. }
  2161. /**
  2162. * Safely create folder
  2163. * @param string $dir
  2164. * @param bool $force
  2165. * @return bool
  2166. */
  2167. function fm_mkdir($dir, $force)
  2168. {
  2169. if (file_exists($dir)) {
  2170. if (is_dir($dir)) {
  2171. return $dir;
  2172. } elseif (!$force) {
  2173. return false;
  2174. }
  2175. unlink($dir);
  2176. }
  2177. return mkdir($dir, 0777, true);
  2178. }
  2179. /**
  2180. * Safely copy file
  2181. * @param string $f1
  2182. * @param string $f2
  2183. * @param bool $upd Indicates if file should be updated with new content
  2184. * @return bool
  2185. */
  2186. function fm_copy($f1, $f2, $upd)
  2187. {
  2188. $time1 = filemtime($f1);
  2189. if (file_exists($f2)) {
  2190. $time2 = filemtime($f2);
  2191. if ($time2 >= $time1 && $upd) {
  2192. return false;
  2193. }
  2194. }
  2195. $ok = copy($f1, $f2);
  2196. if ($ok) {
  2197. touch($f2, $time1);
  2198. }
  2199. return $ok;
  2200. }
  2201. /**
  2202. * Get mime type
  2203. * @param string $file_path
  2204. * @return mixed|string
  2205. */
  2206. function fm_get_mime_type($file_path)
  2207. {
  2208. if (function_exists('finfo_open')) {
  2209. $finfo = finfo_open(FILEINFO_MIME_TYPE);
  2210. $mime = finfo_file($finfo, $file_path);
  2211. finfo_close($finfo);
  2212. return $mime;
  2213. } elseif (function_exists('mime_content_type')) {
  2214. return mime_content_type($file_path);
  2215. } elseif (!stristr(ini_get('disable_functions'), 'shell_exec')) {
  2216. $file = escapeshellarg($file_path);
  2217. $mime = shell_exec('file -bi ' . $file);
  2218. return $mime;
  2219. } else {
  2220. return '--';
  2221. }
  2222. }
  2223. /**
  2224. * HTTP Redirect
  2225. * @param string $url
  2226. * @param int $code
  2227. */
  2228. function fm_redirect($url, $code = 302)
  2229. {
  2230. header('Location: ' . $url, true, $code);
  2231. exit;
  2232. }
  2233. /**
  2234. * Path traversal prevention and clean the url
  2235. * It replaces (consecutive) occurrences of / and \\ with whatever is in DIRECTORY_SEPARATOR, and processes /. and /.. fine.
  2236. * @param $path
  2237. * @return string
  2238. */
  2239. function get_absolute_path($path) {
  2240. $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
  2241. $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
  2242. $absolutes = array();
  2243. foreach ($parts as $part) {
  2244. if ('.' == $part) continue;
  2245. if ('..' == $part) {
  2246. array_pop($absolutes);
  2247. } else {
  2248. $absolutes[] = $part;
  2249. }
  2250. }
  2251. return implode(DIRECTORY_SEPARATOR, $absolutes);
  2252. }
  2253. /**
  2254. * Clean path
  2255. * @param string $path
  2256. * @return string
  2257. */
  2258. function fm_clean_path($path, $trim = true)
  2259. {
  2260. $path = $trim ? trim($path) : $path;
  2261. $path = trim($path, '\\/');
  2262. $path = str_replace(array('../', '..\\'), '', $path);
  2263. $path = get_absolute_path($path);
  2264. if ($path == '..') {
  2265. $path = '';
  2266. }
  2267. return str_replace('\\', '/', $path);
  2268. }
  2269. /**
  2270. * Get parent path
  2271. * @param string $path
  2272. * @return bool|string
  2273. */
  2274. function fm_get_parent_path($path)
  2275. {
  2276. $path = fm_clean_path($path);
  2277. if ($path != '') {
  2278. $array = explode('/', $path);
  2279. if (count($array) > 1) {
  2280. $array = array_slice($array, 0, -1);
  2281. return implode('/', $array);
  2282. }
  2283. return '';
  2284. }
  2285. return false;
  2286. }
  2287. /**
  2288. * Check file is in exclude list
  2289. * @param string $file
  2290. * @return bool
  2291. */
  2292. function fm_is_exclude_items($file) {
  2293. $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
  2294. if(!in_array($file, FM_EXCLUDE_ITEMS) && !in_array("*.$ext", FM_EXCLUDE_ITEMS)) {
  2295. return true;
  2296. }
  2297. return false;
  2298. }
  2299. /**
  2300. * get language translations from json file
  2301. * @param int $tr
  2302. * @return array
  2303. */
  2304. function fm_get_translations($tr) {
  2305. try {
  2306. $content = @file_get_contents('translation.json');
  2307. if($content !== FALSE) {
  2308. $lng = json_decode($content, TRUE);
  2309. global $lang_list;
  2310. foreach ($lng["language"] as $key => $value)
  2311. {
  2312. $code = $value["code"];
  2313. $lang_list[$code] = $value["name"];
  2314. if ($tr)
  2315. $tr[$code] = $value["translation"];
  2316. }
  2317. return $tr;
  2318. }
  2319. }
  2320. catch (Exception $e) {
  2321. echo $e;
  2322. }
  2323. }
  2324. /**
  2325. * @param $file
  2326. * Recover all file sizes larger than > 2GB.
  2327. * Works on php 32bits and 64bits and supports linux
  2328. * @return int|string
  2329. */
  2330. function fm_get_size($file)
  2331. {
  2332. static $iswin;
  2333. static $isdarwin;
  2334. if (!isset($iswin)) {
  2335. $iswin = (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN');
  2336. }
  2337. if (!isset($isdarwin)) {
  2338. $isdarwin = (strtoupper(substr(PHP_OS, 0)) == "DARWIN");
  2339. }
  2340. static $exec_works;
  2341. if (!isset($exec_works)) {
  2342. $exec_works = (function_exists('exec') && !ini_get('safe_mode') && @exec('echo EXEC') == 'EXEC');
  2343. }
  2344. // try a shell command
  2345. if ($exec_works) {
  2346. $arg = escapeshellarg($file);
  2347. $cmd = ($iswin) ? "for %F in (\"$file\") do @echo %~zF" : ($isdarwin ? "stat -f%z $arg" : "stat -c%s $arg");
  2348. @exec($cmd, $output);
  2349. if (is_array($output) && ctype_digit($size = trim(implode("\n", $output)))) {
  2350. return $size;
  2351. }
  2352. }
  2353. // try the Windows COM interface
  2354. if ($iswin && class_exists("COM")) {
  2355. try {
  2356. $fsobj = new COM('Scripting.FileSystemObject');
  2357. $f = $fsobj->GetFile( realpath($file) );
  2358. $size = $f->Size;
  2359. } catch (Exception $e) {
  2360. $size = null;
  2361. }
  2362. if (ctype_digit($size)) {
  2363. return $size;
  2364. }
  2365. }
  2366. // if all else fails
  2367. return filesize($file);
  2368. }
  2369. /**
  2370. * Get nice filesize
  2371. * @param int $size
  2372. * @return string
  2373. */
  2374. function fm_get_filesize($size)
  2375. {
  2376. $size = (float) $size;
  2377. $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
  2378. $power = $size > 0 ? floor(log($size, 1024)) : 0;
  2379. return sprintf('%s %s', round($size / pow(1024, $power), 2), $units[$power]);
  2380. }
  2381. /**
  2382. * Get director total size
  2383. * @param string $directory
  2384. * @return int
  2385. */
  2386. function fm_get_directorysize($directory) {
  2387. global $calc_folder;
  2388. if ($calc_folder==true) { // Slower output
  2389. $size = 0; $count= 0; $dirCount= 0;
  2390. foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file)
  2391. if ($file->isFile())
  2392. { $size+=$file->getSize();
  2393. $count++;
  2394. }
  2395. else if ($file->isDir()) { $dirCount++; }
  2396. // return [$size, $count, $dirCount];
  2397. return $size;
  2398. }
  2399. else return 'Folder'; // Quick output
  2400. }
  2401. /**
  2402. * Get info about zip archive
  2403. * @param string $path
  2404. * @return array|bool
  2405. */
  2406. function fm_get_zif_info($path, $ext) {
  2407. if ($ext == 'zip' && function_exists('zip_open')) {
  2408. $arch = zip_open($path);
  2409. if ($arch) {
  2410. $filenames = array();
  2411. while ($zip_entry = zip_read($arch)) {
  2412. $zip_name = zip_entry_name($zip_entry);
  2413. $zip_folder = substr($zip_name, -1) == '/';
  2414. $filenames[] = array(
  2415. 'name' => $zip_name,
  2416. 'filesize' => zip_entry_filesize($zip_entry),
  2417. 'compressed_size' => zip_entry_compressedsize($zip_entry),
  2418. 'folder' => $zip_folder
  2419. //'compression_method' => zip_entry_compressionmethod($zip_entry),
  2420. );
  2421. }
  2422. zip_close($arch);
  2423. return $filenames;
  2424. }
  2425. } elseif($ext == 'tar' && class_exists('PharData')) {
  2426. $archive = new PharData($path);
  2427. $filenames = array();
  2428. foreach(new RecursiveIteratorIterator($archive) as $file) {
  2429. $parent_info = $file->getPathInfo();
  2430. $zip_name = str_replace("phar://".$path, '', $file->getPathName());
  2431. $zip_name = substr($zip_name, ($pos = strpos($zip_name, '/')) !== false ? $pos + 1 : 0);
  2432. $zip_folder = $parent_info->getFileName();
  2433. $zip_info = new SplFileInfo($file);
  2434. $filenames[] = array(
  2435. 'name' => $zip_name,
  2436. 'filesize' => $zip_info->getSize(),
  2437. 'compressed_size' => $file->getCompressedSize(),
  2438. 'folder' => $zip_folder
  2439. );
  2440. }
  2441. return $filenames;
  2442. }
  2443. return false;
  2444. }
  2445. /**
  2446. * Encode html entities
  2447. * @param string $text
  2448. * @return string
  2449. */
  2450. function fm_enc($text)
  2451. {
  2452. return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
  2453. }
  2454. /**
  2455. * Prevent XSS attacks
  2456. * @param string $text
  2457. * @return string
  2458. */
  2459. function fm_isvalid_filename($text) {
  2460. return (strpbrk($text, '/?%*:|"<>') === FALSE) ? true : false;
  2461. }
  2462. /**
  2463. * Save message in session
  2464. * @param string $msg
  2465. * @param string $status
  2466. */
  2467. function fm_set_msg($msg, $status = 'ok')
  2468. {
  2469. $_SESSION[FM_SESSION_ID]['message'] = $msg;
  2470. $_SESSION[FM_SESSION_ID]['status'] = $status;
  2471. }
  2472. /**
  2473. * Check if string is in UTF-8
  2474. * @param string $string
  2475. * @return int
  2476. */
  2477. function fm_is_utf8($string)
  2478. {
  2479. return preg_match('//u', $string);
  2480. }
  2481. /**
  2482. * Convert file name to UTF-8 in Windows
  2483. * @param string $filename
  2484. * @return string
  2485. */
  2486. function fm_convert_win($filename)
  2487. {
  2488. if (FM_IS_WIN && function_exists('iconv')) {
  2489. $filename = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $filename);
  2490. }
  2491. return $filename;
  2492. }
  2493. /**
  2494. * @param $obj
  2495. * @return array
  2496. */
  2497. function fm_object_to_array($obj)
  2498. {
  2499. if (!is_object($obj) && !is_array($obj)) {
  2500. return $obj;
  2501. }
  2502. if (is_object($obj)) {
  2503. $obj = get_object_vars($obj);
  2504. }
  2505. return array_map('fm_object_to_array', $obj);
  2506. }
  2507. /**
  2508. * Get CSS classname for file
  2509. * @param string $path
  2510. * @return string
  2511. */
  2512. function fm_get_file_icon_class($path)
  2513. {
  2514. // get extension
  2515. $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
  2516. switch ($ext) {
  2517. case 'ico':
  2518. case 'gif':
  2519. case 'jpg':
  2520. case 'jpeg':
  2521. case 'jpc':
  2522. case 'jp2':
  2523. case 'jpx':
  2524. case 'xbm':
  2525. case 'wbmp':
  2526. case 'png':
  2527. case 'bmp':
  2528. case 'tif':
  2529. case 'tiff':
  2530. case 'svg':
  2531. $img = 'fa fa-picture-o';
  2532. break;
  2533. case 'passwd':
  2534. case 'ftpquota':
  2535. case 'sql':
  2536. case 'js':
  2537. case 'json':
  2538. case 'sh':
  2539. case 'config':
  2540. case 'twig':
  2541. case 'tpl':
  2542. case 'md':
  2543. case 'gitignore':
  2544. case 'c':
  2545. case 'cpp':
  2546. case 'cs':
  2547. case 'py':
  2548. case 'map':
  2549. case 'lock':
  2550. case 'dtd':
  2551. $img = 'fa fa-file-code-o';
  2552. break;
  2553. case 'txt':
  2554. case 'ini':
  2555. case 'conf':
  2556. case 'log':
  2557. case 'htaccess':
  2558. $img = 'fa fa-file-text-o';
  2559. break;
  2560. case 'css':
  2561. case 'less':
  2562. case 'sass':
  2563. case 'scss':
  2564. $img = 'fa fa-css3';
  2565. break;
  2566. case 'zip':
  2567. case 'rar':
  2568. case 'gz':
  2569. case 'tar':
  2570. case '7z':
  2571. $img = 'fa fa-file-archive-o';
  2572. break;
  2573. case 'php':
  2574. case 'php4':
  2575. case 'php5':
  2576. case 'phps':
  2577. case 'phtml':
  2578. $img = 'fa fa-code';
  2579. break;
  2580. case 'htm':
  2581. case 'html':
  2582. case 'shtml':
  2583. case 'xhtml':
  2584. $img = 'fa fa-html5';
  2585. break;
  2586. case 'xml':
  2587. case 'xsl':
  2588. $img = 'fa fa-file-excel-o';
  2589. break;
  2590. case 'wav':
  2591. case 'mp3':
  2592. case 'mp2':
  2593. case 'm4a':
  2594. case 'aac':
  2595. case 'ogg':
  2596. case 'oga':
  2597. case 'wma':
  2598. case 'mka':
  2599. case 'flac':
  2600. case 'ac3':
  2601. case 'tds':
  2602. $img = 'fa fa-music';
  2603. break;
  2604. case 'm3u':
  2605. case 'm3u8':
  2606. case 'pls':
  2607. case 'cue':
  2608. $img = 'fa fa-headphones';
  2609. break;
  2610. case 'avi':
  2611. case 'mpg':
  2612. case 'mpeg':
  2613. case 'mp4':
  2614. case 'm4v':
  2615. case 'flv':
  2616. case 'f4v':
  2617. case 'ogm':
  2618. case 'ogv':
  2619. case 'mov':
  2620. case 'mkv':
  2621. case '3gp':
  2622. case 'asf':
  2623. case 'wmv':
  2624. $img = 'fa fa-file-video-o';
  2625. break;
  2626. case 'eml':
  2627. case 'msg':
  2628. $img = 'fa fa-envelope-o';
  2629. break;
  2630. case 'xls':
  2631. case 'xlsx':
  2632. case 'ods':
  2633. $img = 'fa fa-file-excel-o';
  2634. break;
  2635. case 'csv':
  2636. $img = 'fa fa-file-text-o';
  2637. break;
  2638. case 'bak':
  2639. $img = 'fa fa-clipboard';
  2640. break;
  2641. case 'doc':
  2642. case 'docx':
  2643. case 'odt':
  2644. $img = 'fa fa-file-word-o';
  2645. break;
  2646. case 'ppt':
  2647. case 'pptx':
  2648. $img = 'fa fa-file-powerpoint-o';
  2649. break;
  2650. case 'ttf':
  2651. case 'ttc':
  2652. case 'otf':
  2653. case 'woff':
  2654. case 'woff2':
  2655. case 'eot':
  2656. case 'fon':
  2657. $img = 'fa fa-font';
  2658. break;
  2659. case 'pdf':
  2660. $img = 'fa fa-file-pdf-o';
  2661. break;
  2662. case 'psd':
  2663. case 'ai':
  2664. case 'eps':
  2665. case 'fla':
  2666. case 'swf':
  2667. $img = 'fa fa-file-image-o';
  2668. break;
  2669. case 'exe':
  2670. case 'msi':
  2671. $img = 'fa fa-file-o';
  2672. break;
  2673. case 'bat':
  2674. $img = 'fa fa-terminal';
  2675. break;
  2676. default:
  2677. $img = 'fa fa-info-circle';
  2678. }
  2679. return $img;
  2680. }
  2681. /**
  2682. * Get image files extensions
  2683. * @return array
  2684. */
  2685. function fm_get_image_exts()
  2686. {
  2687. return array('ico', 'gif', 'jpg', 'jpeg', 'jpc', 'jp2', 'jpx', 'xbm', 'wbmp', 'png', 'bmp', 'tif', 'tiff', 'psd', 'svg');
  2688. }
  2689. /**
  2690. * Get video files extensions
  2691. * @return array
  2692. */
  2693. function fm_get_video_exts()
  2694. {
  2695. return array('avi', 'webm', 'wmv', 'mp4', 'm4v', 'ogm', 'ogv', 'mov', 'mkv');
  2696. }
  2697. /**
  2698. * Get audio files extensions
  2699. * @return array
  2700. */
  2701. function fm_get_audio_exts()
  2702. {
  2703. return array('wav', 'mp3', 'ogg', 'm4a');
  2704. }
  2705. /**
  2706. * Get text file extensions
  2707. * @return array
  2708. */
  2709. function fm_get_text_exts()
  2710. {
  2711. return array(
  2712. 'txt', 'css', 'ini', 'conf', 'log', 'htaccess', 'passwd', 'ftpquota', 'sql', 'js', 'json', 'sh', 'config',
  2713. 'php', 'php4', 'php5', 'phps', 'phtml', 'htm', 'html', 'shtml', 'xhtml', 'xml', 'xsl', 'm3u', 'm3u8', 'pls', 'cue',
  2714. 'eml', 'msg', 'csv', 'bat', 'twig', 'tpl', 'md', 'gitignore', 'less', 'sass', 'scss', 'c', 'cpp', 'cs', 'py',
  2715. 'map', 'lock', 'dtd', 'svg', 'scss', 'asp', 'aspx', 'asx', 'asmx', 'ashx', 'jsx', 'jsp', 'jspx', 'cfm', 'cgi'
  2716. );
  2717. }
  2718. /**
  2719. * Get mime types of text files
  2720. * @return array
  2721. */
  2722. function fm_get_text_mimes()
  2723. {
  2724. return array(
  2725. 'application/xml',
  2726. 'application/javascript',
  2727. 'application/x-javascript',
  2728. 'image/svg+xml',
  2729. 'message/rfc822',
  2730. );
  2731. }
  2732. /**
  2733. * Get file names of text files w/o extensions
  2734. * @return array
  2735. */
  2736. function fm_get_text_names()
  2737. {
  2738. return array(
  2739. 'license',
  2740. 'readme',
  2741. 'authors',
  2742. 'contributors',
  2743. 'changelog',
  2744. );
  2745. }
  2746. /**
  2747. * Get online docs viewer supported files extensions
  2748. * @return array
  2749. */
  2750. function fm_get_onlineViewer_exts()
  2751. {
  2752. return array('doc', 'docx', 'xls', 'xlsx', 'pdf', 'ppt', 'pptx', 'ai', 'psd', 'dxf', 'xps', 'rar', 'odt', 'ods');
  2753. }
  2754. function fm_get_file_mimes($extension)
  2755. {
  2756. $fileTypes['swf'] = 'application/x-shockwave-flash';
  2757. $fileTypes['pdf'] = 'application/pdf';
  2758. $fileTypes['exe'] = 'application/octet-stream';
  2759. $fileTypes['zip'] = 'application/zip';
  2760. $fileTypes['doc'] = 'application/msword';
  2761. $fileTypes['xls'] = 'application/vnd.ms-excel';
  2762. $fileTypes['ppt'] = 'application/vnd.ms-powerpoint';
  2763. $fileTypes['gif'] = 'image/gif';
  2764. $fileTypes['png'] = 'image/png';
  2765. $fileTypes['jpeg'] = 'image/jpg';
  2766. $fileTypes['jpg'] = 'image/jpg';
  2767. $fileTypes['rar'] = 'application/rar';
  2768. $fileTypes['ra'] = 'audio/x-pn-realaudio';
  2769. $fileTypes['ram'] = 'audio/x-pn-realaudio';
  2770. $fileTypes['ogg'] = 'audio/x-pn-realaudio';
  2771. $fileTypes['wav'] = 'video/x-msvideo';
  2772. $fileTypes['wmv'] = 'video/x-msvideo';
  2773. $fileTypes['avi'] = 'video/x-msvideo';
  2774. $fileTypes['asf'] = 'video/x-msvideo';
  2775. $fileTypes['divx'] = 'video/x-msvideo';
  2776. $fileTypes['mp3'] = 'audio/mpeg';
  2777. $fileTypes['mp4'] = 'audio/mpeg';
  2778. $fileTypes['mpeg'] = 'video/mpeg';
  2779. $fileTypes['mpg'] = 'video/mpeg';
  2780. $fileTypes['mpe'] = 'video/mpeg';
  2781. $fileTypes['mov'] = 'video/quicktime';
  2782. $fileTypes['swf'] = 'video/quicktime';
  2783. $fileTypes['3gp'] = 'video/quicktime';
  2784. $fileTypes['m4a'] = 'video/quicktime';
  2785. $fileTypes['aac'] = 'video/quicktime';
  2786. $fileTypes['m3u'] = 'video/quicktime';
  2787. $fileTypes['php'] = ['application/x-php'];
  2788. $fileTypes['html'] = ['text/html'];
  2789. $fileTypes['txt'] = ['text/plain'];
  2790. return $fileTypes[$extension];
  2791. }
  2792. /**
  2793. * This function scans the files and folder recursively, and return matching files
  2794. * @param string $dir
  2795. * @param string $filter
  2796. * @return json
  2797. */
  2798. function scan($dir, $filter = '') {
  2799. $path = FM_ROOT_PATH.'/'.$dir;
  2800. if($dir) {
  2801. $ite = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
  2802. $rii = new RegexIterator($ite, "/(" . $filter . ")/i");
  2803. $files = array();
  2804. foreach ($rii as $file) {
  2805. if (!$file->isDir()) {
  2806. $fileName = $file->getFilename();
  2807. $location = str_replace(FM_ROOT_PATH, '', $file->getPath());
  2808. $files[] = array(
  2809. "name" => $fileName,
  2810. "type" => "file",
  2811. "path" => $location,
  2812. );
  2813. }
  2814. }
  2815. return $files;
  2816. }
  2817. }
  2818. /*
  2819. Parameters: downloadFile(File Location, File Name,
  2820. max speed, is streaming
  2821. If streaming - videos will show as videos, images as images
  2822. instead of download prompt
  2823. https://stackoverflow.com/a/13821992/1164642
  2824. */
  2825. function fm_download_file($fileLocation, $fileName, $chunkSize = 1024)
  2826. {
  2827. if (connection_status() != 0)
  2828. return (false);
  2829. $extension = pathinfo($fileName, PATHINFO_EXTENSION);
  2830. $contentType = fm_get_file_mimes($extension);
  2831. header("Cache-Control: public");
  2832. header("Content-Transfer-Encoding: binary\n");
  2833. header('Content-Type: $contentType');
  2834. $contentDisposition = 'attachment';
  2835. if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
  2836. $fileName = preg_replace('/\./', '%2e', $fileName, substr_count($fileName, '.') - 1);
  2837. header("Content-Disposition: $contentDisposition;filename=\"$fileName\"");
  2838. } else {
  2839. header("Content-Disposition: $contentDisposition;filename=\"$fileName\"");
  2840. }
  2841. header("Accept-Ranges: bytes");
  2842. $range = 0;
  2843. $size = filesize($fileLocation);
  2844. if (isset($_SERVER['HTTP_RANGE'])) {
  2845. list($a, $range) = explode("=", $_SERVER['HTTP_RANGE']);
  2846. str_replace($range, "-", $range);
  2847. $size2 = $size - 1;
  2848. $new_length = $size - $range;
  2849. header("HTTP/1.1 206 Partial Content");
  2850. header("Content-Length: $new_length");
  2851. header("Content-Range: bytes $range$size2/$size");
  2852. } else {
  2853. $size2 = $size - 1;
  2854. header("Content-Range: bytes 0-$size2/$size");
  2855. header("Content-Length: " . $size);
  2856. }
  2857. if ($size == 0) {
  2858. die('Zero byte file! Aborting download');
  2859. }
  2860. @ini_set('magic_quotes_runtime', 0);
  2861. $fp = fopen("$fileLocation", "rb");
  2862. fseek($fp, $range);
  2863. while (!feof($fp) and (connection_status() == 0)) {
  2864. set_time_limit(0);
  2865. print(@fread($fp, 1024*$chunkSize));
  2866. flush();
  2867. ob_flush();
  2868. sleep(1);
  2869. }
  2870. fclose($fp);
  2871. return ((connection_status() == 0) and !connection_aborted());
  2872. }
  2873. function fm_get_theme() {
  2874. $result = '';
  2875. if(FM_THEME == "dark") {
  2876. $result = "text-white bg-dark";
  2877. }
  2878. return $result;
  2879. }
  2880. /**
  2881. * Class to work with zip files (using ZipArchive)
  2882. */
  2883. class FM_Zipper
  2884. {
  2885. private $zip;
  2886. public function __construct()
  2887. {
  2888. $this->zip = new ZipArchive();
  2889. }
  2890. /**
  2891. * Create archive with name $filename and files $files (RELATIVE PATHS!)
  2892. * @param string $filename
  2893. * @param array|string $files
  2894. * @return bool
  2895. */
  2896. public function create($filename, $files)
  2897. {
  2898. $res = $this->zip->open($filename, ZipArchive::CREATE);
  2899. if ($res !== true) {
  2900. return false;
  2901. }
  2902. if (is_array($files)) {
  2903. foreach ($files as $f) {
  2904. if (!$this->addFileOrDir($f)) {
  2905. $this->zip->close();
  2906. return false;
  2907. }
  2908. }
  2909. $this->zip->close();
  2910. return true;
  2911. } else {
  2912. if ($this->addFileOrDir($files)) {
  2913. $this->zip->close();
  2914. return true;
  2915. }
  2916. return false;
  2917. }
  2918. }
  2919. /**
  2920. * Extract archive $filename to folder $path (RELATIVE OR ABSOLUTE PATHS)
  2921. * @param string $filename
  2922. * @param string $path
  2923. * @return bool
  2924. */
  2925. public function unzip($filename, $path)
  2926. {
  2927. $res = $this->zip->open($filename);
  2928. if ($res !== true) {
  2929. return false;
  2930. }
  2931. if ($this->zip->extractTo($path)) {
  2932. $this->zip->close();
  2933. return true;
  2934. }
  2935. return false;
  2936. }
  2937. /**
  2938. * Add file/folder to archive
  2939. * @param string $filename
  2940. * @return bool
  2941. */
  2942. private function addFileOrDir($filename)
  2943. {
  2944. if (is_file($filename)) {
  2945. return $this->zip->addFile($filename);
  2946. } elseif (is_dir($filename)) {
  2947. return $this->addDir($filename);
  2948. }
  2949. return false;
  2950. }
  2951. /**
  2952. * Add folder recursively
  2953. * @param string $path
  2954. * @return bool
  2955. */
  2956. private function addDir($path)
  2957. {
  2958. if (!$this->zip->addEmptyDir($path)) {
  2959. return false;
  2960. }
  2961. $objects = scandir($path);
  2962. if (is_array($objects)) {
  2963. foreach ($objects as $file) {
  2964. if ($file != '.' && $file != '..') {
  2965. if (is_dir($path . '/' . $file)) {
  2966. if (!$this->addDir($path . '/' . $file)) {
  2967. return false;
  2968. }
  2969. } elseif (is_file($path . '/' . $file)) {
  2970. if (!$this->zip->addFile($path . '/' . $file)) {
  2971. return false;
  2972. }
  2973. }
  2974. }
  2975. }
  2976. return true;
  2977. }
  2978. return false;
  2979. }
  2980. }
  2981. /**
  2982. * Class to work with Tar files (using PharData)
  2983. */
  2984. class FM_Zipper_Tar
  2985. {
  2986. private $tar;
  2987. public function __construct()
  2988. {
  2989. $this->tar = null;
  2990. }
  2991. /**
  2992. * Create archive with name $filename and files $files (RELATIVE PATHS!)
  2993. * @param string $filename
  2994. * @param array|string $files
  2995. * @return bool
  2996. */
  2997. public function create($filename, $files)
  2998. {
  2999. $this->tar = new PharData($filename);
  3000. if (is_array($files)) {
  3001. foreach ($files as $f) {
  3002. if (!$this->addFileOrDir($f)) {
  3003. return false;
  3004. }
  3005. }
  3006. return true;
  3007. } else {
  3008. if ($this->addFileOrDir($files)) {
  3009. return true;
  3010. }
  3011. return false;
  3012. }
  3013. }
  3014. /**
  3015. * Extract archive $filename to folder $path (RELATIVE OR ABSOLUTE PATHS)
  3016. * @param string $filename
  3017. * @param string $path
  3018. * @return bool
  3019. */
  3020. public function unzip($filename, $path)
  3021. {
  3022. $res = $this->tar->open($filename);
  3023. if ($res !== true) {
  3024. return false;
  3025. }
  3026. if ($this->tar->extractTo($path)) {
  3027. return true;
  3028. }
  3029. return false;
  3030. }
  3031. /**
  3032. * Add file/folder to archive
  3033. * @param string $filename
  3034. * @return bool
  3035. */
  3036. private function addFileOrDir($filename)
  3037. {
  3038. if (is_file($filename)) {
  3039. try {
  3040. $this->tar->addFile($filename);
  3041. return true;
  3042. } catch (Exception $e) {
  3043. return false;
  3044. }
  3045. } elseif (is_dir($filename)) {
  3046. return $this->addDir($filename);
  3047. }
  3048. return false;
  3049. }
  3050. /**
  3051. * Add folder recursively
  3052. * @param string $path
  3053. * @return bool
  3054. */
  3055. private function addDir($path)
  3056. {
  3057. $objects = scandir($path);
  3058. if (is_array($objects)) {
  3059. foreach ($objects as $file) {
  3060. if ($file != '.' && $file != '..') {
  3061. if (is_dir($path . '/' . $file)) {
  3062. if (!$this->addDir($path . '/' . $file)) {
  3063. return false;
  3064. }
  3065. } elseif (is_file($path . '/' . $file)) {
  3066. try {
  3067. $this->tar->addFile($path . '/' . $file);
  3068. } catch (Exception $e) {
  3069. return false;
  3070. }
  3071. }
  3072. }
  3073. }
  3074. return true;
  3075. }
  3076. return false;
  3077. }
  3078. }
  3079. /**
  3080. * Save Configuration
  3081. */
  3082. class FM_Config
  3083. {
  3084. var $data;
  3085. function __construct()
  3086. {
  3087. global $root_path, $root_url, $CONFIG;
  3088. $fm_url = $root_url.$_SERVER["PHP_SELF"];
  3089. $this->data = array(
  3090. 'lang' => 'en',
  3091. 'error_reporting' => true,
  3092. 'show_hidden' => true
  3093. );
  3094. $data = false;
  3095. if (strlen($CONFIG)) {
  3096. $data = fm_object_to_array(json_decode($CONFIG));
  3097. } else {
  3098. $msg = 'Tiny File Manager<br>Error: Cannot load configuration';
  3099. if (substr($fm_url, -1) == '/') {
  3100. $fm_url = rtrim($fm_url, '/');
  3101. $msg .= '<br>';
  3102. $msg .= '<br>Seems like you have a trailing slash on the URL.';
  3103. $msg .= '<br>Try this link: <a href="' . $fm_url . '">' . $fm_url . '</a>';
  3104. }
  3105. die($msg);
  3106. }
  3107. if (is_array($data) && count($data)) $this->data = $data;
  3108. else $this->save();
  3109. }
  3110. function save()
  3111. {
  3112. $fm_file = __FILE__;
  3113. $var_name = '$CONFIG';
  3114. $var_value = var_export(json_encode($this->data), true);
  3115. $config_string = "<?php" . chr(13) . chr(10) . "//Default Configuration".chr(13) . chr(10)."$var_name = $var_value;" . chr(13) . chr(10);
  3116. if (is_writable($fm_file)) {
  3117. $lines = file($fm_file);
  3118. if ($fh = @fopen($fm_file, "w")) {
  3119. @fputs($fh, $config_string, strlen($config_string));
  3120. for ($x = 3; $x < count($lines); $x++) {
  3121. @fputs($fh, $lines[$x], strlen($lines[$x]));
  3122. }
  3123. @fclose($fh);
  3124. }
  3125. }
  3126. }
  3127. }
  3128. //--- templates functions
  3129. /**
  3130. * Show nav block
  3131. * @param string $path
  3132. */
  3133. function fm_show_nav_path($path)
  3134. {
  3135. global $lang, $sticky_navbar;
  3136. $isStickyNavBar = $sticky_navbar ? 'fixed-top' : '';
  3137. $getTheme = fm_get_theme();
  3138. $getTheme .= " navbar-light";
  3139. if(FM_THEME == "dark") {
  3140. $getTheme .= " navbar-dark";
  3141. } else {
  3142. $getTheme .= " bg-white";
  3143. }
  3144. ?>
  3145. <nav class="navbar navbar-expand-lg <?php echo $getTheme; ?> mb-4 main-nav <?php echo $isStickyNavBar ?>">
  3146. <a class="navbar-brand" href=""> <?php echo lng('AppTitle') ?> </a>
  3147. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  3148. <span class="navbar-toggler-icon"></span>
  3149. </button>
  3150. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  3151. <?php
  3152. $path = fm_clean_path($path);
  3153. $root_url = "<a href='?fm_usr={$_GET['fm_usr']}&p='><i class='fa fa-home' aria-hidden='true' title='" . FM_ROOT_PATH . "'></i></a>";
  3154. $sep = '<i class="bread-crumb"> / </i>';
  3155. if ($path != '') {
  3156. $exploded = explode('/', $path);
  3157. $count = count($exploded);
  3158. $array = array();
  3159. $parent = '';
  3160. for ($i = 0; $i < $count; $i++) {
  3161. $parent = trim($parent . '/' . $exploded[$i], '/');
  3162. $parent_enc = urlencode($parent);
  3163. $array[] = "<a href='?fm_usr={$_GET['fm_usr']}&p={$parent_enc}'>" . fm_enc(fm_convert_win($exploded[$i])) . "</a>";
  3164. }
  3165. $root_url .= $sep . implode($sep, $array);
  3166. }
  3167. echo '<div class="col-xs-6 col-sm-5">' . $root_url . '</div>';
  3168. ?>
  3169. <div class="col-xs-6 col-sm-7 text-right">
  3170. <ul class="navbar-nav mr-auto float-right <?php echo fm_get_theme(); ?>">
  3171. <li class="nav-item mr-2">
  3172. <div class="input-group input-group-sm mr-1" style="margin-top:4px;">
  3173. <input type="text" class="form-control" placeholder="<?php echo lng('Search') ?>" aria-label="<?php echo lng('Search') ?>" aria-describedby="search-addon2" id="search-addon">
  3174. <div class="input-group-append">
  3175. <span class="input-group-text" id="search-addon2"><i class="fa fa-search"></i></span>
  3176. </div>
  3177. <div class="input-group-append btn-group">
  3178. <span class="input-group-text dropdown-toggle" id="search-addon2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
  3179. <div class="dropdown-menu dropdown-menu-right">
  3180. <a class="dropdown-item" href="<?php echo $path2 = $path ? $path : '.'; ?>" id="js-search-modal" data-toggle="modal" data-target="#searchModal">Advanced Search</a>
  3181. </div>
  3182. </div>
  3183. </div>
  3184. </li>
  3185. <?php if (!FM_READONLY): ?>
  3186. <li class="nav-item">
  3187. <a title="<?php echo lng('Upload') ?>" class="nav-link" href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=<?php echo urlencode(FM_PATH) ?>&amp;upload"><i class="fa fa-cloud-upload" aria-hidden="true"></i> <?php echo lng('Upload') ?></a>
  3188. </li>
  3189. <li class="nav-item">
  3190. <a title="<?php echo lng('NewItem') ?>" class="nav-link" href="#createNewItem" data-toggle="modal" data-target="#createNewItem"><i class="fa fa-plus-square"></i> <?php echo lng('NewItem') ?></a>
  3191. </li>
  3192. <?php endif; ?>
  3193. <?php if (FM_USE_AUTH): ?>
  3194. <li class="nav-item avatar dropdown">
  3195. <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink-5" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <i class="fa fa-user-circle"></i> <?php if(isset($_SESSION[FM_SESSION_ID]['logged'])) { echo $_SESSION[FM_SESSION_ID]['logged']; } ?></a>
  3196. <div class="dropdown-menu dropdown-menu-right <?php echo fm_get_theme(); ?>" aria-labelledby="navbarDropdownMenuLink-5">
  3197. <?php if (!FM_READONLY): ?>
  3198. <a title="<?php echo lng('Settings') ?>" class="dropdown-item nav-link" href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=<?php echo urlencode(FM_PATH) ?>&amp;settings=1"><i class="fa fa-cog" aria-hidden="true"></i> <?php echo lng('Settings') ?></a>
  3199. <?php endif ?>
  3200. <!-- <a title="--><?php //echo lng('Help') ?><!--" class="dropdown-item nav-link" href="?p=--><?php //echo urlencode(FM_PATH) ?><!--&amp;help=2"><i class="fa fa-exclamation-circle" aria-hidden="true"></i> --><?php //echo lng('Help') ?><!--</a>-->
  3201. <a title="<?php echo lng('Logout') ?>" class="dropdown-item nav-link" href="?logout=1"><i class="fa fa-sign-out" aria-hidden="true"></i> <?php echo lng('Logout') ?></a>
  3202. </div>
  3203. </li>
  3204. <?php else: ?>
  3205. <?php if (!FM_READONLY): ?>
  3206. <li class="nav-item">
  3207. <a title="<?php echo lng('Settings') ?>" class="dropdown-item nav-link" href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=<?php echo urlencode(FM_PATH) ?>&amp;settings=1"><i class="fa fa-cog" aria-hidden="true"></i> <?php echo lng('Settings') ?></a>
  3208. </li>
  3209. <?php endif; ?>
  3210. <?php endif; ?>
  3211. </ul>
  3212. </div>
  3213. </div>
  3214. </nav>
  3215. <?php
  3216. }
  3217. /**
  3218. * Show message from session
  3219. */
  3220. function fm_show_message()
  3221. {
  3222. if (isset($_SESSION[FM_SESSION_ID]['message'])) {
  3223. $class = isset($_SESSION[FM_SESSION_ID]['status']) ? $_SESSION[FM_SESSION_ID]['status'] : 'ok';
  3224. echo '<p class="message ' . $class . '">' . $_SESSION[FM_SESSION_ID]['message'] . '</p>';
  3225. unset($_SESSION[FM_SESSION_ID]['message']);
  3226. unset($_SESSION[FM_SESSION_ID]['status']);
  3227. }
  3228. }
  3229. /**
  3230. * Show page header in Login Form
  3231. */
  3232. function fm_show_header_login()
  3233. {
  3234. $sprites_ver = '20160315';
  3235. header("Content-Type: text/html; charset=utf-8");
  3236. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
  3237. header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
  3238. header("Pragma: no-cache");
  3239. global $lang, $root_url, $favicon_path;
  3240. ?>
  3241. <!DOCTYPE html>
  3242. <html lang="en">
  3243. <head>
  3244. <meta charset="utf-8">
  3245. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  3246. <meta name="description" content="Web based File Manager in PHP, Manage your files efficiently and easily with Tiny File Manager">
  3247. <meta name="author" content="CCP Programmers">
  3248. <meta name="robots" content="noindex, nofollow">
  3249. <meta name="googlebot" content="noindex">
  3250. <link rel="icon" href="<?php echo fm_enc($favicon_path) ?>" type="image/png">
  3251. <title><?php echo fm_enc(APP_TITLE) ?></title>
  3252. <link rel="stylesheet" href="/public/filemanager/js/bootstrap.min.css">
  3253. <style>
  3254. body.fm-login-page{ background-color:#f7f9fb;font-size:14px;background-color:#f7f9fb;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 304 304' width='304' height='304'%3E%3Cpath fill='%23e2e9f1' fill-opacity='0.4' d='M44.1 224a5 5 0 1 1 0 2H0v-2h44.1zm160 48a5 5 0 1 1 0 2H82v-2h122.1zm57.8-46a5 5 0 1 1 0-2H304v2h-42.1zm0 16a5 5 0 1 1 0-2H304v2h-42.1zm6.2-114a5 5 0 1 1 0 2h-86.2a5 5 0 1 1 0-2h86.2zm-256-48a5 5 0 1 1 0 2H0v-2h12.1zm185.8 34a5 5 0 1 1 0-2h86.2a5 5 0 1 1 0 2h-86.2zM258 12.1a5 5 0 1 1-2 0V0h2v12.1zm-64 208a5 5 0 1 1-2 0v-54.2a5 5 0 1 1 2 0v54.2zm48-198.2V80h62v2h-64V21.9a5 5 0 1 1 2 0zm16 16V64h46v2h-48V37.9a5 5 0 1 1 2 0zm-128 96V208h16v12.1a5 5 0 1 1-2 0V210h-16v-76.1a5 5 0 1 1 2 0zm-5.9-21.9a5 5 0 1 1 0 2H114v48H85.9a5 5 0 1 1 0-2H112v-48h12.1zm-6.2 130a5 5 0 1 1 0-2H176v-74.1a5 5 0 1 1 2 0V242h-60.1zm-16-64a5 5 0 1 1 0-2H114v48h10.1a5 5 0 1 1 0 2H112v-48h-10.1zM66 284.1a5 5 0 1 1-2 0V274H50v30h-2v-32h18v12.1zM236.1 176a5 5 0 1 1 0 2H226v94h48v32h-2v-30h-48v-98h12.1zm25.8-30a5 5 0 1 1 0-2H274v44.1a5 5 0 1 1-2 0V146h-10.1zm-64 96a5 5 0 1 1 0-2H208v-80h16v-14h-42.1a5 5 0 1 1 0-2H226v18h-16v80h-12.1zm86.2-210a5 5 0 1 1 0 2H272V0h2v32h10.1zM98 101.9V146H53.9a5 5 0 1 1 0-2H96v-42.1a5 5 0 1 1 2 0zM53.9 34a5 5 0 1 1 0-2H80V0h2v34H53.9zm60.1 3.9V66H82v64H69.9a5 5 0 1 1 0-2H80V64h32V37.9a5 5 0 1 1 2 0zM101.9 82a5 5 0 1 1 0-2H128V37.9a5 5 0 1 1 2 0V82h-28.1zm16-64a5 5 0 1 1 0-2H146v44.1a5 5 0 1 1-2 0V18h-26.1zm102.2 270a5 5 0 1 1 0 2H98v14h-2v-16h124.1zM242 149.9V160h16v34h-16v62h48v48h-2v-46h-48v-66h16v-30h-16v-12.1a5 5 0 1 1 2 0zM53.9 18a5 5 0 1 1 0-2H64V2H48V0h18v18H53.9zm112 32a5 5 0 1 1 0-2H192V0h50v2h-48v48h-28.1zm-48-48a5 5 0 0 1-9.8-2h2.07a3 3 0 1 0 5.66 0H178v34h-18V21.9a5 5 0 1 1 2 0V32h14V2h-58.1zm0 96a5 5 0 1 1 0-2H137l32-32h39V21.9a5 5 0 1 1 2 0V66h-40.17l-32 32H117.9zm28.1 90.1a5 5 0 1 1-2 0v-76.51L175.59 80H224V21.9a5 5 0 1 1 2 0V82h-49.59L146 112.41v75.69zm16 32a5 5 0 1 1-2 0v-99.51L184.59 96H300.1a5 5 0 0 1 3.9-3.9v2.07a3 3 0 0 0 0 5.66v2.07a5 5 0 0 1-3.9-3.9H185.41L162 121.41v98.69zm-144-64a5 5 0 1 1-2 0v-3.51l48-48V48h32V0h2v50H66v55.41l-48 48v2.69zM50 53.9v43.51l-48 48V208h26.1a5 5 0 1 1 0 2H0v-65.41l48-48V53.9a5 5 0 1 1 2 0zm-16 16V89.41l-34 34v-2.82l32-32V69.9a5 5 0 1 1 2 0zM12.1 32a5 5 0 1 1 0 2H9.41L0 43.41V40.6L8.59 32h3.51zm265.8 18a5 5 0 1 1 0-2h18.69l7.41-7.41v2.82L297.41 50H277.9zm-16 160a5 5 0 1 1 0-2H288v-71.41l16-16v2.82l-14 14V210h-28.1zm-208 32a5 5 0 1 1 0-2H64v-22.59L40.59 194H21.9a5 5 0 1 1 0-2H41.41L66 216.59V242H53.9zm150.2 14a5 5 0 1 1 0 2H96v-56.6L56.6 162H37.9a5 5 0 1 1 0-2h19.5L98 200.6V256h106.1zm-150.2 2a5 5 0 1 1 0-2H80v-46.59L48.59 178H21.9a5 5 0 1 1 0-2H49.41L82 208.59V258H53.9zM34 39.8v1.61L9.41 66H0v-2h8.59L32 40.59V0h2v39.8zM2 300.1a5 5 0 0 1 3.9 3.9H3.83A3 3 0 0 0 0 302.17V256h18v48h-2v-46H2v42.1zM34 241v63h-2v-62H0v-2h34v1zM17 18H0v-2h16V0h2v18h-1zm273-2h14v2h-16V0h2v16zm-32 273v15h-2v-14h-14v14h-2v-16h18v1zM0 92.1A5.02 5.02 0 0 1 6 97a5 5 0 0 1-6 4.9v-2.07a3 3 0 1 0 0-5.66V92.1zM80 272h2v32h-2v-32zm37.9 32h-2.07a3 3 0 0 0-5.66 0h-2.07a5 5 0 0 1 9.8 0zM5.9 0A5.02 5.02 0 0 1 0 5.9V3.83A3 3 0 0 0 3.83 0H5.9zm294.2 0h2.07A3 3 0 0 0 304 3.83V5.9a5 5 0 0 1-3.9-5.9zm3.9 300.1v2.07a3 3 0 0 0-1.83 1.83h-2.07a5 5 0 0 1 3.9-3.9zM97 100a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-48 32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 48a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-64a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 96a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-144a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-96 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm96 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-64a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-32 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM49 36a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-32 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM33 68a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-48a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 240a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-64a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm80-176a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 48a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm112 176a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM17 180a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM17 84a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 64a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6z'%3E%3C/path%3E%3C/svg%3E");}
  3255. .fm-login-page .brand{ width:121px;overflow:hidden;margin:0 auto;position:relative;z-index:1}
  3256. .fm-login-page .brand img{ width:100%}
  3257. .fm-login-page .card-wrapper{ width:360px;margin-top:10%;margin-left:auto;margin-right:auto;}
  3258. .fm-login-page .card{ border-color:transparent;box-shadow:0 4px 8px rgba(0,0,0,.05)}
  3259. .fm-login-page .card-title{ margin-bottom:1.5rem;font-size:24px;font-weight:400;}
  3260. .fm-login-page .form-control{ border-width:2.3px}
  3261. .fm-login-page .form-group label{ width:100%}
  3262. .fm-login-page .btn.btn-block{ padding:12px 10px}
  3263. .fm-login-page .footer{ margin:40px 0;color:#888;text-align:center}
  3264. @media screen and (max-width:425px){
  3265. .fm-login-page .card-wrapper{ width:90%;margin:0 auto;margin-top:10%;}
  3266. }
  3267. @media screen and (max-width:320px){
  3268. .fm-login-page .card.fat{ padding:0}
  3269. .fm-login-page .card.fat .card-body{ padding:15px}
  3270. }
  3271. .message{ padding:4px 7px;border:1px solid #ddd;background-color:#fff}
  3272. .message.ok{ border-color:green;color:green}
  3273. .message.error{ border-color:red;color:red}
  3274. .message.alert{ border-color:orange;color:orange}
  3275. body.fm-login-page.theme-dark {background-color: #2f2a2a;}
  3276. .theme-dark svg g, .theme-dark svg path {fill: #ffffff; }
  3277. </style>
  3278. </head>
  3279. <body class="fm-login-page <?php echo (FM_THEME == "dark") ? 'theme-dark' : ''; ?>">
  3280. <!-- loading start -->
  3281. <style>
  3282. #loadingMask{
  3283. position: fixed;
  3284. top: 0;
  3285. bottom: 0;
  3286. left: 0;
  3287. right: 0;
  3288. z-index: 1000000;
  3289. background: white;
  3290. opacity: 0.5;
  3291. display: none;
  3292. }
  3293. /* Spinner Circle Rotation */
  3294. .sp {
  3295. width: 32px;
  3296. height: 32px;
  3297. clear: both;
  3298. margin: 20px auto;
  3299. }
  3300. .sp-circle {
  3301. border: 4px rgba(0, 0, 0, 0.25) solid;
  3302. border-top: 4px black solid;
  3303. border-radius: 50%;
  3304. -webkit-animation: spCircRot .6s infinite linear;
  3305. animation: spCircRot .6s infinite linear;
  3306. }
  3307. @-webkit-keyframes spCircRot {
  3308. from {
  3309. -webkit-transform: rotate(0deg);
  3310. }
  3311. to {
  3312. -webkit-transform: rotate(359deg);
  3313. }
  3314. }
  3315. @keyframes spCircRot {
  3316. from {
  3317. transform: rotate(0deg);
  3318. }
  3319. to {
  3320. transform: rotate(359deg);
  3321. }
  3322. }
  3323. /* Spinner 3Balls Scale */
  3324. .sp-3balls, .sp-3balls:before, .sp-3balls:after {
  3325. border-radius: 50%;
  3326. background-color: #000;
  3327. width: 18px;
  3328. height: 18px;
  3329. transform-origin: center center;
  3330. display: inline-block;
  3331. }
  3332. .sp-3balls {
  3333. position: relative;
  3334. background-color: black;
  3335. opacity: 1;
  3336. -webkit-animation: spScaleAlpha 1s infinite linear;
  3337. animation: spScaleAlpha 1s infinite linear;
  3338. }
  3339. .sp-3balls:before, .sp-3balls:after {
  3340. content: '';
  3341. position: relative;
  3342. opacity: 0.25;
  3343. }
  3344. .sp-3balls:before {
  3345. left: 30px;
  3346. top: 0px;
  3347. -webkit-animation: spScaleAlphaBefore 1s infinite linear;
  3348. animation: spScaleAlphaBefore 1s infinite linear;
  3349. }
  3350. .sp-3balls:after {
  3351. left: -30px;
  3352. top: -23px;
  3353. -webkit-animation: spScaleAlphaAfter 1s infinite linear;
  3354. animation: spScaleAlphaAfter 1s infinite linear;
  3355. }
  3356. @-webkit-keyframes spScaleAlpha {
  3357. 0% {
  3358. opacity: 1;
  3359. }
  3360. 33% {
  3361. opacity: 0.25;
  3362. }
  3363. 66% {
  3364. opacity: 0.25;
  3365. }
  3366. 100% {
  3367. opacity: 1;
  3368. }
  3369. }
  3370. @keyframes spScaleAlpha {
  3371. 0% {
  3372. opacity: 1;
  3373. }
  3374. 33% {
  3375. opacity: 0.25;
  3376. }
  3377. 66% {
  3378. opacity: 0.25;
  3379. }
  3380. 100% {
  3381. opacity: 1;
  3382. }
  3383. }
  3384. @-webkit-keyframes spScaleAlphaBefore {
  3385. 0% {
  3386. opacity: 0.25;
  3387. }
  3388. 33% {
  3389. opacity: 1;
  3390. }
  3391. 66% {
  3392. opacity: 0.25;
  3393. }
  3394. }
  3395. @keyframes spScaleAlphaBefore {
  3396. 0% {
  3397. opacity: 0.25;
  3398. }
  3399. 33% {
  3400. opacity: 1;
  3401. }
  3402. 66% {
  3403. opacity: 0.25;
  3404. }
  3405. }
  3406. @-webkit-keyframes spScaleAlphaAfter {
  3407. 33% {
  3408. opacity: 0.25;
  3409. }
  3410. 66% {
  3411. opacity: 1;
  3412. }
  3413. 100% {
  3414. opacity: 0.25;
  3415. }
  3416. }
  3417. @keyframes spScaleAlphaAfter {
  3418. 33% {
  3419. opacity: 0.25;
  3420. }
  3421. 66% {
  3422. opacity: 1;
  3423. }
  3424. 100% {
  3425. opacity: 0.25;
  3426. }
  3427. }
  3428. </style>
  3429. <div id="loadingMask" style="z-index: 999999999">
  3430. <div class="row" style="height: 100%;display: flex;align-items: center;">
  3431. <div class="" style="width: 50%;margin-left: 25%;text-align: center;">
  3432. <div class="sp sp-3balls"></div>
  3433. </div>
  3434. </div>
  3435. </div>
  3436. <!-- loading end -->
  3437. <div id="wrapper" class="container-fluid">
  3438. <?php
  3439. }
  3440. /**
  3441. * Show page footer in Login Form
  3442. */
  3443. function fm_show_footer_login()
  3444. {
  3445. ?>
  3446. </div>
  3447. <script src="/public/filemanager/js/jquery.slim.min.js"></script>
  3448. <script src="/public/filemanager/js/bootstrap.min.js"></script>
  3449. </body>
  3450. </html>
  3451. <?php
  3452. }
  3453. /**
  3454. * Show Header after login
  3455. */
  3456. function fm_show_header()
  3457. {
  3458. $sprites_ver = '20160315';
  3459. header("Content-Type: text/html; charset=utf-8");
  3460. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
  3461. header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
  3462. header("Pragma: no-cache");
  3463. global $lang, $root_url, $sticky_navbar, $favicon_path;
  3464. $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal';
  3465. ?>
  3466. <!DOCTYPE html>
  3467. <html>
  3468. <head>
  3469. <meta charset="utf-8">
  3470. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  3471. <meta name="description" content="Web based File Manager in PHP, Manage your files efficiently and easily with Tiny File Manager">
  3472. <meta name="author" content="CCP Programmers">
  3473. <meta name="robots" content="noindex, nofollow">
  3474. <meta name="googlebot" content="noindex">
  3475. <link rel="icon" href="<?php echo fm_enc($favicon_path) ?>" type="image/png">
  3476. <title><?php echo fm_enc(APP_TITLE) ?></title>
  3477. <link rel="stylesheet" href="/public/filemanager/js/bootstrap.min.css">
  3478. <link rel="stylesheet" href="/public/filemanager/js/font-awesome.min.css">
  3479. <link rel="stylesheet" href="/public/filemanager/js/ekko-lightbox.css" />
  3480. <?php if (FM_USE_HIGHLIGHTJS): ?>
  3481. <link rel="stylesheet" href="/public/filemanager/js/<?php echo FM_HIGHLIGHTJS_STYLE ?>.min.css">
  3482. <?php endif; ?>
  3483. <style>
  3484. body { font-size:14px;color:#222;background:#F7F7F7; }
  3485. body.navbar-fixed { margin-top:55px; }
  3486. a:hover, a:visited, a:focus { text-decoration:none !important; }
  3487. * { -webkit-border-radius:0 !important;-moz-border-radius:0 !important;border-radius:0 !important; }
  3488. .filename, td, th { white-space:nowrap }
  3489. .navbar-brand { font-weight:bold; }
  3490. .nav-item.avatar a { cursor:pointer;text-transform:capitalize; }
  3491. .nav-item.avatar a > i { font-size:15px; }
  3492. .nav-item.avatar .dropdown-menu a { font-size:13px; }
  3493. #search-addon { font-size:12px;border-right-width:0; }
  3494. #search-addon2 { background:transparent;border-left:0; }
  3495. .bread-crumb { color:#cccccc;font-style:normal; }
  3496. #main-table .filename a { color:#222222; }
  3497. .table td, .table th { vertical-align:middle !important; }
  3498. .table .custom-checkbox-td .custom-control.custom-checkbox, .table .custom-checkbox-header .custom-control.custom-checkbox { min-width:18px; }
  3499. .table-sm td, .table-sm th { padding:.4rem; }
  3500. .table-bordered td, .table-bordered th { border:1px solid #f1f1f1; }
  3501. .hidden { display:none }
  3502. pre.with-hljs { padding:0 }
  3503. pre.with-hljs code { margin:0;border:0;overflow:visible }
  3504. code.maxheight, pre.maxheight { max-height:512px }
  3505. .fa.fa-caret-right { font-size:1.2em;margin:0 4px;vertical-align:middle;color:#ececec }
  3506. .fa.fa-home { font-size:1.3em;vertical-align:bottom }
  3507. .path { margin-bottom:10px }
  3508. form.dropzone { min-height:200px;border:2px dashed #007bff;line-height:6rem; }
  3509. .right { text-align:right }
  3510. .center, .close, .login-form { text-align:center }
  3511. .message { padding:4px 7px;border:1px solid #ddd;background-color:#fff }
  3512. .message.ok { border-color:green;color:green }
  3513. .message.error { border-color:red;color:red }
  3514. .message.alert { border-color:orange;color:orange }
  3515. .preview-img { max-width:100%;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAKklEQVR42mL5//8/Azbw+PFjrOJMDCSCUQ3EABZc4S0rKzsaSvTTABBgAMyfCMsY4B9iAAAAAElFTkSuQmCC) }
  3516. .inline-actions > a > i { font-size:1em;margin-left:5px;background:#3785c1;color:#fff;padding:3px;border-radius:3px }
  3517. .preview-video { position:relative;max-width:100%;height:0;padding-bottom:62.5%;margin-bottom:10px }
  3518. .preview-video video { position:absolute;width:100%;height:100%;left:0;top:0;background:#000 }
  3519. .compact-table { border:0;width:auto }
  3520. .compact-table td, .compact-table th { width:100px;border:0;text-align:center }
  3521. .compact-table tr:hover td { background-color:#fff }
  3522. .filename { max-width:420px;overflow:hidden;text-overflow:ellipsis }
  3523. .break-word { word-wrap:break-word;margin-left:30px }
  3524. .break-word.float-left a { color:#7d7d7d }
  3525. .break-word + .float-right { padding-right:30px;position:relative }
  3526. .break-word + .float-right > a { color:#7d7d7d;font-size:1.2em;margin-right:4px }
  3527. #editor { position:absolute;right:15px;top:100px;bottom:15px;left:15px }
  3528. @media (max-width:481px) {
  3529. #editor { top:150px; }
  3530. }
  3531. #normal-editor { border-radius:3px;border-width:2px;padding:10px;outline:none; }
  3532. .btn-2 { border-radius:0;padding:3px 6px;font-size:small; }
  3533. li.file:before,li.folder:before { font:normal normal normal 14px/1 FontAwesome;content:"\f016";margin-right:5px }
  3534. li.folder:before { content:"\f114" }
  3535. i.fa.fa-folder-o { color:#0157b3 }
  3536. i.fa.fa-picture-o { color:#26b99a }
  3537. i.fa.fa-file-archive-o { color:#da7d7d }
  3538. .btn-2 i.fa.fa-file-archive-o { color:inherit }
  3539. i.fa.fa-css3 { color:#f36fa0 }
  3540. i.fa.fa-file-code-o { color:#007bff }
  3541. i.fa.fa-code { color:#cc4b4c }
  3542. i.fa.fa-file-text-o { color:#0096e6 }
  3543. i.fa.fa-html5 { color:#d75e72 }
  3544. i.fa.fa-file-excel-o { color:#09c55d }
  3545. i.fa.fa-file-powerpoint-o { color:#f6712e }
  3546. i.go-back { font-size:1.2em;color:#007bff; }
  3547. .main-nav { padding:0.2rem 1rem;box-shadow:0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12), 0 2px 4px -1px rgba(0, 0, 0, .2) }
  3548. .dataTables_filter { display:none; }
  3549. table.dataTable thead .sorting { cursor:pointer;background-repeat:no-repeat;background-position:center right;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7XQMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC'); }
  3550. table.dataTable thead .sorting_asc { cursor:pointer;background-repeat:no-repeat;background-position:center right;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg=='); }
  3551. table.dataTable thead .sorting_desc { cursor:pointer;background-repeat:no-repeat;background-position:center right;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII='); }
  3552. table.dataTable thead tr:first-child th.custom-checkbox-header:first-child { background-image:none; }
  3553. .footer-action li { margin-bottom:10px; }
  3554. .app-v-title { font-size:24px;font-weight:300;letter-spacing:-.5px;text-transform:uppercase; }
  3555. hr.custom-hr { border-top:1px dashed #8c8b8b;border-bottom:1px dashed #fff; }
  3556. .ekko-lightbox .modal-dialog { max-width:98%; }
  3557. .ekko-lightbox-item.fade.in.show .row { background:#fff; }
  3558. .ekko-lightbox-nav-overlay { display:flex !important;opacity:1 !important;height:auto !important;top:50%; }
  3559. .ekko-lightbox-nav-overlay a { opacity:1 !important;width:auto !important;text-shadow:none !important;color:#3B3B3B; }
  3560. .ekko-lightbox-nav-overlay a:hover { color:#20507D; }
  3561. #snackbar { visibility:hidden;min-width:250px;margin-left:-125px;background-color:#333;color:#fff;text-align:center;border-radius:2px;padding:16px;position:fixed;z-index:1;left:50%;bottom:30px;font-size:17px; }
  3562. #snackbar.show { visibility:visible;-webkit-animation:fadein 0.5s, fadeout 0.5s 2.5s;animation:fadein 0.5s, fadeout 0.5s 2.5s; }
  3563. @-webkit-keyframes fadein { from { bottom:0;opacity:0; }
  3564. to { bottom:30px;opacity:1; }
  3565. }
  3566. @keyframes fadein { from { bottom:0;opacity:0; }
  3567. to { bottom:30px;opacity:1; }
  3568. }
  3569. @-webkit-keyframes fadeout { from { bottom:30px;opacity:1; }
  3570. to { bottom:0;opacity:0; }
  3571. }
  3572. @keyframes fadeout { from { bottom:30px;opacity:1; }
  3573. to { bottom:0;opacity:0; }
  3574. }
  3575. #main-table span.badge { border-bottom:2px solid #f8f9fa }
  3576. #main-table span.badge:nth-child(1) { border-color:#df4227 }
  3577. #main-table span.badge:nth-child(2) { border-color:#f8b600 }
  3578. #main-table span.badge:nth-child(3) { border-color:#00bd60 }
  3579. #main-table span.badge:nth-child(4) { border-color:#4581ff }
  3580. #main-table span.badge:nth-child(5) { border-color:#ac68fc }
  3581. #main-table span.badge:nth-child(6) { border-color:#45c3d2 }
  3582. @media only screen and (min-device-width:768px) and (max-device-width:1024px) and (orientation:landscape) and (-webkit-min-device-pixel-ratio:2) { .navbar-collapse .col-xs-6.text-right { padding:0; }
  3583. }
  3584. .btn.active.focus,.btn.active:focus,.btn.focus,.btn.focus:active,.btn:active:focus,.btn:focus { outline:0!important;outline-offset:0!important;background-image:none!important;-webkit-box-shadow:none!important;box-shadow:none!important }
  3585. .lds-facebook { display:none;position:relative;width:64px;height:64px }
  3586. .lds-facebook div,.lds-facebook.show-me { display:inline-block }
  3587. .lds-facebook div { position:absolute;left:6px;width:13px;background:#007bff;animation:lds-facebook 1.2s cubic-bezier(0,.5,.5,1) infinite }
  3588. .lds-facebook div:nth-child(1) { left:6px;animation-delay:-.24s }
  3589. .lds-facebook div:nth-child(2) { left:26px;animation-delay:-.12s }
  3590. .lds-facebook div:nth-child(3) { left:45px;animation-delay:0 }
  3591. @keyframes lds-facebook { 0% { top:6px;height:51px }
  3592. 100%,50% { top:19px;height:26px }
  3593. }
  3594. ul#search-wrapper { padding-left: 0;border: 1px solid #ecececcc; } ul#search-wrapper li { list-style: none; padding: 5px;border-bottom: 1px solid #ecececcc; }
  3595. ul#search-wrapper li:nth-child(odd){ background: #f9f9f9cc;}
  3596. .c-preview-img {
  3597. max-width: 300px;
  3598. }
  3599. .navbar-light .navbar-nav .nav-link {
  3600. color: #007bff;
  3601. }
  3602. </style>
  3603. <?php
  3604. if (FM_THEME == "dark"): ?>
  3605. <style>
  3606. body.theme-dark { background-color: #2f2a2a; }
  3607. .list-group .list-group-item { background: #343a40; }
  3608. .theme-dark .navbar-nav i, .navbar-nav .dropdown-toggle, .break-word { color: #ffffff; }
  3609. a, a:hover, a:visited, a:active, #main-table .filename a { color: #00ff1f; }
  3610. ul#search-wrapper li:nth-child(odd) { background: #f9f9f9cc; }
  3611. .theme-dark .btn-outline-primary { color: #00ff1f; border-color: #00ff1f; }
  3612. .theme-dark .btn-outline-primary:hover, .theme-dark .btn-outline-primary:active { background-color: #028211;}
  3613. </style>
  3614. <?php endif; ?>
  3615. </head>
  3616. <body class="<?php echo (FM_THEME == "dark") ? 'theme-dark' : ''; ?> <?php echo $isStickyNavBar; ?>">
  3617. <!-- loading start -->
  3618. <style>
  3619. #loadingMask{
  3620. position: fixed;
  3621. top: 0;
  3622. bottom: 0;
  3623. left: 0;
  3624. right: 0;
  3625. z-index: 1000000;
  3626. background: white;
  3627. opacity: 0.5;
  3628. display: none;
  3629. }
  3630. /* Spinner Circle Rotation */
  3631. .sp {
  3632. width: 32px;
  3633. height: 32px;
  3634. clear: both;
  3635. margin: 20px auto;
  3636. }
  3637. .sp-circle {
  3638. border: 4px rgba(0, 0, 0, 0.25) solid;
  3639. border-top: 4px black solid;
  3640. border-radius: 50%;
  3641. -webkit-animation: spCircRot .6s infinite linear;
  3642. animation: spCircRot .6s infinite linear;
  3643. }
  3644. @-webkit-keyframes spCircRot {
  3645. from {
  3646. -webkit-transform: rotate(0deg);
  3647. }
  3648. to {
  3649. -webkit-transform: rotate(359deg);
  3650. }
  3651. }
  3652. @keyframes spCircRot {
  3653. from {
  3654. transform: rotate(0deg);
  3655. }
  3656. to {
  3657. transform: rotate(359deg);
  3658. }
  3659. }
  3660. /* Spinner 3Balls Scale */
  3661. .sp-3balls, .sp-3balls:before, .sp-3balls:after {
  3662. border-radius: 50%!important;
  3663. background-color: #000;
  3664. width: 18px;
  3665. height: 18px;
  3666. transform-origin: center center;
  3667. display: inline-block;
  3668. }
  3669. .sp-3balls {
  3670. position: relative;
  3671. background-color: black;
  3672. opacity: 1;
  3673. -webkit-animation: spScaleAlpha 1s infinite linear;
  3674. animation: spScaleAlpha 1s infinite linear;
  3675. }
  3676. .sp-3balls:before, .sp-3balls:after {
  3677. content: '';
  3678. position: relative;
  3679. opacity: 0.25;
  3680. }
  3681. .sp-3balls:before {
  3682. left: 30px;
  3683. top: 0px;
  3684. -webkit-animation: spScaleAlphaBefore 1s infinite linear;
  3685. animation: spScaleAlphaBefore 1s infinite linear;
  3686. }
  3687. .sp-3balls:after {
  3688. left: -30px;
  3689. top: -23px;
  3690. -webkit-animation: spScaleAlphaAfter 1s infinite linear;
  3691. animation: spScaleAlphaAfter 1s infinite linear;
  3692. }
  3693. @-webkit-keyframes spScaleAlpha {
  3694. 0% {
  3695. opacity: 1;
  3696. }
  3697. 33% {
  3698. opacity: 0.25;
  3699. }
  3700. 66% {
  3701. opacity: 0.25;
  3702. }
  3703. 100% {
  3704. opacity: 1;
  3705. }
  3706. }
  3707. @keyframes spScaleAlpha {
  3708. 0% {
  3709. opacity: 1;
  3710. }
  3711. 33% {
  3712. opacity: 0.25;
  3713. }
  3714. 66% {
  3715. opacity: 0.25;
  3716. }
  3717. 100% {
  3718. opacity: 1;
  3719. }
  3720. }
  3721. @-webkit-keyframes spScaleAlphaBefore {
  3722. 0% {
  3723. opacity: 0.25;
  3724. }
  3725. 33% {
  3726. opacity: 1;
  3727. }
  3728. 66% {
  3729. opacity: 0.25;
  3730. }
  3731. }
  3732. @keyframes spScaleAlphaBefore {
  3733. 0% {
  3734. opacity: 0.25;
  3735. }
  3736. 33% {
  3737. opacity: 1;
  3738. }
  3739. 66% {
  3740. opacity: 0.25;
  3741. }
  3742. }
  3743. @-webkit-keyframes spScaleAlphaAfter {
  3744. 33% {
  3745. opacity: 0.25;
  3746. }
  3747. 66% {
  3748. opacity: 1;
  3749. }
  3750. 100% {
  3751. opacity: 0.25;
  3752. }
  3753. }
  3754. @keyframes spScaleAlphaAfter {
  3755. 33% {
  3756. opacity: 0.25;
  3757. }
  3758. 66% {
  3759. opacity: 1;
  3760. }
  3761. 100% {
  3762. opacity: 0.25;
  3763. }
  3764. }
  3765. </style>
  3766. <div id="loadingMask" style="z-index: 999999999">
  3767. <div class="row" style="height: 100%;display: flex;align-items: center;">
  3768. <div class="" style="width: 50%;margin-left: 25%;text-align: center;">
  3769. <div class="sp sp-3balls"></div>
  3770. </div>
  3771. </div>
  3772. </div>
  3773. <!-- loading end -->
  3774. <div id="wrapper" class="container-fluid">
  3775. <!-- New Item creation -->
  3776. <div class="modal fade" id="createNewItem" tabindex="-1" role="dialog" aria-label="newItemModalLabel" aria-hidden="true">
  3777. <div class="modal-dialog" role="document">
  3778. <div class="modal-content <?php echo fm_get_theme(); ?>">
  3779. <div class="modal-header">
  3780. <h5 class="modal-title" id="newItemModalLabel"><i class="fa fa-plus-square fa-fw"></i><?php echo lng('CreateNewItem') ?></h5>
  3781. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  3782. <span aria-hidden="true">&times;</span>
  3783. </button>
  3784. </div>
  3785. <div class="modal-body">
  3786. <p><label for="newfile"><?php echo lng('ItemType') ?> </label></p>
  3787. <div class="custom-control custom-radio custom-control-inline">
  3788. <input type="radio" id="customRadioInline1" name="newfile" value="file" class="custom-control-input">
  3789. <label class="custom-control-label" for="customRadioInline1"><?php echo lng('File') ?></label>
  3790. </div>
  3791. <div class="custom-control custom-radio custom-control-inline">
  3792. <input type="radio" id="customRadioInline2" name="newfile" value="folder" class="custom-control-input" checked="">
  3793. <label class="custom-control-label" for="customRadioInline2"><?php echo lng('Folder') ?></label>
  3794. </div>
  3795. <p class="mt-3"><label for="newfilename"><?php echo lng('ItemName') ?> </label></p>
  3796. <input type="text" name="newfilename" id="newfilename" value="" class="form-control">
  3797. </div>
  3798. <div class="modal-footer">
  3799. <button type="button" class="btn btn-outline-primary" data-dismiss="modal"><i class="fa fa-times-circle"></i> <?php echo lng('Cancel') ?></button>
  3800. <button type="button" class="btn btn-success" onclick="newfolder('<?php echo fm_enc(FM_PATH) ?>');return false;"><i class="fa fa-check-circle"></i> <?php echo lng('CreateNow') ?></button>
  3801. </div>
  3802. </div>
  3803. </div>
  3804. </div>
  3805. <!-- Modal -->
  3806. <div class="modal fade" id="searchModal" tabindex="-1" role="dialog" aria-labelledby="searchModalLabel" aria-hidden="true">
  3807. <div class="modal-dialog modal-lg" role="document">
  3808. <div class="modal-content <?php echo fm_get_theme(); ?>">
  3809. <div class="modal-header">
  3810. <h5 class="modal-title col-10" id="searchModalLabel">
  3811. <div class="input-group input-group">
  3812. <input type="text" class="form-control" placeholder="<?php echo lng('Search') ?> a files" aria-label="<?php echo lng('Search') ?>" aria-describedby="search-addon3" id="advanced-search" autofocus required>
  3813. <div class="input-group-append">
  3814. <span class="input-group-text" id="search-addon3"><i class="fa fa-search"></i></span>
  3815. </div>
  3816. </div>
  3817. </h5>
  3818. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  3819. <span aria-hidden="true">&times;</span>
  3820. </button>
  3821. </div>
  3822. <div class="modal-body">
  3823. <form action="" method="post">
  3824. <div class="lds-facebook"><div></div><div></div><div></div></div>
  3825. <ul id="search-wrapper">
  3826. <p class="m-2">Search file in folder and subfolders...</p>
  3827. </ul>
  3828. </form>
  3829. </div>
  3830. </div>
  3831. </div>
  3832. </div>
  3833. <script type="text/html" id="js-tpl-modal">
  3834. <div class="modal fade" id="js-ModalCenter-<%this.id%>" tabindex="-1" role="dialog" aria-labelledby="ModalCenterTitle" aria-hidden="true">
  3835. <div class="modal-dialog modal-dialog-centered" role="document">
  3836. <div class="modal-content">
  3837. <div class="modal-header">
  3838. <h5 class="modal-title" id="ModalCenterTitle"><%this.title%></h5>
  3839. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  3840. <span aria-hidden="true">&times;</span>
  3841. </button>
  3842. </div>
  3843. <div class="modal-body">
  3844. <%this.content%>
  3845. </div>
  3846. <div class="modal-footer">
  3847. <button type="button" class="btn btn-outline-primary" data-dismiss="modal"><i class="fa fa-times-circle"></i> <?php echo lng('Cancel') ?></button>
  3848. <%if(this.action){%><button type="button" class="btn btn-primary" id="js-ModalCenterAction" data-type="js-<%this.action%>"><%this.action%></button><%}%>
  3849. </div>
  3850. </div>
  3851. </div>
  3852. </div>
  3853. </script>
  3854. <?php
  3855. }
  3856. /**
  3857. * Show page footer
  3858. */
  3859. function fm_show_footer()
  3860. {
  3861. ?>
  3862. </div>
  3863. <script src="/public/filemanager/js/jquery.min.js"></script>
  3864. <script src="/public/filemanager/js/bootstrap.min.js"></script>
  3865. <script src="/public/filemanager/js/jquery.dataTables.min.js"></script>
  3866. <script src="/public/filemanager/js/ekko-lightbox.min.js"></script>
  3867. <?php if (FM_USE_HIGHLIGHTJS): ?>
  3868. <script src="/public/filemanager/js/highlight.min.js"></script>
  3869. <script>hljs.initHighlightingOnLoad(); var isHighlightingEnabled = true;</script>
  3870. <?php endif; ?>
  3871. <script>
  3872. $(document).on('click', '[data-toggle="lightbox"]', function(event) {
  3873. event.preventDefault();
  3874. var reInitHighlight = function() { if(typeof isHighlightingEnabled !== "undefined" && isHighlightingEnabled) { setTimeout(function () { $('.ekko-lightbox-container pre code').each(function (i, e) { hljs.highlightBlock(e) }); }, 555); } };
  3875. $(this).ekkoLightbox({
  3876. alwaysShowClose: true, showArrows: true, onShown: function() { reInitHighlight(); }, onNavigate: function(direction, itemIndex) { reInitHighlight(); }
  3877. });
  3878. });
  3879. //TFM Config
  3880. window.curi = "/public/filemanager/js/config.json", window.config = null;
  3881. function fm_get_config(){ if(!!window.name){ window.config = JSON.parse(window.name); } else { $.getJSON(window.curi).done(function(c) { if(!!c) { window.name = JSON.stringify(c), window.config = c; } }); }}
  3882. function template(html,options){
  3883. var re=/<\%([^\%>]+)?\%>/g,reExp=/(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g,code='var r=[];\n',cursor=0,match;var add=function(line,js){js?(code+=line.match(reExp)?line+'\n':'r.push('+line+');\n'):(code+=line!=''?'r.push("'+line.replace(/"/g,'\\"')+'");\n':'');return add}
  3884. while(match=re.exec(html)){add(html.slice(cursor,match.index))(match[1],!0);cursor=match.index+match[0].length}
  3885. add(html.substr(cursor,html.length-cursor));code+='return r.join("");';return new Function(code.replace(/[\r\t\n]/g,'')).apply(options)
  3886. }
  3887. function newfolder(e) {
  3888. var t = document.getElementById("newfilename").value, n = document.querySelector('input[name="newfile"]:checked').value;
  3889. null !== t && "" !== t && n && (window.location.hash = "#", window.location.search = "fm_usr=<?php echo $_GET['fm_usr'];?>&p=" + encodeURIComponent(e) + "&new=" + encodeURIComponent(t) + "&type=" + encodeURIComponent(n))
  3890. }
  3891. function rename(e, t) {var n = prompt("New name", t);null !== n && "" !== n && n != t && (window.location.search = "fm_usr=<?php echo $_GET['fm_usr'];?>&p=" + encodeURIComponent(e) + "&ren=" + encodeURIComponent(t) + "&to=" + encodeURIComponent(n))}
  3892. function change_checkboxes(e, t) { for (var n = e.length - 1; n >= 0; n--) e[n].checked = "boolean" == typeof t ? t : !e[n].checked }
  3893. function get_checkboxes() { for (var e = document.getElementsByName("file[]"), t = [], n = e.length - 1; n >= 0; n--) (e[n].type = "checkbox") && t.push(e[n]); return t }
  3894. function select_all() { change_checkboxes(get_checkboxes(), !0) }
  3895. function unselect_all() { change_checkboxes(get_checkboxes(), !1) }
  3896. function invert_all() { change_checkboxes(get_checkboxes()) }
  3897. function checkbox_toggle() { var e = get_checkboxes(); e.push(this), change_checkboxes(e) }
  3898. function backup(e, t) { //Create file backup with .bck
  3899. var n = new XMLHttpRequest,
  3900. a = "path=" + e + "&file=" + t + "&type=backup&ajax=true";
  3901. return n.open("POST", "", !0), n.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), n.onreadystatechange = function () {
  3902. 4 == n.readyState && 200 == n.status && toast(n.responseText)
  3903. }, n.send(a), !1
  3904. }
  3905. // Toast message
  3906. function toast(txt) { var x = document.getElementById("snackbar");x.innerHTML=txt;x.className = "show";setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000); }
  3907. //Save file
  3908. function edit_save(e, t) {
  3909. var n = "ace" == t ? editor.getSession().getValue() : document.getElementById("normal-editor").value;
  3910. if (n) {
  3911. if(true){
  3912. var data = {ajax: true, content: n, type: 'save'};
  3913. $.ajax({
  3914. type: "POST",
  3915. url: window.location,
  3916. // The key needs to match your method's input parameter (case-sensitive).
  3917. data: JSON.stringify(data),
  3918. contentType: "multipart/form-data-encoded; charset=utf-8",
  3919. //dataType: "json",
  3920. success: function(mes){toast("Saved Successfully"); window.onbeforeunload = function() {return}},
  3921. failure: function(mes) {toast("Error: try again");},
  3922. error: function(mes) {toast(`<p style="background-color:red">${mes.responseText}</p>`);}
  3923. });
  3924. }
  3925. else{
  3926. var a = document.createElement("form");
  3927. a.setAttribute("method", "POST"), a.setAttribute("action", "");
  3928. var o = document.createElement("textarea");
  3929. o.setAttribute("type", "textarea"), o.setAttribute("name", "savedata");
  3930. var c = document.createTextNode(n);
  3931. o.appendChild(c), a.appendChild(o), document.body.appendChild(a), a.submit()
  3932. }
  3933. }
  3934. }
  3935. //Check latest version
  3936. function latest_release_info(v) {
  3937. if(!!window.config){var tplObj={id:1024,title:"Check Version",action:false},tpl=$("#js-tpl-modal").html();
  3938. if(window.config.version!=v){tplObj.content=window.config.newUpdate;}else{tplObj.content=window.config.noUpdate;}
  3939. $('#wrapper').append(template(tpl,tplObj));$("#js-ModalCenter-1024").modal('show');}else{fm_get_config();}
  3940. }
  3941. function show_new_pwd() { $(".js-new-pwd").toggleClass('hidden'); }
  3942. //Save Settings
  3943. function save_settings($this) {
  3944. let form = $($this);
  3945. $.ajax({
  3946. type: form.attr('method'), url: form.attr('action'), data: form.serialize()+"&ajax="+true,
  3947. success: function (data) {if(data) { window.location.reload();}}
  3948. }); return false;
  3949. }
  3950. //Create new password hash
  3951. function new_password_hash($this) {
  3952. let form = $($this), $pwd = $("#js-pwd-result"); $pwd.val('');
  3953. $.ajax({
  3954. type: form.attr('method'), url: form.attr('action'), data: form.serialize()+"&ajax="+true,
  3955. success: function (data) { if(data) { $pwd.val(data); } }
  3956. }); return false;
  3957. }
  3958. //Upload files using URL @param {Object}
  3959. function upload_from_url($this) {
  3960. let form = $($this), resultWrapper = $("div#js-url-upload__list");
  3961. $.ajax({
  3962. type: form.attr('method'), url: form.attr('action'), data: form.serialize()+"&ajax="+true,
  3963. beforeSend: function() { form.find("input[name=uploadurl]").attr("disabled","disabled"); form.find("button").hide(); form.find(".lds-facebook").addClass('show-me'); },
  3964. success: function (data) {
  3965. if(data) {
  3966. data = JSON.parse(data);
  3967. if(data.done) {
  3968. resultWrapper.append('<div class="alert alert-success row">Uploaded Successful: '+data.done.name+'</div>'); form.find("input[name=uploadurl]").val('');
  3969. } else if(data['fail']) { resultWrapper.append('<div class="alert alert-danger row">Error: '+data.fail.message+'</div>'); }
  3970. form.find("input[name=uploadurl]").removeAttr("disabled");form.find("button").show();form.find(".lds-facebook").removeClass('show-me');
  3971. }
  3972. },
  3973. error: function(xhr) {
  3974. form.find("input[name=uploadurl]").removeAttr("disabled");form.find("button").show();form.find(".lds-facebook").removeClass('show-me');console.error(xhr);
  3975. }
  3976. }); return false;
  3977. }
  3978. //Search template
  3979. function search_template(data) {
  3980. var response = "";
  3981. $.each(data, function (key, val) {
  3982. response += `<li><a href="?fm_usr=<?php echo $_GET['fm_usr']?>&p=${val.path}&view=${val.name}">${val.path}/${val.name}</a></li>`;
  3983. });
  3984. return response;
  3985. }
  3986. //search
  3987. function fm_search() {
  3988. var searchTxt = $("input#advanced-search").val(), searchWrapper = $("ul#search-wrapper"), path = $("#js-search-modal").attr("href"), _html = "", $loader = $("div.lds-facebook");
  3989. if(!!searchTxt && searchTxt.length > 2 && path) {
  3990. var data = {ajax: true, content: searchTxt, path:path, type: 'search'};
  3991. $.ajax({
  3992. type: "POST",
  3993. url: window.location,
  3994. data: data,
  3995. beforeSend: function() {
  3996. searchWrapper.html('');
  3997. $loader.addClass('show-me');
  3998. },
  3999. success: function(data){
  4000. $loader.removeClass('show-me');
  4001. data = JSON.parse(data);
  4002. if(data && data.length) {
  4003. _html = search_template(data);
  4004. searchWrapper.html(_html);
  4005. } else { searchWrapper.html('<p class="m-2">No result found!<p>'); }
  4006. },
  4007. error: function(xhr) { $loader.removeClass('show-me'); searchWrapper.html('<p class="m-2">ERROR: Try again later!</p>'); },
  4008. failure: function(mes) { $loader.removeClass('show-me'); searchWrapper.html('<p class="m-2">ERROR: Try again later!</p>');}
  4009. });
  4010. } else { searchWrapper.html("OOPS: minimum 3 characters required!"); }
  4011. }
  4012. //on mouse hover image preview
  4013. !function(s){s.previewImage=function(e){var o=s(document),t=".previewImage",a=s.extend({xOffset:20,yOffset:-20,fadeIn:"fast",css:{padding:"5px",border:"1px solid #cccccc","background-color":"#fff"},eventSelector:"[data-preview-image]",dataKey:"previewImage",overlayId:"preview-image-plugin-overlay"},e);return o.off(t),o.on("mouseover"+t,a.eventSelector,function(e){s("p#"+a.overlayId).remove();var o=s("<p>").attr("id",a.overlayId).css("position","absolute").css("display","none").append(s('<img class="c-preview-img">').attr("src",s(this).data(a.dataKey)));a.css&&o.css(a.css),s("body").append(o),o.css("top",e.pageY+a.yOffset+"px").css("left",e.pageX+a.xOffset+"px").fadeIn(a.fadeIn)}),o.on("mouseout"+t,a.eventSelector,function(){s("#"+a.overlayId).remove()}),o.on("mousemove"+t,a.eventSelector,function(e){s("#"+a.overlayId).css("top",e.pageY+a.yOffset+"px").css("left",e.pageX+a.xOffset+"px")}),this},s.previewImage()}(jQuery);
  4014. // Dom Ready Event
  4015. $(document).ready( function () {
  4016. //load config
  4017. fm_get_config();
  4018. //dataTable init
  4019. var $table = $('#main-table'),
  4020. tableLng = $table.find('th').length,
  4021. _targets = (tableLng && tableLng == 7 ) ? [0, 4,5,6] : tableLng == 5 ? [0,4] : [3],
  4022. mainTable = $('#main-table').DataTable({"paging": false, "info": false, "columnDefs": [{"targets": _targets, "orderable": false}]
  4023. });
  4024. //search
  4025. $('#search-addon').on( 'keyup', function () {
  4026. mainTable.search( this.value ).draw();
  4027. });
  4028. $("input#advanced-search").on('keyup', function (e) {
  4029. if (e.keyCode === 13) { fm_search(); }
  4030. });
  4031. $('#search-addon3').on( 'click', function () { fm_search(); });
  4032. //upload nav tabs
  4033. $(".fm-upload-wrapper .card-header-tabs").on("click", 'a', function(e){
  4034. e.preventDefault();let target=$(this).data('target');
  4035. $(".fm-upload-wrapper .card-header-tabs a").removeClass('active');$(this).addClass('active');
  4036. $(".fm-upload-wrapper .card-tabs-container").addClass('hidden');$(target).removeClass('hidden');
  4037. });
  4038. });
  4039. $('.refreshCdn').click(function(){
  4040. var path = $(this).data('href');
  4041. if(confirm('确定刷新CDN目录:'+path)){
  4042. showLoading()
  4043. $.post('/config/refreshCDN',{path:path},function(res){
  4044. hideLoading()
  4045. if(typeof res =='string')res = JSON.parse(res);
  4046. alert(res.msg)
  4047. })
  4048. }
  4049. })
  4050. $('.asyncProd').click(function(){
  4051. var path = $(this).data('href');
  4052. if(confirm('确定同步目录或文件:'+path+' 到正式环境')){
  4053. showLoading()
  4054. $.post('/config/syncBundleDir',{path:path},function(res){
  4055. hideLoading()
  4056. if(typeof res =='string')res = JSON.parse(res);
  4057. alert(res.msg)
  4058. })
  4059. }
  4060. })
  4061. $('.refreshJsonConfig').click(function(){
  4062. var path = $(this).data('href');
  4063. var type = $(this).data('type');
  4064. console.log(path)
  4065. if(confirm('确定刷新:'+path+' JSON配置')){
  4066. showLoading()
  4067. $.post('/config/refreshJsonConfig',{path:path,type:type},function(res){
  4068. hideLoading()
  4069. if(typeof res =='string')res = JSON.parse(res);
  4070. alert(res.msg)
  4071. })
  4072. }
  4073. })
  4074. </script>
  4075. <?php if (isset($_GET['edit']) && isset($_GET['env']) && FM_EDIT_FILE):
  4076. $ext = "javascript";
  4077. $ext = pathinfo($_GET["edit"], PATHINFO_EXTENSION);
  4078. ?>
  4079. <script src="/public/filemanager/js/ace.js"></script>
  4080. <script>
  4081. var editor = ace.edit("editor");
  4082. editor.getSession().setMode( {path:"ace/mode/<?php echo $ext; ?>", inline:true} );
  4083. //editor.setTheme("ace/theme/twilight"); //Dark Theme
  4084. function ace_commend (cmd) { editor.commands.exec(cmd, editor); }
  4085. editor.commands.addCommands([{
  4086. name: 'save', bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
  4087. exec: function(editor) { edit_save(this, 'ace'); }
  4088. }]);
  4089. function renderThemeMode() {
  4090. var $modeEl = $("select#js-ace-mode"), $themeEl = $("select#js-ace-theme"), $fontSizeEl = $("select#js-ace-fontSize"), optionNode = function(type, arr){ var $Option = ""; $.each(arr, function(i, val) { $Option += "<option value='"+type+i+"'>" + val + "</option>"; }); return $Option; },
  4091. _data = {"aceTheme":{"bright":{"chrome":"Chrome","clouds":"Clouds","crimson_editor":"Crimson Editor","dawn":"Dawn","dreamweaver":"Dreamweaver","eclipse":"Eclipse","github":"GitHub","iplastic":"IPlastic","solarized_light":"Solarized Light","textmate":"TextMate","tomorrow":"Tomorrow","xcode":"XCode","kuroir":"Kuroir","katzenmilch":"KatzenMilch","sqlserver":"SQL Server"},"dark":{"ambiance":"Ambiance","chaos":"Chaos","clouds_midnight":"Clouds Midnight","dracula":"Dracula","cobalt":"Cobalt","gruvbox":"Gruvbox","gob":"Green on Black","idle_fingers":"idle Fingers","kr_theme":"krTheme","merbivore":"Merbivore","merbivore_soft":"Merbivore Soft","mono_industrial":"Mono Industrial","monokai":"Monokai","pastel_on_dark":"Pastel on dark","solarized_dark":"Solarized Dark","terminal":"Terminal","tomorrow_night":"Tomorrow Night","tomorrow_night_blue":"Tomorrow Night Blue","tomorrow_night_bright":"Tomorrow Night Bright","tomorrow_night_eighties":"Tomorrow Night 80s","twilight":"Twilight","vibrant_ink":"Vibrant Ink"}},"aceMode":{"javascript":"JavaScript","abap":"ABAP","abc":"ABC","actionscript":"ActionScript","ada":"ADA","apache_conf":"Apache Conf","asciidoc":"AsciiDoc","asl":"ASL","assembly_x86":"Assembly x86","autohotkey":"AutoHotKey","apex":"Apex","batchfile":"BatchFile","bro":"Bro","c_cpp":"C and C++","c9search":"C9Search","cirru":"Cirru","clojure":"Clojure","cobol":"Cobol","coffee":"CoffeeScript","coldfusion":"ColdFusion","csharp":"C#","csound_document":"Csound Document","csound_orchestra":"Csound","csound_score":"Csound Score","css":"CSS","curly":"Curly","d":"D","dart":"Dart","diff":"Diff","dockerfile":"Dockerfile","dot":"Dot","drools":"Drools","edifact":"Edifact","eiffel":"Eiffel","ejs":"EJS","elixir":"Elixir","elm":"Elm","erlang":"Erlang","forth":"Forth","fortran":"Fortran","fsharp":"FSharp","fsl":"FSL","ftl":"FreeMarker","gcode":"Gcode","gherkin":"Gherkin","gitignore":"Gitignore","glsl":"Glsl","gobstones":"Gobstones","golang":"Go","graphqlschema":"GraphQLSchema","groovy":"Groovy","haml":"HAML","handlebars":"Handlebars","haskell":"Haskell","haskell_cabal":"Haskell Cabal","haxe":"haXe","hjson":"Hjson","html":"HTML","html_elixir":"HTML (Elixir)","html_ruby":"HTML (Ruby)","ini":"INI","io":"Io","jack":"Jack","jade":"Jade","java":"Java","json":"JSON","jsoniq":"JSONiq","jsp":"JSP","jssm":"JSSM","jsx":"JSX","julia":"Julia","kotlin":"Kotlin","latex":"LaTeX","less":"LESS","liquid":"Liquid","lisp":"Lisp","livescript":"LiveScript","logiql":"LogiQL","lsl":"LSL","lua":"Lua","luapage":"LuaPage","lucene":"Lucene","makefile":"Makefile","markdown":"Markdown","mask":"Mask","matlab":"MATLAB","maze":"Maze","mel":"MEL","mixal":"MIXAL","mushcode":"MUSHCode","mysql":"MySQL","nix":"Nix","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","pascal":"Pascal","perl":"Perl","perl6":"Perl 6","pgsql":"pgSQL","php_laravel_blade":"PHP (Blade Template)","php":"PHP","puppet":"Puppet","pig":"Pig","powershell":"Powershell","praat":"Praat","prolog":"Prolog","properties":"Properties","protobuf":"Protobuf","python":"Python","r":"R","razor":"Razor","rdoc":"RDoc","red":"Red","rhtml":"RHTML","rst":"RST","ruby":"Ruby","rust":"Rust","sass":"SASS","scad":"SCAD","scala":"Scala","scheme":"Scheme","scss":"SCSS","sh":"SH","sjs":"SJS","slim":"Slim","smarty":"Smarty","snippets":"snippets","soy_template":"Soy Template","space":"Space","sql":"SQL","sqlserver":"SQLServer","stylus":"Stylus","svg":"SVG","swift":"Swift","tcl":"Tcl","terraform":"Terraform","tex":"Tex","text":"Text","textile":"Textile","toml":"Toml","tsx":"TSX","twig":"Twig","typescript":"Typescript","vala":"Vala","vbscript":"VBScript","velocity":"Velocity","verilog":"Verilog","vhdl":"VHDL","visualforce":"Visualforce","wollok":"Wollok","xml":"XML","xquery":"XQuery","yaml":"YAML","django":"Django"},"fontSize":{8:8,10:10,11:11,12:12,13:13,14:14,15:15,16:16,17:17,18:18,20:20,22:22,24:24,26:26,30:30}};
  4092. if(_data && _data.aceMode) { $modeEl.html(optionNode("ace/mode/", _data.aceMode)); }
  4093. if(_data && _data.aceTheme) { var lightTheme = optionNode("ace/theme/", _data.aceTheme.bright), darkTheme = optionNode("ace/theme/", _data.aceTheme.dark); $themeEl.html("<optgroup label=\"Bright\">"+lightTheme+"</optgroup><optgroup label=\"Dark\">"+darkTheme+"</optgroup>");}
  4094. if(_data && _data.fontSize) { $fontSizeEl.html(optionNode("", _data.fontSize)); }
  4095. $modeEl.val( editor.getSession().$modeId );
  4096. $themeEl.val( editor.getTheme() );
  4097. $fontSizeEl.val(12).change(); //set default font size in drop down
  4098. }
  4099. $(function(){
  4100. renderThemeMode();
  4101. $(".js-ace-toolbar").on("click", 'button', function(e){
  4102. e.preventDefault();
  4103. let cmdValue = $(this).attr("data-cmd"), editorOption = $(this).attr("data-option");
  4104. if(cmdValue && cmdValue != "none") {
  4105. ace_commend(cmdValue);
  4106. } else if(editorOption) {
  4107. if(editorOption == "fullscreen") {
  4108. (void 0!==document.fullScreenElement&&null===document.fullScreenElement||void 0!==document.msFullscreenElement&&null===document.msFullscreenElement||void 0!==document.mozFullScreen&&!document.mozFullScreen||void 0!==document.webkitIsFullScreen&&!document.webkitIsFullScreen)
  4109. &&(editor.container.requestFullScreen?editor.container.requestFullScreen():editor.container.mozRequestFullScreen?editor.container.mozRequestFullScreen():editor.container.webkitRequestFullScreen?editor.container.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT):editor.container.msRequestFullscreen&&editor.container.msRequestFullscreen());
  4110. } else if(editorOption == "wrap") {
  4111. let wrapStatus = (editor.getSession().getUseWrapMode()) ? false : true;
  4112. editor.getSession().setUseWrapMode(wrapStatus);
  4113. } else if(editorOption == "help") {
  4114. var helpHtml="";$.each(window.config.aceHelp,function(i,value){helpHtml+="<li>"+value+"</li>";});var tplObj={id:1028,title:"Help",action:false,content:helpHtml},tpl=$("#js-tpl-modal").html();$('#wrapper').append(template(tpl,tplObj));$("#js-ModalCenter-1028").modal('show');
  4115. }
  4116. }
  4117. });
  4118. $("select#js-ace-mode, select#js-ace-theme, select#js-ace-fontSize").on("change", function(e){
  4119. e.preventDefault();
  4120. let selectedValue = $(this).val(), selectionType = $(this).attr("data-type");
  4121. if(selectedValue && selectionType == "mode") {
  4122. editor.getSession().setMode(selectedValue);
  4123. } else if(selectedValue && selectionType == "theme") {
  4124. editor.setTheme(selectedValue);
  4125. }else if(selectedValue && selectionType == "fontSize") {
  4126. editor.setFontSize(parseInt(selectedValue));
  4127. }
  4128. });
  4129. });
  4130. </script>
  4131. <?php endif; ?>
  4132. <div id="snackbar"></div>
  4133. <script>
  4134. function showLoading() {
  4135. $('#loadingMask').show();
  4136. console.log('showLoading')
  4137. }
  4138. function hideLoading() {
  4139. $('#loadingMask').hide();
  4140. console.log('hideLoading')
  4141. }
  4142. </script>
  4143. </body>
  4144. </html>
  4145. <?php
  4146. }
  4147. /**
  4148. * Show image
  4149. * @param string $img
  4150. */
  4151. function fm_show_image($img)
  4152. {
  4153. $modified_time = gmdate('D, d M Y 00:00:00') . ' GMT';
  4154. $expires_time = gmdate('D, d M Y 00:00:00', strtotime('+1 day')) . ' GMT';
  4155. $img = trim($img);
  4156. $images = fm_get_images();
  4157. $image = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAEElEQVR42mL4//8/A0CAAQAI/AL+26JNFgAAAABJRU5ErkJggg==';
  4158. if (isset($images[$img])) {
  4159. $image = $images[$img];
  4160. }
  4161. $image = base64_decode($image);
  4162. if (function_exists('mb_strlen')) {
  4163. $size = mb_strlen($image, '8bit');
  4164. } else {
  4165. $size = strlen($image);
  4166. }
  4167. if (function_exists('header_remove')) {
  4168. header_remove('Cache-Control');
  4169. header_remove('Pragma');
  4170. } else {
  4171. header('Cache-Control:');
  4172. header('Pragma:');
  4173. }
  4174. header('Last-Modified: ' . $modified_time, true, 200);
  4175. header('Expires: ' . $expires_time);
  4176. header('Content-Length: ' . $size);
  4177. header('Content-Type: image/png');
  4178. echo $image;
  4179. exit;
  4180. }
  4181. /**
  4182. * Language Translation System
  4183. * @param string $txt
  4184. * @return string
  4185. */
  4186. function lng($txt) {
  4187. global $lang;
  4188. // English Language
  4189. $tr['en']['AppName'] = 'Tiny File Manager';
  4190. $tr['en']['AppTitle'] = '文件管理器';
  4191. $tr['en']['Login'] = '登录';
  4192. $tr['en']['Username'] = '用户名';
  4193. $tr['en']['Password'] = '密码';
  4194. $tr['en']['Logout'] = '登出';
  4195. $tr['en']['Move'] = '移动';
  4196. $tr['en']['Copy'] = '复制';
  4197. $tr['en']['Save'] = '保存';
  4198. $tr['en']['SelectAll'] = '全选';
  4199. $tr['en']['UnSelectAll'] = '取消全选';
  4200. $tr['en']['File'] = '文件';
  4201. $tr['en']['Back'] = '返回';
  4202. $tr['en']['Size'] = '大小';
  4203. $tr['en']['Perms'] = '权限';
  4204. $tr['en']['Modified'] = '修改';
  4205. $tr['en']['Owner'] = '拥有者';
  4206. $tr['en']['Search'] = '查找';
  4207. $tr['en']['NewItem'] = '新建';
  4208. $tr['en']['Folder'] = '文件夹';
  4209. $tr['en']['Delete'] = '删除';
  4210. $tr['en']['Rename'] = '重名命';
  4211. $tr['en']['CopyTo'] = '复制到';
  4212. $tr['en']['DirectLink'] = '复制链接';
  4213. $tr['en']['UploadingFiles'] = '上传文件';
  4214. $tr['en']['ChangePermissions'] = '修改权限';
  4215. $tr['en']['Copying'] = '复制中';
  4216. $tr['en']['CreateNewItem'] = '创建项目';
  4217. $tr['en']['Name'] = '名称';
  4218. $tr['en']['AdvancedEditor'] = '高级编辑';
  4219. $tr['en']['RememberMe'] = '记住账号';
  4220. $tr['en']['Actions'] = '执行';
  4221. $tr['en']['Upload'] = '上传';
  4222. $tr['en']['Cancel'] = '取消';
  4223. $tr['en']['InvertSelection'] = '反转选择';
  4224. $tr['en']['DestinationFolder'] = '目标文件夹';
  4225. $tr['en']['ItemType'] = '项目类型';
  4226. $tr['en']['ItemName'] = '项目名';
  4227. $tr['en']['CreateNow'] = '立即建立';
  4228. $tr['en']['Download'] = '下载';
  4229. $tr['en']['Open'] = '打开';
  4230. $tr['en']['UnZip'] = '解压';
  4231. $tr['en']['UnZipToFolder'] = '解压到文件夹';
  4232. $tr['en']['Edit'] = '编辑';
  4233. $tr['en']['NormalEditor'] = '普通编辑';
  4234. $tr['en']['BackUp'] = '返回上一页';
  4235. $tr['en']['SourceFolder'] = '源文件夹';
  4236. $tr['en']['Files'] = '目录';
  4237. $tr['en']['Move'] = '移动';
  4238. $tr['en']['Change'] = '变化';
  4239. $tr['en']['Settings'] = '设置';
  4240. $tr['en']['Language'] = '语言';
  4241. $tr['en']['MemoryUsed'] = '使用的内存';
  4242. $tr['en']['PartitionSize'] = '分区大小';
  4243. $tr['en']['ErrorReporting'] = '错误报告';
  4244. $tr['en']['ShowHiddenFiles'] = '显示隐藏文件';
  4245. $tr['en']['Full size'] = '总大小';
  4246. $tr['en']['Help'] = '帮助';
  4247. $tr['en']['Free of'] = '硬盘大小';
  4248. $tr['en']['Preview'] = '查看';
  4249. $tr['en']['Help Documents'] = '帮助文档';
  4250. $tr['en']['Report Issue'] = '报告问题';
  4251. $tr['en']['Generate'] = '生成';
  4252. $tr['en']['FullSize'] = '总大小';
  4253. $tr['en']['FreeOf'] = '硬盘大小';
  4254. $tr['en']['CalculateFolderSize']= '计算文件夹大小';
  4255. $tr['en']['ProcessID'] = '进程ID';
  4256. $tr['en']['Created'] = '创建';
  4257. $tr['en']['HideColumns'] = '隐藏权限/所有者列';
  4258. $tr['en']['Folder is empty'] = '文件夹空';
  4259. $tr['en']['Check Latest Version'] = '查看最新版本';
  4260. $tr['en']['Generate new password hash'] = '生成新的密码哈希';
  4261. $tr['en']['You are logged in'] = '您已登录';
  4262. $tr['en']['Login failed. Invalid username or password'] = '登录失败。 用户名或密码无效';
  4263. $tr['en']['password_hash not supported, Upgrade PHP version'] = 'password_hash不支持,升级PHP版本';
  4264. $i18n = fm_get_translations($tr);
  4265. $tr = $i18n ? $i18n : $tr;
  4266. if (!strlen($lang)) $lang = 'en';
  4267. if (isset($tr[$lang][$txt])) return fm_enc($tr[$lang][$txt]);
  4268. else if (isset($tr['en'][$txt])) return fm_enc($tr['en'][$txt]);
  4269. else return "$txt";
  4270. }
  4271. /**
  4272. * Get base64-encoded images
  4273. * @return array
  4274. */
  4275. function fm_get_images()
  4276. {
  4277. return array(
  4278. 'favicon' => 'Qk04AgAAAAAAADYAAAAoAAAAEAAAABAAAAABABAAAAAAAAICAAASCwAAEgsAAAAAAAAAAAAAIQQhBCEEIQQhBCEEIQQhBCEEIQ
  4279. QhBCEEIQQhBCEEIQQhBCEEIQQhBHNO3n/ef95/vXetNSEEIQQhBCEEIQQhBCEEIQQhBCEEc07ef95/3n/ef95/1lohBCEEIQQhBCEEIQQhBCEEIQ
  4280. RzTt5/3n8hBDFG3n/efyEEIQQhBCEEIQQhBCEEIQQhBHNO3n/efyEEMUbef95/IQQhBCEEIQQhBCEEIQQhBCEErTVzTnNOIQQxRt5/3n8hBCEEIQ
  4281. QhBCEEIQQhBCEEIQQhBCEEIQQhBDFG3n/efyEEIQQhBCEEIQQhBCEEIQQhBCEEIQQxRt5/3n+cc2stIQQhBCEEIQQhBCEEIQQhBCEEIQQIIZxz3n
  4282. /ef5xzay0hBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQhBDFG3n/efyEEIQQhBCEEIQQhBCEEIQQhBK01c05zTiEEMUbef95/IQQhBCEEIQQhBCEEIQ
  4283. QhBCEEc07ef95/IQQxRt5/3n8hBCEEIQQhBCEEIQQhBCEEIQRzTt5/3n8hBDFG3n/efyEEIQQhBCEEIQQhBCEEIQQhBKUUOWfef95/3n/ef95/IQ
  4284. QhBCEEIQQhBCEEIQQhBCEEIQQhBJRW3n/ef95/3n8hBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQAAA=='
  4285. );
  4286. }
  4287. ?>