Register for your free account! | Forgot your password?

You last visited: Today at 05:16

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Release] Web Coupon System

Discussion on [Release] Web Coupon System within the Flyff PServer Guides & Releases forum part of the Flyff Private Server category.

Reply
 
Old   #1
 
xsrf's Avatar
 
elite*gold: 0
Join Date: May 2012
Posts: 871
Received Thanks: 642
[Release] Web Coupon System

Guten Morgen,

da ich wie versprochen die Systeme, die mir sinnvoll erscheinen, programmieren und releasen werde, habe ich hier nun das erste fertige System für euch.

Weitere Vorschläge werden gerne entgegen genommen (:

Das System ist ein Couponsystem.

Das Team erstellt Coupons die via eigenem E-Mail Script, Forum oder sonst wie verbreitet werden können.

Anschließend hat der Benutzer die Möglichkeit diesen Coupon einzulösen. Aktuell sind die Währung Item, Donate Coin und Vote Coin enthalten.

Bei Vorschlägen zu weiteren Währungen bitte einfach im Thread melden.

Bei Vorschlägen zu neuen Systeme oder Fragen zu diesen bitte ebenfalls einfach posten (:

Der Source Code zu dem ganzen Spaß findet sich im Anhang.

Das System lässt sich mit JEDER Webseite kombinieren egal ob es nun eine alte Stefan Pfeifer, die Sapphiere Flyff oder eine eigene Webseite ist.

Hier noch ein Video:


Coupon.Config.php


Class.Coupon.php #updated 12.10.2015

Attached Files
File Type: rar TEST.rar (96.8 KB, 85 views)
xsrf is offline  
Thanks
7 Users
Old 10/12/2015, 12:37   #2
 
kevinkraus's Avatar
 
elite*gold: 110
Join Date: Oct 2010
Posts: 306
Received Thanks: 58
Danke für den Release sehr Nett von dir!
Schönes System

Mit Freundlichen Grüßen,
- Kevin
kevinkraus is offline  
Old 10/12/2015, 12:50   #3
 
-Venom''s Avatar
 
elite*gold: 10
Join Date: Jan 2015
Posts: 937
Received Thanks: 451
Schönes Ding.
Ordentlicher Code.
1a Arbeit wie immer
-Venom' is offline  
Old 10/12/2015, 14:21   #4
ベトナム警察




 
Lumi's Avatar
 
elite*gold: 0
The Black Market: 517/0/0
Join Date: Jan 2012
Posts: 16,498
Received Thanks: 3,526
Wow! Wie hast du die Idee so schnell umgesetzt? Mein dickes Lob! Sehr nützlicher Script und wird vielen sehr weiterhelfen! Vielen Dank.
Lumi is offline  
Old 10/12/2015, 14:28   #5
 
xsrf's Avatar
 
elite*gold: 0
Join Date: May 2012
Posts: 871
Received Thanks: 642
Hatte die ganze Nacht nette Gesellschaft von Gentros

#Update

Da ich von Lumi darauf hingewiesen wurde, dass es noch eine Fehler gab hier einmal ein Update der Class.Coupon.php.

Fehler behoben/Updates:

  • Teilweise nicht versenden an die ITEM_SEND_TBL
  • Es wird gespeichert wer den Coupon benutzt hat
  • Methode zur Generierung des Schlüssels/Coupons erweitert


Class.Coupon.php

PHP Code:
<?php 

class Coupon extends Validation {
    
    private    
$sql;
    
    function 
__construct($sql){
        
$this->sql $sql;
    }
    
    private function 
SetCoupon($event$i){
        return 
strtoupper(md5(time().microtime().rand(11000000000).$i.$event));
    }
    
    private function 
SetCouponCredentials($post$account){
        
$couponCredentials = array(
            
'schedule'        =>        $post['schedule'],
            
'expire'        =>        time() + intval($post['expire'])*24*60*60,
            
'value'            =>        intval($post['value']),
            
'amount'        =>        intval($post['amount']),
            
'event'            =>        $post['event'],
            
'account'        =>        $account,
        );
        return 
$couponCredentials;
    }
    
    private function 
InsertCouponIntoDatabase($coupon$key){
        
$coupon self::Escape($coupon);
        
self::Exec($this->sql'INSERT INTO [' COUPON_TABLE_DBF '].[dbo].[Coupon] ([schedule], [coupon], [expire], [account], [value], [used], [event]) VALUES (' $coupon['schedule'] . ', \'' $key '\', ' $coupon['expire'] . ', ' $coupon['account'] . ', ' $coupon['value'] . ', 0, ' $coupon['event'] . ')');
        if(
odbc_error()){echo odbc_errormsg($this->sql);}
    }
    
    
//CREATE COUPON
    
public function CreateCoupon($post){
        
//If button is not pressed
        
if(!isset($post['create'])){return false;}else{unset($post['create']);}
        
        
//Save account
        
if(!empty($post['account'])){
            
$account =  $post['account'];
        }else {
            
$account 0;
        }
        unset(
$post['account']);
        
        
//If some fields are empty
        
if(self::EmptyInput($post) === 0){echo 'Please fill in all fields'; exit;}
        
        
//Set Coupon Credentials
        
$coupon self::SetCouponCredentials($post$account);
        
        
//Generate Keys
        
$key = array();
        for(
$k 1;$k <= $coupon['amount'];$k++){
            
$key[$k] = self::SetCoupon($post['event'], $k);
        }
        
        
//Insert Coupon into database
        
for($i 1;$i <= $coupon['amount'];$i++){
            
self::InsertCouponIntoDatabase($coupon$key[$i]);
        }
    }
    
    
//SELECT ALL COUPONS
    
private function GetAllCoupons(){
        
$coupons self::Exec($this->sql'SELECT * FROM ' COUPON_TABLE_DBF '.dbo.Coupon');
        return 
$coupons;
    }
    
    public function 
SelectAllCoupons(){
        
$coupons = array();
        
$coupons['Rows'] = self::Rows(self::GetAllCoupons());
        
$coupons['Result'] = self::Fetch(self::GetAllCoupons(), $coupons['Rows']);
        return 
$coupons;
    }
    
    
//DELETE ALL EXPIRED COUPONS
    
public function DeleteAllExpiredCoupons($post){
        if(!isset(
$post['deleteall'])){return false;}
        
self::Exec($this->sql'DELETE FROM ' COUPON_TABLE_DBF '.dbo.Coupon WHERE expire < ' time());
    }
    
    
//SELECT EVENT COUPONS
    
    
private function GetCouponsBySpecificEvent($post){
        
$post self::Escape($post);
        
$coupons self::Exec($this->sql'SELECT * FROM ' COUPON_TABLE_DBF '.dbo.Coupon WHERE [event] = ' $post['event']);
        return 
$coupons;
    }
    
    public function 
SelectEventCoupons($post){
        if(!isset(
$post['eventcoupons'])){return false;}
        
        if(
self::EmptyInput($post) === 0){echo 'Please fill in all fields'; exit;}
        
        
$coupons = array();
        
$coupons['Rows'] = self::Rows(self::GetCouponsBySpecificEvent($post));
        if(
$coupons['Rows'] > 0){
            
$coupons['Result'] = self::Fetch(self::GetCouponsBySpecificEvent($post), $coupons['Rows']);
        }else {
            echo 
'No coupons found.'; exit;
        }
        return 
$coupons;
    }
    
    
//USE COUPONS
    
    
private function GetUsersSpecificCoupon($post$account){
        
$post self::Escape($post);
        
$coupon self::Exec($this->sql'SELECT * FROM ' COUPON_TABLE_DBF '.dbo.Coupon WHERE [coupon] = ' $post['coupon']);
        return 
$coupon;
    }
    
    private function 
GetSpecificReward($schedule$value$player$account$coupon){
                
self::Exec($this->sql'UPDATE [' COUPON_TABLE_DBF '].[dbo].[Coupon] SET [used] = 1 WHERE [coupon] = \'' $coupon '\'');
                
self::Exec($this->sql'UPDATE [' COUPON_TABLE_DBF '].[dbo].[Coupon] SET [account] = \'' $account '\' WHERE [coupon] = \'' $coupon '\'');
        switch(
$schedule){
            case 
'item'
                
self::Exec($this->sql'INSERT INTO [CHARACTER_01_DBF].[dbo].[ITEM_SEND_TBL] ([m_idPlayer], [serverindex], [Item_Name], [Item_count], [idSender]) VALUES (\'' $player '\', \'01\', \'' $value '\', 1, \'0000000\')');
                break;
            case 
'dcoins':
                
$old self::Fetch(self::Exec($this->sql'SELECT [' DONATE_COIN_ROW '] FROM [' WEBSITE_DATABASE '].[dbo].[' DONATE_COIN_TABLE '] WHERE [username] = \'' $account '\''), 1);
                
$old intval($old[1][DONATE_COIN_ROW]);
                
$new intval($value) + intval($old);
                
self::Exec($this->sql'UPDATE [' WEBSITE_DATABASE '].[dbo].[' DONATE_COIN_TABLE '] SET [' DONATE_COIN_ROW '] = ' $new ' WHERE [username] = \'' $account '\'');
                break;
            case 
'vcoins':
                
$old self::Fetch(self::Exec($this->sql'SELECT [' VOTE_COIN_ROW '] FROM [' WEBSITE_DATABASE '].[dbo].[' VOTE_COIN_TABLE '] WHERE [username] = \'' $account '\''), 1);
                
$old intval($old[1][VOTE_COIN_ROW]);
                
$new intval($value) + intval($old);
                
self::Exec($this->sql'UPDATE [' WEBSITE_DATABASE '].[dbo].[' VOTE_COIN_TABLE '] SET [' VOTE_COIN_ROW '] = ' $new ' WHERE [username] = \'' $account '\'');
                break;
        }
    }
    
    public function 
GetCharacterByAccount(){
        
$account $_SESSION[SESSION_USER];
        
$chars self::Exec($this->sql'SELECT [m_idPlayer], [m_szName] FROM [CHARACTER_01_DBF].[dbo].[CHARACTER_TBL] WHERE [account] = \'' $account'\' AND [isblock] = \'F\'');
        
$rows self::Rows($chars);
        if(
$rows <= 0){die('You have to create a character before you can use a coupon.');}
        
$result self::Fetch($chars$rows);
        return 
$result;
    }
    
    public function 
UseCoupon($post){
        
$account $_SESSION[SESSION_USER];
        if(!isset(
$post['usecoupon'])){return false;}
        
        if(
self::EmptyInput($post) === 0){echo 'Please fill in all fields'; exit;}
        
$coupon self::GetUsersSpecificCoupon($post$account);
        
$arr = array();
        
$arr['Rows'] = self::Rows($coupon);
        if(
$arr['Rows'] > 0){
            
$arr['Result'] = self::Fetch($coupon$arr['Rows']);
            if(
intval($arr['Result'][1]['expire']) >= time()){
                if(
intval($arr['Result'][1]['used']) === 0){
                    if(
$arr['Result'][1]['account'] === '0'){
                        
$characterSave $post['character'];
                        
$post self::Escape($post);
                        
$charlength strlen($characterSave);
                        
$str null;
                        for(
$i 1;$i <= 7-intval($charlength);$i++){
                            
$str .= '0';
                        }
                        
$str .= $characterSave;
                        echo 
$str;
                        
self::GetSpecificReward($arr['Result'][1]['schedule'], $arr['Result'][1]['value'], $str$account$arr['Result'][1]['coupon']);
                        echo 
'Item has been send to your character.'; exit;
                    }else {
                        if(
$arr['Result'][1]['account'] === $account){
                            
self::GetSpecificReward($arr['Result'][1]['schedule'], $arr['Result'][1]['value'], $post['character'], $account$arr['Result'][1]['coupon']);
                            echo 
'Item has been send to your character.'; exit;
                        }else {
                            echo 
'This coupon is reserved for another player.'; exit;
                        }
                    }
                }else {
                    echo 
'Coupon was already used by another player.'; exit;
                }
            }else {
                echo 
'Coupon has been expired.'; exit;
            }
        }else {
            echo 
'Coupon not found.'; exit;
        }
    }
    
}

class 
Validation {
    
    public static function 
EmptyInput($array){
        
$result 1;
        foreach(
$array as $key => $value){
            if(empty(
$array[$key])){
                return 
$result 0;
            }
        }
        return 
$result;
    }
    
    protected function 
Escape($array){
        foreach(
$array as $key => $value){
            if(
gettype($value) != 'integer' && $value !== null){
                
$array[$key] = '0x'.bin2hex($value);
            }else {
                
$array[$key] = $value;
            }
        }
        return 
$array;
    }
    
    protected function 
Exec($sql$qry){
         
$exec = @odbc_exec($sql$qry);
         if(
odbc_error()){echo odbc_errormsg($sql);}
         return 
$exec;
    }
    
    protected function 
Rows($rlt){
        return @
odbc_num_rows($rlt);
    }
    
    protected function 
Fetch($rlt$rows){
        
$arr = array();
        for(
$i 1;$i <= $rows;$i++){
           
$arr[$i] = @odbc_fetch_array($rlt$i); 
        }
        return 
$arr;
    }
    
}
xsrf is offline  
Thanks
5 Users
Old 10/13/2015, 21:54   #6

 
Chyukαsame's Avatar
 
elite*gold: 0
Join Date: Oct 2012
Posts: 1,102
Received Thanks: 564
Guter Release ^^
Deine Item Liste (wahrscheinlich dynamisch gelistet) releast du doch bestimmt auch
Chyukαsame is offline  
Old 10/13/2015, 22:45   #7
 
xsrf's Avatar
 
elite*gold: 0
Join Date: May 2012
Posts: 871
Received Thanks: 642
Welche Itemliste?
xsrf is offline  
Old 10/14/2015, 11:32   #8
 
-Venom''s Avatar
 
elite*gold: 10
Join Date: Jan 2015
Posts: 937
Received Thanks: 451
Quote:
Originally Posted by Chyukαsame View Post
Guter Release ^^
Deine Item Liste (wahrscheinlich dynamisch gelistet) releast du doch bestimmt auch
Die item Liste ist relativ einfach zu machen.
Wie es mit Ajax aussieht weiß ich nicht.
Aber du musst um so eine Liste zu erhalten item_dbf aktivieren danach kannste den PHP Code schreiben.
-Venom' is offline  
Old 10/14/2015, 21:01   #9
ベトナム警察




 
Lumi's Avatar
 
elite*gold: 0
The Black Market: 517/0/0
Join Date: Jan 2012
Posts: 16,498
Received Thanks: 3,526
Quote:
Originally Posted by AMAZEN View Post
Welche Itemliste?
Ich vermute mal deine eigene Wiki. Sieht jedenfalls sehr schick aus.
Lumi is offline  
Old 10/15/2015, 10:34   #10

 
Chyukαsame's Avatar
 
elite*gold: 0
Join Date: Oct 2012
Posts: 1,102
Received Thanks: 564
Quote:
Originally Posted by Gentros' View Post
Die item Liste ist relativ einfach zu machen.
Wie es mit Ajax aussieht weiß ich nicht.
Aber du musst um so eine Liste zu erhalten item_dbf aktivieren danach kannste den PHP Code schreiben.

Wie ich eine solche Liste mache ist mir bewusst Gentros, ich bin nicht gerade kurz in der Web Entwicklung. Ajax hält die Liste permanent aktuell und verbessert die Ladezeit da die Liste ja nicht gerade klein ist.

Aber wenn es für dich so einfach ist, warum hat AMAZEN es für dich gecodet und nicht du selber?
Chyukαsame is offline  
Old 10/15/2015, 16:09   #11
 
xTwiLightx's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 1,741
Received Thanks: 1,674
Was hat denn ein asynchroner XML Call mit der Aktualität einer Liste zu tun?
Wollt ihr alle paar Sekunden ALLE Items aus der Datenbank laden lassen, nur damit die Liste auf der Homepage aktuell ist?
xTwiLightx is offline  
Thanks
2 Users
Old 10/17/2015, 01:21   #12
 
elite*gold: 0
Join Date: Aug 2015
Posts: 29
Received Thanks: 7
Schönes System werde es nutzen
Futaba1 is offline  
Old 10/17/2015, 01:44   #13
 
elite*gold: 0
Join Date: May 2014
Posts: 4,409
Received Thanks: 936
Naja man hätte auch das Promocode System von xBlubbs erweitern können, welches man übrigens im Release von Chyukasame findet(Forsaken Flyff Release).
Michi is offline  
Thanks
2 Users
Old 10/17/2015, 10:05   #14

 
Chyukαsame's Avatar
 
elite*gold: 0
Join Date: Oct 2012
Posts: 1,102
Received Thanks: 564
Amazen hat es schon recht gut gemacht ^^
Chyukαsame is offline  
Old 10/17/2015, 10:39   #15
ベトナム警察




 
Lumi's Avatar
 
elite*gold: 0
The Black Market: 517/0/0
Join Date: Jan 2012
Posts: 16,498
Received Thanks: 3,526
Quote:
Originally Posted by 'Dude' View Post
Naja man hätte auch das Promocode System von xBlubbs erweitern können, welches man übrigens im Release von Chyukasame findet(Forsaken Flyff Release).
Hätte hätte Fahrradkette.

Ich persönlich würde es auch selber schreiben, wenn ich die Kenntnisse dafür habe. Wozu dann also ein bestehendes nehmen und umschreiben? :P
Amazen hat es wirklich schon gut gemacht. ^^
Lumi is offline  
Reply


Similar Threads Similar Threads
[B]Coupon System [S]PSC, PP, E*gold
11/22/2014 - Metin2 Trading - 2 Replies
Vorwort: Hallo Community, wie in der Überschrift bereits erwähnt. Biete ich hier ein Coupon System für das Hen-Script. Funktionen: - Ein Admin kann Coupons erstellen - Diese kann man jemandem geben - Jemand kann Sie einlösen und erhält Coins - Beispiel: Man kann einen Couponshop erstellen. (Treasures auf EPVP) o.ä.
[RELEASE]Coupon-System (hen!-CMS)
09/03/2013 - Metin2 PServer Guides & Strategies - 16 Replies
coupon.class.php <?php class coupon { private $couponid; private $couponamount; private $error; public function __construct() { $this->coupon = mysql_real_escape_string($_POST.'-'.$_POST.'-'.$_P OST); $this->couponamount = mysql_real_escape_string($_POST);
[Release] Coupon-System für das hen! CMS
08/10/2012 - Metin2 PServer Guides & Strategies - 9 Replies
Guten Abend, nach langer Zeit gibt es mal wieder ein Release von mir. Das System wurde nicht benutzt und ich benötige es nicht, daher möchte ich es euch nun zur Verfügung stellen. Vielleicht baut der ein oder andere User das System etwas aus, das liegt in eurer Hand. Dies ist kein Neueinstieg in die Sektion, es ist lediglich ein kleines Geschenk. Ich gebe keinen Support zu dem Coupon-System, bei den Tests funktionierte es einwandfrei ;-) Was bringt mir das Coupon-System? Nachdem das...



All times are GMT +1. The time now is 05:16.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.