<?php
class BuyCredits{
public $error;
public function head(){
global $db,$root;
if(!$_SESSION['vcount_wait']) $_SESSION['vcount_wait']=0;
//Gutschein einl¿sen
if($_POST['voucher']){
if(!$_SESSION['vcount'] || $_SESSION['vcount']<6){
$is=$db->selectOne('SELECT * FROM vouchers WHERE code="'.$db->escape($_POST['voucher']).'" AND active=1 AND userId=0');
if($is['id']){
$db->query('UPDATE vouchers SET userId='.$_SESSION['userId'].',active=0,date='.time().',ip="'.$_SERVER['REMOTE_ADDR'].'" WHERE id='.$is['id']);
$db->query('UPDATE user SET account=account+'.$is['amount'].' WHERE id='.$_SESSION['userId']);
$db->insert('INSERT INTO transactions VALUES(NULL,'.$_SESSION['userId'].',1,"'.$_SERVER['REMOTE_ADDR'].'",'.$is['amount'].',"Voucher '.$_POST['voucher'].'",'.time().')');
header('Location:'.$root.'/?do=account&s=credits&balance=1');
}else{
$_SESSION['vcount']++;
$_SESSION['vcount_time']=time();
$this->error='Coupon unknown, already radeemed or deactivated.';
if($_SESSION['vcount']>=5){
$_SESSION['vcount_wait']+=5;
}
}
}
}
//entsperren
if($_SESSION['vcount']>=5){
if(((time()-$_SESSION['vcount_time'])/60)>=$_SESSION['vcount_wait']){
$_SESSION['vcount']=0;
}
}
#$_SESSION['vcount']=0;
#$_SESSION['vcount_wait']=0;
$html='<div class="title">Add Credits</div><div class="pane">';
return $html;
}
public function view(){
global $db,$root,$accountValue,$wmPurse,$wmString;
if($this->error){
$html.='<div style="padding:10px;border:1px dotted #db0000;margin-top:15px;background-color:#ffdede" class="text"><b>'.$this->error.'</b></div>';
}
require_once('app/classes/account/paysafecard2.php');
$paysafe=new Paysafecard();
$html.='<form method="post"><div style="border:1px dotted #666666;padding:6px">
<table border="0" width="100%" cellspacing="0" cellpadding="8">
<tr>
<td width="109" style="text-align:right"><img src="{root}/media/present_32.png"></td>
<td>';
if(!$_SESSION['vcount'] || $_SESSION['vcount']<5){
$html.='
<div class="subtitle">Radeem Coupon</div>
<div class="text" style="margin-top:5px;margin-bottom:5px">Please enter Coupon Code:</div>
<div style="margin-top:8px"><input type="text" name="voucher" value="" style="width:170px"> '.Utility::button('Radeem',false,100,0).'</div>';
}else{
$html.=Utility::syserror('Error: too much trials - please wait for '.$_SESSION['vcount_wait'].' minutes!');
}
$html.='
</td>
</tr>
</table>
</div>
</form>';
//Deposit Money
if($_POST['resolve']){
//Store to Session
$_SESSION['paysafe'][0]=$_POST['randomNumber_1'];
$_SESSION['paysafe'][1]=$_POST['randomNumber_2'];
$_SESSION['paysafe'][2]=$_POST['randomNumber_3'];
$_SESSION['paysafe'][3]=$_POST['randomNumber_4'];
$_SESSION['captchaResponse']=$_POST['captchaResponse'];
$_SESSION['captchaId']=$_POST['captchaId'];
$_SESSION['password']=$_POST['psPassword'];
$_SESSION['jsessid']=$_POST['jsess'];
$_SESSION['retry']=0;
$html.='
<div style="margin-top:40px;border:1px dotted #666666;background-color:#ffffff;padding:6px">
<table border="0" width="100%" cellspacing="0" cellpadding="8">
<tr valign="top">
<div class="text" style="margin-top:5px;margin-bottom:5px">
<div id="psprocess">
<img src="{root}/media/ajax-load-bar.gif" style="vertical-align:middle"> checking card ...
</div>
'.Utility::button('back','?do=account&s=buycredits',120,5).'
<script language="javascript">
num=0;
function asyncPaysafeRequest(){
//alert("ok1");
num++;
var x = getHTTPObject2();
var div = document.getElementById("psprocess");
//var cdiv = document.getElementById("counter");
// cdiv.innerHTML=num;
x.open ("GET", "'.$root.'/?do=ajax&function=pscard", true);
x.onreadystatechange = function (){
if (x.readyState == 4){
if(x.responseText=="retry"){
asyncPaysafeRequest();
}else{
div.innerHTML="";
div.innerHTML = x.responseText;
}
}
}
x.send(null);
}
asyncPaysafeRequest();
</script>
</div>
<div style="margin-top:8px"></div>
</td>
</tr>
</table>
</div>
';
/*
$state=$paysafe->getCardStatus(Array($_POST['randomNumber_1'],$_POST['randomNumber_2'],$_POST['randomNumber_3'],$_POST['randomNumber_4']),$_POST['psPassword'],$_POST['captchaId'],$_POST['captchaResponse'],$_POST['jsess']);
if($state[0]==0){
$html.=Utility::syserror('Fehler: '.$state[1]).'<br>'.Utility::button('zurück','?do=credits&buy=1',120,5);
}else{
$html.='<div class="text" style="border:1px dotted #3bc200;padding:8px;background-color:#ecffe4;margin-top:10px">';
$html.='<div class="title">Successfully booked!</div>'.$state[1].'</div>';
}*/
}else{
#$captcha=$paysafe->getCaptcha();
if($_GET['r1']) $_SESSION['paysafe'][0]=$_GET['r1'];
if($_GET['r2']) $_SESSION['paysafe'][1]=$_GET['r2'];
if($_GET['r3']) $_SESSION['paysafe'][2]=$_GET['r3'];
if($_GET['r4']) $_SESSION['paysafe'][3]=$_GET['r4'];
$_SESSION['retry']=0;
//$_SESSION['paysafe']
$html.='
<form method="post">
<input type="hidden" name="resolve" value="1">
<input type="hidden" name="jsess" value="'.$captcha[2].'">
<div style="margin-top:0px;border:0px dotted #666666;padding:0px">
<tr valign="top">
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
<div style="margin-top:20px;border:1px dotted #666666;padding:6px">
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr valign="top">
<td width="109" style="text-align:right"><img src="{root}/media/money.gif"></td>
<td>
<div class="subtitle" style="margin-top:20px">Buy via LibertyReserve <img src="{root}/media/lr.gif" style="vertical-align:middle"></div>
<div class="text" style="margin-top:5px;margin-bottom:5px">
<div style="padding:4px">
<form action="{root}/app/classes/account/lr.php" method="post">
Credit Amount ($):<input type="text" name="amnt" />
<input type="hidden" value="'.$_SESSION['userID'].'" name="usr" />
<button class="Button" width="100" style="width: 100px;" type="submit">
<div class="Button1">
<div class="Button2">
<div class="Button3">Buy</div>
</div>
</div>
</button>
</form>
</div>
<div style="margin-top:8px"></div>
</td>
</tr>
</table>
</div>
<div style="margin-top:20px;border:1px dotted #666666;padding:6px">
<table border="0" width="100%" cellspacing="0" cellpadding="8">
<tr valign="top">
<td width="109" style="text-align:right"><img src="{root}/media/money.gif"></td>
<td>
<div class="subtitle" style="margin-top:20px">Deposit money with <img src="{root}/media/webmoney.gif" style="vertical-align:middle"></div>
<div class="text" style="margin-top:5px;margin-bottom:5px">
<div style="padding:4px">'.$wmString.'</div>
<div style="padding:4px">Purse: <b>'.$wmPurse.'</b></div>
<div style="padding:4px">Subject: <b>"User-Id: '.$_SESSION['userId'].'"
</div>
<div style="margin-top:8px"></div>
</td>
</tr>
</table>
</div>
';
}
$html.='</div>';
return $html;
}
} |