filemanager.php 196 KB

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