forked from dockay/gridseed-blade-webinterface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
63 lines (44 loc) · 1.23 KB
/
functions.php
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
<?php
function getAllConfigs(){
$configArray = array();
if ($handle = opendir('conf')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != 'template.conf' && $entry != "." && $entry != "..") {
$pos = strpos($entry,'active');
if($pos === false){
array_push($configArray,$entry);
}
}
}
}
sort($configArray);
closedir($handle);
return $configArray;
}
function setDataPerConfig(){
$confArray = getAllConfigs();
foreach($confArray as $key => $entry){
unlink('conf/active_'.$entry);
$entryFileString = file_get_contents('conf/'.$entry);
$newFile = str_replace('%pool%',$_POST[inp_pool],$entryFileString);
$user = $_POST[inp_user];
if($_POST[inp_useradd] == 1) {
$user = $user.($key+1);
}
$newFile = str_replace('%user%',$user,$newFile);
$newFile = str_replace('%pass%',$_POST[inp_pass],$newFile);
$freq = "inp_freq_".$key;
$newFile = str_replace('%freq%',$_POST[$freq],$newFile);
$port = $key;
if($key < 10){
$port = "0".$key;
}
$newFile = str_replace('%port%',$port,$newFile);
$newFileName = "conf/active_".$entry;
$save = file_put_contents($newFileName,$newFile);
}
}
function killAllMiners(){
shell_exec("sudo killall -15 screen");
}
?>