diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..fa5c670
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "php.version": "8.4"
+}
\ No newline at end of file
diff --git a/admin/index.php b/admin/index.php
index e0eff21..285997b 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -31,10 +31,10 @@ if (!isset($_SESSION['account_loggedin'])) {
exit;
}
// If the user is not admin redirect them back to the shopping cart home page
-$stmt = $pdo->prepare('SELECT * FROM accounts WHERE id = ?');
-$stmt->execute([ $_SESSION['account_id'] ]);
-$account = $stmt->fetch(PDO::FETCH_ASSOC);
-if (!$account || $account['role'] != 'Admin') {
+$account = ioAPIv2('/v2/identity/userkey='.$_SESSION['account_id'].'&isverified=1','',$clientsecret);
+$account = json_decode($account,true);
+
+if (!$account || $account[0]['profile'] != 1) {
header('Location: ' . url('../index.php'));
exit;
}
diff --git a/checkout.php b/checkout.php
index 7708569..9da0169 100644
--- a/checkout.php
+++ b/checkout.php
@@ -6,7 +6,7 @@ defined(security_key) or exit;
// Defaults
// ---------------------------------------
$account = [
- 'account_id' => $_POST['account_id'] ?? '',
+ 'account_id' => $_SESSION['account_id'] ?? '',
'email' => $_POST['email'] ?? '',
'first_name' => $_POST['first_name'] ?? '',
'last_name' => $_POST['last_name'] ?? '',
@@ -58,10 +58,12 @@ if (empty($_SESSION['cart'])) {
// Check if user is logged in
if (isset($_SESSION['account_loggedin'])) {
- $stmt = $pdo->prepare('SELECT * FROM accounts WHERE id = ?');
- $stmt->execute([ $_SESSION['account_id'] ]);
- // Fetch the account from the database and return the result as an Array
- $account = $stmt->fetch(PDO::FETCH_ASSOC);
+ $api_url = '/v2/identity/userkey='.$_SESSION['account_id'];
+ $account = ioAPIv2($api_url,'',$clientsecret);
+ if (!empty($account)){$account = json_decode($account,true);}
+ $account = $account[0];
+ //RESET ACCOUNT_ID
+ $account['account_id'] = $account['userkey'];
}
// Update discount code
@@ -119,14 +121,30 @@ if (isset($_POST['method'], $_POST['first_name'], $_POST['last_name'], $_POST['a
// If the user is already logged in
if (isset($_SESSION['account_loggedin'])) {
// Account logged-in, update the user's details
- $stmt = $pdo->prepare('UPDATE accounts SET first_name = ?, last_name = ?, address_street = ?, address_city = ?, address_state = ?, address_zip = ?, address_country = ?, address_phone = ? WHERE id = ?');
- $stmt->execute([ $_POST['first_name'], $_POST['last_name'], $_POST['address_street'], $_POST['address_city'], $_POST['address_state'], $_POST['address_zip'], $_POST['address_country'], $_POST['address_phone'], $_SESSION['account_id'] ]);
- $account_id = $_SESSION['account_id'];
+ $payload = json_encode(
+ array(
+ "language" => $_SESSION['country_code'],
+ "first_name" => $_POST['first_name'],
+ "last_name" => $_POST['last_name'],
+ "address_street" => $_POST['address_street'],
+ "address_city" => $_POST['address_city'],
+ "address_state" => $_POST['address_state'],
+ "address_zip" => $_POST['address_zip'],
+ "address_country" => $_POST['address_country'],
+ "address_phone" => $_POST['address_phone'],
+ "userkey" => $_SESSION['account_id']), JSON_UNESCAPED_UNICODE);
+ $account_update = ioAPIv2('/v2/identity/',$payload,$clientsecret);
+ $account_update = json_decode($account_update,true);
+ $account_id = $account['account_id'] = $_SESSION['account_id'];
+
} else if (isset($_POST['email'], $_POST['password'], $_POST['cpassword']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) && !empty($_POST['password']) && !empty($_POST['cpassword'])) {
// User is not logged in, check if the account already exists with the email they submitted
- $stmt = $pdo->prepare('SELECT id FROM accounts WHERE email = ?');
- $stmt->execute([ $_POST['email'] ]);
- if ($stmt->fetch(PDO::FETCH_ASSOC)) {
+ // Check if the account exists
+ $account = ioAPIv2('/v2/identity/email='.$_POST['email'],'',$clientsecret);
+ $account = json_decode($account,true);
+
+
+ if ($account) {
// Email exists, user should login instead...
$errors[] = $error_account_name;
}
@@ -139,16 +157,33 @@ if (isset($_POST['method'], $_POST['first_name'], $_POST['last_name'], $_POST['a
$errors[] = $error_account_password_match;
}
if (!$errors) {
- // Hash the password
- $password = password_hash($_POST['password'], PASSWORD_DEFAULT);
- // Email doesnt exist, create new account
- $stmt = $pdo->prepare('INSERT INTO accounts (email, password, first_name, last_name, address_street, address_city, address_state, address_zip, address_country, address_phone) VALUES (?,?,?,?,?,?,?,?,?,?)');
- $stmt->execute([ $_POST['email'], $password, $_POST['first_name'], $_POST['last_name'], $_POST['address_street'], $_POST['address_city'], $_POST['address_state'], $_POST['address_zip'], $_POST['address_country'], $_POST['address_phone'] ]);
- $account_id = $pdo->lastInsertId();
- $stmt = $pdo->prepare('SELECT * FROM accounts WHERE id = ?');
- $stmt->execute([ $account_id ]);
- // Fetch the account from the database and return the result as an Array
- $account = $stmt->fetch(PDO::FETCH_ASSOC);
+ // Account doesnt exist, create new account
+ $payload = json_encode(
+ array(
+ "email" => $_POST['email'],
+ "password" => $_POST['password'],
+ "language" => $_SESSION['country_code'],
+ "first_name" => $_POST['first_name'],
+ "last_name" => $_POST['last_name'],
+ "address_street" => $_POST['address_street'],
+ "address_city" => $_POST['address_city'],
+ "address_state" => $_POST['address_state'],
+ "address_zip" => $_POST['address_zip'],
+ "address_country" => $_POST['address_country'],
+ "address_phone" => $_POST['address_phone']), JSON_UNESCAPED_UNICODE);
+
+ $account = ioAPIv2('/v2/identity/',$payload,$clientsecret);
+ $account= json_decode($account,true);
+ $account_id = $account['account_id'] = $account['accountID'];
+
+ if ($account && isset($account['accountID'])) {
+ //SEND VERIFICATION EMAIL
+ include dirname(__FILE__).'/custom/email/email_template_register.php';
+ $register_mail = $message;
+
+ send_mail_by_PHPMailer($account['identity'], $subject, $register_mail,'', '');
+ $register_error = 'Email send to verify your account';
+ }
}
} else if (account_required) {
$errors[] = $error_account;
@@ -159,7 +194,7 @@ if (isset($_POST['method'], $_POST['first_name'], $_POST['last_name'], $_POST['a
//Process checkout => add payment_method to checkout_input array
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$checkout_input['payment_method'] = $_POST['method'];
-
+
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Calculate shopping_cart based on session
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -205,7 +240,7 @@ if (isset($_POST['method'], $_POST['first_name'], $_POST['last_name'], $_POST['a
session_regenerate_id();
$_SESSION['account_loggedin'] = TRUE;
$_SESSION['account_id'] = $account_id;
- $_SESSION['account_role'] = $account ? $account['role'] : 'Member';
+ $_SESSION['account_role'] = $account ? $account['profile'] : 0;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -218,10 +253,10 @@ if (isset($_POST['method'], $_POST['first_name'], $_POST['last_name'], $_POST['a
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- // Mollie = 0 ++++++++++++++++++++++++++++++++++++++++++++++++++
+ // Mollie = 3 ++++++++++++++++++++++++++++++++++++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- if (mollie_enabled && $_POST['method'] == 0) {
+ if (mollie_enabled && $_POST['method'] == 3) {
try {
/*
@@ -290,7 +325,7 @@ if (isset($_POST['method'], $_POST['first_name'], $_POST['last_name'], $_POST['a
// PayPal Payment = 1 +++++++++++++++++++++++++++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- if (paypal_enabled && $_POST['method'] == 'paypal') {
+ if (paypal_enabled && $_POST['method'] == 1) {
//Process Payment
require_once __DIR__."/lib/paypal/paypal.php";
@@ -356,7 +391,7 @@ $view .= '
'.$account_available.' ';
if (mollie_enabled){
- $view .= '
+ $view .= '