Skip to content

Commit 8e531e3

Browse files
committed
Refatored and bugfix
1 parent 85ebc9b commit 8e531e3

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/ElectrumPHP.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ class ElectrumPHP{
1313

1414
public function __construct($walletPath, $walletPass, $user, $pass, $port, $host = '127.0.0.1', $binary = false){
1515

16-
putenv("PATH=/home/www/.local/bin:/usr/local/bin:/usr/bin:/bin");
16+
$which = trim(exec("which electrum"));
17+
18+
if($which && file_exists($which)){
19+
putenv("PATH=" . dirname($which) . ":" . getenv("PATH"));
20+
}
1721

18-
$this->user = $user;
19-
$this->pass = $pass;
20-
$this->port = $port;
21-
$this->wallet = $walletPath;
22-
$this->walletpass = $walletPass;
22+
$this->user = escapeshellarg($user);
23+
$this->pass = escapeshellarg($pass);
24+
$this->port = escapeshellarg($port);
25+
$this->wallet = escapeshellarg($walletPath);
26+
$this->walletpass = escapeshellarg($walletPass);
2327
$this->url = "http://$host:$port";
24-
$this->binary = (!$binary ? $this->getBinary() : $binary);
28+
$this->binary = (!$binary ? $this->getBinary() : escapeshellarg($binary));
2529

2630
}
2731

0 commit comments

Comments
 (0)