-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.php
More file actions
72 lines (63 loc) · 2.11 KB
/
sample.php
File metadata and controls
72 lines (63 loc) · 2.11 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
<?php
/* First in first, need to integrate the class for running the examples.. */
require_once 'StringWise.php';
use Uxms\Stringwise\StringWise;
/*
* I have NormalAdmin (so have User privileges), Reading and Writing permissions, so:
*/
$myPermissions = StringWise::orInt([
StringWise::NormalAdmin,
StringWise::Reading,
StringWise::Writing
]); // gives 27
echo "
Your rights: $myPermissions<br>
<ul>";
foreach (StringWise::getConstants() as $key => $value) {
if (StringWise::andInt([$myPermissions, $value]) == $value)
echo "<li>$key</li>";
}
echo '
</ul>';
/*
* I gave permissions to user which have NormalAdmin and Reading rights for WEB SERVICE, so:
*/
$neededPermissionsWS = StringWise::orInt([
StringWise::NormalAdmin,
StringWise::Reading
]);
echo "
Needed permissions for entering the WEB SERVICE section: $neededPermissionsWS<br>
<ul>";
foreach (StringWise::getConstants() as $key => $value) {
if (StringWise::andInt([$neededPermissionsWS, $value]) == $value)
echo "<li>$key</li>";
}
echo '
</ul>';
if (StringWise::andInt([$myPermissions, $neededPermissionsWS]) == $neededPermissionsWS) {
echo '<h1><em style="color:#58B058;">You have rights for enter WEB SERVICE section</em></h1>';
} else {
echo '<h1><em style="color:#D14641;">You don\'t have rights for enter WEB SERVICE section</em></h1>';
}
/*
* I give permissions to user which have SysAdmin and Reading rights for ADMIN PANEL, so:
*/
$neededPermissionsAP = StringWise::orInt([
StringWise::SysAdmin,
StringWise::Reading
]);
echo "
Needed permissions for entering the ADMIN PANEL section: $neededPermissionsAP<br>
<ul>";
foreach (StringWise::getConstants() as $key => $value) {
if (StringWise::andInt([$neededPermissionsAP, $value]) == $value)
echo "<li>$key</li>";
}
echo '
</ul>';
if (StringWise::andInt([$myPermissions, $neededPermissionsAP]) == $neededPermissionsAP) {
echo '<h1><em style="color:#58B058;">You have rights for enter ADMIN PANEL section</em></h1>';
} else {
echo '<h1><em style="color:#D14641;">You don\'t have rights for enter ADMIN PANEL section</em></h1>';
}