From d26ff7eb7927aae8a8ffe82a2e768a96077daeb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Tantau?= Date: Thu, 6 Oct 2016 14:41:23 +0200 Subject: [PATCH 1/3] Add config to gitignore so that passwords are not saved in git. --- .gitignore | 2 ++ odm/include/{config.php => config.php.example} | 0 2 files changed, 2 insertions(+) create mode 100644 .gitignore rename odm/include/{config.php => config.php.example} (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a69e276 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +odm/include/config.php + diff --git a/odm/include/config.php b/odm/include/config.php.example similarity index 100% rename from odm/include/config.php rename to odm/include/config.php.example From 11b52ecfd4a5f57b2dbc81ec22d718cf3724f320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Tantau?= Date: Thu, 6 Oct 2016 14:46:32 +0200 Subject: [PATCH 2/3] Don't set max_allowed_packets, as it is only allowed for root. --- odm/include/db.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/odm/include/db.php b/odm/include/db.php index 222fa9d..50bcdde 100644 --- a/odm/include/db.php +++ b/odm/include/db.php @@ -51,8 +51,6 @@ function storeMessage($message, $gcm_regid, $data) { function storeFile($id, $handle) { global $con; - $stmt = $con->prepare("SET GLOBAL max_allowed_packet = 524288000"); // 500MB - $stmt->execute(); $stmt = $con->prepare("INSERT INTO gcm_data(id, data) VALUES(?, ?)"); $stmt->bindParam(1, $id); $stmt->bindParam(2, $handle, PDO::PARAM_LOB); @@ -61,8 +59,6 @@ function storeFile($id, $handle) { function storeData($id, $data) { global $con; - $stmt = $con->prepare("SET GLOBAL max_allowed_packet = 524288000"); // 500MB - $stmt->execute(); $stmt = $con->prepare("INSERT INTO gcm_data(id, data) VALUES(?, ?)"); $stmt->execute(array($id, $data)); } From ab9330d96ba39e9eaf1ddca9d63b4e3a7efc3db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Tantau?= Date: Thu, 6 Oct 2016 15:35:39 +0200 Subject: [PATCH 3/3] Make PDO::MYSQL_ATTR_MAX_BUFFER_SIZE optional as it is not available for some versions of PHP. --- odm/include/db.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/odm/include/db.php b/odm/include/db.php index 50bcdde..2265048 100644 --- a/odm/include/db.php +++ b/odm/include/db.php @@ -4,7 +4,11 @@ function dbconnect() { global $DB_HOST, $DB_USER, $DB_PASSWORD, $DB_DATABASE, $con; - $con = new PDO('mysql:dbname='.$DB_DATABASE.';host='.$DB_HOST.';charset=utf8', $DB_USER, $DB_PASSWORD, array(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE=>1024*1024*50)); + if (defined('PDO::MYSQL_ATTR_MAX_BUFFER_SIZE')) { + $con = new PDO('mysql:dbname='.$DB_DATABASE.';host='.$DB_HOST.';charset=utf8', $DB_USER, $DB_PASSWORD, array(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE=>1024*1024*50)); + } else { + $con = new PDO('mysql:dbname='.$DB_DATABASE.';host='.$DB_HOST.';charset=utf8', $DB_USER, $DB_PASSWORD); + } $con->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }