4 var $sections = array();
7 var $attribute_names = array();
9 cfunction getSection($s) {
10 //// echo "getSection(".$s.")<br>";
12 for ($i=0; $i<count($this->sections); $i++) {
13 $sect = $this->sections[$i];
14 // echo $sect[0]."<br>";
16 // echo "Found ".$sect[0]."<br>";
20 // echo "Didn't find ".$s."<br>";
23 $class = explode(".", $s);
24 $sect = $this->getSection($class[0]);
27 for ($i=0; $i<count($sect); $i++) {
29 // echo $values[0]."<br>";
30 if ($values[0] == $class[1]) {
31 // echo "Found ".$values[0]."<br>";
35 // echo "Didn't find ".$class[1]."<br>";
37 cfunction getName($s) {
38 $n = trim(strtok($s, "{"));
41 cfunction getBody($s) {
42 $i = strpos($s, "{") + 1;
43 $j = strpos($s, "}") - 1;
44 $tok = substr($s, $i, $j-$i);
47 cfunction getValues($b) {
48 $t = '" ","\" ","\n"';
52 $pairs = explode(";", $b);
53 for ($i=0; $i<count($pairs)-1; $i++) {
54 $av_pair = explode(":", $pairs[$i]);
55 $av_pair[0] = trim($av_pair[0]);
56 $av_pair[1] = trim($this->stripString($av_pair[1], $t));
57 // echo "<li>".$av_pair[0].":".$av_pair[1];
58 $av_pairs[$i] = $av_pair;
62 cfunction getStatements($s) {
64 $end = strpos($s, "}");
65 while($end != FALSE) {
66 $tok = substr($s, 0, $end+1);
67 $s = substr($s, $end+1, strlen($s));
69 $this->sections[$i] = $this->getStatement($tok);
71 $end = strpos($s, "}");
74 // echo count($this->sections)." sections<br>";
76 cfunction getStatement($s) {
77 $values[0] = $this->getName($s);
78 // echo "<li>Name ".$values[0];
79 $body = $this->getBody($s);
80 // echo "<li>Values<ul>";
81 $values[1] = $this->getValues($body);
85 cfunction loadPreferences() {
86 if (count($preferences) != 0) {
87 echo "I have got ".count($this->sections)." preferences here<br>\n";
90 $fp = fopen("php3tool.conf", "r");
94 $string .= fgets($fp, 80);
97 $this->getStatements($string);
99 $this->loadAttributeNames($this->get("PATH.attributes"));
102 cfunction loadAttributeNames($s = "at.conf") {
103 // global $attribute_names;
104 if (count($this->attribute_names) != 0) {
105 //This is bullshit here..how do we make php3
106 //preserve an array in memory between re-loads?
107 //And no, I'm not going to send it every time
108 //I make a subsequent request..
109 //If we don't fix these things it won't run
110 //on anything smaller than a StarFire 10000
111 //EVEN THOUGH this stuff is suprisingly fast.
112 echo "I have got attribute_names here<br>\n";
115 //echo "I dont have attribute_names here<br>\n";
116 $fp = fopen($s, "r");
121 $string = fgets($fp, 80);
122 $foo = strtok($string, ",");
123 $this->attribute_names[$i][0] = $foo;
125 $this->attribute_names[$i][1] = $foo;
127 $this->attribute_names[$i][2] = $foo;
131 // echo "Hello world:<b>".count($this->attribute_names)."</b>\n";
132 // for ($i=0; $i<count($this->attribute_names)-1; $i++) {
133 // echo $this->attribute_names[$i][0]." - <strong>".$this->attribute_names[$i][1]."</strong> - ".$this->attribute_names[$i][2]."<br>\n";
135 return $this->attribute_names;
138 cfunction stripString($string, $tokens) {
140 for ($i=0; $i<count($tokens); $i++) {
142 $tok = strtok($s, $tokens[$i]);
145 // echo "result = ".$result."\n";
146 $tok = strtok($tokens[$i]);
149 // echo "s = ".$s."\n";
151 // echo "result = ".$result."\n";