Witam
Mam problem z zakupem usług głównie chodzi mi o to aby po zakupie usługi przedłużało datę aktywności konta premium a o to fragment kodu.
Bardzo prosiłbym o pomoc.
$RDB->query("UPDATE lss_users SET premium=DATE_ADD(CURDATE(), INTERVAL DAY WHERE login='".$this->request['login']."'");
$RDB->execute();
Struktura shop.sql
Oraz zawartość kodu:
Spoiler
class public_kokpit_shop_main extends ipsCommand
{
public function doExecute( ipsRegistry $registry )
{
if ( ! class_exists( 'dbMain' ) )
{
require_once( IPS_KERNEL_PATH.'classDb.php' );
require_once( IPS_KERNEL_PATH.'classDb' . ucwords($this->settings['sql_driver']) . '.php' );
}
require_once( IPSLib::getAppDir( 'kokpit' ) . '/sources/classes/kokpit.php' );
$classname = "db_driver_" . $this->settings['sql_driver'];
$RDB = new $classname;
$RDB->obj['sql_database'] = kokpitLib::$db_database;
$RDB->obj['sql_user'] = kokpitLib::$db_user;
$RDB->obj['sql_pass'] = kokpitLib::$db_pass;
$RDB->obj['sql_host'] = kokpitLib::$db_host;
$RDB->connect();
if(!$this->memberData['member_id'])
{
$this->registry->getClass('output')->showError("Musisz być zalogowany(a) aby móc przeglądać tą sekcję. ", 0);
return;
}
$apikey = '-';
$this->DB->query('SELECT * FROM shop');
$this->DB->execute;
while($s = $this->DB->fetch())
{
$i++;
$oList[] = $s;
}
$this->DB->query('SELECT points FROM members WHERE member_id='.$this->memberData['member_id']);
$this->DB->execute;
$gamescore = $this->DB->fetch();
foreach($oList as $shop) {
if(isset($this->request['shop_'.$shop['id']])) {
if($gamescore['points'] >= $shop['cost']) {
$gamescore['points'] -= $shop['cost'];
$this->DB->query('UPDATE members SET points='.$gamescore['points'].' WHERE member_id='.$this->memberData['member_id']);
$this->DB->execute;
$this->registry->output->redirectScreen( 'Zakupiłeś: '.$shop['name'].'. Dziękujemy za zakup i życzymy miłej gry.', $this->settings['base_url'] . 'app=kokpit&module=shop');
}
else
{
$this->registry->output->redirectScreen( 'Nie posiadasz tylu punktów na koncie.', $this->settings['base_url'] . 'app=kokpit&module=shop');
}
}
}
if(isset($this->request['submit'])) {
$sms_amount = $this->request['stype'];
$sms_code = $this->request['scode'];
$pamount = 0;
switch($this->request['stype']) {
case 1:
$pamount = 1000;
case 2:
$pamount = 2000;
case 3:
$pamount = 3000;
case 4:
$pamount = 4100;
case 5:
$pamount = 5150;
case 6:
$pamount = 6100;
case 9:
$pamount = 9200;
case 19:
$pamount = 21000;
case 25:
$pamount = 30000;
break;
}
$contents = file_get_contents("https://admin.serverproject.pl/api/smsapi.php?key=$apikey&amount=".$sms_amount."&code=".$sms_code);
if ($contents)
{
$contents = json_decode($contents);
if ($contents->error)
{
$this->registry->output->redirectScreen( 'Błąd: '.$contents->error, $this->settings['base_url'] . 'app=kokpit&module=shop');
}
else
{
if ($contents->status == 'ok')
{
$gamescore['points'] += $pamount;
$this->DB->query('UPDATE members SET points='.$gamescore['points'].' WHERE member_id='.$this->memberData['member_id']);
$this->DB->execute;
$RDB->query("UPDATE lss_users SET premium=DATE_ADD(CURDATE(), INTERVAL 10 DAY WHERE login='".$this->request['login']."'");
$RDB->execute();
$this->registry->output->redirectScreen( 'Kod poprawny. Portfel właściciela został doładowany kwotą '.$pamount.' punktów.', $this->settings['base_url'] . 'app=kokpit&module=shop');
}
else
{
$this->registry->output->redirectScreen( 'Nieznany błąd.', $this->settings['base_url'] . 'app=kokpit&module=shop');
}
}
}
else
{
echo "Błąd połączenia z API.";
}
}
$template = $this->registry->output->getTemplate('kokpit')->shop($oList, $gamescore['points']);
$this->registry->getClass('output')->addContent($template);
$this->registry->output->setTitle('Sklep');
$this->registry->getClass('output')->sendOutput();
}
}
?>
class public_kokpit_shop_main extends ipsCommand
{
public function doExecute( ipsRegistry $registry )
{
if ( ! class_exists( 'dbMain' ) )
{
require_once( IPS_KERNEL_PATH.'classDb.php' );
require_once( IPS_KERNEL_PATH.'classDb' . ucwords($this->settings['sql_driver']) . '.php' );
}
require_once( IPSLib::getAppDir( 'kokpit' ) . '/sources/classes/kokpit.php' );
$classname = "db_driver_" . $this->settings['sql_driver'];
$RDB = new $classname;
$RDB->obj['sql_database'] = kokpitLib::$db_database;
$RDB->obj['sql_user'] = kokpitLib::$db_user;
$RDB->obj['sql_pass'] = kokpitLib::$db_pass;
$RDB->obj['sql_host'] = kokpitLib::$db_host;
$RDB->connect();
if(!$this->memberData['member_id'])
{
$this->registry->getClass('output')->showError("Musisz być zalogowany(a) aby móc przeglądać tą sekcję. ", 0);
return;
}
$apikey = '-';
$this->DB->query('SELECT * FROM shop');
$this->DB->execute;
while($s = $this->DB->fetch())
{
$i++;
$oList[] = $s;
}
$this->DB->query('SELECT points FROM members WHERE member_id='.$this->memberData['member_id']);
$this->DB->execute;
$gamescore = $this->DB->fetch();
foreach($oList as $shop) {
if(isset($this->request['shop_'.$shop['id']])) {
if($gamescore['points'] >= $shop['cost']) {
$gamescore['points'] -= $shop['cost'];
$this->DB->query('UPDATE members SET points='.$gamescore['points'].' WHERE member_id='.$this->memberData['member_id']);
$this->DB->execute;
$this->registry->output->redirectScreen( 'Zakupiłeś: '.$shop['name'].'. Dziękujemy za zakup i życzymy miłej gry.', $this->settings['base_url'] . 'app=kokpit&module=shop');
}
else
{
$this->registry->output->redirectScreen( 'Nie posiadasz tylu punktów na koncie.', $this->settings['base_url'] . 'app=kokpit&module=shop');
}
}
}
if(isset($this->request['submit'])) {
$sms_amount = $this->request['stype'];
$sms_code = $this->request['scode'];
$pamount = 0;
switch($this->request['stype']) {
case 1:
$pamount = 1000;
case 2:
$pamount = 2000;
case 3:
$pamount = 3000;
case 4:
$pamount = 4100;
case 5:
$pamount = 5150;
case 6:
$pamount = 6100;
case 9:
$pamount = 9200;
case 19:
$pamount = 21000;
case 25:
$pamount = 30000;
break;
}
$contents = file_get_contents("https://admin.serverproject.pl/api/smsapi.php?key=$apikey&amount=".$sms_amount."&code=".$sms_code);
if ($contents)
{
$contents = json_decode($contents);
if ($contents->error)
{
$this->registry->output->redirectScreen( 'Błąd: '.$contents->error, $this->settings['base_url'] . 'app=kokpit&module=shop');
}
else
{
if ($contents->status == 'ok')
{
$gamescore['points'] += $pamount;
$this->DB->query('UPDATE members SET points='.$gamescore['points'].' WHERE member_id='.$this->memberData['member_id']);
$this->DB->execute;
$RDB->query("UPDATE lss_users SET premium=DATE_ADD(CURDATE(), INTERVAL 10 DAY WHERE login='".$this->request['login']."'");
$RDB->execute();
$this->registry->output->redirectScreen( 'Kod poprawny. Portfel właściciela został doładowany kwotą '.$pamount.' punktów.', $this->settings['base_url'] . 'app=kokpit&module=shop');
}
else
{
$this->registry->output->redirectScreen( 'Nieznany błąd.', $this->settings['base_url'] . 'app=kokpit&module=shop');
}
}
}
else
{
echo "Błąd połączenia z API.";
}
}
$template = $this->registry->output->getTemplate('kokpit')->shop($oList, $gamescore['points']);
$this->registry->getClass('output')->addContent($template);
$this->registry->output->setTitle('Sklep');
$this->registry->getClass('output')->sendOutput();
}
}
?>