PageRenderTime 54ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/admin-dev/filemanager/dialog.php

https://github.com/netplayer/PrestaShop
PHP | 990 lines | 919 code | 63 blank | 8 comment | 130 complexity | 72f1455702ade30fcedc54f7f64634bb MD5 | raw file
Possible License(s): CC-BY-SA-3.0, LGPL-2.1, LGPL-3.0
  1. <?php
  2. include('config/config.php');
  3. $_SESSION["verify"] = "RESPONSIVEfilemanager";
  4. if (isset($_POST['submit']))
  5. include('upload.php');
  6. else
  7. {
  8. include('include/utils.php');
  9. if (isset($_GET['fldr'])
  10. && !empty($_GET['fldr'])
  11. && preg_match('/\.{1,2}[\/|\\\]/', urldecode($_GET['fldr'])) === 0
  12. )
  13. $subdir = urldecode(trim(str_replace("\0", '', $_GET['fldr']), '/').'/');
  14. else
  15. $subdir = '';
  16. //remember last position
  17. setcookie('last_position', $subdir, time() + (86400 * 7));
  18. if ($subdir == '')
  19. {
  20. if (!empty($_COOKIE['last_position'])
  21. && strpos($_COOKIE['last_position'], '.') === false
  22. )
  23. $subdir = trim($_COOKIE['last_position']);
  24. }
  25. if ($subdir == '/')
  26. $subdir = '';
  27. /***
  28. *SUB-DIR CODE
  29. ***/
  30. if (!isset($_SESSION['subfolder'])) $_SESSION['subfolder'] = '';
  31. $subfolder = '';
  32. if (!empty($_SESSION['subfolder']) && strpos($_SESSION['subfolder'], '../') === false
  33. && strpos($_SESSION['subfolder'], './') === false && strpos($_SESSION['subfolder'], '/') !== 0
  34. && strpos($_SESSION['subfolder'], '.') === false
  35. ) $subfolder = $_SESSION['subfolder'];
  36. if ($subfolder != '' && $subfolder[strlen($subfolder) - 1] != '/') $subfolder .= '/';
  37. if (!file_exists($current_path.$subfolder.$subdir))
  38. {
  39. $subdir = '';
  40. if (!file_exists($current_path.$subfolder.$subdir))
  41. $subfolder = '';
  42. }
  43. if (trim($subfolder) == '')
  44. {
  45. $cur_dir = $upload_dir.$subdir;
  46. $cur_path = $current_path.$subdir;
  47. $thumbs_path = $thumbs_base_path;
  48. $parent = $subdir;
  49. } else
  50. {
  51. $cur_dir = $upload_dir.$subfolder.$subdir;
  52. $cur_path = $current_path.$subfolder.$subdir;
  53. $thumbs_path = $thumbs_base_path.$subfolder;
  54. $parent = $subfolder.$subdir;
  55. }
  56. $cycle = true;
  57. $max_cycles = 50;
  58. $i = 0;
  59. while ($cycle && $i < $max_cycles)
  60. {
  61. $i++;
  62. if ($parent == './') $parent = '';
  63. if (file_exists($current_path.$parent.'config.php'))
  64. {
  65. require_once($current_path.$parent.'config.php');
  66. $cycle = false;
  67. }
  68. if ($parent == '') $cycle = false;
  69. else $parent = fix_dirname($parent).'/';
  70. }
  71. if (!is_dir($thumbs_path.$subdir))
  72. {
  73. create_folder(false, $thumbs_path.$subdir);
  74. }
  75. if (isset($_GET['popup'])) $popup = $_GET['popup']; else $popup = 0;
  76. //Sanitize popup
  77. $popup = !!$popup;
  78. //view type
  79. if (!isset($_SESSION['view_type']))
  80. {
  81. $view = $default_view;
  82. $_SESSION['view_type'] = $view;
  83. }
  84. if (isset($_GET['view']))
  85. {
  86. $view = $_GET['view'];
  87. $_SESSION['view_type'] = $view;
  88. }
  89. $view = $_SESSION['view_type'];
  90. if (isset($_GET['filter'])) $filter = fix_filename($_GET['filter'], $transliteration);
  91. else $filter = '';
  92. if (!isset($_SESSION['sort_by'])) $_SESSION['sort_by'] = '';
  93. if (isset($_GET['sort_by'])) $sort_by = $_SESSION['sort_by'] = fix_filename($_GET['sort_by'], $transliteration);
  94. else $sort_by = $_SESSION['sort_by'];
  95. if (!isset($_SESSION['descending'])) $_SESSION['descending'] = false;
  96. if (isset($_GET['descending'])) $descending = $_SESSION['descending'] = fix_filename($_GET['descending'], $transliteration) === 'true';
  97. else $descending = $_SESSION['descending'];
  98. $lang = $default_language;
  99. if (isset($_GET['lang']) && $_GET['lang'] != 'undefined' && $_GET['lang'] != '')
  100. $lang = $_GET['lang'];
  101. $language_file = 'lang/'.$default_language.'.php';
  102. if ($lang != $default_language)
  103. {
  104. $path_parts = pathinfo($lang);
  105. if (is_readable('lang/'.$path_parts['basename'].'.php'))
  106. $language_file = 'lang/'.$path_parts['basename'].'.php';
  107. else
  108. $lang = $default_language;
  109. }
  110. require_once $language_file;
  111. if (!isset($_GET['type'])) $_GET['type'] = 0;
  112. if (!isset($_GET['field_id'])) $_GET['field_id'] = '';
  113. $get_params = http_build_query(
  114. array(
  115. 'type' => Tools::safeOutput($_GET['type']),
  116. 'lang' => Tools::safeOutput($lang),
  117. 'popup' => $popup,
  118. 'field_id' => isset($_GET['field_id']) ? (int)$_GET['field_id'] : '',
  119. 'fldr' => ''
  120. )
  121. );
  122. ?>
  123. <!DOCTYPE html>
  124. <html xmlns="https://www.w3.org/1999/xhtml">
  125. <head>
  126. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  127. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  128. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
  129. <meta name="robots" content="noindex,nofollow">
  130. <title>Responsive FileManager</title>
  131. <link rel="shortcut icon" href="img/ico/favicon.ico">
  132. <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
  133. <link href="css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css"/>
  134. <link href="css/bootstrap-lightbox.min.css" rel="stylesheet" type="text/css"/>
  135. <link href="css/style.css" rel="stylesheet" type="text/css"/>
  136. <link href="css/dropzone.min.css" type="text/css" rel="stylesheet"/>
  137. <link href="css/jquery.contextMenu.min.css" rel="stylesheet" type="text/css"/>
  138. <link href="css/bootstrap-modal.min.css" rel="stylesheet" type="text/css"/>
  139. <link href="jPlayer/skin/blue.monday/jplayer.blue.monday.css" rel="stylesheet" type="text/css">
  140. <!--[if lt IE 8]>
  141. <style>
  142. .img-container span, .img-container-mini span {
  143. display: inline-block;
  144. height: 100%;
  145. }
  146. </style><![endif]-->
  147. <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  148. <script type="text/javascript">
  149. if (typeof jQuery === 'undefined') {
  150. document.write(unescape("%3Cscript src='js/jquery.js' type='text/javascript'%3E%3C/script%3E"));
  151. }
  152. </script>
  153. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  154. <script type="text/javascript" src="js/bootstrap-lightbox.min.js"></script>
  155. <script type="text/javascript" src="js/dropzone.min.js"></script>
  156. <script type="text/javascript" src="js/jquery.touchSwipe.min.js"></script>
  157. <script type="text/javascript" src="js/modernizr.custom.js"></script>
  158. <script type="text/javascript" src="js/bootbox.min.js"></script>
  159. <script type="text/javascript" src="js/bootstrap-modal.min.js"></script>
  160. <script type="text/javascript" src="js/bootstrap-modalmanager.min.js"></script>
  161. <script type="text/javascript" src="jPlayer/jquery.jplayer.min.js"></script>
  162. <script type="text/javascript" src="js/imagesloaded.pkgd.min.js"></script>
  163. <script type="text/javascript" src="js/jquery.queryloader2.min.js"></script>
  164. <?php
  165. if ($aviary_active)
  166. {
  167. if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443)
  168. {
  169. ?>
  170. <script type="text/javascript" src="https://dme0ih8comzn4.cloudfront.net/js/feather.js"></script>
  171. <?php }else{ ?>
  172. <script type="text/javascript" src="http://feather.aviary.com/js/feather.js "></script>
  173. <?php
  174. }
  175. } ?>
  176. <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
  177. <!--[if lt IE 9]>
  178. <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2/html5shiv.js"></script>
  179. <![endif]-->
  180. <script src="js/jquery.ui.position.min.js" type="text/javascript"></script>
  181. <script src="js/jquery.contextMenu.min.js" type="text/javascript"></script>
  182. <script>
  183. var ext_img = new Array('<?php echo implode("','", $ext_img)?>');
  184. var allowed_ext = new Array('<?php echo implode("','", $ext)?>');
  185. var loading_bar =<?php echo $loading_bar?"true":"false"; ?>;
  186. var image_editor =<?php echo $aviary_active?"true":"false"; ?>;
  187. //dropzone config
  188. Dropzone.options.myAwesomeDropzone = {
  189. dictInvalidFileType: "<?php echo lang_Error_extension;?>",
  190. dictFileTooBig: "<?php echo lang_Error_Upload; ?>",
  191. dictResponseError: "SERVER ERROR",
  192. paramName: "file", // The name that will be used to transfer the file
  193. maxFilesize: <?php echo $MaxSizeUpload; ?>, // MB
  194. url: "upload.php",
  195. accept: function (file, done) {
  196. var extension = file.name.split('.').pop();
  197. extension = extension.toLowerCase();
  198. if ($.inArray(extension, allowed_ext) > -1) {
  199. done();
  200. }
  201. else {
  202. done("<?php echo lang_Error_extension;?>");
  203. }
  204. }
  205. };
  206. if (image_editor) {
  207. var featherEditor = new Aviary.Feather({
  208. apiKey: "<?php echo $aviary_key; ?>",
  209. apiVersion: <?php echo $aviary_version; ?>,
  210. language: "<?php echo $aviary_language; ?>",
  211. theme: 'light',
  212. tools: 'all',
  213. onSave: function (imageID, newURL) {
  214. show_animation();
  215. var img = document.getElementById(imageID);
  216. img.src = newURL;
  217. $.ajax({
  218. type: "POST",
  219. url: "ajax_calls.php?action=save_img",
  220. data: { url: newURL, path: $('#sub_folder').val() + $('#fldr_value').val(), name: $('#aviary_img').data('name') }
  221. }).done(function (msg) {
  222. featherEditor.close();
  223. d = new Date();
  224. $("figure[data-name='" + $('#aviary_img').data('name') + "']").find('img').each(function () {
  225. $(this).attr('src', $(this).attr('src') + "?" + d.getTime());
  226. });
  227. $("figure[data-name='" + $('#aviary_img').data('name') + "']").find('figcaption a.preview').each(function () {
  228. $(this).data('url', $(this).data('url') + "?" + d.getTime());
  229. });
  230. hide_animation();
  231. });
  232. return false;
  233. },
  234. onError: function (errorObj) {
  235. bootbox.alert(errorObj.message);
  236. }
  237. });
  238. }
  239. </script>
  240. <script type="text/javascript" src="js/include.min.js"></script>
  241. </head>
  242. <body>
  243. <input type="hidden" id="popup" value="<?php echo Tools::safeOutput($popup); ?>"/>
  244. <input type="hidden" id="view" value="<?php echo Tools::safeOutput($view); ?>"/>
  245. <input type="hidden" id="cur_dir" value="<?php echo Tools::safeOutput($cur_dir); ?>"/>
  246. <input type="hidden" id="cur_dir_thumb" value="<?php echo Tools::safeOutput($subdir); ?>"/>
  247. <input type="hidden" id="insert_folder_name" value="<?php echo Tools::safeOutput(lang_Insert_Folder_Name); ?>"/>
  248. <input type="hidden" id="new_folder" value="<?php echo Tools::safeOutput(lang_New_Folder); ?>"/>
  249. <input type="hidden" id="ok" value="<?php echo Tools::safeOutput(lang_OK); ?>"/>
  250. <input type="hidden" id="cancel" value="<?php echo Tools::safeOutput(lang_Cancel); ?>"/>
  251. <input type="hidden" id="rename" value="<?php echo Tools::safeOutput(lang_Rename); ?>"/>
  252. <input type="hidden" id="lang_duplicate" value="<?php echo Tools::safeOutput(lang_Duplicate); ?>"/>
  253. <input type="hidden" id="duplicate" value="<?php if ($duplicate_files) echo 1; else echo 0; ?>"/>
  254. <input type="hidden" id="base_url" value="<?php echo Tools::safeOutput($base_url) ?>"/>
  255. <input type="hidden" id="base_url_true" value="<?php echo base_url(); ?>"/>
  256. <input type="hidden" id="fldr_value" value="<?php echo Tools::safeOutput($subdir); ?>"/>
  257. <input type="hidden" id="sub_folder" value="<?php echo Tools::safeOutput($subfolder); ?>"/>
  258. <input type="hidden" id="file_number_limit_js" value="<?php echo Tools::safeOutput($file_number_limit_js); ?>"/>
  259. <input type="hidden" id="descending" value="<?php echo $descending ? "true" : "false"; ?>"/>
  260. <?php $protocol = 'http'; ?>
  261. <input type="hidden" id="current_url" value="<?php echo str_replace(array('&filter='.$filter), array(''), $protocol."://".$_SERVER['HTTP_HOST'].Tools::safeOutput($_SERVER['REQUEST_URI'])); ?>"/>
  262. <input type="hidden" id="lang_show_url" value="<?php echo Tools::safeOutput(lang_Show_url); ?>"/>
  263. <input type="hidden" id="lang_extract" value="<?php echo Tools::safeOutput(lang_Extract); ?>"/>
  264. <input type="hidden" id="lang_file_info" value="<?php echo fix_strtoupper(lang_File_info); ?>"/>
  265. <input type="hidden" id="lang_edit_image" value="<?php echo Tools::safeOutput(lang_Edit_image); ?>"/>
  266. <input type="hidden" id="transliteration" value="<?php echo $transliteration ? "true" : "false"; ?>"/>
  267. <?php if ($upload_files)
  268. {
  269. ?>
  270. <!----- uploader div start ------->
  271. <div class="uploader">
  272. <center>
  273. <button class="btn btn-inverse close-uploader">
  274. <i class="icon-backward icon-white"></i> <?php echo Tools::safeOutput(lang_Return_Files_List) ?></button>
  275. </center>
  276. <div class="space10"></div>
  277. <div class="space10"></div>
  278. <?php if ($java_upload){ ?>
  279. <div class="tabbable upload-tabbable"> <!-- Only required for left/right tabs -->
  280. <ul class="nav nav-tabs">
  281. <li class="active"><a href="#tab1" data-toggle="tab"><?php echo Tools::safeOutput(lang_Upload_base); ?></a></li>
  282. <li><a href="#tab2" id="uploader-btn" data-toggle="tab"><?php echo Tools::safeOutput(lang_Upload_java); ?></a></li>
  283. </ul>
  284. <div class="tab-content">
  285. <div class="tab-pane active" id="tab1">
  286. <?php } ?>
  287. <form action="dialog.php" method="post" enctype="multipart/form-data" id="myAwesomeDropzone" class="dropzone">
  288. <input type="hidden" name="path" value="<?php echo Tools::safeOutput($subfolder.$subdir); ?>"/>
  289. <input type="hidden" name="path_thumb" value="<?php echo Tools::safeOutput($subfolder.$subdir); ?>"/>
  290. <div class="fallback">
  291. <?php echo lang_Upload_file ?>:<br/>
  292. <input name="file" type="file"/>
  293. <input type="hidden" name="fldr" value="<?php echo Tools::safeOutput($subdir); ?>"/>
  294. <input type="hidden" name="view" value="<?php echo Tools::safeOutput($view); ?>"/>
  295. <input type="hidden" name="type" value="<?php echo Tools::safeOutput($_GET['type']); ?>"/>
  296. <input type="hidden" name="field_id" value="<?php echo (int)$_GET['field_id']; ?>"/>
  297. <input type="hidden" name="popup" value="<?php echo Tools::safeOutput($popup); ?>"/>
  298. <input type="hidden" name="lang" value="<?php echo Tools::safeOutput($lang); ?>"/>
  299. <input type="hidden" name="filter" value="<?php echo Tools::safeOutput($filter); ?>"/>
  300. <input type="submit" name="submit" value="<?php echo lang_OK ?>"/>
  301. </div>
  302. </form>
  303. <div class="upload-help"><?php echo Tools::safeOutput(lang_Upload_base_help); ?></div>
  304. <?php if ($java_upload){ ?>
  305. </div>
  306. <div class="tab-pane" id="tab2">
  307. <div id="iframe-container">
  308. </div>
  309. <div class="upload-help"><?php echo Tools::safeOutput(lang_Upload_java_help); ?></div>
  310. </div>
  311. <?php } ?>
  312. </div>
  313. </div>
  314. </div>
  315. <!----- uploader div start ------->
  316. <?php } ?>
  317. <div class="container-fluid">
  318. <?php
  319. $class_ext = '';
  320. $src = '';
  321. if ($_GET['type'] == 1) $apply = 'apply_img';
  322. elseif ($_GET['type'] == 2) $apply = 'apply_link';
  323. elseif ($_GET['type'] == 0 && $_GET['field_id'] == '') $apply = 'apply_none';
  324. elseif ($_GET['type'] == 3) $apply = 'apply_video';
  325. else $apply = 'apply';
  326. $files = scandir($current_path.$subfolder.$subdir);
  327. $n_files = count($files);
  328. //php sorting
  329. $sorted = array();
  330. $current_folder = array();
  331. $prev_folder = array();
  332. foreach ($files as $k => $file)
  333. {
  334. if ($file == ".") $current_folder = array('file' => $file);
  335. elseif ($file == "..") $prev_folder = array('file' => $file);
  336. elseif (is_dir($current_path.$subfolder.$subdir.$file))
  337. {
  338. $date = filemtime($current_path.$subfolder.$subdir.$file);
  339. $size = foldersize($current_path.$subfolder.$subdir.$file);
  340. $file_ext = lang_Type_dir;
  341. $sorted[$k] = array('file' => $file, 'date' => $date, 'size' => $size, 'extension' => $file_ext);
  342. } else
  343. {
  344. $file_path = $current_path.$subfolder.$subdir.$file;
  345. $date = filemtime($file_path);
  346. $size = filesize($file_path);
  347. $file_ext = substr(strrchr($file, '.'), 1);
  348. $sorted[$k] = array('file' => $file, 'date' => $date, 'size' => $size, 'extension' => $file_ext);
  349. }
  350. }
  351. function filenameSort($x, $y)
  352. {
  353. return $x['file'] < $y['file'];
  354. }
  355. function dateSort($x, $y)
  356. {
  357. return $x['date'] < $y['date'];
  358. }
  359. function sizeSort($x, $y)
  360. {
  361. return $x['size'] - $y['size'];
  362. }
  363. function extensionSort($x, $y)
  364. {
  365. return $x['extension'] < $y['extension'];
  366. }
  367. switch ($sort_by)
  368. {
  369. case 'name':
  370. usort($sorted, 'filenameSort');
  371. break;
  372. case 'date':
  373. usort($sorted, 'dateSort');
  374. break;
  375. case 'size':
  376. usort($sorted, 'sizeSort');
  377. break;
  378. case 'extension':
  379. usort($sorted, 'extensionSort');
  380. break;
  381. default:
  382. break;
  383. }
  384. if ($descending)
  385. {
  386. $sorted = array_reverse($sorted);
  387. }
  388. $files = array_merge(array($prev_folder), array($current_folder), $sorted);
  389. ?>
  390. <!----- header div start ------->
  391. <div class="navbar navbar-fixed-top">
  392. <div class="navbar-inner">
  393. <div class="container-fluid">
  394. <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
  395. <span class="icon-bar"></span>
  396. <span class="icon-bar"></span>
  397. <span class="icon-bar"></span>
  398. </button>
  399. <div class="brand"><?php echo Tools::safeOutput(lang_Toolbar); ?> -></div>
  400. <div class="nav-collapse collapse">
  401. <div class="filters">
  402. <div class="row-fluid">
  403. <div class="span3 half">
  404. <span><?php echo Tools::safeOutput(lang_Actions); ?>:</span>
  405. <?php if ($upload_files)
  406. {
  407. ?>
  408. <button class="tip btn upload-btn" title="<?php echo Tools::safeOutput(lang_Upload_file); ?>">
  409. <i class="icon-plus"></i><i class="icon-file"></i></button>
  410. <?php } ?>
  411. <?php if ($create_folders)
  412. {
  413. ?>
  414. <button class="tip btn new-folder" title="<?php echo Tools::safeOutput(lang_New_Folder) ?>">
  415. <i class="icon-plus"></i><i class="icon-folder-open"></i></button>
  416. <?php } ?>
  417. </div>
  418. <div class="span3 half view-controller">
  419. <span><?php echo lang_View; ?>:</span>
  420. <button class="btn tip<?php if ($view == 0) echo " btn-inverse"; ?>" id="view0" data-value="0" title="<?php echo Tools::safeOutput(lang_View_boxes); ?>">
  421. <i class="icon-th <?php if ($view == 0) echo "icon-white"; ?>"></i></button>
  422. <button class="btn tip<?php if ($view == 1) echo " btn-inverse"; ?>" id="view1" data-value="1" title="<?php echo Tools::safeOutput(lang_View_list); ?>">
  423. <i class="icon-align-justify <?php if ($view == 1) echo "icon-white"; ?>"></i>
  424. </button>
  425. <button class="btn tip<?php if ($view == 2) echo " btn-inverse"; ?>" id="view2" data-value="2" title="<?php echo Tools::safeOutput(lang_View_columns_list); ?>">
  426. <i class="icon-fire <?php if ($view == 2) echo "icon-white"; ?>"></i></button>
  427. </div>
  428. <div class="span6 types">
  429. <span><?php echo Tools::safeOutput(lang_Filters); ?>:</span>
  430. <?php if ($_GET['type'] != 1 && $_GET['type'] != 3)
  431. {
  432. ?>
  433. <input id="select-type-1" name="radio-sort" type="radio" data-item="ff-item-type-1" checked="checked" class="hide"/>
  434. <label id="ff-item-type-1" title="<?php echo Tools::safeOutput(lang_Files); ?>" for="select-type-1" class="tip btn ff-label-type-1"><i class="icon-file"></i></label>
  435. <input id="select-type-2" name="radio-sort" type="radio" data-item="ff-item-type-2" class="hide"/>
  436. <label id="ff-item-type-2" title="<?php echo Tools::safeOutput(lang_Images); ?>" for="select-type-2" class="tip btn ff-label-type-2"><i class="icon-picture"></i></label>
  437. <input id="select-type-3" name="radio-sort" type="radio" data-item="ff-item-type-3" class="hide"/>
  438. <label id="ff-item-type-3" title="<?php echo Tools::safeOutput(lang_Archives); ?>" for="select-type-3" class="tip btn ff-label-type-3"><i class="icon-inbox"></i></label>
  439. <input id="select-type-4" name="radio-sort" type="radio" data-item="ff-item-type-4" class="hide"/>
  440. <label id="ff-item-type-4" title="<?php echo Tools::safeOutput(lang_Videos); ?>" for="select-type-4" class="tip btn ff-label-type-4"><i class="icon-film"></i></label>
  441. <input id="select-type-5" name="radio-sort" type="radio" data-item="ff-item-type-5" class="hide"/>
  442. <label id="ff-item-type-5" title="<?php echo Tools::safeOutput(lang_Music); ?>" for="select-type-5" class="tip btn ff-label-type-5"><i class="icon-music"></i></label>
  443. <?php } ?>
  444. <input accesskey="f" type="text" class="filter-input" id="filter-input" name="filter" placeholder="<?php echo fix_strtolower(lang_Text_filter); ?>..." value="<?php echo Tools::safeOutput($filter); ?>"/><?php if ($n_files > $file_number_limit_js)
  445. {
  446. ?><label id="filter" class="btn"><i class="icon-play"></i></label><?php } ?>
  447. <input id="select-type-all" name="radio-sort" type="radio" data-item="ff-item-type-all" class="hide"/>
  448. <label id="ff-item-type-all" title="<?php echo Tools::safeOutput(lang_All); ?>" <?php if (Tools::getValue('type') == 1 || Tools::getValue('type') == 3){ ?>style="visibility: hidden;" <?php } ?> data-item="ff-item-type-all" for="select-type-all" style="margin-rigth:0px;" class="tip btn btn-inverse ff-label-type-all"><i class="icon-align-justify icon-white"></i></label>
  449. </div>
  450. </div>
  451. </div>
  452. </div>
  453. </div>
  454. </div>
  455. </div>
  456. <!----- header div end ------->
  457. <!----- breadcrumb div start ------->
  458. <div class="row-fluid">
  459. <?php
  460. $link = "dialog.php?".$get_params;
  461. ?>
  462. <ul class="breadcrumb">
  463. <li class="pull-left"><a href="<?php echo Tools::safeOutput($link) ?>/"><i class="icon-home"></i></a></li>
  464. <li><span class="divider">/</span></li>
  465. <?php
  466. $bc = explode("/", $subdir);
  467. $tmp_path = '';
  468. if (!empty($bc))
  469. foreach ($bc as $k => $b)
  470. {
  471. $tmp_path .= $b."/";
  472. if ($k == count($bc) - 2)
  473. {
  474. ?>
  475. <li class="active"><?php echo Tools::safeOutput($b) ?></li><?php
  476. } elseif ($b != "")
  477. {
  478. ?>
  479. <li><a href="<?php echo Tools::safeOutput($link.$tmp_path)?>"><?php echo Tools::safeOutput($b) ?></a></li>
  480. <li><span class="divider"><?php echo "/"; ?></span></li>
  481. <?php
  482. }
  483. }
  484. ?>
  485. <li class="pull-right">
  486. <a class="btn-small" href="javascript:void('')" id="info"><i class="icon-question-sign"></i></a></li>
  487. <li class="pull-right">
  488. <a id="refresh" class="btn-small" href="dialog.php?<?php echo Tools::safeOutput($get_params.$subdir."&".uniqid()) ?>"><i class="icon-refresh"></i></a>
  489. </li>
  490. <li class="pull-right">
  491. <div class="btn-group">
  492. <a class="btn dropdown-toggle sorting-btn" data-toggle="dropdown" href="#">
  493. <i class="icon-signal"></i>
  494. <span class="caret"></span>
  495. </a>
  496. <ul class="dropdown-menu pull-left sorting">
  497. <li>
  498. <center><strong><?php echo Tools::safeOutput(lang_Sorting) ?></strong></center>
  499. </li>
  500. <li><a class="sorter sort-name <?php if ($sort_by == "name")
  501. {
  502. echo ($descending) ? "descending" : "ascending";
  503. } ?>" href="javascript:void('')" data-sort="name"><?php echo Tools::safeOutput(lang_Filename); ?></a></li>
  504. <li><a class="sorter sort-date <?php if ($sort_by == "date")
  505. {
  506. echo ($descending) ? "descending" : "ascending";
  507. } ?>" href="javascript:void('')" data-sort="date"><?php echo Tools::safeOutput(lang_Date); ?></a></li>
  508. <li><a class="sorter sort-size <?php if ($sort_by == "size")
  509. {
  510. echo ($descending) ? "descending" : "ascending";
  511. } ?>" href="javascript:void('')" data-sort="size"><?php echo Tools::safeOutput(lang_Size); ?></a></li>
  512. <li><a class="sorter sort-extension <?php if ($sort_by == "extension")
  513. {
  514. echo ($descending) ? "descending" : "ascending";
  515. } ?>" href="javascript:void('')" data-sort="extension"><?php echo Tools::safeOutput(lang_Type); ?></a></li>
  516. </ul>
  517. </div>
  518. </li>
  519. </ul>
  520. </div>
  521. <!----- breadcrumb div end ------->
  522. <div class="row-fluid ff-container">
  523. <div class="span12">
  524. <?php if (@opendir($current_path.$subfolder.$subdir) === false){ ?>
  525. <br/>
  526. <div class="alert alert-error">There is an error! The upload folder there isn't. Check your config.php file.
  527. </div>
  528. <?php }else{ ?>
  529. <h4 id="help"><?php echo Tools::safeOutput(lang_Swipe_help); ?></h4>
  530. <?php if (isset($folder_message))
  531. {
  532. ?>
  533. <div class="alert alert-block"><?php echo Tools::safeOutput($folder_message); ?></div>
  534. <?php } ?>
  535. <?php if ($show_sorting_bar)
  536. {
  537. ?>
  538. <!-- sorter -->
  539. <div class="sorter-container <?php echo "list-view".Tools::safeOutput($view); ?>">
  540. <div class="file-name"><a class="sorter sort-name <?php if ($sort_by == "name")
  541. {
  542. echo ($descending) ? "descending" : "ascending";
  543. } ?>" href="javascript:void('')" data-sort="name"><?php echo Tools::safeOutput(lang_Filename); ?></a></div>
  544. <div class="file-date"><a class="sorter sort-date <?php if ($sort_by == "date")
  545. {
  546. echo ($descending) ? "descending" : "ascending";
  547. } ?>" href="javascript:void('')" data-sort="date"><?php echo Tools::safeOutput(lang_Date); ?></a></div>
  548. <div class="file-size"><a class="sorter sort-size <?php if ($sort_by == "size")
  549. {
  550. echo ($descending) ? "descending" : "ascending";
  551. } ?>" href="javascript:void('')" data-sort="size"><?php echo Tools::safeOutput(lang_Size); ?></a></div>
  552. <div class='img-dimension'><?php echo Tools::safeOutput(lang_Dimension); ?></div>
  553. <div class='file-extension'><a class="sorter sort-extension <?php if ($sort_by == "extension")
  554. {
  555. echo ($descending) ? "descending" : "ascending";
  556. } ?>" href="javascript:void('')" data-sort="extension"><?php echo Tools::safeOutput(lang_Type); ?></a></div>
  557. <div class='file-operations'><?php echo Tools::safeOutput(lang_Operations); ?></div>
  558. </div>
  559. <?php } ?>
  560. <input type="hidden" id="file_number" value="<?php echo Tools::safeOutput($n_files); ?>"/>
  561. <!--ul class="thumbnails ff-items"-->
  562. <ul class="grid cs-style-2 <?php echo "list-view".Tools::safeOutput($view); ?>">
  563. <?php
  564. $jplayer_ext = array(
  565. "mp4",
  566. "flv",
  567. "webmv",
  568. "webma",
  569. "webm",
  570. "m4a",
  571. "m4v",
  572. "ogv",
  573. "oga",
  574. "mp3",
  575. "midi",
  576. "mid",
  577. "ogg",
  578. "wav"
  579. );
  580. foreach ($files as $file_array)
  581. {
  582. $file = $file_array['file'];
  583. if ($file == '.' || (isset($file_array['extension']) && $file_array['extension'] != lang_Type_dir) || ($file == '..' && $subdir == '') || in_array($file, $hidden_folders) || ($filter != '' && $file != ".." && strpos($file, $filter) === false))
  584. continue;
  585. $new_name = fix_filename($file, $transliteration);
  586. if ($file != '..' && $file != $new_name)
  587. {
  588. //rename
  589. rename_folder($current_path.$subdir.$new_name, $new_name, $transliteration);
  590. $file = $new_name;
  591. }
  592. //add in thumbs folder if not exist
  593. if (!file_exists($thumbs_path.$subdir.$file)) create_folder(false, $thumbs_path.$subdir.$file);
  594. $class_ext = 3;
  595. if ($file == '..' && trim($subdir) != '')
  596. {
  597. $src = explode("/", $subdir);
  598. unset($src[count($src) - 2]);
  599. $src = implode("/", $src);
  600. if ($src == '') $src = "/";
  601. } elseif ($file != '..')
  602. {
  603. $src = $subdir.$file."/";
  604. }
  605. ?>
  606. <li data-name="<?php echo Tools::safeOutput($file) ?>" <?php if ($file == '..') echo 'class="back"'; else echo 'class="dir"'; ?>>
  607. <figure data-name="<?php echo Tools::safeOutput($file) ?>" class="<?php if ($file == "..") echo "back-"; ?>directory" data-type="<?php if ($file != "..")
  608. {
  609. echo "dir";
  610. } ?>">
  611. <a class="folder-link" href="dialog.php?<?php echo $get_params.rawurlencode($src)."&".uniqid() ?>">
  612. <div class="img-precontainer">
  613. <div class="img-container directory"><span></span>
  614. <img class="directory-img" src="img/<?php echo Tools::safeOutput($icon_theme); ?>/folder<?php if ($file == "..")
  615. {
  616. echo "_back";
  617. } ?>.jpg" alt="folder"/>
  618. </div>
  619. </div>
  620. <div class="img-precontainer-mini directory">
  621. <div class="img-container-mini">
  622. <span></span>
  623. <img class="directory-img" src="img/<?php echo Tools::safeOutput($icon_theme); ?>/folder<?php if ($file == "..")
  624. {
  625. echo "_back";
  626. } ?>.png" alt="folder"/>
  627. </div>
  628. </div>
  629. <?php if ($file == ".."){ ?>
  630. <div class="box no-effect">
  631. <h4><?php echo Tools::safeOutput(lang_Back) ?></h4>
  632. </div>
  633. </a>
  634. <?php
  635. } else
  636. {
  637. ?>
  638. </a>
  639. <div class="box">
  640. <h4 class="<?php if ($ellipsis_title_after_first_row)
  641. {
  642. echo "ellipsis";
  643. } ?>">
  644. <a class="folder-link" data-file="<?php echo Tools::safeOutput($file) ?>" href="dialog.php?<?php echo Tools::safeOutput($get_params.rawurlencode($src)."&".uniqid()) ?>"><?php echo Tools::safeOutput($file); ?></a>
  645. </h4>
  646. </div>
  647. <input type="hidden" class="name" value=""/>
  648. <input type="hidden" class="date" value="<?php echo Tools::safeOutput($file_array['date']); ?>"/>
  649. <input type="hidden" class="size" value="<?php echo Tools::safeOutput($file_array['size']); ?>"/>
  650. <input type="hidden" class="extension" value="<?php echo lang_Type_dir; ?>"/>
  651. <div class="file-date"><?php echo date(lang_Date_type, $file_array['date']) ?></div>
  652. <?php if ($show_folder_size)
  653. {
  654. ?>
  655. <div class="file-size"><?php echo makeSize($file_array['size']) ?></div><?php } ?>
  656. <div class='file-extension'><?php echo lang_Type_dir; ?></div>
  657. <figcaption>
  658. <a href="javascript:void('')" class="tip-left edit-button <?php if ($rename_folders) echo "rename-folder"; ?>" title="<?php echo lang_Rename ?>" data-path="<?php echo Tools::safeOutput($subfolder.$subdir.$file); ?>" data-thumb="<?php echo Tools::safeOutput($subdir.$file); ?>">
  659. <i class="icon-pencil <?php if (!$rename_folders) echo 'icon-white'; ?>"></i></a>
  660. <a href="javascript:void('')" class="tip-left erase-button <?php if ($delete_folders) echo "delete-folder"; ?>" title="<?php echo lang_Erase ?>" data-confirm="<?php echo lang_Confirm_Folder_del; ?>" data-path="<?php echo Tools::safeOutput($subfolder.$subdir.$file); ?>" data-thumb="<?php echo Tools::safeOutput($subdir.$file); ?>">
  661. <i class="icon-trash <?php if (!$delete_folders) echo 'icon-white'; ?>"></i>
  662. </a>
  663. </figcaption>
  664. <?php } ?>
  665. </figure>
  666. </li>
  667. <?php
  668. }
  669. foreach ($files as $nu => $file_array) {
  670. $file = $file_array['file'];
  671. if ($file == '.' || $file == '..' || is_dir($current_path.$subfolder.$subdir.$file) || in_array($file, $hidden_files) || !in_array(fix_strtolower($file_array['extension']), $ext) || ($filter != '' && strpos($file, $filter) === false))
  672. continue;
  673. $file_path = $current_path.$subfolder.$subdir.$file;
  674. //check if file have illegal caracter
  675. $filename = substr($file, 0, '-'.(strlen($file_array['extension']) + 1));
  676. if ($file != fix_filename($file, $transliteration))
  677. {
  678. $file1 = fix_filename($file, $transliteration);
  679. $file_path1 = ($current_path.$subfolder.$subdir.$file1);
  680. if (file_exists($file_path1))
  681. {
  682. $i = 1;
  683. $info = pathinfo($file1);
  684. while (file_exists($current_path.$subfolder.$subdir.$info['filename'].".[".$i."].".$info['extension']))
  685. {
  686. $i++;
  687. }
  688. $file1 = $info['filename'].".[".$i."].".$info['extension'];
  689. $file_path1 = ($current_path.$subfolder.$subdir.$file1);
  690. }
  691. $filename = substr($file1, 0, '-'.(strlen($file_array['extension']) + 1));
  692. rename_file($file_path, fix_filename($filename, $transliteration), $transliteration);
  693. $file = $file1;
  694. $file_array['extension'] = fix_filename($file_array['extension'], $transliteration);
  695. $file_path = $file_path1;
  696. }
  697. $is_img = false;
  698. $is_video = false;
  699. $is_audio = false;
  700. $show_original = false;
  701. $show_original_mini = false;
  702. $mini_src = "";
  703. $src_thumb = "";
  704. $extension_lower = fix_strtolower($file_array['extension']);
  705. if (in_array($extension_lower, $ext_img))
  706. {
  707. $src = $base_url.$cur_dir.rawurlencode($file);
  708. $mini_src = $src_thumb = $thumbs_path.$subdir.$file;
  709. if (strpos($src_thumb, _PS_ROOT_DIR_) === 0)
  710. $mini = $thumb = __PS_BASE_URI__.substr($thumbs_path.$subdir.$file, strlen(_PS_ROOT_DIR_) + 1);
  711. //add in thumbs folder if not exist
  712. if (!file_exists($src_thumb))
  713. {
  714. try
  715. {
  716. create_img_gd($file_path, $src_thumb, 122, 91);
  717. new_thumbnails_creation($current_path.$subfolder.$subdir, $file_path, $file, $current_path, $relative_image_creation, $relative_path_from_current_pos, $relative_image_creation_name_to_prepend, $relative_image_creation_name_to_append, $relative_image_creation_width, $relative_image_creation_height, $fixed_image_creation, $fixed_path_from_filemanager, $fixed_image_creation_name_to_prepend, $fixed_image_creation_to_append, $fixed_image_creation_width, $fixed_image_creation_height);
  718. } catch (Exception $e)
  719. {
  720. $src_thumb = $mini_src = "";
  721. }
  722. }
  723. $is_img = true;
  724. //check if is smaller than thumb
  725. list($img_width, $img_height, $img_type, $attr) = getimagesize($file_path);
  726. if ($img_width < 122 && $img_height < 91)
  727. {
  728. $src_thumb = $current_path.$subfolder.$subdir.$file;
  729. $show_original = true;
  730. }
  731. if ($img_width < 45 && $img_height < 38)
  732. {
  733. $mini_src = $current_path.$subfolder.$subdir.$file;
  734. $show_original_mini = true;
  735. }
  736. }
  737. $is_icon_thumb = false;
  738. $is_icon_thumb_mini = false;
  739. $no_thumb = false;
  740. if ($src_thumb == "")
  741. {
  742. $no_thumb = true;
  743. if (file_exists('img/'.$icon_theme.'/'.$extension_lower.".jpg"))
  744. {
  745. $src_thumb = 'img/'.$icon_theme.'/'.$extension_lower.".jpg";
  746. } else
  747. {
  748. $src_thumb = "img/".$icon_theme."/default.jpg";
  749. }
  750. $is_icon_thumb = true;
  751. }
  752. if ($mini_src == "")
  753. {
  754. $is_icon_thumb_mini = false;
  755. }
  756. $class_ext = 0;
  757. if (in_array($extension_lower, $ext_video))
  758. {
  759. $class_ext = 4;
  760. $is_video = true;
  761. } elseif (in_array($extension_lower, $ext_img))
  762. {
  763. $class_ext = 2;
  764. } elseif (in_array($extension_lower, $ext_music))
  765. {
  766. $class_ext = 5;
  767. $is_audio = true;
  768. } elseif (in_array($extension_lower, $ext_misc))
  769. {
  770. $class_ext = 3;
  771. } else
  772. {
  773. $class_ext = 1;
  774. }
  775. if ((!(Tools::getValue('type') == 1 && !$is_img) && !((Tools::getValue('type') == 3 && !$is_video) && (Tools::getValue('type') == 3 && !$is_audio))) && $class_ext > 0){
  776. ?>
  777. <li class="ff-item-type-<?php echo Tools::safeOutput($class_ext); ?> file" data-name="<?php echo Tools::safeOutput($file); ?>">
  778. <figure data-name="<?php echo Tools::safeOutput($file) ?>" data-type="<?php if ($is_img)
  779. {
  780. echo "img";
  781. } else
  782. {
  783. echo "file";
  784. } ?>">
  785. <a href="javascript:void('')" class="link" data-file="<?php echo Tools::safeOutput($file); ?>" data-field_id="" data-function="<?php echo Tools::safeOutput($apply); ?>">
  786. <div class="img-precontainer">
  787. <?php if ($is_icon_thumb)
  788. {
  789. ?>
  790. <div class="filetype"><?php echo $extension_lower ?></div><?php } ?>
  791. <div class="img-container">
  792. <span></span>
  793. <img alt="<?php echo Tools::safeOutput($filename." thumbnails"); ?>" class="<?php echo $show_original ? "original" : "" ?> <?php echo $is_icon_thumb ? "icon" : "" ?>" src="<?php echo Tools::safeOutput($thumb); ?>">
  794. </div>
  795. </div>
  796. <div class="img-precontainer-mini <?php if ($is_img) echo 'original-thumb' ?>">
  797. <div class="filetype <?php echo $extension_lower ?> <?php if (!$is_icon_thumb)
  798. {
  799. echo "hide";
  800. } ?>"><?php echo $extension_lower ?></div>
  801. <div class="img-container-mini">
  802. <span></span>
  803. <?php if ($mini_src != "")
  804. {
  805. ?>
  806. <img alt="<?php echo Tools::safeOutput($filename." thumbnails"); ?>" class="<?php echo $show_original_mini ? "original" : "" ?> <?php echo $is_icon_thumb_mini ? "icon" : "" ?>" src="<?php echo Tools::safeOutput($mini); ?>">
  807. <?php } ?>
  808. </div>
  809. </div>
  810. <?php if ($is_icon_thumb)
  811. {
  812. ?>
  813. <div class="cover"></div>
  814. <?php } ?>
  815. </a>
  816. <div class="box">
  817. <h4 class="<?php if ($ellipsis_title_after_first_row)
  818. {
  819. echo "ellipsis";
  820. } ?>">
  821. <a href="javascript:void('')" class="link" data-file="<?php echo Tools::safeOutput($file); ?>" data-field_id="" data-function="<?php echo Tools::safeOutput($apply); ?>">
  822. <?php echo Tools::safeOutput($filename); ?></a></h4>
  823. </div>
  824. <input type="hidden" class="date" value="<?php echo $file_array['date']; ?>"/>
  825. <input type="hidden" class="size" value="<?php echo $file_array['size'] ?>"/>
  826. <input type="hidden" class="extension" value="<?php echo $extension_lower; ?>"/>
  827. <input type="hidden" class="name" value=""/>
  828. <div class="file-date"><?php echo date(lang_Date_type, $file_array['date']) ?></div>
  829. <div class="file-size"><?php echo makeSize($file_array['size']) ?></div>
  830. <div class='img-dimension'><?php if ($is_img)
  831. {
  832. echo $img_width."x".$img_height;
  833. } ?></div>
  834. <div class='file-extension'><?php echo Tools::safeOutput($extension_lower); ?></div>
  835. <figcaption>
  836. <form action="force_download.php" method="post" class="download-form" id="form<?php echo Tools::safeOutput($nu); ?>">
  837. <input type="hidden" name="path" value="<?php echo Tools::safeOutput($subfolder.$subdir) ?>"/>
  838. <input type="hidden" class="name_download" name="name" value="<?php echo Tools::safeOutput($file) ?>"/>
  839. <a title="<?php echo lang_Download ?>" class="tip-right" href="javascript:void('')" onclick="$('#form<?php echo Tools::safeOutput($nu); ?>').submit();"><i class="icon-download"></i></a>
  840. <?php if ($is_img && $src_thumb != "")
  841. {
  842. ?>
  843. <a class="tip-right preview" title="<?php echo lang_Preview ?>" data-url="<?php echo Tools::safeOutput($src); ?>" data-toggle="lightbox" href="#previewLightbox"><i class=" icon-eye-open"></i></a>
  844. <?php
  845. } elseif (($is_video || $is_audio) && in_array($extension_lower, $jplayer_ext))
  846. {
  847. ?>
  848. <a class="tip-right modalAV <?php if ($is_audio)
  849. {
  850. echo "audio";
  851. } else
  852. {
  853. echo "video";
  854. } ?>"
  855. title="<?php echo lang_Preview ?>" data-url="ajax_calls.php?action=media_preview&title=<?php echo Tools::safeOutput($filename); ?>&file=<?php echo Tools::safeOutput($current_path.$subfolder.$subdir.$file); ?>"
  856. href="javascript:void('');"><i class=" icon-eye-open"></i></a>
  857. <?php
  858. } else
  859. {
  860. ?>
  861. <a class="preview disabled"><i class="icon-eye-open icon-white"></i></a>
  862. <?php } ?>
  863. <a href="javascript:void('')" class="tip-left edit-button <?php if ($rename_files) echo "rename-file"; ?>" title="<?php echo lang_Rename ?>" data-path="<?php echo Tools::safeOutput($subfolder.$subdir.$file); ?>" data-thumb="<?php echo Tools::safeOutput($subdir.$file); ?>">
  864. <i class="icon-pencil <?php if (!$rename_files) echo 'icon-white'; ?>"></i></a>
  865. <a href="javascript:void('')" class="tip-left erase-button <?php if ($delete_files) echo "delete-file"; ?>" title="<?php echo lang_Erase ?>" data-confirm="<?php echo lang_Confirm_del; ?>" data-path="<?php echo Tools::safeOutput($subfolder.$subdir.$file); ?>" data-thumb="<?php echo Tools::safeOutput($subdir.$file); ?>">
  866. <i class="icon-trash <?php if (!$delete_files) echo 'icon-white'; ?>"></i>
  867. </a>
  868. </form>
  869. </figcaption>
  870. </figure>
  871. </li>
  872. <?php
  873. }
  874. }
  875. ?></div>
  876. </ul>
  877. <?php } ?>
  878. </div>
  879. </div>
  880. </div>
  881. <!----- lightbox div start ------->
  882. <div id="previewLightbox" class="lightbox hide fade" tabindex="-1" role="dialog" aria-hidden="true">
  883. <div class='lightbox-content'>
  884. <img id="full-img" src="">
  885. </div>
  886. </div>
  887. <!----- lightbox div end ------->
  888. <!----- loading div start ------->
  889. <div id="loading_container" style="display:none;">
  890. <div id="loading" style="background-color:#000; position:fixed; width:100%; height:100%; top:0px; left:0px;z-index:100000"></div>
  891. <img id="loading_animation" src="img/storing_animation.gif" alt="loading" style="z-index:10001; margin-left:-32px; margin-top:-32px; position:fixed; left:50%; top:50%"/>
  892. </div>
  893. <!----- loading div end ------->
  894. <!----- player div start ------->
  895. <div class="modal hide fade" id="previewAV">
  896. <div class="modal-header">
  897. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  898. <h3><?php echo lang_Preview; ?></h3>
  899. </div>
  900. <div class="modal-body">
  901. <div class="row-fluid body-preview">
  902. </div>
  903. </div>
  904. </div>
  905. <!----- player div end ------->
  906. <img id='aviary_img' src='' class="hide"/>
  907. </body>
  908. </html>
  909. <?php } ?>