Skip to content

Commit a2e0a48

Browse files
committed
Added force installation
1 parent 55d3680 commit a2e0a48

File tree

2 files changed

+34
-26
lines changed

2 files changed

+34
-26
lines changed

controllers/installation.ctrl.php

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
$pass = $_POST['pass'];
1919
$path = $_POST['path'];
2020

21+
$finstall = $_POST['finstall'];
2122

2223
$ercon = (int)$_POST['ercon'];
2324
$essh = (int)$_POST['essh'];
@@ -39,34 +40,38 @@
3940

4041
echo "Starting configuration, please wait...<br>";
4142

42-
if($ercon)
43-
{
44-
$query = new SampRcon($ips, $port, $rcon);
45-
if(!$query->connect())
46-
die(No("Connection error. Retry.",1));
47-
48-
if(count($query->getCommandList()) <= 1) // if invalid, returns one element with error message
49-
exit(No("RCON password - The RCON is invalid, please insert a valid RCON to continue. Make sure there's no <code>rcon 0</code> in your <code>server.cfg</code>. Otherwise, change it to <code>rcon 1</code> to enable remote rcon commands."));
50-
else
51-
Ok("RCON password - Accepted.<br>");
52-
}
53-
54-
if($essh)
43+
if($finstall)
44+
No("[FORCE INSTALLATION] RCON and SSH controls have been skipped!<br>");
45+
else
5546
{
56-
$ssh = new Net_SSH2($ips);
57-
if (!$ssh->login($user, $pass))
58-
exit(No('SSH access - Login incorrect. Please, retry.'));
59-
else
60-
{
61-
if(trim($ssh->exec('find '.$path.'samp03svr')) != $path."samp03svr")
62-
exit(No("SSH access - Login correct, but <u>invalid server path</u>. The path should contains the <code>samp03svr</code> execution file as well as the basic SA-MP files and folders."));
63-
else
64-
Ok('SSH access - Done. <br>');
65-
}
47+
if($ercon)
48+
{
49+
$query = new SampRcon($ips, $port, $rcon);
50+
if(!$query->connect())
51+
die(No("Connection error. Retry.",1));
52+
53+
if(count($query->getCommandList()) <= 1) // if invalid, returns one element with error message
54+
exit(No("RCON password - The RCON is invalid, please insert a valid RCON to continue. Make sure there's no <code>rcon 0</code> in your <code>server.cfg</code>. Otherwise, change it to <code>rcon 1</code> to enable remote rcon commands."));
55+
else
56+
Ok("RCON password - Accepted.<br>");
57+
}
58+
59+
if($essh)
60+
{
61+
$ssh = new Net_SSH2($ips);
62+
if (!$ssh->login($user, $pass))
63+
exit(No('SSH access - Login incorrect. Please, retry.'));
64+
else
65+
{
66+
if(trim($ssh->exec('find '.$path.'samp03svr')) != $path."samp03svr")
67+
exit(No("SSH access - Login correct, but <u>invalid server path</u>. The path should contains the <code>samp03svr</code> execution file as well as the basic SA-MP files and folders."));
68+
else
69+
Ok('SSH access - Done. <br>');
70+
}
71+
}
6672
}
6773

6874

69-
7075
$rcon = str_replace('"', '\"', $rcon);
7176
$pass = str_replace('"', '\"', $pass);
7277

@@ -150,7 +155,7 @@
150155
$lock = fopen("installed.lock", "x");
151156
if($lock) Ok("Configuration completed! Wait..");
152157
else die($errorPermissions);
153-
sleep(1);
158+
sleep(3);
154159
location("install.php");
155160
}
156161
else

views/installation.view.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<form action='?a=do-magic-things' method='post' class="form-control">
2020

21-
<h3 class="pt-4 pb-2"><i class="fa fa-thumbtack"></i> Main configuration <span class="badge badge-danger small">REQUIRED</span></h3>
21+
<h3 class="pt-4 pb-2"><i class="fa fa-thumbtack"></i> Main configuration <span class="badge badge-success small">REQUIRED</span></h3>
2222
<input type='password' class='form-control' required placeholder='Choose a password' name='srcp'>
2323
<p class="text-muted small mt-2 mb-4">Choose a Password to access the SRC. <b><code>Letters, numbers, dashes and underscores only; [4-32] characters length.</code></b></p>
2424
<input type='text' value="<?=$ips;?>" class='form-control' required placeholder='Server IP Address (without port)' name='ips'>
@@ -41,6 +41,9 @@
4141
<input type='password' class='form-control' placeholder='SSH Password' name='pass' id="sshPass" disabled /><br>
4242
<input type='text' class='form-control' value="<?=$path;?>" placeholder='SSH Path/to/sa-mp/server' name='path' id="sshPath" disabled />
4343
<p class="text-muted small my-2"><b>Warning</b>, the folder MUST end with <code>/</code>. For example: <code>samp03/</code></p>
44+
<hr>
45+
<input type='checkbox' name='finstall' class="custom-checkbox" id="forceInstall" value="1"> Force installation <span class="badge badge-danger">Not Recommended</span>
46+
<p class="text-muted small my-2">Use this option to bypass SSH and RCON controls. If credentials are wrong, some features won't work. </p>
4447
<br>
4548
<button class='btn btn-primary' type='submit'>Submit the form <span class="fa fa-sign-in-alt"></span></button>
4649
</form>

0 commit comments

Comments
 (0)