function exec_ogp_module() { global $db; global $view; $home_id = isset($_REQUEST['home_id']) ? $_REQUEST['home_id'] : ""; $mod_id = isset($_REQUEST['mod_id']) ? $_REQUEST['mod_id'] : ""; $isAdmin = $db->isAdmin($_SESSION['user_id']); if ($isAdmin) { $home_info = $db->getGameHome($home_id); } else { $home_info = $db->getUserGameHome($_SESSION['user_id'], $home_id); } if ($home_info === FALSE || preg_match("/u/", $home_info['access_rights']) != 1) { print_failure(get_lang('no_rights')); echo create_back_button("gamemanager", "gamemanager"); return; } $state = isset($_REQUEST['state']) ? $_REQUEST['state'] : ""; $pid = isset($_REQUEST['pid']) ? $_REQUEST['pid'] : -1; $filename = isset($_REQUEST['filename']) ? $_REQUEST['filename'] : ""; echo "<h2>" . get_lang('install_update_manual') . " {$home_info['home_name']}</h2>"; if (!empty($state)) { $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']); if ($state == "start") { if (isset($_POST['one_dir_down'])) { $home_info['home_path'] .= "/../"; } $pid = $remote->start_file_download($_REQUEST['url'], $home_info['home_path'], $filename, "uncompress"); if ($pid < 0) { print_failure(get_lang("failed_to_start_file_download")); return; } } $url = $_REQUEST['url']; $headers = get_headers($url, 1); $download_available = !$headers ? FALSE : TRUE; // Check if any error occured if ($download_available) { $bytes = is_array($headers['Content-Length']) ? $headers['Content-Length'][1] : $headers['Content-Length']; // Display the File Size $totalsize = $bytes / 1024; clearstatcache(); } $kbytes = $remote->rsync_progress($home_info['home_path'] . "/" . $filename); list($totalsize, $mbytes, $pct) = explode(";", do_progress($kbytes, $totalsize)); $totalmbytes = round($totalsize / 1024, 2); $pct = $pct > 100 ? 100 : $pct; echo '<div class="dragbox bloc rounded" style="background-color:#dce9f2;" > <h4>' . get_lang('update_in_progress') . " {$mbytes}MB/{$totalmbytes}MB</h4>\n\t\t\t <div style='background-color:#dce9f2;' >\n\t\t\t "; $bar = ''; for ($i = 1; $i <= $pct; $i++) { $bar .= '<img style="width:0.92%;vertical-align:middle;" src="images/progressBar.png">'; } echo "<center>{$bar} <b style='vertical-align:top;display:inline;font-size:1.2em;color:red;' >{$pct}%</b></center>\n\t\t\t\t</div>\n\t\t\t </div>"; if ($remote->is_file_download_in_progress($pid) == 0) { print_success(get_lang('finished_manual_update')); } else { echo "<p><a href=\"?m=gamemanager&p=update_manual&state=refresh&home_id=" . $home_id . "&mod_id={$mod_id}&pid={$pid}&url={$url}&filename={$filename}\">Refresh</a></p>"; $view->refresh("?m=gamemanager&p=update_manual&state=refresh&home_id=" . $home_id . "&mod_id={$mod_id}&pid={$pid}&url={$url}&filename={$filename}", 5); } echo create_back_button($_GET['m'], "game_monitor&home_id=" . $_GET['home_id']); } else { echo "<form action='?m=gamemanager&p=update_manual' method='post'>\n <table class='center'>\n <input type='hidden' name='home_id' value='{$home_id}' />\n <input type='hidden' name='mod_id' value='{$mod_id}' />\n <input type='hidden' name='state' value='start' />\n <tr><td align='right'>" . get_lang('game_name') . ":</td><td align='left'>{$home_info['game_name']}</td></tr>\n <tr><td align='right'>" . get_lang('dest_dir') . ":</td><td align='left'>{$home_info['home_path']}</td></tr>\n <tr><td align='right'>" . get_lang('remote_server') . ":</td>\n <td align='left'>{$home_info['remote_server_name']} ({$home_info['agent_ip']}:{$home_info['agent_port']})</td></tr>\n <tr><td align='right'>" . get_lang('file_url') . ":</td>\n <td align='left'><input type='text' name='url' value='' size='50' /></td></tr>\n <tr><td colspan='2' class='info'>" . get_lang('file_url_info') . "</td></tr>\n <tr><td align='right'>" . get_lang('one_dir_down') . ":</td><td align='left'><input type='checkbox' name='one_dir_down' /></td></tr>\n <tr><td align='right'>" . get_lang('dest_filename') . ":</td>\n <td align='left'><input type='text' name='filename' value='' size='50'/></td></tr>\n <tr><td colspan='2' class='info'>" . get_lang('dest_filename_info') . "</td></tr>\n </table>\n <p><input type='submit' name='update' value='" . get_lang('update_server') . "' /></p>\n </form>"; } return; }
function exec_ogp_module() { global $db; global $view; $home_cfg_id = isset($_REQUEST['home_cfg_id']) ? $_REQUEST['home_cfg_id'] : ""; $home_id = isset($_REQUEST['home_id']) ? $_REQUEST['home_id'] : ""; $addon_id = isset($_REQUEST['addon_id']) ? $_REQUEST['addon_id'] : ""; $isAdmin = $db->isAdmin($_SESSION['user_id']); if ($isAdmin) { $home_info = $db->getGameHome($home_id); } else { $home_info = $db->getUserGameHome($_SESSION['user_id'], $home_id); } if ($home_info === FALSE) { print_failure(get_lang('no_rights')); echo create_back_button("addonsmanager", "user_addons"); return; } $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $home_info['home_cfg_file']); $state = isset($_REQUEST['state']) ? $_REQUEST['state'] : ""; $pid = isset($_REQUEST['pid']) ? $_REQUEST['pid'] : -1; if (!empty($state)) { $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']); $addons_rows = $db->resultQuery("SELECT url, path, post_script FROM OGP_DB_PREFIXaddons WHERE addon_id=" . $addon_id); $addon_info = $addons_rows[0]; $url = $addon_info['url']; $filename = basename($url); #### This makes replacements to the bash script: if (isset($addon_info['post_script']) and !empty($addon_info['post_script']) and $addon_info['post_script'] != "") { $check_passed = FALSE; $address_at_post = $_POST['ip'] . ":" . $_POST['port']; $ip_ports = $db->getHomeIpPorts($home_info["home_id"]); foreach ($ip_ports as $ip_port) { } $address_owned = $ip_port['ip'] . ":" . $ip_port['port']; if ($address_owned == $address_at_post) { $check_passed = TRUE; break; } $ip = $ip_port['ip']; $port = $ip_port['port']; $home_info["ip"] = $check_passed ? $_POST['ip'] : $ip; $home_info["port"] = $check_passed ? $_POST['port'] : $port; if (isset($server_xml->gameq_query_name)) { $home_info["query_port"] = get_query_port($server_xml, $home_info['port']); } elseif (isset($server_xml->lgsl_query_name)) { $get_q_and_s = lgsl_port_conversion((string) $server_xml->lgsl_query_name, $home_info['port'], "", ""); $home_info["query_port"] = $get_q_and_s['1']; } $home_info["incremental"] = $db->incrementalNumByHomeId($home_info["home_id"], $home_info["mod_cfg_id"], $home_info["remote_server_id"]); $post_script = preg_replace("/\\%home_path\\%/i", $home_info["home_path"], $addon_info['post_script']); $post_script = preg_replace("/\\%home_name\\%/i", $home_info["home_name"], $post_script); $post_script = preg_replace("/\\%control_password\\%/i", $home_info["control_password"], $post_script); $post_script = preg_replace("/\\%max_players\\%/i", $home_info["max_players"], $post_script); $post_script = preg_replace("/\\%ip\\%/i", $home_info["ip"], $post_script); $post_script = preg_replace("/\\%port\\%/i", $home_info["port"], $post_script); $post_script = preg_replace("/\\%query_port\\%/i", $home_info["query_port"], $post_script); $post_script = preg_replace("/\\%incremental\\%/i", $home_info["incremental"], $post_script); } else { $post_script = ""; } #### end of replacememnts if ($state == "start" and $addon_id != "") { $pid = $remote->start_file_download($addon_info['url'], $home_info['home_path'] . "/" . $addon_info['path'], $filename, "uncompress", $post_script); } $headers = get_headers($url, 1); $download_available = !$headers ? FALSE : TRUE; // Check if any error occured if ($download_available) { $bytes = is_array($headers['Content-Length']) ? $headers['Content-Length'][1] : $headers['Content-Length']; // Display the File Size $totalsize = $bytes / 1024; clearstatcache(); } $kbytes = $remote->rsync_progress($home_info['home_path'] . "/" . $addon_info['path'] . "/" . $filename); list($totalsize, $mbytes, $pct) = explode(";", do_progress($kbytes, $totalsize)); $totalmbytes = round($totalsize / 1024, 2); $pct = $pct > 100 ? 100 : $pct; echo "<h2>" . $home_info['home_name'] . "</h2>"; echo '<div class="dragbox bloc rounded" style="background-color:#dce9f2;" > <h4>' . get_lang('install') . " " . $filename . " {$mbytes}MB/{$totalmbytes}MB</h4>\n\t\t\t <div style='background-color:#dce9f2;' >\n\t\t\t "; $bar = ''; for ($i = 1; $i <= $pct; $i++) { $bar .= '<img style="width:0.92%;vertical-align:middle;" src="images/progressBar.png">'; } echo "<center>{$bar} <b style='vertical-align:top;display:inline;font-size:1.2em;color:red;' >{$pct}%</b></center>\n\t\t\t\t</div>\n\t\t\t </div>"; if (($pct == "100" or !$download_available) and $post_script != "") { $log_retval = $remote->get_log("post_script", $pid, clean_path($home_info['home_path'] . "/" . $server_xml->exe_location), $script_log); if ($log_retval == 0) { print_failure(get_lang('agent_offline')); } elseif ($log_retval == 1 || $log_retval == 2) { echo "<pre class='log'>" . $script_log . "</pre>"; } elseif ($remote->is_screen_running("post_script", $pid) == 1) { print_failure(get_lang_f('unable_to_get_log', $log_retval)); } } if ($pct == "100" or !$download_available or $download_available and $pct == "-" and $pid > 0) { if (!$download_available) { print_failure(get_lang('failed_to_start_file_download')); } elseif ($remote->is_file_download_in_progress($pid) === 1) { print_success(get_lang_f('wait_while_decompressing', $filename)); echo "<p><a href=\"?m=addonsmanager&p=addons&state=refresh&home_id=" . $home_id . "&addon_id={$addon_id}&pid={$pid}\">" . get_lang('refresh') . "</a></p>"; $view->refresh("?m=addonsmanager&p=addons&state=refresh&home_id=" . $home_id . "&addon_id={$addon_id}&pid={$pid}", 5); } elseif ($remote->is_file_download_in_progress($pid) === 0 and $remote->is_screen_running("post_script", $pid) === 0) { print_success(get_lang('addon_installed_successfully')); $view->refresh("?m=addonsmanager&p=user_addons&home_id=" . $home_id, 10); return; } } else { echo "<p><a href=\"?m=addonsmanager&p=addons&state=refresh&home_id=" . $home_id . "&addon_id={$addon_id}&pid={$pid}\">" . get_lang('refresh') . "</a></p>"; $view->refresh("?m=addonsmanager&p=addons&state=refresh&home_id=" . $home_id . "&addon_id={$addon_id}&pid={$pid}", 5); } } elseif (!empty($_GET['addon_type'])) { ?> <h2><?php echo $home_info['home_name'] . " " . get_lang($_GET['addon_type']); ?> </h2> <table class='center'> <form action='?m=addonsmanager&p=addons<?php echo "&ip=" . $_GET['ip'] . "&port=" . $_GET['port']; ?> ' method='post'> <input type='hidden' name='home_id' value='<?php echo "{$home_id}"; ?> ' /> <input type='hidden' name='state' value='start' /> <tr><td align='right'><?php print_lang('game_name'); ?> : </td><td align='left'><?php echo "{$home_info['game_name']}"; ?> </td></tr> <tr><td align='right'><?php print_lang('directory'); ?> : </td><td align='left'><?php echo "{$home_info['home_path']}"; ?> </td></tr> <tr><td align='right'><?php print_lang('remote_server'); ?> : </td> <td align='left'><?php echo "{$home_info['remote_server_name']} ({$home_info['agent_ip']}:{$home_info['agent_port']})"; ?> </td></tr> <tr><td align='right'><?php print_lang('select_addon'); ?> : </td> <td align='left'> <select name="addon_id"> <?php $addons = $db->resultQuery("SELECT addon_id, name FROM OGP_DB_PREFIXaddons WHERE addon_type='" . $_GET['addon_type'] . "' AND home_cfg_id=" . $home_cfg_id); foreach ($addons as $addon) { ?> <option value="<?php echo $addon['addon_id']; ?> "><?php echo $addon['name']; ?> </option> <?php } ?> </select> </td></tr> <tr><td colspan='2' class='info'> </td></tr> <td align='left'> </td></tr><tr><td align="right"> <input type="submit" name="update" value="<?php print_lang('install'); ?> " /> </form></td><td> <form action="" method="get"> <input type="hidden" name="m" value="addonsmanager" /> <input type="hidden" name="p" value="user_addons" /> <input type="hidden" name="home_id" value="<?php echo "{$home_id}"; ?> " /> <input type="submit" value="<?php print_lang('back'); ?> " /> </form> </td></tr> </table> <?php } return; }
function exec_ogp_module() { $home_id = $_REQUEST['home_id']; if (empty($home_id)) { print_failure(get_lang('home_id_missing')); return; } global $db, $view; $isAdmin = $db->isAdmin($_SESSION['user_id']); if ($isAdmin) { $home_cfg = $db->getGameHome($home_id); } else { $home_cfg = $db->getUserGameHome($_SESSION['user_id'], $home_id); } if ($home_cfg === FALSE) { print_failure(get_lang('no_access_to_home')); return; } litefm_check($home_id); $remote = new OGPRemoteLibrary($home_cfg['agent_ip'], $home_cfg['agent_port'], $home_cfg['encryption_key']); $os_string = $remote->what_os(); $os = preg_match("/Linux/i", $os_string) ? "linux" : "windows"; echo "<h2>"; echo empty($home_cfg['home_name']) ? get_lang('not_available') : $home_cfg['home_name']; echo "</h2>"; // We must always add the home directory to the fm_cwd so that user // can not go out of the homedir. $path = clean_path($home_cfg['home_path'] . "/" . @$_SESSION['fm_cwd_' . $home_id]); $upload_folder_path = "modules/litefm/uploads/home_id_{$home_id}"; if (isset($_GET['pid']) and $_GET['pid'] != "") { $bytes = $_GET['bytes']; $totalsize = $bytes / 1024; $uploaded_filename = $_GET['uploaded_filename']; $dest_file_path = clean_path($upload_folder_path . "/" . $uploaded_filename . ".txt"); $kbytes = $remote->rsync_progress(clean_path($path . "/" . $uploaded_filename)); list($totalsize, $mbytes, $pct) = explode(";", do_progress($kbytes, $totalsize)); $totalmbytes = round($totalsize / 1024, 2); $pct = $pct > 100 ? 100 : $pct; if ($pct > 0) { echo '<div class="dragbox bloc rounded" style="background-color:#dce9f2;" > <h4>' . get_lang('upload') . " " . $uploaded_filename . " {$mbytes}MB/{$totalmbytes}MB</h4>\n\t\t\t\t <div style='background-color:#dce9f2;' >\n\t\t\t\t "; $bar = ''; for ($i = 1; $i <= $pct; $i++) { $bar .= '<img style="width:0.92%;vertical-align:middle;" src="images/progressBar.png">'; } echo "<center>{$bar} <b style='vertical-align:top;display:inline;font-size:1.2em;color:red;' >{$pct}%</b></center>\n\t\t\t\t\t</div>\n\t\t\t\t </div>"; } $pid = $_GET['pid']; if ($remote->is_file_download_in_progress($pid) == 0) { unlink($dest_file_path); $directory = dir($upload_folder_path); $directory_not_empty = FALSE; while (FALSE !== ($item = $directory->read()) && !isset($directory_not_empty)) { if ($item != '.' && $item != '..') { $directory_not_empty = TRUE; } } $directory->close(); if (!$directory_not_empty) { rmdir($upload_folder_path); } print_success(print_lang('upload_complete')); $db->logger(get_lang('upload_complete') . " ( " . clean_path($path . "/" . $uploaded_filename) . " )"); $view->refresh('?m=litefm&home_id=' . $home_id, 2); return; } else { print_success(print_lang('upload_in_progress')); $view->refresh('?m=litefm&home_id=' . $home_id . "&uploaded_filename={$uploaded_filename}&bytes={$bytes}&pid={$pid}&upload=true", 2); return; } } else { echo "<table class='center'><tr><td><a href='?m=gamemanager&p=game_monitor&home_id=" . $home_cfg['home_id'] . "'><< " . get_lang('back') . "</a></td></tr></table>"; $POST_MAX_SIZE = ini_get('post_max_size'); $mul = substr($POST_MAX_SIZE, -1); $mul = $mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1)); if (isset($_GET['upload']) && $_GET['upload'] == "true" && $_SERVER['CONTENT_LENGTH'] > $mul * (int) $POST_MAX_SIZE && $POST_MAX_SIZE) { print_failure(get_lang_f('upload_failed', '( php.ini: upload_max_filesize = ' . ini_get('upload_max_filesize') . ", post_max_size = " . ini_get('post_max_size') . ", memory_limit = " . ini_get('memory_limit') . ' )')); } if (isset($_POST['upload'])) { if (isset($_FILES['uploaded_file'])) { $bytes = $_FILES['uploaded_file']['size']; $bad_chars = preg_replace("/([[:alnum:]_\\.-]*)/", "", $_FILES['uploaded_file']['name']); $bad_arr = str_split($bad_chars); $uploaded_filename = str_replace($bad_arr, "", $_FILES['uploaded_file']['name']); $dest_file_path = clean_path($upload_folder_path . "/" . $uploaded_filename . ".txt"); $s = isset($_SERVER['HTTPS']) ? "s" : ""; $p = isset($_SERVER['SERVER_PORT']) & $_SERVER['SERVER_PORT'] != "80" ? ":" . $_SERVER['SERVER_PORT'] : NULL; $url = 'http' . $s . '://' . $_SERVER['SERVER_NAME'] . $p . $_SERVER['SCRIPT_NAME']; $file_url = str_replace("home.php", $dest_file_path, $url); if ($_FILES['uploaded_file']['error'] > 0) { print_failure(get_lang_f('upload_failed'), $_FILES['uploaded_file']['error']); } else { if (!file_exists($upload_folder_path)) { if (!mkdir($upload_folder_path, 0777, true)) { print_failure(get_lang_f('can_not_create_upload_folder_path'), $upload_folder_path); } } if (file_exists($dest_file_path)) { unlink($dest_file_path); } move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], $dest_file_path); if (file_exists($dest_file_path)) { $remote_file_path = clean_path($path . "/" . $uploaded_filename); if ($remote->rfile_exists($remote_file_path)) { $remote->exec('rm -f ' . $remote_file_path); } $uncompress = isset($_POST['uncompress']) ? "uncompress" : ""; $pid = $remote->start_file_download($file_url, $path, $uploaded_filename, $uncompress); if ($remote->is_file_download_in_progress($pid) < 0) { print_failure(get_lang_f('upload_failed', get_lang_f('url_is_not_accesible_from_agent', $file_url))); } else { $view->refresh('?m=litefm&home_id=' . $home_id . "&uploaded_filename={$uploaded_filename}&bytes={$bytes}&pid={$pid}&upload=true", 1); } } } } } if (isset($_POST['create_folder'])) { $bad_chars = preg_replace("/([[:alnum:]_\\.-]*)/", "", $_POST['folder_name']); $bad_arr = str_split($bad_chars); $folder_name = str_replace($bad_arr, "", $_POST['folder_name']); $remote->exec('mkdir ' . clean_path($path . "/" . $folder_name)); $db->logger(get_lang('create_folder') . " " . clean_path($path . "/" . $folder_name)); } if (isset($_POST['delete'])) { if (!isset($_POST['delete_check'])) { echo "<table class='center' style='width:100%;' ><tr>\n" . "<td>" . get_lang_f('delete_item', clean_path($path . "/" . $_POST['delete'])) . "</td>" . "</tr><tr><td>" . '<form action="?m=litefm&home_id=' . $home_id . '" method="post" enctype="multipart/form-data">' . "\n" . '<input type="hidden" name="delete" value="' . $_POST['delete'] . '">' . "\n" . '<button name="delete_check" value="yes" >' . get_lang('yes') . "</button>\n" . '<button name="delete_check" value="no" >' . get_lang('no') . "</button>\n" . "</form>\n" . "</td>\n" . "</tr>\n" . "</table>\n"; } elseif ($_POST['delete_check'] == "yes") { $remote->exec('rm -Rf "' . clean_path($path . "/" . $_POST['delete']) . '"'); $db->logger('rm -Rf "' . clean_path($path . "/" . $_POST['delete']) . '"'); } } // Chattr Check if (isset($_POST['secureButton'])) { if (!isset($_POST['secure_check'])) { echo "<table class='center' style='width:100%;' ><tr>\n" . "<td>" . get_lang_f('secure_item', clean_path($path . "/" . $_POST['secureFile'])) . "</td>" . "</tr><tr><td>" . '<form action="?m=litefm&home_id=' . $home_id . '" method="post" >' . "\n" . '<input type="hidden" name="secureFile" value="' . $_POST['secureFile'] . '">' . "\n" . '<input type="hidden" name="secureButton" value="' . $_POST['secureButton'] . '">' . "\n" . '<button name="secure_check" value="yes" >' . get_lang('yes') . "</button>\n" . '<button name="secure_check" value="no" >' . get_lang('no') . "</button>\n" . "</form>\n" . "</td>\n" . "</tr>\n" . "</table>\n"; } elseif ($_POST['secure_check'] == "yes") { $chatAction = $_POST['secureButton']; if ($chatAction == get_lang('chattr_yes')) { $action = 'chattr+i'; } else { $action = 'chattr-i'; } $pathToFile = clean_path($path . "/" . $_POST['secureFile']); $remote->secure_path($action, $pathToFile); if ($action == 'chattr+i') { $db->logger(get_lang('chattr_locked') . ": {$pathToFile}"); } else { $db->logger(get_lang('chattr_unlocked') . ": {$pathToFile}"); } } } echo "<table class='center' style='width:100%;' ><tr>\n" . "<td colspan='3' ><h3>" . get_lang_f('currently_viewing', $path) . "</h3></td>" . "</tr><tr><td style='border:1px solid gray;'>" . get_lang('upload_file') . ':<form action="?m=litefm&home_id=' . $home_id . '&upload=true" method="post" enctype="multipart/form-data">' . "\n" . '<input type="file" name="uploaded_file" id="file">' . "\n" . '<input type="checkbox" name="uncompress" value="true"> ' . get_lang('uncompress') . "\n" . '<input type="submit" name="upload" value="' . get_lang('upload') . '">' . "\n" . "</form>\n" . "</td>\n" . "<td>\n" . " " . "</td>\n" . "<td style='border:1px solid gray;' >\n" . get_lang('create_folder') . ':<form action="?m=litefm&home_id=' . $home_id . '&create_folder=true" method="post" >' . "\n" . '<input type="text" name="folder_name" />' . "\n" . '<input type="submit" name="create_folder" value="' . get_lang('create') . '"/>' . "\n" . "</form>\n" . "</td></tr>\n" . "</table>\n"; if (!$remote->rfile_exists($path)) { $path = clean_path($home_cfg['home_path']); if (!$remote->rfile_exists($path)) { print_failure(get_lang_f("dir_not_found", $path)); } else { $_SESSION['fm_cwd_' . $home_id] = str_replace("\\", "", dirname($_SESSION['fm_cwd_' . $home_id])); echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=?m=litefm&home_id=' . $home_id . '">'; } } else { $dirlist = $remote->remote_dirlistfm($path); if ($os == "linux") { $lsattr = $remote->exec('lsattr ' . $path); } if (!is_array($dirlist)) { if ($dirlist === -1) { if ($path != $home_cfg['home_path'] . "/") { echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=?m=litefm&home_id=' . $home_id . '">'; } else { print_failure('Your game server\'s home path is too long or there is a file with a very long name inside of your game server\'s home folder.'); } } else { if ($remote->rfile_exists($path)) { if (strpos($path, '/') !== FALSE) { $ePath = explode('/', $path); $filename = end($ePath); } else { if (strpos($path, '\\') !== FALSE) { $ePath = explode('\\', $path); $filename = end($ePath); } } $_SESSION['fm_cwd_' . $home_id] = str_replace("\\", "", dirname($_SESSION['fm_cwd_' . $home_id])); echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=?m=litefm&home_id=' . $home_id . '&path=' . $filename . '&p=read_file">'; } else { print_failure(get_lang("failed_list")); } } return; } if (empty($dirlist)) { print_lang('empty_directory'); echo "<table class='center' style='width:100%;' >\n" . show_back($home_id) . "</table>"; } else { echo "<table class='center' style='width:100%;' >\n" . show_back($home_id) . "<tr><td style='width:10px;' ></td><td align=left>\n" . get_lang('filename') . "</td>"; if ($os == "linux") { echo "<td>" . get_lang('filesecure') . "</td>"; } echo "<td>" . get_lang('filesize') . " [" . get_lang('bytes') . "]</td><td>" . get_lang('owner') . " " . get_lang('group') . "</td></tr>\n"; $directorys = array(); $files = array(); $binarys = array(); foreach ($dirlist as $item) { # dirlist FM returns an array. Each element has 5 fields separated by the | character list($filename, $size, $user, $group, $type) = explode("|", $item); $filepath = str_replace("/", "\\/", clean_path($path . "/" . $filename)); if ($os == "linux") { preg_match('/(\\S+)\\s' . $filepath . '/', $lsattr, $file_attributes); } // Directory if ($type == 'D') { $directorys[$filename]['filename'] = $filename; $directorys[$filename]['user'] = $user; $directorys[$filename]['group'] = $group; } elseif ($type == 'F') { $files[$filename]['filename'] = $filename; $files[$filename]['size'] = $size; $files[$filename]['user'] = $user; $files[$filename]['group'] = $group; if ($os == "linux") { $files[$filename]['attr'] = $file_attributes[1]; } } elseif ($type == 'B') { $binarys[$filename]['filename'] = $filename; $binarys[$filename]['size'] = $size; $binarys[$filename]['user'] = $user; $binarys[$filename]['group'] = $group; if ($os == "linux") { $binarys[$filename]['attr'] = $file_attributes[1]; } } } foreach ($directorys as $directory) { echo "<tr>\n" . "<td>" . '<form method=POST>' . "<input type=hidden name='delete' value='" . $directory['filename'] . "' class='item' />\n" . '<input type="image" style="width:12px;padding-left:5px;" src="modules/administration/images/remove.gif" />' . "</form>\n" . "</td>" . "<td align=left>" . "<img class=\"viewitem\" src=\"images/folder.png\" alt=\"Directory\" /> " . "<a href=\"?m=litefm&home_id={$home_id}&path=" . $directory['filename'] . "\">" . $directory['filename'] . "</a></td>"; if ($os == "linux") { echo "<td>-</td>"; } echo "<td>-</td> <td>" . $directory['user'] . " " . $directory['group'] . "</td>\n" . "</tr>\n"; } foreach ($files as $file) { if ($os == "linux") { if ($isAdmin) { $secureFile = '<td><form method=POST>'; $secureFile .= "<input type=hidden name='secureFile' value='" . $file['filename'] . "' class='item' />\n"; if (preg_match("/i/", $file['attr'])) { $secureFile .= "<input type='submit' class='chattrButton' name='secureButton' value='" . get_lang('chattr_no') . "' class='item' />\n"; } else { $secureFile .= "<input type='submit' class='chattrButton' name='secureButton' value='" . get_lang('chattr_yes') . "' class='item' />\n"; } $secureFile .= '</form></td>'; } else { $secureFile = "<td><span class="; if (preg_match("/i/", $file['attr'])) { $secureFile .= "'chattrLock'>" . get_lang('chattr_locked'); } else { $secureFile .= "'chattrUnlock'>" . get_lang('chattr_unlocked'); } $secureFile .= "</span></td>\n"; } } else { $secureFile = ""; } echo "<tr>\n" . "<td>" . '<form method=POST>' . "<input type=hidden name='delete' value='" . $file['filename'] . "' class='item' />\n" . '<input type="image" style="width:12px;padding-left:5px;" src="modules/administration/images/remove.gif" />' . "</form>\n" . "</td>" . "<td align=left>"; echo "<img class=\"viewitem\" src=\"images/txt.png\" alt=\"Text file\" /> " . "<a href=\"?m=litefm&home_id={$home_id}&path=" . $file['filename'] . "&p=read_file\">" . get_lang("button_edit") . "</a>" . $file['filename'] . "</td>\n\t\t\t\t\t\t {$secureFile}<td>" . $file['size'] . "</td> <td>" . $file['user'] . " " . $file['group'] . "</td>\n"; echo "</tr>\n"; } foreach ($binarys as $binary) { if ($os == "linux") { if ($isAdmin) { $secureFile = '<td><form method=POST>'; $secureFile .= "<input type=hidden name='secureFile' value='" . $binary['filename'] . "' class='item' />\n"; if (preg_match("/i/", $binary['attr'])) { $secureFile .= "<input type='submit' class='chattrButton' name='secureButton' value='" . get_lang('chattr_no') . "' class='item' />\n"; } else { $secureFile .= "<input type='submit' class='chattrButton' name='secureButton' value='" . get_lang('chattr_yes') . "' class='item' />\n"; } $secureFile .= '</form></td>'; } else { $secureFile = "<td><span class="; if (preg_match("/i/", $binary['attr'])) { $secureFile .= "'chattrLock'>" . get_lang('chattr_locked'); } else { $secureFile .= "'chattrUnlock'>" . get_lang('chattr_unlocked'); } $secureFile .= "</span></td>\n"; } } else { $secureFile = ""; } echo "<tr>\n" . "<td>" . '<form method=POST>' . "<input type=hidden name='delete' value='" . $binary['filename'] . "' class='item' />\n" . '<input type="image" style="width:12px;padding-left:5px;" src="modules/administration/images/remove.gif" />' . "</form>\n" . "</td>" . "<td align=left>"; echo "<img class=\"viewitem\" src=\"images/exec.png\" alt=\"Binary file\" /> " . $binary['filename'] . "</td>\n\t\t\t\t\t\t {$secureFile}<td>" . $binary['size'] . "</td><td>" . $binary['user'] . " " . $binary['group'] . "</td>\n"; echo "</tr>\n"; } echo "</table>\n"; } } } echo "<table class='center'><tr><td><a href='?m=gamemanager&p=game_monitor&home_id=" . $home_cfg['home_id'] . "'><< " . get_lang('back') . "</a></td></tr></table>"; }