more function reduction
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -281,7 +281,7 @@ if ($action == '2fa_entercode') {
|
|||||||
$replace_arr = array(
|
$replace_arr = array(
|
||||||
'CODE' => $code
|
'CODE' => $code
|
||||||
);
|
);
|
||||||
$mail_body = html_entity_decode(replace_variables($lng['mails']['2fa']['mailbody'], $replace_arr));
|
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables($lng['mails']['2fa']['mailbody'], $replace_arr));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$mail->Subject = $lng['mails']['2fa']['subject'];
|
$mail->Subject = $lng['mails']['2fa']['subject'];
|
||||||
@@ -496,7 +496,7 @@ if ($action == 'forgotpwd') {
|
|||||||
"lang" => $def_language
|
"lang" => $def_language
|
||||||
));
|
));
|
||||||
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$mail_subject = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['password_reset']['subject']), $replace_arr));
|
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['password_reset']['subject']), $replace_arr));
|
||||||
|
|
||||||
$result_stmt = Database::prepare('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '`
|
$result_stmt = Database::prepare('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '`
|
||||||
WHERE `adminid`= :adminid
|
WHERE `adminid`= :adminid
|
||||||
@@ -508,7 +508,7 @@ if ($action == 'forgotpwd') {
|
|||||||
"lang" => $def_language
|
"lang" => $def_language
|
||||||
));
|
));
|
||||||
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$mail_body = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['password_reset']['mailbody']), $replace_arr));
|
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['password_reset']['mailbody']), $replace_arr));
|
||||||
|
|
||||||
$_mailerror = false;
|
$_mailerror = false;
|
||||||
$mailerr_msg = "";
|
$mailerr_msg = "";
|
||||||
|
|||||||
@@ -457,7 +457,7 @@ abstract class ApiCommand extends ApiParameter
|
|||||||
"var" => $varname
|
"var" => $varname
|
||||||
), true, true);
|
), true, true);
|
||||||
// @fixme html_entity_decode
|
// @fixme html_entity_decode
|
||||||
$content = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $default), $replace_arr));
|
$content = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result['value'] != '') ? $result['value'] : $default), $replace_arr));
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -760,14 +760,14 @@ class Apache extends HttpConfigBase
|
|||||||
|
|
||||||
if (Settings::Get('system.logfiles_piped') == '1' && Settings::Get('system.logfiles_script') != '') {
|
if (Settings::Get('system.logfiles_piped') == '1' && Settings::Get('system.logfiles_script') != '') {
|
||||||
// replace for error_log
|
// replace for error_log
|
||||||
$command = replace_variables(Settings::Get('system.logfiles_script'), array(
|
$command = \Froxlor\PhpHelper::replace_variables(Settings::Get('system.logfiles_script'), array(
|
||||||
'LOGFILE' => $error_log,
|
'LOGFILE' => $error_log,
|
||||||
'DOMAIN' => $domain['domain'],
|
'DOMAIN' => $domain['domain'],
|
||||||
'CUSTOMER' => $domain['loginname']
|
'CUSTOMER' => $domain['loginname']
|
||||||
));
|
));
|
||||||
$logfiles_text .= ' ErrorLog "| ' . $command . "\"\n";
|
$logfiles_text .= ' ErrorLog "| ' . $command . "\"\n";
|
||||||
// replace for access_log
|
// replace for access_log
|
||||||
$command = replace_variables(Settings::Get('system.logfiles_script'), array(
|
$command = \Froxlor\PhpHelper::replace_variables(Settings::Get('system.logfiles_script'), array(
|
||||||
'LOGFILE' => $access_log,
|
'LOGFILE' => $access_log,
|
||||||
'DOMAIN' => $domain['domain'],
|
'DOMAIN' => $domain['domain'],
|
||||||
'CUSTOMER' => $domain['loginname']
|
'CUSTOMER' => $domain['loginname']
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class HttpConfigBase
|
|||||||
'SCHEME' => ($is_ssl_vhost) ? 'https' : 'http',
|
'SCHEME' => ($is_ssl_vhost) ? 'https' : 'http',
|
||||||
'DOCROOT' => $domain['documentroot']
|
'DOCROOT' => $domain['documentroot']
|
||||||
);
|
);
|
||||||
return replace_variables($template, $templateVars);
|
return \Froxlor\PhpHelper::replace_variables($template, $templateVars);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getMyPath($ip_port = null)
|
protected function getMyPath($ip_port = null)
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class Fcgid
|
|||||||
$phpini_file .= "; php.ini created/changed on " . date("Y.m.d H:i:s") . " for domain '" . $this->_domain['domain'] . "' with id #" . $this->_domain['id'] . " from php template '" . $phpconfig['description'] . "' with id #" . $phpconfig['id'] . "\n";
|
$phpini_file .= "; php.ini created/changed on " . date("Y.m.d H:i:s") . " for domain '" . $this->_domain['domain'] . "' with id #" . $this->_domain['id'] . " from php template '" . $phpconfig['description'] . "' with id #" . $phpconfig['id'] . "\n";
|
||||||
$phpini_file .= "; Do not change anything in this file, it will be overwritten by the Froxlor Cronjob!\n";
|
$phpini_file .= "; Do not change anything in this file, it will be overwritten by the Froxlor Cronjob!\n";
|
||||||
$phpini_file .= ";\n\n";
|
$phpini_file .= ";\n\n";
|
||||||
$phpini_file .= replace_variables($phpconfig['phpsettings'], $php_ini_variables);
|
$phpini_file .= \Froxlor\PhpHelper::replace_variables($phpconfig['phpsettings'], $php_ini_variables);
|
||||||
$phpini_file = str_replace('"none"', 'none', $phpini_file);
|
$phpini_file = str_replace('"none"', 'none', $phpini_file);
|
||||||
// $phpini_file = preg_replace('/\"+/', '"', $phpini_file);
|
// $phpini_file = preg_replace('/\"+/', '"', $phpini_file);
|
||||||
$phpini_file_handler = fopen($this->getIniFile(), 'w');
|
$phpini_file_handler = fopen($this->getIniFile(), 'w');
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ class Fpm
|
|||||||
'CUSTOMER_HOMEDIR' => \Froxlor\FileDir::makeCorrectDir($this->_domain['customerroot'])
|
'CUSTOMER_HOMEDIR' => \Froxlor\FileDir::makeCorrectDir($this->_domain['customerroot'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$phpini = replace_variables($phpconfig['phpsettings'], $php_ini_variables);
|
$phpini = \Froxlor\PhpHelper::replace_variables($phpconfig['phpsettings'], $php_ini_variables);
|
||||||
$phpini_array = explode("\n", $phpini);
|
$phpini_array = explode("\n", $phpini);
|
||||||
|
|
||||||
$fpm_config .= "\n\n";
|
$fpm_config .= "\n\n";
|
||||||
|
|||||||
@@ -95,9 +95,9 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
|
|||||||
);
|
);
|
||||||
|
|
||||||
$lngfile_stmt = Database::prepare("
|
$lngfile_stmt = Database::prepare("
|
||||||
SELECT `file` FROM `" . TABLE_PANEL_LANGUAGE . "`
|
SELECT `file` FROM `" . TABLE_PANEL_LANGUAGE . "`
|
||||||
WHERE `language` = :deflang
|
WHERE `language` = :deflang
|
||||||
");
|
");
|
||||||
$lngfile = Database::pexecute_first($lngfile_stmt, array(
|
$lngfile = Database::pexecute_first($lngfile_stmt, array(
|
||||||
'deflang' => $row['def_language']
|
'deflang' => $row['def_language']
|
||||||
));
|
));
|
||||||
@@ -129,11 +129,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
|
|||||||
'varname' => 'trafficmaxpercent_subject'
|
'varname' => 'trafficmaxpercent_subject'
|
||||||
);
|
);
|
||||||
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
||||||
$mail_subject = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
|
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
|
||||||
|
|
||||||
$result2_data['varname'] = 'trafficmaxpercent_mailbody';
|
$result2_data['varname'] = 'trafficmaxpercent_mailbody';
|
||||||
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
||||||
$mail_body = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
|
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
|
||||||
|
|
||||||
$_mailerror = false;
|
$_mailerror = false;
|
||||||
$mailerr_msg = "";
|
$mailerr_msg = "";
|
||||||
@@ -231,11 +231,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
|
|||||||
'varname' => 'trafficmaxpercent_subject'
|
'varname' => 'trafficmaxpercent_subject'
|
||||||
);
|
);
|
||||||
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
||||||
$mail_subject = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
|
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
|
||||||
|
|
||||||
$resul2_data['varname'] = 'trafficmaxpercent_mailbody';
|
$resul2_data['varname'] = 'trafficmaxpercent_mailbody';
|
||||||
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
||||||
$mail_body = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
|
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
|
||||||
|
|
||||||
$_mailerror = false;
|
$_mailerror = false;
|
||||||
$mailerr_msg = "";
|
$mailerr_msg = "";
|
||||||
|
|||||||
@@ -1,20 +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 Cron
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
@@ -85,11 +85,11 @@ if ((int)Settings::Get('system.report_webmax') > 0)
|
|||||||
'varname' => 'diskmaxpercent_subject'
|
'varname' => 'diskmaxpercent_subject'
|
||||||
);
|
);
|
||||||
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
||||||
$mail_subject = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr));
|
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr));
|
||||||
|
|
||||||
$result2_data['varname'] = 'diskmaxpercent_mailbody';
|
$result2_data['varname'] = 'diskmaxpercent_mailbody';
|
||||||
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
||||||
$mail_body = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr));
|
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr));
|
||||||
|
|
||||||
$_mailerror = false;
|
$_mailerror = false;
|
||||||
try {
|
try {
|
||||||
@@ -175,11 +175,11 @@ if ((int)Settings::Get('system.report_webmax') > 0)
|
|||||||
'varname' => 'diskmaxpercent_subject'
|
'varname' => 'diskmaxpercent_subject'
|
||||||
);
|
);
|
||||||
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
||||||
$mail_subject = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr));
|
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr));
|
||||||
|
|
||||||
$result2_data['varname'] = 'diskmaxpercent_mailbody';
|
$result2_data['varname'] = 'diskmaxpercent_mailbody';
|
||||||
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
|
||||||
$mail_body = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr));
|
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr));
|
||||||
|
|
||||||
$_mailerror = false;
|
$_mailerror = false;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -318,6 +318,69 @@ class FileDir
|
|||||||
return $destination;
|
return $destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of found directories
|
||||||
|
*
|
||||||
|
* This function checks every found directory if they match either $uid or $gid, if they do
|
||||||
|
* the found directory is valid. It uses recursive-iterators to find subdirectories.
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* the path to start searching in
|
||||||
|
* @param int $uid
|
||||||
|
* the uid which must match the found directories
|
||||||
|
* @param int $gid
|
||||||
|
* the gid which must match the found direcotries
|
||||||
|
*
|
||||||
|
* @return array Array of found valid paths
|
||||||
|
*/
|
||||||
|
public static function findDirs($path, $uid, $gid)
|
||||||
|
{
|
||||||
|
$_fileList = array();
|
||||||
|
$path = self::makeCorrectDir($path);
|
||||||
|
|
||||||
|
// valid directory?
|
||||||
|
if (is_dir($path)) {
|
||||||
|
|
||||||
|
// Will exclude everything under these directories
|
||||||
|
$exclude = array(
|
||||||
|
'awstats',
|
||||||
|
'webalizer'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param SplFileInfo $file
|
||||||
|
* @param mixed $key
|
||||||
|
* @param RecursiveCallbackFilterIterator $iterator
|
||||||
|
* @return bool True if you need to recurse or if the item is acceptable
|
||||||
|
*/
|
||||||
|
$filter = function ($file, $key, $iterator) use ($exclude) {
|
||||||
|
if (in_array($file->getFilename(), $exclude)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// create RecursiveIteratorIterator
|
||||||
|
$its = new \RecursiveIteratorIterator(new \RecursiveCallbackFilterIterator(new IgnorantRecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), $filter));
|
||||||
|
// we can limit the recursion-depth, but will it be helpful or
|
||||||
|
// will people start asking "why do I only see 2 subdirectories, i want to use /a/b/c"
|
||||||
|
// let's keep this in mind and see whether it will be useful
|
||||||
|
// @TODO
|
||||||
|
// $its->setMaxDepth(2);
|
||||||
|
|
||||||
|
// check every file
|
||||||
|
foreach ($its as $fullFileName => $it) {
|
||||||
|
if ($it->isDir() && (fileowner($fullFileName) == $uid || filegroup($fullFileName) == $gid)) {
|
||||||
|
$_fileList[] = self::makeCorrectDir(dirname($fullFileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$_fileList[] = $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_unique($_fileList);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if the system is FreeBSD (if exact)
|
* check if the system is FreeBSD (if exact)
|
||||||
* or BSD-based (NetBSD, OpenBSD, etc.
|
* or BSD-based (NetBSD, OpenBSD, etc.
|
||||||
@@ -381,4 +444,23 @@ class FileDir
|
|||||||
return 'chattr ' . (($remove === true) ? '-i ' : '+i ');
|
return 'chattr ' . (($remove === true) ? '-i ' : '+i ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If you use RecursiveDirectoryIterator with RecursiveIteratorIterator and run
|
||||||
|
* into UnexpectedValueException you may use this little hack to ignore those
|
||||||
|
* directories, such as lost+found on linux.
|
||||||
|
* (User "antennen" @ http://php.net/manual/en/class.recursivedirectoryiterator.php#101654)
|
||||||
|
*/
|
||||||
|
class IgnorantRecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
||||||
|
{
|
||||||
|
|
||||||
|
function getChildren()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return new IgnorantRecursiveDirectoryIterator($this->getPathname());
|
||||||
|
} catch (\UnexpectedValueException $e) {
|
||||||
|
return new \RecursiveArrayIterator(array());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,106 +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
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array of found directories
|
|
||||||
*
|
|
||||||
* This function checks every found directory if they match either $uid or $gid, if they do
|
|
||||||
* the found directory is valid. It uses recursive-iterators to find subdirectories.
|
|
||||||
*
|
|
||||||
* @param string $path
|
|
||||||
* the path to start searching in
|
|
||||||
* @param int $uid
|
|
||||||
* the uid which must match the found directories
|
|
||||||
* @param int $gid
|
|
||||||
* the gid which must match the found direcotries
|
|
||||||
*
|
|
||||||
* @return array Array of found valid paths
|
|
||||||
*/
|
|
||||||
function findDirs($path, $uid, $gid)
|
|
||||||
{
|
|
||||||
$_fileList = array();
|
|
||||||
$path = \Froxlor\FileDir::makeCorrectDir($path);
|
|
||||||
|
|
||||||
// valid directory?
|
|
||||||
if (is_dir($path)) {
|
|
||||||
|
|
||||||
// Will exclude everything under these directories
|
|
||||||
$exclude = array(
|
|
||||||
'awstats',
|
|
||||||
'webalizer'
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param SplFileInfo $file
|
|
||||||
* @param mixed $key
|
|
||||||
* @param RecursiveCallbackFilterIterator $iterator
|
|
||||||
* @return bool True if you need to recurse or if the item is acceptable
|
|
||||||
*/
|
|
||||||
$filter = function ($file, $key, $iterator) use ($exclude) {
|
|
||||||
if (in_array($file->getFilename(), $exclude)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// create RecursiveIteratorIterator
|
|
||||||
$its = new RecursiveIteratorIterator(
|
|
||||||
new RecursiveCallbackFilterIterator(
|
|
||||||
new IgnorantRecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),
|
|
||||||
$filter
|
|
||||||
)
|
|
||||||
);
|
|
||||||
// we can limit the recursion-depth, but will it be helpful or
|
|
||||||
// will people start asking "why do I only see 2 subdirectories, i want to use /a/b/c"
|
|
||||||
// let's keep this in mind and see whether it will be useful
|
|
||||||
// @TODO
|
|
||||||
// $its->setMaxDepth(2);
|
|
||||||
|
|
||||||
// check every file
|
|
||||||
foreach ($its as $fullFileName => $it) {
|
|
||||||
if ($it->isDir() && (fileowner($fullFileName) == $uid || filegroup($fullFileName) == $gid)) {
|
|
||||||
$_fileList[] = \Froxlor\FileDir::makeCorrectDir(dirname($fullFileName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$_fileList[] = $path;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_unique($_fileList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If you use RecursiveDirectoryIterator with RecursiveIteratorIterator and run
|
|
||||||
* into UnexpectedValueException you may use this little hack to ignore those
|
|
||||||
* directories, such as lost+found on linux.
|
|
||||||
* (User "antennen" @ http://php.net/manual/en/class.recursivedirectoryiterator.php#101654)
|
|
||||||
*/
|
|
||||||
class IgnorantRecursiveDirectoryIterator extends RecursiveDirectoryIterator
|
|
||||||
{
|
|
||||||
|
|
||||||
function getChildren()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return new IgnorantRecursiveDirectoryIterator($this->getPathname());
|
|
||||||
} catch (UnexpectedValueException $e) {
|
|
||||||
return new RecursiveArrayIterator(array());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,18 +20,22 @@
|
|||||||
/**
|
/**
|
||||||
* Returns a valid html tag for the chosen $fieldType for paths
|
* Returns a valid html tag for the chosen $fieldType for paths
|
||||||
*
|
*
|
||||||
* @param string path The path to start searching in
|
* @param
|
||||||
* @param integer uid The uid which must match the found directories
|
* string path The path to start searching in
|
||||||
* @param integer gid The gid which must match the found direcotries
|
* @param
|
||||||
* @param string value the value for the input-field
|
* integer uid The uid which must match the found directories
|
||||||
*
|
* @param
|
||||||
* @return string The html tag for the chosen $fieldType
|
* integer gid The gid which must match the found direcotries
|
||||||
*
|
* @param
|
||||||
* @author Martin Burchert <martin.burchert@syscp.de>
|
* string value the value for the input-field
|
||||||
|
*
|
||||||
|
* @return string The html tag for the chosen $fieldType
|
||||||
|
*
|
||||||
|
* @author Martin Burchert <martin.burchert@syscp.de>
|
||||||
* @author Manuel Bernhardt <manuel.bernhardt@syscp.de>
|
* @author Manuel Bernhardt <manuel.bernhardt@syscp.de>
|
||||||
*/
|
*/
|
||||||
function makePathfield($path, $uid, $gid, $value = '', $dom = false) {
|
function makePathfield($path, $uid, $gid, $value = '', $dom = false)
|
||||||
|
{
|
||||||
global $lng;
|
global $lng;
|
||||||
|
|
||||||
$value = str_replace($path, '', $value);
|
$value = str_replace($path, '', $value);
|
||||||
@@ -41,11 +45,11 @@ function makePathfield($path, $uid, $gid, $value = '', $dom = false) {
|
|||||||
// but dirList holds the paths with starting slash
|
// but dirList holds the paths with starting slash
|
||||||
// so we just add one here to get the correct
|
// so we just add one here to get the correct
|
||||||
// default path selected, #225
|
// default path selected, #225
|
||||||
if (substr($value, 0, 1) != '/' && !$dom) {
|
if (substr($value, 0, 1) != '/' && ! $dom) {
|
||||||
$value = '/'.$value;
|
$value = '/' . $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fieldType = Settings::Get('panel.pathedit');
|
$fieldType = \Froxlor\Settings::Get('panel.pathedit');
|
||||||
|
|
||||||
if ($fieldType == 'Manual') {
|
if ($fieldType == 'Manual') {
|
||||||
|
|
||||||
@@ -53,16 +57,15 @@ function makePathfield($path, $uid, $gid, $value = '', $dom = false) {
|
|||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'value' => htmlspecialchars($value)
|
'value' => htmlspecialchars($value)
|
||||||
);
|
);
|
||||||
|
} elseif ($fieldType == 'Dropdown') {
|
||||||
|
|
||||||
} elseif($fieldType == 'Dropdown') {
|
$dirList = \Froxlor\FileDir::findDirs($path, $uid, $gid);
|
||||||
|
|
||||||
$dirList = findDirs($path, $uid, $gid);
|
|
||||||
natcasesort($dirList);
|
natcasesort($dirList);
|
||||||
|
|
||||||
if (sizeof($dirList) > 0) {
|
if (sizeof($dirList) > 0) {
|
||||||
if (sizeof($dirList) <= 100) {
|
if (sizeof($dirList) <= 100) {
|
||||||
$_field = '';
|
$_field = '';
|
||||||
foreach ($dirList as $key => $dir) {
|
foreach ($dirList as $dir) {
|
||||||
if (strpos($dir, $path) === 0) {
|
if (strpos($dir, $path) === 0) {
|
||||||
$dir = substr($dir, strlen($path));
|
$dir = substr($dir, strlen($path));
|
||||||
// docroot cut off of current directory == empty -> directory is the docroot
|
// docroot cut off of current directory == empty -> directory is the docroot
|
||||||
@@ -71,7 +74,7 @@ function makePathfield($path, $uid, $gid, $value = '', $dom = false) {
|
|||||||
}
|
}
|
||||||
$dir = \Froxlor\FileDir::makeCorrectDir($dir);
|
$dir = \Froxlor\FileDir::makeCorrectDir($dir);
|
||||||
}
|
}
|
||||||
$_field.= makeoption($dir, $dir, $value);
|
$_field .= makeoption($dir, $dir, $value);
|
||||||
}
|
}
|
||||||
$field = array(
|
$field = array(
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
@@ -81,7 +84,7 @@ function makePathfield($path, $uid, $gid, $value = '', $dom = false) {
|
|||||||
// remove starting slash we added
|
// remove starting slash we added
|
||||||
// for the Dropdown, #225
|
// for the Dropdown, #225
|
||||||
$value = substr($value, 1);
|
$value = substr($value, 1);
|
||||||
//$field = $lng['panel']['toomanydirs'];
|
// $field = $lng['panel']['toomanydirs'];
|
||||||
$field = array(
|
$field = array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'value' => htmlspecialchars($value),
|
'value' => htmlspecialchars($value),
|
||||||
@@ -89,8 +92,8 @@ function makePathfield($path, $uid, $gid, $value = '', $dom = false) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//$field = $lng['panel']['dirsmissing'];
|
// $field = $lng['panel']['dirsmissing'];
|
||||||
//$field = '<input type="hidden" name="path" value="/" />';
|
// $field = '<input type="hidden" name="path" value="/" />';
|
||||||
$field = array(
|
$field = array(
|
||||||
'type' => 'hidden',
|
'type' => 'hidden',
|
||||||
'value' => '/',
|
'value' => '/',
|
||||||
|
|||||||
@@ -28,36 +28,36 @@
|
|||||||
function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false) {
|
function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false) {
|
||||||
|
|
||||||
if ($force
|
if ($force
|
||||||
|| (int)Settings::Get('system.store_index_file_subs') == 1
|
|| (int)\Froxlor\Settings::Get('system.store_index_file_subs') == 1
|
||||||
) {
|
) {
|
||||||
$result_stmt = Database::prepare("
|
$result_stmt = \Froxlor\Database\Database::prepare("
|
||||||
SELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login`
|
SELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login`
|
||||||
FROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a`
|
FROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a`
|
||||||
ON `c`.`adminid` = `a`.`adminid`
|
ON `c`.`adminid` = `a`.`adminid`
|
||||||
INNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t`
|
INNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t`
|
||||||
ON `a`.`adminid` = `t`.`adminid`
|
ON `a`.`adminid` = `t`.`adminid`
|
||||||
WHERE `varname` = 'index_html' AND `c`.`loginname` = :loginname");
|
WHERE `varname` = 'index_html' AND `c`.`loginname` = :loginname");
|
||||||
Database::pexecute($result_stmt, array('loginname' => $loginname));
|
\Froxlor\Database\Database::pexecute($result_stmt, array('loginname' => $loginname));
|
||||||
|
|
||||||
if (Database::num_rows() > 0) {
|
if (\Froxlor\Database\Database::num_rows() > 0) {
|
||||||
|
|
||||||
$template = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
$template = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$replace_arr = array(
|
$replace_arr = array(
|
||||||
'SERVERNAME' => Settings::Get('system.hostname'),
|
'SERVERNAME' => \Froxlor\Settings::Get('system.hostname'),
|
||||||
'CUSTOMER' => $template['customer_login'],
|
'CUSTOMER' => $template['customer_login'],
|
||||||
'ADMIN' => $template['admin_login'],
|
'ADMIN' => $template['admin_login'],
|
||||||
'CUSTOMER_EMAIL' => $template['customer_email'],
|
'CUSTOMER_EMAIL' => $template['customer_email'],
|
||||||
'ADMIN_EMAIL' => $template['admin_email']
|
'ADMIN_EMAIL' => $template['admin_email']
|
||||||
);
|
);
|
||||||
|
|
||||||
$htmlcontent = replace_variables($template['value'], $replace_arr);
|
$htmlcontent = \Froxlor\PhpHelper::replace_variables($template['value'], $replace_arr);
|
||||||
$indexhtmlpath = \Froxlor\FileDir::makeCorrectFile($destination . '/index.' . Settings::Get('system.index_file_extension'));
|
$indexhtmlpath = \Froxlor\FileDir::makeCorrectFile($destination . '/index.' . \Froxlor\Settings::Get('system.index_file_extension'));
|
||||||
$index_html_handler = fopen($indexhtmlpath, 'w');
|
$index_html_handler = fopen($indexhtmlpath, 'w');
|
||||||
fwrite($index_html_handler, $htmlcontent);
|
fwrite($index_html_handler, $htmlcontent);
|
||||||
fclose($index_html_handler);
|
fclose($index_html_handler);
|
||||||
if ($logger !== null) {
|
if ($logger !== null) {
|
||||||
$logger->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . Settings::Get('system.index_file_extension') . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath));
|
$logger->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . \Froxlor\Settings::Get('system.index_file_extension') . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user