fm_dir.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  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. $serverName = $_SERVER["SERVER_NAME"];
  147. if(empty($serverName) || $serverName == "_"){
  148. $serverName = $_SERVER['HTTP_HOST'];
  149. }
  150. $url = 'http'.$s.'://'.$serverName.$p.$_SERVER['SCRIPT_NAME'];
  151. // loop all files
  152. foreach ( $_FILES['files']['name'] as $i => $name )
  153. {
  154. // if file not uploaded then skip it
  155. if ( !is_uploaded_file($_FILES['files']['tmp_name'][$i]) )
  156. continue;
  157. // now we can move uploaded files
  158. $bad_chars = preg_replace( "/([[:alnum:]_\.-]*)/", "", $_FILES['files']['name'][$i] );
  159. $bad_arr = str_split( $bad_chars );
  160. $filename = str_replace( $bad_arr, "", $_FILES['files']['name'][$i] );
  161. $dest_file_path = clean_path( $upload_folder_path . "/" . $filename . ".txt" );
  162. $file_url = str_replace( "home.php", $dest_file_path, $url );
  163. if( file_exists( $dest_file_path ) )
  164. unlink($dest_file_path);
  165. if( move_uploaded_file( $_FILES["files"]["tmp_name"][$i], $dest_file_path ) )
  166. {
  167. $remote_file_path = clean_path( $path . "/" . $filename );
  168. if( $remote->rfile_exists($remote_file_path) )
  169. $remote->shell_action('remove_file', $remote_file_path);
  170. $pid = $remote->start_file_download( $file_url, $path, $filename );
  171. $files[$count] = array('filename' => $filename,
  172. 'size' => $_FILES['files']['size'][$i],
  173. 'pid' => $pid);
  174. $count++;
  175. }
  176. }
  177. echo json_encode(array('count' => $count,
  178. 'files' => $files));
  179. }
  180. }
  181. // Create Folder
  182. elseif( isset( $_POST['create_folder'] ) and $fo['create_folder'] == "1" )
  183. {
  184. $folder_name = stripslashes($_POST['folder_name']);
  185. $folder_path = clean_path( $path . "/" . $folder_name );
  186. $remote->shell_action('create_dir', $folder_path);
  187. $db->logger( get_lang("create_folder") . ": " . $folder_path );
  188. }
  189. // Delete File(s)
  190. elseif( isset( $_POST['remove'] ) and $fo['remove'] == "1" )
  191. {
  192. if( isset($_SESSION['fm_files_'.$home_id]) and !empty($_SESSION['fm_files_'.$home_id]) )
  193. {
  194. $files = "";
  195. foreach($_POST['items'] as $item)
  196. {
  197. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  198. {
  199. $item_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  200. $files .= $item_path.";";
  201. }
  202. }
  203. echo $files;
  204. if($files != "")
  205. {
  206. $remote->shell_action('remove_recursive', $files);
  207. $files = str_replace('" "','"<br>"',$files);
  208. $db->logger( get_lang("remove") . ": " . $files );
  209. }
  210. }
  211. }
  212. // Rename File(s)/Folder(s)
  213. elseif( isset( $_POST['rename'] ) and $fo['rename'] == "1" )
  214. {
  215. if( isset($_SESSION['fm_files_'.$home_id]) and !empty($_SESSION['fm_files_'.$home_id]) )
  216. {
  217. foreach($_POST['items'] as $i => $item)
  218. {
  219. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  220. {
  221. $item_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  222. $new_item = removeInvalidFileNameCharacters(stripslashes($_POST['values'][$i]));
  223. $new_item_path = clean_path( $path . "/" . $new_item );
  224. if ($item_path != $new_item_path)
  225. {
  226. $remote->shell_action('rename', "$item_path;$new_item_path");
  227. $db->logger( get_lang("rename") . ": $item_path " . get_lang("to") . " $new_item_path" );
  228. }
  229. }
  230. }
  231. }
  232. }
  233. // Move Files/Folders
  234. elseif( isset( $_POST['move'] ) and $fo['move'] == "1" )
  235. {
  236. $selected_path = preg_replace("#[/\.\./]+#","/", stripslashes($_POST['selected_path']));
  237. $destination = clean_path($home_cfg['home_path']. "/" . $selected_path);
  238. if($path != $destination)
  239. {
  240. if($remote->rfile_exists($destination))
  241. {
  242. foreach($_POST['items'] as $item)
  243. {
  244. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  245. {
  246. $item_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  247. $destination = clean_path($destination . "/.");
  248. $remote->shell_action('move', "$item_path;$destination");
  249. $db->logger( get_lang("move") . ": $item_path " . get_lang("to") . " $destination" );
  250. }
  251. }
  252. }
  253. }
  254. }
  255. // Copy Files/Folders
  256. elseif( isset( $_POST['copy'] ) and $fo['copy'] == "1" )
  257. {
  258. $selected_path = preg_replace("#[/\.\./]+#","/", stripslashes($_POST['selected_path']));
  259. $destination = clean_path($home_cfg['home_path']. "/" . $selected_path);
  260. if($path != $destination)
  261. {
  262. if($remote->rfile_exists($destination))
  263. {
  264. foreach($_POST['items'] as $item)
  265. {
  266. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  267. {
  268. $item_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  269. $destination = clean_path($destination . "/.");
  270. $remote->shell_action('copy', "$item_path;$destination");
  271. $db->logger( get_lang("copy") . ": $item_path " . get_lang("to") . " $destination" );
  272. }
  273. }
  274. }
  275. }
  276. }
  277. // Compress Files/Folders
  278. elseif( isset( $_POST['compress'] ) and $fo['compress'] == "1" )
  279. {
  280. $files_w_path = '';
  281. $items = '';
  282. foreach($_POST['items'] as $item)
  283. {
  284. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  285. {
  286. $item_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  287. $files_w_path .= $item_path.'<br>';
  288. $items .= $_SESSION['fm_files_'.$home_id][$item].'\n';
  289. }
  290. }
  291. if($items != '')
  292. {
  293. $remote->compress_files($items,$path,$_POST['archive_name'],$_POST['archive_type']);
  294. $db->logger( get_lang("compress") . " " . $_POST['archive_type'] . ":<br>$files_w_path" );
  295. }
  296. }
  297. // uncompress
  298. elseif( isset( $_POST['uncompress'] ) and $fo['uncompress'] == "1" )
  299. {
  300. $selected_path = preg_replace("#[/\.\./]+#","/", stripslashes($_POST['selected_path']));
  301. $destination = clean_path($home_cfg['home_path']. "/" . $selected_path);
  302. if($remote->rfile_exists($destination))
  303. {
  304. foreach($_POST['items'] as $item)
  305. {
  306. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  307. {
  308. $file_location = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  309. $remote->uncompress_file($file_location, $destination);
  310. $db->logger( get_lang("uncompress") . ": $file_location " . to . " $destination." );
  311. }
  312. }
  313. }
  314. }
  315. // Create file
  316. elseif( isset( $_POST['create_file'] ) and $fo['create_file'] == "1" )
  317. {
  318. $file_name = removeInvalidFileNameCharacters(stripslashes($_POST['file_name']));
  319. $destination = clean_path( $path . "/" . $file_name);
  320. $remote->shell_action('touch', $destination);
  321. $db->logger( get_lang("create_file") . ": $destination" );
  322. }
  323. // Send by email
  324. elseif( isset( $_POST['send_by_email'] ) and $fo['send_by_email'] == "1" )
  325. {
  326. $archive_name = $_POST['archive_name'];
  327. $archive_type = $_POST['archive_type'];
  328. $subject = $_POST['subject'];
  329. $message = $_POST['message'];
  330. $dest_email = $_POST['dest_email'];
  331. $items = '';
  332. foreach($_POST['items'] as $item)
  333. {
  334. if(isset($_SESSION['fm_files_'.$home_id][$item]))
  335. {
  336. $item_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$item] );
  337. $items .= $_SESSION['fm_files_'.$home_id][$item].'\n';
  338. }
  339. }
  340. if($items != '')
  341. {
  342. $retval = $remote->compress_files($items,$path,$archive_name,$archive_type);
  343. $archive = clean_path( $path . "/" . $archive_name . "." . $archive_type );
  344. if( $retval == 0 )
  345. {
  346. do{
  347. $size1 = $remote->shell_action('size', $archive);
  348. sleep( 2 );
  349. $size2 = $remote->shell_action('size', $archive);
  350. }while($size1 != $size2);
  351. }
  352. if( $retval != -1 and $remote->rfile_exists($archive) )
  353. {
  354. $mail_retval = $remote->exec( "(echo '" . esc_squote($message) . "' | mutt -a '" . esc_squote($archive) . "' -s '" . esc_squote($subject) . "' -- '" . esc_squote($dest_email) . "');echo \$?" );
  355. if($mail_retval == 0)
  356. {
  357. echo get_lang("mail_sent_successfully");
  358. $db->logger( get_lang("send_by_email") . ": '$archive'<br>Subject: '$subject'<br>to: '$dest_email'" );
  359. }
  360. else
  361. {
  362. echo "The email could not be sent,\n".
  363. "the package mutt or mutt-patched (a mail client)\n".
  364. "must be installed, and postfix should be configured\n".
  365. "in order to send large files.";
  366. }
  367. }
  368. }
  369. }
  370. // Secure File
  371. elseif( isset( $_POST['secure_file'] ) and $isAdmin )
  372. {
  373. if(isset($_SESSION['fm_files_'.$home_id][$_POST['item']]))
  374. {
  375. if($_POST['set_attr'] == '+i' or $_POST['set_attr'] == '-i')
  376. {
  377. $type = $_POST['set_attr'] == '+i' ? get_lang("chattr_locked") : get_lang("chattr_unlocked");
  378. $action = "chattr".$_POST['set_attr'];
  379. $file_path = clean_path( $path . "/" . $_SESSION['fm_files_'.$home_id][$_POST['item']] );
  380. $remote->secure_path($action, $file_path);
  381. $db->logger( "$type: $file_path" );
  382. }
  383. }
  384. }
  385. else
  386. {
  387. ?>
  388. <script type="text/javascript" src="js/jquery/plugins/jquery.form.min.js"></script>
  389. <script type="text/javascript" src="js/zlib/zlib.min.js"></script>
  390. <script type="text/javascript" src="js/modules/litefm.js"></script>
  391. <?php
  392. echo "<h2>";
  393. echo empty($home_cfg['home_name']) ? get_lang("not_available") : htmlentities($home_cfg['home_name']);
  394. echo "</h2>";
  395. $_SESSION['fm_files_'.$home_id] = array();
  396. $show_path = (isset($_SESSION['fm_cwd_'.$home_id])) ? clean_path($_SESSION['fm_cwd_'.$home_id]) : "/";
  397. if($isAdmin)
  398. $show_path = clean_path($home_cfg['home_path'].$show_path);
  399. 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>";
  400. if ($remote->rfile_exists($path))
  401. {
  402. echo "<table class='center' style='width:100%;' ><tr>\n".
  403. "<td colspan='3' ><h3>".
  404. get_lang_f('currently_viewing',$show_path)."</h3></td>".
  405. "</tr></table>\n";
  406. echo "<div class='file-operations' >\n";
  407. foreach($fo_keys as $key)
  408. {
  409. if($fo[$key] == "1")
  410. 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";
  411. }
  412. echo "</div>\n";
  413. $dirlist = $remote->remote_dirlistfm($path);
  414. if (!is_array($dirlist))
  415. {
  416. if(isset($_SESSION['fm_cwd_'.$home_id]))
  417. {
  418. unset($_SESSION['fm_cwd_'.$home_id]);
  419. $view->refresh("?m=litefm&amp;home_id=$home_id",0);
  420. return;
  421. }
  422. else
  423. {
  424. print_failure( get_lang("failed_list") );
  425. return;
  426. }
  427. }
  428. if ( empty($dirlist) )
  429. {
  430. echo "<table class='center' style='width:100%;' >\n".
  431. show_back($home_id)."</table>";
  432. echo "<p>" . get_lang("empty_directory") . "</p>";
  433. }
  434. else
  435. {
  436. echo "<table class='center' style='width:100%;' >\n"
  437. .show_back($home_id).
  438. "<tr>\n<td style='width:10px;' >".
  439. "<input type=checkbox name='switch' id='switch_check' />".
  440. "</td>\n<td align=left>".
  441. get_lang("filename") ."</td>\n";
  442. if( $os == "linux" )
  443. echo "<td>". get_lang("filesecure") ."</td>\n";
  444. echo "<td>". get_lang("filesize") ." [". get_lang("bytes") ."]</td>\n<td>".
  445. get_lang("owner") ." ". get_lang("group") ."</td>\n</tr>\n";
  446. $i = 0;
  447. if(isset($dirlist['directorys']) and is_array($dirlist['directorys']))
  448. {
  449. $dirlist['directorys'] = array_orderby($dirlist['directorys'], 'filename', SORT_ASC);
  450. foreach($dirlist['directorys'] as $directory)
  451. {
  452. $directory['filename'] = removeInvalidFileNameCharacters($directory['filename']);
  453. echo "<tr>\n".
  454. "<td>".
  455. "<input type=checkbox name='folder' data-item='$i' value=\"" . str_replace('"', "&quot;", $directory['filename']) . "\" class='item' />\n".
  456. "</td>".
  457. "<td align=left>".
  458. "<img class=\"viewitem\" src=\"" . check_theme_image("images/folder.png") . "\" alt=\"Directory\" /> ".
  459. "<a href=\"?m=litefm&amp;home_id=$home_id&amp;item=$i&amp;name=" . urlencode($directory['filename']) . "&amp;type=directory\">".
  460. $directory['filename'] . "</a></td>";
  461. if( $os == "linux" )
  462. echo "<td>-</td>";
  463. echo "<td>-</td> <td>" . $directory['user'] . " " . $directory['group']. "</td>\n".
  464. "</tr>\n";
  465. $_SESSION['fm_files_'.$home_id][$i] = $directory['filename'];
  466. $i++;
  467. }
  468. }
  469. if(isset($dirlist['files']) and is_array($dirlist['files']))
  470. {
  471. $dirlist['files'] = array_orderby($dirlist['files'], 'filename', SORT_ASC);
  472. foreach($dirlist['files'] as $file)
  473. {
  474. if(stripos($file['filename'], "OGP_HOME_") !== false && stripos($file['filename'], $home_id . "_startup_scr.sh") !== false){
  475. continue;
  476. }
  477. $file['filename'] = removeInvalidFileNameCharacters($file['filename']);
  478. if( $os == "linux" )
  479. {
  480. if($isAdmin){
  481. $secureFile = "<td><div data-item='$i' data-file_name=\"" . str_replace('"', "&quot;", $file['filename']) . "\" class='chattrButton ";
  482. if( preg_match( "/i/", $file['attr'] ) ){
  483. $secureFile .= "locked' data-set_attr='-i' ><i></i><span>". get_lang("chattr_no");
  484. }else{
  485. $secureFile .= "unlocked' data-set_attr='+i' ><i></i><span>". get_lang("chattr_yes");
  486. }
  487. $secureFile .= "</span></div></td>\n";
  488. }else{
  489. $secureFile = "<td><span class=";
  490. if( preg_match( "/i/", $file['attr'] ) ){
  491. $secureFile .= "'chattrLock'>". get_lang("chattr_locked");
  492. }else{
  493. $secureFile .= "'chattrUnlock'>". get_lang("chattr_unlocked");
  494. }
  495. $secureFile .= "</span></td>\n";
  496. }
  497. }
  498. else
  499. $secureFile = "";
  500. echo "<tr>\n".
  501. "<td>".
  502. "<input type=checkbox name='file' data-item='$i' value=\"" . str_replace('"', "&quot;", $file['filename']) . "\" class='item' />\n".
  503. "</td>".
  504. "<td align=left id='fileid$i' >";
  505. echo "<img class=\"viewitem\" src=\"" . check_theme_image("images/txt.png") . "\" alt=\"Text file\" /> ".
  506. "<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>".
  507. "<a href=\"javascript:downloadFile($home_id, $i, {$file['size']}, '".str_replace("'", "\'", $file['filename'])."');\" id=\"jsDwl$i\" >" .$file['filename'] . "</a>&nbsp;".
  508. "</td>$secureFile<td>" . $file['size'] . "</td> <td>" . $file['user'] . " " . $file['group']. "</td>\n";
  509. echo "</tr>\n";
  510. $_SESSION['fm_files_'.$home_id][$i] = $file['filename'];
  511. $i++;
  512. }
  513. }
  514. if(isset($dirlist['binarys']) and is_array($dirlist['binarys']))
  515. {
  516. $dirlist['binarys'] = array_orderby($dirlist['binarys'], 'filename', SORT_ASC);
  517. foreach($dirlist['binarys'] as $binary)
  518. {
  519. $binary['filename'] = removeInvalidFileNameCharacters($binary['filename']);
  520. if( $os == "linux" )
  521. {
  522. if($isAdmin){
  523. $secureFile = "<td><div data-item='$i' data-file_name=\"" . str_replace('"', "&quot;", $binary['filename']) . "\" class='chattrButton ";
  524. if( preg_match( "/i/", $binary['attr'] ) ){
  525. $secureFile .= "locked' data-set_attr='-i' ><i></i><span>". get_lang("chattr_no");
  526. }else{
  527. $secureFile .= "unlocked' data-set_attr='+i' ><i></i><span>". get_lang("chattr_yes");
  528. }
  529. $secureFile .= "</span></div></td>\n";
  530. }else{
  531. $secureFile = "<td><span class=";
  532. if( preg_match( "/i/", $binary['attr'] ) ){
  533. $secureFile .= "'chattrLock'>". get_lang("chattr_locked");
  534. }else{
  535. $secureFile .= "'chattrUnlock'>". get_lang("chattr_unlocked");
  536. }
  537. $secureFile .= "</span></td>\n";
  538. }
  539. }
  540. else
  541. $secureFile = "";
  542. echo "<tr>\n".
  543. "<td>".
  544. "<input type=checkbox name='binary' data-item='$i' value=\"" . str_replace('"', "&quot;", $binary['filename']) . "\" class='item' />\n".
  545. "</td>".
  546. "<td align=left id='fileid$i' >";
  547. echo "<img class=\"viewitem\" src=\"" . check_theme_image("images/exec.png") . "\" alt=\"Binary file\" /> ".
  548. "<a href=\"javascript:downloadFile($home_id, $i, {$binary['size']}, '".str_replace("'", "\'", $binary['filename'])."');\" id=\"jsDwl$i\" >" .$binary['filename'] . "</a>&nbsp;".
  549. "</td>$secureFile<td>" . $binary['size'] . "</td><td>" . $binary['user'] . " " . $binary['group']. "</td>\n";
  550. echo "</tr>\n";
  551. $_SESSION['fm_files_'.$home_id][$i] = $binary['filename'];
  552. $i++;
  553. }
  554. }
  555. echo "</table>\n";
  556. }
  557. }
  558. 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>";
  559. // Dialog translation && info
  560. $user = $db->getUserById($_SESSION['user_id']);
  561. echo "<div id='dialog' ".
  562. "data-folder=\"" . clean_path("/".str_replace('"', "&quot;", @(string)$_SESSION['fm_cwd_'.$home_id])) . "\" " .
  563. "data-select_at_least_one_item='" . get_lang("select_at_least_one_item") . "' " .
  564. "data-ask_delete='" . get_lang("delete_item") . "' " .
  565. "data-ask_rename='" . get_lang("rename_item") . "' " .
  566. "data-ask_move='" . get_lang("move_item") . "' " .
  567. "data-ask_copy='" . get_lang("copy_item") . "' " .
  568. "data-ask_compress='" . get_lang("compress_item") . "' " .
  569. "data-ask_uncompress='" . get_lang("uncompress_item") . "' " .
  570. "data-archive_name='" . get_lang("archive_name") . "' " .
  571. "data-archive_type='" . get_lang("archive_type") . "' " .
  572. "data-file_name='" . get_lang("file_name") . "' " .
  573. "data-folder_name='" . get_lang("folder_name") . "' " .
  574. "data-compresses_files_separately='" . get_lang("compresses_files_separately") . "' " .
  575. "data-to='" . get_lang("to") . "' " .
  576. "data-yes='" . get_lang("yes") . "' " .
  577. "data-no='" . get_lang("no") . "' " .
  578. "data-max_file_uploads='" . ini_get('max_file_uploads') . "' " .
  579. "data-upload_to_web='" . get_lang("upload_to_web") . "' " .
  580. "data-transfer_to_server='" . get_lang("transfer_to_server") . "' " .
  581. "data-upload='" . get_lang("upload") . "' " .
  582. "data-ask_send_by_email='" . get_lang("send_item_by_email") . "' " .
  583. "data-subject='" . get_lang("subject") . "' " .
  584. "data-message='" . get_lang("message") . "' " .
  585. "data-dest_email='" . get_lang("dest_email") . "' " .
  586. "data-user_email='" . $user['users_email'] . "' ";
  587. if($isAdmin)
  588. echo "data-ask_change_attr=\"" . get_lang_f( 'secure_item', clean_path( str_replace('"', "&quot;", $path) . "/%file_name%" ) ) . "\" ";
  589. echo "></div>";
  590. }
  591. }
  592. ?>