]> git.wh0rd.org - tt-rss.git/blob - utils/mysql_convert_unicode.php
update translations
[tt-rss.git] / utils / mysql_convert_unicode.php
1 <?php
2 error_reporting(E_ERROR | E_WARNING | E_PARSE);
3
4 require_once "../sessions.php";
5
6 require_once "../sanity_check.php";
7 require_once "../functions.php";
8 require_once "../config.php";
9 require_once "../db.php";
10
11 $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
12
13 init_connection($link);
14
15 login_sequence($link);
16
17 $owner_uid = $_SESSION["uid"];
18
19 if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
20 $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
21 render_login_form($link);
22 exit;
23 }
24
25
26 ?>
27
28 <html>
29 <head>
30 <title>MySQL Charset Converter</title>
31 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
32 <link rel="stylesheet" type="text/css" href="utility.css">
33 <script type="text/javascript" src="localized_js.php"></script>
34 </head>
35
36 <body>
37
38 <script type='text/javascript'>
39 function confirmOP() {
40 return confirm(__("Update the database?"));
41 }
42 </script>
43
44 <div class="floatingLogo"><img src="images/ttrss_logo.png"></div>
45
46 <h1><?php echo __("MySQL Charset Updater") ?></h1>
47
48 <?php
49
50 $op = $_POST["op"];
51
52 if (DB_TYPE != "mysql") {
53 print_warning(__("This script is for Tiny Tiny RSS installations with MySQL backend only."));
54
55 print "<form method=\"GET\" action=\"logout.php\">
56 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
57 </form>";
58
59 } else if (!$op) {
60
61 print_warning(__("Please backup your database before proceeding."));
62
63 print "<p>" . __("This script will convert your Tiny Tiny RSS database to UTF-8.
64 Depending on current database charset you may experience data corruption (lost accent characters, etc.).
65 After update, you'll have to set <b>MYSQL_CHARSET</b> option in config.php to 'utf8'.") . "</p>";
66
67 print "<form method='POST'>
68 <input type='hidden' name='op' value='do'>
69 <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'>
70 </form>";
71
72 } else if ($op == "do") {
73
74 print "<p>".__("Converting database...")."</p>";
75
76 db_query($link, "BEGIN");
77 db_query($link, "SET FOREIGN_KEY_CHECKS=0");
78
79 $result = db_query($link, "SHOW TABLES LIKE 'ttrss%'");
80
81 while ($line = db_fetch_assoc($result)) {
82 $vals = array_values($line);
83 $table = $vals[0];
84
85 $query = "ALTER TABLE $table CONVERT TO
86 CHARACTER SET 'utf8'";
87
88 print "<p class='query'>$query</p>";
89
90 db_query($link, $query);
91 }
92
93 db_query($link, "SET FOREIGN_KEY_CHECKS=1");
94 db_query($link, "COMMIT");
95
96 print "<form method=\"GET\" action=\"logout.php\">
97 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
98 </form>";
99
100 }
101
102 ?>
103
104 </body>
105 </html>
106