예제 #1
0
ini_set('include_path', $path);
require_once "Auth/OpenID.php";
/**
 * Data.
 */
$store_types = array("Filesystem" => "Auth_OpenID_FileStore", "MySQL" => "Auth_OpenID_MySQLStore", "PostgreSQL" => "Auth_OpenID_PostgreSQLStore", "SQLite" => "Auth_OpenID_SQLiteStore");
/**
 * Main.
 */
$messages = array();
session_start();
init_session();
if (!check_session() || isset($_GET['add_openid'])) {
    render_form();
} else {
    print generate_config(isset($_GET['download']));
}
/**
 * Functions.
 */
function check_url($url)
{
    return Auth_OpenID::normalizeUrl($url) !== null;
}
function build_url()
{
    $port = $_SERVER['SERVER_PORT'] == 80 ? null : $_SERVER['SERVER_PORT'];
    $parts = explode("/", $_SERVER['SERVER_PROTOCOL']);
    $scheme = strtolower($parts[0]);
    if ($port) {
        return sprintf("%s://%s:%s%s/server.php", $scheme, $_SERVER['SERVER_NAME'], $port, dirname($_SERVER['PHP_SELF']));
예제 #2
0
/**
 * write_config
 *
 * Write new configuration into the current configuration file by keeping old values.
 */
function write_config($current_file_path)
{
    $new_data = generate_config(parse_ini_file($current_file_path));
    // Start writing into the current config file
    $handle = fopen($current_file_path, 'w+');
    fwrite($handle, $new_data, strlen($new_data));
    fclose($handle);
}
예제 #3
0
 */
require_once '../lib/init.php';
if (!Access::check('interface', 100) or AmpConfig::get('demo_mode')) {
    UI::access_denied();
    exit;
}
UI::show_header();
/* Switch on action boys */
switch ($_REQUEST['action']) {
    /* This re-generates the config file comparing
     * /config/ampache.cfg to .cfg.dist
     */
    case 'generate_config':
        ob_end_clean();
        $current = parse_ini_file(AmpConfig::get('prefix') . '/config/ampache.cfg.php');
        $final = generate_config($current);
        $browser = new Horde_Browser();
        $browser->downloadHeaders('ampache.cfg.php', 'text/plain', false, filesize(AmpConfig::get('prefix') . '/config/ampache.cfg.php.dist'));
        echo $final;
        exit;
    case 'reset_db_charset':
        Dba::reset_db_charset();
        show_confirmation(T_('Database Charset Updated'), T_('Your Database and associated tables have been updated to match your currently configured charset'), AmpConfig::get('web_path') . '/admin/system.php?action=show_debug');
        break;
    case 'show_debug':
        $configuration = AmpConfig::get_all();
        if ($_REQUEST['autoupdate'] == 'force') {
            $version = AutoUpdate::get_latest_version(true);
        }
        require_once AmpConfig::get('prefix') . '/templates/show_debug.inc.php';
        break;
예제 #4
0
/**
 * install_create_config
 *
 * Attempts to write out the config file or offer it as a download.
 */
function install_create_config($download = false)
{
    $config_file = AmpConfig::get('prefix') . '/config/ampache.cfg.php';
    /* Attempt to make DB connection */
    Dba::dbh();
    $params = AmpConfig::get_all();
    if (empty($params['database_username']) || empty($params['database_password']) && strpos($params['database_hostname'], '/') !== 0) {
        Error::add('general', T_("Invalid configuration settings"));
        return false;
    }
    // Connect to the DB
    if (!Dba::check_database()) {
        Error::add('general', T_("Database Connection Failed Check Hostname, Username and Password"));
        return false;
    }
    $final = generate_config($params);
    // Make sure the directory is writable OR the empty config file is
    if (!$download) {
        if (!check_config_writable()) {
            Error::add('general', T_('Config file is not writable'));
            return false;
        } else {
            // Given that $final is > 0, we can ignore lazy comparison problems
            if (!file_put_contents($config_file, $final)) {
                Error::add('general', T_('Error writing config file'));
                return false;
            }
        }
    } else {
        $browser = new Horde_Browser();
        $browser->downloadHeaders('ampache.cfg.php', 'text/plain', false, strlen($final));
        echo $final;
        exit;
    }
    return true;
}
예제 #5
0
        //var_dump($result);
        //echo 'do install';
    } elseif (isset($_POST['next'])) {
        $_SESSION['stage'] = $g_stage = 5;
        unset($_POST['next']);
    } elseif (isset($_POST['back'])) {
        $_SESSION['stage'] = $g_stage = 3;
        $g_params['user'] = $_SESSION['admin']['user'];
        $g_params['pass'] = $_SESSION['admin']['pass'];
        $g_params['email'] = $_SESSION['admin']['email'];
    }
}
if ($g_stage == 5) {
    if (isset($_POST['next'])) {
        $_SESSION['admin']['require_approval'] = $_POST['require_approval'] == '1' ? TRUE : FALSE;
        if (generate_config('../bin/config.php') === FALSE) {
            $g_params['errors'] = 'Unable to write the config file (/bin/config.php)';
        } else {
            // Other settings that require changes in db tables.
            $data = array();
            $data['allow_uploads'] = $_POST['uploads'] == '1' ? 1 : 0;
            $data['timeout_snail'] = (double) $_POST['timeout_snail'];
            $data['timeout_slow'] = (double) $_POST['timeout_slow'];
            $data['timeout_normal'] = (double) $_POST['timeout_normal'];
            $data['timeout_fast'] = (double) $_POST['timeout_fast'];
            $data['timeout_blitz'] = (double) $_POST['timeout_blitz'];
            $data['language'] = $_POST['language'] . '.txt';
            $data['max_players'] = (int) $_POST['max_players'];
            $result = update_settings($data);
            if ($result['success']) {
                unset($_POST['next']);
예제 #6
0
    $step = intval($_REQUEST['step']);
    if (isset($_REQUEST['action']) and $_REQUEST['action'] == 'next') {
        $step = $step + 1;
    }
} else {
    $step = 1;
}
if ($step >= 4) {
    header('Location: ../admin/index.php');
}
$template_name = '';
$renderArray = array();
if ($step == 1) {
    if (isset($_REQUEST['action']) and $_REQUEST['action'] == 'save') {
        $template_name = 'install-step1-result.html';
        $config_content = generate_config($twig);
        $result = save_config($config_content);
        if ($result) {
            $renderArray['resultText'] = 'Файл конфигурации был успешно сохранен!';
        } else {
            $renderArray['resultText'] = 'Файл конфигурации невозможно сохранить. Вам необходимо сделать это вручную';
            $renderArray['confFileContent'] = $config_content;
        }
    } else {
        $template_name = 'install-step1.html';
        if (file_exists(CONFIG_FILE)) {
            include_once CONFIG_FILE;
            if (!isset($config) or !is_array($config)) {
                $renderArray['message1'] = 'Файл конфигурации необходимо обновить';
                $renderArray['isNewConfig'] = false;
                $renderArray['conf_db_host'] = $db_host;