| 1 | <?php
 | 
  
    | 2 | 
 | 
  
    | 3 | // $Id: frontend.functions.php 120 2005-09-17 10:26:27Z stefan $
 | 
  
    | 4 | 
 | 
  
    | 5 | /*
 | 
  
    | 6 | 
 | 
  
    | 7 |  Website Baker Project <http://www.websitebaker.org/>
 | 
  
    | 8 |  Copyright (C) 2004-2005, Ryan Djurovich
 | 
  
    | 9 | 
 | 
  
    | 10 |  Website Baker is free software; you can redistribute it and/or modify
 | 
  
    | 11 |  it under the terms of the GNU General Public License as published by
 | 
  
    | 12 |  the Free Software Foundation; either version 2 of the License, or
 | 
  
    | 13 |  (at your option) any later version.
 | 
  
    | 14 | 
 | 
  
    | 15 |  Website Baker is distributed in the hope that it will be useful,
 | 
  
    | 16 |  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
  
    | 17 |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
  
    | 18 |  GNU General Public License for more details.
 | 
  
    | 19 | 
 | 
  
    | 20 |  You should have received a copy of the GNU General Public License
 | 
  
    | 21 |  along with Website Baker; if not, write to the Free Software
 | 
  
    | 22 |  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
  
    | 23 | 
 | 
  
    | 24 | */
 | 
  
    | 25 | 
 | 
  
    | 26 | /*
 | 
  
    | 27 | 	This file is purely for ensuring compatibility with 3rd party
 | 
  
    | 28 | 	contributions made for WB version 2.5.2 or below
 | 
  
    | 29 | */
 | 
  
    | 30 | if(!defined('WB_URL')) {
 | 
  
    | 31 | 	header('Location: ../index.php');
 | 
  
    | 32 | }
 | 
  
    | 33 | 
 | 
  
    | 34 | // references to objects and variables that changed their names
 | 
  
    | 35 | 
 | 
  
    | 36 | $admin = &$wb;
 | 
  
    | 37 | 
 | 
  
    | 38 | $default_link=&$wb->default_link;
 | 
  
    | 39 | 
 | 
  
    | 40 | $page_trail=&$wb->page_trail;
 | 
  
    | 41 | $page_description=&$wb->page_description;
 | 
  
    | 42 | $page_keywords=&$wb->page_keywords;
 | 
  
    | 43 | $page_link=&$wb->link;
 | 
  
    | 44 | 
 | 
  
    | 45 | // extra_sql is not used anymore - this is basically a register_globals exploit prevention...
 | 
  
    | 46 | $extra_sql=&$wb->extra_sql;
 | 
  
    | 47 | $extra_where_sql=&$wb->extra_where_sql;
 | 
  
    | 48 | 
 | 
  
    | 49 | $query="SELECT directory FROM ".TABLE_PREFIX."modules WHERE type='snippet'";
 | 
  
    | 50 | $query_result=$database->query($query);
 | 
  
    | 51 | if ($query_result->numRows()>0) {
 | 
  
    | 52 | 	while ($row = $query_result->fetchRow()) {
 | 
  
    | 53 | 		$module_dir = $row['directory'];
 | 
  
    | 54 | 		if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) {
 | 
  
    | 55 | 			include(WB_PATH.'/modules/'.$module_dir.'/include.php');
 | 
  
    | 56 | 		}
 | 
  
    | 57 | 	}
 | 
  
    | 58 | }
 | 
  
    | 59 | 
 | 
  
    | 60 | // Frontend functions
 | 
  
    | 61 | if (!function_exists('page_link')) {
 | 
  
    | 62 | 	function page_link($link) {
 | 
  
    | 63 | 		global $wb;
 | 
  
    | 64 | 		return $wb->page_link($link);
 | 
  
    | 65 | 	}
 | 
  
    | 66 | }
 | 
  
    | 67 | 
 | 
  
    | 68 | // Old menu call invokes new menu function
 | 
  
    | 69 | if (!function_exists('page_menu')) {
 | 
  
    | 70 | 	function page_menu($parent = 0, $menu_number = 1, $item_template = '<li><span[class]>[a][menu_title][/a]</span>', $menu_header = '<ul>', $menu_footer = '</ul>', $default_class = ' class="menu_default"', $current_class = ' class="menu_current"', $recurse = LEVEL) {
 | 
  
    | 71 | 		global $wb;
 | 
  
    | 72 | 		$wb->menu_number=$menu_number;
 | 
  
    | 73 | 		$wb->menu_item_template=$item_template;
 | 
  
    | 74 | 		$wb->menu_parent = $parent;
 | 
  
    | 75 | 		$wb->menu_header = $menu_header; 
 | 
  
    | 76 | 		$wb->menu_footer = $menu_footer;
 | 
  
    | 77 | 		$wb->menu_default_class = $default_class;
 | 
  
    | 78 | 		$wb->menu_current_class = $current_class;
 | 
  
    | 79 | 		$wb->menu_recurse = $recurse+2; 	
 | 
  
    | 80 | 		$wb->menu();
 | 
  
    | 81 | 	}
 | 
  
    | 82 | }
 | 
  
    | 83 | 
 | 
  
    | 84 | if (!function_exists('page_content')) {
 | 
  
    | 85 | 	function page_content($block = 1) {
 | 
  
    | 86 | 		// Get outside objects
 | 
  
    | 87 | 		global $TEXT,$MENU,$HEADING,$MESSAGE;
 | 
  
    | 88 | 		global $globals;
 | 
  
    | 89 | 		global $database;
 | 
  
    | 90 | 		global $wb;
 | 
  
    | 91 | 		$admin = & $wb;
 | 
  
    | 92 | 		if ($wb->page_access_denied==true) {
 | 
  
    | 93 | 	        echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
 | 
  
    | 94 | 			exit();
 | 
  
    | 95 | 		}
 | 
  
    | 96 | 		if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } }
 | 
  
    | 97 | 		// Make sure block is numeric
 | 
  
    | 98 | 		if(!is_numeric($block)) { $block = 1; }
 | 
  
    | 99 | 		// Include page content
 | 
  
    | 100 | 		if(!defined('PAGE_CONTENT') OR $block!=1) {
 | 
  
    | 101 | 			if ($wb->page_id==0) {
 | 
  
    | 102 | 				if ($wb->default_block_content=='none') {
 | 
  
    | 103 | 					return;
 | 
  
    | 104 | 				}
 | 
  
    | 105 | 				if (is_numeric($wb->default_block_content)) {
 | 
  
    | 106 | 					$page_id=$wb->default_block_content;
 | 
  
    | 107 | 				} else {
 | 
  
    | 108 | 					$page_id=$wb->default_page-id;
 | 
  
    | 109 | 				}				
 | 
  
    | 110 | 			} else {
 | 
  
    | 111 | 				$page_id=$wb->page_id;
 | 
  
    | 112 | 			}
 | 
  
    | 113 | 			// First get all sections for this page
 | 
  
    | 114 | 			$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
 | 
  
    | 115 | 			if($query_sections->numRows() > 0) {
 | 
  
    | 116 | 				// Loop through them and include there modules file
 | 
  
    | 117 | 				while($section = $query_sections->fetchRow()) {
 | 
  
    | 118 | 					$section_id = $section['section_id'];
 | 
  
    | 119 | 					$module = $section['module'];
 | 
  
    | 120 | 					require(WB_PATH.'/modules/'.$module.'/view.php');
 | 
  
    | 121 | 				}
 | 
  
    | 122 | 			}
 | 
  
    | 123 | 		} else {
 | 
  
    | 124 | 			require(PAGE_CONTENT);
 | 
  
    | 125 | 		}
 | 
  
    | 126 | 	}
 | 
  
    | 127 | }
 | 
  
    | 128 | 
 | 
  
    | 129 | if (!function_exists('show_content')) {
 | 
  
    | 130 | 	function show_content($block=1) {
 | 
  
    | 131 | 		page_content($block);
 | 
  
    | 132 | 	}
 | 
  
    | 133 | }
 | 
  
    | 134 | 
 | 
  
    | 135 | if (!function_exists('show_breadcrumbs')) {
 | 
  
    | 136 | 	function show_breadcrumbs($sep=' > ',$tier=1,$links=true) {
 | 
  
    | 137 | 		global $wb;
 | 
  
    | 138 | 		$page_id=$wb->page_id;
 | 
  
    | 139 | 		if ($page_id!=0)
 | 
  
    | 140 | 		{
 | 
  
    | 141 | 	 		global $database;
 | 
  
    | 142 | 			$bca=$wb->page_trail;
 | 
  
    | 143 | 			$counter=0;
 | 
  
    | 144 | 			foreach ($bca as $temp)
 | 
  
    | 145 | 			{
 | 
  
    | 146 | 		        if ($counter>=($tier-1));
 | 
  
    | 147 | 		        {
 | 
  
    | 148 | 					if ($counter>=$tier) echo $sep;
 | 
  
    | 149 | 					$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
 | 
  
    | 150 | 					$page=$query_menu->fetchRow();
 | 
  
    | 151 | 					if ($links==true AND $temp!=$page_id)
 | 
  
    | 152 | 						echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>';
 | 
  
    | 153 | 					else
 | 
  
    | 154 | 					    echo $page['menu_title'];
 | 
  
    | 155 | 		        }
 | 
  
    | 156 | 	            $counter++;
 | 
  
    | 157 | 			}
 | 
  
    | 158 | 		}
 | 
  
    | 159 | 	}
 | 
  
    | 160 | }
 | 
  
    | 161 | 
 | 
  
    | 162 | // Function for page title
 | 
  
    | 163 | if (!function_exists('page_title')) {
 | 
  
    | 164 | 	function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
 | 
  
    | 165 | 		$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
 | 
  
    | 166 | 		$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
 | 
  
    | 167 | 		echo str_replace($vars, $values, $template);
 | 
  
    | 168 | 	}
 | 
  
    | 169 | }
 | 
  
    | 170 | 
 | 
  
    | 171 | // Function for page description
 | 
  
    | 172 | if (!function_exists('page_description')) {
 | 
  
    | 173 | 	function page_description() {
 | 
  
    | 174 | 		echo WEBSITE_DESCRIPTION;
 | 
  
    | 175 | 	}
 | 
  
    | 176 | }
 | 
  
    | 177 | // Function for page keywords
 | 
  
    | 178 | if (!function_exists('page_keywords')) {
 | 
  
    | 179 | 	function page_keywords() {
 | 
  
    | 180 | 		echo WEBSITE_KEYWORDS;
 | 
  
    | 181 | 	}
 | 
  
    | 182 | }
 | 
  
    | 183 | // Function for page header
 | 
  
    | 184 | if (!function_exists('page_header')) {
 | 
  
    | 185 | 	function page_header($date_format = 'Y') {
 | 
  
    | 186 | 		echo WEBSITE_HEADER;
 | 
  
    | 187 | 	}
 | 
  
    | 188 | }
 | 
  
    | 189 | 
 | 
  
    | 190 | // Function for page footer
 | 
  
    | 191 | if (!function_exists('page_footer')) {
 | 
  
    | 192 | 	function page_footer($date_format = 'Y') {
 | 
  
    | 193 | 		global $starttime;
 | 
  
    | 194 | 		$vars = array('[YEAR]', '[PROCESSTIME]');
 | 
  
    | 195 | 		$processtime=array_sum(explode(" ",microtime()))-$starttime;
 | 
  
    | 196 | 		$values = array(date($date_format),$processtime);
 | 
  
    | 197 | 		echo str_replace($vars, $values, WEBSITE_FOOTER);
 | 
  
    | 198 | 	}
 | 
  
    | 199 | }
 | 
  
    | 200 | 
 | 
  
    | 201 | // Begin WB < 2.4.x template compatibility code
 | 
  
    | 202 | 	// Make extra_sql accessable through private_sql
 | 
  
    | 203 | 	$private_sql = $extra_sql;
 | 
  
    | 204 | 	$private_where_sql = $extra_where_sql;
 | 
  
    | 205 | 	// Query pages for menu
 | 
  
    | 206 | 	$menu1 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '0' AND $extra_where_sql ORDER BY position ASC");
 | 
  
    | 207 | 	// Check if current pages is a parent page and if we need its submenu
 | 
  
    | 208 | 	if(PARENT == 0) {
 | 
  
    | 209 | 		// Get the pages submenu
 | 
  
    | 210 | 		$menu2 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '".PAGE_ID."' AND $extra_where_sql ORDER BY position ASC");
 | 
  
    | 211 | 	} else {
 | 
  
    | 212 | 		// Get the pages submenu
 | 
  
    | 213 | 		$menu2 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '".PARENT."' AND $extra_where_sql ORDER BY position ASC");
 | 
  
    | 214 | 	}
 | 
  
    | 215 | // End WB < 2.4.x template compatibility code
 | 
  
    | 216 | // Include template file
 | 
  
    | 217 | 
 | 
  
    | 218 | 
 | 
  
    | 219 | ?>
 |