Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class CashBill_SMS {
- private static $CASHBILL_URL = "https://sms.cashbill.pl/code";
- private $token, $connection;
- public function __construct($token) {
- $this->token = $token;
- $this->connection = curl_init ();
- }
- public function validateCode($code) {
- curl_setopt_array ( $this->connection, array (
- CURLOPT_URL => self::$CASHBILL_URL . "/" . $this->token . "/" . $code,
- CURLOPT_RETURNTRANSFER => true
- ) );
- return json_decode ( curl_exec ( $this->connection ) );
- }
- function __destruct() {
- curl_close ( $this->connection );
- }
- }
- $cashbill_token = "Twój Token";
- $cashbill_configuration = array (
- "71XX" => array (
- "name" => "TEST NAME 1",
- "withoutTax" => 2.00,
- "withTax" => 2.46,
- "description" => "Treść SMS'a CashBill",
- "userGain" => 1
- ),
- "74XX" => array (
- "name" => "TEST NAME 2",
- "withoutTax" => 4.00,
- "withTax" => 4.92,
- "description" => "Treść SMS'a CashBill",
- "userGain" => 2
- )
- );
- $cashbill = new CashBill_SMS ( $cashbill_token );
- if (isset ( $_POST ['code'] )) {
- $codeInfo = $cashbill->validateCode ( $_POST ['code'] );
- if (isset ( $codeInfo->error )) {
- echo '<div class="alert alert-dismissable alert-warning">
- <button type="button" class="close" data-dismiss="alert">×</button>
- <p>Wpisałeś zły kod.</p>
- </div>';
- } else if ($codeInfo->active == true) {
- $serviceData = $cashbill_configuration [$codeInfo->number];
- echo '<div class="alert alert-dismissable alert-success">
- <button type="button" class="close" data-dismiss="alert">×</button>
- <p>Doładowałeś konto swoje konto o ' . $serviceData ['userGain'] . ' pkt</p>
- </div>';
- $LS->updateUser ( array (
- "portfel" => "portfel" + $serviceData ['userGain']
- ) );
- } else {
- echo '<div class="alert alert-dismissable alert-warning">
- <button type="button" class="close" data-dismiss="alert">×</button>
- <p>Podany kod został już wykorzystany.</p>
- </div>';
- }
- }
- ?>
- <table class="table table-striped table-hover ">
- <thead>
- <tr>
- <th>Numer smsa</th>
- <th>Treść smsa</th>
- <th>Koszt smsa</th>
- <th>Dostaniesz</th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach ( $cashbill_configuration as $key => $v )
- echo '<tr class="active">
- <td>' . $key . '</td>
- <td>' . $v ['description'] . '</td>
- <td>' . $v ['withouTax'] . 'zł+VAT (' . $v ['withTax'] . 'zł)</td>
- <td>' . $v ['userGain'] . ' zł</td>';
- ?>
- </tbody>
- </table>
- <div class="text-center">
- <form method="post" action="">
- <input
- style="border: 1px solid rgb(76, 175, 80); border-bottom-width: 2px; width: 150px;"
- type="text" size="8" name="code"> <input class="btn btn-success"
- type="submit" value="Doładuj konto">
- </form>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement