get rid of some more functions
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* 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 Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* chowns either awstats or webalizer folder,
|
||||
* either with webserver-user or - if fcgid
|
||||
* is used - the customers name, #258
|
||||
*
|
||||
* @param array $row array if panel_customers
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function makeChownWithNewStats($row) {
|
||||
|
||||
// get correct user
|
||||
if ((Settings::Get('system.mod_fcgid') == '1' || Settings::Get('phpfpm.enabled') == '1')
|
||||
&& isset($row['deactivated'])
|
||||
&& $row['deactivated'] == '0'
|
||||
) {
|
||||
$user = $row['loginname'];
|
||||
$group = $row['loginname'];
|
||||
} else {
|
||||
$user = $row['guid'];
|
||||
$group = $row['guid'];
|
||||
}
|
||||
|
||||
// get correct directory
|
||||
$dir = $row['documentroot'];
|
||||
if (Settings::Get('system.awstats_enabled') == '1') {
|
||||
$dir .= '/awstats/';
|
||||
} else {
|
||||
$dir .= '/webalizer/';
|
||||
}
|
||||
|
||||
// only run chown if directory exists
|
||||
if (file_exists($dir)) {
|
||||
// run chown
|
||||
\Froxlor\FileDir::safe_exec('chown -R '.escapeshellarg($user).':'.escapeshellarg($group).' '.escapeshellarg(\Froxlor\FileDir::makeCorrectDir($dir)));
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* 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 Michael Kaufmann <mkaufmann@nutime.de>
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Cron
|
||||
*
|
||||
* @since 0.9.33
|
||||
*
|
||||
*/
|
||||
use Froxlor\Settings;
|
||||
|
||||
/**
|
||||
* Cronjob function to end a cronjob in a critical condition
|
||||
* but not without sending a notification mail to the admin
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $subject
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function dieWithMail($message, $subject = "[froxlor] Cronjob error")
|
||||
{
|
||||
if (Settings::Get('system.send_cron_errors') == '1') {
|
||||
|
||||
$_mail = new \PHPMailer\PHPMailer\PHPMailer(true);
|
||||
$_mail->CharSet = "UTF-8";
|
||||
|
||||
if (Settings::Get('system.mail_use_smtp')) {
|
||||
$_mail->isSMTP();
|
||||
$_mail->Host = Settings::Get('system.mail_smtp_host');
|
||||
$_mail->SMTPAuth = Settings::Get('system.mail_smtp_auth') == '1' ? true : false;
|
||||
$_mail->Username = Settings::Get('system.mail_smtp_user');
|
||||
$_mail->Password = Settings::Get('system.mail_smtp_passwd');
|
||||
if (Settings::Get('system.mail_smtp_usetls')) {
|
||||
$_mail->SMTPSecure = 'tls';
|
||||
} else {
|
||||
$mail->SMTPAutoTLS = false;
|
||||
}
|
||||
$_mail->Port = Settings::Get('system.mail_smtp_port');
|
||||
}
|
||||
|
||||
if (\PHPMailer\PHPMailer\PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) {
|
||||
// set return-to address and custom sender-name, see #76
|
||||
$_mail->SetFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname'));
|
||||
if (Settings::Get('panel.adminmail_return') != '') {
|
||||
$_mail->AddReplyTo(Settings::Get('panel.adminmail_return'), Settings::Get('panel.adminmail_defname'));
|
||||
}
|
||||
}
|
||||
|
||||
$_mailerror = false;
|
||||
try {
|
||||
$_mail->Subject = $subject;
|
||||
$_mail->AltBody = $message;
|
||||
$_mail->MsgHTML(nl2br($message));
|
||||
$_mail->AddAddress(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname'));
|
||||
$_mail->Send();
|
||||
} catch (\PHPMailer\PHPMailer\Exception $e) {
|
||||
$mailerr_msg = $e->errorMessage();
|
||||
$_mailerror = true;
|
||||
} catch (Exception $e) {
|
||||
$mailerr_msg = $e->getMessage();
|
||||
$_mailerror = true;
|
||||
}
|
||||
|
||||
$_mail->ClearAddresses();
|
||||
|
||||
if ($_mailerror) {
|
||||
echo 'Error sending mail: ' . $mailerr_msg . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
die($message);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2015 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> (2014-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
*
|
||||
* @since 0.9.33.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* return an array of available hashes for the crypt() function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getAvailablePasswordHashes()
|
||||
{
|
||||
global $lng;
|
||||
|
||||
// get available pwd-hases
|
||||
$available_pwdhashes = array(
|
||||
0 => $lng['serversettings']['systemdefault']
|
||||
);
|
||||
if (defined('CRYPT_MD5') && CRYPT_MD5 == 1) {
|
||||
$available_pwdhashes[1] = 'MD5';
|
||||
}
|
||||
if (defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) {
|
||||
$available_pwdhashes[2] = 'BLOWFISH';
|
||||
}
|
||||
if (defined('CRYPT_SHA256') && CRYPT_SHA256 == 1) {
|
||||
$available_pwdhashes[3] = 'SHA-256';
|
||||
}
|
||||
if (defined('CRYPT_SHA512') && CRYPT_SHA512 == 1) {
|
||||
$available_pwdhashes[4] = 'SHA-512';
|
||||
}
|
||||
|
||||
return $available_pwdhashes;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* 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 Michal Wojcik <m.wojcik@sonet3.pl>
|
||||
* @author Michael Kaufmann <mkaufmann@nutime.de>
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Make crypted password from clear text password
|
||||
*
|
||||
* @author Michal Wojcik <m.wojcik@sonet3.pl>
|
||||
* @author Michael Kaufmann <mkaufmann@nutime.de>
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
*
|
||||
* 0 - default crypt (depenend on system configuration)
|
||||
* 1 - MD5 $1$
|
||||
* 2 - BLOWFISH $2a$ | $2y$07$ (on php 5.3.7+)
|
||||
* 3 - SHA-256 $5$ (default)
|
||||
* 4 - SHA-512 $6$
|
||||
*
|
||||
* @param string $password Password to be crypted
|
||||
*
|
||||
* @return string encrypted password
|
||||
*/
|
||||
function makeCryptPassword ($password) {
|
||||
|
||||
$type = Settings::Get('system.passwordcryptfunc') !== null ? (int)Settings::Get('system.passwordcryptfunc') : 3;
|
||||
|
||||
switch ($type) {
|
||||
case 0:
|
||||
$cryptPassword = crypt($password);
|
||||
break;
|
||||
case 1:
|
||||
$cryptPassword = crypt($password, '$1$' . generatePassword(true). generatePassword(true));
|
||||
break;
|
||||
case 2:
|
||||
if (version_compare(phpversion(), '5.3.7', '<')) {
|
||||
$cryptPassword = crypt($password, '$2a$' . generatePassword(true). generatePassword(true));
|
||||
} else {
|
||||
// Blowfish hashing with a salt as follows: "$2a$", "$2x$" or "$2y$",
|
||||
// a two digit cost parameter, "$", and 22 characters from the alphabet "./0-9A-Za-z"
|
||||
$cryptPassword = crypt(
|
||||
$password,
|
||||
'$2y$07$' . substr(generatePassword(true).generatePassword(true).generatePassword(true), 0, 22)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
$cryptPassword = crypt($password, '$5$' . generatePassword(true). generatePassword(true));
|
||||
break;
|
||||
case 4:
|
||||
$cryptPassword = crypt($password, '$6$' . generatePassword(true). generatePassword(true));
|
||||
break;
|
||||
default:
|
||||
$cryptPassword = crypt($password);
|
||||
break;
|
||||
}
|
||||
return $cryptPassword;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ function validatePasswordLogin($userinfo = null, $password = null, $table = 'pan
|
||||
UPDATE " . $table . " SET `password` = :newpasswd WHERE `" . $uid . "` = :uid
|
||||
");
|
||||
$params = array (
|
||||
'newpasswd' => makeCryptPassword($password),
|
||||
'newpasswd' => \Froxlor\System::makeCryptPassword($password),
|
||||
'uid' => $userinfo[$uid]
|
||||
);
|
||||
Database::pexecute($upd_stmt, $params);
|
||||
|
||||
Reference in New Issue
Block a user