2 error_reporting(E_ERROR | E_WARNING | E_PARSE
);
4 require_once "sessions.php";
6 require_once "sanity_check.php";
7 require_once "functions.php";
8 require_once "config.php";
11 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
13 if (DB_TYPE
== "pgsql") {
14 pg_query($link, "set client_encoding = 'utf-8'");
15 pg_set_client_encoding("UNICODE");
17 if (defined('MYSQL_CHARSET') && MYSQL_CHARSET
) {
18 db_query($link, "SET NAMES " . MYSQL_CHARSET
);
19 // db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
23 login_sequence($link);
25 $owner_uid = $_SESSION["uid"];
27 if (!SINGLE_USER_MODE
&& $_SESSION["access_level"] < 10) {
28 $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
29 render_login_form($link);
38 <title
>MySQL Charset Converter
</title
>
39 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8">
40 <link rel
="stylesheet" type
="text/css" href
="utility.css">
41 <script type
="text/javascript" src
="localized_js.php"></script
>
46 <script type
='text/javascript'>
47 function confirmOP() {
48 return confirm(__("Update the database?"));
52 <div
class="floatingLogo"><img src
="images/ttrss_logo.png"></div
>
54 <h1
><?php
echo __("MySQL Charset Updater") ?
></h1
>
60 if (DB_TYPE
!= "mysql") {
61 print_warning(__("This script is for Tiny Tiny RSS installations with MySQL backend only."));
63 print "<form method=\"GET\" action=\"logout.php\">
64 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
69 print_warning(__("Please backup your database before proceeding."));
71 print "<p>" . __("This script will convert your Tiny Tiny RSS database to UTF-8.
72 Depending on current database charset you may experience data corruption (lost accent characters, etc.).
73 After update, you'll have to set <b>MYSQL_CHARSET</b> option in config.php to 'utf8'.") . "</p>";
75 print "<form method='POST'>
76 <input type='hidden' name='op' value='do'>
77 <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'>
80 } else if ($op == "do") {
82 print "<p>".__("Converting database...")."</p>";
84 db_query($link, "BEGIN");
85 db_query($link, "SET FOREIGN_KEY_CHECKS=0");
87 $result = db_query($link, "SHOW TABLES LIKE 'ttrss%'");
89 while ($line = db_fetch_assoc($result)) {
90 $vals = array_values($line);
93 $query = "ALTER TABLE $table CONVERT TO
94 CHARACTER SET 'utf8'";
96 print "<p class='query'>$query</p>";
98 db_query($link, $query);
101 db_query($link, "SET FOREIGN_KEY_CHECKS=1");
102 db_query($link, "COMMIT");
104 print "<form method=\"GET\" action=\"logout.php\">
105 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">