Esempio n. 1
0
 /**
  * Delete a order
  *
  * @param OrderEntity the order object
  */
 public function delete(OrderEntity $order)
 {
     $sql = "DELETE FROM Orders WHERE Id = :id";
     $stmt = $this->db->prepare($sql);
     $result = $stmt->execute(["id" => $order->getId()]);
     if (!$result) {
         throw new Exception("could not delete record");
     }
 }
Esempio n. 2
0
 public function requestForms()
 {
     // Login
     $formLogin =& $this->doorGets->Form['login'];
     if (!empty($formLogin->i)) {
         $array = array('login' => $formLogin->i['loginEmail'], 'password' => $formLogin->i['loginPassword']);
         $hasConnected = false;
         // vérification champ vide
         foreach ($formLogin->i as $k => $v) {
             if (empty($v)) {
                 $formLogin->e['login_' . $k] = 'ok';
             }
         }
         // verification de la taille du password
         if (strlen($formLogin->i['loginPassword']) < 4) {
             $formLogin->e['login_loginPassword'] = '******';
         }
         if (!empty($formLogin->e)) {
             $this->doorGets->fireWallIp();
         } else {
             $LogineExist = $this->doorGets->dbQS($formLogin->i['loginEmail'], '_users', 'login');
             if (!empty($LogineExist)) {
                 $hasPassword = $this->doorGets->_decryptMe($formLogin->i['loginPassword'], $LogineExist['salt'], $LogineExist['password']);
                 if ($hasPassword) {
                     $isUserInfos = $this->doorGets->dbQS($LogineExist['id'], '_users_info', 'id_user');
                     if (!empty($isUserInfos) && ($isUserInfos['active'] == '2' or $isUserInfos['active'] == '5')) {
                         $this->doorGets->clearFireWallIp();
                         $_token = md5(uniqid(mt_rand(), true));
                         $_SESSION['doorgets_user']['id'] = $isUserInfos['id_user'];
                         $_SESSION['doorgets_user']['groupe'] = $isUserInfos['network'];
                         $_SESSION['doorgets_user']['login'] = $LogineExist['login'];
                         $_SESSION['doorgets_user']['password'] = $LogineExist['password'];
                         $_SESSION['doorgets_user']['langue'] = $isUserInfos['langue'];
                         $_SESSION['doorgets_user']['token'] = $_token;
                         $this->doorGets->dbQU($LogineExist['id'], array('token' => $_token), '_users');
                         FlashInfo::set($this->doorGets->__("Connexion réussie"));
                         if ($isUserInfos['active'] == '5') {
                             $this->doorGets->dbQU($LogineExist['id'], array('active' => '2'), '_users_info');
                             FlashInfo::set($this->doorGets->__("Connexion réussie") . ', ' . $this->doorGets->__("Votre compte est maintenant ouvert"));
                         }
                         header('Location:' . $_SERVER['REQUEST_URI']);
                         $hasConnected = true;
                     } else {
                         $this->doorGets->fireWallIp();
                     }
                 }
             } else {
                 $this->doorGets->fireWallIp();
             }
             if (!$hasConnected) {
                 $formLogin->e['login_loginEmail'] = 'ok';
                 $formLogin->e['login_loginPassword'] = '******';
             }
         }
     }
     // Register
     $formRegister =& $this->doorGets->Form['register'];
     if (!empty($formRegister->i)) {
         $groupes = $this->doorGets->loadGroupesSubscriber();
         $countGroupes = count($groupes);
         $idGroupe = null;
         $hasVerification = true;
         $errorMsg = '';
         if (empty($idActiveGroupe) && $countGroupes === 1) {
             foreach ($groupes as $key => $value) {
                 $idGroupe = $groupes[$key]['id'];
                 $hasVerfication = $groupes[$key]['verification'];
             }
         } elseif (array_key_exists($idActiveGroupe, $groupes)) {
             $idGroupe = $groupes[$idActiveGroupe]['id'];
             $hasVerfication = $groupes[$idActiveGroupe]['verification'];
         }
         $array = array('registerLastname' => $formRegister->i['registerLastname'], 'registerFirstname' => $formRegister->i['registerFirstname'], 'registerEmail' => $formRegister->i['registerEmail'], 'registerType' => $formRegister->i['registerType'], 'registerPassword' => $formRegister->i['registerPassword'], 'registerCompany' => $formRegister->i['registerCompany'], 'registerAddress' => $formRegister->i['registerAddress'], 'registerZipcode' => $formRegister->i['registerZipcode'], 'registerCity' => $formRegister->i['registerCity'], 'registerCountry' => $formRegister->i['registerCountry'], 'registerPhone' => $formRegister->i['registerPhone']);
         // vérification champ vide
         foreach ($formRegister->i as $k => $v) {
             if (empty($v) && $k !== 'registerCompany') {
                 $formRegister->e['register_' . $k] = 'Vide !';
             }
         }
         // verification adresse email
         if (empty($formRegister->e['register_registerEmail'])) {
             // verification du format mail
             $email = filter_var($formRegister->i['registerEmail'], FILTER_VALIDATE_EMAIL);
             if (empty($email)) {
                 $formRegister->e['register_registerEmail'] = 'Format email invalid';
             }
             // verification de l'existance de l'adresse email
             if (empty($formRegister->e['register_registerEmail'])) {
                 $isEmail = $this->doorGets->dbQS($formRegister->i['registerEmail'], '_users_info', 'email');
                 $isEmailLogin = $this->doorGets->dbQS($formRegister->i['registerEmail'], '_users', 'login');
                 if (!empty($isEmail) || !empty($isEmailLogin)) {
                     $formRegister->e['register_registerEmail'] = 'Email deja ulisise';
                 }
             }
         }
         // création du pseudo
         $pseudo = 'dg' . uniqid();
         $hasMember = $formRegister->e['register_registerPassword'] && $formRegister->i['registerType'] === 'new-member';
         // verification du mot de passe
         if (array_key_exists('register_registerPassword', $formRegister->e) && empty($hasMember)) {
             if (strlen($formRegister->i['registerPassword']) < 8) {
                 $formRegister->e['register_registerPassword'] = '******';
             }
         }
         if (empty($formRegister->e) && $countGroupes > 0) {
             if ($idGroupe) {
                 $avatar = $this->doorGets->copyGravatar($formRegister->i['registerEmail']);
                 $crypto = $this->doorGets->_cryptMe($formRegister->i['registerPassword']);
                 $dataLogin['login'] = $formRegister->i['registerEmail'];
                 $dataLogin['password'] = $crypto['password'];
                 $dataLogin['salt'] = $crypto['salt'];
                 $dataInfo['langue'] = $this->doorGets->myLanguage;
                 $dataInfo['network'] = $idGroupe;
                 $dataInfo['active'] = $hasVerfication ? '3' : '2';
                 // moderation mode
                 $dataInfo['pseudo'] = $pseudo;
                 $dataInfo['company'] = $formRegister->i['registerCompany'];
                 $dataInfo['email'] = $formRegister->i['registerEmail'];
                 $dataInfo['last_name'] = $formRegister->i['registerLastname'];
                 $dataInfo['first_name'] = $formRegister->i['registerFirstname'];
                 $dataInfo['tel_mobil'] = $formRegister->i['registerPhone'];
                 $dataInfo['notification_newsletter'] = array_key_exists('registerNewsletter', $formRegister->i) ? 1 : 0;
                 $dataInfo['country'] = $formRegister->i['registerCountry'];
                 $dataInfo['city'] = $formRegister->i['registerCity'];
                 $dataInfo['zipcode'] = $formRegister->i['registerZipcode'];
                 $dataInfo['adresse'] = $formRegister->i['registerAddress'];
                 $dataInfo['date_creation'] = time();
                 $dataInfo['avatar'] = $avatar;
                 $dataInfo['id_user'] = $this->doorGets->dbQI($dataLogin, '_users');
                 $this->doorGets->dbQI($dataInfo, '_users_info');
                 // create activation code
                 if ($hasVerfication) {
                     $dataCode['type'] = 'subscribe';
                     $dataCode['id_user'] = $dataInfo['id_user'];
                     $dataCode['code'] = $this->doorGets->_genRandomKey(45);
                     $dataCode['date_creation'] = time();
                     $this->doorGets->dbQI($dataCode, '_users_activation');
                     $this->doorGets->createFolderUser($dataInfo['pseudo'], $dataInfo['id_user']);
                     $lgUser = '';
                     if (count($this->doorGets->allLanguagesWebsite) > 1) {
                         $lgUser = $this->doorGets->myLanguage . '/';
                     }
                     $urlToSend = URL_USER . $lgUser . '?controller=authentification&action=activation&code=' . $dataCode['code'];
                     // send mail with code confirmation
                     new SendMailAuth($dataInfo['email'], 'subscribe', $urlToSend, $this->doorGets);
                 } else {
                     // Connect user
                     $_token = md5(uniqid(mt_rand(), true));
                     $_SESSION['doorgets_user']['id'] = $dataInfo['id_user'];
                     $_SESSION['doorgets_user']['groupe'] = $dataInfo['network'];
                     $_SESSION['doorgets_user']['login'] = $dataLogin['login'];
                     $_SESSION['doorgets_user']['password'] = $dataLogin['password'];
                     $_SESSION['doorgets_user']['langue'] = $dataInfo['langue'];
                     $_SESSION['doorgets_user']['token'] = $_token;
                     $this->doorGets->createFolderUser($dataInfo['pseudo'], $dataInfo['id_user']);
                     $this->doorGets->dbQU($dataInfo['id_user'], array('token' => $_token), '_users');
                     FlashInfo::set($this->doorGets->__("Connexion réussie"));
                     header('Location:' . $_SERVER['REQUEST_URI']);
                     exit;
                 }
                 $formRegister->isSended = true;
             }
         }
     }
     $formCodepromo =& $this->doorGets->Form['codepromo'];
     if (!empty($formCodepromo->i)) {
         echo '<pre>';
         echo $this->doorGets->varDumpArray($formCodepromo->i);
         exit;
     }
     // Address
     $formAddress =& $this->doorGets->Form['address'];
     if (!empty($formAddress->i)) {
         $this->cart->setShippingMethod($formAddress->i['methodShipping']);
         // echo '<pre>';
         // echo $this->doorGets->varDumpArray($formAddress->i);
         // exit();
         $ignore = array('shippingCompany', 'billingCompany', 'shippingPhone', 'billingPhone', 'message');
         //$_SESSION = array();
         // vdump($_SESSION);
         // exit();
         // vérification champ vide
         foreach ($formAddress->i as $k => $v) {
             if (empty($v) && !in_array($k, $ignore)) {
                 $formAddress->e['address_' . $k] = 'ok';
             }
         }
         if (empty($formAddress->e)) {
             $time = time();
             $timeHuman = ucfirst(strftime("%A %d %B %Y %H:%M", $time));
             $this->order['reference'] = 'DG' . $this->user['id'] . uniqid();
             $this->order['shipping_lastname'] = $formAddress->i['shippingLastname'];
             $this->order['shipping_firstname'] = $formAddress->i['shippingFirstname'];
             $this->order['shipping_company'] = $formAddress->i['shippingCompany'];
             $this->order['shipping_address'] = $formAddress->i['shippingAddress'];
             $this->order['shipping_zipcode'] = $formAddress->i['shippingZipcode'];
             $this->order['shipping_city'] = $formAddress->i['shippingCity'];
             $this->order['shipping_country'] = $formAddress->i['shippingCountry'];
             $this->order['shipping_phone'] = $formAddress->i['shippingPhone'];
             $this->order['billing_lastname'] = $formAddress->i['billingLastname'];
             $this->order['billing_firstname'] = $formAddress->i['billingFirstname'];
             $this->order['billing_company'] = $formAddress->i['billingCompany'];
             $this->order['billing_address'] = $formAddress->i['billingAddress'];
             $this->order['billing_zipcode'] = $formAddress->i['billingZipcode'];
             $this->order['billing_city'] = $formAddress->i['billingCity'];
             $this->order['billing_country'] = $formAddress->i['billingCountry'];
             $this->order['billing_phone'] = $formAddress->i['billingPhone'];
             $this->methodBilling = $formAddress->i['methodBilling'];
             $this->methodShipping = $formAddress->i['methodShipping'];
             $this->order['type'] = Constant::$orderType['checkout'];
             $this->order['status'] = $this->status;
             $this->order['langue'] = $this->langue;
             $this->order['vat'] = 20;
             $this->order['amount'] = $this->cart->getTotalAmountPromoVAT();
             $this->order['amount_real'] = $this->cart->getTotalAmountVAT();
             $this->order['amount_billing'] = $this->cart->getTotalBillingAmount();
             $this->order['amount_profit'] = $this->cart->getTotalProfitAmount();
             $this->order['amount_vat'] = $this->cart->getTotalVATAmount();
             $this->order['amount_with_shipping'] = $this->cart->getTotalAmountPromoShippingVAT();
             $this->order['count'] = $this->cart->getCount();
             $this->order['currency'] = $this->currency;
             $this->order['shipping_amount'] = $this->cart->shippingAmount;
             $this->order['method_billing'] = $this->methodBilling;
             $this->order['method_shipping'] = $this->methodShipping;
             $this->order['date_creation'] = $time;
             $this->order['date_creation_human'] = $timeHuman;
             $this->order['date_modification'] = $time;
             $this->order['date_modification_human'] = $timeHuman;
             $this->order['products'] = base64_encode(serialize($this->products));
             $this->order['message'] = $formAddress->i['message'];
             $orderEntity = new OrderEntity($this->order, $this->doorGets);
             $orderEntity->save(false);
             $_SESSION['cart_info']['orderId'] = $this->order['id'] = $orderEntity->getId();
             $paymentUrl = './?payment&lg=' . $this->langue;
             if ($this->methodBilling === 'paypal') {
                 $paypalService = new PaypalService($this->doorGets, $this->cart);
                 $paymentUrl = $paypalService->getUrl();
             }
             header('Location:' . $paymentUrl);
             exit;
         }
     }
 }
Esempio n. 3
0
 public function requestForms()
 {
     // Address
     $formAddress =& $this->doorGets->Form['address'];
     if (!empty($formAddress->i)) {
         // echo '<pre>';
         // echo $this->doorGets->varDumpArray($formAddress->i);
         // exit();
         $ignore = array('billingCompany', 'billingPhone', 'billingRegion');
         //$_SESSION = array();
         // vdump($_SESSION);
         // exit();
         // vérification champ vide
         foreach ($formAddress->i as $k => $v) {
             if (empty($v) && !in_array($k, $ignore)) {
                 $formAddress->e['address_' . $k] = 'ok';
             }
         }
         if (empty($formAddress->e)) {
             $time = time();
             $timeHuman = ucfirst(strftime("%A %d %B %Y %H:%M", $time));
             $this->order['reference'] = 'DG' . $this->user['id'] . uniqid();
             $this->order['billing_lastname'] = $formAddress->i['billingLastname'];
             $this->order['billing_firstname'] = $formAddress->i['billingFirstname'];
             $this->order['billing_company'] = $formAddress->i['billingCompany'];
             $this->order['billing_address'] = $formAddress->i['billingAddress'];
             $this->order['billing_zipcode'] = $formAddress->i['billingZipcode'];
             $this->order['billing_city'] = $formAddress->i['billingCity'];
             $this->order['billing_country'] = $formAddress->i['billingCountry'];
             $this->order['billing_phone'] = $formAddress->i['billingPhone'];
             $this->order['billing_region'] = $formAddress->i['billingRegion'];
             $this->methodBilling = $formAddress->i['methodBilling'];
             $this->order['type'] = Constant::$orderType['payment'];
             $this->order['status'] = $this->status;
             $this->order['langue'] = $this->langue;
             $this->order['amount'] = $this->subscription->data['amount_total'];
             $this->order['amount_real'] = $this->subscription->data['amount_total'];
             $this->order['amount_billing'] = $this->subscription->data['amount_total'];
             $this->order['amount_profit'] = $this->subscription->data['amount_total'];
             $this->order['amount_vat'] = $this->subscription->data['amount_total'];
             $this->order['amount_with_shipping'] = $this->subscription->data['amount_total'];
             $this->order['count'] = $this->subscription->data['tranche'];
             $this->order['currency'] = $this->subscription->data['currency'];
             $this->order['method_billing'] = $this->methodBilling;
             $this->order['date_creation'] = $time;
             $this->order['date_creation_human'] = $timeHuman;
             $this->order['date_modification'] = $time;
             $this->order['date_modification_human'] = $timeHuman;
             $this->order['products'] = base64_encode(serialize($this->subscription));
             $orderEntity = new OrderEntity($this->order, $this->doorGets);
             $orderEntity->save(false);
             $this->saveUserAddress();
             $_SESSION['orderId'] = $this->order['id'] = $orderEntity->getId();
             $paymentUrl = './?payment&lg=' . $this->langue;
             if ($this->methodBilling === 'paypal') {
                 $paypalService = new PaypalPaymentService($this->doorGets, $this->subscription);
                 $paymentUrl = $paypalService->getUrl();
             }
             header('Location:' . $paymentUrl);
             exit;
         }
     }
 }