Example #1
0
function listACLsByPath($pathname)
{
    $me = $_SERVER["PHP_SELF"];
    if (!canEdit($pathname)) {
        echo "Ihnen fehlt leider die Berechtigung, das Verzeichnis {$pathname} zu bearbeiten";
        return false;
    }
    // Verzeichnisobjekt holen
    $path = new Path();
    if (!$path->selectByName($pathname)) {
        fehlerausgabe("Das Verzeichnis {$pathname} konnte nicht aus der DB gewählt werden");
        return false;
    }
    // ACLs fuer das Verzeichnis holen
    $acllist = new ACLList();
    if (!$acllist->selectByPath($pathname)) {
        fehlerausgabe("Die zum Verzeichnis {$pathname} gehörigen ACLs konnten nicht aus der DB gewählt werden");
        return false;
    }
    echo "ACLs für Pfad {$pathname}:";
    echo <<<EOF
<form name="acleditor" method="post" action="{$me}">
<select name="cmd">
    <option value="edit">Eine ACL bearbeiten</option>
    <option value="del">L&ouml;schen</option>
</select>
<input type="hidden" name="pathname" value="{$pathname}" />
<input type="submit" value="Los" />
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="table-layout:fixed">
    <tr>
        <td>User</td>
        <td>L&ouml;schen</td>
        <td>Schreiben</td>
        <td>Lesen</td>
        <td>Umbenennen</td>
    </tr>
EOF;
    $user = new User();
    for ($i = 0; $i < count($acllist->list); $i++) {
        $acl = $acllist->list[$i];
        $user->selectByID($acl->user_id);
        echo <<<EOF
<tr>
    <td><input type="checkbox" name="aclid[]" value="{$acl->acl_id}" />{$user->loginname}</td>
    <td>{$acl->delete_path}</td>
    <td>{$acl->write_path}</td>
    <td>{$acl->read_path}</td>
    <td>{$acl->rename_path}</td>
</tr>
EOF;
    }
    echo <<<EOF
</table>
</form>
EOF;
    return true;
}
Example #2
0
 function getACLByPath($path)
 {
     $retacl = new ACL();
     if ($this->is_su == "1") {
         $retacl->acl_id = 1;
         $retacl->delete_path = "1";
         $retacl->write_path = "1";
         $retacl->read_path = "1";
         $retacl->rename_path = "1";
         $retacl->delete_file = "1";
         $retacl->write_file = "1";
         $retacl->read_file = "1";
         $retacl->rename_file = "1";
         return $retacl;
     }
     $done = false;
     $acllist = new ACLList();
     $curacls = array();
     $currentUserId = $this->user_id;
     while (!$done) {
         $currentUser = new User();
         if (!$currentUser->selectById($currentUserId)) {
             $done = true;
         } else {
             if ($acllist->selectByUserIdAndPath($currentUser->user_id, $path)) {
                 $curacls = $acllist->list;
             }
             if (count($curacls) == 0) {
                 $currentUserId = $currentUser->user_id_parent;
             } else {
                 $done = true;
                 $retacl->initializeFromRow($curacls[0]);
             }
         }
     }
     return $retacl;
 }
Example #3
0
function doMkDir()
{
    global $sage_data_dir;
    $cwd = $_SESSION["path"];
    $newname = quotemeta(@$_REQUEST["OrdnerName"]);
    if (strstr($newname, "/") || strstr($newname, "\\")) {
        fehlerausgabe("Kann {$newname} nicht anlegen: Ung&uuml;ltiger Name");
        return false;
    }
    $path = new Path();
    if ($path->selectByName($newname)) {
        fehlerausgabe("Kann Ordner {$newname} nicht anlegen: Ordner existiert schon");
        return false;
    }
    $path->loginname = $_SESSION["user"]->loginname;
    $path->pathname = $_SESSION["path"] . "/" . $newname;
    $path->description = $_REQUEST["Beschreibung"];
    $path->insert_at = "NOW()";
    $path->modified_at = "NOW()";
    $curpath = new Path();
    if (!$curpath->selectByName($_SESSION["path"])) {
        fehlerausgabe("Kann Ordner {$newname} nicht anlegen: Kann Parent-Pfad nicht finden");
        return false;
    }
    $path->path_id_parent = $curpath->path_id;
    if (!$path->insert()) {
        fehlerausgabe("Kann Ordner {$newname} nicht anlegen: Kann Pfad nicht in DB schreiben");
        return false;
    }
    $path->selectByName($_SESSION["path"] . "/" . $newname);
    // zur Zeit wird ein neuer Ordner standardmässig der Gruppe zur Verfügung gestellt
    $acluserid = $_SESSION["user"]->user_id_parent;
    if ($acluserid == "") {
        $acluserid = $_SESSION["user"]->user_id;
    }
    // [kludge]: verwende Referenz auf die Parent-ACL mit veränderter Path-ID, um eine neue
    // ACL zu erzeugen
    $acllist = new ACLList();
    if (!$acllist->selectByUserIDAndPath($acluserid, $_SESSION["path"])) {
        fehlerausgabe("Kann Ordner {$newname} nicht anlegen: Fehler beim Selektieren der Parent-ACL");
        return false;
    }
    if (count($acllist) < 1) {
        fehlerausgabe("Kann Ordner {$newname} nicht anlegen: Kann Parent-ACL nicht finden");
        return false;
    }
    $acl = $acllist->list[0];
    $acl->user_id = $acluserid;
    $acl->path_id = $path->path_id;
    if (!$acl->insert()) {
        fehlerausgabe("Kann Ordner {$newname} nicht anlegen: Kann nicht einfügen");
        return false;
    }
    //fs
    $oldumask = umask();
    umask(077);
    if (!mkdir($sage_data_dir . $path->pathname, 0700)) {
        fehlerausgabe("Kann Ordner {$newname} nicht anlegen: Dateisystem weigert sich");
        return false;
    }
    umask($oldumask);
    redirectTo($_SERVER["PHP_SELF"] . "?cmd=ls");
    return true;
}