get rid of some more functions
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -1,100 +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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create or modify the AWStats configuration file for the given domain.
|
||||
* Modified by Berend Dekens to allow custom configurations.
|
||||
*
|
||||
* @param logFile
|
||||
* @param siteDomain
|
||||
* @param hostAliases
|
||||
* @return null
|
||||
*/
|
||||
function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot, $awstats_params = array()) {
|
||||
|
||||
// Generation header
|
||||
$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 = \Froxlor\FileDir::makeCorrectDir($customerDocroot.'/awstats/'.$siteDomain.'/');
|
||||
if (!is_dir($awstats_dir)) {
|
||||
\Froxlor\FileDir::safe_exec('mkdir -p '.escapeshellarg($awstats_dir));
|
||||
}
|
||||
// chown created folder, #258
|
||||
makeChownWithNewStats($awstats_params);
|
||||
|
||||
// weird but could happen...
|
||||
if (!is_dir(Settings::Get('system.awstats_conf'))) {
|
||||
\Froxlor\FileDir::safe_exec('mkdir -p '.escapeshellarg(Settings::Get('system.awstats_conf')));
|
||||
}
|
||||
|
||||
// These are the variables we will replace
|
||||
$regex = array(
|
||||
'/\{LOG_FILE\}/',
|
||||
'/\{SITE_DOMAIN\}/',
|
||||
'/\{HOST_ALIASES\}/',
|
||||
'/\{CUSTOMER_DOCROOT\}/',
|
||||
'/\{AWSTATS_CONF\}/'
|
||||
);
|
||||
$replace = array(
|
||||
\Froxlor\FileDir::makeCorrectFile($logFile),
|
||||
$siteDomain,
|
||||
$hostAliases,
|
||||
$awstats_dir,
|
||||
\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.awstats_conf'))
|
||||
);
|
||||
|
||||
// File names
|
||||
$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 = \Froxlor\FileDir::makeCorrectFile($model_file);
|
||||
|
||||
// Test if the file exists
|
||||
if (file_exists($domain_file)) {
|
||||
// Check for the generated header - if this is a manual modification we won't update
|
||||
$awstats_domain_conf = fopen($domain_file, 'r');
|
||||
|
||||
if (fgets($awstats_domain_conf, strlen($header)) != $header) {
|
||||
fclose($awstats_domain_conf);
|
||||
return;
|
||||
}
|
||||
|
||||
// Close the file
|
||||
fclose($awstats_domain_conf);
|
||||
}
|
||||
|
||||
$awstats_domain_conf = fopen($domain_file, 'w');
|
||||
$awstats_model_conf = fopen($model_file, 'r');
|
||||
|
||||
// Write the header
|
||||
fwrite($awstats_domain_conf, $header);
|
||||
fwrite($awstats_domain_conf, preg_replace($regex, $replace, $header2));
|
||||
|
||||
// Write the configuration file
|
||||
while (($line = fgets($awstats_model_conf, 4096)) !== false) {
|
||||
if (!preg_match('/^#/', $line)
|
||||
&& trim($line) != ''
|
||||
) {
|
||||
fwrite($awstats_domain_conf, preg_replace($regex, $replace, $line));
|
||||
}
|
||||
}
|
||||
|
||||
fclose($awstats_domain_conf);
|
||||
fclose($awstats_model_conf);
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2011- 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 Froxlor team <team@froxlor.org> (2011-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generates a random password
|
||||
*
|
||||
* @param boolean $isSalt
|
||||
* optional, create a hash for a salt used in makeCryptPassword because crypt() does not like some special characters in its salts, default is false
|
||||
*/
|
||||
function generatePassword($isSalt = false)
|
||||
{
|
||||
$alpha_lower = 'abcdefghijklmnopqrstuvwxyz';
|
||||
$alpha_upper = strtoupper($alpha_lower);
|
||||
$numeric = '0123456789';
|
||||
$special = Settings::Get('panel.password_special_char');
|
||||
$length = Settings::Get('panel.password_min_length') > 3 ? Settings::Get('panel.password_min_length') : 10;
|
||||
|
||||
$pw = special_shuffle($alpha_lower);
|
||||
$n = floor(($length) / 4);
|
||||
|
||||
if (Settings::Get('panel.password_alpha_upper')) {
|
||||
$pw .= mb_substr(special_shuffle($alpha_upper), 0, $n);
|
||||
}
|
||||
|
||||
if (Settings::Get('panel.password_numeric')) {
|
||||
$pw .= mb_substr(special_shuffle($numeric), 0, $n);
|
||||
}
|
||||
|
||||
if (Settings::Get('panel.password_special_char_required') && !$isSalt) {
|
||||
$pw .= mb_substr(special_shuffle($special), 0, $n);
|
||||
}
|
||||
|
||||
$pw = mb_substr($pw, - $length);
|
||||
|
||||
return special_shuffle($pw);
|
||||
}
|
||||
|
||||
/**
|
||||
* multibyte-character safe shuffle function
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function special_shuffle($str = null)
|
||||
{
|
||||
$len = mb_strlen($str);
|
||||
$sploded = array();
|
||||
while ($len -- > 0) {
|
||||
$sploded[] = mb_substr($str, $len, 1);
|
||||
}
|
||||
shuffle($sploded);
|
||||
return join('', $sploded);
|
||||
}
|
||||
Reference in New Issue
Block a user