]> git.mxchange.org Git - ctracker.git/blobdiff - libs/lib_general.php
Updated a lot:
[ctracker.git] / libs / lib_general.php
index 907b835c9cecdc20aecda771a592872ef9a5a531..8d5dd1e93ae268deb63ba850cc1d3d0b5cc8f519 100644 (file)
@@ -2,11 +2,11 @@
 /**
  * General functions library
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            3.0.0
  * @copyright  Copyright (c) 2009 - 2011 Cracker Tracker Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.org
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -73,6 +73,24 @@ if (!function_exists('implode_secure')) {
        } // END - function
 } // END - if
 
+// Load configuration, if found
+function crackerTrackerLoadConfiguration () {
+       // FQFN
+       $fqfn = sprintf('%s/config/db_config.php', $GLOBALS['ctracker_base_path']);
+
+       // Is the file readable?
+       if (!isCrackerTrackerFileFound($fqfn)) {
+               // No config file found
+               die(__FUNCTION__.': No configuration file found.');
+       } // END - if
+
+       // Load it
+       require($fqfn);
+
+       // Load email header
+       $GLOBALS['ctracker_header'] = crackerTrackerLoadEmailTemplate('header');
+}
+
 // Getter for ctracker_debug_enabled
 function isCrackerTrackerDebug () {
        // Is it set?
@@ -229,8 +247,8 @@ function isCrackerTrackerFileFound ($FQFN) {
 // Loads a given "template" (this is more an include file)
 function crackerTrackerLoadTemplate ($template) {
        // Create the full-qualified filename (FQFN)
-       $FQFN = sprintf('%s/templates/%s.tpl.php',
-               dirname(__FILE__),
+       $FQFN = sprintf('%s/libs/templates/%s.tpl.php',
+               $GLOBALS['ctracker_base_path'],
                $template
        );
 
@@ -250,8 +268,8 @@ function crackerTrackerLoadTemplate ($template) {
 // Loads a given "template" (this is more an include file)
 function crackerTrackerLoadLocalizedTemplate ($template) {
        // Create the full-qualified filename (FQFN)
-       $FQFN = sprintf('%s/templates/%s/%s.tpl.php',
-               dirname(__FILE__),
+       $FQFN = sprintf('%s/libs/templates/%s/%s.tpl.php',
+               $GLOBALS['ctracker_base_path'],
                getCrackerTrackerLanguage(),
                $template
        );
@@ -289,8 +307,8 @@ function crackerTrackerLanguage () {
        } // END - if
 
        // Construct FQFN
-       $FQFN = sprintf('%s/language/%s.php',
-               dirname(__FILE__),
+       $FQFN = sprintf('%s/libs/language/%s.php',
+               $GLOBALS['ctracker_base_path'],
                getCrackerTrackerLanguage()
        );
 
@@ -300,7 +318,7 @@ function crackerTrackerLanguage () {
                $GLOBALS['ctracker_language'] = 'en';
 
                // Construct FQFN again
-               $FQFN = sprintf('%s/language/en.php', dirname(__FILE__));
+               $FQFN = sprintf('%s/libs/language/en.php', $GLOBALS['ctracker_base_path']);
        } // END - if
 
        // Load the language file
@@ -313,8 +331,8 @@ function crackerTrackerLoadEmailTemplate ($template, array $content = array(), $
        crackerTrackerLanguage();
 
        // Generate the FQFN
-       $FQFN = sprintf('%s/mails/%s/%s.tpl',
-               dirname(__FILE__),
+       $FQFN = sprintf('%s/libs/mails/%s/%s.tpl',
+               $GLOBALS['ctracker_base_path'],
                getCrackerTrackerLanguage($language),
                $template
        );
@@ -322,10 +340,11 @@ function crackerTrackerLoadEmailTemplate ($template, array $content = array(), $
        // So is the file there?
        if (isCrackerTrackerFileFound($FQFN)) {
                // Init result
-               $result = 'No result from template ' . $template . '. Please report this at http://forum.ship-simu.org Thank you.';
+               $result = 'No result from template ' . $template . '. Please report this at http://forum.shipsimu.org Thank you.';
 
                // Then load it
-               eval('$result = "' . crackerTrackerCompileCode(file_get_contents($FQFN)) . '";');
+               //* DEBUG-DIE: */ die('<pre>$result = "' . crackerTrackerCompileCode(trim(file_get_contents($FQFN))) . '";</pre>');
+               eval('$result = "' . crackerTrackerCompileCode(trim(file_get_contents($FQFN))) . '";');
 
                // Return the result
                return $result;
@@ -483,6 +502,7 @@ function unsetCtrackerData () {
 
        // Unset all ctracker data
        foreach (array(
+                       'ctracker_base_path',
                        'ctracker_host',
                        'ctracker_dbname',
                        'ctracker_user',