- function db_query($link, $query, $type, $die_on_error = true) {
- if ($type == "pgsql") {
- $result = pg_query($link, $query);
- if (!$result) {
- $query = htmlspecialchars($query); // just in case
- if ($die_on_error) {
- die("Query <i>$query</i> failed [$result]: " . ($link ? pg_last_error($link) : "No connection"));
- }
- }
- return $result;
- } else if ($type == "mysql") {
-
- if (function_exists("mysqli_connect")) {
- $result = mysqli_query($link, $query);
- } else {
- $result = mysql_query($query, $link);
- }
- if (!$result) {
- $query = htmlspecialchars($query);
- if ($die_on_error) {
- die("Query <i>$query</i> failed: " . ($link ? function_exists("mysqli_connect") ? mysqli_error($link) : mysql_error($link) : "No connection"));
- }
- }
- return $result;
- }
+ function is_server_https() {
+ return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https');