Sponsorenverwaltung - Team StarCraft e.V.
 All Data Structures Files Functions Variables
common.php
Go to the documentation of this file.
1 <?php
2  /**
3  * @file common.php
4  *
5  * @brief Does most of the include/require tasks. Links the usermanagement
6  * with the sponsormanagement
7  *
8  * @details
9  * At first the common.php takes care of basic initialisation tasks. It determines
10  * the absolute path of the whole package and provides it as a constant and creates
11  * some basic structures later used for storing error and success-messages. One of
12  * the most important task is to initialize the template enginge and the database
13  * connection used for all tasks that require the display of stored information
14  * to the user.
15  *
16  * Therefore common.php-file has the task to link the usermanagement with the
17  * sponsormanagement. This is done by including all the files that provide the
18  * functionality of each of the componenents to the other components.
19  *
20  * This file requires inc/functions.php, inc/functions_sponsoring.php,
21  * inc/functions_locks.php, inc/functions_delete.php, inc/functions_export.php,
22  * libs/usercake/config_usercake.php, libs/smarty/Smarty.class.php and inc/db.php
23  * to be present to work properly.
24  *
25  * @copyright (c) 2013, Team StarCraft e.V.
26  * @version 1.0.0
27  * @author Daniel Seichter
28  * @author Alexander Vorndran
29  * @date 02.07.2013
30  */
31 
32  // enable/disable error reporting
33  error_reporting(-1);
34  ini_set('display_errors','On');
35  //error_reporting(0);
36  //ini_set('display_errors','Off');
37 
38  //start time to calculate the duration of the script execution
39  //! holds the time the script execution started
40  $scriptDurationStartValue = microtime(TRUE);
41 
42  // enable outputbuffer to change header information
43  ob_start();
44 
45  // set local settings
46  date_default_timezone_set("Europe/Berlin");
47 
48  // define absolute path
49  //! used to get absolute path to script root
50  $absPath = str_replace('\\','/',realpath(dirname(__FILE__))).'/';
51  $absPath = str_replace('//','/',str_replace('inc','',$absPath));
52  $absPath = (is_dir($absPath)) ? $absPath : '../';
53  //! holds the absolute path to script root
54  define('ABS_PATH', $absPath);
55 
56  // includes files
57  require_once(ABS_PATH."inc/functions.php");
58  require_once(ABS_PATH."inc/functions_sponsoring.php");
59  require_once(ABS_PATH."inc/functions_locks.php");
60  require_once(ABS_PATH."inc/functions_delete.php");
61  require_once(ABS_PATH."inc/functions_export.php");
62  // includes usercake files
63  require_once(ABS_PATH.'/libs/usercake/config_usercake.php');
64  // includes smarty files
65  require_once(ABS_PATH.'libs/smarty/Smarty.class.php');
66  // includes database files
67  require_once(ABS_PATH.'inc/db.php');
68 
69 
70  //! holds the error messages that occurred
71  $errors = array();
72 
73  //! holds the success messages that occurred
74  $successes = array();
75 
76  // init smarty
77  //! holds the template engine object
78  $smarty = new Smarty;
79 
80  //! This mysqli object is used all over the whole website to access the database
82  if (mysqli_connect_errno() != 0) {
83  $errorTextArray = array(mysqli_connect_error());
84  exitWithErrorTemplate($errorTextArray);
85  }
86  // set the charset to avoid encoding problems
87  $mysqli->set_charset("utf8");
88 
89 
90  /// @cond MAINPART
91  // set some smarty options
92  $smarty->template_dir = ABS_PATH.'inc/templates';
93  $smarty->compile_dir = ABS_PATH.'inc/templates_c';
94  $smarty->config_dir = ABS_PATH.'config';
95  $smarty->cache_dir = ABS_PATH.'cache';
96  $smarty->clearCompiledTemplate();
97 
98  // assign some global usercake template vars
99  $smarty->assign('isLoggedIn', isUserLoggedIn());
100  // if the user is logged in assign his information to personalize the website
101  if(isUserLoggedIn()) {
102  $smarty->assign('ownUserName', $loggedInUser->username);
103  $smarty->assign('isUserAdministrator', isUserAdministrator());
104  $smarty->assign('isUserRoot', isUserRoot());
105  $smarty->assign('ownUserId',$loggedInUser->userId);
106  if(hasOnetimePassword($loggedInUser->userId)) {
107  $smarty->assign('changePassword', true);
108  }
109  }
110 
111  /// @endcond
112 ?>