steffen: server/kolab-resource-handlers/kolab-resource-handlers/freebusy freebusy.php, 1.28, 1.29 freebusycache.class.php, 1.2, 1.3 freebusyldap.class.php, 1.2, 1.3 misc.php, 1.1, 1.2 pfb.php, 1.2, 1.3
cvs at intevation.de
cvs at intevation.de
Tue Oct 5 11:13:43 CEST 2004
- Previous message: steffen: server/kolab-resource-handlers/kolab-resource-handlers/resmgr resmgr.php, 1.26, 1.27
- Next message: michel: doc/proko2-doc serverinternetmail.png, NONE, 1.1 serverkolabhosts.png, NONE, 1.1 serverprivilegednetworks.png, NONE, 1.1 serverquotasettings.png, NONE, 1.1 serverrelayhost.png, NONE, 1.1 doc2.sxw, 1.42, 1.43 managerservices.png, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: steffen
Update of /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy
In directory doto:/tmp/cvs-serv12787/kolab-resource-handlers/freebusy
Modified Files:
freebusy.php freebusycache.class.php freebusyldap.class.php
misc.php pfb.php
Log Message:
new freebusy stuff
Index: freebusy.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusy.php,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- freebusy.php 4 Oct 2004 09:31:18 -0000 1.28
+++ freebusy.php 5 Oct 2004 09:13:41 -0000 1.29
@@ -3,8 +3,11 @@
require_once('freebusy/freebusycollector.class.php');
require_once('freebusy/freebusyldap.class.php');
require_once('freebusy/misc.php');
+
require_once('@l_prefix@/etc/resmgr/freebusy.conf');
+logInit( 'freebusy' );
+
$user = trim($_REQUEST['uid']);
$imapuser = $_SERVER['PHP_AUTH_USER'];
$imappw = $_SERVER['PHP_AUTH_PW'];
@@ -43,6 +46,9 @@
$collector =& new FreeBusyCollector( $user );
$groups = $ldap->distlists( $ldap->dn( $user ) );
+for( $i = 0; $i < count($groups); $i++ ) {
+ $groups[$i] = $groups[$i].'@'.$params['email_domain'];
+}
$pfbs = $cache->findAll( $user, $groups );
$ts = 0;
if( $pfbs === false ) {
Index: freebusycache.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusycache.class.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- freebusycache.class.php 4 Oct 2004 09:31:18 -0000 1.2
+++ freebusycache.class.php 5 Oct 2004 09:13:41 -0000 1.3
@@ -14,6 +14,8 @@
return false;
}
+ myLog("Storing $filename with acl ".var_export($acl,true), RM_LOG_DEBUG);
+
// Create directories if missing
$fbfilename = $this->mkfbfilename($filename);
$fbdirname = dirname( $fbfilename );
@@ -48,8 +50,10 @@
$lst = dba_fetch( $ac['USER'], $db );
$lst = $this->decodeList( $lst );
$lst[] = $filename;
+ myLog("(add) dba_replace(".$ac['USER'].", \"".$this->encodeList(array_unique($lst))."\")", RM_LOG_DEBUG);
dba_replace( $ac['USER'], $this->encodeList(array_unique($lst)), $db );
} else {
+ myLog("(add) dba_insert(".$ac['USER'].", \"".$filename."\")", RM_LOG_DEBUG);
dba_insert( $ac['USER'], $filename, $db );
}
}
@@ -60,6 +64,7 @@
$lst = dba_fetch( $uid, $db );
$lst = $this->decodeList( $lst );
$lst = array_diff( $lst, array($fbfilename));
+ myLog("(delete) dba_replace(".$uid.", \"".$this->encodeList($lst)."\")", RM_LOG_DEBUG);
dba_replace( $uid, $this->encodeList($lst), $db );
}
}
@@ -79,20 +84,26 @@
}
function findAll( $uid, $groups ) {
- $lst = false;
+ $lst = array();
$db = dba_open( $this->basedir.'/pfbcache.db', 'rd', 'gdbm' );
if( $db === false ) return false;
$uids = $groups;
+ for( $i = 0; $i < count($uids); $i++ ) $uids[$i] = 'group:'.$uids[$i];
$uids[] = $uid;
foreach( $uids as $uid ) {
if( dba_exists( $uid, $db ) ) {
- $lst = dba_fetch( $uid, $db );
- $lst = array_merge( $lst, $this->decodeList( $lst ) );
+ $tmplst = dba_fetch( $uid, $db );
+ myLog("Found ".$uid." := $tmplst", RM_LOG_DEBUG);
+ $lst = array_merge( $lst, $this->decodeList( $tmplst ) );
+ } else {
+ myLog("$uid not found", RM_LOG_DEBUG);
}
- dba_close($db);
}
- if( is_array( $lst ) ) return array_unique($lst);
- else return false;
+ dba_close($db);
+ $lst = array_unique($lst);
+ myLog( "FreeBusyCache::findAll( $uid, [".join(', ', $groups).'] ) = ['.join(', ',$lst).']',
+ RM_LOG_DEBUG );
+ return $lst;
}
/*************** Private API below this line *************/
@@ -165,7 +176,9 @@
}
function getRights( $acl, $uid, $groups ) {
- $uids = array_merge( array($uid), $groups );
+ $uids = $groups;
+ for( $i = 0; $i < count($uids); $i++ ) $uids[$i] = 'group:'.$uids[$i];
+ $uids[] = $uid;
$rights = array();
$negacl = array();
@@ -178,7 +191,7 @@
continue;
}
if( in_array( $u, $uids ) ) {
- for( $i = 0; $i < strlen($r); ++$i ) {
+ for( $i = 0; $i < strlen($r); $i++ ) {
$rights[$r{$i}] = true;
}
}
@@ -189,7 +202,7 @@
$r = $ac['RIGHTS'];
$u = $ac['USER'];
if( in_array( $u, $uids ) ) {
- for( $i = 1; $i < strlen($r); ++$i ) {
+ for( $i = 1; $i < strlen($r); $i++ ) {
unset($rights[$r{$i}]);
}
}
Index: freebusyldap.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusyldap.class.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- freebusyldap.class.php 4 Oct 2004 09:31:18 -0000 1.2
+++ freebusyldap.class.php 5 Oct 2004 09:13:41 -0000 1.3
@@ -58,18 +58,49 @@
return false;
}
function distlists( $dn ) {
+ myLog( "FreeBusyLDAP::distlists( $dn )", RM_LOG_DEBUG );
$result = ldap_search( $this->connection, $this->base,
- '(&(objectClass=kolabGroupOfNames)(member=$dn))',
+ '(&(objectClass=kolabGroupOfNames)(member='.FreeBusyLDAP::escape($dn).'))',
array( 'cn' ) );
if( $result ) {
$entries = ldap_get_entries( $this->connection, $result );
$lst = array();
- for( $i = 0; i < $entries['count']; ++$i ) {
+ myLog( 'FreeBusyLDAP::distlists found '.$entries['count'].' entries', RM_LOG_DEBUG );
+ for( $i = 0; $i < $entries['count']; $i++ ) {
+ myLog( "FreeBusyLDAP::distlists found ".$entries[$i]['cn'][0], RM_LOG_DEBUG );
$lst[] = $entries[$i]['cn'][0];
}
return $lst;
}
return false;
+ }
+
+ /**********/
+ function escape( $str ) {
+ /*
+ From RFC-2254:
+
+ If a value should contain any of the following characters
+
+ Character ASCII value
+ ---------------------------
+ * 0x2a
+ ( 0x28
+ ) 0x29
+ \ 0x5c
+ NUL 0x00
+
+ the character must be encoded as the backslash '\' character (ASCII
+ 0x5c) followed by the two hexadecimal digits representing the ASCII
+ value of the encoded character. The case of the two hexadecimal
+ digits is not significant.
+ */
+ $str = str_replace( '\\', '\\5c', $str );
+ $str = str_replace( '*', '\\2a', $str );
+ $str = str_replace( '(', '\\28', $str );
+ $str = str_replace( ')', '\\29', $str );
+ $str = str_replace( '\0', '\\00', $str );
+ return $str;
}
var $connection;
Index: misc.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/misc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- misc.php 28 Sep 2004 13:12:26 -0000 1.1
+++ misc.php 5 Oct 2004 09:13:41 -0000 1.2
@@ -10,6 +10,7 @@
$ldap->close();
$ldap = false;
}
+ logClose();
}
function serverError($errortext) {
@@ -87,4 +88,116 @@
exit;
}
+
+// What myLog levels we can use
+define('RM_LOG_SUPER', -1);
+define('RM_LOG_SILENT', 0);
+define('RM_LOG_ERROR', 1);
+define('RM_LOG_WARN', 2);
+define('RM_LOG_INFO', 3);
+define('RM_LOG_DEBUG', 4);
+
+$logLevelPrefixes = array(
+ RM_LOG_SUPER => '',
+ RM_LOG_SILENT => '',
+ RM_LOG_ERROR => 'Error',
+ RM_LOG_WARN => 'Warning',
+ RM_LOG_INFO => '',
+ RM_LOG_DEBUG => 'Debug',
+);
+// What logging mechanisms are available for use
+define('RM_LOG_SYSLOG', 1);
+define('RM_LOG_FILE', 2);
+define('RM_LOG_STDERR', 3);
+
+$logType = 0;
+$logPrefix = '';
+$logDestination = NULL;
+
+function logInit($name = '')
+{
+ global $params, $argv, $logType, $logPrefix, $logDestination;
+
+ if (empty($name)) {
+ $name = basename($argv[0]);
+ }
+
+ if (!array_key_exists('log', $params) || empty($params['log'])) {
+ return;
+ }
+
+ $matches = array();
+ if (preg_match('/(\w+):(.*)?/', $params['log'], $matches)) {
+ switch ($matches[1]) {
+ case 'syslog':
+ $logType = RM_LOG_SYSLOG;
+ $txtopts = preg_split('/[\s,]+/', $matches[2], -1, PREG_SPLIT_NO_EMPTY);
+ $options = 0;
+ foreach ($txtopts as $txtopt) {
+ switch ($txtopt) {
+ case 'cons': $options |= LOG_CONS; break;
+ case 'ndelay': $options |= LOG_NDELAY; break;
+ case 'odelay': $options |= LOG_ODELAY; break;
+ case 'perror': $options |= LOG_PERROR; break;
+ case 'pid': $options |= LOG_PID; break;
+ }
+ }
+ openlog($name, $options, LOG_USER);
+ break;
+
+ case 'file':
+ $logType = RM_LOG_FILE;
+ $logPrefix = $name;
+ $logDestination = fopen($matches[2], 'a');
+ break;
+ case 'stderr':
+ $logType = RM_LOG_STDERR;
+ $logPrefix = $name;
+ $logDestination = fopen('php://stderr', 'a');
+ break;
+ }
+ }
+}
+
+function logClose()
+{
+ global $logType, $logDestination;
+
+ switch ($logType) {
+ case RM_LOG_SYSLOG:
+ closelog();
+ break;
+
+ case RM_LOG_FILE:
+ fclose($logDestination);
+ $logDestination = NULL;
+ break;
+ }
+}
+function myLog($text, $priority = RM_LOG_INFO)
+{
+ global $params, $logLevelPrefixes, $logPrefix, $logType, $logDestination;
+
+ if ($params['log_level'] >= $priority) {
+ if (!empty($logLevelPrefixes[$priority])) {
+ $text = $logLevelPrefixes[$priority] . ": $text";
+ }
+
+ switch ($logType) {
+ case RM_LOG_SYSLOG:
+ syslog(RM_LOG_INFO, $text);
+ break;
+
+ case RM_LOG_FILE:
+ fwrite($logDestination, strftime('%B %d %T') . " ${logPrefix}[" . getmypid() . "]: $text\n");
+ fflush($logDestination);
+ break;
+ case RM_LOG_STDERR:
+ fwrite($logDestination, strftime('%B %d %T') . " ${logPrefix}[" . getmypid() . "]: $text\n");
+ fflush($logDestination);
+ break;
+ }
+ }
+}
+
?>
Index: pfb.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/pfb.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pfb.php 4 Oct 2004 09:31:18 -0000 1.2
+++ pfb.php 5 Oct 2004 09:13:41 -0000 1.3
@@ -4,8 +4,11 @@
require_once('freebusy/freebusyldap.class.php');
require_once('freebusy/freebusycache.class.php');
require_once('freebusy/misc.php');
+
require_once('@l_prefix@/etc/resmgr/freebusy.conf');
+logInit('pfb');
+
$imapuser = $_SERVER['PHP_AUTH_USER'];
$imappw = $_SERVER['PHP_AUTH_PW'];
$req_cache = (bool)$_REQUEST['cache'];
@@ -48,6 +51,9 @@
// Check access
$distlists = $ldap->distlists( $ldap->dn($imapuser));
if( $distlists === false ) unauthorized( $req_folder.($req_extended?'.xpfb':'.pfb' ) );
+ for( $i = 0; $i < count($distlists); $i++ ) {
+ $distlists[$i] = $distlists[$i].'@'.$params['email_domain'];
+ }
$rights = $cache->getRights( $acl, $imapuser, $distlists );
if( $rights['r'] ) {
// All OK
- Previous message: steffen: server/kolab-resource-handlers/kolab-resource-handlers/resmgr resmgr.php, 1.26, 1.27
- Next message: michel: doc/proko2-doc serverinternetmail.png, NONE, 1.1 serverkolabhosts.png, NONE, 1.1 serverprivilegednetworks.png, NONE, 1.1 serverquotasettings.png, NONE, 1.1 serverrelayhost.png, NONE, 1.1 doc2.sxw, 1.42, 1.43 managerservices.png, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the commits
mailing list