From 4617cb46a80618409ff34aa4f52be3eade787408 Mon Sep 17 00:00:00 2001 From: botanicvelious Date: Sun, 7 Dec 2014 06:42:57 -0800 Subject: [PATCH] add some additional checking for database errors --- code/web/private_php/ams/autoload/ticket_user.php | 14 ++++++++++++-- code/web/public_php/setup/install.php | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/code/web/private_php/ams/autoload/ticket_user.php b/code/web/private_php/ams/autoload/ticket_user.php index 6de69ccdd..a52ffaec8 100644 --- a/code/web/private_php/ams/autoload/ticket_user.php +++ b/code/web/private_php/ams/autoload/ticket_user.php @@ -20,8 +20,18 @@ class Ticket_User{ * @param $permission the permission that will be given to the user. 1=user, 2=mod, 3=admin */ public static function createTicketUser( $extern_id, $permission) { - $dbl = new DBLayer("lib"); - $dbl->insert("ticket_user",array('TUserId' => $extern_id, 'Permission' => $permission, 'ExternId' => $extern_id)); + try { + //make connection with and put into db + $dbl = new DBLayer("lib"); + $dbl->insert("ticket_user",array('TUserId' => $extern_id, 'Permission' => $permission, 'ExternId' => $extern_id)); + } + catch (PDOException $e) { + //oh noooz... + //error_log(print_r($e, true)); + //print_r($e); + echo "Problem creating user in database!"; + } + } diff --git a/code/web/public_php/setup/install.php b/code/web/public_php/setup/install.php index 49fc0b3a7..438a5c332 100644 --- a/code/web/public_php/setup/install.php +++ b/code/web/public_php/setup/install.php @@ -42,6 +42,20 @@ require_once('setup/version.php'); $continue = false; } } + + if ($continue) { + try { + if (!in_array("mysql",PDO::getAvailableDrivers(),TRUE)) + { + throw new PDOException ("Cannot work without a proper database setting up"); + } + } + catch (PDOException $pdoEx) + { + printalert("danger", "PHP PDO seems to be missing the mysql driver"); + $continue = false; + } + } // Validate basics if ($continue) {