<?php
/***************************************************************************
* mides.ru
* -------------------
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_chanceace.' . $phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
if ( !$userdata['session_logged_in'] )
{
$redirect = "chanceace.$phpEx";
$redirect .= ( isset($user_id) ) ? '&user_id=' . $user_id : '';
header('Location: ' . append_sid("login.$phpEx?redirect=$redirect", true));
}
// POKIES BEGIN
if ($board_config['chance_onoff'] == off) {
message_die(GENERAL_MESSAGE, $lang['chanceace_disabled']);
}
$page_title = $lang['chance_title'];
if ($_POST["bet"] == '') {
$layout = '
<tr>
<td class="row1"><form method="POST"><input type="submit" value="Испытай свою удачу" name="bet" class="button"></form></td>
</tr>';
$wnlose = '
<tr>
<td class="row1">'.$lang['chance_welcome'].' '.$board_config['chance_playprice'].' '.$board_config['points_name'].''.$lang['chance_welcome2'].'</td>
</tr>
<tr>
<td class="row1"><b>'.$lang['chance_youhave'].' '.$userdata['user_points'].' '.$board_config['points_name'].''.$lang['chance_afterpoints'].'</b><br>
'.$lang['chance_played'].' '.$board_config['chance_played'].' '.$lang['chance_times'].'<br>
'.$lang['chance_given'].' '.$board_config['chance_given'].' '.$board_config['points_name'].''.$lang['chance_afterpoints'].'<br>'.$lang['chance_taken'].' '.$board_config['chance_taken'].' '.$board_config['points_name'].''.$lang['chance_afterpoints'].'
</td>
</tr>';
}
else
{
if ($userdata['user_points'] < $board_config['chance_playprice']) {
$layout = '<br>'.$lang['chance_minimum'].' '.$board_config['chance_playprice'].' '.$board_config['points_name'].''.$lang['chance_minimum2'].'<br>';
}
else {
$xtraplay = $board_config['chance_played'] + 1;
$sql = "update " . CONFIG_TABLE . " set config_value='$xtraplay' where config_name='chance_played'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating chance machine total played, ', __LINE__, __FILE__, $sql); }
$frstspot = '';
$scndspot = '';
$thrdspot = '';
// Random
$frstno = rand (1, 50);
$scndno = rand (1, 50);
$thrdno = rand (1, 50);
// Image results
// FIRST
if (($frstno >= 1) && ($frstno <= 20)) {
$frstspot = 'aceofclubs';
$aceofclubscount++;
}
if (($frstno >= 21) && ($frstno <= 35)) {
$frstspot = 'aceofdiamonds';
$aceofdiamondscount++;
}
if (($frstno >= 36) && ($frstno <= 45)) {
$frstspot = 'aceofhearts';
$aceofheartscount++;
}
if (($frstno >= 46) && ($frstno <= 50)) {
$frstspot = 'aceofspades';
$starcount++;
}
// SECOND
if (($scndno >= 1) && ($scndno <= 20)) {
$scndspot = 'aceofclubs';
$aceofclubscount++;
}
if (($scndno >= 21) && ($scndno <= 35)) {
$scndspot = 'aceofdiamonds';
$aceofdiamondscount++;
}
if (($scndno >= 36) && ($scndno <= 45)) {
$scndspot = 'aceofhearts';
$aceofheartscount++;
}
if (($scndno >= 46) && ($scndno <= 50)) {
$scndspot = 'aceofspades';
$starcount++;
}
// THIRD
if (($thrdno >= 1) && ($thrdno <= 20)) {
$thrdspot = 'aceofclubs';
$aceofclubscount++;
}
if (($thrdno >= 21) && ($thrdno <= 35)) {
$thrdspot = 'aceofdiamonds';
$aceofdiamondscount++;
}
if (($thrdno >= 36) && ($thrdno <= 45)) {
$thrdspot = 'aceofhearts';
$aceofheartscount++;
}
if (($thrdno >= 46) && ($thrdno <= 50)) {
$thrdspot = 'aceofspades';
$starcount++;
}
// END Image results
$rslt = 'Sorry, you didnt win';
// Adds to the pool for every play.
$updatetaken = $board_config['chance_playprice'] + $board_config['chance_taken'];
$sql = "update " . CONFIG_TABLE . " set config_value='$updatetaken' where config_name='chance_taken'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating chance machine given or taken amount, ', __LINE__, __FILE__, $sql); }
if ($aceofclubscount == 3) {
$rslt = $lang['chance_winaceofclubs'].' '.$board_config['chance_aceofclubs'].' '.$board_config['points_name'].''.$lang['chance_afterpoints'];
$togive = ($userdata['user_points'] + $board_config['chance_aceofclubs']) - $board_config['chance_playprice'];
$sql = "update " . USERS_TABLE . " set user_points='$togive' where user_id='{$userdata['user_id']}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); }
$updategiven = $board_config['chance_aceofclubs'] + $board_config['chance_given'];
$sql = "update " . CONFIG_TABLE . " set config_value='$updategiven' where config_name='chance_given'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating chanceace machine given or taken amount, ', __LINE__, __FILE__, $sql); }
} else {
$countr = $countr + 1;
}
if ($aceofdiamondscount == 3) {
$rslt = $lang['chance_winaceofdiamonds'].' '.$board_config['chance_aceofdiamonds'].' '.$board_config['points_name'].''.$lang['chance_afterpoints'];
$togive = ($userdata['user_points'] + $board_config['chance_aceofdiamonds']) - $board_config['chance_playprice'];
$sql = "update " . USERS_TABLE . " set user_points='$togive' where user_id='{$userdata['user_id']}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); }
$updategiven = $board_config['chance_aceofdiamonds'] + $board_config['chance_given'];
$sql = "update " . CONFIG_TABLE . " set config_value='$updategiven' where config_name='chance_given'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating chanceace machine given or taken amount, ', __LINE__, __FILE__, $sql); }
} else {
$countr = $countr + 1;
}
if ($aceofheartscount == 3) {
$rslt = $lang['chance_winaceofhearts'].' '.$board_config['chance_aceofhearts'].' '.$board_config['points_name'].''.$lang['chance_afterpoints'];
$togive = ($userdata['user_points'] + $board_config['chance_aceofhearts']) - $board_config['chance_playprice'];
$sql = "update " . USERS_TABLE . " set user_points='$togive' where user_id='{$userdata['user_id']}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); }
$updategiven = $board_config['chance_aceofhearts'] + $board_config['chance_given'];
$sql = "update " . CONFIG_TABLE . " set config_value='$updategiven' where config_name='chance_given'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Slot machine given or taken amount, ', __LINE__, __FILE__, $sql); }
} else {
$countr = $countr + 1;
}
if ($aceofspadescount == 3) {
$rslt = $lang['chance_winstar'].' '.$board_config['chance_aceofspades'].' '.$board_config['points_name'].''.$lang['chance_afterpoints'];
$togive = ($userdata['user_points'] + $board_config['chance_aceofspades']) - $board_config['chance_playprice'];
$sql = "update " . USERS_TABLE . " set user_points='$togive' where user_id='{$userdata['user_id']}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); }
$updategiven = $board_config['chance_aceofspades'] + $board_config['chance_given'];
$sql = "update " . CONFIG_TABLE . " set config_value='$updategiven' where config_name='chance_given'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Slot machine given or taken amount, ', __LINE__, __FILE__, $sql); }
} else {
$countr = $countr + 1;
}
if ($board_config['chance_minorprize'] != 0) {
if (($aceofclubscount == 2) || ($aceofdiamondscount == 2) || ($aceofheartscount == 2) || ($starcount == 2)) {
$rslt = $lang['chance_win2'].' '.$board_config['chance_minorprize'].' '.$board_config['points_name'].''.$lang['chance_afterpoints'];
$togive = ($userdata['user_points'] + $board_config['chance_minorprize']) - $board_config['chance_playprice'];
$sql = "update " . USERS_TABLE . " set user_points='$togive' where user_id='{$userdata['user_id']}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); }
$updategiven = $board_config['chance_minorprize'] + $board_config['chance_given'];
$sql = "update " . CONFIG_TABLE . " set config_value='$updategiven' where config_name='chance_given'";
if ( !($db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Updating Slot machine given or taken amount, ', __LINE__, __FILE__, $sql); }
} else {
$countr = $countr + 1;
}
}
if ($board_config['chance_minorprize'] != 0) {
if ($countr == 5) {
$rslt = $lang['chance_didntwin'];
$totake = $userdata['user_points'] - $board_config['chance_playprice'];
$sql = "update " . USERS_TABLE . " set user_points='$totake' where user_id='{$userdata['user_id']}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); }
}
} else {
if ($countr == 4) {
$rslt = $lang['chance_didntwin'];
$totake = $userdata['user_points'] - $board_config['chance_playprice'];
$sql = "update " . USERS_TABLE . " set user_points='$totake' where user_id='{$userdata['user_id']}'";
if ( !($usresult = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Points Information!'); } }
}
// Show table
$layout = '
<div class="body"><img src = "images/chanceace/'.$frstspot.'.gif"> <img src = "images/chanceace/'.$scndspot.'.gif"> <img src = "images/chanceace/'.$thrdspot.'.gif"><br>';
$wnlose = '
<tr>
<td class="row1" width="100%">'.$rslt.'<br><a href="'.append_sid('ChanceAce.'.$phpEx).'">'.$lang['chance_tryagain'].'</a>';
}
}
// POKIES END
$chanceloc = ' -> <a href="'.append_sid("ChanceAce.".$phpEx).'" class="nav">'.$lang['chance_title'].'</a>';
// Includes
include($phpbb_root_path . 'includes/page_header.' . $phpEx);
$template->assign_vars(array(
'LAYOUT' => $layout,
'WINLOSE' => $wnlose,
'TTL' => $lang['chance_title'],
'CHANCELOCATION' => $chanceloc,
));
$template->assign_block_vars('', array());
$template->set_filenames(array(
'body' => 'chance_body.tpl')
);
// Generate page
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.' . $phpEx);
?>