Copyright (C) 2004-2009, Ryan Djurovich Website Baker is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Website Baker is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Website Baker; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ header("Location: ../index.php"); ?>())); // Include config file require_once(dirname(__FILE__).'/config.php'); // Check if the config file has been set-up if(!defined('WB_PATH')) { header("Location: install/index.php"); exit(0); } require_once(WB_PATH.'/framework/class.frontend.php'); // Create new frontend object $wb = new frontend(); // Figure out which page to display // Stop processing if intro page was shown $wb->page_select() or die(); // Collect info about the currently viewed page // and check permissions $wb->get_page_details(); // Collect general website settings $wb->get_website_settings(); // Load functions available to templates, modules and code sections // also, set some aliases for backward compatibility require(WB_PATH.'/framework/frontend.functions.php'); // redirect menu-link $this_page_id = PAGE_ID; if(version_compare(phpversion(), '4.3', '>=')) $php43 = TRUE; else $php43 = FALSE; $query_this_module = $database->query("SELECT module, block FROM ".TABLE_PREFIX."sections WHERE page_id = '$this_page_id' AND module = 'menu_link'"); if($query_this_module->numRows() == 1) { // This is a menu_link. Get link of target-page and redirect // get target_page_id $table = TABLE_PREFIX.'mod_menu_link'; $query_tpid = $database->query("SELECT * FROM $table WHERE page_id = '$this_page_id'"); if($query_tpid->numRows() == 1) { $res=$query_tpid->fetchRow(); $target_page_id = $res['target_page_id']; $r_type = $res['redirect_type']; $anchor = $res['anchor']; $extern = $res['extern']; if($anchor != '0') $anchor = ''.$anchor; else $anchor = FALSE; // set redirect-type if($r_type=='301') { if($php43) @header('HTTP/1.1 301 Moved Permanently', TRUE, 301); else @header('HTTP/1.1 301 Moved Permanently'); } if($target_page_id == -1) { if($extern!='') { header("Location: $extern".($anchor?'#'.$anchor:'')); } } else { // get link of target-page $table = TABLE_PREFIX.'pages'; $query_linf_REQUEST['lmpTabModus'][3])) $lmpTabModus = intval($_REQUEST['lmpTabModus'][3]); else $lmpTabModus = 0; $lmpMenu = LmpMenu(1, $lmpLeagueSport, $lmpLeagueID, 400, 0, 0, 0, 0); LmpPrepareAutoImport($lmpLeagueID, $lmpVersion); LmpShowUserRanking($lmpLeagueSport, $lmpLeagueID, $lmpTabModus); eval("\$tpl->output(\"".$tpl->get("league_mp_index")."\");"); exit(); } if ($action == "showgamestatsmatchdaystoggle") { if (checkpermissions('can_league_mp_read_game') == 0) access_error(); if (isset($_REQUEST['lmpLeagueSport'][4])) $lmpLeagueSport = intval($_REQUEST['lmpLeagueSport'][4]); else $lmpLeagueSport = 0; if (isset($_REQUEST['lmpLeagueID'][4])) $lmpLeagueID = intval($_REQUEST['lmpLeagueID'][4]); else $lmpLeagueID = 0; if (isset($_REQUEST['lmpTabModus'][4])) $lmpTabModus = intval($_REQUEST['lmpTabModus'][4]); else $lmpTabModus = 0; $lmpMenu = LmpMenu(1, $lmpLeagueSport, $lmpLeagueID, 500, 0, 0, 0, 0); LmpPrepareAutoImport($lmpLeagueID, $lmpVersion); $lmpLeagueDetails = $db->query_first("SELECT * FROM bb".$n."_lmp_000000_leagues WHERE leagueID = '".$lmpLeagueID."'"); $lmpSpecialTips = $lmpLeagueDetails['specialTips']; if ($lmpSpecialTips == 1) { LmpShowSpecialTipOverview($lmpLeagueSport, $lmpLeagueID, $lmpTabModus, 500); } else { $lmpContentHeader = $lang->items['LANG_LEAGUE_MP_GAMESTATS']; $lmpContentDesc = $lang->get("LANG_LEAGUE_MP_LEAGUE_STANDING_DESC"); eval("\$lmpIndexContent .= \"".$tpl->get("league_mp_index_content")."\";"); } eval("\$tpl->output(\"".$tpl->get("league_mp_index")."\");"); exit(); } if ($action == "showgamestatsmatchdays") { if (checkpermissions('can_league_mp_read_game') == 0) access_error(); if (isset($_REQUEST['lmpLeagueSport'][4])) $lmpLeagueSport = intval($_REQUEST['lmpLeagueSport'][4]); else $lmpLeagueSport = 0; if (isset($_REQUEST['lmpLeagueID'][4])) $lmpLeagueID = intval($_REQUEST['lmpLeagueID'][4]); else $lmpLeagueID = 0; if (isset($_REQUEST['lmpTabModus'][4])) $lmpTabModus = intval($_REQUEST['lmpTabModus'][4]); else $lmpTabModus = 0; $lmpMenu = LmpMenu(1, $lmpLeagueSport, $lmpLeagueID, 500, 0, 0, 14, 1); LmpPrepareAutoImport($lmpLeagueID, $lmpVersion); $lmpLeagueDetails = $db->query_first("SELECT * FROM bb".$n."_lmp_000000_leagues WHERE leagueID = '".$lmpLeagueID."'"); $lmpSpecialTips = $lmpLeagueDetails['specialTips']; if ($lmpSpecialTips == 1) { LmpShowSpecialTipOverview($lmpLeagueSport, $lmpLeagueID, $lmpTabModus, 500); } else { $lmpContentHeader = $lang->items['LANG_LEAGUE_MP_GAMESTATS']; $lmpContentDesc = $lang->get("LANG_LEAGUE_MP_LEAGUE_STANDING_DESC"); eval("\$lmpIndexContent .= \"".$tpl->get("league_mp_index_content")."\";"); } eval("\$tpl->output(\"".$tpl->get("league_mp_index")."\");"); exit(); } if ($action == "showgamestatsbymatchday") { if (checkpermissions('can_league_mp_read_stats') == 0) access_error(); if (isset($_REQUEST['lmpLeagueSport'][14])) $lmpLeagueSport = intval($_REQUEST['lmpLeagueSport'][14]); else $lmpLeagueSport = 0; if (isset($_REQUEST['lmpLeagueID'][14])) $lmpLeagueID = intval($_REQUEST['lmpLeagueID'][14]); else $lmpLeagueID = 0; if (isset($_REQUEST['lmpTabModus'][14])) $lmpTabModus = intval($_REQUEST['lmpTabModus'][14]); else $lmpTabModus = 0; if (isset($_REQUEST['lmpMatchDay'][14])) $lmpMatchDay = intval($_REQUEST['lmpMatchDay'][14]); else $lmpMatchDay = 0; $lmpMenu = LmpMenu(1, $lmpLeagueSport, $lmpLeagueID, 500, 0, $lmpMatchDay, 14, 0); LmpPrepareAutoImport($lmpLeagueID, $lmpVersion); LmpShowGameStats($lmpLeagueSport, $lmpLeagueID, $lmpTabModus, $lmpMatchDay); eval("\$tpl->output(\"".$tpl->get("league_mp_index")."\");"); exit(); } if ($action == "showgamemembers") { if (checkpermissions('can_league_mp_read_game') == 0) access_error(); if (isset($_REQUEST['lmpLeagueSport'][5])) $lmpLeagueSport = intval($_REQUEST['lmpLeagueSport'][5]); else $lmpLeagueSport = 0; if (isset($_REQUEST['lmpLeagueID'][5])) $lmpLeagueID = intval($_REQUEST['lmpLeagueID'][5]); else $lmpLeagueID = 0; if (isset($_REQUEST['lmpTabModus'][5])) $lmpTabModus = intval($_REQUEST['lmpTabModus'][5]); else $lmpTabModus = 0; $lmpMenu = LmpMenu(1, $lmpLeagueSport, $lmpLeagueID, 600, 0, 0, 0, 0); LmpPrepareAutoImport($lmpLeagueID, $lmpVersion); LmpShowGameMembers($lmpLeagueSport, $lmpLeagueID, $lmpTabModus); eval("\$tpl->output(\"".$tpl->get("league_mp_index")."\");"); exit(); } if ($action == "showtipoverviewmatchdaystoggle") { if (checkpermissions('can_league_mp_use_game') == 0) access_error(); if (isset($_REQUEST['lmpLeagueSport'][6])) $lmpLeagueSport = intval($_REQUEST['lmpLeagueSport'][6]); else $lmpLeagueSport = 0; if (isset($_REQUEST['lmpLeagueID'][6])) $lmpLeagueID = intval($_REQUEST['lmpLeagueID'][6]); else $lmpLeagueID = 0; if (isset($_REQUEST['lmpTabModus'][6])) $lmpTabModus = intval($_REQUEST['lmpTabModus'][6]); else $lmpTabModus = 0; $lmpMenu = LmpMenu(1, $lmpLeagueSport, $lmpLeagueID, 700, 0, 0, 0, 0); LmpPrepareAutoImport($lmpLeagueID, $lmpVersion); $lmpLeagueDetails = $db->query_first("SELECT * FROM bb".$n."_lmp_000000_leagues WHERE leagueID = '".$lmpLeagueID."'"); $lmpTipFixedMatchesOnly = intval($lmpLeagueDetails['tipFixedMatchesOnly']); $lmpContentHeader = $lang->items['LANG_LEAGUE_MP_LEAGUE_HEADER_SELECTTIPS']; $lmpContentDesc = $lang->get("LANG_LEAGUE_MP_LEAGUE_TIP_DESC"); $lmpJokerActive = intval($lmpLeagueDetails['jokerActive']); $lmpJokerNumbersMatchDay = intval($lmpLeagueDetails['jokerNumbersMatchDay']); $lmpJokerNumbersSpecialTips = intval($lmpLeagueDetails['jokerNumbersSpecialTips']); $lmpJokerFstr_replace($varrefs[0][$i],$new,$code); } // This will handle the remaining root-level varrefs $code=preg_replace('#\{([a-z0-9\-_]*?)\}#is','\' . ( ( isset($this->_tpldata[\'.\'][0][\'\1\']) ) ? $this->_tpldata[\'.\'][0][\'\1\'] : \'\' ) . \'',$code); // Break it up into lines. $code_lines=explode("\n",$code); $block_nesting_level=0; $block_names=array(); $block_names[0]="."; // Second: prepend echo ', append ' . "\n"; to each line. $line_count=sizeof($code_lines); for ($i=0; $i < $line_count; $i++) { $code_lines[$i]=chop($code_lines[$i]); if (preg_match('##',$code_lines[$i],$m)) { $n[0]=$m[0]; $n[1]=$m[1]; // Added: dougk_ff7-Keeps templates from bombing if begin is on the same line as end.. I think. :) if (preg_match('##',$code_lines[$i],$n)) { $block_nesting_level++; $block_names[$block_nesting_level]=$m[1]; if ($block_nesting_level < 2) { // Block is not nested. $code_lines[$i]='$_' . $n[1] . '_count = ( isset($this->_tpldata[\'' . $n[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $n[1] . '.\']) : 0;'; $code_lines[$i].="\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)'; $code_lines[$i].="\n" . '{'; } else { // This block is nested. // Generate a namespace string for this block. $namespace=implode('.',$block_names); // strip leading period from root level.. $namespace=substr($namespace,2); // Get a reference to the data array for this block that depends on the // current indices of all parent blocks. $varref=$this->generate_block_data_ref($namespace,false); // Create the for loop code to iterate over this block. $code_lines[$i]='$_' . $n[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;'; $code_lines[$i].="\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)'; $code_lines[$i].="\n" . '{'; } // We have the end of a block. unset($block_names[$block_nesting_level]); $block_nesting_level--; $code_lines[$i].='} // END ' . $n[1]; $m[0]=$n[0]; $m[1]=$n[1]; } else { // We have the start of a block. $block_nesting_level++; $block_names[$block_nesting_level]=$m[1]; if ($block_nesting_level < 2) { // Block is not nested. $code_lines[$i]='$_' . $m[1] . '_count = ( isset($this->_tpldata[\'' . $m[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $m[1] . '.\']) : 0;'; $code_lines[$i].="\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)'; $code_lines[$i].="\n" . '{'; } else { // This block is nested. // Generate a namespace string for this block. $namespace=implode('.',$block_names); // strip leading period from root level.. $namespace=substr($namespace,2); // Get a reference to the data array for this block that depends on the // current indices of all parent blocks. $varref=$this->generate_block_data_ref($namespace,false); // Create the for loop code to iterate over this block. $code_lines[$i]='$_' . $m[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;'; $code_lines[$i].="\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)'; $code_lines[$i].="\n" . '{'; } } } else if (preg_match('##',$code_lines[$i],$m)) { // We have the end of a block. unset($block_names[$block_nesting_level]); $block_nesting_level--; $code_lines[$i]='} // END ' . $m[1]; } else { // We have an ordinary line of code. if (!$do_not_echo) { $code_lines[$i]='echo \'' . $code_lines[$i] . '\' . "\\n";'; } else { $code_lines[$i]='$' . $retvar . '.= \'' . $code_lines[$i] . '\' . "\\n";'; } } } // Bring it back into a single string of lines of code. $code=implode("\n",$code_lines); return $code; } /** * Generates a reference to the given variable inside the given (possibly nested) * block namespace. This is a string of the form: * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' * It's ready to be inserted into an "echo" line in one of the templates. * NOTE: expects a trailing "." on the namespace. */ function generate_block_varref($namespace, $varname) { // Strip the trailing period. $namespace=substr($namespace,0,strlen($namespace) - 1); // Get a reference to the data block for this namespace. $varref=$this->generate_block_data_ref($namespace,true); // Prepend the necessary code to stick this in an echo line. // Append the variable reference. $varref.='[\'' . $varname . '\']'; $varref='\' . ( ( isset(' . $varref . ') ) ? ' . $varref . ' : \'\' ) . \''; return $varref; } /** * Generates a reference to the array of data values for the given * (possibly nested) block namespace. This is a string of the form: * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] * * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. * NOTE: does not expect a trailing "." on the blockname. */ function generate_block_data_ref($blockname, $include_last_iterator) { // Get an array of the blocks involved. $blocks=explode(".",$blockname); $blockcount=sizeof($blocks) - 1; $varref='$this->_tpldata'; // Build up the string with everything but the last child. for ($i=0; $i < $blockcount; $i++) { $varref.='[\'' . $blocks[$i] . '.\'][$_' . $blocks[$i] . '_i]'; } // Add the block reference for the last child. $varref.='[\'' . $blocks[$blockcount] . '.\']'; // Add the iterator for the last child if requried. if ($include_last_iterator) { $varref.='[$_' . $blocks[$blockcount] . '_i]'; } return $varref; } } ?>