Location: PHPKode > projects > phpAWE > phpAWE.0.4.beta.demo-page/install/index.php
<?php

function parse_mysql_dump($url) {
   
    $handle = @fopen($url, "r");
    $query = "";
    while(!feof($handle)) {

        $query = fgets($handle);
        $result = mysql_query($query) or die(mysql_error());
        $query = "";    
    } 
}


if (!$_POST) {
    echo "<h1>phpAWE demo page installation</h1>";
    echo "<p>Enter required information</p>";
    echo "<form method=\"post\" action=\"index.php\">";
    echo "<table>";
    echo "<tr>";
    echo "<td>MySql database name (must exist)</td>";
    echo "<td><input type=\"text\" name=\"db_name\" /></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>admin login (in this release may be skipped)</td>";
    echo "<td><input type=\"text\" name=\"adm_login\" /></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>admin password (in this release may be skipped)</td>";
    echo "<td><input type=\"text\" name=\"adm_passwd\" /></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>user login (only SELECT permission required)</td>";
    echo "<td><input type=\"text\" name=\"usr_login\" /></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>user password (only SELECT permission required)</td>";
    echo "<td><input type=\"text\" name=\"usr_passwd\" /></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td></td>";
    echo "<td><input type=\"submit\" name=\"zapisz\" / value=\"save\"></td>";
    echo "</tr>";
    echo "</table>";
    echo "</form>";
}
else {

    $adm_config = "<?php
                   \$db_address  = \"localhost\";
                   \$db_username = \"$_POST[adm_login]\";
                   \$db_password = \"$_POST[adm_passwd]\";
                   \$db_database = \"$_POST[db_name]\";
                   ?>";
                   
    $usr_config = "<?php
                   \$db_address  = \"localhost\";
                   \$db_username = \"$_POST[usr_login]\";
                   \$db_password = \"$_POST[usr_passwd]\";
                   \$db_database = \"$_POST[db_name]\"
                   ?>";
                   
    $db_handle = mysql_connect('localhost', $_POST[adm_login], $_POST[adm_passwd]);
    if (!$db_handle) {
        die('Error while connecting database: ' . mysql_error());
    }
          @mysql_query("SET NAMES latin2");
          @mysql_query("SET collation_connection = latin2_general_ci");
          @mysql_query("SET CHARACTER SET latin2");
          @mysql_query("set character_set_connection=latin2");
          @mysql_query("set character_set_client=latin2");
          @mysql_query("set character_set_database=latin2");
          @mysql_query("set character_set_results=latin2");
          @mysql_query("set character_set_server=latin2");
          @mysql_query("set collation_database=latin2_general_ci");
          @mysql_query("set collation_server=latin2_general_ci"); 
    
    mysql_select_db($_POST[db_name]) 
        or die('Error while selecting database: ' . mysql_error());
            
    parse_mysql_dump("data/awe.sql");
       
    if (!copy('data/index.php', '../index.php')) 
        die('File copy failed');
        
    if (!copy('data/fol-demo.php', '../fol-demo.php')) 
        die('File copy failed');
        
    $usr_config_file = fopen("../awe/config/db.php","w");
    fwrite($usr_config_file, $usr_config);
    fclose($usr_config_file);  
        
    $adm_config_file = fopen("../awe/aweManager/config/db.php","w");
    fwrite($adm_config_file, $adm_config);
    fclose($adm_config_file);
    
    echo "installation succesfull</br>";
    echo "<a href=\"../index.php\">Go to main page</a>";  
 
    


}
?>
Return current item: phpAWE