Exemplo n.º 1
0
 static function get_dirs($path, $parent, $recursive)
 {
     if (sys_allowedpath(dirname($path)) != "") {
         return array();
     }
     $data = self::_get_data($path);
     $right = 2;
     $tree = array();
     if ($recursive and count($data) > 0 and sys_is_folderstate_open($path, "xml", $parent) and file_exists($path)) {
         foreach (array_keys($data) as $folder) {
             $tree[$right] = array("id" => $path . "/" . $folder, "lft" => $right, "rgt" => $right + 1, "flevel" => 1, "ftitle" => $folder, "ftype" => "nodb_" . basename($path) . "_" . $folder, "ffcount" => 0);
             $right = $right + 2;
         }
     }
     $icon = "sys_nodb_xml.png";
     $tree[1] = array("id" => $path, "lft" => 1, "rgt" => $right, "flevel" => 0, "ftitle" => basename($path), "ftype" => "sys_nodb_xml", "icon" => $icon);
     return $tree;
 }
Exemplo n.º 2
0
 private static function _get_dirs($path, $left, $level, $parent, $recursive, &$tree)
 {
     $right = $left + 1;
     if ($recursive and sys_is_folderstate_open($path, "gdocs", $parent)) {
         // TODO optimize
         $docs_path = self::_get_docs_path($path, $parent);
         $docs_boxes = self::_get_boxes($parent);
         if (!empty($docs_boxes[$docs_path])) {
             foreach ($docs_boxes[$docs_path] as $id) {
                 $right = self::_get_dirs($path . $id . "/", $right, $level + 1, $parent, true, $tree);
             }
         }
     } else {
         $right = $right + 2;
     }
     $title = basename($path);
     $icon = "";
     if ($level == 0) {
         $icon = "sys_nodb_gdocs.png";
     }
     $tree[$left] = array("id" => $path, "lft" => $left, "rgt" => $right, "flevel" => $level, "ftitle" => $title, "ftype" => "sys_nodb_gdocs", "icon" => $icon);
     return $right + 1;
 }
Exemplo n.º 3
0
 private static function _get_dirs($path, $left, $level, $parent, $recursive, &$tree)
 {
     if (sys_allowedpath($path) != "") {
         return $left;
     }
     $right = $left + 1;
     if ($recursive and sys_is_folderstate_open($path, "fs", $parent)) {
         $subfolders = 0;
         $folders = array();
         if ($handle = @opendir($path)) {
             while (false !== ($file = readdir($handle))) {
                 if ($file != '.' and $file != '..' and is_dir($path . $file)) {
                     $folders[] = $path . $file . "/";
                     $subfolders = 1;
                 }
             }
         }
         natcasesort($folders);
         foreach ($folders as $folder) {
             $right = self::_get_dirs($folder, $right, $level + 1, $parent, true, $tree);
         }
     } else {
         $right = $right + 2;
         $subfolders = (int) self::_has_subfolder($path);
     }
     $icon = "";
     if ($level == 0) {
         $icon = "sys_nodb_fs.png";
     }
     $tree[$left] = array("id" => $path, "lft" => $left, "rgt" => $right, "flevel" => $level, "ftitle" => basename($path), "ftype" => "sys_nodb_fs", "icon" => $icon, "ffcount" => $subfolders);
     return $right + 1;
 }
Exemplo n.º 4
0
 private static function _get_dirs($path, $left, $level, $parent, $recursive, &$tree)
 {
     $right = $left + 1;
     $ldap_path = substr($path, strpos($path, "/") + 1, -1);
     if ($recursive and sys_is_folderstate_open($path, "ldap", $parent)) {
         if ($ldap_path != "") {
             $paths = array_reverse(explode("/", $ldap_path));
         } else {
             $paths = array();
         }
         $paths[] = self::_base_dn($parent);
         $new_path = implode(",", $paths);
         $cid = "ldap_" . md5("boxes_" . $parent . "/" . $path);
         $info = sys_cache_get($cid);
         if (!is_array($info)) {
             if (!($ds = self::_connect($parent))) {
                 return $right + 1;
             }
             if (!($sr = @ldap_list($ds, $new_path, "objectClass=*", array("dn", "objectClass")))) {
                 return $right + 1;
             }
             $info = ldap_get_entries($ds, $sr);
             sys_cache_set($cid, $info, LDAP_LIST_CACHE);
         }
         foreach ($info as $item) {
             if (!is_array($item)) {
                 continue;
             }
             if (isset($item["objectclass"]) and (in_array("organizationalPerson", $item["objectclass"]) or in_array("organizationalRole", $item["objectclass"]) or in_array("posixAccount", $item["objectclass"]) or in_array("inetOrgPerson", $item["objectclass"]) or in_array("group", $item["objectclass"]))) {
                 continue;
             }
             $data = ldap_explode_dn($item["dn"], 0);
             $right = self::_get_dirs($path . $data[0] . "/", $right, $level + 1, $parent, true, $tree);
         }
     }
     $icon = "";
     if ($level == 0) {
         $icon = "sys_nodb_ldap.png";
     }
     $tree[$left] = array("id" => $path, "lft" => $left, "rgt" => $right, "flevel" => $level, "ftitle" => utf8_encode(basename($path)), "ftype" => "sys_nodb_ldap", "icon" => $icon);
     return $right + 1;
 }
Exemplo n.º 5
0
 private static function _get_dirs($path, $left, $level, $parent, $recursive, &$tree)
 {
     $right = $left + 1;
     $subfolders = 0;
     if ($recursive and sys_is_folderstate_open($path, "cifs", $parent)) {
         try {
             $ntlm = self::_get_ntlm($parent);
             $w = new Java("jcifs.smb.SmbFile", "smb://" . $path, $ntlm);
             if ($files = $w->listFiles()) {
                 $dirs = array();
                 foreach ($files as $file) {
                     $type = $file->getType();
                     if ($file->isDirectory() and $type != 32 and (!in_array($type, array(8, 16)) or !$file->isHidden())) {
                         $dirs[] = $path . str_replace(chr(0), "", $file->getName());
                         $subfolders = 1;
                     }
                 }
                 natcasesort($dirs);
                 foreach ($dirs as $dir) {
                     $right = self::_get_dirs($dir, $right, $level + 1, $parent, true, $tree);
                 }
             }
         } catch (Exception $e) {
             if (DEBUG_JAVA) {
                 $msg = java_cast($e, "string");
             } else {
                 $msg = $e->getMessage();
             }
             sys_warning("{t}Access denied.{/t} [get_dirs] " . $msg . " " . $path);
         }
     } else {
         $right = $right + 2;
         $subfolders = 1;
         if ($level > 1) {
             $subfolders = (int) self::_has_subfolder($path, self::_get_ntlm($parent));
         }
     }
     $icon = "";
     if ($level == 0) {
         $icon = "sys_nodb_cifs.png";
     }
     $tree[$left] = array("id" => $path, "lft" => $left, "rgt" => $right, "flevel" => $level, "ftitle" => basename($path), "ftype" => "sys_nodb_cifs", "icon" => $icon, "ffcount" => $subfolders);
     return $right + 1;
 }