0) { $pct = round(( $kbytes / $totalsize ) * 100, 2); } else { $pct = unavailable; } #echo "Percent is $pct"; return "$totalsize;$mbytes;$pct"; } require_once("includes/lib_remote.php"); require_once("modules/config_games/server_config_parser.php"); function exec_ogp_module() { global $db, $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( no_rights ); echo create_back_button("gamemanager","gamemanager"); return; } $home_id = $home_info['home_id']; $state = isset($_REQUEST['state']) ? $_REQUEST['state'] : ""; $pid = isset($_REQUEST['pid']) ? $_REQUEST['pid'] : -1; $filename = isset($_REQUEST['filename']) ? $_REQUEST['filename'] : ""; echo "

". install_update_manual ." $home_info[home_name]

"; if ( !empty($state) ) { $remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']); if ( $state == "start" ) { $server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']); $postinstall = $server_xml->post_install ? $server_xml->post_install : ""; $pid = $remote->start_file_download($_REQUEST['url'],$home_info['home_path'], $filename,"uncompress",$postinstall); if ( $pid < 0 ) { print_failure( 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 '

'. update_in_progress ." ${mbytes}MB/${totalmbytes}MB

"; $bar = ''; for( $i = 1; $i <= $pct; $i++ ) { $bar .= ''; } echo "
$bar $pct%
"; if ( $remote->is_file_download_in_progress($pid) == 0 ) { print_success( finished_manual_update ); } else { echo "

Refresh

"; $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=".$home_id); } else { echo "
". game_name .":$home_info[game_name]
". dest_dir .":$home_info[home_path]
". remote_server .": $home_info[remote_server_name] ($home_info[agent_ip]:$home_info[agent_port])
". file_url .":
". file_url_info ."
". dest_filename .":
". dest_filename_info ."

"; ?>