-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
54 lines (43 loc) · 1.74 KB
/
index.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
<?php
function randomPassword($length,$count, $characters) {
// $length - the length of the generated password
// $count - number of passwords to be generated
// $characters - types of characters to be used in the password
// define variables used within the function
$symbols = array();
$passwords = array();
$used_symbols = '';
$pass = '';
// an array of different character types
$symbols["lower_case"] = 'abcdefghijklmnopqrstuvwxyz';
$symbols["upper_case"] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$symbols["numbers"] = '1234567890';
$symbols["special_symbols"] = '!?~@#-_+<>[]{}';
$characters = split(",",$characters); // get characters types to be used for the passsword
foreach ($characters as $key=>$value) {
$used_symbols .= $symbols[$value]; // build a string with all characters
}
$symbols_length = strlen($used_symbols) - 1; //strlen starts from 0 so to get number of characters deduct 1
for ($p = 0; $p < $count; $p++) {
$pass = '';
for ($i = 0; $i < $length; $i++) {
$n = rand(0, $symbols_length); // get a random character from the string with all characters
$pass .= $used_symbols[$n]; // add the character to the password string
}
$passwords[] = $pass;
}
return $passwords; // return the generated password
}
$DeveloperPasswords = ["Name1-Password1","Name2-Password2"];
if(!isset($_COOKIE['DeveloperPassword'])) {
include("./includes/401.php");
}else{
for ($i=0; $i < sizeof($DeveloperPasswords) -1; $i++) {
if ($DeveloperPasswords[$i] == $_COOKIE['DeveloperPassword']) {
include("./includes/home.php");
}else{
include("./includes/401.php");
}
}
}
?>