diff --git a/search2/bin/cronCleanup.php b/search2/bin/cronCleanup.php new file mode 100644 index 0000000..198be1e --- /dev/null +++ b/search2/bin/cronCleanup.php @@ -0,0 +1,71 @@ +. + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * California 94120-7775, or email info@knowledgetree.com. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "Powered by + * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. + * Contributor( s): ______________________________________ + * + */ + +chdir(dirname(__FILE__)); +require_once(realpath('../../config/dmsDefaults.php')); + +$config = KTConfig::getSingleton(); +$temp_dir =$config->get("urls/tmpDirectory"); + + +cleanupTempDirectory($temp_dir); + +function cleanupTempDirectory($dir) +{ + if (!is_dir($dir)) + { + return; + } + $dir = str_replace('\\','/', $dir); + + $dh = opendir($dir); + while (($name = readdir($dh)) !== false) + { + if (substr($name, 0, 9) != 'ktindexer') + { + continue; + } + unlink($dir . '/' . $name); + } + closedir($dh); +} + + + +?> \ No newline at end of file diff --git a/search2/indexing/extractorCore.inc.php b/search2/indexing/extractorCore.inc.php index 8b02f6a..2c5808c 100644 --- a/search2/indexing/extractorCore.inc.php +++ b/search2/indexing/extractorCore.inc.php @@ -654,6 +654,7 @@ abstract class CompositeExtractor extends DocumentExtractor } @unlink($intermediateFile); + $this->setTargetFile($this->targetExtractor->getTargetFile()); return $result; } diff --git a/search2/indexing/extractors/OOTextExtractor.inc.php b/search2/indexing/extractors/OOTextExtractor.inc.php index c26b7b4..4850184 100644 --- a/search2/indexing/extractors/OOTextExtractor.inc.php +++ b/search2/indexing/extractors/OOTextExtractor.inc.php @@ -132,6 +132,9 @@ class OOTextExtractor extends ExternalDocumentExtractor return true; } $content = file_get_contents($this->targetfile); + + $this->setTargetFile($this->targetfile . '.txt'); + return file_put_contents($this->targetfile, $this->filter($content)); } diff --git a/search2/indexing/extractors/PDFExtractor.inc.php b/search2/indexing/extractors/PDFExtractor.inc.php index 89157bb..a4640ff 100644 --- a/search2/indexing/extractors/PDFExtractor.inc.php +++ b/search2/indexing/extractors/PDFExtractor.inc.php @@ -73,6 +73,18 @@ class PDFExtractor extends ApplicationExtractor return true; } + if (false === $res && (strpos($this->output, 'font') !== false)) + { + $this->output = ''; + return true; + } + + if (filesize($this->targetfile) > 0) + { + $this->output = ''; + return true; + } + return $res; } diff --git a/sql/mysql/install/data.sql b/sql/mysql/install/data.sql index a94d388..c4b139f 100644 --- a/sql/mysql/install/data.sql +++ b/sql/mysql/install/data.sql @@ -809,7 +809,9 @@ INSERT INTO `scheduler_tasks` VALUES (3,'Index Optimisation','search2/bin/optimise.php','',0,'weekly','2007-10-01',NULL,0,'system'), (4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled'), (5,'Database Maintenance','bin/dbmaint.php','optimize',0,'monthly','2007-10-01',NULL,0,'disabled'), -(6,'Open Office test','bin/checkopenoffice.php','',0,'1min','2007-10-01',NULL,0,'enabled'); +(6,'Open Office test','bin/checkopenoffice.php','',0,'1min','2007-10-01',NULL,0,'enabled'), +(7,'Cleanup Temporary Directory','search2/bin/cronCleanup.php','',0,'1min','2007-10-01',NULL,0,'enabled'); + /*!40000 ALTER TABLE `scheduler_tasks` ENABLE KEYS */; UNLOCK TABLES; @@ -984,7 +986,8 @@ INSERT INTO `upgrades` VALUES (1,'sql*2.0.6*0*2.0.6/create_upgrade_table.sql','D (176,'sql*3.5.2*0*3.5.2/clean_plugin_helper.sql','Clean out the plugin helper table.','2007-11-21 00:00:00',1,'upgrade*3.5.2*99*upgrade3.5.2'), (177,'sql*3.5.2*0*3.5.2/openxml_mime_types.sql','Add the OpenXML mimetypes.','2007-11-21 00:00:00',1,'upgrade*3.5.2*99*upgrade3.5.2'), (178,'sql*3.5.2*0*3.5.2/rss_plugin_title.sql','Increase size of RSS Title.','2007-11-21 00:00:00',1,'upgrade*3.5.2*99*upgrade3.5.2'), -(179,'upgrade*3.5.2*99*upgrade3.5.2','Upgrade from version 3.5.1 to 3.5.2','2007-11-21 00:00:00',1,'upgrade*3.5.2*99*upgrade3.5.2'); +(179,'sql*3.5.2*0*3.5.2/temp_cleanup.sql','Adds background script to clean up temporary index files.','2007-11-21 00:00:00',1,'upgrade*3.5.2*99*upgrade3.5.2'), +(180,'upgrade*3.5.2*99*upgrade3.5.2','Upgrade from version 3.5.1 to 3.5.2','2007-11-21 00:00:00',1,'upgrade*3.5.2*99*upgrade3.5.2'); /*!40000 ALTER TABLE `upgrades` ENABLE KEYS */; UNLOCK TABLES; @@ -1722,7 +1725,7 @@ UNLOCK TABLES; LOCK TABLES `zseq_scheduler_tasks` WRITE; /*!40000 ALTER TABLE `zseq_scheduler_tasks` DISABLE KEYS */; -INSERT INTO `zseq_scheduler_tasks` VALUES (6); +INSERT INTO `zseq_scheduler_tasks` VALUES (7); /*!40000 ALTER TABLE `zseq_scheduler_tasks` ENABLE KEYS */; UNLOCK TABLES; @@ -1811,7 +1814,7 @@ UNLOCK TABLES; LOCK TABLES `zseq_upgrades` WRITE; /*!40000 ALTER TABLE `zseq_upgrades` DISABLE KEYS */; -INSERT INTO `zseq_upgrades` VALUES (179); +INSERT INTO `zseq_upgrades` VALUES (180); /*!40000 ALTER TABLE `zseq_upgrades` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/mysql/upgrade/3.5.2/temp_cleanup.sql b/sql/mysql/upgrade/3.5.2/temp_cleanup.sql new file mode 100644 index 0000000..1dbc8c5 --- /dev/null +++ b/sql/mysql/upgrade/3.5.2/temp_cleanup.sql @@ -0,0 +1,4 @@ +select @id:=ifnull(max(id),0)+1 from scheduler_tasks; +INSERT INTO `scheduler_tasks` VALUES (@id,'Cleanup Temporary Directory','search2/bin/cronCleanup.php','',0,'1min','2007-10-01',NULL,0,'enabled'); + +UPDATE zseq_scheduler_tasks set id=@id; \ No newline at end of file