-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.php
More file actions
76 lines (63 loc) · 1.71 KB
/
utils.php
File metadata and controls
76 lines (63 loc) · 1.71 KB
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
<?php
/*
* Copyright © 2026 COPD GUARD - Health Management System (Dashboard)
* All rights reserved.
* Developed by Abdulrahman Fadhl Ameer Saif
* @EngAboodSDev (abdulrahmanfadhl@gmail.com)
*/
function redirect(String $page)
{
echo "<script>window.location.href='" . $page . "'</script>";
}
function alertMessage($message)
{
echo "<script>alert('" . $message . "')</script>";
}
function escapeStr($con,$str)
{
return htmlentities(mysqli_real_escape_string($con,$str));
}
/*
* Copyright © 2026 COPD GUARD - Health Management System (Dashboard)
* All rights reserved.
* Developed by Abdulrahman Fadhl Ameer Saif
* @EngAboodSDev (abdulrahmanfadhl@gmail.com)
*/
// Encryption
function encrypt($string, $key) { // key = U#h2*4pL!Z8d@9sF
$cipher = "AES-256-CBC";
$iv = random_bytes(openssl_cipher_iv_length($cipher));
$encrypted = openssl_encrypt($string, $cipher, $key, 0, $iv);
return base64_encode($iv . $encrypted);
}
// Decryption
function decrypt($encryptedString, $key) {
$cipher = "AES-256-CBC";
$data = base64_decode($encryptedString);
$iv = substr($data, 0, openssl_cipher_iv_length($cipher));
$encrypted = substr($data, openssl_cipher_iv_length($cipher));
return openssl_decrypt($encrypted, $cipher, $key, 0, $iv);
}
function isUserLoggedIn()
{
return isset($_COOKIE['user_id']);
}
function isAdminLoggedIn()
{
return isset($_COOKIE['admin_id']);
}
function currentUserId()
{
return $_COOKIE['user_id'];
}
function currentAdminId()
{
return $_COOKIE['admin_id'];
}
/*
* Copyright © 2026 COPD GUARD - Health Management System (Dashboard)
* All rights reserved.
* Developed by Abdulrahman Fadhl Ameer Saif
* @EngAboodSDev (abdulrahmanfadhl@gmail.com)
*/
?>