Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordfenc.../lib
File: wfVersionCheckController.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class wfVersionCheckController {
[2] Fix | Delete
const VERSION_COMPATIBLE = 'compatible';
[3] Fix | Delete
const VERSION_DEPRECATED = 'deprecated';
[4] Fix | Delete
const VERSION_UNSUPPORTED = 'unsupported';
[5] Fix | Delete
[6] Fix | Delete
const OPENSSL_DEV = 0;
[7] Fix | Delete
//Betas are 1-14
[8] Fix | Delete
const OPENSSL_RELEASE = 15;
[9] Fix | Delete
[10] Fix | Delete
public static function shared() {
[11] Fix | Delete
static $_shared = false;
[12] Fix | Delete
if ($_shared === false) {
[13] Fix | Delete
$_shared = new wfVersionCheckController();
[14] Fix | Delete
}
[15] Fix | Delete
return $_shared;
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Returns whether or not all version checks are successful. If any check returns a value other than VERSION_COMPATIBLE, this returns false.
[20] Fix | Delete
*
[21] Fix | Delete
* @return bool
[22] Fix | Delete
*/
[23] Fix | Delete
public function checkVersions() {
[24] Fix | Delete
return ($this->checkPHPVersion() == self::VERSION_COMPATIBLE) && ($this->checkOpenSSLVersion() == self::VERSION_COMPATIBLE) && ($this->checkWordPressVersion() == self::VERSION_COMPATIBLE);
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Does the same thing as checkVersions but also triggers display of the corresponding warnings.
[29] Fix | Delete
*
[30] Fix | Delete
* @return bool
[31] Fix | Delete
*/
[32] Fix | Delete
public function checkVersionsAndWarn() {
[33] Fix | Delete
require(dirname(__FILE__) . '/wfVersionSupport.php');
[34] Fix | Delete
/**
[35] Fix | Delete
* @var string $wfPHPDeprecatingVersion
[36] Fix | Delete
* @var string $wfPHPMinimumVersion
[37] Fix | Delete
* @var string $wfOpenSSLDeprecatingVersion
[38] Fix | Delete
* @var string $wfOpenSSLMinimumVersion
[39] Fix | Delete
* @var string $wfWordPressDeprecatingVersion
[40] Fix | Delete
* @var string $wfWordPressMinimumVersion
[41] Fix | Delete
*/
[42] Fix | Delete
[43] Fix | Delete
//PHP
[44] Fix | Delete
$php = $this->checkPHPVersion();
[45] Fix | Delete
if ($php == self::VERSION_DEPRECATED) {
[46] Fix | Delete
$this->_alertEmail(
[47] Fix | Delete
'phpVersionCheckDeprecationEmail_' . $wfPHPDeprecatingVersion,
[48] Fix | Delete
__('PHP version too old', 'wordfence'),
[49] Fix | Delete
sprintf(
[50] Fix | Delete
/* translators: 1. PHP version. 2. PHP version. */
[51] Fix | Delete
__('Your site is using a PHP version (%1$s) that will no longer be supported by Wordfence in an upcoming release and needs to be updated. We recommend using the newest version of PHP available but will currently support PHP versions as old as %2$s. Version checks are run regularly, so if you have successfully updated, you can dismiss this notice or check that the update has taken effect later.', 'wordfence'),
[52] Fix | Delete
phpversion(),
[53] Fix | Delete
$wfPHPDeprecatingVersion
[54] Fix | Delete
)
[55] Fix | Delete
. ' ' .
[56] Fix | Delete
sprintf(__('Learn More: %s', 'wordfence'), wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_PHP))
[57] Fix | Delete
);
[58] Fix | Delete
[59] Fix | Delete
$this->_adminNotice(
[60] Fix | Delete
'phpVersionCheckDeprecationNotice_' . $wfPHPDeprecatingVersion,
[61] Fix | Delete
'phpVersionCheck',
[62] Fix | Delete
wp_kses(sprintf(
[63] Fix | Delete
/* translators: 1. PHP version. 2. PHP version. */
[64] Fix | Delete
__('<strong>WARNING: </strong> Your site is using a PHP version (%1$s) that will no longer be supported by Wordfence in an upcoming release and needs to be updated. We recommend using the newest version of PHP available but will currently support PHP versions as old as %2$s. Version checks are run regularly, so if you have successfully updated, you can dismiss this notice or check that the update has taken effect later.', 'wordfence'),
[65] Fix | Delete
phpversion(),
[66] Fix | Delete
$wfPHPDeprecatingVersion
[67] Fix | Delete
), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array()))) . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_PHP) . '" target="_blank" rel="noopener noreferrer">' . esc_html__('Learn More', 'wordfence') . '<span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'
[68] Fix | Delete
);
[69] Fix | Delete
}
[70] Fix | Delete
else if ($php == self::VERSION_UNSUPPORTED) {
[71] Fix | Delete
$this->_alertEmail(
[72] Fix | Delete
'phpVersionCheckUnsupportedEmail_' . $wfPHPMinimumVersion,
[73] Fix | Delete
__('PHP version too old', 'wordfence'),
[74] Fix | Delete
sprintf(
[75] Fix | Delete
/* translators: 1. PHP version. 2. PHP version. */
[76] Fix | Delete
__('Your site is using a PHP version (%1$s) that is no longer supported by Wordfence and needs to be updated. We recommend using the newest version of PHP available but will currently support PHP versions as old as %2$s. Version checks are run regularly, so if you have successfully updated, you can dismiss this notice or check that the update has taken effect later.', 'wordfence'),
[77] Fix | Delete
phpversion(),
[78] Fix | Delete
$wfPHPDeprecatingVersion
[79] Fix | Delete
) . ' ' . sprintf(/* translators: Support URL. */ __('Learn More: %s', 'wordfence'), wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_PHP))
[80] Fix | Delete
);
[81] Fix | Delete
[82] Fix | Delete
$this->_adminNotice(
[83] Fix | Delete
'phpVersionCheckUnsupportedNotice_' . $wfPHPMinimumVersion,
[84] Fix | Delete
'phpVersionCheck',
[85] Fix | Delete
wp_kses(sprintf(
[86] Fix | Delete
/* translators: 1. PHP version. 2. PHP version. */
[87] Fix | Delete
__('<strong>WARNING: </strong> Your site is using a PHP version (%1$s) that is no longer supported by Wordfence and needs to be updated. We recommend using the newest version of PHP available but will currently support PHP versions as old as %2$s. Version checks are run regularly, so if you have successfully updated, you can dismiss this notice or check that the update has taken effect later.', 'wordfence'),
[88] Fix | Delete
phpversion(),
[89] Fix | Delete
$wfPHPDeprecatingVersion
[90] Fix | Delete
), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array()))) . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_PHP) . '" target="_blank" rel="noopener noreferrer">' . esc_html__('Learn More', 'wordfence') . '<span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'
[91] Fix | Delete
);
[92] Fix | Delete
}
[93] Fix | Delete
else {
[94] Fix | Delete
wfAdminNoticeQueue::removeAdminNotice(false, 'phpVersionCheck');
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
if (wfAdminNoticeQueue::hasNotice('phpVersionCheck')) {
[98] Fix | Delete
return false;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
//OpenSSL
[102] Fix | Delete
wfAdminNoticeQueue::removeAdminNotice(false, 'opensslVersionCheck');
[103] Fix | Delete
/*$openssl = $this->checkOpenSSLVersion();
[104] Fix | Delete
if ($openssl == self::VERSION_DEPRECATED) {
[105] Fix | Delete
$this->_alertEmail(
[106] Fix | Delete
'opensslVersionCheckDeprecationEmail_' . $wfOpenSSLDeprecatingVersion,
[107] Fix | Delete
__('OpenSSL version too old', 'wordfence'),
[108] Fix | Delete
sprintf(__('Your site is using an OpenSSL version (%s) that will no longer be supported by Wordfence in an upcoming release and needs to be updated. We recommend using the newest version of OpenSSL but will currently support OpenSSL versions as old as %s. Version checks are run regularly, so if you have successfully updated, you can dismiss this notice or check that the update has taken effect later.', 'wordfence'), self::openssl_make_text_version(), $wfOpenSSLDeprecatingVersion) . ' ' . sprintf(__('Learn More: %s', 'wordfence'), wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_OPENSSL))
[109] Fix | Delete
);
[110] Fix | Delete
[111] Fix | Delete
$this->_adminNotice(
[112] Fix | Delete
'opensslVersionCheckDeprecationNotice_' . $wfOpenSSLDeprecatingVersion,
[113] Fix | Delete
'opensslVersionCheck',
[114] Fix | Delete
sprintf(__('<strong>WARNING: </strong> Your site is using an OpenSSL version (%s) that will no longer be supported by Wordfence in an upcoming release and needs to be updated. We recommend using the newest version of OpenSSL but will currently support OpenSSL versions as old as %s. Version checks are run regularly, so if you have successfully updated, you can dismiss this notice or check that the update has taken effect later.', 'wordfence'), self::openssl_make_text_version(), $wfOpenSSLDeprecatingVersion) . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_OPENSSL) . '" target="_blank" rel="noopener noreferrer">' . __('Learn More', 'wordfence') . '<span class="screen-reader-text"> (<?php esc_html_e('opens in new tab', 'wordfence') ?>)</span></a>'
[115] Fix | Delete
);
[116] Fix | Delete
[117] Fix | Delete
return false;
[118] Fix | Delete
}
[119] Fix | Delete
else if ($openssl == self::VERSION_UNSUPPORTED) {
[120] Fix | Delete
$this->_alertEmail(
[121] Fix | Delete
'opensslVersionCheckUnsupportedEmail_' . $wfOpenSSLMinimumVersion,
[122] Fix | Delete
__('OpenSSL version too old', 'wordfence'),
[123] Fix | Delete
sprintf(__('Your site is using an OpenSSL version (%s) that is no longer supported by Wordfence and needs to be updated. We recommend using the newest version of OpenSSL but will currently support OpenSSL versions as old as %s. Version checks are run regularly, so if you have successfully updated, you can dismiss this notice or check that the update has taken effect later.', 'wordfence'), self::openssl_make_text_version(), $wfOpenSSLDeprecatingVersion) . ' ' . sprintf(__('Learn More: %s', 'wordfence'), wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_OPENSSL))
[124] Fix | Delete
);
[125] Fix | Delete
[126] Fix | Delete
$this->_adminNotice(
[127] Fix | Delete
'opensslVersionCheckUnsupportedNotice_' . $wfOpenSSLMinimumVersion,
[128] Fix | Delete
'opensslVersionCheck',
[129] Fix | Delete
sprintf(__('<strong>WARNING: </strong> Your site is using an OpenSSL version (%s) that is no longer supported by Wordfence and needs to be updated. We recommend using the newest version of OpenSSL but will currently support OpenSSL versions as old as %s. Version checks are run regularly, so if you have successfully updated, you can dismiss this notice or check that the update has taken effect later.', 'wordfence'), self::openssl_make_text_version(), $wfOpenSSLDeprecatingVersion) . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_OPENSSL) . '" target="_blank" rel="noopener noreferrer">' . __('Learn More', 'wordfence') . '<span class="screen-reader-text"> (<?php esc_html_e('opens in new tab', 'wordfence') ?>)</span></a>'
[130] Fix | Delete
);
[131] Fix | Delete
[132] Fix | Delete
return false;
[133] Fix | Delete
}
[134] Fix | Delete
else {
[135] Fix | Delete
wfAdminNoticeQueue::removeAdminNotice(false, 'opensslVersionCheck');
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
if (wfAdminNoticeQueue::hasNotice('opensslVersionCheck')) {
[139] Fix | Delete
return false;
[140] Fix | Delete
}*/
[141] Fix | Delete
[142] Fix | Delete
//WordPress
[143] Fix | Delete
$wordpress = $this->checkWordPressVersion();
[144] Fix | Delete
if ($wordpress == self::VERSION_DEPRECATED) {
[145] Fix | Delete
require(ABSPATH . 'wp-includes/version.php'); /** @var string $wp_version */
[146] Fix | Delete
[147] Fix | Delete
$this->_alertEmail(
[148] Fix | Delete
'wordpressVersionCheckDeprecationEmail_' . $wfWordPressDeprecatingVersion,
[149] Fix | Delete
__('WordPress version too old', 'wordfence'),
[150] Fix | Delete
sprintf(
[151] Fix | Delete
/* translators: 1. WordPress version. 2. WordPress version. */
[152] Fix | Delete
__('Your site is using a WordPress version (%1$s) that will no longer be supported by Wordfence in an upcoming release and needs to be updated. We recommend using the newest version of WordPress but will currently support WordPress versions as old as %2$s. Version checks are run regularly, so if you have successfully updated, you can dismiss this notice or check that the update has taken effect later.', 'wordfence'),
[153] Fix | Delete
$wp_version,
[154] Fix | Delete
$wfWordPressDeprecatingVersion
[155] Fix | Delete
) . ' ' . sprintf(__('Learn More: %s', 'wordfence'), wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_WORDPRESS))
[156] Fix | Delete
);
[157] Fix | Delete
[158] Fix | Delete
$this->_adminNotice(
[159] Fix | Delete
'wordpressVersionCheckDeprecationNotice_' . $wfWordPressDeprecatingVersion,
[160] Fix | Delete
'wordpressVersionCheck',
[161] Fix | Delete
wp_kses(sprintf(
[162] Fix | Delete
/* translators: 1. WordPress version. 2. WordPress version. */
[163] Fix | Delete
__('<strong>WARNING: </strong> Your site is using a WordPress version (%1$s) that will no longer be supported by Wordfence in an upcoming release and needs to be updated. We recommend using the newest version of WordPress but will currently support WordPress versions as old as %2$s. Version checks are run regularly, so if you have successfully updated, you can dismiss this notice or check that the update has taken effect later.', 'wordfence'),
[164] Fix | Delete
$wp_version,
[165] Fix | Delete
$wfWordPressDeprecatingVersion
[166] Fix | Delete
), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array()))) . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_WORDPRESS) . '" target="_blank" rel="noopener noreferrer">' . esc_html__('Learn More', 'wordfence') . '<span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'
[167] Fix | Delete
);
[168] Fix | Delete
}
[169] Fix | Delete
else if ($wordpress == self::VERSION_UNSUPPORTED) {
[170] Fix | Delete
require(ABSPATH . 'wp-includes/version.php'); /** @var string $wp_version */
[171] Fix | Delete
[172] Fix | Delete
$this->_alertEmail(
[173] Fix | Delete
'wordpressVersionCheckUnsupportedEmail_' . $wfWordPressMinimumVersion,
[174] Fix | Delete
__('WordPress version too old', 'wordfence'),
[175] Fix | Delete
sprintf(
[176] Fix | Delete
/* translators: 1. WordPress version. 2. WordPress version. */
[177] Fix | Delete
__('Your site is using a WordPress version (%1$s) that is no longer supported by Wordfence and needs to be updated. We recommend using the newest version of WordPress but will currently support WordPress versions as old as %2$s. Version checks are run regularly, so if you have successfully updated, you can dismiss this notice or check that the update has taken effect later.', 'wordfence'), $wp_version, $wfWordPressDeprecatingVersion) . ' ' . sprintf(__('Learn More: %s', 'wordfence'), wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_WORDPRESS))
[178] Fix | Delete
);
[179] Fix | Delete
[180] Fix | Delete
$this->_adminNotice(
[181] Fix | Delete
'wordpressVersionCheckUnsupportedNotice_' . $wfWordPressMinimumVersion,
[182] Fix | Delete
'wordpressVersionCheck',
[183] Fix | Delete
wp_kses(sprintf(
[184] Fix | Delete
/* translators: 1. WordPress version. 2. WordPress version. */
[185] Fix | Delete
__('<strong>WARNING: </strong> Your site is using a WordPress version (%1$s) that is no longer supported by Wordfence and needs to be updated. We recommend using the newest version of WordPress but will currently support WordPress versions as old as %2$s. Version checks are run regularly, so if you have successfully updated, you can dismiss this notice or check that the update has taken effect later.', 'wordfence'), $wp_version, $wfWordPressDeprecatingVersion), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array()))) . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_WORDPRESS) . '" target="_blank" rel="noopener noreferrer">' . esc_html__('Learn More', 'wordfence') . '<span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'
[186] Fix | Delete
);
[187] Fix | Delete
}
[188] Fix | Delete
else {
[189] Fix | Delete
wfAdminNoticeQueue::removeAdminNotice(false, 'wordpressVersionCheck');
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
if (wfAdminNoticeQueue::hasNotice('wordpressVersionCheck')) {
[193] Fix | Delete
return false;
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
return true;
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
private function _alertEmail($checkKey, $title, $body) {
[200] Fix | Delete
if (!wfConfig::get($checkKey)) {
[201] Fix | Delete
wordfence::alert($title, $body, wfUtils::getIP());
[202] Fix | Delete
wfConfig::set($checkKey, true);
[203] Fix | Delete
}
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
private function _adminNotice($checkKey, $noticeKey, $message) {
[207] Fix | Delete
if (!wfConfig::get($checkKey)) {
[208] Fix | Delete
wfAdminNoticeQueue::addAdminNotice(wfAdminNotice::SEVERITY_CRITICAL, $message, $noticeKey);
[209] Fix | Delete
wfConfig::set($checkKey, true);
[210] Fix | Delete
}
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
/**
[214] Fix | Delete
* Returns whether or not the PHP version meets our minimum requirement or is a version being deprecated.
[215] Fix | Delete
*
[216] Fix | Delete
* @return string One of the VERSION_ constants.
[217] Fix | Delete
*/
[218] Fix | Delete
public function checkPHPVersion() {
[219] Fix | Delete
require(dirname(__FILE__) . '/wfVersionSupport.php');
[220] Fix | Delete
/**
[221] Fix | Delete
* @var string $wfPHPDeprecatingVersion
[222] Fix | Delete
* @var string $wfPHPMinimumVersion
[223] Fix | Delete
*/
[224] Fix | Delete
[225] Fix | Delete
if (version_compare(phpversion(), $wfPHPDeprecatingVersion, '>=')) {
[226] Fix | Delete
return self::VERSION_COMPATIBLE;
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
if ($wfPHPDeprecatingVersion != $wfPHPMinimumVersion && version_compare(phpversion(), $wfPHPMinimumVersion, '>=')) {
[230] Fix | Delete
return self::VERSION_DEPRECATED;
[231] Fix | Delete
}
[232] Fix | Delete
[233] Fix | Delete
return self::VERSION_UNSUPPORTED;
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
/**
[237] Fix | Delete
* Returns whether or not the OpenSSL version meets our minimum requirement or is a version being deprecated.
[238] Fix | Delete
*
[239] Fix | Delete
* @return string One of the VERSION_ constants.
[240] Fix | Delete
*/
[241] Fix | Delete
public function checkOpenSSLVersion() {
[242] Fix | Delete
require(dirname(__FILE__) . '/wfVersionSupport.php');
[243] Fix | Delete
/**
[244] Fix | Delete
* @var string $wfOpenSSLDeprecatingVersion
[245] Fix | Delete
* @var string $wfOpenSSLMinimumVersion
[246] Fix | Delete
*/
[247] Fix | Delete
[248] Fix | Delete
if (self::openssl_version_compare($wfOpenSSLDeprecatingVersion) <= 0) {
[249] Fix | Delete
return self::VERSION_COMPATIBLE;
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
if ($wfOpenSSLDeprecatingVersion != $wfOpenSSLMinimumVersion && self::openssl_version_compare($wfOpenSSLMinimumVersion) <= 0) {
[253] Fix | Delete
return self::VERSION_DEPRECATED;
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
return self::VERSION_UNSUPPORTED;
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
/**
[260] Fix | Delete
* Returns whether or not the WordPress version meets our minimum requirement or is a version being deprecated.
[261] Fix | Delete
*
[262] Fix | Delete
* @return string One of the VERSION_ constants.
[263] Fix | Delete
*/
[264] Fix | Delete
public function checkWordPressVersion() {
[265] Fix | Delete
require(ABSPATH . 'wp-includes/version.php'); /** @var string $wp_version */
[266] Fix | Delete
[267] Fix | Delete
require(dirname(__FILE__) . '/wfVersionSupport.php');
[268] Fix | Delete
/**
[269] Fix | Delete
* @var string $wfWordPressDeprecatingVersion
[270] Fix | Delete
* @var string $wfWordPressMinimumVersion
[271] Fix | Delete
*/
[272] Fix | Delete
[273] Fix | Delete
if (version_compare($wp_version, $wfWordPressDeprecatingVersion, '>=')) {
[274] Fix | Delete
return self::VERSION_COMPATIBLE;
[275] Fix | Delete
}
[276] Fix | Delete
[277] Fix | Delete
if ($wfWordPressDeprecatingVersion != $wfWordPressMinimumVersion && version_compare($wp_version, $wfWordPressMinimumVersion, '>=')) {
[278] Fix | Delete
return self::VERSION_DEPRECATED;
[279] Fix | Delete
}
[280] Fix | Delete
[281] Fix | Delete
return self::VERSION_UNSUPPORTED;
[282] Fix | Delete
}
[283] Fix | Delete
[284] Fix | Delete
/**
[285] Fix | Delete
* Utility Functions
[286] Fix | Delete
*/
[287] Fix | Delete
[288] Fix | Delete
/**
[289] Fix | Delete
* Returns whether or not the OpenSSL version is before, after, or equal to the equivalent text version string.
[290] Fix | Delete
*
[291] Fix | Delete
* @param string $compareVersion
[292] Fix | Delete
* @param int $openSSLVersion A version number in the format OpenSSL uses.
[293] Fix | Delete
* @param bool $allowDevBeta If true, dev and beta versions of $compareVersion are treated as equivalent to release versions despite having a lower version number.
[294] Fix | Delete
* @return bool|int Returns -1 if $compareVersion is earlier, 0 if equal, 1 if later, and false if not a valid version string.
[295] Fix | Delete
*/
[296] Fix | Delete
public static function openssl_version_compare($compareVersion, $openSSLVersion = OPENSSL_VERSION_NUMBER, $allowDevBeta = true) {
[297] Fix | Delete
if (preg_match('/^(\d+)\.(\d+)\.(\d+)([a-z]*)((?:-dev|-beta\d\d?)?)/i', $compareVersion, $matches)) {
[298] Fix | Delete
$primary = 0; $major = 0; $minor = 0; $fixLetterIndexes = 0; $patch = self::OPENSSL_RELEASE;
[299] Fix | Delete
if (isset($matches[1])) { $primary = (int) $matches[1]; }
[300] Fix | Delete
if (isset($matches[2])) { $major = (int) $matches[2]; }
[301] Fix | Delete
if (isset($matches[3])) { $minor = (int) $matches[3]; }
[302] Fix | Delete
if (isset($matches[4]) && !empty($matches[4])) {
[303] Fix | Delete
$letters = str_split($matches[4]);
[304] Fix | Delete
foreach ($letters as $l) {
[305] Fix | Delete
$fixLetterIndexes += strpos('abcdefghijklmnopqrstuvwxyz', strtolower($l)) + 1;
[306] Fix | Delete
}
[307] Fix | Delete
}
[308] Fix | Delete
if (isset($matches[5]) && !empty($matches[5])) {
[309] Fix | Delete
if (preg_match('/^-beta(\d+)$/i', $matches[5], $betaMatches)) {
[310] Fix | Delete
$patch = (int) $betaMatches[1];
[311] Fix | Delete
}
[312] Fix | Delete
else {
[313] Fix | Delete
$patch = self::OPENSSL_DEV;
[314] Fix | Delete
}
[315] Fix | Delete
}
[316] Fix | Delete
[317] Fix | Delete
$compareOpenSSLVersion = self::openssl_make_number_version($primary, $major, $minor, $fixLetterIndexes, $patch);
[318] Fix | Delete
if ($allowDevBeta) {
[319] Fix | Delete
$compareOpenSSLVersion = $compareOpenSSLVersion >> 4;
[320] Fix | Delete
$openSSLVersion = $openSSLVersion >> 4;
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
if ($compareOpenSSLVersion < $openSSLVersion) { return -1; }
[324] Fix | Delete
else if ($compareOpenSSLVersion == $openSSLVersion) { return 0; }
[325] Fix | Delete
return 1;
[326] Fix | Delete
}
[327] Fix | Delete
[328] Fix | Delete
return false;
[329] Fix | Delete
}
[330] Fix | Delete
[331] Fix | Delete
/**
[332] Fix | Delete
* Builds a number that can be compared to OPENSSL_VERSION_NUMBER from the parameters given. This is a modified
[333] Fix | Delete
* version of the macro in the OpenSSL source.
[334] Fix | Delete
*
[335] Fix | Delete
* @param int $primary The '1' in 1.0.2g.
[336] Fix | Delete
* @param int $major The '0' in 1.0.2g.
[337] Fix | Delete
* @param int $minor The '2' in 1.0.2g.
[338] Fix | Delete
* @param int $fixLetterIndexes The 'g' in 1.0.2g. This can potentially be multiple letters, in which case, all of the indexes are added.
[339] Fix | Delete
* @param int $patch
[340] Fix | Delete
* @return int
[341] Fix | Delete
*/
[342] Fix | Delete
public static function openssl_make_number_version($primary, $major, $minor, $fixLetterIndexes = 0, $patch = 0) {
[343] Fix | Delete
return ((($primary & 0xff) << 28) + (($major & 0xff) << 20) + (($minor & 0xff) << 12) + (($fixLetterIndexes & 0xff) << 4) + $patch);
[344] Fix | Delete
}
[345] Fix | Delete
[346] Fix | Delete
/**
[347] Fix | Delete
* Builds a text version of the OpenSSL version from a number-formatted one.
[348] Fix | Delete
*
[349] Fix | Delete
* @param int $number
[350] Fix | Delete
* @return string
[351] Fix | Delete
*/
[352] Fix | Delete
public static function openssl_make_text_version($number = OPENSSL_VERSION_NUMBER) {
[353] Fix | Delete
$primary = (($number >> 28) & 0xff);
[354] Fix | Delete
$major = (($number >> 20) & 0xff);
[355] Fix | Delete
$minor = (($number >> 12) & 0xff);
[356] Fix | Delete
$fix = (($number >> 4) & 0xff);
[357] Fix | Delete
$patch = ($number & 0xf); //0 is dev, 1-14 are betas, 15 is release
[358] Fix | Delete
[359] Fix | Delete
$alphabet = str_split('abcdefghijklmnopqrstuvwxyz');
[360] Fix | Delete
$fixLetters = '';
[361] Fix | Delete
while ($fix > 26) {
[362] Fix | Delete
$fixLetters .= 'z';
[363] Fix | Delete
$fix -= 26;
[364] Fix | Delete
}
[365] Fix | Delete
if (array_key_exists($fix - 1, $alphabet)) {
[366] Fix | Delete
$fixLetters .= $alphabet[$fix - 1];
[367] Fix | Delete
}
[368] Fix | Delete
[369] Fix | Delete
$version = "{$primary}.{$major}.{$minor}{$fixLetters}";
[370] Fix | Delete
[371] Fix | Delete
if ($patch == self::OPENSSL_DEV) {
[372] Fix | Delete
$version .= '-dev';
[373] Fix | Delete
}
[374] Fix | Delete
else if ($patch == self::OPENSSL_RELEASE) {
[375] Fix | Delete
//Do nothing
[376] Fix | Delete
}
[377] Fix | Delete
else {
[378] Fix | Delete
$version .= '-beta' . $patch;
[379] Fix | Delete
}
[380] Fix | Delete
[381] Fix | Delete
return $version;
[382] Fix | Delete
}
[383] Fix | Delete
}
[384] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function