Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/mysql.php
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-04-17 09:36:08 +0200
committerErich Eckner <git@eckner.net>2018-04-17 09:36:08 +0200
commit8af016645fee5c0b22e69d46de9b3401c1bc82d3 (patch)
tree992acf6649f005c3d6891d767a5509fdbb91024b /lib/mysql.php
parent951d045cb95cc8e0d07c97104a2b9a5e9ea5ffc8 (diff)
lib/ new
Diffstat (limited to 'lib/mysql.php')
-rw-r--r--lib/mysql.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/mysql.php b/lib/mysql.php
new file mode 100644
index 0000000..a5edbd5
--- /dev/null
+++ b/lib/mysql.php
@@ -0,0 +1,26 @@
+<?php
+
+# do not include twice
+if (isset($mysql))
+ return;
+
+include "lib/http.php";
+
+$mysql = new mysqli("localhost", "webserver", "empty", "buildmaster");
+if ( $mysql -> connect_error ) {
+ die_500( "Connection failed: " . $mysql -> connect_error );
+}
+
+function mysql_run_query($query) {
+ global $mysql;
+ if ( ! $result = $mysql -> query($query) )
+ die_500( "Query failed: " . $mysql -> error );
+ return $result;
+}
+function show_warning_on_offline_slave() {
+ $result = mysql_run_query("SHOW STATUS LIKE \"Slave_running\"");
+ if (($result -> num_rows == 0) ||
+ ($result -> fetch_assoc() ["Value"] != "ON")) {
+ print "<div><font color=\"fff0000\">The replication slave is currently not running. The database might be outdated.</font></div>";
+ }
+}