diff --git a/config/dmsDefaults.php b/config/dmsDefaults.php index 1cbf86f..0556027 100644 --- a/config/dmsDefaults.php +++ b/config/dmsDefaults.php @@ -182,10 +182,12 @@ class KTInit { $oKTConfig =& KTConfig::getSingleton(); + $prefix = defined('USE_DB_ADMIN_USER')?'Admin':''; + $dsn = array( 'phptype' => $oKTConfig->get('db/dbType'), - 'username' => $oKTConfig->get('db/dbUser'), - 'password' => $oKTConfig->get('db/dbPass'), + 'username' => $oKTConfig->get("db/db{$prefix}User"), + 'password' => $oKTConfig->get("db/db{$prefix}Pass"), 'hostspec' => $oKTConfig->get('db/dbHost'), 'database' => $oKTConfig->get('db/dbName'), 'port' => $oKTConfig->get('db/dbPort'), @@ -320,6 +322,25 @@ class KTInit { } // }}} + static function detectMagicFile() + { + $knownPaths = array( + '/usr/share/file/magic', // the old default + '/etc/httpd/conf/magic', // fedora's location + '/etc/magic' // worst case scenario. Noticed this is sometimes empty and containing a reference to somewher else + ); + + foreach($knownPaths as $path) + { + if (file_exists($path)) + { + return $path; + } + } + return KT_DIR . '/config/magic'; + } + + static protected $handlerMapping = array( E_WARNING=>PEAR_LOG_WARNING, E_USER_WARNING=>PEAR_LOG_WARNING, @@ -360,10 +381,10 @@ function catchFatalErrors($p_OnOff='On'){ ini_set('display_errors','On'); $phperror='>>
'; - ini_set('error_append_string',$phperror); + ini_set('error_append_string',$phperror); } @@ -452,7 +473,7 @@ function catchFatalErrors($p_OnOff='On'){ $oKTConfig->setdefaultns('KnowledgeTree', 'rootUrl', $this->guessRootUrl()); $oKTConfig->setdefaultns('KnowledgeTree', 'execSearchPath', $_SERVER['PATH']); $oKTConfig->setdefaultns('KnowledgeTree', 'pathInfoSupport', false); - $oKTConfig->setdefaultns('KnowledgeTree', 'magicDatabase', '/usr/share/file/magic'); + $oKTConfig->setdefaultns('KnowledgeTree', 'magicDatabase', KTInit::detectMagicFile()); $oKTConfig->setdefaultns('dashboard', 'alwaysShowYCOD', true); @@ -612,14 +633,14 @@ require_once(KT_LIB_DIR . '/ktentity.inc'); $KTInit->catchFatalErrors(); if (phpversion()<5){ - + $sErrorPage = 'http://'.$_SERVER['HTTP_HOST'].'/'.'customerrorpage.php'; - + session_start(); - + $_SESSION['sErrorMessage'] = 'KnowledgeTree now requires that PHP version 5 is installed. PHP version 4 is no longer supported.'; - - + + header('location:'. $sErrorPage ) ; } @@ -632,7 +653,7 @@ $KTInit->setupI18n(); define('KTLOG_CACHE',false); -if ($GLOBALS['kt_test']) { +if (isset($GLOBALS['kt_test'])) { $KTInit->initTesting(); } diff --git a/lib/mime.inc.php b/lib/mime.inc.php index dad1b44..65049a8 100644 --- a/lib/mime.inc.php +++ b/lib/mime.inc.php @@ -5,32 +5,32 @@ * KnowledgeTree Open Source Edition * Document Management Made Simple * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, * Blake Street, Observatory, 7925 South Africa. 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 + * 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. + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. * Contributor( s): ______________________________________ * */ @@ -50,15 +50,9 @@ class KTMime { function getMimeTypeID($sMimeType, $sFileName) { global $default; $sTable = KTUtil::getTableName('mimetypes'); - $lookupExtension = false; - if (in_array($sMimeType, array('application/x-zip','application/octet-stream', 'application/msword', 'text/plain'))) - { - $lookupExtension = true; - } - if ($lookupExtension || empty($sMimeType)) - { + // check by file extension $sExtension = KTMime::stripAllButExtension($sFileName); $res = DBUtil::getOneResultKey(array("SELECT id FROM " . $sTable . " WHERE LOWER(filetypes) = ?", array($sExtension)),'id'); @@ -69,7 +63,7 @@ class KTMime { else { return $res; } - } + // get the mime type id if (isset($sMimeType)) { @@ -207,12 +201,12 @@ class KTMime { function stripAllButExtension($sFileName) { return strtolower(substr($sFileName, strrpos($sFileName, ".")+1, strlen($sFileName) - strrpos($sFileName, "."))); } - + /** - * getAllMimeTypesInformation is a staic function used to get a fuller set of + * getAllMimeTypesInformation is a staic function used to get a fuller set of * information on the mime types held in the database. - * - */ + * + */ function getAllMimeTypesInformation() { $sTable = KTUtil::getTableName('mimetypes'); @@ -221,10 +215,10 @@ class KTMime { $res = DBUtil::getResultArray($aQuery); return $res; } - + /** * get all information on all the extractors in the database - * + * */ function getMimeExtractorInformation() { @@ -232,11 +226,11 @@ class KTMime { $res = DBUtil::getResultArray($aQuery); return $res; } - + /** *give the mimetype name and get the friendly names and the extensions * - */ + */ function getFriendlyNameAndExtension($sMimeType) { $sTable = KTUtil::getTableName('mimetypes');