aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'status.php')
-rw-r--r--status.php40
1 files changed, 24 insertions, 16 deletions
diff --git a/status.php b/status.php
index 48f4dff..66d55f8 100644
--- a/status.php
+++ b/status.php
@@ -8,17 +8,21 @@
if (!isset($argv[1])) {
die("No handle hash given\n");
}
- $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
- if (!$db) {
- die("Could not connect to database ".mysql_error()."\n");
+
+ $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
+ MYSQL_PASSWORD, MYSQL_DATABASE);
+ if (mysqli_connect_errno()) {
+ die("Could not connect to database ".mysqli_connect_error());
}
- mysql_select_db(MYSQL_DATABASE);
- $query = "SELECT handle FROM builds ".
- "WHERE id = '".mysql_real_escape_string($argv[1])."'";
- $result = mysql_query($query);
- if (mysql_num_rows($result) == 1) {
- $handles = mysql_fetch_array($result);
- $handle = $handles[0];
+
+ $query = "SELECT handle FROM builds WHERE id = ?";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("s", $argv[1]);
+ $stmt->execute();
+ $stmt->store_result();
+ if ($stmt->num_rows == 1) {
+ $stmt->bind_result($handle);
+ $stmt->close();
$client = new GearmanClient();
$client->addServer();
@@ -33,11 +37,14 @@
}
} else {
$query = "SELECT returncode, result FROM builds ".
- "WHERE id = '".mysql_real_escape_string($argv[1])."'";
- $result = mysql_query($query);
- $jobres = mysql_fetch_array($result);
- if ($jobres[0] !== null) {
- echo "Job returned with code ".$jobres[0].": ".$jobres[1]."\n";
+ "WHERE id = ?";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("s", $argv[1]);
+ $stmt->execute();
+ $stmt->bind_result($returncode, $result);
+ $stmt->fetch();
+ if ($returncode !== null) {
+ echo "Job returned with code ".$returncode.": ".$result."\n";
} else {
echo "Job failed\n";
}
@@ -45,4 +52,5 @@
} else {
echo "Invalid handle hash\n";
}
-
+
+ $db->close(); \ No newline at end of file