mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
Trying update core to PHP 7.4.21
This commit is contained in:
parent
e74e6c3f77
commit
1a884f6d2a
12 changed files with 80 additions and 79 deletions
|
|
@ -48,7 +48,7 @@ class Java_String{
|
|||
trigger_error("Undefined offset $index", E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
return $this->value{$index};
|
||||
return $this->value[$index];
|
||||
}
|
||||
|
||||
public function hashCode(){
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Random{
|
|||
$state[] = $i;
|
||||
}
|
||||
for($i = $j = 0; $i < 256; ++$i){
|
||||
$j = ($j + ord($seed{$i & 0x03}) + $state[$i]) & 0xFF;
|
||||
$j = ($j + ord($seed[$i & 0x03]) + $state[$i]) & 0xFF;
|
||||
$state[$i] ^= $state[$j];
|
||||
$state[$j] ^= $state[$i];
|
||||
$state[$i] ^= $state[$j];
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ class Utils{
|
|||
public static $online = true;
|
||||
public static $ip = false;
|
||||
|
||||
public static function isOnline(){
|
||||
/*public static function isOnline(){
|
||||
return ((@fsockopen("8.8.8.8", 80, $e = null, $n = null, 2) !== false or @fsockopen("www.linux.org", 80, $e = null, $n = null, 2) !== false or @fsockopen("www.php.net", 80, $e = null, $n = null, 2) !== false) ? true:false);
|
||||
}
|
||||
}*/
|
||||
|
||||
public static function getCallableIdentifier(callable $variable){
|
||||
if(is_array($variable)){
|
||||
|
|
@ -205,14 +205,14 @@ class Utils{
|
|||
public static function readMetadata($value, $types = false){
|
||||
$offset = 0;
|
||||
$m = array();
|
||||
$b = ord($value{$offset});
|
||||
$b = ord($value[$offset]);
|
||||
++$offset;
|
||||
while($b !== 127 and isset($value{$offset})){
|
||||
while($b !== 127 and isset($value[$offset])){
|
||||
$bottom = $b & 0x1F;
|
||||
$type = $b >> 5;
|
||||
switch($type){
|
||||
case 0:
|
||||
$r = Utils::readByte($value{$offset});
|
||||
$r = Utils::readByte($value[$offset]);
|
||||
++$offset;
|
||||
break;
|
||||
case 1:
|
||||
|
|
@ -237,7 +237,7 @@ class Utils{
|
|||
$r = array();
|
||||
$r[] = Utils::readLShort(substr($value, $offset, 2));
|
||||
$offset += 2;
|
||||
$r[] = ord($value{$offset});
|
||||
$r[] = ord($value[$offset]);
|
||||
++$offset;
|
||||
$r[] = Utils::readLShort(substr($value, $offset, 2));
|
||||
$offset += 2;
|
||||
|
|
@ -256,7 +256,7 @@ class Utils{
|
|||
}else{
|
||||
$m[$bottom] = $r;
|
||||
}
|
||||
$b = ord($value{$offset});
|
||||
$b = ord($value[$offset]);
|
||||
++$offset;
|
||||
}
|
||||
return $m;
|
||||
|
|
@ -309,7 +309,7 @@ class Utils{
|
|||
(string) memory_get_usage().".".memory_get_peak_usage(),
|
||||
php_uname(),
|
||||
phpversion(),
|
||||
extension_loaded("gmp") ? gmp_strval(gmp_random(4)):microtime(),
|
||||
//extension_loaded("gmp") ? gmp_strval(gmp_random(4)):microtime(),
|
||||
zend_version(),
|
||||
(string) getmypid(),
|
||||
(string) getmyuid(),
|
||||
|
|
@ -353,11 +353,11 @@ class Utils{
|
|||
//Von Neumann randomness extractor, increases entropy
|
||||
$bitcnt = 0;
|
||||
for($j = 0; $j < 64; ++$j){
|
||||
$a = ord($strongEntropy{$j});
|
||||
$a = ord($strongEntropy[$j]);
|
||||
for($i = 0; $i < 8; $i += 2){
|
||||
$b = ($a & (1 << $i)) > 0 ? 1:0;
|
||||
if($b != (($a & (1 << ($i + 1))) > 0 ? 1:0)){
|
||||
$secureValue |= $b << $bitcnt;
|
||||
$secureValue = $b << $bitcnt;
|
||||
if($bitcnt == 7){
|
||||
$value .= chr($secureValue);
|
||||
$secureValue = 0;
|
||||
|
|
@ -465,7 +465,7 @@ class Utils{
|
|||
}
|
||||
|
||||
public static function readByte($c, $signed = true){
|
||||
$b = ord($c{0});
|
||||
$b = ord($c[0]);
|
||||
if($signed === true and ($b & 0x80) === 0x80){ //calculate Two's complement
|
||||
$b = -0x80 + ($b & 0x7f);
|
||||
}
|
||||
|
|
@ -585,7 +585,7 @@ class Utils{
|
|||
public static function readLong($x, $signed = true){
|
||||
$value = "0";
|
||||
if($signed === true){
|
||||
$negative = ((ord($x{0}) & 0x80) === 0x80) ? true:false;
|
||||
$negative = ((ord($x[0]) & 0x80) === 0x80) ? true:false;
|
||||
if($negative){
|
||||
$x = ~$x;
|
||||
}
|
||||
|
|
@ -595,17 +595,17 @@ class Utils{
|
|||
|
||||
for($i = 0; $i < 8; $i += 4){
|
||||
$value = bcmul($value, "4294967296", 0); //4294967296 == 2^32
|
||||
$value = bcadd($value, 0x1000000 * ord(@$x{$i}) + ((ord(@$x{$i + 1}) << 16) | (ord(@$x{$i + 2}) << 8) | ord(@$x{$i + 3})), 0);
|
||||
$value = bcadd($value, 0x1000000 * ord(@$x[$i]) + ((ord(@$x[$i + 1]) << 16) | (ord(@$x[$i + 2]) << 8) | ord(@$x[$i + 3])), 0);
|
||||
}
|
||||
return ($negative === true ? "-".$value:$value);
|
||||
}
|
||||
|
||||
public static function writeLong($value){
|
||||
$x = "";
|
||||
if($value{0} === "-"){
|
||||
if($value[0] === "-"){
|
||||
$negative = true;
|
||||
$value = bcadd($value, "1");
|
||||
if($value{0} === "-"){
|
||||
if($value[0] === "-"){
|
||||
$value = substr($value, 1);
|
||||
}
|
||||
}else{
|
||||
|
|
@ -634,6 +634,6 @@ class Utils{
|
|||
|
||||
}
|
||||
|
||||
if(Utils::isOnline() === false){
|
||||
Utils::$online = false;
|
||||
}
|
||||
//if(Utils::isOnline() === false){
|
||||
//Utils::$online = false;
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -22,23 +22,6 @@
|
|||
define("ASYNC_CURL_GET", 1);
|
||||
define("ASYNC_CURL_POST", 2);
|
||||
|
||||
class StackableArray extends Stackable{
|
||||
public function __construct(){
|
||||
foreach(func_get_args() as $n => $value){
|
||||
if(is_array($value)){
|
||||
$this->{$n} = new StackableArray();
|
||||
call_user_func_array(array($this->{$n}, "__construct"), $value);
|
||||
}else{
|
||||
$this->{$n} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct(){}
|
||||
|
||||
public function run(){}
|
||||
}
|
||||
|
||||
class AsyncMultipleQueue extends Thread{
|
||||
public $input;
|
||||
public $output;
|
||||
|
|
@ -57,8 +40,8 @@ class AsyncMultipleQueue extends Thread{
|
|||
}
|
||||
$offset = 0;
|
||||
while(!isset($str{$len - 1})){
|
||||
if(isset($this->input{$offset})){
|
||||
$str .= $this->input{$offset};
|
||||
if(isset($this->input[$offset])){
|
||||
$str .= $this->input[$offset];
|
||||
++$offset;
|
||||
}
|
||||
}
|
||||
|
|
@ -76,9 +59,9 @@ class AsyncMultipleQueue extends Thread{
|
|||
$timeout = Utils::readShort($this->get(2));
|
||||
|
||||
$res = (string) Utils::curl_get($url, $timeout);
|
||||
$this->lock();
|
||||
//$this->lock();
|
||||
$this->output .= Utils::writeInt($rID).Utils::writeShort(ASYNC_CURL_GET).Utils::writeInt(strlen($res)).$res;
|
||||
$this->unlock();
|
||||
//$this->unlock();
|
||||
break;
|
||||
case ASYNC_CURL_POST:
|
||||
$url = $this->get(Utils::readShort($this->get(2), false));
|
||||
|
|
@ -90,9 +73,9 @@ class AsyncMultipleQueue extends Thread{
|
|||
$d[$key] = $this->get(Utils::readInt($this->get(4), false));
|
||||
}
|
||||
$res = (string) Utils::curl_post($url, $d, $timeout);
|
||||
$this->lock();
|
||||
//$this->lock();
|
||||
$this->output .= Utils::writeInt($rID).Utils::writeShort(ASYNC_CURL_POST).Utils::writeInt(strlen($res)).$res;
|
||||
$this->unlock();
|
||||
//$this->unlock();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -132,4 +115,21 @@ class Async extends Thread{
|
|||
|
||||
return $this->result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*class StackableArray extends Stackable{
|
||||
public function __construct(){
|
||||
foreach(func_get_args() as $n => $value){
|
||||
if(is_array($value)){
|
||||
$this->{$n} = new StackableArray();
|
||||
call_user_func_array(array($this->{$n}, "__construct"), $value);
|
||||
}else{
|
||||
$this->{$n} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct(){}
|
||||
|
||||
public function run(){}
|
||||
}*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue