Location: PHPKode > scripts > Minecraft Admin > minecraft-admin/includes/mc-core.php
<?php
if (!defined('ABSPATH'))
		exit;
define('MC_CORE_IS_INSTALLED', 1);
define('MC_CORE_VERSION', '0.1.7');
define('MC_CORE_DB_VERSION', '1');
define('MC_CORE_MINECRAFT_DIR', WP_CONTENT_DIR . '/minecraft.dir/');
class MC_mc_core extends MCA
{
		function __construct(&$MC)
		{
				global $current_user;
				get_currentuserinfo();
				$this->MC = (object) $MC;
				$this->setup();
				define('MC_CORE_PLUGIN_INCLUDES_DIR', WP_PLUGIN_DIR . '/' . MC_PLUGIN_DIR . '/includes/' . $this->MC->core->path);
				$includes = array(
						'/mc-core-functions.php'
				);
				parent::includes(MC_CORE_PLUGIN_INCLUDES_DIR, $includes);
				$user = $current_user->user_login;
				if (isset($_GET['mc_server']) && !empty($_GET['mc_server'])) {
						$this->MC->userdata->$user->aktuellerserver = (int) $_GET['mc_server'];
				} //isset($_GET['mc_server']) && !empty($_GET['mc_server'])
				add_action('admin_menu', array(
						&$this,
						'admin_menu_page'
				));
				add_action('wp_before_admin_bar_render', array(
						&$this,
						'mc_nav'
				));
				wp_register_style('mc-core', plugins_url(MC_PLUGIN_DIR . '/includes/' . $this->MC->core->path . '/css/mc-core.css'), array(), '20120208', 'all');
				wp_enqueue_style('mc-core');
				wp_enqueue_script('mc-core', plugins_url(MC_PLUGIN_DIR . '/includes/' . $this->MC->core->path . '/js/mc-core.js'));
				add_action('wp_ajax_mc_log', array(
						&$this,
						'mc_ajax_log'
				));
				$this->widget();
		}
		function save($parameter = "replace")
		{
				parent::save($this->MC, $parameter);
		}
		function __destruct()
		{
		}
		function setup()
		{
				global $current_user;
				get_currentuserinfo();
				$user = $current_user->user_login;
				if (!isset($this->MC->core)) {
						$this->MC->core = new stdClass;
				} //!isset($this->MC->core)
				if (!isset($this->MC->core->name)) {
						$this->MC->core->name = __("Core", "minecraft-admin");
				} //!isset($this->MC->core->name)
				if (!isset($this->MC->core->beschreibung)) {
						$this->MC->core->beschreibung = __("This component can't be disabled. It makes the Minecraft Admin plugin work.", "minecraft-admin");
				} //!isset($this->MC->core->beschreibung)
				if (!isset($this->MC->core->version)) {
						$this->MC->core->version = MC_CORE_VERSION;
				} //!isset($this->MC->core->version)
				if (!isset($this->MC->core->path)) {
						$this->MC->core->path = "mc-core";
				} //!isset($this->MC->core->path)
				if (!isset($this->MC->core->aktive)) {
						$this->MC->core->aktive = "ja";
				} //!isset($this->MC->core->aktive)
				if (!isset($this->MC->core->status) or $this->MC->core->status == "") {
						$this->MC->core->status = "";
				} //!isset($this->MC->core->status) or $this->MC->core->status == ""
				if (!isset($this->MC->servers) or $this->MC->servers == "") {
						$this->MC->core->servers = new stdClass;
				} //!isset($this->MC->servers) or $this->MC->servers == ""
				if (!isset($this->MC->userdata) or $this->MC->userdata == "") {
						$this->MC->userdata = new stdClass;
				} //!isset($this->MC->userdata) or $this->MC->userdata == ""
				if (!isset($this->MC->userdata->$user) or $this->MC->userdata->$user == "") {
						$this->MC->userdata->$user = new stdClass;
				} //!isset($this->MC->userdata->$user) or $this->MC->userdata->$user == ""
				if (!isset($this->MC->userdata->$user->aktuellerserver) or $this->MC->userdata->$user->aktuellerserver == "") {
						$this->MC->userdata->$user->aktuellerserver = "no";
				} //!isset($this->MC->userdata->$user->aktuellerserver) or $this->MC->userdata->$user->aktuellerserver == ""
				if (!isset($this->MC->core->widget)) {
						$this->MC->core->widget = new stdClass;
				} //!isset($this->MC->core->widget)
				if (is_user_logged_in()) {
						if (!defined('MC_ID')) {
								define('MC_ID', (int) (empty($this->MC->userdata->$user->aktuellerserver)) ? "no" : $this->MC->userdata->$user->aktuellerserver);
						} //!defined('MC_ID')
						$MC_ID = MC_ID;
						if (!isset($this->MC->servers->$MC_ID)) {
								unset($_GET['mc_server']);
						} //!isset($this->MC->servers->$MC_ID)
				} //is_user_logged_in()
		}
		function admin_menu_page()
		{
				add_menu_page(__('Minecraft Admin', 'minecraft-admin'), __('Minecraft', 'minecraft-admin'), 'read', mc_url_menu_page(), array(
						&$this,
						'mc_core_info'
				), plugins_url(MC_PLUGIN_DIR . '/includes/images/icon.png'));
				if ($this->MC->server->installed === "ja" && MC_ID != "") {
						add_submenu_page('minecraft-admin', __('Commands | Minecraft Admin', 'minecraft-admin'), __('Commands', 'minecraft-admin'), 'manage_options', mc_url_menu_page("commands"), array(
								&$this,
								'mc_core_commands'
						));
						if (!defined("MC_ID")) {
								define('MC_ID', (int) $_GET['mc_server']);
						} //!defined("MC_ID")
						$MC_ID = MC_ID;
						if ($this->MC->servers->$MC_ID->server == "bukkit") {
								add_submenu_page('minecraft-admin', __('Plugins | Minecraft Admin', 'minecraft-admin'), __('Plugins', 'minecraft-admin'), 'manage_options', mc_url_menu_page("plugins"), array(
										&$this,
										'plugins'
								));
						} //$this->MC->servers->$MC_ID->server == "bukkit"
						add_submenu_page('minecraft-admin', __('Filebrowser | Minecraft Admin', 'minecraft-admin'), __('Filebrowser', 'minecraft-admin'), "read", mc_url_menu_page("filebrowser"), array(
								&$this,
								'filebrowser'
						));
						add_submenu_page('minecraft-admin', __('Recurring action | Minecraft Admin', 'minecraft-admin'), __('Recurring action', 'minecraft-admin'), "read", mc_url_menu_page("cronjob"), array(
								&$this,
								'cronjob'
						));
						add_submenu_page('minecraft-admin', __('Settings | Minecraft Admin', 'minecraft-admin'), __('Settings', 'minecraft-admin'), "read", mc_url_menu_page("settings"), array(
								&$this,
								'settings'
						));
				} //$this->MC->server->installed === "ja" && MC_ID != ""
				add_submenu_page('minecraft-admin', __('Install | Minecraft Admin', 'minecraft-admin'), __('Install', 'minecraft-admin'), "read", mc_url_menu_page("install"), array(
						&$this,
						'mc_setup'
				));
		}
		function template($path)
		{
				$path = WP_PLUGIN_DIR . '/' . MC_PLUGIN_DIR . '/includes/templates/' . $path . '.php';
				if (is_file($path)) {
						include_once($path);
				} //is_file($path)
				else {
						die(__('MC-ERROR: The MC component file ' . $path . ' couldn\'t be load. Please check your path settings.', 'minecraft-admin'));
				}
		}
		function widget()
		{
				$includes = array(
						'/mc-widget.php'
				);
				parent::includes(MC_CORE_PLUGIN_INCLUDES_DIR, $includes);
				$MC_CORE_WIDGET = new MC_CORE_WIDGET($this->MC);
		}
		function mc_core_commands()
		{
				if ($this->MC->server->installed === "ja") {
						global $blog_id;
						$this->template('mc-core/commands');
						if (isset($_GET["p"]) && !empty($_GET["p"])) {
								$output = parse_minecraft_output(shell_exec('sh /etc/init.d/minecraft ' . $blog_id . ' ' . MC_ID . ' ' . $_GET["p"]));
								echo "<pre>" . $output . "</pre>";
						} //isset($_GET["p"]) && !empty($_GET["p"])
						else if (!empty($_POST["p"])) {
								$output = parse_minecraft_output(shell_exec('sh /etc/init.d/minecraft ' . $blog_id . ' ' . MC_ID . ' command "' . $_POST["p"] . '"'));
								echo "<pre>" . $output . "</pre>";
						} //!empty($_POST["p"])
						echo '<br />';
						$users = parse_minecraft_output(shell_exec('sh /etc/init.d/minecraft ' . $blog_id . ' ' . MC_ID . ' command "list"'), false);
						$test  = str_replace("\n", "", $users);
						$test  = str_replace("\r", "", $test);
						$test  = str_replace(' ', "", $test);
						if (!empty($test)) {
								_e("The following users are online:", "minecraft-admin");
								echo $users;
								$outputs = shell_exec('sh /etc/init.d/minecraft ' . $blog_id . ' ' . MC_ID . ' status');
								echo "<pre>" . $outputs . "</pre>";
						} //!empty($test)
						else {
								_e("It seems to be no user are online :(", "minecraft-admin");
						}
						$zaehler = 0;
						if (!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "server.log")) {
								touch(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "server.log");
								$output = parse_minecraft_output(shell_exec('sh /etc/init.d/minecraft ' . $blog_id . ' ' . MC_ID . ' command start'));
								echo "<pre>" . $output . "</pre>";
						} //!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "server.log")
						$log = file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "server.log");
						$i   = sizeof($log);
						echo '<br /><div id="mc_core_log"><textarea cols="150" rows="' . $this->MC->core->log . '">';
						$z    = 0;
						$ex   = explode("\n", parse_minecraft_output(shell_exec("tail -n " . $this->MC->core->log . " " . MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "server.log")));
						$zahl = $this->MC->core->log;
						while (true) {
								$i = $zahl - $z;
								if (isset($ex[$i]) && !empty($ex[$i])) {
										echo $ex[$i] . "\n";
								} //isset($ex[$i]) && !empty($ex[$i])
								if ($i == 0) {
										break;
								} //$i == 0
								$z++;
						} //true
						echo "</textarea></div>";
				} //$this->MC->server->installed === "ja"
		}
		function mc_ajax_log()
		{
				global $blog_id;
				if (!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "server.log")) {
						touch(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "server.log");
				} //!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "server.log")
				$z    = 0;
				$ex   = explode("\n", parse_minecraft_output(shell_exec("tail -n " . $this->MC->core->log . " " . MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "server.log")));
				$zahl = $this->MC->core->log;
				while (true) {
						$i = $zahl - $z;
						if (isset($ex[$i]) && !empty($ex[$i])) {
								echo $ex[$i] . "\n";
						} //isset($ex[$i]) && !empty($ex[$i])
						if ($i == 0) {
								break;
						} //$i == 0
						$z++;
				} //true
		}
		function mc_core_info()
		{
				global $blog_id;
				if (isset($_POST['submit']) && check_admin_referer('mc-core-components')) {
						if (isset($_POST['new_server'])) {
								$anzahl  = count((array) $this->MC->servers);
								$servers = (array) $this->MC->servers;
								ksort($servers);
								end($servers);
								$anzahl                             = (int) key($servers) + 1;
								$this->MC->servers->$anzahl         = new stdClass;
								$this->MC->servers->$anzahl->server = $_POST['server'];
								$this->MC->servers->$anzahl->name   = __("NEW SERVER", "minecraft-admin");
								$this->MC->servers->$anzahl->worlds = "world,world_nether";
								$this->MC->servers->$anzahl->cpu    = "1";
								$this->MC->servers->$anzahl->ram    = "512m";
								$this->MC->servers->$anzahl->log    = "100";
								$this->MC->servers->$anzahl->users  = "";
								$this->MC->servers->$anzahl->pfad   = MC_CORE_MINECRAFT_DIR . $blog_id . '/' . $anzahl . '/';
								install_server($anzahl, $this->MC->servers->$anzahl, true);
								$this->MC->servers->$anzahl->installed = "ja";
						} //isset($_POST['new_server'])
						else {
								foreach ($this->MC as $id => $plugin) {
										if (isset($plugin->name)) {
												$this->MC->$id->aktive = "nein";
										} //isset($plugin->name)
								} //$this->MC as $id => $plugin
								$_POST['mc-core-component']["core"] = "ja";
								foreach ($_POST['mc-core-component'] as $plugin => $akt) {
										$akt                       = ($akt == "ja") ? "ja" : "nein";
										$plugin                    = str_replace('mc-', '', $plugin);
										$this->MC->$plugin->aktive = $akt;
								} //$_POST['mc-core-component'] as $plugin => $akt
						}
						$updated = true;
				} //isset($_POST['submit']) && check_admin_referer('mc-core-components')
				elseif (isset($_GET['mc_server_del']) && !empty($_GET['mc_server_del'])) {
						$res = lochen_verzeichnis(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . $_GET['mc_server_del']);
						switch ($res) {
								case 0:
										_e("The directory was deleted successfully.", 'minecraft-admin');
										break;
								case -1:
										_e("Error: This isn't a directory", 'minecraft-admin');
										break;
								case -2:
										_e("Error: The directory wasn't deleted successfully. Reason: unknown", 'minecraft-admin');
										break;
								case -3:
										_e("Error: The directory wasn't deleted successfully. Reason: filetype unknown", 'minecraft-admin');
										break;
								default:
										_e("Error: The directory wasn't deleted successfully. Reason: The delete function seems to be incorrect. Inform the author.", 'minecraft-admin');
										break;
						} //$res
						echo '<br />';
						$anzahl = $_GET['mc_server_del'];
						unset($this->MC->servers->$anzahl);
				} //isset($_GET['mc_server_del']) && !empty($_GET['mc_server_del'])
				$options = get_option('mc_settings_options');
				if (!empty($options)) {
						if (is_dir($options['pfad'])) {
								exec("mv " . $options['pfad'] . " " . MC_CORE_MINECRAFT_DIR . "veryold");
								$res = lochen_verzeichnis($options['pfad']);
								switch ($res) {
										case 0:
												_e("The directory was deleted successfully.", 'minecraft-admin');
												break;
										case -1:
												_e("Error: This isn't a directory", 'minecraft-admin');
												break;
										case -2:
												_e("Error: The directory wasn't deleted successfully. Reason: unknown", 'minecraft-admin');
												break;
										case -3:
												_e("Error: The directory wasn't deleted successfully. Reason: filetype unknown", 'minecraft-admin');
												break;
										default:
												_e("Error: The directory wasn't deleted successfully. Reason: The delete function seems to be incorrect. Inform the author.", 'minecraft-admin');
												break;
								} //$res
						} //is_dir($options['pfad'])
						delete_option('mc_settings_options');
				} //!empty($options)
				if (is_dir(plugins_url(MC_PLUGIN_DIR . '/includes/' . $this->MC->core->path . '/minecraft-dir/'))) {
						exec("mv " . plugins_url(MC_PLUGIN_DIR . '/includes/' . $this->MC->core->path . '/minecraft-dir/') . " " . MC_CORE_MINECRAFT_DIR . "old");
						$res = lochen_verzeichnis(plugins_url(MC_PLUGIN_DIR . '/includes/' . $this->MC->core->path . '/minecraft-dir/'));
						switch ($res) {
								case 0:
										_e("The directory was deleted successfully.", 'minecraft-admin');
										break;
								case -1:
										_e("Error: This isn't a directory", 'minecraft-admin');
										break;
								case -2:
										_e("Error: The directory wasn't deleted successfully. Reason: unknown", 'minecraft-admin');
										break;
								case -3:
										_e("Error: The directory wasn't deleted successfully. Reason: filetype unknown", 'minecraft-admin');
										break;
								default:
										_e("Error: The directory wasn't deleted successfully. Reason: The delete function seems to be incorrect. Inform the author.", 'minecraft-admin');
										break;
						} //$res
				} //is_dir(plugins_url(MC_PLUGIN_DIR . '/includes/' . $this->MC->core->path . '/minecraft-dir/'))
				$this->template('mc-core/info');
				$this->save();
		}
		function mc_nav()
		{
				global $wp_admin_bar, $blog_id;
				$path = opendir(MC_CORE_MINECRAFT_DIR . $blog_id . '/');
				$wp_admin_bar->add_menu(array(
						'id' => 'minecraft-admin',
						'title' => __('Minecraft Admin', 'minecraft-admin'),
						'href' => mc_url("")
				));
				while ($datei = readdir($path)) {
						if ($datei != ".." and $datei != ".") {
								if (is_dir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . $datei . '/')) {
										$array = array(
												"mc_server" => $datei
										);
										$wp_admin_bar->add_menu(array(
												'id' => 'minecraft-admin-server-' . $datei,
												'title' => $this->MC->servers->$datei->name,
												'parent' => 'minecraft-admin',
												'href' => mc_url("", $array)
										));
										$wp_admin_bar->add_menu(array(
												'id' => 'minecraft-admin-befehl-' . $datei,
												'parent' => 'minecraft-admin-server-' . $datei,
												'title' => __('Commands', 'minecraft-admin'),
												'href' => mc_url("commands", $array)
										));
										$wp_admin_bar->add_menu(array(
												'id' => 'minecraft-admin-befehl-start-' . $datei,
												'parent' => 'minecraft-admin-befehl-' . $datei,
												'title' => __('start', 'minecraft-admin'),
												'href' => mc_url("commands", array(
														"p" => "start",
														"mc_server" => $datei
												))
										));
										$wp_admin_bar->add_menu(array(
												'id' => 'minecraft-admin-befehl-stop-' . $datei,
												'parent' => 'minecraft-admin-befehl-' . $datei,
												'title' => __('stop', 'minecraft-admin'),
												'href' => mc_url("commands", array(
														"p" => "stop",
														"mc_server" => $datei
												))
										));
										$wp_admin_bar->add_menu(array(
												'id' => 'minecraft-admin-befehl-restart-' . $datei,
												'parent' => 'minecraft-admin-befehl-' . $datei,
												'title' => __('restart', 'minecraft-admin'),
												'href' => mc_url("commands", array(
														"p" => "restart",
														"mc_server" => $datei
												))
										));
										$wp_admin_bar->add_menu(array(
												'id' => 'minecraft-admin-cronjob-' . $datei,
												'parent' => 'minecraft-admin-server-' . $datei,
												'title' => __('recurring actions', 'minecraft-admin'),
												'href' => mc_url("cronjob", $array)
										));
										$wp_admin_bar->add_menu(array(
												'id' => 'minecraft-admin-einstellungen-' . $datei,
												'parent' => 'minecraft-admin-server-' . $datei,
												'title' => __('Settings', 'minecraft-admin'),
												'href' => mc_url("settings", $array)
										));
										$wp_admin_bar->add_menu(array(
												'id' => 'minecraft-admin-filebrowser-' . $datei,
												'parent' => 'minecraft-admin-server-' . $datei,
												'title' => __('filebrowser', 'minecraft-admin'),
												'href' => mc_url("filebrowser", $array)
										));
										if ($this->MC->servers->$datei->server == "bukkit") {
												$wp_admin_bar->add_menu(array(
														'id' => 'minecraft-admin-plugins-' . $datei,
														'parent' => 'minecraft-admin-server-' . $datei,
														'title' => __('Plugins', 'minecraft-admin'),
														'href' => mc_url("plugins", $array)
												));
										} //$this->MC->servers->$datei->server == "bukkit"
								} //is_dir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . $datei . '/')
						} //$datei != ".." and $datei != "."
				} //$datei = readdir($path)
		}
		function mc_setup()
		{
				global $blog_id;
				if (isset($_POST["type"]) && check_admin_referer('mc-core-setup', 'mc-core-setup')) {
						if ($_POST["type"] == "install") {
								$this->MC->core->status = "install";
						} //$_POST["type"] == "install"
						elseif ($_POST["type"] == "delete") {
								$this->MC->core->status = "delete";
						} //$_POST["type"] == "delete"
				} //isset($_POST["type"]) && check_admin_referer('mc-core-setup', 'mc-core-setup')
				if (!isset($_GET["p"])) {
						$_GET["p"] = "";
				} //!isset($_GET["p"])
				$oswebserver         = explode("(", $_SERVER['SERVER_SOFTWARE']);
				$os                  = str_replace(")", "", $oswebserver[1]);
				$webserver           = $oswebserver[1];
				$os_unterstuetzt     = false;
				$os_unter            = array(
						'Debian',
						'Ubuntu'
				);
				$os_unter_vielleicht = array(
						'Fedora',
						'openSUSE'
				);
				$os_nicht_unter      = array(
						'Windows'
				);
				foreach ($os_unter as $system) {
						if ($system == $os) {
								$os_unterstuetzt = true;
								break;
						} //$system == $os
				} //$os_unter as $system
				if ($os_unterstuetzt) {
						echo '<div id="message" class="updated"><p><strong>' . __("Your operating system is supported.", "minecraft-admin") . '</strong></p></div>';
				} //$os_unterstuetzt
				else {
						$os_unterstuetzt_vielleicht = false;
						foreach ($os_unter_vielleicht as $system) {
								if ($system == $os) {
										$os_unterstuetzt_vielleicht = true;
										break;
								} //$system == $os
						} //$os_unter_vielleicht as $system
						if ($os_unterstuetzt_vielleicht) {
								echo '<div id="message" class="error"><p><strong>' . __("There are no offical test data for your operating system. <br /> A similar operating system is supported, so it is possible that on your operating system 'Minecraft Admin' runs.", "minecraft-admin") . '</strong></p></div>';
						} //$os_unterstuetzt_vielleicht
						else {
								$os_unterstuetzt_nicht = false;
								foreach ($os_nicht_unter as $system) {
										if ($system == $os) {
												$os_unterstuetzt_nicht = true;
												break;
										} //$system == $os
								} //$os_nicht_unter as $system
								if ($os_unterstuetzt_nicht) {
										echo '<div id="message" class="error"><p><strong>' . __("Your operating system is not supported. <br /> It is not recommended to install 'Minecraft Admin'.", "minecraft-admin") . '</strong></p></div>';
								} //$os_unterstuetzt_nicht
								else {
										echo '<div id="message" class="updated"><p><strong>' . __("There are no offical test data for your operating system. You can still try to install 'Minecraft Admin'.", "minecraft-admin") . '</strong></p></div>';
								}
						}
				}
				echo '<br /><br />';
				if ($this->MC->core->status == "delete") {
						if (is_file('/etc/init.d/minecraft')) {
								unlink('/etc/init.d/minecraft');
						} //is_file('/etc/init.d/minecraft')
						if (delete_option(MC_OPTION_NAME)) {
								echo '<div id="message" class="updated"><p><strong>' . __('The plugin datas was successfull delete. You can now delete the plugin via the plugins menu', "minecraft-admin") . '</strong></p></div>';
						} //delete_option(MC_OPTION_NAME)
						else {
								echo '<div id="message" class="error"><p><strong>' . __("ERROR: The plugin-datas couldn't be deleted.", "minecraft-admin") . '</strong></p></div>';
						}
						$this->MC->server->installed = "nein";
						$this->MC->core->status      = "";
						delete_option("MC");
						unset($this->MC);
				} //$this->MC->core->status == "delete"
				else if ($this->MC->core->status == "install") {
						$touch = @touch(WP_PLUGIN_DIR . '/' . MC_PLUGIN_DIR . '/.mc-admin-test.txt');
						if ($touch && is_writable(WP_PLUGIN_DIR . '/' . MC_PLUGIN_DIR . '/.mc-admin-test.txt')) {
								if (!is_dir(MC_CORE_MINECRAFT_DIR)) {
										mkdir(MC_CORE_MINECRAFT_DIR);
								} //!is_dir(MC_CORE_MINECRAFT_DIR)
								if (!is_dir(MC_CORE_MINECRAFT_DIR . $blog_id)) {
										mkdir(MC_CORE_MINECRAFT_DIR . $blog_id);
								} //!is_dir(MC_CORE_MINECRAFT_DIR . $blog_id)
								if (!is_file(MC_CORE_MINECRAFT_DIR . '.installed')) {
										echo MC_initd();
										if (is_file(MC_CORE_MINECRAFT_DIR . 'initd.sh')) {
												if ($os == "Debian" or $os == "Ubuntu") {
														$os = "deb";
												} //$os == "Debian" or $os == "Ubuntu"
												else if ($os == "openSUSE" or $os == "Fedora") {
														$os = "yum";
												} //$os == "openSUSE" or $os == "Fedora"
												else {
														$os = "no";
														_e("Because there are no test data for your operating system, a automatic installer script couldn't be created. Please install Java manually.", "minecraft-admin");
												}
												echo MC_installer($os);
												if (is_file(MC_CORE_MINECRAFT_DIR . 'installer.sh')) {
														echo '<div class="updated">' . __("Log in to your server and execute the following command:", 'minecraft-admin') . '</div>';
														echo '<textarea cols="150">sh ' . MC_CORE_MINECRAFT_DIR . 'installer.sh' . '</textarea>';
														echo '<form method="post" action="' . mc_url("install") . '"><p class="submit"><input type="submit" class="button-primary" value="' . __('Finish', 'minecraft-admin') . '" /></p></form>';
												} //is_file(MC_CORE_MINECRAFT_DIR . 'installer.sh')
												else {
														echo '<div class="error">' . __("The Minecraft Admin folder isn't wirteable. Please change the permissions so the Minecraft Admin folder is wirteable.", 'minecraft-admin') . '</div>';
												}
										} //is_file(MC_CORE_MINECRAFT_DIR . 'initd.sh')
										else {
												echo '<div class="error">' . __("The Minecraft Admin folder isn't wirteable. Please change the permissions so the Minecraft Admin folder is wirteable.", 'minecraft-admin') . '</div>';
										}
								} //!is_file(MC_CORE_MINECRAFT_DIR . '.installed')
								else {
										$this->MC->server->installed = "ja";
										$this->MC->core->status      = "";
										echo '<div class="updated">' . __("Minecraft Admin was successfull installed.", 'minecraft-admin') . '</div>';
										unlink(MC_CORE_MINECRAFT_DIR . '.installed');
										echo '<form method="post" action="' . mc_url() . '"><p class="submit"><input type="submit" class="button-primary" value="' . __('Create a new Minecraft Server', 'minecraft-admin') . '" /></p></form>';
								}
						} //$touch && is_writable(WP_PLUGIN_DIR . '/' . MC_PLUGIN_DIR . '/.mc-admin-test.txt')
						else {
								echo '<div class="error">' . __("The Minecraft Admin folder isn't wirteable. Please change the permissions so the Minecraft Admin folder is wirteable.", 'minecraft-admin') . '</div>';
						}
				} //$this->MC->core->status == "install"
				else {
						$this->template('mc-core/setup_start');
				}
				$this->save();
		}
		function settings()
		{
				$anzahl     = MC_ID;
				$mc_updated = false;
				if (isset($_POST['settings']) && check_admin_referer('mc-core-einstellungen')) {
						foreach ($_POST['mc_settings_options'] as $set => $wert) {
								if (isset($this->MC->servers->$anzahl->$set) && $set != "pfad" && $set != "backup") {
										if ($set == "server") {
												if ($wert != $this->MC->servers->$anzahl->$set) {
														$down = true;
												} //$wert != $this->MC->servers->$anzahl->$set
												else {
														$down = false;
												}
										} //$set == "server"
										$this->MC->servers->$anzahl->$set = $wert;
								} //isset($this->MC->servers->$anzahl->$set) && $set != "pfad" && $set != "backup"
						} //$_POST['mc_settings_options'] as $set => $wert
						install_server($anzahl, $this->MC->servers->$anzahl, $down);
						$mc_updated = true;
				} //isset($_POST['settings']) && check_admin_referer('mc-core-einstellungen')
				$this->template('mc-core/interne_einstellungen');
				template_interne_einstellungen($this->MC->servers->$anzahl, $mc_updated);
				$this->save();
		}
		function plugins()
		{
				global $blog_id;
				if (!isset($_GET["cache"])) {
						$_GET["cache"] = "";
				} //!isset($_GET["cache"])
				if ($_GET["cache"] == "false") {
						lochen_verzeichnis(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp");
						echo '<meta http-equiv="refresh" content="0; URL=' . mc_url("plugins") . '"> ';
				} //$_GET["cache"] == "false"
				echo '<a href="' . mc_url("plugins", array(
						"cache" => "false"
				)) . '">Lösche Cache</a>';
				$val = (!empty($_GET["install"])) ? 'value="' . $_GET["install"] . '"' : "";
				echo '<form action="admin.php" method="GET">
' . __('install', 'minecraft-admin') . ':<input type="text" name="install" placeholder="' . __('plugin name', 'minecraft-admin') . '" ' . $val . '>
<input type="hidden" name="page" value="minecraft-admin?mc=plugins">
    <input type="submit" name="absenden" value="' . __('send', 'minecraft-admin') . '"></form>';
				if (!is_dir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/")) {
						mkdir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/");
				} //!is_dir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/")
				if (!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/created-by-mc-admin.txt")) {
						touch(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/created-by-mc-admin.txt");
				} //!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/created-by-mc-admin.txt")
				if (!is_dir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "plugins/")) {
						mkdir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "plugins/");
				} //!is_dir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "plugins/")
				$handle = opendir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "plugins/");
				while ($datei = readdir($handle)) {
						if (mime_content_type(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "plugins/" . $datei) == "application/zip") {
								if (!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/$datei.yml")) {
										mkdir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/plugin-" . str_replace(".jar", "", $datei) . "/");
										exec("unzip " . MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "plugins/" . $datei . " -d " . MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/plugin-" . str_replace(".jar", "", $datei) . "/");
										exec("cp " . MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/plugin-" . str_replace(".jar", "", $datei) . "/plugin.yml " . MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . str_replace(".jar", "", $datei) . ".yml");
										exec("rm -r " . MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/plugin-" . str_replace(".jar", "", $datei));
								} //!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/$datei.yml")
						} //mime_content_type(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "plugins/" . $datei) == "application/zip"
				} //$datei = readdir($handle)
				closedir($handle);
				if (empty($val)) {
						echo "<table><tr><th>" . __("name", "minecraft-admin") . "</th><th>" . __("version", "minecraft-admin") . "</th><th>" . __("plugin file", "minecraft-admin") . "</th><th>" . __("options", "minecraft-admin") . "</th><th>" . __("Bukkit website", "minecraft-admin") . "</th><th>" . __("Up-To-Date?", "minecraft-admin") . "</tr>";
						$handle = opendir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/");
						while ($dateiyml = readdir($handle)) {
								if ($dateiyml != "created-by-mc-admin.txt" && $dateiyml != "." && strpos($dateiyml, ".yml") !== false && $dateiyml != ".." && is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . $dateiyml)) {
										$yml = file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . $dateiyml);
										foreach ($yml as $key => $value) {
												$ex = explode(":", $value);
												if ($ex[0] == "name") {
														$name = str_replace(" ", "", $ex[1]);
														$name = str_replace("\n", "", $name);
														$name = str_replace("\r", "", $name);
												} //$ex[0] == "name"
												if ($ex[0] == "version") {
														$version = str_replace(" ", "", strtolower($ex[1]));
														$version = str_replace("\n", "", $version);
														$version = str_replace("\r", "", $version);
												} //$ex[0] == "version"
										} //$yml as $key => $value
										$rss_url = 'http://dev.bukkit.org/server-mods/' . $name . '/files.rss';
										if (!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . $name . ".rss")) {
												exec('wget ' . $rss_url . ' -O ' . MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . $name . ".rss");
										} //!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . $name . ".rss")
										$uptodate = false;
										$error    = false;
										$xml      = @simplexml_load_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . $name . ".rss");
										if (empty($xml->channel->item) or $xml->channel->item == "" or $xml->channel->item == " ") {
												if (!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . $name . ".html")) {
														exec('wget "http://dev.bukkit.org/server-mods/' . $name . '/files/" -O ' . MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . '.tmp/' . $name . '.html --no-check-certificate');
												} //!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . $name . ".html")
												$bukkitorg = file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . $name . ".html");
												if (!empty($bukkitorg)) {
														foreach ($bukkitorg as $id => $lines) {
																if (!empty($lines)) {
																		$lines = str_replace(" ", "", strtolower($lines));
																		$lines = str_replace("\n", "", $lines);
																		$lines = str_replace("\r", "", $lines);
																		if (strpos($lines, "noresultsfound") !== false) {
																				$error = __("There aren't downloads anymore.", "minecraft-admin");
																		} //strpos($lines, "noresultsfound") !== false
																		elseif (strpos($lines, '<h3>login</h3>') !== false) {
																				$error = __("The plugin wasn't found.", "minecraft-admin");
																		} //strpos($lines, '<h3>login</h3>') !== false
																} //!empty($lines)
														} //$bukkitorg as $id => $lines
												} //!empty($bukkitorg)
												else {
														$error = __("The plugin wasn't found.", "minecraft-admin");
												}
										} //empty($xml->channel->item) or $xml->channel->item == "" or $xml->channel->item == " "
										else if (!empty($xml->channel->item) && $xml->channel->item != "" && $xml->channel->item != " ") {
												foreach ($xml->channel->item as $id => $item) {
														$version_ohne_klammern = preg_replace('#\(.*?\)#m', '', $version);
														$title_ohne_klammern   = preg_replace('#\(.*?\)#m', '', $item->title);
														$cross                 = $this->array_cartesian(array(
																$version_ohne_klammern,
																$version,
																"v" . $version,
																strtolower($name) . " " . $version_ohne_klammern,
																strtolower($name) . " v" . $version_ohne_klammern,
																strtolower($name) . " " . $version,
																strtolower($name) . " v" . $version
														), array(
																$title_ohne_klammern,
																strtolower($item->title),
																"v" . strtolower($item->title)
														));
														$cross                 = (empty($cross)) ? array() : $cross;
														foreach ($cross as $arr) {
																if ($arr[0] == $arr[1]) {
																		$uptodate = true;
																		break;
																} //$arr[0] == $arr[1]
														} //$cross as $arr
												} //$xml->channel->item as $id => $item
										} //!empty($xml->channel->item) && $xml->channel->item != "" && $xml->channel->item != " "
										unset($item);
										unset($xml);
										$errors = (empty($error) && $error === false) ? "Update" : $error;
										$up     = ($uptodate) ? "Ja" : $errors;
										echo "<tr><td>$name</td><td>$version</td><td>" . str_replace(".yml", ".jar", $dateiyml) . '</td><td>comming soon</td><td>
<a href="http://dev.bukkit.org/server-mods/' . $name . '/">' . __("Bukkit Dev", "minecraft-admin") . '</a></td><td>' . $up . '</td></tr>';
										unset($name);
										unset($version);
										unset($uptodate);
										unset($error);
								} //$dateiyml != "created-by-mc-admin.txt" && $dateiyml != "." && strpos($dateiyml, ".yml") !== false && $dateiyml != ".." && is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . $dateiyml)
						} //$dateiyml = readdir($handle)
						closedir($handle);
						echo "</table>";
				} //empty($val)
				else {
						$includes = array(
								'/Snoopy.class.php'
						);
						parent::includes(MC_CORE_PLUGIN_INCLUDES_DIR, $includes);
						$snoopy = new Snoopy;
						if (!empty($_GET["download"])) {
								$name    = str_replace("/server-mods/", "", $_GET["download"]);
								$name    = str_replace("/", "", $name);
								$rss_url = 'http://dev.bukkit.org' . $_GET["download"] . 'files.rss';
								exec('wget ' . $rss_url . ' -O ' . MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . $name . ".rss");
								$xml  = simplexml_load_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . ".tmp/" . $name . ".rss");
								$link = (string) $xml->channel->item[0]->link;
								$snoopy->fetch($link);
								$erste     = explode('<li class="user-action user-action-download">', $snoopy->results);
								$zweite    = explode('Download', $erste[1]);
								$zweite[0] = str_replace('<span><a href="', "", $zweite[0]);
								$zweite[0] = str_replace('">', "", $zweite[0]);
								exec('wget ' . $zweite[0] . ' -O ' . MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "plugins/" . $name . ".jar");
								exec('sh /etc/init.d/minecraft restart');
								echo '<meta http-equiv="refresh" content="0; URL=admin.php?page=minecraft-admin?mc=plugins"> ';
						} //!empty($_GET["download"])
						$snoopy->fetch("http://dev.bukkit.org/search/?scope=projects&search=" . $_GET["install"]);
						$explode  = explode('<div class="listing-container">', $snoopy->results);
						$explodes = explode('<div class="listing-pagination listing-pagination-bottom">', $explode[1]);
						$lines    = $explodes[0];
						$lines    = preg_replace('/<td class="col-search-entry"><h2><a href="(.*)">(.*)<\/a><\/h2><\/td>/', '<td class="col-search-entry"><h2><a href="$1">$2</a></h2><br /><a href="admin.php?page=minecraft-admin?mc=plugins&install=' . $_GET["install"] . '&download=$1" style="    background: none repeat scroll 0 0 green;    color: white;">' . __("install", "minecraft-admin") . '</a></td>', $lines);
						$lines    = str_replace("\n", "", $lines);
						$lines    = str_replace("\r", "", $lines);
						$lines    = str_replace('<td class="col-status"></td>', "", $lines);
						$lines    = str_replace('<colgroup><col/><col/><col/><col/></colgroup>', "", $lines);
						$lines    = str_replace('<td colspan="4" class="summary">', '<td></td><td></td><td colspan="4" class="summary">', $lines);
						$lines    = str_replace('<span><span></span></span>', '', $lines);
						$lines    = str_replace('href="/', 'href="http://dev.bukkit.org/', $lines);
						$lines    = str_replace('<thead><tr><th scope="col" class="col-status single-col"></th>', '', $lines);
						print($lines);
				}
		}
		function array_cartesian()
		{
				$_ = func_get_args();
				if (!empty($_)) {
						if (count($_) == 0) {
								return array(
										array()
								);
						} //count($_) == 0
						$a = array_shift($_);
						$c = call_user_func_array(array(
								$this,
								__FUNCTION__
						), $_);
						if (!empty($c)) {
								$r = array();
								foreach ($a as $v) {
										foreach ($c as $p) {
												$p   = str_replace(" ", "", strtolower($p));
												$p   = str_replace("\n", "", $p);
												$p   = str_replace("\r", "", $p);
												$v   = str_replace(" ", "", strtolower($v));
												$v   = str_replace("\n", "", $v);
												$v   = str_replace("\r", "", $v);
												$r[] = array_merge(array(
														$v
												), $p);
										} //$c as $p
								} //$a as $v
								return $r;
						} //!empty($c)
				} //!empty($_)
		}
		function filebrowser()
		{
				global $blog_id;
				if (!isset($_GET["path"]) or empty($_GET['path']))
						$_GET['path'] = "/";
				$path = $_GET['path'];
				if (!empty($_GET["lochen"])) {
						$res  = lochen_verzeichnis(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $path);
						$path = substr($path, 0, strrpos($path, "/"));
						switch ($res) {
								case 0:
										_e("The directory was deleted successfully.", 'minecraft-admin');
										break;
								case -1:
										_e("Error: This isn't a directory", 'minecraft-admin');
										break;
								case -2:
										_e("Error: The directory wasn't deleted successfully. Reason: unknown", 'minecraft-admin');
										break;
								case -3:
										_e("Error: The directory wasn't deleted successfully. Reason: filetype unknown", 'minecraft-admin');
										break;
								default:
										_e("Error: The directory wasn't deleted successfully. Reason: The delete function seems to be incorrect. Inform the author.", 'minecraft-admin');
										break;
						} //$res
						echo '<br />';
				} //!empty($_GET["lochen"])
				if (!empty($_FILES["datei"]["tmp_name"])) {
						$uploadFile = MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $path . '/' . $_FILES['datei']['name'];
						echo "<pre>";
						if (move_uploaded_file($_FILES['datei']['tmp_name'], $uploadFile)) {
								echo _e("The file was successfully uploaded.", 'minecraft-admin');
						} //move_uploaded_file($_FILES['datei']['tmp_name'], $uploadFile)
						else {
								echo _e("The file wasn't successfully uploaded.", 'minecraft-admin');
						}
						echo "</pre>";
				} //!empty($_FILES["datei"]["tmp_name"])
				else if (!empty($_POST["neu"])) {
						rename(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $path, MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . substr($path, 0, strrpos($path, "/")) . '/' . $_POST["neu"]);
						$path = substr($path, 0, strrpos($path, "/")) . '/' . $_POST["neu"];
				} //!empty($_POST["neu"])
				else if (!empty($_POST["neuerstellen"])) {
						var_dump(strpos($_POST["neuerstellen"], '.'));
						if (strpos($_POST["neuerstellen"], '.')) {
								$path = $path . '/' . $_POST["neuerstellen"];
								$fp   = fopen(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $path, "w+");
								fwrite($fp, "#test");
								fclose($fp);
								clearstatcache();
						} //strpos($_POST["neuerstellen"], '.')
						else {
								mkDir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $path . '/' . $_POST["neuerstellen"]);
						}
				} //!empty($_POST["neuerstellen"])
				echo '<a href="' . mc_url("filebrowser", array(
						"path" => "/"
				)) . '">' . __("Minecraft", "minecraft-admin") . '</a>/';
				if ($path != '' or $path != '/') {
						$expath  = explode('/', $path);
						$gesamnt = count($expath);
						for ($i = 0; $i < $gesamnt; $i++) {
								$url = '';
								for ($r = 0; $r < $i; $r++) {
										$url .= '/' . $expath[$r + 1];
								} //$r = 0; $r < $i; $r++
								if (!empty($expath[$i])) {
										echo '<a href="' . mc_url("filebrowser", array(
												"path" => $url
										)) . '">' . $expath[$i] . '</a>';
										if (!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $url)) {
												echo '/';
										} //!is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $url)
								} //!empty($expath[$i])
						} //$i = 0; $i < $gesamnt; $i++
				} //$path != '' or $path != '/'
				echo '<br>';
				if (is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $path)) {
						if (isset($_POST["inhalt"])) {
								$fp = fopen(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $path, "w+");
								fwrite($fp, str_replace('\\', "", $_POST["inhalt"]));
								fclose($fp);
								clearstatcache();
						} //isset($_POST["inhalt"])
						if (substr($path, 0, strrpos($path, "/")) == "") {
								$zuruck = mc_url("filebrowser", array(
										"path" => "/"
								));
						} //substr($path, 0, strrpos($path, "/")) == ""
						else {
								$zuruck = mc_url("filebrowser", array(
										"path" => substr($path, 0, strrpos($path, "/"))
								));
						}
						echo '<div class="wrap"><h2>' . $path . '</h2><a href="' . $zuruck . '">' . __("back", "minecraft-admin") . '</a><form method="post" action=""><textarea name="inhalt" rows="25" cols="100">';
						$datei         = file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $path);
						$ausgabe_datei = '';
						foreach ($datei as $key => $value) {
								$ausgabe_datei .= $value;
						} //$datei as $key => $value
						echo $ausgabe_datei . '</textarea><p class="submit"><input type="submit" class="button-primary" value="' . __("Save changes", 'minecraft-admin') . '" /></p></form></div><form method="POST" action=""><a href="' . mc_url("filebrowser", array(
								"path" => $path,
								"lochen" => "true"
						)) . '"><img src="' . get_bloginfo("wpurl") . '/wp-content/plugins/minecraft-admin/images/filebrowser/folder_delete.png" alt="[' . __("Delete", 'minecraft-admin') . ']" /></a><img src="' . get_bloginfo("wpurl") . '/wp-content/plugins/minecraft-admin/images/filebrowser/folder_edit.png" alt="[' . __("rename", 'minecraft-admin') . ']" /> <input type="text" name="neu" /><input type="submit" class="button-primary" value="' . __("rename", 'minecraft-admin') . '" /></form>';
				} //is_file(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $path)
				else {
						$dir      = opendir(MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $path);
						$array    = array();
						$arrayneu = array();
						while ($file = readdir($dir)) {
								$filepath = MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . $path . "/" . $file;
								$stat     = stat($filepath);
								if ($file != "." and $file != ".." and $file != "aufgaben.crontab" and $file != ".tmp") {
										$filetypebyphp = mime_content_type($filepath);
										if (strpos($filepath, ".") !== false) {
												$filetypebyown = explode('.', $filepath);
												$filetypebyown = (isset($filetypebyown[1]) ? $filetypebyown[1] : $filetypebyown[0]);
												if (is_file(str_replace("wp-admin/admin.php", "", $_SERVER['SCRIPT_FILENAME']) . 'wp-content/plugins/minecraft-admin/images/filebrowser/file_extension_' . $filetypebyown . '.png')) {
														if ($filetypebyown != $filetypebyphp) {
																$filetype = $filetypebyown;
														} //$filetypebyown != $filetypebyphp
														else {
																$filetype = $filetypebyphp;
														}
												} //is_file(str_replace("wp-admin/admin.php", "", $_SERVER['SCRIPT_FILENAME']) . 'wp-content/plugins/minecraft-admin/images/filebrowser/file_extension_' . $filetypebyown . '.png')
												else {
														$filetype = $filetypebyphp;
												}
										} //strpos($filepath, ".") !== false
										else {
												$filetype = $filetypebyphp;
										}
										$array[$filetype][] = array(
												'zugriff' => date("d-m-Y, H:i:s", $stat[8]),
												'anderung' => date("d-m-Y, H:i:s", $stat[9]),
												'size' => binary_multiples($stat[7], true, false),
												'file' => $file
										);
								} //$file != "." and $file != ".." and $file != "aufgaben.crontab" and $file != ".tmp"
						} //$file = readdir($dir)
						closedir($dir);
						foreach ($array as $id => $inhalt) {
								usort($inhalt, "cmp");
								$arrayneu[$id] = $inhalt;
						} //$array as $id => $inhalt
						echo "<table>";
						foreach ($arrayneu as $id => $inhalt) {
								foreach ($inhalt as $unterid => $unterinhalt) {
										$id_nachher = explode("/", $id);
										$id_nachher = (isset($id_nachher[1]) ? $id_nachher[1] : $id_nachher[0]);
										if (!is_file(str_replace("wp-admin/admin.php", "", $_SERVER['SCRIPT_FILENAME']) . 'wp-content/plugins/minecraft-admin/includes/images/filebrowser/file_extension_' . $id_nachher . '.png')) {
												$id_nachher = "unkown";
										} //!is_file(str_replace("wp-admin/admin.php", "", $_SERVER['SCRIPT_FILENAME']) . 'wp-content/plugins/minecraft-admin/includes/images/filebrowser/file_extension_' . $id_nachher . '.png')
										echo '<tr  class="mc_admin_hidden_false">
            <td><img src="' . get_bloginfo("wpurl") . '/wp-content/plugins/minecraft-admin/includes/images/filebrowser/file_extension_' . $id_nachher . '.png" alt="[' . $id . ']" /></td>
            <td>
               <table class="mc_admin_hidden"><tr>
               <td>' . __("Last access", "minecraft-admin") . ':</td>
               <td> ' . $unterinhalt["zugriff"] . '</td></tr><tr>
               <td>' . __("size", "minecraft-admin") . ':</td>
               <td> ' . $unterinhalt["size"] . '</td></tr><tr>
               <td>' . __("last change", "minecraft-admin") . ':</td>
               <td> ' . $unterinhalt["anderung"] . '</td></tr><tr>
               <td><img src="' . get_bloginfo("wpurl") . '/wp-content/plugins/minecraft-admin/includes/images/filebrowser/folder_edit.png" alt="[' . __("rename", 'minecraft-admin') . ']" /></td>
               <td><form style="margin:0;" method="POST" action="admin.php?page=minecraft-admin?mc=filebrowser&path=' . (($path == "/") ? "" : $path) . '/' . rawurlencode($unterinhalt["file"]) . '"> <input type="text" name="neu" value="' . $unterinhalt["file"] . '"/></form></td></tr><tr>
               <td><a href="' . mc_url("filebrowser", array(
												"path" => (($path == "/") ? "" : $path) . '/' . rawurlencode($unterinhalt["file"]),
												"lochen" => "true"
										)) . '"><img src="' . get_bloginfo("wpurl") . '/wp-content/plugins/minecraft-admin/includes/images/filebrowser/folder_delete.png" alt="[' . __("Delete", 'minecraft-admin') . ']" /></a></td>
               <td></td></tr>
               </table>
            </td>
            <td><a href="' . mc_url("filebrowser", array(
												"path" => (($path == "/") ? "" : $path) . '/' . rawurlencode($unterinhalt["file"])
										)) . '">' . $unterinhalt["file"] . '</a></td></tr>';
								} //$inhalt as $unterid => $unterinhalt
						} //$arrayneu as $id => $inhalt
						echo '<tr><td><img src="' . get_bloginfo("wpurl") . '/wp-content/plugins/minecraft-admin/includes/images/filebrowser/folder_add.png" alt="[' . __("new", "minecraft-admin") . ']" /></td><td></td><td><form action="" method="POST"><input name="neuerstellen" type="text" /><input type="submit" class="button-primary" value="' . __("create", 'minecraft-admin') . '" /></form></td><td></td></tr></table><form enctype="multipart/form-data" action="" method="post">' . __("Choose a file to be uploaded", 'minecraft-admin') . ': <input name="datei" type="file"><input type="submit" value="' . __("Upload file", 'minecraft-admin') . '"></form>';
						if ($path != "/" XOR !empty($path) XOR $path != '') {
								echo '<a href="' . mc_url("filebrowser", array(
										"path" => $path,
										"lochen" => "true"
								)) . '>' . __("Delete actually directory.", 'minecraft-admin') . '</a><form method="POST" action="">' . __("rename actually directory.", "minecraft-admin") . ' <input type="text" name="neu" /><input type="submit" class="button-primary" value="' . __("rename", 'minecraft-admin') . '" /></form>';
						} //$path != "/" XOR !empty($path) XOR $path != ''
				}
		}
		function cronjob()
		{
				global $blog_id;
				$prog = MC_CORE_MINECRAFT_DIR . $blog_id . '/' . MC_ID . '/' . "aufgaben.crontab";
				if (!is_file($prog)) {
						touch($prog);
				} //!is_file($prog)
				if (isset($_GET["id"])) {
						$properties = file($prog);
						unlink($prog);
						exec("touch " . $prog);
						$dat = fopen($prog, "w");
						unset($properties[$_GET["id"]]);
						$properties = array_values($properties);
						foreach ($properties as $key => $value) {
								if (!empty($value) or $value != " ") {
										fwrite($dat, $value);
								} //!empty($value) or $value != " "
						} //$properties as $key => $value
						fclose($dat);
						exec("crontab $prog");
						echo '<meta http-equiv="refresh" content="0; URL=' . mc_url("cronjob") . '"> ';
				} //isset($_GET["id"])
				if (!empty($_POST["befehl"])) {
						if (is_array($_POST["min"])) {
								foreach ($_POST["min"] as $key => $value) {
										if (!isset($min)) {
												$min = $value;
										} //!isset($min)
										else {
												$min .= ',' . $value;
										}
								} //$_POST["min"] as $key => $value
						} //is_array($_POST["min"])
						else {
								$min = $_POST["min"];
						}
						if ($min == "") {
								$min = "*";
						} //$min == ""
						if (is_array($_POST["hour"])) {
								foreach ($_POST["hour"] as $key => $value) {
										if (!isset($hour)) {
												$hour = $value;
										} //!isset($hour)
										else {
												$hour .= ',' . $value;
										}
								} //$_POST["hour"] as $key => $value
						} //is_array($_POST["hour"])
						else {
								$hour = $_POST["hour"];
						}
						if ($hour == "") {
								$hour = "*";
						} //$hour == ""
						if (is_array($_POST["day"])) {
								foreach ($_POST["day"] as $key => $value) {
										if (!isset($day)) {
												$day = $value;
										} //!isset($day)
										else {
												$day .= ',' . $value;
										}
								} //$_POST["day"] as $key => $value
						} //is_array($_POST["day"])
						else {
								$day = $_POST["day"];
						}
						if ($day == "") {
								$day = "*";
						} //$day == ""
						if (is_array($_POST["month"])) {
								foreach ($_POST["month"] as $key => $value) {
										if (!isset($month)) {
												$month = $value;
										} //!isset($month)
										else {
												$month .= ',' . $value;
										}
								} //$_POST["month"] as $key => $value
						} //is_array($_POST["month"])
						else {
								$month = $_POST["month"];
						}
						if ($month == "") {
								$month = "*";
						} //$month == ""
						if (is_array($_POST["week"])) {
								foreach ($_POST["week"] as $key => $value) {
										if (!isset($week)) {
												$week = $value;
										} //!isset($week)
										else {
												$week .= ',' . $value;
										}
								} //$_POST["week"] as $key => $value
						} //is_array($_POST["week"])
						else {
								$week = $_POST["week"];
						}
						if ($week == "") {
								$week = "*";
						} //$week == ""
						if (!is_file($prog)) {
								exec("touch " . $prog);
						} //!is_file($prog)
						if ($_POST["befehl"] == "command") {
								$befehl = "sh /etc/init.d/minecraft command " . $_POST["mcbefehl"];
						} //$_POST["befehl"] == "command"
						else {
								$befehl = "sh /etc/init.d/minecraft " . $_POST["befehl"];
						}
						echo '<div class="updated">';
						exec("echo \"$min $hour $day $month $week $befehl\" >> $prog");
						exec("crontab $prog");
						_e('recurring action was successfully created', 'minecraft-admin');
						echo '</div>';
				} //!empty($_POST["befehl"])
				echo '<table><tr><th>' . __('Id', 'minecraft-admin') . '</th><th>' . __('minute', 'minecraft-admin') . '</th><th>' . __('hour', 'minecraft-admin') . '</th><th>' . __('day', 'minecraft-admin') . '</th><th>' . __('month', 'minecraft-admin') . '</th><th>' . __('weeksday', 'minecraft-admin') . '</th><th>' . __('command', 'minecraft-admin') . '</th><th>' . __("delete", "minecraft-admin") . '</th></tr>';
				$properties = file($prog);
				foreach ($properties as $key => $value) {
						$explode = explode("sh /etc/init.d/minecraft", $value);
						$leer    = explode(" ", $explode[0]);
						foreach ($leer as $zähler => $zahl) {
								if ($zahl == '*') {
										$leer[$zähler] = __("all", "minecraft-admin");
								} //$zahl == '*'
						} //$leer as $zähler => $zahl
						$bef    = explode(" ", $explode[1]);
						$bef[1] = str_replace("\n", "", $bef[1]);
						if ($bef[1] == "command") {
								$befehl = __('minecraft command', 'minecraft-admin') . ': <div style="color:green;">';
								foreach ($bef as $id => $rest) {
										if ($id != 0 && $id != 1) {
												$befehl .= $rest . ' ';
										} //$id != 0 && $id != 1
								} //$bef as $id => $rest
								$befehl .= '</div>';
						} //$bef[1] == "command"
						elseif ($bef[1] == "start") {
								$befehl = __('start', 'minecraft-admin');
						} //$bef[1] == "start"
								elseif ($bef[1] == "stop") {
								$befehl = __('stop', 'minecraft-admin');
						} //$bef[1] == "stop"
								elseif ($bef[1] == "restart") {
								$befehl = __('restart', 'minecraft-admin');
						} //$bef[1] == "restart"
								elseif ($bef[1] == "backup") {
								$befehl = __('backup', 'minecraft-admin');
						} //$bef[1] == "backup"
						echo '<tr><td>' . ($key + 1) . '.</td><td>' . $leer[0] . '</td><td>' . $leer[1] . '</td><td>' . $leer[2] . '</td><td>' . $leer[3] . '</td><td>' . $leer[4] . '</td><td>' . $befehl . '</td><td><a href="admin.php?page=minecraft-admin?mc=cronjob&id=' . $key . '">' . __("Delete", "minecraft-admin") . '</a></td></tr>';
						unset($befehl);
				} //$properties as $key => $value
				echo '</table>';
				$this->template('mc-core/cronjobs');
		}
}
?>
Return current item: Minecraft Admin