do not use / in random password and let preg_quote know we use / as delimiter (also fixing ide warnings)

This commit is contained in:
Ralf Becker 2014-02-11 09:20:14 +00:00
parent c9c89c4d66
commit 40018bf777

View File

@ -417,12 +417,13 @@ function patch_header($filename,&$user,$password)
{ {
$header = file_get_contents($filename); $header = file_get_contents($filename);
if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '")."([^']+)';/m",$header,$umatches) || $umatches = $pmatches = null;
!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '")."([^']*)';/m",$header,$pmatches)) if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m",$header,$umatches) ||
!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",$header,$pmatches))
{ {
bail_out(99,"$filename is no regular EGroupware header.inc.php!"); bail_out(99,"$filename is no regular EGroupware header.inc.php!");
} }
file_put_contents($filename,preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '")."([^']*)';/m", file_put_contents($filename,preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",
"\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';",$header)); "\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';",$header));
$user = $umatches[1]; $user = $umatches[1];
@ -445,6 +446,7 @@ function run_cmd($cmd,array &$output=null,$no_bailout=null)
if ($verbose) if ($verbose)
{ {
echo $cmd."\n"; echo $cmd."\n";
$ret = null;
system($cmd,$ret); system($cmd,$ret);
} }
else else
@ -485,8 +487,8 @@ function randomstring($len=16)
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L', 'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'@','!','$','%','&','/','(',')','=','?',';',':','#','_','-','<', '@','!','$','%','&','(',')','=','?',';',':','#','_','-','<',
'>','|','[',']','}', // dont add \,'"{ as we have problems dealing with them '>','|','[',']','}', // dont add /\,'"{ as we have problems dealing with them
); );
$str = ''; $str = '';
@ -532,6 +534,7 @@ function check_install_pear_packages()
{ {
global $config; global $config;
$out = $ret = null;
exec($config['pear'].' list',$out,$ret); exec($config['pear'].' list',$out,$ret);
if ($ret) if ($ret)
{ {
@ -539,8 +542,9 @@ function check_install_pear_packages()
exit(95); exit(95);
} }
$packages_installed = array(); $packages_installed = array();
foreach($out as $n => $line) foreach($out as $line)
{ {
$matches = null;
if (preg_match('/^([a-z0-9_]+)\s+([0-9.]+[a-z0-9]*)\s+([a-z]+)/i',$line,$matches)) if (preg_match('/^([a-z0-9_]+)\s+([0-9.]+[a-z0-9]*)\s+([a-z]+)/i',$line,$matches))
{ {
$packages_installed[$matches[1]] = $matches[2]; $packages_installed[$matches[1]] = $matches[2];
@ -549,6 +553,7 @@ function check_install_pear_packages()
// read required packages from apps // read required packages from apps
$packages = array('PEAR' => true, 'HTTP_WebDAV_Server' => '999.egw-pear'); // pear must be the first, to run it's update first! $packages = array('PEAR' => true, 'HTTP_WebDAV_Server' => '999.egw-pear'); // pear must be the first, to run it's update first!
$egw_pear_packages = array(); $egw_pear_packages = array();
$setup_info = array();
foreach(scandir($config['source_dir']) as $app) foreach(scandir($config['source_dir']) as $app)
{ {
if (is_dir($dir=$config['source_dir'].'/'.$app) && file_exists($file=$dir.'/setup/setup.inc.php')) include $file; if (is_dir($dir=$config['source_dir'].'/'.$app) && file_exists($file=$dir.'/setup/setup.inc.php')) include $file;