2004-10-20 00:24:10 +02:00
< ? php
2009-01-25 18:56:42 +01:00
/* Copyright ( C ) 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2008-02-01 02:01:56 +01:00
* Copyright ( C ) 2004 Eric Seigne < eric . seigne @ ryxeo . com >
2012-10-07 20:04:07 +02:00
* Copyright ( C ) 2004 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
2005-01-08 12:40:21 +01:00
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
* Copyright ( C ) 2004 Sebastien DiCintio < sdicintio @ ressource - toi . org >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2005 - 2011 Regis Houssin < regis . houssin @ capnetworks . com >
2004-02-11 19:08:59 +01:00
*
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2004-02-11 19:08:59 +01:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2011-08-01 01:24:38 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2004-02-11 19:08:59 +01:00
*/
2004-12-04 16:30:14 +01:00
2005-03-24 00:27:50 +01:00
/**
2008-12-05 00:25:48 +01:00
* \file htdocs / install / fileconf . php
* \ingroup install
2010-01-20 18:54:44 +01:00
* \brief Ask all informations required to build Dolibarr htdocs / conf / conf . php file ( will be wrote on disk on next page )
2008-12-05 00:25:48 +01:00
*/
2008-02-01 02:01:56 +01:00
2012-10-07 20:04:07 +02:00
include_once 'inc.php' ;
2005-02-12 22:25:39 +01:00
2005-04-02 22:56:18 +02:00
$err = 0 ;
2012-10-13 13:56:37 +02:00
$setuplang = GETPOST ( " selectlang " , '' , 3 ) ? GETPOST ( " selectlang " , '' , 3 ) : ( isset ( $_GET [ " lang " ]) ? $_GET [ " lang " ] : 'auto' );
2005-10-30 02:07:00 +01:00
$langs -> setDefaultLang ( $setuplang );
2005-02-12 22:25:39 +01:00
$langs -> load ( " install " );
2010-02-04 23:00:51 +01:00
$langs -> load ( " errors " );
2004-02-11 19:08:59 +01:00
2008-04-21 09:21:13 +02:00
dolibarr_install_syslog ( " Fileconf: Entering fileconf.php page " );
2012-12-05 11:18:45 +01:00
// You can force preselected values of the config step of Dolibarr by adding a file
// install.forced.php into directory htdocs/install (This is the case with some wizard
// installer like DoliWamp, DoliMamp or DoliBuntu).
// We first init "forced values" to nothing.
if ( ! isset ( $force_install_noedit )) $force_install_noedit = '' ; // 1=To block var specific to distrib, 2 to block all technical parameters
if ( ! isset ( $force_install_type )) $force_install_type = '' ;
if ( ! isset ( $force_install_dbserver )) $force_install_dbserver = '' ;
if ( ! isset ( $force_install_port )) $force_install_port = '' ;
if ( ! isset ( $force_install_database )) $force_install_database = '' ;
if ( ! isset ( $force_install_prefix )) $force_install_prefix = '' ;
if ( ! isset ( $force_install_createdatabase )) $force_install_createdatabase = '' ;
if ( ! isset ( $force_install_databaselogin )) $force_install_databaselogin = '' ;
if ( ! isset ( $force_install_databasepass )) $force_install_databasepass = '' ;
if ( ! isset ( $force_install_databaserootlogin )) $force_install_databaserootlogin = '' ;
if ( ! isset ( $force_install_databaserootpass )) $force_install_databaserootpass = '' ;
// Now we load forced value from install.forced.php file.
$useforcedwizard = false ;
$forcedfile = " ./install.forced.php " ;
if ( $conffile == " /etc/dolibarr/conf.php " ) $forcedfile = " /etc/dolibarr/install.forced.php " ; // Must be after inc.php
if ( @ file_exists ( $forcedfile )) {
$useforcedwizard = true ; include_once $forcedfile ;
2012-10-07 20:04:07 +02:00
}
//$force_install_message='This is the message';
//$force_install_noedit=1;
2008-04-21 09:21:13 +02:00
2010-09-29 10:09:17 +02:00
2008-04-21 09:21:13 +02:00
/*
2010-09-29 10:09:17 +02:00
* View
*/
2005-10-30 02:07:00 +01:00
2012-12-01 15:45:05 +01:00
session_start (); // To be able to keep info into session (used for not loosing pass during navigation. pass must not transit throug parmaeters)
2012-11-20 11:22:57 +01:00
2012-10-17 14:53:05 +02:00
pHeader ( $langs -> trans ( " ConfigurationFile " ), " etape1 " , " set " , " " ,( empty ( $force_dolibarr_js_JQUERY ) ? '' : $force_dolibarr_js_JQUERY . '/' ));
2004-02-11 19:08:59 +01:00
2010-09-29 10:09:17 +02:00
// Test if we can run a first install process
if ( ! is_writable ( $conffile ))
{
2011-07-30 12:23:24 +02:00
print $langs -> trans ( " ConfFileIsNotWritable " , $conffiletoshow );
2010-09-29 10:09:17 +02:00
pFooter ( 1 , $setuplang , 'jscheckparam' );
exit ;
}
2009-10-29 23:28:03 +01:00
if ( ! empty ( $force_install_message ))
2008-05-17 16:56:06 +02:00
{
2012-10-07 20:04:07 +02:00
print '<div><table><tr><td valign="middle"><img src="../theme/common/information.png" style="height:40px;"></td><td valign="middle">' . $langs -> trans ( $force_install_message ) . '</td></tr></table>' ;
/* print '<script type="text/javascript">' ;
print ' jQuery ( document ) . ready ( function () {
jQuery ( " #linktoshowtechnicalparam " ) . click ( function () {
jQuery ( " .hidewhenedit " ) . hide ();
jQuery ( " .hidewhennoedit " ) . show ();
}); ' ;
if ( $force_install_noedit ) print 'jQuery(".hidewhennoedit").hide();' ;
print '});' ;
print '</script>' ;
print '<br><a href="#" id="linktoshowtechnicalparam" class="hidewhenedit">' . $langs -> trans ( " ShowEditTechnicalParameters " ) . '</a><br>' ;
*/
2008-05-17 16:56:06 +02:00
}
2007-05-26 18:45:00 +02:00
?>
2012-10-07 20:04:07 +02:00
< div >
< table class = " nobordernopadding<?php if ( $force_install_noedit ) print ' hidewhennoedit'; ?> " >
2008-12-05 00:25:48 +01:00
2010-09-29 10:09:17 +02:00
< tr >
< td colspan = " 3 " class = " label " align = " center " >
< h3 >< ? php echo $langs -> trans ( " WebServer " ); ?> </h3>
</ td >
</ tr >
2007-05-26 18:45:00 +02:00
2011-09-29 22:21:57 +02:00
<!-- Documents root $dolibarr_main_document_root -->
2010-09-29 10:09:17 +02:00
< tr >
2011-09-29 22:21:57 +02:00
< ? php
print '<td valign="top" class="label"><b>' ;
print $langs -> trans ( " WebPagesDirectory " );
print " </b></td> " ;
if ( ! isset ( $dolibarr_main_url_root ) || dol_strlen ( $dolibarr_main_url_root ) == 0 )
{
//print "x".$_SERVER["SCRIPT_FILENAME"]." y".$_SERVER["DOCUMENT_ROOT"];
// Si le php fonctionne en CGI, alors SCRIPT_FILENAME vaut le path du php et
// ce n'est pas ce qu'on veut. Dans ce cas, on propose $_SERVER["DOCUMENT_ROOT"]
if ( preg_match ( '/^php$/i' , $_SERVER [ " SCRIPT_FILENAME " ]) || preg_match ( '/[\\/]php$/i' , $_SERVER [ " SCRIPT_FILENAME " ]) || preg_match ( '/php\.exe$/i' , $_SERVER [ " SCRIPT_FILENAME " ]))
{
$dolibarr_main_document_root = $_SERVER [ " DOCUMENT_ROOT " ];
if ( ! preg_match ( '/[\\/]dolibarr[\\/]htdocs$/i' , $dolibarr_main_document_root ))
{
$dolibarr_main_document_root .= " /dolibarr/htdocs " ;
}
}
else
{
$dolibarr_main_document_root = substr ( $_SERVER [ " SCRIPT_FILENAME " ], 0 , dol_strlen ( $_SERVER [ " SCRIPT_FILENAME " ]) - 21 );
// Nettoyage du path propose
// Gere les chemins windows avec double "\"
$dolibarr_main_document_root = str_replace ( '\\\\' , '/' , $dolibarr_main_document_root );
// Supprime les slash ou antislash de fins
$dolibarr_main_document_root = preg_replace ( '/[\\/]+$/' , '' , $dolibarr_main_document_root );
}
}
?>
< td class = " label " valign = " top " >< ? php
2011-06-08 11:52:06 +02:00
if ( $force_install_noedit ) print '<input type="hidden" value="' . $dolibarr_main_document_root . '" name="main_dir">' ;
2011-08-31 17:12:09 +02:00
print '<input type="text" size="60" value="' . $dolibarr_main_document_root . '"' . ( empty ( $force_install_noedit ) ? '' : ' disabled="disabled"' ) . ' name="main_dir' . ( empty ( $force_install_noedit ) ? '' : '_bis' ) . '">' ;
2011-09-29 22:21:57 +02:00
?> </td>
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php
print $langs -> trans ( " WithNoSlashAtTheEnd " ) . " <br> " ;
print $langs -> trans ( " Examples " ) . " :<br> " ;
?>
< ul >
< li >/ var / www / dolibarr / htdocs </ li >
< li > C :/ wwwroot / dolibarr / htdocs </ li >
</ ul >
</ td >
</ tr >
2011-09-29 22:21:57 +02:00
<!-- Documents URL $dolibarr_main_data_root -->
2010-09-29 10:09:17 +02:00
< tr >
2011-01-09 23:47:02 +01:00
< td valign = " top " class = " label " >< b > < ? php print $langs -> trans ( " DocumentsDirectory " ); ?> </b>
</ td >
2010-09-29 10:09:17 +02:00
< ? php
if ( empty ( $dolibarr_main_data_root ))
{
// Si le repertoire documents non defini, on en propose un par defaut
if ( empty ( $force_install_main_data_root ))
{
$dolibarr_main_data_root = preg_replace ( " / \ /htdocs $ / " , " " , $dolibarr_main_document_root );
$dolibarr_main_data_root .= " /documents " ;
}
else
{
$dolibarr_main_data_root = $force_install_main_data_root ;
}
}
?>
2011-09-29 22:21:57 +02:00
< td class = " label " valign = " top " >< ? php
2011-08-07 01:10:00 +02:00
if ( $force_install_noedit ) print '<input type="hidden" value="' . $dolibarr_main_data_root . '" name="main_data_dir">' ;
2011-08-31 17:12:09 +02:00
print '<input type="text" size="60" value="' . $dolibarr_main_data_root . '"' . ( empty ( $force_install_noedit ) ? '' : ' disabled="disabled"' ) . ' name="main_data_dir' . ( empty ( $force_install_noedit ) ? '' : '_bis' ) . '">' ;
2011-09-29 22:21:57 +02:00
?> </td>
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php
print $langs -> trans ( " WithNoSlashAtTheEnd " ) . " <br> " ;
print $langs -> trans ( " DirectoryRecommendation " ) . " <br> " ;
print $langs -> trans ( " Examples " ) . " :<br> " ;
?>
< ul >
2011-07-30 16:56:11 +02:00
< li >/ var / lib / dolibarr / documents </ li >
2010-09-29 10:09:17 +02:00
< li > C :/ My Documents / dolibarr /</ li >
</ ul >
</ td >
</ tr >
2011-09-29 22:21:57 +02:00
<!-- Root URL $dolibarr_main_url_root -->
< ? php
if ( ! empty ( $main_url )) $dolibarr_main_url_root = $main_url ;
if ( empty ( $dolibarr_main_url_root ))
{
// If defined (Ie: Apache with Linux)
if ( isset ( $_SERVER [ " SCRIPT_URI " ])) {
$dolibarr_main_url_root = $_SERVER [ " SCRIPT_URI " ];
}
// If defined (Ie: Apache with Caudium)
elseif ( isset ( $_SERVER [ " SERVER_URL " ]) && isset ( $_SERVER [ " DOCUMENT_URI " ])) {
$dolibarr_main_url_root = $_SERVER [ " SERVER_URL " ] . $_SERVER [ " DOCUMENT_URI " ];
}
// If SCRIPT_URI, SERVER_URL, DOCUMENT_URI not defined (Ie: Apache 2.0.44 for Windows)
else
{
$proto = 'http' ;
if ( ! empty ( $_SERVER [ " HTTP_HOST " ])) $serverport = $_SERVER [ " HTTP_HOST " ];
else $serverport = $_SERVER [ " SERVER_NAME " ];
$dolibarr_main_url_root = $proto . " :// " . $serverport . $_SERVER [ " SCRIPT_NAME " ];
}
// Clean proposed URL
$dolibarr_main_url_root = preg_replace ( '/\/fileconf\.php$/' , '' , $dolibarr_main_url_root ); // Remove the /fileconf.php
$dolibarr_main_url_root = preg_replace ( '/\/$/' , '' , $dolibarr_main_url_root ); // Remove the /
$dolibarr_main_url_root = preg_replace ( '/\/index\.php$/' , '' , $dolibarr_main_url_root ); // Remove the /index.php
$dolibarr_main_url_root = preg_replace ( '/\/install$/' , '' , $dolibarr_main_url_root ); // Remove the /install
}
?>
2011-01-09 23:47:02 +01:00
< tr >
< td valign = " top " class = " label " >< b > < ? php echo $langs -> trans ( " URLRoot " ); ?> </b>
</ td >
2011-09-29 22:21:57 +02:00
< td valign = " top " class = " label " >< ? php
2011-08-07 01:10:00 +02:00
if ( $force_install_noedit ) print '<input type="hidden" value="' . $dolibarr_main_url_root . '" name="main_url">' ;
2011-08-31 17:12:09 +02:00
print '<input type="text" size="60" value="' . $dolibarr_main_url_root . '"' . ( empty ( $force_install_noedit ) ? '' : ' disabled="disabled"' ) . ' name="main_url' . ( empty ( $force_install_noedit ) ? '' : '_bis' ) . '">' ;
2011-09-29 22:21:57 +02:00
?> </td>
2011-01-09 23:47:02 +01:00
< td class = " comment " >< ? php print $langs -> trans ( " Examples " ) . " :<br> " ; ?>
2010-09-29 10:09:17 +02:00
< ul >
< li > http :// localhost /</ li >
< li > http :// www . myserver . com : 8180 / dolibarr </ li >
</ ul >
2011-08-12 20:48:35 +02:00
</ td >
2010-09-29 10:09:17 +02:00
</ tr >
2011-09-29 22:21:57 +02:00
< ? php
if ( ! empty ( $_SERVER [ " HTTPS " ]) && $_SERVER [ " HTTPS " ] == 'on' ) { // Enabled if the installation process is "https://"
?>
2010-09-29 10:09:17 +02:00
< tr >
2011-01-09 16:37:23 +01:00
< td valign = " top " class = " label " >< ? php echo $langs -> trans ( " ForceHttps " ); ?> </td>
2010-09-29 10:09:17 +02:00
< td class = " label " valign = " top " >< input type = " checkbox "
name = " main_force_https "
< ? php if ( ! empty ( $force_install_mainforcehttps )) print ' checked="on"' ; ?> ></td>
< td class = " comment " >< ? php echo $langs -> trans ( " CheckToForceHttps " ); ?>
</ td >
</ tr >
2011-09-29 22:21:57 +02:00
< ? php
}
?>
2010-09-29 10:09:17 +02:00
<!-- Dolibarr database -->
< tr >
< td colspan = " 3 " class = " label " align = " center " >< br >
< h3 >< ? php echo $langs -> trans ( " DolibarrDatabase " ); ?> </h3>
</ td >
</ tr >
2011-12-19 23:32:24 +01:00
< tr >
< td class = " label " valign = " top " >< b > < ? php echo $langs -> trans ( " DatabaseName " ); ?>
</ b ></ td >
< td class = " label " valign = " top " >< input type = " text " id = " db_name "
name = " db_name "
value = " <?php echo (! empty( $dolibarr_main_db_name ))? $dolibarr_main_db_name :( $force_install_database ? $force_install_database :'dolibarr'); ?> " ></ td >
< td class = " comment " >< ? php echo $langs -> trans ( " DatabaseName " ); ?> </td>
</ tr >
2010-09-29 10:09:17 +02:00
< ? php
if ( ! isset ( $dolibarr_main_db_host ))
{
$dolibarr_main_db_host = " localhost " ;
}
?>
< tr >
2011-01-09 23:47:02 +01:00
<!-- Driver type -->
2010-09-29 10:09:17 +02:00
< td valign = " top " class = " label " >< b > < ? php echo $langs -> trans ( " DriverType " ); ?>
</ b ></ td >
< td class = " label " >< ? php
$defaultype =! empty ( $dolibarr_main_db_type ) ? $dolibarr_main_db_type : ( $force_install_type ? $force_install_type : 'mysqli' );
2011-09-29 22:21:57 +02:00
$modules = array ();
$nbok = $nbko = 0 ;
$option = '' ;
2010-12-15 19:15:08 +01:00
2011-09-29 22:21:57 +02:00
// Scan les drivers
2011-10-24 10:06:37 +02:00
$dir = DOL_DOCUMENT_ROOT . '/core/db' ;
2010-09-29 10:09:17 +02:00
$handle = opendir ( $dir );
2011-09-29 22:21:57 +02:00
if ( is_resource ( $handle ))
{
while (( $file = readdir ( $handle )) !== false )
{
2012-01-28 16:04:48 +01:00
if ( is_readable ( $dir . " / " . $file ) && preg_match ( '/^(.*)\.class\.php$/i' , $file , $reg ))
2011-09-29 22:21:57 +02:00
{
$type = $reg [ 1 ];
2013-09-11 15:48:25 +02:00
if ( $type === 'DoliDB' ) continue ; // Skip abstract class
2011-12-19 21:10:23 +01:00
$class = 'DoliDB' . ucfirst ( $type );
2012-08-23 02:04:35 +02:00
include_once $dir . " / " . $file ;
2011-09-29 22:21:57 +02:00
2012-01-02 13:21:26 +01:00
if ( $type == 'sqlite' ) continue ; // We hide sqlite because support can't be complete unti sqlit does not manage foreign key creation after table creation
2011-12-19 21:10:23 +01:00
// Version min of database
2011-12-27 00:07:42 +01:00
$versionbasemin = getStaticMember ( $class , 'versionmin' );
$note = '(' . getStaticMember ( $class , 'label' ) . ' >= ' . versiontostring ( $versionbasemin ) . ')' ;
2011-09-29 22:21:57 +02:00
// Switch to mysql if mysqli is not present
if ( $defaultype == 'mysqli' && ! function_exists ( 'mysqli_connect' )) $defaultype = 'mysql' ;
2011-12-19 21:10:23 +01:00
// Show line into list
2012-01-02 02:46:12 +01:00
if ( $type == 'mysql' ) { $testfunction = 'mysql_connect' ; $testclass = '' ; }
if ( $type == 'mysqli' ) { $testfunction = 'mysqli_connect' ; $testclass = '' ; }
if ( $type == 'pgsql' ) { $testfunction = 'pg_connect' ; $testclass = '' ; }
if ( $type == 'mssql' ) { $testfunction = 'mssql_connect' ; $testclass = '' ; }
if ( $type == 'sqlite' ) { $testfunction = '' ; $testclass = 'PDO' ; }
2011-09-29 22:21:57 +02:00
$option .= '<option value="' . $type . '"' . ( $defaultype == $type ? ' selected="selected"' : '' );
2012-01-02 02:46:12 +01:00
if ( $testfunction && ! function_exists ( $testfunction )) $option .= ' disabled="disabled"' ;
if ( $testclass && ! class_exists ( $testclass )) $option .= ' disabled="disabled"' ;
2011-09-29 22:21:57 +02:00
$option .= '>' ;
$option .= $type . ' ' ;
if ( $note ) $option .= ' ' . $note ;
// Experimental
2011-12-19 21:10:23 +01:00
if ( $type == 'mssql' ) $option .= ' ' . $langs -> trans ( " Experimental " );
elseif ( $type == 'sqlite' ) $option .= ' ' . $langs -> trans ( " Experimental " );
2011-09-29 22:21:57 +02:00
// No available
elseif ( ! function_exists ( $testfunction )) $option .= ' - ' . $langs -> trans ( " FunctionNotAvailableInThisPHP " );
$option .= '</option>' ;
}
}
}
if ( $force_install_noedit && $force_install_type ) print '<input id="db_type" type="hidden" value="' . $force_install_type . '" name="db_type">' ;
print '<select id="db_type" name="db_type' . ( empty ( $force_install_noedit ) || empty ( $force_install_type ) ? '' : '_bis' ) . '"' . ( $force_install_noedit && $force_install_type ? ' disabled="disabled"' : '' ) . '>' ;
2011-06-08 11:52:06 +02:00
print $option ;
2011-07-30 16:56:11 +02:00
print '</select>' ;
2010-09-29 10:09:17 +02:00
2011-07-30 16:56:11 +02:00
?> </td>
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " DatabaseType " ); ?> </td>
</ tr >
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2010-09-29 10:09:17 +02:00
< td valign = " top " class = " label " >< b > < ? php echo $langs -> trans ( " Server " ); ?>
</ b ></ td >
2011-09-29 22:21:57 +02:00
< td valign = " top " class = " label " >< input type = " text "
name = " db_host<?php print ( $force_install_noedit ==2 && $force_install_dbserver )?'_bis':''; ?> "
2011-08-07 01:10:00 +02:00
< ? php if ( $force_install_noedit == 2 && $force_install_dbserver ) print ' disabled="disabled"' ; ?>
2011-06-26 03:52:59 +02:00
value = " <?php print (! empty( $dolibarr_main_db_host ))? $dolibarr_main_db_host :(empty( $force_install_dbserver )?'localhost': $force_install_dbserver ); ?> " >
2011-09-29 22:21:57 +02:00
< ? php if ( $force_install_noedit == 2 && $force_install_dbserver ) print '<input type="hidden" name="db_host" value="' . (( ! empty ( $dolibarr_main_db_host )) ? $dolibarr_main_db_host : $force_install_dbserver ) . '">' ; ?>
2011-06-12 01:21:59 +02:00
</ td >
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " ServerAddressDescription " ); ?>
</ td >
</ tr >
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2010-09-29 10:09:17 +02:00
< td valign = " top " class = " label " >< ? php echo $langs -> trans ( " Port " ); ?> </td>
2011-09-29 22:21:57 +02:00
< td valign = " top " class = " label " >< input type = " text "
name = " db_port<?php print ( $force_install_noedit ==2 && $force_install_port )?'_bis':''; ?> "
2011-08-07 01:10:00 +02:00
< ? php if ( $force_install_noedit == 2 && $force_install_port ) print ' disabled="disabled"' ; ?>
2010-09-29 10:09:17 +02:00
value = " <?php print (! empty( $dolibarr_main_db_port ))? $dolibarr_main_db_port : $force_install_port ; ?> " >
2011-09-29 22:21:57 +02:00
< ? php if ( $force_install_noedit == 2 && $force_install_port ) print '<input type="hidden" name="db_port" value="' . (( ! empty ( $dolibarr_main_db_port )) ? $dolibarr_main_db_port : $force_install_port ) . '">' ; ?>
2011-06-12 01:21:59 +02:00
</ td >
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " ServerPortDescription " ); ?>
</ td >
</ tr >
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2011-12-19 23:32:24 +01:00
< td class = " label " valign = " top " >< ? php echo $langs -> trans ( " DatabasePrefix " ); ?>
</ td >
2011-11-23 23:09:57 +01:00
< td class = " label " valign = " top " >< input type = " text " id = " db_prefix "
name = " db_prefix "
value = " <?php echo (! empty( $dolibarr_main_db_prefix ))? $dolibarr_main_db_prefix :( $force_install_prefix ? $force_install_prefix :'llx_'); ?> " ></ td >
< td class = " comment " >< ? php echo $langs -> trans ( " DatabasePrefix " ); ?> </td>
</ tr >
2010-09-29 10:09:17 +02:00
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2010-09-29 10:09:17 +02:00
< td class = " label " valign = " top " >< ? php echo $langs -> trans ( " CreateDatabase " ); ?>
</ td >
< td class = " label " valign = " top " >< input type = " checkbox "
2011-05-17 10:46:56 +02:00
id = " db_create_database " name = " db_create_database "
2010-09-29 10:09:17 +02:00
< ? php if ( $force_install_createdatabase ) print ' checked="on"' ; ?> ></td>
< td class = " comment " >< ? php echo $langs -> trans ( " CheckToCreateDatabase " ); ?>
</ td >
</ tr >
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2010-09-29 10:09:17 +02:00
< td class = " label " valign = " top " >< b >< ? php echo $langs -> trans ( " Login " ); ?> </b>
</ td >
2011-09-29 22:21:57 +02:00
< td class = " label " valign = " top " >< input type = " text " id = " db_user "
name = " db_user "
2010-09-29 10:09:17 +02:00
value = " <?php print (! empty( $dolibarr_main_db_user ))? $dolibarr_main_db_user : $force_install_databaselogin ; ?> " ></ td >
< td class = " comment " >< ? php echo $langs -> trans ( " AdminLogin " ); ?> </td>
</ tr >
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2010-09-29 10:09:17 +02:00
< td class = " label " valign = " top " >< b >< ? php echo $langs -> trans ( " Password " ); ?> </b>
</ td >
2013-04-20 05:37:52 +02:00
< td class = " label " valign = " top " >< input type = " password " id = " db_pass " autocomplete = " off "
2011-09-29 22:21:57 +02:00
name = " db_pass "
2012-06-17 23:27:17 +02:00
value = " <?php
2012-11-20 11:22:57 +01:00
//$autofill=((! empty($dolibarr_main_db_pass))?$dolibarr_main_db_pass:$force_install_databasepass);
$autofill = (( ! empty ( $_SESSION [ 'dol_save_pass' ])) ? $_SESSION [ 'dol_save_pass' ] : $force_install_databasepass );
2012-08-03 10:26:39 +02:00
if ( ! empty ( $dolibarr_main_prod )) $autofill = '' ;
2012-06-17 23:27:17 +02:00
print dol_escape_htmltag ( $autofill );
?> "></td>
2010-09-29 10:09:17 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " AdminPassword " ); ?> </td>
</ tr >
2012-01-02 02:46:12 +01:00
< tr class = " hidesqlite " >
2010-09-29 10:09:17 +02:00
< td class = " label " valign = " top " >< ? php echo $langs -> trans ( " CreateUser " ); ?>
</ td >
2011-09-29 22:21:57 +02:00
< td class = " label " valign = " top " >< input type = " checkbox "
id = " db_create_user " name = " db_create_user "
2010-09-29 10:09:17 +02:00
< ? php if ( ! empty ( $force_install_createuser )) print ' checked="on"' ; ?> ></td>
< td class = " comment " >< ? php echo $langs -> trans ( " CheckToCreateUser " ); ?>
</ td >
</ tr >
<!-- Super access -->
2011-08-07 01:10:00 +02:00
< ? php
2011-09-29 22:21:57 +02:00
$force_install_databaserootlogin = preg_replace ( '/__SUPERUSERLOGIN__/' , 'root' , $force_install_databaserootlogin );
$force_install_databaserootpass = preg_replace ( '/__SUPERUSERPASSWORD__/' , '' , $force_install_databaserootpass );
2011-08-07 01:10:00 +02:00
?>
2012-07-04 10:23:59 +02:00
< tr class = " hidesqlite hideroot " >
2010-09-29 10:09:17 +02:00
< td colspan = " 3 " class = " label " align = " center " >< br >
< h3 >< ? php echo $langs -> trans ( " DatabaseSuperUserAccess " ); ?> </h3>
</ td >
</ tr >
2012-07-04 10:23:59 +02:00
< tr class = " hidesqlite hideroot " >
2012-11-20 11:22:57 +01:00
< td class = " label " valign = " top " >< b >< ? php echo $langs -> trans ( " Login " ); ?> </b></td>
2011-09-29 22:21:57 +02:00
< td class = " label " valign = " top " >< input type = " text " id = " db_user_root "
name = " db_user_root " class = " needroot "
2010-09-29 10:09:17 +02:00
value = " <?php print (! empty( $db_user_root ))? $db_user_root : $force_install_databaserootlogin ; ?> " ></ td >
2011-09-29 22:21:57 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " DatabaseRootLoginDescription " ); ?>
2011-08-12 20:48:35 +02:00
<!--
< ? php echo '<br>' . $langs -> trans ( " Examples " ) . ':<br>' ?>
< ul >
< li > root ( Mysql ) </ li >
< li > postgres ( PostgreSql ) </ li >
</ ul >
2010-09-29 10:09:17 +02:00
</ td >
2011-08-12 20:48:35 +02:00
-->
2011-09-29 22:21:57 +02:00
2010-09-29 10:09:17 +02:00
</ tr >
2012-07-04 10:23:59 +02:00
< tr class = " hidesqlite hideroot " >
2012-11-20 11:22:57 +01:00
< td class = " label " valign = " top " >< b >< ? php echo $langs -> trans ( " Password " ); ?> </b>
2010-09-29 10:09:17 +02:00
</ td >
2013-04-20 05:37:52 +02:00
< td class = " label " valign = " top " >< input type = " password " autocomplete = " off "
2011-09-29 22:21:57 +02:00
id = " db_pass_root " name = " db_pass_root " class = " needroot "
2012-06-17 23:27:17 +02:00
value = " <?php
$autofill = (( ! empty ( $db_pass_root )) ? $db_pass_root : $force_install_databaserootpass );
2013-08-06 17:26:05 +02:00
if ( ! empty ( $dolibarr_main_prod )) $autofill = '' ; // Do not autofill password if instance is a production instance
if ( ! empty ( $_SERVER [ " SERVER_NAME " ]) && ! in_array ( $_SERVER [ " SERVER_NAME " ], array ( '127.0.0.1' , 'localhost' ))) $autofill = '' ; // Do not autofill password for remote access
2012-06-17 23:27:17 +02:00
print dol_escape_htmltag ( $autofill );
?> "></td>
2011-09-29 22:21:57 +02:00
< td class = " comment " >< ? php echo $langs -> trans ( " KeepEmptyIfNoPassword " ); ?>
2010-09-29 10:09:17 +02:00
</ td >
</ tr >
2004-02-11 19:08:59 +01:00
</ table >
2012-10-07 20:04:07 +02:00
</ div >
2004-12-04 16:30:14 +01:00
2011-11-21 01:34:37 +01:00
< script type = " text/javascript " >
2011-05-17 10:46:56 +02:00
jQuery ( document ) . ready ( function () {
2011-12-19 23:32:24 +01:00
jQuery ( " #db_type " ) . change ( function () {
if ( jQuery ( " #db_type " ) . val () == 'sqlite' ) { jQuery ( " .hidesqlite " ) . hide (); }
else { jQuery ( " .hidesqlite " ) . show (); }
});
2011-05-17 10:46:56 +02:00
function init_needroot ()
{
/*alert(jQuery("#db_create_database").attr("checked")); */
if ( jQuery ( " #db_create_database " ) . attr ( " checked " ) || jQuery ( " #db_create_user " ) . attr ( " checked " ))
2011-06-08 11:52:06 +02:00
{
2012-07-04 10:23:59 +02:00
jQuery ( " .hideroot " ) . show ();
2011-05-17 10:46:56 +02:00
jQuery ( " .needroot " ) . removeAttr ( 'disabled' );
}
else
{
2012-07-04 10:23:59 +02:00
jQuery ( " .hideroot " ) . hide ();
2011-05-17 10:46:56 +02:00
jQuery ( " .needroot " ) . attr ( 'disabled' , 'disabled' );
}
}
2011-12-19 23:32:24 +01:00
2011-05-17 10:46:56 +02:00
init_needroot ();
jQuery ( " #db_create_database " ) . click ( function () {
init_needroot ();
});
jQuery ( " #db_create_user " ) . click ( function () {
init_needroot ();
});
2012-10-08 02:38:30 +02:00
< ? php if ( $force_install_noedit && empty ( $force_install_databasepass )) { ?>
2011-07-30 16:56:11 +02:00
jQuery ( " #db_pass " ) . focus ();
< ? php } ?>
2011-05-17 10:46:56 +02:00
});
2010-02-04 23:00:51 +01:00
function checkDatabaseName ( databasename ) {
2010-08-20 13:58:29 +02:00
if ( databasename . match ( / [; \ . ] / )) { return false ; }
2010-02-04 23:00:51 +01:00
return true ;
}
2010-01-20 18:54:44 +01:00
function jscheckparam ()
{
ok = true ;
if ( document . forminstall . main_dir . value == '' )
{
ok = false ;
alert ( '<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("WebPagesDirectory"))); ?>' );
}
else if ( document . forminstall . main_data_dir . value == '' )
{
ok = false ;
alert ( '<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("DocumentsDirectory"))); ?>' );
}
else if ( document . forminstall . main_url . value == '' )
{
ok = false ;
alert ( '<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("URLRoot"))); ?>' );
}
else if ( document . forminstall . db_host . value == '' )
{
ok = false ;
alert ( '<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("Server"))); ?>' );
}
else if ( document . forminstall . db_name . value == '' )
{
ok = false ;
alert ( '<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("DatabaseName"))); ?>' );
}
2010-02-04 23:00:51 +01:00
else if ( ! checkDatabaseName ( document . forminstall . db_name . value ))
{
ok = false ;
alert ( '<?php echo dol_escape_js($langs->transnoentities("ErrorSpecialCharNotAllowedForField",$langs->transnoentitiesnoconv("DatabaseName"))); ?>' );
}
2010-01-20 18:54:44 +01:00
// If create database asked
2010-02-04 23:00:51 +01:00
else if ( document . forminstall . db_create_database . checked == true && ( document . forminstall . db_user_root . value == '' ))
2010-01-20 18:54:44 +01:00
{
ok = false ;
alert ( '<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>' );
}
2010-02-04 23:00:51 +01:00
else if ( document . forminstall . db_create_database . checked == true && ( document . forminstall . db_user_root . value == '' ))
2010-01-20 18:54:44 +01:00
{
ok = false ;
alert ( '<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>' );
}
// If create user asked
2010-02-04 23:00:51 +01:00
else if ( document . forminstall . db_create_user . checked == true && ( document . forminstall . db_user_root . value == '' ))
2010-01-20 18:54:44 +01:00
{
ok = false ;
alert ( '<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>' );
}
2010-02-04 23:00:51 +01:00
else if ( document . forminstall . db_create_user . checked == true && ( document . forminstall . db_user_root . value == '' ))
2010-01-20 18:54:44 +01:00
{
ok = false ;
alert ( '<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>' );
}
return ok ;
}
</ script >
2004-12-04 16:30:14 +01:00
2012-07-04 10:23:59 +02:00
< ? php
2004-12-04 16:30:14 +01:00
2012-07-04 10:23:59 +02:00
// $db->close(); Not database connexion yet
pFooter ( $err , $setuplang , 'jscheckparam' );
?>