Better test by starts with

This commit is contained in:
Jeroen De Meerleer 2019-04-25 17:40:32 +02:00
parent e5f829e1f8
commit 71d94ccf42
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
4 changed files with 4 additions and 4 deletions

View File

@ -47,7 +47,7 @@ $(document).ready(function() {
});
});
$("body").on("focusout", "input[name=url]", function() {
if($("input[name=url]").val().indexOf("reboot") !== -1) {
if($("input[name=url]").val().startsWith("reboot") !== -1) {
$("label[for=expected]").html("Capture services after reboot? (1: yes; 0: no)");
$("input[name=expected]").attr("placeholder", "1");
}

View File

@ -49,7 +49,7 @@ if (filter_var($jobnameResult[0]["url"], FILTER_VALIDATE_URL)) {
$timestamp = time();
} else {
if(!stristr($jobnameResult[0]["url"],"reboot")) {
if(strpos($jobnameResult[0]["url"],"reboot") !== 0) {
$body = '';
$statuscode = 0;
$url = "ssh " . $jobnameResult[0]['host'] . " '" . $jobnameResult[0]['url'] . "' 2>&1";

View File

@ -34,7 +34,7 @@ if ($jobnameResult[0]["user"] != $_SESSION["userID"]) {
exit;
}
$jobName = $jobnameResult[0]['name'];
$rebootjob = stristr($jobnameResult[0]["url"],"reboot") ? true : false;
$rebootjob = strpos($jobnameResult[0]["url"],"reboot") === 0 ? true : false;
$runsForJobQry = "SELECT runs.*, jobs.jobID FROM runs, jobs WHERE runs.job = jobs.jobID AND runs.job = ?";
$allruns = true;

View File

@ -81,7 +81,7 @@ foreach ($results as $result) {
$body = $res->getBody();
} else {
if(!stristr($result["url"],"reboot")) {
if(strpos($result["url"],"reboot") !== 0) {
$body = '';
$statuscode = 0;
$url = "ssh " . $result['host'] . " '" . $result['url'] . "' 2>&1";