Exemplo n.º 1
0
 public function __construct(Payment $pay)
 {
     if ($pay != null) {
         if (!empty($pay->order)) {
             if ($this->isInt($pay->order) && $pay->order > 0) {
                 $this->correctOrder = true;
                 if (SingleDB::getInstance()->checkOrder($pay->order)) {
                     $this->correctEmptyOrder = true;
                 }
             }
         }
         if (!empty($pay->cost) && $this->isInt($pay->cost)) {
             $this->correctCost = true;
         }
         if (!empty($pay->card_num)) {
             if (strlen($pay->card_num) == 16 && ctype_digit($pay->card_num)) {
                 $this->correctNumber = true;
             }
         }
         if (!empty($pay->card_holder)) {
             $strArray = explode(" ", $pay->card_holder);
             if (count($strArray) == 2) {
                 $strCorrect = true;
                 foreach ($strArray as $str) {
                     if (!preg_match("/^[a-zA-Z]+\$/", $str)) {
                         $strCorrect = false;
                         break;
                     }
                 }
                 $this->correctHolder = $strCorrect;
             }
         }
         $correctMonth = false;
         if (!empty($pay->card_expMonth) && $pay->card_expMonth > 0 && $pay->card_expMonth < 13) {
             $correctMonth = true;
         }
         $correctYear = false;
         if (!empty($pay->card_expYear) && $pay->card_expYear >= date("Y")) {
             $correctYear = true;
         }
         if ($correctMonth && $correctYear) {
             $expDate = new DateTime();
             $expDate->setDate($pay->card_expYear, $pay->card_expMonth, 1);
             $expDate->setTime(0, 0);
             $curDate = new DateTime("now");
             if ($expDate > $curDate) {
                 $this->correctExpDate = true;
             }
         }
         if (!empty($pay->card_cvv) && strlen($pay->card_cvv) == 3 && $this->isInt($pay->card_cvv)) {
             $this->correctCvv = true;
         }
     }
 }
Exemplo n.º 2
0
function printShow(XTemplate &$tpl)
{
    $rows = SingleDB::getInstance()->getAllOrders();
    if (count($rows) == 0) {
        echo EMPTY_TABLE;
        $tpl->parse("page.showPage.backForm");
        $tpl->parse("page.showPage");
        $tpl->parse("page");
        $tpl->out("page");
    } else {
        $tpl->parse("page.showPage.backForm");
        foreach ($rows as $row) {
            $showArray = array("ind" => $row[0], "order" => $row[1], "cost" => $row[2], "rubSel" => $row[3] == 1 ? "selected" : "", "usdSel" => $row[3] == 2 ? "selected" : "", "card_num" => $row[4], "card_holder" => $row[5], "card_expMonth" => $row[6], "card_expYear" => $row[7], "card_cvv" => $row[8]);
            $tpl->assign("showArray", $showArray);
            $tpl->parse("page.showPage.showForm.payRow");
        }
        $tpl->parse("page.showPage.showForm");
        $tpl->parse("page.showPage");
        $tpl->parse("page");
        $tpl->out("page");
    }
}
Exemplo n.º 3
0
    $act = $_POST['act'];
}
$payArray = array();
$default = true;
switch ($act) {
    case "edit":
        $pay = new Payment();
        SingleDB::getInstance()->updatePayment($_POST['ind'], $pay);
    case "show":
        printShow($tplCommon);
        break;
    case "buy":
        $pay = new Payment();
        $checker = new PaymentChecker($pay);
        if ($checker->isCorrect()) {
            SingleDB::getInstance()->insertPayment($pay);
        } else {
            $default = false;
            $payArray["order"] = $pay->order;
            $payArray["cost"] = $pay->cost;
            $payArray["rubSel"] = $pay->currency == 1 ? "selected" : "";
            $payArray["usdSel"] = $pay->currency == 2 ? "selected" : "";
            $payArray["number"] = $pay->card_num;
            $payArray["holder"] = $pay->card_holder;
            $payArray["month"] = $pay->card_expMonth;
            $payArray["year"] = $pay->card_expYear;
            $payArray["cvv"] = $pay->card_cvv;
        }
    default:
        $payArray["submitAct"] = "buy";
        if ($default) {
Exemplo n.º 4
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new OrdersDb(self::$server, self::$user, self::$password, self::$db_name);
     }
     return self::$instance;
 }