blob: 0481d15a9283db450aed9fec3fca41e83960784c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?php
/* dba dump utility
*
* Usage php dba_dump <file> <handler>
*
* Note: configure with --enable-dba
*
* (c) Marcus Boerger
*/
class dba_reader implements spl_sequence_assoc
{
private $db = NULL;
private $key = false;
private $val = false;
function __construct($file, $handler) {
$this->db = dba_open($file, 'r', $handler);
}
function __destruct() {
if ($this->db) {
dba_close($this->db);
}
}
function rewind() {
if ($this->db) {
$this->key = dba_firstkey($this->db);
}
}
function current() {
return $this->val;
}
function next() {
if ($this->db) {
$this->key = dba_nextkey($this->db);
if ($this->key !== false) {
$this->val = dba_fetch($this->key, $this->db);
}
}
}
function has_more() {
if ($this->db && $this->key !== false) {
return true;
} else {
return false;
}
}
function key() {
return $this->key;
}
}
$db = new dba_reader($argv[1], $argv[2]);
foreach($db as $key => $val) {
echo "'$key' => '$val'\n";
}
?>
|