diff --git a/add-alias.php b/add-alias.php index 49c73da..d9404d5 100644 --- a/add-alias.php +++ b/add-alias.php @@ -58,7 +58,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($domain_exist && empty($message)) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,?,?,NOW(),NOW())"); $sth->bindParam(1, $from, PDO::PARAM_STR); $sth->bindParam(2, $goto, PDO::PARAM_STR); diff --git a/add-mailbox.php b/add-mailbox.php index 7c33a7c..1172294 100644 --- a/add-mailbox.php +++ b/add-mailbox.php @@ -64,7 +64,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $maildir = $from . "/"; try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,'vmail',?,NOW(),NOW())"); $sth->bindParam(1, $from, PDO::PARAM_STR); $sth->bindParam(2, $domain, PDO::PARAM_STR); @@ -75,7 +75,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { } try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("INSERT INTO mailbox (username,password,name,maildir,domain,created,modified) VALUES (?,?,?,?,?,NOW(),NOW())"); $sth->bindParam(1, $from, PDO::PARAM_STR); $sth->bindParam(2, $hashed, PDO::PARAM_STR); diff --git a/admin/add-alias.php b/admin/add-alias.php index 42233f0..5ee4352 100644 --- a/admin/add-alias.php +++ b/admin/add-alias.php @@ -57,7 +57,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($domain_exist && empty($message)) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,?,?,NOW(),NOW())"); $sth->bindParam(1, $from, PDO::PARAM_STR); $sth->bindParam(2, $goto, PDO::PARAM_STR); diff --git a/admin/add-mailbox.php b/admin/add-mailbox.php index 88ab3d2..bb61226 100644 --- a/admin/add-mailbox.php +++ b/admin/add-mailbox.php @@ -63,7 +63,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $maildir = $from . "/"; try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("INSERT INTO alias (address,goto,domain,created,modified) VALUES (?,'vmail',?,NOW(),NOW())"); $sth->bindParam(1, $from, PDO::PARAM_STR); $sth->bindParam(2, $domain, PDO::PARAM_STR); @@ -74,7 +74,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { } try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("INSERT INTO mailbox (username,password,name,maildir,domain,created,modified) VALUES (?,?,?,?,?,NOW(),NOW())"); $sth->bindParam(1, $from, PDO::PARAM_STR); $sth->bindParam(2, $hashed, PDO::PARAM_STR); diff --git a/admin/admin.php b/admin/admin.php index 7d8b93e..f776b90 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -62,7 +62,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (empty($message)) { $hashed = bcrypt($password1); try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("INSERT INTO admin (username,password,created,modified) VALUES (?,?,NOW(),NOW())"); $sth->bindParam(1, $username, PDO::PARAM_STR); $sth->bindParam(2, $hashed, PDO::PARAM_STR); @@ -87,7 +87,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (empty($message) && !empty($password1)) { $hashed = bcrypt($password1); try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("UPDATE admin SET password=?,modified=NOW() WHERE username=?"); $sth->bindParam(1, $hashed, PDO::PARAM_STR); $sth->bindParam(2, $username, PDO::PARAM_STR); @@ -102,7 +102,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { } if (empty($message)) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT COUNT(*) FROM domain_admins WHERE username=?"); $sth->execute(array($username)); $count_domain_admins = $sth->fetchColumn(); diff --git a/admin/backup.php b/admin/backup.php index aafc11f..c55757f 100644 --- a/admin/backup.php +++ b/admin/backup.php @@ -36,7 +36,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { include '../templates/footer.tpl'; } else { fwrite($fh, $header); - $dbh = connect_db(); + $dbh = pdo_connect(); foreach ($tables as $table) { $sth = $dbh->query("SHOW CREATE TABLE $table"); $row = $sth->fetch(PDO::FETCH_ASSOC); diff --git a/admin/delete.php b/admin/delete.php index 72e6b67..7a1cec7 100644 --- a/admin/delete.php +++ b/admin/delete.php @@ -35,7 +35,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { if ($domain_exist && $table == "domain") { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $dbh->beginTransaction(); $sth = $dbh->prepare("SELECT COUNT(*) FROM log WHERE domain=?"); @@ -110,7 +110,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { if ($table == "admin") { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $dbh->beginTransaction(); $sth = $dbh->prepare("SELECT COUNT(*) FROM admin WHERE username=?"); @@ -146,7 +146,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { if ($domain_exist && ($table == 'alias' || $table == 'mailbox')) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("DELETE FROM alias WHERE address=? AND domain=?"); $sth->bindParam(1, $delete, PDO::PARAM_STR); $sth->bindParam(2, $domain, PDO::PARAM_STR); @@ -164,7 +164,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { } try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("DELETE FROM mailbox WHERE username=? AND domain=?"); $sth->bindParam(1, $delete, PDO::PARAM_STR); $sth->bindParam(2, $domain, PDO::PARAM_STR); diff --git a/admin/domain.php b/admin/domain.php index 74f9fca..6ad2f57 100644 --- a/admin/domain.php +++ b/admin/domain.php @@ -50,7 +50,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (!in_array($domain, array_column($list_domains, 'domain'))) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("INSERT INTO domain (domain,description,aliases,mailboxes,created,modified) VALUES (?,?,?,?,NOW(),NOW())"); $sth->bindParam(1, $domain, PDO::PARAM_STR); $sth->bindParam(2, $description, PDO::PARAM_STR); @@ -67,7 +67,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (in_array($domain, array_column($list_domains, 'domain')) && $action == 'edit') { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("UPDATE domain SET description=?,aliases=?,mailboxes=?,modified=NOW() WHERE domain=?"); $sth->bindParam(1, $description, PDO::PARAM_STR); $sth->bindParam(2, $aliases, PDO::PARAM_INT); diff --git a/admin/edit-alias.php b/admin/edit-alias.php index 12fa2a7..102e770 100644 --- a/admin/edit-alias.php +++ b/admin/edit-alias.php @@ -34,7 +34,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { if ($domain_exist) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT goto FROM alias WHERE address=? AND domain=?"); $sth->bindParam(1, $address, PDO::PARAM_STR); $sth->bindParam(2, $domain, PDO::PARAM_STR); @@ -73,7 +73,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($domain_exist && empty($message)) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("UPDATE alias SET goto=?,modified=NOW() WHERE address=? AND domain=?"); $sth->bindParam(1, $goto, PDO::PARAM_STR); $sth->bindParam(2, $address, PDO::PARAM_STR); diff --git a/admin/edit-mailbox.php b/admin/edit-mailbox.php index 2ff5684..f5f32a7 100644 --- a/admin/edit-mailbox.php +++ b/admin/edit-mailbox.php @@ -36,7 +36,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { if ($domain_exist) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT * FROM mailbox WHERE username=? AND domain=?"); $sth->bindParam(1, $username, PDO::PARAM_STR); $sth->bindParam(2, $domain, PDO::PARAM_STR); @@ -65,7 +65,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (empty($message) && isset($domain_key) && !empty($password1)) { $hashed = bcrypt($password1); try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("UPDATE mailbox SET password=?,name=?,modified=NOW() WHERE username=? AND domain=?"); $sth->bindParam(1, $hashed, PDO::PARAM_STR); $sth->bindParam(2, $name, PDO::PARAM_STR); @@ -79,7 +79,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($domain_exist && empty($message)) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("UPDATE mailbox SET name=?,modified=NOW() WHERE username=? AND domain=?"); $sth->bindParam(1, $name, PDO::PARAM_STR); $sth->bindParam(2, $username, PDO::PARAM_STR); diff --git a/admin/search.php b/admin/search.php index f9b1fca..3bdc5f9 100644 --- a/admin/search.php +++ b/admin/search.php @@ -26,7 +26,7 @@ $list_domains = list_domains(); $search = filter_input(INPUT_POST, 'search', FILTER_DEFAULT); if (isset($search)) { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.address LIKE ? AND mailbox.maildir IS NULL ORDER BY alias.address"); $sth->bindValue(1, '%'.$search.'%', PDO::PARAM_STR); $sth->execute(); diff --git a/admin/viewlog.php b/admin/viewlog.php index 574bd08..8ff88fe 100644 --- a/admin/viewlog.php +++ b/admin/viewlog.php @@ -28,7 +28,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { $domain_exist = in_array($domain, array_column($list_domains, 'domain')); if ($domain_exist) { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT * FROM log WHERE domain=? ORDER BY timestamp DESC LIMIT 10"); $sth->bindParam(1, $domain, PDO::PARAM_STR); $sth->execute(); diff --git a/delete.php b/delete.php index 8d76d06..c64a5e2 100644 --- a/delete.php +++ b/delete.php @@ -36,7 +36,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { if ($domain_exist && ($table == 'alias' || $table == 'mailbox')) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("DELETE FROM alias WHERE address=? AND domain=?"); $sth->bindParam(1, $delete, PDO::PARAM_STR); $sth->bindParam(2, $domain, PDO::PARAM_STR); @@ -54,7 +54,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { } try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("DELETE FROM mailbox WHERE username=? AND domain=?"); $sth->bindParam(1, $delete, PDO::PARAM_STR); $sth->bindParam(2, $domain, PDO::PARAM_STR); diff --git a/edit-alias.php b/edit-alias.php index bb51f29..41a5571 100644 --- a/edit-alias.php +++ b/edit-alias.php @@ -35,7 +35,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { if ($domain_exist) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT goto FROM alias WHERE address=? AND domain=?"); $sth->bindParam(1, $address, PDO::PARAM_STR); $sth->bindParam(2, $domain, PDO::PARAM_STR); @@ -74,7 +74,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($domain_exist && empty($message)) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("UPDATE alias SET goto=?,modified=NOW() WHERE address=? AND domain=?"); $sth->bindParam(1, $goto, PDO::PARAM_STR); $sth->bindParam(2, $address, PDO::PARAM_STR); diff --git a/edit-mailbox.php b/edit-mailbox.php index 289b08c..0235062 100644 --- a/edit-mailbox.php +++ b/edit-mailbox.php @@ -37,7 +37,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { if ($domain_exist) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT * FROM mailbox WHERE username=? AND domain=?"); $sth->bindParam(1, $username, PDO::PARAM_STR); $sth->bindParam(2, $domain, PDO::PARAM_STR); @@ -66,7 +66,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (empty($message) && isset($domain_key) && !empty($password1)) { $hashed = bcrypt($password1); try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("UPDATE mailbox SET password=?,name=?,modified=NOW() WHERE username=? AND domain=?"); $sth->bindParam(1, $hashed, PDO::PARAM_STR); $sth->bindParam(2, $name, PDO::PARAM_STR); @@ -80,7 +80,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($domain_exist && empty($message)) { try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("UPDATE mailbox SET name=?,modified=NOW() WHERE username=? AND domain=?"); $sth->bindParam(1, $name, PDO::PARAM_STR); $sth->bindParam(2, $username, PDO::PARAM_STR); diff --git a/functions.inc.php b/functions.inc.php index df06e5a..bdbefe4 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -55,11 +55,23 @@ function check_language() { } // -// connect_db -// Action: make db connection -// Call: connect_db() +// bcrypt +// Action: Hashs the password with bcrypt +// Call: bcrypt(string cleartextpassword) // -function connect_db() { +function bcrypt($password) { + $options = ['cost' => 8]; + $hashed = password_hash($password, PASSWORD_BCRYPT, $options); + $hashed = preg_replace('/\$2y\$/', '\$2b\$', $hashed); + return $hashed; +} + +// +// pdo_connect +// Action: make db connection +// Call: pdo_connect() +// +function pdo_connect() { try { $dbh = new PDO(DB_TYPE . ':host='. DB_HOST . ';dbname='. DB_NAME , DB_USER, DB_PASS, array(PDO::ATTR_PERSISTENT => true)); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -76,7 +88,7 @@ function connect_db() { // Call: list_domains(string admin (optional)) // function list_domains($username = null) { - $dbh = connect_db(); + $dbh = pdo_connect(); if (isset($username)) { $sth = $dbh->prepare("SELECT * FROM domain INNER JOIN domain_admins ON domain.domain=domain_admins.domain WHERE domain_admins.username=? ORDER BY domain_admins.domain"); $sth->bindParam(1, $username, PDO::PARAM_STR); @@ -106,7 +118,7 @@ function list_domains($username = null) { // Call: list_aliases(string domain, int offset) // function list_aliases($domain, $offset, $limit) { - $dbh = connect_db(); + $dbh = pdo_connect(); if (ALIAS_CONTROL == 'NO') { $sth = $dbh->prepare("SELECT alias.address,alias.goto,alias.modified FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.domain=? AND mailbox.maildir IS NULL ORDER BY alias.address LIMIT ?, ?"); } else { @@ -126,7 +138,7 @@ function list_aliases($domain, $offset, $limit) { // Call: list_mailboxes(string domaini, int offset) // function list_mailboxes($domain, $offset, $limit) { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT * FROM mailbox WHERE domain=? ORDER BY username LIMIT ?, ?"); $sth->bindParam(1, $domain, PDO::PARAM_STR); $sth->bindParam(2, $offset, PDO::PARAM_INT); @@ -156,18 +168,6 @@ function list_admins() { return $list; } -// -// bcrypt -// Action: Hashs the password with bcrypt -// Call: bcrypt(string cleartextpassword) -// -function bcrypt($password) { - $options = ['cost' => 8]; - $hashed = password_hash($password, PASSWORD_BCRYPT, $options); - $hashed = preg_replace('/\$2y\$/', '\$2b\$', $hashed); - return $hashed; -} - // logging // Action: Logs actions from admin // Call: logging(string username, string domain, string action, string data) @@ -176,7 +176,7 @@ function logging($username, $domain, $action, $data) { $remote_addr = $_SERVER['HTTP_X_CLIENTIP'] ?? $_SERVER['REMOTE_ADDR']; $username = $username . ' (' . $remote_addr . ')'; if (LOGGING == 'YES') { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("INSERT INTO log (timestamp,username,domain,action,data) VALUES (NOW(),?,?,?,?)"); $sth->bindParam(1, $username, PDO::PARAM_STR); $sth->bindParam(2, $domain, PDO::PARAM_STR); diff --git a/login.php b/login.php index 8a716cb..2521d02 100644 --- a/login.php +++ b/login.php @@ -27,7 +27,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $password = filter_input(INPUT_POST, 'password', FILTER_DEFAULT); if (!empty($username) && !empty($password)) { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT password FROM admin WHERE username=?"); $sth->bindParam(1, $username, PDO::PARAM_STR); $sth->execute(); diff --git a/password.php b/password.php index fff4275..3cc408f 100644 --- a/password.php +++ b/password.php @@ -35,7 +35,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { } if (empty($message) && !empty($password_current)) { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT password FROM admin WHERE username=?"); $sth->bindParam(1, $username, PDO::PARAM_STR); $sth->execute(); @@ -48,7 +48,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (empty($message) && !empty($password1)) { $hashed = bcrypt($password1); try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("UPDATE admin SET password=?,modified=NOW() WHERE username=?"); $sth->bindParam(1, $hashed, PDO::PARAM_STR); $sth->bindParam(2, $username, PDO::PARAM_STR); diff --git a/search.php b/search.php index 1e2032d..3aab1b6 100644 --- a/search.php +++ b/search.php @@ -27,7 +27,7 @@ $list_domains = list_domains($SESSID_USERNAME); $search = filter_input(INPUT_POST, 'search', FILTER_DEFAULT); if (isset($search)) { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT alias.address,alias.goto,alias.modified,alias.domain FROM alias LEFT JOIN mailbox ON alias.address=mailbox.username WHERE alias.address LIKE ? AND mailbox.maildir IS NULL ORDER BY alias.address"); $sth->bindValue(1, '%'.$search.'%', PDO::PARAM_STR); $sth->execute(); diff --git a/templates/search.tpl b/templates/search.tpl index ede9048..5ceca7e 100644 --- a/templates/search.tpl +++ b/templates/search.tpl @@ -45,6 +45,7 @@ if (count($list_mailbox) > 0) { echo " \n"; echo " " . $row['username'] . "\n"; echo " " . $row['name'] . "\n"; + echo " " . $row['modified'] . "\n"; echo " " . $LANG['edit'] . "\n"; echo " " . $LANG['del'] . "\n"; echo " \n"; diff --git a/users/login.php b/users/login.php index b63e049..f1fe900 100644 --- a/users/login.php +++ b/users/login.php @@ -27,7 +27,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $password = filter_input(INPUT_POST, 'password', FILTER_DEFAULT); if (!empty($username) && !empty($password)) { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT password FROM mailbox WHERE username=?"); $sth->bindParam(1, $username, PDO::PARAM_STR); $sth->execute(); diff --git a/users/password.php b/users/password.php index 044ff3d..9ddb89b 100644 --- a/users/password.php +++ b/users/password.php @@ -36,7 +36,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { } if (empty($message) && !empty($password_current)) { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT password FROM mailbox WHERE username=?"); $sth->bindParam(1, $username, PDO::PARAM_STR); $sth->execute(); @@ -49,7 +49,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (empty($message) && !empty($password1)) { $hashed = bcrypt($password1); try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("UPDATE mailbox SET password=?,modified=NOW() WHERE username=?"); $sth->bindParam(1, $hashed, PDO::PARAM_STR); $sth->bindParam(2, $username, PDO::PARAM_STR); diff --git a/users/vacation.php b/users/vacation.php index bece113..b7bca0b 100644 --- a/users/vacation.php +++ b/users/vacation.php @@ -27,7 +27,7 @@ $SESSID_USERNAME = check_session('userid'); $USERID_DOMAIN = substr(strrchr($SESSID_USERNAME, "@"), 1); if ($_SERVER['REQUEST_METHOD'] == "GET") { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT COUNT(*) FROM vacation WHERE email=?"); $sth->execute(array($SESSID_USERNAME)); @@ -45,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (!empty($_POST['back'])) { $action = 'back'; - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("DELETE FROM vacation WHERE email=?"); $sth->bindParam(1, $SESSID_USERNAME, PDO::PARAM_STR); $sth->execute(); @@ -60,7 +60,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { if (!empty($_POST['away'])) { $action = 'away'; try { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("INSERT INTO vacation (email,subject,body,cache,domain,created) VALUES (?,?,?,'',?,NOW())"); $sth->bindParam(1, $SESSID_USERNAME, PDO::PARAM_STR); $sth->bindParam(2, $subject, PDO::PARAM_STR); diff --git a/viewlog.php b/viewlog.php index fdae458..48c1249 100644 --- a/viewlog.php +++ b/viewlog.php @@ -29,7 +29,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { $domain_exist = in_array($domain, array_column($list_domains, 'domain')); if ($domain_exist) { - $dbh = connect_db(); + $dbh = pdo_connect(); $sth = $dbh->prepare("SELECT * FROM log WHERE domain=? ORDER BY timestamp DESC LIMIT 10"); $sth->bindParam(1, $domain, PDO::PARAM_STR); $sth->execute();