-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfunctions.php
More file actions
105 lines (56 loc) · 1.7 KB
/
Copy pathfunctions.php
File metadata and controls
105 lines (56 loc) · 1.7 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
<?php
function baseurl(){
// output: /myproject/index.php
$currentPath = $_SERVER['PHP_SELF'];
// output: Array ( [dirname] => /myproject [basename] => index.php [extension] => php [filename] => index )
$pathInfo = pathinfo($currentPath);
// output: localhost
$hostName = $_SERVER['HTTP_HOST'];
// output: http://
$protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https://'?'https://':'http://';
// return: http://localhost/myproject/
return $protocol.$hostName.$pathInfo['dirname']."/";
}
function url($additional_path){
//$baseurl = baseurl();
$baseurl = base_path;
$completepath = $baseurl.$additional_path;
return $completepath;
}
function cleaninput($value){
$value = trim(strip_tags(addslashes($value)));
return $value;
}
function random_string($length) {
$key = '';
$keys = array_merge(range(0, 9), range('a', 'z'));
for ($i = 0; $i < $length; $i++) {
$key .= $keys[array_rand($keys)];
}
return $key;
}
function random_stringcode($length) {
$key = '';
$keys = array_merge(range(0, 9));
for ($i = 0; $i < $length; $i++) {
$key .= $keys[array_rand($keys)];
}
return $key;
}
function encryptdata($data)
{
//return $data;
$code = base64_encode($data);
$randomcode = random_string(53).$code.random_string(64);
return $randomcode;
}
function decryptdata($data)
{
//return $data;
$val1 = $data;
$worlst = substr($val1 , 53);
$worlst = substr($worlst ,0 , -64);
$worlst = base64_decode($worlst);
return $worlst;
}
?>