Commit 67f92c0396753fe1e87b592d3646d5cea8bfd35c
1 parent
cfc0ba99
KTS-2859
"Unable to upload files in Windows XP and Windows 2003 - seemingly an MS Word issue only." Fixed. Added a batch file to call antiword.exe, should prevent the browser from hanging. Committed by: Megan Watson Reviewed by: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.4.6-Release-Branch@7937 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
51 additions
and
17 deletions
bin/exec_files.bat
0 → 100755
lib/util/ktutil.inc
| ... | ... | @@ -185,7 +185,7 @@ class KTUtil { |
| 185 | 185 | } else { |
| 186 | 186 | $sCmd = $aCmd; |
| 187 | 187 | } |
| 188 | - | |
| 188 | + | |
| 189 | 189 | $sAppend = KTUtil::arrayGet($aOptions, 'append'); |
| 190 | 190 | if ($sAppend) { |
| 191 | 191 | $sCmd .= " >> " . escapeshellarg($sAppend); |
| ... | ... | @@ -207,16 +207,26 @@ class KTUtil { |
| 207 | 207 | $iRet = ''; |
| 208 | 208 | |
| 209 | 209 | if(OS_WINDOWS){ |
| 210 | - $sCmd = 'call '.$sCmd; | |
| 210 | + $wait = false; | |
| 211 | + if(isset($aOptions['exec_wait']) && ($aOptions['exec_wait'] == 'true')){ | |
| 212 | + $wait = true; | |
| 213 | + } | |
| 214 | + | |
| 215 | + $WshShell = new COM("WScript.Shell"); | |
| 216 | + $res = $WshShell->Run($sCmd, 0, $wait); | |
| 217 | + | |
| 218 | + $iRet = 0; | |
| 219 | + $aOutput = array($res); | |
| 220 | + }else{ | |
| 221 | + exec($sCmd, $aOutput, $iRet); | |
| 211 | 222 | } |
| 212 | - exec($sCmd, $aOutput, $iRet); | |
| 213 | 223 | |
| 214 | 224 | $aRet['ret'] = $iRet; |
| 215 | 225 | $aRet['out'] = $aOutput; |
| 216 | 226 | return $aRet; |
| 217 | 227 | } |
| 218 | 228 | // }}} |
| 219 | - | |
| 229 | + | |
| 220 | 230 | // {{{ winexec |
| 221 | 231 | /** |
| 222 | 232 | * Execute a command on a windows platform. | ... | ... |
plugins/ktstandard/contents/WordIndexer.php
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
| 7 | 7 | * compliance with the License. You may obtain a copy of the License at |
| 8 | 8 | * http://www.knowledgetree.com/KPL |
| 9 | - * | |
| 9 | + * | |
| 10 | 10 | * Software distributed under the License is distributed on an "AS IS" |
| 11 | 11 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
| 12 | 12 | * See the License for the specific language governing rights and |
| ... | ... | @@ -17,9 +17,9 @@ |
| 17 | 17 | * (ii) the KnowledgeTree copyright notice |
| 18 | 18 | * in the same form as they appear in the distribution. See the License for |
| 19 | 19 | * requirements. |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * The Original Code is: KnowledgeTree Open Source |
| 22 | - * | |
| 22 | + * | |
| 23 | 23 | * The Initial Developer of the Original Code is The Jam Warehouse Software |
| 24 | 24 | * (Pty) Ltd, trading as KnowledgeTree. |
| 25 | 25 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright |
| ... | ... | @@ -39,9 +39,9 @@ class KTWordIndexerTrigger extends KTBaseIndexerTrigger { |
| 39 | 39 | var $commandconfig = 'indexer/catdoc'; // could be any application. |
| 40 | 40 | var $args = array("-w", "-d", "UTF-8"); |
| 41 | 41 | var $use_pipes = true; |
| 42 | - | |
| 42 | + | |
| 43 | 43 | function extract_contents($sFilename, $sTempFilename) { |
| 44 | - if (OS_WINDOWS) { | |
| 44 | + if (OS_WINDOWS) { | |
| 45 | 45 | $this->command = 'c:\antiword\antiword.exe'; |
| 46 | 46 | $this->commandconfig = 'indexer/antiword'; |
| 47 | 47 | $this->args = array(); |
| ... | ... | @@ -52,32 +52,55 @@ class KTWordIndexerTrigger extends KTBaseIndexerTrigger { |
| 52 | 52 | if (empty($sCommand)) { |
| 53 | 53 | return false; |
| 54 | 54 | } |
| 55 | - | |
| 56 | - if (OS_WINDOWS) { | |
| 55 | + | |
| 56 | + if (OS_WINDOWS) { | |
| 57 | 57 | $sDir = dirname(dirname($sCommand)); |
| 58 | - putenv('HOME=' . $sDir); | |
| 58 | + putenv('HOME=' . $sDir); | |
| 59 | + $sBatDir = KT_DIR.'\bin\exec_files.bat'; | |
| 60 | + | |
| 61 | + $cmdline = array($sCommand); | |
| 62 | + $cmdline = kt_array_merge($cmdline, $this->args); | |
| 63 | + | |
| 64 | + $sCmd_1 = KTUtil::safeShellString($cmdline); | |
| 65 | + $sCmd_2 = escapeshellarg($sFilename); | |
| 66 | + $sCmd_3 = escapeshellarg($sTempFilename); | |
| 67 | + | |
| 68 | + $sCmd_1 = str_replace( '/','\\',$sCmd_1); | |
| 69 | + $sCmd_2 = str_replace( '/','\\',$sCmd_2); | |
| 70 | + $sCmd_3 = str_replace( '/','\\',$sCmd_3); | |
| 71 | + | |
| 72 | + $iRet = ''; | |
| 73 | + | |
| 74 | + $sBat = '"'.$sBatDir.'" '.$sCmd_1.' '.$sCmd_2.' '.$sCmd_3; | |
| 75 | + $sBat = str_replace( '/','\\',$sBat); | |
| 76 | + | |
| 77 | + $WshShell = new COM("WScript.Shell"); | |
| 78 | + $res = $WshShell->Run($sBat, 0, true); | |
| 79 | + | |
| 80 | + $contents = file_get_contents($sTempFilename); | |
| 81 | + return $contents; | |
| 59 | 82 | } |
| 60 | 83 | return parent::extract_contents($sFilename, $sTempFilename); |
| 61 | 84 | } |
| 62 | - | |
| 85 | + | |
| 63 | 86 | function findLocalCommand() { |
| 64 | 87 | if (OS_WINDOWS) { |
| 65 | 88 | $this->command = 'c:\antiword\antiword.exe'; |
| 66 | 89 | $this->commandconfig = 'indexer/antiword'; |
| 67 | 90 | $this->args = array(); |
| 68 | - } | |
| 91 | + } | |
| 69 | 92 | $sCommand = KTUtil::findCommand($this->commandconfig, $this->command); |
| 70 | 93 | return $sCommand; |
| 71 | 94 | } |
| 72 | - | |
| 95 | + | |
| 73 | 96 | function getDiagnostic() { |
| 74 | 97 | $sCommand = $this->findLocalCommand(); |
| 75 | - | |
| 98 | + | |
| 76 | 99 | // can't find the local command. |
| 77 | 100 | if (empty($sCommand)) { |
| 78 | 101 | return sprintf(_kt('Unable to find required command for indexing. Please ensure that <strong>%s</strong> is installed and in the %s Path. For more information on indexers and helper applications, please <a href="%s">visit the %s site</a>.'), $this->command, APP_NAME, $this->support_url, APP_NAME); |
| 79 | 102 | } |
| 80 | - | |
| 103 | + | |
| 81 | 104 | return null; |
| 82 | 105 | } |
| 83 | 106 | } | ... | ... |