Fix: Fix regression by adding "custom" feature making web server hang in infinite loop.

This commit is contained in:
Laurent Destailleur 2010-12-15 18:15:08 +00:00
parent ebd25c5c75
commit b5e5dc3849
40 changed files with 1892 additions and 1795 deletions

View File

@ -337,10 +337,13 @@ $aliasarray=array();
if (is_dir($aliasDir)) if (is_dir($aliasDir))
{ {
$handle=opendir($aliasDir); $handle=opendir($aliasDir);
if (is_resource($handle))
{
while ($file = readdir($handle)) while ($file = readdir($handle))
{ {
$listoffiles[]=$file; $listoffiles[]=$file;
} }
}
sort($listoffiles); sort($listoffiles);
foreach($listoffiles as $file) foreach($listoffiles as $file)
@ -369,11 +372,14 @@ if (!isset($aliasContents))
// Read projects in www dir // Read projects in www dir
$listoffiles=array(); $listoffiles=array();
$handle=opendir("."); $handle=opendir(".");
while ($file = readdir($handle)) if (is_resource($handle))
{ {
while ($file = readdir($handle))
{
$listoffiles[]=$file; $listoffiles[]=$file;
}
closedir($handle);
} }
closedir($handle);
foreach($listoffiles as $file) foreach($listoffiles as $file)
{ {

View File

@ -208,7 +208,7 @@ clearstatcache();
$dir = "../includes/modules/commande/"; $dir = "../includes/modules/commande/";
$handle = opendir($dir); $handle = opendir($dir);
if ($handle) if (is_resource($handle))
{ {
$var=true; $var=true;
@ -330,8 +330,10 @@ clearstatcache();
$handle=opendir($dir); $handle=opendir($dir);
$var=true; $var=true;
while (($file = readdir($handle))!==false) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_') if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
{ {
$name = substr($file, 4, dol_strlen($file) -16); $name = substr($file, 4, dol_strlen($file) -16);
@ -405,9 +407,9 @@ while (($file = readdir($handle))!==false)
print "</tr>\n"; print "</tr>\n";
} }
}
closedir($handle);
} }
closedir($handle);
print '</table>'; print '</table>';
//Autres Options //Autres Options

View File

@ -177,8 +177,10 @@ clearstatcache();
$handle=opendir($dir); $handle=opendir($dir);
$var=True; $var=True;
while (($file = readdir($handle))!==false) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.modules\.php$/i',$file)) if (preg_match('/\.modules\.php$/i',$file))
{ {
$var = !$var; $var = !$var;
@ -253,8 +255,9 @@ while (($file = readdir($handle))!==false)
print "</tr>\n"; print "</tr>\n";
} }
} }
}
closedir($handle);
} }
closedir($handle);
print '</table>'; print '</table>';

View File

@ -304,6 +304,8 @@ if(is_dir($dir))
$handle=opendir($dir); $handle=opendir($dir);
$var=true; $var=true;
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,15) == 'pdf_expedition_') if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,15) == 'pdf_expedition_')
@ -373,6 +375,7 @@ if(is_dir($dir))
} }
} }
closedir($handle); closedir($handle);
}
} }
else else
{ {

View File

@ -258,7 +258,7 @@ foreach ($conf->file->dol_document_root as $dirroot)
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
@ -414,7 +414,7 @@ foreach ($conf->file->dol_document_root as $dirroot)
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle=opendir($dir); $handle=opendir($dir);
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {

View File

@ -197,7 +197,7 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
$handle = opendir($dir); $handle = opendir($dir);
if ($handle) if (is_resource($handle))
{ {
$var=true; $var=true;
@ -304,8 +304,10 @@ clearstatcache();
$var=true; $var=true;
$handle=opendir($dir); $handle=opendir($dir);
while (($file = readdir($handle))!==false) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false)
{
if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_') if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_')
{ {
$name = substr($file, 4, dol_strlen($file) -16); $name = substr($file, 4, dol_strlen($file) -16);
@ -375,8 +377,9 @@ while (($file = readdir($handle))!==false)
print '</tr>'; print '</tr>';
} }
}
closedir($handle);
} }
closedir($handle);
print '</table>'; print '</table>';

View File

@ -232,7 +232,7 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
$handle = opendir($dir); $handle = opendir($dir);
if ($handle) if (is_resource($handle))
{ {
$var=true; $var=true;
@ -356,8 +356,10 @@ clearstatcache();
$handle=opendir($dir); $handle=opendir($dir);
$var=true; $var=true;
while (($file = readdir($handle))!==false) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_') if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
{ {
$name = substr($file, 4, dol_strlen($file) -16); $name = substr($file, 4, dol_strlen($file) -16);
@ -423,9 +425,10 @@ while (($file = readdir($handle))!==false)
print "</tr>\n"; print "</tr>\n";
} }
} }
closedir($handle); closedir($handle);
}
print '</table><br/>'; print '</table><br/>';
@ -476,8 +479,10 @@ clearstatcache();
$handle=opendir($dir); $handle=opendir($dir);
$var=true; $var=true;
while (($file = readdir($handle)) !== false) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false)
{
if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_') if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
{ {
$name = substr($file, 4, dol_strlen($file) -16); $name = substr($file, 4, dol_strlen($file) -16);
@ -543,6 +548,8 @@ while (($file = readdir($handle)) !== false)
print "</tr>\n"; print "</tr>\n";
} }
}
close($handle);
} }
print '</table><br/>'; print '</table><br/>';

View File

@ -207,7 +207,7 @@ clearstatcache();
$handle = opendir($dir); $handle = opendir($dir);
$var=true; $var=true;
if ($handle) if (is_resource($handle))
{ {
$var=true; $var=true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
@ -329,6 +329,8 @@ if(is_dir($dir))
$handle=opendir($dir); $handle=opendir($dir);
$var=true; $var=true;
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_') if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_')
@ -397,6 +399,7 @@ if(is_dir($dir))
} }
} }
closedir($handle); closedir($handle);
}
} }
else else
{ {

View File

@ -91,7 +91,7 @@ foreach ($conf->file->dol_document_root as $dirroot)
//print $dir."\n<br>"; //print $dir."\n<br>";
dol_syslog("Scan directory ".$dir." for modules"); dol_syslog("Scan directory ".$dir." for modules");
$handle=@opendir($dir); $handle=@opendir($dir);
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {

View File

@ -84,7 +84,7 @@ foreach ($conf->file->dol_document_root as $dirroot)
// Load modules attributes in arrays (name, numero, orders) from dir directory // Load modules attributes in arrays (name, numero, orders) from dir directory
//print $dir."\n<br>"; //print $dir."\n<br>";
$handle=@opendir($dir); $handle=@opendir($dir);
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {

View File

@ -173,7 +173,7 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
$handle = opendir($dir); $handle = opendir($dir);
if ($handle) if (is_resource($handle))
{ {
$var=true; $var=true;
@ -294,8 +294,10 @@ clearstatcache();
$handle=opendir($dir); $handle=opendir($dir);
$var=true; $var=true;
while (($file = readdir($handle))!==false) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_') if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
{ {
$name = substr($file, 4, dol_strlen($file) -16); $name = substr($file, 4, dol_strlen($file) -16);
@ -359,8 +361,9 @@ while (($file = readdir($handle))!==false)
print "</tr>\n"; print "</tr>\n";
} }
}
closedir($handle);
} }
closedir($handle);
print '</table><br/>'; print '</table><br/>';

View File

@ -212,7 +212,7 @@ foreach ($conf->file->dol_document_root as $dirroot)
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
@ -333,8 +333,10 @@ clearstatcache();
$handle=opendir($dir); $handle=opendir($dir);
$var=true; $var=true;
while (($file = readdir($handle))!==false) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false)
{
if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,12) == 'pdf_propale_') if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,12) == 'pdf_propale_')
{ {
$name = substr($file, 12, dol_strlen($file) - 24); $name = substr($file, 12, dol_strlen($file) - 24);
@ -410,8 +412,9 @@ while (($file = readdir($handle))!==false)
print "</tr>\n"; print "</tr>\n";
} }
}
closedir($handle);
} }
closedir($handle);
print '</table>'; print '</table>';
print '<br>'; print '<br>';

View File

@ -218,8 +218,10 @@ $dir = "../includes/modules/security/generate";
clearstatcache(); clearstatcache();
$handle=opendir($dir); $handle=opendir($dir);
$i=1; $i=1;
while (($file = readdir($handle))!==false) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false)
{
if (preg_match('/(modGeneratePass[a-z]+)\.class\.php/i',$file,$reg)) if (preg_match('/(modGeneratePass[a-z]+)\.class\.php/i',$file,$reg))
{ {
// Chargement de la classe de numerotation // Chargement de la classe de numerotation
@ -230,8 +232,9 @@ while (($file = readdir($handle))!==false)
$arrayhandler[$obj->id]=$obj; $arrayhandler[$obj->id]=$obj;
$i++; $i++;
} }
}
closedir($handle);
} }
closedir($handle);
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -188,7 +188,7 @@ clearstatcache();
$dir = "../includes/modules/societe/"; $dir = "../includes/modules/societe/";
$handle = opendir($dir); $handle = opendir($dir);
if ($handle) if (is_resource($handle))
{ {
$var = true; $var = true;
@ -259,7 +259,7 @@ clearstatcache();
$dir = "../includes/modules/societe/"; $dir = "../includes/modules/societe/";
$handle = opendir($dir); $handle = opendir($dir);
if ($handle) if (is_resource($handle))
{ {
$var = true; $var = true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
@ -348,7 +348,7 @@ foreach ($conf->file->dol_document_root as $dirroot)
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle=opendir($dir); $handle=opendir($dir);
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {

View File

@ -55,6 +55,8 @@ foreach($conf->file->dol_document_root as $searchdir)
if (preg_match('/custom$/i',$searchdir)) $dirtoscan = $searchdir . "/modules/"; if (preg_match('/custom$/i',$searchdir)) $dirtoscan = $searchdir . "/modules/";
else $dirtoscan = $searchdir . "/includes/modules/"; else $dirtoscan = $searchdir . "/includes/modules/";
$handle=opendir($dirtoscan); $handle=opendir($dirtoscan);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (is_readable($dirtoscan.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') if (is_readable($dirtoscan.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
@ -73,6 +75,8 @@ foreach($conf->file->dol_document_root as $searchdir)
} }
} }
} }
close($handle);
}
} }
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -1097,7 +1097,8 @@ class Categorie
if (file_exists($dir)) if (file_exists($dir))
{ {
$handle=opendir($dir); $handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle)) != false) while (($file = readdir($handle)) != false)
{ {
if (is_file($dir.$file)) if (is_file($dir.$file))
@ -1126,6 +1127,7 @@ class Categorie
} }
closedir($handle); closedir($handle);
}
} }
return $tabobj; return $tabobj;

View File

@ -236,7 +236,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle=opendir($dir); $handle=opendir($dir);
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {

View File

@ -73,8 +73,10 @@ $dir=DOL_DOCUMENT_ROOT."/includes/modules/mailings";
$handle=opendir($dir); $handle=opendir($dir);
$var=True; $var=True;
while (($file = readdir($handle))!==false) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false)
{
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{ {
if (preg_match("/(.*)\.(.*)\.(.*)/i",$file,$reg)) if (preg_match("/(.*)\.(.*)\.(.*)/i",$file,$reg))
@ -133,9 +135,9 @@ while (($file = readdir($handle))!==false)
} }
} }
} }
}
closedir($handle);
} }
closedir($handle);
print "</table><br>"; print "</table><br>";

View File

@ -134,6 +134,8 @@ $found=0;
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle=opendir($dir); $handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (is_dir($dir.'/'.$file) && ! preg_match('/^\./',$file)) if (is_dir($dir.'/'.$file) && ! preg_match('/^\./',$file))
@ -142,6 +144,7 @@ if (is_dir($dir))
$linkforyear[]=$file; $linkforyear[]=$file;
} }
} }
}
} }
asort($linkforyear); asort($linkforyear);
foreach($linkforyear as $cursoryear) foreach($linkforyear as $cursoryear)
@ -164,6 +167,8 @@ if ($year)
print '<td align="right">'.$langs->trans("Date").'</td>'; print '<td align="right">'.$langs->trans("Date").'</td>';
print '</tr>'; print '</tr>';
$var=true; $var=true;
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (preg_match('/^payment/i',$file)) if (preg_match('/^payment/i',$file))
@ -176,6 +181,8 @@ if ($year)
print '<td align="right">'.dol_print_date(dol_filemtime($tfile),"dayhour").'</td></tr>'; print '<td align="right">'.dol_print_date(dol_filemtime($tfile),"dayhour").'</td></tr>';
} }
} }
close($handle);
}
print '</table>'; print '</table>';
} }
} }

View File

@ -135,6 +135,8 @@ class FormAdmin
$menuarray=array(); $menuarray=array();
$handle=opendir($dirmenu); $handle=opendir($dirmenu);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (is_file($dirmenu."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') if (is_file($dirmenu."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
@ -154,6 +156,8 @@ class FormAdmin
$menuarray[$prefix.'_'.$file]='<option value="'.$file.'">'.$filelib.'</option>'; $menuarray[$prefix.'_'.$file]='<option value="'.$file.'">'.$filelib.'</option>';
} }
} }
}
close($handle);
} }
ksort($menuarray); ksort($menuarray);
@ -194,6 +198,8 @@ class FormAdmin
foreach($dirmenuarray as $dirmenu) foreach($dirmenuarray as $dirmenu)
{ {
$handle=opendir($dirmenu); $handle=opendir($dirmenu);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (is_file($dirmenu."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') if (is_file($dirmenu."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
@ -208,6 +214,7 @@ class FormAdmin
$menuarray['all']=1; $menuarray['all']=1;
} }
closedir($handle); closedir($handle);
}
} }
ksort($menuarray); ksort($menuarray);

View File

@ -76,7 +76,8 @@ class Interfaces
$handle=opendir($dir); $handle=opendir($dir);
$modules = array(); $modules = array();
$nbfile = $nbtotal = $nbok = $nbko = 0; $nbfile = $nbtotal = $nbok = $nbko = 0;
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (is_readable($dir."/".$file) && preg_match('/^interface_([^_]+)_(.+)\.class\.php$/i',$file,$reg)) if (is_readable($dir."/".$file) && preg_match('/^interface_([^_]+)_(.+)\.class\.php$/i',$file,$reg))
@ -156,6 +157,7 @@ class Interfaces
} }
} }
closedir($handle); closedir($handle);
}
} }
if ($nbko) if ($nbko)
@ -191,7 +193,8 @@ class Interfaces
if (!is_dir($dir)) continue; if (!is_dir($dir)) continue;
$handle=opendir($dir); $handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (is_readable($dir.'/'.$file) && preg_match('/^interface_([^_]+)_(.+)\.class\.php/',$file,$reg)) if (is_readable($dir.'/'.$file) && preg_match('/^interface_([^_]+)_(.+)\.class\.php/',$file,$reg))
@ -222,6 +225,7 @@ class Interfaces
} }
} }
closedir($handle); closedir($handle);
}
} }
asort($orders); asort($orders);

View File

@ -127,7 +127,7 @@ $errorlevel=error_reporting();
error_reporting(0); error_reporting(0);
$handle=opendir($upload_dir); $handle=opendir($upload_dir);
error_reporting($errorlevel); error_reporting($errorlevel);
if ($handle) if (is_resource($handle))
{ {
$i=0; $i=0;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)

View File

@ -78,7 +78,7 @@ class Export
// Search available exports // Search available exports
$handle=@opendir($dir); $handle=@opendir($dir);
if ($handle) if (is_resource($handle))
{ {
$var=True; $var=True;
$i=0; $i=0;

View File

@ -70,7 +70,7 @@ class Import
// Search available exports // Search available exports
$handle=@opendir($dir); $handle=@opendir($dir);
if ($handle) if (is_resource($handle))
{ {
// Recherche des exports disponibles // Recherche des exports disponibles
$var=True; $var=True;

View File

@ -551,7 +551,7 @@ if ($step == 3 && $datatoimport)
$dir = $conf->import->dir_temp; $dir = $conf->import->dir_temp;
$newdir=utf8_check($dir)?utf8_decode($dir):$dir; // opendir need ISO $newdir=utf8_check($dir)?utf8_decode($dir):$dir; // opendir need ISO
$handle=@opendir($newdir); $handle=@opendir($newdir);
if ($handle) if (is_resource($handle))
{ {
//print '<tr><td colspan="4">'; //print '<tr><td colspan="4">';
//print '<table class="noborder" width="100%">'; //print '<table class="noborder" width="100%">';

View File

@ -501,7 +501,7 @@ class DolibarrModules
// Run llx_mytable.sql files // Run llx_mytable.sql files
$handle=@opendir($dir); // Dir may not exists $handle=@opendir($dir); // Dir may not exists
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
@ -516,7 +516,7 @@ class DolibarrModules
// Run llx_mytable.key.sql files // Run llx_mytable.key.sql files
$handle=@opendir($dir); // Dir may not exist $handle=@opendir($dir); // Dir may not exist
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
@ -531,7 +531,7 @@ class DolibarrModules
// Run data_xxx.sql files // Run data_xxx.sql files
$handle=@opendir($dir); // Dir may not exist $handle=@opendir($dir); // Dir may not exist
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {

View File

@ -89,7 +89,7 @@ foreach ($conf->file->dol_document_root as $dirroot)
$dir = $dirroot . "/includes/modules/barcode/"; $dir = $dirroot . "/includes/modules/barcode/";
$handle=@opendir($dir); $handle=@opendir($dir);
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {

View File

@ -64,6 +64,8 @@ class ModeleExports
// Recherche des fichiers drivers exports disponibles // Recherche des fichiers drivers exports disponibles
$var=True; $var=True;
$i=0; $i=0;
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (preg_match("/^export_(.*)\.modules\.php$/i",$file,$reg)) if (preg_match("/^export_(.*)\.modules\.php$/i",$file,$reg))
@ -90,7 +92,8 @@ class ModeleExports
$i++; $i++;
} }
} }
close($handle);
}
return $this->driverlabel; return $this->driverlabel;
} }

View File

@ -64,6 +64,8 @@ class ModeleImports
// Recherche des fichiers drivers imports disponibles // Recherche des fichiers drivers imports disponibles
$var=True; $var=True;
$i=0; $i=0;
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (preg_match("/^import_(.*)\.modules\.php/i",$file,$reg)) if (preg_match("/^import_(.*)\.modules\.php/i",$file,$reg))
@ -90,6 +92,7 @@ class ModeleImports
$i++; $i++;
} }
} }
}
return array_keys($this->driverlabel); return array_keys($this->driverlabel);
} }

View File

@ -149,6 +149,8 @@ if ($_POST["action"] == "set")
dolibarr_install_syslog("Open tables directory ".$dir." handle=".$handle,LOG_DEBUG); dolibarr_install_syslog("Open tables directory ".$dir." handle=".$handle,LOG_DEBUG);
$tablefound = 0; $tablefound = 0;
$tabledata=array(); $tabledata=array();
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && ! preg_match('/\.key\.sql$/i',$file)) if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && ! preg_match('/\.key\.sql$/i',$file))
@ -158,6 +160,7 @@ if ($_POST["action"] == "set")
} }
} }
closedir($handle); closedir($handle);
}
// Sort list of sql files on alphabetical order (load order is important) // Sort list of sql files on alphabetical order (load order is important)
sort($tabledata); sort($tabledata);
@ -255,6 +258,8 @@ if ($_POST["action"] == "set")
dolibarr_install_syslog("Open keys directory ".$dir." handle=".$handle,LOG_DEBUG); dolibarr_install_syslog("Open keys directory ".$dir." handle=".$handle,LOG_DEBUG);
$tablefound = 0; $tablefound = 0;
$tabledata=array(); $tabledata=array();
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && preg_match('/\.key\.sql$/i',$file)) if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && preg_match('/\.key\.sql$/i',$file))
@ -264,6 +269,7 @@ if ($_POST["action"] == "set")
} }
} }
closedir($handle); closedir($handle);
}
// Sort list of sql files on alphabetical order (load order is important) // Sort list of sql files on alphabetical order (load order is important)
sort($tabledata); sort($tabledata);
@ -474,6 +480,8 @@ if ($_POST["action"] == "set")
dolibarr_install_syslog("Open directory data ".$dir." handle=".$handle,LOG_DEBUG); dolibarr_install_syslog("Open directory data ".$dir." handle=".$handle,LOG_DEBUG);
$tablefound = 0; $tablefound = 0;
$tabledata=array(); $tabledata=array();
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file)) if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file))
@ -483,6 +491,7 @@ if ($_POST["action"] == "set")
} }
} }
closedir($handle); closedir($handle);
}
// Sort list of data files on alphabetical order (load order is important) // Sort list of data files on alphabetical order (load order is important)
sort($tabledata); sort($tabledata);

View File

@ -250,13 +250,15 @@ if (1 == 2) { // Disabled during install process because HTTPS may not be yet
$defaultype=! empty($dolibarr_main_db_type)?$dolibarr_main_db_type:($force_install_type?$force_install_type:'mysqli'); $defaultype=! empty($dolibarr_main_db_type)?$dolibarr_main_db_type:($force_install_type?$force_install_type:'mysqli');
// Scan les drivers
$dir=DOL_DOCUMENT_ROOT.'/lib/databases';
$handle=opendir($dir);
$modules = array(); $modules = array();
$nbok = $nbko = 0; $nbok = $nbko = 0;
$option=''; $option='';
// Scan les drivers
$dir=DOL_DOCUMENT_ROOT.'/lib/databases';
$handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (is_readable($dir."/".$file) && preg_match('/^(.*)\.lib\.php/i',$file,$reg)) if (is_readable($dir."/".$file) && preg_match('/^(.*)\.lib\.php/i',$file,$reg))
@ -294,6 +296,7 @@ if (1 == 2) { // Disabled during install process because HTTPS may not be yet
$option.='</option>'; $option.='</option>';
} }
} }
}
?> <select name='db_type'> ?> <select name='db_type'>
<?php echo $option ?> <?php echo $option ?>

View File

@ -163,10 +163,13 @@ if ($ok)
# Recupere list fichier # Recupere list fichier
$filesindir=array(); $filesindir=array();
$handle=opendir($dir); $handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (preg_match('/\.sql$/i',$file)) $filesindir[]=$file; if (preg_match('/\.sql$/i',$file)) $filesindir[]=$file;
} }
}
sort($filesindir); sort($filesindir);
foreach($filesindir as $file) foreach($filesindir as $file)

View File

@ -290,7 +290,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
# Recupere list fichier # Recupere list fichier
$filesindir=array(); $filesindir=array();
$handle=opendir($dir); $handle=opendir($dir);
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {

View File

@ -1438,7 +1438,8 @@ function getLoginMethod()
if (!is_dir($dir)) continue; if (!is_dir($dir)) continue;
$handle=opendir($dir); $handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (is_readable($dir.'/'.$file) && preg_match('/^functions_([^_]+)\.php/',$file,$reg)) if (is_readable($dir.'/'.$file) && preg_match('/^functions_([^_]+)\.php/',$file,$reg))
@ -1469,6 +1470,7 @@ function getLoginMethod()
} }
} }
} }
}
closedir($handle); closedir($handle);
} }
return $login; return $login;

View File

@ -232,7 +232,8 @@ if ($conf->global->PRODUCT_CANVAS_ABILITY)
require_once(DOL_DOCUMENT_ROOT . "/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT . "/product/class/product.class.php");
$handle=opendir($dir); $handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (file_exists($dir.$file.'/product.'.$file.'.class.php')) if (file_exists($dir.$file.'/product.'.$file.'.class.php'))
@ -272,9 +273,9 @@ if ($conf->global->PRODUCT_CANVAS_ABILITY)
} }
} }
} }
closedir($handle); closedir($handle);
} }
}
else else
{ {
print "<tr><td><b>ERROR</b>: $dir is not a directory !</td></tr>\n"; print "<tr><td><b>ERROR</b>: $dir is not a directory !</td></tr>\n";

View File

@ -2462,12 +2462,15 @@ class Product extends CommonObject
if (file_exists($dir_osencoded)) if (file_exists($dir_osencoded))
{ {
$handle=opendir($dir_osencoded); $handle=opendir($dir_osencoded);
if (is_resource($handle))
{
while (($file = readdir($handle)) != false) while (($file = readdir($handle)) != false)
{ {
if (! utf8_check($file)) $file=utf8_encode($file); // To be sure data is stored in UTF8 in memory if (! utf8_check($file)) $file=utf8_encode($file); // To be sure data is stored in UTF8 in memory
if (dol_is_file($dir.$file)) return true; if (dol_is_file($dir.$file)) return true;
} }
} }
}
return false; return false;
} }
@ -2502,6 +2505,8 @@ class Product extends CommonObject
if (file_exists($dir_osencoded)) if (file_exists($dir_osencoded))
{ {
$handle=opendir($dir_osencoded); $handle=opendir($dir_osencoded);
if (is_resource($handle))
{
while (($file = readdir($handle)) != false) while (($file = readdir($handle)) != false)
{ {
$photo=''; $photo='';
@ -2596,6 +2601,7 @@ class Product extends CommonObject
if ($nbmax && $nbphoto >= $nbmax) break; if ($nbmax && $nbphoto >= $nbmax) break;
} }
} }
}
if ($nbbyrow && $size==1) if ($nbbyrow && $size==1)
{ {
@ -2632,7 +2638,7 @@ class Product extends CommonObject
$dir_osencoded=dol_osencode($dir); $dir_osencoded=dol_osencode($dir);
$handle=@opendir($dir_osencoded); $handle=@opendir($dir_osencoded);
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle)) != false) while (($file = readdir($handle)) != false)
{ {

View File

@ -81,6 +81,8 @@ foreach ($dirlist as $dirroot)
// Charge tableaux modules, nom, numero, orders depuis repertoire dir // Charge tableaux modules, nom, numero, orders depuis repertoire dir
$handle=opendir($dir); $handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
//print "$i ".$file."\n<br>"; //print "$i ".$file."\n<br>";
@ -126,7 +128,7 @@ foreach ($dirlist as $dirroot)
} }
} }
} }
}
} }
asort($orders); asort($orders);

View File

@ -212,7 +212,7 @@ if ($socid > 0)
error_reporting(0); error_reporting(0);
$handle=opendir($courrier_dir); $handle=opendir($courrier_dir);
error_reporting($errorlevel); error_reporting($errorlevel);
if ($handle) if (is_resource($handle))
{ {
$i=0; $i=0;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)

View File

@ -101,7 +101,7 @@ if ($_GET["id"])
// Load modules attributes in arrays (name, numero, orders) from dir directory // Load modules attributes in arrays (name, numero, orders) from dir directory
//print $dir."\n<br>"; //print $dir."\n<br>";
$handle=@opendir($dir); $handle=@opendir($dir);
if ($handle) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {

View File

@ -128,6 +128,8 @@ foreach($listdir as $dirroot)
$dir=$dirroot."/includes/modules/"; $dir=$dirroot."/includes/modules/";
$handle=opendir($dir); $handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
@ -148,6 +150,7 @@ foreach($listdir as $dirroot)
} }
} }
} }
}
} }
$db->commit(); $db->commit();