Esempio n. 1
0
 public function approveRequest($id, $transaction, $startBalance = 0.0)
 {
     $table = "users";
     if ($transaction) {
         $table = "transactions";
     }
     //check if already approved
     $dbHandler = DatabaseHandler::getInstance();
     $aprroved = $dbHandler->execQuery("SELECT approved FROM " . $table . " WHERE id='" . $id . "';");
     if ($aprroved == '1') {
         echo "ERROR: Already approved!\n";
         return NULL;
     }
     //change the value
     $dbHandler->execQuery("UPDATE " . $table . " SET approved='1' WHERE id='" . $id . "';");
     if ($transaction) {
         MoneyTransferHandler::performTransaction($id);
     } else {
         $res = $dbHandler->execQuery("SELECT * FROM " . $table . " WHERE id='" . $id . "';");
         $row = $res->fetch_assoc();
         $email = $row['mail_address'];
         $usesSCS = $row['uses_scs'];
         if ($usesSCS) {
             self::mailSCS($email);
         } else {
             $tans = self::createTans($id);
             $tanFile = self::CreateTanPDF($tans, $id, $row['password']);
             self::mailTans($tanFile, $email);
         }
         $balance = floatval($startBalance);
         $dbHandler->execQuery("UPDATE accounts SET balance='" . $balance . "' WHERE user_id='" . $id . "';");
     }
 }
Esempio n. 2
0
        $amount = htmlentities(strip_tags($_POST['amount']));
        $tid = htmlentities(strip_tags($_POST['tid']));
        $tan = htmlentities(strip_tags($_POST['tan']));
        $description = htmlentities(strip_tags($_POST['description']));
        $rc = MoneyTransferHandler::transferMoney($id, $iban, $amount, $tan, $tid, $description, $uploadFilePath);
        if ($rc != 0) {
            echo "ERROR: Transfer could not be processed! Error Code: {$rc}";
            return;
        }
    } elseif ($type == 'multiple') {
        $tid = $_POST['tid'];
        $tan = $_POST['tan'];
        $parts = pathinfo($_FILES['batchfile']['name']);
        if ($parts['extension'] != "txt") {
            echo "ERROR: Wrong file type!";
            return;
        }
        if (move_uploaded_file($_FILES['batchfile']['tmp_name'], $uploadFilePath)) {
            $rc = MoneyTransferHandler::parseBatchFile($id, $uploadFilePath, $tid, $tan);
            if ($rc != 0) {
                echo "ERROR: Batch file couldn't be processed! Error Code: {$rc}";
                return;
            }
        } else {
            echo "ERROR: Batch file wasn't uploaded successfully!";
            return;
        }
    }
}
//after the transaction goes back to the account page
header("Location:../View/account.php");