Commit 17ff539ead80bb92c7782e015cc82906aa1f8824

Authored by Conrad Vermeulen
1 parent 219fba2f

KTS-3350

"When installing stack as root, OpenOffice stores files as root in the KT temp folder. The indexing scripts cannot clean these up."
Fixed.

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@8448 c91229c3-7414-0410-bfa2-8a42b809f60b
search2/bin/cronCleanup.php 0 → 100644
  1 +<?php
  2 +
  3 +/**
  4 + * $Id:$
  5 + *
  6 + * KnowledgeTree Community Edition
  7 + * Document Management Made Simple
  8 + * Copyright (C) 2008 KnowledgeTree Inc.
  9 + * Portions copyright The Jam Warehouse Software (Pty) Limited
  10 + *
  11 + * This program is free software; you can redistribute it and/or modify it under
  12 + * the terms of the GNU General Public License version 3 as published by the
  13 + * Free Software Foundation.
  14 + *
  15 + * This program is distributed in the hope that it will be useful, but WITHOUT
  16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  18 + * details.
  19 + *
  20 + * You should have received a copy of the GNU General Public License
  21 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22 + *
  23 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  24 + * California 94120-7775, or email info@knowledgetree.com.
  25 + *
  26 + * The interactive user interfaces in modified source and object code versions
  27 + * of this program must display Appropriate Legal Notices, as required under
  28 + * Section 5 of the GNU General Public License version 3.
  29 + *
  30 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  31 + * these Appropriate Legal Notices must retain the display of the "Powered by
  32 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  33 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  34 + * must display the words "Powered by KnowledgeTree" and retain the original
  35 + * copyright notice.
  36 + * Contributor( s): ______________________________________
  37 + *
  38 + */
  39 +
  40 +chdir(dirname(__FILE__));
  41 +require_once(realpath('../../config/dmsDefaults.php'));
  42 +
  43 +$config = KTConfig::getSingleton();
  44 +$temp_dir =$config->get("urls/tmpDirectory");
  45 +
  46 +
  47 +cleanupTempDirectory($temp_dir);
  48 +
  49 +function cleanupTempDirectory($dir)
  50 +{
  51 + if (!is_dir($dir))
  52 + {
  53 + return;
  54 + }
  55 + $dir = str_replace('\\','/', $dir);
  56 +
  57 + $dh = opendir($dir);
  58 + while (($name = readdir($dh)) !== false)
  59 + {
  60 + if (substr($name, 0, 9) != 'ktindexer')
  61 + {
  62 + continue;
  63 + }
  64 + unlink($dir . '/' . $name);
  65 + }
  66 + closedir($dh);
  67 +}
  68 +
  69 +
  70 +
  71 +?>
0 72 \ No newline at end of file
... ...
search2/indexing/extractorCore.inc.php
... ... @@ -7,31 +7,31 @@
7 7 * Document Management Made Simple
8 8 * Copyright (C) 2008 KnowledgeTree Inc.
9 9 * Portions copyright The Jam Warehouse Software (Pty) Limited
10   - *
  10 + *
11 11 * This program is free software; you can redistribute it and/or modify it under
12 12 * the terms of the GNU General Public License version 3 as published by the
13 13 * Free Software Foundation.
14   - *
  14 + *
15 15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 18 * details.
19   - *
  19 + *
20 20 * You should have received a copy of the GNU General Public License
21 21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22   - *
23   - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  22 + *
  23 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
24 24 * California 94120-7775, or email info@knowledgetree.com.
25   - *
  25 + *
26 26 * The interactive user interfaces in modified source and object code versions
27 27 * of this program must display Appropriate Legal Notices, as required under
28 28 * Section 5 of the GNU General Public License version 3.
29   - *
  29 + *
30 30 * In accordance with Section 7(b) of the GNU General Public License version 3,
31 31 * these Appropriate Legal Notices must retain the display of the "Powered by
32   - * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
33 33 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
34   - * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * must display the words "Powered by KnowledgeTree" and retain the original
35 35 * copyright notice.
36 36 * Contributor( s): ______________________________________
37 37 *
... ... @@ -655,6 +655,7 @@ abstract class CompositeExtractor extends DocumentExtractor
655 655 }
656 656  
657 657 @unlink($intermediateFile);
  658 + $this->setTargetFile($this->targetExtractor->getTargetFile());
658 659  
659 660 return $result;
660 661 }
... ...
search2/indexing/extractors/OOTextExtractor.inc.php
... ... @@ -7,31 +7,31 @@
7 7 * Document Management Made Simple
8 8 * Copyright (C) 2008 KnowledgeTree Inc.
9 9 * Portions copyright The Jam Warehouse Software (Pty) Limited
10   - *
  10 + *
11 11 * This program is free software; you can redistribute it and/or modify it under
12 12 * the terms of the GNU General Public License version 3 as published by the
13 13 * Free Software Foundation.
14   - *
  14 + *
15 15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 18 * details.
19   - *
  19 + *
20 20 * You should have received a copy of the GNU General Public License
21 21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22   - *
23   - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  22 + *
  23 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
24 24 * California 94120-7775, or email info@knowledgetree.com.
25   - *
  25 + *
26 26 * The interactive user interfaces in modified source and object code versions
27 27 * of this program must display Appropriate Legal Notices, as required under
28 28 * Section 5 of the GNU General Public License version 3.
29   - *
  29 + *
30 30 * In accordance with Section 7(b) of the GNU General Public License version 3,
31 31 * these Appropriate Legal Notices must retain the display of the "Powered by
32   - * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
33 33 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
34   - * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * must display the words "Powered by KnowledgeTree" and retain the original
35 35 * copyright notice.
36 36 * Contributor( s): ______________________________________
37 37 *
... ... @@ -133,6 +133,9 @@ class OOTextExtractor extends ExternalDocumentExtractor
133 133 return true;
134 134 }
135 135 $content = file_get_contents($this->targetfile);
  136 +
  137 + $this->setTargetFile($this->targetfile . '.txt');
  138 +
136 139 return file_put_contents($this->targetfile, $this->filter($content));
137 140  
138 141 }
... ...
search2/indexing/extractors/PDFExtractor.inc.php
... ... @@ -7,31 +7,31 @@
7 7 * Document Management Made Simple
8 8 * Copyright (C) 2008 KnowledgeTree Inc.
9 9 * Portions copyright The Jam Warehouse Software (Pty) Limited
10   - *
  10 + *
11 11 * This program is free software; you can redistribute it and/or modify it under
12 12 * the terms of the GNU General Public License version 3 as published by the
13 13 * Free Software Foundation.
14   - *
  14 + *
15 15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 18 * details.
19   - *
  19 + *
20 20 * You should have received a copy of the GNU General Public License
21 21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22   - *
23   - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  22 + *
  23 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
24 24 * California 94120-7775, or email info@knowledgetree.com.
25   - *
  25 + *
26 26 * The interactive user interfaces in modified source and object code versions
27 27 * of this program must display Appropriate Legal Notices, as required under
28 28 * Section 5 of the GNU General Public License version 3.
29   - *
  29 + *
30 30 * In accordance with Section 7(b) of the GNU General Public License version 3,
31 31 * these Appropriate Legal Notices must retain the display of the "Powered by
32   - * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
33 33 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
34   - * must display the words "Powered by KnowledgeTree" and retain the original
  34 + * must display the words "Powered by KnowledgeTree" and retain the original
35 35 * copyright notice.
36 36 * Contributor( s): ______________________________________
37 37 *
... ... @@ -74,6 +74,18 @@ class PDFExtractor extends ApplicationExtractor
74 74 return true;
75 75 }
76 76  
  77 + if (false === $res && (strpos($this->output, 'font') !== false))
  78 + {
  79 + $this->output = '';
  80 + return true;
  81 + }
  82 +
  83 + if (filesize($this->targetfile) > 0)
  84 + {
  85 + $this->output = '';
  86 + return true;
  87 + }
  88 +
77 89 return $res;
78 90  
79 91 }
... ...
sql/mysql/install/data.sql
... ... @@ -5,31 +5,31 @@
5 5 -- Document Management Made Simple
6 6 -- Copyright (C) 2008 KnowledgeTree Inc.
7 7 -- Portions copyright The Jam Warehouse Software (Pty) Limited
8   ---
  8 +--
9 9 -- This program is free software; you can redistribute it and/or modify it under
10 10 -- the terms of the GNU General Public License version 3 as published by the
11 11 -- Free Software Foundation.
12   ---
  12 +--
13 13 -- This program is distributed in the hope that it will be useful, but WITHOUT
14 14 -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 15 -- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 16 -- details.
17   ---
  17 +--
18 18 -- You should have received a copy of the GNU General Public License
19 19 -- along with this program. If not, see <http://www.gnu.org/licenses/>.
20   ---
21   --- You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  20 +--
  21 +-- You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
22 22 -- California 94120-7775, or email info@knowledgetree.com.
23   ---
  23 +--
24 24 -- The interactive user interfaces in modified source and object code versions
25 25 -- of this program must display Appropriate Legal Notices, as required under
26 26 -- Section 5 of the GNU General Public License version 3.
27   ---
  27 +--
28 28 -- In accordance with Section 7(b) of the GNU General Public License version 3,
29 29 -- these Appropriate Legal Notices must retain the display of the "Powered by
30   --- KnowledgeTree" logo and retain the original copyright notice. If the display of the
  30 +-- KnowledgeTree" logo and retain the original copyright notice. If the display of the
31 31 -- logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
32   --- must display the words "Powered by KnowledgeTree" and retain the original
  32 +-- must display the words "Powered by KnowledgeTree" and retain the original
33 33 -- copyright notice.
34 34 -- Contributor( s): ______________________________________
35 35 --
... ... @@ -813,7 +813,9 @@ INSERT INTO `scheduler_tasks` VALUES
813 813 (3,'Index Optimisation','search2/bin/optimise.php','',0,'weekly','2007-10-01',NULL,0,'system'),
814 814 (4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled'),
815 815 (5,'Database Maintenance','bin/dbmaint.php','optimize',0,'monthly','2007-10-01',NULL,0,'disabled'),
816   -(6,'Open Office test','bin/checkopenoffice.php','',0,'1min','2007-10-01',NULL,0,'enabled');
  816 +(6,'Open Office test','bin/checkopenoffice.php','',0,'1min','2007-10-01',NULL,0,'enabled'),
  817 +(7,'Cleanup Temporary Directory','search2/bin/cronCleanup.php','',0,'1min','2007-10-01',NULL,0,'enabled');
  818 +
817 819 /*!40000 ALTER TABLE `scheduler_tasks` ENABLE KEYS */;
818 820 UNLOCK TABLES;
819 821  
... ... @@ -988,7 +990,8 @@ INSERT INTO `upgrades` VALUES (1,&#39;sql*2.0.6*0*2.0.6/create_upgrade_table.sql&#39;,&#39;D
988 990 (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'),
989 991 (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'),
990 992 (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'),
991   -(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');
  993 +(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'),
  994 +(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');
992 995 /*!40000 ALTER TABLE `upgrades` ENABLE KEYS */;
993 996 UNLOCK TABLES;
994 997  
... ... @@ -1726,7 +1729,7 @@ UNLOCK TABLES;
1726 1729  
1727 1730 LOCK TABLES `zseq_scheduler_tasks` WRITE;
1728 1731 /*!40000 ALTER TABLE `zseq_scheduler_tasks` DISABLE KEYS */;
1729   -INSERT INTO `zseq_scheduler_tasks` VALUES (6);
  1732 +INSERT INTO `zseq_scheduler_tasks` VALUES (7);
1730 1733 /*!40000 ALTER TABLE `zseq_scheduler_tasks` ENABLE KEYS */;
1731 1734 UNLOCK TABLES;
1732 1735  
... ... @@ -1815,7 +1818,7 @@ UNLOCK TABLES;
1815 1818  
1816 1819 LOCK TABLES `zseq_upgrades` WRITE;
1817 1820 /*!40000 ALTER TABLE `zseq_upgrades` DISABLE KEYS */;
1818   -INSERT INTO `zseq_upgrades` VALUES (179);
  1821 +INSERT INTO `zseq_upgrades` VALUES (180);
1819 1822 /*!40000 ALTER TABLE `zseq_upgrades` ENABLE KEYS */;
1820 1823 UNLOCK TABLES;
1821 1824  
... ...
sql/mysql/upgrade/3.5.2/temp_cleanup.sql 0 → 100644
  1 +select @id:=ifnull(max(id),0)+1 from scheduler_tasks;
  2 +INSERT INTO `scheduler_tasks` VALUES (@id,'Cleanup Temporary Directory','search2/bin/cronCleanup.php','',0,'1min','2007-10-01',NULL,0,'enabled');
  3 +
  4 +UPDATE zseq_scheduler_tasks set id=@id;
0 5 \ No newline at end of file
... ...