diff --git a/admin_autoupdate.php b/admin_autoupdate.php index c71238f2..ce9d8141 100644 --- a/admin_autoupdate.php +++ b/admin_autoupdate.php @@ -67,7 +67,7 @@ if ($page == 'overview') { 'page' => 'error', 'errno' => 3 )); - } elseif (version_compare2($version, $_version) == - 1) { + } elseif (\Froxlor\Froxlor::version_compare2($version, $_version) == - 1) { // there is a newer version - yay $isnewerversion = 1; } else { diff --git a/admin_plans.php b/admin_plans.php index a54bc3aa..65f40fe3 100644 --- a/admin_plans.php +++ b/admin_plans.php @@ -107,7 +107,7 @@ if ($page == '' || $page == 'overview') { $value_arr = array(); - $value_arr['diskspace'] = intval_ressource($_POST['diskspace']); + $value_arr['diskspace'] = (int)($_POST['diskspace']); if (isset($_POST['diskspace_ul'])) { $value_arr['diskspace'] = - 1; } @@ -117,22 +117,22 @@ if ($page == '' || $page == 'overview') { $value_arr['traffic'] = - 1; } - $value_arr['subdomains'] = intval_ressource($_POST['subdomains']); + $value_arr['subdomains'] = (int)($_POST['subdomains']); if (isset($_POST['subdomains_ul'])) { $value_arr['subdomains'] = - 1; } - $value_arr['emails'] = intval_ressource($_POST['emails']); + $value_arr['emails'] = (int)($_POST['emails']); if (isset($_POST['emails_ul'])) { $value_arr['emails'] = - 1; } - $value_arr['email_accounts'] = intval_ressource($_POST['email_accounts']); + $value_arr['email_accounts'] = (int)($_POST['email_accounts']); if (isset($_POST['email_accounts_ul'])) { $value_arr['email_accounts'] = - 1; } - $value_arr['email_forwarders'] = intval_ressource($_POST['email_forwarders']); + $value_arr['email_forwarders'] = (int)($_POST['email_forwarders']); if (isset($_POST['email_forwarders_ul'])) { $value_arr['email_forwarders'] = - 1; } @@ -151,20 +151,20 @@ if ($page == '' || $page == 'overview') { $value_arr['email_imap'] = 0; if (isset($_POST['email_imap'])) { - $value_arr['email_imap'] = intval_ressource($_POST['email_imap']); + $value_arr['email_imap'] = (int)($_POST['email_imap']); } $value_arr['email_pop3'] = 0; if (isset($_POST['email_pop3'])) { - $value_arr['email_pop3'] = intval_ressource($_POST['email_pop3']); + $value_arr['email_pop3'] = (int)($_POST['email_pop3']); } - $value_arr['ftps'] = intval_ressource($_POST['ftps']); + $value_arr['ftps'] = (int)($_POST['ftps']); if (isset($_POST['ftps_ul'])) { $value_arr['ftps'] = - 1; } - $value_arr['mysqls'] = intval_ressource($_POST['mysqls']); + $value_arr['mysqls'] = (int)($_POST['mysqls']); if (isset($_POST['mysqls_ul'])) { $value_arr['mysqls'] = - 1; } @@ -285,7 +285,7 @@ if ($page == '' || $page == 'overview') { $value_arr = array(); - $value_arr['diskspace'] = intval_ressource($_POST['diskspace']); + $value_arr['diskspace'] = (int)($_POST['diskspace']); if (isset($_POST['diskspace_ul'])) { $value_arr['diskspace'] = - 1; } @@ -295,22 +295,22 @@ if ($page == '' || $page == 'overview') { $value_arr['traffic'] = - 1; } - $value_arr['subdomains'] = intval_ressource($_POST['subdomains']); + $value_arr['subdomains'] = (int)($_POST['subdomains']); if (isset($_POST['subdomains_ul'])) { $value_arr['subdomains'] = - 1; } - $value_arr['emails'] = intval_ressource($_POST['emails']); + $value_arr['emails'] = (int)($_POST['emails']); if (isset($_POST['emails_ul'])) { $value_arr['emails'] = - 1; } - $value_arr['email_accounts'] = intval_ressource($_POST['email_accounts']); + $value_arr['email_accounts'] = (int)($_POST['email_accounts']); if (isset($_POST['email_accounts_ul'])) { $value_arr['email_accounts'] = - 1; } - $value_arr['email_forwarders'] = intval_ressource($_POST['email_forwarders']); + $value_arr['email_forwarders'] = (int)($_POST['email_forwarders']); if (isset($_POST['email_forwarders_ul'])) { $value_arr['email_forwarders'] = - 1; } @@ -329,20 +329,20 @@ if ($page == '' || $page == 'overview') { $value_arr['email_imap'] = 0; if (isset($_POST['email_imap'])) { - $value_arr['email_imap'] = intval_ressource($_POST['email_imap']); + $value_arr['email_imap'] = (int)($_POST['email_imap']); } $value_arr['email_pop3'] = 0; if (isset($_POST['email_pop3'])) { - $value_arr['email_pop3'] = intval_ressource($_POST['email_pop3']); + $value_arr['email_pop3'] = (int)($_POST['email_pop3']); } - $value_arr['ftps'] = intval_ressource($_POST['ftps']); + $value_arr['ftps'] = (int)($_POST['ftps']); if (isset($_POST['ftps_ul'])) { $value_arr['ftps'] = - 1; } - $value_arr['mysqls'] = intval_ressource($_POST['mysqls']); + $value_arr['mysqls'] = (int)($_POST['mysqls']); if (isset($_POST['mysqls_ul'])) { $value_arr['mysqls'] = - 1; } diff --git a/customer_index.php b/customer_index.php index 8dd06d22..39e1d6ae 100644 --- a/customer_index.php +++ b/customer_index.php @@ -120,11 +120,11 @@ if ($page == 'overview') { } elseif ($page == 'change_password') { if (isset($_POST['send']) && $_POST['send'] == 'send') { $old_password = \Froxlor\Validate\Validate::validate($_POST['old_password'], 'old password'); - if (! validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_CUSTOMERS, 'customerid')) { + if (! \Froxlor\System\Crypt::validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_CUSTOMERS, 'customerid')) { \Froxlor\UI\Response::standard_error('oldpasswordnotcorrect'); } - $new_password = validatePassword($_POST['new_password'], 'new password'); + $new_password = \Froxlor\System\Crypt::validatePassword($_POST['new_password'], 'new password'); $new_password_confirm = validatePassword($_POST['new_password_confirm'], 'new password confirm'); if ($old_password == '') { diff --git a/index.php b/index.php index c0b28d19..18648b8c 100644 --- a/index.php +++ b/index.php @@ -602,8 +602,8 @@ if ($action == 'resetpwd') { $new_password = \Froxlor\Validate\Validate::validate($_POST['new_password'], 'new password'); $new_password_confirm = \Froxlor\Validate\Validate::validate($_POST['new_password_confirm'], 'new password confirm'); } else { - $new_password = validatePassword($_POST['new_password'], 'new password'); - $new_password_confirm = validatePassword($_POST['new_password_confirm'], 'new password confirm'); + $new_password = \Froxlor\System\Crypt::validatePassword($_POST['new_password'], 'new password'); + $new_password_confirm = \Froxlor\System\Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm'); } if ($new_password == '') { diff --git a/install/updates/froxlor/0.9/update_0.9.inc.php b/install/updates/froxlor/0.9/update_0.9.inc.php index 18a1ca96..ab2a5e23 100644 --- a/install/updates/froxlor/0.9/update_0.9.inc.php +++ b/install/updates/froxlor/0.9/update_0.9.inc.php @@ -1081,7 +1081,7 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.9.12')) { lastStepStatus(0); if ((int) Settings::Get('autoresponder.autoresponder_active') == 1) { - $update_autoresponder_default = isset($_POST['update_autoresponder_default']) ? intval_ressource($_POST['update_autoresponder_default']) : 0; + $update_autoresponder_default = isset($_POST['update_autoresponder_default']) ? (int)($_POST['update_autoresponder_default']) : 0; if (isset($_POST['update_autoresponder_default_ul'])) { $update_autoresponder_default = - 1; } diff --git a/install/updates/preconfig.php b/install/updates/preconfig.php index ca777413..7f48c6a2 100644 --- a/install/updates/preconfig.php +++ b/install/updates/preconfig.php @@ -51,5 +51,5 @@ function versionInUpdate($current_version, $version_to_check) return true; } - return (version_compare2($current_version, $version_to_check) == - 1 ? true : false); + return (\Froxlor\Froxlor::version_compare2($current_version, $version_to_check) == - 1 ? true : false); } diff --git a/lib/Froxlor/Api/ApiParameter.php b/lib/Froxlor/Api/ApiParameter.php index 9424994e..533531c2 100644 --- a/lib/Froxlor/Api/ApiParameter.php +++ b/lib/Froxlor/Api/ApiParameter.php @@ -123,7 +123,7 @@ abstract class ApiParameter */ protected function getUlParam($param = null, $ul_field = null, $optional = false, $default = 0) { - $param_value = intval_ressource($this->getParam($param, $optional, $default)); + $param_value = (int)$this->getParam($param, $optional, $default); $ul_field_value = $this->getBoolParam($ul_field, true, 0); if ($ul_field_value != '0') { $param_value = - 1; @@ -169,7 +169,7 @@ abstract class ApiParameter // check one level deeper return $this->getModFunctionString(++ $level, $max_level, $trace); } - return $class . ':' . $func; + return str_replace("Froxlor\\Api\\Commands\\", "", $class) . ':' . $func; } /** diff --git a/lib/Froxlor/Api/Commands/Admins.php b/lib/Froxlor/Api/Commands/Admins.php index cf141bf2..327b1ba1 100644 --- a/lib/Froxlor/Api/Commands/Admins.php +++ b/lib/Froxlor/Api/Commands/Admins.php @@ -208,7 +208,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt // only check if not empty, // cause empty == generate password automatically if ($password != '') { - $password = validatePassword($password, true); + $password = \Froxlor\System\Crypt::validatePassword($password, true); } $diskspace = $diskspace * 1024; @@ -529,7 +529,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt } if ($password != '') { - $password = validatePassword($password, true); + $password = \Froxlor\System\Crypt::validatePassword($password, true); $password = \Froxlor\System\Crypt::makeCryptPassword($password); } else { $password = $result['password']; diff --git a/lib/Froxlor/Api/Commands/Customers.php b/lib/Froxlor/Api/Commands/Customers.php index 8bf57b1e..3830161e 100644 --- a/lib/Froxlor/Api/Commands/Customers.php +++ b/lib/Froxlor/Api/Commands/Customers.php @@ -227,7 +227,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource $fax = $this->getParam('fax', true, ''); $customernumber = $this->getParam('customernumber', true, ''); $def_language = $this->getParam('def_language', true, Settings::Get('panel.standardlanguage')); - $gender = intval_ressource($this->getParam('gender', true, 0)); + $gender = (int) $this->getParam('gender', true, 0); $custom_notes = $this->getParam('custom_notes', true, ''); $custom_notes_show = $this->getBoolParam('custom_notes_show', true, 0); @@ -276,7 +276,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource // only check if not empty, // cause empty == generate password automatically if ($password != '') { - $password = validatePassword($password, true); + $password = \Froxlor\System\Crypt::validatePassword($password, true); } // gender out of range? [0,2] @@ -846,7 +846,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource if ($this->isAdmin()) { // parameters - $move_to_admin = intval_ressource($this->getBoolParam('move_to_admin', true, 0)); + $move_to_admin = (int) ($this->getBoolParam('move_to_admin', true, 0)); $idna_convert = new \Froxlor\Idna\IdnaWrapper(); $email = $this->getParam('email', true, $idna_convert->decode($result['email'])); @@ -861,7 +861,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource $fax = $this->getParam('fax', true, $result['fax']); $customernumber = $this->getParam('customernumber', true, $result['customernumber']); $def_language = $this->getParam('def_language', true, $result['def_language']); - $gender = intval_ressource($this->getParam('gender', true, $result['gender'])); + $gender = (int) $this->getParam('gender', true, $result['gender']); $custom_notes = $this->getParam('custom_notes', true, $result['custom_notes']); $custom_notes_show = $this->getBoolParam('custom_notes_show', true, $result['custom_notes_show']); @@ -940,7 +940,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource } if ($password != '') { - $password = validatePassword($password, true); + $password = \Froxlor\System\Crypt::validatePassword($password, true); $password = \Froxlor\System\Crypt::makeCryptPassword($password); } else { $password = $result['password']; diff --git a/lib/Froxlor/Api/Commands/DomainZones.php b/lib/Froxlor/Api/Commands/DomainZones.php index f6cebf61..c0295a8c 100644 --- a/lib/Froxlor/Api/Commands/DomainZones.php +++ b/lib/Froxlor/Api/Commands/DomainZones.php @@ -143,7 +143,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour // remove it for checks $content = substr($content, 0, - 1); } - if (! validateDomain($content)) { + if (! \Froxlor\Validate\Validate::validateDomain($content)) { $errors[] = $this->lng['error']['dns_mx_needdom']; } else { // check whether there is a CNAME-record for the same resource @@ -166,7 +166,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour // add domain name $content .= '.' . $domain; } - if (! validateDomain($content, true)) { + if (! \Froxlor\Validate\Validate::validateDomain($content, true)) { $errors[] = $this->lng['error']['dns_cname_invaliddom']; } else { // check whether there are RR-records for the same resource @@ -185,7 +185,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour // remove it for checks $content = substr($content, 0, - 1); } - if (! validateDomain($content)) { + if (! \Froxlor\Validate\Validate::validateDomain($content)) { $errors[] = $this->lng['error']['dns_ns_invaliddom']; } // append trailing dot (again) @@ -212,7 +212,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour $target = substr($target, 0, - 1); } } - if ($target != '.' && ! validateDomain($target, true)) { + if ($target != '.' && ! \Froxlor\Validate\Validate::validateDomain($target, true)) { $errors[] = $this->lng['error']['dns_srv_needdom']; } else { // check whether there is a CNAME-record for the same resource diff --git a/lib/Froxlor/Api/Commands/EmailAccounts.php b/lib/Froxlor/Api/Commands/EmailAccounts.php index fe9efab2..a93e9ca9 100644 --- a/lib/Froxlor/Api/Commands/EmailAccounts.php +++ b/lib/Froxlor/Api/Commands/EmailAccounts.php @@ -85,7 +85,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso $idna_convert = new \Froxlor\Idna\IdnaWrapper(); $username = $idna_convert->decode($email_full); $password = \Froxlor\Validate\Validate::validate($email_password, 'password', '', '', array(), true); - $password = validatePassword($password, true); + $password = \Froxlor\System\Crypt::validatePassword($password, true); if ($result['popaccountid'] != 0) { throw new \Exception("Email address '" . $email_full . "' has already an account assigned.", 406); @@ -346,7 +346,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso if ($password == $result['email_full']) { \Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true); } - $password = validatePassword($password, true); + $password = \Froxlor\System\Crypt::validatePassword($password, true); $cryptPassword = \Froxlor\System\Crypt::makeCryptPassword($password); $upd_query .= (Settings::Get('system.mailpwcleartext') == '1' ? "`password` = :password, " : '') . "`password_enc`= :password_enc"; $upd_params['password_enc'] = $cryptPassword; diff --git a/lib/Froxlor/Api/Commands/Froxlor.php b/lib/Froxlor/Api/Commands/Froxlor.php index 755fc1e2..9a9d4ec4 100644 --- a/lib/Froxlor/Api/Commands/Froxlor.php +++ b/lib/Froxlor/Api/Commands/Froxlor.php @@ -58,7 +58,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand // check for customized version to not output // "There is a newer version of froxlor" besides the error-message $isnewerversion = - 1; - } elseif (version_compare2($this->version, $_version) == - 1) { + } elseif (\Froxlor\Froxlor::version_compare2($this->version, $_version) == - 1) { // there is a newer version - yay $isnewerversion = 1; } else { diff --git a/lib/Froxlor/Api/Commands/Ftps.php b/lib/Froxlor/Api/Commands/Ftps.php index ee4a4e0c..551ce3de 100644 --- a/lib/Froxlor/Api/Commands/Ftps.php +++ b/lib/Froxlor/Api/Commands/Ftps.php @@ -68,7 +68,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit // validation $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); - $password = validatePassword($password, true); + $password = \Froxlor\System\Crypt::validatePassword($password, true); $description = \Froxlor\Validate\Validate::validate(trim($description), 'description', '', '', array(), true); if (Settings::Get('system.allow_customer_shell') == '1') { @@ -353,7 +353,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit // password update? if ($password != '') { // validate password - $password = validatePassword($password, true); + $password = \Froxlor\System\Crypt::validatePassword($password, true); if ($password == $result['username']) { \Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true); diff --git a/lib/Froxlor/Api/Commands/Mysqls.php b/lib/Froxlor/Api/Commands/Mysqls.php index 864dee0e..0b34b2a0 100644 --- a/lib/Froxlor/Api/Commands/Mysqls.php +++ b/lib/Froxlor/Api/Commands/Mysqls.php @@ -54,7 +54,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt // validation $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); - $password = validatePassword($password, true); + $password = \Froxlor\System\Crypt::validatePassword($password, true); $databasedescription = \Froxlor\Validate\Validate::validate(trim($databasedescription), 'description', '', '', array(), true); // validate whether the dbserver exists @@ -315,7 +315,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt if ($password != '') { // validate password - $password = validatePassword($password, true); + $password = \Froxlor\System\Crypt::validatePassword($password, true); if ($password == $result['databasename']) { \Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true); diff --git a/lib/Froxlor/Api/Commands/SubDomains.php b/lib/Froxlor/Api/Commands/SubDomains.php index f819093f..035410db 100644 --- a/lib/Froxlor/Api/Commands/SubDomains.php +++ b/lib/Froxlor/Api/Commands/SubDomains.php @@ -104,7 +104,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc // merge the two parts together $completedomain = $subdomain . '.' . $domain; - if (Settings::Get('system.validate_domain') && ! validateDomain($completedomain)) { + if (Settings::Get('system.validate_domain') && ! \Froxlor\Validate\Validate::validateDomain($completedomain)) { \Froxlor\UI\Response::standard_error(array( 'stringiswrong', 'mydomain' diff --git a/lib/Froxlor/Cli/Action/ConfigServicesAction.php b/lib/Froxlor/Cli/Action/ConfigServicesAction.php index 8f21147d..062db116 100644 --- a/lib/Froxlor/Cli/Action/ConfigServicesAction.php +++ b/lib/Froxlor/Cli/Action/ConfigServicesAction.php @@ -16,7 +16,7 @@ class ConfigServicesAction extends \Froxlor\Cli\Action public function run() { - $this->_\Froxlor\Validate\Validate::validate(); + $this->_validate(); } /** @@ -24,7 +24,7 @@ class ConfigServicesAction extends \Froxlor\Cli\Action * * @throws \Exception */ - private function _\Froxlor\Validate\Validate::validate() + private function _validate() { $this->_checkConfigParam(true); $this->_parseConfig(); diff --git a/lib/Froxlor/Cli/Action/SwitchServerIpAction.php b/lib/Froxlor/Cli/Action/SwitchServerIpAction.php index 30b47ca4..ba2fa4a4 100644 --- a/lib/Froxlor/Cli/Action/SwitchServerIpAction.php +++ b/lib/Froxlor/Cli/Action/SwitchServerIpAction.php @@ -14,7 +14,7 @@ class SwitchServerIpAction extends \Froxlor\Cli\Action public function run() { - $this->_\Froxlor\Validate\Validate::validate(); + $this->_validate(); } /** @@ -22,7 +22,7 @@ class SwitchServerIpAction extends \Froxlor\Cli\Action * * @throws \Exception */ - private function _\Froxlor\Validate\Validate::validate() + private function _validate() { $need_config = false; if (array_key_exists("list", $this->_args) || array_key_exists("switch", $this->_args)) { diff --git a/lib/Froxlor/Froxlor.php b/lib/Froxlor/Froxlor.php index 49a5a34d..647e1607 100644 --- a/lib/Froxlor/Froxlor.php +++ b/lib/Froxlor/Froxlor.php @@ -201,4 +201,76 @@ final class Froxlor } return false; } + + /** + * compare of froxlor versions + * + * @param string $a + * @param string $b + * + * @return integer 0 if equal, 1 if a>b and -1 if b>a + */ + public static function version_compare2($a, $b) + { + + // split version into pieces and remove trailing .0 + $a = explode(".", $a); + $b = explode(".", $b); + + self::_parseVersionArray($a); + self::_parseVersionArray($b); + + while (count($a) != count($b)) { + if (count($a) < count($b)) { + $a[] = '0'; + } elseif (count($b) < count($a)) { + $b[] = '0'; + } + } + + foreach ($a as $depth => $aVal) { + // iterate over each piece of A + if (isset($b[$depth])) { + // if B matches A to this depth, compare the values + if ($aVal > $b[$depth]) { + return 1; // A > B + } else if ($aVal < $b[$depth]) { + return - 1; // B > A + } + // an equal result is inconclusive at this point + } else { + // if B does not match A to this depth, then A comes after B in sort order + return 1; // so A > B + } + } + // at this point, we know that to the depth that A and B extend to, they are equivalent. + // either the loop ended because A is shorter than B, or both are equal. + return (count($a) < count($b)) ? - 1 : 0; + } + + private static function _parseVersionArray(&$arr = null) + { + // -svn or -dev or -rc ? + if (stripos($arr[count($arr) - 1], '-') !== false) { + $x = explode("-", $arr[count($arr) - 1]); + $arr[count($arr) - 1] = $x[0]; + if (stripos($x[1], 'rc') !== false) { + $arr[] = '-1'; + $arr[] = '2'; // rc > dev > svn + // number of rc + $arr[] = substr($x[1], 2); + } else if (stripos($x[1], 'dev') !== false) { + $arr[] = '-1'; + $arr[] = '1'; // svn < dev < rc + // number of dev + $arr[] = substr($x[1], 3); + } // -svn version are deprecated + else if (stripos($x[1], 'svn') !== false) { + $arr[] = '-1'; + $arr[] = '0'; // svn < dev < rc + // number of svn + $arr[] = substr($x[1], 3); + } + } + } } diff --git a/lib/Froxlor/System/Crypt.php b/lib/Froxlor/System/Crypt.php index f9597146..407b2e93 100644 --- a/lib/Froxlor/System/Crypt.php +++ b/lib/Froxlor/System/Crypt.php @@ -88,7 +88,7 @@ class Crypt $cryptPassword = crypt($password, '$1$' . self::generatePassword(true) . self::generatePassword(true)); break; case 2: - if (version_compare(phpversion(), '5.3.7', '<')) { + if (\Froxlor\Froxlor::version_compare(phpversion(), '5.3.7', '<')) { $cryptPassword = crypt($password, '$2a$' . self::generatePassword(true) . self::generatePassword(true)); } else { // Blowfish hashing with a salt as follows: "$2a$", "$2x$" or "$2y$", @@ -228,7 +228,7 @@ class Crypt if ($pwd_hash == $pwd_check) { // check for update of hash (only if our database is ready to handle the bigger string) - $is_ready = (version_compare2("0.9.33", \Froxlor\Froxlor::getVersion()) <= 0 ? true : false); + $is_ready = (\Froxlor\Froxlor::version_compare2("0.9.33", \Froxlor\Froxlor::getVersion()) <= 0 ? true : false); if ($update_hash && $is_ready) { $upd_stmt = \Froxlor\Database\Database::prepare(" UPDATE " . $table . " SET `password` = :newpasswd WHERE `" . $uid . "` = :uid @@ -244,4 +244,4 @@ class Crypt } return false; } -} \ No newline at end of file +} diff --git a/lib/functions/froxlor/function.version_compare2.php b/lib/functions/froxlor/function.version_compare2.php deleted file mode 100644 index 6ef915f9..00000000 --- a/lib/functions/froxlor/function.version_compare2.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -/** - * compare of froxlor versions - * - * @param string $a - * @param string $b - * - * @return integer 0 if equal, 1 if a>b and -1 if b>a - */ -function version_compare2($a, $b) -{ - - // split version into pieces and remove trailing .0 - $a = explode(".", $a); - $b = explode(".", $b); - - _parseVersionArray($a); - _parseVersionArray($b); - - while (count($a) != count($b)) { - if (count($a) < count($b)) { - $a[] = '0'; - } elseif (count($b) < count($a)) { - $b[] = '0'; - } - } - - foreach ($a as $depth => $aVal) { - // iterate over each piece of A - if (isset($b[$depth])) { - // if B matches A to this depth, compare the values - if ($aVal > $b[$depth]) { - return 1; // A > B - } else if ($aVal < $b[$depth]) { - return - 1; // B > A - } - // an equal result is inconclusive at this point - } else { - // if B does not match A to this depth, then A comes after B in sort order - return 1; // so A > B - } - } - // at this point, we know that to the depth that A and B extend to, they are equivalent. - // either the loop ended because A is shorter than B, or both are equal. - return (count($a) < count($b)) ? - 1 : 0; -} - -function _parseVersionArray(&$arr = null) -{ - // -svn or -dev or -rc ? - if (stripos($arr[count($arr) - 1], '-') !== false) { - $x = explode("-", $arr[count($arr) - 1]); - $arr[count($arr) - 1] = $x[0]; - if (stripos($x[1], 'rc') !== false) { - $arr[] = '-1'; - $arr[] = '2'; // rc > dev > svn - // number of rc - $arr[] = substr($x[1], 2); - } else if (stripos($x[1], 'dev') !== false) { - $arr[] = '-1'; - $arr[] = '1'; // svn < dev < rc - // number of dev - $arr[] = substr($x[1], 3); - } // -svn version are deprecated - else if (stripos($x[1], 'svn') !== false) { - $arr[] = '-1'; - $arr[] = '0'; // svn < dev < rc - // number of svn - $arr[] = substr($x[1], 3); - } - } -} diff --git a/lib/functions/phphelpers/function.intval_ressource.php b/lib/functions/phphelpers/function.intval_ressource.php deleted file mode 100644 index 73a3e2b4..00000000 --- a/lib/functions/phphelpers/function.intval_ressource.php +++ /dev/null @@ -1,38 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Functions - * - */ - -/** - * Returns an integer of the given value which isn't negative. - * Returns -1 if the given value was -1. - * - * @param - * any The value - * @return int The positive value - * @author Florian Lippert - */ -function intval_ressource($the_value) -{ - $the_value = intval($the_value); - - if ($the_value < 0 && $the_value != '-1') { - $the_value *= - 1; - } - - return $the_value; -}