Location: PHPKode > projects > PHPEcho CMS > install/index.php
<?php
/*  +--------------------------------------------
*   |
*   |     Product:       PHPEchoCMS
*   |     Author:        Tigran Abrahamyan
*   |     License:       GPL
*   |     Last updated:  03.03.07
*   |     For version:   2.0  
*   |     Desc:          Install system for CMS
*   |        
*   +--------------------------------------------
*/

include ("../config.php");
include ("../kernel/core.inc.php");

echo "
<html>
<head>
<title>PHPEcho CMS Installer</title>
<link rel='stylesheet' href='../templates/default/style/style.css' type='text/css'>
<style>
table {
margin-left: 250px;
}
</style>
</head>
<body>
<center>
<img src='../templates/default/images/logo.jpg'>
</center>
<TABLE width='500px'>
<TR>
<TD width='50%' class='border'>";

mysql_connect($cfg_db_host, $cfg_db_user, $cfg_db_pass) or die("MySQL connecting error. Check the config.php");
mysql_select_db($cfg_db_name) or die("MySQL connecting error. Check the config.php");

if ( session_is_registered ("login") )
{
    session_unregister ("login");
}

switch (@$_GET['step'])
{
    case "01":
        step01();
        break;
    case "02":
        step02();
        break;
    case "cleardb":
        cleardb();
        break;
    default:
        step01();
}

function cleardb ()
{
    echo "<font color='red'>DO YOU WANT TO CLEAR DB? IT WILL BE DELETE ALL DATA ABOUT PHPECMS!</font><Br />
    <a href='index.php?step=cleardb&really=yes'>Yes, clear my db</a>
    ";
    if ( @$_GET['really'] )
    {
        mysql_query ( "DROP TABLE `".PREFIX."blocks`, `".PREFIX."files`, `".PREFIX."gallery`, `".PREFIX."gallery_cats`, `".PREFIX."languages`, `".PREFIX."modules`, `".PREFIX."news`, `".PREFIX."news_comments`, `".PREFIX."settings`, `".PREFIX."themes`, `".PREFIX."users`, `".PREFIX."sections`, `".PREFIX."threads`, `".PREFIX."voting`, `".PREFIX."voting_elements`, `".PREFIX."current_users`, `".PREFIX."statistics_os`, `".PREFIX."statistics_browser`, `".PREFIX."admin_perms`, `".PREFIX."banners`;");
        $core->redirect ("index.php");
    }
}
function step01()
{
    echo "Database configuration is <font color='green'>OK</font>!<br />
    <a href='index.php?step=cleardb'>Clear database</a><br />
    <a href='index.php?step=02'>Go to next step</a><br />";
    $cache_write = is_writeable("../cache");
    $uploads_write = is_writeable("../uploads");
    if ( !$cache_write )
    {
        die ("'Cache' dir is <font color='red'>not</font> writeable. Please chmod to 777.");
    }
    if ( !$uploads_write )
    {
        die ("'Uploads' dir is <font color='red'>not</font> writeable. Please chmod to 777.");
    }
}

function step02()
{
    require ( "./data/mysql_tables.php" );
    require ( "./data/mysql_inserts.php" );

    foreach ($table as $onetable)
    {
        mysql_query($onetable) or die(mysql_error());
    }
    foreach ($insert as $oneinsert)
    {
        mysql_query($oneinsert) or die(mysql_error());
    }
    
    echo "You have <font color='green'>successfuly</font> installed the PHPEcho CMS!<br>
    Please <font color='red'>DELETE</font> the 'install.php' file.
    <a href='../index.php'>Go</a> to your web site home!
    ";
}
echo "
</TD>
</TR>
</TABLE>
</body>
</html>";
?>
Return current item: PHPEcho CMS