1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| <?php
class ShowBuyPremiumPage extends AbstractPage
{
function __construct()
{
parent::__construct();
}
function show(){
global $USER, $PLANET, $LNG, $UNI, $CONF,$resource,$pricelist;
$prem_s_build = HTTP::_GP('prem_s_build', 0);
$prem_o_build = HTTP::_GP('prem_o_build', 0);
$prem_button = HTTP::_GP('prem_button', 0);
$prem_leveling = HTTP::_GP('prem_leveling', 0);
$prem_bank_ally = HTTP::_GP('prem_bank_ally', 0);
$cost_prem = HTTP::_GP('cost_prem', 0);
$count_day = HTTP::_GP('count_day', 0);
$bonus1 = 0;
if($USER['premium_until'] > TIMESTAMP )
$bonus1 = $USER['prem_s_build'];
$bonus2 = 0;
if($USER['premium_until'] > TIMESTAMP )
$bonus2 = $USER['prem_o_build'];
$bonus3 = 0;
if($USER['premium_until'] > TIMESTAMP )
$bonus3 = $USER['prem_button'];
$bonus4 = 0;
if($USER['premium_until'] > TIMESTAMP)
$bonus4 = $USER['prem_leveling'];
$bonus5 = 0;
if($USER['premium_until'] > TIMESTAMP)
$bonus5 = $USER['prem_bank_ally'];
if($_POST){
//enough dm ?
if($USER['darkmatter'] < 150000){
$this->printMessage("Not enough DM", true, array('game.php?page=BuyPremium', 2));
die();
}
// if($USER['premium_until'] > TIMESTAMP){
//$this->printMessage("You already have premium account", true, array('game.php?page=BuyPremium', 2));
//die();
//}
//seems legit, go forward and see what needs to be done
//1. remove dm
$USER['darkmatter'] -= 150000;
$GLOBALS['DATABASE']->query("
Update
".USERS."
SET
`prem_s_build` = ".$prem_s_build.",
`prem_o_build` = ".$prem_o_build.",
`prem_button` = ".$prem_button.",
`prem_leveling` = ".$prem_leveling.",
`prem_bank_ally` = ".$prem_bank_ally.",
`premium_until` = ".(TIMESTAMP + $count_day*60*60*24)."
WHERE
`id` = ".$USER['id']." ;
");
// $GLOBALS['DATABASE']->query("INSERT INTO `uni1_premium_lottery` VALUES ('".$USER['id']."','".$USER['username']."','1') ;");
$this->printMessage($cost_prem, true, array('game.php?page=BuyPremium', 2));
die();
}
$this->tplObj->loadscript("jquery.countdown.js");
$this->tplObj->assign_vars(
array(
'bonus1' => $bonus1,
'bonus2' => $bonus2,
'bonus3' => $bonus3,
'bonus4' => $bonus4,
'bonus5' => $bonus5,
'p_state' => (($USER['premium_until'] > TIMESTAMP) ? '' :'<button type="submit" name="Buy">Buy</button>' ),
'premium_active' => ((!empty($USER['premium_until']) && $USER['premium_until'] > TIMESTAMP) ? ($USER['premium_until'] - TIMESTAMP) : 0),
)
);
$this->display("page.premium_page.default.tpl");
}
} |