diff --git a/plugins/ktstandard/contents/BaseIndexer.php b/plugins/ktstandard/contents/BaseIndexer.php index 3f48a7f..28640f3 100644 --- a/plugins/ktstandard/contents/BaseIndexer.php +++ b/plugins/ktstandard/contents/BaseIndexer.php @@ -141,6 +141,7 @@ class KTBaseIndexerTrigger { $cmdline[] = $sFilename; $aOptions = array(); + $aOptions['exec_wait'] = 'true'; if ($this->use_pipes) { $aOptions["append"] = $sTempFilename; } else { diff --git a/plugins/ktstandard/contents/OpenDocumentIndexer.php b/plugins/ktstandard/contents/OpenDocumentIndexer.php index 15a1108..1edf7bc 100644 --- a/plugins/ktstandard/contents/OpenDocumentIndexer.php +++ b/plugins/ktstandard/contents/OpenDocumentIndexer.php @@ -112,7 +112,10 @@ class KTOpenDocumentIndexerTrigger extends KTBaseIndexerTrigger { if (empty($sUnzipCommand)) { return; } - $this->sTmpPath = tempnam('/tmp', 'opendocumentextract'); + $oKTConfig =& KTConfig::getSingleton(); + $sBasedir = $oKTConfig->get("urls/tmpDirectory"); + + $this->sTmpPath = tempnam($sBasedir, 'opendocumentextract'); if ($this->sTmpPath === false) { return; } @@ -125,14 +128,20 @@ class KTOpenDocumentIndexerTrigger extends KTBaseIndexerTrigger { "-d", $this->sTmpPath, $sFilename, ); - KTUtil::pexec($sCmd); + KTUtil::pexec($sCmd, array('exec_wait' => 'true')); $sManifest = sprintf("%s/%s", $this->sTmpPath, "META-INF/manifest.xml"); + if (OS_WINDOWS) { + $sManifest = str_replace( '/','\\',$sManifest); + } if (!file_exists($sManifest)) { $this->cleanup(); return; } $sContentFile = sprintf("%s/%s", $this->sTmpPath, "content.xml"); + if (OS_WINDOWS) { + $sContentFile = str_replace( '/','\\',$sContentFile ); + } if (!file_exists($sContentFile)) { $this->cleanup(); return; @@ -146,7 +155,8 @@ class KTOpenDocumentIndexerTrigger extends KTBaseIndexerTrigger { } function cleanup() { - KTUtil::deleteDirectory($this->sTmpPath); + return; + //KTUtil::deleteDirectory($this->sTmpPath); } } diff --git a/plugins/ktstandard/contents/WordIndexer.php b/plugins/ktstandard/contents/WordIndexer.php index d80e915..7c1a8d7 100644 --- a/plugins/ktstandard/contents/WordIndexer.php +++ b/plugins/ktstandard/contents/WordIndexer.php @@ -45,12 +45,35 @@ class KTWordIndexerTrigger extends KTBaseIndexerTrigger { $this->command = 'c:\antiword\antiword.exe'; $this->commandconfig = 'indexer/antiword'; $this->args = array(); + } + putenv('LANG=en_US.UTF-8'); $sCommand = KTUtil::findCommand($this->commandconfig, $this->command); - $sDir = dirname(dirname($sCommand)); - putenv('HOME=' . $sDir); + if (empty($sCommand)) { + return false; + } + + if (OS_WINDOWS) { + $sDir = dirname(dirname($sCommand)); + putenv('HOME=' . $sDir); + + $cmdline = array($sCommand); + $cmdline = kt_array_merge($cmdline, $this->args); + $cmdline[] = $sFilename; + + $sCmd = KTUtil::safeShellString($cmdline); + $sCmd .= " >> " . escapeshellarg($sTempFilename); + + $sCmd = str_replace( '/','\\',$sCmd); + + $sCmd = "start /b \"kt\" " . $sCmd; + + pclose(popen($sCmd, 'r')); + + $this->aCommandOutput = 1; + $contents = file_get_contents($sTempFilename); + return $contents; } - putenv('LANG=en_US.UTF-8'); return parent::extract_contents($sFilename, $sTempFilename); }