コード例 #1
0
 public function display()
 {
     // Cancel the transfer if a request is submitted.
     if (isset($_POST['cancel'])) {
         $transfer = new Transfer();
         $transfer->cancelSessions();
         unset($_POST['cancel']);
         $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
         $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
         header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "New-Funds-Transfer");
         // Otherwise process the transfer.
     } elseif (isset($_POST['submit'])) {
         unset($_POST['submit']);
         // To negate any back button issues.
         if (!isset($_SESSION['transferDate']) || !isset($_SESSION['transferDescription']) || !isset($_SESSION['transferRemitter']) || !isset($_SESSION['transferAmount'])) {
             header('Location: New-Funds-Transfer');
         }
         if (isset($_POST['password'])) {
             $validate = new Validation();
             // Validate the password.
             try {
                 $validate->password($_POST['password']);
             } catch (ValidationException $e) {
                 $_SESSION['error'] = $e->getError();
             }
             if (isset($_SESSION['error'])) {
                 unset($_POST['password']);
                 header('Location: New-Funds-Transfer');
             } else {
                 $user = new Users();
                 $user->userID = $_SESSION['userID'];
                 $user->password = $_POST['password'];
                 unset($_POST['password']);
                 // Confirm the password is corredt.
                 try {
                     $user->confirmPassword();
                 } catch (ValidationException $e) {
                     $_SESSION['error'] = $e->getError();
                 }
                 if (isset($_SESSION['error'])) {
                     header('Location: New-Funds-Transfer');
                 } else {
                     // If everything is ok, process the transfer and display
                     // the Transfer Acknowledgement Page
                     $account = new Account();
                     $account->accountID = $_SESSION['transferAccountID'];
                     if ($account->processTransfer()) {
                         include 'view/layout/transferack.php';
                     } else {
                         // Otherwise return to the Check Transfer page.
                         $checkTransfer = new CheckTransfer();
                         $checkTransfer->init();
                         include 'view/layout/checktransfer.php';
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
 public function display()
 {
     // Cancels the transfer.
     if (isset($_POST['cancel'])) {
         $transfer = new Transfer();
         $transfer->cancelSessions();
         unset($_POST['cancel']);
         $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
         $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
         header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "New-Funds-Transfer");
         // Proceeds with the transfer.
     } elseif (isset($_POST['next'])) {
         $checktransfer = new CheckTransfer();
         if (isset($_POST['account']) && isset($_POST['accountPayee'])) {
             $checktransfer->unsetLast();
             $_SESSION['transferAccountID'] = $_POST['account'];
             unset($_POST['account']);
             $_SESSION['transferAccountPayeeID'] = $_POST['accountPayee'];
             unset($_POST['accountPayee']);
         }
         $validate = new Validation();
         if (isset($_POST['transferAmount'])) {
             // Validates the amount.
             try {
                 $transferAmount = $_POST['transferAmount'];
                 unset($_POST['transferAmount']);
                 $validate->transferAmount($transferAmount);
             } catch (ValidationException $e) {
                 $_SESSION['error'] = $e->getError();
             }
             if (isset($_SESSION['error'])) {
                 $transferAmount = null;
                 unset($_POST['next']);
                 header('Location: New-Funds-Transfer');
             } else {
                 $_SESSION['transferAmount'] = $transferAmount;
                 // Validates the description.
                 try {
                     $transferDescription = $_POST['transferDescription'];
                     unset($_POST['transferDescription']);
                     $validate->transferDescription($transferDescription);
                 } catch (ValidationException $e) {
                     $_SESSION['error'] = $e->getError();
                 }
                 if (isset($_SESSION['error'])) {
                     $transferDescription = null;
                     unset($_POST['next']);
                     header('Location: New-Funds-Transfer');
                 } else {
                     $_SESSION['transferDescription'] = $transferDescription;
                     // Validates the remitter.
                     try {
                         $transferRemitter = $_POST['transferRemitter'];
                         unset($_POST['transferRemitter']);
                         $validate->transferRemitter($transferRemitter);
                     } catch (ValidationException $e) {
                         $_SESSION['error'] = $e->getError();
                     }
                     if (isset($_SESSION['error'])) {
                         $transferRemitter = null;
                         unset($_POST['next']);
                         header('Location: New-Funds-Transfer');
                     } else {
                         $_SESSION['transferRemitter'] = $transferRemitter;
                         // Validates the date.
                         try {
                             $transferDate = $_POST['transferDate'];
                             unset($_POST['transferDate']);
                             $validate->transferDate($transferDate);
                         } catch (ValidationException $e) {
                             $_SESSION['error'] = $e->getError();
                         }
                         if (isset($_SESSION['error'])) {
                             $transferDate = null;
                             unset($_POST['next']);
                             header('Location: New-Funds-Transfer');
                         } else {
                             $_SESSION['transferDate'] = $transferDate;
                             // Displays the Check Transfer Page.
                             $checktransfer->init();
                             include 'view/layout/checktransfer.php';
                         }
                     }
                 }
             }
         }
     }
 }