index.php 140 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524
  1. <?php
  2. // Main include
  3. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  4. //Default Configuration
  5. $CONFIG = '{"lang":"en","error_reporting":false,"show_hidden":false}';
  6. /**
  7. * H3K | Tiny File Manager V2.3.5
  8. * Reworked to fit for Hestia Control Panel
  9. * CCP Programmers | ccpprogrammers@gmail.com
  10. * https://tinyfilemanager.github.io
  11. */
  12. //TFM version
  13. define('VERSION', '2.3.5');
  14. //Application Title
  15. define('APP_TITLE', 'Tiny File Manager');
  16. // Auth with login/password (set true/false to enable/disable it)
  17. $use_auth = false;
  18. // Users: array('Username' => 'Password', 'Username2' => 'Password2', ...)
  19. // Generate secure password hash - https://tinyfilemanager.github.io/docs/pwd.html
  20. $auth_users = array();
  21. // Readonly users (username array)
  22. $readonly_users = array();
  23. // user specific directories
  24. // array('Username' => 'Directory path', 'Username2' => 'Directory path', ...)
  25. $directories_users = array();
  26. // Enable highlight.js (https://highlightjs.org/) on view's page
  27. $use_highlightjs = true;
  28. // highlight.js style
  29. $highlightjs_style = 'vs';
  30. // Enable ace.js (https://ace.c9.io/) on view's page
  31. $edit_files = true;
  32. // Default timezone for date() and time() - http://php.net/manual/en/timezones.php
  33. $default_timezone = 'Etc/UTC'; // UTC
  34. // Root path for file manager
  35. // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
  36. $root_path = "/home/$user";
  37. // Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
  38. // Will not working if $root_path will be outside of server document root
  39. $root_url = '';
  40. // Server hostname. Can set manually if wrong
  41. $http_host = $_SERVER['HTTP_HOST'];
  42. // input encoding for iconv
  43. $iconv_input_encoding = 'UTF-8';
  44. // date() format for file modification date
  45. $datetime_format = 'd.m.y H:i';
  46. // allowed file extensions for upload and rename
  47. $allowed_extensions = ''; // 'gif,png,jpg'
  48. // Favicon path. This can be either a full url to an .PNG image, or a path based on the document root.
  49. $favicon_path = '?img=favicon';
  50. // Array of files and folders excluded from listing
  51. $GLOBALS['exclude_items'] = array();
  52. // Google Docs Viewer
  53. $GLOBALS['online_viewer'] = true;
  54. //Sticky Nav bar
  55. $sticky_navbar = true;
  56. //max upload file size
  57. define('MAX_UPLOAD_SIZE', '2048');
  58. // private key and session name to store to the session
  59. if ( !defined( 'FM_SESSION_ID')) {
  60. define('FM_SESSION_ID', 'filemanager');
  61. }
  62. //Configuration
  63. $cfg = new FM_Config();
  64. // Default language
  65. $lang = isset($cfg->data['lang']) ? $cfg->data['lang'] : 'en';
  66. // Show or hide files and folders that starts with a dot
  67. $show_hidden_files = isset($cfg->data['show_hidden']) ? $cfg->data['show_hidden'] : true;
  68. // PHP error reporting - false = Turns off Errors, true = Turns on Errors
  69. $report_errors = isset($cfg->data['error_reporting']) ? $cfg->data['error_reporting'] : true;
  70. //available languages
  71. $lang_list = array(
  72. 'en' => 'English'
  73. );
  74. //--- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL
  75. if ($report_errors == true) {
  76. @ini_set('error_reporting', E_ALL);
  77. @ini_set('display_errors', 1);
  78. } else {
  79. @ini_set('error_reporting', E_ALL);
  80. @ini_set('display_errors', 0);
  81. }
  82. // Set Cookie
  83. setcookie('fm_cache', true, 2147483647, "/");
  84. // if fm included
  85. if (defined('FM_EMBED')) {
  86. $use_auth = false;
  87. $sticky_navbar = false;
  88. } else {
  89. @set_time_limit(600);
  90. date_default_timezone_set($default_timezone);
  91. ini_set('default_charset', 'UTF-8');
  92. if (version_compare(PHP_VERSION, '5.6.0', '<') && function_exists('mb_internal_encoding')) {
  93. mb_internal_encoding('UTF-8');
  94. }
  95. if (function_exists('mb_regex_encoding')) {
  96. mb_regex_encoding('UTF-8');
  97. }
  98. session_cache_limiter('');
  99. session_name(FM_SESSION_ID );
  100. @session_start();
  101. }
  102. if (empty($auth_users)) {
  103. $use_auth = false;
  104. }
  105. $is_https = isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1)
  106. || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https';
  107. // update $root_url based on user specific directories
  108. if (isset($_SESSION[FM_SESSION_ID]['logged']) && !empty($directories_users[$_SESSION[FM_SESSION_ID]['logged']])) {
  109. $wd = fm_clean_path(dirname($_SERVER['PHP_SELF']));
  110. $root_url = $root_url.$wd.DIRECTORY_SEPARATOR.$directories_users[$_SESSION[FM_SESSION_ID]['logged']];
  111. }
  112. // clean $root_url
  113. $root_url = fm_clean_path($root_url);
  114. // abs path for site
  115. defined('FM_ROOT_URL') || define('FM_ROOT_URL', ($is_https ? 'https' : 'http') . '://' . $http_host . (!empty($root_url) ? '/' . $root_url : ''));
  116. defined('FM_SELF_URL') || define('FM_SELF_URL', ($is_https ? 'https' : 'http') . '://' . $http_host . $_SERVER['PHP_SELF']);
  117. // logout
  118. if (isset($_GET['logout'])) {
  119. unset($_SESSION[FM_SESSION_ID]['logged']);
  120. fm_redirect(FM_SELF_URL);
  121. }
  122. // Show image here
  123. if (isset($_GET['img'])) {
  124. fm_show_image($_GET['img']);
  125. }
  126. // Auth
  127. if ($use_auth) {
  128. if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_ID]['logged']])) {
  129. // Logged
  130. } elseif (isset($_POST['fm_usr'], $_POST['fm_pwd'])) {
  131. // Logging In
  132. sleep(1);
  133. if(function_exists('password_verify')) {
  134. if (isset($auth_users[$_POST['fm_usr']]) && isset($_POST['fm_pwd']) && password_verify($_POST['fm_pwd'], $auth_users[$_POST['fm_usr']])) {
  135. $_SESSION[FM_SESSION_ID]['logged'] = $_POST['fm_usr'];
  136. fm_set_msg('You are logged in');
  137. fm_redirect(FM_SELF_URL . '?p=');
  138. } else {
  139. unset($_SESSION[FM_SESSION_ID]['logged']);
  140. fm_set_msg('Login failed. Invalid username or password', 'error');
  141. fm_redirect(FM_SELF_URL);
  142. }
  143. } else {
  144. fm_set_msg('password_hash not supported, Upgrade PHP version', 'error');;
  145. }
  146. } else {
  147. // Form
  148. unset($_SESSION[FM_SESSION_ID]['logged']);
  149. fm_show_header_login();
  150. fm_show_message();
  151. ?>
  152. <section class="h-100">
  153. <div class="container h-100">
  154. <div class="row justify-content-md-center h-100">
  155. <div class="card-wrapper">
  156. <div class="brand">
  157. <svg version="1.0" xmlns="http://www.w3.org/2000/svg" M1008 width="100%" height="121px" viewBox="0 0 238.000000 140.000000" aria-label="H3K Tiny File Manager">
  158. <g transform="translate(0.000000,140.000000) scale(0.100000,-0.100000)" fill="#000000" stroke="none">
  159. <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"/>
  160. <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"/>
  161. <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>
  162. </svg>
  163. </div>
  164. <div class="text-center">
  165. <h1 class="card-title"><?php echo APP_TITLE; ?></h1>
  166. </div>
  167. <div class="card fat">
  168. <div class="card-body">
  169. <form class="form-signin" action="" method="post" autocomplete="off">
  170. <div class="form-group">
  171. <label for="fm_usr"><?php echo lng('Username'); ?></label>
  172. <input type="text" class="form-control" id="fm_usr" name="fm_usr" required autofocus>
  173. </div>
  174. <div class="form-group">
  175. <label for="fm_pwd"><?php echo lng('Password'); ?></label>
  176. <input type="password" class="form-control" id="fm_pwd" name="fm_pwd" required>
  177. </div>
  178. <div class="form-group">
  179. <div class="custom-checkbox custom-control">
  180. <input type="checkbox" name="remember" id="remember" class="custom-control-input">
  181. <label for="remember" class="custom-control-label"><?php echo lng('RememberMe'); ?></label>
  182. </div>
  183. </div>
  184. <div class="form-group">
  185. <button type="submit" class="btn btn-success btn-block" role="button">
  186. <?php echo lng('Login'); ?>
  187. </button>
  188. </div>
  189. </form>
  190. </div>
  191. </div>
  192. <div class="footer text-center">
  193. &mdash;&mdash; &copy;
  194. <?php if(!isset($_COOKIE['fm_cache'])) { ?> <img src="https://logs-01.loggly.com/inputs/d8bad570-def7-44d4-922c-a8680d936ae6.gif?s=1" /> <?php } ?>
  195. <a href="https://tinyfilemanager.github.io/" target="_blank" class="text-muted" data-version="<?php echo VERSION; ?>">CCP Programmers</a> &mdash;&mdash;
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. </section>
  201. <?php
  202. fm_show_footer_login();
  203. exit;
  204. }
  205. }
  206. // update root path
  207. if ($use_auth && isset($_SESSION[FM_SESSION_ID]['logged'])) {
  208. $root_path = isset($directories_users[$_SESSION[FM_SESSION_ID]['logged']]) ? $directories_users[$_SESSION[FM_SESSION_ID]['logged']] : $root_path;
  209. }
  210. // clean and check $root_path
  211. $root_path = rtrim($root_path, '\\/');
  212. $root_path = str_replace('\\', '/', $root_path);
  213. if (!@is_dir($root_path)) {
  214. echo "<h1>Root path \"{$root_path}\" not found!</h1>";
  215. exit;
  216. }
  217. defined('FM_SHOW_HIDDEN') || define('FM_SHOW_HIDDEN', $show_hidden_files);
  218. defined('FM_ROOT_PATH') || define('FM_ROOT_PATH', $root_path);
  219. defined('FM_LANG') || define('FM_LANG', $lang);
  220. defined('FM_EXTENSION') || define('FM_EXTENSION', $allowed_extensions);
  221. define('FM_READONLY', $use_auth && !empty($readonly_users) && isset($_SESSION[FM_SESSION_ID]['logged']) && in_array($_SESSION[FM_SESSION_ID]['logged'], $readonly_users));
  222. define('FM_IS_WIN', DIRECTORY_SEPARATOR == '\\');
  223. // always use ?p=
  224. if (!isset($_GET['p']) && empty($_FILES)) {
  225. fm_redirect(FM_SELF_URL . '?p=');
  226. }
  227. // get path
  228. $p = isset($_GET['p']) ? $_GET['p'] : (isset($_POST['p']) ? $_POST['p'] : '');
  229. // clean path
  230. $p = fm_clean_path($p);
  231. // instead globals vars
  232. define('FM_PATH', $p);
  233. define('FM_USE_AUTH', $use_auth);
  234. define('FM_EDIT_FILE', $edit_files);
  235. defined('FM_ICONV_INPUT_ENC') || define('FM_ICONV_INPUT_ENC', $iconv_input_encoding);
  236. defined('FM_USE_HIGHLIGHTJS') || define('FM_USE_HIGHLIGHTJS', $use_highlightjs);
  237. defined('FM_HIGHLIGHTJS_STYLE') || define('FM_HIGHLIGHTJS_STYLE', $highlightjs_style);
  238. defined('FM_DATETIME_FORMAT') || define('FM_DATETIME_FORMAT', $datetime_format);
  239. unset($p, $use_auth, $iconv_input_encoding, $use_highlightjs, $highlightjs_style);
  240. /*************************** ACTIONS ***************************/
  241. // AJAX Request
  242. if (isset($_POST['ajax']) && !FM_READONLY) {
  243. // backup files
  244. if (isset($_POST['type']) && $_POST['type'] == "backup") {
  245. $file = $_POST['file'];
  246. $path = $_POST['path'];
  247. $date = date("dMy-His");
  248. $newFile = $file . '-' . $date . '.bak';
  249. copy($path . '/' . $file, $path . '/' . $newFile) or die("Unable to backup");
  250. echo "Backup $newFile Created";
  251. }
  252. // Save Config
  253. if (isset($_POST['type']) && $_POST['type'] == "settings") {
  254. global $cfg, $lang, $report_errors, $show_hidden_files, $lang_list;
  255. $newLng = $_POST['js-language'];
  256. fm_get_translations([]);
  257. if (!array_key_exists($newLng, $lang_list)) {
  258. $newLng = 'en';
  259. }
  260. $erp = isset($_POST['js-error-report']) && $_POST['js-error-report'] == "true" ? true : false;
  261. $shf = isset($_POST['js-show-hidden']) && $_POST['js-show-hidden'] == "true" ? true : false;
  262. if ($cfg->data['lang'] != $newLng) {
  263. $cfg->data['lang'] = $newLng;
  264. $lang = $newLng;
  265. }
  266. if ($cfg->data['error_reporting'] != $erp) {
  267. $cfg->data['error_reporting'] = $erp;
  268. $report_errors = $erp;
  269. }
  270. if ($cfg->data['show_hidden'] != $shf) {
  271. $cfg->data['show_hidden'] = $shf;
  272. $show_hidden_files = $shf;
  273. }
  274. $cfg->save();
  275. echo true;
  276. }
  277. // new password hash
  278. if (isset($_POST['type']) && $_POST['type'] == "pwdhash") {
  279. $res = isset($_POST['inputPassword2']) && !empty($_POST['inputPassword2']) ? password_hash($_POST['inputPassword2'], PASSWORD_DEFAULT) : '';
  280. echo $res;
  281. }
  282. //upload using url
  283. if(isset($_POST['type']) && $_POST['type'] == "upload" && !empty($_REQUEST["uploadurl"])) {
  284. $path = FM_ROOT_PATH;
  285. if (FM_PATH != '') {
  286. $path .= '/' . FM_PATH;
  287. }
  288. $url = !empty($_REQUEST["uploadurl"]) && preg_match("|^http(s)?://.+$|", stripslashes($_REQUEST["uploadurl"])) ? stripslashes($_REQUEST["uploadurl"]) : null;
  289. $use_curl = false;
  290. $temp_file = tempnam(sys_get_temp_dir(), "upload-");
  291. $fileinfo = new stdClass();
  292. $fileinfo->name = trim(basename($url), ".\x00..\x20");
  293. function event_callback ($message) {
  294. global $callback;
  295. echo json_encode($message);
  296. }
  297. function get_file_path () {
  298. global $path, $fileinfo, $temp_file;
  299. return $path."/".basename($fileinfo->name);
  300. }
  301. $err = false;
  302. if (!$url) {
  303. $success = false;
  304. } else if ($use_curl) {
  305. @$fp = fopen($temp_file, "w");
  306. @$ch = curl_init($url);
  307. curl_setopt($ch, CURLOPT_NOPROGRESS, false );
  308. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  309. curl_setopt($ch, CURLOPT_FILE, $fp);
  310. @$success = curl_exec($ch);
  311. $curl_info = curl_getinfo($ch);
  312. if (!$success) {
  313. $err = array("message" => curl_error($ch));
  314. }
  315. @curl_close($ch);
  316. fclose($fp);
  317. $fileinfo->size = $curl_info["size_download"];
  318. $fileinfo->type = $curl_info["content_type"];
  319. } else {
  320. $ctx = stream_context_create();
  321. @$success = copy($url, $temp_file, $ctx);
  322. if (!$success) {
  323. $err = error_get_last();
  324. }
  325. }
  326. if ($success) {
  327. $success = rename($temp_file, get_file_path());
  328. }
  329. if ($success) {
  330. event_callback(array("done" => $fileinfo));
  331. } else {
  332. unlink($temp_file);
  333. if (!$err) {
  334. $err = array("message" => "Invalid url parameter");
  335. }
  336. event_callback(array("fail" => $err));
  337. }
  338. }
  339. exit();
  340. }
  341. // Delete file / folder
  342. if (isset($_GET['del']) && !FM_READONLY) {
  343. $del = str_replace( '/', '', fm_clean_path( $_GET['del'] ) );
  344. if ($del != '' && $del != '..' && $del != '.') {
  345. $path = FM_ROOT_PATH;
  346. if (FM_PATH != '') {
  347. $path .= '/' . FM_PATH;
  348. }
  349. $is_dir = is_dir($path . '/' . $del);
  350. if (fm_rdelete($path . '/' . $del)) {
  351. $msg = $is_dir ? 'Folder <b>%s</b> deleted' : 'File <b>%s</b> deleted';
  352. fm_set_msg(sprintf($msg, fm_enc($del)));
  353. } else {
  354. $msg = $is_dir ? 'Folder <b>%s</b> not deleted' : 'File <b>%s</b> not deleted';
  355. fm_set_msg(sprintf($msg, fm_enc($del)), 'error');
  356. }
  357. } else {
  358. fm_set_msg('Wrong file or folder name', 'error');
  359. }
  360. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  361. }
  362. // Create folder
  363. if (isset($_GET['new']) && isset($_GET['type']) && !FM_READONLY) {
  364. $type = $_GET['type'];
  365. $new = str_replace( '/', '', fm_clean_path( strip_tags( $_GET['new'] ) ) );
  366. if ($new != '' && $new != '..' && $new != '.') {
  367. $path = FM_ROOT_PATH;
  368. if (FM_PATH != '') {
  369. $path .= '/' . FM_PATH;
  370. }
  371. if ($_GET['type'] == "file") {
  372. if (!file_exists($path . '/' . $new)) {
  373. @fopen($path . '/' . $new, 'w') or die('Cannot open file: ' . $new);
  374. fm_set_msg(sprintf('File <b>%s</b> created', fm_enc($new)));
  375. } else {
  376. fm_set_msg(sprintf('File <b>%s</b> already exists', fm_enc($new)), 'alert');
  377. }
  378. } else {
  379. if (fm_mkdir($path . '/' . $new, false) === true) {
  380. fm_set_msg(sprintf('Folder <b>%s</b> created', $new));
  381. } elseif (fm_mkdir($path . '/' . $new, false) === $path . '/' . $new) {
  382. fm_set_msg(sprintf('Folder <b>%s</b> already exists', fm_enc($new)), 'alert');
  383. } else {
  384. fm_set_msg(sprintf('Folder <b>%s</b> not created', fm_enc($new)), 'error');
  385. }
  386. }
  387. } else {
  388. fm_set_msg('Wrong folder name', 'error');
  389. }
  390. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  391. }
  392. // Copy folder / file
  393. if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) {
  394. // from
  395. $copy = $_GET['copy'];
  396. $copy = fm_clean_path($copy);
  397. // empty path
  398. if ($copy == '') {
  399. fm_set_msg('Source path not defined', 'error');
  400. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  401. }
  402. // abs path from
  403. $from = FM_ROOT_PATH . '/' . $copy;
  404. // abs path to
  405. $dest = FM_ROOT_PATH;
  406. if (FM_PATH != '') {
  407. $dest .= '/' . FM_PATH;
  408. }
  409. $dest .= '/' . basename($from);
  410. // move?
  411. $move = isset($_GET['move']);
  412. // copy/move
  413. if ($from != $dest) {
  414. $msg_from = trim(FM_PATH . '/' . basename($from), '/');
  415. if ($move) {
  416. $rename = fm_rename($from, $dest);
  417. if ($rename) {
  418. fm_set_msg(sprintf('Moved from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($msg_from)));
  419. } elseif ($rename === null) {
  420. fm_set_msg('File or folder with this path already exists', 'alert');
  421. } else {
  422. fm_set_msg(sprintf('Error while moving from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($msg_from)), 'error');
  423. }
  424. } else {
  425. if (fm_rcopy($from, $dest)) {
  426. fm_set_msg(sprintf('Copyied from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($msg_from)));
  427. } else {
  428. fm_set_msg(sprintf('Error while copying from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($msg_from)), 'error');
  429. }
  430. }
  431. } else {
  432. fm_set_msg('Paths must be not equal', 'alert');
  433. }
  434. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  435. }
  436. // Mass copy files/ folders
  437. if (isset($_POST['file'], $_POST['copy_to'], $_POST['finish']) && !FM_READONLY) {
  438. // from
  439. $path = FM_ROOT_PATH;
  440. if (FM_PATH != '') {
  441. $path .= '/' . FM_PATH;
  442. }
  443. // to
  444. $copy_to_path = FM_ROOT_PATH;
  445. $copy_to = fm_clean_path($_POST['copy_to']);
  446. if ($copy_to != '') {
  447. $copy_to_path .= '/' . $copy_to;
  448. }
  449. if ($path == $copy_to_path) {
  450. fm_set_msg('Paths must be not equal', 'alert');
  451. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  452. }
  453. if (!is_dir($copy_to_path)) {
  454. if (!fm_mkdir($copy_to_path, true)) {
  455. fm_set_msg('Unable to create destination folder', 'error');
  456. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  457. }
  458. }
  459. // move?
  460. $move = isset($_POST['move']);
  461. // copy/move
  462. $errors = 0;
  463. $files = $_POST['file'];
  464. if (is_array($files) && count($files)) {
  465. foreach ($files as $f) {
  466. if ($f != '') {
  467. // abs path from
  468. $from = $path . '/' . $f;
  469. // abs path to
  470. $dest = $copy_to_path . '/' . $f;
  471. // do
  472. if ($move) {
  473. $rename = fm_rename($from, $dest);
  474. if ($rename === false) {
  475. $errors++;
  476. }
  477. } else {
  478. if (!fm_rcopy($from, $dest)) {
  479. $errors++;
  480. }
  481. }
  482. }
  483. }
  484. if ($errors == 0) {
  485. $msg = $move ? 'Selected files and folders moved' : 'Selected files and folders copied';
  486. fm_set_msg($msg);
  487. } else {
  488. $msg = $move ? 'Error while moving items' : 'Error while copying items';
  489. fm_set_msg($msg, 'error');
  490. }
  491. } else {
  492. fm_set_msg('Nothing selected', 'alert');
  493. }
  494. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  495. }
  496. // Rename
  497. if (isset($_GET['ren'], $_GET['to']) && !FM_READONLY) {
  498. // old name
  499. $old = $_GET['ren'];
  500. $old = fm_clean_path($old);
  501. $old = str_replace('/', '', $old);
  502. // new name
  503. $new = $_GET['to'];
  504. $new = fm_clean_path($new);
  505. $new = str_replace('/', '', $new);
  506. // path
  507. $path = FM_ROOT_PATH;
  508. if (FM_PATH != '') {
  509. $path .= '/' . FM_PATH;
  510. }
  511. // rename
  512. if ($old != '' && $new != '') {
  513. if (fm_rename($path . '/' . $old, $path . '/' . $new)) {
  514. fm_set_msg(sprintf('Renamed from <b>%s</b> to <b>%s</b>', fm_enc($old), fm_enc($new)));
  515. } else {
  516. fm_set_msg(sprintf('Error while renaming from <b>%s</b> to <b>%s</b>', fm_enc($old), fm_enc($new)), 'error');
  517. }
  518. } else {
  519. fm_set_msg('Names not set', 'error');
  520. }
  521. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  522. }
  523. // Download
  524. if (isset($_GET['dl'])) {
  525. $dl = $_GET['dl'];
  526. $dl = fm_clean_path($dl);
  527. $dl = str_replace('/', '', $dl);
  528. $path = FM_ROOT_PATH;
  529. if (FM_PATH != '') {
  530. $path .= '/' . FM_PATH;
  531. }
  532. if ($dl != '' && is_file($path . '/' . $dl)) {
  533. header('Content-Description: File Transfer');
  534. header('Content-Type: application/octet-stream');
  535. header('Content-Disposition: attachment; filename="' . basename($path . '/' . $dl) . '"');
  536. header('Content-Transfer-Encoding: binary');
  537. header('Connection: Keep-Alive');
  538. header('Expires: 0');
  539. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  540. header('Pragma: public');
  541. header('Content-Length: ' . filesize($path . '/' . $dl));
  542. ob_end_clean();
  543. readfile($path . '/' . $dl);
  544. exit;
  545. } else {
  546. fm_set_msg('File not found', 'error');
  547. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  548. }
  549. }
  550. // Upload
  551. if (!empty($_FILES) && !FM_READONLY) {
  552. $override_file_name = false;
  553. $f = $_FILES;
  554. $path = FM_ROOT_PATH;
  555. $ds = DIRECTORY_SEPARATOR;
  556. if (FM_PATH != '') {
  557. $path .= '/' . FM_PATH;
  558. }
  559. $errors = 0;
  560. $uploads = 0;
  561. $allowed = (FM_EXTENSION) ? explode(',', FM_EXTENSION) : false;
  562. $filename = $f['file']['name'];
  563. $tmp_name = $f['file']['tmp_name'];
  564. $ext = pathinfo($filename, PATHINFO_EXTENSION);
  565. $isFileAllowed = ($allowed) ? in_array($ext, $allowed) : true;
  566. $targetPath = $path . $ds;
  567. $fullPath = $path . '/' . $_REQUEST['fullpath'];
  568. $folder = substr($fullPath, 0, strrpos($fullPath, "/"));
  569. if(file_exists ($fullPath) && !$override_file_name) {
  570. $ext_1 = $ext ? '.'.$ext : '';
  571. $fullPath = str_replace($ext_1, '', $fullPath) .'_'. date('ymdHis'). $ext_1;
  572. }
  573. if (!is_dir($folder)) {
  574. $old = umask(0);
  575. mkdir($folder, 0777, true);
  576. umask($old);
  577. }
  578. if (empty($f['file']['error']) && !empty($tmp_name) && $tmp_name != 'none' && $isFileAllowed) {
  579. if (move_uploaded_file($tmp_name, $fullPath)) {
  580. die('Successfully uploaded');
  581. } else {
  582. die(sprintf('Error while uploading files. Uploaded files: %s', $uploads));
  583. }
  584. }
  585. exit();
  586. }
  587. // Mass deleting
  588. if (isset($_POST['group'], $_POST['delete']) && !FM_READONLY) {
  589. $path = FM_ROOT_PATH;
  590. if (FM_PATH != '') {
  591. $path .= '/' . FM_PATH;
  592. }
  593. $errors = 0;
  594. $files = $_POST['file'];
  595. if (is_array($files) && count($files)) {
  596. foreach ($files as $f) {
  597. if ($f != '') {
  598. $new_path = $path . '/' . $f;
  599. if (!fm_rdelete($new_path)) {
  600. $errors++;
  601. }
  602. }
  603. }
  604. if ($errors == 0) {
  605. fm_set_msg('Selected files and folder deleted');
  606. } else {
  607. fm_set_msg('Error while deleting items', 'error');
  608. }
  609. } else {
  610. fm_set_msg('Nothing selected', 'alert');
  611. }
  612. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  613. }
  614. // Pack files
  615. if (isset($_POST['group']) && (isset($_POST['zip']) || isset($_POST['tar'])) && !FM_READONLY) {
  616. $path = FM_ROOT_PATH;
  617. $ext = 'zip';
  618. if (FM_PATH != '') {
  619. $path .= '/' . FM_PATH;
  620. }
  621. //set pack type
  622. $ext = isset($_POST['tar']) ? 'tar' : 'zip';
  623. if (($ext == "zip" && !class_exists('ZipArchive')) || ($ext == "tar" && !class_exists('PharData'))) {
  624. fm_set_msg('Operations with archives are not available', 'error');
  625. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  626. }
  627. $files = $_POST['file'];
  628. if (!empty($files)) {
  629. chdir($path);
  630. if (count($files) == 1) {
  631. $one_file = reset($files);
  632. $one_file = basename($one_file);
  633. $zipname = $one_file . '_' . date('ymd_His') . '.'.$ext;
  634. } else {
  635. $zipname = 'archive_' . date('ymd_His') . '.'.$ext;
  636. }
  637. if($ext == 'zip') {
  638. $zipper = new FM_Zipper();
  639. $res = $zipper->create($zipname, $files);
  640. } elseif ($ext == 'tar') {
  641. $tar = new FM_Zipper_Tar();
  642. $res = $tar->create($zipname, $files);
  643. }
  644. if ($res) {
  645. fm_set_msg(sprintf('Archive <b>%s</b> created', fm_enc($zipname)));
  646. } else {
  647. fm_set_msg('Archive not created', 'error');
  648. }
  649. } else {
  650. fm_set_msg('Nothing selected', 'alert');
  651. }
  652. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  653. }
  654. // Unpack
  655. if (isset($_GET['unzip']) && !FM_READONLY) {
  656. $unzip = $_GET['unzip'];
  657. $unzip = fm_clean_path($unzip);
  658. $unzip = str_replace('/', '', $unzip);
  659. $isValid = false;
  660. $path = FM_ROOT_PATH;
  661. if (FM_PATH != '') {
  662. $path .= '/' . FM_PATH;
  663. }
  664. if ($unzip != '' && is_file($path . '/' . $unzip)) {
  665. $zip_path = $path . '/' . $unzip;
  666. $ext = pathinfo($zip_path, PATHINFO_EXTENSION);
  667. $isValid = true;
  668. } else {
  669. fm_set_msg('File not found', 'error');
  670. }
  671. if (($ext == "zip" && !class_exists('ZipArchive')) || ($ext == "tar" && !class_exists('PharData'))) {
  672. fm_set_msg('Operations with archives are not available', 'error');
  673. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  674. }
  675. if ($isValid) {
  676. //to folder
  677. $tofolder = '';
  678. if (isset($_GET['tofolder'])) {
  679. $tofolder = pathinfo($zip_path, PATHINFO_FILENAME);
  680. if (fm_mkdir($path . '/' . $tofolder, true)) {
  681. $path .= '/' . $tofolder;
  682. }
  683. }
  684. if($ext == "zip") {
  685. $zipper = new FM_Zipper();
  686. $res = $zipper->unzip($zip_path, $path);
  687. } elseif ($ext == "tar") {
  688. $gzipper = new PharData($zip_path);
  689. $res = $gzipper->extractTo($path);
  690. }
  691. if ($res) {
  692. fm_set_msg('Archive unpacked');
  693. } else {
  694. fm_set_msg('Archive not unpacked', 'error');
  695. }
  696. } else {
  697. fm_set_msg('File not found', 'error');
  698. }
  699. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  700. }
  701. // Change Perms (not for Windows)
  702. if (isset($_POST['chmod']) && !FM_READONLY && !FM_IS_WIN) {
  703. $path = FM_ROOT_PATH;
  704. if (FM_PATH != '') {
  705. $path .= '/' . FM_PATH;
  706. }
  707. $file = $_POST['chmod'];
  708. $file = fm_clean_path($file);
  709. $file = str_replace('/', '', $file);
  710. if ($file == '' || (!is_file($path . '/' . $file) && !is_dir($path . '/' . $file))) {
  711. fm_set_msg('File not found', 'error');
  712. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  713. }
  714. $mode = 0;
  715. if (!empty($_POST['ur'])) {
  716. $mode |= 0400;
  717. }
  718. if (!empty($_POST['uw'])) {
  719. $mode |= 0200;
  720. }
  721. if (!empty($_POST['ux'])) {
  722. $mode |= 0100;
  723. }
  724. if (!empty($_POST['gr'])) {
  725. $mode |= 0040;
  726. }
  727. if (!empty($_POST['gw'])) {
  728. $mode |= 0020;
  729. }
  730. if (!empty($_POST['gx'])) {
  731. $mode |= 0010;
  732. }
  733. if (!empty($_POST['or'])) {
  734. $mode |= 0004;
  735. }
  736. if (!empty($_POST['ow'])) {
  737. $mode |= 0002;
  738. }
  739. if (!empty($_POST['ox'])) {
  740. $mode |= 0001;
  741. }
  742. if (@chmod($path . '/' . $file, $mode)) {
  743. fm_set_msg('Permissions changed');
  744. } else {
  745. fm_set_msg('Permissions not changed', 'error');
  746. }
  747. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  748. }
  749. /*************************** /ACTIONS ***************************/
  750. // get current path
  751. $path = FM_ROOT_PATH;
  752. if (FM_PATH != '') {
  753. $path .= '/' . FM_PATH;
  754. }
  755. // check path
  756. if (!is_dir($path)) {
  757. fm_redirect(FM_SELF_URL . '?p=');
  758. }
  759. // get parent folder
  760. $parent = fm_get_parent_path(FM_PATH);
  761. $objects = is_readable($path) ? scandir($path) : array();
  762. $folders = array();
  763. $files = array();
  764. if (is_array($objects)) {
  765. foreach ($objects as $file) {
  766. if ($file == '.' || $file == '..' && in_array($file, $GLOBALS['exclude_items'])) {
  767. continue;
  768. }
  769. if (!FM_SHOW_HIDDEN && substr($file, 0, 1) === '.') {
  770. continue;
  771. }
  772. $new_path = $path . '/' . $file;
  773. if (@is_file($new_path) && !in_array($file, $GLOBALS['exclude_items'])) {
  774. $files[] = $file;
  775. } elseif (@is_dir($new_path) && $file != '.' && $file != '..' && !in_array($file, $GLOBALS['exclude_items'])) {
  776. $folders[] = $file;
  777. }
  778. }
  779. }
  780. if (!empty($files)) {
  781. natcasesort($files);
  782. }
  783. if (!empty($folders)) {
  784. natcasesort($folders);
  785. }
  786. // upload form
  787. if (isset($_GET['upload']) && !FM_READONLY) {
  788. fm_show_header(); // HEADER
  789. fm_show_nav_path(FM_PATH); // current path
  790. ?>
  791. <link href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/min/dropzone.min.css" rel="stylesheet">
  792. <div class="path">
  793. <div class="card mb-2 fm-upload-wrapper">
  794. <div class="card-header">
  795. <ul class="nav nav-tabs card-header-tabs">
  796. <li class="nav-item">
  797. <a class="nav-link active" href="#fileUploader" data-target="#fileUploader"><i class="fa fa-arrow-circle-o-up"></i> <?php echo lng('UploadingFiles') ?></a>
  798. </li>
  799. <li class="nav-item">
  800. <a class="nav-link" href="#urlUploader" class="js-url-upload" data-target="#urlUploader"><i class="fa fa-link"></i> Upload from URL</a>
  801. </li>
  802. </ul>
  803. </div>
  804. <div class="card-body">
  805. <p class="card-text">
  806. <a href="?p=<?php echo FM_PATH ?>" class="float-right"><i class="fa fa-chevron-circle-left go-back"></i> <?php echo lng('Back')?></a>
  807. <?php echo lng('DestinationFolder') ?>: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH)) ?>
  808. </p>
  809. <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]) . '?p=' . fm_enc(FM_PATH) ?>" class="dropzone card-tabs-container" id="fileUploader" enctype="multipart/form-data">
  810. <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
  811. <input type="hidden" name="fullpath" id="fullpath" value="<?php echo fm_enc(FM_PATH) ?>">
  812. <div class="fallback">
  813. <input name="file" type="file" multiple/>
  814. </div>
  815. </form>
  816. <div class="upload-url-wrapper card-tabs-container hidden" id="urlUploader">
  817. <form id="js-form-url-upload" class="form-inline" onsubmit="return upload_from_url(this);" method="POST" action="">
  818. <input type="hidden" name="type" value="upload" aria-label="hidden" aria-hidden="true">
  819. <input type="url" placeholder="URL" name="uploadurl" required class="form-control" style="width: 80%">
  820. <button type="submit" class="btn btn-primary ml-3"><?php echo lng('Upload') ?></button>
  821. <div class="lds-facebook"><div></div><div></div><div></div></div>
  822. </form>
  823. <div id="js-url-upload__list" class="col-9 mt-3"></div>
  824. </div>
  825. </div>
  826. </div>
  827. </div>
  828. <script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/min/dropzone.min.js"></script>
  829. <script>
  830. Dropzone.options.fileUploader = {
  831. timeout: 120000,
  832. maxFilesize: <?php echo MAX_UPLOAD_SIZE; ?>,
  833. init: function () {
  834. this.on("sending", function (file, xhr, formData) {
  835. let _path = (file.fullPath) ? file.fullPath : file.name;
  836. document.getElementById("fullpath").value = _path;
  837. xhr.ontimeout = (function() {
  838. alert('Error: Server Timeout');
  839. });
  840. }).on("success", function (res) {
  841. console.log('Upload Status >> ', res.status);
  842. }).on("error", function(file, response) {
  843. alert(response);
  844. });
  845. }
  846. }
  847. </script>
  848. <?php
  849. fm_show_footer();
  850. exit;
  851. }
  852. // copy form POST
  853. if (isset($_POST['copy']) && !FM_READONLY) {
  854. $copy_files = $_POST['file'];
  855. if (!is_array($copy_files) || empty($copy_files)) {
  856. fm_set_msg('Nothing selected', 'alert');
  857. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  858. }
  859. fm_show_header(); // HEADER
  860. fm_show_nav_path(FM_PATH); // current path
  861. ?>
  862. <div class="path">
  863. <div class="card">
  864. <div class="card-header">
  865. <h6><?php echo lng('Copying') ?></h6>
  866. </div>
  867. <div class="card-body">
  868. <form action="" method="post">
  869. <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
  870. <input type="hidden" name="finish" value="1">
  871. <?php
  872. foreach ($copy_files as $cf) {
  873. echo '<input type="hidden" name="file[]" value="' . fm_enc($cf) . '">' . PHP_EOL;
  874. }
  875. ?>
  876. <p class="break-word"><?php echo lng('Files') ?>: <b><?php echo implode('</b>, <b>', $copy_files) ?></b></p>
  877. <p class="break-word"><?php echo lng('SourceFolder') ?>: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH)) ?><br>
  878. <label for="inp_copy_to"><?php echo lng('DestinationFolder') ?>:</label>
  879. <?php echo FM_ROOT_PATH ?>/<input type="text" name="copy_to" id="inp_copy_to" value="<?php echo fm_enc(FM_PATH) ?>">
  880. </p>
  881. <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>
  882. <p>
  883. <button type="submit" class="btn btn-success"><i class="fa fa-check-circle"></i> <?php echo lng('Copy') ?></button> &nbsp;
  884. <b><a href="?p=<?php echo urlencode(FM_PATH) ?>" class="btn btn-outline-primary"><i class="fa fa-times-circle"></i> <?php echo lng('Cancel') ?></a></b>
  885. </p>
  886. </form>
  887. </div>
  888. </div>
  889. </div>
  890. <?php
  891. fm_show_footer();
  892. exit;
  893. }
  894. // copy form
  895. if (isset($_GET['copy']) && !isset($_GET['finish']) && !FM_READONLY) {
  896. $copy = $_GET['copy'];
  897. $copy = fm_clean_path($copy);
  898. if ($copy == '' || !file_exists(FM_ROOT_PATH . '/' . $copy)) {
  899. fm_set_msg('File not found', 'error');
  900. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  901. }
  902. fm_show_header(); // HEADER
  903. fm_show_nav_path(FM_PATH); // current path
  904. ?>
  905. <div class="path">
  906. <p><b>Copying</b></p>
  907. <p class="break-word">
  908. Source path: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . $copy)) ?><br>
  909. Destination folder: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH)) ?>
  910. </p>
  911. <p>
  912. <b><a href="?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;
  913. <b><a href="?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;
  914. <b><a href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="fa fa-times-circle"></i> Cancel</a></b>
  915. </p>
  916. <p><i>Select folder</i></p>
  917. <ul class="folders break-word">
  918. <?php
  919. if ($parent !== false) {
  920. ?>
  921. <li><a href="?p=<?php echo urlencode($parent) ?>&amp;copy=<?php echo urlencode($copy) ?>"><i class="fa fa-chevron-circle-left"></i> ..</a></li>
  922. <?php
  923. }
  924. foreach ($folders as $f) {
  925. ?>
  926. <li>
  927. <a href="?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>
  928. <?php
  929. }
  930. ?>
  931. </ul>
  932. </div>
  933. <?php
  934. fm_show_footer();
  935. exit;
  936. }
  937. if (isset($_GET['settings']) && !FM_READONLY) {
  938. fm_show_header(); // HEADER
  939. fm_show_nav_path(FM_PATH); // current path
  940. global $cfg, $lang, $lang_list;
  941. ?>
  942. <div class="col-md-8 offset-md-2 pt-3">
  943. <div class="card mb-2">
  944. <h6 class="card-header">
  945. <i class="fa fa-cog"></i> <?php echo lng('Settings') ?>
  946. <a href="?p=<?php echo FM_PATH ?>" class="float-right"><i class="fa fa-window-close"></i> <?php echo lng('Cancel')?></a>
  947. </h6>
  948. <div class="card-body">
  949. <form id="js-settings-form" action="" method="post" data-type="ajax" onsubmit="return save_settings(this)">
  950. <input type="hidden" name="type" value="settings" aria-label="hidden" aria-hidden="true">
  951. <div class="form-group row">
  952. <label for="js-language" class="col-sm-3 col-form-label"><?php echo lng('Language') ?></label>
  953. <div class="col-sm-5">
  954. <select class="form-control" id="js-language" name="js-language">
  955. <?php
  956. function getSelected($l) {
  957. global $lang;
  958. return ($lang == $l) ? 'selected' : '';
  959. }
  960. foreach ($lang_list as $k => $v) {
  961. echo "<option value='$k' ".getSelected($k).">$v</option>";
  962. }
  963. ?>
  964. </select>
  965. </div>
  966. </div>
  967. <?php
  968. //get ON/OFF and active class
  969. function getChecked($conf, $val, $txt) {
  970. if($conf== 1 && $val ==1) {
  971. return $txt;
  972. } else if($conf == '' && $val == '') {
  973. return $txt;
  974. } else {
  975. return '';
  976. }
  977. }
  978. ?>
  979. <div class="form-group row">
  980. <label for="js-err-rpt-1" class="col-sm-3 col-form-label"><?php echo lng('ErrorReporting') ?></label>
  981. <div class="col-sm-9">
  982. <div class="btn-group btn-group-toggle" data-toggle="buttons">
  983. <label class="btn btn-secondary <?php echo getChecked($report_errors, 1, 'active') ?>">
  984. <input type="radio" name="js-error-report" id="js-err-rpt-1" autocomplete="off" value="true" <?php echo getChecked($report_errors, 1, 'checked') ?> > ON
  985. </label>
  986. <label class="btn btn-secondary <?php echo getChecked($report_errors, '', 'active') ?>">
  987. <input type="radio" name="js-error-report" id="js-err-rpt-0" autocomplete="off" value="false" <?php echo getChecked($report_errors, '', 'checked') ?> > OFF
  988. </label>
  989. </div>
  990. </div>
  991. </div>
  992. <div class="form-group row">
  993. <label for="js-hdn-1" class="col-sm-3 col-form-label"><?php echo lng('ShowHiddenFiles') ?></label>
  994. <div class="col-sm-9">
  995. <div class="btn-group btn-group-toggle" data-toggle="buttons">
  996. <label class="btn btn-secondary <?php echo getChecked($show_hidden_files, 1, 'active') ?>">
  997. <input type="radio" name="js-show-hidden" id="js-hdn-1" autocomplete="off" value="true" <?php echo getChecked($show_hidden_files, 1, 'checked') ?> > ON
  998. </label>
  999. <label class="btn btn-secondary <?php echo getChecked($show_hidden_files, '', 'active') ?>">
  1000. <input type="radio" name="js-show-hidden" id="js-hdn-0" autocomplete="off" value="false" <?php echo getChecked($show_hidden_files, '', 'checked') ?> > OFF
  1001. </label>
  1002. </div>
  1003. </div>
  1004. </div>
  1005. <div class="form-group row">
  1006. <div class="col-sm-10">
  1007. <button type="submit" class="btn btn-success"> <i class="fa fa-check-circle"></i> <?php echo lng('Save'); ?></button>
  1008. </div>
  1009. </div>
  1010. </form>
  1011. </div>
  1012. </div>
  1013. </div>
  1014. <?php
  1015. fm_show_footer();
  1016. exit;
  1017. }
  1018. if (isset($_GET['help'])) {
  1019. fm_show_header(); // HEADER
  1020. fm_show_nav_path(FM_PATH); // current path
  1021. global $cfg, $lang;
  1022. ?>
  1023. <div class="col-md-8 offset-md-2 pt-3">
  1024. <div class="card mb-2">
  1025. <h6 class="card-header">
  1026. <i class="fa fa-exclamation-circle"></i> <?php echo lng('Help') ?>
  1027. <a href="?p=<?php echo FM_PATH ?>" class="float-right"><i class="fa fa-window-close"></i> <?php echo lng('Cancel')?></a>
  1028. </h6>
  1029. <div class="card-body">
  1030. <div class="row">
  1031. <div class="col-xs-12 col-sm-6">
  1032. <p><h3><a href="https://github.com/prasathmani/tinyfilemanager" target="_blank" class="app-v-title"> Tiny File Manager <?php echo VERSION; ?></a></h3></p>
  1033. <p>Author: Prasath Mani</p>
  1034. <p>Mail Us: <a href="mailto:ccpprogrammers@gmail.com">ccpprogrammers[at]gmail.com</a> </p>
  1035. </div>
  1036. <div class="col-xs-12 col-sm-6">
  1037. <div class="card">
  1038. <ul class="list-group list-group-flush">
  1039. <li class="list-group-item"><a href="https://tinyfilemanager.github.io/" target="_blank"><i class="fa fa-question-circle"></i> Help Documents</a> </li>
  1040. <li class="list-group-item"><a href="https://github.com/prasathmani/tinyfilemanager/issues" target="_blank"><i class="fa fa-bug"></i> Report Issue</a></li>
  1041. <li class="list-group-item"><a href="javascript:latest_release_info('<?php echo VERSION; ?>');" target="_blank"><i class="fa fa-link"></i> Check Latest Version</a></li>
  1042. <?php if(!FM_READONLY) { ?>
  1043. <li class="list-group-item"><a href="javascript:show_new_pwd();" target="_blank"><i class="fa fa-lock"></i> Generate new password hash</a></li>
  1044. <?php } ?>
  1045. </ul>
  1046. </div>
  1047. </div>
  1048. </div>
  1049. <div class="row js-new-pwd hidden mt-2">
  1050. <div class="col-12">
  1051. <form class="form-inline" onsubmit="return new_password_hash(this)" method="POST" action="">
  1052. <input type="hidden" name="type" value="pwdhash" aria-label="hidden" aria-hidden="true">
  1053. <div class="form-group mb-2">
  1054. <label for="staticEmail2">Generate new password hash</label>
  1055. </div>
  1056. <div class="form-group mx-sm-3 mb-2">
  1057. <label for="inputPassword2" class="sr-only">Password</label>
  1058. <input type="text" class="form-control btn-sm" id="inputPassword2" name="inputPassword2" placeholder="Password" required>
  1059. </div>
  1060. <button type="submit" class="btn btn-success btn-sm mb-2">Generate</button>
  1061. </form>
  1062. <textarea class="form-control" rows="2" readonly id="js-pwd-result"></textarea>
  1063. </div>
  1064. </div>
  1065. </div>
  1066. </div>
  1067. </div>
  1068. <?php
  1069. fm_show_footer();
  1070. exit;
  1071. }
  1072. // file viewer
  1073. if (isset($_GET['view'])) {
  1074. $file = $_GET['view'];
  1075. $quickView = (isset($_GET['quickView']) && $_GET['quickView'] == 1) ? true : false;
  1076. $file = fm_clean_path($file);
  1077. $file = str_replace('/', '', $file);
  1078. if ($file == '' || !is_file($path . '/' . $file)) {
  1079. fm_set_msg('File not found', 'error');
  1080. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1081. }
  1082. if(!$quickView) {
  1083. fm_show_header(); // HEADER
  1084. fm_show_nav_path(FM_PATH); // current path
  1085. }
  1086. $file_url = FM_ROOT_URL . fm_convert_win((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file);
  1087. $file_path = $path . '/' . $file;
  1088. $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
  1089. $mime_type = fm_get_mime_type($file_path);
  1090. $filesize = fm_get_filesize(filesize($file_path));
  1091. $is_zip = false;
  1092. $is_gzip = false;
  1093. $is_image = false;
  1094. $is_audio = false;
  1095. $is_video = false;
  1096. $is_text = false;
  1097. $is_onlineViewer = false;
  1098. $view_title = 'File';
  1099. $filenames = false; // for zip
  1100. $content = ''; // for text
  1101. if($GLOBALS['online_viewer'] && in_array($ext, fm_get_onlineViewer_exts())){
  1102. $is_onlineViewer = true;
  1103. }
  1104. elseif ($ext == 'zip' || $ext == 'tar') {
  1105. $is_zip = true;
  1106. $view_title = 'Archive';
  1107. $filenames = fm_get_zif_info($file_path, $ext);
  1108. } elseif (in_array($ext, fm_get_image_exts())) {
  1109. $is_image = true;
  1110. $view_title = 'Image';
  1111. } elseif (in_array($ext, fm_get_audio_exts())) {
  1112. $is_audio = true;
  1113. $view_title = 'Audio';
  1114. } elseif (in_array($ext, fm_get_video_exts())) {
  1115. $is_video = true;
  1116. $view_title = 'Video';
  1117. } elseif (in_array($ext, fm_get_text_exts()) || substr($mime_type, 0, 4) == 'text' || in_array($mime_type, fm_get_text_mimes())) {
  1118. $is_text = true;
  1119. $content = file_get_contents($file_path);
  1120. }
  1121. ?>
  1122. <div class="row">
  1123. <div class="col-12">
  1124. <?php if(!$quickView) { ?>
  1125. <p class="break-word"><b><?php echo $view_title ?> "<?php echo fm_enc(fm_convert_win($file)) ?>"</b></p>
  1126. <p class="break-word">
  1127. Full path: <?php echo fm_enc(fm_convert_win($file_path)) ?><br>
  1128. File
  1129. size: <?php echo fm_get_filesize($filesize) ?><?php if ($filesize >= 1000): ?> (<?php echo sprintf('%s bytes', $filesize) ?>)<?php endif; ?>
  1130. <br>
  1131. MIME-type: <?php echo $mime_type ?><br>
  1132. <?php
  1133. // ZIP info
  1134. if (($is_zip || $is_gzip) && $filenames !== false) {
  1135. $total_files = 0;
  1136. $total_comp = 0;
  1137. $total_uncomp = 0;
  1138. foreach ($filenames as $fn) {
  1139. if (!$fn['folder']) {
  1140. $total_files++;
  1141. }
  1142. $total_comp += $fn['compressed_size'];
  1143. $total_uncomp += $fn['filesize'];
  1144. }
  1145. ?>
  1146. Files in archive: <?php echo $total_files ?><br>
  1147. Total size: <?php echo fm_get_filesize($total_uncomp) ?><br>
  1148. Size in archive: <?php echo fm_get_filesize($total_comp) ?><br>
  1149. Compression: <?php echo round(($total_comp / $total_uncomp) * 100) ?>%<br>
  1150. <?php
  1151. }
  1152. // Image info
  1153. if ($is_image) {
  1154. $image_size = getimagesize($file_path);
  1155. echo 'Image sizes: ' . (isset($image_size[0]) ? $image_size[0] : '0') . ' x ' . (isset($image_size[1]) ? $image_size[1] : '0') . '<br>';
  1156. }
  1157. // Text info
  1158. if ($is_text) {
  1159. $is_utf8 = fm_is_utf8($content);
  1160. if (function_exists('iconv')) {
  1161. if (!$is_utf8) {
  1162. $content = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $content);
  1163. }
  1164. }
  1165. echo 'Charset: ' . ($is_utf8 ? 'utf-8' : '8 bit') . '<br>';
  1166. }
  1167. ?>
  1168. </p>
  1169. <p>
  1170. <b><a href="?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;
  1171. <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>
  1172. &nbsp;
  1173. <?php
  1174. // ZIP actions
  1175. if (!FM_READONLY && ($is_zip || $is_gzip) && $filenames !== false) {
  1176. $zip_name = pathinfo($file_path, PATHINFO_FILENAME);
  1177. ?>
  1178. <b><a href="?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;
  1179. <b><a href="?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>
  1180. <?php echo lng('UnZipToFolder') ?></a></b> &nbsp;
  1181. <?php
  1182. }
  1183. if ($is_text && !FM_READONLY) {
  1184. ?>
  1185. <b><a href="?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') ?>
  1186. </a></b> &nbsp;
  1187. <b><a href="?p=<?php echo urlencode(trim(FM_PATH)) ?>&amp;edit=<?php echo urlencode($file) ?>&env=ace"
  1188. class="edit-file"><i class="fa fa-pencil-square-o"></i> <?php echo lng('AdvancedEditor') ?>
  1189. </a></b> &nbsp;
  1190. <?php } ?>
  1191. <b><a href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="fa fa-chevron-circle-left go-back"></i> <?php echo lng('Back') ?></a></b>
  1192. </p>
  1193. <?php
  1194. }
  1195. if($is_onlineViewer) {
  1196. // Google docs viewer
  1197. 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>';
  1198. } elseif ($is_zip) {
  1199. // ZIP content
  1200. if ($filenames !== false) {
  1201. echo '<code class="maxheight">';
  1202. foreach ($filenames as $fn) {
  1203. if ($fn['folder']) {
  1204. echo '<b>' . fm_enc($fn['name']) . '</b><br>';
  1205. } else {
  1206. echo $fn['name'] . ' (' . fm_get_filesize($fn['filesize']) . ')<br>';
  1207. }
  1208. }
  1209. echo '</code>';
  1210. } else {
  1211. echo '<p>Error while fetching archive info</p>';
  1212. }
  1213. } elseif ($is_image) {
  1214. // Image content
  1215. if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico', 'svg'))) {
  1216. echo '<p><img src="' . fm_enc($file_url) . '" alt="" class="preview-img"></p>';
  1217. }
  1218. } elseif ($is_audio) {
  1219. // Audio content
  1220. echo '<p><audio src="' . fm_enc($file_url) . '" controls preload="metadata"></audio></p>';
  1221. } elseif ($is_video) {
  1222. // Video content
  1223. echo '<div class="preview-video"><video src="' . fm_enc($file_url) . '" width="640" height="360" controls preload="metadata"></video></div>';
  1224. } elseif ($is_text) {
  1225. if (FM_USE_HIGHLIGHTJS) {
  1226. // highlight
  1227. $hljs_classes = array(
  1228. 'shtml' => 'xml',
  1229. 'htaccess' => 'apache',
  1230. 'phtml' => 'php',
  1231. 'lock' => 'json',
  1232. 'svg' => 'xml',
  1233. );
  1234. $hljs_class = isset($hljs_classes[$ext]) ? 'lang-' . $hljs_classes[$ext] : 'lang-' . $ext;
  1235. if (empty($ext) || in_array(strtolower($file), fm_get_text_names()) || preg_match('#\.min\.(css|js)$#i', $file)) {
  1236. $hljs_class = 'nohighlight';
  1237. }
  1238. $content = '<pre class="with-hljs"><code class="' . $hljs_class . '">' . fm_enc($content) . '</code></pre>';
  1239. } elseif (in_array($ext, array('php', 'php4', 'php5', 'phtml', 'phps'))) {
  1240. // php highlight
  1241. $content = highlight_string($content, true);
  1242. } else {
  1243. $content = '<pre>' . fm_enc($content) . '</pre>';
  1244. }
  1245. echo $content;
  1246. }
  1247. ?>
  1248. </div>
  1249. </div>
  1250. <?php
  1251. if(!$quickView) {
  1252. fm_show_footer();
  1253. }
  1254. exit;
  1255. }
  1256. // file editor
  1257. if (isset($_GET['edit'])) {
  1258. $file = $_GET['edit'];
  1259. $file = fm_clean_path($file);
  1260. $file = str_replace('/', '', $file);
  1261. if ($file == '' || !is_file($path . '/' . $file)) {
  1262. fm_set_msg('File not found', 'error');
  1263. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1264. }
  1265. header('X-XSS-Protection:0');
  1266. fm_show_header(); // HEADER
  1267. fm_show_nav_path(FM_PATH); // current path
  1268. $file_url = FM_ROOT_URL . fm_convert_win((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file);
  1269. $file_path = $path . '/' . $file;
  1270. // normal editer
  1271. $isNormalEditor = true;
  1272. if (isset($_GET['env'])) {
  1273. if ($_GET['env'] == "ace") {
  1274. $isNormalEditor = false;
  1275. }
  1276. }
  1277. // Save File
  1278. if (isset($_POST['savedata'])) {
  1279. $writedata = $_POST['savedata'];
  1280. $fd = fopen($file_path, "w");
  1281. @fwrite($fd, $writedata);
  1282. fclose($fd);
  1283. fm_set_msg('File Saved Successfully');
  1284. }
  1285. $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
  1286. $mime_type = fm_get_mime_type($file_path);
  1287. $filesize = filesize($file_path);
  1288. $is_text = false;
  1289. $content = ''; // for text
  1290. if (in_array($ext, fm_get_text_exts()) || substr($mime_type, 0, 4) == 'text' || in_array($mime_type, fm_get_text_mimes())) {
  1291. $is_text = true;
  1292. $content = file_get_contents($file_path);
  1293. }
  1294. ?>
  1295. <div class="path">
  1296. <div class="row">
  1297. <div class="col-xs-12 col-sm-5 col-lg-6 pt-1">
  1298. <div class="btn-toolbar" role="toolbar">
  1299. <?php if (!$isNormalEditor) { ?>
  1300. <div class="btn-group js-ace-toolbar">
  1301. <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>
  1302. <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>
  1303. <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>
  1304. <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>
  1305. <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>
  1306. <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>
  1307. <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>
  1308. <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>
  1309. </div>
  1310. <?php } ?>
  1311. </div>
  1312. </div>
  1313. <div class="edit-file-actions col-xs-12 col-sm-7 col-lg-6 text-right pt-1">
  1314. <a title="Back" class="btn btn-sm btn-outline-primary" href="?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>
  1315. <a title="Backup" class="btn btn-sm btn-outline-primary" href="javascript:backup('<?php echo urlencode($path) ?>','<?php echo urlencode($file) ?>')"><i class="fa fa-database"></i> <?php echo lng('BackUp') ?></a>
  1316. <?php if ($is_text) { ?>
  1317. <?php if ($isNormalEditor) { ?>
  1318. <a title="Advanced" class="btn btn-sm btn-outline-primary" href="?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>
  1319. <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
  1320. </button>
  1321. <?php } else { ?>
  1322. <a title="Plain Editor" class="btn btn-sm btn-outline-primary" href="?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>
  1323. <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') ?>
  1324. </button>
  1325. <?php } ?>
  1326. <?php } ?>
  1327. </div>
  1328. </div>
  1329. <?php
  1330. if ($is_text && $isNormalEditor) {
  1331. echo '<textarea class="mt-2" id="normal-editor" rows="33" cols="120" style="width: 99.5%;">' . htmlspecialchars($content) . '</textarea>';
  1332. } elseif ($is_text) {
  1333. echo '<div id="editor" contenteditable="true">' . htmlspecialchars($content) . '</div>';
  1334. } else {
  1335. fm_set_msg('FILE EXTENSION HAS NOT SUPPORTED', 'error');
  1336. }
  1337. ?>
  1338. </div>
  1339. <?php
  1340. fm_show_footer();
  1341. exit;
  1342. }
  1343. // chmod (not for Windows)
  1344. if (isset($_GET['chmod']) && !FM_READONLY && !FM_IS_WIN) {
  1345. $file = $_GET['chmod'];
  1346. $file = fm_clean_path($file);
  1347. $file = str_replace('/', '', $file);
  1348. if ($file == '' || (!is_file($path . '/' . $file) && !is_dir($path . '/' . $file))) {
  1349. fm_set_msg('File not found', 'error');
  1350. fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1351. }
  1352. fm_show_header(); // HEADER
  1353. fm_show_nav_path(FM_PATH); // current path
  1354. $file_url = FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file;
  1355. $file_path = $path . '/' . $file;
  1356. $mode = fileperms($path . '/' . $file);
  1357. ?>
  1358. <div class="path">
  1359. <div class="card mb-2">
  1360. <h6 class="card-header">
  1361. <?php echo lng('ChangePermissions') ?>
  1362. </h6>
  1363. <div class="card-body">
  1364. <p class="card-text">
  1365. Full path: <?php echo $file_path ?><br>
  1366. </p>
  1367. <form action="" method="post">
  1368. <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
  1369. <input type="hidden" name="chmod" value="<?php echo fm_enc($file) ?>">
  1370. <table class="table compact-table">
  1371. <tr>
  1372. <td></td>
  1373. <td><b><?php echo lng('Owner') ?></b></td>
  1374. <td><b><?php echo lng('Group') ?></b></td>
  1375. <td><b><?php echo lng('Other') ?></b></td>
  1376. </tr>
  1377. <tr>
  1378. <td style="text-align: right"><b><?php echo lng('Read') ?></b></td>
  1379. <td><label><input type="checkbox" name="ur" value="1"<?php echo ($mode & 00400) ? ' checked' : '' ?>></label></td>
  1380. <td><label><input type="checkbox" name="gr" value="1"<?php echo ($mode & 00040) ? ' checked' : '' ?>></label></td>
  1381. <td><label><input type="checkbox" name="or" value="1"<?php echo ($mode & 00004) ? ' checked' : '' ?>></label></td>
  1382. </tr>
  1383. <tr>
  1384. <td style="text-align: right"><b><?php echo lng('Write') ?></b></td>
  1385. <td><label><input type="checkbox" name="uw" value="1"<?php echo ($mode & 00200) ? ' checked' : '' ?>></label></td>
  1386. <td><label><input type="checkbox" name="gw" value="1"<?php echo ($mode & 00020) ? ' checked' : '' ?>></label></td>
  1387. <td><label><input type="checkbox" name="ow" value="1"<?php echo ($mode & 00002) ? ' checked' : '' ?>></label></td>
  1388. </tr>
  1389. <tr>
  1390. <td style="text-align: right"><b><?php echo lng('Execute') ?></b></td>
  1391. <td><label><input type="checkbox" name="ux" value="1"<?php echo ($mode & 00100) ? ' checked' : '' ?>></label></td>
  1392. <td><label><input type="checkbox" name="gx" value="1"<?php echo ($mode & 00010) ? ' checked' : '' ?>></label></td>
  1393. <td><label><input type="checkbox" name="ox" value="1"<?php echo ($mode & 00001) ? ' checked' : '' ?>></label></td>
  1394. </tr>
  1395. </table>
  1396. <p>
  1397. <button type="submit" class="btn btn-success"><i class="fa fa-check-circle"></i> <?php echo lng('Change') ?></button> &nbsp;
  1398. <b><a href="?p=<?php echo urlencode(FM_PATH) ?>" class="btn btn-outline-primary"><i class="fa fa-times-circle"></i> <?php echo lng('Cancel') ?></a></b>
  1399. </p>
  1400. </form>
  1401. </div>
  1402. </div>
  1403. </div>
  1404. <?php
  1405. fm_show_footer();
  1406. exit;
  1407. }
  1408. //--- FILEMANAGER MAIN
  1409. fm_show_header(); // HEADER
  1410. fm_show_nav_path(FM_PATH); // current path
  1411. // messages
  1412. fm_show_message();
  1413. $num_files = count($files);
  1414. $num_folders = count($folders);
  1415. $all_files_size = 0;
  1416. ?>
  1417. <form action="" method="post" class="pt-3">
  1418. <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
  1419. <input type="hidden" name="group" value="1">
  1420. <div class="table-responsive">
  1421. <table class="table table-bordered table-hover table-sm bg-white" id="main-table">
  1422. <thead class="thead-white">
  1423. <tr>
  1424. <?php if (!FM_READONLY): ?>
  1425. <th style="width:3%" class="custom-checkbox-header">
  1426. <div class="custom-control custom-checkbox">
  1427. <input type="checkbox" class="custom-control-input" id="js-select-all-items" onclick="checkbox_toggle()">
  1428. <label class="custom-control-label" for="js-select-all-items"></label>
  1429. </div>
  1430. </th><?php endif; ?>
  1431. <th><?php echo lng('Name') ?></th>
  1432. <th><?php echo lng('Size') ?></th>
  1433. <th><?php echo lng('Modified') ?></th>
  1434. <?php if (!FM_IS_WIN): ?>
  1435. <th><?php echo lng('Perms') ?></th>
  1436. <th><?php echo lng('Owner') ?></th><?php endif; ?>
  1437. <th><?php echo lng('Actions') ?></th>
  1438. </tr>
  1439. </thead>
  1440. <?php
  1441. // link to parent folder
  1442. if ($parent !== false) {
  1443. ?>
  1444. <tr><?php if (!FM_READONLY): ?>
  1445. <td class="nosort"></td><?php endif; ?>
  1446. <td class="border-0"><a href="?p=<?php echo urlencode($parent) ?>"><i class="fa fa-chevron-circle-left go-back"></i> ..</a></td>
  1447. <td class="border-0"></td>
  1448. <td class="border-0"></td>
  1449. <td class="border-0"></td>
  1450. <?php if (!FM_IS_WIN) { ?>
  1451. <td class="border-0"></td>
  1452. <td class="border-0"></td>
  1453. <?php } ?>
  1454. </tr>
  1455. <?php
  1456. }
  1457. $ii = 3399;
  1458. foreach ($folders as $f) {
  1459. $is_link = is_link($path . '/' . $f);
  1460. $img = $is_link ? 'icon-link_folder' : 'fa fa-folder-o';
  1461. $modif = date(FM_DATETIME_FORMAT, filemtime($path . '/' . $f));
  1462. $perms = substr(decoct(fileperms($path . '/' . $f)), -4);
  1463. if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
  1464. $owner = posix_getpwuid(fileowner($path . '/' . $f));
  1465. $group = posix_getgrgid(filegroup($path . '/' . $f));
  1466. } else {
  1467. $owner = array('name' => '?');
  1468. $group = array('name' => '?');
  1469. }
  1470. ?>
  1471. <tr>
  1472. <?php if (!FM_READONLY): ?>
  1473. <td class="custom-checkbox-td">
  1474. <div class="custom-control custom-checkbox">
  1475. <input type="checkbox" class="custom-control-input" id="<?php echo $ii ?>" name="file[]" value="<?php echo fm_enc($f) ?>">
  1476. <label class="custom-control-label" for="<?php echo $ii ?>"></label>
  1477. </div>
  1478. </td><?php endif; ?>
  1479. <td>
  1480. <div class="filename"><a href="?p=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="<?php echo $img ?>"></i> <?php echo fm_convert_win($f) ?>
  1481. </a><?php echo($is_link ? ' &rarr; <i>' . readlink($path . '/' . $f) . '</i>' : '') ?></div>
  1482. </td>
  1483. <td><?php echo lng('Folder') ?></td>
  1484. <td><?php echo $modif ?></td>
  1485. <?php if (!FM_IS_WIN): ?>
  1486. <td><?php if (!FM_READONLY): ?><a title="Change Permissions" href="?p=<?php echo urlencode(FM_PATH) ?>&amp;chmod=<?php echo urlencode($f) ?>"><?php echo $perms ?></a><?php else: ?><?php echo $perms ?><?php endif; ?>
  1487. </td>
  1488. <td><?php echo $owner['name'] . ':' . $group['name'] ?></td>
  1489. <?php endif; ?>
  1490. <td class="inline-actions"><?php if (!FM_READONLY): ?>
  1491. <a title="<?php echo lng('Delete')?>" href="?p=<?php echo urlencode(FM_PATH) ?>&amp;del=<?php echo urlencode($f) ?>" onclick="return confirm('Delete folder?');"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
  1492. <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>
  1493. <a title="<?php echo lng('CopyTo')?>..." href="?p=&amp;copy=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="fa fa-files-o" aria-hidden="true"></i></a>
  1494. <?php endif; ?>
  1495. <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>
  1496. </td>
  1497. </tr>
  1498. <?php
  1499. flush();
  1500. $ii++;
  1501. }
  1502. $ik = 6070;
  1503. foreach ($files as $f) {
  1504. $is_link = is_link($path . '/' . $f);
  1505. $img = $is_link ? 'fa fa-file-text-o' : fm_get_file_icon_class($path . '/' . $f);
  1506. $modif = date(FM_DATETIME_FORMAT, filemtime($path . '/' . $f));
  1507. $filesize_raw = fm_get_size($path . '/' . $f);
  1508. $filesize = fm_get_filesize($filesize_raw);
  1509. $filelink = '?p=' . urlencode(FM_PATH) . '&amp;view=' . urlencode($f);
  1510. $all_files_size += $filesize_raw;
  1511. $perms = substr(decoct(fileperms($path . '/' . $f)), -4);
  1512. if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
  1513. $owner = posix_getpwuid(fileowner($path . '/' . $f));
  1514. $group = posix_getgrgid(filegroup($path . '/' . $f));
  1515. } else {
  1516. $owner = array('name' => '?');
  1517. $group = array('name' => '?');
  1518. }
  1519. ?>
  1520. <tr>
  1521. <?php if (!FM_READONLY): ?>
  1522. <td class="custom-checkbox-td">
  1523. <div class="custom-control custom-checkbox">
  1524. <input type="checkbox" class="custom-control-input" id="<?php echo $ik ?>" name="file[]" value="<?php echo fm_enc($f) ?>">
  1525. <label class="custom-control-label" for="<?php echo $ik ?>"></label>
  1526. </div>
  1527. </td><?php endif; ?>
  1528. <td>
  1529. <div class="filename"><a href="<?php echo $filelink ?>" title="File info"><i class="<?php echo $img ?>"></i> <?php echo fm_convert_win($f) ?>
  1530. </a><?php echo($is_link ? ' &rarr; <i>' . readlink($path . '/' . $f) . '</i>' : '') ?></div>
  1531. </td>
  1532. <td><span title="<?php printf('%s bytes', $filesize_raw) ?>"><?php echo $filesize ?></span></td>
  1533. <td><?php echo $modif ?></td>
  1534. <?php if (!FM_IS_WIN): ?>
  1535. <td><?php if (!FM_READONLY): ?><a title="<?php echo 'Change Permissions' ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&amp;chmod=<?php echo urlencode($f) ?>"><?php echo $perms ?></a><?php else: ?><?php echo $perms ?><?php endif; ?>
  1536. </td>
  1537. <td><?php echo fm_enc($owner['name'] . ':' . $group['name']) ?></td>
  1538. <?php endif; ?>
  1539. <td class="inline-actions">
  1540. <?php if (!FM_READONLY): ?>
  1541. <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>
  1542. <a title="<?php echo lng('Delete') ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&amp;del=<?php echo urlencode($f) ?>" onclick="return confirm('Delete file?');"><i class="fa fa-trash-o"></i></a>
  1543. <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>
  1544. <a title="<?php echo lng('CopyTo') ?>..."
  1545. href="?p=<?php echo urlencode(FM_PATH) ?>&amp;copy=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="fa fa-files-o"></i></a>
  1546. <?php endif; ?>
  1547. <a title="<?php echo lng('DirectLink') ?>" href="<?php echo fm_enc(FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f) ?>" target="_blank"><i class="fa fa-link"></i></a>
  1548. <a title="<?php echo lng('Download') ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&amp;dl=<?php echo urlencode($f) ?>"><i class="fa fa-download"></i></a>
  1549. </td>
  1550. </tr>
  1551. <?php
  1552. flush();
  1553. $ik++;
  1554. }
  1555. if (empty($folders) && empty($files)) {
  1556. ?>
  1557. <tfoot>
  1558. <tr><?php if (!FM_READONLY): ?>
  1559. <td></td><?php endif; ?>
  1560. <td colspan="<?php echo !FM_IS_WIN ? '6' : '4' ?>"><em><?php echo 'Folder is empty' ?></em></td>
  1561. </tr>
  1562. </tfoot>
  1563. <?php
  1564. } else {
  1565. ?>
  1566. <tfoot>
  1567. <tr><?php if (!FM_READONLY): ?>
  1568. <td class="gray"></td><?php endif; ?>
  1569. <td class="gray" colspan="<?php echo !FM_IS_WIN ? '6' : '4' ?>">
  1570. Full size: <span title="<?php printf('%s bytes', $all_files_size) ?>"><?php echo '<span class="badge badge-light">'.fm_get_filesize($all_files_size).'</span>' ?></span>
  1571. <?php echo lng('File').': <span class="badge badge-light">'.$num_files.'</span>' ?>
  1572. <?php echo lng('Folder').': <span class="badge badge-light">'.$num_folders.'</span>' ?>
  1573. <?php echo lng('MemoryUsed').': <span class="badge badge-light">'.fm_get_filesize(@memory_get_usage(true)).'</span>' ?>
  1574. <?php echo lng('PartitionSize').': <span class="badge badge-light">'.fm_get_filesize(@disk_free_space($path)) .'</span> free of <span class="badge badge-light">'.fm_get_filesize(@disk_total_space($path)).'</span>'; ?>
  1575. </td>
  1576. </tr>
  1577. </tfoot>
  1578. <?php
  1579. }
  1580. ?>
  1581. </table>
  1582. </div>
  1583. <div class="row">
  1584. <?php if (!FM_READONLY): ?>
  1585. <div class="col-xs-12 col-sm-9">
  1586. <ul class="list-inline footer-action">
  1587. <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>
  1588. <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>
  1589. <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>
  1590. <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?')">
  1591. <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>
  1592. <li class="list-inline-item"><input type="submit" class="hidden" name="zip" id="a-zip" value="zip" onclick="return confirm('Create archive?')">
  1593. <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>
  1594. <li class="list-inline-item"><input type="submit" class="hidden" name="tar" id="a-tar" value="tar" onclick="return confirm('Create archive?')">
  1595. <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>
  1596. <li class="list-inline-item"><input type="submit" class="hidden" name="copy" id="a-copy" value="Copy">
  1597. <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>
  1598. </ul>
  1599. </div>
  1600. <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>
  1601. <?php else: ?>
  1602. <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>
  1603. <?php endif; ?>
  1604. </div>
  1605. </form>
  1606. <?php
  1607. fm_show_footer();
  1608. //--- END
  1609. // Functions
  1610. /**
  1611. * Delete file or folder (recursively)
  1612. * @param string $path
  1613. * @return bool
  1614. */
  1615. function fm_rdelete($path)
  1616. {
  1617. if (is_link($path)) {
  1618. return unlink($path);
  1619. } elseif (is_dir($path)) {
  1620. $objects = scandir($path);
  1621. $ok = true;
  1622. if (is_array($objects)) {
  1623. foreach ($objects as $file) {
  1624. if ($file != '.' && $file != '..') {
  1625. if (!fm_rdelete($path . '/' . $file)) {
  1626. $ok = false;
  1627. }
  1628. }
  1629. }
  1630. }
  1631. return ($ok) ? rmdir($path) : false;
  1632. } elseif (is_file($path)) {
  1633. return unlink($path);
  1634. }
  1635. return false;
  1636. }
  1637. /**
  1638. * Recursive chmod
  1639. * @param string $path
  1640. * @param int $filemode
  1641. * @param int $dirmode
  1642. * @return bool
  1643. * @todo Will use in mass chmod
  1644. */
  1645. function fm_rchmod($path, $filemode, $dirmode)
  1646. {
  1647. if (is_dir($path)) {
  1648. if (!chmod($path, $dirmode)) {
  1649. return false;
  1650. }
  1651. $objects = scandir($path);
  1652. if (is_array($objects)) {
  1653. foreach ($objects as $file) {
  1654. if ($file != '.' && $file != '..') {
  1655. if (!fm_rchmod($path . '/' . $file, $filemode, $dirmode)) {
  1656. return false;
  1657. }
  1658. }
  1659. }
  1660. }
  1661. return true;
  1662. } elseif (is_link($path)) {
  1663. return true;
  1664. } elseif (is_file($path)) {
  1665. return chmod($path, $filemode);
  1666. }
  1667. return false;
  1668. }
  1669. /**
  1670. * Safely rename
  1671. * @param string $old
  1672. * @param string $new
  1673. * @return bool|null
  1674. */
  1675. function fm_rename($old, $new)
  1676. {
  1677. $allowed = (FM_EXTENSION) ? explode(',', FM_EXTENSION) : false;
  1678. $ext = pathinfo($new, PATHINFO_EXTENSION);
  1679. $isFileAllowed = ($allowed) ? in_array($ext, $allowed) : true;
  1680. if(!$isFileAllowed) return false;
  1681. return (!file_exists($new) && file_exists($old)) ? rename($old, $new) : null;
  1682. }
  1683. /**
  1684. * Copy file or folder (recursively).
  1685. * @param string $path
  1686. * @param string $dest
  1687. * @param bool $upd Update files
  1688. * @param bool $force Create folder with same names instead file
  1689. * @return bool
  1690. */
  1691. function fm_rcopy($path, $dest, $upd = true, $force = true)
  1692. {
  1693. if (is_dir($path)) {
  1694. if (!fm_mkdir($dest, $force)) {
  1695. return false;
  1696. }
  1697. $objects = scandir($path);
  1698. $ok = true;
  1699. if (is_array($objects)) {
  1700. foreach ($objects as $file) {
  1701. if ($file != '.' && $file != '..') {
  1702. if (!fm_rcopy($path . '/' . $file, $dest . '/' . $file)) {
  1703. $ok = false;
  1704. }
  1705. }
  1706. }
  1707. }
  1708. return $ok;
  1709. } elseif (is_file($path)) {
  1710. return fm_copy($path, $dest, $upd);
  1711. }
  1712. return false;
  1713. }
  1714. /**
  1715. * Safely create folder
  1716. * @param string $dir
  1717. * @param bool $force
  1718. * @return bool
  1719. */
  1720. function fm_mkdir($dir, $force)
  1721. {
  1722. if (file_exists($dir)) {
  1723. if (is_dir($dir)) {
  1724. return $dir;
  1725. } elseif (!$force) {
  1726. return false;
  1727. }
  1728. unlink($dir);
  1729. }
  1730. return mkdir($dir, 0777, true);
  1731. }
  1732. /**
  1733. * Safely copy file
  1734. * @param string $f1
  1735. * @param string $f2
  1736. * @param bool $upd
  1737. * @return bool
  1738. */
  1739. function fm_copy($f1, $f2, $upd)
  1740. {
  1741. $time1 = filemtime($f1);
  1742. if (file_exists($f2)) {
  1743. $time2 = filemtime($f2);
  1744. if ($time2 >= $time1 && $upd) {
  1745. return false;
  1746. }
  1747. }
  1748. $ok = copy($f1, $f2);
  1749. if ($ok) {
  1750. touch($f2, $time1);
  1751. }
  1752. return $ok;
  1753. }
  1754. /**
  1755. * Get mime type
  1756. * @param string $file_path
  1757. * @return mixed|string
  1758. */
  1759. function fm_get_mime_type($file_path)
  1760. {
  1761. if (function_exists('finfo_open')) {
  1762. $finfo = finfo_open(FILEINFO_MIME_TYPE);
  1763. $mime = finfo_file($finfo, $file_path);
  1764. finfo_close($finfo);
  1765. return $mime;
  1766. } elseif (function_exists('mime_content_type')) {
  1767. return mime_content_type($file_path);
  1768. } elseif (!stristr(ini_get('disable_functions'), 'shell_exec')) {
  1769. $file = escapeshellarg($file_path);
  1770. $mime = shell_exec('file -bi ' . $file);
  1771. return $mime;
  1772. } else {
  1773. return '--';
  1774. }
  1775. }
  1776. /**
  1777. * HTTP Redirect
  1778. * @param string $url
  1779. * @param int $code
  1780. */
  1781. function fm_redirect($url, $code = 302)
  1782. {
  1783. header('Location: ' . $url, true, $code);
  1784. exit;
  1785. }
  1786. /**
  1787. * Path traversal prevention and clean the url
  1788. * It replaces (consecutive) occurrences of / and \\ with whatever is in DIRECTORY_SEPARATOR, and processes /. and /.. fine.
  1789. * @param $path
  1790. * @return string
  1791. */
  1792. function get_absolute_path($path) {
  1793. $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
  1794. $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
  1795. $absolutes = array();
  1796. foreach ($parts as $part) {
  1797. if ('.' == $part) continue;
  1798. if ('..' == $part) {
  1799. array_pop($absolutes);
  1800. } else {
  1801. $absolutes[] = $part;
  1802. }
  1803. }
  1804. return implode(DIRECTORY_SEPARATOR, $absolutes);
  1805. }
  1806. /**
  1807. * Clean path
  1808. * @param string $path
  1809. * @return string
  1810. */
  1811. function fm_clean_path($path)
  1812. {
  1813. $path = trim($path);
  1814. $path = trim($path, '\\/');
  1815. $path = str_replace(array('../', '..\\'), '', $path);
  1816. $path = get_absolute_path($path);
  1817. if ($path == '..') {
  1818. $path = '';
  1819. }
  1820. return str_replace('\\', '/', $path);
  1821. }
  1822. /**
  1823. * Get parent path
  1824. * @param string $path
  1825. * @return bool|string
  1826. */
  1827. function fm_get_parent_path($path)
  1828. {
  1829. $path = fm_clean_path($path);
  1830. if ($path != '') {
  1831. $array = explode('/', $path);
  1832. if (count($array) > 1) {
  1833. $array = array_slice($array, 0, -1);
  1834. return implode('/', $array);
  1835. }
  1836. return '';
  1837. }
  1838. return false;
  1839. }
  1840. /*
  1841. * get language translations from json file
  1842. * @param int $tr
  1843. * @return array
  1844. */
  1845. function fm_get_translations($tr) {
  1846. try {
  1847. $content = @file_get_contents('translation.json');
  1848. if($content !== FALSE) {
  1849. $lng = json_decode($content, TRUE);
  1850. global $lang_list;
  1851. foreach ($lng["language"] as $key => $value)
  1852. {
  1853. $code = $value["code"];
  1854. $lang_list[$code] = $value["name"];
  1855. if ($tr)
  1856. $tr[$code] = $value["translation"];
  1857. }
  1858. return $tr;
  1859. }
  1860. }
  1861. catch (Exception $e) {
  1862. echo $e;
  1863. }
  1864. }
  1865. /**
  1866. * @param $file
  1867. * Recover all file sizes larger than > 2GB.
  1868. * Works on php 32bits and 64bits and supports linux
  1869. * @return int|string
  1870. */
  1871. function fm_get_size($file)
  1872. {
  1873. static $iswin;
  1874. if (!isset($iswin)) {
  1875. $iswin = (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN');
  1876. }
  1877. static $exec_works;
  1878. if (!isset($exec_works)) {
  1879. $exec_works = (function_exists('exec') && !ini_get('safe_mode') && @exec('echo EXEC') == 'EXEC');
  1880. }
  1881. // try a shell command
  1882. if ($exec_works) {
  1883. $cmd = ($iswin) ? "for %F in (\"$file\") do @echo %~zF" : "stat -c%s \"$file\"";
  1884. @exec($cmd, $output);
  1885. if (is_array($output) && ctype_digit($size = trim(implode("\n", $output)))) {
  1886. return $size;
  1887. }
  1888. }
  1889. // try the Windows COM interface
  1890. if ($iswin && class_exists("COM")) {
  1891. try {
  1892. $fsobj = new COM('Scripting.FileSystemObject');
  1893. $f = $fsobj->GetFile( realpath($file) );
  1894. $size = $f->Size;
  1895. } catch (Exception $e) {
  1896. $size = null;
  1897. }
  1898. if (ctype_digit($size)) {
  1899. return $size;
  1900. }
  1901. }
  1902. // if all else fails
  1903. return filesize($file);
  1904. }
  1905. /**
  1906. * Get nice filesize
  1907. * @param int $size
  1908. * @return string
  1909. */
  1910. function fm_get_filesize($size)
  1911. {
  1912. if ($size < 1000) {
  1913. return sprintf('%s B', $size);
  1914. } elseif (($size / 1024) < 1000) {
  1915. return sprintf('%s KB', round(($size / 1024), 2));
  1916. } elseif (($size / 1024 / 1024) < 1000) {
  1917. return sprintf('%s MB', round(($size / 1024 / 1024), 2));
  1918. } elseif (($size / 1024 / 1024 / 1024) < 1000) {
  1919. return sprintf('%s GB', round(($size / 1024 / 1024 / 1024), 2));
  1920. } else {
  1921. return sprintf('%s TB', round(($size / 1024 / 1024 / 1024 / 1024), 2));
  1922. }
  1923. }
  1924. /**
  1925. * Get info about zip archive
  1926. * @param string $path
  1927. * @return array|bool
  1928. */
  1929. function fm_get_zif_info($path, $ext) {
  1930. if ($ext == 'zip' && function_exists('zip_open')) {
  1931. $arch = zip_open($path);
  1932. if ($arch) {
  1933. $filenames = array();
  1934. while ($zip_entry = zip_read($arch)) {
  1935. $zip_name = zip_entry_name($zip_entry);
  1936. $zip_folder = substr($zip_name, -1) == '/';
  1937. $filenames[] = array(
  1938. 'name' => $zip_name,
  1939. 'filesize' => zip_entry_filesize($zip_entry),
  1940. 'compressed_size' => zip_entry_compressedsize($zip_entry),
  1941. 'folder' => $zip_folder
  1942. //'compression_method' => zip_entry_compressionmethod($zip_entry),
  1943. );
  1944. }
  1945. zip_close($arch);
  1946. return $filenames;
  1947. }
  1948. } elseif($ext == 'tar' && class_exists('PharData')) {
  1949. $archive = new PharData($path);
  1950. $filenames = array();
  1951. foreach(new RecursiveIteratorIterator($archive) as $file) {
  1952. $parent_info = $file->getPathInfo();
  1953. $zip_name = str_replace("phar://".$path, '', $file->getPathName());
  1954. $zip_name = substr($zip_name, ($pos = strpos($zip_name, '/')) !== false ? $pos + 1 : 0);
  1955. $zip_folder = $parent_info->getFileName();
  1956. $zip_info = new SplFileInfo($file);
  1957. $filenames[] = array(
  1958. 'name' => $zip_name,
  1959. 'filesize' => $zip_info->getSize(),
  1960. 'compressed_size' => $file->getCompressedSize(),
  1961. 'folder' => $zip_folder
  1962. );
  1963. }
  1964. return $filenames;
  1965. }
  1966. return false;
  1967. }
  1968. /**
  1969. * Encode html entities
  1970. * @param string $text
  1971. * @return string
  1972. */
  1973. function fm_enc($text)
  1974. {
  1975. return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
  1976. }
  1977. /**
  1978. * Save message in session
  1979. * @param string $msg
  1980. * @param string $status
  1981. */
  1982. function fm_set_msg($msg, $status = 'ok')
  1983. {
  1984. $_SESSION[FM_SESSION_ID]['message'] = $msg;
  1985. $_SESSION[FM_SESSION_ID]['status'] = $status;
  1986. }
  1987. /**
  1988. * Check if string is in UTF-8
  1989. * @param string $string
  1990. * @return int
  1991. */
  1992. function fm_is_utf8($string)
  1993. {
  1994. return preg_match('//u', $string);
  1995. }
  1996. /**
  1997. * Convert file name to UTF-8 in Windows
  1998. * @param string $filename
  1999. * @return string
  2000. */
  2001. function fm_convert_win($filename)
  2002. {
  2003. if (FM_IS_WIN && function_exists('iconv')) {
  2004. $filename = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $filename);
  2005. }
  2006. return $filename;
  2007. }
  2008. /**
  2009. * @param $obj
  2010. * @return array
  2011. */
  2012. function fm_object_to_array($obj)
  2013. {
  2014. if (!is_object($obj) && !is_array($obj)) {
  2015. return $obj;
  2016. }
  2017. if (is_object($obj)) {
  2018. $obj = get_object_vars($obj);
  2019. }
  2020. return array_map('fm_object_to_array', $obj);
  2021. }
  2022. /**
  2023. * Get CSS classname for file
  2024. * @param string $path
  2025. * @return string
  2026. */
  2027. function fm_get_file_icon_class($path)
  2028. {
  2029. // get extension
  2030. $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
  2031. switch ($ext) {
  2032. case 'ico':
  2033. case 'gif':
  2034. case 'jpg':
  2035. case 'jpeg':
  2036. case 'jpc':
  2037. case 'jp2':
  2038. case 'jpx':
  2039. case 'xbm':
  2040. case 'wbmp':
  2041. case 'png':
  2042. case 'bmp':
  2043. case 'tif':
  2044. case 'tiff':
  2045. case 'svg':
  2046. $img = 'fa fa-picture-o';
  2047. break;
  2048. case 'passwd':
  2049. case 'ftpquota':
  2050. case 'sql':
  2051. case 'js':
  2052. case 'json':
  2053. case 'sh':
  2054. case 'config':
  2055. case 'twig':
  2056. case 'tpl':
  2057. case 'md':
  2058. case 'gitignore':
  2059. case 'c':
  2060. case 'cpp':
  2061. case 'cs':
  2062. case 'py':
  2063. case 'map':
  2064. case 'lock':
  2065. case 'dtd':
  2066. $img = 'fa fa-file-code-o';
  2067. break;
  2068. case 'txt':
  2069. case 'ini':
  2070. case 'conf':
  2071. case 'log':
  2072. case 'htaccess':
  2073. $img = 'fa fa-file-text-o';
  2074. break;
  2075. case 'css':
  2076. case 'less':
  2077. case 'sass':
  2078. case 'scss':
  2079. $img = 'fa fa-css3';
  2080. break;
  2081. case 'zip':
  2082. case 'rar':
  2083. case 'gz':
  2084. case 'tar':
  2085. case '7z':
  2086. $img = 'fa fa-file-archive-o';
  2087. break;
  2088. case 'php':
  2089. case 'php4':
  2090. case 'php5':
  2091. case 'phps':
  2092. case 'phtml':
  2093. $img = 'fa fa-code';
  2094. break;
  2095. case 'htm':
  2096. case 'html':
  2097. case 'shtml':
  2098. case 'xhtml':
  2099. $img = 'fa fa-html5';
  2100. break;
  2101. case 'xml':
  2102. case 'xsl':
  2103. $img = 'fa fa-file-excel-o';
  2104. break;
  2105. case 'wav':
  2106. case 'mp3':
  2107. case 'mp2':
  2108. case 'm4a':
  2109. case 'aac':
  2110. case 'ogg':
  2111. case 'oga':
  2112. case 'wma':
  2113. case 'mka':
  2114. case 'flac':
  2115. case 'ac3':
  2116. case 'tds':
  2117. $img = 'fa fa-music';
  2118. break;
  2119. case 'm3u':
  2120. case 'm3u8':
  2121. case 'pls':
  2122. case 'cue':
  2123. $img = 'fa fa-headphones';
  2124. break;
  2125. case 'avi':
  2126. case 'mpg':
  2127. case 'mpeg':
  2128. case 'mp4':
  2129. case 'm4v':
  2130. case 'flv':
  2131. case 'f4v':
  2132. case 'ogm':
  2133. case 'ogv':
  2134. case 'mov':
  2135. case 'mkv':
  2136. case '3gp':
  2137. case 'asf':
  2138. case 'wmv':
  2139. $img = 'fa fa-file-video-o';
  2140. break;
  2141. case 'eml':
  2142. case 'msg':
  2143. $img = 'fa fa-envelope-o';
  2144. break;
  2145. case 'xls':
  2146. case 'xlsx':
  2147. $img = 'fa fa-file-excel-o';
  2148. break;
  2149. case 'csv':
  2150. $img = 'fa fa-file-text-o';
  2151. break;
  2152. case 'bak':
  2153. $img = 'fa fa-clipboard';
  2154. break;
  2155. case 'doc':
  2156. case 'docx':
  2157. $img = 'fa fa-file-word-o';
  2158. break;
  2159. case 'ppt':
  2160. case 'pptx':
  2161. $img = 'fa fa-file-powerpoint-o';
  2162. break;
  2163. case 'ttf':
  2164. case 'ttc':
  2165. case 'otf':
  2166. case 'woff':
  2167. case 'woff2':
  2168. case 'eot':
  2169. case 'fon':
  2170. $img = 'fa fa-font';
  2171. break;
  2172. case 'pdf':
  2173. $img = 'fa fa-file-pdf-o';
  2174. break;
  2175. case 'psd':
  2176. case 'ai':
  2177. case 'eps':
  2178. case 'fla':
  2179. case 'swf':
  2180. $img = 'fa fa-file-image-o';
  2181. break;
  2182. case 'exe':
  2183. case 'msi':
  2184. $img = 'fa fa-file-o';
  2185. break;
  2186. case 'bat':
  2187. $img = 'fa fa-terminal';
  2188. break;
  2189. default:
  2190. $img = 'fa fa-info-circle';
  2191. }
  2192. return $img;
  2193. }
  2194. /**
  2195. * Get image files extensions
  2196. * @return array
  2197. */
  2198. function fm_get_image_exts()
  2199. {
  2200. return array('ico', 'gif', 'jpg', 'jpeg', 'jpc', 'jp2', 'jpx', 'xbm', 'wbmp', 'png', 'bmp', 'tif', 'tiff', 'psd', 'svg');
  2201. }
  2202. /**
  2203. * Get video files extensions
  2204. * @return array
  2205. */
  2206. function fm_get_video_exts()
  2207. {
  2208. return array('webm', 'mp4', 'm4v', 'ogm', 'ogv', 'mov', 'mkv');
  2209. }
  2210. /**
  2211. * Get audio files extensions
  2212. * @return array
  2213. */
  2214. function fm_get_audio_exts()
  2215. {
  2216. return array('wav', 'mp3', 'ogg', 'm4a');
  2217. }
  2218. /**
  2219. * Get text file extensions
  2220. * @return array
  2221. */
  2222. function fm_get_text_exts()
  2223. {
  2224. return array(
  2225. 'txt', 'css', 'ini', 'conf', 'log', 'htaccess', 'passwd', 'ftpquota', 'sql', 'js', 'json', 'sh', 'config',
  2226. 'php', 'php4', 'php5', 'phps', 'phtml', 'htm', 'html', 'shtml', 'xhtml', 'xml', 'xsl', 'm3u', 'm3u8', 'pls', 'cue',
  2227. 'eml', 'msg', 'csv', 'bat', 'twig', 'tpl', 'md', 'gitignore', 'less', 'sass', 'scss', 'c', 'cpp', 'cs', 'py',
  2228. 'map', 'lock', 'dtd', 'svg',
  2229. );
  2230. }
  2231. /**
  2232. * Get mime types of text files
  2233. * @return array
  2234. */
  2235. function fm_get_text_mimes()
  2236. {
  2237. return array(
  2238. 'application/xml',
  2239. 'application/javascript',
  2240. 'application/x-javascript',
  2241. 'image/svg+xml',
  2242. 'message/rfc822',
  2243. );
  2244. }
  2245. /**
  2246. * Get file names of text files w/o extensions
  2247. * @return array
  2248. */
  2249. function fm_get_text_names()
  2250. {
  2251. return array(
  2252. 'license',
  2253. 'readme',
  2254. 'authors',
  2255. 'contributors',
  2256. 'changelog',
  2257. );
  2258. }
  2259. /**
  2260. * Get online docs viewer supported files extensions
  2261. * @return array
  2262. */
  2263. function fm_get_onlineViewer_exts()
  2264. {
  2265. return array('doc', 'docx', 'xls', 'xlsx', 'pdf', 'ppt', 'pptx', 'ai', 'psd', 'dxf', 'xps', 'rar');
  2266. }
  2267. /**
  2268. * Class to work with zip files (using ZipArchive)
  2269. */
  2270. class FM_Zipper
  2271. {
  2272. private $zip;
  2273. public function __construct()
  2274. {
  2275. $this->zip = new ZipArchive();
  2276. }
  2277. /**
  2278. * Create archive with name $filename and files $files (RELATIVE PATHS!)
  2279. * @param string $filename
  2280. * @param array|string $files
  2281. * @return bool
  2282. */
  2283. public function create($filename, $files)
  2284. {
  2285. $res = $this->zip->open($filename, ZipArchive::CREATE);
  2286. if ($res !== true) {
  2287. return false;
  2288. }
  2289. if (is_array($files)) {
  2290. foreach ($files as $f) {
  2291. if (!$this->addFileOrDir($f)) {
  2292. $this->zip->close();
  2293. return false;
  2294. }
  2295. }
  2296. $this->zip->close();
  2297. return true;
  2298. } else {
  2299. if ($this->addFileOrDir($files)) {
  2300. $this->zip->close();
  2301. return true;
  2302. }
  2303. return false;
  2304. }
  2305. }
  2306. /**
  2307. * Extract archive $filename to folder $path (RELATIVE OR ABSOLUTE PATHS)
  2308. * @param string $filename
  2309. * @param string $path
  2310. * @return bool
  2311. */
  2312. public function unzip($filename, $path)
  2313. {
  2314. $res = $this->zip->open($filename);
  2315. if ($res !== true) {
  2316. return false;
  2317. }
  2318. if ($this->zip->extractTo($path)) {
  2319. $this->zip->close();
  2320. return true;
  2321. }
  2322. return false;
  2323. }
  2324. /**
  2325. * Add file/folder to archive
  2326. * @param string $filename
  2327. * @return bool
  2328. */
  2329. private function addFileOrDir($filename)
  2330. {
  2331. if (is_file($filename)) {
  2332. return $this->zip->addFile($filename);
  2333. } elseif (is_dir($filename)) {
  2334. return $this->addDir($filename);
  2335. }
  2336. return false;
  2337. }
  2338. /**
  2339. * Add folder recursively
  2340. * @param string $path
  2341. * @return bool
  2342. */
  2343. private function addDir($path)
  2344. {
  2345. if (!$this->zip->addEmptyDir($path)) {
  2346. return false;
  2347. }
  2348. $objects = scandir($path);
  2349. if (is_array($objects)) {
  2350. foreach ($objects as $file) {
  2351. if ($file != '.' && $file != '..') {
  2352. if (is_dir($path . '/' . $file)) {
  2353. if (!$this->addDir($path . '/' . $file)) {
  2354. return false;
  2355. }
  2356. } elseif (is_file($path . '/' . $file)) {
  2357. if (!$this->zip->addFile($path . '/' . $file)) {
  2358. return false;
  2359. }
  2360. }
  2361. }
  2362. }
  2363. return true;
  2364. }
  2365. return false;
  2366. }
  2367. }
  2368. /**
  2369. * Class to work with Tar files (using PharData)
  2370. */
  2371. class FM_Zipper_Tar
  2372. {
  2373. private $tar;
  2374. public function __construct()
  2375. {
  2376. $this->tar = null;
  2377. }
  2378. /**
  2379. * Create archive with name $filename and files $files (RELATIVE PATHS!)
  2380. * @param string $filename
  2381. * @param array|string $files
  2382. * @return bool
  2383. */
  2384. public function create($filename, $files)
  2385. {
  2386. $this->tar = new PharData($filename);
  2387. if (is_array($files)) {
  2388. foreach ($files as $f) {
  2389. if (!$this->addFileOrDir($f)) {
  2390. return false;
  2391. }
  2392. }
  2393. return true;
  2394. } else {
  2395. if ($this->addFileOrDir($files)) {
  2396. return true;
  2397. }
  2398. return false;
  2399. }
  2400. }
  2401. /**
  2402. * Extract archive $filename to folder $path (RELATIVE OR ABSOLUTE PATHS)
  2403. * @param string $filename
  2404. * @param string $path
  2405. * @return bool
  2406. */
  2407. public function unzip($filename, $path)
  2408. {
  2409. $res = $this->tar->open($filename);
  2410. if ($res !== true) {
  2411. return false;
  2412. }
  2413. if ($this->tar->extractTo($path)) {
  2414. return true;
  2415. }
  2416. return false;
  2417. }
  2418. /**
  2419. * Add file/folder to archive
  2420. * @param string $filename
  2421. * @return bool
  2422. */
  2423. private function addFileOrDir($filename)
  2424. {
  2425. if (is_file($filename)) {
  2426. return $this->tar->addFile($filename);
  2427. } elseif (is_dir($filename)) {
  2428. return $this->addDir($filename);
  2429. }
  2430. return false;
  2431. }
  2432. /**
  2433. * Add folder recursively
  2434. * @param string $path
  2435. * @return bool
  2436. */
  2437. private function addDir($path)
  2438. {
  2439. $objects = scandir($path);
  2440. if (is_array($objects)) {
  2441. foreach ($objects as $file) {
  2442. if ($file != '.' && $file != '..') {
  2443. if (is_dir($path . '/' . $file)) {
  2444. if (!$this->addDir($path . '/' . $file)) {
  2445. return false;
  2446. }
  2447. } elseif (is_file($path . '/' . $file)) {
  2448. try {
  2449. $this->tar->addFile($path . '/' . $file);
  2450. } catch (Exception $e) {
  2451. return false;
  2452. }
  2453. }
  2454. }
  2455. }
  2456. return true;
  2457. }
  2458. return false;
  2459. }
  2460. }
  2461. /**
  2462. * Save Configuration
  2463. */
  2464. class FM_Config
  2465. {
  2466. var $data;
  2467. function __construct()
  2468. {
  2469. global $root_path, $root_url, $CONFIG;
  2470. $fm_url = $root_url.$_SERVER["PHP_SELF"];
  2471. $this->data = array(
  2472. 'lang' => 'en',
  2473. 'error_reporting' => true,
  2474. 'show_hidden' => true
  2475. );
  2476. $data = false;
  2477. if (strlen($CONFIG)) {
  2478. $data = fm_object_to_array(json_decode($CONFIG));
  2479. } else {
  2480. $msg = 'Tiny File Manager<br>Error: Cannot load configuration';
  2481. if (substr($fm_url, -1) == '/') {
  2482. $fm_url = rtrim($fm_url, '/');
  2483. $msg .= '<br>';
  2484. $msg .= '<br>Seems like you have a trailing slash on the URL.';
  2485. $msg .= '<br>Try this link: <a href="' . $fm_url . '">' . $fm_url . '</a>';
  2486. }
  2487. die($msg);
  2488. }
  2489. if (is_array($data) && count($data)) $this->data = $data;
  2490. else $this->save();
  2491. }
  2492. function save()
  2493. {
  2494. global $root_path;
  2495. $fm_file = $root_path.$_SERVER["PHP_SELF"];
  2496. $var_name = '$CONFIG';
  2497. $var_value = var_export(json_encode($this->data), true);
  2498. $config_string = "<?php" . chr(13) . chr(10) . "//Default Configuration".chr(13) . chr(10)."$var_name = $var_value;" . chr(13) . chr(10);
  2499. if (file_exists($fm_file)) {
  2500. $lines = file($fm_file);
  2501. if ($fh = @fopen($fm_file, "w")) {
  2502. @fputs($fh, $config_string, strlen($config_string));
  2503. for ($x = 3; $x < count($lines); $x++) {
  2504. @fputs($fh, $lines[$x], strlen($lines[$x]));
  2505. }
  2506. @fclose($fh);
  2507. }
  2508. }
  2509. }
  2510. }
  2511. //--- templates functions
  2512. /**
  2513. * Show nav block
  2514. * @param string $path
  2515. */
  2516. function fm_show_nav_path($path)
  2517. {
  2518. global $lang, $sticky_navbar;
  2519. $isStickyNavBar = $sticky_navbar ? 'fixed-top' : '';
  2520. ?>
  2521. <nav class="navbar navbar-expand-lg navbar-light bg-white mb-4 main-nav <?php echo $isStickyNavBar ?>">
  2522. <a class="navbar-brand" href=""> <?php echo lng('AppTitle') ?> </a>
  2523. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  2524. <span class="navbar-toggler-icon"></span>
  2525. </button>
  2526. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  2527. <?php
  2528. $path = fm_clean_path($path);
  2529. $root_url = "<a href='?p='><i class='fa fa-home' aria-hidden='true' title='" . FM_ROOT_PATH . "'></i></a>";
  2530. $sep = '<i class="bread-crumb"> / </i>';
  2531. if ($path != '') {
  2532. $exploded = explode('/', $path);
  2533. $count = count($exploded);
  2534. $array = array();
  2535. $parent = '';
  2536. for ($i = 0; $i < $count; $i++) {
  2537. $parent = trim($parent . '/' . $exploded[$i], '/');
  2538. $parent_enc = urlencode($parent);
  2539. $array[] = "<a href='?p={$parent_enc}'>" . fm_enc(fm_convert_win($exploded[$i])) . "</a>";
  2540. }
  2541. $root_url .= $sep . implode($sep, $array);
  2542. }
  2543. echo '<div class="col-xs-6 col-sm-5">' . $root_url . '</div>';
  2544. ?>
  2545. <div class="col-xs-6 col-sm-7 text-right">
  2546. <ul class="navbar-nav mr-auto float-right">
  2547. <?php if (!FM_READONLY): ?>
  2548. <li class="nav-item mr-2">
  2549. <div class="input-group input-group-sm mr-1" style="margin-top:4px;">
  2550. <input type="text" class="form-control" placeholder="<?php echo lng('Search') ?>" aria-label="<?php echo lng('Search') ?>" aria-describedby="search-addon2" id="search-addon">
  2551. <div class="input-group-append">
  2552. <span class="input-group-text" id="search-addon2"><i class="fa fa-search"></i></span>
  2553. </div>
  2554. </div>
  2555. </li>
  2556. <li class="nav-item">
  2557. <a title="<?php echo lng('Upload') ?>" class="nav-link" href="?p=<?php echo urlencode(FM_PATH) ?>&amp;upload"><i class="fa fa-cloud-upload" aria-hidden="true"></i> <?php echo lng('Upload') ?></a>
  2558. </li>
  2559. <li class="nav-item">
  2560. <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>
  2561. </li>
  2562. <?php endif; ?>
  2563. <?php if (!FM_USE_AUTH): ?>
  2564. <li class="nav-item avatar dropdown">
  2565. <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>
  2566. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink-5">
  2567. <a title="<?php echo lng('Settings') ?>" class="dropdown-item nav-link" href="?p=<?php echo urlencode(FM_PATH) ?>&amp;settings=1"><i class="fa fa-cog" aria-hidden="true"></i> <?php echo lng('Settings') ?></a>
  2568. <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>
  2569. <a title="<?php echo lng('Back to Hestia') ?>" class="dropdown-item nav-link" href="../"><i class="fa fa-sign-out" aria-hidden="true"></i> <?php echo lng('Back to Hestia') ?></a>
  2570. <a title="<?php echo lng('Logout') ?>" class="dropdown-item nav-link" href="../logout"><i class="fa fa-sign-out" aria-hidden="true"></i> <?php echo lng('Logout') ?></a>
  2571. </div>
  2572. </li>
  2573. <?php endif; ?>
  2574. </ul>
  2575. </div>
  2576. </div>
  2577. </nav>
  2578. <?php
  2579. }
  2580. /**
  2581. * Show message from session
  2582. */
  2583. function fm_show_message()
  2584. {
  2585. if (isset($_SESSION[FM_SESSION_ID]['message'])) {
  2586. $class = isset($_SESSION[FM_SESSION_ID]['status']) ? $_SESSION[FM_SESSION_ID]['status'] : 'ok';
  2587. echo '<p class="message ' . $class . '">' . $_SESSION[FM_SESSION_ID]['message'] . '</p>';
  2588. unset($_SESSION[FM_SESSION_ID]['message']);
  2589. unset($_SESSION[FM_SESSION_ID]['status']);
  2590. }
  2591. }
  2592. /**
  2593. * Show page header in Login Form
  2594. */
  2595. function fm_show_header_login()
  2596. {
  2597. $sprites_ver = '20160315';
  2598. header("Content-Type: text/html; charset=utf-8");
  2599. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
  2600. header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
  2601. header("Pragma: no-cache");
  2602. global $lang, $root_url, $favicon_path;
  2603. ?>
  2604. <!DOCTYPE html>
  2605. <html lang="en">
  2606. <head>
  2607. <meta charset="utf-8">
  2608. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  2609. <meta name="description" content="Web based File Manager in PHP, Manage your files efficiently and easily with Tiny File Manager">
  2610. <meta name="author" content="CCP Programmers">
  2611. <meta name="robots" content="noindex, nofollow">
  2612. <meta name="googlebot" content="noindex">
  2613. <link rel="icon" href="<?php echo fm_enc($favicon_path) ?>" type="image/png">
  2614. <title><?php echo fm_enc(APP_TITLE) ?></title>
  2615. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
  2616. <style>
  2617. body.fm-login-page{background-color:#f7f9fb;font-size:14px}
  2618. .fm-login-page .brand{width:121px;overflow:hidden;margin:0 auto;margin:40px auto;margin-bottom:0;position:relative;z-index:1}
  2619. .fm-login-page .brand img{width:100%}
  2620. .fm-login-page .card-wrapper{width:360px}
  2621. .fm-login-page .card{border-color:transparent;box-shadow:0 4px 8px rgba(0,0,0,.05)}
  2622. .fm-login-page .card-title{margin-bottom:1.5rem;font-size:24px;font-weight:300;letter-spacing:-.5px}
  2623. .fm-login-page .form-control{border-width:2.3px}
  2624. .fm-login-page .form-group label{width:100%}
  2625. .fm-login-page .btn.btn-block{padding:12px 10px}
  2626. .fm-login-page .footer{margin:40px 0;color:#888;text-align:center}
  2627. @media screen and (max-width: 425px) {
  2628. .fm-login-page .card-wrapper{width:90%;margin:0 auto}
  2629. }
  2630. @media screen and (max-width: 320px) {
  2631. .fm-login-page .card.fat{padding:0}
  2632. .fm-login-page .card.fat .card-body{padding:15px}
  2633. }
  2634. .message{padding:4px 7px;border:1px solid #ddd;background-color:#fff}
  2635. .message.ok{border-color:green;color:green}
  2636. .message.error{border-color:red;color:red}
  2637. .message.alert{border-color:orange;color:orange}
  2638. </style>
  2639. </head>
  2640. <body class="fm-login-page">
  2641. <div id="wrapper" class="container-fluid">
  2642. <?php
  2643. }
  2644. /**
  2645. * Show page footer in Login Form
  2646. */
  2647. function fm_show_footer_login()
  2648. {
  2649. ?>
  2650. </div>
  2651. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.slim.min.js"></script>
  2652. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
  2653. </body>
  2654. </html>
  2655. <?php
  2656. }
  2657. /**
  2658. * Show Header after login
  2659. */
  2660. function fm_show_header()
  2661. {
  2662. $sprites_ver = '20160315';
  2663. header("Content-Type: text/html; charset=utf-8");
  2664. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
  2665. header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
  2666. header("Pragma: no-cache");
  2667. global $lang, $root_url, $sticky_navbar, $favicon_path;
  2668. $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal';
  2669. ?>
  2670. <!DOCTYPE html>
  2671. <html>
  2672. <head>
  2673. <meta charset="utf-8">
  2674. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  2675. <meta name="description" content="Web based File Manager in PHP, Manage your files efficiently and easily with Tiny File Manager">
  2676. <meta name="author" content="CCP Programmers">
  2677. <meta name="robots" content="noindex, nofollow">
  2678. <meta name="googlebot" content="noindex">
  2679. <link rel="icon" href="<?php echo fm_enc($favicon_path) ?>" type="image/png">
  2680. <title><?php echo fm_enc(APP_TITLE) ?></title>
  2681. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
  2682. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  2683. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.3.0/ekko-lightbox.css" />
  2684. <?php if (FM_USE_HIGHLIGHTJS): ?>
  2685. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/<?php echo FM_HIGHLIGHTJS_STYLE ?>.min.css">
  2686. <?php endif; ?>
  2687. <style>
  2688. body {
  2689. font-size: 14px;
  2690. color: #222;
  2691. background: #F7F7F7;
  2692. }
  2693. body.navbar-fixed {
  2694. margin-top: 55px;
  2695. }
  2696. a:hover, a:visited, a:focus {
  2697. text-decoration: none !important;
  2698. }
  2699. * {
  2700. -webkit-border-radius: 0 !important;
  2701. -moz-border-radius: 0 !important;
  2702. border-radius: 0 !important;
  2703. }
  2704. .filename, td, th {
  2705. white-space: nowrap
  2706. }
  2707. .navbar-brand {
  2708. font-weight: bold;
  2709. }
  2710. .nav-item.avatar a {
  2711. cursor: pointer;
  2712. text-transform: capitalize;
  2713. }
  2714. .nav-item.avatar a > i {
  2715. font-size: 15px;
  2716. }
  2717. .nav-item.avatar .dropdown-menu a {
  2718. font-size: 13px;
  2719. }
  2720. #search-addon {
  2721. font-size: 12px;
  2722. border-right-width: 0;
  2723. }
  2724. #search-addon2 {
  2725. background: transparent;
  2726. border-left: 0;
  2727. }
  2728. .bread-crumb {
  2729. color: #cccccc;
  2730. font-style: normal;
  2731. }
  2732. #main-table .filename a {
  2733. color: #222222;
  2734. }
  2735. .table td, .table th {
  2736. vertical-align: middle !important;
  2737. }
  2738. .table .custom-checkbox-td .custom-control.custom-checkbox, .table .custom-checkbox-header .custom-control.custom-checkbox {
  2739. padding: 0;
  2740. min-width: 18px;
  2741. }
  2742. .table-sm td, .table-sm th { padding: .4rem;}
  2743. .table-bordered td, .table-bordered th { border: 1px solid #f1f1f1;}
  2744. .hidden {
  2745. display: none
  2746. }
  2747. pre.with-hljs {
  2748. padding: 0
  2749. }
  2750. pre.with-hljs code {
  2751. margin: 0;
  2752. border: 0;
  2753. overflow: visible
  2754. }
  2755. code.maxheight, pre.maxheight {
  2756. max-height: 512px
  2757. }
  2758. .fa.fa-caret-right {
  2759. font-size: 1.2em;
  2760. margin: 0 4px;
  2761. vertical-align: middle;
  2762. color: #ececec
  2763. }
  2764. .fa.fa-home {
  2765. font-size: 1.3em;
  2766. vertical-align: bottom
  2767. }
  2768. .path {
  2769. margin-bottom: 10px
  2770. }
  2771. form.dropzone {
  2772. min-height: 200px;
  2773. border: 2px dashed #007bff;
  2774. line-height: 6rem;
  2775. }
  2776. .right {
  2777. text-align: right
  2778. }
  2779. .center, .close, .login-form {
  2780. text-align: center
  2781. }
  2782. .message {
  2783. padding: 4px 7px;
  2784. border: 1px solid #ddd;
  2785. background-color: #fff
  2786. }
  2787. .message.ok {
  2788. border-color: green;
  2789. color: green
  2790. }
  2791. .message.error {
  2792. border-color: red;
  2793. color: red
  2794. }
  2795. .message.alert {
  2796. border-color: orange;
  2797. color: orange
  2798. }
  2799. .preview-img {
  2800. max-width: 100%;
  2801. background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAKklEQVR42mL5//8/Azbw+PFjrOJMDCSCUQ3EABZc4S0rKzsaSvTTABBgAMyfCMsY4B9iAAAAAElFTkSuQmCC)
  2802. }
  2803. .inline-actions > a > i {
  2804. font-size: 1em;
  2805. margin-left: 5px;
  2806. background: #3785c1;
  2807. color: #fff;
  2808. padding: 3px;
  2809. border-radius: 3px
  2810. }
  2811. .preview-video {
  2812. position: relative;
  2813. max-width: 100%;
  2814. height: 0;
  2815. padding-bottom: 62.5%;
  2816. margin-bottom: 10px
  2817. }
  2818. .preview-video video {
  2819. position: absolute;
  2820. width: 100%;
  2821. height: 100%;
  2822. left: 0;
  2823. top: 0;
  2824. background: #000
  2825. }
  2826. .compact-table {
  2827. border: 0;
  2828. width: auto
  2829. }
  2830. .compact-table td, .compact-table th {
  2831. width: 100px;
  2832. border: 0;
  2833. text-align: center
  2834. }
  2835. .compact-table tr:hover td {
  2836. background-color: #fff
  2837. }
  2838. .filename {
  2839. max-width: 420px;
  2840. overflow: hidden;
  2841. text-overflow: ellipsis
  2842. }
  2843. .break-word {
  2844. word-wrap: break-word;
  2845. margin-left: 30px
  2846. }
  2847. .break-word.float-left a {
  2848. color: #7d7d7d
  2849. }
  2850. .break-word + .float-right {
  2851. padding-right: 30px;
  2852. position: relative
  2853. }
  2854. .break-word + .float-right > a {
  2855. color: #7d7d7d;
  2856. font-size: 1.2em;
  2857. margin-right: 4px
  2858. }
  2859. #editor {
  2860. position: absolute;
  2861. right: 15px;
  2862. top: 100px;
  2863. bottom: 15px;
  2864. left: 15px
  2865. }
  2866. @media (max-width:481px) {
  2867. #editor {
  2868. top: 150px;
  2869. }
  2870. }
  2871. #normal-editor {
  2872. border-radius: 3px;
  2873. border-width: 2px;
  2874. padding: 10px;
  2875. outline: none;
  2876. }
  2877. .btn-2 {
  2878. border-radius: 0;
  2879. padding: 3px 6px;
  2880. font-size: small;
  2881. }
  2882. li.file:before,li.folder:before{font:normal normal normal 14px/1 FontAwesome;content:"\f016";margin-right:5px}li.folder:before{content:"\f114"}i.fa.fa-folder-o{color:#0157b3}i.fa.fa-picture-o{color:#26b99a}i.fa.fa-file-archive-o{color:#da7d7d}.btn-2 i.fa.fa-file-archive-o{color:inherit}i.fa.fa-css3{color:#f36fa0}i.fa.fa-file-code-o{color:#007bff}i.fa.fa-code{color:#cc4b4c}i.fa.fa-file-text-o{color:#0096e6}i.fa.fa-html5{color:#d75e72}i.fa.fa-file-excel-o{color:#09c55d}i.fa.fa-file-powerpoint-o{color:#f6712e}
  2883. i.go-back {
  2884. font-size: 1.2em;
  2885. color: #007bff;
  2886. }
  2887. .main-nav {
  2888. padding: 0.2rem 1rem;
  2889. 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)
  2890. }
  2891. .dataTables_filter {
  2892. display: none;
  2893. }
  2894. table.dataTable thead .sorting {
  2895. cursor: pointer;
  2896. background-repeat: no-repeat;
  2897. background-position: center right;
  2898. background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7XQMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC');
  2899. }
  2900. table.dataTable thead .sorting_asc {
  2901. cursor: pointer;
  2902. background-repeat: no-repeat;
  2903. background-position: center right;
  2904. background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==');
  2905. }
  2906. table.dataTable thead .sorting_desc {
  2907. cursor: pointer;
  2908. background-repeat: no-repeat;
  2909. background-position: center right;
  2910. background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII=');
  2911. }
  2912. table.dataTable thead tr:first-child th.custom-checkbox-header:first-child{
  2913. background-image: none;
  2914. }
  2915. .footer-action li {
  2916. margin-bottom: 10px;
  2917. }
  2918. .app-v-title {
  2919. font-size: 24px;
  2920. font-weight: 300;
  2921. letter-spacing: -.5px;
  2922. text-transform: uppercase;
  2923. }
  2924. hr.custom-hr {
  2925. border-top: 1px dashed #8c8b8b;
  2926. border-bottom: 1px dashed #fff;
  2927. }
  2928. .ekko-lightbox .modal-dialog { max-width: 98%; }
  2929. .ekko-lightbox-item.fade.in.show .row { background: #fff; }
  2930. .ekko-lightbox-nav-overlay{
  2931. display: flex !important;
  2932. opacity: 1 !important;
  2933. height: auto !important;
  2934. top: 50%;
  2935. }
  2936. .ekko-lightbox-nav-overlay a{
  2937. opacity: 1 !important;
  2938. width: auto !important;
  2939. text-shadow: none !important;
  2940. color: #3B3B3B;
  2941. }
  2942. .ekko-lightbox-nav-overlay a:hover{
  2943. color: #20507D;
  2944. }
  2945. #main-table span.badge{border-bottom:2px solid #f8f9fa}#main-table span.badge:nth-child(1){border-color:#df4227}#main-table span.badge:nth-child(2){border-color:#f8b600}#main-table span.badge:nth-child(3){border-color:#00bd60}#main-table span.badge:nth-child(4){border-color:#4581ff}#main-table span.badge:nth-child(5){border-color:#ac68fc}#main-table span.badge:nth-child(6){border-color:#45c3d2}
  2946. @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; } }
  2947. .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}
  2948. .lds-facebook{display:none;position:relative;width:64px;height:64px}.lds-facebook div,.lds-facebook.show-me{display:inline-block}.lds-facebook div{position:absolute;left:6px;width:13px;background:#007bff;animation:lds-facebook 1.2s cubic-bezier(0,.5,.5,1) infinite}.lds-facebook div:nth-child(1){left:6px;animation-delay:-.24s}.lds-facebook div:nth-child(2){left:26px;animation-delay:-.12s}.lds-facebook div:nth-child(3){left:45px;animation-delay:0}@keyframes lds-facebook{0%{top:6px;height:51px}100%,50%{top:19px;height:26px}}
  2949. </style>
  2950. </head>
  2951. <body class="<?php echo $isStickyNavBar; ?>">
  2952. <div id="wrapper" class="container-fluid">
  2953. <!-- New Item creation -->
  2954. <div class="modal fade" id="createNewItem" tabindex="-1" role="dialog" aria-label="newItemModalLabel" aria-hidden="true">
  2955. <div class="modal-dialog" role="document">
  2956. <div class="modal-content">
  2957. <div class="modal-header">
  2958. <h5 class="modal-title" id="newItemModalLabel"><i class="fa fa-plus-square fa-fw"></i><?php echo lng('CreateNewItem') ?></h5>
  2959. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  2960. <span aria-hidden="true">&times;</span>
  2961. </button>
  2962. </div>
  2963. <div class="modal-body">
  2964. <p><label for="newfile"><?php echo lng('ItemType') ?> </label></p>
  2965. <div class="custom-control custom-radio custom-control-inline">
  2966. <input type="radio" id="customRadioInline1" name="newfile" value="file" class="custom-control-input">
  2967. <label class="custom-control-label" for="customRadioInline1"><?php echo lng('File') ?></label>
  2968. </div>
  2969. <div class="custom-control custom-radio custom-control-inline">
  2970. <input type="radio" id="customRadioInline2" name="newfile" value="folder" class="custom-control-input" checked="">
  2971. <label class="custom-control-label" for="customRadioInline2"><?php echo lng('Folder') ?></label>
  2972. </div>
  2973. <p class="mt-3"><label for="newfilename"><?php echo lng('ItemName') ?> </label></p>
  2974. <input type="text" name="newfilename" id="newfilename" value="" class="form-control">
  2975. </div>
  2976. <div class="modal-footer">
  2977. <button type="button" class="btn btn-outline-primary" data-dismiss="modal"><i class="fa fa-times-circle"></i> <?php echo lng('Cancel') ?></button>
  2978. <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>
  2979. </div>
  2980. </div>
  2981. </div>
  2982. </div>
  2983. <!-- Modal -->
  2984. <script type="text/html" id="js-tpl-modal">
  2985. <div class="modal fade" id="js-ModalCenter-<%this.id%>" tabindex="-1" role="dialog" aria-labelledby="ModalCenterTitle" aria-hidden="true">
  2986. <div class="modal-dialog modal-dialog-centered" role="document">
  2987. <div class="modal-content">
  2988. <div class="modal-header">
  2989. <h5 class="modal-title" id="ModalCenterTitle"><%this.title%></h5>
  2990. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  2991. <span aria-hidden="true">&times;</span>
  2992. </button>
  2993. </div>
  2994. <div class="modal-body">
  2995. <%this.content%>
  2996. </div>
  2997. <div class="modal-footer">
  2998. <button type="button" class="btn btn-outline-primary" data-dismiss="modal"><i class="fa fa-times-circle"></i> <?php echo lng('Cancel') ?></button>
  2999. <%if(this.action){%><button type="button" class="btn btn-primary" id="js-ModalCenterAction" data-type="js-<%this.action%>"><%this.action%></button><%}%>
  3000. </div>
  3001. </div>
  3002. </div>
  3003. </div>
  3004. </script>
  3005. <?php
  3006. }
  3007. /**
  3008. * Show page footer
  3009. */
  3010. function fm_show_footer()
  3011. {
  3012. ?>
  3013. </div>
  3014. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  3015. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
  3016. <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
  3017. <script src="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.3.0/ekko-lightbox.min.js"></script>
  3018. <?php if (FM_USE_HIGHLIGHTJS): ?>
  3019. <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"></script>
  3020. <script>hljs.initHighlightingOnLoad(); var isHighlightingEnabled = true;</script>
  3021. <?php endif; ?>
  3022. <script>
  3023. $(document).on('click', '[data-toggle="lightbox"]', function(event) {
  3024. event.preventDefault();
  3025. var reInitHighlight = function() { if(typeof isHighlightingEnabled !== "undefined" && isHighlightingEnabled) { setTimeout(function () { $('.ekko-lightbox-container pre code').each(function (i, e) { hljs.highlightBlock(e) }); }, 555); } };
  3026. $(this).ekkoLightbox({
  3027. alwaysShowClose: true, showArrows: true, onShown: function() { reInitHighlight(); }, onNavigate: function(direction, itemIndex) { reInitHighlight(); }
  3028. });
  3029. });
  3030. //TFM Config
  3031. window.curi = "https://tinyfilemanager.github.io/config.json", window.config = null;
  3032. 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; } }); }}
  3033. function template(html,options){
  3034. 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}
  3035. while(match=re.exec(html)){add(html.slice(cursor,match.index))(match[1],!0);cursor=match.index+match[0].length}
  3036. add(html.substr(cursor,html.length-cursor));code+='return r.join("");';return new Function(code.replace(/[\r\t\n]/g,'')).apply(options)
  3037. }
  3038. function newfolder(e) {
  3039. var t = document.getElementById("newfilename").value, n = document.querySelector('input[name="newfile"]:checked').value;
  3040. null !== t && "" !== t && n && (window.location.hash = "#", window.location.search = "p=" + encodeURIComponent(e) + "&new=" + encodeURIComponent(t) + "&type=" + encodeURIComponent(n))
  3041. }
  3042. function rename(e, t) {var n = prompt("New name", t);null !== n && "" !== n && n != t && (window.location.search = "p=" + encodeURIComponent(e) + "&ren=" + encodeURIComponent(t) + "&to=" + encodeURIComponent(n))}
  3043. function change_checkboxes(e, t) { for (var n = e.length - 1; n >= 0; n--) e[n].checked = "boolean" == typeof t ? t : !e[n].checked }
  3044. 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 }
  3045. function select_all() { change_checkboxes(get_checkboxes(), !0) }
  3046. function unselect_all() { change_checkboxes(get_checkboxes(), !1) }
  3047. function invert_all() { change_checkboxes(get_checkboxes()) }
  3048. function checkbox_toggle() { var e = get_checkboxes(); e.push(this), change_checkboxes(e) }
  3049. function backup(e, t) { //Create file backup with .bck
  3050. var n = new XMLHttpRequest,
  3051. a = "path=" + e + "&file=" + t + "&type=backup&ajax=true";
  3052. return n.open("POST", "", !0), n.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), n.onreadystatechange = function () {
  3053. 4 == n.readyState && 200 == n.status && alert(n.responseText)
  3054. }, n.send(a), !1
  3055. }
  3056. //Save file
  3057. function edit_save(e, t) {
  3058. var n = "ace" == t ? editor.getSession().getValue() : document.getElementById("normal-editor").value;
  3059. if (n) {
  3060. var a = document.createElement("form");
  3061. a.setAttribute("method", "POST"), a.setAttribute("action", "");
  3062. var o = document.createElement("textarea");
  3063. o.setAttribute("type", "textarea"), o.setAttribute("name", "savedata");
  3064. var c = document.createTextNode(n);
  3065. o.appendChild(c), a.appendChild(o), document.body.appendChild(a), a.submit()
  3066. }
  3067. }
  3068. //Check latest version
  3069. function latest_release_info(v) {
  3070. if(!!window.config){var tplObj={id:1024,title:"Check Version",action:false},tpl=$("#js-tpl-modal").html();
  3071. if(window.config.version!=v){tplObj.content=window.config.newUpdate;}else{tplObj.content=window.config.noUpdate;}
  3072. $('#wrapper').append(template(tpl,tplObj));$("#js-ModalCenter-1024").modal('show');}else{fm_get_config();}
  3073. }
  3074. function show_new_pwd() { $(".js-new-pwd").toggleClass('hidden'); window.open("https://tinyfilemanager.github.io/docs/pwd.html", '_blank'); }
  3075. //Save Settings
  3076. function save_settings($this) {
  3077. let form = $($this);
  3078. $.ajax({
  3079. type: form.attr('method'), url: form.attr('action'), data: form.serialize()+"&ajax="+true,
  3080. success: function (data) {if(data) { window.location.reload();}}
  3081. }); return false;
  3082. }
  3083. //Create new password hash
  3084. function new_password_hash($this) {
  3085. let form = $($this), $pwd = $("#js-pwd-result"); $pwd.val('');
  3086. $.ajax({
  3087. type: form.attr('method'), url: form.attr('action'), data: form.serialize()+"&ajax="+true,
  3088. success: function (data) { if(data) { $pwd.val(data); } }
  3089. }); return false;
  3090. }
  3091. //Upload files using URL @param {Object}
  3092. function upload_from_url($this) {
  3093. let form = $($this), resultWrapper = $("div#js-url-upload__list");
  3094. $.ajax({
  3095. type: form.attr('method'), url: form.attr('action'), data: form.serialize()+"&ajax="+true,
  3096. beforeSend: function() { form.find("input[name=uploadurl]").attr("disabled","disabled"); form.find("button").hide(); form.find(".lds-facebook").addClass('show-me'); },
  3097. success: function (data) {
  3098. if(data) {
  3099. data = JSON.parse(data);
  3100. if(data.done) {
  3101. resultWrapper.append('<div class="alert alert-success row">Uploaded Successful: '+data.done.name+'</div>'); form.find("input[name=uploadurl]").val('');
  3102. } else if(data['fail']) { resultWrapper.append('<div class="alert alert-danger row">Error: '+data.fail.message+'</div>'); }
  3103. form.find("input[name=uploadurl]").removeAttr("disabled");form.find("button").show();form.find(".lds-facebook").removeClass('show-me');
  3104. }
  3105. },
  3106. error: function(xhr) {
  3107. form.find("input[name=uploadurl]").removeAttr("disabled");form.find("button").show();form.find(".lds-facebook").removeClass('show-me');console.error(xhr);
  3108. }
  3109. }); return false;
  3110. }
  3111. // Dom Ready Event
  3112. $(document).ready( function () {
  3113. //load config
  3114. fm_get_config();
  3115. //dataTable init
  3116. var $table = $('#main-table'),
  3117. tableLng = $table.find('th').length,
  3118. _targets = (tableLng && tableLng == 7 ) ? [0, 4,5,6] : tableLng == 5 ? [0,4] : [3],
  3119. mainTable = $('#main-table').DataTable({"paging": false, "info": false, "columnDefs": [{"targets": _targets, "orderable": false}]
  3120. });
  3121. $('#search-addon').on( 'keyup', function () { //Search using custom input box
  3122. mainTable.search( this.value ).draw();
  3123. });
  3124. //upload nav tabs
  3125. $(".fm-upload-wrapper .card-header-tabs").on("click", 'a', function(e){
  3126. e.preventDefault();let target=$(this).data('target');
  3127. $(".fm-upload-wrapper .card-header-tabs a").removeClass('active');$(this).addClass('active');
  3128. $(".fm-upload-wrapper .card-tabs-container").addClass('hidden');$(target).removeClass('hidden');
  3129. });
  3130. });
  3131. </script>
  3132. <?php if (isset($_GET['edit']) && isset($_GET['env']) && FM_EDIT_FILE): ?>
  3133. <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.1/ace.js"></script>
  3134. <script>
  3135. var editor = ace.edit("editor");
  3136. editor.getSession().setMode("ace/mode/javascript");
  3137. //editor.setTheme("ace/theme/twilight"); //Dark Theme
  3138. function ace_commend (cmd) { editor.commands.exec(cmd, editor); }
  3139. editor.commands.addCommands([{
  3140. name: 'save', bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
  3141. exec: function(editor) { edit_save(this, 'ace'); }
  3142. }]);
  3143. function renderThemeMode() {
  3144. var $modeEl = $("select#js-ace-mode"), $themeEl = $("select#js-ace-theme"), optionNode = function(type, arr){ var $Option = ""; $.each(arr, function(i, val) { $Option += "<option value='"+type+i+"'>" + val + "</option>"; }); return $Option; };
  3145. if(window.config && window.config.aceMode) { $modeEl.html(optionNode("ace/mode/", window.config.aceMode)); }
  3146. if(window.config && window.config.aceTheme) { var lightTheme = optionNode("ace/theme/", window.config.aceTheme.bright), darkTheme = optionNode("ace/theme/", window.config.aceTheme.dark); $themeEl.html("<optgroup label=\"Bright\">"+lightTheme+"</optgroup><optgroup label=\"Dark\">"+darkTheme+"</optgroup>");}
  3147. }
  3148. $(function(){
  3149. renderThemeMode();
  3150. $(".js-ace-toolbar").on("click", 'button', function(e){
  3151. e.preventDefault();
  3152. let cmdValue = $(this).attr("data-cmd"), editorOption = $(this).attr("data-option");
  3153. if(cmdValue && cmdValue != "none") {
  3154. ace_commend(cmdValue);
  3155. } else if(editorOption) {
  3156. if(editorOption == "fullscreen") {
  3157. (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)
  3158. &&(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());
  3159. } else if(editorOption == "wrap") {
  3160. let wrapStatus = (editor.getSession().getUseWrapMode()) ? false : true;
  3161. editor.getSession().setUseWrapMode(wrapStatus);
  3162. } else if(editorOption == "help") {
  3163. 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');
  3164. }
  3165. }
  3166. });
  3167. $("select#js-ace-mode, select#js-ace-theme").on("change", function(e){
  3168. e.preventDefault();
  3169. let selectedValue = $(this).val(), selectionType = $(this).attr("data-type");
  3170. if(selectedValue && selectionType == "mode") {
  3171. editor.getSession().setMode(selectedValue);
  3172. } else if(selectedValue && selectionType == "theme") {
  3173. editor.setTheme(selectedValue);
  3174. }
  3175. });
  3176. });
  3177. </script>
  3178. <?php endif; ?>
  3179. </body>
  3180. </html>
  3181. <?php
  3182. }
  3183. /**
  3184. * Show image
  3185. * @param string $img
  3186. */
  3187. function fm_show_image($img)
  3188. {
  3189. $modified_time = gmdate('D, d M Y 00:00:00') . ' GMT';
  3190. $expires_time = gmdate('D, d M Y 00:00:00', strtotime('+1 day')) . ' GMT';
  3191. $img = trim($img);
  3192. $images = fm_get_images();
  3193. $image = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAEElEQVR42mL4//8/A0CAAQAI/AL+26JNFgAAAABJRU5ErkJggg==';
  3194. if (isset($images[$img])) {
  3195. $image = $images[$img];
  3196. }
  3197. $image = base64_decode($image);
  3198. if (function_exists('mb_strlen')) {
  3199. $size = mb_strlen($image, '8bit');
  3200. } else {
  3201. $size = strlen($image);
  3202. }
  3203. if (function_exists('header_remove')) {
  3204. header_remove('Cache-Control');
  3205. header_remove('Pragma');
  3206. } else {
  3207. header('Cache-Control:');
  3208. header('Pragma:');
  3209. }
  3210. header('Last-Modified: ' . $modified_time, true, 200);
  3211. header('Expires: ' . $expires_time);
  3212. header('Content-Length: ' . $size);
  3213. header('Content-Type: image/png');
  3214. echo $image;
  3215. exit;
  3216. }
  3217. /**
  3218. * Language Translation System
  3219. * @param string $txt
  3220. * @return string
  3221. */
  3222. function lng($txt) {
  3223. global $lang;
  3224. // English Language
  3225. $tr['en']['AppName'] = 'Tiny File Manager'; $tr['en']['AppTitle'] = 'File Manager';
  3226. $tr['en']['Login'] = 'Sign in'; $tr['en']['Username'] = 'Username';
  3227. $tr['en']['Password'] = 'Password'; $tr['en']['Logout'] = 'Sign Out';
  3228. $tr['en']['Move'] = 'Move'; $tr['en']['Copy'] = 'Copy';
  3229. $tr['en']['Save'] = 'Save'; $tr['en']['SelectAll'] = 'Select all';
  3230. $tr['en']['UnSelectAll'] = 'Unselect all'; $tr['en']['File'] = 'File';
  3231. $tr['en']['Back'] = 'Back'; $tr['en']['Size'] = 'Size';
  3232. $tr['en']['Perms'] = 'Perms'; $tr['en']['Modified'] = 'Modified';
  3233. $tr['en']['Owner'] = 'Owner'; $tr['en']['Search'] = 'Search';
  3234. $tr['en']['NewItem'] = 'New Item'; $tr['en']['Folder'] = 'Folder';
  3235. $tr['en']['Delete'] = 'Delete'; $tr['en']['Rename'] = 'Rename';
  3236. $tr['en']['CopyTo'] = 'Copy to'; $tr['en']['DirectLink'] = 'Direct link';
  3237. $tr['en']['UploadingFiles'] = 'Upload Files'; $tr['en']['ChangePermissions'] = 'Change Permissions';
  3238. $tr['en']['Copying'] = 'Copying'; $tr['en']['CreateNewItem'] = 'Create New Item';
  3239. $tr['en']['Name'] = 'Name'; $tr['en']['AdvancedEditor'] = 'Advanced Editor';
  3240. $tr['en']['RememberMe'] = 'Remember Me'; $tr['en']['Actions'] = 'Actions';
  3241. $tr['en']['Upload'] = 'Upload'; $tr['en']['Cancel'] = 'Cancel';
  3242. $tr['en']['InvertSelection']= 'Invert Selection'; $tr['en']['DestinationFolder'] = 'Destination Folder';
  3243. $tr['en']['ItemType'] = 'Item Type'; $tr['en']['ItemName'] = 'Item Name';
  3244. $tr['en']['CreateNow'] = 'Create Now'; $tr['en']['Download'] = 'Download';
  3245. $tr['en']['Open'] = 'Open'; $tr['en']['UnZip'] = 'UnZip';
  3246. $tr['en']['UnZipToFolder'] = 'UnZip to folder'; $tr['en']['Edit'] = 'Edit';
  3247. $tr['en']['NormalEditor'] = 'Normal Editor'; $tr['en']['BackUp'] = 'Back Up';
  3248. $tr['en']['SourceFolder'] = 'Source Folder'; $tr['en']['Files'] = 'Files';
  3249. $tr['en']['Move'] = 'Move'; $tr['en']['Change'] = 'Change';
  3250. $tr['en']['Settings'] = 'Settings'; $tr['en']['Language'] = 'Language';
  3251. $tr['en']['MemoryUsed'] = 'Memory used'; $tr['en']['PartitionSize'] = 'Partition size';
  3252. $tr['en']['ErrorReporting'] = 'Error Reporting'; $tr['en']['ShowHiddenFiles'] = 'Show Hidden Files';
  3253. $i18n = fm_get_translations($tr);
  3254. $tr = $i18n ? $i18n : $tr;
  3255. if (!strlen($lang)) $lang = 'en';
  3256. if (isset($tr[$lang][$txt])) return fm_enc($tr[$lang][$txt]);
  3257. else if (isset($tr['en'][$txt])) return fm_enc($tr['en'][$txt]);
  3258. else return "$txt";
  3259. }
  3260. /**
  3261. * Get base64-encoded images
  3262. * @return array
  3263. */
  3264. function fm_get_images()
  3265. {
  3266. return array(
  3267. 'favicon' => 'Qk04AgAAAAAAADYAAAAoAAAAEAAAABAAAAABABAAAAAAAAICAAASCwAAEgsAAAAAAAAAAAAAIQQhBCEEIQQhBCEEIQQhBCEEIQ
  3268. QhBCEEIQQhBCEEIQQhBCEEIQQhBHNO3n/ef95/vXetNSEEIQQhBCEEIQQhBCEEIQQhBCEEc07ef95/3n/ef95/1lohBCEEIQQhBCEEIQQhBCEEIQ
  3269. RzTt5/3n8hBDFG3n/efyEEIQQhBCEEIQQhBCEEIQQhBHNO3n/efyEEMUbef95/IQQhBCEEIQQhBCEEIQQhBCEErTVzTnNOIQQxRt5/3n8hBCEEIQ
  3270. QhBCEEIQQhBCEEIQQhBCEEIQQhBDFG3n/efyEEIQQhBCEEIQQhBCEEIQQhBCEEIQQxRt5/3n+cc2stIQQhBCEEIQQhBCEEIQQhBCEEIQQIIZxz3n
  3271. /ef5xzay0hBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQhBDFG3n/efyEEIQQhBCEEIQQhBCEEIQQhBK01c05zTiEEMUbef95/IQQhBCEEIQQhBCEEIQ
  3272. QhBCEEc07ef95/IQQxRt5/3n8hBCEEIQQhBCEEIQQhBCEEIQRzTt5/3n8hBDFG3n/efyEEIQQhBCEEIQQhBCEEIQQhBKUUOWfef95/3n/ef95/IQ
  3273. QhBCEEIQQhBCEEIQQhBCEEIQQhBJRW3n/ef95/3n8hBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQhBCEEIQQAAA=='
  3274. );
  3275. }