summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-11-02 16:41:36 (GMT)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-11-02 16:43:25 (GMT)
commit5e08b8f88850f6ca56b57da923c434b7f264e33f (patch)
tree77ce0be7e98cebfb159a1398ab7b908d82883cfe
parent2f8034bf4cb919391de7e277c89540113ed3ec69 (diff)
downloadbuildroot-test-5e08b8f88850f6ca56b57da923c434b7f264e33f.tar.gz
buildroot-test-5e08b8f88850f6ca56b57da923c434b7f264e33f.tar.bz2
utils,web: migrate to PHP 7
Main changes are: - Use mysqli API instead of mysql API - Use preg_match() instead of ereg() Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-rwxr-xr-xutils/remove.php8
-rw-r--r--web/db.inc.php20
-rw-r--r--web/funcs.inc.php2
-rw-r--r--web/graph.php2
-rw-r--r--web/import.inc.php2
-rw-r--r--web/index.php18
-rw-r--r--web/rss.php6
-rw-r--r--web/stats.php4
8 files changed, 29 insertions, 33 deletions
diff --git a/utils/remove.php b/utils/remove.php
index 07a7fd3..289a617 100755
--- a/utils/remove.php
+++ b/utils/remove.php
@@ -1,4 +1,4 @@
-#!/usr/bin/env php5
+#!/usr/bin/env php
<?php
/*
* Remove one build failure from the database
@@ -23,12 +23,12 @@ if ($ret == FALSE) {
echo "FAILED\n";
exit(1);
}
-if (mysql_num_rows($ret) != 1) {
+if (mysqli_num_rows($ret) != 1) {
echo "NOT FOUND\n";
exit(1);
}
-$c = mysql_fetch_object($ret);
+$c = mysqli_fetch_object($ret);
$id = $c->id;
echo " $id\n";
@@ -42,7 +42,7 @@ if (!is_writable($path)) {
echo "Removing from results_config...";
-$sql = "delete from results_config where resultid=" . $id;
+$sql = "delete from symbol_per_result where result_id=" . $id;
$ret = $db->query($sql);
if ($ret == FALSE) {
echo "FAILED\n";
diff --git a/web/db.inc.php b/web/db.inc.php
index 950c10e..99f83a2 100644
--- a/web/db.inc.php
+++ b/web/db.inc.php
@@ -10,26 +10,22 @@ class db
global $db_pass;
global $db_name;
- if(mysql_connect($db_host,$db_user,$db_pass)==FALSE)
+ $this->conn = mysqli_connect($db_host,$db_user,$db_pass,$db_name);
+ if (!$this->conn)
{
echo "Issue connecting to DB on host $db_host.\n";
return 0;
}
- if(mysql_select_db($db_name) == FALSE)
- {
- echo "Issue connecting to DB $db_name on host $db_host.\n";
- return 0;
- }
-
- mysql_query("set names 'utf8'");
+ $this->conn->query("set names 'utf8'");
}
function query ($query)
{
- if( ($result = mysql_query($query)) == FALSE)
+ $result = $this->conn->query($query);
+ if (!$result)
{
- echo "Syntax problem in '$query' : " . mysql_error() . "\n";
+ echo "Syntax problem in '$query'\n";
return 0;
}
@@ -38,7 +34,7 @@ class db
function insertid ()
{
- return mysql_insert_id ();
+ return $this->conn->insert_id;
}
/**
@@ -54,7 +50,7 @@ class db
$value = stripslashes($value);
if (!is_numeric($value))
- $value = "'" . mysql_real_escape_string($value) . "'";
+ $value = "'" . $this->conn->real_escape_string($value) . "'";
return $value;
}
diff --git a/web/funcs.inc.php b/web/funcs.inc.php
index 04b7e31..6624b0b 100644
--- a/web/funcs.inc.php
+++ b/web/funcs.inc.php
@@ -43,7 +43,7 @@ function bab_total_results_count()
return;
}
- $ret = mysql_fetch_array($ret);
+ $ret = mysqli_fetch_array($ret);
return $ret[0];
}
diff --git a/web/graph.php b/web/graph.php
index d8996d0..eeafa68 100644
--- a/web/graph.php
+++ b/web/graph.php
@@ -24,7 +24,7 @@ $failures_data = array();
$timeouts_data = array();
$total_data = array();
-while($current = mysql_fetch_object($ret)) {
+while($current = mysqli_fetch_object($ret)) {
array_push($dates_data, $current->day);
array_push($success_data, $current->success * 100 / $current->total);
array_push($failures_data, $current->failures * 100 / $current->total);
diff --git a/web/import.inc.php b/web/import.inc.php
index 28d4b0a..8eb3066 100644
--- a/web/import.inc.php
+++ b/web/import.inc.php
@@ -53,7 +53,7 @@ function get_all_symbols_id($db, $opts)
$result = $db->query($sql);
$symbolids = array();
- while($row = mysql_fetch_array($result)) {
+ while($row = mysqli_fetch_array($result)) {
array_push($symbolids, $row["id"]);
}
diff --git a/web/index.php b/web/index.php
index 6750cc9..95563fd 100644
--- a/web/index.php
+++ b/web/index.php
@@ -25,12 +25,12 @@ function format_duration($seconds_count)
/* When no start is given, or start is a crazy value (not an integer),
just default to start=0 */
-if (! isset($_GET['start']) || ! ereg("^[0-9]*$", $_GET['start']))
+if (! isset($_GET['start']) || ! preg_match("/^[0-9]*$/", $_GET['start']))
$start = 0;
else
$start = $_GET['start'];
-if (! isset($_GET['step']) || ! ereg("^[0-9]*$", $_GET['step']))
+if (! isset($_GET['step']) || ! preg_match("/^[0-9]*$/", $_GET['step']))
$step = 50;
else
$step = $_GET['step'];
@@ -48,32 +48,32 @@ if (isset ($_GET['status'])) {
$filter_status = 2;
}
-if (isset($_GET['arch']) && ereg("^[a-z0-9_]*$", $_GET['arch']))
+if (isset($_GET['arch']) && preg_match("/^[a-z0-9_]*$/", $_GET['arch']))
$filter_arch = $_GET['arch'];
else
$filter_arch = "";
-if (isset($_GET['branch']) && ereg("^[a-z0-9_\.]*$", $_GET['branch']))
+if (isset($_GET['branch']) && preg_match("/^[a-z0-9_\.]*$/", $_GET['branch']))
$filter_branch = $_GET['branch'];
else
$filter_branch = "";
-if (isset($_GET['reason']) && ereg("^[A-Za-z0-9_\+\.\-]*$", $_GET['reason']))
+if (isset($_GET['reason']) && preg_match("/^[A-Za-z0-9_\+\.\-]*$/", $_GET['reason']))
$filter_reason = $_GET['reason'];
else
$filter_reason = "";
-if (isset($_GET['libc']) && ereg("^[a-z]*$", $_GET['libc']))
+if (isset($_GET['libc']) && preg_match("/^[a-z]*$/", $_GET['libc']))
$filter_libc = $_GET['libc'];
else
$filter_libc = "";
-if (isset($_GET['static']) && ereg("^[0-1]$", $_GET['static']))
+if (isset($_GET['static']) && preg_match("/^[0-1]$/", $_GET['static']))
$filter_static = $_GET['static'];
else
$filter_static = "";
-if (isset($_GET['subarch']) && ereg("^[A-Za-z0-9_\+\.\-]*$", $_GET['subarch']))
+if (isset($_GET['subarch']) && preg_match("/^[A-Za-z0-9_\+\.\-]*$/", $_GET['subarch']))
$filter_subarch = $_GET['subarch'];
else
$filter_subarch = "";
@@ -93,7 +93,7 @@ echo "</tr>";
$results = bab_get_results($start, $step, $filter_status, $filter_arch, $filter_reason, $filter_submitter, $filter_libc, $filter_static, $filter_subarch, $filter_branch);
-while ($current = mysql_fetch_object($results)) {
+while ($current = mysqli_fetch_object($results)) {
/* Beautify a bit the name of the host that has been used for the build */
$submitter = preg_replace("/(\w+) (\([^)]*\))/", "$1<br/><span style=\"font-size: 80%;\"><i>$2</i></font>", $current->submitter);
diff --git a/web/rss.php b/web/rss.php
index 8b02a07..b2d2ed3 100644
--- a/web/rss.php
+++ b/web/rss.php
@@ -25,16 +25,16 @@ $results = bab_get_results(0, 50);
echo " <items>\n";
echo " <rdf:Seq>\n";
-while ($current = mysql_fetch_object($results))
+while ($current = mysqli_fetch_object($results))
echo "<rdf:li rdf:resource=\"http://autobuild.buildroot.org/results/" .
$current->identifier . "\"/>\n";
echo " </rdf:Seq>\n";
echo " </items>\n";
echo "</channel>\n";
-mysql_data_seek($results, 0);
+mysqli_data_seek($results, 0);
-while ($current = mysql_fetch_object($results)) {
+while ($current = mysqli_fetch_object($results)) {
echo " <item rdf:about=\"http://autobuild.buildroot.org/results/" .
$current->identifier . "\">\n";
diff --git a/web/stats.php b/web/stats.php
index bdb835f..f8ad59d 100644
--- a/web/stats.php
+++ b/web/stats.php
@@ -27,7 +27,7 @@ $successtotal = 0;
$failuretotal = 0;
$timeouttotal = 0;
$total = 0;
-while ($current = mysql_fetch_object($ret)) {
+while ($current = mysqli_fetch_object($ret)) {
$successtotal += $current->success;
$failuretotal += $current->failures;
$timeouttotal += $current->timeouts;
@@ -71,7 +71,7 @@ if ($ret == FALSE) {
exit;
}
-$result = mysql_fetch_object($ret);
+$result = mysqli_fetch_object($ret);
$successrate = sprintf("%2.2f", $result->success / $result->total * 100);
$failurerate = sprintf("%2.2f", $result->failures / $result->total * 100);