From 88a7cf6a3e7ca4be026e68947c9dea0fd8e3569d Mon Sep 17 00:00:00 2001 From: Robbt Date: Fri, 3 Jan 2020 13:20:40 -0500 Subject: [PATCH] fix database statements --- airtime_mvc/public/setup/database-setup.php | 86 ++++++++++++++++++--- 1 file changed, 75 insertions(+), 11 deletions(-) diff --git a/airtime_mvc/public/setup/database-setup.php b/airtime_mvc/public/setup/database-setup.php index bbbecd9fc..4ff510713 100644 --- a/airtime_mvc/public/setup/database-setup.php +++ b/airtime_mvc/public/setup/database-setup.php @@ -184,17 +184,81 @@ class DatabaseSetup extends Setup { if (!file_exists(LIBRETIME_CONF_DIR . '/icecast_pass')) { throw new AirtimeDatabaseException("The Icecast Password file was not accessible", array()); }; - $icecastPass = file_get_contents(LIBRETIME_CONF_DIR . '/icecast_pass', true); - error_log($icecastPass); - $statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's1_pass' AND SET value = :icecastpass WHERE keyname = 's1_admin_pass'; " - . "UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's2_pass'; " - . "UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's2_admin_pass'; " - . "UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's3_pass'; " - . "UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's3_admin_pass'; " - . "INSERT INTO cc_pref (keystr, valstr) VALUES ('default_icecast_password', :icecastpass )"); - if (!$statement->execute(array(":icecastpass" => $icecastPass))) { - throw new AirtimeDatabaseException("Could not update the database with icecast password!", array()); - } + $icecast_pass = file_get_contents(LIBRETIME_CONF_DIR . '/icecast_pass', true); + error_log($icecast_pass); + $statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's1_pass'"); + $statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR); + try { + $statement->execute(); + } + catch (PDOException $ex) { + print "Error!: " . $ex->getMessage() . "
"; + die(); + } + $statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's1_admin_pass'"); + $statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR); + try { + $statement->execute(); + } + catch (PDOException $ex) { + print "Error!: " . $ex->getMessage() . "
"; + die(); + } + $statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's2_pass'"); + $statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR); + try { + $statement->execute(); + } + catch (PDOException $ex) { + print "Error!: " . $ex->getMessage() . "
"; + die(); + } + $statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's2_admin_pass'"); + $statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR); + try { + $statement->execute(); + } + catch (PDOException $ex) { + print "Error!: " . $ex->getMessage() . "
"; + die(); + } + + $statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's3_pass'"); + $statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR); + try { + $statement->execute(); + } + catch (PDOException $ex) { + print "Error!: " . $ex->getMessage() . "
"; + die(); + } + $statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's3_admin_pass'"); + $statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR); + try { + $statement->execute(); + } + catch (PDOException $ex) { + print "Error!: " . $ex->getMessage() . "
"; + die(); + } + $statement = self::$dbh->prepare("UPDATE cc_stream_setting SET value = :icecastpass WHERE keyname = 's1_admin_pass'"); + $statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR); + try { + $statement->execute(); + } + catch (PDOException $ex) { + print "Error!: " . $ex->getMessage() . "
"; + die(); + } + $statement = self::$dbh->prepare("INSERT INTO cc_pref (keystr, valstr) VALUES ('default_icecast_password', :icecastpass )"); + $statement->bindValue(':icecastpass', $icecast_pass, PDO::PARAM_STR); + try { + $statement->execute(); + } + catch (PDOException $ex) { + print "Error!: " . $ex->getMessage() . "
"; + die(); + } } }