Update to my little php3-tool thingy - config file parsing.

This commit is contained in:
Predrag "Pele" Balorda 1998-11-21 20:33:20 +00:00
parent e1417bf74c
commit 744be28b32
6 changed files with 50 additions and 89 deletions

View File

@ -1,6 +1,29 @@
blah blah blah yadda yadda yadda don't forget to modify at.conf
blah blah
/me hopes you'll like this
This is the first version of this README
php3-tool v0.2gamma
This package has been tested and run with apache/php3 and OpenLDAP 1.1-devel
Look at the php3tool.conf (no need to at present) . The file format is exactly
the same as CSS1/2. No particular reason, just that I like it..
So you have something like:
PATH {
attributes: "at.conf";
photo: "ldap-photo.php3";
}
Section PATH, which has following attribute-value pairs:
attributes: "at.conf"
this pair defines where the schema stuff is.
photo: "ldap-photo.php3";
this pair defines which script to use to fetch and convert photos for an entry.
Also look at the at.conf (where all your schema stuff is). Format of at.conf is like follows:
string,Human Readable Representation,VISIBLE
So, for example
homephone,Home Telephone Number,TRUE
will _show_ anyone's home phone if it is present and will display it as "Home Telephone Number". I think the rest is self-explanatory.
I really couldn't think of anything else to put here (at the moment that is). But please feel free to add whatever else you consider neccessary to understanding how this thing works. Enjoy, and I hope this can be useful to you in some miniscule way.
Pele
p.s. do _NOT_ forget to add this to your /etc/httpd/conf/srm.conf (or wherever your put it):
DorectoryIndex .... index.php3 ...

View File

@ -14,7 +14,7 @@ homephone,Home Telephone Number,TRUE
homepostaladdress,Home Postal Address,TRUE
joinable,Can be joined,TRUE
jpegphoto,Photograph,TRUE
krbname,Kerberos Name,TRUE
krbname,Kerberos Name,FALSE
l,Location,TRUE
labeledurl,Web Page,TRUE
lastmodifiedby,Last Modified by,TRUE
@ -28,10 +28,10 @@ modifytimestamp,Modified at,TRUE
modifiersname,Modified by,TRUE
multilinedescription,Multi-lined description,TRUE
naminglink,Naming Link,TRUE
nobatchupdates,No Batch Updates,TRUE
nobatchupdates,No Batch Updates,FALSE
notice,Notice,TRUE
o,Organization,TRUE
objectclass,Object Class,TRUE
objectclass,Object Class,FALSE
onvacation,On Vacation,TRUE
ou,Organizational Unit,TRUE
owner,Owner,TRUE

View File

@ -9,19 +9,19 @@ class ldap_entry_attribute {
}
cfunction getAttributeName($string) {
global $attribute_names;
for ($i=0; $i<count($attribute_names); $i++) {
if ($attribute_names[$i][0] == $string) {
return $attribute_names[$i][1];
global $prefs;
for ($i=0; $i<count($prefs->attribute_names); $i++) {
if ($prefs->attribute_names[$i][0] == $string) {
return $prefs->attribute_names[$i][1];
}
}
return $string;
}
cfunction isVisible($string) {
global $attribute_names;
for ($i=0; $i<count($attribute_names); $i++) {
if ($attribute_names[$i][0] == $string) {
return $attribute_names[$i][2];
global $prefs;
for ($i=0; $i<count($prefs->attribute_names); $i++) {
if ($prefs->attribute_names[$i][0] == $string) {
return $prefs->attribute_names[$i][2];
}
}
return "FALSE";
@ -66,7 +66,7 @@ class ldap_entry_attribute {
}
cfunction formatHTMLValue($index) {
global $FILE, $JPEGFILE, $host;
global $prefs, $FILE, $host;
$p = "";
switch ($this->name) {
case "cn":
@ -116,7 +116,7 @@ class ldap_entry_attribute {
$p .= $date;
break;
case "jpegphoto":
$p .= '<a href="'.$JPEGFILE.'?base_dn='.urlencode($this->dn).'"><img src="'.$JPEGFILE.'?base_dn='.urlencode($this->dn).'" alt="Image of '.$this->cn.'" border=0></a>';
$p .= '<a href="'.$prefs->get("PATH.photo").'?base_dn='.urlencode($this->dn).'"><img src="'.$prefs->get("PATH.photo").'?base_dn='.urlencode($this->dn).'" alt="Image of '.$this->cn.'" border=0></a>';
break;
default:
$p .= $this->values[$index];

View File

@ -46,41 +46,6 @@ class ldap_manager {
echo $this->formatHTMLEntries();
}
cfunction loadAttributeNames() {
global $attribute_names;
if (count($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<br>\n";
}
else {
//echo "I dont have attribute_names here<br>\n";
$fp = fopen("at.conf", "r");
$i = 0;
while (!feof($fp)) {
$string = "";
$foo = "";
$string = fgets($fp, 80);
$foo = strtok($string, ",");
$attribute_names[$i][0] = $foo;
$foo = strtok(",");
$attribute_names[$i][1] = $foo;
$foo = strtok("\n");
$attribute_names[$i][2] = $foo;
$i++;
}
}
// echo "Hello world:<b>".count($attribute_names)."</b>\n";
// for ($i=0; $i<count($attribute_names)-1; $i++) {
// echo $attribute_names[$i][0]." - <strong>".$attribute_names[$i][1]."</strong> - ".$attribute_names[$i][2]."<br>\n";
// }
return $attribute_names;
}
cfunction formatHTMLBaseDN($dn) {
global $FILE, $host;
$string = "";

View File

@ -52,7 +52,7 @@ class query_manager {
case "Common Name": $search_filter .= "(cn"; break;
case "Surname": $search_filter .= "(sn"; break;
case "Business Phone": $search_filter .= "(telephone"; break;
case "E-mail": $search_filter .= "(mail"; break;
case "E-mail Address": $search_filter .= "(mail"; break;
case "Title": $search_filter .= "(title"; break;
case "Distinguished Name": $search_filter .="(dn"; break;
case "Location": $search_filter .="(l"; break;

View File

@ -1,60 +1,33 @@
<!-- copyright, (C) Predrag Balorda, 1998 -->
<!DOCTYPE PUBLIC HTML "-//W3C//HTML3.2 Final//En">
<html>
<head>
<style type="text/css">
<!--
BODY {
font-family: lucida sans unicode;
}
B {
font-weight: bold;
}
P {
font-family: lucida sans unicode,Arial,Helvetica;
font-size: 12pt;
}
.form {
font-family: lucinda sans unicode;
font-size: 10pt;
color: #003333;
}
H3 {
font-family: Verdana,Arial,Helvetica;
font-size: 12pt;
font-weight: bold;
}
.head {
font-size: 13pt;
color: #003333;
}
.subsection {
font-size: 12pt;
color: #003333;
}
-->
</style>
<!-- copyright, (C) Predrag Balorda, OpenLDAP Foundation, 1998 -->
<title>PHP3 Thingy</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<?
include ('include/preferences.inc');
include ('include/ldap_manager.inc');
include ('include/query_manager.inc');
include ('include/search_form.inc');
$FILE = "http://$HTTP_HOST$SCRIPT_NAME";
$JPEGFILE = "http://$HTTP_HOST/ldap/ldap-photo.php3";
$JPEGFILE = "http://$HTTP_HOST/ldap/php3-tool/ldap-photo.php3";
$qm = new query_manager;
$lm = new ldap_manager;
$attribute_names = array();
$prefs = new preferences;
function main() {
$main_start_time = microtime();
global $lm, $qm, $FILE;
global $lm, $qm, $prefs, $FILE;
$qm = new query_manager;
$lm = new ldap_manager;
$prefs = new preferences;
$lm->ldap_action = $qm->get_action();
$lm->base_dn = $qm->get_base_dn();
$lm->host = $qm->get_host();
$lm->search_filter = $qm->get_search_filter();
$lm->loadAttributeNames();
$prefs->loadPreferences();
display_advanced_form();
if (!$lm->connect($lm->host)) {
echo "Couldn't connect to <b>".$lm->host."</b><br>\n";