svn:eol-style got murdered on some files for whatever reason so it gets resurrected now, also set some svn:keywords

This commit is contained in:
Robert Foerster (Dessa)
2010-01-27 08:54:31 +00:00
parent 30f2de8f9e
commit 883963d2e2
190 changed files with 34136 additions and 34136 deletions

View File

@@ -1,33 +1,33 @@
<?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
* @version $Id$
*/
/**
* Create a valid from/to - mailheader (remove carriage-returns)
*
* @param string The name of the recipient
* @param string The mailaddress
* @return string A valid header-entry
* @author Florian Aders <eleras@syscp.org>
*/
function buildValidMailFrom($name, $mailaddress)
{
$mailfrom = str_replace(array("\r", "\n"), '', $name) . ' <' . str_replace(array("\r", "\n"), '', $mailaddress) . '>';
return $mailfrom;
}
<?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
* @version $Id$
*/
/**
* Create a valid from/to - mailheader (remove carriage-returns)
*
* @param string The name of the recipient
* @param string The mailaddress
* @return string A valid header-entry
* @author Florian Aders <eleras@syscp.org>
*/
function buildValidMailFrom($name, $mailaddress)
{
$mailfrom = str_replace(array("\r", "\n"), '', $name) . ' <' . str_replace(array("\r", "\n"), '', $mailaddress) . '>';
return $mailfrom;
}

View File

@@ -1,35 +1,35 @@
<?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
* @version $Id$
*/
function checkMysqlAccessHost($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
$mysql_access_host_array = array_map('trim', explode(',', $newfieldvalue));
foreach($mysql_access_host_array as $host_entry)
{
if(validate_ip($host_entry, true) == false
&& validateDomain($host_entry) == false
&& $host_entry != '%')
{
return array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'invalidmysqlhost', $host_entry);
}
}
return array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
}
<?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
* @version $Id$
*/
function checkMysqlAccessHost($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
$mysql_access_host_array = array_map('trim', explode(',', $newfieldvalue));
foreach($mysql_access_host_array as $host_entry)
{
if(validate_ip($host_entry, true) == false
&& validateDomain($host_entry) == false
&& $host_entry != '%')
{
return array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'invalidmysqlhost', $host_entry);
}
}
return array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
}

View File

@@ -1,37 +1,37 @@
<?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
* @version $Id$
*/
function checkUsername($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
global $settings;
if(!isset($allnewfieldvalues['customer_mysqlprefix']))
{
$allnewfieldvalues['customer_mysqlprefix'] = $settings['customer']['mysqlprefix'];
}
$returnvalue = array();
if(validateUsername($newfieldvalue, $settings['panel']['unix_names'], 14 - strlen($allnewfieldvalues['customer_mysqlprefix'])) === true)
{
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
}
else
{
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'accountprefixiswrong');
}
return $returnvalue;
}
<?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
* @version $Id$
*/
function checkUsername($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
global $settings;
if(!isset($allnewfieldvalues['customer_mysqlprefix']))
{
$allnewfieldvalues['customer_mysqlprefix'] = $settings['customer']['mysqlprefix'];
}
$returnvalue = array();
if(validateUsername($newfieldvalue, $settings['panel']['unix_names'], 14 - strlen($allnewfieldvalues['customer_mysqlprefix'])) === true)
{
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
}
else
{
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'accountprefixiswrong');
}
return $returnvalue;
}

View File

@@ -1,45 +1,45 @@
<?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
* @version $Id$
*/
/**
* 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;
}
<?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
* @version $Id$
*/
/**
* 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;
}

View File

@@ -1,85 +1,85 @@
<?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
* @version $Id$
*/
/**
* Validates the given string by matching against the pattern, prints an error on failure and exits
*
* @param string $str the string to be tested (user input)
* @param string the $fieldname to be used in error messages
* @param string $pattern the regular expression to be used for testing
* @param string language id for the error
* @return string the clean string
*
* If the default pattern is used and the string does not match, we try to replace the
* 'bad' values and log the action.
*
*/
function validate($str, $fieldname, $pattern = '', $lng = '', $emptydefault = array())
{
global $log;
if(!is_array($emptydefault))
{
$emptydefault_array = array(
$emptydefault
);
unset($emptydefault);
$emptydefault = $emptydefault_array;
unset($emptydefault_array);
}
// Check if the $str is one of the values which represent the default for an 'empty' value
if(is_array($emptydefault)
&& !empty($emptydefault)
&& in_array($str, $emptydefault)
&& isset($emptydefault[0]))
{
return $emptydefault[0];
}
if($pattern == '')
{
$pattern = '/^[^\r\n\t\f\0]*$/D';
if(!preg_match($pattern, $str))
{
// Allows letters a-z, digits, space (\\040), hyphen (\\-), underscore (\\_) and backslash (\\\\),
// everything else is removed from the string.
$allowed = "/[^a-z0-9\\040\\.\\-\\_\\\\]/i";
preg_replace($allowed, "", $str);
$log->logAction(null, LOG_WARNING, "cleaned bad formatted string (" . $str . ")");
}
}
if(preg_match($pattern, $str))
{
return $str;
}
if($lng == '')
{
$lng = 'stringformaterror';
}
standard_error($lng, $fieldname);
exit;
}
<?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
* @version $Id$
*/
/**
* Validates the given string by matching against the pattern, prints an error on failure and exits
*
* @param string $str the string to be tested (user input)
* @param string the $fieldname to be used in error messages
* @param string $pattern the regular expression to be used for testing
* @param string language id for the error
* @return string the clean string
*
* If the default pattern is used and the string does not match, we try to replace the
* 'bad' values and log the action.
*
*/
function validate($str, $fieldname, $pattern = '', $lng = '', $emptydefault = array())
{
global $log;
if(!is_array($emptydefault))
{
$emptydefault_array = array(
$emptydefault
);
unset($emptydefault);
$emptydefault = $emptydefault_array;
unset($emptydefault_array);
}
// Check if the $str is one of the values which represent the default for an 'empty' value
if(is_array($emptydefault)
&& !empty($emptydefault)
&& in_array($str, $emptydefault)
&& isset($emptydefault[0]))
{
return $emptydefault[0];
}
if($pattern == '')
{
$pattern = '/^[^\r\n\t\f\0]*$/D';
if(!preg_match($pattern, $str))
{
// Allows letters a-z, digits, space (\\040), hyphen (\\-), underscore (\\_) and backslash (\\\\),
// everything else is removed from the string.
$allowed = "/[^a-z0-9\\040\\.\\-\\_\\\\]/i";
preg_replace($allowed, "", $str);
$log->logAction(null, LOG_WARNING, "cleaned bad formatted string (" . $str . ")");
}
}
if(preg_match($pattern, $str))
{
return $str;
}
if($lng == '')
{
$lng = 'stringformaterror';
}
standard_error($lng, $fieldname);
exit;
}

View File

@@ -1,48 +1,48 @@
<?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
* @version $Id$
*/
/**
* Check if the submitted string is a valid domainname, i.e.
* it consists only of the following characters ([a-z0-9][a-z0-9\-]+\.)+[a-z]{2,4}
*
* @param string The domainname which should be checked.
* @return boolean True if the domain is valid, false otherwise
* @author Florian Lippert <flo@syscp.org>
* @author Michael Duergner
*
*/
function validateDomain($domainname)
{
// we add http:// because this makes a domain valid for the filter;
$domainname_tmp = 'http://' . $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?
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
{
return false;
}
}
<?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
* @version $Id$
*/
/**
* Check if the submitted string is a valid domainname, i.e.
* it consists only of the following characters ([a-z0-9][a-z0-9\-]+\.)+[a-z]{2,4}
*
* @param string The domainname which should be checked.
* @return boolean True if the domain is valid, false otherwise
* @author Florian Lippert <flo@syscp.org>
* @author Michael Duergner
*
*/
function validateDomain($domainname)
{
// we add http:// because this makes a domain valid for the filter;
$domainname_tmp = 'http://' . $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?
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
{
return false;
}
}

View File

@@ -1,34 +1,34 @@
<?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
* @version $Id$
*/
/**
* Returns if an emailaddress is in correct format or not
*
* @param string The email address to check
* @return bool Correct or not
* @author Florian Lippert <flo@syscp.org>
*
* @changes Backported regex from SysCP 1.3 (lib/classes/Syscp/Handler/Validation.class.php)
*/
function validateEmail($email)
{
$email = strtolower($email);
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
<?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
* @version $Id$
*/
/**
* Returns if an emailaddress is in correct format or not
*
* @param string The email address to check
* @return bool Correct or not
* @author Florian Lippert <flo@syscp.org>
*
* @changes Backported regex from SysCP 1.3 (lib/classes/Syscp/Handler/Validation.class.php)
*/
function validateEmail($email)
{
$email = strtolower($email);
return filter_var($email, FILTER_VALIDATE_EMAIL);
}

View File

@@ -12,7 +12,7 @@
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id: $
* @version $Id$
*/
function validateSqlInterval($interval = null)

View File

@@ -1,72 +1,72 @@
<?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
* @version $Id$
*/
/**
* Returns whether a URL is in a correct format or not
*
* @param string URL to be tested
* @return bool
* @author Christian Hoffmann
*
*/
function validateUrl($url)
{
if(strtolower(substr($url, 0, 7)) != "http://"
&& strtolower(substr($url, 0, 8)) != "https://")
{
$url = 'http://' . $url;
}
if(filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) !== false)
{
return true;
}
else
{
if(strtolower(substr($url, 0, 7)) == "http://"
|| strtolower(substr($url, 0, 8)) == "https://")
{
if(strtolower(substr($url, 0, 7)) == "http://")
{
$ip = strtolower(substr($url, 7));
}
if(strtolower(substr($url, 0, 8)) == "https://")
{
$ip = strtolower(substr($url, 8));
}
$ip = substr($ip, 0, strpos($ip, '/'));
if(validate_ip($ip, true) !== false)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
}
<?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
* @version $Id$
*/
/**
* Returns whether a URL is in a correct format or not
*
* @param string URL to be tested
* @return bool
* @author Christian Hoffmann
*
*/
function validateUrl($url)
{
if(strtolower(substr($url, 0, 7)) != "http://"
&& strtolower(substr($url, 0, 8)) != "https://")
{
$url = 'http://' . $url;
}
if(filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) !== false)
{
return true;
}
else
{
if(strtolower(substr($url, 0, 7)) == "http://"
|| strtolower(substr($url, 0, 8)) == "https://")
{
if(strtolower(substr($url, 0, 7)) == "http://")
{
$ip = strtolower(substr($url, 7));
}
if(strtolower(substr($url, 0, 8)) == "https://")
{
$ip = strtolower(substr($url, 8));
}
$ip = substr($ip, 0, strpos($ip, '/'));
if(validate_ip($ip, true) !== false)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
}

View File

@@ -1,47 +1,47 @@
<?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
* @version $Id$
*/
/**
* Returns if an username is in correct format or not.
*
* @param string The username to check
* @return bool Correct or not
* @author Michael Duergner <michael@duergner.com>
*
* @changes Backported regex from SysCP 1.3 (lib/classes/Syscp/Handler/Validation.class.php)
*/
function validateUsername($username, $unix_names = 1, $mysql_max = '')
{
if($unix_names == 0)
{
if(strpos($username, '--') === false)
{
return (preg_match('/^[a-z][a-z0-9\-_]{1,' . (int)($mysql_max - 1) . '}[a-z0-9]{1}$/Di', $username) != false);
}
else
{
return false;
}
}
else
{
return (preg_match('/^[a-z][a-z0-9]{1,' . $mysql_max . '}$/Di', $username) != false);
}
}
<?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
* @version $Id$
*/
/**
* Returns if an username is in correct format or not.
*
* @param string The username to check
* @return bool Correct or not
* @author Michael Duergner <michael@duergner.com>
*
* @changes Backported regex from SysCP 1.3 (lib/classes/Syscp/Handler/Validation.class.php)
*/
function validateUsername($username, $unix_names = 1, $mysql_max = '')
{
if($unix_names == 0)
{
if(strpos($username, '--') === false)
{
return (preg_match('/^[a-z][a-z0-9\-_]{1,' . (int)($mysql_max - 1) . '}[a-z0-9]{1}$/Di', $username) != false);
}
else
{
return false;
}
}
else
{
return (preg_match('/^[a-z][a-z0-9]{1,' . $mysql_max . '}$/Di', $username) != false);
}
}

View File

@@ -1,46 +1,46 @@
<?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
* @version $Id$
*/
/**
* Checks whether it is a valid ip
*
* @return mixed ip address on success, standard_error on failure
*/
function validate_ip($ip, $return_bool = false, $lng = 'invalidip')
{
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE
&& filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE
&& filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) === FALSE)
{
if($return_bool)
{
return false;
}
else
{
standard_error($lng, $ip);
exit;
}
}
else
{
return $ip;
}
}
<?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
* @version $Id$
*/
/**
* Checks whether it is a valid ip
*
* @return mixed ip address on success, standard_error on failure
*/
function validate_ip($ip, $return_bool = false, $lng = 'invalidip')
{
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE
&& filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE
&& filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) === FALSE)
{
if($return_bool)
{
return false;
}
else
{
standard_error($lng, $ip);
exit;
}
}
else
{
return $ip;
}
}