public static function fileOpen($path) { $file = FSI::getFile($path); $memory = MemoryManager::getInstance(); if (strtolower($file->getExtension()) == 'edoc') { $file->checkReadPermission(); //we have to extract etc etc $filepath = 'home:///'; $myFile = FSI::getFile($filepath); $myRealFile = $myFile->getRealFile(); $fileNameDestination = AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath()); $fileNameDestination .= '/.office/documents/' . ProcManager::getInstance()->getCurrentProcess()->getPid(); if (!file_exists(AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath()) . '/.office/')) { mkdir(AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath()) . '/.office/'); } else { $cmd = 'rm -fr ' . escapeshellarg(AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath()) . '/.office/documents/'); shell_exec($cmd); } mkdir(AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath()) . '/.office/documents/'); if (file_exists($fileNameDestination)) { AdvancedPathLib::rmdirs($fileNameDestination); } mkdir($fileNameDestination); $myRealFile = $file->getRealFile(); $originalFile = AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath()); $cmd = 'unzip -d ' . escapeshellarg($fileNameDestination) . ' ' . escapeshellarg($originalFile); shell_exec($cmd); if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { $isIE = true; } else { $isIE = false; } $documentUniqueId = file_get_contents($fileNameDestination . '/duid'); if (!$isIE) { $channel = '/topic/document_' . $documentUniqueId; if (!file_exists('/tmp/doc_' . basename($documentUniqueId))) { /* @todo */ //exec('nohup python ' . EYE_ROOT . '/' . APPS_DIR . '/documents/libs/listener.py ' . escapeshellarg($channel) . ' ' . escapeshellarg($fileNameDestination) . '/document.html' . ' ' . escapeshellarg($documentUniqueId). ' | at now'); DocumentsApplication::createSharedFile($channel, $fileNameDestination . '/document.html', $documentUniqueId); } else { $manager = new CometManager(); $subscriptions = $manager->getSubscriptions($channel); if (!$subscriptions) { DocumentsApplication::createSharedFile($channel, $fileNameDestination . '/document.html', $documentUniqueId); } } $content = file_get_contents('/tmp/doc_' . $documentUniqueId); $checknum = ProcManager::getInstance()->getCurrentProcess()->getChecknum(); // var_dump($checknum, $content); exit; $content = str_replace('CHECKNUM_HERE', $checknum, $content); } else { $content = file_get_contents($fileNameDestination . '/document.html'); } $return[] = $content; $return[] = $file->getName(); $return[] = $documentUniqueId; } else { $return[] = $file->getContents(); $return[] = $file->getName(); } $memory->set('currentDocument', $path); //var_dump($return);exit; return $return; }