forked from emoncms/backup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_emoncms_mysql_auth.php
More file actions
31 lines (26 loc) · 909 Bytes
/
get_emoncms_mysql_auth.php
File metadata and controls
31 lines (26 loc) · 909 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
<?php
// file_put_contents("/tmp/checkuser", "test");
// $user = fileowner("/tmp/checkuser");
// unlink("/tmp/checkuser");
// if ($user!=1000) die;
# get passed emoncms location from bash e.g. $ echo /var/www/emoncms | php get_emoncms_mysql_auth.php
function getInput()
{
$input = '';
$fr = fopen("php://stdin", "r");
while (!feof ($fr))
{
$input .= fgets($fr);
}
fclose($fr);
return $input;
}
$emoncms_dir = getInput();
# Strip new line
$emoncms_dir = trim(preg_replace('/\s\s+/', ' ', $emoncms_dir));
# Get MYSQL auth details from Emoncms settings.php
chdir($emoncms_dir);
//chdir("/var/www/emoncms");
define('EMONCMS_EXEC', 1);
require "process_settings.php";
echo $settings['sql']['username'].":".$settings['sql']['password'].":".$settings['sql']['database'];