summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2007-08-25 05:28:10 +0100
committerAndrew Dolgov <[email protected]>2007-08-25 05:28:10 +0100
commit75ca19864eceaf5c8c706d16ee11559c548347d1 (patch)
tree99ec7f4372b93c47a516334dda73db670244379f
parent588fb13b5d82b39aaf1aa3d46e71e7c46e42bcf1 (diff)
remove mysql SET CHARACTER SET call
-rw-r--r--backend.php2
-rw-r--r--mysql_convert_unicode.php112
-rw-r--r--opml.php2
-rw-r--r--update.php2
-rw-r--r--update_daemon.php2
-rw-r--r--update_feeds.php2
-rw-r--r--xml-rpc.php2
7 files changed, 118 insertions, 6 deletions
diff --git a/backend.php b/backend.php
index 3783c8226..77323008f 100644
--- a/backend.php
+++ b/backend.php
@@ -52,7 +52,7 @@
} else {
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
db_query($link, "SET NAMES " . MYSQL_CHARSET);
- db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
+// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
}
}
diff --git a/mysql_convert_unicode.php b/mysql_convert_unicode.php
new file mode 100644
index 000000000..dfc833b44
--- /dev/null
+++ b/mysql_convert_unicode.php
@@ -0,0 +1,112 @@
+<?php
+ error_reporting(E_ERROR | E_WARNING | E_PARSE);
+
+ require_once "sessions.php";
+
+ require_once "sanity_check.php";
+ require_once "functions.php";
+ require_once "config.php";
+ 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);
+ }
+ }
+
+ login_sequence($link);
+
+ $owner_uid = $_SESSION["uid"];
+
+ if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
+ $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
+ render_login_form($link);
+ exit;
+ }
+
+
+?>
+
+<html>
+<head>
+<title>MySQL Charset Converter</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<link rel="stylesheet" type="text/css" href="utility.css">
+<script type="text/javascript" src="localized_js.php"></script>
+</head>
+
+<body>
+
+<script type='text/javascript'>
+function confirmOP() {
+ return confirm(__("Update the database?"));
+}
+</script>
+
+<div class="floatingLogo"><img src="images/ttrss_logo.png"></div>
+
+<h1><?php echo __("MySQL Charset Updater") ?></h1>
+
+<?php
+
+ $op = $_POST["op"];
+
+ if (DB_TYPE != "mysql") {
+ print_warning(__("This script is for Tiny Tiny RSS installations with MySQL backend only."));
+
+ print "<form method=\"GET\" action=\"logout.php\">
+ <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
+ </form>";
+
+ } else if (!$op) {
+
+ print_warning(__("Please backup your database before proceeding."));
+
+ print "<p>" . __("This script will convert your Tiny Tiny RSS database to UTF-8.
+ Depending on current database charset you may experience data corruption (lost accent characters, etc.).
+ After update, you'll have to set <b>MYSQL_CHARSET</b> option in config.php to 'utf8'.") . "</p>";
+
+ print "<form method='POST'>
+ <input type='hidden' name='op' value='do'>
+ <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'>
+ </form>";
+
+ } else if ($op == "do") {
+
+ print "<p>".__("Converting database...")."</p>";
+
+ db_query($link, "SET FOREIGN_KEY_CHECKS=0");
+
+ $result = db_query($link, "SHOW TABLES LIKE 'ttrss%'");
+
+ while ($line = db_fetch_assoc($result)) {
+ $vals = array_values($line);
+ $table = $vals[0];
+
+ $query = "ALTER TABLE $table CONVERT TO
+ CHARACTER SET 'utf8'";
+
+ print "<p class='query'>$query</p>";
+
+ db_query($link, $query);
+ }
+
+ db_query($link, "SET FOREIGN_KEY_CHECKS=1");
+
+ print "<form method=\"GET\" action=\"logout.php\">
+ <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
+ </form>";
+
+ }
+
+?>
+
+</body>
+</html>
+
diff --git a/opml.php b/opml.php
index ce7b490b4..883ddd0d9 100644
--- a/opml.php
+++ b/opml.php
@@ -16,7 +16,7 @@
} else {
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
db_query($link, "SET NAMES " . MYSQL_CHARSET);
- db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
+// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
}
}
diff --git a/update.php b/update.php
index f05fefcce..f59f9ef3e 100644
--- a/update.php
+++ b/update.php
@@ -16,7 +16,7 @@
} else {
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
db_query($link, "SET NAMES " . MYSQL_CHARSET);
- db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
+// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
}
}
diff --git a/update_daemon.php b/update_daemon.php
index e7f1f4016..ce5d2535e 100644
--- a/update_daemon.php
+++ b/update_daemon.php
@@ -68,7 +68,7 @@
} else {
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
db_query($link, "SET NAMES " . MYSQL_CHARSET);
- db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
+// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
}
}
diff --git a/update_feeds.php b/update_feeds.php
index 9a1b8f43d..a6956dfa8 100644
--- a/update_feeds.php
+++ b/update_feeds.php
@@ -29,7 +29,7 @@
} else {
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
db_query($link, "SET NAMES " . MYSQL_CHARSET);
- db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
+// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
}
}
diff --git a/xml-rpc.php b/xml-rpc.php
index affb09d0e..07f423cbd 100644
--- a/xml-rpc.php
+++ b/xml-rpc.php
@@ -25,7 +25,7 @@
} else {
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
db_query($link, "SET NAMES " . MYSQL_CHARSET);
- db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
+// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
}
}