use correct makeCorrect(Dir/File) everywhere
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
function findDirs($path, $uid, $gid)
|
||||
{
|
||||
$_fileList = array();
|
||||
$path = makeCorrectDir($path);
|
||||
$path = \Froxlor\FileDir::makeCorrectDir($path);
|
||||
|
||||
// valid directory?
|
||||
if (is_dir($path)) {
|
||||
@@ -77,7 +77,7 @@ function findDirs($path, $uid, $gid)
|
||||
// check every file
|
||||
foreach ($its as $fullFileName => $it) {
|
||||
if ($it->isDir() && (fileowner($fullFileName) == $uid || filegroup($fullFileName) == $gid)) {
|
||||
$_fileList[] = makeCorrectDir(dirname($fullFileName));
|
||||
$_fileList[] = \Froxlor\FileDir::makeCorrectDir(dirname($fullFileName));
|
||||
}
|
||||
}
|
||||
$_fileList[] = $path;
|
||||
|
||||
@@ -49,6 +49,6 @@ function makeChownWithNewStats($row) {
|
||||
// only run chown if directory exists
|
||||
if (file_exists($dir)) {
|
||||
// run chown
|
||||
safe_exec('chown -R '.escapeshellarg($user).':'.escapeshellarg($group).' '.escapeshellarg(makeCorrectDir($dir)));
|
||||
safe_exec('chown -R '.escapeshellarg($user).':'.escapeshellarg($group).' '.escapeshellarg(\Froxlor\FileDir::makeCorrectDir($dir)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ function makePathfield($path, $uid, $gid, $value = '', $dom = false) {
|
||||
if (empty($dir)) {
|
||||
$dir = '/';
|
||||
}
|
||||
$dir = makeCorrectDir($dir);
|
||||
$dir = \Froxlor\FileDir::makeCorrectDir($dir);
|
||||
}
|
||||
$_field.= makeoption($dir, $dir, $value);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ function storeDefaultIndex($loginname = null, $destination = null, $logger = nul
|
||||
);
|
||||
|
||||
$htmlcontent = replace_variables($template['value'], $replace_arr);
|
||||
$indexhtmlpath = makeCorrectFile($destination . '/index.' . Settings::Get('system.index_file_extension'));
|
||||
$indexhtmlpath = \Froxlor\FileDir::makeCorrectFile($destination . '/index.' . Settings::Get('system.index_file_extension'));
|
||||
$index_html_handler = fopen($indexhtmlpath, 'w');
|
||||
fwrite($index_html_handler, $htmlcontent);
|
||||
fclose($index_html_handler);
|
||||
@@ -61,7 +61,7 @@ function storeDefaultIndex($loginname = null, $destination = null, $logger = nul
|
||||
}
|
||||
|
||||
} else {
|
||||
$destination = makeCorrectDir($destination);
|
||||
$destination = \Froxlor\FileDir::makeCorrectDir($destination);
|
||||
if ($logger !== null) {
|
||||
$logger->logAction(CRON_ACTION, LOG_NOTICE, 'Running: cp -a ' . \Froxlor\Froxlor::getInstallDir() . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
|
||||
}
|
||||
|
||||
@@ -63,15 +63,15 @@ function validateFormFieldHiddenString($fieldname, $fielddata, $newfieldvalue)
|
||||
if(substr($newfieldvalue, -1) != '/') {
|
||||
$newfieldvalue.= '/';
|
||||
}
|
||||
$returnvalue = ($newfieldvalue == makeCorrectDir($newfieldvalue));
|
||||
$returnvalue = ($newfieldvalue == \Froxlor\FileDir::makeCorrectDir($newfieldvalue));
|
||||
}
|
||||
elseif(isset($fielddata['string_type']) && $fielddata['string_type'] == 'file')
|
||||
{
|
||||
$returnvalue = ($newfieldvalue == makeCorrectFile($newfieldvalue));
|
||||
$returnvalue = ($newfieldvalue == \Froxlor\FileDir::makeCorrectFile($newfieldvalue));
|
||||
}
|
||||
elseif(isset($fielddata['string_type']) && $fielddata['string_type'] == 'filedir')
|
||||
{
|
||||
$returnvalue = (($newfieldvalue == makeCorrectDir($newfieldvalue)) || ($newfieldvalue == makeCorrectFile($newfieldvalue)));
|
||||
$returnvalue = (($newfieldvalue == \Froxlor\FileDir::makeCorrectDir($newfieldvalue)) || ($newfieldvalue == \Froxlor\FileDir::makeCorrectFile($newfieldvalue)));
|
||||
}
|
||||
elseif(preg_match('/^[^\r\n\t\f\0]*$/D', $newfieldvalue))
|
||||
{
|
||||
|
||||
@@ -65,7 +65,7 @@ function validateFormFieldString($fieldname, $fielddata, $newfieldvalue)
|
||||
if (substr($newfieldvalue, -1) != '/') {
|
||||
$newfieldvalue.= '/';
|
||||
}
|
||||
$returnvalue = ($newfieldvalue == makeCorrectDir($newfieldvalue));
|
||||
$returnvalue = ($newfieldvalue == \Froxlor\FileDir::makeCorrectDir($newfieldvalue));
|
||||
}
|
||||
}
|
||||
elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'confdir') {
|
||||
@@ -84,7 +84,7 @@ function validateFormFieldString($fieldname, $fielddata, $newfieldvalue)
|
||||
$newfieldvalue = '';
|
||||
$returnvalue = 'givendirnotallowed';
|
||||
} else {
|
||||
$returnvalue = ($newfieldvalue == makeCorrectDir($newfieldvalue));
|
||||
$returnvalue = ($newfieldvalue == \Froxlor\FileDir::makeCorrectDir($newfieldvalue));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ function validateFormFieldString($fieldname, $fielddata, $newfieldvalue)
|
||||
$newfieldvalue = '';
|
||||
$returnvalue = 'stringmustntbeempty';
|
||||
} else {
|
||||
$returnvalue = ($newfieldvalue == makeCorrectFile($newfieldvalue));
|
||||
$returnvalue = ($newfieldvalue == \Froxlor\FileDir::makeCorrectFile($newfieldvalue));
|
||||
}
|
||||
}
|
||||
elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'filedir') {
|
||||
@@ -103,7 +103,7 @@ function validateFormFieldString($fieldname, $fielddata, $newfieldvalue)
|
||||
$newfieldvalue = '';
|
||||
$returnvalue = 'stringmustntbeempty';
|
||||
} else {
|
||||
$returnvalue = (($newfieldvalue == makeCorrectDir($newfieldvalue)) || ($newfieldvalue == makeCorrectFile($newfieldvalue)));
|
||||
$returnvalue = (($newfieldvalue == \Froxlor\FileDir::makeCorrectDir($newfieldvalue)) || ($newfieldvalue == \Froxlor\FileDir::makeCorrectFile($newfieldvalue)));
|
||||
}
|
||||
}
|
||||
elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'validate_ip') {
|
||||
|
||||
@@ -37,7 +37,7 @@ function correctErrorDocument($errdoc = null, $throw_exception = false) {
|
||||
) {
|
||||
// a file
|
||||
if (substr($errdoc, 0, 1) != '"') {
|
||||
$errdoc = makeCorrectFile($errdoc);
|
||||
$errdoc = \Froxlor\FileDir::makeCorrectFile($errdoc);
|
||||
// apache needs a starting-slash (starting at the domains-docroot)
|
||||
if (!substr($errdoc, 0, 1) == '/') {
|
||||
$errdoc = '/'.$errdoc;
|
||||
|
||||
@@ -32,7 +32,7 @@ function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot
|
||||
$header = "## GENERATED BY FROXLOR\n";
|
||||
$header2 = "## Do not remove the line above! This tells Froxlor to update this configuration\n## If you wish to manually change this configuration file, remove the first line to make sure Froxlor won't rebuild this file\n## Generated for domain {SITE_DOMAIN} on " . date('l dS \of F Y h:i:s A') . "\n";
|
||||
|
||||
$awstats_dir = makeCorrectDir($customerDocroot.'/awstats/'.$siteDomain.'/');
|
||||
$awstats_dir = \Froxlor\FileDir::makeCorrectDir($customerDocroot.'/awstats/'.$siteDomain.'/');
|
||||
if (!is_dir($awstats_dir)) {
|
||||
safe_exec('mkdir -p '.escapeshellarg($awstats_dir));
|
||||
}
|
||||
@@ -53,17 +53,17 @@ function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot
|
||||
'/\{AWSTATS_CONF\}/'
|
||||
);
|
||||
$replace = array(
|
||||
makeCorrectFile($logFile),
|
||||
\Froxlor\FileDir::makeCorrectFile($logFile),
|
||||
$siteDomain,
|
||||
$hostAliases,
|
||||
$awstats_dir,
|
||||
makeCorrectDir(Settings::Get('system.awstats_conf'))
|
||||
\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.awstats_conf'))
|
||||
);
|
||||
|
||||
// File names
|
||||
$domain_file = makeCorrectFile(Settings::Get('system.awstats_conf').'/awstats.' . $siteDomain . '.conf');
|
||||
$domain_file = \Froxlor\FileDir::makeCorrectFile(Settings::Get('system.awstats_conf').'/awstats.' . $siteDomain . '.conf');
|
||||
$model_file = \Froxlor\Froxlor::getInstallDir().'/templates/misc/awstats/awstats.froxlor.model.conf';
|
||||
$model_file = makeCorrectFile($model_file);
|
||||
$model_file = \Froxlor\FileDir::makeCorrectFile($model_file);
|
||||
|
||||
// Test if the file exists
|
||||
if (file_exists($domain_file)) {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
function getThemes() {
|
||||
|
||||
$themespath = makeCorrectDir(\Froxlor\Froxlor::getInstallDir().'/templates/');
|
||||
$themespath = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir().'/templates/');
|
||||
$themes_available = array();
|
||||
|
||||
if (is_dir($themespath)) {
|
||||
|
||||
@@ -78,7 +78,7 @@ function updateCounters($returndebuginfo = false) {
|
||||
|
||||
while($customer_emails_row = $customer_emails_result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
if($customer_emails_row['destination'] != '') {
|
||||
$customer_emails_row['destination'] = explode(' ', makeCorrectDestination($customer_emails_row['destination']));
|
||||
$customer_emails_row['destination'] = explode(' ', \Froxlor\FileDir::makeCorrectDestination($customer_emails_row['destination']));
|
||||
$customer_email_forwarders+= count($customer_emails_row['destination']);
|
||||
|
||||
if(in_array($customer_emails_row['email_full'], $customer_emails_row['destination'])) {
|
||||
|
||||
@@ -37,9 +37,9 @@ function appendOpenBasedirPath($path = '', $first = false)
|
||||
&& ! preg_match("#:#", $path)) {
|
||||
|
||||
if (preg_match("#^/dev/urandom#i", $path)) {
|
||||
$path = makeCorrectFile($path);
|
||||
$path = \Froxlor\FileDir::makeCorrectFile($path);
|
||||
} else {
|
||||
$path = makeCorrectDir($path);
|
||||
$path = \Froxlor\FileDir::makeCorrectDir($path);
|
||||
}
|
||||
|
||||
// check for php-version that requires the trailing
|
||||
|
||||
@@ -38,7 +38,7 @@ function checkDisallowedPaths($path = null) {
|
||||
"/opt/", "/proc/", "/root/", "/run/", "/sbin/", "/sys/", "/tmp/", "/usr/", "/var/"
|
||||
);
|
||||
|
||||
$path = makeCorrectDir($path);
|
||||
$path = \Froxlor\FileDir::makeCorrectDir($path);
|
||||
|
||||
// check if it's a disallowed path
|
||||
if (in_array($path, $disallowed_values)) {
|
||||
|
||||
@@ -20,13 +20,13 @@ function checkPathConflicts($fieldname, $fielddata, $newfieldvalue, $allnewfield
|
||||
if((int)Settings::Get('system.mod_fcgid') == 1) {
|
||||
// fcgid-configdir has changed -> check against customer-doc-prefix
|
||||
if ($fieldname == "system_mod_fcgid_configdir") {
|
||||
$newdir = makeCorrectDir($newfieldvalue);
|
||||
$cdir = makeCorrectDir(Settings::Get('system.documentroot_prefix'));
|
||||
$newdir = \Froxlor\FileDir::makeCorrectDir($newfieldvalue);
|
||||
$cdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.documentroot_prefix'));
|
||||
}
|
||||
// customer-doc-prefix has changed -> check against fcgid-configdir
|
||||
elseif ($fieldname == "system_documentroot_prefix") {
|
||||
$newdir = makeCorrectDir($newfieldvalue);
|
||||
$cdir = makeCorrectDir(Settings::Get('system.mod_fcgid_configdir'));
|
||||
$newdir = \Froxlor\FileDir::makeCorrectDir($newfieldvalue);
|
||||
$cdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.mod_fcgid_configdir'));
|
||||
}
|
||||
|
||||
// neither dir can be within the other nor can they be equal
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Florian Lippert <flo@syscp.org> (2003-2009)
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function which returns a correct destination for Postfix Virtual Table
|
||||
*
|
||||
* @param string The destinations
|
||||
* @return string the corrected destinations
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
|
||||
function makeCorrectDestination($destination)
|
||||
{
|
||||
$search = '/ +/';
|
||||
$replace = ' ';
|
||||
$destination = preg_replace($search, $replace, $destination);
|
||||
|
||||
if(substr($destination, 0, 1) == ' ')
|
||||
{
|
||||
$destination = substr($destination, 1);
|
||||
}
|
||||
|
||||
if(substr($destination, -1, 1) == ' ')
|
||||
{
|
||||
$destination = substr($destination, 0, strlen($destination) - 1);
|
||||
}
|
||||
|
||||
return $destination;
|
||||
}
|
||||
Reference in New Issue
Block a user