forked from kol-ton/greenlime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.txt
More file actions
34 lines (23 loc) · 698 Bytes
/
setup.txt
File metadata and controls
34 lines (23 loc) · 698 Bytes
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
<?php
function generate_random_key(){
if(function_exists('openssl_random_pseudo_bytes')){
$random = openssl_random_pseudo_bytes(100);
} else {
$random = rand().microtime().rand();
}
return md5($random);
}
$path_config = './config.php';
// config.php won't be writable if ran from within web server
if(!is_writable($path_config)){
exit;
}
$key = generate_random_key();
// open config.php
$config = file_get_contents($path_config);
// replace blank app_key with new generated key
$config = str_replace('$config[\'app_key\'] = \'\';', '$config[\'app_key\'] = \''.$key.'\';', $config);
// write to config.php
file_put_contents($path_config, $config);
echo "New Key: {$key}\r\n";
?>