@@ -23,16 +23,17 @@ public function __construct(IdentityHelper $identityHelper) {
23
23
*
24
24
*/
25
25
public function index (Request $ request ) {
26
- // Set variables
26
+
27
+ $ platformBase = filter_input (INPUT_SERVER , 'DOCUMENT_ROOT ' );
28
+ $ moduleBase = $ platformBase . dirname (filter_input (INPUT_SERVER , 'PHP_SELF ' ));
27
29
$ configBase = env ('CONFIG_DIR ' , "/share/Public/storagenode.conf " );
28
- $ scriptsBase = base_path ( ' public /scripts ') ;
30
+ $ scriptsBase = $ moduleBase . ' /scripts ' ;
29
31
$ identityGenBinary = env ('IDENTITY_GEN_BINARY ' , "/share/Public/identity.bin/identity " );
30
32
$ logFile = env ('IDENTITY_LOG ' , "share/Public/identity/logs/storj_identity.log " );
31
33
32
-
33
34
$ data = $ this ->identityHelper ->loadConfig ("$ {configBase}/config.json " );
34
- // Update config json file if updates provided
35
- $ inputs = $ request -> all ( );
35
+ # Update config json file if updates provided
36
+ $ inputs = $ this -> identityHelper -> loadConfig ( " php://input " );
36
37
if (isset ($ inputs ['authkey ' ]) || isset ($ inputs ['identity ' ])) {
37
38
// Saving Identity Path and Auth Key in JSON file.
38
39
if (isset ($ inputs ["authkey " ])) {
@@ -41,22 +42,22 @@ public function index(Request $request) {
41
42
if (isset ($ inputs ["identity " ])) {
42
43
$ data ['Identity ' ] = $ inputs ["identity " ];
43
44
}
44
- $ this ->identityHelper ->storeConfig ($ data , "$ {configBase} / config.json " );
45
+ $ this ->identityHelper ->storeConfig ($ data , "config.json " );
45
46
}
46
47
47
48
$ identityGenScriptPath = $ scriptsBase . DIRECTORY_SEPARATOR . 'generateIdentity.sh ' ;
48
49
$ Path = $ data ["Identity " ] . "/storagenode " ;
49
50
$ identityFilePath = "$ {Path}/identity.key " ;
50
- $ urlToFetch = env ('IDENTITY_URL ' , "https://github.com/storj/storj/releases/latest/download/identity_linux_amd64.zip " );
51
- $ identitypidFile = url ('identity.pid ' );
52
-
51
+ $ urlToFetch = "https://github.com/storj/storj/releases/latest/download/identity_linux_amd64.zip " ;
52
+ $ identitypidFile = $ moduleBase . DIRECTORY_SEPARATOR . 'identity.pid ' ;
53
53
54
+ # ------------------------------------------------------------------------
54
55
55
56
$ date = Date ('Y-m-d H:i:s ' );
56
57
$ output = "" ;
57
- $ configFile = "$ {configBase} / config.json " ;
58
+ $ configFile = "config.json " ;
58
59
59
- $ inputs = $ request -> all ( );
60
+ $ inputs = $ this -> identityHelper -> loadConfig ( " php://input " );
60
61
61
62
62
63
$ this ->identityHelper ->logMessage ("================== identity.php invoked ================== " );
@@ -112,12 +113,12 @@ public function index(Request $request) {
112
113
113
114
$ this ->identityHelper ->logMessage ("Invoked identity generation program ( $ identityGenScriptPath) " );
114
115
echo $ lastline ;
115
- } else if (isset ($ inputs ['status ' ])) {
116
+ } else if (filter_input ( INPUT_POST , ' status ' ) || isset ($ inputs ['status ' ])) {
116
117
$ this ->identityHelper ->logMessage ("Identity php called for fetching STATUS! " );
117
- $ data ['LogFilePath ' ] = $ logFile ;
118
- $ data ['idGenStartTime ' ] = $ date ;
118
+
119
119
$ file = $ data ['LogFilePath ' ];
120
- $ pid = file_get_contents ("identity.pid " );
120
+
121
+ $ pid = file_get_contents ($ identitypidFile );
121
122
$ prgStartTime = $ data ['idGenStartTime ' ];
122
123
$ file = escapeshellarg ($ file );
123
124
$ lastline = `tail -c160 $ file | sed -e 's# \\r# \\n#g' | tail -1 `;
@@ -131,11 +132,10 @@ public function index(Request $request) {
131
132
$ this ->identityHelper ->logMessage ("identity available at $ {identityFilePath}" );
132
133
echo "identity available at $ {identityFilePath}" ;
133
134
} else {
134
- $ data = $ this ->identityHelper ->loadConfig ($ configFile );
135
- $ data ['idGenStartTime ' ] = $ date ;
135
+ $ data = $ this ->identityHelper ->loadConfig ("/share/Public/storagenode.conf/config.json " );
136
136
$ lastline = preg_replace ('/\n$/ ' , '' , $ lastline );
137
137
$ this ->identityHelper ->logMessage ("STATUS: Identity generation in progress (LOG: $ lastline) " );
138
- echo "Identity generation STATUS( $ date):<BR> " .
138
+ echo "Identity generation STATUS a ( $ date):<BR> " .
139
139
"Process ID: $ pid , " .
140
140
"Started at: " . $ data ['idGenStartTime ' ] . "<BR> " . $ lastline ;
141
141
?> <div style="text-align: center"><img src="img/spinner.gif"></div><?php
0 commit comments