Fix: Add test on database name

This commit is contained in:
Laurent Destailleur 2010-02-04 22:00:51 +00:00
parent ab8e9904ef
commit a5513d165e
6 changed files with 33 additions and 17 deletions

View File

@ -22,21 +22,21 @@
*/ */
/** /**
* \defgroup agenda Module agenda * \defgroup agenda Module agenda
* \brief Module pour gerer l'agenda et actions * \brief Module pour gerer l'agenda et actions
* \brief $Id$ * \brief $Id$
*/ */
/** /**
* \file htdocs/includes/modules/modAgenda.class.php * \file htdocs/includes/modules/modAgenda.class.php
* \ingroup agenda * \ingroup agenda
* \brief Fichier de description et activation du module agenda * \brief Fichier de description et activation du module agenda
*/ */
include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php"); include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php");
/** /**
* \class modAdherent * \class modAdherent
* \brief Classe de description et activation du module Adherent * \brief Classe de description et activation du module Adherent
*/ */
class modAgenda extends DolibarrModules class modAgenda extends DolibarrModules
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
@ -351,7 +351,7 @@ if ($_POST["action"] == "set")
print $langs->trans("DatabaseCreation").' : '; print $langs->trans("DatabaseCreation").' : ';
print $dolibarr_main_db_name; print $dolibarr_main_db_name;
print '</td>'; print '</td>';
print '<td>'.$langs->trans("Error").' '.$db->errno().'</td></tr>'; print '<td>'.$langs->trans("Error").' '.$db->lasterrno().'</td></tr>';
// Affiche aide diagnostique // Affiche aide diagnostique
print '<tr><td colspan="2"><br>'; print '<tr><td colspan="2"><br>';
@ -360,6 +360,7 @@ if ($_POST["action"] == "set")
print '<br>'; print '<br>';
print '</td></tr>'; print '</td></tr>';
dolibarr_install_syslog('etape1: Failed to create database '.$dolibarr_main_db_name.' '.$db->lasterrno(), LOG_ERR);
$error++; $error++;
} }
$db->close(); $db->close();

View File

@ -35,6 +35,7 @@ $setuplang=isset($_POST["selectlang"])?$_POST["selectlang"]:(isset($_GET["select
$langs->setDefaultLang($setuplang); $langs->setDefaultLang($setuplang);
$langs->load("install"); $langs->load("install");
$langs->load("errors");
// You can force preselected values of the config step of Dolibarr by adding a file // 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 installer // install.forced.php into directory htdocs/install (This is the case with some installer
@ -384,6 +385,12 @@ while (($file = readdir($handle))!==false)
</table> </table>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
function checkDatabaseName(databasename) {
if (databasename.match(/[-;_\.]/)) { return false; }
return true;
}
function jscheckparam() function jscheckparam()
{ {
ok=true; ok=true;
@ -413,24 +420,29 @@ function jscheckparam()
ok=false; ok=false;
alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("DatabaseName"))); ?>'); alert('<?php echo dol_escape_js($langs->transnoentities("ErrorFieldRequired",$langs->transnoentitiesnoconv("DatabaseName"))); ?>');
} }
else if (! checkDatabaseName(document.forminstall.db_name.value))
{
ok=false;
alert('<?php echo dol_escape_js($langs->transnoentities("ErrorSpecialCharNotAllowedForField",$langs->transnoentitiesnoconv("DatabaseName"))); ?>');
}
// If create database asked // If create database asked
else if (document.forminstall.db_create_database.checked == true && (document.forminstall.db_user_root.value == '' || document.forminstall.db_pass_root.value == '')) else if (document.forminstall.db_create_database.checked == true && (document.forminstall.db_user_root.value == ''))
{ {
ok=false; ok=false;
alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>'); alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
} }
else if (document.forminstall.db_create_database.checked == true && (document.forminstall.db_user_root.value == '' || document.forminstall.db_pass_root.value == '')) else if (document.forminstall.db_create_database.checked == true && (document.forminstall.db_user_root.value == ''))
{ {
ok=false; ok=false;
alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>'); alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
} }
// If create user asked // If create user asked
else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == '' || document.forminstall.db_pass_root.value == '')) else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == ''))
{ {
ok=false; ok=false;
alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>'); alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
} }
else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == '' || document.forminstall.db_pass_root.value == '')) else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == ''))
{ {
ok=false; ok=false;
alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>'); alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');

View File

@ -60,3 +60,4 @@ ErrorWrongValueForField=Wrong value for field number <b>%s</b> (value '<b>%s</b>
ErrorsOnXLines=Errors on <b>%s</b> source lines ErrorsOnXLines=Errors on <b>%s</b> source lines
WarningsOnXLines=Warnings on <b>%s</b> source lines WarningsOnXLines=Warnings on <b>%s</b> source lines
ErrorFileIsInfectedWithAVirus=The antivirus program was not able to validate the file (file might be infected by a virus) ErrorFileIsInfectedWithAVirus=The antivirus program was not able to validate the file (file might be infected by a virus)
ErrorSpecialCharNotAllowedForField=Special characters are not allowed for field "%s"

View File

@ -61,3 +61,4 @@ ErrorWrongValueForField=Mauvaise valeur pour le champ numéro <b>%s</b> (la vale
ErrorsOnXLines=Erreurs sur <b>%s</b> lignes sources ErrorsOnXLines=Erreurs sur <b>%s</b> lignes sources
WarningsOnXLines=Alertes sur <b>%s</b> lignes sources WarningsOnXLines=Alertes sur <b>%s</b> lignes sources
ErrorFileIsInfectedWithAVirus=L'antivirus n'a pas pu valider ce fichier (il est probablement infecté par un virus) ! ErrorFileIsInfectedWithAVirus=L'antivirus n'a pas pu valider ce fichier (il est probablement infecté par un virus) !
ErrorSpecialCharNotAllowedForField=Les caractères spéciaux ne sont pas admins pour le champ "%s"

View File

@ -75,13 +75,14 @@ function print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbort
print '<tr>'; print '<tr>';
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
print $langs->trans("ActionsToDoBy"); print $langs->trans("or").' '.$langs->trans("ActionsToDoBy");
print ' &nbsp;</td><td nowrap="nowrap">'; print ' &nbsp;</td><td nowrap="nowrap">';
print $form->select_users($filtert,'usertodo',1,'',!$canedit); print $form->select_users($filtert,'usertodo',1,'',!$canedit);
print '</td></tr>'; print '</td></tr>';
print '<tr>'; print '<tr>';
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
print $langs->trans("ActionsDoneBy"); print $langs->trans("or").' '.$langs->trans("ActionsDoneBy");
print ' &nbsp;</td><td nowrap="nowrap">'; print ' &nbsp;</td><td nowrap="nowrap">';
print $form->select_users($filterd,'userdone',1,'',!$canedit); print $form->select_users($filterd,'userdone',1,'',!$canedit);
print '</td></tr>'; print '</td></tr>';