Location: PHPKode > projects > L-Forum > l-forum/admin/install.php
<?

$nosql = 1;
include "../config.php";
include "../lib/init.inc";

auth();

$head = str_replace("__TITLE__", $lang['administration'], $design['head']);

echo $head;

include "../themes/".$theme."/header.inc";

if(empty($stage_make)){
?>

<div class=header>Database preparation</div>
Choose database settings
<form method=post action="<?echo $PHP_SELF?>">
<input type=hidden name=stage_make value=1>
<table border=0>
<tr>
 <td>Database type</td>
 <td>
  <select name="ndb_type">
   <option value="postgres">PostgreSQL
   <option value="mysql">MySQL
  </select>
 </td>
</tr>
<tr>
 <td>Database hostname</td>
 <td><input type="text" name="ndb_host" value="localhost">
</tr>
<tr>
 <td>Database name</td>
 <td><input type="text" name="ndb_name">
</tr>
<tr>
 <td>Database username</td>
 <td><input type="text" name="ndb_user">
</tr>
<tr>
 <td>Database password</td>
 <td><input type="text" name="ndb_pass">
</tr>
<tr>
 <td>Relative path to L-forum<br>
 <small>i.e. if address to forum is<br>http://your-dom.com/forum/<br>
 set this option to "forum/"</small></td>
 <td valign=top><input type="text" name="nrelpath">
</tr>
<tr>
 <td align="center" colspan=2><input type="submit" value="Set"></td>
</tr>
</table>
</form>
<?
} else {

   $db_name = $ndb_name;
   $db_user = $ndb_user;
   $db_pass = $ndb_pass;
   $db_host = $ndb_host;

   switch($ndb_type){
      case 'postgres':
	 $conn = @pg_connect("dbname=$db_name user=$db_user password=$db_pass");
	 if(!$conn){
	    error("Error while connecting to database. Check configuration options, make sure that database exists, and try again.");
	 }
	 pg_close($conn);
	 $sys_basename = $db_name;
	 $sys_database = new Database();
	 break;
      case 'mysql':
	 $conn = mysql_connect($db_host, $db_user, $db_pass);
	 if(!$conn){
	    error("Error while connecting to database. Check configuration options and try again.");
	 }
	 if(!mysql_select_db($db_name, $conn))
	    error("Can't open database. Check name and make sure that database exists");
	 mysql_close($conn);
	 $sys_basename = $db_name;
	 $sys_database = new MySQLDatabase();
	 break;
   }
   $queries = file("base_".$ndb_type.".sql");
   echo "<table border=0>";
   $count = count($queries);
   for($i=0; $i<$count; $i++){
      echo "<tr><td>";
      switch($i){
	 case 0:
	    echo "Creating table 'articles'";
	    break;
	 case 1:
	    echo "Creating table 'block_ip'";
	    break;
	 case 2:
	    echo "Setting permissions for table 'articles'";
	    break;
	 case 3:
	    echo "Setting permissions for table 'block_ip'";
	    break;
	 case 4:
	    echo "Setting permissions for sequence 'articles_id_seq'";
	    break;
      }
      flush();
      echo "</td><td>";
      $q = new Query($queries[$i]);
      echo "[<font color=Green>OK</font>]</td></tr>";
      flush();
   }
   echo "</table>";
   include "save_db.inc";
}
include "../themes/".$theme."/footer.inc";

echo $design['footer'];

?>

Return current item: L-Forum