Xaraya / Postnuke CVS Notices - Message

Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites

View Statistics - Next Notice - Previous Notice

Directory filter : [ all ] / postnuke_official / html / modules / installer [ view in CVS ]

Date Directory [filter] File(s) [view] Author [filter]
03 Aug 2002 03:07:53postnuke_official/html/modules/installerpnadmin.php,NONE,1.1Paul Rosania
 installer beginnings

Update of /home/cvsroot/postnuke_official/html/modules/installer
In directory ns7.hostnuke.net:/tmp/cvs-serv32055/installer

Added Files:
	pnadmin.php 
Log Message:
installer beginnings


--- NEW FILE: pnadmin.php ---
<?php // $Id: pnadmin.php,v 1.1 2002/08/03 03:07:51 paul Exp $
// ----------------------------------------------------------------------
// PostNuke Content Management System
// Copyright (C) 2002 by the PostNuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) 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.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Paul Rosania
// Purpose of file: Installer display functions
// ----------------------------------------------------------------------

function installer_admin_main(){}
// entry point for the installer

function installer_admin_phase1() {
    return array('languages' => array('eng' => 'English'));
}

function installer_admin_phase2() {
    return array();
}

function installer_admin_phase3() {
    global $HTTP_POST_VARS;
    if ($HTTP_POST_VARS['agree'] != 'agree') {
        // didn't agree to license, don't install
        pnRedirect('install.php');
    }
    
    return array();
}

function installer_admin_phase4() {
    return array('database_host' => 'localhost',
                 'database_username' => 'root',
                 'database_password' => '',
                 'database_name' => 'Ragnarok',
                 'database_prefix' => 'pn',
                 'database_types' => array('mysql'    => 'MySQL',
                                           'postgres' => 'Postgres'));
}

function installer_admin_phase5() {
    global $HTTP_POST_VARS;
    
    $dbhost = $HTTP_POST_VARS['install_database_host'];
    $dbname = $HTTP_POST_VARS['install_database_name'];
    $dbuser = $HTTP_POST_VARS['install_database_username'];
    $dbpass = $HTTP_POST_VARS['install_database_password'];
    $prefix = $HTTP_POST_VARS['install_database_prefix'];
    $dbtype = $HTTP_POST_VARS['install_database_type'];
    
    if (isset($HTTP_POST_VARS['install_create_database'])) {
        $create = true;
    } else {
        $create = false;
    }
    
    if (isset($HTTP_POST_VARS['install_intranet'])) {
        $intranet = true;
    } else {
        $intranet = false;
    }

    // Save config data
    installer_adminapi_modifyconfig($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dbtype);
    
    // Kick it
    pnInit(_PNINIT_LOAD_DATABASE);
    
    // Initialize *minimal* tableset
    // Load the installer module, the hard way - file check too
    $base_init_file = 'modules/base/pninit.php';

    if (file_exists($base_init_file)) {
        include_once ($base_init_file);
    } else {
        // modules/base/pninit.php not found?!
        pnExceptionSet(PN_SYSTEM_EXCEPTION, 'MODULE_FILE_NOT_EXIST',
                       new SystemException(__FILE__."(".__LINE__."): Module file $base_init_file doesn't exist."));return;
    }
    
    // Run the function, check for existence
    $mod_func = 'base_init';

    if (function_exists($mod_func)) {
        $res = $mod_func();
        // Handle exceptions
        if (pnExceptionMajor() != PN_NO_EXCEPTION) {
            return;
        }
        if ($res == false) {
            // exception
        }
    } else {
        // base_init() not found?!
        pnExceptionSet(PN_SYSTEM_EXCEPTION, 'MODULE_FUNCTION_NOT_EXIST',
                       new SystemException(__FILE__."(".__LINE__."): Module API function $mod_func doesn't exist."));return;
    }
    
    return array();
}

function installer_admin_modifyconfig(){}

// Update database information in config.php
// TODO: EXCEPTIONS!!
function installer_adminapi_modifyconfig($dbhost, $dbuname, $dbpass, $dbname, $prefix, $dbtype)
{
    $config_php = join('', file('config.php'));
    
    if (isset($HTTP_ENV_VARS['OS']) && strstr($HTTP_ENV_VARS['OS'], 'Win')) {
        $system = 1;
    } else {
        $system = 0;
    }

    $config_php = ereg_replace('\[\'dbtype\'\]\s*=\s*(\'|\")(.*)\\1;', "['dbtype'] = '$dbtype';", $config_php);
    $config_php = ereg_replace('\[\'dbhost\'\]\s*=\s*(\'|\")(.*)\\1;', "['dbhost'] = '$dbhost';", $config_php);
    $config_php = ereg_replace('\[\'dbuname\'\]\s*=\s*(\'|\")(.*)\\1;', "['dbuname'] = '$dbuname';", $config_php);
    $config_php = ereg_replace('\[\'dbpass\'\]\s*=\s*(\'|\")(.*)\\1;', "['dbpass'] = '$dbpass';", $config_php);
    $config_php = ereg_replace('\[\'dbname\'\]\s*=\s*(\'|\")(.*)\\1;', "['dbname'] = '$dbname';", $config_php);
    $config_php = ereg_replace('\[\'prefix\'\]\s*=\s*(\'|\")(.*)\\1;', "['prefix'] = '$prefix';", $config_php);
    $config_php = ereg_replace('\[\'system\'\]\s*=\s*(\'|\")(.*)\\1;', "['system'] = '$system';", $config_php);

    $fp = fopen ('config.php', 'w+');
    fwrite ($fp, $config_php);
    fclose ($fp);
}

?>

Directory filter : [ all ] / postnuke_official / html / modules / installer [ view in CVS ]

View Statistics - Next Notice - Previous Notice


Visit Developer Site - Browse CVS Repository Syndicate via backend.rss
(max. once per hour please)
Powered by CVSNotice 0.1.3