fm_dir.php 22 KB

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