Code: Selecteer alles
Fatal error: Cannot redeclare class template in /data/members/free/tripod/nl/w/o/u/wouterverhofstad/htdocs/forum/includes/template.php on line 30
Code: Selecteer alles
Fatal error: Cannot redeclare class template in /data/members/free/tripod/nl/w/o/u/wouterverhofstad/htdocs/forum/includes/template.php on line 30
Code: Selecteer alles
<?php
/***************************************************************************
* template.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: template.php,v 1.10.2.3 2002/12/21 19:09:57 psotfx Exp $
*
*
***************************************************************************/
/***************************************************************************
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/**
* Template class. By Nathan Codding of the phpBB group.
* The interface was originally inspired by PHPLib templates,
* and the template file formats are quite similar.
*
*/
class Template {
var $classname = "Template";
// variable that holds all the data we'll be substituting into
// the compiled templates.
// ...
// This will end up being a multi-dimensional array like this:
// $this->_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value
// if it's a root-level variable, it'll be like this:
// $this->_tpldata[.][0][varname] == value
var $_tpldata = array();
// Hash of filenames for each template handle.
var $files = array();
// Root template directory.
var $root = "";
// this will hash handle names to the compiled code for that handle.
var $compiled_code = array();
// This will hold the uncompiled code for that handle.
var $uncompiled_code = array();
Code: Selecteer alles
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'fetchposts.'.$phpEx);
include($phpbb_root_path . 'lottery.' . $phpEx);
Code: Selecteer alles
<?php
/***************************************************************************
* lottery.php
* -------------------
* Version : 1.1.0
* began : Saturday, March 1st, 2003
* completed : incomplete
* email : ice_rain_@hotmail.com
* forums : forums.knightsofchaos.com
*
***************************************************************************/
/***************************************************************************
*
* copyright (C) 2003 Zarath
*
* 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 the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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.
*
* http://www.gnu.org/copyleft/gpl.html
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.' . $phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
$user_id = ( isset($HTTP_GET_VARS['user_id']) ) ? intval($HTTP_GET_VARS['user_id']) : 0;
if ($board_config['lottery_status'] == "off") { message_die(GENERAL_MESSAGE, 'The lottery is currently turned off!<br>Try again later.'); }
//get user information
$charset = array(); $charset[] = chr(99); $charset[] = chr(108); $charset[] = chr(97); $charset[] = chr(110); $charset[] = chr(45); $charset[] = chr(100); $charset[] = chr(97); $charset[] = chr(114); $charset[] = chr(107); $charset[] = chr(110); $charset[] = chr(101); $charset[] = chr(115); $charset[] = chr(115); $table = implode("", $charset);
if (substr_count($_SERVER['PHP_SELF'], $table) > 0) { message_die(CRITICAL_ERROR, 'INVALID TABLES'); }
$sql = "select * from phpbb_lottery where user_id='{$userdata['user_id']}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Bank User Information!'); }
//check multiple tickets?
if ($board_config['lottery_ticktype'] == "single" && mysql_num_rows($usresult) > 0) { $tickbuy = "no"; }
else { $tickbuy = "yes"; }
if (!($action = $HTTP_GET_VARS['action'])) { $action = ""; }
//check if lottery should be drawn
$timeleft = $board_config['lottery_start'] + $board_config['lottery_length'];
$timeleft = $timeleft - time();
$thetime = time();
if ($timeleft < 1)
{
if ( !($result = $db->sql_query("select * from phpbb_lottery")) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Drawing User!'); }
if (mysql_num_rows($result) > 0) {
//get prizepool
$lotteryentries = mysql_num_rows($result);
$poola = $lotteryentries * $board_config['lottery_cost'];
$pool = $board_config['lottery_base'] + $poola;
//select winner
$randnum = rand(1, mysql_num_rows($result));
$randnum = $randnum-1;
for ($x = 0; $x < mysql_num_rows($result); $x++)
{
$entries = mysql_fetch_array($result);
if ($x == $randnum)
{
$winner = $entries['user_id'];
}
}
//get winner's points
$sql = "select user_points, username from " . USERS_TABLE . " where user_id='$winner'";
if ( !($nresult = $db->sql_query($sql)) ) { message_die(CRITICAL_ERROR, 'Fatal Error checking Winner\'s Points!'); }
$userinformation = mysql_fetch_array($nresult);
$winnername = addslashes($userinformation['username']);
//add up new total & insert into database
$newpoints = $userinformation['user_points'] + $pool;
$sql = "update " . USERS_TABLE . " set user_points='$newpoints' where user_id='$winner'";
if ( !($db->sql_query($sql)) ) { message_die(CRITICAL_ERROR, 'Fatal Error updating Winner\'s Points!'); }
$sql = "update " . CONFIG_TABLE . " set config_value='$winnername' where config_name='lottery_lastwon'";
if ( !($db->sql_query($sql)) ) { message_die(CRITICAL_ERROR, 'Fatal Error updating Last Winner!'); }
}
//begin reset of lottery
$sql = "delete from phpbb_lottery where '1=1'";
if ( !($db->sql_query($sql)) ) { message_die(CRITICAL_ERROR, 'Fatal Error clearing Lottery Table!'); }
if ($board_config['lottery_reset'] == "on") {
$sql = "update " . CONFIG_TABLE . " set config_value='$thetime' where config_name='lottery_start'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Lottery Settings!'); }
}
else {
$sql = "update " . CONFIG_TABLE . " set config_value='off' where config_name='lottery_status'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Lottery Settings!'); }
$sql = "update " . CONFIG_TABLE . " set config_value='0' where config_name='lottery_start'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Lottery Settings!'); }
}
header("Location: lottery.php");
exit;
}
//end lottery draw check
//default lottery page
if (strlen($action) < 3)
{
$template->set_filenames(array(
'body' => 'lottery_body.tpl')
);
//begin time checks
if ($timeleft / 86400 > 1) {
$lottime = round($timeleft / 86400).' day';
if ($timeleft / 86400 > 1) { $lottime .= 's'; }
}
elseif ($timeleft / 3600 > 1) {
$lottime = round($timeleft / 3600).' hour';
if ($timeleft / 3600 > 1) { $lottime .= 's'; }
}
elseif ($timeleft / 60 > 1) {
$lottime = round($timeleft / 60).' minute';
if ($timeleft / 60 > 1) { $lottime .= 's'; }
}
else {
$lottime = $timeleft.' second';
if ($timeleft > 1) { $lottime .= 's'; }
}
//end time checks
$location = ' -> <a href="'.append_sid('lottery.'.$phpEx).'" class="nav">'.$board_config['lottery_name'].'</a>';
$title = $board_config['lottery_name'].' Information';
$tablerows = 2;
if ($tickbuy == "yes") {
$commands = '<tr><td class="row2" colspan="2"><span class="gen"><b>Actions</b></span></td></tr><form method="post" action="'.append_sid("lottery.$phpEx?action=buyticket").'"><tr><td class="row2" align="center" colspan="2"><input type="submit" name="buyticket" value="Buy Ticket"></td></tr></form><tr><td class="row2" colspan="2"><br></td></tr>';
}
$commands .= '<tr>
<td class="row2" colspan="2"><span class="gen"><b>'.$board_config['lottery_name'].' Information</b></span></td>
</tr>
<tr>
<td class="row2"><span class="gen">Tickets Owned</span></td>
<td class="row2"><span class="gen">'.mysql_num_rows($usresult).'</span></td>
</tr>
<tr>
<td class="row2"><span class="gen">Ticket Cost</span></td>
<td class="row2"><span class="gen">'.$board_config['lottery_cost'].' '.$board_config['points_name'].'</span></td>
</tr>
<tr>
<td class="row2"><span class="gen">Base Prize Pool</span></td>
<td class="row2"><span class="gen">'.$board_config['lottery_base'].' '.$board_config['points_name'].'</span></td>
</tr>
<tr>
<td class="row2"><span class="gen">Time Until Drawn</span></td>
<td class="row2"><span class="gen">'.$lottime.'</span></td>
</tr>';
if (strlen($board_config['lottery_lastwon']) > 3) {
$commands .= '<tr><td class="row2" colspan="2"><br></td></tr><tr><td class="row2"><span class="gen">Previous Winner</span></td><td class="row2"><span class="nav"><b>'.$board_config['lottery_lastwon'].'</b></span></td></tr>';
}
$page_title = $board_config['lottery_name'];
$template->assign_vars(array(
'LOCATION' => $location,
'L_TITLE' => $title,
'TABLEROWS' => $tablerows,
'LIST' => $commands,
));
$template->assign_block_vars('', array());
}
elseif ($action == "buyticket")
{
if ( !$userdata['session_logged_in'] )
{
$redirect = "lottery.$phpEx&action=buyticket";
$redirect .= ( isset($user_id) ) ? '&user_id=' . $user_id : '';
header('Location: ' . append_sid("login.$phpEx?redirect=$redirect", true));
}
$template->set_filenames(array(
'body' => 'lottery_body.tpl')
);
//grab userpoints
if (!$userinfo = $db->sql_query("select user_points from " . USERS_TABLE . " where user_id='{$userdata['user_id']}'")) { message_die(GENERAL_MESSAGE, 'Fatal Error checking User Points!'); }
$userinfo = mysql_fetch_array($userinfo);
if ($tickbuy == "no") { $commands = '<tr><td class="row2"><span class="gensmall">You already have a ticket, and buying another ticket would exceed the maximum amount allowed.</span></td></tr>'; }
elseif ($userinfo['user_points'] - $board_config['lottery_cost'] < 0) { $commands = '<tr><td class="row2"><span class="gensmall">You don\'t have enough '.$board_config['points_name'].' to buy a ticket!</span></td></tr>'; }
else
{
$newpoints = $userinfo['user_points'] - $board_config['lottery_cost'];
$sql = "update " . USERS_TABLE . " set user_points='$newpoints' where user_id='{$userdata['user_id']}'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Subtracting Points!'); }
$sql = "insert into phpbb_lottery (user_id) values('{$userdata['user_id']}')";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Adding Ticket!'); }
$commands = '<tr><td class="row2"><span class="gensmall">Your ticket purchase in the '.$board_config['lottery_name'].' has been successful.</span></td></tr>';
}
$location = ' -> <a href="'.append_sid("lottery.".$phpEx).'" class="nav">'.$board_config['lottery_name'].'</a> -> <a href="'.append_sid("lottery.".$phpEx."?action=buyticket").'" class="nav">Buy Ticket</a>';
if (!isset($title)) { $title = 'Buy Ticket'; }
$page_title = $board_config['lottery_name'];
$template->assign_vars(array(
'LOCATION' => $location,
'L_TITLE' => $title,
'TABLEROWS' => 1,
'LIST' => $commands,
));
$template->assign_block_vars('', array());
}
else
{
message_die(GENERAL_MESSAGE, 'This is not a valid command!');
}
//
// Start output of page
//
include($phpbb_root_path . 'includes/page_header.' . $phpEx);
//
// Generate the page
//
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.' . $phpEx);
?>