-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.php
More file actions
113 lines (69 loc) · 1.76 KB
/
helpers.php
File metadata and controls
113 lines (69 loc) · 1.76 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
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
<?php
/**
* Created by Md. Atiqur Rahman. <atiqur.su@gmail.com, atiqur@shaficonsultancy.com>
* Date: 11/10/2019
* Time: 1:48 PM
*/
/**
* @author Md. Atiqur Rahman <atiqur.su@gmail.com, atiqur@shaficonsultancy.com>
* @param $arg
* @param string $msg
*/
function dd($arg, $msg = 'I am exiting....') {
echo '<pre>';
if(is_array($arg)) {
print_r($arg);
} elseif(is_object($arg)) {
var_dump($arg);
} else {
var_dump($arg);
}
echo '</pre>';
die($msg);
}
/**
* @author Md. Atiqur Rahman <atiqur.su@gmail.com, atiqur@shaficonsultancy.com>
*/
function ddd() {
$args = func_get_args();
if(empty($args)) die('No argument passed........');
foreach($args as $arg) {
echo '<pre>';
if(is_array($arg)) {
print_r($arg);
} elseif(is_object($arg)) {
var_dump($arg);
} else {
var_dump($arg);
}
}
echo '</pre>';
die('Exiting....all arguments are dumped!');
}
/**
*
* @author Md. Atiqur Rahman <atiqur.su@gmail.com, atiqur@shaficonsultancy.com>
* @return bool
*/
function generateNewSalt() {
$salt = substr(str_replace('+', '.', base64_encode(md5(mt_rand(), true))), 0, 16);
$reading = fopen('config.php', 'r');
$writing = fopen('config.php.tmp', 'w');
$replaced = false;
while(!feof($reading)) {
$line = fgets($reading);
if(strrpos($line, '$salt') !== false) {
$line = '$salt = \'' . $salt . '\';';
$replaced = true;
}
fputs($writing, $line);
}
fclose($reading);
fclose($writing);
if($replaced) {
rename('config.php.tmp', 'config.php');
} else {
unlink('config.php.tmp');
}
return true;
}