2
0
forked from Wavyzz/dolibarr

Fix: strict mode everywhere

This commit is contained in:
Regis Houssin
2012-09-02 22:48:52 +02:00
parent 8a5fe809f4
commit d2ae90f938
9 changed files with 55 additions and 40 deletions

View File

@@ -1,9 +1,9 @@
<?php <?php
/* Copyright (C) 2001 Fabien Seisen <seisen@linuxfr.org> /* Copyright (C) 2001 Fabien Seisen <seisen@linuxfr.org>
* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -714,10 +714,10 @@ class DoliDBMysql
global $conf; global $conf;
// Type of encryption (2: AES (recommended), 1: DES , 0: no encryption) // Type of encryption (2: AES (recommended), 1: DES , 0: no encryption)
$cryptType = ($conf->db->dolibarr_main_db_encryption?$conf->db->dolibarr_main_db_encryption:0); $cryptType = (isset($conf->db->dolibarr_main_db_encryption)?$conf->db->dolibarr_main_db_encryption:0);
//Encryption key //Encryption key
$cryptKey = (!empty($conf->db->dolibarr_main_db_cryptkey)?$conf->db->dolibarr_main_db_cryptkey:''); $cryptKey = (! empty($conf->db->dolibarr_main_db_cryptkey)?$conf->db->dolibarr_main_db_cryptkey:'');
$return = ($withQuotes?"'":"").$this->escape($fieldorvalue).($withQuotes?"'":""); $return = ($withQuotes?"'":"").$this->escape($fieldorvalue).($withQuotes?"'":"");

View File

@@ -1,9 +1,9 @@
<?php <?php
/* Copyright (C) 2001 Fabien Seisen <seisen@linuxfr.org> /* Copyright (C) 2001 Fabien Seisen <seisen@linuxfr.org>
* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -709,10 +709,10 @@ class DoliDBMysqli
global $conf; global $conf;
// Type of encryption (2: AES (recommended), 1: DES , 0: no encryption) // Type of encryption (2: AES (recommended), 1: DES , 0: no encryption)
$cryptType = ($conf->db->dolibarr_main_db_encryption?$conf->db->dolibarr_main_db_encryption:0); $cryptType = (isset($conf->db->dolibarr_main_db_encryption)?$conf->db->dolibarr_main_db_encryption:0);
//Encryption key //Encryption key
$cryptKey = (!empty($conf->db->dolibarr_main_db_cryptkey)?$conf->db->dolibarr_main_db_cryptkey:''); $cryptKey = (! empty($conf->db->dolibarr_main_db_cryptkey)?$conf->db->dolibarr_main_db_cryptkey:'');
$return = ($withQuotes?"'":"").$this->escape($fieldorvalue).($withQuotes?"'":""); $return = ($withQuotes?"'":"").$this->escape($fieldorvalue).($withQuotes?"'":"");

View File

@@ -350,7 +350,7 @@ function ajax_combobox($htmlname, $event=array())
* @param int $entity Entity to set * @param int $entity Entity to set
* @return void * @return void
*/ */
function ajax_constantonoff($code,$input=array(),$entity=false) function ajax_constantonoff($code, $input=array(), $entity=false)
{ {
global $conf, $langs; global $conf, $langs;

View File

@@ -3033,12 +3033,13 @@ function get_exdir($num,$level=3,$alpha=0,$withoutslash=0)
/** /**
* Creation of a directory (this can create recursive subdir) * Creation of a directory (this can create recursive subdir)
* *
* @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir') * @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir')
* @return int < 0 if KO, 0 = already exists, > 0 if OK * @param string $dataroot Data root directory (to avoid having the data root in the loop)
* @return int < 0 if KO, 0 = already exists, > 0 if OK
*/ */
function dol_mkdir($dir) function dol_mkdir($dir, $dataroot='')
{ {
global $conf; global $db, $conf;
dol_syslog("functions.lib::dol_mkdir: dir=".$dir,LOG_INFO); dol_syslog("functions.lib::dol_mkdir: dir=".$dir,LOG_INFO);
@@ -3048,8 +3049,14 @@ function dol_mkdir($dir)
$nberr=0; $nberr=0;
$nbcreated=0; $nbcreated=0;
$ccdir = ''; $ccdir='';
$cdir = explode("/",$dir); if (! empty($dataroot)) {
// Remove data root from loop
$dir = str_replace($dataroot.'/', '', $dir);
$ccdir = $dataroot.'/';
}
$cdir = explode("/", $dir);
$num=count($cdir); $num=count($cdir);
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++)
{ {

View File

@@ -1170,7 +1170,7 @@ abstract class DolibarrModules
$err=0; $err=0;
if (is_array($this->dirs)) if (isset($this->dirs) && is_array($this->dirs) && ! empty($this->dirs))
{ {
foreach ($this->dirs as $key => $value) foreach ($this->dirs as $key => $value)
{ {
@@ -1184,19 +1184,19 @@ abstract class DolibarrModules
$subname = empty($this->dirs[$key][3])?'':strtoupper($this->dirs[$key][3]); // Add submodule name (ex: $conf->module->submodule->dir_output) $subname = empty($this->dirs[$key][3])?'':strtoupper($this->dirs[$key][3]); // Add submodule name (ex: $conf->module->submodule->dir_output)
$forcename = empty($this->dirs[$key][4])?'':strtoupper($this->dirs[$key][4]); // Change the module name if different $forcename = empty($this->dirs[$key][4])?'':strtoupper($this->dirs[$key][4]); // Change the module name if different
if ($forcename) $constname = 'MAIN_MODULE_'.$forcename."_DIR_"; if (! empty($forcename)) $constname = 'MAIN_MODULE_'.$forcename."_DIR_";
if ($subname) $constname = $constname.$subname."_"; if (! empty($subname)) $constname = $constname.$subname."_";
$name = $constname.strtoupper($this->dirs[$key][0]); $name = $constname.strtoupper($this->dirs[$key][0]);
} }
// Define directory full path ($dir must start with "/") // Define directory full path ($dir must start with "/")
if (empty($conf->global->MAIN_MODULE_MULTICOMPANY) || $conf->entity == 1) $fulldir = DOL_DATA_ROOT.$dir; if (empty($conf->global->MAIN_MODULE_MULTICOMPANY) || $conf->entity == 1) $fulldir = DOL_DATA_ROOT.$dir;
else $fulldir = DOL_DATA_ROOT."/".$conf->entity.$dir; else $fulldir = DOL_DATA_ROOT."/".$conf->entity.$dir;
// Create dir if it does not exists // Create dir if it does not exists
if ($fulldir && ! file_exists($fulldir)) if (! empty($fulldir) && ! file_exists($fulldir))
{ {
if (dol_mkdir($fulldir) < 0) if (dol_mkdir($fulldir, DOL_DATA_ROOT) < 0)
{ {
$this->error = $langs->trans("ErrorCanNotCreateDir",$fulldir); $this->error = $langs->trans("ErrorCanNotCreateDir",$fulldir);
dol_syslog(get_class($this)."::_init ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::_init ".$this->error, LOG_ERR);
@@ -1205,9 +1205,9 @@ abstract class DolibarrModules
} }
// Define the constant in database if requested (not the default mode) // Define the constant in database if requested (not the default mode)
if ($addtodatabase) if (! empty($addtodatabase))
{ {
$result = $this->insert_dirs($name,$dir); $result = $this->insert_dirs($name, $dir);
if ($result) $err++; if ($result) $err++;
} }
} }

View File

@@ -246,4 +246,4 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
return -1; return -1;
} }
} }
?> ?>

View File

@@ -251,4 +251,4 @@ function delivery_order_pdf_create($db, $object, $modele, $outputlangs='')
} }
} }
?> ?>

View File

@@ -35,8 +35,8 @@ $langs->load("exports");
$langs->load("errors"); $langs->load("errors");
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; if (! empty($user->societe_id)) $socid=$user->societe_id;
$result=restrictedArea($user,'import',$origin_id,''); $result=restrictedArea($user, 'import');
$entitytoicon=array( $entitytoicon=array(
'invoice'=>'bill','invoice_line'=>'bill', 'invoice'=>'bill','invoice_line'=>'bill',
@@ -68,7 +68,8 @@ $entitytolang=array( // Translation code
$datatoimport = GETPOST('datatoimport'); $datatoimport = GETPOST('datatoimport');
$format = GETPOST('format'); $format = GETPOST('format');
$filetoimport = GETPOST('filetoimport'); $filetoimport = GETPOST('filetoimport');
$action = GETPOST('action'); $action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
$step = (GETPOST('step') ? GETPOST('step') : 1); $step = (GETPOST('step') ? GETPOST('step') : 1);
$import_name = GETPOST('import_name'); $import_name = GETPOST('import_name');
$hexa = GETPOST('hexa'); $hexa = GETPOST('hexa');
@@ -92,7 +93,7 @@ foreach($fieldsarray as $elem)
{ {
$tabelem=explode('=',$elem,2); $tabelem=explode('=',$elem,2);
$key=$tabelem[0]; $key=$tabelem[0];
$val=$tabelem[1]; $val=(isset($tabelem[1])?$tabelem[1]:'');
if ($key && $val) if ($key && $val)
{ {
$array_match_file_to_database[$key]=$val; $array_match_file_to_database[$key]=$val;
@@ -192,7 +193,7 @@ if ($action == 'add_import_model')
if ($step == 3 && $datatoimport) if ($step == 3 && $datatoimport)
{ {
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{ {
dol_mkdir($conf->import->dir_temp); dol_mkdir($conf->import->dir_temp);
$nowyearmonth=dol_print_date(dol_now(),'%Y%m%d%H%M%S'); $nowyearmonth=dol_print_date(dol_now(),'%Y%m%d%H%M%S');
@@ -451,6 +452,14 @@ if ($step == 3 && $datatoimport)
dol_fiche_head($head, 'step3', $langs->trans("NewImport")); dol_fiche_head($head, 'step3', $langs->trans("NewImport"));
/*
* Confirm delete file
*/
if ($action == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?urlfile='.urlencode(GETPOST('urlfile')).'&step=3'.$param, $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
if ($ret == 'html') print '<br>';
}
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
@@ -511,7 +520,7 @@ if ($step == 3 && $datatoimport)
print "</tr>\n"; print "</tr>\n";
// Search available imports // Search available imports
$filearray=dol_dir_list($conf->import->dir_temp,'files',0,'','','name',SORT_DESC); $filearray=dol_dir_list($conf->import->dir_temp, 'files', 0, '', '', 'name', SORT_DESC);
if (count($filearray) > 0) if (count($filearray) > 0)
{ {
$dir=$conf->import->dir_temp; $dir=$conf->import->dir_temp;
@@ -545,8 +554,7 @@ if ($step == 3 && $datatoimport)
// Affiche date fichier // Affiche date fichier
print '<td align="right">'.dol_print_date(dol_filemtime($dir.'/'.$file),'dayhour').'</td>'; print '<td align="right">'.dol_print_date(dol_filemtime($dir.'/'.$file),'dayhour').'</td>';
// Del button // Del button
print '<td align="right"><a href="'.DOL_URL_ROOT.'/document.php?action=remove_file&step=3'.$param.'&modulepart='.$modulepart.'&file='.urlencode($relativepath); print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=delete&step=3'.$param.'&urlfile='.urlencode($relativepath);
print '&urlsource='.urlencode($urlsource);
print '">'.img_delete().'</a></td>'; print '">'.img_delete().'</a></td>';
// Action button // Action button
print '<td align="right">'; print '<td align="right">';

View File

@@ -1000,7 +1000,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js"></script>'."\n";
} }
// jQuery File Upload // jQuery File Upload
if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD)) if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) || defined('REQUIRE_JQUERY_FILEUPLOAD'))
{ {
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/template/tmpl.min.js"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/template/tmpl.min.js"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.iframe-transport.js"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.iframe-transport.js"></script>'."\n";