reverting awful mess in fp-includes

This commit is contained in:
real_nowhereman 2009-07-21 16:41:35 +00:00
parent a1176756a4
commit 744e16a9bb
14 changed files with 146 additions and 184 deletions

View File

@ -224,7 +224,7 @@ class pairs {
function &slice($offset, $count=null) { function &slice($offset, $count=null) {
if (is_null($count)) $count = $this->count; if (is_null($count)) $count = $this->count;
$a = new pairs( $a =& new pairs(
array_slice($this->a, $offset, $count), array_slice($this->a, $offset, $count),
array_slice($this->b, $offset, $count) array_slice($this->b, $offset, $count)
); );
@ -562,14 +562,14 @@ class BPlusTree_Node {
function &getclone($position) { function &getclone($position) {
if ($this->fifo) { if ($this->fifo) {
$dict = $this->fifo->fifo_dict; $dict =& $this->fifo->fifo_dict;
if (isset($dict[$position])) { if (isset($dict[$position])) {
return $dict[$position]; return $dict[$position];
} }
} }
$o = new BPlusTree_Node( $o =& new BPlusTree_Node(
$this->flag, $this->flag,
$this->size, $this->size,
$this->keylen, $this->keylen,
@ -636,7 +636,7 @@ class BPlusTree_Node {
$this->indices[0] = $position; $this->indices[0] = $position;
} else { } else {
// there are nodes // there are nodes
$keys = $this->keys; $keys =& $this->keys;
// is the key there already? // is the key there already?
if (in_array($key, $keys)) { if (in_array($key, $keys)) {
if (array_search($key, $keys) < $validkeys) if (array_search($key, $keys) < $validkeys)
@ -653,7 +653,7 @@ class BPlusTree_Node {
#array_splice($keys, $last, 1); #array_splice($keys, $last, 1);
// store the index // store the index
$indices = $this->indices; $indices =& $this->indices;
#echo "inserting $position before ", var_dump($indices,1), "\n"; #echo "inserting $position before ", var_dump($indices,1), "\n";
array_splice($indices, $place+1, 0, $position); array_splice($indices, $place+1, 0, $position);
unset($indices[$last+1]); unset($indices[$last+1]);
@ -680,8 +680,8 @@ class BPlusTree_Node {
} }
$validkeys = $this->validkeys; $validkeys = $this->validkeys;
$indices = $this->indices; $indices =& $this->indices;
$keys = $this->keys; $keys =& $this->keys;
if (is_null($key)) { if (is_null($key)) {
$place = 0; $place = 0;
$indexplace = 0; $indexplace = 0;
@ -751,7 +751,7 @@ class BPlusTree_Node {
* @returns object {@link pairs} * @returns object {@link pairs}
*/ */
function &_pairs($a, $b) { function &_pairs($a, $b) {
$x = new pairs($a,$b); $x =& new pairs($a,$b);
return $x; return $x;
} }
@ -805,12 +805,12 @@ class BPlusTree_Node {
// fifo // fifo
$fifo = $this->fifo; $fifo =& $this->fifo;
if ($fifo) { if ($fifo) {
$ff = $fifo->fifo; $ff =& $fifo->fifo;
$fd = $fifo->fifo_dict; $fd =& $fifo->fifo_dict;
if (isset($fd[$place])) { if (isset($fd[$place])) {
$node = $fd[$place]; $node =& $fd[$place];
#unset($ff[$place]); #unset($ff[$place]);
$idx = array_search($node, $ff, true); $idx = array_search($node, $ff, true);
array_splice($ff, $idx, 1); array_splice($ff, $idx, 1);
@ -819,8 +819,8 @@ class BPlusTree_Node {
} }
} }
$node = $this->getclone($place); $node =& $this->getclone($place);
$node = $node->materialize(); $node =& $node->materialize();
return $node; return $node;
} }
@ -839,8 +839,8 @@ class BPlusTree_Node {
if ($place == BPT_NULLSEEK) if ($place == BPT_NULLSEEK)
return null; return null;
else { else {
$node = $this->getclone($place); $node =& $this->getclone($place);
$node = $node->materialize(); $node =& $node->materialize();
return $node; return $node;
} }
@ -855,8 +855,8 @@ class BPlusTree_Node {
if ($place == BPT_NULLSEEK) if ($place == BPT_NULLSEEK)
return null; return null;
else { else {
$node = $this->getclone($place); $node =& $this->getclone($place);
$node = $node->materialize(); $node =& $node->materialize();
return $node; return $node;
} }
@ -878,8 +878,8 @@ class BPlusTree_Node {
trigger_error("cannot get next for non-leaf ($key)", E_USER_ERROR); trigger_error("cannot get next for non-leaf ($key)", E_USER_ERROR);
} }
$validkeys = $this->validkeys; $validkeys = $this->validkeys;
$indices = $this->indices; $indices =& $this->indices;
$keys = $this->keys; $keys =& $this->keys;
if ($validkeys<=0) { // empty if ($validkeys<=0) { // empty
// first entry // first entry
@ -934,8 +934,8 @@ class BPlusTree_Node {
*/ */
function put_all_values($keys_indices) { function put_all_values($keys_indices) {
$this->clear(); $this->clear();
$indices = $this->indices; $indices =& $this->indices;
$keys = $this->keys; $keys =& $this->keys;
$length = $this->validkeys = $keys_indices->count;#count($keys_indices); $length = $this->validkeys = $keys_indices->count;#count($keys_indices);
if ($length > $this->size) if ($length > $this->size)
trigger_error("bad length $length", E_USER_ERROR); trigger_error("bad length $length", E_USER_ERROR);
@ -959,8 +959,8 @@ class BPlusTree_Node {
function put_all_positions($first_position, $keys_positions) { function put_all_positions($first_position, $keys_positions) {
$this->clear(); $this->clear();
$indices = $this->indices; $indices =& $this->indices;
$keys = $this->keys; $keys =& $this->keys;
$length = $this->validkeys = $keys_positions->count;#count($keys_positions); $length = $this->validkeys = $keys_positions->count;#count($keys_positions);
if ($length > $this->size) { if ($length > $this->size) {
trigger_error("bad length $length", E_USER_ERROR); trigger_error("bad length $length", E_USER_ERROR);
@ -1012,9 +1012,9 @@ class BPlusTree_Node {
trigger_error('cannot make leaf neighbour for non-leaf'); trigger_error('cannot make leaf neighbour for non-leaf');
// create clone // create clone
$neighbour = $this->getclone($position); $neighbour =& $this->getclone($position);
$size = $this->size; $size = $this->size;
$indices = $this->indices; $indices =& $this->indices;
// linking siblings // linking siblings
$neighbour->indices[$size] = $indices[$size]; $neighbour->indices[$size] = $indices[$size];
@ -1087,8 +1087,8 @@ class BPlusTree_Node {
* @param string $key target key * @param string $key target key
*/ */
function delvalue($key) { function delvalue($key) {
$keys = $this->keys; $keys =& $this->keys;
$indices = $this->indices; $indices =& $this->indices;
if (!in_array($key, $keys)) { if (!in_array($key, $keys)) {
d($keys); d($keys);
trigger_error ("missing key, can't delete", E_USER_ERROR); trigger_error ("missing key, can't delete", E_USER_ERROR);
@ -1168,7 +1168,7 @@ class BPlusTree_Node {
fseek($file, 0, SEEK_END); fseek($file, 0, SEEK_END);
$position = ftell($file); $position = ftell($file);
d("ALLOCATING SPACE..."); d("ALLOCATING SPACE...");
$thenode = $this->getclone($position); $thenode =& $this->getclone($position);
$thenode->store(); $thenode->store();
return array(&$thenode, BPT_NULLSEEK); return array(&$thenode, BPT_NULLSEEK);
} else { } else {
@ -1210,9 +1210,9 @@ class BPlusTree_Node {
if (is_null($position)) if (is_null($position))
trigger_error("position cannot be null",E_USER_ERROR); trigger_error("position cannot be null",E_USER_ERROR);
$fifo = $this->fifo; $fifo =& $this->fifo;
if (!$force && $fifo) { if (!$force && $fifo) {
$fd = $fifo->fifo_dict; $fd =& $fifo->fifo_dict;
if (isset($fd[$this->position]) && $fd[$position] === $this) { if (isset($fd[$this->position]) && $fd[$position] === $this) {
$this->dirty = true; $this->dirty = true;
return; // defer processing return; // defer processing
@ -1245,11 +1245,11 @@ class BPlusTree_Node {
$position = $this->position; $position = $this->position;
if ($this->fifo) { if ($this->fifo) {
$fifo = $this->fifo; $fifo =& $this->fifo;
$dict = $fifo->fifo_dict; $dict =& $fifo->fifo_dict;
$ff = $fifo->fifo; $ff =& $fifo->fifo;
if (isset($dict[$position])) { if (isset($dict[$position])) {
$node = $dict[$position]; $node =& $dict[$position];
if ($node !== $ff[0]) { if ($node !== $ff[0]) {
$nidx = array_search($node, $ff, true); $nidx = array_search($node, $ff, true);
unset($ff[$nidx]); unset($ff[$nidx]);
@ -1359,8 +1359,8 @@ class BPlusTree_Node {
echo "free->", $this->position, "\n"; echo "free->", $this->position, "\n";
$nextp = $this->indices[0]; $nextp = $this->indices[0];
if ($nextp!=BPT_NULLSEEK) { if ($nextp!=BPT_NULLSEEK) {
$next = $this->getclone($nextp); $next =& $this->getclone($nextp);
$next = $next->materialize(); $next =& $next->materialize();
$next->dump(); $next->dump();
} else { } else {
echo "!last\n"; echo "!last\n";
@ -1386,8 +1386,8 @@ class BPlusTree_Node {
while(list(,$i) = each($this->indices)) { while(list(,$i) = each($this->indices)) {
if ($i!=BPT_NULLSEEK) { if ($i!=BPT_NULLSEEK) {
// interior // interior
$n = $this->getclone($i); $n =& $this->getclone($i);
$n = $n->materialize(); $n =& $n->materialize();
$n->dump($nextindent); $n->dump($nextindent);
} else { } else {
//leaf //leaf
@ -1404,18 +1404,18 @@ class BPlusTree_Node {
* adds this node to fifo * adds this node to fifo
*/ */
function add_to_fifo() { function add_to_fifo() {
$fifo = $this->fifo; $fifo =& $this->fifo;
$ff = $fifo->fifo; $ff =& $fifo->fifo;
$dict = $fifo->fifo_dict; $dict =& $fifo->fifo_dict;
$position = $this->position; $position = $this->position;
if(isset($dict[$position])) { if(isset($dict[$position])) {
$old = $dict[$position]; $old =& $dict[$position];
unset($dict[$position]); unset($dict[$position]);
# ff.remove(old) # ff.remove(old)
array_splice($ff, array_search($old, $ff, true), 1); array_splice($ff, array_search($old, $ff, true), 1);
} }
$dict[$this->position] = $this; $dict[$this->position] =& $this;
array_splice($ff, 0, 0, array(&$this)); array_splice($ff, 0, 0, array(&$this));
if (count($ff)>$this->fifo->fifosize) { if (count($ff)>$this->fifo->fifosize) {
$lastidx = count($ff)-1; $lastidx = count($ff)-1;
@ -1546,7 +1546,7 @@ class BPlusTree {
$includeupper =null $includeupper =null
) { ) {
$o = new BPlusWalker($this, $keylower, $includelower, $keyupper, $includeupper); $o =& new BPlusWalker($this, $keylower, $includelower, $keyupper, $includeupper);
return $o; return $o;
} }
@ -1594,7 +1594,7 @@ class BPlusTree {
$file = $this->file; $file = $this->file;
fseek($file, 0, SEEK_END); fseek($file, 0, SEEK_END);
$this->root_seek = ftell($file); $this->root_seek = ftell($file);
$this->root = new BplusTree_Node( $this->root =& new BplusTree_Node(
BPT_FLAG_LEAFANDROOT, BPT_FLAG_LEAFANDROOT,
$this->nodesize, $this->keylen, $this->root_seek, $file $this->nodesize, $this->keylen, $this->root_seek, $file
); );
@ -1609,14 +1609,14 @@ class BPlusTree {
$file = $this->file; $file = $this->file;
if ($this->get_parameters()===false) if ($this->get_parameters()===false)
return false; return false;
$this->root = new BplusTree_Node( $this->root =& new BplusTree_Node(
BPT_FLAG_LEAFANDROOT, BPT_FLAG_LEAFANDROOT,
$this->nodesize, $this->nodesize,
$this->keylen, $this->keylen,
$this->root_seek, $this->root_seek,
$file $file
); );
$this->root = $this->root->materialize(); $this->root =& $this->root->materialize();
return true; return true;
} }
@ -1749,7 +1749,7 @@ class BPlusTree {
} }
$node = $node->getnode($nodekey); $node =& $node->getnode($nodekey);
} }
return $node->getvalue($key, $loose); return $node->getvalue($key, $loose);
@ -1781,7 +1781,7 @@ class BPlusTree {
if (!is_numeric($val)) if (!is_numeric($val))
trigger_error("Second parameter must be numeric", E_USER_ERROR); trigger_error("Second parameter must be numeric", E_USER_ERROR);
$curr_length = $this->length; $curr_length = $this->length;
$root = $this->root; $root =& $this->root;
if (is_null($root)) trigger_error("not open", E_USER_ERROR); if (is_null($root)) trigger_error("not open", E_USER_ERROR);
if (!is_string($key)) trigger_error("$key must be string", E_USER_ERROR); if (!is_string($key)) trigger_error("$key must be string", E_USER_ERROR);
if (strlen($key)>$this->keylen) if (strlen($key)>$this->keylen)
@ -1817,7 +1817,7 @@ class BPlusTree {
$newroot->clear(); $newroot->clear();
$newroot->putfirstindex($root->position); $newroot->putfirstindex($root->position);
$newroot->putnode($leftmost, $node); $newroot->putnode($leftmost, $node);
$this->root = $newroot; $this->root =& $newroot;
$this->root_seek = $newroot->position; $this->root_seek = $newroot->position;
$newroot->store(); $newroot->store();
$root->store(); $root->store();
@ -1850,7 +1850,7 @@ class BPlusTree {
function set($key, $val, &$node) { function set($key, $val, &$node) {
//{{{ //{{{
$keys = $node->keys; $keys =& $node->keys;
$validkeys = $node->validkeys; $validkeys = $node->validkeys;
if (($node->flag & BPT_FLAG_INTERIOR) == BPT_FLAG_INTERIOR) { if (($node->flag & BPT_FLAG_INTERIOR) == BPT_FLAG_INTERIOR) {
d("NON LEAF: FIND DESCENDANT"); d("NON LEAF: FIND DESCENDANT");
@ -1949,7 +1949,7 @@ class BPlusTree {
array(&$this, 'update_freelist') array(&$this, 'update_freelist')
); );
d("CREATE NEW NEIGHBOUR"); d("CREATE NEW NEIGHBOUR");
$newnode = $node->newneighbour($newnode->position); $newnode =& $node->newneighbour($newnode->position);
$newnode->flag = BPT_FLAG_LEAF; $newnode->flag = BPT_FLAG_LEAF;
$newleftmost = $this->divide_entries(0, $node, $newnode, $ki); $newleftmost = $this->divide_entries(0, $node, $newnode, $ki);
$node->store(); $node->store();
@ -1995,7 +1995,7 @@ class BPlusTree {
if (($node->flag & BPT_FLAG_INTERIOR) == BPT_FLAG_INTERIOR) { if (($node->flag & BPT_FLAG_INTERIOR) == BPT_FLAG_INTERIOR) {
// non-leaf // non-leaf
$keys = $node->keys; $keys =& $node->keys;
$validkeys =$node->validkeys; $validkeys =$node->validkeys;
$place = BPT_bisect($keys, $key, 0, $validkeys); $place = BPT_bisect($keys, $key, 0, $validkeys);
@ -2018,7 +2018,7 @@ class BPlusTree {
} }
// get child node // get child node
$nextnode = $node->getnode($nodekey); $nextnode =& $node->getnode($nodekey);
// RECURSION! remove from nextnode; // RECURSION! remove from nextnode;
// returns new leftmost if changed, otherwise null, // returns new leftmost if changed, otherwise null,
@ -2049,17 +2049,17 @@ class BPlusTree {
if ($place >= $validkeys) { if ($place >= $validkeys) {
// final node in row, get previous // final node in row, get previous
$rightnode = $nextnode; $rightnode =& $nextnode;
$rightkey = $nodekey; $rightkey = $nodekey;
if ($validkeys<=1) { if ($validkeys<=1) {
$leftkey = null; $leftkey = null;
} else { } else {
$leftkey = $keys[$place-2]; $leftkey = $keys[$place-2];
} }
$leftnode = $node->getnode($leftkey); $leftnode =& $node->getnode($leftkey);
} else { } else {
// non-final, get next // non-final, get next
$leftnode = $nextnode; $leftnode =& $nextnode;
$leftkey = $nodekey; $leftkey = $nodekey;
if ($index == 0) { if ($index == 0) {
@ -2075,7 +2075,7 @@ class BPlusTree {
#$ki = array_merge($leftki, $rightki); #$ki = array_merge($leftki, $rightki);
$leftki->append($rightki); $leftki->append($rightki);
$ki = $leftki; $ki =& $leftki;
#array_splice ($leftki, count($leftki), 0, $rightki); #array_splice ($leftki, count($leftki), 0, $rightki);
@ -2287,8 +2287,8 @@ class BPlusTree {
} }
$this->root = $root->getnode(null); $this->root =& $root->getnode(null);
$newroot = $this->root; $newroot =& $this->root;
$this->root_seek = $newroot->position; $this->root_seek = $newroot->position;
$this->free = $root->free($this->free); $this->free = $root->free($this->free);
$this->reset_header(); $this->reset_header();
@ -2312,7 +2312,7 @@ class BPlusTree {
} }
function _dump() { function _dump() {
$free = $this->root->getclone($this->free); $free =& $this->root->getclone($this->free);
for ($i=$this->headersize; for ($i=$this->headersize;
!feof($this->file); !feof($this->file);
fseek($this->file, $i), $i+=$free->storage) { fseek($this->file, $i), $i+=$free->storage) {
@ -2329,8 +2329,8 @@ class BPlusTree {
function dump() { function dump() {
$this->root->dump() ; $this->root->dump() ;
if ($this->free != BPT_NULLSEEK) { if ($this->free != BPT_NULLSEEK) {
$free = $this->root->getclone($this->free); $free =& $this->root->getclone($this->free);
$free = $free->materialize(); $free =& $free->materialize();
$free->dump(); $free->dump();
} }
} }
@ -2354,7 +2354,7 @@ class BPlusWalker {
$keyupper=null, $keyupper=null,
$includeupper=null){ $includeupper=null){
$this->tree = $tree; $this->tree =& $tree;
$this->keylower = $keylower; $this->keylower = $keylower;
$this->includelower = $includelower; $this->includelower = $includelower;
$this->keyupper = $keyupper; $this->keyupper = $keyupper;
@ -2380,11 +2380,11 @@ class BPlusWalker {
} }
} }
$node = $node->getnode($nkey); $node =& $node->getnode($nkey);
} }
$this->startnode = $node; $this->startnode =& $node;
$this->node = $node; $this->node =& $node;
$this->node_index = null; $this->node_index = null;
$this->valid = 0; $this->valid = 0;
@ -2393,10 +2393,10 @@ class BPlusWalker {
} }
function first() { function first() {
$this->node = $this->startnode; $this->node =& $this->startnode;
$node = $this->node; $node =& $this->node;
$keys = $node->keys; $keys =& $node->keys;
$keylower = $this->keylower; $keylower = $this->keylower;
$keyupper = $this->keyupper; $keyupper = $this->keyupper;
$validkeys= $node->validkeys; $validkeys= $node->validkeys;
@ -2435,9 +2435,9 @@ class BPlusWalker {
$this->keylower = $testk; $this->keylower = $testk;
} else { } else {
$next = $node->nextneighbour(); $next =& $node->nextneighbour();
if (!is_null($next)) { if (!is_null($next)) {
$this->startnode = $next; $this->startnode =& $next;
$this->first(); $this->first();
return; return;
} else { } else {
@ -2476,15 +2476,15 @@ class BPlusWalker {
function next() { function next() {
$nextp = $this->node_index+1; $nextp = $this->node_index+1;
$node = $this->node; $node =& $this->node;
if ($nextp>=$node->validkeys) { if ($nextp>=$node->validkeys) {
$next = $node->nextneighbour(); $next =& $node->nextneighbour();
if (is_null($next)) { if (is_null($next)) {
$this->valid = 0; $this->valid = 0;
return; return;
} }
$this->node = $next; $this->node =& $next;
$node = $next; $node =& $next;
$nextp = 0; $nextp = 0;
} }
if($node->validkeys <= $nextp) { if($node->validkeys <= $nextp) {
@ -2593,7 +2593,7 @@ class SBPlusTree extends BPlusTree {
$keyupper =null, $keyupper =null,
$includeupper =null $includeupper =null
) { ) {
$o = new SBPlusWalker($this, $keylower, $includelower, $keyupper, $includeupper); $o =& new SBPlusWalker($this, $keylower, $includelower, $keyupper, $includeupper);
return $o; return $o;
} }
} }
@ -2611,14 +2611,6 @@ class caching_SBPT extends SBPlusTree {
var $cache = array(); var $cache = array();
function caching_SBPT($infile, $stringfile,
$maxstring = 256,
$pos=null, $nodesize=null, $keylen=null) {
$this->SBPlusTree($infile, $stringfile, $maxstring, $pos, $nodesize, $keylen);
}
function getitem(&$key, $loose=false) { function getitem(&$key, $loose=false) {
if (isset($cache[$key])) if (isset($cache[$key]))
return $cache[$key]; return $cache[$key];

View File

@ -21,7 +21,7 @@
trigger_error ("Can't find index '{$this->_cachefile}'", E_USER_ERROR); trigger_error ("Can't find index '{$this->_cachefile}'", E_USER_ERROR);
} }
$this->_tree = new caching_SBPT( $this->_tree =& new caching_SBPT(
fopen($this->_cachefile.'.dat', 'rb'), fopen($this->_cachefile.'.dat', 'rb'),
fopen(INDEX_DIR.'index.strings.dat', 'rb'), fopen(INDEX_DIR.'index.strings.dat', 'rb'),
256, 256,
@ -84,7 +84,7 @@
function delete($entryid) { function delete($entryid) {
trigger_error('Cannot delete from a cache', E_USER_ERROR) ; trigger_error('Cannot delete from a cache', E_USER_ERROR) ;
$cache = $this->_list; $cache =& $this->_list;
unset($cache[$entryid]); // if id found, it is deleted unset($cache[$entryid]); // if id found, it is deleted
return $this->save(); return $this->save();

View File

@ -39,7 +39,7 @@
* @see bdb_idtofile() * @see bdb_idtofile()
*/ */
function comment_getlist($id) { function comment_getlist($id) {
$obj = new comment_indexer($id); //todo change syntax $obj =& new comment_indexer($id); //todo change syntax
return $obj->getList(); return $obj->getList();
} }

View File

@ -39,7 +39,7 @@
function &draft_init() { function &draft_init() {
global $draftdb; global $draftdb;
if (!isset($draftdb)) if (!isset($draftdb))
$draftdb = new draft_indexer; $draftdb =& new draft_indexer;
return $draftdb; return $draftdb;
} }
@ -49,7 +49,7 @@
static $list = array(); static $list = array();
if (!$list) { if (!$list) {
$obj = draft_init(); $obj =& draft_init();
$list = $obj->getList(); $list = $obj->getList();
krsort($list); krsort($list);
} }
@ -95,7 +95,7 @@
fs_delete($ed.EXT); fs_delete($ed.EXT);
// remove from normal flow // remove from normal flow
$o = entry_init(); $o =& entry_init();
$o->delete($id, null); $o->delete($id, null);
} }
@ -148,7 +148,7 @@
if (!file_exists($f)) if (!file_exists($f))
return false; return false;
//$draftdb = draft_init(); //$draftdb =& draft_init();
//$draftdb->delete($id); //$draftdb->delete($id);
fs_delete_recursive($dir); fs_delete_recursive($dir);
@ -198,7 +198,7 @@
'id'=>'' 'id'=>''
) )
); );
$arr = $smarty->get_template_vars('draft_list'); $arr =& $smarty->get_template_vars('draft_list');
list($id, $subject)=each($arr); list($id, $subject)=each($arr);

View File

@ -87,7 +87,7 @@
$mode = 'r+b'; $mode = 'r+b';
else $mode = 'w+b'; else $mode = 'w+b';
$this->indices[$cat] = new BPlusTree( $this->indices[$cat] =& new BPlusTree(
fopen($f, $mode), fopen($f, $mode),
$this->_offset, $this->_offset,
$this->_chunksize, $this->_chunksize,
@ -104,7 +104,7 @@
$key = entry_idtokey($id); $key = entry_idtokey($id);
$val = $entry['subject']; $val = $entry['subject'];
$main = $this->get_index(); $main =& $this->get_index();
$seek = null; $seek = null;
// title must not be updated, let's get the offset value from has_key // title must not be updated, let's get the offset value from has_key
@ -121,7 +121,7 @@
if (isset($entry['categories']) && is_array($entry['categories'])) { if (isset($entry['categories']) && is_array($entry['categories'])) {
foreach ($entry['categories'] as $cat) { foreach ($entry['categories'] as $cat) {
if (!is_numeric($cat)) continue; if (!is_numeric($cat)) continue;
$this_index = $this->get_index($cat); $this_index =& $this->get_index($cat);
$this_index->setitem($key, $seek); $this_index->setitem($key, $seek);
} }
} }
@ -131,7 +131,7 @@
foreach($del as $cat) { foreach($del as $cat) {
// echo 'DEL '. $cat,"\n"; // echo 'DEL '. $cat,"\n";
if (!is_numeric($cat)) continue; if (!is_numeric($cat)) continue;
$this_index = $this->get_index($cat); $this_index =& $this->get_index($cat);
$this_index->delitem($key); $this_index->delitem($key);
} }
} }
@ -143,14 +143,14 @@
function delete($id, $entry) { function delete($id, $entry) {
$key = entry_idtokey($id); $key = entry_idtokey($id);
$main = $this->get_index(); $main =& $this->get_index();
$main->delitem($key); $main->delitem($key);
if (isset($entry['categories']) && is_array($entry['categories'])) { if (isset($entry['categories']) && is_array($entry['categories'])) {
foreach ($entry['categories'] as $cat) { foreach ($entry['categories'] as $cat) {
if (!is_numeric($cat)) continue; if (!is_numeric($cat)) continue;
$this_index = $this->get_index($cat); $this_index =& $this->get_index($cat);
if ($this_index->has_key($key)) if ($this_index->has_key($key))
$this_index->delitem($key); $this_index->delitem($key);
} }
@ -345,7 +345,7 @@
static $entry_index = null; static $entry_index = null;
if (is_null($entry_index)) if (is_null($entry_index))
$entry_index= new entry_index; $entry_index=& new entry_index;
return $entry_index; return $entry_index;
@ -358,7 +358,7 @@
if (!file_exists($F)) { if (!file_exists($F)) {
$o = false; $o = false;
} else { } else {
$o = new entry_cached_index($id_cat); $o =& new entry_cached_index($id_cat);
} }
return $o; return $o;
@ -423,7 +423,7 @@
trigger_error('function deprecated', E_USER_ERROR); trigger_error('function deprecated', E_USER_ERROR);
$obj = entry_init(); $obj =& entry_init();
$entry_arr = $obj->getList(); $entry_arr = $obj->getList();
@ -503,7 +503,7 @@
*/ */
function &entry_get_comments($id, &$count) { function &entry_get_comments($id, &$count) {
$obj = new comment_indexer($id); $obj =& new comment_indexer($id);
$count = count($obj->getList()); $count = count($obj->getList());
@ -797,7 +797,7 @@
print_r($all_cats); print_r($all_cats);
*/ */
$INDEX = entry_init(); $INDEX =& entry_init();
$ok = ($update_index) ? $INDEX->add($id, $entry, $delete_cats, $update_title) : true; $ok = ($update_index) ? $INDEX->add($id, $entry, $delete_cats, $update_title) : true;
// PHASE 4 : index updated; let's move back the entry // PHASE 4 : index updated; let's move back the entry
@ -861,7 +861,7 @@
$d = entry_dir($id); $d = entry_dir($id);
fs_delete_recursive($d); fs_delete_recursive($d);
$obj = entry_init(); $obj =& entry_init();
$obj->delete($id, entry_parse($id)); $obj->delete($id, entry_parse($id));
do_action('delete_post', $id); do_action('delete_post', $id);
@ -870,7 +870,7 @@
} }
function entry_purge_cache() { function entry_purge_cache() {
$obj = entry_init(); $obj =& entry_init();
$obj->purge(); $obj->purge();
} }
//add_action('init', //add_action('init',

View File

@ -260,7 +260,7 @@
function fs_delete_recursive($path) { function fs_delete_recursive($path) {
if (file_exists($path)) { if (file_exists($path)) {
$obj = new fs_pathlister($path); $obj =& new fs_pathlister($path);
$list = ($obj->getList()); $list = ($obj->getList());
unset($obj); unset($obj);

View File

@ -148,14 +148,14 @@
global $current_query; global $current_query;
$this->params = new FPDB_QueryParams($params); $this->params =& new FPDB_QueryParams($params);
$this->ID = $ID; $this->ID = $ID;
if ($this->params->id || $this->params->random) { if ($this->params->id || $this->params->random) {
$this->single = true; $this->single = true;
} }
$GLOBALS['current_query'] = $this; $GLOBALS['current_query'] =& $this;
} }
@ -166,7 +166,7 @@
$fpdb->init(); $fpdb->init();
$entry_index = $fpdb->get_index($this->params->category); $entry_index =& $fpdb->get_index($this->params->category);
$this->counter++; $this->counter++;
@ -198,7 +198,7 @@
if (!$this->params->id) if (!$this->params->id)
trigger_error("FPDB: no ID found for query {$this->ID}", E_USER_ERROR); trigger_error("FPDB: no ID found for query {$this->ID}", E_USER_ERROR);
$qp = $this->params; $qp =& $this->params;
$time = entry_idtotime($qp->id); $time = entry_idtotime($qp->id);
@ -222,7 +222,7 @@
// also, if $prevkey != $newkey then $prevkey := $newkey // also, if $prevkey != $newkey then $prevkey := $newkey
$this->walker = $entry_index->walker($prevkey, 2, null, null); $this->walker =& $entry_index->walker($prevkey, 2, null, null);
// since we're searching for $prevkey, i.e. a key preceding the target $id // since we're searching for $prevkey, i.e. a key preceding the target $id
// in the sequence, if $prevkey becomes equal to $key then it means // in the sequence, if $prevkey becomes equal to $key then it means
@ -242,7 +242,7 @@
function _prepare_list(&$entry_index) { function _prepare_list(&$entry_index) {
$qp = $this->params; $qp =& $this->params;
$entry_num = 0; $entry_num = 0;
@ -253,18 +253,18 @@
#$this->local_list = array_keys($entry_index); #$this->local_list = array_keys($entry_index);
$index_count = $entry_index->length(); $index_count = $entry_index->length();
$this->walker = $entry_index->walker($firstid=null); $this->walker =& $entry_index->walker($firstid=null);
} else { } else {
// notice this won't work with cats (for now) // notice this won't work with cats (for now)
$obj = new entry_archives($qp->y, $qp->m, $qp->d); $obj =& new entry_archives($qp->y, $qp->m, $qp->d);
$filteredkeys = $obj->getList(); $filteredkeys = $obj->getList();
$index_count = $obj->getCount(); $index_count = $obj->getCount();
if ($filteredkeys) if ($filteredkeys)
$this->walker = $entry_index->walker( $this->walker =& $entry_index->walker(
entry_idtokey($filteredkeys[0]), true, entry_idtokey($filteredkeys[0]), true,
entry_idtokey($filteredkeys[$index_count-1]), true entry_idtokey($filteredkeys[$index_count-1]), true
); );
@ -294,7 +294,7 @@
/* /*
stuff for cats, have a look stuff for cats, have a look
$this->local_list = $tmp; $this->local_list =& $tmp;
if ($qp->start + $qp->count > $i) { if ($qp->start + $qp->count > $i) {
$qp->count = $i - $qp->start; $qp->count = $i - $qp->start;
@ -305,7 +305,7 @@
// not so great implementation... doesn't work well // not so great implementation... doesn't work well
function _get_random_id(&$entry_index) { function _get_random_id(&$entry_index) {
$qp = $this->params; $qp =& $this->params;
$now = time(); $now = time();
$first = '999999999999'; $first = '999999999999';
@ -329,7 +329,7 @@
function hasMore() { function hasMore() {
$GLOBALS['current_query'] = $this; $GLOBALS['current_query'] =& $this;
if ($this->counter < 0) if ($this->counter < 0)
@ -347,7 +347,7 @@
return $false; return $false;
} }
$qp = $this->params; $qp =& $this->params;
if ($this->counter < 0) if ($this->counter < 0)
@ -403,7 +403,7 @@
} }
if ($qp->comments) { if ($qp->comments) {
$this->comments = new FPDB_CommentList($id, comment_getlist($id)); $this->comments =& new FPDB_CommentList($id, comment_getlist($id));
$cont['comments'] = $this->comments->getCount(); $cont['comments'] = $this->comments->getCount();
} }
@ -420,7 +420,7 @@
if (!$this->hasMore()) if (!$this->hasMore())
return false; return false;
$var = $this->peekEntry(); $var =& $this->peekEntry();
$this->lastentry = $var; $this->lastentry = $var;
$this->walker->next(); $this->walker->next();
@ -581,9 +581,9 @@
function init() { function init() {
#if (!$this->_indexer) { #if (!$this->_indexer) {
#$this->_indexer = new entry_indexer(); #$this->_indexer =& new entry_indexer();
$this->_categories = entry_categories_get(); $this->_categories = entry_categories_get();
#$obj = $this->_indexer; #$obj =& $this->_indexer;
#$this->entry_index = $obj->getList(); #$this->entry_index = $obj->getList();
@ -592,7 +592,7 @@
function &get_index($cat_id = 0) { function &get_index($cat_id = 0) {
if (!isset($this->_indexer[$cat_id])) { if (!isset($this->_indexer[$cat_id])) {
$this->_indexer[$cat_id] = entry_cached_index($cat_id); $this->_indexer[$cat_id] =& entry_cached_index($cat_id);
} }
return $this->_indexer[$cat_id]; return $this->_indexer[$cat_id];
} }
@ -653,7 +653,7 @@
static $queryId=-1; static $queryId=-1;
$queryId++; $queryId++;
$this->queries[$queryId] = new FPDB_Query($params, $queryId); $this->queries[$queryId] =& new FPDB_Query($params, $queryId);
$this->init(); $this->init();
@ -666,7 +666,7 @@
function doquery($queryId=0) { function doquery($queryId=0) {
if (isset($this->queries[$queryId])) { if (isset($this->queries[$queryId])) {
$q = $this->queries[$queryId]; $q =& $this->queries[$queryId];
} else { } else {
return false; return false;
trigger_error("FPDB: no such query ID ($queryId)", E_USER_WARNING); trigger_error("FPDB: no such query ID ($queryId)", E_USER_WARNING);
@ -688,7 +688,7 @@
function &getQuery($queryId=0) { function &getQuery($queryId=0) {
$o = null; $o = null;
if (isset($this->queries[$queryId])) if (isset($this->queries[$queryId]))
$o = $this->queries[$queryId]; $o =& $this->queries[$queryId];
return $o; return $o;
} }
} }
@ -785,15 +785,15 @@
return $content; return $content;
} }
$q = $fpdb->getQuery(); $q =& $fpdb->getQuery();
if($repeat=$q->hasMore()) { if($repeat=$q->hasMore()) {
$couplet = $q->getEntry() ; $couplet =& $q->getEntry() ;
$id = $couplet[0]; $id =& $couplet[0];
$entry = $couplet[1]; $entry =& $couplet[1];
if (THEME_LEGACY_MODE) { if (THEME_LEGACY_MODE) {
$entry = theme_entry_filters($entry, $id); $entry = theme_entry_filters($entry, $id);
@ -835,14 +835,14 @@
) )
); );
$q = $fpdb->getQuery(); $q =& $fpdb->getQuery();
if($repeat=$q->comments->hasMore()) { if($repeat=$q->comments->hasMore()) {
$couplet = $q->comments->getComment(); $couplet =& $q->comments->getComment();
$id = $couplet[0]; $id =& $couplet[0];
$comment = $couplet[1]; $comment =& $couplet[1];
foreach($comment as $k=>$v) { foreach($comment as $k=>$v) {
@ -870,7 +870,7 @@
function smarty_block_comments($params, $content, &$smarty, &$repeat) { function smarty_block_comments($params, $content, &$smarty, &$repeat) {
global $fpdb; global $fpdb;
$q = $fpdb->getQuery(); $q =& $fpdb->getQuery();
$show = $q->comments->getCount(); $show = $q->comments->getCount();
$smarty->assign('entryid', $q->comments->entryid); $smarty->assign('entryid', $q->comments->entryid);

View File

@ -8,7 +8,7 @@
// checks if we already loaded this lang file // checks if we already loaded this lang file
$vals = explode('.', $postfix); // my.file.name ---> my, file, name $vals = explode('.', $postfix); // my.file.name ---> my, file, name
$old_lang = $GLOBALS['lang']; $old_lang =& $GLOBALS['lang'];
if (!$old_lang) if (!$old_lang)
$old_lang = array(); $old_lang = array();
@ -118,7 +118,7 @@
} }
function lang_list() { function lang_list() {
$obj = new lang_indexer(); $obj =& new lang_indexer();
return $obj->getList(); return $obj->getList();
} }

View File

@ -30,7 +30,7 @@
function getEnableds($checkonly) { function getEnableds($checkonly) {
$lang = $GLOBALS['lang']; $lang =& $GLOBALS['lang'];
$errors = array(); $errors = array();
if (!file_exists($this->_enabledlist)) if (!file_exists($this->_enabledlist))
@ -59,7 +59,7 @@
// this is done during init process // this is done during init process
// all the plugin are loaded // all the plugin are loaded
$pluginlister = new plugin_indexer; $pluginlister =& new plugin_indexer;
$enab = $pluginlister->getEnableds($check); $enab = $pluginlister->getEnableds($check);
include_once (INCLUDES_DIR . 'core.wp-pluggable-funcs.php'); include_once (INCLUDES_DIR . 'core.wp-pluggable-funcs.php');
@ -70,7 +70,7 @@
function plugin_get($id=null){ function plugin_get($id=null){
$pluginlister = new plugin_indexer; $pluginlister =& new plugin_indexer;
return $pluginlister->getList(); return $pluginlister->getList();
} }

View File

@ -17,7 +17,7 @@
function static_getlist() { function static_getlist() {
$obj = new static_indexer; $obj =& new static_indexer;
$list = $obj->getList(); $list = $obj->getList();
return $list; return $list;

View File

@ -154,12 +154,12 @@
system_unregister_globals(); system_unregister_globals();
system_prepare_iis(); system_prepare_iis();
$GLOBALS['fpdb'] = new FPDB; $GLOBALS['fpdb'] =& new FPDB;
$GLOBALS['fp_widgets'] = new widget_indexer; $GLOBALS['fp_widgets'] =& new widget_indexer;
$GLOBALS['smarty'] = $GLOBALS['_FP_SMARTY']; $GLOBALS['smarty'] =& $GLOBALS['_FP_SMARTY'];
$smarty = $GLOBALS['smarty']; $smarty =& $GLOBALS['smarty'];
$GLOBALS['fp_config'] = config_load(); $GLOBALS['fp_config'] = config_load();
@ -169,9 +169,9 @@
ob_start(); ob_start();
$GLOBALS['theme'] = theme_loadsettings(); $GLOBALS['theme'] =& theme_loadsettings();
$GLOBALS['lang'] = lang_load(); $GLOBALS['lang'] =& lang_load();
plugin_loadall(); plugin_loadall();

View File

@ -22,7 +22,7 @@
function user_list(){ function user_list(){
$obj = new user_lister; $obj =& new user_lister;
if ($users = $obj->getList()) { if ($users = $obj->getList()) {
return $entry_arr; return $entry_arr;
} else return false; } else return false;

View File

@ -366,36 +366,6 @@ ERR;
} }
} }
class utils_array_walker {
var $_array;
var $valid;
function utils_array_walker(&$array) {
if (!is_array($array) || empty($array))
$this->valid = false;
$this->_array =& $array;
$this->first();
}
function first() {
return reset($this->_array);
}
function current_key() {
return key($this->_array);
}
function current_value() {
return current($this->_array);
}
function current() {
return array($this->current_key(),$this->current_value());
}
function next() {
$v = next($this->_array);
$this->valid = (bool) $v;
return $v;
}
}
function fplog($str) { function fplog($str) {

View File

@ -6,8 +6,8 @@
require_once INCLUDES_DIR.'core.utils.php'; require_once INCLUDES_DIR.'core.utils.php';
utils_checksmarty(); utils_checksmarty();
require(SMARTY_DIR . 'Smarty.class.php'); require(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty; $smarty =& new Smarty;
$_FP_SMARTY = $smarty; $_FP_SMARTY =& $smarty;
// WordPress plugin system // WordPress plugin system
@ -42,7 +42,7 @@
require_once INCLUDES_DIR.'core.cookie.php'; require_once INCLUDES_DIR.'core.cookie.php';
require_once INCLUDES_DIR.'core.system.php'; require_once INCLUDES_DIR.'core.system.php';
require_once INCLUDES_DIR.'core.theme.php'; require_once INCLUDES_DIR.'core.theme.php';
# require_once INCLUDES_DIR.'core.layout.php'; require_once INCLUDES_DIR.'core.layout.php';
require_once INCLUDES_DIR.'core.users.php'; require_once INCLUDES_DIR.'core.users.php';
?> ?>