diff --git a/contrib/php3-tool/include/preferences.inc b/contrib/php3-tool/include/preferences.inc
new file mode 100644
index 0000000000..11ca8f04f0
--- /dev/null
+++ b/contrib/php3-tool/include/preferences.inc
@@ -0,0 +1,155 @@
+
+class preferences {
+ var $name;
+ var $sections = array();
+ var $base_dn;
+ var $host;
+ var $attribute_names = array();
+
+ cfunction getSection($s) {
+ //// echo "getSection(".$s.")
";
+ $sect = array();
+ for ($i=0; $isections); $i++) {
+ $sect = $this->sections[$i];
+ // echo $sect[0]."
";
+ if ($sect[0] == $s) {
+ // echo "Found ".$sect[0]."
";
+ return $sect[1];
+ }
+ }
+ // echo "Didn't find ".$s."
";
+ }
+ cfunction get($s) {
+ $class = explode(".", $s);
+ $sect = $this->getSection($class[0]);
+ $values = array();
+ $values = $sect[1];
+ for ($i=0; $i";
+ if ($values[0] == $class[1]) {
+ // echo "Found ".$values[0]."
";
+ return $values[1];
+ }
+ }
+ // echo "Didn't find ".$class[1]."
";
+ }
+ cfunction getName($s) {
+ $n = trim(strtok($s, "{"));
+ return $n;
+ }
+ cfunction getBody($s) {
+ $i = strpos($s, "{") + 1;
+ $j = strpos($s, "}") - 1;
+ $tok = substr($s, $i, $j-$i);
+ return $tok;
+ }
+ cfunction getValues($b) {
+ $t = '" ","\" ","\n"';
+ $av_pairs = array();
+ $pairs = array();
+ $av_pair = array();
+ $pairs = explode(";", $b);
+ for ($i=0; $istripString($av_pair[1], $t));
+ // echo "".$av_pair[0].":".$av_pair[1];
+ $av_pairs[$i] = $av_pair;
+ }
+ return $av_pairs;
+ }
+ cfunction getStatements($s) {
+ $i = 0;
+ $end = strpos($s, "}");
+ while($end != FALSE) {
+ $tok = substr($s, 0, $end+1);
+ $s = substr($s, $end+1, strlen($s));
+ // echo "";
+ $this->sections[$i] = $this->getStatement($tok);
+ // echo "
\n";
+ $end = strpos($s, "}");
+ $i++;
+ }
+ // echo count($this->sections)." sections
";
+ }
+ cfunction getStatement($s) {
+ $values[0] = $this->getName($s);
+// echo "Name ".$values[0];
+ $body = $this->getBody($s);
+// echo "Values";
+ $values[1] = $this->getValues($body);
+// echo "
";
+ return $values;
+ }
+ cfunction loadPreferences() {
+ if (count($preferences) != 0) {
+ echo "I have got ".count($this->sections)." preferences here
\n";
+ }
+ else {
+ $fp = fopen("php3tool.conf", "r");
+ $i = 0;
+ $string = "";
+ while (!feof($fp)) {
+ $string .= fgets($fp, 80);
+ }
+ fclose($fp);
+ $this->getStatements($string);
+ }
+ $this->loadAttributeNames($this->get("PATH.attributes"));
+ }
+
+ cfunction loadAttributeNames($s = "at.conf") {
+ // global $attribute_names;
+ if (count($this->attribute_names) != 0) {
+ //This is bullshit here..how do we make php3
+ //preserve an array in memory between re-loads?
+ //And no, I'm not going to send it every time
+ //I make a subsequent request..
+ //If we don't fix these things it won't run
+ //on anything smaller than a StarFire 10000
+ //EVEN THOUGH this stuff is suprisingly fast.
+ echo "I have got attribute_names here
\n";
+ }
+ else {
+ //echo "I dont have attribute_names here
\n";
+ $fp = fopen($s, "r");
+ $i = 0;
+ while (!feof($fp)) {
+ $string = "";
+ $foo = "";
+ $string = fgets($fp, 80);
+ $foo = strtok($string, ",");
+ $this->attribute_names[$i][0] = $foo;
+ $foo = strtok(",");
+ $this->attribute_names[$i][1] = $foo;
+ $foo = strtok("\n");
+ $this->attribute_names[$i][2] = $foo;
+ $i++;
+ }
+ }
+ // echo "Hello world:".count($this->attribute_names)."\n";
+ // for ($i=0; $iattribute_names)-1; $i++) {
+ // echo $this->attribute_names[$i][0]." - ".$this->attribute_names[$i][1]." - ".$this->attribute_names[$i][2]."
\n";
+ // }
+ return $this->attribute_names;
+ }
+
+ cfunction stripString($string, $tokens) {
+ $s = $string;
+ for ($i=0; $i