コード例 #1
0
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>";
}
コード例 #2
0
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>";
}
コード例 #3
0
            } elseif ($options == "tagValueByName") {
                $file_content = preg_replace('/(' . $default . '.*name="' . $var . '".*value=)(".*")/m', '${1}"' . $info_param . '"', $file_content, 1);
            } elseif ($options == "s") {
                //separated
                $file_content = preg_replace("/{$default}/m", "{$var} {$info_param}", $file_content, 1);
            } elseif ($options == "q") {
                //quoted
                $file_content = preg_replace("/{$default}/m", "{$var}\"{$info_param}\"", $file_content, 1);
            } elseif ($options == "sq") {
                //separated & quoted
                $file_content = preg_replace("/{$default}/m", "{$var} \"{$info_param}\"", $file_content, 1);
            } elseif ($options == "sc") {
                //separated & ending with a comma (used in JC2MP Example)
                $file_content = preg_replace("/{$default}/m", "{$var} {$info_param},", $file_content, 1);
            } elseif ($options == "sqc") {
                //separated & quoted & ending with a comma
                $file_content = preg_replace("/{$default}/m", "{$var} \"{$info_param}\",", $file_content, 1);
            } elseif ($options == "key-regex") {
                $var = str_replace("%key%", $info_param, $var);
                $file_content = preg_replace("/{$default}/m", "{$var}", $file_content, 1);
            } else {
                $file_content = preg_replace("/{$default}/m", "{$var}{$info_param}", $file_content, 1);
            }
        }
        if (get_magic_quotes_gpc()) {
            $file_content = stripslashes($file_content);
        }
    }
    //echo "<xmp>".$file_content."</xmp>";
    $remote->remote_writefile($server_home['home_path'] . "/" . $filepath, $file_content);
}