Location: PHPKode > projects > Php4dvd - movie database > php4dvd/install/index.php
<?php
/**
================================================================================
 LISENCE
================================================================================

    This file is part of php4dvd.

    php4dvd 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 3 of the License, or
    (at your option) any later version.

    php4dvd 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 php4dvd. If not, see <http://www.gnu.org/licenses/>.
**/

//No caching the installer please
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>php4dvd Installer</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>

<div id="root">
    <div id="menu">
        <table><tr><td><a href="#">php4dvd Installer</a></td></tr></table>
    </div>
    <div id="main">

<?php
/**
 * The util class.
 */
require_once("files/util.inc.php");

//Get the page to go to
$go='';
if(isset($_GET['go'])) {
    $go=$_GET['go'];
}

//Sub parameter
$sub='';
if(isset($_GET['sub'])) {
    $sub=$_GET['sub'];
}

if ($go=='') {
    //First time visitor
    include_once('files/welcome.php');
}elseif ($go=='perm') {
    //After welcome screen lets check thier permissions
    include_once('files/perm.php');
}elseif ($go=='type') {
    //After permissions lets ask what type of install
    include_once('files/type.php');
}elseif ($go=='new') {
    //After type of install, since new, create settings file
    include_once('files/create_config.php');

    //Check the second paremeter to determine whether to display config
    //form, create the config file, or to upgrade the db
    if ($sub=='') {
        config_form("localhost","php4dvd","root","");
    } elseif ($sub=='post') {
        //Get the posted fields (from the form)
        get_post();

        //Try the conenction
        $Connection=getConnection($db["server"],$db["user"],$db["pass"]);
        if ($Connection) {
            //If it has a connection, now check to see if db exists
            $Exists=getDb($db["name"]);
            if ($Exists) {
                config_form($db["server"],$db["name"],$db["user"],$db["pass"]);
                db_exists($db["server"],$db["name"],$db["user"],$db["pass"]);
            } else {
                post_config();
            }
        } else {
            config_form($db["server"],$db["name"],$db["user"],$db["pass"]);
            echo "<span class='inputerror'>We could not connect to your database.
                    Please adjust your settings to match your environment.</span>";
        }
    } elseif ($sub=='postconfig') {
        //Get the posted fields (from the form) and the connection
        get_post();
        $Connection=getConnection($db["server"],$db["user"],$db["pass"]);
        post_config();
    } elseif ($sub=='db') {
        include_once('files/create_db.php');
        echo "<p>";
        create_db();     //New install so create db
        new_install();   //New install so run proper function
        echo "</p>";
        echo "<p><a href='?go=cleanup'>Next</a></p>";
    }
}elseif ($go=='upgrade') {
    //After type of install, since new, create settings file
    include_once('files/create_config.php');

    //Check the second paremeter to determine whether to create the
    //config file or to upgrade the db
    if ($sub=='') {
        include_config();    //Create config but including and then pulling vars
    }elseif ($sub=='db') {
        include_once('files/create_db.php');
        echo "<p>";
        upgrade_install();   //Upgrade db
        echo "</p>";
        echo "<p><a href='?go=cleanup'>Next</a></p>";
    }
}elseif ($go=='cleanup') {
    //They are finished the install, create the version file and rename /install/index.php
    include_once('files/cleanup.php');
    rename_index();
    create_version();
    display_finish();
}
?>

    </div>
</div>

<div id="credits">
    <a href="http://php4dvd.sourceforge.net/" target="_blank">php4dvd v0.2</a>
</div>

<script type="text/javascript" src="javascripts/forms.js"></script>

</body>
</html>
Return current item: Php4dvd - movie database