public function fetch_by_id($id)
 {
     $value = self::fetch($id);
     $cloud = DB::fetch_first("select * from " . DB::table('connect') . " where bz='{$value['bz']}'");
     $data = array('id' => $value['id'], 'fid' => md5($cloud['bz'] . ':' . $value['id'] . ':' . $cloud['root']), 'pfid' => 0, 'fname' => $value['cloudname'], 'ficon' => 'dzz/images/default/system/' . $cloud['bz'] . '.png', 'bz' => $cloud['bz'] . ':' . $value['id'] . ':', 'path' => $cloud['bz'] . ':' . $value['id'] . ':' . $cloud['root'], 'type' => 'ftp', 'fsperm' => perm_FolderSPerm::flagPower($cloud['bz']), 'perm' => perm_binPerm::getGroupPower('all'), 'flag' => $cloud['bz'], 'iconview' => 1, 'disp' => '0');
     return $data;
 }
Beispiel #2
0
 public function fetch_by_fid($fid)
 {
     //返回一条数据同时加载附件表数据
     global $_G;
     $fid = intval($fid);
     if (!($data = self::fetch($fid))) {
         return false;
     }
     //$data['icon']=($data['ficon']?$data['ficon']:geticonfromext('','folder'));
     $data['title'] = $data['fname'];
     if ($data['flag'] == 'recycle') {
         $data['iconum'] = DB::result_first("select COUNT(*) from " . DB::table('icos') . " where isdelete>0 and uid='{$_G['uid']}'");
     } elseif ($data['uid'] < 1) {
         $data['iconum'] = DB::result_first("select COUNT(*) from " . DB::table('icos') . " where pfid='{$fid}' and uid='{$_G['uid']}' and isdelete<1");
     } else {
         $data['iconum'] = DB::result_first("select COUNT(*) from " . DB::table('icos') . " where pfid='{$fid}' and isdelete<1");
     }
     $data['perm'] = perm_check::getPerm($fid);
     $data['perm1'] = perm_check::getPerm1($fid);
     //print_r($data);
     if ($data['gid'] > 0) {
         $data['ismoderator'] = C::t('organization_admin')->ismoderator_by_uid_orgid($data['gid'], $_G['uid']);
         $permtitle = perm_binPerm::getGroupTitleByPower($data['perm1']);
         if (file_exists('dzz/images/default/system/folder-' . $permtitle['flag'] . '.png')) {
             $data['icon'] = 'dzz/images/default/system/folder-' . $permtitle['flag'] . '.png';
         } else {
             $data['icon'] = 'dzz/images/default/system/folder-read.png';
         }
     }
     $data['path'] = $data['fid'];
     $data['oid'] = $data['fid'];
     $data['bz'] = '';
     return $data;
 }
Beispiel #3
0
 public function __construct($path)
 {
     $arr = DB::fetch_first("SELECT root,name FROM %t WHERE bz=%s", array('connect', self::BZ));
     $this->_root = $arr['root'];
     $this->_rootname = $arr['name'];
     $this->perm = perm_binPerm::getMyPower();
     //self::init($path);
 }
 public function fetch_by_id($id)
 {
     $value = self::fetch($id);
     $cloud = DB::fetch_first("select * from " . DB::table('connect') . " where bz='{$value['bz']}'");
     $value['access_id'] = authcode($value['access_id'], 'DECODE', $value['bz']) ? authcode($value['access_id'], 'DECODE', $value['bz']) : $value['access_id'];
     if (!$value['cloudname']) {
         $value['cloudname'] = $cloud['name'] . ':' . ($value['bucket'] ? $value['bucket'] : cutstr($value['access_id'], 4, ''));
     }
     if ($value['bucket']) {
         $value['bucket'] .= '/';
     }
     $data = array('id' => $value['id'], 'fid' => md5($cloud['bz'] . ':' . $value['id'] . ':' . $value['bucket']), 'pfid' => 0, 'fname' => $value['cloudname'], 'ficon' => 'dzz/images/default/system/' . $cloud['bz'] . '.png', 'bz' => $cloud['bz'] . ':' . $value['id'] . ':', 'path' => $cloud['bz'] . ':' . $value['id'] . ':' . $value['bucket'], 'type' => 'storage', 'fsperm' => $value['bucket'] ? '0' : perm_FolderSPerm::flagPower($cloud['bz'] . '_root'), 'perm' => perm_binPerm::getGroupPower('all'), 'flag' => $cloud['bz'], 'iconview' => 1, 'disp' => '0');
     return $data;
 }
Beispiel #5
0
 public function __construct($path)
 {
     $bzarr = explode(':', $path);
     $ftpid = trim($bzarr[1]);
     if ($config = DB::fetch_first("select * from " . DB::table(self::T) . " where  id='{$ftpid}'")) {
         $this->_root = 'ftp:' . $config['id'] . ':';
         $this->encode = $config['charset'];
         $this->_rootname = $config['cloudname'];
         $ftp = new dzz_ftp($config);
         if ($ftp->error()) {
             $this->error = $ftp->error();
             return $this;
         }
         if ($ftp->connect()) {
             $this->conn = $ftp;
         } else {
             $this->error = 'ftp not connect';
         }
     } else {
         $this->error = 'need authorize';
     }
     $this->perm = perm_binPerm::getMyPower();
     return $this;
 }
 public function setFolderByOrgid($orgid)
 {
     if (!($org = parent::fetch($orgid))) {
         return false;
     }
     if (!$org['available']) {
         return;
     }
     if ($org['forgid'] == 0) {
         $pfid = 0;
     } else {
         $toporgid = self::getTopOrgid($orgid);
         $pfid = DB::result_first("select fid from " . DB::table($this->_table) . " where orgid='{$toporgid}'");
     }
     if ($fid = DB::result_first("select fid from " . DB::table('folder') . " where gid='{$orgid}' and uid='0'  and flag='organization'")) {
         C::t('folder')->update($fid, array('fname' => $org['orgname'], 'display' => $org['disp'], 'pfid' => $pfid, 'perm' => perm_binPerm::getGroupPower('read'), 'innav' => $org['available']));
         self::update($orgid, array('fid' => $fid));
     } else {
         $folder = array('fname' => $org['orgname'], 'pfid' => $pfid, 'display' => $org['disp'], 'flag' => 'organization', 'gid' => $org['orgid'], 'innav' => $org['available'], 'perm' => perm_binPerm::getGroupPower('read'));
         $fid = C::t('folder')->insert($folder, true);
     }
     if ($fid) {
         return self::update($org['orgid'], array('fid' => $fid));
     }
     return false;
 }
Beispiel #7
0
 public function fetch_all_by_pfid($pfid, $name = '', $limit = 0, $orderby = '', $order = '', $start = 0, $count = false)
 {
     global $_G;
     $limitsql = $limit ? DB::limit($start, $limit) : '';
     $data = array();
     $wheresql = '';
     $where = array();
     $para = array($this->_table);
     $where[] = ' isdelete<1 ';
     if ($name) {
         $where[] = 'name like %s';
         $para[] = '%' . $name . '%';
     }
     if (is_array($pfid)) {
         $arr = array();
         foreach ($pfid as $fid) {
             $arr[] = ' pfid = %d ';
             $para[] = $fid;
         }
         if ($arr) {
             $where[] = '(' . implode(' OR ', $arr) . ')';
         }
     } elseif ($pfid) {
         $where[] = 'pfid= %d';
         $para[] = $pfid;
     }
     if ($folder = C::t('folder')->fetch_by_fid($pfid)) {
         $where1 = array();
         if ($folder['gid'] > 0) {
             $folder['perm'] = perm_check::getPerm($folder['fid']);
             if ($folder['perm'] > 0) {
                 if (perm_binPerm::havePower('read1', $folder['perm'])) {
                     $where1[] = "uid='{$_G[uid]}'";
                 }
                 if (perm_binPerm::havePower('read2', $folder['perm'])) {
                     if ($where1) {
                         $where1 = array();
                     } else {
                         $where1[] = "uid!='{$_G[uid]}'";
                     }
                 }
             }
         }
         if ($where1) {
             $where = array_merge($where, $where1);
         }
     }
     if ($where) {
         $wheresql = 'WHERE ' . implode(' AND ', $where);
     } else {
         return false;
     }
     //exit($wheresql);
     if ($count) {
         return DB::result_first("SELECT COUNT(*) FROM %t  {$wheresql} ", $para);
     }
     $ordersql = '';
     if (is_array($orderby)) {
         foreach ($orderby as $key => $value) {
             $orderby[$key] = $value . ' ' . $order;
         }
         $ordersql = ' ORDER BY ' . implode(',', $orderby);
     } elseif ($orderby) {
         $ordersql = ' ORDER BY ' . $orderby . ' ' . $order;
     }
     foreach (DB::fetch_all("SELECT icoid FROM %t {$wheresql} {$ordersql} {$limitsql}", $para) as $value) {
         if ($arr = self::fetch_by_icoid($value['icoid'])) {
             $data[$value['icoid']] = $arr;
         }
     }
     return $data;
 }
Beispiel #8
0
         while ($arr1) {
             $patharr1[] = array_pop($arr1);
         }
         $info['path'] = implode('/', $patharr1) . '/' . $icoarr['tdata']['name'];
     }
     $info['size'] = '-';
     if ($icoarr['tdata']['type'] == 'folder') {
         $info['icon'] = 'dzz/images/default/system/folder.png';
     }
     break;
 case 'folder':
     if ($icoarr['gid'] > 0 && ($pfolder = C::t('folder')->fetch_by_fid($icoarr['pfid'])) && perm_binPerm::havePower('read2', $pfolder['perm1']) && (C::t('organization_admin')->ismoderator_by_uid_orgid($icoarr['gid'], $_G['uid']) || $_G['adminid'] == 1)) {
         $folder = C::t('folder')->fetch($icoarr['oid']);
         $ismoderator = 1;
         $permtitle = perm_binPerm::getGroupTitleByPower($icoarr['perm1']);
         $permarr = perm_binPerm::groupPowerPack();
     }
     $info['icon'] = $icoarr['img'] ? $icoarr['img'] : 'dzz/images/default/system/folder.png';
     $contains = getContainsByFid($icoarr['oid']);
     $info['size'] = lang('template', 'property_info_size', array('fsize' => formatsize($contains['size']), 'size' => $contains['size']));
     $info['contain'] = lang('template', 'property_info_contain', array('filenum' => $contains['contain'][0], 'foldernum' => $contains['contain'][1]));
     break;
 case 'dzzdoc':
     $info['path'] = implode('/', $patharr) . '/' . $icoarr['name'];
     $info['size'] = lang('template', 'property_info_size', array('fsize' => formatsize($icoarr['size']), 'size' => $icoarr['size']));
     break;
 case 'link':
     $info['path'] = implode('/', $patharr) . '/' . $icoarr['name'];
     $info['size'] = '-';
     break;
 case 'video':
Beispiel #9
0
 public function CreateFolder($pfid, $fname, $perm, $ondup = 'newcopy')
 {
     global $_G, $_GET;
     $fname = self::name_filter($fname);
     if (!($folder = DB::fetch_first("select fid,pfid,iconview,disp,gid from %t where fid=%d", array('folder', $pfid)))) {
         return array('error' => '父目录不存在');
     }
     if (!perm_check::checkperm_Container($pfid, 'folder')) {
         return array('error' => lang('message', 'no_privilege'));
     }
     if ($ondup == 'overwrite' && ($icoid = self::getRepeatIDByName($fname, $pfid, true))) {
         //如果目录下有同名目录
         $data = array();
         $data['icoarr'] = C::t('icos')->fetch_by_icoid($icoid);
         $data['folderarr'] = self::getFolderByIcosdata($data['icoarr']);
         return $data;
     } else {
         $fname = self::getFolderName($fname, $pfid);
     }
     //重命名
     $setarr = array('fname' => $fname, 'uid' => $_G['uid'], 'username' => $_G['username'], 'pfid' => $folder['fid'], 'iconview' => $folder['iconview'], 'disp' => $folder['disp'], 'perm' => $perm, 'flag' => 'folder', 'dateline' => $_G['timestamp'], 'gid' => $folder['gid']);
     if ($setarr['fid'] = C::t('folder')->insert($setarr, true)) {
         $setarr['path'] = $setarr['fid'];
         $setarr['perm'] = perm_check::getPerm($setarr['fid']);
         $setarr['perm1'] = perm_check::getPerm1($setarr['fid']);
         $setarr['title'] = $setarr['fname'];
         $setarr['ext'] = '';
         $setarr['size'] = 0;
         $setarr1 = array('uid' => $_G['uid'], 'username' => $_G['username'], 'oid' => $setarr['fid'], 'name' => $setarr['fname'], 'type' => 'folder', 'flag' => '', 'dateline' => $_G['timestamp'], 'pfid' => $folder['fid'], 'gid' => $folder['gid'], 'ext' => '', 'size' => 0);
         if ($setarr1['icoid'] = DB::insert('icos', $setarr1, 1)) {
             $setarr1['path'] = $setarr1['icoid'];
             $setarr1['dpath'] = dzzencode($setarr1['icoid']);
             $setarr1['bz'] = '';
             addtoconfig($setarr1);
             $setarr1['fsize'] = formatsize($setarr1['size']);
             $setarr1['ftype'] = getFileTypeName($setarr1['type'], $setarr1['ext']);
             $setarr1['fdateline'] = dgmdate($setarr1['dateline']);
             if ($setarr['gid']) {
                 $permtitle = perm_binPerm::getGroupTitleByPower($setarr['perm1']);
                 if (file_exists('dzz/images/default/system/folder-' . $permtitle['flag'] . '.png')) {
                     $setarr['icon'] = $setarr1['img'] = 'dzz/images/default/system/folder-' . $permtitle['flag'] . '.png';
                 } else {
                     $setarr['icon'] = $setarr1['img'] = 'dzz/images/default/system/folder-read.png';
                 }
             }
             return array('icoarr' => $setarr1, 'folderarr' => $setarr);
         }
     }
     return false;
 }
Beispiel #10
0
 function getSumByAction($action = array())
 {
     //$action==all 时返回所有的值相加
     $i = 0;
     $powerarr = self::getPowerArr();
     if ($action == 'all') {
         foreach ($powerarr as $key => $val) {
             $i += $val;
         }
     } else {
         $i = 1;
         foreach ($action as $val) {
             $i += intval($powerarr[$val]);
         }
     }
     if (getglobal('setting/allowshare')) {
         $power = new perm_binPerm($i);
         $i = $power->delPower('share');
     }
     return $i;
 }
Beispiel #11
0
                $value1['bucket'] .= '/';
            }
            $value1['icoid'] = md5($value['bz'] . ':' . $value1['id'] . ':' . $value1['bucket']);
            $value1['img'] = 'dzz/images/default/system/' . $value['bz'] . '.png';
            $mycloud[] = $value1;
            $icosdata[md5($value['bz'] . ':' . $value1['id'] . ':' . $value1['bucket'])] = array('icoid' => md5($value['bz'] . ':' . $value1['id'] . ':' . $value1['bucket']), 'name' => $value1['cloudname'], 'img' => 'dzz/images/default/system/' . $value['bz'] . '.png', 'bz' => $value['bz'] . ':' . $value1['id'] . ':', 'path' => $value['bz'] . ':' . $value1['id'] . ':' . $value1['bucket'], 'type' => 'storage', 'oid' => md5($value['bz'] . ':' . $value1['id'] . ':' . $value1['bucket']));
            $folderdata[md5($value['bz'] . ':' . $value1['id'] . ':' . $value1['bucket'])] = array('fid' => md5($value['bz'] . ':' . $value1['id'] . ':' . $value1['bucket']), 'pfid' => 0, 'fname' => $value1['cloudname'], 'icon' => 'dzz/images/default/system/' . $value['bz'] . '.png', 'bz' => $value['bz'] . ':' . $value1['id'] . ':', 'path' => $value['bz'] . ':' . $value1['id'] . ':' . $value1['bucket'], 'type' => 'storage', 'fsperm' => $value1['bucket'] ? '0' : perm_FolderSPerm::flagPower($value['bz'] . '_root'), 'perm' => perm_binPerm::getGroupPower('all'));
        }
    } elseif ($value['type'] == 'ftp') {
        foreach (DB::fetch_all("select id,bz,cloudname,dateline from " . DB::table($value['dname']) . " where bz='{$value[bz]}' and uid='{$_G[uid]}'") as $value1) {
            $value1['bz'] = $value['bz'];
            $value1['icoid'] = md5($value['bz'] . ':' . $value1['id'] . ':');
            $value1['img'] = 'dzz/images/default/system/' . $value['bz'] . '.png';
            $mycloud[] = $value1;
            $icosdata[md5($value['bz'] . ':' . $value1['id'] . ':')] = array('icoid' => md5($value['bz'] . ':' . $value1['id'] . ':' . $value1['bucket']), 'name' => $value1['cloudname'], 'img' => 'dzz/images/default/system/' . $value['bz'] . '.png', 'bz' => $value['bz'] . ':' . $value1['id'] . ':', 'path' => $value['bz'] . ':' . $value1['id'] . ':', 'type' => 'ftp', 'oid' => md5($value['bz'] . ':' . $value1['id'] . ':'));
            $folderdata[md5($value['bz'] . ':' . $value1['id'] . ':')] = array('fid' => md5($value['bz'] . ':' . $value1['id'] . ':'), 'pfid' => 0, 'fname' => $value1['cloudname'], 'icon' => 'dzz/images/default/system/' . $value['bz'] . '.png', 'bz' => $value['bz'] . ':' . $value1['id'] . ':', 'path' => $value['bz'] . ':' . $value1['id'] . ':', 'type' => 'ftp', 'fsperm' => perm_FolderSPerm::flagPower($value['bz']), 'perm' => perm_binPerm::getGroupPower('all'));
        }
    }
}
//按创建时间排序时间排序
function sortcloud($a, $b)
{
    if ($a['dateline'] == $b['dateline']) {
        return 0;
    }
    return $a['dateline'] > $b['dateline'] ? -1 : 1;
}
usort($mycloud, "sortcloud");
$icosdata_json = json_encode($icosdata);
$folderdata_json = json_encode($folderdata);
include template("connect_index");
Beispiel #12
0
 function groupPerm($fid, $action, $gid)
 {
     //判断容器有没有指定的权限
     global $_G;
     $ismoderator = C::t('organization_admin')->ismoderator_by_uid_orgid($gid, $_G['uid']);
     //if($action=='admin' && $ismoderator)  return true;
     if ($ismoderator) {
         //是机构管理员
         return true;
     }
     //exit($action);
     include_once libfile('function/organization');
     if ($gid) {
         $members = getUserByOrgid($gid, 1, array(), true);
     }
     if (!in_array($_G['uid'], $members)) {
         return false;
     }
     //if($action=='download' || $action=='saveto' || $action=='copy' ) return true;
     $perm = self::getPerm($fid);
     //exit($perm.'====='.$fid.'======='.$gid.'===='.$action);
     if ($perm > 0) {
         $power = new perm_binPerm($perm);
         //exit($perm.'====='.$fid.'======='.$gid.'===='.$action.'==='.$power->isPower($action));
         return $power->isPower($action);
     }
     return false;
 }
Beispiel #13
0
     }
 } else {
     $arr = array();
     $icos = array();
     $icosdata = array();
     $folderdata = array();
     $folderids = array();
     if ($folder = DB::fetch_first('select * from ' . DB::table('folder') . " where fid='{$id}'")) {
         $sql = '';
         if ($folder['gid'] > 0) {
             $folder['perm'] = perm_check::getPerm($folder['fid']);
             if ($folder['perm'] > 0) {
                 if (perm_binPerm::havePower('read1', $folder['perm'])) {
                     $sql .= " and uid='{$_G[uid]}'";
                 }
                 if (perm_binPerm::havePower('read2', $folder['perm'])) {
                     if ($sql) {
                         $sql = '';
                     } else {
                         $sql .= " and uid!='{$_G[uid]}'";
                     }
                 }
             }
         }
         $query = DB::query("select * from " . DB::table('folder') . " where innav>0 and pfid='{$folder[fid]}' and isdelete<1 {$sql} order by display");
         while ($value = DB::fetch($query)) {
             if ($value['gid'] && $value['flag'] == 'organization') {
                 $uids = C::t('organization_user')->fetch_uids_by_orgid($value['gid']);
                 $ismoderator = C::t('organization_admin')->ismoderator_by_uid_orgid($value['gid'], $_G['uid']);
                 if (!in_array($_G['uid'], $uids) && !$ismoderator && $_G['adminid'] != 1) {
                     continue;