Your IP : 216.73.217.64


Current Path : /home3/gp97/docs.sapat20172020.97gp.net/php/
Upload File :
Current File : //home3/gp97/docs.sapat20172020.97gp.net/php/install.php

<?php

if (file_exists("dbconfig.php")) {
  header ("Location: index.php");
  exit;
 }

header("Content-Type: text/html; charset=UTF-8");
define("TABLE_PREFIX","dm_");

require_once("lang.php");
require_once("functions.php");

$mysql_server = isset($_POST["mysql_server"]) ? trim($_POST["mysql_server"]) : "localhost";
$mysql_database = isset($_POST["mysql_database"]) ? trim($_POST["mysql_database"]) : "dmanager";
$mysql_createdatabase = isset($_POST["mysql_createdatabase"]) ? trim($_POST["mysql_createdatabase"]) : 0;
$mysql_user = isset($_POST["mysql_user"]) ? trim($_POST["mysql_user"]) : "dmanager";
$mysql_pass = isset($_POST["mysql_pass"]) ? trim($_POST["mysql_pass"]) : "";

$admin_login = isset($_POST["admin_login"]) ? trim($_POST["admin_login"]) : "admin";
$admin_pwd = isset($_POST["admin_pwd"]) ? trim($_POST["admin_pwd"]) : "";
$admin_mail = isset($_POST["admin_mail"]) ? trim($_POST["admin_mail"]) : "";

$error = "";

function stage2() {
  global $error;
  global $mysql_server, $mysql_database, $mysql_createdatabase, $mysql_user, $mysql_pass, $admin_login, $admin_pwd, $admin_mail;
  
  if (empty($mysql_server) || empty($mysql_database) || empty($mysql_user) || empty($admin_login) || empty($admin_pwd)) {
      $error = _l("You forgot to fill some fields.");
      return;
  }
  
  if (@mysql_connect($mysql_server, $mysql_user, $mysql_pass) === false) {
    $error = _l("Cannot connect to the MySQL server:") ." ". mysql_error();
    return;
  }
  
  if ($mysql_createdatabase) {
    $res = mysql_query("CREATE DATABASE " . $mysql_database);
    if ($res === false) {
      $error = _l("An error occurred while creating the database:"). " " . mysql_error();
      return;
    }
  }
  
  if (mysql_select_db($mysql_database) === false) {
    $error = _l("Cannot connect to the database:"). " ". $mysql_database . " : " . mysql_error();
    return;
  }
  
  $query = "DROP TABLE IF EXISTS `".TABLE_PREFIX."config`";
  $res = mysql_query($query);
  
  $query = "DROP TABLE IF EXISTS `".TABLE_PREFIX."extensions`";
  $res = mysql_query($query);
  
  $query = "DROP TABLE IF EXISTS `".TABLE_PREFIX."files`";
  $res = mysql_query($query);
  
  $query = "DROP TABLE IF EXISTS `".TABLE_PREFIX."folders`";
  $res = mysql_query($query);
  
  $query = "DROP TABLE IF EXISTS `".TABLE_PREFIX."users`";
  $res = mysql_query($query);
  
  $query = "DROP TABLE IF EXISTS `".TABLE_PREFIX."rights`";
  $res = mysql_query($query);
  
  $query = "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."config` ("
    . "`conf_lang` varchar(10) NOT NULL default '',"
    . "`conf_adminmail` varchar(100) NOT NULL default '',"
    . "`conf_mailcondition` tinyint(4) NOT NULL default '0',"
    . "`conf_sendrecipient` tinyint(4) NOT NULL default '0',"
    . "`conf_showhelpbutton` tinyint(4) NOT NULL default '0',"
    . "`conf_shcom` tinyint(4) NOT NULL default '0',"
    . "`conf_style` varchar(100) NOT NULL default ''"
    . ") ENGINE=MyISAM;";
  
  $res = mysql_query($query);
  
  if ($res === false) {
    $error = _l("An error occurred while creating the table") . " ".TABLE_PREFIX."config : " . mysql_error();
    return;
  }
  
  $query = "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."extensions` ("
    . "`ext_short` varchar(10) NOT NULL default '',"
    . "`ext_mime` varchar(255) NOT NULL default '',"
    . "`ext_desc` varchar(255) NOT NULL default '',"
    . "PRIMARY KEY  (`ext_short`)"
    . ") ENGINE=MyISAM;";
  $res = mysql_query($query);
  
  if ($res === false) {
    $error = _l("An error occurred while creating the table") . " ".TABLE_PREFIX."extensions : " . mysql_error();
    return;
  }
  
  $query = "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."files` ("
    . "`id_file` int(11) NOT NULL auto_increment,"
    . "`id_folder` int(11) NOT NULL default '0',"
    . "`id_user` int(11) NOT NULL default '0',"
    . "`file_name` varchar(255) NOT NULL default '',"
    . "`file_size` int(11) NOT NULL default '0',"
    . "`file_mtime` datetime NOT NULL default '0000-00-00 00:00:00',"
    . "`file_comment` text NOT NULL,"
    . "`file_flag` tinyint(4) NOT NULL default '0',"
    . "PRIMARY KEY  (`id_file`),"
    . "KEY `id_folder` (`id_folder`)"
    . ") ENGINE=MyISAM AUTO_INCREMENT=10 AUTO_INCREMENT=10 ;";
  $res = mysql_query($query);
  
  if ($res === false) {
    $error = _l("An error occurred while creating the table") . " ".TABLE_PREFIX."files : " . mysql_error();
    return;
  }
  
  $query = "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."folders` ("
    . "`id_folder` int(11) NOT NULL auto_increment,"
    . "`id_parent` int(11) NOT NULL default '0',"
    . "`folder_path` text NOT NULL,"
    . "`folder_name` varchar(255) NOT NULL default '',"
    . "`folder_size` int(11) NOT NULL default '0',"
    . "`folder_mtime` datetime NOT NULL default '0000-00-00 00:00:00',"
    . "`folder_comment` text NOT NULL,"
    . "PRIMARY KEY  (`id_folder`),"
    . "KEY `id_parent` (`id_parent`)"
    . ") ENGINE=MyISAM AUTO_INCREMENT=10 AUTO_INCREMENT=10 ;";
  $res = mysql_query($query);
  
  if ($res === false) {
    $error = _l("An error occurred while creating the table") . " ".TABLE_PREFIX."folders : " . mysql_error();
    return;
  }
  
  $query = "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."rights` ("
    . "`id_rights` int(11) NOT NULL auto_increment,"
    . "`id_user` int(11) NOT NULL default '0',"
    . "`id_folder` int(11) NOT NULL default '0',"
    . "`rights` varchar(15) NOT NULL default '',"
    . "PRIMARY KEY  (`id_rights`),"
    . "KEY `id_folder` (`id_folder`)"
    . ") ENGINE=MyISAM AUTO_INCREMENT=18 AUTO_INCREMENT=18 ;";
  $res = mysql_query($query);
  
  if ($res === false) {
    $error = _l("An error occurred while creating the table") . " ".TABLE_PREFIX."rights : " . mysql_error();
    return;
  }
  
  $query = "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."users` ("
    . "`id_user` int(11) NOT NULL auto_increment,"
    . "`user_name` varchar(50) NOT NULL default '',"
    . "`user_password` varchar(32) NOT NULL default '',"
    . "`user_mail` varchar(50) NOT NULL default '',"
    . "`user_admin` tinyint(4) NOT NULL default '0',"
    . "`user_ccp` tinyint(4) NOT NULL default '0',"
    . "`user_showcom` tinyint(4) NOT NULL default '0',"
    . "`user_lastlogin` datetime NOT NULL default '0000-00-00 00:00:00',"
    . "PRIMARY KEY  (`id_user`)"
    . ") ENGINE=MyISAM AUTO_INCREMENT=34 AUTO_INCREMENT=34 ;";
  $res = mysql_query($query);
  
  if ($res === false) {
    $error = _l("An error occurred while creating the table") . " ".TABLE_PREFIX."users: " . mysql_error();
    return;
  }
  
  $query = "INSERT INTO `".TABLE_PREFIX."config` (`conf_lang`, `conf_adminmail`, `conf_mailcondition`, `conf_sendrecipient`, `conf_showhelpbutton`, `conf_shcom`, `conf_style`) VALUES ('fr', 'inscrire votre adresse mail ici', 3, 1, 1, 1, 'stylevert.css');";
  $res = mysql_query($query);
  
  $query = "INSERT INTO `".TABLE_PREFIX."files` (`id_file`, `id_folder`, `id_user`, `file_name`, `file_size`, `file_mtime`, `file_comment`, `file_flag`) VALUES (2, 0, 23, 'test.txt', 48, '2006-10-06 09:59:41', 'Il est sympa cet outil !\r\nje prends !', 0);";
  $res = mysql_query($query);
  
  $query = "INSERT INTO `".TABLE_PREFIX."rights` (`id_rights`, `id_user`, `id_folder`, `rights`) VALUES (11, 29, 0, 'rudfntmcp');";
  $res = mysql_query($query);
  
  $query = "INSERT INTO `".TABLE_PREFIX."users` (`id_user`, `user_name`, `user_password`, `user_mail`, `user_admin`, `user_ccp`, `user_showcom`, `user_lastlogin`) VALUES (29, '" . $admin_login . "', '" . md5($admin_pwd) . "', '".$admin_mail."', 1, 1, 1, '0000-00-00 00:00:00');";
  $res = mysql_query($query);
  
  $configCode  = "<?php\n";
  $configCode .= "/* *************************************************\n";
  $configCode .= " *\n";
  $configCode .= " * Document Manager (C) 2002-2010\n";
  $configCode .= " * Version 4 - dmanager MySQL\n";
  $configCode .= " * Benjamin Sonntag <benjamin@sonntag.fr>\n";
  $configCode .= " * Chantal Bernard-Putz <chantal@bernard-putz.net>\n";
  $configCode .= " * Franck Denis \n";
  $configCode .= " * This software is protected by copyright laws,\n";
  $configCode .= " * please read the file COPYRIGHT\n";
  $configCode .= " * This software is provided as is with no warranty.\n";
  $configCode .= " *\n";
  $configCode .= " ************************************************* */\n";
  $configCode .= "\n";
  $configCode .= "define (\"TABLE_PREFIX\", \"dm_\");\n";
  $configCode .= "\n";
  $configCode .= "\$databaseConfig = array (\n";
  $configCode .= "\t\"server\"   => \"" . $mysql_server . "\",\n";
  $configCode .= "\t\"login\"    => \"" . $mysql_user . "\",\n";
  $configCode .= "\t\"pass\"     => \"" . $mysql_pass . "\",\n";
  $configCode .= "\t\"database\" => \"" . $mysql_database . "\",\n";
  $configCode .= ");\n";
  $configCode .= "\n";
  $configCode .= "if (!mysql_connect(\$databaseConfig[\"server\"], \$databaseConfig[\"login\"], \$databaseConfig[\"pass\"]) || !mysql_select_db(\$databaseConfig[\"database\"]))\n";
  $configCode .= "\tdie (\"Invalid query: \" . mysql_error());\n";
  $configCode .= "\n";
  $configCode .= "?>";
  
  $fp = @fopen("dbconfig.php", "w");
  
  if ($fp) {
    fwrite($fp, $configCode);
    fclose($fp);
    
    sendAnonymousStats(true);

    echo "<p>"._l("Here we are!")."</p><p><a href=\"index.php\">"._l("Click here to connect")."</a></p>";
    die;
  } else {
    $error = _l("The configuration file has not been created. Check that you are allowed to write in the web directory.");
    return;
  }
}

if (isset($_POST["stage2"]))
  stage2();

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
  <head>
  <title><?php echo _l("Document Manager")." - "._l("Install Shield"); ?></title>
<meta name="author" content="Franck DENIS - Eitic" />
  <meta http-equiv="content-type" content="text/html; charset=ISO8859-1" />
  <link rel="stylesheet" type="text/css" href="install.css" />
  </head>
  <body>
  <div>
  <h1><?php echo _l("Document Manager")." - "._l("Install Shield"); ?></h1>
  <p><?php __l("Please fill all the fields below"); ?></p>
  <?php if (isset($error) && !empty($error)) echo "<p class=\"error\">" . $error . "</p>"; ?>
<form action="install.php" method="post" enctype="multipart/form-data">
  <table class="center">
  <tr>
  <td colspan="2" style="text-align: center;"><h2><?php __l("Database configuration"); ?></h2></td>
  </tr>
  <tr>
  <td style="text-align: right;"></td>
  <td><?php __l("Your MySQL server machine name, it's usually 'localhost'"); ?></td>
</tr>
<tr>
  <td style="text-align: right;"><label for="mysql_server"><?php __l("MySQL Server"); ?></label></td>
<td><input type="text" name="mysql_server" id="mysql_server" value="<?php echo $mysql_server; ?>" /></td>
</tr>
<tr>
<td style="text-align: right;"></td>
  <td><?php __l("The name of your database, which should already exist"); ?></td>
</tr>
<tr>
  <td style="text-align: right;"><label for="mysql_database"><?php __l("MySQL database name"); ?></label></td>
<td><input type="text" name="mysql_database" id="mysql_database" value="<?php echo $mysql_database; ?>" /></td>
</tr>
<tr>
  <td style="text-align: right;"><label for="mysql_createdatabase"><?php __l("Create that database"); ?></label></td>
  <td><input type="checkbox" name="mysql_createdatabase" id="mysql_createdatabase" value="1"<?php if ($mysql_createdatabase == 1) echo " checked=\"checked\""; ?>/> <span style="color: red;"><?php __l("Only useful if you need to create the database, and if your user has enough rights"); ?></span></td>
</tr>
<tr>
<td style="text-align: right;"></td>
  <td><?php __l("The login and password of your MySQL user"); ?></td>
</tr>
<tr>
  <td style="text-align: right;"><label for="mysql_user"><?php __l("MySQL Username"); ?></label></td>
<td><input type="text" name="mysql_user" id="mysql_user" value="<?php echo $mysql_user; ?>" /></td>
</tr>
<tr>
  <td style="text-align: right;"><label for="mysql_pass"><?php __l("MySQL Password"); ?></label></td>
<td><input type="password" name="mysql_pass" id="mysql_pass" value="" /></td>
</tr>

<tr>
  <td colspan="2" style="text-align: center;"><h2><?php __l("Identity of the Document Manager administrator"); ?></h2></td>
</tr>

<tr>
  <td style="text-align: right;"><label for="admin_login"><?php __l("Login"); ?></label></td>
<td><input type="text" name="admin_login" id="admin_login" value="<?php echo $admin_login; ?>" /></td>
</tr>

<tr>
  <td style="text-align: right;"><label for="admin_pwd"><?php __l("Password"); ?></label></td>
<td><input type="password" name="admin_pwd" id="admin_pwd" value="" /></td>
</tr>

<tr>
  <td style="text-align: right;"><label for="admin_mail"><?php __l("Administrator's email"); ?></label></td>
<td><input type="text" name="admin_mail" id="admin_mail" value="<?php echo $admin_mail; ?>" /></td>
</tr>

<tr>
<td colspan="2"><input type="submit" name="stage2" value="<?php __l("Continue"); ?>" /></td>
</tr>
</table>
</form>
<p>&nbsp;</p>
<p>
If you want to use another language, click on the links below <br />
Pour changer de langue, cliquez sur l'un des liens ci-dessous.<br />
</p>
<p>
<a href="?setlang=fr">fr</a>&nbsp;&nbsp;
<a href="?setlang=en">en</a>&nbsp;&nbsp;
<a href="?setlang=es">es</a>&nbsp;&nbsp;
</p>

</div>
</body>
</html>