示例#1
0
 function startRegistration()
 {
     $_POST = sanitizeData($_POST);
     $this->set('post', $_POST);
     $userInfo = $_POST;
     $subscriptionActive = false;
     $errMsg['userName'] = formatErrorMsg($this->validate->checkUname($userInfo['userName']));
     $errMsg['password'] = formatErrorMsg($this->validate->checkPasswords($userInfo['password'], $userInfo['confirmPassword']));
     $errMsg['firstName'] = formatErrorMsg($this->validate->checkBlank($userInfo['firstName']));
     $errMsg['lastName'] = formatErrorMsg($this->validate->checkBlank($userInfo['lastName']));
     $errMsg['email'] = formatErrorMsg($this->validate->checkEmail($userInfo['email']));
     $errMsg['code'] = formatErrorMsg($this->validate->checkCaptcha($userInfo['code']));
     $errMsg['utype_id'] = formatErrorMsg($this->validate->checkNumber($userInfo['utype_id']));
     // if payment plugin installed check whether valid payment gateway found
     $seopluginCtrler = new SeoPluginsController();
     if ($seopluginCtrler->isPluginActive("Subscription")) {
         $subscriptionActive = true;
         $errMsg['pg_id'] = formatErrorMsg($this->validate->checkNumber($userInfo['pg_id']));
     }
     if (!$this->validate->flagErr) {
         if (!$this->__checkUserName($userInfo['userName'])) {
             if (!$this->__checkEmail($userInfo['email'])) {
                 $utypeId = intval($userInfo['utype_id']);
                 $sql = "insert into users\r\n\t\t\t\t\t(utype_id,username,password,first_name,last_name,email,created,status) \r\n\t\t\t\t\tvalues ({$utypeId},'" . addslashes($userInfo['userName']) . "','" . md5($userInfo['password']) . "',\r\n\t\t\t\t\t'" . addslashes($userInfo['firstName']) . "','" . addslashes($userInfo['lastName']) . "',\r\n\t\t\t\t\t'" . addslashes($userInfo['email']) . "',UNIX_TIMESTAMP(),1)";
                 $this->db->query($sql);
                 // get user id created
                 $userId = $this->db->getMaxId('users');
                 // check whether subscription is active
                 if ($subscriptionActive and $userId) {
                     $utypeCtrler = new UserTypeController();
                     $utypeInfo = $utypeCtrler->__getUserTypeInfo($utypeId);
                     // if it is paid subscription, proceed with payment
                     if ($utypeInfo['price'] > 0) {
                         $paymentPluginId = intval($userInfo['pg_id']);
                         @Session::setSession('payment_plugin_id', $paymentPluginId);
                         $quantity = intval($userInfo['quantity']);
                         $pluginCtrler = $seopluginCtrler->createPluginObject("Subscription");
                         $paymentForm = $pluginCtrler->pgCtrler->getPaymentForm($paymentPluginId, $userId, $utypeInfo, $quantity);
                         $this->set('paymentForm', $paymentForm);
                     }
                 }
                 $this->render('common/registerconfirm');
                 return True;
             } else {
                 $errMsg['email'] = formatErrorMsg($_SESSION['text']['login']['emailexist']);
             }
         } else {
             $errMsg['userName'] = formatErrorMsg($_SESSION['text']['login']['usernameexist']);
         }
     }
     $this->set('errMsg', $errMsg);
     $this->register();
 }