| 1 | 1379 | Luisehahne | <?php
 | 
      
        | 2 |  |  | /**
 | 
      
        | 3 |  |  |  *
 | 
      
        | 4 | 1529 | Luisehahne |  * @category        framewotk
 | 
      
        | 5 |  |  |  * @package         backend admin
 | 
      
        | 6 |  |  |  * @author          Ryan Djurovich, WebsiteBaker Project
 | 
      
        | 7 | 1700 | Luisehahne |  * @copyright       2009-2012, WebsiteBaker Org. e.V.
 | 
      
        | 8 | 1379 | Luisehahne |  * @link			http://www.websitebaker2.org/
 | 
      
        | 9 |  |  |  * @license         http://www.gnu.org/licenses/gpl.html
 | 
      
        | 10 |  |  |  * @platform        WebsiteBaker 2.8.x
 | 
      
        | 11 |  |  |  * @requirements    PHP 5.2.2 and higher
 | 
      
        | 12 |  |  |  * @version         $Id$
 | 
      
        | 13 |  |  |  * @filesource		$HeadURL$
 | 
      
        | 14 |  |  |  * @lastmodified    $Date$
 | 
      
        | 15 |  |  |  *
 | 
      
        | 16 |  |  |  */
 | 
      
        | 17 | 1496 | DarkViper | /* -------------------------------------------------------- */
 | 
      
        | 18 |  |  | // Must include code to stop this file being accessed directly
 | 
      
        | 19 | 1499 | DarkViper | if(!defined('WB_PATH')) {
 | 
      
        | 20 |  |  | 	require_once(dirname(__FILE__).'/globalExceptionHandler.php');
 | 
      
        | 21 |  |  | 	throw new IllegalFileException();
 | 
      
        | 22 |  |  | }
 | 
      
        | 23 | 1496 | DarkViper | /* -------------------------------------------------------- */
 | 
      
        | 24 | 1379 | Luisehahne | require_once(WB_PATH.'/framework/class.wb.php');
 | 
      
        | 25 |  |  | 
 | 
      
        | 26 |  |  | // Get WB version
 | 
      
        | 27 |  |  | require_once(ADMIN_PATH.'/interface/version.php');
 | 
      
        | 28 |  |  | 
 | 
      
        | 29 |  |  | // Include EditArea wrapper functions
 | 
      
        | 30 | 1428 | Luisehahne | // require_once(WB_PATH . '/include/editarea/wb_wrapper_edit_area.php');
 | 
      
        | 31 | 1462 | DarkViper | //require_once(WB_PATH . '/framework/SecureForm.php');
 | 
      
        | 32 | 1379 | Luisehahne | 
 | 
      
        | 33 |  |  | 
 | 
      
        | 34 | 1684 | Luisehahne | /**
 | 
      
        | 35 |  |  |  * admin
 | 
      
        | 36 |  |  |  *
 | 
      
        | 37 |  |  |  * @package
 | 
      
        | 38 |  |  |  * @copyright
 | 
      
        | 39 |  |  |  * @version 2012
 | 
      
        | 40 |  |  |  * @access public
 | 
      
        | 41 |  |  |  */
 | 
      
        | 42 | 1379 | Luisehahne | class admin extends wb {
 | 
      
        | 43 |  |  | 	// Authenticate user then auto print the header
 | 
      
        | 44 | 1684 | Luisehahne | 	/**
 | 
      
        | 45 |  |  | 	 * admin::__construct()
 | 
      
        | 46 |  |  | 	 *
 | 
      
        | 47 |  |  | 	 * @param string $section_name
 | 
      
        | 48 |  |  | 	 * @param string $section_permission
 | 
      
        | 49 |  |  | 	 * @param bool $auto_header
 | 
      
        | 50 |  |  | 	 * @param bool $auto_auth
 | 
      
        | 51 |  |  | 	 * @return void
 | 
      
        | 52 |  |  | 	 */
 | 
      
        | 53 | 1379 | Luisehahne | 	public function __construct($section_name= '##skip##', $section_permission = 'start', $auto_header = true, $auto_auth = true)
 | 
      
        | 54 |  |  | 	{
 | 
      
        | 55 |  |  | 		parent::__construct(SecureForm::BACKEND);
 | 
      
        | 56 |  |  | 	if( $section_name != '##skip##' )
 | 
      
        | 57 |  |  | 	{
 | 
      
        | 58 |  |  | 		global $database, $MESSAGE;
 | 
      
        | 59 |  |  | 		// Specify the current applications name
 | 
      
        | 60 |  |  | 		$this->section_name = $section_name;
 | 
      
        | 61 |  |  | 		$this->section_permission = $section_permission;
 | 
      
        | 62 |  |  | 		// Authenticate the user for this application
 | 
      
        | 63 |  |  | 		if($auto_auth == true)
 | 
      
        | 64 |  |  | 		{
 | 
      
        | 65 |  |  | 			// First check if the user is logged-in
 | 
      
        | 66 |  |  | 			if($this->is_authenticated() == false)
 | 
      
        | 67 |  |  | 			{
 | 
      
        | 68 |  |  | 				header('Location: '.ADMIN_URL.'/login/index.php');
 | 
      
        | 69 |  |  | 				exit(0);
 | 
      
        | 70 |  |  | 			}
 | 
      
        | 71 |  |  | 
 | 
      
        | 72 |  |  | 			// Now check if they are allowed in this section
 | 
      
        | 73 |  |  | 			if($this->get_permission($section_permission) == false) {
 | 
      
        | 74 | 1700 | Luisehahne | 				die($MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES']);
 | 
      
        | 75 | 1379 | Luisehahne | 			}
 | 
      
        | 76 |  |  | 		}
 | 
      
        | 77 |  |  | 
 | 
      
        | 78 |  |  | 		// Check if the backend language is also the selected language. If not, send headers again.
 | 
      
        | 79 | 1486 | DarkViper | 		$sql  = 'SELECT `language` FROM `'.TABLE_PREFIX.'users` ';
 | 
      
        | 80 |  |  | 		$sql .= 'WHERE `user_id`='.(int)$this->get_user_id();
 | 
      
        | 81 |  |  | 		$get_user_language = @$database->query($sql);
 | 
      
        | 82 | 1379 | Luisehahne | 		$user_language = ($get_user_language) ? $get_user_language->fetchRow() : '';
 | 
      
        | 83 |  |  | 		// prevent infinite loop if language file is not XX.php (e.g. DE_du.php)
 | 
      
        | 84 |  |  | 		$user_language = substr($user_language[0],0,2);
 | 
      
        | 85 |  |  | 		// obtain the admin folder (e.g. /admin)
 | 
      
        | 86 |  |  | 		$admin_folder = str_replace(WB_PATH, '', ADMIN_PATH);
 | 
      
        | 87 |  |  | 		if((LANGUAGE != $user_language) && file_exists(WB_PATH .'/languages/' .$user_language .'.php')
 | 
      
        | 88 |  |  | 			&& strpos($_SERVER['PHP_SELF'],$admin_folder.'/') !== false) {
 | 
      
        | 89 |  |  | 			// check if page_id is set
 | 
      
        | 90 |  |  | 			$page_id_url = (isset($_GET['page_id'])) ? '&page_id=' .(int) $_GET['page_id'] : '';
 | 
      
        | 91 |  |  | 			$section_id_url = (isset($_GET['section_id'])) ? '§ion_id=' .(int) $_GET['section_id'] : '';
 | 
      
        | 92 |  |  | 			if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') { // check if there is an query-string
 | 
      
        | 93 |  |  | 				header('Location: '.$_SERVER['PHP_SELF'] .'?lang='.$user_language .$page_id_url .$section_id_url.'&'.$_SERVER['QUERY_STRING']);
 | 
      
        | 94 |  |  | 			} else {
 | 
      
        | 95 |  |  | 				header('Location: '.$_SERVER['PHP_SELF'] .'?lang='.$user_language .$page_id_url .$section_id_url);
 | 
      
        | 96 |  |  | 			}
 | 
      
        | 97 |  |  | 			exit();
 | 
      
        | 98 |  |  | 		}
 | 
      
        | 99 |  |  | 
 | 
      
        | 100 |  |  | 		// Auto header code
 | 
      
        | 101 |  |  | 		if($auto_header == true) {
 | 
      
        | 102 |  |  | 			$this->print_header();
 | 
      
        | 103 |  |  | 		}
 | 
      
        | 104 |  |  | 	}
 | 
      
        | 105 |  |  | 	}
 | 
      
        | 106 |  |  | 
 | 
      
        | 107 |  |  | 	// Print the admin header
 | 
      
        | 108 | 1684 | Luisehahne | 	/**
 | 
      
        | 109 |  |  | 	 * admin::print_header()
 | 
      
        | 110 |  |  | 	 *
 | 
      
        | 111 |  |  | 	 * @param string $body_tags
 | 
      
        | 112 |  |  | 	 * @return void
 | 
      
        | 113 |  |  | 	 */
 | 
      
        | 114 |  |  | 	function print_header($body_tags = '')
 | 
      
        | 115 |  |  | 	{
 | 
      
        | 116 | 1379 | Luisehahne | 		// Get vars from the language file
 | 
      
        | 117 | 1678 | Luisehahne | 		global $MENU, $MESSAGE, $TEXT;
 | 
      
        | 118 | 1379 | Luisehahne | 		// Connect to database and get website title
 | 
      
        | 119 |  |  | 		global $database;
 | 
      
        | 120 | 1457 | Luisehahne | 		// $GLOBALS['FTAN'] = $this->getFTAN();
 | 
      
        | 121 |  |  | 		$this->createFTAN();
 | 
      
        | 122 | 1486 | DarkViper | 		$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'website_title\'';
 | 
      
        | 123 |  |  | 		$get_title = $database->query($sql);
 | 
      
        | 124 | 1379 | Luisehahne | 		$title = $get_title->fetchRow();
 | 
      
        | 125 | 1529 | Luisehahne | 		// Setup template object, parse vars to it, then parse it
 | 
      
        | 126 | 1684 | Luisehahne | 		$header_template = new Template(dirname($this->correct_theme_source('header.htt')) );
 | 
      
        | 127 | 1379 | Luisehahne | 		$header_template->set_file('page', 'header.htt');
 | 
      
        | 128 |  |  | 		$header_template->set_block('page', 'header_block', 'header');
 | 
      
        | 129 |  |  | 		if(defined('DEFAULT_CHARSET')) {
 | 
      
        | 130 |  |  | 			$charset=DEFAULT_CHARSET;
 | 
      
        | 131 |  |  | 		} else {
 | 
      
        | 132 |  |  | 			$charset='utf-8';
 | 
      
        | 133 |  |  | 		}
 | 
      
        | 134 |  |  | 
 | 
      
        | 135 |  |  | 		// work out the URL for the 'View menu' link in the WB backend
 | 
      
        | 136 |  |  | 		// if the page_id is set, show this page otherwise show the root directory of WB
 | 
      
        | 137 |  |  | 		$view_url = WB_URL;
 | 
      
        | 138 |  |  | 		if(isset($_GET['page_id'])) {
 | 
      
        | 139 |  |  | 			// extract page link from the database
 | 
      
        | 140 | 1486 | DarkViper | 			$sql  = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` ';
 | 
      
        | 141 |  |  | 			$sql .= 'WHERE `page_id`='.intval($_GET['page_id']);
 | 
      
        | 142 |  |  | 			$result = @$database->query($sql);
 | 
      
        | 143 | 1379 | Luisehahne | 			$row = @$result->fetchRow();
 | 
      
        | 144 |  |  | 			if($row) $view_url .= PAGES_DIRECTORY .$row['link']. PAGE_EXTENSION;
 | 
      
        | 145 |  |  | 		}
 | 
      
        | 146 | 1700 | Luisehahne | 		$sServerAdress = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '127.0.0.1';
 | 
      
        | 147 | 1379 | Luisehahne | 		$header_template->set_var(	array(
 | 
      
        | 148 | 1684 | Luisehahne | 							'SECTION_FORGOT' => $MENU['FORGOT'],
 | 
      
        | 149 |  |  | 							'SECTION_NAME' => $MENU['LOGIN'],
 | 
      
        | 150 | 1402 | Luisehahne | 							'BODY_TAGS' => $body_tags,
 | 
      
        | 151 |  |  | 							'WEBSITE_TITLE' => ($title['value']),
 | 
      
        | 152 |  |  | 							'TEXT_ADMINISTRATION' => $TEXT['ADMINISTRATION'],
 | 
      
        | 153 | 1700 | Luisehahne | 							'CURRENT_USER' => $MESSAGE['START_CURRENT_USER'],
 | 
      
        | 154 | 1402 | Luisehahne | 							'DISPLAY_NAME' => $this->get_display_name(),
 | 
      
        | 155 |  |  | 							'CHARSET' => $charset,
 | 
      
        | 156 |  |  | 							'LANGUAGE' => strtolower(LANGUAGE),
 | 
      
        | 157 |  |  | 							'VERSION' => VERSION,
 | 
      
        | 158 | 1532 | Luisehahne | 							'SP' => (defined('SP') ? SP : ''),
 | 
      
        | 159 | 1402 | Luisehahne | 							'REVISION' => REVISION,
 | 
      
        | 160 | 1700 | Luisehahne | 							'SERVER_ADDR' => ((int)$this->get_user_id()==1 ? $sServerAdress : ''),
 | 
      
        | 161 | 1402 | Luisehahne | 							'WB_URL' => WB_URL,
 | 
      
        | 162 |  |  | 							'ADMIN_URL' => ADMIN_URL,
 | 
      
        | 163 |  |  | 							'THEME_URL' => THEME_URL,
 | 
      
        | 164 | 1684 | Luisehahne | 							'START_URL' => ADMIN_URL.'/index.php',
 | 
      
        | 165 |  |  | 							'START_CLASS' => 'start',
 | 
      
        | 166 |  |  | 							'TITLE_START' => $TEXT['READ_MORE'],
 | 
      
        | 167 |  |  | 							'TITLE_VIEW' => $TEXT['WEBSITE'],
 | 
      
        | 168 | 1402 | Luisehahne | 							'TITLE_HELP' => $MENU['HELP'],
 | 
      
        | 169 |  |  | 							'URL_VIEW' => $view_url,
 | 
      
        | 170 | 1684 | Luisehahne | 							'TITLE_LOGOUT' => $MENU['LOGIN'],
 | 
      
        | 171 | 1700 | Luisehahne | 							'LOGIN_DISPLAY_HIDDEN' => !$this->is_authenticated() ? 'hidden' : '',
 | 
      
        | 172 |  |  | 							'LOGIN_DISPLAY_NONE' => !$this->is_authenticated() ? 'none' : '',
 | 
      
        | 173 | 1684 | Luisehahne | 							'LOGIN_LINK' => $_SERVER['SCRIPT_NAME'],
 | 
      
        | 174 |  |  | 							'LOGIN_ICON' => 'login',
 | 
      
        | 175 |  |  | 							'START_ICON' => 'blank',
 | 
      
        | 176 |  |  | 							'URL_HELP' => 'http://www.websitebaker.org/',
 | 
      
        | 177 | 1402 | Luisehahne | 							'BACKEND_MODULE_CSS' => $this->register_backend_modfiles('css'),	// adds backend.css
 | 
      
        | 178 |  |  | 							'BACKEND_MODULE_JS'  => $this->register_backend_modfiles('js')		// adds backend.js
 | 
      
        | 179 |  |  | 						)
 | 
      
        | 180 |  |  | 					);
 | 
      
        | 181 | 1379 | Luisehahne | 
 | 
      
        | 182 |  |  | 		// Create the menu
 | 
      
        | 183 | 1684 | Luisehahne | 		if(!$this->is_authenticated())
 | 
      
        | 184 |  |  | 		{
 | 
      
        | 185 | 1700 | Luisehahne | 		$header_template->set_var('STYLE', 'login');
 | 
      
        | 186 | 1379 | Luisehahne | 		$menu = array(
 | 
      
        | 187 | 1684 | Luisehahne | //						array('http://www.websitebaker.org/', '_blank', 'WebsiteBaker Home', 'help', 0),
 | 
      
        | 188 |  |  | //						array($view_url, '_blank', $TEXT['FRONTEND'], '', 0),
 | 
      
        | 189 |  |  | //						array(ADMIN_URL.'/login/index.php', '', $MENU['LOGIN'], '', 0)
 | 
      
        | 190 |  |  | 						);
 | 
      
        | 191 |  |  | 		} else {
 | 
      
        | 192 | 1700 | Luisehahne | 			$header_template->set_var('STYLE', 'start');
 | 
      
        | 193 | 1684 | Luisehahne | 			$header_template->set_var(	array(
 | 
      
        | 194 |  |  | 						'SECTION_NAME' => $MENU[strtoupper($this->section_name)],
 | 
      
        | 195 |  |  | 						'TITLE_LOGOUT' => $MENU['LOGOUT'],
 | 
      
        | 196 |  |  | 						'LOGIN_DISPLAY_NONE' => '',
 | 
      
        | 197 |  |  | 						'START_ICON' => 'home',
 | 
      
        | 198 |  |  | 						'LOGIN_ICON' => 'logout',
 | 
      
        | 199 |  |  | 						'LOGIN_LINK' => ADMIN_URL.'/logout/index.php',
 | 
      
        | 200 |  |  | 						'TITLE_START' => $MENU['START']
 | 
      
        | 201 |  |  | 						)
 | 
      
        | 202 |  |  | 					);
 | 
      
        | 203 |  |  | 			// @array ( $url, $target, $title, $page_permission, $ppermission_required )
 | 
      
        | 204 |  |  | 			$menu = array(
 | 
      
        | 205 |  |  | //					array(ADMIN_URL.'/index.php', '', $MENU['START'], 'start', 1 ),
 | 
      
        | 206 | 1379 | Luisehahne | 					array(ADMIN_URL.'/pages/index.php', '', $MENU['PAGES'], 'pages', 1),
 | 
      
        | 207 | 1684 | Luisehahne | // 					array($view_url, '_blank', $MENU['FRONTEND'], 'pages', 1),
 | 
      
        | 208 | 1379 | Luisehahne | 					array(ADMIN_URL.'/media/index.php', '', $MENU['MEDIA'], 'media', 1),
 | 
      
        | 209 |  |  | 					array(ADMIN_URL.'/addons/index.php', '', $MENU['ADDONS'], 'addons', 1),
 | 
      
        | 210 | 1700 | Luisehahne | 					array(ADMIN_URL.'/preferences/index.php', '', $MENU['PREFERENCES'], 'preferences', 1),
 | 
      
        | 211 | 1379 | Luisehahne | 					array(ADMIN_URL.'/settings/index.php', '', $MENU['SETTINGS'], 'settings', 1),
 | 
      
        | 212 |  |  | 					array(ADMIN_URL.'/admintools/index.php', '', $MENU['ADMINTOOLS'], 'admintools', 1),
 | 
      
        | 213 | 1684 | Luisehahne | 					array(ADMIN_URL.'/access/index.php', '', $MENU['ACCESS'], 'access', 1),
 | 
      
        | 214 |  |  | //					array('http://www.websitebaker.org/', '_blank', 'WebsiteBaker Home', '', 0),
 | 
      
        | 215 |  |  | //					array(ADMIN_URL.'/logout/index.php', '', $MENU['LOGOUT'], '', 0)
 | 
      
        | 216 |  |  | 
 | 
      
        | 217 | 1379 | Luisehahne | 					);
 | 
      
        | 218 | 1684 | Luisehahne | 		}
 | 
      
        | 219 |  |  | 
 | 
      
        | 220 | 1379 | Luisehahne | 		$header_template->set_block('header_block', 'linkBlock', 'link');
 | 
      
        | 221 | 1700 | Luisehahne | 		foreach($menu AS $menu_item)
 | 
      
        | 222 |  |  | 		{
 | 
      
        | 223 | 1379 | Luisehahne | 			$link = $menu_item[0];
 | 
      
        | 224 |  |  | 			$target = ($menu_item[1] == '') ? '_self' : $menu_item[1];
 | 
      
        | 225 |  |  | 			$title = $menu_item[2];
 | 
      
        | 226 |  |  | 			$permission_title = $menu_item[3];
 | 
      
        | 227 |  |  | 			$required = $menu_item[4];
 | 
      
        | 228 |  |  | 			$replace_old = array(ADMIN_URL, WB_URL, '/', 'index.php');
 | 
      
        | 229 | 1684 | Luisehahne | 			if($required == false || ($this->is_authenticated() && $this->get_link_permission($permission_title)) )
 | 
      
        | 230 |  |  | 			{
 | 
      
        | 231 | 1379 | Luisehahne | 				$header_template->set_var('LINK', $link);
 | 
      
        | 232 |  |  | 				$header_template->set_var('TARGET', $target);
 | 
      
        | 233 |  |  | 				// If link is the current section apply a class name
 | 
      
        | 234 |  |  | 				if($permission_title == strtolower($this->section_name)) {
 | 
      
        | 235 |  |  | 					$header_template->set_var('CLASS', $menu_item[3] . ' current');
 | 
      
        | 236 | 1700 | Luisehahne | 					$header_template->set_var('STYLE', $menu_item[3] );
 | 
      
        | 237 | 1379 | Luisehahne | 				} else {
 | 
      
        | 238 | 1700 | Luisehahne | 					$header_template->set_var('CLASS', $menu_item[3] );
 | 
      
        | 239 | 1379 | Luisehahne | 				}
 | 
      
        | 240 |  |  | 				$header_template->set_var('TITLE', $title);
 | 
      
        | 241 |  |  | 				// Print link
 | 
      
        | 242 |  |  | 				$header_template->parse('link', 'linkBlock', true);
 | 
      
        | 243 |  |  | 			}
 | 
      
        | 244 |  |  | 		}
 | 
      
        | 245 |  |  | 		$header_template->parse('header', 'header_block', false);
 | 
      
        | 246 |  |  | 		$header_template->pparse('output', 'page');
 | 
      
        | 247 | 1700 | Luisehahne | 		unset($header_template);
 | 
      
        | 248 | 1379 | Luisehahne | 	}
 | 
      
        | 249 | 1684 | Luisehahne | 
 | 
      
        | 250 | 1379 | Luisehahne | 	// Print the admin footer
 | 
      
        | 251 | 1443 | Luisehahne | 		function print_footer($activateJsAdmin = false) {
 | 
      
        | 252 | 1700 | Luisehahne | 		global $database,$starttime,$iPhpDeclaredClasses;
 | 
      
        | 253 | 1379 | Luisehahne | 		// include the required file for Javascript admin
 | 
      
        | 254 | 1443 | Luisehahne | 		if($activateJsAdmin != false) {
 | 
      
        | 255 |  |  | 			if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php')){
 | 
      
        | 256 |  |  | 				@include_once(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
 | 
      
        | 257 |  |  | 			}
 | 
      
        | 258 | 1379 | Luisehahne | 		}
 | 
      
        | 259 | 1443 | Luisehahne | 
 | 
      
        | 260 | 1529 | Luisehahne | 		// Setup template object, parse vars to it, then parse it
 | 
      
        | 261 | 1625 | Luisehahne | 		$footer_template = new Template(dirname($this->correct_theme_source('footer.htt')));
 | 
      
        | 262 | 1379 | Luisehahne | 		$footer_template->set_file('page', 'footer.htt');
 | 
      
        | 263 |  |  | 		$footer_template->set_block('page', 'footer_block', 'header');
 | 
      
        | 264 |  |  | 		$footer_template->set_var(array(
 | 
      
        | 265 |  |  | 						'BACKEND_BODY_MODULE_JS' => $this->register_backend_modfiles_body('js'),
 | 
      
        | 266 |  |  | 						'WB_URL' => WB_URL,
 | 
      
        | 267 |  |  | 						'ADMIN_URL' => ADMIN_URL,
 | 
      
        | 268 |  |  | 						'THEME_URL' => THEME_URL,
 | 
      
        | 269 |  |  | 			 ) );
 | 
      
        | 270 | 1668 | Luisehahne | 
 | 
      
        | 271 |  |  | 		$footer_template->set_block('footer_block', 'show_debug_block', 'show_debug');
 | 
      
        | 272 |  |  | 
 | 
      
        | 273 | 1674 | Luisehahne | 		$bDebug = (defined('DEBUG') ? DEBUG : false);
 | 
      
        | 274 | 1668 | Luisehahne | 		$bDevInfo = (defined('DEV_INFOS') && (DEV_INFOS == true) && (1 == $this->get_user_id()) ? true : false);
 | 
      
        | 275 |  |  | //         if( $debug && (1 == $this->get_user_id()))
 | 
      
        | 276 |  |  |         if( $bDevInfo )
 | 
      
        | 277 |  |  | 		{
 | 
      
        | 278 | 1684 | Luisehahne | 
 | 
      
        | 279 | 1700 | Luisehahne | 			$footer_template->set_var('MEMORY', number_format(memory_get_peak_usage(true), 0, ',', '.').' Byte' );
 | 
      
        | 280 |  |  | //			$footer_template->set_var('MEMORY', number_format(memory_get_usage(true), 0, ',', '.').' Byte' );
 | 
      
        | 281 | 1668 | Luisehahne | 			$footer_template->set_var('QUERIES', $database->getQueryCount );
 | 
      
        | 282 |  |  | 			// $footer_template->set_var('QUERIES', 'disabled' );
 | 
      
        | 283 |  |  | 	        $included_files =  get_included_files();
 | 
      
        | 284 |  |  | 			$footer_template->set_var('INCLUDES', sizeof($included_files) );
 | 
      
        | 285 | 1700 | Luisehahne | 	        $included_classes =  get_declared_classes();
 | 
      
        | 286 |  |  | 			$footer_template->set_var('CLASSES', sizeof($included_classes)-$iPhpDeclaredClasses );
 | 
      
        | 287 | 1668 | Luisehahne | 
 | 
      
        | 288 | 1700 | Luisehahne | 			$sum_classes = 0;
 | 
      
        | 289 | 1668 | Luisehahne | 			$sum_filesize = 0;
 | 
      
        | 290 |  |  | 			$footer_template->set_block('show_debug_block', 'show_block_list', 'show_list');
 | 
      
        | 291 |  |  | 			$footer_template->set_block('show_block_list', 'include_block_list', 'include_list');
 | 
      
        | 292 | 1684 | Luisehahne | 			// $bDebug = true;  for testing
 | 
      
        | 293 | 1668 | Luisehahne | 			foreach($included_files as $filename)
 | 
      
        | 294 |  |  | 			{
 | 
      
        | 295 | 1674 | Luisehahne | 				if(!is_readable($filename)) { continue; }
 | 
      
        | 296 | 1668 | Luisehahne | 				if($bDebug)
 | 
      
        | 297 |  |  | 				{
 | 
      
        | 298 |  |  | 					$footer_template->set_var('INCLUDES_ARRAY', str_replace(WB_PATH, '',$filename) );
 | 
      
        | 299 |  |  | 					$footer_template->set_var('FILESIZE', number_format(filesize($filename), 0, ',', '.').' Byte');
 | 
      
        | 300 |  |  | 					$footer_template->parse('include_list', 'include_block_list', true);
 | 
      
        | 301 |  |  | 				}
 | 
      
        | 302 |  |  | 				$sum_filesize += filesize($filename);
 | 
      
        | 303 |  |  | 			}
 | 
      
        | 304 |  |  | 			$footer_template->parse('show_list', 'show_block_list', true);
 | 
      
        | 305 |  |  | 
 | 
      
        | 306 | 1684 | Luisehahne | 			$endtime = array_sum(explode(" ",microtime()));
 | 
      
        | 307 |  |  | 			$iEndTime = $endtime;
 | 
      
        | 308 |  |  | 			$iStartTime = $starttime;
 | 
      
        | 309 | 1678 | Luisehahne | 			if(!$bDebug)
 | 
      
        | 310 | 1668 | Luisehahne | 			{
 | 
      
        | 311 | 1684 | Luisehahne | 				$footer_template->parse('show_list', '');
 | 
      
        | 312 | 1668 | Luisehahne | 				$footer_template->parse('include_list', '');
 | 
      
        | 313 |  |  | 			}
 | 
      
        | 314 |  |  | 
 | 
      
        | 315 |  |  | 			$footer_template->set_var('FILESIZE', ini_get('memory_limit'));
 | 
      
        | 316 |  |  | 			$footer_template->set_var('TXT_SUM_FILESIZE', 'Summary size of included files: ');
 | 
      
        | 317 |  |  | 			$footer_template->set_var('SUM_FILESIZE', number_format($sum_filesize, 0, ',', '.').' Byte');
 | 
      
        | 318 | 1700 | Luisehahne | 			$footer_template->set_var('SUM_CLASSES', number_format($sum_classes, 0, ',', '.').' Byte');
 | 
      
        | 319 | 1684 | Luisehahne | 			$footer_template->set_var('PAGE_LOAD_TIME', round($iEndTime-$iStartTime,3 ));
 | 
      
        | 320 | 1700 | Luisehahne | 			$footer_template->set_var('DUMP_CLASSES', '<pre>'.var_export($included_classes,true).'</pre>');
 | 
      
        | 321 | 1684 | Luisehahne | 
 | 
      
        | 322 | 1668 | Luisehahne | 			$footer_template->parse('show_debug', 'show_debug_block', true);
 | 
      
        | 323 |  |  |         } else {
 | 
      
        | 324 |  |  | 			$footer_template->parse('show_debug', '');
 | 
      
        | 325 | 1684 | Luisehahne | 			$footer_template->parse('show_list', '');
 | 
      
        | 326 |  |  | 
 | 
      
        | 327 | 1668 | Luisehahne |         }
 | 
      
        | 328 | 1379 | Luisehahne | 		$footer_template->parse('header', 'footer_block', false);
 | 
      
        | 329 |  |  | 		$footer_template->pparse('output', 'page');
 | 
      
        | 330 | 1700 | Luisehahne | 		unset($footer_template);
 | 
      
        | 331 | 1379 | Luisehahne | 	}
 | 
      
        | 332 | 1684 | Luisehahne | 
 | 
      
        | 333 | 1379 | Luisehahne | 	// Return a system permission
 | 
      
        | 334 |  |  | 	function get_permission($name, $type = 'system') {
 | 
      
        | 335 | 1700 | Luisehahne | 
 | 
      
        | 336 | 1379 | Luisehahne | 		// Append to permission type
 | 
      
        | 337 |  |  | 		$type .= '_permissions';
 | 
      
        | 338 |  |  | 		// Check if we have a section to check for
 | 
      
        | 339 |  |  | 		if($name == 'start') {
 | 
      
        | 340 |  |  | 			return true;
 | 
      
        | 341 |  |  | 		} else {
 | 
      
        | 342 |  |  | 			// Set system permissions var
 | 
      
        | 343 |  |  | 			$system_permissions = $this->get_session('SYSTEM_PERMISSIONS');
 | 
      
        | 344 |  |  | 			// Set module permissions var
 | 
      
        | 345 |  |  | 			$module_permissions = $this->get_session('MODULE_PERMISSIONS');
 | 
      
        | 346 |  |  | 			// Set template permissions var
 | 
      
        | 347 |  |  | 			$template_permissions = $this->get_session('TEMPLATE_PERMISSIONS');
 | 
      
        | 348 |  |  | 			// Return true if system perm = 1
 | 
      
        | 349 |  |  | 			if (isset($$type) && is_array($$type) && is_numeric(array_search($name, $$type))) {
 | 
      
        | 350 |  |  | 				if($type == 'system_permissions') {
 | 
      
        | 351 |  |  | 					return true;
 | 
      
        | 352 |  |  | 				} else {
 | 
      
        | 353 |  |  | 					return false;
 | 
      
        | 354 |  |  | 				}
 | 
      
        | 355 |  |  | 			} else {
 | 
      
        | 356 |  |  | 				if($type == 'system_permissions') {
 | 
      
        | 357 |  |  | 					return false;
 | 
      
        | 358 |  |  | 				} else {
 | 
      
        | 359 |  |  | 					return true;
 | 
      
        | 360 |  |  | 				}
 | 
      
        | 361 |  |  | 			}
 | 
      
        | 362 |  |  | 		}
 | 
      
        | 363 | 1700 | Luisehahne | 
 | 
      
        | 364 | 1379 | Luisehahne | 	}
 | 
      
        | 365 | 1700 | Luisehahne | 
 | 
      
        | 366 | 1441 | Luisehahne |  function get_user_details($user_id) {
 | 
      
        | 367 |  |  |   global $database;
 | 
      
        | 368 |  |  |   $retval = array('username'=>'unknown','display_name'=>'Unknown','email'=>'');
 | 
      
        | 369 |  |  |   $sql  = 'SELECT `username`,`display_name`,`email` ';
 | 
      
        | 370 |  |  |   $sql .= 'FROM `'.TABLE_PREFIX.'users` ';
 | 
      
        | 371 | 1486 | DarkViper |   $sql .= 'WHERE `user_id`='.(int)$user_id;
 | 
      
        | 372 | 1441 | Luisehahne |   if( ($resUsers = $database->query($sql)) ) {
 | 
      
        | 373 |  |  |    if( ($recUser = $resUsers->fetchRow()) ) {
 | 
      
        | 374 |  |  |     $retval = $recUser;
 | 
      
        | 375 |  |  |    }
 | 
      
        | 376 |  |  |   }
 | 
      
        | 377 |  |  |   return $retval;
 | 
      
        | 378 |  |  |  }
 | 
      
        | 379 |  |  | 
 | 
      
        | 380 |  |  |     //
 | 
      
        | 381 |  |  | 	function get_section_details( $section_id, $backLink = 'index.php' ) {
 | 
      
        | 382 |  |  | 	global $database, $TEXT;
 | 
      
        | 383 |  |  | 		$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'sections` ';
 | 
      
        | 384 | 1486 | DarkViper | 		$sql .= 'WHERE `section_id`='.intval($section_id);
 | 
      
        | 385 | 1441 | Luisehahne | 		if(($resSection = $database->query($sql))){
 | 
      
        | 386 |  |  | 			if(!($recSection = $resSection->fetchRow())) {
 | 
      
        | 387 |  |  | 				$this->print_header();
 | 
      
        | 388 |  |  | 				$this->print_error($TEXT['SECTION'].' '.$TEXT['NOT_FOUND'], $backLink, true);
 | 
      
        | 389 |  |  | 			}
 | 
      
        | 390 |  |  | 			} else {
 | 
      
        | 391 |  |  | 				$this->print_header();
 | 
      
        | 392 |  |  | 				$this->print_error($database->get_error(), $backLink, true);
 | 
      
        | 393 |  |  | 			}
 | 
      
        | 394 |  |  | 		return $recSection;
 | 
      
        | 395 |  |  | 	}
 | 
      
        | 396 |  |  | 
 | 
      
        | 397 |  |  | 	function get_page_details( $page_id, $backLink = 'index.php' ) {
 | 
      
        | 398 | 1486 | DarkViper | 		global $database, $TEXT;
 | 
      
        | 399 |  |  | 		$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'pages` ';
 | 
      
        | 400 |  |  | 		$sql .= 'WHERE `page_id`='.intval($page_id);
 | 
      
        | 401 |  |  | 		if(($resPages = $database->query($sql))){
 | 
      
        | 402 |  |  | 			if(!($recPage = $resPages->fetchRow())) {
 | 
      
        | 403 |  |  | 			$this->print_header();
 | 
      
        | 404 |  |  | 			$this->print_error($TEXT['PAGE'].' '.$TEXT['NOT_FOUND'], $backLink, true);
 | 
      
        | 405 |  |  | 			}
 | 
      
        | 406 | 1441 | Luisehahne | 		} else {
 | 
      
        | 407 | 1486 | DarkViper | 			$this->print_header();
 | 
      
        | 408 |  |  | 			$this->print_error($database->get_error(), $backLink, true);
 | 
      
        | 409 | 1379 | Luisehahne | 		}
 | 
      
        | 410 | 1486 | DarkViper | 		return $recPage;
 | 
      
        | 411 | 1379 | Luisehahne | 	}
 | 
      
        | 412 |  |  | 
 | 
      
        | 413 | 1441 | Luisehahne | 	function get_page_permission($page,$action='admin') {
 | 
      
        | 414 |  |  | 		if($action != 'viewing') { $action = 'admin'; }
 | 
      
        | 415 |  |  | 		$action_groups = $action.'_groups';
 | 
      
        | 416 |  |  | 		$action_users  = $action.'_users';
 | 
      
        | 417 |  |  | 		$groups = $users = '0';
 | 
      
        | 418 |  |  | 		if(is_array($page)) {
 | 
      
        | 419 |  |  | 			$groups = $page[$action_groups];
 | 
      
        | 420 |  |  | 			$users  = $page[$action_users];
 | 
      
        | 421 |  |  | 		} else {
 | 
      
        | 422 |  |  | 			global $database;
 | 
      
        | 423 |  |  | 			$sql  = 'SELECT `'.$action_groups.'`,`'.$action_users.'` ';
 | 
      
        | 424 |  |  | 			$sql .= 'FROM `'.TABLE_PREFIX.'pages` ';
 | 
      
        | 425 |  |  | 			$sql .= 'WHERE `page_id`='.(int)$page;
 | 
      
        | 426 |  |  | 			if( ($res = $database->query($sql)) ) {
 | 
      
        | 427 |  |  | 				if( ($rec = $res->fetchRow()) ) {
 | 
      
        | 428 |  |  | 					$groups = $rec[$action_groups];
 | 
      
        | 429 |  |  | 					$users  = $rec[$action_users];
 | 
      
        | 430 |  |  | 				}
 | 
      
        | 431 |  |  | 			}
 | 
      
        | 432 |  |  | 		}
 | 
      
        | 433 |  |  | 		return ($this->ami_group_member($groups) || $this->is_group_match($this->get_user_id(), $users));
 | 
      
        | 434 |  |  | 	}
 | 
      
        | 435 |  |  | 
 | 
      
        | 436 | 1379 | Luisehahne | 	// Returns a system permission for a menu link
 | 
      
        | 437 |  |  | 	function get_link_permission($title) {
 | 
      
        | 438 |  |  | 		$title = str_replace('_blank', '', $title);
 | 
      
        | 439 |  |  | 		$title = strtolower($title);
 | 
      
        | 440 |  |  | 		// Set system permissions var
 | 
      
        | 441 |  |  | 		$system_permissions = $this->get_session('SYSTEM_PERMISSIONS');
 | 
      
        | 442 |  |  | 		// Set module permissions var
 | 
      
        | 443 |  |  | 		$module_permissions = $this->get_session('MODULE_PERMISSIONS');
 | 
      
        | 444 |  |  | 		if($title == 'start') {
 | 
      
        | 445 |  |  | 			return true;
 | 
      
        | 446 |  |  | 		} else {
 | 
      
        | 447 |  |  | 			// Return true if system perm = 1
 | 
      
        | 448 |  |  | 			if(is_numeric(array_search($title, $system_permissions))) {
 | 
      
        | 449 |  |  | 				return true;
 | 
      
        | 450 |  |  | 			} else {
 | 
      
        | 451 |  |  | 				return false;
 | 
      
        | 452 |  |  | 			}
 | 
      
        | 453 |  |  | 		}
 | 
      
        | 454 |  |  | 	}
 | 
      
        | 455 |  |  | 
 | 
      
        | 456 |  |  | 	// Function to add optional module Javascript or CSS stylesheets into the <body> section of the backend
 | 
      
        | 457 |  |  | 	function register_backend_modfiles_body($file_id="js")
 | 
      
        | 458 |  |  | 		{
 | 
      
        | 459 |  |  | 		// sanity check of parameter passed to the function
 | 
      
        | 460 |  |  | 		$file_id = strtolower($file_id);
 | 
      
        | 461 |  |  | 		if($file_id !== "javascript" && $file_id !== "js")
 | 
      
        | 462 |  |  | 		{
 | 
      
        | 463 |  |  | 			return;
 | 
      
        | 464 |  |  | 		}
 | 
      
        | 465 |  |  | 		global $database;
 | 
      
        | 466 |  |  |         $body_links = "";
 | 
      
        | 467 |  |  | 		// define default baselink and filename for optional module javascript and stylesheet files
 | 
      
        | 468 |  |  | 		if($file_id == "js") {
 | 
      
        | 469 | 1441 | Luisehahne | 			$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend_body.js" type="text/javascript"></script>';
 | 
      
        | 470 | 1379 | Luisehahne | 			$base_file = "backend_body.js";
 | 
      
        | 471 |  |  | 		}
 | 
      
        | 472 |  |  | 		// check if backend_body.js files needs to be included to the <body></body> section of the backend
 | 
      
        | 473 |  |  | 		if(isset($_GET['tool']))
 | 
      
        | 474 |  |  | 			{
 | 
      
        | 475 |  |  | 			// check if displayed page contains a installed admin tool
 | 
      
        | 476 | 1486 | DarkViper | 			$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'addons` ';
 | 
      
        | 477 |  |  | 			$sql .= 'WHERE `type`=\'module\' AND `function`=\'tool\' AND `directory`=\''.addslashes($_GET['tool']).'\'';
 | 
      
        | 478 |  |  | 			$result = $database->query($sql);
 | 
      
        | 479 | 1379 | Luisehahne | 			if($result->numRows())
 | 
      
        | 480 |  |  | 				{
 | 
      
        | 481 |  |  | 				// check if admin tool directory contains a backend_body.js file to include
 | 
      
        | 482 |  |  | 				$tool = $result->fetchRow();
 | 
      
        | 483 |  |  | 				if(file_exists(WB_PATH ."/modules/" .$tool['directory'] ."/$base_file"))
 | 
      
        | 484 |  |  | 				{
 | 
      
        | 485 |  |  | 					// return link to the backend_body.js file
 | 
      
        | 486 |  |  | 					return str_replace("{MODULE_DIRECTORY}", $tool['directory'], $base_link);
 | 
      
        | 487 |  |  | 				}
 | 
      
        | 488 |  |  | 			}
 | 
      
        | 489 |  |  | 		} elseif(isset($_GET['page_id']) or isset($_POST['page_id']))
 | 
      
        | 490 |  |  | 		{
 | 
      
        | 491 |  |  | 			// check if displayed page in the backend contains a page module
 | 
      
        | 492 |  |  | 			if (isset($_GET['page_id']))
 | 
      
        | 493 |  |  | 			{
 | 
      
        | 494 |  |  | 				$page_id = (int) addslashes($_GET['page_id']);
 | 
      
        | 495 |  |  | 			} else {
 | 
      
        | 496 |  |  | 				$page_id = (int) addslashes($_POST['page_id']);
 | 
      
        | 497 |  |  | 			}
 | 
      
        | 498 |  |  | 			// gather information for all models embedded on actual page
 | 
      
        | 499 | 1486 | DarkViper | 			$sql = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id`='.(int)$page_id;
 | 
      
        | 500 |  |  | 			$query_modules = $database->query($sql);
 | 
      
        | 501 | 1379 | Luisehahne | 			while($row = $query_modules->fetchRow()) {
 | 
      
        | 502 |  |  | 				// check if page module directory contains a backend_body.js file
 | 
      
        | 503 |  |  | 				if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) {
 | 
      
        | 504 |  |  | 					// create link with backend_body.js source for the current module
 | 
      
        | 505 |  |  | 					$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
 | 
      
        | 506 |  |  | 					// ensure that backend_body.js is only added once per module type
 | 
      
        | 507 |  |  | 					if(strpos($body_links, $tmp_link) === false) {
 | 
      
        | 508 |  |  | 						$body_links .= $tmp_link ."\n";
 | 
      
        | 509 |  |  | 					}
 | 
      
        | 510 |  |  | 				}
 | 
      
        | 511 |  |  | 			}
 | 
      
        | 512 |  |  | 			// write out links with all external module javascript/CSS files, remove last line feed
 | 
      
        | 513 |  |  | 			return rtrim($body_links);
 | 
      
        | 514 |  |  | 		}
 | 
      
        | 515 |  |  | 	}
 | 
      
        | 516 |  |  | 
 | 
      
        | 517 |  |  | 
 | 
      
        | 518 |  |  | 	// Function to add optional module Javascript or CSS stylesheets into the <head> section of the backend
 | 
      
        | 519 |  |  | 	function register_backend_modfiles($file_id="css") {
 | 
      
        | 520 |  |  | 		// sanity check of parameter passed to the function
 | 
      
        | 521 |  |  | 		$file_id = strtolower($file_id);
 | 
      
        | 522 |  |  | 		if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js") {
 | 
      
        | 523 |  |  | 			return;
 | 
      
        | 524 |  |  | 		}
 | 
      
        | 525 |  |  | 
 | 
      
        | 526 |  |  | 		global $database;
 | 
      
        | 527 |  |  | 		// define default baselink and filename for optional module javascript and stylesheet files
 | 
      
        | 528 |  |  | 		$head_links = "";
 | 
      
        | 529 |  |  | 		if($file_id == "css") {
 | 
      
        | 530 |  |  |       	$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend.css"';
 | 
      
        | 531 |  |  | 			$base_link.= ' rel="stylesheet" type="text/css" media="screen" />';
 | 
      
        | 532 |  |  | 			$base_file = "backend.css";
 | 
      
        | 533 |  |  | 		} else {
 | 
      
        | 534 | 1441 | Luisehahne | 			$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend.js" type="text/javascript"></script>';
 | 
      
        | 535 | 1379 | Luisehahne | 			$base_file = "backend.js";
 | 
      
        | 536 |  |  | 		}
 | 
      
        | 537 |  |  | 
 | 
      
        | 538 |  |  | 		// check if backend.js or backend.css files needs to be included to the <head></head> section of the backend
 | 
      
        | 539 |  |  | 		if(isset($_GET['tool'])) {
 | 
      
        | 540 |  |  | 			// check if displayed page contains a installed admin tool
 | 
      
        | 541 | 1486 | DarkViper | 			$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'addons` ';
 | 
      
        | 542 |  |  | 			$sql .= 'WHERE `type`=\'module\' AND `function`=\'tool\' AND `directory`=\''.addslashes($_GET['tool']).'\'';
 | 
      
        | 543 |  |  | 			$result = $database->query($sql);
 | 
      
        | 544 | 1379 | Luisehahne | 			if($result->numRows()) {
 | 
      
        | 545 |  |  | 				// check if admin tool directory contains a backend.js or backend.css file to include
 | 
      
        | 546 |  |  | 				$tool = $result->fetchRow();
 | 
      
        | 547 |  |  | 				if(file_exists(WB_PATH ."/modules/" .$tool['directory'] ."/$base_file")) {
 | 
      
        | 548 |  |  |         			// return link to the backend.js or backend.css file
 | 
      
        | 549 |  |  | 					return str_replace("{MODULE_DIRECTORY}", $tool['directory'], $base_link);
 | 
      
        | 550 |  |  | 				}
 | 
      
        | 551 |  |  | 			}
 | 
      
        | 552 | 1441 | Luisehahne | 		} elseif(isset($_GET['page_id']) || isset($_POST['page_id'])) {
 | 
      
        | 553 | 1379 | Luisehahne | 			// check if displayed page in the backend contains a page module
 | 
      
        | 554 |  |  | 			if (isset($_GET['page_id'])) {
 | 
      
        | 555 |  |  | 				$page_id = (int)$_GET['page_id'];
 | 
      
        | 556 |  |  | 			} else {
 | 
      
        | 557 |  |  | 				$page_id = (int)$_POST['page_id'];
 | 
      
        | 558 |  |  | 			}
 | 
      
        | 559 |  |  | 
 | 
      
        | 560 |  |  |     		// gather information for all models embedded on actual page
 | 
      
        | 561 | 1486 | DarkViper | 			$sql = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id`='.(int)$page_id;
 | 
      
        | 562 |  |  | 			$query_modules = $database->query($sql);
 | 
      
        | 563 | 1379 | Luisehahne | 
 | 
      
        | 564 |  |  |     		while($row = $query_modules->fetchRow()) {
 | 
      
        | 565 |  |  | 				// check if page module directory contains a backend.js or backend.css file
 | 
      
        | 566 |  |  |       		if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) {
 | 
      
        | 567 |  |  | 					// create link with backend.js or backend.css source for the current module
 | 
      
        | 568 |  |  | 					$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
 | 
      
        | 569 |  |  |         			// ensure that backend.js or backend.css is only added once per module type
 | 
      
        | 570 |  |  |         			if(strpos($head_links, $tmp_link) === false) {
 | 
      
        | 571 |  |  | 						$head_links .= $tmp_link ."\n";
 | 
      
        | 572 |  |  | 					}
 | 
      
        | 573 |  |  | 				}
 | 
      
        | 574 |  |  |     		}
 | 
      
        | 575 |  |  |     		// write out links with all external module javascript/CSS files, remove last line feed
 | 
      
        | 576 |  |  | 			return rtrim($head_links);
 | 
      
        | 577 |  |  | 		}
 | 
      
        | 578 |  |  | 	}
 | 
      
        | 579 |  |  | }
 |