-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClients_welcome.php
219 lines (177 loc) · 7.67 KB
/
Clients_welcome.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="style_client.css">
</head>
<body>
<?php
session_start();
require_once 'Database.php';
require_once 'Active_Subscriptions.php';
require_once 'pictures_subscriptions.php';
unset($_SESSION['user_id_Agent']);
unset($_SESSION['user_id_Admins']);
echo '<div class="top">';
// Check if the user is logged in
if (isset($_SESSION['user_id_Client'])) {
$userId = $_SESSION['user_id_Client'];
echo "<h1>Client ID: $userId</h1><br/>";
Verify_if_client_has_Active_Subscription_Client_ver($connection, $userId);
$Request = "SELECT * FROM images, Clients WHERE ClientID = $userId AND id = ProfilePictureID";
$stmt = $connection->prepare($Request);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
echo '</div>';//top
echo '<div class="bottom">';
echo '<div class="bottom-left">';
echo '<form method="post">';
if ($result) {
$imageData = base64_encode($result['image_data']);
echo '<img src="data:image/jpeg;base64,' . $imageData . '" class="img2">';
} else {
echo "Image not found";
}
echo '<input type="submit" name="ChangePswd" class="bouton-left" value="Change my Password">';
echo '<input type="submit" name="upchpfpforms" class="bouton-left" value="Upload/Change my profile picture">';
echo '<input type="submit" name="Subscribe" class="bouton-left" value="Subscribe">';
echo '<input type="submit" name="RenewSub" class="bouton-left" value="Renew my current subscription">';
echo '<input type="submit" name="Logoff" class="bouton-left2" value="Logoff">';
echo '</form>';
echo '</div>';//bottomleft
////////// print pfp ////////////////////////////////////////////////////
echo '<div class="bottom-right">';
echo '<div class="container_right">';
echo "<br>";
echo '<div><a class="numbr">If you want to renew your current subscription, then you have to click on renew before the subscription ends</a></div>';
echo '<div><a class="numbr">If you want to change your subscription, just wait for your current subscription to end and create a new one</a></div>';
echo "<br>";
///change pfp
if (isset($_POST["upchpfpforms"])) {
echo "<br>";
echo '<div>Please upload your profile picture (make sure its a picture of you)</div>';
echo '<form enctype="multipart/form-data" action="" method="POST">';echo "<br>";
echo '<div><label for="filee">Choose Image:</label>';
echo '<input type="file" id="filee" name="filee" accept="image/*" required></div>';echo "<br>";
echo '<div><input type="submit" class="formbot3" name="final_submit_pfp" value="Upload"></div>';
}
if (isset($_POST["final_submit_pfp"])) {
$IDPic = null;
if (isset($_FILES['filee'])) {
$IDPic = handleImageUpload($_FILES['filee'], $connection);
echo "Your profile picture has been changed";
if (!$IDPic) {
echo "Error uploading IDPic";
exit();
}
}
uploadrenewPfp_clients($connection,$userId, $IDPic);
}
if (isset($_POST['RenewSub'])) {
require_once 'Renew_Request.php';
$ClientID = $_SESSION['user_id_Client'];
$tempbool = hasRenewalRequest($connection, $ClientID);
if ($tempbool == 'true'){ echo "you've already submitted a renewal request";}
else {
$ClientID = $_SESSION['user_id_Client'];
$pay = Check_if_has_to_pay($connection, $ClientID);
if ($pay > 0) {
echo "<br>";
echo '<div>Please upload your proof of payment</div>';
echo '<form enctype="multipart/form-data" action="" method="POST"><br>';
echo '<div><label for="file">Choose Image:</label>';
echo '<input type="file" id="file" name="file" accept="image/*" required></div>';
echo "<br>";
echo '<div><input class="formbot3" type="submit" name="final_submit1" value="Renew"></div>';
echo '</form>';
} else {
echo '<form enctype="multipart/form-data" action="" method="POST">';echo "<br>";
echo 'Renew (since your subscription was free, you dont have to upload any documents)';echo "<br>";
echo '<div><input type="submit" class="formbot3" name="final_submit2" value="Renew"></div>';
echo '</form>';
}
}}
if (isset($_POST['final_submit1'])) {
require_once 'Renew_Request.php';
$ClientID = $_SESSION['user_id_Client'];
$RenewalID = Get_New_ID_Renew($connection, 'Renew_Requests', 'RenewalID');
$AsubID = GetActSubID($connection, $ClientID);
$Price = Check_if_has_to_pay($connection, $ClientID);
$SubscriptionType = null;
$ProofOfPaymentID = null;
if (isset($_FILES['file'])) {
$ProofOfPaymentID = handleImageUpload($_FILES['file'], $connection);
if (!$ProofOfPaymentID) {
echo "Error uploading Proof";
exit();
}
}
$ReqOBJ = new Renew_Requests($RenewalID, $AsubID, $SubscriptionType, $Price, $ProofOfPaymentID);
$ReqOBJ->Renew_Request_Table_Creation($connection);
$ReqOBJ->Submit_Renewal_Request($connection);
}
if (isset($_POST['final_submit2'])) {
require_once 'Renew_Request.php';
$ClientID = $_SESSION['user_id_Client'];
$RenewalID = Get_New_ID_Renew($connection, 'Renew_Requests', 'RenewalID');
$AsubID = GetActSubID($connection, $ClientID);
$Price = 'Free';
$SubscriptionType = null;
$ProofOfPaymentID = null;
$ReqOBJ = new Renew_Requests($RenewalID, $AsubID, $SubscriptionType, $Price, $ProofOfPaymentID);
$ReqOBJ->Renew_Request_Table_Creation($connection);
$ReqOBJ->Submit_Renewal_Request($connection);
}
//////// change it, check if current client has an active subscription already
if (isset($_POST['Subscribe'])) {
echo '<script>window.location.href = "New_Subscription_Request_Clients.php";</script>';
//header("Location: New_Subscription_Request_Clients.php");
exit();
}
} else {
header("Location: login.php");
exit();
}
function Change_Password_Forms(){
echo '<h2 class="titre">Change Password</h2>';
echo '<form action="" method="post">';
echo ' <label class="formtxt" for="new_password">New Password:</label>';
echo ' <input class="form" type="password" id="new_password" name="new_password" required><br>';
echo ' <label class="formtxt" for="confirm_password">Confirm Password:</label>';
echo ' <input class="form" type="password" id="confirm_password" name="confirm_password" required><br>';
echo ' <input class="formbot3" type="submit" name="change_password" value="Change Password">';
echo '</form>';
}
if (isset($_POST["ChangePswd"])) {
Change_Password_Forms();
}
if (isset($_POST["Logoff"])) {
session_destroy();
unset($_SESSION['user_id_Client']);
echo '<script>window.location.href = "login.php";</script>';
exit();
}
if (isset($_POST["change_password"])) {
// Validate form data
$newPassword = $_POST["new_password"];
$confirmPassword = $_POST["confirm_password"];
if ($newPassword != $confirmPassword) {
echo "Error: New password and confirm password do not match.";
exit();
}
// Hash the password with md5()
$hashedPassword = md5($newPassword);
$Request = "UPDATE Clients SET Password = :NewPassword WHERE ClientID = :ClientID";
$stmt = $connection->prepare($Request);
$stmt->execute([
':NewPassword' => $hashedPassword,
':ClientID' => $userId
]);
echo "Password changed successfully!";
}
echo '</div>';//containerright
echo '</div>';//bottomright
echo '</div>';//bottom
?>
</body>
</html>