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: wfArray.php
<?php
[0] Fix | Delete
class wfArray {
[1] Fix | Delete
private $data = "";
[2] Fix | Delete
private $size = 0;
[3] Fix | Delete
private $shiftPtr = 0;
[4] Fix | Delete
private $keys;
[5] Fix | Delete
public function __construct($keys){
[6] Fix | Delete
$this->keys = $keys;
[7] Fix | Delete
}
[8] Fix | Delete
public function push($val){ //associative array with keys that match those given to constructor
[9] Fix | Delete
foreach($this->keys as $key){
[10] Fix | Delete
$this->data .= pack('N', wfUtils::strlen($val[$key])) . $val[$key];
[11] Fix | Delete
}
[12] Fix | Delete
$this->size++;
[13] Fix | Delete
}
[14] Fix | Delete
public function shift(){ //If you alternately call push and shift you must periodically call collectGarbage() or ->data will keep growing
[15] Fix | Delete
$arr = array();
[16] Fix | Delete
if(wfUtils::strlen($this->data) < 1){ return null; }
[17] Fix | Delete
if($this->shiftPtr == wfUtils::strlen($this->data)){ return null; }
[18] Fix | Delete
foreach($this->keys as $key){
[19] Fix | Delete
$len = unpack('N', wfUtils::substr($this->data, $this->shiftPtr, 4));
[20] Fix | Delete
$len = $len[1];
[21] Fix | Delete
$arr[$key] = wfUtils::substr($this->data, $this->shiftPtr + 4, $len);
[22] Fix | Delete
$this->shiftPtr += 4 + $len;
[23] Fix | Delete
}
[24] Fix | Delete
if($this->shiftPtr == wfUtils::strlen($this->data)){ //garbage collection
[25] Fix | Delete
$this->data = ""; //we don't shorten with substr() because the assignment doubles peak mem
[26] Fix | Delete
$this->shiftPtr = 0;
[27] Fix | Delete
}
[28] Fix | Delete
$this->size--;
[29] Fix | Delete
return $arr;
[30] Fix | Delete
}
[31] Fix | Delete
public function collectGarbage(){ //only call collectGarbage if you're alternating between pushes and shifts and never emptying the array.
[32] Fix | Delete
//If you don't collect garbage then the data that is shifted is never freed
[33] Fix | Delete
$this->data = wfUtils::substr($this->data, $this->shiftPtr); //at this point memory usage doubles because of the = assignment (string copy is made), so try not to call collect garbage unless you have to.
[34] Fix | Delete
$this->shiftPtr = 0;
[35] Fix | Delete
}
[36] Fix | Delete
public function zero(){ //Rather call this instead of collect garbage because it's way more mem efficient.
[37] Fix | Delete
$this->data = "";
[38] Fix | Delete
$this->shiftPtr = 0;
[39] Fix | Delete
$this->size = 0;
[40] Fix | Delete
}
[41] Fix | Delete
public function size(){
[42] Fix | Delete
return $this->size;
[43] Fix | Delete
}
[44] Fix | Delete
}
[45] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function