Example #1
0
    }
    if ($icoarr['size'] > $maxputsize) {
        $url = DZZSCRIPT . '?mod=textviewer&path=' . dzzencode($path);
        header("Location: {$url}");
        exit;
    }
    if (isset($icoarr['error'])) {
        exit($icoarr['error']);
    }
    //根据ext获取加载codemirror的mode;
    $ext = isset($icoarr['ext']) ? $icoarr['ext'] : '';
    require_once DZZ_ROOT . './dzz/document/codemirror/exttomodes.php';
    $mode = isset($modes[$ext]) ? $modes[$ext] : '';
    //获取文件地址,如果文件可以执行的话(如php,html,js等) 必须使用绝对地址,否则会得到运行后的内容;
    //判断有无编辑权限
    $isadmin = perm_check::checkperm('edit', $icoarr);
    $str = IO::getFileContent($path);
    require_once DZZ_ROOT . './dzz/class/class_encode.php';
    $p = new Encode_Core();
    $code = $p->get_encoding($str);
    if ($code) {
        $str = diconv($str, $code, CHARSET);
    }
    $str = htmlspecialchars($str);
    include template('textviewer');
}
function getUrlMimeType($url)
{
    if (function_exists('mime_content_type ')) {
        return mime_content_type($url);
    } else {
Example #2
0
            //版本比较模式,显示当前版本与前一版本的差异
            $current = $versions[$version];
            if (isset($versions[$version])) {
                $dzzpath = getDzzPath($versions[$version]);
                $str_new = str_replace(array("\r\n", "\r", "\n"), "", IO::getFileContent($dzzpath));
            } else {
                $dzzpath = getDzzPath($document);
                $str_new = str_replace(array("\r\n", "\r", "\n"), "", IO::getFileContent($dzzpath));
            }
            if ($versions[$version - 1]) {
                $dzzpath_old = getDzzPath($versions[$version - 1]);
                $str_old = str_replace(array("\r\n", "\r", "\n"), "", IO::getFileContent($dzzpath_old));
            } else {
                $str_old = $str_new;
            }
            include_once dzz_libfile('class/html_diff', 'document');
            $diff = new html_diff();
            $str = $diff->compare($str_old, $str_new);
        } else {
            $current = $document;
            $dzzpath = getDzzPath($document);
            $str = str_replace(array("\r\n", "\r", "\n"), "", IO::getFileContent($dzzpath));
            $navtitle = $document['subject'];
        }
    } else {
        showmessage('文档不存在或已经删除', dreferer());
    }
    $dicoid = dzzencode($icoid);
    $editperm = perm_check::checkperm('edit', $icoarr);
    include template('document_view');
}
Example #3
0
    if (!($attach = getTxtAttachByMd5($message, $icoarr['name'] . '.dzzdoc'))) {
        showmessage('保存文档错误,请检查您的磁盘是否有足够空间或写入权限', dreferer());
    }
    //获取文档内附件
    $attachs = getAidsByMessage($message);
    $setarr = array('uid' => $_G['uid'], 'username' => $_G['username'], 'aid' => $attach['aid'], 'did' => $did);
    if (!($did = C::t('document')->insert($setarr, $attachs, $area, $areaid, $new))) {
        showmessage('保存文档错误,请检查您数据库是否正常');
    }
    $return = array('did' => $did, 'autosave' => $autosave, 'icoid' => dzzencode($icoid));
    showmessage('do_success', dreferer(), array('data' => rawurlencode(json_encode($return))), array('showmsg' => true));
} else {
    $navtitle = '';
    $icoid = intval(dzzdecode($_GET['icoid']));
    if ($icoid && ($icoarr = C::t('icos')->fetch_by_icoid($icoid))) {
        if (!perm_check::checkperm('edit', $icoarr)) {
            showmessage('no_privilege');
        }
        $did = $icoarr['did'];
    } else {
        showmessage('文档不存在');
    }
    if ($document = C::t('document')->fetch_by_did($did)) {
        $dzzpath = getDzzPath($document);
        $str = trim(IO::getFileContent($dzzpath));
        $navtitle = $document['subject'];
    } else {
        $navtitle = '新建文档';
    }
    include template('document_edit');
}
Example #4
0
 public function update_by_name($icoid, $text)
 {
     //重命名
     $arr = array();
     $arr['text'] = $text;
     if (!($icoarr = self::fetch($icoid))) {
         $arr['error'] = lang('message', 'icoid_not_exist');
         return $arr;
     }
     if (!perm_check::checkperm('rename', $icoarr)) {
         $arr['error'] = lang('message', 'no_privilege');
         return $arr;
     }
     switch ($icoarr['type']) {
         case 'folder':
             if (C::t('folder')->update($icoarr['oid'], array('fname' => $text))) {
                 $arr['dataname'] = 'fname';
             }
             break;
         case 'link':
         case 'video':
         case 'music':
         case 'image':
         case 'attach':
         case 'document':
             C::t('source_' . $icoarr['type'])->update($icoarr['oid'], array('title' => $text));
             break;
         case 'pan':
             C::t('connect_' . $icoarr['type'])->update($icoarr['oid'], array('cloudname' => $text));
             break;
         case 'storage':
             C::t('connect_' . $icoarr['type'])->update($icoarr['oid'], array('cloudname' => $text));
             break;
         case 'shortcut':
             break;
     }
     if (C::t('icos')->update($icoid, array('name' => $text))) {
         $arr['msg'] = 'success';
     }
     return $arr;
 }
Example #5
0
        if ($share['password']) {
            $share['password'] = dzzencode($share['password']);
        }
        $share['times'] = intval($share['times']);
        $share['count'] = 0;
        if ($ret = C::t('share')->insert_by_sid($share)) {
            $ret['msg'] = 'success';
            exit(json_encode($ret));
        } else {
            exit(json_encode(array('error' => '创建失败!')));
        }
    }
} elseif ($do == 'property') {
    $icoid = rawurldecode($_GET['icoid']);
    $icoarr = IO::getMeta($icoid);
    $perm = perm_check::checkperm('rename', $icoarr);
    if ($icoarr['error']) {
        showmessage($icoarr['error']);
    }
    if (submitcheck('propertysubmit')) {
        $return = array();
        if (!$icoarr['bz']) {
            $name = io_dzz::name_filter(trim($_GET['name']));
            if ($icoarr['name'] != $name || $icoarr['type'] == 'folder' && $icoarr['gid'] > 0) {
                C::t('icos')->update_by_name($icoid, $name);
                if ($icoarr['type'] == 'folder' && $icoarr['gid'] > 0 && (C::t('organization_admin')->ismoderator_by_uid_orgid($icoarr['gid'], $_G['uid']) || $_G['adminid'] == 1)) {
                    C::t('folder')->update($icoarr['fid'], array('perm' => intval($_GET['perm'])));
                }
                $return = C::t('icos')->fetch_by_icoid($icoid);
                $return['msg'] = 'success';
            }
Example #6
0
        exit;
    }
    if (!is_array($icoids)) {
        $icoids = array($icoids);
    }
    if (!perm_check::checkperm_Container($pfid, 'admin')) {
        exit(lang('message', 'no_privilege'));
    }
    C::t("dzz_icos")->update($icoids, array('position' => ''));
    exit;
} elseif ($do == 'icoposition') {
    $icoid = intval($_POST['icoid']);
    $dataname = $_GET['dataname'];
    $val = trim($_POST[$dataname]);
    if ($icoarr = C::t('icos')->fetch($icoid)) {
        if (perm_check::checkperm('admin', $icoarr)) {
            C::t('icos')->update($icoid, array($dataname => $val));
        }
    }
    exit;
} elseif ($_GET['do'] == 'move') {
    $obz = trim($_GET['obz']);
    $tbz = trim($_GET['tbz']);
    $sourcetype = trim($_GET['sourcetype']);
    $icoids = explode(',', $_GET['icoid']);
    $ticoid = intval($_GET['ticoid']);
    $container = trim($_GET['container']);
    $iscut = isset($_GET['iscut']) ? intval($_GET['iscut']) : 0;
    $data = array();
    $icoarr = array();
    $folderarr = array();
Example #7
0
 public function FileCopy($icoid, $pfid, $first = true)
 {
     global $_G, $_GET;
     if (!($tfolder = DB::fetch_first("select * from " . DB::table('folder') . " where fid='{$pfid}'"))) {
         return array('error' => ' 目标位置不存在');
     }
     if ($icoarr = C::t('icos')->fetch($icoid)) {
         //判断当前文件有没有拷贝权限;
         if (!perm_check::checkperm('copy', $icoarr)) {
             return array('error' => ' 没有权限');
         }
         //判断目录目录有无当前类型的添加权限
         if (in_array($icoarr['type'], array('folder', 'link', 'video', 'dzzdoc', 'shortcut'))) {
             if (!perm_check::checkperm_Container($pfid, $icoarr['type'])) {
                 return array('error' => ' 没有权限');
             }
         } elseif (!perm_check::checkperm_Container($pfid, 'newtype')) {
             return array('error' => ' 没有权限');
         }
         $success = 0;
         if ($gid = DB::result_first("select gid from " . DB::table('folder') . " where fid='{$pfid}'")) {
             //判断空间大小
             if (!SpaceSize($icoarr['size'], $gid)) {
                 return array('error' => lang('message', 'inadequate_capacity_space'));
             }
         }
         //判断重复
         if ($ricoid = self::getRepeatIDByName($icoarr['name'], $pfid, $icoarr['type'] == 'folder' ? true : false)) {
             //如果目录下有同名文件
             if ($icoarr['type'] == 'folder') {
                 $icoarr['name'] = self::getFolderName($icoarr['name'], $pfid);
             } else {
                 $icoarr['name'] = self::getFileName($icoarr['name'], $pfid);
             }
         }
         switch ($icoarr['type']) {
             case 'folder':
                 if ($folder = C::t('folder')->fetch($icoarr['oid'])) {
                     $oldfid = $folder['fid'];
                     $oldfolder = $folder;
                     unset($folder['fid']);
                     $folder['uid'] = $_G['uid'];
                     $folder['username'] = $_G['username'];
                     $folder['pfid'] = $pfid;
                     $folder['fname'] = $icoarr['name'];
                     $folder['gid'] = $gid;
                     //$folder['perm']=0;
                     if ($folder['fid'] = C::t("folder")->insert($folder, 1)) {
                         foreach (C::t('icos')->fetch_all_by_pfid($oldfid) as $value) {
                             try {
                                 self::FileCopy($value['icoid'], $folder['fid'], false);
                             } catch (Exception $e) {
                             }
                         }
                         $return['folderarr'] = $folder;
                         $icoarr['oid'] = $folder['fid'];
                         $success = 1;
                     }
                 } else {
                     return array('error', lang('message', 'folder_not_exist'));
                 }
                 break;
             case 'user':
                 $success = 1;
                 break;
             case 'shortcut':
                 $shortcut = C::t('source_shortcut')->fetch($icoarr['oid']);
                 unset($shortcut['cutid']);
                 if ($cutid = C::t('source_shortcut')->insert($shortcut, 1)) {
                     $icoarr['oid'] = $cutid;
                     $success = 1;
                 }
                 break;
             case 'app':
                 $success = 1;
                 break;
             case 'image':
                 if ($image = C::t('source_image')->fetch($icoarr['oid'])) {
                     $opicid = $image['picid'];
                     unset($image['picid']);
                     $image['title'] = $icoarr['name'];
                     $image['uid'] = $_G['uid'];
                     $image['gid'] = $gid;
                     $image['username'] = $_G['username'];
                     if ($image['picid'] = DB::insert('source_image', $image, 1)) {
                         $image['aid'] && C::t('attachment')->addcopy_by_aid($image['aid']);
                         $icoarr['oid'] = $image['picid'];
                         $success = 1;
                     }
                 } else {
                     return array('error', lang('message', 'image_not_exist'));
                 }
                 break;
             case 'video':
                 if ($video = C::t('source_video')->fetch($icoarr['oid'])) {
                     $video['uid'] = $_G['uid'];
                     $video['gid'] = $gid;
                     unset($video['vid']);
                     $video['title'] = $icoarr['name'];
                     $video['username'] = $_G['username'];
                     if ($video['vid'] = DB::insert('source_video', $video, 1)) {
                         if ($video['cid']) {
                             DB::query("update " . DB::table('cai_video') . " set copys=copys+1 where cid='{$video[cid]}'");
                         }
                         $icoarr['oid'] = $video['vid'];
                         $success = 1;
                     }
                 } else {
                     return array('error', lang('message', 'video_not_exist'));
                 }
                 break;
             case 'music':
                 if ($music = C::t('source_music')->fetch($icoarr['oid'])) {
                     unset($music['mid']);
                     $music['uid'] = $_G['uid'];
                     $music['gid'] = $gid;
                     $music['title'] = $icoarr['name'];
                     $music['username'] = $_G['username'];
                     if ($music['mid'] = DB::insert('source_music', $music, 1)) {
                         if ($music['cid']) {
                             DB::query("update " . DB::table('cai_music') . " set copys=copys+1 where cid='{$music[cid]}'");
                         }
                         $icoarr['oid'] = $music['mid'];
                         $success = 1;
                     }
                 } else {
                     return array('error', lang('message', 'video_not_exist'));
                 }
                 break;
             case 'link':
                 if ($link = C::t('source_link')->fetch($icoarr['oid'])) {
                     $olink = $link['lid'];
                     unset($link['lid']);
                     $link['uid'] = $_G['uid'];
                     $link['username'] = $_G['username'];
                     $link['title'] = $icoarr['name'];
                     $link['gid'] = $gid;
                     if ($link['lid'] = DB::insert('source_link', $link, 1)) {
                         if ($link['cid']) {
                             DB::query("update " . DB::table('cai_link') . " set copys=copys+1 where cid='{$link[cid]}'");
                         }
                         if ($link['did']) {
                             C::t('icon')->update_copys_by_did($link['did']);
                         }
                         $icoarr['oid'] = $link['lid'];
                         $success = 1;
                     }
                 } else {
                     return array('error', lang('message', 'link_not_exist'));
                 }
                 break;
             case 'attach':
                 if ($attach1 = C::t('source_attach')->fetch($icoarr['oid'])) {
                     $oqid = $attach1['qid'];
                     unset($attach1['qid']);
                     $attach1['uid'] = $_G['uid'];
                     $attach['title'] = $icoarr['name'];
                     $attach1['username'] = $_G['username'];
                     $attach1['gid'] = $gid;
                     if ($attach1['qid'] = DB::insert('source_attach', $attach1, 1)) {
                         $attach1['aid'] && C::t('attachment')->addcopy_by_aid($attach1['aid']);
                         $icoarr['oid'] = $attach1['qid'];
                         $success = 1;
                     }
                 } else {
                     return array('error', lang('message', 'attach_not_exist'));
                 }
                 break;
             case 'document':
                 if ($document = C::t('source_document')->fetch($icoarr['oid'])) {
                     $odid = $document['did'];
                     unset($document['did']);
                     $document['uid'] = $_G['uid'];
                     $document['title'] = $icoarr['name'];
                     $document['username'] = $_G['username'];
                     $document['gid'] = $gid;
                     if ($document['did'] = DB::insert('source_document', $document, 1)) {
                         $document['aid'] && C::t('attachment')->addcopy_by_aid($document['aid']);
                         $icoarr['oid'] = $document['did'];
                         $success = 1;
                     }
                 } else {
                     return array('error', lang('message', 'document_not_exist'));
                 }
                 break;
             case 'dzzdoc':
                 if ($did = C::t('document')->copy_by_did($icoarr['oid'])) {
                     $icoarr['oid'] = $did;
                     $success = 1;
                 } else {
                     return array('error', '创建Dzz文档失败');
                 }
                 break;
             default:
                 $success = 1;
         }
         if ($success) {
             unset($icoarr['icoid']);
             $icoarr['gid'] = $gid;
             $icoarr['uid'] = $_G['uid'];
             $icoarr['username'] = $_G['username'];
             $icoarr['pfid'] = $pfid;
             if ($icoarr['icoid'] = DB::insert('icos', $icoarr, 1)) {
                 if ($icoarr['size'] > 0) {
                     SpaceSize($icoarr['size'], $gid, 1);
                 }
                 if (!$first) {
                     addtoconfig($icoarr);
                 } else {
                     $return['icoarr'] = C::t('icos')->fetch_by_icoid($icoarr['icoid']);
                     return $return;
                 }
             } else {
                 return array('error' => '此类文件不允许复制');
             }
         }
     }
     return array('error' => 'copy error');
 }