| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * UnoconvService |
|---|
| 5 | * |
|---|
| 6 | * @author Tomasz Świenty |
|---|
| 7 | * @version 0.1 |
|---|
| 8 | * @copyright Copyright (c) eDokumenty |
|---|
| 9 | */ |
|---|
| 10 | final class UnoconvService { |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | public static function getPortNumber() { |
|---|
| 15 | |
|---|
| 16 | return 8001; |
|---|
| 17 | |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | public static function check() { |
|---|
| 23 | |
|---|
| 24 | $officePort = self::getPortNumber(); |
|---|
| 25 | $IS_WINDOWS = FALSE; |
|---|
| 26 | if (strpos(strtolower(php_uname()), 'windows') !== FALSE) { |
|---|
| 27 | $IS_WINDOWS = TRUE; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | $filePointer = fsockopen('127.0.0.1', $officePort); |
|---|
| 31 | if (!$filePointer) { |
|---|
| 32 | if ($IS_WINDOWS) { |
|---|
| 33 | popen("start \"OFFICE_SRV\" \"E:\SOFT\OpenOffice 4\program\soffice\" -headless -accept=\"socket,host=127.0.0.1,port='.$officePort.';urp;\" -nofirststartwizard", "r"); |
|---|
| 34 | } else { |
|---|
| 35 | shell_exec('libreoffice --headless --accept="socket,host=0,port='.$officePort.',tcpNoDelay=1;urp" --nodefault --nofirststartwizard --nolockcheck --nologo --norestore --invisible &'); |
|---|
| 36 | } |
|---|
| 37 | } else { |
|---|
| 38 | echo __CLASS__.'OK'; |
|---|
| 39 | } |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | if (!isset($commandLine)) { |
|---|
| 45 | UnoconvService::check(); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | ?> |
|---|