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
67
68
69
70
|
<?php
class sql_gentoo_package extends sql_row_obj {
protected $table='gentoo_packages', $primary_key=array('id'), $columns=array(
'id' => array (
'type' => 'INT',
'length' => 10,
'unsigned' => true,
'not_null' => true,
'auto_increment' => true
),
'profile' => array (
'type' => 'TINYINT',
'length' => 3,
'unsigned' => true,
'not_null' => true,
'default' => 0,
'refers_to' => 'gentoo_profiles.id'
),
'bcat' => array (
'type' => 'VARCHAR',
'length' => 255,
'not_null' => true,
'default' => ''
),
'lcat' => array (
'type' => 'VARCHAR',
'length' => 255,
'not_null' => true,
'default' => ''
),
'name' => array (
'type' => 'VARCHAR',
'length' => 255,
'not_null' => true,
'default' => ''
),
'version' => array (
'type' => 'VARCHAR',
'length' => 255,
'not_null' => true,
'default' => ''
),
'data' => array (
'type' => 'TEXT',
'not_null' => true
)
);
function &to_array($skip_masked=false) {
$r=array();
foreach (explode("\n", $this->data) as $line) {
if (!strlen($line)) continue;
list($name, $val)=explode(': ', $line, 2);
$name=strtolower($name);
$r[$name]=$val;
}
if (!$skip_masked) {
$r['masked']=$this->is_masked($r);
}
return $r;
}
function is_masked(&$array=null) {
if ($array === null) {
$array=$this->to_array(true);
}
$heads=$this->get_profile()->get_headers();
return !count(array_intersect(explode(' ', $array['keywords']), explode(' ', $heads['accept_keywords'])));
}
}
?>
|