Location: PHPKode > projects > Skrupel User Game Administration > install.php
<?php
//we are in install mode, we need to use our own including
define("INSTALL_DIR",dirname(__FILE__));
if(is_file("./include/conf.inc.php")){
        //already installed
        die("SUGA doesn't need to be installed twice");
}

require INSTALL_DIR."/include/inc_template.php";

$script_part = $_GET['fu']+0;

$webpath = explode("/",strrev($_SERVER["REQUEST_URI"]),2);
$webpath = strrev($webpath[1]);
set_template($webpath,"",dirname(__FILE__));

if($script_part == 1){
        $step_description = 'Angaben zum Server';
}
else{
        $step_description = $_POST['what'];
}

$template->assign_vars(array('page_title'=> 'Installation',
                             'install_step' => $script_part,
                             'step_description' => $step_description));

if ($script_part == 1)
{
        $template->assign_block_vars('install_fu1',array());
}

if ($script_part == 2){
        $serverpath = $_POST["serverpath"];
        //include scrupel conf (why did he use his own db things then?)
        if(!is_file($serverpath."/inc.conf.php")){
                //the path is wrong
                $template->assign_block_vars('install_fu2',array('serverpath' => $_POST['serverpath'],
                                                                 'serverurl' => $_POST['serverurl'],
                                                                 'sugaurl' => $_POST['sgaurl'],
                                                                 'sprache' => $_POST['sprache'],
                                                                 'anrede' => $_POST['anrede'],
                                                                 'servername' => $_POST['servername'],));
        }
        else{
                include ($serverpath."/inc.conf.php");
                
         
                //Feste Werte
                $reload = "1200";
                $sugaurl = $_POST["sugaurl"]; //<- needs to be url
                $serverurl = $_POST["serverurl"];
                $sprache = $_POST["sprache"];
                $servername = $_POST["servername"];
                $anrede = $_POST["anrede"];
          
                $sugapath = INSTALL_DIR;
                    
                $datei = fopen($sugapath."/include/conf.inc.php", "w");
          
                if ($datei != false){
                        fwrite($datei, '<?php'."\n");
                        fwrite($datei, "//Konfiguration für die SUGA\n");
                        fwrite($datei, '$serverpath = "'.$serverpath.'";'."\n");
                        fwrite($datei, '$serverurl = "'.$serverurl.'";'."\n");
                        fwrite($datei, '$sugapath = "'.$sugapath.'";'."\n");
                        fwrite($datei, '$sugaurl = "'.$sugaurl.'";'."\n");
                        fwrite($datei, '$language = "'.$sprache.'";'."\n");
                        fwrite($datei, '$servername = "'.$servername.'";'."\n");
                        fwrite($datei, '$anrede = "'.$anrede.'";'."\n");
                        fwrite($datei, '$reload = "'.$reload.'";'."\n");
                        fwrite($datei, 'include ($sugapath."/include/templates.inc.php");'."\n");
                        fwrite($datei, 'include ($sugapath."/include/inc_template.php");'."\n");
                        fwrite($datei, 'include ($sugapath."/lang/$language.lang.php");'."\n");
                        fwrite($datei, 'include ($sugapath."/include/db_mysql.inc.php");'."\n");
                        fwrite($datei, 'include ($serverpath."/inc.conf.php");'."\n");
                        fwrite($datei, '$DB = new db_sql($server,$database,$login,$password);'."\n");
                        fwrite($datei, '?>');
                        fclose($datei);
                        $meldung = "Die Datei 'conf.inc.php' wurde auf dem Server gespeichert.";
                }
                else{
                        $meldung = "Die Datei 'conf.inc.php' kann nicht geöffnet oder erstellt werden.";
                }
                
                include ($sugapath."/include/db_mysql.inc.php");
                $DB = new db_sql;
                
                $sql="
                        CREATE TABLE skrupel_sugaspiele (
                        id int(11) NOT NULL auto_increment,
                        spiel_name varchar(255) NOT NULL default '',
                        siegbedingungen int(11) NOT NULL default '0',
                        zielinfo_1 varchar(255) NOT NULL default '',
                        zielinfo_2 varchar(255) NOT NULL default '',
                        zielinfo_3 varchar(255) NOT NULL default '',
                        zielinfo_4 varchar(255) NOT NULL default '',
                        zielinfo_5 varchar(255) NOT NULL default '',
                        user_1 varchar(255) NOT NULL default '',
                        user_2 varchar(255) NOT NULL default '',
                        user_3 varchar(255) NOT NULL default '',
                        user_4 varchar(255) NOT NULL default '',
                        user_5 varchar(255) NOT NULL default '',
                        user_6 varchar(255) NOT NULL default '',
                        user_7 varchar(255) NOT NULL default '',
                        user_8 varchar(255) NOT NULL default '',
                        user_9 varchar(255) NOT NULL default '',
                        user_10 varchar(255) NOT NULL default '',
                        rasse_1 varchar(255) NOT NULL default '',
                        rasse_2 varchar(255) NOT NULL default '',
                        rasse_3 varchar(255) NOT NULL default '',
                        rasse_4 varchar(255) NOT NULL default '',
                        rasse_5 varchar(255) NOT NULL default '',
                        rasse_6 varchar(255) NOT NULL default '',
                        rasse_7 varchar(255) NOT NULL default '',
                        rasse_8 varchar(255) NOT NULL default '',
                        rasse_9 varchar(255) NOT NULL default '',
                        rasse_10 varchar(255) NOT NULL default '',
                        spieler_admin int(11) NOT NULL default '',
                        startposition int(11) NOT NULL default '',
                        imperiumgroesse int(11) NOT NULL default '',
                        geldmittel int(11) NOT NULL default '',
                        mineralienhome int(11) NOT NULL default '',
                        sternendichte int(11) NOT NULL default '',
                        mineralien int(11) NOT NULL default '',
                        spezien int(11) NOT NULL default '',
                        max int(11) NOT NULL default '',
                        wahr int(11) NOT NULL default '',
                        lang int(11) NOT NULL default '',
                        instabil int(11) NOT NULL default '',
                        stabil int(11) NOT NULL default '',
                        leminvorkommen int(11) NOT NULL default '',
                        umfang int(11) NOT NULL default '',
                        struktur varchar(255) NOT NULL default '',
                        modul_0 int(11) NOT NULL default '',
                        modul_2 int(11) NOT NULL default '',
                        team1 int(11) NOT NULL default '0',
                        team2 int(11) NOT NULL default '0',
                        team3 int(11) NOT NULL default '0',
                        team4 int(11) NOT NULL default '0',
                        team5 int(11) NOT NULL default '0',
                        team6 int(11) NOT NULL default '0',
                        team7 int(11) NOT NULL default '0',
                        team8 int(11) NOT NULL default '0',
                        team9 int(11) NOT NULL default '0',
                        team10 int(11) NOT NULL default '0',
                        nebel int(11) NOT NULL default '',
                        piraten_mitte int(11) NOT NULL default '0',
                        piraten_aussen int(11) NOT NULL default '0',
                        piraten_min int(11) NOT NULL default '0',
                        piraten_max int(11) NOT NULL default '0',
                        playable int(11) NOT NULL default '0',
                        PRIMARY KEY  (id)
                        ) TYPE=MyISAM;
                        ";
                $DB->query($sql);
                
                $sql="
                        CREATE TABLE skrupel_sugacounter (
                        ID int(10) unsigned NOT NULL auto_increment,
                        USER int NOT NULL default '0',
                        DATETIME int(100) NOT NULL default '0',
                        PRIMARY KEY  (id)
                        ) TYPE=MyISAM;
                ";
                
                $DB->query($sql);
                $template->assign_block_vars('install_fu3',array('message' => $message,
                                                                 'message2' => 'Tabellen wurden erstellt, SUGA ist jetzt installiert'));
        }
}
$template->pparse('xhtmlhead');
$template->pparse('installation');
?>
Return current item: Skrupel User Game Administration