Commit 0e8d9fede8d5403e9aeaadde022979f49954599b

Authored by conradverm
1 parent 09d73e63

KTS-2642

"Improve magicDatabase path detection"
Fixed.

Committed By: Conrad Vermeulen
Reviewed By: Megan Watson

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7981 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 32 additions and 11 deletions
config/dmsDefaults.php
... ... @@ -182,10 +182,12 @@ class KTInit {
182 182  
183 183 $oKTConfig =& KTConfig::getSingleton();
184 184  
  185 + $prefix = defined('USE_DB_ADMIN_USER')?'Admin':'';
  186 +
185 187 $dsn = array(
186 188 'phptype' => $oKTConfig->get('db/dbType'),
187   - 'username' => $oKTConfig->get('db/dbUser'),
188   - 'password' => $oKTConfig->get('db/dbPass'),
  189 + 'username' => $oKTConfig->get("db/db{$prefix}User"),
  190 + 'password' => $oKTConfig->get("db/db{$prefix}Pass"),
189 191 'hostspec' => $oKTConfig->get('db/dbHost'),
190 192 'database' => $oKTConfig->get('db/dbName'),
191 193 'port' => $oKTConfig->get('db/dbPort'),
... ... @@ -320,6 +322,25 @@ class KTInit {
320 322 }
321 323 // }}}
322 324  
  325 + static function detectMagicFile()
  326 + {
  327 + $knownPaths = array(
  328 + '/usr/share/file/magic', // the old default
  329 + '/etc/httpd/conf/magic', // fedora's location
  330 + '/etc/magic' // worst case scenario. Noticed this is sometimes empty and containing a reference to somewher else
  331 + );
  332 +
  333 + foreach($knownPaths as $path)
  334 + {
  335 + if (file_exists($path))
  336 + {
  337 + return $path;
  338 + }
  339 + }
  340 + return KT_DIR . '/config/magic';
  341 + }
  342 +
  343 +
323 344 static protected $handlerMapping = array(
324 345 E_WARNING=>PEAR_LOG_WARNING,
325 346 E_USER_WARNING=>PEAR_LOG_WARNING,
... ... @@ -360,10 +381,10 @@ function catchFatalErrors($p_OnOff='On'){
360 381 ini_set('display_errors','On');
361 382 $phperror='><div id="phperror" style="display:none">';
362 383 ini_set('error_prepend_string',$phperror);
363   -
  384 +
364 385 $phperror='</div>><form name="catcher" action="/customerrorpage.php" method="post" ><input type="hidden" name="fatal" value=""></form>
365 386 <script> document.catcher.fatal.value = document.getElementById("phperror").innerHTML; document.catcher.submit();</script>';
366   - ini_set('error_append_string',$phperror);
  387 + ini_set('error_append_string',$phperror);
367 388 }
368 389  
369 390  
... ... @@ -452,7 +473,7 @@ function catchFatalErrors($p_OnOff=&#39;On&#39;){
452 473 $oKTConfig->setdefaultns('KnowledgeTree', 'rootUrl', $this->guessRootUrl());
453 474 $oKTConfig->setdefaultns('KnowledgeTree', 'execSearchPath', $_SERVER['PATH']);
454 475 $oKTConfig->setdefaultns('KnowledgeTree', 'pathInfoSupport', false);
455   - $oKTConfig->setdefaultns('KnowledgeTree', 'magicDatabase', '/usr/share/file/magic');
  476 + $oKTConfig->setdefaultns('KnowledgeTree', 'magicDatabase', KTInit::detectMagicFile());
456 477  
457 478 $oKTConfig->setdefaultns('dashboard', 'alwaysShowYCOD', true);
458 479  
... ... @@ -612,14 +633,14 @@ require_once(KT_LIB_DIR . &#39;/ktentity.inc&#39;);
612 633 $KTInit->catchFatalErrors();
613 634  
614 635 if (phpversion()<5){
615   -
  636 +
616 637 $sErrorPage = 'http://'.$_SERVER['HTTP_HOST'].'/'.'customerrorpage.php';
617   -
  638 +
618 639 session_start();
619   -
  640 +
620 641 $_SESSION['sErrorMessage'] = 'KnowledgeTree now requires that PHP version 5 is installed. PHP version 4 is no longer supported.';
621   -
622   -
  642 +
  643 +
623 644 header('location:'. $sErrorPage ) ;
624 645  
625 646 }
... ... @@ -632,7 +653,7 @@ $KTInit-&gt;setupI18n();
632 653  
633 654 define('KTLOG_CACHE',false);
634 655  
635   -if ($GLOBALS['kt_test']) {
  656 +if (isset($GLOBALS['kt_test'])) {
636 657 $KTInit->initTesting();
637 658 }
638 659  
... ...