/*
 * Generated by the Jasper component of Apache Tomcat
 * Version: Apache Tomcat/7.0.19
 * Generated at: 2014-03-11 08:27:00 UTC
 * Note: The last modified time of this file was set to
 *       the last modified time of the source file after
 *       generation to assist with modification tracking.
 */
package org.apache.jsp.manage;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.io.*;
import java.text.*;
import java.lang.*;
import java.util.Calendar.*;
import java.util.*;
import com.goldhuman.util.*;
import protocol.*;
import com.goldhuman.auth.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.goldhuman.util.LocaleUtil;
import com.goldhuman.util.*;

public final class instance_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final javax.servlet.jsp.JspFactory _jspxFactory =
          javax.servlet.jsp.JspFactory.getDefaultFactory();

  private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;

  static {
    _jspx_dependants = new java.util.HashMap<java.lang.String,java.lang.Long>(3);
    _jspx_dependants.put("/include/.config.jsp", Long.valueOf(1394526092000L));
    _jspx_dependants.put("/manage/../include/foot.jsp", Long.valueOf(1394524943000L));
    _jspx_dependants.put("/manage/../include/header.jsp", Long.valueOf(1394526250000L));
  }

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.tomcat.InstanceManager _jsp_instancemanager;

  public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
  }

  public void _jspDestroy() {
  }

  public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
        throws java.io.IOException, javax.servlet.ServletException {

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");

	String db_host = "localhost";
	String db_port = "3306";
	String db_user = "root";
	String db_password = "1234";
	String db_database = "pw";
	String item_labels = "pwi";
	String pw_server_path = "/home/";

      out.write('\n');
      out.write("\n");
      out.write("\n");
      out.write("<html>\n");
      out.write("<title>Локации и службы</title>\n");
      out.write("<head>\n");
      out.write("\n");
      out.write("\n");
      out.write("<title>IWEB 1.4.5</title>\n");
      out.write("<LINK href=\"/iweb/css/style.css\" rel=stylesheet type=text/css>\n");
      out.write("<meta http-equiv=\"Pragma\" content=\"no-cache\">\n");
      out.write("<meta http-equiv=\"cache-control\" content=\"no-cache\">\n");
      out.write("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">\n");
      out.write("\t<tr>\n");
      out.write("\t\t<td width=\"30\" height=\"70\" bgcolor=\"#007fff\">\n");
      out.write("\t\t</td>\n");
      out.write("\t\t</td>\n");
      out.write("\t\t<td width=\"600\" class=\"navColor align=\"center\" >\n");
      out.write("\t\t<a href=\"/iweb/index.jsp\" class=\"white\">[Аккаунты]</a> | \n");
      out.write("\t\t<a href=\"/iweb/role/index.jsp\" class=\"white\">[Редактирование XML]</a>| \n");
      out.write("\t\t<a href=\"/iweb/role/manage.jsp\" class=\"white\">[Персонажи]</a> | \n");
      out.write("\t\t<a href=\"/iweb/manage/index.jsp\" class=\"white\">[Настройки сервера]</a>\t| \n");
      out.write("\t\t<a href=\"/iweb/manage/instance.jsp\" class=\"white\">[Локации и службы]</a> | \n");
      out.write("\t\t<a href=\"http://forum.kn1fe-zone.ru\" class=\"white\">[Доработал до 1.5.1 Kn1fe]</a>\n");
      out.write("\t</td>\n");
      out.write("\t</tr>\n");
      out.write("\t<tr class=\"shadow\">\n");
      out.write("\t\t<td height=\"4\" colspan=\"3\"></td>\n");
      out.write("\t</tr>\n");
      out.write("\t<tr>\n");
      out.write("\t\t<td height=\"10\" colspan=\"3\"></td>\n");
      out.write("\t</tr>\n");
      out.write("</table>");
      out.write("\n");
      out.write("</head>\n");
      out.write("<body style=\"background-color:#ffffff;\">\n");
      out.write("<link href=\"../include/style.css\" rel=\"stylesheet\" type=\"text/css\">\n");
      out.write("<div align=\"center\"><font size=\"6\">Локации и службы</font>\n");
      out.write("<table width=\"800\" border=\"0\" cellspacing=\"0\">\n");
      out.write("\n");

	String message = "<br>";

	if(request.getParameter("process") != null)
	{
		Process p;
		String command;
		File working_directory;

		if(request.getParameter("process").compareTo("stopserver") == 0)
		{
			try
			{
				command = pw_server_path + "gamedbd/./gamedbd " + pw_server_path + "gamedbd/gamesys.conf exportclsconfig";
				working_directory = new File(pw_server_path + "gamedbd/");
				p = Runtime.getRuntime().exec(command, null, working_directory);
				p.waitFor();
				Thread.sleep(1000);

				Runtime.getRuntime().exec("pkill -9 gs");
				Runtime.getRuntime().exec("pkill -9 glinkd");
				Runtime.getRuntime().exec("pkill -9 gdeliveryd");
				Runtime.getRuntime().exec("pkill -9 gfactiond");
				Runtime.getRuntime().exec("pkill -9 gacd");
				Runtime.getRuntime().exec("pkill -9 gamedbd");
				Runtime.getRuntime().exec("pkill -9 uniquenamed");
				p = Runtime.getRuntime().exec("ps -A w");
				BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
				String line;
				while((line = input.readLine()) != null)
				{
					if(line.indexOf("authd") != -1)
					{
						Runtime.getRuntime().exec("kill " + line.substring(0, 5).replace(" ", ""));
					}
					else
						;
				}
				Runtime.getRuntime().exec("pkill -9 logservice");
				Runtime.getRuntime().exec("sync");
				FileWriter fw = new FileWriter(new File("/proc/sys/vm/drop_caches"));
				fw.write("3");
				fw.close();

				Thread.sleep(6000);

				message = "<font color=\"#00cc00\"><b>Сервер выключен</font>";
			}
			catch(Exception e)
			{
				message = "<font color=\"#ee0000\"><b>Выключение не удалось</b></font>";
			}
		}
		else
			;

		if(request.getParameter("process").compareTo("startserver") == 0)
		{
			File f = new File(pw_server_path + "iweb_starter.sh");
			try
			{
				FileWriter fw = new FileWriter(f);
				fw.write("if [ ! -d " + pw_server_path + "logs ]; then\n");
				fw.write("mkdir " + pw_server_path + "logs\n");
				fw.write("fi\n");
				fw.write("cd " + pw_server_path + "logservice; ./logservice logservice.conf >" + pw_server_path + "logs/logservice.log &\n");
				fw.write("sleep 1\n");
				fw.write("cd " + pw_server_path + "uniquenamed; ./uniquenamed gamesys.conf >" + pw_server_path + "logs/uniquenamed.log &\n");
				fw.write("sleep 1\n");
				fw.write("cd " + pw_server_path + "auth/build; ./authd >" + pw_server_path + "logs/auth.log &\n");
				fw.write("sleep 1\n");
				fw.write("cd " + pw_server_path + "gamedbd; ./gamedbd gamesys.conf >" + pw_server_path + "logs/gamedbd.log &\n");
				fw.write("sleep 1\n");
				fw.write("cd " + pw_server_path + "gacd; ./gacd gamesys.conf >" + pw_server_path + "logs/gacd.log &\n");
				fw.write("sleep 1\n");
				fw.write("cd " + pw_server_path + "gfactiond; ./gfactiond gamesys.conf >" + pw_server_path + "logs/gfactiond.log &\n");
				fw.write("sleep 1\n");
				fw.write("cd " + pw_server_path + "gdeliveryd; ./gdeliveryd gamesys.conf >" + pw_server_path + "logs/gdeliveryd.log &\n");
				fw.write("sleep 1\n");
				fw.write("cd " + pw_server_path + "glinkd; ./glinkd gamesys.conf 1 >" + pw_server_path + "logs/glink1.log &\n");
				fw.write("cd " + pw_server_path + "glinkd; ./glinkd gamesys.conf 2 >" + pw_server_path + "logs/glink2.log &\n");
				fw.write("cd " + pw_server_path + "glinkd; ./glinkd gamesys.conf 3 >" + pw_server_path + "logs/glink3.log &\n");
				fw.write("cd " + pw_server_path + "glinkd; ./glinkd gamesys.conf 4 >" + pw_server_path + "logs/glink4.log &\n");
				fw.write("sleep 1\n");
				fw.write("cd " + pw_server_path + "gamed; ./gs gs01 >" + pw_server_path + "logs/gs01.log &\n");
				fw.write("sleep 1");
				fw.close();

				command = "sh " + pw_server_path + "iweb_starter.sh";
				working_directory = new File(pw_server_path);
				Runtime.getRuntime().exec("chmod 777 " + pw_server_path + "iweb_starter.sh");
				Runtime.getRuntime().exec(command, null, working_directory);
				Thread.sleep(12000);
				f.delete();

				message = "<font color=\"#00cc00\"><b>Запуск...</font>";
			}
			catch(Exception e)
			{
				f.delete();
				message = "<font color=\"#ee0000\"><b>Запуск не удался</b></font>" + e.getMessage();
			}
		}
		else
		;

		if(request.getParameter("process").compareTo("stopallmaps") == 0)
		{
			try
			{
				int time = Integer.parseInt(request.getParameter("time"));
				if(protocol.DeliveryDB.GMRestartServer(-1, time))
				{
					message = "<font color=\"#00cc00\"><b>Все будет остановлено через " + time + " сек</font>";
				}
				else
				{
					message = "<font color=\"#ee0000\"><b>Остановить не удалось</b></font>";
				}
			}
			catch(Exception e)
			{
				message = "<font color=\"#ee0000\"><b>Остановить не удалось</b></font>";
			}
		}
		else
		;

		if(request.getParameter("process").compareTo("stopmap") == 0)
		{
			try
			{
				String[] maps = request.getParameterValues("map");
				for(int i=0; i<maps.length; i++)
				{
					Runtime.getRuntime().exec("kill " +  maps[i]);
					Thread.sleep(1000);
				}
				message = "<font color=\"#00cc00\"><b>Выключено</b></font>";
			}
			catch(Exception e)
			{
				message = "<font color=\"#ee0000\"><b>Остановить не удалась</b></font>";
			}
		}
		else
			;

		if(request.getParameter("process").compareTo("startmap") == 0)
		{
			File f = new File(pw_server_path + "iweb_map.sh");
			try
			{
				String[] maps = request.getParameterValues("map");
				FileWriter fw = new FileWriter(f);
				for(int i=0; i<maps.length; i++)
				{
					fw.write("cd " + pw_server_path + "gamed; ./gs " + maps[i] + " >" + pw_server_path + "logs/" + maps[i] + ".log &\n");
					fw.write("sleep 1");
				}
				fw.close();

				command = "sh " + pw_server_path + "./iweb_map.sh";
				working_directory = new File(pw_server_path);
				Runtime.getRuntime().exec("chmod 755 " + pw_server_path + "iweb_map.sh");
				Runtime.getRuntime().exec(command, null, working_directory);
				Thread.sleep(1000*maps.length);
				f.delete();
				message = "<font color=\"#00cc00\"><b>Запущено</b></font>";
			}
			catch(Exception e)
			{
				f.delete();
				message = "<font color=\"#ee0000\"><b>Не удалось запустить</b></font>";
			}
		}
		else
			;
		if(request.getParameter("process").compareTo("backup") == 0)
		{
			// Check if another Backup is running

			String line;
			boolean backup_allowed = true;
			p = Runtime.getRuntime().exec("ps -A w");
			BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
			while((line = input.readLine()) != null)
			{
				if(line.substring(27).indexOf("/./pw_backup.sh") != -1)
				{
					backup_allowed = false;
				}
				else
					;
			}
			input.close();

			if(backup_allowed)
			{
				File f = new File(pw_server_path + "pw_backup.sh");
				try
				{
					String time = (new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss")).format(new java.util.Date());
					FileWriter fw = new FileWriter(f);
					fw.write("cd " + pw_server_path + "\n");
					fw.write("mysqldump -u" + db_user + " -p" + db_password + " " + db_database + " --routines > " + pw_server_path + "pw_backup_" + time + ".sql\n");
					fw.write("sleep 1\n");
					fw.write("tar -zcf " + pw_server_path + "pw_backup_" + time + ".tar.gz " + pw_server_path + " --exclude=pw_backup*\n");
					fw.write("sleep 1\n");
					fw.write("sync; echo 3 > /proc/sys/vm/drop_caches");
					fw.close();

					command = "sh " + pw_server_path + "./pw_backup.sh";
					working_directory = new File(pw_server_path);
					Runtime.getRuntime().exec("chmod 755 " + pw_server_path + "pw_backup.sh");
					Runtime.getRuntime().exec(command, null, working_directory);

					Thread.sleep(3000);

					f.delete();
					message = "<font color=\"#00cc00\"><b>Backup Started -> " + pw_server_path + "pw_backup_" + time + "</b></font>";
				}
				catch(Exception e)
				{
					f.delete();
					message = "<font color=\"#ee0000\"><b>Backup Failed</b></font>";
				}
			}
			else
				;
		}
		else
			;
	}
	else
		;

	// Load

	// maps[*][0] -> process ID / pid
	// maps[*][1] -> map id
	// maps[*][2] -> map name
	String[][] maps;
	if(item_labels.compareTo("pwi") == 0)
	{
		String[][] m = 
		{
		{"0", "gs01", "Мир"}, 
		{"0", "is01", "Город Темных Зверей"}, 
		{"0", "is02", "Могильник Героя"}, 
		{"0", "is05", "Пещера Огненных Скал"}, 
		{"0", "is06", "Логово Бешеных Волков"}, 
		{"0", "is07", "Пещера Ползучих Гадов"}, 
		{"0", "is08", "Зеленый Курган"}, 
		{"0", "is09", "Темная Обитель"}, 
		{"0", "is10", "Инеевый Предел"}, 
		{"0", "is11", "Долина Расхитителей Небес"}, 
		{"0", "is12", "Руины В Джунглях"}, 
		{"0", "is13", "Предел Дьявольских Наслаждений"}, 
		{"0", "is14", "Врата Беспокойных Духов"}, 
		{"0", "is15", "Пещера Драгоценностей"}, 
		{"0", "is16", "Небо Иллюзий"}, 
		{"0", "is17", "Небо Наваждений"}, 
		{"0", "is18", "Дворец Царя Драконов"}, 
		{"0", "is19", "Остров ночного плача"}, 
		{"0", "is20", "Остров Тысячи Змей"}, 
		{"0", "is21", "Земли Небожителей"}, 
		{"0", "is22", "Земли Магов И Демонов"}, 
		{"0", "is23", "Чистилище"}, 
		{"0", "is24", "Земной Ад"}, 
		{"0", "is25", "Город Боевых Песен"}, 
		{"0", "is26", "Нирвана"}, 
		{"0", "is27", "Долина Таинственной Луны"}, 
		{"0", "is28", "Долина бездушия (Гуй Му)"}, 
		{"0", "is29", "Город Инея"}, 
		{"0", "is31", "Сумеречный Храм"}, 
		{"0", "is32", "Куб Рока"}, 
		{"0", "is33", "Хрономир"}, 
		{"0", "is34", "Церковь"},
		{"0", "is35", "База Гильдий"},
		{"0", "is37", "Морай"},
		{"0", "is38", "Ущелье Феникса"},
		{"0", "is39", "Пещера Вечности"},
		{"0", "is40", "Дворец Короля Сминфисов"},
		{"0", "is41", "Пещера Вечности"},
		{"0", "is42", "Место отдыха"},
		{"0", "is43", "Небесный престол"},
		{"0", "is44", "Тренировочная площадка"},
		{"0", "is45", "Тренировочная площадка"},
		{"0", "is46", "Тренировочная площадка"},
		{"0", "is47", "Битва Катапульт"},
		{"0", "is48", "Зал наказаний"},
		{"0", "is49", "Драконье убежище"},
		{"0", "is50", "Страна Грез"},
		{"0", "is62", "Стартовая локация"},
		{"0", "is63", "Человеческий мир"},
		{"0", "is64", "Зал Перерождения"},
		{"0", "is66", "Потоки серебра"},
		{"0", "is67", "Зал V"},
		{"0", "is68", "Человеческий мир [2]"},
		{"0", "arena01", "Арена ГМ Асура"}, 
		{"0", "arena02", "Арена ГО"}, 
		{"0", "arena03", "Арена ГП"}, 
		{"0", "arena04", "Арена ГД Эвент"}, 
		{"0", "arena05", "Нирвана(старая)"}, 
		{"0", "bg01", "ТВ T-3 PvP - 1"}, 
		{"0", "bg02", "ТВ T-3 PvE - 2"}, 
		{"0", "bg03", "ТВ T-2 PvP - 3"}, 
		{"0", "bg04", "ТВ T-2 PvE - 4"}, 
		{"0", "bg05", "ТВ T-1 PvP - 5"}, 
		{"0", "bg06", "ТВ T-1 PvE - 6"}
		};
		maps = m;
	}
	else
	{
		String[][] m = 
		{
		{"0", "gs01", "Мир"}, 
		{"0", "is01", "Город Темных Зверей"}, 
		{"0", "is02", "Могильник Героя"}, 
		{"0", "is05", "Пещера Огненных Скал"}, 
		{"0", "is06", "Логово Бешеных Волков"}, 
		{"0", "is07", "Пещера Ползучих Гадов"}, 
		{"0", "is08", "Зеленый Курган"}, 
		{"0", "is09", "Темная Обитель"}, 
		{"0", "is10", "Инеевый Предел"}, 
		{"0", "is11", "Долина Расхитителей Небес"}, 
		{"0", "is12", "Руины В Джунглях"}, 
		{"0", "is13", "Предел Дьявольских Наслаждений"}, 
		{"0", "is14", "Врата Беспокойных Духов"}, 
		{"0", "is15", "Пещера Драгоценностей"}, 
		{"0", "is16", "Небо Иллюзий"}, 
		{"0", "is17", "Небо Наваждений"}, 
		{"0", "is18", "Дворец Царя Драконов"}, 
		{"0", "is19", "Остров ночного плача"}, 
		{"0", "is20", "Остров Тысячи Змей"}, 
		{"0", "is21", "Земли Небожителей"}, 
		{"0", "is22", "Земли Магов И Демонов"}, 
		{"0", "is23", "Чистилище"}, 
		{"0", "is24", "Земной Ад"}, 
		{"0", "is25", "Город Боевых Песен"}, 
		{"0", "is26", "Нирвана"}, 
		{"0", "is27", "Долина Таинственной Луны"}, 
		{"0", "is28", "Долина бездушия (Гуй Му)"}, 
		{"0", "is29", "Город Инея"}, 
		{"0", "is31", "Сумеречный Храм"}, 
		{"0", "is32", "Куб Рока"}, 
		{"0", "is33", "Хрономир"}, 
		{"0", "is34", "Церковь"},
		{"0", "is35", "База Гильдий"},
		{"0", "is37", "Морай"},
		{"0", "is38", "Ущелье Феникса"},
		{"0", "is39", "Пещера Вечности"},
		{"0", "is40", "Дворец Короля Сминфисов"},
		{"0", "is41", "Пещера Вечности"},
		{"0", "is42", "Место отдыха"},
		{"0", "is43", "Небесный престол"},
		{"0", "is44", "Тренировочная площадка"},
		{"0", "is45", "Тренировочная площадка"},
		{"0", "is46", "Тренировочная площадка"},
		{"0", "is47", "Битва Катапульт"},
		{"0", "is48", "Зал наказаний"},
		{"0", "is49", "Драконье убежище"},
		{"0", "is50", "Страна Грез"},
		{"0", "is62", "Стартовая локация"},
		{"0", "is63", "Человеческий мир"},
		{"0", "is64", "Зал Перерождения"},
		{"0", "is66", "Потоки серебра"},
		{"0", "is67", "Зал V"},
		{"0", "is68", "Человеческий мир [2]"},
		{"0", "arena01", "Арена ГМ Асура"}, 
		{"0", "arena02", "Арена ГО"}, 
		{"0", "arena03", "Арена ГП"}, 
		{"0", "arena04", "Арена ГД Эвент"}, 
		{"0", "arena05", "Нирвана(старая)"}, 
		{"0", "bg01", "ТВ T-3 PvP - 1"}, 
		{"0", "bg02", "ТВ T-3 PvE - 2"}, 
		{"0", "bg03", "ТВ T-2 PvP - 3"}, 
		{"0", "bg04", "ТВ T-2 PvE - 4"}, 
		{"0", "bg05", "ТВ T-1 PvP - 5"}, 
		{"0", "bg06", "ТВ T-1 PvE - 6"}
		};
		maps = m;
	}

	boolean server_running = false;
	boolean backup_running = false;
	int log_count = 0;
	int auth_count = 0;
	int unique_count = 0;
	int gac_count = 0;
	int gfaction_count = 0;
	int gdelivery_count = 0;
	int glink_count = 0;
	int gamedb_count = 0;
	int map_count = 0;
	String[] mem;
	String[] swp;
	String line;
	String process;
	Process p;
	BufferedReader input;

	p = Runtime.getRuntime().exec("free -m");
	input = new BufferedReader(new InputStreamReader(p.getInputStream()));
	input.readLine();
	mem = input.readLine().split("\\s+");
	input.readLine();
	swp = input.readLine().split("\\s+");
	input.close();

	p = Runtime.getRuntime().exec("ps -A w");
	input = new BufferedReader(new InputStreamReader(p.getInputStream()));
	while((line = input.readLine()) != null)
	{
		process = line.substring(27);

		if(process.indexOf("./pw_backup.sh") != -1)
		{
			message += "<br><font color=\"#ee0000\"><b>Выполняется копирование данных<br>Клик <a href=\"index.jsp?page=serverctrl\"><font color=\"#0000cc\">here</font></a> Обновляйте страницу, пока это сообщение не исчезнет ...</b></font>";
		}
		else
			;

		if(process.indexOf("./logservice") != -1)
		{
			log_count++;
			server_running = true;
		}
		else
			;
			
		if(process.indexOf("./authd") != -1)
		{
			auth_count++;
			server_running = true;
		}
		else
			;
			
		if(process.indexOf("./uniquenamed") != -1)
		{
			unique_count++;
			server_running = true;
		}
		else
			;
			
		if(process.indexOf("./gacd") != -1)
		{
			gac_count++;
			server_running = true;
		}
		else
			;
			
		if(process.indexOf("./gfactiond") != -1)
		{
			gfaction_count++;
			server_running = true;
		}
		else
			;
			
		if(process.indexOf("./gdeliveryd") != -1)
		{
			gdelivery_count++;
			server_running = true;
		}
		else
			;
			
		if(process.indexOf("./glinkd") != -1)
		{
			glink_count++;
		}
		else
			;
			
		if(process.indexOf("./gamedb") != -1)
		{
			gamedb_count++;
			server_running = true;
		}
		else
			;
			

		// Check running maps
		for(int i=0; i<maps.length; i++)
		{
			if (process.indexOf("./gs " + maps[i][1]) != -1)
			{
				// set the process id
				maps[i][0] = line.substring(0, 5).replace(" ", "");
				map_count++;
				server_running = true;
			}
			else
				;
		}
	}
	input.close();

      out.write("\n");
      out.write("\n");
      out.write("<table width=\"800\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"#ffffff\">\n");
      out.write("\n");
      out.write("<tr bgcolor=\"#ffffff\">\n");
      out.write("\t<td align=\"center\" colspan=\"2\">\n");
      out.write("\t\t");
      out.print( message );
      out.write("\n");
      out.write("\t</td>\n");
      out.write("</tr>\n");
      out.write("\n");
      out.write("<tr bgcolor=\"#ffffff\">\n");
      out.write("\t<td colspan=\"2\">\n");
      out.write("\t\t<br>\n");
      out.write("\t</td>\n");
      out.write("</tr>\n");
      out.write("\n");
      out.write("<tr bgcolor=\"#ffffff\">\n");
      out.write("<td align=\"center\" valign=\"top\">\n");
      out.write("\n");
      out.write("\t<table width=\"380\" cellpadding=\"2\" cellspacing=\"0\" style=\"border: 1px solid #ffffff;\">\n");
      out.write("\t\t<tr bgcolor=\"#d5d5d5\">\n");
      out.write("\t\t\t<th colspan=\"4\" style=\"padding: 5;\">\n");
      out.write("\t\t\t\t<b>Службы</b>\n");
      out.write("\t\t\t</th>\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#d5d5d5\">\n");
      out.write("\t\t\t<td>\n");
      out.write("\t\t\t\t<b>Память (Мб)</b>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"center\">\n");
      out.write("\t\t\t\t<b>Всего<b>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"center\">\n");
      out.write("\t\t\t\t<b>#<b>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"center\">\n");
      out.write("\t\t\t\t<b>Свободно<b>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\tRAM:\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t");

				out.println(mem[1]);
			
      out.write("\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t");

				out.println(mem[2]);
			
      out.write("\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t");

				out.println(mem[3]);
			
      out.write("\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\tSwap:\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t");

				out.println(swp[1]);
			
      out.write("\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t");

				out.println(swp[2]);
			
      out.write("\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t");

				out.println(swp[3]);
			
      out.write("\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#d5d5d5\">\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t<b>Описание</b>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t<b>Процесс</b>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t<b>#</b>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t<b>Статус</b>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\tLogservice\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t./logservice\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t");

				out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">" + log_count + "</td>");
				if(log_count > 0)
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#00cc00\">Online</font></td>");
				}
				else
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#ee0000\">Offline</font></td>");
				}
			
      out.write("\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\tAuth Daemon\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t./authd\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t");

				out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">" + auth_count + "</td>");
				if(auth_count > 0)
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#00cc00\">Online</font></td>");
				}
				else
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#ee0000\">Offline</font></td>");
				}
			
      out.write("\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\tUnique Name Daemon\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t./uniquenamed\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t");

				out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">" + unique_count + "</td>");
				if(unique_count > 0)
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#00cc00\">Online</font></td>");
				}
				else
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#ee0000\">Offline</font></td>");
				}
			
      out.write("\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\tGame Anti-Cheat Daemon\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t./gacd\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t");

				out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">" + gac_count + "</td>");
				if(gac_count > 0)
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#00cc00\">Online</font></td>");
				}
				else
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#ee0000\">Offline</font></td>");
				}
			
      out.write("\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\tFaction Daemon\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t./gfactiond\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t");

				out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">" + gfaction_count + "</td>");
				if(gfaction_count > 0)
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#00cc00\">Online</font></td>");
				}
				else
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#ee0000\">Offline</font></td>");
				}
			
      out.write("\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\tGame Delivery Daemon\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t./gdeliveryd\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t");

				out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">" + gdelivery_count + "</td>");
				if(gdelivery_count > 0)
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#00cc00\">Online</font></td>");
				}
				else
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#ee0000\">Offline</font></td>");
				}
			
      out.write("\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\tGame Link Daemon\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t./glinkd\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t");

				out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">" + glink_count + "</td>");
				if(glink_count > 0)
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#00cc00\">Online</font></td>");
				}
				else
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#ee0000\">Offline</font></td>");
				}
			
      out.write("\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\tGame Database Daemon\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t./gamedbd\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t");

				out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">" + gamedb_count + "</td>");
				if(gamedb_count > 0)
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#00cc00\">Online</font></td>");
				}
				else
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#ee0000\">Offline</font></td>");
				}
			
      out.write("\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\tЯдро(gs)\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t./gs\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t");

				out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\">" + map_count + "</td>");
				if(map_count > 0)
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#00cc00\">Online</font></td>");
				}
				else
				{
					out.println("<td align=\"center\" style=\"border-top: 1px solid #ffffff;\"><font color=\"#ee0000\">Offline</font></td>");
				}
			
      out.write("\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td colspan=4\" align=\"center\" style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t<form action=\"instance.jsp?page=instance\" method=\"post\" style=\"margin: 0px;\">\n");
      out.write("\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n");
      out.write("\t\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t");

					if(server_running)
					{
						out.print("<td style=\"padding-right: 2px;\"><input type=\"hidden\" name=\"process\" value=\"stopserver\"></input>");
						out.print("<input type=\"image\" src=\"../include/btn_stop.jpg\"  style=\"border: 0px;\"></input>");
					}
					else
					{
						out.print("<td><input type=\"hidden\" name=\"process\" value=\"startserver\"></input>");
						out.print("<input type=\"image\" src=\"../include/btn_start.jpg\"  style=\"border: 0px;\"></input></td>");
					}
					out.print("<td style=\"padding-left: 2px;\"><a href=\"instance.jsp?page=instance&process=backup\"><img src=\"../include/btn_backup.jpg\" border=\"0\"></img></a></td>");
			
      out.write("\n");
      out.write("\t\t\t</tr>\n");
      out.write("\t\t\t</table>\n");
      out.write("\t\t\t</form>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t</tr>\n");
      out.write("\t</table>\n");
      out.write("</td>\n");
      out.write("\n");
      out.write("<td align=\"center\" valign=\"top\">\n");
      out.write("\n");
      out.write("\t<table width=\"500\" cellpadding=\"2\" cellspacing=\"0\"  style=\"border: 1px solid #ffffff;\">\n");
      out.write("\t\t<tr bgcolor=\"#d5d5d5\">\n");
      out.write("\t\t\t<th colspan=\"2\" style=\"padding: 5;\">\n");
      out.write("\t\t\t\t<b>Локации</b>\n");
      out.write("\t\t\t</th>\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#d5d5d5\">\n");
      out.write("\t\t\t<td align=\"center\" colspan=\"2\" style=\"border-top: 1px solid #ffffff;\">\n");
      out.write("\t\t\t\t<b>Остановить все<b>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td align=\"left\">\n");
      out.write("\t\t\t\tЗадержка (в секундах):\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"right\">\n");
      out.write("\t\t\t\t<form action=\"instance.jsp?page=instance&process=stopallmaps\" method=\"post\" style=\"margin: 0px;\">\n");
      out.write("\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n");
      out.write("\t\t\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t\t<td><input type=\"text\" name=\"time\" value=\"300\" style=\"width: 50px; text-align: center;\"></input></td>\n");
      out.write("\t\t\t\t<td style=\"padding-left: 2px;\"><input type=\"image\" src=\"../include/btn_stop.jpg\"  style=\"border: 0px;\"></input></td>\n");
      out.write("\t\t\t\t</tr>\n");
      out.write("\t\t\t\t</table>\n");
      out.write("\t\t\t\t</form>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#d5d5d5\">\n");
      out.write("\t\t\t<td width=\"50%\" align=\"center\">\n");
      out.write("\t\t\t\t<b>Запущено</b>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td width=\"50%\" align=\"center\">\n");
      out.write("\t\t\t\t<b>Все карты</b>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t<tr bgcolor=\"#ffffff\">\n");
      out.write("\t\t\t<td align=\"center\">\n");
      out.write("\t\t\t\t<form action=\"instance.jsp?page=instance&process=stopmap\" method=\"post\" solstyle=\"margin: 0px;\">\n");
      out.write("\t\t\t\t<select name=\"map\" size=\"11\" multiple=\"multiple\" style=\"width: 100%;\">\n");
      out.write("\t\t\t\t");

					for(int i=0; i<maps.length; i++)
					{
						if(maps[i][0].compareTo("0") != 0)
						{
							out.println("<option value=\"" + maps[i][0] + "\">" + maps[i][1] + " : " + maps[i][2] + "</option>");
						}
					}
				
      out.write("\n");
      out.write("\t\t\t\t</select>\n");
      out.write("\t\t\t\t");

						out.print("<input type=\"image\" title=\"Stop the selected Maps\" src=\"../include/btn_stop.jpg\" style=\"border: 0px; padding: 2px;\"></input>");
				
      out.write("\n");
      out.write("\t\t\t\t</form>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t\t<td align=\"center\">\n");
      out.write("\t\t\t\t<form action=\"instance.jsp?page=instance&process=startmap\" method=\"post\" style=\"margin: 0px;\">\n");
      out.write("\t\t\t\t<select name=\"map\" size=\"11\" multiple=\"multiple\" style=\"width: 100%;\">\n");
      out.write("\t\t\t\t");

					for(int i=0; i<maps.length; i++)
					{
						if(maps[i][0].compareTo("0") == 0)
						{
							out.println("<option value=\"" + maps[i][1] + "\">" + maps[i][1] + " : " + maps[i][2] + "</option>");
						}
					}
				
      out.write("\n");
      out.write("\t\t\t\t</select>\n");
      out.write("\t\t\t\t");

						out.print("<input type=\"image\" title=\"Start the selected Maps\" src=\"../include/btn_start.jpg\" style=\"border: 0px; padding: 2px;\"></input>");
				
      out.write("\n");
      out.write("\t\t\t\t</form>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t</tr>\n");
      out.write("\t</table>\n");
      out.write("</td>\n");
      out.write("</tr>\n");
      out.write("</table>\n");
      out.write("</div>\n");
      out.write("<br>\n");
      out.write("\n");
      out.write("<table width=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">\n");
      out.write("  <tr>\n");
      out.write("    <td height=\"10\"></td>\n");
      out.write("  </tr>\n");
      out.write("  <tr>\n");
      out.write("    <td align=\"right\" class=\"topline\"></td>\n");
      out.write("  </tr>\n");
      out.write("</table>\n");
      out.write("\n");
      out.write("</body>\n");
      out.write("</html>");
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
