showmessage('no_privilege', dreferer()); } //桌面上的文档 $area=='' && $areaid=0; //项目内文档 $area=='project' && $areaid==$pjid; $area = $_GET['area'] == 'folder' ? '' : trim($_GET['area']); $areaid = $_GET['area'] == 'folder' ? 0 : trim($_GET['areaid']); $new = intval($_GET['newversion']); $autosave = intval($_GET['autosave']); if ($autosave) { $new = 0; } //存储文档内容到文本文件内 $_GET['message'] = helper_security::checkhtml($_GET['message']); $message = str_replace(array("\r\n", "\r", "\n"), "", $_GET['message']); //去除换行 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)) {
public function setFileContent($icoid, $fileContent) { global $_G, $space; if (!($icoarr = C::t('icos')->fetch_by_icoid($icoid))) { return array('error' => lang('message', 'file_not_exist')); } if ($icoarr['type'] != 'document' && $icoarr['type'] != 'attach' && $icoarr['type'] != 'image') { return array('error' => lang('message', 'no_privilege')); } $gid = DB::result_first("select gid from %t where fid=%d", array('folder', $icoarr['pfid'])); if (!perm_check::checkperm('edit', $icoarr)) { return array('error' => lang('message', 'no_privilege')); } if (!($attach = getTxtAttachByMd5($fileContent, $icoarr['name'], $icoarr['ext']))) { return array('error' => lang('message', 'file_save_failure')); } //计算用户新的空间大小 $csize = $attach['filesize'] - $icoarr['size']; //重新计算用户空间 if ($csize) { if (!SpaceSize($csize, $gid)) { return array('error' => lang('message', 'inadequate_capacity_space')); } SpaceSize($csize, $gid, 1); } $oldaid = $icoarr['aid']; //更新附件数量 if ($oldaid != $attach['aid']) { if ($icoarr['type'] == 'document') { C::t('source_document')->update($icoarr['did'], array('aid' => $attach['aid'])); } elseif ($icoarr['type'] == 'image') { C::t('source_image')->update($icoarr['picid'], array('aid' => $attach['aid'])); } else { C::t('source_attach')->update($icoarr['qid'], array('aid' => $attach['aid'])); } C::t('attachment')->update($attach['aid'], array('copys' => $attach['copys'] + 1)); C::t('attachment')->delete_by_aid($oldaid); } return C::t('icos')->fetch_by_icoid($icoid); }
//$subject=empty($_GET['subject'])?'新文档':str_replace('...','',getstr($_GET['subject'],80)); //桌面上的文档 $area=='' && $areaid=0; //项目内文档 $area=='project' && $areaid==$pjid; $area = 'corpus'; $cid = intval($_GET['cid']); $fid = intval($_GET['fid']); $new = intval($_GET['newversion']); $autosave = intval($_GET['autosave']); $class = C::t('corpus_class')->fetch($fid); if ($autosave) { $new = 0; } //存储文档内容到文本文件内 $message = helper_security::checkhtml($_GET['message']); //str_replace(array("\r\n", "\r", "\n"), "",$_GET['message']); //去除换行 if (!($attach = getTxtAttachByMd5($message, $class['fname'] . '.dzzdoc'))) { showmessage('保存文档错误,请检查您的磁盘是否有足够空间或写入权限', dreferer()); } //获取文档内附件 $attachs = getAidsByMessage($message); $setarr = array('uid' => $_G['uid'], 'username' => $_G['username'], 'aid' => $attach['aid'], 'fid' => $fid, 'did' => $did); if (!($did = C::t('document')->insert($setarr, $attachs, $area, $cid, $new))) { showmessage('保存文档错误,请检查您数据库是否正常'); } else { C::t('corpus_class')->update($fid, array('did' => $did)); //产生事件 if (!$autosave) { //自动保存不产生事件 $event = array('uid' => getglobal('uid'), 'username' => getglobal('username'), 'body_template' => $new ? 'corpus_reversion_doc' : 'corpus_edit_doc', 'body_data' => serialize(array('cid' => $cid, 'fid' => $fid, 'fname' => $class['fname'])), 'dateline' => TIMESTAMP, 'bz' => 'corpus_' . $cid); C::t('corpus_event')->insert($event); //通知文档原作者
//文本类文档; if (!($attach = C::t('attachment')->fetch($aid))) { C::t('corpus_class')->delete_by_fid($fid, true); exit(json_encode(array('error' => '文档导入失败'))); } $path = getDzzPath($attach); $message = IO::getFileContent($path); require_once DZZ_ROOT . './dzz/class/class_encode.php'; $p = new Encode_Core(); $code = $p->get_encoding($message); if ($code) { $message = diconv($message, $code, CHARSET); } $message = htmlspecialchars($message); $message = nl2br(str_replace(array("\t", ' ', ' '), array(' ', ' ', ' '), $message)); if (!($attach = getTxtAttachByMd5($message, $setarr['fname'] . '.dzzdoc'))) { C::t('corpus_class')->delete_by_fid($fid, true); exit(json_encode(array('error' => '文档导入失败'))); } $setarr1 = array('uid' => $_G['uid'], 'username' => $_G['username'], 'aid' => $attach['aid'], 'fid' => $fid); if (!($newdid = C::t('document')->insert($setarr1, array(), 'corpus', $cid))) { C::t('corpus_class')->delete_by_fid($fid, true); exit(json_encode(array('error' => '文档导入失败'))); } else { if (C::t('corpus_class')->update($fid, array('did' => $newdid))) { $data = array('id' => $fid, 'text' => $setarr['fname'], 'type' => $type); exit(json_encode($data)); } else { C::t('document')->delete_by_did($newdid, true); exit(json_encode(array('error' => '文档导入失败'))); }