Fix error on install

This commit is contained in:
Laurent Destailleur 2009-01-25 17:56:42 +00:00
parent c3adbb11fe
commit 68d4f9c693
9 changed files with 103 additions and 90 deletions

View File

@ -73,7 +73,7 @@ if ($db->ok == 1)
{
print '<br>';
print '<div class="error">'.$langs->trans("PasswordsMismatch").'</div>';
$err=1;
$err=0; // We show button
}
if (isset($_GET["error"]) && $_GET["error"] == 2)
@ -82,14 +82,14 @@ if ($db->ok == 1)
print '<div class="error">';
print $langs->trans("PleaseTypePassword");
print '</div>';
$err=1;
$err=0; // We show button
}
if (isset($_GET["error"]) && $_GET["error"] == 3)
{
print '<br>';
print '<div class="error">'.$langs->trans("PleaseTypeALogin").'</div>';
$err=1;
$err=0; // We show button
}
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien DiCintio <sdicintio@ressource-toi.org>
*
@ -56,9 +56,9 @@ dolibarr_install_syslog("Fileconf: Entering fileconf.php page");
pHeader($langs->trans("ConfigurationFile"),"etape0");
if ($force_install_message_doliwamp)
if (! empty($force_install_message_doliwamp))
{
print $langs->trans("KeepDefaultValues").'<br>';
print $langs->trans("KeepDefaultValues").'<br>';
}
?>
@ -118,7 +118,7 @@ print $langs->trans("Examples").":<br>";
<td valign="top" class="label"><b>
<?php print $langs->trans("DocumentsDirectory"); ?>
</b></td>
<?php
<?php
if (empty($dolibarr_main_data_root))
{
// Si le repertoire documents non defini, on en propose un par defaut
@ -149,7 +149,7 @@ print $langs->trans("Examples").":<br>";
<td valign="top" class="label"><b>
<?php echo $langs->trans("URLRoot"); ?>
</b></td><td valign="top" class="label"><input type="text" size="60" name="main_url" value="
<?php
<?php
if (isset($main_url) && $main_url)
$dolibarr_main_url_root=$main_url;
if (! isset($dolibarr_main_url_root) || strlen($dolibarr_main_url_root) == 0)
@ -164,7 +164,7 @@ if (! isset($dolibarr_main_url_root) || strlen($dolibarr_main_url_root) == 0)
}
# Si SCRIPT_URI, SERVER_URL, DOCUMENT_URI non d<>fini (Ex: Apache 2.0.44 pour Windows)
else
{
{
$proto='http';
if (! empty($_SERVER["HTTP_HOST"])) $serverport=$_SERVER["HTTP_HOST"];
else $serverport=$_SERVER["SERVER_NAME"];
@ -230,7 +230,7 @@ while (($file = readdir($handle))!==false)
if ($type=='mysqli') { $versionbasemin=array(4,1,0); $testfunction='mysqli_connect'; }
if ($type=='pgsql') { $versionbasemin=array(8,1,0); $testfunction='pg_connect'; }
if ($type=='mssql') { $versionbasemin=array(2000); $testfunction='mssql_connect'; }
// Remarques
$note='';
if ($type=='mysql') $note='(Mysql >= '.versiontostring($versionbasemin).')';
@ -339,7 +339,7 @@ while (($file = readdir($handle))!==false)
<?php echo $langs->trans("CreateUser"); ?>
</td>
<td class="label" valign="top"><input type="checkbox" name="db_create_user"<?php if ($force_install_createuser) print ' checked="on"'; ?>></td>
<td class="label" valign="top"><input type="checkbox" name="db_create_user"<?php if (! empty($force_install_createuser)) print ' checked="on"'; ?>></td>
<td class="comment">
<?php echo $langs->trans("CheckToCreateUser"); ?>
</td>
@ -379,6 +379,7 @@ while (($file = readdir($handle))!==false)
<?php
pFooter($err,$setuplang);
$db->close();
pFooter($err,$setuplang);
?>

View File

@ -107,6 +107,7 @@ if (! defined('DONOTLOADCONF') && file_exists($conffile))
$includeconferror='ErrorBadFormatForConfFile';
}
}
$conf->global->MAIN_LOGTOHTML=1;
// Define prefix
@ -294,7 +295,7 @@ function pFooter($nonext=0,$setuplang='')
print '</form>'."\n";
// If there is some logs in buffer to show
if (sizeof($conf->logbuffer))
if (isset($conf->logbuffer) && sizeof($conf->logbuffer))
{
print "\n";
print "<!-- Start of log output\n";

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -43,13 +43,14 @@ dolibarr_install_syslog("Licence: Entering licence.php page");
pHeader($langs->trans("License"),"fileconf");
//print '<pre style="align: center; font-size: 12px">';
$result=$langs->print_file("html/gpl.html",1);
if (! $result)
{
print '<center>'."\n";
print '<textarea readonly="1" rows="26" cols="80">';
$langs->print_file("html/gpl.txt",1);
$result=$langs->print_file("html/gpl.txt",1);
print '</textarea>';
print '</center>'."\n";
}

View File

@ -224,6 +224,7 @@ class DoliDb
*/
function close()
{
dolibarr_syslog("DoliDB::disconnect",LOG_DEBUG);
return mssql_close($this->db);
}
@ -371,7 +372,7 @@ class DoliDb
$result = mssql_query("SELECT @@ERROR as code", $this->db);
$row = mssql_fetch_array($result);
$this->lasterror = $this->error();
$this->lasterrno = $row["code"];
}
@ -557,7 +558,7 @@ class DoliDb
$date=dolibarr_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4));
return $date;
}
/**
* \brief Convert (by PHP) a GM Timestamp date into a GM string date to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica
@ -568,7 +569,7 @@ class DoliDb
{
return adodb_strftime("%Y%m%d%H%M%S",$param,true);
}*/
/**
* \brief Convert (by PHP) a GM string date into a GM Timestamps date
* \param string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
@ -671,7 +672,7 @@ class DoliDb
1217 => 'DB_ERROR_CHILD_EXISTS',
1451 => 'DB_ERROR_CHILD_EXISTS'
);
if (isset($errorcode_map[$this->lasterrno]))
{
return $errorcode_map[$this->lasterrno];

View File

@ -269,6 +269,7 @@ class DoliDb
*/
function close()
{
dolibarr_syslog("DoliDB::disconnect",LOG_DEBUG);
return mysql_close($this->db);
}

View File

@ -48,7 +48,7 @@ class DoliDb
var $versionmin=array(4,1,0);
//! Resultset of last request
var $results;
//! 1 if connected, 0 else
//! 1 if connected, 0 else
var $connected;
//! 1 if database selected, 0 else
var $database_selected;
@ -162,7 +162,7 @@ class DoliDb
{
// Pas de selection de base demandee, ok ou ko
$this->database_selected = 0;
if ($this->connected)
{
// If client connected with different charset than Dolibarr HTML output
@ -275,6 +275,7 @@ class DoliDb
*/
function close()
{
dolibarr_syslog("DoliDB::disconnect",LOG_DEBUG);
return mysqli_close($this->db);
}
@ -562,7 +563,7 @@ class DoliDb
$date=dolibarr_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4));
return $date;
}
/**
* \brief Convert (by PHP) a GM Timestamp date into a GM string date to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica
@ -573,7 +574,7 @@ class DoliDb
{
return adodb_strftime("%Y%m%d%H%M%S",$param,true);
}*/
/**
* \brief Convert (by PHP) a GM string date into a GM Timestamps date
* \param string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
@ -677,7 +678,7 @@ class DoliDb
1217 => 'DB_ERROR_CHILD_EXISTS',
1451 => 'DB_ERROR_CHILD_EXISTS'
);
if (isset($errorcode_map[mysqli_errno($this->db)]))
{
return $errorcode_map[mysqli_errno($this->db)];
@ -744,7 +745,7 @@ class DoliDb
{
if (empty($charset)) $charset=$this->forcecharset;
if (empty($collation)) $collation=$this->collation;
// ALTER DATABASE dolibarr_db DEFAULT CHARACTER SET latin DEFAULT COLLATE latin1_swedish_ci
$sql = 'CREATE DATABASE '.$database;
$sql.= ' DEFAULT CHARACTER SET '.$charset.' DEFAULT COLLATE '.$collation;

View File

@ -55,7 +55,7 @@ class DoliDb
var $ok;
var $error;
var $lasterror;
/**
@ -142,7 +142,7 @@ class DoliDb
return $this->ok;
}
/**
* \brief Convert a SQL request in mysql syntax to database syntax
* \param line SQL request line to convert
@ -151,7 +151,7 @@ class DoliDb
function convertSQLFromMysql($line)
{
# comments or empty lines
if (eregi('^-- \$Id',$line)) {
if (eregi('^-- \$Id',$line)) {
return '';
}
# comments or empty lines
@ -162,12 +162,12 @@ class DoliDb
if ($create_sql != "")
{ # we are inside create table statement so lets process datatypes
if (eregi('(ISAM|innodb)',$line)) { # end of create table sequence
$line=eregi_replace('\) *type=(MyISAM|innodb);',');');
$line=eregi_replace('\) *engine=(MyISAM|innodb);',');');
}
$line=eregi_replace('\) *type=(MyISAM|innodb);',');');
$line=eregi_replace('\) *engine=(MyISAM|innodb);',');');
}
# int, auto_increment -> serial
// } elsif (/^[\s\t]*(\w*)\s*.*int.*auto_increment/i) {
// } elsif (/^[\s\t]*(\w*)\s*.*int.*auto_increment/i) {
// $seq = qq~${table}_${1}_seq~;
// s/[\s\t]*([a-zA-Z_0-9]*)\s*.*int.*auto_increment[^,]*/ $1 SERIAL PRIMARY KEY/ig;
// $create_sql.=$_;
@ -186,44 +186,44 @@ class DoliDb
s/\w*int\(\d+\)/$out/g;
}
*/
$line=eregi_replace('tinyint','smallint');
$line=eregi_replace('tinyint','smallint');
# nuke unsigned
if (eregi_replace('(int\w+|smallint)\s+unsigned','smallint',$reg))
{
$line=eregi_replace('(int\w+|smallint)\s+unsigned',$reg[1]);
$line=eregi_replace('(int\w+|smallint)\s+unsigned',$reg[1]);
}
# blob -> text
$line=eregi_replace('\w*blob','text');
$line=eregi_replace('\w*blob','text');
# tinytext/mediumtext -> text
$line=eregi_replace('tinytext','text');
$line=eregi_replace('mediumtext','text');
$line=eregi_replace('tinytext','text');
$line=eregi_replace('mediumtext','text');
# char -> varchar
# PostgreSQL would otherwise pad with spaces as opposed
# to MySQL! Your user interface may depend on this!
// s/(\s+)char/${1}varchar/gi;
# nuke date representation (not supported in PostgreSQL)
// s/datetime default '[^']+'/datetime/i;
// s/date default '[^']+'/datetime/i;
// s/time default '[^']+'/datetime/i;
# change not null datetime field to null valid ones
# (to support remapping of "zero time" to null
$line=eregi_replace('datetime not null','datetime');
$line=eregi_replace('datetime','timestamp');
$line=eregi_replace('datetime not null','datetime');
$line=eregi_replace('datetime','timestamp');
# nuke size of timestamp
// s/timestamp\([^)]*\)/timestamp/i;
# double -> real
// s/^double/real/i;
// s/(\s*)double/${1}real/i;
# unique key(field1,field2)
/* if (/unique key\s*\((\w+\s*,\s*\w+)\)/i) {
s/unique key\s*\((\w+\s*,\s*\w+)\)/UNIQUE\($1\)/i;
@ -237,7 +237,7 @@ class DoliDb
$create_sql.=$_;
next;
}
*/
*/
# unique key [name] (field)
/* if (/unique key\s*(\w*)\s*\((\w+)\)/i) {
s/unique key\s*(\w*)\s*\((\w+)\)/UNIQUE\($2\)/i;
@ -266,30 +266,30 @@ class DoliDb
$create_index .= "CREATE INDEX $idxname ON $table ($fieldlist);\n";
next;
}
*/
*/
# index(field)
/* if (/index\s*(\w*)\s*\((\w+)\)/i) {
my $idxname=($1?"$1":"idx_${table}_$2");
$create_index .= "CREATE INDEX $idxname ON $table ($2);\n";
next;
}
*/
*/
# primary key
/* if (/\bkey\b/i && !/^\s+primary key\s+/i) {
s/KEY(\s+)[^(]*(\s+)/$1 UNIQUE $2/i; # hack off name of the non-primary key
}
*/
*/
# key(xxx)
/* if (/key\s*\((\w+)\)/i) {
my $idxname="idx_${table}_$1";
$create_index .= "CREATE INDEX $idxname ON $table ($1);\n";
next;
}
*/
*/
# Quote column names
/* s/(^\s*)([^\s\-\(]+)(\s*)/$1"$2"$3/gi if (!/\bkey\b/i);
*/
# Remap colums with names of existing system attribute
*/
# Remap colums with names of existing system attribute
/* if (/"oid"/i) {
s/"oid"/"_oid"/g;
print STDERR "WARNING: table $table uses column \"oid\" which is renamed to \"_oid\"\nYou should fix application manually! Press return to continue.";
@ -309,13 +309,13 @@ class DoliDb
s!\x85!... !g; # \ldots
s!\x92!`!g;
}
*/
*/
# fix dates '0000-00-00 00:00:00' (should be null)
/* s/'0000-00-00 00:00:00'/null/gi;
s/'0000-00-00'/null/gi;
s/'00:00:00'/null/gi;
s/([12]\d\d\d)([01]\d)([0-3]\d)([0-2]\d)([0-6]\d)([0-6]\d)/'$1-$2-$3 $4:$5:$6'/;
if (/create\s+table\s+(\w+)/i) {
$create_sql = $_;
/create\s*table\s*(\w+)/i;
@ -325,11 +325,11 @@ class DoliDb
}
*/
} # end of if inside create_table
return $line;
}
/**
\brief Selectionne une database.
\param database nom de la database
@ -396,7 +396,7 @@ class DoliDb
}
return $vlist[0].$vlist[1].$vlist[2];
}
/**
\brief Renvoie la version du serveur dans un tableau
\return array Tableau de chaque niveau de version
@ -412,7 +412,8 @@ class DoliDb
*/
function close()
{
return pg_close($this->db);
dolibarr_syslog("DoliDB::disconnect",LOG_DEBUG);
return pg_close($this->db);
}
@ -448,7 +449,7 @@ class DoliDb
if ($this->transaction_opened<=1)
{
$ret=$this->query("COMMIT;");
if ($ret)
if ($ret)
{
$this->transaction_opened=0;
dolibarr_syslog("COMMIT Transaction",LOG_DEBUG);
@ -491,11 +492,11 @@ class DoliDb
function query($query)
{
$query = trim($query);
if ($this->forcecharset=="UTF-8"){
$buffer=utf8_encode ($buffer);
}
$ret = pg_query($this->db, $query);
$ret = pg_query($this->db, $query);
if (! eregi("^COMMIT",$query) && ! eregi("^ROLLBACK",$query))
{
// Si requete utilisateur, on la sauvegarde ainsi que son resultset
@ -622,7 +623,7 @@ class DoliDb
{
if (! $return) $return.=' ORDER BY ';
else $return.=',';
$return.=$val;
if ($sortorder) $return.=' '.$sortorder;
}
@ -633,8 +634,8 @@ class DoliDb
return '';
}
}
/**
\brief Escape a string to insert data.
\param stringtoencode String to escape
@ -682,7 +683,7 @@ class DoliDb
$date=dolibarr_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4));
return $date;
}
/**
* \brief Convert (by PHP) a GM Timestamp date into a GM string date to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica
@ -693,7 +694,7 @@ class DoliDb
{
return adodb_strftime("%Y%m%d%H%M%S",$param,true);
}*/
/**
* \brief Convert (by PHP) a GM string date into a GM Timestamps date
* \param string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
@ -707,7 +708,7 @@ class DoliDb
$date=dolibarr_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),1);
return $date;
}*/
/**
* \brief Formatage d'un if SQL
* \param test chaine test
@ -834,7 +835,7 @@ class DoliDb
{
if (empty($charset)) $charset=$this->forcecharset;
if (empty($collation)) $collation=$this->collation;
$ret=$this->query('CREATE DATABASE '.$database.' OWNER '.$this->db_user.' ENCODING \''.$charset.'\' ;');
return $ret;
}
@ -850,7 +851,7 @@ class DoliDb
return $this->results;
}
/**
\brief Create a user
\param dolibarr_main_db_host Ip serveur
@ -869,28 +870,28 @@ class DoliDb
{
return -1;
}
return 1;
}
function getDefaultCharacterSetDatabase(){
$resql=$this->query('SHOW SERVER_ENCODING');
$liste=$this->fetch_array($resql);
return $liste['server_encoding'];
}
function getListOfCharacterSet(){
$resql=$this->query('SHOW CHARSET');
$liste = array();
if ($resql)
if ($resql)
{
$i = 0;
while ($obj = $this->fetch_object($resql) )
{
$liste[$i]['charset'] = $obj->Charset;
$liste[$i]['description'] = $obj->Description;
$i++;
}
$i++;
}
$this->free($resql);
} else {
// version Mysql < 4.1.1
@ -898,7 +899,7 @@ class DoliDb
}
return $liste;
}
function getDefaultCollationDatabase(){
$resql=$this->query('SHOW VARIABLES LIKE \'collation_database\'');
if (!$resql)
@ -909,18 +910,18 @@ class DoliDb
$liste=$this->fetch_array($resql);
return $liste['Value'];
}
function getListOfCollation(){
$resql=$this->query('SHOW COLLATION');
$liste = array();
if ($resql)
if ($resql)
{
$i = 0;
while ($obj = $this->fetch_object($resql) )
{
$liste[$i]['collation'] = $obj->Collation;
$i++;
}
$i++;
}
$this->free($resql);
} else {
// version Mysql < 4.1.1
@ -928,6 +929,6 @@ class DoliDb
}
return $liste;
}
}
?>

View File

@ -522,10 +522,12 @@ class Translate {
{
global $conf;
// Test si fichier dans repertoire de la langue
// Test if file is in lang directory
foreach($this->dir as $searchdir)
{
$htmlfile=($searchdir."/langs/".$this->defaultlang."/".$filename);
dolibarr_syslog('Translate::print_file search file '.$htmlfile, LOG_DEBUG);
if (is_readable($htmlfile))
{
$content=file_get_contents($htmlfile);
@ -535,20 +537,24 @@ class Translate {
else print $content;
return true;
}
else dolibarr_syslog('Translate::print_file not found', LOG_DEBUG);
if ($searchalt) {
// Test si fichier dans repertoire de la langue alternative
if ($this->defaultlang != "en_US") $htmlfilealt = $searchdir."/en_US/".$filename;
if ($this->defaultlang != "en_US") $htmlfilealt = $searchdir."/langs/en_US/".$filename;
else $htmlfilealt = $searchdir."/langs/fr_FR/".$filename;
if (is_readable($htmlfilealt))
dolibarr_syslog('Translate::print_file search alt file '.$htmlfilealt, LOG_DEBUG);
//print 'getcwd='.getcwd().' htmlfilealt='.$htmlfilealt.' X '.file_exists(getcwd().'/'.$htmlfilealt);
if (is_readable($htmlfilealt))
{
$content=file_get_contents($htmlfile);
$content=file_get_contents($htmlfilealt);
$isutf8=utf8_check($content);
if (! $isutf8 && $conf->character_set_client == 'UTF-8') print utf8_encode($content);
elseif ($isutf8 && $conf->character_set_client == 'ISO-8859-1') print utf8_decode($content);
else print $content;
return true;
}
else dolibarr_syslog('Translate::print_file not found', LOG_DEBUG);
}
}