steffen: server/kolab/kolab/admin/sharedfolder create_sharedfolder.php, 1.7, 1.8 index.php, 1.7, 1.8
cvs at intevation.de
cvs at intevation.de
Fri Apr 16 12:17:31 CEST 2004
Author: steffen
Update of /kolabrepository/server/kolab/kolab/admin/sharedfolder
In directory doto:/tmp/cvs-serv22487/admin/sharedfolder
Modified Files:
create_sharedfolder.php index.php
Log Message:
Started restructuring the webinterface. New classes:
KolabLdap: Class for accessing the ldap server, API not fully evolved yet
KolabAuth: Class for authenticating a user using the LDAP class
KolabForm: HTML form handling class. This is supposed to replace the many
long input forms in the webinterface. Currently it is only used in
user/ and some error-handling is missing
Index: create_sharedfolder.php
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/admin/sharedfolder/create_sharedfolder.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- create_sharedfolder.php 14 Jun 2003 17:06:31 -0000 1.7
+++ create_sharedfolder.php 16 Apr 2004 10:17:28 -0000 1.8
@@ -5,12 +5,16 @@
This program is Free Software under the GNU General Public License (>=v2).
Read the file COPYING that comes with this packages for details.
*/
- include("head.php");
- This("sharedfolder/create_sharedfolder.php?action=create");
- Head();
-?>
+require_once('../include/authenticate.php');
+include("head.php");
+This("sharedfolder/create_sharedfolder.php?action=create");
+Head();
-<?
+// user authentication
+$uid = $auth->uid();
+$bind_dn = $auth->dn();
+$group = $auth->group();
+$link = $ldap->connection;
function debug ($a)
{
@@ -74,11 +78,6 @@
$dn="";
if (!empty($HTTP_GET_VARS['dn'])) $dn = trim(urldecode($HTTP_GET_VARS['dn']));
-if (!($uid = $_SERVER['PHP_AUTH_USER']) ||
- !($bind_dn = uid2dn($uid)) ||
- !($group = uid2group($uid)))
- array_push($errors, "Internal Error: could not get Authentication Information");
-
if (!$errors && $group != "admin" && $group != "maintainer")
array_push($errors, "Error: You don't have the required Permissions");
@@ -86,16 +85,6 @@
$myself = $_SERVER['PHP_SELF'];
-if (!empty($_SESSION['ldap_server'])) $ldap_server = $_SESSION['ldap_server'];
- else $ldap_server = '127.0.0.1';
-
-if (!empty($_SESSION['ldap_port'])) $ldap_port = $_SESSION['ldap_port'];
- else $ldap_port = 389;
-
-
-if (!$errors && (!($link = ldap_connect($ldap_server,$ldap_port)) ||
- !ldap_bind($link, $bind_dn, $_SERVER["PHP_AUTH_PW"])))
- array_push($errors, "Communication Error: could not query ldap://$ldap_server:$ldap_port ".ldap_error($link));
if (!$errors) {
$attrs = array( 'objectClass' => 'sharedfolder');
@@ -106,10 +95,10 @@
print("<div class=\"maintitle\"> Delete Shared Folder </div>\n");
$attrs['deleteflag'][0] = 'TRUE';
if (!(ldap_modify($link,$dn,$attrs))) {
- array_push($errors, "LDAP Error: could not mark ".utf8_decode($dn)." for deletion ".ldap_error($link));
+ array_push($errors, "LDAP Error: could not mark ".$dn." for deletion ".ldap_error($link));
} else {
// system("sudo -u kolab /kolab/etc/kolab/kolab_buildconfig & ");
- print("<div class=\"message\"> The object ".utf8_decode($dn)." is scheduled for deletion</div>\n");
+ print("<div class=\"message\"> The object ".$dn." is scheduled for deletion</div>\n");
}
}
} else {
@@ -148,13 +137,13 @@
$comment['cn_0'] = "<span style=\"color:#FF0000\"> Fill in Folder name </span>";
} else {
$attrs['cn'][0] = trim(urldecode($HTTP_GET_VARS['cn_0']));
- $dn = "cn=".(utf8_encode($attrs['cn'][0])).",".$_SESSION['base_dn'];
+ $dn = "cn=".($attrs['cn'][0]).",".$_SESSION['base_dn'];
}
}
$myentry = array_merge_recursive($myentry,$attrs);
if (!empty($myentry['cn'][0])) {
- $myentry['cn'][0] = utf8_encode($myentry['cn'][0]);
- $attrs['cn'][0] = utf8_encode($attrs['cn'][0]);
+ $myentry['cn'][0] = $myentry['cn'][0];
+ $attrs['cn'][0] = $attrs['cn'][0];
}
if ($errors) {
$dn = "";
@@ -206,7 +195,7 @@
else $adduser = "";
$myentry['acl'][$myentry['acl']['count']] = $adduser;
$myentry['acl']['count']++;
- $myentry['cn'][0] = utf8_decode($myentry['cn'][0]);
+ $myentry['cn'][0] = $myentry['cn'][0];
ldap_free_result($result);
} else array_push($errors, "LDAP Error: could not read dn ".ldap_error($link));
}
Index: index.php
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/admin/sharedfolder/index.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- index.php 14 Jun 2003 13:52:38 -0000 1.7
+++ index.php 16 Apr 2004 10:17:28 -0000 1.8
@@ -5,9 +5,10 @@
This program is Free Software under the GNU General Public License (>=v2).
Read the file COPYING that comes with this packages for details.
*/
- include("head.php");
- This("sharedfolder/");
- Head();
+require_once('../include/authenticate.php');
+include("head.php");
+This("sharedfolder/");
+Head();
if (isset($HTTP_GET_VARS['alphaselect'])) $alphaselect = $HTTP_GET_VARS['alphaselect'];
else $alphaselect = "[all]";
@@ -15,11 +16,11 @@
else $page = "1";
$errors = array();
-// check user authentication
-if (!($uid = $_SERVER["PHP_AUTH_USER"]) ||
- !($bind_dn = uid2dn($uid)) ||
- !($group = uid2group($uid)))
- array_push($errors, "Internal Error: could not get Authentication Information");
+// user authentication
+$uid = $auth->uid();
+$bind_dn = $auth->dn();
+$group = $auth->group();
+$link = $ldap->connection;
if (!$errors && $group != "admin" && $group != "maintainer")
array_push($errors, "Error: You don't have Permissions to access this Menue");
@@ -29,22 +30,12 @@
$myself = $_SERVER['PHP_SELF'];
-if (isset($_SESSION['ldap_server'])) $ldap_server = $_SESSION['ldap_server'];
- else $ldap_server = '127.0.0.1';
-
-if (isset($_SESSION['ldap_port'])) $ldap_port = $_SESSION['ldap_port'];
- else $ldap_port = 389;
-
-if (!$errors && !($link = ldap_connect($ldap_server,$ldap_port)) || !ldap_bind($link))
- array_push($errors, "Communication Error: could not query ldap://$ldap_server:$ldap_port ".ldap_error($link));
-
-
// get all entries & dynamically split the letters with growing entries
- $filter = "(objectClass=sharedfolder)";
- $result = ldap_search($link, $base_dn, $filter);
- // counting all entries
- $entries= ldap_count_entries($link, $result);
- ldap_free_result($result);
+$filter = "(objectClass=sharedfolder)";
+$result = ldap_search($link, $base_dn, $filter);
+// counting all entries
+$entries= ldap_count_entries($link, $result);
+ldap_free_result($result);
if (!$errors) {
printf("<div class=\"maintitle\">Manage Shared Folders (%s Folders)</div>", $entries);
@@ -144,8 +135,8 @@
// $dn = urlencode($resultEntries[$i]["dn"]);
$dn = ldap_get_dn($link, $entry);
$attrs = ldap_get_attributes($link,$entry);
- $cn = utf8_decode($attrs['cn'][0]);
- printf("<tr><td class=\"content\">%s</td><td class=\"contentaction\">
+ $cn = $attrs['cn'][0];
+ printf("<tr><td class=\"content\">%s</td><td class=\"contentaction\">
<a href=\"create_sharedfolder.php?action=modify&dn=%s\"> [Modify]</a>
<a href=\"create_sharedfolder.php?action=delete&dn=%s\"> [Delete]</a>
</td></tr>\n",$cn,$dn,$dn);
@@ -163,18 +154,18 @@
// splitting into more than one page?
$pages = ceil($entries / $views);
if ($pages > 1) {
- for ($i = 1; $i < $pages; $i++) {
- // the actual page won't be clickable
- if ($page != $i)
- printf(" <a href=\"index.php?alphaselect=%s&page=%s\">%s</a> |\n", $alphaselect, $i, $i);
- else
- printf(" %s |\n", $i);
- }
- // last item w/o vertical dash
- if ($page != $i)
- printf(" <a href=\"index.php?alphaselect=%s&page=%s\">%s</a> \n", $alphaselect, $i, $i);
- else
- printf(" %s ", $i);
+ for ($i = 1; $i < $pages; $i++) {
+ // the actual page won't be clickable
+ if ($page != $i)
+ printf(" <a href=\"index.php?alphaselect=%s&page=%s\">%s</a> |\n", $alphaselect, $i, $i);
+ else
+ printf(" %s |\n", $i);
+ }
+ // last item w/o vertical dash
+ if ($page != $i)
+ printf(" <a href=\"index.php?alphaselect=%s&page=%s\">%s</a> \n", $alphaselect, $i, $i);
+ else
+ printf(" %s ", $i);
}
print("</div>\n");
More information about the commits
mailing list