public function download($path, $filename) { global $_G; $attachexists = FALSE; if (strpos($path, 'attach::') === 0) { $attachment = C::t('attachment')->fetch(intval(str_replace('attach::', '', $path))); $attachment['name'] = $filename ? $filename : $attachment['filename']; $path = getDzzPath($attachment); $attachurl = IO::getStream($path); } elseif (strpos($path, 'dzz::') === 0) { $attachment = array('attachment' => preg_replace("/^dzz::/i", '', $path), 'name' => $filename ? $filename : substr(strrpos($path, '/'))); $attachurl = $_G['setting']['attachdir'] . $attachment['attachment']; } elseif (is_numeric($path)) { $icoid = intval($path); $icoarr = C::t('icos')->fetch_by_icoid($path); if (!$icoarr['icoid']) { topshowmessage(lang('message', 'attachment_nonexistence')); } elseif ($icoarr['type'] == 'folder') { self::zipdownload($path); exit; } if (!$icoarr['aid']) { topshowmessage(lang('message', 'attachment_nonexistence')); } $attachment = $icoarr; $attachurl = IO::getStream($path); } //$filename = $_G['setting']['attachdir'].$attachment['attachment']; $filesize = !$attachment['remote'] ? filesize($attachurl) : $attachment['filesize']; if ($attachment['ext'] && strpos(strtolower($attachment['name']), $attachment['ext']) === false) { $attachment['name'] .= '.' . $attachment['ext']; } $attachment['name'] = '"' . (strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'rv:11')) ? urlencode($attachment['name']) : $attachment['name']) . '"'; if (!($fp = @fopen($attachurl, 'rb'))) { topshowmessage('文件不存在'); } $db = DB::object(); $db->close(); $chunk = 10 * 1024 * 1024; dheader('Date: ' . gmdate('D, d M Y H:i:s', $attach['dateline']) . ' GMT'); dheader('Last-Modified: ' . gmdate('D, d M Y H:i:s', $attach['dateline']) . ' GMT'); dheader('Content-Encoding: none'); dheader('Content-Disposition: attachment; filename=' . $attachment['name']); dheader('Content-Type: application/octet-stream'); dheader('Content-Length: ' . $filesize); @ob_end_clean(); if (getglobal('gzipcompress')) { @ob_start('ob_gzhandler'); } while (!feof($fp)) { echo fread($fp, $chunk); @ob_flush(); // flush output @flush(); } fclose($fp); //@readfile($attachurl); // @ob_flush();@flush(); exit; }
//版本比较模式,显示当前版本与前一版本的差异 $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'); }
exit(json_encode($data)); } else { C::t('document')->delete_by_did($newdid, true); exit(json_encode(array('error' => '文档导入失败'))); } } else { C::t('corpus_class')->delete_by_fid($fid, true); exit(json_encode(array('error' => '文档导入失败'))); } } elseif ($aid > 0) { //文本类文档; 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))) {