예제 #1
0
 function createPDF($dirname, $resource_path)
 {
     $outfile = "";
     //接收参数    1、加密文件夹物理路径
     //接收参数    1、加密文件物理路径
     //使用PHPinfo方法。进行路径解析
     $info = pathinfo($resource_path);
     //组装一个文件标示,方便判断文件是否生成
     $lockFile = $info['dirname'] . '/' . $info['filename'] . '.lock';
     //验证标示文件是否存在,判断是否为后台自动生成中,避免第二次点击的时候在重新生成
     if (!file_exists($lockFile)) {
         //生成标示文件
         file_put_contents($lockFile, 'true');
         //执行PDF文件生成
         import('@.ORG.OfficeOnline.OfficeOnlineView');
         $OfficeOnlineView = new OfficeOnlineView();
         $outfile = $OfficeOnlineView->fileCreate($dirname, $resource_path, 'swf/pdf');
         //删除标示文件
         unlink($lockFile);
     }
     return $outfile;
 }
예제 #2
0
 /**
  * @Title: playSWF
  * @Description: todo(文件在线查看方法)
  * @author liminggang
  * @date 2014-8-12 下午5:29:50
  * @throws
  */
 function playSWF()
 {
     $file_type = "file";
     $socuse = str_replace("\\", "/", base64_decode($_REQUEST['name']));
     $uid = $_REQUEST['uid'];
     $file_path = $resource_path = str_replace("\\", "/", UPLOAD_PATH . $socuse);
     $this->assign("resource_path", $resource_path);
     if (!file_exists($file_path)) {
         $this->display("Public:playswfno");
         exit;
     }
     $info = pathinfo($file_path);
     $filesArr = C('TRANSFORM_SWF');
     $filesArr[] = 'pdf';
     $photoArr = C('IMG_file');
     $file_extension_lower = strtolower($info['extension']);
     if ($file_extension_lower == "docx" || $file_extension_lower == "doc") {
         $action = $this->getActionName();
         // 			$ip = gethostbyname($_SERVER['SERVER_NAME']);
         $ip = C("DB_HOST_WORD");
         //"192.168.0.238";
         require_once "http://{$ip}:8088/JavaBridge/java/Java.inc";
         //此行必须
         $PageOfficeCtrl = new Java("com.zhuozhengsoft.pageoffice.PageOfficeCtrlPHP");
         //此行必须
         $PageOfficeCtrl->setServerPage("http://{$ip}:8088/JavaBridge/poserver.zz");
         //此行必须,设置服务器页面
         $url = __ROOT__ . "/Admin/index.php/{$action}/saveOnlineEditWord/name/" . $_REQUEST['name'];
         java_set_file_encoding("utf8");
         //设置中文编码,若涉及到中文必须设置中文编码
         // 			//添加自定义按钮
         // 			$PageOfficeCtrl->addCustomToolButton("保存","Save",1);
         // 			//设置保存页面
         $PageOfficeCtrl->setSaveFilePage($url);
         $PageOfficeCtrl->addCustomToolButton("保存", "Save", 1);
         $PageOfficeCtrl->addCustomToolButton("显示/隐藏修改记录", "Show_HidRevisions", 7);
         // 			$PageOfficeCtrl->setAllowCopy(false);//禁止拷贝
         //$PageOfficeCtrl->setMenubar(false);//隐藏菜单栏
         // 			$PageOfficeCtrl->setOfficeToolbars(false);//隐藏Office工具条
         // 			$PageOfficeCtrl->setCustomToolbar(false);//隐藏自定义工具栏
         //打开excel文档
         $PageOfficeCtrl->UserAgent = $_SERVER['HTTP_USER_AGENT'];
         //若使用谷歌浏览器此行代码必须有,其他浏览器此行代码可不加
         $OpenMode = new Java("com.zhuozhengsoft.pageoffice.OpenModeType");
         $socuse = str_replace("\\", "/", base64_decode($_REQUEST['name']));
         $file_path = str_replace("\\", "/", UPLOAD_PATH . $socuse);
         $file_path = preg_replace("/^([\\s\\S]+)\\/Public/", "/Public/", $file_path);
         // 			$PageOfficeCtrl->webOpen($file_path, $OpenMode->docNormalEdit, "张三");//此行必须
         //获取用户名称
         $loginUserName = getFieldBy($uid, "id", "name", "user");
         $PageOfficeCtrl->webOpen($file_path, $OpenMode->docRevisionOnly, $loginUserName);
         //此行必须
         $this->assign('PageOfficeCtrl', $PageOfficeCtrl->getDocumentView("PageOfficeCtrl1"));
         $this->display("Public:showEditWord");
     } else {
         if (in_array($file_extension_lower, $filesArr)) {
             $file_path = preg_replace("/^([\\s\\S]+)\\/Public/", "../Public", $info["dirname"]);
             if ('pdf' == $file_extension_lower) {
                 $file_path .= '/' . $info['filename'] . '.pdf';
                 $file_path = @iconv('UTF-8', 'GBK', $file_path);
                 import('@.ORG.OfficeOnline.OfficeOnlineView');
                 $OfficeOnlineView = new OfficeOnlineView();
                 if (!file_exists(str_replace("pdf", "swf", $file_path))) {
                     $OfficeOnlineView->pdf2swf($resource_path, str_replace("MisFileManagerPlaySWF", "MisFileManager", $info['dirname']), 1);
                 }
                 $result = 0;
             } else {
                 $result = 0;
                 $file_path .= '/pdf/' . $info['filename'] . '.pdf';
                 $file_path = @iconv('UTF-8', 'GBK', $file_path);
                 if (!file_exists($file_path)) {
                     $result = 1;
                     //调用文件IO操作,生成文件
                     $HttpSoctetIOAction = A('Http');
                     $HttpSoctetIOAction->createPDF(str_replace("MisFileManager", "MisFileManagerPlaySWF", $info['dirname']), $resource_path);
                     $file_path = str_replace("MisFileManager", "MisFileManagerPlaySWF", $file_path);
                     $file_path = str_replace("pdf", "swf", $file_path);
                 }
             }
             $this->assign('result', $result);
             $this->assign('file_name', $_REQUEST['filename']);
         }
         if (in_array($file_extension_lower, $photoArr)) {
             $file_type = "photo";
         }
         $file_path = preg_replace("/^([\\s\\S]+)\\/Public/", "__PUBLIC__", $file_path);
         $this->assign("file_type", $file_type);
         $this->assign('file_path', str_replace("pdf", "swf", $file_path));
         $this->display("Public:playswf");
     }
 }
 function playSWF()
 {
     $file_type = "file";
     $socuse = str_replace("\\", "/", base64_decode($_REQUEST['name']));
     $file_path = $resource_path = str_replace("\\", "/", UPLOAD_PATH . $socuse);
     if (!file_exists($file_path)) {
         $this->error('文件不存在!');
     }
     $info = pathinfo($file_path);
     $filesArr = C('TRANSFORM_SWF');
     $filesArr[] = 'pdf';
     $photoArr = C('IMG_file');
     $file_extension_lower = strtolower($info['extension']);
     if (in_array($file_extension_lower, $filesArr)) {
         $file_path = preg_replace("/^([\\s\\S]+)\\/Public/", "../Public", $info["dirname"]);
         $file_path .= '/swf/' . $info['filename'] . '.swf';
         $file_path = @iconv('UTF-8', 'GBK', $file_path);
         if (!file_exists($file_path)) {
             import('@.ORG.OfficeOnline.OfficeOnlineView');
             $OfficeOnlineView = new OfficeOnlineView();
             if ('pdf' == $file_extension_lower) {
                 $OfficeOnlineView->fileCreate($info['dirname'], $resource_path, 'swf');
             } else {
                 $OfficeOnlineView->fileCreate($info['dirname'], $resource_path, 'swf/pdf');
             }
         }
         $this->assign('file_name', $_REQUEST['filename']);
     }
     if (in_array($file_extension_lower, $photoArr)) {
         $file_type = "photo";
     }
     $file_path = preg_replace("/^([\\s\\S]+)\\/Public/", "__PUBLIC__", $file_path);
     $this->assign("file_type", $file_type);
     $this->assign('file_path', $file_path);
     $this->display("Public:playswf");
 }