return;
}
- if (DB_TYPE == "pgsql") {
- pg_query("set client_encoding = 'UTF-8'");
- pg_set_client_encoding("UNICODE");
- } else {
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- db_query($link, "SET NAMES " . MYSQL_CHARSET);
-// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
- }
- }
+ init_connection($link);
$op = $_REQUEST["op"];
official site for more information.");
$ERRORS[11] = "[This error is not returned by server]";
+
+ $ERRORS[12] = __("SQL escaping test failed, check your database and PHP configuration");
?>
}
}
+ if (db_escape_string("testTEST") != "testTEST") {
+ $error_code = 12;
+ }
+
error_reporting (DEFAULT_ERROR_LEVEL);
if ($error_code != 0) {
function feed_has_icon($id) {
return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0;
}
+
+ function init_connection($link) {
+ if (DB_TYPE == "pgsql") {
+ pg_query("set client_encoding = 'UTF-8'");
+ pg_set_client_encoding("UNICODE");
+ } else {
+ if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
+ db_query($link, "SET NAMES " . MYSQL_CHARSET);
+ // db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
+ }
+ }
+ }
?>
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
- if (DB_TYPE == "pgsql") {
- pg_query("set client_encoding = 'UTF-8'");
- pg_set_client_encoding("UNICODE");
- } else {
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- db_query($link, "SET NAMES " . MYSQL_CHARSET);
-// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
- }
- }
+ init_connection($link);
login_sequence($link, true);
require_once "db.php";
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
-
- if (DB_TYPE == "pgsql") {
- pg_query($link, "set client_encoding = 'utf-8'");
- pg_set_client_encoding("UNICODE");
- } else {
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- db_query($link, "SET NAMES " . MYSQL_CHARSET);
-// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
- }
- }
+
+ init_connection($link);
login_sequence($link);
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
- if (DB_TYPE == "pgsql") {
- pg_query($link, "set client_encoding = 'utf-8'");
- pg_set_client_encoding("UNICODE");
- } else {
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- db_query($link, "SET NAMES " . MYSQL_CHARSET);
-// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
- }
- }
-
+ init_connection($link);
login_sequence($link);
$owner_uid = $_SESSION["uid"];
require_once "db.php";
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
-
- if (DB_TYPE == "pgsql") {
- pg_query($link, "set client_encoding = 'utf-8'");
- pg_set_client_encoding("UNICODE");
- } else {
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- db_query($link, "SET NAMES " . MYSQL_CHARSET);
-// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
- }
- }
+ init_connection($link);
login_sequence($link);
$owner_uid = $_SESSION["uid"];
"Maybe another daemon is already running.\n");
}
+ // Testing database connection.
+ // It is unnecessary to start the fork loop if database is not ok.
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if (!$link) {
return;
}
- if (DB_TYPE == "pgsql") {
- pg_query("set client_encoding = 'utf-8'");
- pg_set_client_encoding("UNICODE");
- } else {
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- db_query($link, "SET NAMES " . MYSQL_CHARSET);
-// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
- }
- }
-
db_close($link);
$last_purge = 0;
db_close($link);
-
while (true) {
// Since sleep is interupted by SIGCHLD, we need another way to
return;
}
- if (DB_TYPE == "pgsql") {
- pg_query("set client_encoding = 'utf-8'");
- pg_set_client_encoding("UNICODE");
- } else {
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- db_query($link, "SET NAMES " . MYSQL_CHARSET);
- // db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
- }
- }
+ init_connection($link);
// We disable stamp file, since it is of no use in a multiprocess update.
// not really, tho for the time being -fox
return;
}
- if (DB_TYPE == "pgsql") {
- pg_query("set client_encoding = 'utf-8'");
- pg_set_client_encoding("UNICODE");
- } else {
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- db_query($link, "SET NAMES " . MYSQL_CHARSET);
-// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
- }
- }
+ init_connection($link);
$last_purge = 0;
return;
}
- if (DB_TYPE == "pgsql") {
- pg_query("set client_encoding = 'utf-8'");
- pg_set_client_encoding("UNICODE");
- } else {
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- db_query($link, "SET NAMES " . MYSQL_CHARSET);
-// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
- }
- }
+ init_connection($link);
// Purge all posts (random 30 feeds)
global_purge_old_posts($link, true, 30);
return;
}
- if (DB_TYPE == "pgsql") {
- pg_query("set client_encoding = 'utf-8'");
- pg_set_client_encoding("UNICODE");
- } else {
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- db_query($link, "SET NAMES " . MYSQL_CHARSET);
-// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
- }
- }
+ init_connection($link);
function getVirtualFeeds($msg) {
global $link;