├── office ├── test.docx ├── test.pptx ├── test.xlsx └── test1.doc ├── composer.json ├── .gitignore ├── README.md └── index.php /office/test.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cisiqo/WopiHost/HEAD/office/test.docx -------------------------------------------------------------------------------- /office/test.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cisiqo/WopiHost/HEAD/office/test.pptx -------------------------------------------------------------------------------- /office/test.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cisiqo/WopiHost/HEAD/office/test.xlsx -------------------------------------------------------------------------------- /office/test1.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cisiqo/WopiHost/HEAD/office/test1.doc -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "corneltek/pux": "~1.5" 4 | } 5 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Folder view configuration files 2 | # Thumbnail cache files 3 | .DS_Store 4 | ._* 5 | Thumbs.db 6 | 7 | .htaccess 8 | composer.lock 9 | /vendor 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WopiHost 2 | ======== 3 | 4 | Microsoft Office Web Apps Server preview MS files 5 | 6 | ## install pux 7 | `` $ composer install `` 8 | 9 | ## create .htaccess file like this 10 | ``` 11 | RewriteEngine On 12 | 13 | RewriteBase /WopiHost/ 14 | 15 | RewriteCond %{REQUEST_FILENAME} !-f 16 | RewriteCond %{REQUEST_FILENAME} !-d 17 | 18 | RewriteRule .* index.php/$0 [PT,L] 19 | ``` 20 | 21 | ## test wopi is correct 22 | `` http://localhost/WopiHost/files/test.docx `` 23 | 24 | if response a json data, it's ok. 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | $name, 17 | 'OwnerId' => 'admin', 18 | 'Size' => $size, 19 | 'SHA256' => $SHA256, 20 | 'Version' => '222888822' 21 | ); 22 | echo json_encode($json); 23 | } else { 24 | echo json_encode(array()); 25 | } 26 | } 27 | 28 | public function getFileAction($name) { 29 | $path = "office/$name"; 30 | if (file_exists($path)) { 31 | $handle = fopen($path, "r"); 32 | $contents = fread($handle, filesize($path)); 33 | header("Content-type: application/octet-stream"); 34 | echo $contents; 35 | } 36 | } 37 | 38 | } 39 | 40 | $mux = new Mux; 41 | 42 | $mux->get('/files/:name', ['FilesController','getFileInfoAction']); 43 | 44 | $mux->get('/files/:name/contents', ['FilesController','getFileAction']); 45 | 46 | $path = $_SERVER['PATH_INFO']; 47 | 48 | $args = explode("&", $path); 49 | 50 | $route = $mux->dispatch( $args[0] ); 51 | Executor::execute($route); 52 | --------------------------------------------------------------------------------