- implemented alternative regex-validation for broken php "filter_var" function in various php-versions, refs #109, #122, #138
- check for webalizer binary in /usr/bin and in /usr/local/bin (freebsd), fixes #140
This commit is contained in:
@@ -37,12 +37,24 @@ function validateDomain($domainname)
|
||||
// If FILTER_VALIDATE_URL is good, but FILTER_VALIDATE_URL with FILTER_FLAG_PATH_REQUIRED or FILTER_FLAG_QUERY_REQUIRED is also good, it isn't just a domain.
|
||||
// This is a ugly hack, maybe a good regex would be better?
|
||||
|
||||
// there is a bug in php 5.2.13 - 5.3.2 which
|
||||
// lets filter_var fail if the domain has
|
||||
// a dash (-) in it. #
|
||||
if(version_compare("5.2.13", PHP_VERSION, ">=")
|
||||
&& version_compare("5.3.2", PHP_VERSION, "<="))
|
||||
{
|
||||
if(filter_var($domainname_tmp, FILTER_VALIDATE_URL) !== false && filter_var($domainname_tmp, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) === false && filter_var($domainname_tmp, FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED) === false)
|
||||
{
|
||||
return $domainname;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$pattern = '/^([a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?\.)+[a-z]{2,6}$/i';
|
||||
if(preg_match($pattern, $domainname_tmp))
|
||||
{
|
||||
return $domainname;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,6 +191,14 @@ function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlis
|
||||
$verbosity = '-Q';
|
||||
}
|
||||
|
||||
$we = '/usr/bin/webalizer';
|
||||
|
||||
// FreeBSD uses other paths, #140
|
||||
if(!file_exists($we))
|
||||
{
|
||||
$we = '/usr/local/bin/webalizer';
|
||||
}
|
||||
|
||||
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Running webalizer for domain '".$caption."'");
|
||||
safe_exec('webalizer ' . $verbosity . ' -p -o ' . escapeshellarg($outputdir) . ' -n ' . escapeshellarg($caption) . $domainargs . ' ' . escapeshellarg($settings['system']['logfiles_directory'] . $logfile . '-access.log'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user