function versionInUpdate($current_version, $version_to_check) { if (!isFroxlor()) { return true; } return version_compare2($current_version, $version_to_check) == -1 ? true : false; }
/** * Function validatePasswordLogin * * compare user password-hash with given user-password * and check if they are the same * additionally it updates the hash if the system settings changed * or if the very old md5() sum is used * * @param array $userinfo user-data from table * @param string $password the password to validate * @param string $table either panel_customers or panel_admins * @param string $uid user-id-field in $table * * @return boolean */ function validatePasswordLogin($userinfo = null, $password = null, $table = 'panel_customers', $uid = 'customerid') { global $version; $systype = 3; // SHA256 if (Settings::Get('system.passwordcryptfunc') !== null) { $systype = (int) Settings::Get('system.passwordcryptfunc'); } $pwd_hash = $userinfo['password']; $update_hash = false; // check for good'ole md5 if (strlen($pwd_hash) == 32 && ctype_xdigit($pwd_hash)) { $pwd_check = md5($password); $update_hash = true; } else { // cut out the salt from the hash $pwd_salt = str_replace(substr(strrchr($pwd_hash, "\$"), 1), "", $pwd_hash); // create same hash to compare $pwd_check = crypt($password, $pwd_salt); // check whether the hash needs to be updated $hash_type_chk = substr($pwd_hash, 0, 3); if ($systype == 1 && $hash_type_chk != '$1$' || $systype == 2 && $hash_type_chk != '$2$' || $systype == 3 && $hash_type_chk != '$5$' || $systype == 4 && $hash_type_chk != '$6$') { $update_hash = true; } } 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", $version) <= 0 ? true : false; if ($update_hash && $is_ready) { $upd_stmt = Database::prepare("\n\t\t\t\tUPDATE " . $table . " SET `password` = :newpasswd WHERE `" . $uid . "` = :uid\n\t\t\t"); $params = array('newpasswd' => makeCryptPassword($password), 'uid' => $userinfo[$uid]); Database::pexecute($upd_stmt, $params); } return true; } return false; }
$latestversion = explode('|', $latestversion[0]); if (is_array($latestversion) && count($latestversion) >= 1) { $_version = $latestversion[0]; $_message = isset($latestversion[1]) ? $latestversion[1] : ''; $_link = isset($latestversion[2]) ? $latestversion[2] : htmlspecialchars($filename . '?s=' . urlencode($s) . '&page=' . urlencode($page) . '&lookfornewversion=yes'); // add the branding so debian guys are not gettings confused // about their version-number $version_label = $_version . $branding; $version_link = $_link; $message_addinfo = $_message; // not numeric -> error-message if (!preg_match('/^((\\d+\\.)(\\d+\\.)(\\d+\\.)?(\\d+)?(\\-(svn|dev|rc)(\\d+))?)$/', $_version)) { // check for customized version to not output // "There is a newer version of froxlor" besides the error-message redirectTo($filename, array('s' => $s, 'page' => 'error', 'errno' => 3)); } elseif (version_compare2($version, $_version) == -1) { // there is a newer version - yay $isnewerversion = 1; } else { // nothing new $isnewerversion = 0; } // anzeige über version-status mit ggfls. formular // zum update schritt #1 -> download if ($isnewerversion == 1) { $text = 'There is a newer version available. Update to version <b>' . $_version . '</b> now?<br/>(Your current version is: ' . $version . ')'; $hiddenparams = '<input type="hidden" name="newversion" value="' . $_version . '" />'; $yesfile = $filename . '?s=' . $s . '&page=getdownload'; eval("echo \"" . getTemplate("misc/question_yesno", true) . "\";"); exit; } elseif ($isnewerversion == 0) {
function check_market_compatibility($versions) { $versions = explode(',', $versions); $current_version = OSCLASS_VERSION; foreach ($versions as $_version) { $result = version_compare2(OSCLASS_VERSION, $_version); if ($result == 0 || $result == -1) { return true; } } return false; }
function getLatestFroxlorVersion($vendor, $module, $version) { $version_file = dirname(__FILE__) . '/vfiles/' . strtolower($vendor) . '_' . strtolower($module) . '.version'; $vf_data = getVersionInfoFromFile($version_file); $return = array(); if (!isset($vf_data['error'])) { $v = $vf_data[0]; $u = isset($vf_data[1]) ? $vf_data[1] : ''; $m = isset($vf_data[2]) ? $vf_data[2] : ''; $vc = version_compare2($v, $version); if ($vc == 0) { $return['has_latest'] = true; $return['version'] = $v; } elseif ($vc == 1) { $return['has_latest'] = false; $return['version'] = $v; $return['uri'] = $u; $return['message'] = $m; } else { /* * maybe testing version? */ $vf_data = getLatestFroxlorTestingVersion(); if (!isset($vf_data['error'])) { $v = $vf_data[0]; $u = isset($vf_data[1]) ? $vf_data[1] : ''; $m = isset($vf_data[2]) ? $vf_data[2] : ''; $vc = version_compare2($v, $version); if ($vc == 0) { $return['has_latest'] = true; $return['is_testing'] = true; $return['version'] = $v; } elseif ($vc == 1) { $return['has_latest'] = false; $return['is_testing'] = true; $return['version'] = $v; $return['uri'] = $u; $return['message'] = $m; } else { return array('error' => true, 'message' => 'It looks like your Froxlor installation has been customized, no support sorry.'); } } else { /* * return error */ $return = $vf_data; } } } else { $return = $vf_data; } return $return; }
function check_market_compatibility($versions, $type = '') { $compatible = false; $versions = explode(',', $versions); $current_version = OSCLASS_VERSION; $version_length = strlen($current_version); foreach ($versions as $_version) { $result = version_compare2(OSCLASS_VERSION, $_version); if ($result == 0 || $result == -1) { return true; } } return $compatible; }
function osc_is_update_compatible($section, $element, $osclass_version = OSCLASS_VERSION) { if ($element != '') { $data = array(); if (stripos($element, "http://") === FALSE) { // OSCLASS OFFICIAL REPOSITORY $url = osc_market_url($section, $element); $data = json_decode(osc_file_get_contents($url, array('api_key' => osc_market_api_connect())), true); } else { // THIRD PARTY REPOSITORY if (osc_market_external_sources()) { $data = json_decode(osc_file_get_contents($element), true); } } if (isset($data['s_compatible'])) { $versions = explode(',', $data['s_compatible']); foreach ($versions as $_version) { $result = version_compare2($osclass_version, $_version); if ($result == 0 || $result == -1) { return true; } } } } return false; }
function _need_update($uri, $version, $operator = '>') { if (false === ($json = @osc_file_get_contents($uri))) { return false; } else { $data = json_decode($json, true); if (isset($data['s_version'])) { $result = version_compare2($data['s_version'], $version); if ($result == -1) { return true; } } } }