function exec_ogp_module()
{
    global $db;
    global $view;
    $user_id = $_GET['user_id'];
    $y = isset($_GET['y']) ? $_GET['y'] : "";
    $user = $db->getUserById($user_id);
    if (empty($user)) {
        print_failure(get_lang_f('user_with_id_does_not_exist', $user_id));
        return;
    }
    $username = $user['users_login'];
    if ($y !== 'y') {
        if (!$db->isModuleInstalled("subusers")) {
            echo "<p>" . get_lang_f('are_you_sure_you_want_to_delete_user', $username) . "</p>";
        } else {
            if (!$db->isSubUser($user_id)) {
                echo "<p>" . get_lang_f('are_you_sure_you_want_to_delete_user', $username) . get_lang('andSubUsers') . "</p>";
            } else {
                echo "<p>" . get_lang_f('are_you_sure_you_want_to_delete_user', $username) . "</p>";
            }
        }
        echo "<p><a href=\"?m=user_admin&amp;p=del&amp;user_id={$user_id}&amp;y=y\">" . get_lang('yes') . "</a> <a href=\"?m=user_admin\">" . get_lang('no') . "</a></p>";
        return;
    }
    if (!$db->delUser($user_id)) {
        print_failure(get_lang_f('unable_to_delete_user', $username));
        $view->refresh("?m=user_admin");
        return;
    }
    print_success(get_lang_f('successfully_deleted_user', $username));
    $db->logger(get_lang_f('successfully_deleted_user', $username));
    $view->refresh("?m=user_admin");
}
function exec_ogp_module()
{
    global $view;
    global $db;
    #This will add a remote host to the list
    if (isset($_REQUEST['add_remote_host'])) {
        $rhost_ip = trim($_POST['remote_host']);
        $rhost_name = trim($_POST['remote_host_name']);
        $rhost_user_name = trim($_POST['remote_host_user_name']);
        $rhost_port = trim($_POST['remote_host_port']);
        $rhost_ftp_ip = trim($_POST['remote_host_ftp_ip']);
        $rhost_ftp_port = trim($_POST['remote_host_ftp_port']);
        $encryption_key = trim($_POST['remote_encryption_key']);
        $timeout = trim($_POST['timeout']);
        $use_nat = trim($_POST['use_nat']);
        if (empty($rhost_ip)) {
            print_failure(get_lang('enter_ip_host'));
            $view->refresh("?m=server");
            return;
        }
        if (empty($rhost_user_name)) {
            print_failure(get_lang('enter_unix_user_name'));
            $view->refresh("?m=server");
            return;
        }
        if (!isPortValid($rhost_port)) {
            print_failure(get_lang('enter_valid_ip'));
            $view->refresh("?m=server");
            return;
        }
        $rhost_id = $db->addRemoteServer($rhost_ip, $rhost_name, $rhost_user_name, $rhost_port, $rhost_ftp_ip, $rhost_ftp_port, $encryption_key, $timeout, $use_nat);
        if (!$rhost_id) {
            print_failure("" . get_lang('could_not_add_server') . " " . $rhost_ip . " " . get_lang('to_db') . "");
            $view->refresh("?m=server");
            return;
        }
        print_success("" . get_lang('added_server') . " {$rhost_ip} " . get_lang('with_port') . " {$rhost_port} " . get_lang('to_db_succesfully') . "");
        require_once 'includes/lib_remote.php';
        $remote = new OGPRemoteLibrary($rhost_ip, $rhost_port, $encryption_key);
        $iplist = $remote->discover_ips();
        if (empty($iplist)) {
            print_failure("" . get_lang('unable_discover') . " " . $rhost_ip . ". " . get_lang('set_ip_manually') . "");
        } else {
            print_success("" . get_lang('found_ips') . " (" . implode(",", $iplist) . ") " . get_lang('for_remote_server') . "");
            foreach ($iplist as $remote_ip) {
                $remote_ip = trim($remote_ip);
                if (empty($remote_ip)) {
                    continue;
                }
                if (!$db->addRemoteServerIp($rhost_id, $remote_ip)) {
                    print_failure("" . get_lang('failed_add_ip') . " (" . $remote_ip . ") " . get_lang('for_remote_server') . "");
                }
            }
        }
        $view->refresh("?m=server");
        return;
    }
}
function exec_ogp_module()
{
    global $db;
    global $view;
    print "<h2>" . get_lang_f('uninstalling_module', $_REQUEST['module']) . "</h2>";
    require_once 'modules/modulemanager/module_handling.php';
    if (isset($_REQUEST['id']) && isset($_REQUEST['module']) && uninstall_module($db, $_REQUEST['id'], $_REQUEST['module']) === TRUE) {
        print_success(get_lang_f("successfully_uninstalled_module", $_REQUEST['module']));
    } else {
        print_failure(get_lang_f("failed_to_uninstall_module", $_REQUEST['module']));
    }
    $view->refresh("?m=modulemanager");
}
function exec_ogp_module()
{
    require_once 'modules/settings/functions.php';
    require_once 'includes/form_table_class.php';
    global $db, $view, $settings;
    if (isset($_REQUEST['update_settings'])) {
        $settings = array("theme" => $_REQUEST['theme'], "welcome_title" => $_REQUEST['welcome_title'], "welcome_title_message" => $_REQUEST['welcome_title_message'], "logo_link" => $_REQUEST['logo_link'], "bg_wrapper" => @$_REQUEST['bg_wrapper'], "custom_tab" => $_REQUEST['custom_tab'], "custom_tab_name" => @$_REQUEST['custom_tab_name'], "custom_tab_link" => @$_REQUEST['custom_tab_link'], "custom_tab_sub" => @$_REQUEST['custom_tab_sub'], "custom_tab_sub_name" => @$_REQUEST['custom_tab_sub_name'], "custom_tab_sub_link" => @$_REQUEST['custom_tab_sub_link'], "custom_tab_sub_name2" => @$_REQUEST['custom_tab_sub_name2'], "custom_tab_sub_link2" => @$_REQUEST['custom_tab_sub_link2'], "custom_tab_sub_name3" => @$_REQUEST['custom_tab_sub_name3'], "custom_tab_sub_link3" => @$_REQUEST['custom_tab_sub_link3'], "custom_tab_sub_name4" => @$_REQUEST['custom_tab_sub_name4'], "custom_tab_sub_link4" => @$_REQUEST['custom_tab_sub_link4'], "custom_tab_target_blank" => @$_REQUEST['custom_tab_target_blank']);
        $db->setSettings($settings);
        print_success(get_lang('settings_updated'));
        $view->refresh("?m=settings&p=themes");
        return;
    }
    echo "<h2>" . get_lang('theme_settings') . "</h2>";
    $row = $db->getSettings();
    $ft = new FormTable();
    $ft->start_form("?m=settings&p=themes");
    $ft->start_table();
    $ft->add_custom_field('theme', get_theme_html_str(@$row['theme']));
    $ft->add_field('on_off', 'welcome_title', @$row['welcome_title']);
    $ft->add_field('text', 'welcome_title_message', @$row['welcome_title_message']);
    $ft->add_field('string', 'logo_link', @$row['logo_link']);
    if ($settings['theme'] == "Revolution" or "Soft") {
        $ft->add_field('bg_wrapper', 'bg_wrapper', @$row['bg_wrapper']);
    }
    $ft->add_field('on_off', 'custom_tab', @$row['custom_tab']);
    if (isset($settings['custom_tab']) && $settings['custom_tab'] == "1") {
        $ft->add_field('string', 'custom_tab_name', @$row['custom_tab_name']);
        $ft->add_field('string', 'custom_tab_link', @$row['custom_tab_link']);
        $ft->add_field('on_off', 'custom_tab_sub', @$row['custom_tab_sub']);
        if (isset($settings['custom_tab_sub']) && $settings['custom_tab_sub'] == "1") {
            $ft->add_field('string', 'custom_tab_sub_name', @$row['custom_tab_sub_name']);
            $ft->add_field('string', 'custom_tab_sub_link', @$row['custom_tab_sub_link']);
            $ft->add_field('string', 'custom_tab_sub_name2', @$row['custom_tab_sub_name2']);
            $ft->add_field('string', 'custom_tab_sub_link2', @$row['custom_tab_sub_link2']);
            $ft->add_field('string', 'custom_tab_sub_name3', @$row['custom_tab_sub_name3']);
            $ft->add_field('string', 'custom_tab_sub_link3', @$row['custom_tab_sub_link3']);
            $ft->add_field('string', 'custom_tab_sub_name4', @$row['custom_tab_sub_name4']);
            $ft->add_field('string', 'custom_tab_sub_link4', @$row['custom_tab_sub_link4']);
        }
        $ft->add_field('target_self_blank', 'custom_tab_target_blank', @$row['custom_tab_target_blank']);
    }
    $ft->end_table();
    $ft->add_button("submit", "update_settings", get_lang('update_settings'));
    $ft->end_form();
}
function exec_ogp_module()
{
    global $db;
    global $view;
    if (isset($_POST['add_group'])) {
        $group = trim($_POST['group_name']);
        if (empty($group)) {
            print_failure(get_lang('group_name_empty'));
            return;
        }
        if (!$db->addGroup($group, $_SESSION['user_id'])) {
            print_failure(get_lang_f("failed_to_add_group", $group));
            $view->refresh("?m=user_admin&amp;p=show_groups");
            return;
        }
        print_success(get_lang_f('successfully_added_group', $group));
        $db->logger(get_lang_f('successfully_added_group', $group));
        $view->refresh("?m=user_admin&amp;p=show_groups");
    }
}
function exec_ogp_module()
{
    global $view;
    global $db;
    echo "<h2>" . get_lang('view_log') . "</h2>";
    $rhost_id = @$_REQUEST['rhost_id'];
    $remote_server = $db->getRemoteServer($rhost_id);
    $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']);
    if (isset($_POST['save_file'])) {
        $file_info = $remote->remote_writefile('./ogp_agent.log', $_REQUEST['file_content']);
        if ($file_info === 1) {
            print_success(get_lang('wrote_changes'));
        } else {
            if ($file_info === 0) {
                print_failure(get_lang('failed_write'));
            } else {
                print_failure(get_lang("agent_offline"));
            }
        }
    }
    $data = "";
    $file_info = $remote->remote_readfile('./ogp_agent.log', $data);
    if ($file_info === 0) {
        print_failure(get_lang("not_found"));
        return;
    } else {
        if ($file_info === -1) {
            print_failure(get_lang("agent_offline"));
            return;
        } else {
            if ($file_info === -2) {
                print_failure(get_lang("failed_read"));
                return;
            }
        }
    }
    echo "<form action='?m=server&amp;p=log&amp;rhost_id=" . $rhost_id . "' method='post'>";
    echo "<textarea name='file_content' style='width:98%;' rows='40'>{$data}</textarea>";
    echo "<p><input type='submit' name='save_file' value='Save' /></p>";
    echo "</form>";
}
function exec_ogp_module()
{
    global $db;
    global $view;
    print "<h2>" . get_lang_f('installing_module', $_REQUEST['module']) . "</h2>";
    require_once 'modules/modulemanager/module_handling.php';
    $install_retval = -99;
    if (isset($_REQUEST['module'])) {
        $install_retval = install_module($db, $_REQUEST['module']);
    }
    if ($install_retval > 0) {
        print_success(get_lang_f("successfully_installed_module", $_REQUEST['module']));
    } else {
        if ($install_retval == 0) {
            print_success(get_lang_f("module_already_installed", $_REQUEST['module']));
        } else {
            print_failure(get_lang_f("failed_to_install_module", $_REQUEST['module']));
        }
    }
    $view->refresh("?m=modulemanager");
}
function exec_ogp_module()
{
    global $db;
    global $view;
    $group_id = $_GET['group_id'];
    if (!$db->isAdmin($_SESSION['user_id'])) {
        $result = $db->getUserGroupList($_SESSION['user_id']);
        foreach ($result as $row) {
            if ($row['group_id'] == $group_id) {
                $own_group = TRUE;
            }
        }
    }
    if (!$db->isAdmin($_SESSION['user_id']) && !isset($own_group)) {
        echo "<p class='note'>" . get_lang('not_available') . "</p>";
        return;
    }
    $y = isset($_GET['y']) ? $_GET['y'] : "";
    $group = $db->getGroupById($group_id);
    if (empty($group)) {
        print_failure(get_lang_f('group_with_id_does_not_exist', $group_id));
        return;
    }
    $groupname = $group['group_name'];
    if ($y !== 'y') {
        echo "<p>" . get_lang_f('are_you_sure_you_want_to_delete_group', $groupname) . "</p>";
        echo "<p><a href=\"?m=user_admin&amp;p=del_group&amp;group_id={$group_id}&amp;y=y\">" . get_lang('yes') . "</a> <a href=\"?m=user_admin&amp;p=show_groups\">" . get_lang('no') . "</a></p>";
        return;
    }
    if (!$db->delGroup($group_id)) {
        print_failure(get_lang_f('unable_to_delete_group', $groupname));
        $view->refresh("?m=user_admin&amp;p=show_groups");
        return;
    }
    print_success(get_lang_f('successfully_deleted_group', $groupname));
    $db->logger(get_lang_f('successfully_deleted_group', $groupname));
    $view->refresh("?m=user_admin&amp;p=show_groups");
}
function exec_ogp_module()
{
    $home_id = $_REQUEST['home_id'];
    if (empty($home_id)) {
        print_failure(get_lang('home_id_missing'));
        return;
    }
    global $db;
    $isAdmin = $db->isAdmin($_SESSION['user_id']);
    if ($isAdmin) {
        $home_cfg = $db->getGameHome($home_id);
    } else {
        $home_cfg = $db->getUserGameHome($_SESSION['user_id'], $home_id);
    }
    if ($home_cfg === FALSE) {
        print_failure(get_lang('no_access_to_home'));
        return;
    }
    if (isset($_REQUEST['save_file'])) {
        // If magic quotes are on then we need to remove those slashes here.
        if (get_magic_quotes_gpc()) {
            $_REQUEST['file_content'] = stripslashes($_REQUEST['file_content']);
        }
        $remote = new OGPRemoteLibrary($home_cfg['agent_ip'], $home_cfg['agent_port'], $home_cfg['encryption_key']);
        $file_info = $remote->remote_writefile($home_cfg['home_path'] . "/" . $_SESSION['fm_cwd_' . $home_id], $_REQUEST['file_content']);
        if ($file_info === 1) {
            print_success(get_lang('wrote_changes'));
            $db->logger(get_lang('wrote_changes') . " ( " . $home_cfg['home_name'] . " - " . $home_cfg['home_path'] . $_SESSION['fm_cwd_' . $home_id] . " )");
        } else {
            if ($file_info === 0) {
                print_failure(get_lang('failed_write'));
            } else {
                print_failure(get_lang("agent_offline"));
            }
        }
    }
    echo "<table class='center' style='width:100%;'>" . show_back($home_id) . "</table>";
}
<script src="modules/addonsmanager/jquery-ui.js"></script>
<script>
$(function() {
$( 'input,textarea' ).tooltip();
});
</script>
<?php 
/*
 *
 * OGP - Open Game Panel
 * Copyright (C) Copyright (C) 2008 - 2013 The OGP Development Team
 *
 * http://www.opengamepanel.org/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
function exec_ogp_module()
{
    global $db;
    if (isset($_POST['create_addon']) and isset($_POST['name']) and $_POST['url'] == "") {
        print_failure(get_lang("fill_the_url_address_to_a_compressed_file"));
    } elseif (isset($_POST['create_addon']) and isset($_POST['url']) and $_POST['name'] == "") {
        print_failure(get_lang("fill_the_addon_name"));
    } elseif (isset($_POST['create_addon']) and isset($_POST['name']) and isset($_POST['url']) and empty($_POST['addon_type'])) {
        print_failure(get_lang("select_an_addon_type"));
    } elseif (isset($_POST['create_addon']) and isset($_POST['name']) and isset($_POST['url']) and isset($_POST['addon_type']) and empty($_POST['home_cfg_id'])) {
        print_failure(get_lang("select_a_game_type"));
    } elseif (isset($_POST['create_addon']) and isset($_POST['name']) and isset($_POST['url']) and isset($_POST['addon_type']) and isset($_POST['home_cfg_id'])) {
        $fields['name'] = $_POST['name'];
        $fields['url'] = $_POST['url'];
        $fields['path'] = $_POST['path'];
        $fields['addon_type'] = $_POST['addon_type'];
        $fields['home_cfg_id'] = $_POST['home_cfg_id'];
        $fields['post_script'] = $_POST['post_script'];
        if (is_numeric($db->resultInsertId('addons', $fields))) {
            print_success(get_lang_f("addon_has_been_created", $_POST['name']));
            if (isset($_POST['addon_id']) && isset($_POST['edit'])) {
                $db->query("DELETE FROM OGP_DB_PREFIXaddons WHERE addon_id=" . $_POST['addon_id']);
            }
        }
    }
    echo "<h2>" . get_lang('addons_manager') . "</h2>";
    $name = isset($_POST['name']) ? $_POST['name'] : "";
    $url = isset($_POST['url']) ? $_POST['url'] : "";
    $path = isset($_POST['path']) ? $_POST['path'] : "";
    $post_script = isset($_POST['post_script']) ? $_POST['post_script'] : "";
    $home_cfg_id = isset($_POST['home_cfg_id']) ? $_POST['home_cfg_id'] : "";
    $addon_type = isset($_POST['addon_type']) ? $_POST['addon_type'] : "";
    if (isset($_POST['addon_id']) && isset($_POST['edit'])) {
        $addons_rows = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXaddons WHERE addon_id=" . $_POST['addon_id']);
        $addon_info = $addons_rows[0];
        $name = isset($addon_info['name']) ? $addon_info['name'] : "";
        $url = isset($addon_info['url']) ? $addon_info['url'] : "";
        $path = isset($addon_info['path']) ? $addon_info['path'] : "";
        $post_script = isset($addon_info['post_script']) ? $addon_info['post_script'] : "";
        $home_cfg_id = isset($addon_info['home_cfg_id']) ? $addon_info['home_cfg_id'] : "";
        $addon_type = isset($addon_info['addon_type']) ? $addon_info['addon_type'] : "";
    }
    ?>
	<form action="" method="post">
		<table class="center">
			<tr>				
				<td align="right">
					<b><?php 
    print_lang('addon_name');
    ?>
</b>
				</td>
				<td align="left">
					<input type="text" value="<?php 
    echo $name;
    ?>
" name="name" size="90" title="<?php 
    print_lang('addon_name_info');
    ?>
" />
				</td>
			</tr>
			<tr>					
				<td align="right">
					<b><?php 
    print_lang('url');
    ?>
</b>
				</td>
				<td align="left">
					<input type="text" value="<?php 
    echo $url;
    ?>
" name="url" size="90" title="<?php 
    print_lang('url_info');
    ?>
" />
				</td>
			</tr>
			<!-- If any, you can set the destination path, should be a relative path to the main game server folder. -->
			<tr>					
				<td align="right">
					<b><?php 
    print_lang('path');
    ?>
</b>
					</td>
					<td align="left">
					<input type="text" value="<?php 
    echo $path;
    ?>
" name="path" size="90" title="<?php 
    print_lang('path_info');
    ?>
" />
				</td>
			</tr>
			<tr>					
				<td align="right">
					<b><?php 
    print_lang('post-script');
    ?>
</b><br>
					<u><?php 
    print_lang('replacements');
    ?>
</u><br>
					%home_path%<br>
					%home_name%<br>
					%control_password%<br>
					%max_players%<br>
					%ip%<br>
					%port%<br>
					%query_port%<br>
					%incremental%<br>
				</td>
				<td align="left">
					<textarea name="post_script" style="width:99%;height:175px;" title="<?php 
    print_lang('post-script_info');
    ?>
" ><?php 
    echo $post_script;
    ?>
</textarea>
				</td>
			</tr>
			<tr>
				<td align="right">
					<b><?php 
    print_lang('select_game_type');
    ?>
</b>
				</td>
				<td align="left">
				<select name='home_cfg_id'>
		<?php 
    $game_cfgs = $db->getGameCfgs();
    echo "<option style='background:black;color:white;' value=''>" . get_lang('linux_games') . "</option>\n";
    foreach ($game_cfgs as $row) {
        if (preg_match("/linux/", $row['game_key'])) {
            $selected = (isset($home_cfg_id) and $row['home_cfg_id'] == $home_cfg_id) ? 'selected="selected"' : '';
            echo "<option {$selected} value='" . $row['home_cfg_id'] . "'>" . $row['game_name'];
            if (preg_match("/64/", $row['game_key'])) {
                echo " (64bit)";
            }
            echo "</option>\n";
        }
    }
    echo "<option style='background:black;color:white;' value=''>" . get_lang('windows_games') . "</option>\n";
    foreach ($game_cfgs as $row) {
        if (preg_match("/win/", $row['game_key'])) {
            $selected = (isset($home_cfg_id) and $row['home_cfg_id'] == $home_cfg_id) ? 'selected=selected' : '';
            echo "<option {$selected} value='" . $row['home_cfg_id'] . "'>" . $row['game_name'];
            if (preg_match("/64/", $row['game_key'])) {
                echo " (64bit)";
            }
            echo "</option>\n";
        }
    }
    ?>
				</select>
				</td>
			</tr>
			<tr>
				<td align="right">
				<b><?php 
    print_lang('type');
    ?>
</b>	
				</td>
				<td align="left">
		<?php 
    $types = array('plugin', 'mappack', 'config');
    foreach ($types as $type) {
        $checked = (isset($addon_type) and $type == $addon_type) ? 'checked' : '';
        echo '<input type="radio" name="addon_type" value="' . $type . '" ' . $checked . '>' . get_lang($type);
    }
    ?>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
				<?php 
    if (isset($_POST['addon_id']) && isset($_POST['edit'])) {
        echo '<input type="hidden" name="addon_id" value="' . $_POST['addon_id'] . '" >';
        echo '<input type="hidden" name="edit" value="' . $_POST['edit'] . '" >';
        ?>
					<button name="create_addon" type="submit">
					<?php 
        print_lang('edit_addon');
        ?>
					</button>
				<?php 
    } else {
        ?>
					<button name="create_addon" type="submit">
					<?php 
        print_lang('create_addon');
        ?>
					</button>
				<?php 
    }
    ?>
				</td>
			</tr>
		</table>
	</form>
	<br>
	<h2><?php 
    print_lang('addons_db');
    ?>
</h2>
	<table class="center">
		<tr>	
			<td align="center">
				<form name="remove" action="" method="get">
				<input name="m" type="hidden" value="addonsmanager"/>
				<input name="p" type="hidden" value="addons_manager"/>
				<b><?php 
    print_lang('game');
    ?>
</b> <select name='home_cfg_id'>
				<?php 
    echo "<option style='background:black;color:white;' value=''>" . get_lang('linux_games') . "</option>\n";
    foreach ($game_cfgs as $row) {
        if (preg_match("/linux/", $row['game_key'])) {
            if (isset($_GET['home_cfg_id']) and $row['home_cfg_id'] == $_GET['home_cfg_id']) {
                $selected = "selected='selected'";
            } else {
                $selected = "";
            }
            echo "<option value='" . $row['home_cfg_id'] . "' {$selected} >" . $row['game_name'];
Exemple #11
0
<div class="row">
  <div class="col-sm-4">
    <ol class="breadcrumb bc-3">
      <li> <a href="admin.php?act=dashboard"><i class="entypo-home"></i>Dashboard</a> </li>
      <li> <a href="admin.php?act=apiauthentications"><i></i>Manage Authentication Keys</a> </li>
      <li class="active"> <strong>API Authentications</strong> </li>
    </ol>
  </div>
    
</div>
<h2>Add Keys</h2>
    <div class="clearfix"></div>
<br />

<?php 
print_success($msg);
print_error($error);
?>
<div class="row">
    <div>
        <form  role="form" class="form-horizontal" method="post" action="admin.php?act=addauthkey">
            
            <div class="form-group">
                <label for="company_name" class="col-sm-2 control-label">Company Name : </label>
                <div class="col-sm-4">
                  <input type="text" name ="company_name" class="form-control" id="inp_company_name" placeholder="Company Name" value="<?php 
echo $api_company_name;
?>
">
                </div>
                <div class="col-sm-6"></div>
function createHost($hostname, $snmp_community = NULL, $snmp_version, $snmp_port = 161, $snmp_transport = 'udp', $snmp_v3 = array())
{
    $hostname = trim(strtolower($hostname));
    $device = array('hostname' => $hostname, 'sysName' => $hostname, 'status' => '1', 'snmp_community' => $snmp_community, 'snmp_port' => $snmp_port, 'snmp_transport' => $snmp_transport, 'snmp_version' => $snmp_version);
    // Add snmp v3 auth params
    foreach (array('authlevel', 'authname', 'authpass', 'authalgo', 'cryptopass', 'cryptoalgo') as $v3_key) {
        if (isset($snmp_v3['snmp_' . $v3_key])) {
            // Or $snmp_v3['snmp_authlevel']
            $device['snmp_' . $v3_key] = $snmp_v3['snmp_' . $v3_key];
        } else {
            if (isset($snmp_v3[$v3_key])) {
                // Or $snmp_v3['authlevel']
                $device['snmp_' . $v3_key] = $snmp_v3[$v3_key];
            }
        }
    }
    // This is compatibility code after refactor in r6306, for keep devices up before DB updated
    if (get_db_version() < 189) {
        // FIXME. Remove this in r7000
        $device['snmpver'] = $device['snmp_version'];
        unset($device['snmp_version']);
        foreach (array('transport', 'port', 'timeout', 'retries', 'community', 'authlevel', 'authname', 'authpass', 'authalgo', 'cryptopass', 'cryptoalgo') as $old_key) {
            if (isset($device['snmp_' . $old_key])) {
                // Convert to old device snmp keys
                $device[$old_key] = $device['snmp_' . $old_key];
                unset($device['snmp_' . $old_key]);
            }
        }
    }
    $device['os'] = get_device_os($device);
    $device['snmpEngineID'] = snmp_cache_snmpEngineID($device);
    $device['sysName'] = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
    $device['location'] = snmp_get($device, "sysLocation.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
    $device['sysContact'] = snmp_get($device, "sysContact.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
    if ($device['os']) {
        $device_id = dbInsert($device, 'devices');
        if ($device_id) {
            log_event("设备添加: {$hostname}", $device_id, 'device', $device_id, 5);
            // severity 5, for logging user/console info
            if (is_cli()) {
                print_success("正在使用自动发现功能 " . $device['hostname'] . " (id = " . $device_id . ")");
                $device['device_id'] = $device_id;
                // Discover things we need when linking this to other hosts.
                discover_device($device, $options = array('m' => 'ports'));
                discover_device($device, $options = array('m' => 'ipv4-addresses'));
                discover_device($device, $options = array('m' => 'ipv6-addresses'));
                log_event("snmpEngineID -> " . $device['snmpEngineID'], $device, 'device', $device['device_id']);
                // Reset `last_discovered` for full rediscover device by cron
                dbUpdate(array('last_discovered' => 'NULL'), 'devices', '`device_id` = ?', array($device_id));
                array_push($GLOBALS['devices'], $device_id);
            }
            return $device_id;
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}
Exemple #13
0
            print_message("Adding host {$hostname} communit" . (count($config['snmp']['community']) == 1 ? "y" : "ies") . " " . implode(', ', $config['snmp']['community']) . " port {$port}");
        } elseif ($_POST['snmpver'] === "v3") {
            $v3 = array('authlevel' => $_POST['authlevel'], 'authname' => $_POST['authname'], 'authpass' => $_POST['authpass'], 'authalgo' => $_POST['authalgo'], 'cryptopass' => $_POST['cryptopass'], 'cryptoalgo' => $_POST['cryptoalgo']);
            array_push($config['snmp']['v3'], $v3);
            $snmpver = "v3";
            print_message("Adding SNMPv3 host {$hostname} port {$port}");
        } else {
            print_error("Unsupported SNMP Version. There was a dropdown menu, how did you reach this error ?");
            // We have a hacker!
        }
        if ($_POST['ignorerrd'] == 'confirm') {
            $config['rrd_override'] = TRUE;
        }
        $result = add_device($hostname, $snmpver, $port);
        if ($result) {
            print_success("Device added (id = {$result})");
        }
    } else {
        print_error("You don't have the necessary privileges to add hosts.");
    }
}
$pagetitle[] = "Add host";
?>

<form name="form1" method="post" action="" class="form-horizontal">

  <p>Devices will be checked for Ping and SNMP reachability before being probed. Only devices with recognised OSes will be added.</p>

  <fieldset>
    <legend>Device Properties</legend>
    <div class="control-group">
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage webui
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
if ($_SESSION['userlevel'] < 10) {
    print_error_permission();
    return;
}
echo '<div style="margin: 10px;">';
if (auth_usermanagement()) {
    if ($vars['action'] == "deleteuser") {
        $delete_username = dbFetchCell("SELECT `username` FROM `users` WHERE `user_id` = ?", array($vars['user_id']));
        if ($vars['confirm'] == "yes") {
            if (deluser($delete_username)) {
                print_success('User "' . escape_html($delete_username) . '" deleted!');
            } else {
                print_error('Error deleting user "' . escape_html($delete_username) . '"!');
            }
        } else {
            print_error('You have requested deletion of the user "' . escape_html($delete_username) . '". This action can not be reversed.<br /><a href="edituser/action=deleteuser/user_id=' . $vars['user_id'] . '/confirm=yes/">Click to confirm</a>');
        }
    }
} else {
    print_error("Authentication module does not allow user management!");
}
echo '</div>';
// EOF
function exec_ogp_module()
{
    global $db;
    global $view;
    $home_id = $_REQUEST['home_id'];
    $isAdmin = $db->isAdmin($_SESSION['user_id']);
    if ($isAdmin) {
        $home_info = $db->getGameHome($home_id);
    } else {
        $home_info = $db->getUserGameHome($_SESSION['user_id'], $home_id);
    }
    if ($home_info == FALSE) {
        print_failure(get_lang('no_rights_to_start_server'));
        echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=" . $home_info['home_id'] . "-" . $home_info['mod_id'] . "-" . $_REQUEST['ip'] . "-" . $_REQUEST['port'] . "'><< " . get_lang('back') . "</a></td></tr></table>";
        return;
    }
    $mod_id = $_REQUEST['mod_id'];
    if (!array_key_exists($mod_id, $home_info['mods'])) {
        print_failure("Unable to retrieve mod information from database.");
        return;
    }
    echo "<h2>";
    echo empty($home_info['home_name']) ? get_lang('not_available') : $home_info['home_name'];
    echo "</h2>";
    require_once 'includes/lib_remote.php';
    $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']);
    $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $home_info['home_cfg_file']);
    if (!$server_xml) {
        echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=" . $home_info['home_id'] . "-" . $home_info['mod_id'] . "-" . $_REQUEST['ip'] . "-" . $_REQUEST['port'] . "'><< " . get_lang('back') . "</a></td></tr></table>";
        return;
    }
    // It compares ip and port on POST with the pair on DB for security reasons (URL HACKING)
    $home_id = $home_info['home_id'];
    $ip_info = $db->getHomeIpPorts($home_id);
    foreach ($ip_info as $ip_ports_row) {
        if ($ip_ports_row['ip'] == $_REQUEST['ip'] && $ip_ports_row['port'] == $_REQUEST['port']) {
            $ip = $ip_ports_row['ip'];
            $port = $ip_ports_row['port'];
        }
    }
    if (!isset($ip) or !isset($port)) {
        echo "<h2>" . get_lang_f('ip_port_pair_not_owned') . "</h2>";
        echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port={$home_id}-{$mod_id}-{$ip}-{$port}'><< " . get_lang('back') . "</a></td></tr></table>";
        return;
    }
    if (isset($server_xml->console_log)) {
        $log_retval = $remote->remote_readfile($home_info['home_path'] . '/' . $server_xml->console_log, $home_log);
    } else {
        $log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME, $home_info['home_id'], clean_path($home_info['home_path'] . "/" . $server_xml->exe_location), $home_log);
    }
    function getLastLines($string, $n = 1)
    {
        $lines = explode("\n", $string);
        $lines = array_slice($lines, -$n);
        return implode("\n", $lines);
    }
    $home_log = getLastLines($home_log, 40);
    if ($log_retval > 0) {
        if ($log_retval == 2) {
            print_failure(get_lang('server_not_running_log_found'));
        }
        echo "<pre style='background:black;color:white;'>" . $home_log . "</pre>";
        if ($log_retval == 2) {
            return;
        }
    } else {
        print_failure(get_lang_f('unable_to_get_log', $log_retval));
    }
    // If game is not supported by lgsl we skip the lgsl checks and
    // assume successfull start.
    if ($home_info['use_nat'] == 1) {
        $query_ip = $home_info['agent_ip'];
    } else {
        $query_ip = $ip;
    }
    $running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME, $home_info['home_id']);
    if ($server_xml->lgsl_query_name) {
        require 'protocol/lgsl/lgsl_protocol.php';
        $get_q_and_s = lgsl_port_conversion((string) $server_xml->lgsl_query_name, $port, "", "");
        //Connection port
        $c_port = $get_q_and_s['0'];
        //query port
        $q_port = $get_q_and_s['1'];
        //software port
        $s_port = $get_q_and_s['2'];
        $data = lgsl_query_live((string) $server_xml->lgsl_query_name, $query_ip, $c_port, $q_port, $s_port, "sa");
        if ($data['b']['status'] == "0") {
            $running = FALSE;
        }
    } elseif ($server_xml->gameq_query_name) {
        require 'protocol/GameQ/GameQ.php';
        $query_port = get_query_port($server_xml, $port);
        $servers = array(array('id' => 'server', 'type' => (string) $server_xml->gameq_query_name, 'host' => $query_ip . ":" . $query_port));
        $gq = new GameQ();
        $gq->addServers($servers);
        $gq->setOption('timeout', 4);
        $gq->setOption('debug', FALSE);
        $gq->setFilter('normalise');
        $game = $gq->requestData();
        if (!$game['server']['gq_online']) {
            $running = FALSE;
        }
    }
    if (!$running) {
        if (!isset($_GET['retry'])) {
            $retry = 0;
        } else {
            $retry = $_GET['retry'];
        }
        if ($retry >= 5) {
            echo "<p>" . get_lang('server_running_not_responding') . "\n\t\t\t<a href=?m=gamemanager&amp;p=stop&amp;home_id=" . $home_info['home_id'] . "&amp;ip=" . $ip . "&amp;port=" . $port . ">" . get_lang('already_running_stop_server') . ".</a></p>";
            echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port={$home_id}-{$mod_id}-{$ip}-{$port}'><< " . get_lang('back') . "</a></td></tr></table>";
        }
        echo "</b>Retry #" . $retry . ".</b>";
        $retry++;
        print "<p class='note'>" . get_lang('starting_server') . "</p>";
        $view->refresh("?m=gamemanager&amp;p=start&amp;refresh&amp;ip={$ip}&amp;port={$port}&amp;home_id={$home_id}&amp;mod_id={$mod_id}&amp;retry=" . $retry, 3);
        return;
    }
    print_success(get_lang('server_started'));
    $ip_id = $db->getIpIdByIp($ip);
    $db->delServerStatusCache($ip_id, $port);
    $view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port={$home_id}-{$mod_id}-{$ip}-{$port}");
    return;
}
if (is_numeric($_SESSION['user_id'])) {
    $user_id = $_SESSION['user_id'];
    $prefs = get_user_prefs($user_id);
    // Reset RSS/Atom key
    if ($vars['atom_key'] == "toggle") {
        if (set_user_pref($user_id, 'atom_key', md5(strgen()))) {
            print_success('RSS/Atom key updated.');
            $prefs = get_user_prefs($user_id);
        } else {
            print_error('Error generating RSS/Atom key.');
        }
    }
    // Reset API key
    if ($vars['api_key'] == "toggle") {
        if (set_user_pref($user_id, 'api_key', md5(strgen()))) {
            print_success('API key updated.');
            $prefs = get_user_prefs($user_id);
        } else {
            print_error('Error generating API key.');
        }
    }
}
$atom_key_updated = isset($prefs['atom_key']['updated']) ? formatUptime(time() - strtotime($prefs['atom_key']['updated']), 'shorter') . ' ago' : 'Never';
$api_key_updated = isset($prefs['api_key']['updated']) ? formatUptime(time() - strtotime($prefs['api_key']['updated']), 'shorter') . ' ago' : 'Never';
$filename = $config['html_dir'] . '/pages/preferences/' . $vars['section'] . '.inc.php';
if (is_file($filename)) {
    $vars = get_vars('POST');
    // Note, on edit pages use only method POST!
    include $filename;
} else {
    print_error('<h4>Page does not exist</h4>
Exemple #17
0
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage cli
 * @author     Adam Armstrong <*****@*****.**>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
chdir(dirname($argv[0]));
include "includes/defaults.inc.php";
include "config.php";
include "includes/definitions.inc.php";
include "includes/functions.inc.php";
$scriptname = basename($argv[0]);
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WRemove Device%n\n", 'color');
// Remove a host and all related data from the system
if ($argv[1]) {
    $host = strtolower($argv[1]);
    $id = getidbyname($host);
    $delete_rrd = isset($argv[2]) && strtolower($argv[2]) == 'rrd' ? TRUE : FALSE;
    // Test if a valid id was fetched from getidbyname.
    if (isset($id) && is_numeric($id)) {
        print_warning(delete_device($id, $delete_rrd));
        print_success("Device {$host} removed.");
    } else {
        print_error("Device {$host} doesn't exist!");
    }
} else {
    print_message("%n\nUSAGE:\n{$scriptname} <hostname> [rrd]\n\nEXAMPLE:\n%WKeep RRDs%n:   {$scriptname} <hostname>\n%WRemove RRDs%n: {$scriptname} <hostname> rrd\n\n%rInvalid arguments!%n", 'color', FALSE);
}
// EOF
function exec_ogp_module()
{
    global $db;
    global $view;
    $home_cfg_id = isset($_REQUEST['home_cfg_id']) ? $_REQUEST['home_cfg_id'] : "";
    $home_id = isset($_REQUEST['home_id']) ? $_REQUEST['home_id'] : "";
    $addon_id = isset($_REQUEST['addon_id']) ? $_REQUEST['addon_id'] : "";
    $isAdmin = $db->isAdmin($_SESSION['user_id']);
    if ($isAdmin) {
        $home_info = $db->getGameHome($home_id);
    } else {
        $home_info = $db->getUserGameHome($_SESSION['user_id'], $home_id);
    }
    if ($home_info === FALSE) {
        print_failure(get_lang('no_rights'));
        echo create_back_button("addonsmanager", "user_addons");
        return;
    }
    $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $home_info['home_cfg_file']);
    $state = isset($_REQUEST['state']) ? $_REQUEST['state'] : "";
    $pid = isset($_REQUEST['pid']) ? $_REQUEST['pid'] : -1;
    if (!empty($state)) {
        $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']);
        $addons_rows = $db->resultQuery("SELECT url, path, post_script FROM OGP_DB_PREFIXaddons WHERE addon_id=" . $addon_id);
        $addon_info = $addons_rows[0];
        $url = $addon_info['url'];
        $filename = basename($url);
        #### This makes replacements to the bash script:
        if (isset($addon_info['post_script']) and !empty($addon_info['post_script']) and $addon_info['post_script'] != "") {
            $check_passed = FALSE;
            $address_at_post = $_POST['ip'] . ":" . $_POST['port'];
            $ip_ports = $db->getHomeIpPorts($home_info["home_id"]);
            foreach ($ip_ports as $ip_port) {
            }
            $address_owned = $ip_port['ip'] . ":" . $ip_port['port'];
            if ($address_owned == $address_at_post) {
                $check_passed = TRUE;
                break;
            }
            $ip = $ip_port['ip'];
            $port = $ip_port['port'];
            $home_info["ip"] = $check_passed ? $_POST['ip'] : $ip;
            $home_info["port"] = $check_passed ? $_POST['port'] : $port;
            if (isset($server_xml->gameq_query_name)) {
                $home_info["query_port"] = get_query_port($server_xml, $home_info['port']);
            } elseif (isset($server_xml->lgsl_query_name)) {
                $get_q_and_s = lgsl_port_conversion((string) $server_xml->lgsl_query_name, $home_info['port'], "", "");
                $home_info["query_port"] = $get_q_and_s['1'];
            }
            $home_info["incremental"] = $db->incrementalNumByHomeId($home_info["home_id"], $home_info["mod_cfg_id"], $home_info["remote_server_id"]);
            $post_script = preg_replace("/\\%home_path\\%/i", $home_info["home_path"], $addon_info['post_script']);
            $post_script = preg_replace("/\\%home_name\\%/i", $home_info["home_name"], $post_script);
            $post_script = preg_replace("/\\%control_password\\%/i", $home_info["control_password"], $post_script);
            $post_script = preg_replace("/\\%max_players\\%/i", $home_info["max_players"], $post_script);
            $post_script = preg_replace("/\\%ip\\%/i", $home_info["ip"], $post_script);
            $post_script = preg_replace("/\\%port\\%/i", $home_info["port"], $post_script);
            $post_script = preg_replace("/\\%query_port\\%/i", $home_info["query_port"], $post_script);
            $post_script = preg_replace("/\\%incremental\\%/i", $home_info["incremental"], $post_script);
        } else {
            $post_script = "";
        }
        #### end of replacememnts
        if ($state == "start" and $addon_id != "") {
            $pid = $remote->start_file_download($addon_info['url'], $home_info['home_path'] . "/" . $addon_info['path'], $filename, "uncompress", $post_script);
        }
        $headers = get_headers($url, 1);
        $download_available = !$headers ? FALSE : TRUE;
        // Check if any error occured
        if ($download_available) {
            $bytes = is_array($headers['Content-Length']) ? $headers['Content-Length'][1] : $headers['Content-Length'];
            // Display the File Size
            $totalsize = $bytes / 1024;
            clearstatcache();
        }
        $kbytes = $remote->rsync_progress($home_info['home_path'] . "/" . $addon_info['path'] . "/" . $filename);
        list($totalsize, $mbytes, $pct) = explode(";", do_progress($kbytes, $totalsize));
        $totalmbytes = round($totalsize / 1024, 2);
        $pct = $pct > 100 ? 100 : $pct;
        echo "<h2>" . $home_info['home_name'] . "</h2>";
        echo '<div class="dragbox bloc rounded" style="background-color:#dce9f2;" >
				<h4>' . get_lang('install') . " " . $filename . " {$mbytes}MB/{$totalmbytes}MB</h4>\n\t\t\t  <div style='background-color:#dce9f2;' >\n\t\t\t  ";
        $bar = '';
        for ($i = 1; $i <= $pct; $i++) {
            $bar .= '<img style="width:0.92%;vertical-align:middle;" src="images/progressBar.png">';
        }
        echo "<center>{$bar} <b style='vertical-align:top;display:inline;font-size:1.2em;color:red;' >{$pct}%</b></center>\n\t\t\t\t</div>\n\t\t\t  </div>";
        if (($pct == "100" or !$download_available) and $post_script != "") {
            $log_retval = $remote->get_log("post_script", $pid, clean_path($home_info['home_path'] . "/" . $server_xml->exe_location), $script_log);
            if ($log_retval == 0) {
                print_failure(get_lang('agent_offline'));
            } elseif ($log_retval == 1 || $log_retval == 2) {
                echo "<pre class='log'>" . $script_log . "</pre>";
            } elseif ($remote->is_screen_running("post_script", $pid) == 1) {
                print_failure(get_lang_f('unable_to_get_log', $log_retval));
            }
        }
        if ($pct == "100" or !$download_available or $download_available and $pct == "-" and $pid > 0) {
            if (!$download_available) {
                print_failure(get_lang('failed_to_start_file_download'));
            } elseif ($remote->is_file_download_in_progress($pid) === 1) {
                print_success(get_lang_f('wait_while_decompressing', $filename));
                echo "<p><a href=\"?m=addonsmanager&amp;p=addons&amp;state=refresh&amp;home_id=" . $home_id . "&addon_id={$addon_id}&amp;pid={$pid}\">" . get_lang('refresh') . "</a></p>";
                $view->refresh("?m=addonsmanager&amp;p=addons&amp;state=refresh&amp;home_id=" . $home_id . "&addon_id={$addon_id}&amp;pid={$pid}", 5);
            } elseif ($remote->is_file_download_in_progress($pid) === 0 and $remote->is_screen_running("post_script", $pid) === 0) {
                print_success(get_lang('addon_installed_successfully'));
                $view->refresh("?m=addonsmanager&amp;p=user_addons&amp;home_id=" . $home_id, 10);
                return;
            }
        } else {
            echo "<p><a href=\"?m=addonsmanager&amp;p=addons&amp;state=refresh&amp;home_id=" . $home_id . "&addon_id={$addon_id}&amp;pid={$pid}\">" . get_lang('refresh') . "</a></p>";
            $view->refresh("?m=addonsmanager&amp;p=addons&amp;state=refresh&amp;home_id=" . $home_id . "&addon_id={$addon_id}&amp;pid={$pid}", 5);
        }
    } elseif (!empty($_GET['addon_type'])) {
        ?>
			<h2><?php 
        echo $home_info['home_name'] . "&nbsp;" . get_lang($_GET['addon_type']);
        ?>
</h2>
            <table class='center'>
			<form action='?m=addonsmanager&amp;p=addons<?php 
        echo "&amp;ip=" . $_GET['ip'] . "&amp;port=" . $_GET['port'];
        ?>
' method='post'>
            <input type='hidden' name='home_id' value='<?php 
        echo "{$home_id}";
        ?>
' />
            <input type='hidden' name='state' value='start' />
            <tr><td align='right'><?php 
        print_lang('game_name');
        ?>
: </td><td align='left'><?php 
        echo "{$home_info['game_name']}";
        ?>
</td></tr>
            <tr><td align='right'><?php 
        print_lang('directory');
        ?>
: </td><td align='left'><?php 
        echo "{$home_info['home_path']}";
        ?>
</td></tr>
            <tr><td align='right'><?php 
        print_lang('remote_server');
        ?>
: </td>
            <td align='left'><?php 
        echo "{$home_info['remote_server_name']} ({$home_info['agent_ip']}:{$home_info['agent_port']})";
        ?>
</td></tr>
            <tr><td align='right'><?php 
        print_lang('select_addon');
        ?>
: </td>
            <td align='left'>
			<select name="addon_id">
			<?php 
        $addons = $db->resultQuery("SELECT addon_id, name FROM OGP_DB_PREFIXaddons WHERE addon_type='" . $_GET['addon_type'] . "' AND home_cfg_id=" . $home_cfg_id);
        foreach ($addons as $addon) {
            ?>
			<option value="<?php 
            echo $addon['addon_id'];
            ?>
"><?php 
            echo $addon['name'];
            ?>
</option>
			<?php 
        }
        ?>
			</select>
			</td></tr>
            <tr><td colspan='2' class='info'>&nbsp;</td></tr>
            <td align='left'>
			&nbsp;
			</td></tr><tr><td align="right">
            <input type="submit" name="update" value="<?php 
        print_lang('install');
        ?>
" />
            </form></td><td>
			<form action="" method="get">
			<input type="hidden" name="m" value="addonsmanager" />
            <input type="hidden" name="p" value="user_addons" />
			<input type="hidden" name="home_id" value="<?php 
        echo "{$home_id}";
        ?>
" />
			<input type="submit" value="<?php 
        print_lang('back');
        ?>
" />
			</form>
			</td></tr>
			</table>
<?php 
    }
    return;
}
Exemple #19
0
function createHost($host, $community = NULL, $snmpver, $port = 161, $transport = 'udp', $v3 = array())
{
    $host = trim(strtolower($host));
    $device = array('hostname' => $host, 'sysName' => $host, 'community' => $community, 'port' => $port, 'transport' => $transport, 'status' => '1', 'snmpver' => $snmpver);
    $device = array_merge($device, $v3);
    $device['os'] = get_device_os($device);
    $device['snmpEngineID'] = snmp_cache_snmpEngineID($device);
    $device['sysName'] = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
    $device['location'] = snmp_get($device, "sysLocation.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
    $device['sysContact'] = snmp_get($device, "sysContact.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
    if ($device['os']) {
        $device_id = dbInsert($device, 'devices');
        if ($device_id) {
            log_event("Device added: {$host}", $device_id, 'device');
            if (is_cli()) {
                print_success("Now discovering " . $device['hostname'] . " (id = " . $device_id . ")");
                $device['device_id'] = $device_id;
                // Discover things we need when linking this to other hosts.
                discover_device($device, $options = array('m' => 'ports'));
                discover_device($device, $options = array('m' => 'ipv4-addresses'));
                discover_device($device, $options = array('m' => 'ipv6-addresses'));
                log_event("snmpEngineID -> " . $device['snmpEngineID'], $device, 'system');
                // Reset `last_discovered` for full rediscover device by cron
                dbUpdate(array('last_discovered' => 'NULL'), 'devices', '`device_id` = ?', array($device_id));
                array_push($GLOBALS['devices'], $device_id);
            }
            return $device_id;
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}
Exemple #20
0
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage webui
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
echo '<div style="margin: 10px;">';
if ($_SESSION['userlevel'] < '10') {
    include "includes/error-no-perm.inc.php";
} else {
    if (auth_usermanagement()) {
        if ($vars['action'] == "deleteuser") {
            $delete_username = dbFetchCell("SELECT `username` FROM `users` WHERE `user_id` = ?", array($vars['user_id']));
            if ($vars['confirm'] == "yes") {
                if (deluser($delete_username)) {
                    print_success('User "' . $delete_username . '" deleted!');
                } else {
                    print_error('Error deleting user "' . $delete_username . '"!');
                }
            } else {
                print_error('You have requested deletion of the user "' . $delete_username . '". This action can not be reversed.<br /><a href="edituser/action=deleteuser/user_id=' . $vars['user_id'] . '/confirm=yes/">Click to confirm</a>');
            }
        }
    } else {
        print_error("Authentication module does not allow user management!");
    }
}
echo '</div>';
// EOF
    echo generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'latency'));
    ?>
">
        <i class="oicon-blocks"></i> Smokeping</a></div>
      <div class="content">
<?php 
    if ($config['smokeping']['dir'] != '') {
        $smokeping_files = get_smokeping_files(1);
        echo '<p />';
        if ($smokeping_files['incoming'][$device['hostname']]) {
            print_success("RRD发现进向流量延迟.");
        } else {
            print_error("RRD未发现进向流量延迟.");
        }
        if ($smokeping_files['outgoing'][$device['hostname']]) {
            print_success("RRD发现出向流量延迟.");
        } else {
            print_error("RRD未发现出向流量延迟.");
        }
    } else {
        print_warning("没有配置Smokeping目录.");
    }
    ?>
      </div>
    </div>
  </div>

</div>

    <div class="well info_box">
      <div class="title"><a href="<?php 
Exemple #22
0
    print_versions();
}
$auth_file = $config['html_dir'] . '/includes/authentication/' . $config['auth_mechanism'] . '.inc.php';
if (is_file($auth_file)) {
    include $auth_file;
    // Include base auth functions calls
    include $config['html_dir'] . '/includes/authenticate-functions.inc.php';
} else {
    print_error("ERROR: no valid auth_mechanism defined.");
    exit;
}
if (auth_usermanagement()) {
    if (isset($argv[1]) && isset($argv[2]) && isset($argv[3])) {
        if (!auth_user_exists($argv[1])) {
            if (adduser($argv[1], $argv[2], $argv[3], @$argv[4])) {
                print_success("User " . $argv[1] . " added successfully.");
            } else {
                print_error("User " . $argv[1] . " creation failed!");
            }
        } else {
            print_warning("User " . $argv[1] . " already exists!");
        }
    } else {
        $msg = "%n\nUSAGE:\n{$scriptname} <username> <password> <level 1-10> [email]\n\nEXAMPLE:\n%WADMIN%n:   {$scriptname} <username> <password> 10 [email]\n\nUSER LEVELS:" . PHP_EOL;
        foreach ($GLOBALS['config']['user_level'] as $level => $entry) {
            $msg .= '  ' . $level . ' - %W' . $entry['name'] . '%n (' . $entry['subtext'] . ')' . PHP_EOL;
        }
        $msg .= PHP_EOL . "%rInvalid arguments!%n";
        print_message($msg, 'color', FALSE);
    }
} else {
Exemple #23
0
                dbInsert(array('config_key' => $key, 'config_value' => serialize($value)), 'config');
                $updates++;
            }
        }
    }
    // Delete fields that were reset to default
    if (count($deletes)) {
        dbDelete('config', '`config_key` IN (' . implode(',', $deletes) . ')');
        $updates++;
    }
    // Print errors from validation above, if any
    foreach ($errors as $error) {
        print_error($error);
    }
    if ($updates) {
        print_success("Settings updated.<br />Please note Web UI setting takes effect only when refreshing the page <i>after</i> saving the configuration. Please click <a href=\"" . $_SERVER['REQUEST_URI'] . "\">here</a> to reload the page.");
        // Reload $config now, or form below will show old settings still
        include $config['install_dir'] . '/includes/sql-config.inc.php';
    } else {
        print_error('No changes made.');
    }
}
$link_array = array('page' => 'settings');
foreach ($config_sections as $type => $section) {
    if (isset($section['edition']) && $section['edition'] != OBSERVIUM_EDITION) {
        // Skip sections not allowed for current Observium edition
        continue;
    }
    if (!isset($vars['section'])) {
        $vars['section'] = $type;
    }
function exec_ogp_module()
{
    global $db;
    global $view;
    $home_id = isset($_REQUEST['home_id']) ? $_REQUEST['home_id'] : "";
    $mod_id = isset($_REQUEST['mod_id']) ? $_REQUEST['mod_id'] : "";
    $isAdmin = $db->isAdmin($_SESSION['user_id']);
    if ($isAdmin) {
        $home_info = $db->getGameHome($home_id);
    } else {
        $home_info = $db->getUserGameHome($_SESSION['user_id'], $home_id);
    }
    if ($home_info === FALSE || preg_match("/u/", $home_info['access_rights']) != 1) {
        print_failure(get_lang('no_rights'));
        echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id=" . $home_info['home_id'] . "'><< " . get_lang('back') . "</a></td></tr></table>";
        return;
    }
    $game_type = $home_info['game_key'];
    echo "<h2>Updating game server <em>" . $home_info['home_name'] . "</em></h2>";
    $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $home_info['home_cfg_file']);
    if ($server_xml->installer != "steamcmd") {
        print_failure(get_lang('xml_steam_error'));
        return;
    }
    $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']);
    $host_stat = $remote->status_chk();
    if ($remote->is_screen_running(OGP_SCREEN_TYPE_HOME, $home_id) == 1) {
        print_failure(get_lang('server_running_cant_update'));
        return;
    }
    $log_txt = '';
    $update_active = $remote->get_log(OGP_SCREEN_TYPE_UPDATE, $home_id, clean_path($home_info['home_path']), $log_txt);
    $modkey = $home_info['mods'][$mod_id]['mod_key'];
    $mod_xml = xml_get_mod($server_xml, $modkey);
    if (!$mod_xml) {
        print_failure(get_lang_f('mod_key_not_found_from_xml', $modkey));
        return;
    }
    if ($update_active === 0) {
        print_failure(get_lang('agent_offline'));
        echo "<meta http-equiv='refresh' content='5'>";
        return;
    } else {
        if ($_REQUEST['update'] == 'update' && $update_active != 1) {
            $installer_name = $modkey;
            if (isset($mod_xml->installer_name)) {
                $installer_name = $mod_xml->installer_name;
            }
            $mod_cfg_id = $home_info['mod_cfg_id'];
            $game_mod_precmd = $db->resultQuery("SELECT DISTINCT precmd FROM OGP_DB_PREFIXgame_mods WHERE mod_id='{$mod_id}'");
            if ($game_mod_precmd[0]['precmd'] === NULL or empty($game_mod_precmd[0]['precmd'])) {
                $config_mod_precmd = $db->resultQuery("SELECT DISTINCT def_precmd FROM OGP_DB_PREFIXconfig_mods WHERE mod_cfg_id='{$mod_cfg_id}'");
                if ($config_mod_precmd[0]['def_precmd'] === NULL or empty($config_mod_precmd[0]['def_precmd'])) {
                    $precmd = "";
                } else {
                    $precmd = $config_mod_precmd[0]['def_precmd'];
                }
            } else {
                $precmd = $game_mod_precmd[0]['precmd'];
            }
            $game_mod_postcmd = $db->resultQuery("SELECT DISTINCT postcmd FROM OGP_DB_PREFIXgame_mods WHERE mod_id='{$mod_id}'");
            if ($game_mod_postcmd[0]['postcmd'] === NULL or empty($game_mod_postcmd[0]['postcmd'])) {
                $config_mod_postcmd = $db->resultQuery("SELECT DISTINCT def_postcmd FROM OGP_DB_PREFIXconfig_mods WHERE mod_cfg_id='{$mod_cfg_id}'");
                if ($config_mod_postcmd[0]['def_postcmd'] === NULL or empty($config_mod_postcmd[0]['def_postcmd'])) {
                    $postcmd = "";
                } else {
                    $postcmd = $config_mod_postcmd[0]['def_postcmd'];
                }
            } else {
                $postcmd = $game_mod_postcmd[0]['postcmd'];
            }
            $exec_folder_path = clean_path($home_info['home_path'] . "/" . $server_xml->exe_location);
            $exec_path = clean_path($exec_folder_path . "/" . $server_xml->server_exec_name);
            if (isset($_REQUEST['master_server_home_id'])) {
                $ms_home_id = $_REQUEST['master_server_home_id'];
                $ms_info = $db->getGameHome($ms_home_id);
                $steam_out = $remote->masterServerUpdate($home_id, $home_info['home_path'], $ms_home_id, $ms_info['home_path'], $exec_folder_path, $exec_path, $precmd, $postcmd);
            } else {
                if (preg_match("/win32/", $server_xml->game_key) or preg_match("/win64/", $server_xml->game_key)) {
                    $cfg_os = "windows";
                } elseif (preg_match("/linux/", $server_xml->game_key)) {
                    $cfg_os = "linux";
                }
                $settings = $db->getSettings();
                // Some games like L4D2 require anonymous login
                if ($mod_xml->installer_login) {
                    $login = $mod_xml->installer_login;
                    $pass = '';
                } else {
                    $login = $settings['steam_user'];
                    $pass = $settings['steam_pass'];
                }
                $modname = ($installer_name == '90' and !preg_match("/(cstrike|valve)/", $modkey)) ? $modkey : '';
                $betaname = isset($mod_xml->betaname) ? $mod_xml->betaname : '';
                $betapwd = isset($mod_xml->betapwd) ? $mod_xml->betapwd : '';
                $steam_out = $remote->steam_cmd($home_id, $home_info['home_path'], $installer_name, $modname, $betaname, $betapwd, $login, $pass, $settings['steam_guard'], $exec_folder_path, $exec_path, $precmd, $postcmd, $cfg_os);
            }
            if ($steam_out === 0) {
                print_failure(get_lang('failed_to_start_steam_update'));
                return;
            } else {
                if ($steam_out === 1) {
                    print_success(get_lang('update_started'));
                } else {
                    if ($host_stat === 0) {
                        print_failure(get_lang('agent_offline'));
                        $view->refresh("?m=gamemanager&amp;p=update&amp;update=refresh&amp;home_id={$home_id}&amp;mod_id={$mod_id}", 5);
                        return;
                    }
                    echo "Installing Steam... wait.";
                    $steamcmdtrue = isset($_REQUEST['steamcmd']) ? "&amp;steamcmd=true" : "";
                    $view->refresh("?m=gamemanager&amp;p=update&amp;update=update&amp;home_id={$home_id}&amp;mod_id={$mod_id}{$steamcmdtrue}", 5);
                    return;
                }
            }
        } else {
            if (isset($_POST['stop_update_x'])) {
                $stop_update = sprintf("screen -S OGP_UPDATE_%09d -X quit", $home_id);
                $remote->exec("{$stop_update}");
            }
            $update_complete = false;
            if ($update_active == 1) {
                echo "<p class='note'>" . get_lang('update_in_progress') . "</p>\n";
                echo "<form method=POST><input type='image' name='stop_update' onsubmit='submit-form();' src='modules/administration/images/remove.gif'>" . get_lang('stop_update') . "</input></form>";
            } else {
                echo "<meta http-equiv='refresh' content='60'>";
                print_success(get_lang('update_completed'));
                echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id=" . $home_info['home_id'] . "'><< " . get_lang('back') . "</a></td></tr></table>";
                $update_complete = true;
            }
            if (empty($log_txt)) {
                $log_txt = get_lang('not_available');
            }
            echo "<pre>" . $log_txt . "</pre>\n";
            if ($update_complete) {
                return;
            }
        }
    }
    echo "<p><a href=\"?m=gamemanager&amp;p=update&amp;update=refresh&amp;home_id={$home_id}&amp;mod_id={$mod_id}\">";
    echo get_lang('refresh_steam_status') . "</a></p>";
    $view->refresh("?m=gamemanager&amp;p=update&amp;update=refresh&amp;home_id={$home_id}&amp;mod_id={$mod_id}", 5);
    return;
}
Exemple #25
0
        $errors[] = 'MODX works best if Apache includes the <code>mod_rewrite</code> module.';
    }
} else {
    print 'Could not test Apache modules.  Skipping...<br/>';
}
// Safe Mode off
if (ini_get('safe_mode')) {
    $errors[] = "MODX requires PHP's <code>safe_mode</code> to be disabled.";
}
// Globals off
if (ini_get('register_globals')) {
    $errors[] = "MODX requires PHP's <code>register_globals</code> to be disabled.";
}
// Magic quotes off
if (ini_get('magic_quotes_gpc') || function_exists('magic_quotes_gpc')) {
    $errors[] = "MODX requires PHP's <code>magic_quotes_gpc</code> to be disabled.";
}
// Memory Limit
$ram = ini_get('memory_limit');
$ram = preg_replace('/[^0-9]/', '', $ram);
if ($ram < 24) {
    $errors[] = 'MODX requires at least 24M of memory.';
}
// Summary
if (!empty($errors)) {
    print_errors($errors);
    exit;
} else {
    print_success();
}
/*EOF*/
function exec_ogp_module()
{
    global $db;
    global $view;
    echo "<h2>" . get_lang('add_new_game_home') . "</h2>";
    echo "<p><a href='?m=user_games'>&lt;&lt; " . get_lang('back_to_game_servers') . "</a></p>";
    $remote_servers = $db->getRemoteServers();
    if ($remote_servers === FALSE) {
        echo "<p class='note'>" . get_lang('no_remote_servers_configured') . "</p>\n\t\t\t  <p><a href='?m=server'>" . get_lang('add_remote_server') . "</a></p>";
        return;
    }
    $game_cfgs = $db->getGameCfgs();
    $users = $db->getUserList();
    if ($game_cfgs === FALSE) {
        echo "<p class='note'>" . get_lang('no_game_configurations_found') . " <a href='?m=config_games'>" . get_lang('game_configurations') . "</a></p>";
        return;
    }
    echo "<p> <span class='note'>" . get_lang('note') . ":</span> " . get_lang('add_mods_note') . "</p>";
    $selections = array("allow_updates" => "u", "allow_file_management" => "f", "allow_parameter_usage" => "p", "allow_extra_params" => "e", "allow_ftp" => "t", "allow_custom_fields" => "c");
    if (isset($_REQUEST['add_game_home'])) {
        $rserver_id = $_POST['rserver_id'];
        $home_cfg_id = $_POST['home_cfg_id'];
        $web_user_id = trim($_POST['web_user_id']);
        $control_password = genRandomString(8);
        $access_rights = "";
        $ftp = FALSE;
        foreach ($selections as $selection => $flag) {
            if (isset($_REQUEST[$selection])) {
                $access_rights .= $flag;
                if ($flag == "t") {
                    $ftp = TRUE;
                }
            }
        }
        if (empty($web_user_id)) {
            print_failure(get_lang('game_path_empty'));
        } else {
            foreach ($game_cfgs as $row) {
                if ($row['home_cfg_id'] == $home_cfg_id) {
                    $server_name = $row['game_name'];
                }
            }
            foreach ($remote_servers as $server) {
                if ($server['remote_server_id'] == $rserver_id) {
                    $ogp_user = $server['ogp_user'];
                }
            }
            foreach ($users as $user) {
                if ($user['user_id'] == $web_user_id) {
                    $web_user = $user['users_login'];
                }
            }
            $ftppassword = genRandomString(8);
            $game_path = "/home/" . $ogp_user . "/OGP_User_Files/";
            if (($new_home_id = $db->addGameHome($rserver_id, $web_user_id, $home_cfg_id, clean_path($game_path), $server_name, $control_password, $ftppassword)) !== FALSE) {
                $db->assignHomeTo("user", $web_user_id, $new_home_id, $access_rights);
                if ($ftp) {
                    $home_info = $db->getGameHomeWithoutMods($new_home_id);
                    require_once 'includes/lib_remote.php';
                    $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']);
                    $host_stat = $remote->status_chk();
                    if ($host_stat === 1) {
                        $remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']);
                    }
                    $db->changeFtpStatus('enabled', $new_home_id);
                }
                print_success(get_lang('game_home_added'));
                $db->logger(get_lang('game_home_added') . " ({$server_name})");
                $view->refresh("?m=user_games&amp;p=edit&amp;home_id={$new_home_id}");
            } else {
                print_failure(get_lang_f("failed_to_add_home_to_db", $db->getError()));
            }
        }
    }
    // View form to add more servers.
    if (!isset($_POST['rserver_id'])) {
        echo "<form action='?m=user_games&amp;p=add' method='post'>";
        echo "<table class='center'>";
        echo "<tr><td  class='right'>" . get_lang('game_server') . "</td><td class='left'><select onchange=" . '"this.form.submit()"' . " name='rserver_id'>\n";
        echo "<option>" . get_lang('select_remote_server') . "</option>\n";
        foreach ($remote_servers as $server) {
            echo "<option value='" . $server['remote_server_id'] . "'>" . $server['remote_server_name'] . " (" . $server['agent_ip'] . ")</option>\n";
        }
        echo "</select>\n";
        echo "</form>";
        echo "</td></tr></table>";
    } else {
        if (isset($_POST['rserver_id'])) {
            $rhost_id = $_POST['rserver_id'];
        }
        $remote_server = $db->getRemoteServer($rhost_id);
        require_once 'includes/lib_remote.php';
        $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']);
        $host_stat = $remote->status_chk();
        if ($host_stat === 1) {
            $os = $remote->what_os();
        } else {
            print_failure(get_lang_f("caution_agent_offline_can_not_get_os_and_arch_showing_servers_for_all_platforms"));
            $os = "Unknown OS";
        }
        echo "<form action='?m=user_games&amp;p=add' method='post'>";
        echo "<table class='center'>";
        echo "<tr><td class='right'>" . get_lang('game_type') . "</td><td class='left'> <select name='home_cfg_id'>\n";
        // Linux 64 bits + wine
        if (preg_match("/Linux/", $os) and preg_match("/64/", $os) and preg_match("/wine/", $os)) {
            foreach ($game_cfgs as $row) {
                if (preg_match("/linux/", $row['game_key'])) {
                    echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'];
                }
                if (preg_match("/64/", $row['game_key'])) {
                    echo " (64 bit)";
                }
                echo "</option>\n";
            }
            echo "<option style='background:black;color:white;' value=''>" . get_lang('wine_games') . ":</option>\n";
            foreach ($game_cfgs as $row) {
                if (preg_match("/win/", $row['game_key'])) {
                    echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'];
                }
                if (preg_match("/64/", $row['game_key'])) {
                    echo " (64 bit)";
                }
                echo "</option>\n";
            }
        } elseif (preg_match("/Linux/", $os) and preg_match("/64/", $os)) {
            foreach ($game_cfgs as $row) {
                if (preg_match("/linux/", $row['game_key'])) {
                    echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'];
                }
                if (preg_match("/64/", $row['game_key'])) {
                    echo " (64 bit)";
                }
                echo "</option>\n";
            }
        } elseif (preg_match("/Linux/", $os) and preg_match("/wine/", $os)) {
            foreach ($game_cfgs as $row) {
                if (preg_match("/linux32/", $row['game_key'])) {
                    echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'] . "</option>\n";
                }
            }
            echo "<option style='background:black;color:white;' value=''>" . get_lang('wine_games') . "</option>\n";
            foreach ($game_cfgs as $row) {
                if (preg_match("/win32/", $row['game_key'])) {
                    echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'] . "</option>\n";
                }
            }
        } elseif (preg_match("/Linux/", $os)) {
            foreach ($game_cfgs as $row) {
                if (preg_match("/linux32/", $row['game_key'])) {
                    echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'] . "</option>\n";
                }
            }
        } elseif (preg_match("/CYGWIN/", $os) and preg_match("/64/", $os)) {
            foreach ($game_cfgs as $row) {
                if (preg_match("/win/", $row['game_key'])) {
                    echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'];
                }
                if (preg_match("/64/", $row['game_key'])) {
                    echo " (64 bit)";
                }
                echo "</option>\n";
            }
        } elseif (preg_match("/CYGWIN/", $os)) {
            foreach ($game_cfgs as $row) {
                if (preg_match("/win32/", $row['game_key'])) {
                    echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'] . "</option>\n";
                }
            }
        } elseif ($os == "Unknown OS") {
            foreach ($game_cfgs as $row) {
                echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'];
                if (preg_match("/64/", $row['game_key'])) {
                    echo " (64 bit)";
                }
                echo "</option>\n";
            }
        }
        echo "</select>\n</td></tr>";
        // Select user
        echo "<tr><td class='right'>" . get_lang('login') . ":</td>\n\t\t\t<td class='left'><select name='web_user_id'>";
        $users = $db->getUserList();
        foreach ($users as $user) {
            // Only users and admins can be assigned homes... not subusers
            if (is_null($user['users_parent'])) {
                echo "<option value='" . $user['user_id'] . "'>" . $user['users_login'] . "</option>\n";
            }
        }
        echo "</select>\n</td></tr>";
        // Select permisions
        echo "<tr><td class='right'>" . get_lang('access_rights') . ":</td>\n\t\t\t<td class='left'>";
        foreach ($selections as $selection => $flag) {
            echo create_selection($selection, $flag);
        }
        echo "</td></tr>";
        // Assign home
        echo "<tr><td align='center' colspan='2'>\n\t\t\t  <input type='hidden' name='rserver_id' value='" . $rhost_id . "' />" . "<input type='submit' name='add_game_home' value='" . get_lang('add_game_home') . "' /></td></tr></table>";
        echo "</form>";
    }
}
function exec_ogp_module()
{
    if (!function_exists("curl_init")) {
        print_failure(get_lang('curl_needed'));
        return;
    }
    if ($_SESSION['users_group'] != "admin") {
        print_failure(get_lang('no_access'));
        return;
    }
    global $db;
    global $view;
    $version = $_GET['version'];
    $vtype = "SVN";
    echo "<h4>" . get_lang('dwl_update') . "</h4>\n";
    //This is usefull when you are downloading big files, as it
    //will prevent time out of the script
    set_time_limit(0);
    error_reporting(E_ALL);
    ini_set('display_errors', true);
    $baseDir = str_replace("modules" . DIRECTORY_SEPARATOR . "update", "", dirname(__FILE__));
    if (!is_writable($baseDir)) {
        if (!@chmod($baseDir, 0755)) {
            print_failure(get_lang_f('base_dir_not_writable', $baseDir));
            return;
        }
    }
    if (is_writable(sys_get_temp_dir())) {
        // Download file to temporary folder
        if (isset($_POST['mirror']) && !empty($_POST['mirror'])) {
            $mirror = $_POST['mirror'];
        } else {
            $mirror = "master";
        }
        $temp_dwl = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'svn.tar.gz';
        $fp = fopen($temp_dwl, 'w+');
        //This is the download destination
        $url = "http://" . $mirror . ".dl.sourceforge.net/project/ogpextras/Alternative-Snapshot/hldstart-code-{$version}.zip";
        //This is the download source
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_TIMEOUT, 500);
        curl_setopt($ch, CURLOPT_FILE, $fp);
        curl_exec($ch);
        curl_close($ch);
        fclose($fp);
        // Check if the file exists and the size is bigger than a 404 error page from sf.net
        if (file_exists($temp_dwl)) {
            $stat = stat($temp_dwl);
        } else {
            print_failure(get_lang_f('dwl_failed', $url));
            return;
        }
        if ($stat['size'] > 1500) {
            print_success(get_lang('dwl_complete'));
        } else {
            print_failure(get_lang_f('dwl_failed', $url));
            return;
        }
        echo "<h4>" . get_lang('install_update') . "</h4>\n";
        // Set default values for file checkings before installing
        $not_writable = get_lang('can_not_update_non_writable_files') . " :<br>";
        $filename = "";
        $overwritten = 0;
        $new = 0;
        $all_writable = TRUE;
        $filelist = "";
        $overwritten_files = "";
        $new_files = "";
        $unwanted_path = "hldstart-code-{$version}/trunk/upload";
        $extract_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "OGP_update";
        if (!file_exists($extract_path)) {
            mkdir($extract_path, 0775);
        }
        $blacklist = array('/install.php', '/modules/gamemanager/rsync_sites_local.list');
        $blacklisted_files = $db->resultQuery('SELECT file_path FROM `OGP_DB_PREFIXupdate_blacklist`;');
        if ($blacklisted_files !== FALSE) {
            $curren_blacklist = array();
            foreach ($blacklisted_files as $blacklisted_file) {
                $curren_blacklist[] = $blacklisted_file['file_path'];
            }
            $blacklist = array_merge($curren_blacklist, $blacklist);
        }
        include 'unzip.php';
        // array|false extractZip( string $zipFile, string $extract_path [, string $remove_path, array $blacklist, array $whitelist] )
        $files = extractZip($temp_dwl, $extract_path, $unwanted_path, $blacklist, '');
        if (is_array($files) and count($files) > 0) {
            // Check file by file if already exists, if it matches, compares both files
            // looking for changes determining if the file needs to be updated.
            // Also determines if the file is writable
            $filelist = array();
            $i = 0;
            foreach ($files as $file) {
                $filename = str_replace($unwanted_path . "/", "", $file['filename']);
                if (in_array($filename, $blacklist)) {
                    continue;
                }
                $temp_file = $extract_path . DIRECTORY_SEPARATOR . $filename;
                $web_file = $baseDir . $filename;
                if (file_exists($web_file)) {
                    $temp = file_get_contents($temp_file);
                    $web = file_get_contents($web_file);
                    if ($temp != $web) {
                        if (!is_writable($web_file)) {
                            if (!@chmod($web_file, 0775)) {
                                $all_writable = FALSE;
                                $not_writable .= $web_file . "<br>";
                            } else {
                                $filelist[$i] = $file['filename'];
                                $i++;
                                $overwritten_files .= $filename . "<br>";
                                $overwritten++;
                            }
                        } else {
                            $filelist[$i] = $file['filename'];
                            $i++;
                            $overwritten_files .= $filename . "<br>";
                            $overwritten++;
                        }
                    }
                } else {
                    $filelist[$i] = $file['filename'];
                    $i++;
                    $new_files .= $filename . "<br>";
                    $new++;
                }
            }
        }
        // Once checkings are done the temp folder is removed
        if (file_exists($extract_path)) {
            rmdir_recurse($extract_path);
        }
        if ($all_writable) {
            // Extract the files that are set in $filelist, to the folder at $baseDir and removes 'upload' from the beggining of the path.
            $files = extractZip($temp_dwl, preg_replace("/\\/\$/", "", $baseDir), $unwanted_path, $blacklist, $filelist);
            if (is_array($files)) {
                // Updated files
                if ($overwritten > 0) {
                    print_success(get_lang_f('files_overwritten', $overwritten));
                    echo get_lang_f("updated_files", $overwritten_files);
                }
                if ($new > 0) {
                    print_success(get_lang_f('new_files', $new));
                    echo get_lang_f("updated_files", $new_files);
                }
                // update version info in db
                $db->query("UPDATE OGP_DB_PREFIXsettings SET value = '{$version}'\tWHERE setting = 'ogp_version'");
                $db->query("UPDATE OGP_DB_PREFIXsettings SET value = '{$vtype}'\tWHERE setting = 'version_type'");
                // Remove the downloaded package
                if (file_exists($temp_dwl)) {
                    unlink($temp_dwl);
                }
                // Remove files that are not related to the panel
                if (file_exists($baseDir . DIRECTORY_SEPARATOR . "hldstart-code-{$version}")) {
                    rmdir_recurse($baseDir . DIRECTORY_SEPARATOR . "hldstart-code-{$version}");
                }
                echo "<br>\n<h4>" . get_lang('updating_modules') . "</h4>\n";
                require_once 'modules/modulemanager/module_handling.php';
                $modules = $db->getInstalledModules();
                foreach ($modules as $row) {
                    update_module($db, $row['id'], $row['folder']);
                }
                print_success(get_lang('update_complete'));
            } else {
                print_failure("Failed extracting files.<br>There is not enough space available in the system temporary folder (" . sys_get_temp_dir() . ").</b>");
            }
        } else {
            print_failure($not_writable);
        }
    } else {
        print_failure(get_lang_f('temp_folder_not_writable', sys_get_temp_dir()));
    }
}
function exec_ogp_module()
{
    global $db;
    $isAdmin = $db->isAdmin($_SESSION['user_id']);
    if (isset($_REQUEST['user_id']) && !$isAdmin) {
        echo "<p class='note'>" . get_lang('not_available') . "</p>";
        return;
    }
    if (isset($_REQUEST['group_id']) && !$isAdmin) {
        $result = $db->getUserGroupList($_SESSION['user_id']);
        foreach ($result as $row) {
            if ($row['group_id'] == $_REQUEST['group_id']) {
                $own_group = TRUE;
            }
        }
    }
    if (!$isAdmin && !isset($own_group)) {
        echo "<p class='note'>" . get_lang('not_available') . "</p>";
        return;
    }
    if (!isset($_REQUEST['user_id']) && !isset($_REQUEST['group_id'])) {
        print_failure(get_lang("invalid_url"));
        return;
    }
    /// \todo We might want to save this information to XML file?
    $selections = array("allow_updates" => "u", "allow_file_management" => "f", "allow_parameter_usage" => "p", "allow_extra_params" => "e", "allow_ftp" => "t", "allow_custom_fields" => "c");
    if (isset($_REQUEST['user_id'])) {
        $assign_id = $_REQUEST['user_id'];
        $id_type = "user";
        $user = $db->getUserById($assign_id);
        $assign_name = $user['users_login'];
    } else {
        if (isset($_REQUEST['group_id'])) {
            $assign_id = $_REQUEST['group_id'];
            $id_type = "group";
            $group = $db->getGroupById($assign_id);
            $assign_name = $group['group_name'];
        }
    }
    $submit = isset($_POST['submit']) ? $_POST['submit'] : "";
    if (isset($_REQUEST['assign'])) {
        $access_rights = "";
        foreach ($selections as $selection => $flag) {
            if (isset($_REQUEST[$selection])) {
                $access_rights .= $flag;
            }
        }
        $hacker = FALSE;
        if (!$isAdmin) {
            $home_info = $db->getUserGameHome($_SESSION['user_id'], $_REQUEST['home_id']);
            if (!$home_info) {
                print_failure(get_lang_f("failed_to_assign_game_for", $id_type, "(Hacking attempt)"));
                $hacker = TRUE;
            } else {
                foreach ($selections as $selection => $flag) {
                    if (isset($_REQUEST[$selection])) {
                        if (!preg_match("/{$flag}/", $home_info['access_rights'])) {
                            print_failure(get_lang_f("failed_to_assign_game_for", $id_type, "(Hacking attempt)"));
                            $hacker = TRUE;
                        }
                    }
                }
            }
        }
        if (!$hacker) {
            if ($db->assignHomeTo($id_type, $assign_id, $_REQUEST['home_id'], $access_rights) === TRUE) {
                print_success(get_lang_f("assigned_home_to_" . $id_type, $_REQUEST['home_id'], $assign_name));
                $db->logger(get_lang_f("assigned_home_to_" . $id_type, $_REQUEST['home_id'], $assign_name));
            } else {
                print_failure(get_lang_f("failed_to_assign_game_for_", $id_type, $db->getError()));
            }
        }
        unset($_POST['home_id']);
    } else {
        if (isset($_REQUEST['unassign'])) {
            if ($db->unassignHomeFrom($id_type, $assign_id, $_REQUEST['home_id']) === TRUE) {
                print_success(get_lang_f("unassigned_home_from_" . $id_type, $_REQUEST['home_id'], $assign_name));
                $db->logger(get_lang_f("unassigned_home_from_" . $id_type, $_REQUEST['home_id'], $assign_name));
            } else {
                print_failure(get_lang_f("failed_to_assign_game_from_", $id_type));
            }
        }
    }
    $remote_servers = $db->getRemoteServers();
    if (empty($remote_servers)) {
        print_failure(get_lang("no_remote_servers_available_please_add_at_least_one"));
        echo "<p><a href='?m=server'>" . get_lang('add_remote_server') . "</a></p>";
        return;
    }
    if ($isAdmin) {
        $available_homes = $db->getAvailableHomesFor($id_type, $assign_id);
    } else {
        $available_homes = $db->getAvailableUserHomesFor($id_type, $assign_id, $_SESSION['user_id']);
    }
    if (!empty($available_homes)) {
        echo "<h2>" . get_lang_f('assign_new_home_to_' . $id_type, $assign_name) . "</h2>";
        echo "<form action='?m=user_games&amp;p=assign' method='post'>";
        echo "<input name='" . $id_type . "_id' value='" . $assign_id . "' type='hidden' />\n";
        echo "<table class='center'><tr><td align='right'><label for='home_id'>" . get_lang('select_home') . ":</label></td>";
        echo '<td align="left"><select id="home_id" name="home_id" onchange="this.form.submit();">';
        echo "<option></option>\n";
        foreach ($available_homes as $home) {
            if (isset($_POST['home_id']) && $_POST['home_id'] == $home['home_id']) {
                $selected = "selected='selected'";
            } else {
                $selected = "";
            }
            echo "<option value='" . $home['home_id'] . "' {$selected} >" . $home['home_name'] . "</option>\n";
        }
        echo "</select></td>\n";
        if (isset($_POST['home_id']) and !empty($_POST['home_id'])) {
            if ($isAdmin) {
                $access_rights = "ufpetc";
            } else {
                $home_info = $db->getUserGameHome($_SESSION['user_id'], $_POST['home_id']);
                $access_rights = $home_info['access_rights'];
            }
            foreach ($selections as $selection => $flag) {
                echo create_selection($selection, $flag, $access_rights);
            }
            echo "<tr><td colspan='2'><input type='submit' name='assign' value='" . get_lang('assign') . "' /></td></tr>";
        }
        echo "</table></form>";
    } else {
        echo "<h2>" . get_lang("no_more_homes_available_that_can_be_assigned_for_this_{$id_type}") . "</h2>";
        //print_lang('you_can_add_a_new_game_server_from');
        //echo "<a href='?m=user_games'>".get_lang('game_servers')."</a>.</p>";
        if ($isAdmin) {
            echo get_lang_f("you_can_add_a_new_game_server_from", "<a href='?m=user_games'>" . get_lang('game_servers') . "</a>") . "</p>";
        }
    }
    // View servers for use if there are any.
    $game_homes = $db->getHomesFor($id_type, $assign_id);
    if (empty($game_homes)) {
        echo "<h3>" . get_lang_f("no_homes_assigned_to_" . $id_type, $assign_name) . "</h3>";
    } else {
        echo "<h2>" . get_lang('assigned_homes') . "</h2>";
        echo '<table class="center">';
        echo "<tr><th>" . get_lang('home_id') . "</th><th>" . get_lang('game_server') . "</th>\n            <th>" . get_lang('game_type') . "</th>\n            <th align='center'>" . get_lang('game_home') . "</th>\n            <th>" . get_lang('game_home_name') . "</th><th>" . get_lang('access_rights') . "</th>\n            <th>" . get_lang('actions') . "</th></tr>";
        foreach ($game_homes as $row) {
            echo "<tr><td>{$row['home_id']}</td>\n                <td>" . $row['agent_ip'] . " (Agent)</td>\n                <td>{$row['game_name']}</td>\n                <td>{$row['home_path']}</td>\n                <td>{$row['home_name']}</td>\n                <td>";
            echo empty($row['access_rights']) ? "-" : $row['access_rights'];
            echo "</td>\n                <td>\n                <form action='?m=user_games&amp;p=assign' method='post'>\n                <input name='" . $id_type . "_id' value='{$assign_id}' type='hidden' />\n                <input name='home_id' value='" . $row['home_id'] . "' type='hidden' />\n                <input type='submit' name='unassign' value='" . get_lang('unassign') . "' /></form></td>\n                </tr>";
        }
        echo "</table>";
    }
    if ($id_type === "group") {
        echo create_back_button('user_admin', 'show_groups');
    } else {
        echo create_back_button('user_admin');
    }
}
Exemple #29
0
print_message("This page allows you to disable or enable certain Graphs detected for a device.");
$graphs_db = array();
foreach (dbFetchRows("SELECT `graph`,`enabled` FROM `device_graphs` WHERE `device_id` = ?", array($device['device_id'])) as $entry) {
    $graph = $entry['graph'];
    $section = $config['graph_types']['device'][$graph]['section'];
    $graphs_db[$graph] = (bool) $entry['enabled'];
    // Another array sorted by sections
    $graphs_sections[$section][$graph] = (bool) $entry['enabled'];
}
$graph = $_POST['toggle_graph'];
if ($graph && isset($graphs_db[$graph]) && !in_array($config['graph_types']['device'][$graph]['section'], array('poller', 'system'))) {
    $value = (int) (!$graphs_db[$graph]);
    // Toggle current 'enabled' value
    $updated = dbUpdate(array('enabled' => $value), 'device_graphs', '`device_id` = ? AND `graph` = ?', array($device['device_id'], $graph));
    if ($updated) {
        print_success("Graph '{$graph}' " . ($value ? 'enabled' : 'disabled') . '.');
        $graphs_sections[$config['graph_types']['device'][$graph]['section']][$graph] = (bool) $value;
    }
}
?>

<div class="row"> <!-- begin row -->

  <div class="col-md-6"> <!-- begin poller options -->

<fieldset>
  <legend>Device Graphs</legend>
</fieldset>

<table class="table table-bordered table-striped table-condensed table-rounded">
  <thead>
function exec_ogp_module()
{
    global $db, $view;
    $home_id = $_GET['home_id'];
    $isAdmin = $db->isAdmin($_SESSION['user_id']);
    if ($isAdmin) {
        $home_info = $db->getGameHome($home_id);
        $custom_fileds_access_enabled = TRUE;
    } else {
        $home_info = $db->getUserGameHome($_SESSION['user_id'], $home_id);
        $custom_fileds_access_enabled = preg_match("/c/", $home_info['access_rights']) > 0 ? TRUE : FALSE;
    }
    if (!$home_info or !$custom_fileds_access_enabled) {
        return;
    }
    $server_xml = read_server_config(SERVER_CONFIG_LOCATION . $home_info['home_cfg_file']);
    include 'includes/lib_remote.php';
    $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']);
    echo "<h2>" . get_lang('editing_home_called') . " \"" . $home_info['home_name'] . "\"</h2>";
    echo "<p>";
    echo "<a href='?m=gamemanager&p=game_monitor&home_id={$home_id}'>&lt;&lt; " . get_lang('back_to_game_monitor') . "</a>";
    if ($isAdmin) {
        echo "  &nbsp; ";
        echo "<a href='?m=user_games'>&lt;&lt; " . get_lang('back_to_game_servers') . "</a>";
    }
    echo "  &nbsp; ";
    echo "<a href='?m=user_games&p=edit&home_id={$home_id}'>&lt;&lt; " . get_lang('back_to_edit_server') . "</a>";
    echo "</p>";
    if (isset($_POST['update_settings'])) {
        $save_field = $_POST['fields'];
        $db->changeCustomFields($home_info['home_id'], json_encode($save_field));
        print_success(get_lang('settings_updated'));
        $view->refresh("?m=user_games&p=custom_fields&home_id=" . $home_id);
    }
    $ft = new FormTable();
    $ft->start_form("", "post", "autocomplete=\"off\"");
    $ft->start_table();
    foreach ($server_xml->custom_fields->field as $field) {
        renderCustomFields($field, $home_info['home_id']);
    }
    $ft->end_table();
    $ft->add_button("submit", "update_settings", get_lang('update_settings'));
    $ft->end_form();
}