fm_dir.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. require_once(MODULES."/litefm/functions.php");
  25. require_once(MODULES."/litefm/litefm.php");
  26. function exec_ogp_module()
  27. {
  28. $home_id = $_REQUEST['home_id'];
  29. if (empty($home_id))
  30. {
  31. print_failure( get_lang("home_id_missing") );
  32. return;
  33. }
  34. global $db, $view, $settings;
  35. $isAdmin = $db->isAdmin( $_SESSION['user_id'] );
  36. if($isAdmin)
  37. $home_cfg = $db->getGameHome($home_id);
  38. else
  39. $home_cfg = $db->getUserGameHome($_SESSION['user_id'],$home_id);
  40. if ($home_cfg === FALSE)
  41. {
  42. print_failure( get_lang("no_access_to_home") );
  43. return;
  44. }
  45. if ( preg_match("/f/",$home_cfg['access_rights']) != 1 )
  46. {
  47. print_failure( get_lang("no_rights") );
  48. echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id=".$home_cfg['home_id']."'><< ". get_lang("back") ."</a></td></tr></table>";
  49. return;
  50. }
  51. litefm_check($home_id);
  52. $remote = new OGPRemoteLibrary($home_cfg['agent_ip'], $home_cfg['agent_port'], $home_cfg['encryption_key'], $home_cfg['timeout']);
  53. $os_string = $remote->what_os();
  54. $os = preg_match("/Linux/i", $os_string) ? "linux" : "windows";
  55. // We must always add the home directory to the fm_cwd so that user
  56. // can not go out of the homedir.
  57. $path = clean_path($home_cfg['home_path']."/".@$_SESSION['fm_cwd_'.$home_id]);
  58. if (!$remote->rfile_exists($path))
  59. {
  60. while(!$remote->rfile_exists($path))
  61. {
  62. $_SESSION['fm_cwd_'.$home_id] = dirname($_SESSION['fm_cwd_'.$home_id]);
  63. $path = clean_path($home_cfg['home_path']."/".@$_SESSION['fm_cwd_'.$home_id]);
  64. if($path == clean_path($home_cfg['home_path']."/"))
  65. {
  66. print_failure(get_lang_f("dir_not_found",$path));
  67. echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id=".$home_cfg['home_id']."'><< ". back ."</a></td></tr></table>";
  68. return;
  69. }
  70. }
  71. }
  72. // Get File Operations Keys
  73. $fo_keys = get_file_operations_keys();
  74. // Get File Operations Settings
  75. $fo = get_fo_settings($settings,$fo_keys);
  76. $upload_folder_path = "modules/litefm/uploads/home_id_$home_id";
  77. // PHP post_max_size handling
  78. $PMS_bytes = return_bytes(ini_get('post_max_size'));
  79. if(isset($_SERVER['CONTENT_LENGTH']) AND $_SERVER['CONTENT_LENGTH'] > $PMS_bytes and $fo['upload'] == "1")
  80. {
  81. $error['post_max_size'] = "The uploaded file(s) size exceed the post_max_size directive in php.ini (".ini_get('post_max_size').").";
  82. echo json_encode( array( 'error' => $error ) );
  83. }
  84. // Get web to agent transfer progress
  85. elseif( isset( $_GET['pid'] ) and $_GET['pid'] != "" and $fo['upload'] == "1" )
  86. {
  87. $bytes = $_GET['size'];
  88. $totalsize = $bytes / 1024;
  89. $filename = $_GET['filename'];
  90. $kbytes = $remote->rsync_progress( clean_path( $path."/".$filename ) );
  91. list($totalsize,$mbytes,$pct) = explode(";",do_progress($kbytes,$totalsize));
  92. $totalmbytes = round($totalsize / 1024, 2);
  93. $pct = $pct > 100 ? 100 : $pct;
  94. $complete = false;
  95. if ( $remote->is_file_download_in_progress( $_GET['pid'] ) == 0 )
  96. {
  97. $dest_file_path = clean_path( $upload_folder_path . "/" . $filename . ".txt" );
  98. unlink($dest_file_path);
  99. $directory = dir($upload_folder_path);
  100. $directory_empty = TRUE;
  101. while ((FALSE !== ($item = $directory->read())) && ( ! isset($directory_not_empty)))
  102. {
  103. if ($item != '.' && $item != '..')
  104. {
  105. $directory_empty = FALSE;
  106. }
  107. }
  108. $directory->close();
  109. if( $directory_empty )
  110. rmdir( $upload_folder_path );
  111. $db->logger(get_lang("upload_complete") . ": " . clean_path( $path . "/" . $filename ));
  112. $complete = true;
  113. }
  114. echo json_encode(array('pct' => $pct,
  115. 'complete' => $complete));
  116. }
  117. // Upload File(s)
  118. elseif( isset( $_POST['upload'] ) and $fo['upload'] == "1" )
  119. {
  120. $error = FALSE;
  121. foreach ( $_FILES['files']['error'] as $i => $error_code )
  122. {
  123. if($error_code > 0)
  124. {
  125. $error['error_message'][$i] = codeToMessage($error_code,$_FILES['files']['name'][$i]);
  126. }
  127. }
  128. if( is_array($error) )
  129. {
  130. echo json_encode( array( 'error' => $error ) );
  131. }
  132. // Save uploaded file to the website and start file download from the agent
  133. else
  134. {
  135. if( ! file_exists( $upload_folder_path ) )
  136. {
  137. if( ! mkdir($upload_folder_path, 0777, true) )
  138. {
  139. echo json_encode(array('error' => get_lang_f('can_not_create_upload_folder_path', "\n(".$upload_folder_path.")" )));
  140. return;
  141. }
  142. }
  143. $count = 0;
  144. $s = ( isset($_SERVER['HTTPS']) and get_true_boolean($_SERVER['HTTPS']) ) ? "s" : "";
  145. $p = (isset($_SERVER['SERVER_PORT']) and $_SERVER['SERVER_PORT'] != "80") ? ":".$_SERVER['SERVER_PORT'] : "";
  146. $url = 'http'.$s.'://'.$_SERVER['SERVER_NAME'].$p.$_SERVER['SCRIPT_NAME'];
  147. // loop all files
  148. foreach ( $_FILES['files']['name'] as $i => $name )
  149. {
  150. // if file not uploaded then skip it
  151. if ( !is_uploaded_file($_FILES['files']['tmp_name'][$i]) )
  152. continue;
  153. // now we can move uploaded files
  154. $bad_chars = preg_replace( "/([[:alnum:]_\.-]*)/", "", $_FILES['files']['name'][$i] );
  155. $bad_arr = str_split( $bad_chars );
  156. $filename = str_replace( $bad_arr, "", $_FILES['files']['name'][$i] );
  157. $dest_file_path = clean_path( $upload_folder_path . "/" . $filename . ".txt" );
  158. $file_url = str_replace( "home.php", $dest_file_path, $url );
  159. if( file_exists( $dest_file_path ) )
  160. unlink($dest_file_path);
  161. if( move_uploaded_file( $_FILES["files"]["tmp_name"][$i], $dest_file_path ) )
  162. {
  163. $remote_file_path = clean_path( $path . "/" . $filename );
  164. if( $remote->rfile_exists($remote_file_path) )
  165. $remote->shell_action('remove_file', $remote_file_path);
  166. $pid = $remote->start_file_download( $file_url, $path, $filename );
  167. $files[$count] = array('filename' => $filename,
  168. 'size' => $_FILES['files']['size'][$i],
  169. 'pid' => $pid);
  170. $count++;
  171. }
  172. }
  173. echo json_encode(array('count' => $count,
  174. 'files' => $files));
  175. }
  176. }
  177. // Create Folder
  178. elseif( isset( $_POST['create_folder'] ) and $fo['create_folder'] == "1" )
  179. {
  180. $folder_name = stripslashes($_POST['folder_name']);
  181. $folder_path = clean_path( $path . "/" . $folder_name );
  182. $remote->shell_action('create_dir', $folder_path);
  183. $db->logger( get_lang("create_folder") . ": " . $folder_path );
  184. }
  185. // Delete File(s)
  186. elseif( isset( $_POST['remove'] ) and $fo['remove'] == "1" )
  187. {
  188. if( isset($_SESSION['fm_files_'.$home_id]) and !empty($_SESSION['fm_files_'.$home_id]) )
  189. {
  190. $files = "";
  191. foreach($_POST['items'] as $item)
  192. {
  193. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  194. {
  195. $item_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  196. $files .= $item_path.";";
  197. }
  198. }
  199. echo $files;
  200. if($files != "")
  201. {
  202. $remote->shell_action('remove_recursive', $files);
  203. $files = str_replace('" "','"<br>"',$files);
  204. $db->logger( get_lang("remove") . ": ${files}" );
  205. }
  206. }
  207. }
  208. // Rename File(s)/Folder(s)
  209. elseif( isset( $_POST['rename'] ) and $fo['rename'] == "1" )
  210. {
  211. if( isset($_SESSION['fm_files_'.$home_id]) and !empty($_SESSION['fm_files_'.$home_id]) )
  212. {
  213. foreach($_POST['items'] as $i => $item)
  214. {
  215. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  216. {
  217. $item_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  218. $new_item = removeInvalidFileNameCharacters(stripslashes($_POST['values'][$i]));
  219. $new_item_path = clean_path( $path . "/" . $new_item );
  220. if ($item_path != $new_item_path)
  221. {
  222. $remote->shell_action('rename', "$item_path;$new_item_path");
  223. $db->logger( get_lang("rename") . ": $item_path " . get_lang("to") . " $new_item_path" );
  224. }
  225. }
  226. }
  227. }
  228. }
  229. // Move Files/Folders
  230. elseif( isset( $_POST['move'] ) and $fo['move'] == "1" )
  231. {
  232. $selected_path = preg_replace("#[/\.\./]+#","/", stripslashes($_POST['selected_path']));
  233. $destination = clean_path($home_cfg['home_path']. "/" . $selected_path);
  234. if($path != $destination)
  235. {
  236. if($remote->rfile_exists($destination))
  237. {
  238. foreach($_POST['items'] as $item)
  239. {
  240. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  241. {
  242. $item_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  243. $destination = clean_path($destination . "/.");
  244. $remote->shell_action('move', "$item_path;$destination");
  245. $db->logger( get_lang("move") . ": $item_path " . get_lang("to") . " $destination" );
  246. }
  247. }
  248. }
  249. }
  250. }
  251. // Copy Files/Folders
  252. elseif( isset( $_POST['copy'] ) and $fo['copy'] == "1" )
  253. {
  254. $selected_path = preg_replace("#[/\.\./]+#","/", stripslashes($_POST['selected_path']));
  255. $destination = clean_path($home_cfg['home_path']. "/" . $selected_path);
  256. if($path != $destination)
  257. {
  258. if($remote->rfile_exists($destination))
  259. {
  260. foreach($_POST['items'] as $item)
  261. {
  262. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  263. {
  264. $item_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  265. $destination = clean_path($destination . "/.");
  266. $remote->shell_action('copy', "$item_path;$destination");
  267. $db->logger( get_lang("copy") . ": $item_path " . get_lang("to") . " $destination" );
  268. }
  269. }
  270. }
  271. }
  272. }
  273. // Compress Files/Folders
  274. elseif( isset( $_POST['compress'] ) and $fo['compress'] == "1" )
  275. {
  276. $files_w_path = '';
  277. $items = '';
  278. foreach($_POST['items'] as $item)
  279. {
  280. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  281. {
  282. $item_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  283. $files_w_path .= $item_path.'<br>';
  284. $items .= $_SESSION['fm_files_'.$home_id][$item].'\n';
  285. }
  286. }
  287. if($items != '')
  288. {
  289. $remote->compress_files($items,$path,$_POST['archive_name'],$_POST['archive_type']);
  290. $db->logger( get_lang("compress") . " " . $_POST['archive_type'] . ":<br>$files_w_path" );
  291. }
  292. }
  293. // uncompress
  294. elseif( isset( $_POST['uncompress'] ) and $fo['uncompress'] == "1" )
  295. {
  296. $selected_path = preg_replace("#[/\.\./]+#","/", stripslashes($_POST['selected_path']));
  297. $destination = clean_path($home_cfg['home_path']. "/" . $selected_path);
  298. if($remote->rfile_exists($destination))
  299. {
  300. foreach($_POST['items'] as $item)
  301. {
  302. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  303. {
  304. $file_location = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  305. $remote->uncompress_file($file_location, $destination);
  306. $db->logger( get_lang("uncompress") . ": $file_location " . to . " $destination." );
  307. }
  308. }
  309. }
  310. }
  311. // Create file
  312. elseif( isset( $_POST['create_file'] ) and $fo['create_file'] == "1" )
  313. {
  314. $file_name = removeInvalidFileNameCharacters(stripslashes($_POST['file_name']));
  315. $destination = clean_path( $path . "/" . $file_name);
  316. $remote->shell_action('touch', $destination);
  317. $db->logger( get_lang("create_file") . ": $destination" );
  318. }
  319. // Send by email
  320. elseif( isset( $_POST['send_by_email'] ) and $fo['send_by_email'] == "1" )
  321. {
  322. $archive_name = $_POST['archive_name'];
  323. $archive_type = $_POST['archive_type'];
  324. $subject = $_POST['subject'];
  325. $message = $_POST['message'];
  326. $dest_email = $_POST['dest_email'];
  327. $items = '';
  328. foreach($_POST['items'] as $item)
  329. {
  330. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  331. {
  332. $item_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  333. $items .= $_SESSION['fm_files_'.$home_id][$item].'\n';
  334. }
  335. }
  336. if($items != '')
  337. {
  338. $retval = $remote->compress_files($items,$path,$archive_name,$archive_type);
  339. $archive = clean_path( "${path}/${archive_name}.${archive_type}" );
  340. if( $retval == 0 )
  341. {
  342. do{
  343. $size1 = $remote->shell_action('size', $archive);
  344. sleep( 2 );
  345. $size2 = $remote->shell_action('size', $archive);
  346. }while($size1 != $size2);
  347. }
  348. if( $retval != -1 and $remote->rfile_exists($archive) )
  349. {
  350. $mail_retval = $remote->exec( "(echo '" . esc_squote($message) . "' | mutt -a '" . esc_squote($archive) . "' -s '" . esc_squote($subject) . "' -- '" . esc_squote($dest_email) . "');echo \$?" );
  351. if($mail_retval == 0)
  352. {
  353. echo get_lang("mail_sent_successfully");
  354. $db->logger( get_lang("send_by_email") . ": '$archive'<br>Subject: '$subject'<br>to: '$dest_email'" );
  355. }
  356. else
  357. {
  358. echo "The email could not be sent,\n".
  359. "the package mutt or mutt-patched (a mail client)\n".
  360. "must be installed, and postfix should be configured\n".
  361. "in order to send large files.";
  362. }
  363. }
  364. }
  365. }
  366. // Secure File
  367. elseif( isset( $_POST['secure_file'] ) and $isAdmin )
  368. {
  369. if(isset($_SESSION['fm_files_'.$home_id][$_POST['item']]))
  370. {
  371. if($_POST['set_attr'] == '+i' or $_POST['set_attr'] == '-i')
  372. {
  373. $type = $_POST['set_attr'] == '+i' ? get_lang("chattr_locked") : get_lang("chattr_unlocked");
  374. $action = "chattr".$_POST['set_attr'];
  375. $file_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$_POST['item']] );
  376. $remote->secure_path($action, $file_path);
  377. $db->logger( "$type: $file_path" );
  378. }
  379. }
  380. }
  381. else
  382. {
  383. ?>
  384. <script type="text/javascript" src="js/jquery/plugins/jquery.form.min.js"></script>
  385. <script type="text/javascript" src="js/zlib/zlib.min.js"></script>
  386. <script type="text/javascript" src="js/modules/litefm.js"></script>
  387. <?php
  388. echo "<h2>";
  389. echo empty($home_cfg['home_name']) ? get_lang("not_available") : htmlentities($home_cfg['home_name']);
  390. echo "</h2>";
  391. $_SESSION['fm_files_'.$home_id] = array();
  392. $show_path = (isset($_SESSION['fm_cwd_'.$home_id])) ? clean_path($_SESSION['fm_cwd_'.$home_id]) : "/";
  393. if($isAdmin)
  394. $show_path = clean_path($home_cfg['home_path'].$show_path);
  395. echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id=".$home_cfg['home_id']."'><< ". get_lang("back") ."</a></td></tr></table>";
  396. if ($remote->rfile_exists($path))
  397. {
  398. echo "<table class='center' style='width:100%;' ><tr>\n".
  399. "<td colspan='3' ><h3>".
  400. get_lang_f('currently_viewing',$show_path)."</h3></td>".
  401. "</tr></table>\n";
  402. echo "<div class='file-operations' >\n";
  403. foreach($fo_keys as $key)
  404. {
  405. if($fo[$key] == "1")
  406. echo "<div class='operations-button' id='$key'><img src='" . check_theme_image("modules/litefm/action-images/$key.gif") . "' /><div>&nbsp;".get_lang($key)."</div></div>\n";
  407. }
  408. echo "</div>\n";
  409. $dirlist = $remote->remote_dirlistfm($path);
  410. if (!is_array($dirlist))
  411. {
  412. if(isset($_SESSION['fm_cwd_'.$home_id]))
  413. {
  414. unset($_SESSION['fm_cwd_'.$home_id]);
  415. $view->refresh("?m=litefm&amp;home_id=$home_id",0);
  416. return;
  417. }
  418. else
  419. {
  420. print_failure( get_lang("failed_list") );
  421. return;
  422. }
  423. }
  424. if ( empty($dirlist) )
  425. {
  426. echo "<table class='center' style='width:100%;' >\n".
  427. show_back($home_id)."</table>";
  428. echo "<p>" . get_lang("empty_directory") . "</p>";
  429. }
  430. else
  431. {
  432. echo "<table class='center' style='width:100%;' >\n"
  433. .show_back($home_id).
  434. "<tr>\n<td style='width:10px;' >".
  435. "<input type=checkbox name='switch' id='switch_check' />".
  436. "</td>\n<td align=left>".
  437. get_lang("filename") ."</td>\n";
  438. if( $os == "linux" )
  439. echo "<td>". get_lang("filesecure") ."</td>\n";
  440. echo "<td>". get_lang("filesize") ." [". get_lang("bytes") ."]</td>\n<td>".
  441. get_lang("owner") ." ". get_lang("group") ."</td>\n</tr>\n";
  442. $i = 0;
  443. if(isset($dirlist['directorys']) and is_array($dirlist['directorys']))
  444. {
  445. $dirlist['directorys'] = array_orderby($dirlist['directorys'], 'filename', SORT_ASC);
  446. foreach($dirlist['directorys'] as $directory)
  447. {
  448. $directory['filename'] = removeInvalidFileNameCharacters($directory['filename']);
  449. echo "<tr>\n".
  450. "<td>".
  451. "<input type=checkbox name='folder' data-item='$i' value=\"" . str_replace('"', "&quot;", $directory['filename']) . "\" class='item' />\n".
  452. "</td>".
  453. "<td align=left>".
  454. "<img class=\"viewitem\" src=\"" . check_theme_image("images/folder.png") . "\" alt=\"Directory\" /> ".
  455. "<a href=\"?m=litefm&amp;home_id=$home_id&amp;item=$i&amp;name=" . urlencode($directory['filename']) . "&amp;type=directory\">".
  456. $directory['filename'] . "</a></td>";
  457. if( $os == "linux" )
  458. echo "<td>-</td>";
  459. echo "<td>-</td> <td>" . $directory['user'] . " " . $directory['group']. "</td>\n".
  460. "</tr>\n";
  461. $_SESSION['fm_files_'.$home_id][$i] = $directory['filename'];
  462. $i++;
  463. }
  464. }
  465. if(isset($dirlist['files']) and is_array($dirlist['files']))
  466. {
  467. $dirlist['files'] = array_orderby($dirlist['files'], 'filename', SORT_ASC);
  468. foreach($dirlist['files'] as $file)
  469. {
  470. $file['filename'] = removeInvalidFileNameCharacters($file['filename']);
  471. if( $os == "linux" )
  472. {
  473. if($isAdmin){
  474. $secureFile = "<td><div data-item='$i' data-file_name=\"" . str_replace('"', "&quot;", $file['filename']) . "\" class='chattrButton ";
  475. if( preg_match( "/i/", $file['attr'] ) ){
  476. $secureFile .= "locked' data-set_attr='-i' ><i></i><span>". get_lang("chattr_no");
  477. }else{
  478. $secureFile .= "unlocked' data-set_attr='+i' ><i></i><span>". get_lang("chattr_yes");
  479. }
  480. $secureFile .= "</span></div></td>\n";
  481. }else{
  482. $secureFile = "<td><span class=";
  483. if( preg_match( "/i/", $file['attr'] ) ){
  484. $secureFile .= "'chattrLock'>". get_lang("chattr_locked");
  485. }else{
  486. $secureFile .= "'chattrUnlock'>". get_lang("chattr_unlocked");
  487. }
  488. $secureFile .= "</span></td>\n";
  489. }
  490. }
  491. else
  492. $secureFile = "";
  493. echo "<tr>\n".
  494. "<td>".
  495. "<input type=checkbox name='file' data-item='$i' value=\"" . str_replace('"', "&quot;", $file['filename']) . "\" class='item' />\n".
  496. "</td>".
  497. "<td align=left id='fileid$i' >";
  498. echo "<img class=\"viewitem\" src=\"" . check_theme_image("images/txt.png") . "\" alt=\"Text file\" /> ".
  499. "<a href=\"?m=litefm&amp;home_id=$home_id&amp;item=$i&amp;p=read_file&amp;name=" . urlencode($file['filename']) . "&amp;type=file\">". get_lang("button_edit") ."</a>".
  500. "<a href=\"javascript:downloadFile($home_id, $i, {$file['size']}, '".str_replace("'", "\'", $file['filename'])."');\" id=\"jsDwl$i\" >" .$file['filename'] . "</a>&nbsp;".
  501. "</td>$secureFile<td>" . $file['size'] . "</td> <td>" . $file['user'] . " " . $file['group']. "</td>\n";
  502. echo "</tr>\n";
  503. $_SESSION['fm_files_'.$home_id][$i] = $file['filename'];
  504. $i++;
  505. }
  506. }
  507. if(isset($dirlist['binarys']) and is_array($dirlist['binarys']))
  508. {
  509. $dirlist['binarys'] = array_orderby($dirlist['binarys'], 'filename', SORT_ASC);
  510. foreach($dirlist['binarys'] as $binary)
  511. {
  512. $binary['filename'] = removeInvalidFileNameCharacters($binary['filename']);
  513. if( $os == "linux" )
  514. {
  515. if($isAdmin){
  516. $secureFile = "<td><div data-item='$i' data-file_name=\"" . str_replace('"', "&quot;", $binary['filename']) . "\" class='chattrButton ";
  517. if( preg_match( "/i/", $binary['attr'] ) ){
  518. $secureFile .= "locked' data-set_attr='-i' ><i></i><span>". get_lang("chattr_no");
  519. }else{
  520. $secureFile .= "unlocked' data-set_attr='+i' ><i></i><span>". get_lang("chattr_yes");
  521. }
  522. $secureFile .= "</span></div></td>\n";
  523. }else{
  524. $secureFile = "<td><span class=";
  525. if( preg_match( "/i/", $binary['attr'] ) ){
  526. $secureFile .= "'chattrLock'>". get_lang("chattr_locked");
  527. }else{
  528. $secureFile .= "'chattrUnlock'>". get_lang("chattr_unlocked");
  529. }
  530. $secureFile .= "</span></td>\n";
  531. }
  532. }
  533. else
  534. $secureFile = "";
  535. echo "<tr>\n".
  536. "<td>".
  537. "<input type=checkbox name='binary' data-item='$i' value=\"" . str_replace('"', "&quot;", $binary['filename']) . "\" class='item' />\n".
  538. "</td>".
  539. "<td align=left id='fileid$i' >";
  540. echo "<img class=\"viewitem\" src=\"" . check_theme_image("images/exec.png") . "\" alt=\"Binary file\" /> ".
  541. "<a href=\"javascript:downloadFile($home_id, $i, {$binary['size']}, '".str_replace("'", "\'", $binary['filename'])."');\" id=\"jsDwl$i\" >" .$binary['filename'] . "</a>&nbsp;".
  542. "</td>$secureFile<td>" . $binary['size'] . "</td><td>" . $binary['user'] . " " . $binary['group']. "</td>\n";
  543. echo "</tr>\n";
  544. $_SESSION['fm_files_'.$home_id][$i] = $binary['filename'];
  545. $i++;
  546. }
  547. }
  548. echo "</table>\n";
  549. }
  550. }
  551. echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id=".$home_cfg['home_id']."'><< ". get_lang("back") ."</a></td></tr></table>";
  552. // Dialog translation && info
  553. $user = $db->getUserById($_SESSION['user_id']);
  554. echo "<div id='dialog' ".
  555. "data-folder=\"" . clean_path("/".str_replace('"', "&quot;", @(string)$_SESSION['fm_cwd_'.$home_id])) . "\" " .
  556. "data-select_at_least_one_item='" . get_lang("select_at_least_one_item") . "' " .
  557. "data-ask_delete='" . get_lang("delete_item") . "' " .
  558. "data-ask_rename='" . get_lang("rename_item") . "' " .
  559. "data-ask_move='" . get_lang("move_item") . "' " .
  560. "data-ask_copy='" . get_lang("copy_item") . "' " .
  561. "data-ask_compress='" . get_lang("compress_item") . "' " .
  562. "data-ask_uncompress='" . get_lang("uncompress_item") . "' " .
  563. "data-archive_name='" . get_lang("archive_name") . "' " .
  564. "data-archive_type='" . get_lang("archive_type") . "' " .
  565. "data-file_name='" . get_lang("file_name") . "' " .
  566. "data-folder_name='" . get_lang("folder_name") . "' " .
  567. "data-compresses_files_separately='" . get_lang("compresses_files_separately") . "' " .
  568. "data-to='" . get_lang("to") . "' " .
  569. "data-yes='" . get_lang("yes") . "' " .
  570. "data-no='" . get_lang("no") . "' " .
  571. "data-max_file_uploads='" . ini_get('max_file_uploads') . "' " .
  572. "data-upload_to_web='" . get_lang("upload_to_web") . "' " .
  573. "data-transfer_to_server='" . get_lang("transfer_to_server") . "' " .
  574. "data-upload='" . get_lang("upload") . "' " .
  575. "data-ask_send_by_email='" . get_lang("send_item_by_email") . "' " .
  576. "data-subject='" . get_lang("subject") . "' " .
  577. "data-message='" . get_lang("message") . "' " .
  578. "data-dest_email='" . get_lang("dest_email") . "' " .
  579. "data-user_email='" . $user['users_email'] . "' ";
  580. if($isAdmin)
  581. echo "data-ask_change_attr=\"" . get_lang_f( 'secure_item', clean_path( str_replace('"', "&quot;", $path) . "/%file_name%" ) ) . "\" ";
  582. echo "></div>";
  583. }
  584. }
  585. ?>