@@ -7,15 +7,15 @@ |
||
7 | 7 | <link rel="shortcut icon" type="image/png" href="images/favicon.png"> |
8 | 8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
9 | 9 | <?php |
10 | - foreach (array("lib/prototype.js", |
|
11 | - "lib/dojo/dojo.js", |
|
12 | - "lib/dojo/tt-rss-layer.js", |
|
13 | - "js/common.js", |
|
14 | - "errors.php?mode=js") as $jsfile) { |
|
10 | + foreach (array("lib/prototype.js", |
|
11 | + "lib/dojo/dojo.js", |
|
12 | + "lib/dojo/tt-rss-layer.js", |
|
13 | + "js/common.js", |
|
14 | + "errors.php?mode=js") as $jsfile) { |
|
15 | 15 | |
16 | - echo javascript_tag($jsfile); |
|
16 | + echo javascript_tag($jsfile); |
|
17 | 17 | |
18 | - } ?> |
|
18 | + } ?> |
|
19 | 19 | |
20 | 20 | <script type="text/javascript"> |
21 | 21 | require({cache:{}}); |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | |
380 | 380 | // TODO: should this support POST requests or not? idk |
381 | 381 | |
382 | - $context_options = array( |
|
383 | - 'http' => array( |
|
382 | + $context_options = array( |
|
383 | + 'http' => array( |
|
384 | 384 | 'header' => array( |
385 | 385 | 'Connection: close' |
386 | 386 | ), |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | 'ignore_errors' => true, |
389 | 389 | 'timeout' => $timeout ? $timeout : FILE_FETCH_TIMEOUT, |
390 | 390 | 'protocol_version'=> 1.1) |
391 | - ); |
|
391 | + ); |
|
392 | 392 | |
393 | 393 | if (!$post_query && $last_modified) |
394 | 394 | array_push($context_options['http']['header'], "If-Modified-Since: $last_modified"); |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | function logout_user() { |
660 | 660 | @session_destroy(); |
661 | 661 | if (isset($_COOKIE[session_name()])) { |
662 | - setcookie(session_name(), '', time()-42000, '/'); |
|
662 | + setcookie(session_name(), '', time()-42000, '/'); |
|
663 | 663 | } |
664 | 664 | session_commit(); |
665 | 665 | } |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | if (AUTH_AUTO_LOGIN && authenticate_user(null, null)) { |
700 | 700 | $_SESSION["ref_schema_version"] = get_schema_version(true); |
701 | 701 | } else { |
702 | - authenticate_user(null, null, true); |
|
702 | + authenticate_user(null, null, true); |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | if (!$_SESSION["uid"]) { |
@@ -974,9 +974,9 @@ discard block |
||
974 | 974 | $params = array(); |
975 | 975 | |
976 | 976 | foreach (array("ON_CATCHUP_SHOW_NEXT_FEED", "HIDE_READ_FEEDS", |
977 | - "ENABLE_FEED_CATS", "FEEDS_SORT_BY_UNREAD", "CONFIRM_FEED_CATCHUP", |
|
978 | - "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE", |
|
979 | - "HIDE_READ_SHOWS_SPECIAL", "COMBINED_DISPLAY_MODE") as $param) { |
|
977 | + "ENABLE_FEED_CATS", "FEEDS_SORT_BY_UNREAD", "CONFIRM_FEED_CATCHUP", |
|
978 | + "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE", |
|
979 | + "HIDE_READ_SHOWS_SPECIAL", "COMBINED_DISPLAY_MODE") as $param) { |
|
980 | 980 | |
981 | 981 | $params[strtolower($param)] = (int) get_pref($param); |
982 | 982 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | __("Session failed to validate (schema version changed)"); |
43 | 43 | return false; |
44 | 44 | } |
45 | - $pdo = Db::pdo(); |
|
45 | + $pdo = Db::pdo(); |
|
46 | 46 | |
47 | 47 | if ($_SESSION["uid"]) { |
48 | 48 | |
@@ -56,21 +56,21 @@ discard block |
||
56 | 56 | |
57 | 57 | // user not found |
58 | 58 | if ($row = $sth->fetch()) { |
59 | - $pwd_hash = $row["pwd_hash"]; |
|
59 | + $pwd_hash = $row["pwd_hash"]; |
|
60 | 60 | |
61 | - if ($pwd_hash != $_SESSION["pwd_hash"]) { |
|
61 | + if ($pwd_hash != $_SESSION["pwd_hash"]) { |
|
62 | 62 | |
63 | - $_SESSION["login_error_msg"] = |
|
63 | + $_SESSION["login_error_msg"] = |
|
64 | 64 | __("Session failed to validate (password changed)"); |
65 | 65 | |
66 | - return false; |
|
67 | - } |
|
66 | + return false; |
|
67 | + } |
|
68 | 68 | } else { |
69 | 69 | |
70 | - $_SESSION["login_error_msg"] = |
|
71 | - __("Session failed to validate (user not found)"); |
|
70 | + $_SESSION["login_error_msg"] = |
|
71 | + __("Session failed to validate (user not found)"); |
|
72 | 72 | |
73 | - return false; |
|
73 | + return false; |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | } |
@@ -1,107 +1,107 @@ discard block |
||
1 | 1 | #!/usr/bin/env php |
2 | 2 | <?php |
3 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
4 | - get_include_path()); |
|
3 | + set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
4 | + get_include_path()); |
|
5 | 5 | |
6 | - define('DISABLE_SESSIONS', true); |
|
6 | + define('DISABLE_SESSIONS', true); |
|
7 | 7 | |
8 | - chdir(dirname(__FILE__)); |
|
8 | + chdir(dirname(__FILE__)); |
|
9 | 9 | |
10 | - require_once "autoload.php"; |
|
11 | - require_once "functions.php"; |
|
12 | - require_once "config.php"; |
|
13 | - require_once "sanity_check.php"; |
|
14 | - require_once "db.php"; |
|
15 | - require_once "db-prefs.php"; |
|
10 | + require_once "autoload.php"; |
|
11 | + require_once "functions.php"; |
|
12 | + require_once "config.php"; |
|
13 | + require_once "sanity_check.php"; |
|
14 | + require_once "db.php"; |
|
15 | + require_once "db-prefs.php"; |
|
16 | 16 | |
17 | - function cleanup_tags($days = 14, $limit = 1000) { |
|
17 | + function cleanup_tags($days = 14, $limit = 1000) { |
|
18 | 18 | |
19 | - $days = (int) $days; |
|
19 | + $days = (int) $days; |
|
20 | 20 | |
21 | - if (DB_TYPE == "pgsql") { |
|
22 | - $interval_query = "date_updated < NOW() - INTERVAL '$days days'"; |
|
23 | - } else if (DB_TYPE == "mysql") { |
|
24 | - $interval_query = "date_updated < DATE_SUB(NOW(), INTERVAL $days DAY)"; |
|
25 | - } |
|
21 | + if (DB_TYPE == "pgsql") { |
|
22 | + $interval_query = "date_updated < NOW() - INTERVAL '$days days'"; |
|
23 | + } else if (DB_TYPE == "mysql") { |
|
24 | + $interval_query = "date_updated < DATE_SUB(NOW(), INTERVAL $days DAY)"; |
|
25 | + } |
|
26 | 26 | |
27 | - $tags_deleted = 0; |
|
27 | + $tags_deleted = 0; |
|
28 | 28 | |
29 | - $pdo = Db::pdo(); |
|
29 | + $pdo = Db::pdo(); |
|
30 | 30 | |
31 | - while ($limit > 0) { |
|
32 | - $limit_part = 500; |
|
31 | + while ($limit > 0) { |
|
32 | + $limit_part = 500; |
|
33 | 33 | |
34 | - $sth = $pdo->prepare("SELECT ttrss_tags.id AS id |
|
34 | + $sth = $pdo->prepare("SELECT ttrss_tags.id AS id |
|
35 | 35 | FROM ttrss_tags, ttrss_user_entries, ttrss_entries |
36 | 36 | WHERE post_int_id = int_id AND $interval_query AND |
37 | 37 | ref_id = ttrss_entries.id AND tag_cache != '' LIMIT ?"); |
38 | - $sth->bindValue(1, $limit_part, PDO::PARAM_INT); |
|
39 | - $sth->execute(); |
|
40 | - |
|
41 | - $ids = array(); |
|
42 | - |
|
43 | - while ($line = $sth->fetch()) { |
|
44 | - array_push($ids, $line['id']); |
|
45 | - } |
|
46 | - |
|
47 | - if (count($ids) > 0) { |
|
48 | - $ids = join(",", $ids); |
|
49 | - |
|
50 | - $usth = $pdo->query("DELETE FROM ttrss_tags WHERE id IN ($ids)"); |
|
51 | - $tags_deleted = $usth->rowCount(); |
|
52 | - } else { |
|
53 | - break; |
|
54 | - } |
|
55 | - |
|
56 | - $limit -= $limit_part; |
|
57 | - } |
|
58 | - |
|
59 | - return $tags_deleted; |
|
60 | - } |
|
61 | - |
|
62 | - if (!defined('PHP_EXECUTABLE')) |
|
63 | - define('PHP_EXECUTABLE', '/usr/bin/php'); |
|
64 | - |
|
65 | - $pdo = Db::pdo(); |
|
66 | - |
|
67 | - init_plugins(); |
|
68 | - |
|
69 | - $longopts = array("feeds", |
|
70 | - "daemon", |
|
71 | - "daemon-loop", |
|
72 | - "send-digests", |
|
73 | - "task:", |
|
74 | - "cleanup-tags", |
|
75 | - "quiet", |
|
76 | - "log:", |
|
77 | - "log-level:", |
|
78 | - "indexes", |
|
79 | - "pidlock:", |
|
80 | - "update-schema", |
|
81 | - "convert-filters", |
|
82 | - "force-update", |
|
83 | - "gen-search-idx", |
|
84 | - "list-plugins", |
|
85 | - "debug-feed:", |
|
86 | - "force-refetch", |
|
87 | - "force-rehash", |
|
88 | - "help"); |
|
89 | - |
|
90 | - foreach (PluginHost::getInstance()->get_commands() as $command => $data) { |
|
91 | - array_push($longopts, $command . $data["suffix"]); |
|
92 | - } |
|
93 | - |
|
94 | - $options = getopt("", $longopts); |
|
95 | - |
|
96 | - if (!is_array($options)) { |
|
97 | - die("error: getopt() failed. ". |
|
98 | - "Most probably you are using PHP CGI to run this script ". |
|
99 | - "instead of required PHP CLI. Check tt-rss wiki page on updating feeds for ". |
|
100 | - "additional information.\n"); |
|
101 | - } |
|
102 | - |
|
103 | - if (count($options) == 0 && !defined('STDIN')) { |
|
104 | - ?> |
|
38 | + $sth->bindValue(1, $limit_part, PDO::PARAM_INT); |
|
39 | + $sth->execute(); |
|
40 | + |
|
41 | + $ids = array(); |
|
42 | + |
|
43 | + while ($line = $sth->fetch()) { |
|
44 | + array_push($ids, $line['id']); |
|
45 | + } |
|
46 | + |
|
47 | + if (count($ids) > 0) { |
|
48 | + $ids = join(",", $ids); |
|
49 | + |
|
50 | + $usth = $pdo->query("DELETE FROM ttrss_tags WHERE id IN ($ids)"); |
|
51 | + $tags_deleted = $usth->rowCount(); |
|
52 | + } else { |
|
53 | + break; |
|
54 | + } |
|
55 | + |
|
56 | + $limit -= $limit_part; |
|
57 | + } |
|
58 | + |
|
59 | + return $tags_deleted; |
|
60 | + } |
|
61 | + |
|
62 | + if (!defined('PHP_EXECUTABLE')) |
|
63 | + define('PHP_EXECUTABLE', '/usr/bin/php'); |
|
64 | + |
|
65 | + $pdo = Db::pdo(); |
|
66 | + |
|
67 | + init_plugins(); |
|
68 | + |
|
69 | + $longopts = array("feeds", |
|
70 | + "daemon", |
|
71 | + "daemon-loop", |
|
72 | + "send-digests", |
|
73 | + "task:", |
|
74 | + "cleanup-tags", |
|
75 | + "quiet", |
|
76 | + "log:", |
|
77 | + "log-level:", |
|
78 | + "indexes", |
|
79 | + "pidlock:", |
|
80 | + "update-schema", |
|
81 | + "convert-filters", |
|
82 | + "force-update", |
|
83 | + "gen-search-idx", |
|
84 | + "list-plugins", |
|
85 | + "debug-feed:", |
|
86 | + "force-refetch", |
|
87 | + "force-rehash", |
|
88 | + "help"); |
|
89 | + |
|
90 | + foreach (PluginHost::getInstance()->get_commands() as $command => $data) { |
|
91 | + array_push($longopts, $command . $data["suffix"]); |
|
92 | + } |
|
93 | + |
|
94 | + $options = getopt("", $longopts); |
|
95 | + |
|
96 | + if (!is_array($options)) { |
|
97 | + die("error: getopt() failed. ". |
|
98 | + "Most probably you are using PHP CGI to run this script ". |
|
99 | + "instead of required PHP CLI. Check tt-rss wiki page on updating feeds for ". |
|
100 | + "additional information.\n"); |
|
101 | + } |
|
102 | + |
|
103 | + if (count($options) == 0 && !defined('STDIN')) { |
|
104 | + ?> |
|
105 | 105 | <!DOCTYPE html> |
106 | 106 | <html> |
107 | 107 | <head> |
@@ -116,376 +116,376 @@ discard block |
||
116 | 116 | |
117 | 117 | </body></html> |
118 | 118 | <?php |
119 | - exit; |
|
120 | - } |
|
121 | - |
|
122 | - if (count($options) == 0 || isset($options["help"]) ) { |
|
123 | - print "Tiny Tiny RSS data update script.\n\n"; |
|
124 | - print "Options:\n"; |
|
125 | - print " --feeds - update feeds\n"; |
|
126 | - print " --daemon - start single-process update daemon\n"; |
|
127 | - print " --task N - create lockfile using this task id\n"; |
|
128 | - print " --cleanup-tags - perform tags table maintenance\n"; |
|
129 | - print " --quiet - don't output messages to stdout\n"; |
|
130 | - print " --log FILE - log messages to FILE\n"; |
|
131 | - print " --log-level N - log verbosity level\n"; |
|
132 | - print " --indexes - recreate missing schema indexes\n"; |
|
133 | - print " --update-schema - update database schema\n"; |
|
134 | - print " --gen-search-idx - generate basic PostgreSQL fulltext search index\n"; |
|
135 | - print " --convert-filters - convert type1 filters to type2\n"; |
|
136 | - print " --send-digests - send pending email digests\n"; |
|
137 | - print " --force-update - force update of all feeds\n"; |
|
138 | - print " --list-plugins - list all available plugins\n"; |
|
139 | - print " --debug-feed N - perform debug update of feed N\n"; |
|
140 | - print " --force-refetch - debug update: force refetch feed data\n"; |
|
141 | - print " --force-rehash - debug update: force rehash articles\n"; |
|
142 | - print " --help - show this help\n"; |
|
143 | - print "Plugin options:\n"; |
|
144 | - |
|
145 | - foreach (PluginHost::getInstance()->get_commands() as $command => $data) { |
|
146 | - $args = $data['arghelp']; |
|
147 | - printf(" --%-19s - %s\n", "$command $args", $data["description"]); |
|
148 | - } |
|
149 | - |
|
150 | - return; |
|
151 | - } |
|
152 | - |
|
153 | - if (!isset($options['daemon'])) { |
|
154 | - require_once "errorhandler.php"; |
|
155 | - } |
|
156 | - |
|
157 | - if (!isset($options['update-schema'])) { |
|
158 | - $schema_version = get_schema_version(); |
|
159 | - |
|
160 | - if ($schema_version != SCHEMA_VERSION) { |
|
161 | - die("Schema version is wrong, please upgrade the database (--update-schema).\n"); |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - Debug::set_enabled(true); |
|
166 | - |
|
167 | - if (isset($options["log-level"])) { |
|
168 | - Debug::set_loglevel((int)$options["log-level"]); |
|
119 | + exit; |
|
120 | + } |
|
121 | + |
|
122 | + if (count($options) == 0 || isset($options["help"]) ) { |
|
123 | + print "Tiny Tiny RSS data update script.\n\n"; |
|
124 | + print "Options:\n"; |
|
125 | + print " --feeds - update feeds\n"; |
|
126 | + print " --daemon - start single-process update daemon\n"; |
|
127 | + print " --task N - create lockfile using this task id\n"; |
|
128 | + print " --cleanup-tags - perform tags table maintenance\n"; |
|
129 | + print " --quiet - don't output messages to stdout\n"; |
|
130 | + print " --log FILE - log messages to FILE\n"; |
|
131 | + print " --log-level N - log verbosity level\n"; |
|
132 | + print " --indexes - recreate missing schema indexes\n"; |
|
133 | + print " --update-schema - update database schema\n"; |
|
134 | + print " --gen-search-idx - generate basic PostgreSQL fulltext search index\n"; |
|
135 | + print " --convert-filters - convert type1 filters to type2\n"; |
|
136 | + print " --send-digests - send pending email digests\n"; |
|
137 | + print " --force-update - force update of all feeds\n"; |
|
138 | + print " --list-plugins - list all available plugins\n"; |
|
139 | + print " --debug-feed N - perform debug update of feed N\n"; |
|
140 | + print " --force-refetch - debug update: force refetch feed data\n"; |
|
141 | + print " --force-rehash - debug update: force rehash articles\n"; |
|
142 | + print " --help - show this help\n"; |
|
143 | + print "Plugin options:\n"; |
|
144 | + |
|
145 | + foreach (PluginHost::getInstance()->get_commands() as $command => $data) { |
|
146 | + $args = $data['arghelp']; |
|
147 | + printf(" --%-19s - %s\n", "$command $args", $data["description"]); |
|
148 | + } |
|
149 | + |
|
150 | + return; |
|
151 | + } |
|
152 | + |
|
153 | + if (!isset($options['daemon'])) { |
|
154 | + require_once "errorhandler.php"; |
|
155 | + } |
|
156 | + |
|
157 | + if (!isset($options['update-schema'])) { |
|
158 | + $schema_version = get_schema_version(); |
|
159 | + |
|
160 | + if ($schema_version != SCHEMA_VERSION) { |
|
161 | + die("Schema version is wrong, please upgrade the database (--update-schema).\n"); |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + Debug::set_enabled(true); |
|
166 | + |
|
167 | + if (isset($options["log-level"])) { |
|
168 | + Debug::set_loglevel((int)$options["log-level"]); |
|
169 | 169 | } |
170 | 170 | |
171 | - if (isset($options["log"])) { |
|
172 | - Debug::set_quiet(isset($options['quiet'])); |
|
173 | - Debug::set_logfile($options["log"]); |
|
171 | + if (isset($options["log"])) { |
|
172 | + Debug::set_quiet(isset($options['quiet'])); |
|
173 | + Debug::set_logfile($options["log"]); |
|
174 | 174 | Debug::log("Logging to " . $options["log"]); |
175 | 175 | } else { |
176 | - if (isset($options['quiet'])) { |
|
177 | - Debug::set_loglevel(Debug::$LOG_DISABLED); |
|
176 | + if (isset($options['quiet'])) { |
|
177 | + Debug::set_loglevel(Debug::$LOG_DISABLED); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - if (!isset($options["daemon"])) { |
|
182 | - $lock_filename = "update.lock"; |
|
183 | - } else { |
|
184 | - $lock_filename = "update_daemon.lock"; |
|
185 | - } |
|
181 | + if (!isset($options["daemon"])) { |
|
182 | + $lock_filename = "update.lock"; |
|
183 | + } else { |
|
184 | + $lock_filename = "update_daemon.lock"; |
|
185 | + } |
|
186 | 186 | |
187 | - if (isset($options["task"])) { |
|
188 | - Debug::log("Using task id " . $options["task"]); |
|
189 | - $lock_filename = $lock_filename . "-task_" . $options["task"]; |
|
190 | - } |
|
187 | + if (isset($options["task"])) { |
|
188 | + Debug::log("Using task id " . $options["task"]); |
|
189 | + $lock_filename = $lock_filename . "-task_" . $options["task"]; |
|
190 | + } |
|
191 | 191 | |
192 | - if (isset($options["pidlock"])) { |
|
193 | - $my_pid = $options["pidlock"]; |
|
194 | - $lock_filename = "update_daemon-$my_pid.lock"; |
|
192 | + if (isset($options["pidlock"])) { |
|
193 | + $my_pid = $options["pidlock"]; |
|
194 | + $lock_filename = "update_daemon-$my_pid.lock"; |
|
195 | 195 | |
196 | - } |
|
196 | + } |
|
197 | 197 | |
198 | - Debug::log("Lock: $lock_filename"); |
|
198 | + Debug::log("Lock: $lock_filename"); |
|
199 | 199 | |
200 | - $lock_handle = make_lockfile($lock_filename); |
|
201 | - $must_exit = false; |
|
200 | + $lock_handle = make_lockfile($lock_filename); |
|
201 | + $must_exit = false; |
|
202 | 202 | |
203 | - if (isset($options["task"]) && isset($options["pidlock"])) { |
|
204 | - $waits = $options["task"] * 5; |
|
205 | - Debug::log("Waiting before update ($waits)"); |
|
206 | - sleep($waits); |
|
207 | - } |
|
203 | + if (isset($options["task"]) && isset($options["pidlock"])) { |
|
204 | + $waits = $options["task"] * 5; |
|
205 | + Debug::log("Waiting before update ($waits)"); |
|
206 | + sleep($waits); |
|
207 | + } |
|
208 | 208 | |
209 | - // Try to lock a file in order to avoid concurrent update. |
|
210 | - if (!$lock_handle) { |
|
211 | - die("error: Can't create lockfile ($lock_filename). ". |
|
212 | - "Maybe another update process is already running.\n"); |
|
213 | - } |
|
209 | + // Try to lock a file in order to avoid concurrent update. |
|
210 | + if (!$lock_handle) { |
|
211 | + die("error: Can't create lockfile ($lock_filename). ". |
|
212 | + "Maybe another update process is already running.\n"); |
|
213 | + } |
|
214 | 214 | |
215 | - if (isset($options["force-update"])) { |
|
216 | - Debug::log("marking all feeds as needing update..."); |
|
215 | + if (isset($options["force-update"])) { |
|
216 | + Debug::log("marking all feeds as needing update..."); |
|
217 | 217 | |
218 | - $pdo->query( "UPDATE ttrss_feeds SET |
|
218 | + $pdo->query( "UPDATE ttrss_feeds SET |
|
219 | 219 | last_update_started = '1970-01-01', last_updated = '1970-01-01'"); |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - if (isset($options["feeds"])) { |
|
223 | - RSSUtils::update_daemon_common(); |
|
224 | - RSSUtils::housekeeping_common(true); |
|
222 | + if (isset($options["feeds"])) { |
|
223 | + RSSUtils::update_daemon_common(); |
|
224 | + RSSUtils::housekeeping_common(true); |
|
225 | 225 | |
226 | - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); |
|
227 | - } |
|
226 | + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); |
|
227 | + } |
|
228 | 228 | |
229 | - if (isset($options["daemon"])) { |
|
230 | - while (true) { |
|
231 | - $quiet = (isset($options["quiet"])) ? "--quiet" : ""; |
|
229 | + if (isset($options["daemon"])) { |
|
230 | + while (true) { |
|
231 | + $quiet = (isset($options["quiet"])) ? "--quiet" : ""; |
|
232 | 232 | $log = isset($options['log']) ? '--log '.$options['log'] : ''; |
233 | 233 | $log_level = isset($options['log-level']) ? '--log-level '.$options['log-level'] : ''; |
234 | 234 | |
235 | - passthru(PHP_EXECUTABLE . " " . $argv[0] ." --daemon-loop $quiet $log $log_level"); |
|
235 | + passthru(PHP_EXECUTABLE . " " . $argv[0] ." --daemon-loop $quiet $log $log_level"); |
|
236 | 236 | |
237 | - // let's enforce a minimum spawn interval as to not forkbomb the host |
|
238 | - $spawn_interval = max(60, DAEMON_SLEEP_INTERVAL); |
|
237 | + // let's enforce a minimum spawn interval as to not forkbomb the host |
|
238 | + $spawn_interval = max(60, DAEMON_SLEEP_INTERVAL); |
|
239 | 239 | |
240 | - Debug::log("Sleeping for $spawn_interval seconds..."); |
|
241 | - sleep($spawn_interval); |
|
242 | - } |
|
243 | - } |
|
240 | + Debug::log("Sleeping for $spawn_interval seconds..."); |
|
241 | + sleep($spawn_interval); |
|
242 | + } |
|
243 | + } |
|
244 | 244 | |
245 | - if (isset($options["daemon-loop"])) { |
|
246 | - if (!make_stampfile('update_daemon.stamp')) { |
|
247 | - Debug::log("warning: unable to create stampfile\n"); |
|
248 | - } |
|
245 | + if (isset($options["daemon-loop"])) { |
|
246 | + if (!make_stampfile('update_daemon.stamp')) { |
|
247 | + Debug::log("warning: unable to create stampfile\n"); |
|
248 | + } |
|
249 | 249 | |
250 | - RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT); |
|
250 | + RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT); |
|
251 | 251 | |
252 | - if (!isset($options["pidlock"]) || $options["task"] == 0) |
|
253 | - RSSUtils::housekeeping_common(true); |
|
252 | + if (!isset($options["pidlock"]) || $options["task"] == 0) |
|
253 | + RSSUtils::housekeeping_common(true); |
|
254 | 254 | |
255 | - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); |
|
256 | - } |
|
255 | + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); |
|
256 | + } |
|
257 | 257 | |
258 | - if (isset($options["cleanup-tags"])) { |
|
259 | - $rc = cleanup_tags( 14, 50000); |
|
260 | - Debug::log("$rc tags deleted.\n"); |
|
261 | - } |
|
258 | + if (isset($options["cleanup-tags"])) { |
|
259 | + $rc = cleanup_tags( 14, 50000); |
|
260 | + Debug::log("$rc tags deleted.\n"); |
|
261 | + } |
|
262 | 262 | |
263 | - if (isset($options["indexes"])) { |
|
264 | - Debug::log("PLEASE BACKUP YOUR DATABASE BEFORE PROCEEDING!"); |
|
265 | - Debug::log("Type 'yes' to continue."); |
|
263 | + if (isset($options["indexes"])) { |
|
264 | + Debug::log("PLEASE BACKUP YOUR DATABASE BEFORE PROCEEDING!"); |
|
265 | + Debug::log("Type 'yes' to continue."); |
|
266 | 266 | |
267 | - if (read_stdin() != 'yes') |
|
268 | - exit; |
|
267 | + if (read_stdin() != 'yes') |
|
268 | + exit; |
|
269 | 269 | |
270 | - Debug::log("clearing existing indexes..."); |
|
270 | + Debug::log("clearing existing indexes..."); |
|
271 | 271 | |
272 | - if (DB_TYPE == "pgsql") { |
|
273 | - $sth = $pdo->query( "SELECT relname FROM |
|
272 | + if (DB_TYPE == "pgsql") { |
|
273 | + $sth = $pdo->query( "SELECT relname FROM |
|
274 | 274 | pg_catalog.pg_class WHERE relname LIKE 'ttrss_%' |
275 | 275 | AND relname NOT LIKE '%_pkey' |
276 | 276 | AND relkind = 'i'"); |
277 | - } else { |
|
278 | - $sth = $pdo->query( "SELECT index_name,table_name FROM |
|
277 | + } else { |
|
278 | + $sth = $pdo->query( "SELECT index_name,table_name FROM |
|
279 | 279 | information_schema.statistics WHERE index_name LIKE 'ttrss_%'"); |
280 | - } |
|
281 | - |
|
282 | - while ($line = $sth->fetch()) { |
|
283 | - if (DB_TYPE == "pgsql") { |
|
284 | - $statement = "DROP INDEX " . $line["relname"]; |
|
285 | - Debug::log($statement); |
|
286 | - } else { |
|
287 | - $statement = "ALTER TABLE ". |
|
288 | - $line['table_name']." DROP INDEX ".$line['index_name']; |
|
289 | - Debug::log($statement); |
|
290 | - } |
|
291 | - $pdo->query($statement); |
|
292 | - } |
|
280 | + } |
|
293 | 281 | |
294 | - Debug::log("reading indexes from schema for: " . DB_TYPE); |
|
282 | + while ($line = $sth->fetch()) { |
|
283 | + if (DB_TYPE == "pgsql") { |
|
284 | + $statement = "DROP INDEX " . $line["relname"]; |
|
285 | + Debug::log($statement); |
|
286 | + } else { |
|
287 | + $statement = "ALTER TABLE ". |
|
288 | + $line['table_name']." DROP INDEX ".$line['index_name']; |
|
289 | + Debug::log($statement); |
|
290 | + } |
|
291 | + $pdo->query($statement); |
|
292 | + } |
|
295 | 293 | |
296 | - $fp = fopen("schema/ttrss_schema_" . DB_TYPE . ".sql", "r"); |
|
297 | - if ($fp) { |
|
298 | - while ($line = fgets($fp)) { |
|
299 | - $matches = array(); |
|
294 | + Debug::log("reading indexes from schema for: " . DB_TYPE); |
|
300 | 295 | |
301 | - if (preg_match("/^create index ([^ ]+) on ([^ ]+)$/i", $line, $matches)) { |
|
302 | - $index = $matches[1]; |
|
303 | - $table = $matches[2]; |
|
296 | + $fp = fopen("schema/ttrss_schema_" . DB_TYPE . ".sql", "r"); |
|
297 | + if ($fp) { |
|
298 | + while ($line = fgets($fp)) { |
|
299 | + $matches = array(); |
|
304 | 300 | |
305 | - $statement = "CREATE INDEX $index ON $table"; |
|
301 | + if (preg_match("/^create index ([^ ]+) on ([^ ]+)$/i", $line, $matches)) { |
|
302 | + $index = $matches[1]; |
|
303 | + $table = $matches[2]; |
|
306 | 304 | |
307 | - Debug::log($statement); |
|
308 | - $pdo->query($statement); |
|
309 | - } |
|
310 | - } |
|
311 | - fclose($fp); |
|
312 | - } else { |
|
313 | - Debug::log("unable to open schema file."); |
|
314 | - } |
|
315 | - Debug::log("all done."); |
|
316 | - } |
|
305 | + $statement = "CREATE INDEX $index ON $table"; |
|
317 | 306 | |
318 | - if (isset($options["convert-filters"])) { |
|
319 | - Debug::log("WARNING: this will remove all existing type2 filters."); |
|
320 | - Debug::log("Type 'yes' to continue."); |
|
307 | + Debug::log($statement); |
|
308 | + $pdo->query($statement); |
|
309 | + } |
|
310 | + } |
|
311 | + fclose($fp); |
|
312 | + } else { |
|
313 | + Debug::log("unable to open schema file."); |
|
314 | + } |
|
315 | + Debug::log("all done."); |
|
316 | + } |
|
321 | 317 | |
322 | - if (read_stdin() != 'yes') |
|
323 | - exit; |
|
318 | + if (isset($options["convert-filters"])) { |
|
319 | + Debug::log("WARNING: this will remove all existing type2 filters."); |
|
320 | + Debug::log("Type 'yes' to continue."); |
|
324 | 321 | |
325 | - Debug::log("converting filters..."); |
|
322 | + if (read_stdin() != 'yes') |
|
323 | + exit; |
|
326 | 324 | |
327 | - $pdo->query("DELETE FROM ttrss_filters2"); |
|
325 | + Debug::log("converting filters..."); |
|
328 | 326 | |
329 | - $res = $pdo->query("SELECT * FROM ttrss_filters ORDER BY id"); |
|
327 | + $pdo->query("DELETE FROM ttrss_filters2"); |
|
330 | 328 | |
331 | - while ($line = $res->fetch()) { |
|
332 | - $owner_uid = $line["owner_uid"]; |
|
329 | + $res = $pdo->query("SELECT * FROM ttrss_filters ORDER BY id"); |
|
333 | 330 | |
334 | - // date filters are removed |
|
335 | - if ($line["filter_type"] != 5) { |
|
336 | - $filter = array(); |
|
331 | + while ($line = $res->fetch()) { |
|
332 | + $owner_uid = $line["owner_uid"]; |
|
337 | 333 | |
338 | - if (sql_bool_to_bool($line["cat_filter"])) { |
|
339 | - $feed_id = "CAT:" . (int)$line["cat_id"]; |
|
340 | - } else { |
|
341 | - $feed_id = (int)$line["feed_id"]; |
|
342 | - } |
|
334 | + // date filters are removed |
|
335 | + if ($line["filter_type"] != 5) { |
|
336 | + $filter = array(); |
|
343 | 337 | |
344 | - $filter["enabled"] = $line["enabled"] ? "on" : "off"; |
|
345 | - $filter["rule"] = array( |
|
346 | - json_encode(array( |
|
347 | - "reg_exp" => $line["reg_exp"], |
|
348 | - "feed_id" => $feed_id, |
|
349 | - "filter_type" => $line["filter_type"]))); |
|
338 | + if (sql_bool_to_bool($line["cat_filter"])) { |
|
339 | + $feed_id = "CAT:" . (int)$line["cat_id"]; |
|
340 | + } else { |
|
341 | + $feed_id = (int)$line["feed_id"]; |
|
342 | + } |
|
350 | 343 | |
351 | - $filter["action"] = array( |
|
352 | - json_encode(array( |
|
353 | - "action_id" => $line["action_id"], |
|
354 | - "action_param_label" => $line["action_param"], |
|
355 | - "action_param" => $line["action_param"]))); |
|
344 | + $filter["enabled"] = $line["enabled"] ? "on" : "off"; |
|
345 | + $filter["rule"] = array( |
|
346 | + json_encode(array( |
|
347 | + "reg_exp" => $line["reg_exp"], |
|
348 | + "feed_id" => $feed_id, |
|
349 | + "filter_type" => $line["filter_type"]))); |
|
356 | 350 | |
357 | - // Oh god it's full of hacks |
|
351 | + $filter["action"] = array( |
|
352 | + json_encode(array( |
|
353 | + "action_id" => $line["action_id"], |
|
354 | + "action_param_label" => $line["action_param"], |
|
355 | + "action_param" => $line["action_param"]))); |
|
358 | 356 | |
359 | - $_REQUEST = $filter; |
|
360 | - $_SESSION["uid"] = $owner_uid; |
|
357 | + // Oh god it's full of hacks |
|
361 | 358 | |
362 | - $filters = new Pref_Filters($_REQUEST); |
|
363 | - $filters->add(); |
|
364 | - } |
|
365 | - } |
|
359 | + $_REQUEST = $filter; |
|
360 | + $_SESSION["uid"] = $owner_uid; |
|
366 | 361 | |
367 | - } |
|
362 | + $filters = new Pref_Filters($_REQUEST); |
|
363 | + $filters->add(); |
|
364 | + } |
|
365 | + } |
|
368 | 366 | |
369 | - if (isset($options["update-schema"])) { |
|
370 | - Debug::log("Checking for updates (" . DB_TYPE . ")..."); |
|
367 | + } |
|
368 | + |
|
369 | + if (isset($options["update-schema"])) { |
|
370 | + Debug::log("Checking for updates (" . DB_TYPE . ")..."); |
|
371 | 371 | |
372 | - $updater = new DbUpdater(DB_TYPE, SCHEMA_VERSION); |
|
372 | + $updater = new DbUpdater(DB_TYPE, SCHEMA_VERSION); |
|
373 | 373 | |
374 | - if ($updater->isUpdateRequired()) { |
|
375 | - Debug::log("Schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION); |
|
374 | + if ($updater->isUpdateRequired()) { |
|
375 | + Debug::log("Schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION); |
|
376 | 376 | |
377 | - if (DB_TYPE == "mysql") |
|
378 | - Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". |
|
379 | - "Errors may put it in an inconsistent state requiring manual rollback.\nBACKUP YOUR DATABASE BEFORE CONTINUING."); |
|
380 | - else |
|
381 | - Debug::log("WARNING: please backup your database before continuing."); |
|
377 | + if (DB_TYPE == "mysql") |
|
378 | + Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". |
|
379 | + "Errors may put it in an inconsistent state requiring manual rollback.\nBACKUP YOUR DATABASE BEFORE CONTINUING."); |
|
380 | + else |
|
381 | + Debug::log("WARNING: please backup your database before continuing."); |
|
382 | 382 | |
383 | - Debug::log("Type 'yes' to continue."); |
|
383 | + Debug::log("Type 'yes' to continue."); |
|
384 | 384 | |
385 | - if (read_stdin() != 'yes') |
|
386 | - exit; |
|
385 | + if (read_stdin() != 'yes') |
|
386 | + exit; |
|
387 | 387 | |
388 | - Debug::log("Performing updates to version " . SCHEMA_VERSION); |
|
388 | + Debug::log("Performing updates to version " . SCHEMA_VERSION); |
|
389 | 389 | |
390 | - for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) { |
|
391 | - Debug::log("* Updating to version $i..."); |
|
390 | + for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) { |
|
391 | + Debug::log("* Updating to version $i..."); |
|
392 | 392 | |
393 | - $result = $updater->performUpdateTo($i, false); |
|
393 | + $result = $updater->performUpdateTo($i, false); |
|
394 | 394 | |
395 | - if ($result) { |
|
396 | - Debug::log("* Completed."); |
|
397 | - } else { |
|
398 | - Debug::log("One of the updates failed. Either retry the process or perform updates manually."); |
|
399 | - return; |
|
400 | - } |
|
395 | + if ($result) { |
|
396 | + Debug::log("* Completed."); |
|
397 | + } else { |
|
398 | + Debug::log("One of the updates failed. Either retry the process or perform updates manually."); |
|
399 | + return; |
|
400 | + } |
|
401 | 401 | |
402 | - } |
|
403 | - } else { |
|
404 | - Debug::log("Update not required."); |
|
405 | - } |
|
402 | + } |
|
403 | + } else { |
|
404 | + Debug::log("Update not required."); |
|
405 | + } |
|
406 | 406 | |
407 | - } |
|
407 | + } |
|
408 | 408 | |
409 | - if (isset($options["gen-search-idx"])) { |
|
410 | - echo "Generating search index (stemming set to English)...\n"; |
|
409 | + if (isset($options["gen-search-idx"])) { |
|
410 | + echo "Generating search index (stemming set to English)...\n"; |
|
411 | 411 | |
412 | - $res = $pdo->query("SELECT COUNT(id) AS count FROM ttrss_entries WHERE tsvector_combined IS NULL"); |
|
413 | - $row = $res->fetch(); |
|
414 | - $count = $row['count']; |
|
412 | + $res = $pdo->query("SELECT COUNT(id) AS count FROM ttrss_entries WHERE tsvector_combined IS NULL"); |
|
413 | + $row = $res->fetch(); |
|
414 | + $count = $row['count']; |
|
415 | 415 | |
416 | - print "Articles to process: $count.\n"; |
|
416 | + print "Articles to process: $count.\n"; |
|
417 | 417 | |
418 | - $limit = 500; |
|
419 | - $processed = 0; |
|
418 | + $limit = 500; |
|
419 | + $processed = 0; |
|
420 | 420 | |
421 | - $sth = $pdo->prepare("SELECT id, title, content FROM ttrss_entries WHERE |
|
421 | + $sth = $pdo->prepare("SELECT id, title, content FROM ttrss_entries WHERE |
|
422 | 422 | tsvector_combined IS NULL ORDER BY id LIMIT ?"); |
423 | - $sth->execute([$limit]); |
|
423 | + $sth->execute([$limit]); |
|
424 | 424 | |
425 | - $usth = $pdo->prepare("UPDATE ttrss_entries |
|
425 | + $usth = $pdo->prepare("UPDATE ttrss_entries |
|
426 | 426 | SET tsvector_combined = to_tsvector('english', ?) WHERE id = ?"); |
427 | 427 | |
428 | - while (true) { |
|
428 | + while (true) { |
|
429 | 429 | |
430 | - while ($line = $sth->fetch()) { |
|
431 | - $tsvector_combined = mb_substr(strip_tags($line["title"] . " " . $line["content"]), 0, 1000000); |
|
430 | + while ($line = $sth->fetch()) { |
|
431 | + $tsvector_combined = mb_substr(strip_tags($line["title"] . " " . $line["content"]), 0, 1000000); |
|
432 | 432 | |
433 | - $usth->execute([$tsvector_combined, $line['id']]); |
|
433 | + $usth->execute([$tsvector_combined, $line['id']]); |
|
434 | 434 | |
435 | - $processed++; |
|
436 | - } |
|
435 | + $processed++; |
|
436 | + } |
|
437 | 437 | |
438 | - print "Processed $processed articles...\n"; |
|
438 | + print "Processed $processed articles...\n"; |
|
439 | 439 | |
440 | - if ($processed < $limit) { |
|
441 | - echo "All done.\n"; |
|
442 | - break; |
|
443 | - } |
|
444 | - } |
|
445 | - } |
|
440 | + if ($processed < $limit) { |
|
441 | + echo "All done.\n"; |
|
442 | + break; |
|
443 | + } |
|
444 | + } |
|
445 | + } |
|
446 | 446 | |
447 | - if (isset($options["list-plugins"])) { |
|
448 | - $tmppluginhost = new PluginHost(); |
|
449 | - $tmppluginhost->load_all($tmppluginhost::KIND_ALL, false); |
|
450 | - $enabled = array_map("trim", explode(",", PLUGINS)); |
|
447 | + if (isset($options["list-plugins"])) { |
|
448 | + $tmppluginhost = new PluginHost(); |
|
449 | + $tmppluginhost->load_all($tmppluginhost::KIND_ALL, false); |
|
450 | + $enabled = array_map("trim", explode(",", PLUGINS)); |
|
451 | 451 | |
452 | - echo "List of all available plugins:\n"; |
|
452 | + echo "List of all available plugins:\n"; |
|
453 | 453 | |
454 | - foreach ($tmppluginhost->get_plugins() as $name => $plugin) { |
|
455 | - $about = $plugin->about(); |
|
454 | + foreach ($tmppluginhost->get_plugins() as $name => $plugin) { |
|
455 | + $about = $plugin->about(); |
|
456 | 456 | |
457 | - $status = $about[3] ? "system" : "user"; |
|
457 | + $status = $about[3] ? "system" : "user"; |
|
458 | 458 | |
459 | - if (in_array($name, $enabled)) $name .= "*"; |
|
459 | + if (in_array($name, $enabled)) $name .= "*"; |
|
460 | 460 | |
461 | - printf("%-50s %-10s v%.2f (by %s)\n%s\n\n", |
|
462 | - $name, $status, $about[0], $about[2], $about[1]); |
|
463 | - } |
|
461 | + printf("%-50s %-10s v%.2f (by %s)\n%s\n\n", |
|
462 | + $name, $status, $about[0], $about[2], $about[1]); |
|
463 | + } |
|
464 | 464 | |
465 | - echo "Plugins marked by * are currently enabled for all users.\n"; |
|
465 | + echo "Plugins marked by * are currently enabled for all users.\n"; |
|
466 | 466 | |
467 | - } |
|
467 | + } |
|
468 | 468 | |
469 | - if (isset($options["debug-feed"])) { |
|
470 | - $feed = $options["debug-feed"]; |
|
469 | + if (isset($options["debug-feed"])) { |
|
470 | + $feed = $options["debug-feed"]; |
|
471 | 471 | |
472 | - if (isset($options["force-refetch"])) $_REQUEST["force_refetch"] = true; |
|
473 | - if (isset($options["force-rehash"])) $_REQUEST["force_rehash"] = true; |
|
472 | + if (isset($options["force-refetch"])) $_REQUEST["force_refetch"] = true; |
|
473 | + if (isset($options["force-rehash"])) $_REQUEST["force_rehash"] = true; |
|
474 | 474 | |
475 | - Debug::set_loglevel(Debug::$LOG_EXTENDED); |
|
475 | + Debug::set_loglevel(Debug::$LOG_EXTENDED); |
|
476 | 476 | |
477 | - $rc = RSSUtils::update_rss_feed($feed) != false ? 0 : 1; |
|
477 | + $rc = RSSUtils::update_rss_feed($feed) != false ? 0 : 1; |
|
478 | 478 | |
479 | - exit($rc); |
|
480 | - } |
|
479 | + exit($rc); |
|
480 | + } |
|
481 | 481 | |
482 | - if (isset($options["send-digests"])) { |
|
483 | - Digest::send_headlines_digests(); |
|
484 | - } |
|
482 | + if (isset($options["send-digests"])) { |
|
483 | + Digest::send_headlines_digests(); |
|
484 | + } |
|
485 | 485 | |
486 | - PluginHost::getInstance()->run_commands($options); |
|
486 | + PluginHost::getInstance()->run_commands($options); |
|
487 | 487 | |
488 | - if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) |
|
489 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
490 | - fclose($lock_handle); |
|
491 | - unlink(LOCK_DIRECTORY . "/$lock_filename"); |
|
488 | + if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) |
|
489 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
490 | + fclose($lock_handle); |
|
491 | + unlink(LOCK_DIRECTORY . "/$lock_filename"); |
@@ -1,44 +1,44 @@ |
||
1 | 1 | <?php |
2 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
3 | - get_include_path()); |
|
2 | + set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
3 | + get_include_path()); |
|
4 | 4 | |
5 | - require_once "autoload.php"; |
|
6 | - require_once "sessions.php"; |
|
7 | - require_once "functions.php"; |
|
8 | - require_once "sanity_check.php"; |
|
9 | - require_once "config.php"; |
|
10 | - require_once "db.php"; |
|
11 | - require_once "db-prefs.php"; |
|
5 | + require_once "autoload.php"; |
|
6 | + require_once "sessions.php"; |
|
7 | + require_once "functions.php"; |
|
8 | + require_once "sanity_check.php"; |
|
9 | + require_once "config.php"; |
|
10 | + require_once "db.php"; |
|
11 | + require_once "db-prefs.php"; |
|
12 | 12 | |
13 | - startup_gettext(); |
|
13 | + startup_gettext(); |
|
14 | 14 | |
15 | - $script_started = microtime(true); |
|
15 | + $script_started = microtime(true); |
|
16 | 16 | |
17 | - if (!init_plugins()) return; |
|
17 | + if (!init_plugins()) return; |
|
18 | 18 | |
19 | - if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { |
|
20 | - ob_start("ob_gzhandler"); |
|
21 | - } |
|
19 | + if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { |
|
20 | + ob_start("ob_gzhandler"); |
|
21 | + } |
|
22 | 22 | |
23 | - $method = $_REQUEST["op"]; |
|
23 | + $method = $_REQUEST["op"]; |
|
24 | 24 | |
25 | - $override = PluginHost::getInstance()->lookup_handler("public", $method); |
|
25 | + $override = PluginHost::getInstance()->lookup_handler("public", $method); |
|
26 | 26 | |
27 | - if ($override) { |
|
28 | - $handler = $override; |
|
29 | - } else { |
|
30 | - $handler = new Handler_Public($_REQUEST); |
|
31 | - } |
|
27 | + if ($override) { |
|
28 | + $handler = $override; |
|
29 | + } else { |
|
30 | + $handler = new Handler_Public($_REQUEST); |
|
31 | + } |
|
32 | 32 | |
33 | - if (implements_interface($handler, "IHandler") && $handler->before($method)) { |
|
34 | - if ($method && method_exists($handler, $method)) { |
|
35 | - $handler->$method(); |
|
36 | - } else if (method_exists($handler, 'index')) { |
|
37 | - $handler->index(); |
|
38 | - } |
|
39 | - $handler->after(); |
|
40 | - return; |
|
41 | - } |
|
33 | + if (implements_interface($handler, "IHandler") && $handler->before($method)) { |
|
34 | + if ($method && method_exists($handler, $method)) { |
|
35 | + $handler->$method(); |
|
36 | + } else if (method_exists($handler, 'index')) { |
|
37 | + $handler->index(); |
|
38 | + } |
|
39 | + $handler->after(); |
|
40 | + return; |
|
41 | + } |
|
42 | 42 | |
43 | - header("Content-Type: text/plain"); |
|
44 | - print error_json(13); |
|
43 | + header("Content-Type: text/plain"); |
|
44 | + print error_json(13); |
@@ -1,93 +1,93 @@ discard block |
||
1 | 1 | <?php |
2 | - // This file uses two additional include files: |
|
3 | - // |
|
4 | - // 1) templates/register_notice.txt - displayed above the registration form |
|
5 | - // 2) register_expire_do.php - contains user expiration queries when necessary |
|
2 | + // This file uses two additional include files: |
|
3 | + // |
|
4 | + // 1) templates/register_notice.txt - displayed above the registration form |
|
5 | + // 2) register_expire_do.php - contains user expiration queries when necessary |
|
6 | 6 | |
7 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
8 | - get_include_path()); |
|
7 | + set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
8 | + get_include_path()); |
|
9 | 9 | |
10 | - require_once "autoload.php"; |
|
11 | - require_once "functions.php"; |
|
12 | - require_once "sessions.php"; |
|
13 | - require_once "sanity_check.php"; |
|
14 | - require_once "config.php"; |
|
15 | - require_once "db.php"; |
|
10 | + require_once "autoload.php"; |
|
11 | + require_once "functions.php"; |
|
12 | + require_once "sessions.php"; |
|
13 | + require_once "sanity_check.php"; |
|
14 | + require_once "config.php"; |
|
15 | + require_once "db.php"; |
|
16 | 16 | |
17 | - startup_gettext(); |
|
17 | + startup_gettext(); |
|
18 | 18 | |
19 | - $action = $_REQUEST["action"]; |
|
19 | + $action = $_REQUEST["action"]; |
|
20 | 20 | |
21 | - if (!init_plugins()) return; |
|
21 | + if (!init_plugins()) return; |
|
22 | 22 | |
23 | - if ($_REQUEST["format"] == "feed") { |
|
24 | - header("Content-Type: text/xml"); |
|
23 | + if ($_REQUEST["format"] == "feed") { |
|
24 | + header("Content-Type: text/xml"); |
|
25 | 25 | |
26 | - print '<?xml version="1.0" encoding="utf-8"?>'; |
|
27 | - print "<feed xmlns=\"http://www.w3.org/2005/Atom\"> |
|
26 | + print '<?xml version="1.0" encoding="utf-8"?>'; |
|
27 | + print "<feed xmlns=\"http://www.w3.org/2005/Atom\"> |
|
28 | 28 | <id>".htmlspecialchars(SELF_URL_PATH . "/register.php")."</id> |
29 | 29 | <title>Tiny Tiny RSS registration slots</title> |
30 | 30 | <link rel=\"self\" href=\"".htmlspecialchars(SELF_URL_PATH . "/register.php?format=feed")."\"/> |
31 | 31 | <link rel=\"alternate\" href=\"".htmlspecialchars(SELF_URL_PATH)."\"/>"; |
32 | 32 | |
33 | - if (ENABLE_REGISTRATION) { |
|
34 | - $result = db_query( "SELECT COUNT(*) AS cu FROM ttrss_users"); |
|
35 | - $num_users = db_fetch_result($result, 0, "cu"); |
|
33 | + if (ENABLE_REGISTRATION) { |
|
34 | + $result = db_query( "SELECT COUNT(*) AS cu FROM ttrss_users"); |
|
35 | + $num_users = db_fetch_result($result, 0, "cu"); |
|
36 | 36 | |
37 | - $num_users = REG_MAX_USERS - $num_users; |
|
38 | - if ($num_users < 0) $num_users = 0; |
|
39 | - $reg_suffix = "enabled"; |
|
40 | - } else { |
|
41 | - $num_users = 0; |
|
42 | - $reg_suffix = "disabled"; |
|
43 | - } |
|
37 | + $num_users = REG_MAX_USERS - $num_users; |
|
38 | + if ($num_users < 0) $num_users = 0; |
|
39 | + $reg_suffix = "enabled"; |
|
40 | + } else { |
|
41 | + $num_users = 0; |
|
42 | + $reg_suffix = "disabled"; |
|
43 | + } |
|
44 | 44 | |
45 | - print "<entry> |
|
45 | + print "<entry> |
|
46 | 46 | <id>".htmlspecialchars(SELF_URL_PATH)."/register.php?$num_users"."</id> |
47 | 47 | <link rel=\"alternate\" href=\"".htmlspecialchars(SELF_URL_PATH . "/register.php")."\"/>"; |
48 | 48 | |
49 | - print "<title>$num_users slots are currently available, registration $reg_suffix</title>"; |
|
50 | - print "<summary>$num_users slots are currently available, registration $reg_suffix</summary>"; |
|
49 | + print "<title>$num_users slots are currently available, registration $reg_suffix</title>"; |
|
50 | + print "<summary>$num_users slots are currently available, registration $reg_suffix</summary>"; |
|
51 | 51 | |
52 | - print "</entry>"; |
|
52 | + print "</entry>"; |
|
53 | 53 | |
54 | - print "</feed>"; |
|
54 | + print "</feed>"; |
|
55 | 55 | |
56 | - return; |
|
57 | - } |
|
56 | + return; |
|
57 | + } |
|
58 | 58 | |
59 | - /* Remove users which didn't login after receiving their registration information */ |
|
59 | + /* Remove users which didn't login after receiving their registration information */ |
|
60 | 60 | |
61 | - if (DB_TYPE == "pgsql") { |
|
62 | - db_query( "DELETE FROM ttrss_users WHERE last_login IS NULL |
|
61 | + if (DB_TYPE == "pgsql") { |
|
62 | + db_query( "DELETE FROM ttrss_users WHERE last_login IS NULL |
|
63 | 63 | AND created < NOW() - INTERVAL '1 day' AND access_level = 0"); |
64 | - } else { |
|
65 | - db_query( "DELETE FROM ttrss_users WHERE last_login IS NULL |
|
64 | + } else { |
|
65 | + db_query( "DELETE FROM ttrss_users WHERE last_login IS NULL |
|
66 | 66 | AND created < DATE_SUB(NOW(), INTERVAL 1 DAY) AND access_level = 0"); |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | - if (file_exists("register_expire_do.php")) { |
|
70 | - require_once "register_expire_do.php"; |
|
71 | - } |
|
69 | + if (file_exists("register_expire_do.php")) { |
|
70 | + require_once "register_expire_do.php"; |
|
71 | + } |
|
72 | 72 | |
73 | - if ($action == "check") { |
|
74 | - header("Content-Type: application/xml"); |
|
73 | + if ($action == "check") { |
|
74 | + header("Content-Type: application/xml"); |
|
75 | 75 | |
76 | - $login = trim(db_escape_string( $_REQUEST['login'])); |
|
76 | + $login = trim(db_escape_string( $_REQUEST['login'])); |
|
77 | 77 | |
78 | - $result = db_query( "SELECT id FROM ttrss_users WHERE |
|
78 | + $result = db_query( "SELECT id FROM ttrss_users WHERE |
|
79 | 79 | LOWER(login) = LOWER('$login')"); |
80 | 80 | |
81 | - $is_registered = db_num_rows($result) > 0; |
|
81 | + $is_registered = db_num_rows($result) > 0; |
|
82 | 82 | |
83 | - print "<result>"; |
|
83 | + print "<result>"; |
|
84 | 84 | |
85 | - printf("%d", $is_registered); |
|
85 | + printf("%d", $is_registered); |
|
86 | 86 | |
87 | - print "</result>"; |
|
87 | + print "</result>"; |
|
88 | 88 | |
89 | - return; |
|
90 | - } |
|
89 | + return; |
|
90 | + } |
|
91 | 91 | ?> |
92 | 92 | <!DOCTYPE html> |
93 | 93 | <html> |
@@ -185,20 +185,20 @@ discard block |
||
185 | 185 | <div class="content"> |
186 | 186 | |
187 | 187 | <?php |
188 | - if (!ENABLE_REGISTRATION) { |
|
189 | - print_error(__("New user registrations are administratively disabled.")); |
|
188 | + if (!ENABLE_REGISTRATION) { |
|
189 | + print_error(__("New user registrations are administratively disabled.")); |
|
190 | 190 | |
191 | - print "<p><form method=\"GET\" action=\"backend.php\"> |
|
191 | + print "<p><form method=\"GET\" action=\"backend.php\"> |
|
192 | 192 | <input type=\"hidden\" name=\"op\" value=\"logout\"> |
193 | 193 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> |
194 | 194 | </form>"; |
195 | - return; |
|
196 | - } |
|
195 | + return; |
|
196 | + } |
|
197 | 197 | ?> |
198 | 198 | |
199 | 199 | <?php if (REG_MAX_USERS > 0) { |
200 | - $result = db_query( "SELECT COUNT(*) AS cu FROM ttrss_users"); |
|
201 | - $num_users = db_fetch_result($result, 0, "cu"); |
|
200 | + $result = db_query( "SELECT COUNT(*) AS cu FROM ttrss_users"); |
|
201 | + $num_users = db_fetch_result($result, 0, "cu"); |
|
202 | 202 | } ?> |
203 | 203 | |
204 | 204 | <?php if (!REG_MAX_USERS || $num_users < REG_MAX_USERS) { ?> |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | <!-- If you have any rules or ToS you'd like to display, enter them here --> |
207 | 207 | |
208 | 208 | <?php if (file_exists("templates/register_notice.txt")) { |
209 | - require_once "templates/register_notice.txt"; |
|
210 | - } ?> |
|
209 | + require_once "templates/register_notice.txt"; |
|
210 | + } ?> |
|
211 | 211 | |
212 | 212 | <?php if (!$action) { ?> |
213 | 213 | |
@@ -241,110 +241,110 @@ discard block |
||
241 | 241 | <?php } else if ($action == "do_register") { ?> |
242 | 242 | |
243 | 243 | <?php |
244 | - $login = mb_strtolower(trim(db_escape_string( $_REQUEST["login"]))); |
|
245 | - $email = trim(db_escape_string( $_REQUEST["email"])); |
|
246 | - $test = trim(db_escape_string( $_REQUEST["turing_test"])); |
|
244 | + $login = mb_strtolower(trim(db_escape_string( $_REQUEST["login"]))); |
|
245 | + $email = trim(db_escape_string( $_REQUEST["email"])); |
|
246 | + $test = trim(db_escape_string( $_REQUEST["turing_test"])); |
|
247 | 247 | |
248 | - if (!$login || !$email || !$test) { |
|
249 | - print_error(__("Your registration information is incomplete.")); |
|
250 | - print "<p><form method=\"GET\" action=\"index.php\"> |
|
248 | + if (!$login || !$email || !$test) { |
|
249 | + print_error(__("Your registration information is incomplete.")); |
|
250 | + print "<p><form method=\"GET\" action=\"index.php\"> |
|
251 | 251 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> |
252 | 252 | </form>"; |
253 | - return; |
|
254 | - } |
|
253 | + return; |
|
254 | + } |
|
255 | 255 | |
256 | - if ($test == "four" || $test == "4") { |
|
256 | + if ($test == "four" || $test == "4") { |
|
257 | 257 | |
258 | - $result = db_query( "SELECT id FROM ttrss_users WHERE |
|
258 | + $result = db_query( "SELECT id FROM ttrss_users WHERE |
|
259 | 259 | login = '$login'"); |
260 | 260 | |
261 | - $is_registered = db_num_rows($result) > 0; |
|
261 | + $is_registered = db_num_rows($result) > 0; |
|
262 | 262 | |
263 | - if ($is_registered) { |
|
264 | - print_error(__('Sorry, this username is already taken.')); |
|
265 | - print "<p><form method=\"GET\" action=\"index.php\"> |
|
263 | + if ($is_registered) { |
|
264 | + print_error(__('Sorry, this username is already taken.')); |
|
265 | + print "<p><form method=\"GET\" action=\"index.php\"> |
|
266 | 266 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> |
267 | 267 | </form>"; |
268 | - } else { |
|
268 | + } else { |
|
269 | 269 | |
270 | - $password = make_password(); |
|
270 | + $password = make_password(); |
|
271 | 271 | |
272 | - $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
|
273 | - $pwd_hash = encrypt_password($password, $salt, true); |
|
272 | + $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
|
273 | + $pwd_hash = encrypt_password($password, $salt, true); |
|
274 | 274 | |
275 | - db_query( "INSERT INTO ttrss_users |
|
275 | + db_query( "INSERT INTO ttrss_users |
|
276 | 276 | (login,pwd_hash,access_level,last_login, email, created, salt) |
277 | 277 | VALUES ('$login', '$pwd_hash', 0, null, '$email', NOW(), '$salt')"); |
278 | 278 | |
279 | - $result = db_query( "SELECT id FROM ttrss_users WHERE |
|
279 | + $result = db_query( "SELECT id FROM ttrss_users WHERE |
|
280 | 280 | login = '$login' AND pwd_hash = '$pwd_hash'"); |
281 | 281 | |
282 | - if (db_num_rows($result) != 1) { |
|
283 | - print_error(__('Registration failed.')); |
|
284 | - print "<p><form method=\"GET\" action=\"index.php\"> |
|
282 | + if (db_num_rows($result) != 1) { |
|
283 | + print_error(__('Registration failed.')); |
|
284 | + print "<p><form method=\"GET\" action=\"index.php\"> |
|
285 | 285 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> |
286 | 286 | </form>"; |
287 | - } else { |
|
288 | - |
|
289 | - $new_uid = db_fetch_result($result, 0, "id"); |
|
290 | - |
|
291 | - initialize_user( $new_uid); |
|
292 | - |
|
293 | - $reg_text = "Hi!\n". |
|
294 | - "\n". |
|
295 | - "You are receiving this message, because you (or somebody else) have opened\n". |
|
296 | - "an account at Tiny Tiny RSS.\n". |
|
297 | - "\n". |
|
298 | - "Your login information is as follows:\n". |
|
299 | - "\n". |
|
300 | - "Login: $login\n". |
|
301 | - "Password: $password\n". |
|
302 | - "\n". |
|
303 | - "Don't forget to login at least once to your new account, otherwise\n". |
|
304 | - "it will be deleted in 24 hours.\n". |
|
305 | - "\n". |
|
306 | - "If that wasn't you, just ignore this message. Thanks."; |
|
307 | - |
|
308 | - $mailer = new Mailer(); |
|
309 | - $rc = $mailer->mail(["to_address" => $email, |
|
310 | - "subject" => "Registration information for Tiny Tiny RSS", |
|
311 | - "message" => $reg_text]); |
|
312 | - |
|
313 | - if (!$rc) print_error($mailer->error()); |
|
314 | - |
|
315 | - $reg_text = "Hi!\n". |
|
316 | - "\n". |
|
317 | - "New user had registered at your Tiny Tiny RSS installation.\n". |
|
318 | - "\n". |
|
319 | - "Login: $login\n". |
|
320 | - "Email: $email\n"; |
|
321 | - |
|
322 | - $mailer = new Mailer(); |
|
323 | - $rc = $mailer->mail(["to_address" => REG_NOTIFY_ADDRESS, |
|
324 | - "subject" => "Registration notice for Tiny Tiny RSS", |
|
325 | - "message" => $reg_text]); |
|
326 | - |
|
327 | - if (!$rc) print_error($mailer->error()); |
|
328 | - |
|
329 | - print_notice(__("Account created successfully.")); |
|
330 | - |
|
331 | - print "<p><form method=\"GET\" action=\"index.php\"> |
|
287 | + } else { |
|
288 | + |
|
289 | + $new_uid = db_fetch_result($result, 0, "id"); |
|
290 | + |
|
291 | + initialize_user( $new_uid); |
|
292 | + |
|
293 | + $reg_text = "Hi!\n". |
|
294 | + "\n". |
|
295 | + "You are receiving this message, because you (or somebody else) have opened\n". |
|
296 | + "an account at Tiny Tiny RSS.\n". |
|
297 | + "\n". |
|
298 | + "Your login information is as follows:\n". |
|
299 | + "\n". |
|
300 | + "Login: $login\n". |
|
301 | + "Password: $password\n". |
|
302 | + "\n". |
|
303 | + "Don't forget to login at least once to your new account, otherwise\n". |
|
304 | + "it will be deleted in 24 hours.\n". |
|
305 | + "\n". |
|
306 | + "If that wasn't you, just ignore this message. Thanks."; |
|
307 | + |
|
308 | + $mailer = new Mailer(); |
|
309 | + $rc = $mailer->mail(["to_address" => $email, |
|
310 | + "subject" => "Registration information for Tiny Tiny RSS", |
|
311 | + "message" => $reg_text]); |
|
312 | + |
|
313 | + if (!$rc) print_error($mailer->error()); |
|
314 | + |
|
315 | + $reg_text = "Hi!\n". |
|
316 | + "\n". |
|
317 | + "New user had registered at your Tiny Tiny RSS installation.\n". |
|
318 | + "\n". |
|
319 | + "Login: $login\n". |
|
320 | + "Email: $email\n"; |
|
321 | + |
|
322 | + $mailer = new Mailer(); |
|
323 | + $rc = $mailer->mail(["to_address" => REG_NOTIFY_ADDRESS, |
|
324 | + "subject" => "Registration notice for Tiny Tiny RSS", |
|
325 | + "message" => $reg_text]); |
|
326 | + |
|
327 | + if (!$rc) print_error($mailer->error()); |
|
328 | + |
|
329 | + print_notice(__("Account created successfully.")); |
|
330 | + |
|
331 | + print "<p><form method=\"GET\" action=\"index.php\"> |
|
332 | 332 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> |
333 | 333 | </form>"; |
334 | 334 | |
335 | - } |
|
335 | + } |
|
336 | 336 | |
337 | - } |
|
337 | + } |
|
338 | 338 | |
339 | - } else { |
|
340 | - print_error('Plese check the form again, you have failed the robot test.'); |
|
341 | - print "<p><form method=\"GET\" action=\"index.php\"> |
|
339 | + } else { |
|
340 | + print_error('Plese check the form again, you have failed the robot test.'); |
|
341 | + print "<p><form method=\"GET\" action=\"index.php\"> |
|
342 | 342 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> |
343 | 343 | </form>"; |
344 | 344 | |
345 | - } |
|
346 | - } |
|
347 | - ?> |
|
345 | + } |
|
346 | + } |
|
347 | + ?> |
|
348 | 348 | |
349 | 349 | <?php } else { ?> |
350 | 350 |
@@ -1,35 +1,35 @@ |
||
1 | 1 | <?php |
2 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
3 | - get_include_path()); |
|
2 | + set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
3 | + get_include_path()); |
|
4 | 4 | |
5 | - require_once "autoload.php"; |
|
6 | - require_once "functions.php"; |
|
7 | - require_once "sessions.php"; |
|
8 | - require_once "sanity_check.php"; |
|
9 | - require_once "config.php"; |
|
10 | - require_once "db.php"; |
|
11 | - require_once "db-prefs.php"; |
|
5 | + require_once "autoload.php"; |
|
6 | + require_once "functions.php"; |
|
7 | + require_once "sessions.php"; |
|
8 | + require_once "sanity_check.php"; |
|
9 | + require_once "config.php"; |
|
10 | + require_once "db.php"; |
|
11 | + require_once "db-prefs.php"; |
|
12 | 12 | |
13 | - if (!init_plugins()) return; |
|
13 | + if (!init_plugins()) return; |
|
14 | 14 | |
15 | - $op = $_REQUEST['op']; |
|
15 | + $op = $_REQUEST['op']; |
|
16 | 16 | |
17 | - if ($op == "publish"){ |
|
18 | - $key = $_REQUEST["key"]; |
|
19 | - $pdo = Db::pdo(); |
|
17 | + if ($op == "publish"){ |
|
18 | + $key = $_REQUEST["key"]; |
|
19 | + $pdo = Db::pdo(); |
|
20 | 20 | |
21 | - $sth = $pdo->prepare( "SELECT owner_uid |
|
21 | + $sth = $pdo->prepare( "SELECT owner_uid |
|
22 | 22 | FROM ttrss_access_keys WHERE |
23 | 23 | access_key = ? AND feed_id = 'OPML:Publish'"); |
24 | - $sth->execute([$key]); |
|
24 | + $sth->execute([$key]); |
|
25 | 25 | |
26 | - if ($row = $sth->fetch()) { |
|
27 | - $owner_uid = $row['owner_uid']; |
|
26 | + if ($row = $sth->fetch()) { |
|
27 | + $owner_uid = $row['owner_uid']; |
|
28 | 28 | |
29 | - $opml = new Opml($_REQUEST); |
|
30 | - $opml->opml_export("", $owner_uid, true, false); |
|
29 | + $opml = new Opml($_REQUEST); |
|
30 | + $opml->opml_export("", $owner_uid, true, false); |
|
31 | 31 | |
32 | - } else { |
|
33 | - print "<error>User not found</error>"; |
|
34 | - } |
|
35 | - } |
|
32 | + } else { |
|
33 | + print "<error>User not found</error>"; |
|
34 | + } |
|
35 | + } |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php |
2 | - function stylesheet_tag($filename, $id = false) { |
|
3 | - $timestamp = filemtime($filename); |
|
2 | + function stylesheet_tag($filename, $id = false) { |
|
3 | + $timestamp = filemtime($filename); |
|
4 | 4 | |
5 | - $id_part = $id ? "id=\"$id\"" : ""; |
|
5 | + $id_part = $id ? "id=\"$id\"" : ""; |
|
6 | 6 | |
7 | - return "<link rel=\"stylesheet\" $id_part type=\"text/css\" href=\"$filename?$timestamp\"/>\n"; |
|
8 | - } |
|
7 | + return "<link rel=\"stylesheet\" $id_part type=\"text/css\" href=\"$filename?$timestamp\"/>\n"; |
|
8 | + } |
|
9 | 9 | |
10 | - function javascript_tag($filename) { |
|
11 | - $query = ""; |
|
10 | + function javascript_tag($filename) { |
|
11 | + $query = ""; |
|
12 | 12 | |
13 | - if (!(strpos($filename, "?") === FALSE)) { |
|
14 | - $query = substr($filename, strpos($filename, "?")+1); |
|
15 | - $filename = substr($filename, 0, strpos($filename, "?")); |
|
16 | - } |
|
13 | + if (!(strpos($filename, "?") === FALSE)) { |
|
14 | + $query = substr($filename, strpos($filename, "?")+1); |
|
15 | + $filename = substr($filename, 0, strpos($filename, "?")); |
|
16 | + } |
|
17 | 17 | |
18 | - $timestamp = filemtime($filename); |
|
18 | + $timestamp = filemtime($filename); |
|
19 | 19 | |
20 | - if ($query) $timestamp .= "&$query"; |
|
20 | + if ($query) $timestamp .= "&$query"; |
|
21 | 21 | |
22 | - return "<script type=\"text/javascript\" charset=\"utf-8\" src=\"$filename?$timestamp\"></script>\n"; |
|
23 | - } |
|
22 | + return "<script type=\"text/javascript\" charset=\"utf-8\" src=\"$filename?$timestamp\"></script>\n"; |
|
23 | + } |
|
24 | 24 | ?> |
25 | 25 | <!DOCTYPE html> |
26 | 26 | <html> |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | textarea { font-size : 12px; } |
32 | 32 | </style> |
33 | 33 | <?php |
34 | - echo stylesheet_tag("../css/default.css"); |
|
35 | - echo javascript_tag("../lib/prototype.js"); |
|
36 | - echo javascript_tag("../lib/dojo/dojo.js"); |
|
37 | - echo javascript_tag("../lib/dojo/tt-rss-layer.js"); |
|
38 | - ?> |
|
34 | + echo stylesheet_tag("../css/default.css"); |
|
35 | + echo javascript_tag("../lib/prototype.js"); |
|
36 | + echo javascript_tag("../lib/dojo/dojo.js"); |
|
37 | + echo javascript_tag("../lib/dojo/tt-rss-layer.js"); |
|
38 | + ?> |
|
39 | 39 | </head> |
40 | 40 | <body class="flat ttrss_utility installer"> |
41 | 41 | |
@@ -50,149 +50,149 @@ discard block |
||
50 | 50 | |
51 | 51 | <?php |
52 | 52 | |
53 | - // could be needed because of existing config.php |
|
54 | - function define_default($param, $value) { |
|
55 | - // |
|
56 | - } |
|
53 | + // could be needed because of existing config.php |
|
54 | + function define_default($param, $value) { |
|
55 | + // |
|
56 | + } |
|
57 | 57 | |
58 | - function make_password($length = 12) { |
|
59 | - $password = ""; |
|
60 | - $possible = "0123456789abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ*%+^"; |
|
58 | + function make_password($length = 12) { |
|
59 | + $password = ""; |
|
60 | + $possible = "0123456789abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ*%+^"; |
|
61 | 61 | |
62 | - $i = 0; |
|
62 | + $i = 0; |
|
63 | 63 | |
64 | - while ($i < $length) { |
|
64 | + while ($i < $length) { |
|
65 | 65 | |
66 | - try { |
|
67 | - $idx = function_exists("random_int") ? random_int(0, strlen($possible) - 1) : mt_rand(0, strlen($possible) - 1); |
|
68 | - } catch (Exception $e) { |
|
69 | - $idx = mt_rand(0, strlen($possible) - 1); |
|
70 | - } |
|
66 | + try { |
|
67 | + $idx = function_exists("random_int") ? random_int(0, strlen($possible) - 1) : mt_rand(0, strlen($possible) - 1); |
|
68 | + } catch (Exception $e) { |
|
69 | + $idx = mt_rand(0, strlen($possible) - 1); |
|
70 | + } |
|
71 | 71 | |
72 | - $char = substr($possible, $idx, 1); |
|
72 | + $char = substr($possible, $idx, 1); |
|
73 | 73 | |
74 | - if (!strstr($password, $char)) { |
|
75 | - $password .= $char; |
|
76 | - $i++; |
|
77 | - } |
|
78 | - } |
|
74 | + if (!strstr($password, $char)) { |
|
75 | + $password .= $char; |
|
76 | + $i++; |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - return $password; |
|
81 | - } |
|
80 | + return $password; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - function sanity_check($db_type) { |
|
85 | - $errors = array(); |
|
84 | + function sanity_check($db_type) { |
|
85 | + $errors = array(); |
|
86 | 86 | |
87 | - if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
|
88 | - array_push($errors, "PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . "."); |
|
89 | - } |
|
87 | + if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
|
88 | + array_push($errors, "PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . "."); |
|
89 | + } |
|
90 | 90 | |
91 | - if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) { |
|
92 | - array_push($errors, "PHP configuration option allow_url_fopen is disabled, and CURL functions are not present. Either enable allow_url_fopen or install PHP extension for CURL."); |
|
93 | - } |
|
91 | + if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) { |
|
92 | + array_push($errors, "PHP configuration option allow_url_fopen is disabled, and CURL functions are not present. Either enable allow_url_fopen or install PHP extension for CURL."); |
|
93 | + } |
|
94 | 94 | |
95 | - if (!function_exists("json_encode")) { |
|
96 | - array_push($errors, "PHP support for JSON is required, but was not found."); |
|
97 | - } |
|
95 | + if (!function_exists("json_encode")) { |
|
96 | + array_push($errors, "PHP support for JSON is required, but was not found."); |
|
97 | + } |
|
98 | 98 | |
99 | - if (!class_exists("PDO")) { |
|
100 | - array_push($errors, "PHP support for PDO is required but was not found."); |
|
101 | - } |
|
99 | + if (!class_exists("PDO")) { |
|
100 | + array_push($errors, "PHP support for PDO is required but was not found."); |
|
101 | + } |
|
102 | 102 | |
103 | - if (!function_exists("mb_strlen")) { |
|
104 | - array_push($errors, "PHP support for mbstring functions is required but was not found."); |
|
105 | - } |
|
103 | + if (!function_exists("mb_strlen")) { |
|
104 | + array_push($errors, "PHP support for mbstring functions is required but was not found."); |
|
105 | + } |
|
106 | 106 | |
107 | - if (!function_exists("hash")) { |
|
108 | - array_push($errors, "PHP support for hash() function is required but was not found."); |
|
109 | - } |
|
107 | + if (!function_exists("hash")) { |
|
108 | + array_push($errors, "PHP support for hash() function is required but was not found."); |
|
109 | + } |
|
110 | 110 | |
111 | - if (!function_exists("iconv")) { |
|
112 | - array_push($errors, "PHP support for iconv is required to handle multiple charsets."); |
|
113 | - } |
|
111 | + if (!function_exists("iconv")) { |
|
112 | + array_push($errors, "PHP support for iconv is required to handle multiple charsets."); |
|
113 | + } |
|
114 | 114 | |
115 | - if (ini_get("safe_mode")) { |
|
116 | - array_push($errors, "PHP safe mode setting is obsolete and not supported by tt-rss."); |
|
117 | - } |
|
115 | + if (ini_get("safe_mode")) { |
|
116 | + array_push($errors, "PHP safe mode setting is obsolete and not supported by tt-rss."); |
|
117 | + } |
|
118 | 118 | |
119 | - if (!class_exists("DOMDocument")) { |
|
120 | - array_push($errors, "PHP support for DOMDocument is required, but was not found."); |
|
121 | - } |
|
119 | + if (!class_exists("DOMDocument")) { |
|
120 | + array_push($errors, "PHP support for DOMDocument is required, but was not found."); |
|
121 | + } |
|
122 | 122 | |
123 | - return $errors; |
|
124 | - } |
|
123 | + return $errors; |
|
124 | + } |
|
125 | 125 | |
126 | - function print_error($msg) { |
|
127 | - print "<div class='alert alert-error'>$msg</div>"; |
|
128 | - } |
|
126 | + function print_error($msg) { |
|
127 | + print "<div class='alert alert-error'>$msg</div>"; |
|
128 | + } |
|
129 | 129 | |
130 | - function print_notice($msg) { |
|
131 | - print "<div class=\"alert alert-info\">$msg</div>"; |
|
132 | - } |
|
130 | + function print_notice($msg) { |
|
131 | + print "<div class=\"alert alert-info\">$msg</div>"; |
|
132 | + } |
|
133 | 133 | |
134 | - function pdo_connect($host, $user, $pass, $db, $type, $port = false) { |
|
134 | + function pdo_connect($host, $user, $pass, $db, $type, $port = false) { |
|
135 | 135 | |
136 | - $db_port = $port ? ';port=' . $port : ''; |
|
137 | - $db_host = $host ? ';host=' . $host : ''; |
|
136 | + $db_port = $port ? ';port=' . $port : ''; |
|
137 | + $db_host = $host ? ';host=' . $host : ''; |
|
138 | 138 | |
139 | - try { |
|
140 | - $pdo = new PDO($type . ':dbname=' . $db . $db_host . $db_port, |
|
141 | - $user, |
|
142 | - $pass); |
|
139 | + try { |
|
140 | + $pdo = new PDO($type . ':dbname=' . $db . $db_host . $db_port, |
|
141 | + $user, |
|
142 | + $pass); |
|
143 | 143 | |
144 | - return $pdo; |
|
145 | - } catch (Exception $e) { |
|
146 | - print "<div class='alert alert-danger'>" . $e->getMessage() . "</div>"; |
|
147 | - return null; |
|
144 | + return $pdo; |
|
145 | + } catch (Exception $e) { |
|
146 | + print "<div class='alert alert-danger'>" . $e->getMessage() . "</div>"; |
|
147 | + return null; |
|
148 | 148 | } |
149 | - } |
|
150 | - |
|
151 | - function make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, |
|
152 | - $DB_PORT, $SELF_URL_PATH) { |
|
153 | - |
|
154 | - $data = explode("\n", file_get_contents("../config.php-dist")); |
|
155 | - |
|
156 | - $rv = ""; |
|
157 | - |
|
158 | - $finished = false; |
|
159 | - |
|
160 | - foreach ($data as $line) { |
|
161 | - if (preg_match("/define\('DB_TYPE'/", $line)) { |
|
162 | - $rv .= "\tdefine('DB_TYPE', '$DB_TYPE');\n"; |
|
163 | - } else if (preg_match("/define\('DB_HOST'/", $line)) { |
|
164 | - $rv .= "\tdefine('DB_HOST', '$DB_HOST');\n"; |
|
165 | - } else if (preg_match("/define\('DB_USER'/", $line)) { |
|
166 | - $rv .= "\tdefine('DB_USER', '$DB_USER');\n"; |
|
167 | - } else if (preg_match("/define\('DB_NAME'/", $line)) { |
|
168 | - $rv .= "\tdefine('DB_NAME', '$DB_NAME');\n"; |
|
169 | - } else if (preg_match("/define\('DB_PASS'/", $line)) { |
|
170 | - $rv .= "\tdefine('DB_PASS', '$DB_PASS');\n"; |
|
171 | - } else if (preg_match("/define\('DB_PORT'/", $line)) { |
|
172 | - $rv .= "\tdefine('DB_PORT', '$DB_PORT');\n"; |
|
173 | - } else if (preg_match("/define\('SELF_URL_PATH'/", $line)) { |
|
174 | - $rv .= "\tdefine('SELF_URL_PATH', '$SELF_URL_PATH');\n"; |
|
175 | - } else if (!$finished) { |
|
176 | - $rv .= "$line\n"; |
|
177 | - } |
|
178 | - |
|
179 | - if (preg_match("/\?\>/", $line)) { |
|
180 | - $finished = true; |
|
181 | - } |
|
182 | - } |
|
183 | - |
|
184 | - return $rv; |
|
185 | - } |
|
186 | - |
|
187 | - function is_server_https() { |
|
188 | - return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'); |
|
189 | - } |
|
190 | - |
|
191 | - function make_self_url_path() { |
|
192 | - $url_path = (is_server_https() ? 'https://' : 'http://') . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
193 | - |
|
194 | - return $url_path; |
|
195 | - } |
|
149 | + } |
|
150 | + |
|
151 | + function make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, |
|
152 | + $DB_PORT, $SELF_URL_PATH) { |
|
153 | + |
|
154 | + $data = explode("\n", file_get_contents("../config.php-dist")); |
|
155 | + |
|
156 | + $rv = ""; |
|
157 | + |
|
158 | + $finished = false; |
|
159 | + |
|
160 | + foreach ($data as $line) { |
|
161 | + if (preg_match("/define\('DB_TYPE'/", $line)) { |
|
162 | + $rv .= "\tdefine('DB_TYPE', '$DB_TYPE');\n"; |
|
163 | + } else if (preg_match("/define\('DB_HOST'/", $line)) { |
|
164 | + $rv .= "\tdefine('DB_HOST', '$DB_HOST');\n"; |
|
165 | + } else if (preg_match("/define\('DB_USER'/", $line)) { |
|
166 | + $rv .= "\tdefine('DB_USER', '$DB_USER');\n"; |
|
167 | + } else if (preg_match("/define\('DB_NAME'/", $line)) { |
|
168 | + $rv .= "\tdefine('DB_NAME', '$DB_NAME');\n"; |
|
169 | + } else if (preg_match("/define\('DB_PASS'/", $line)) { |
|
170 | + $rv .= "\tdefine('DB_PASS', '$DB_PASS');\n"; |
|
171 | + } else if (preg_match("/define\('DB_PORT'/", $line)) { |
|
172 | + $rv .= "\tdefine('DB_PORT', '$DB_PORT');\n"; |
|
173 | + } else if (preg_match("/define\('SELF_URL_PATH'/", $line)) { |
|
174 | + $rv .= "\tdefine('SELF_URL_PATH', '$SELF_URL_PATH');\n"; |
|
175 | + } else if (!$finished) { |
|
176 | + $rv .= "$line\n"; |
|
177 | + } |
|
178 | + |
|
179 | + if (preg_match("/\?\>/", $line)) { |
|
180 | + $finished = true; |
|
181 | + } |
|
182 | + } |
|
183 | + |
|
184 | + return $rv; |
|
185 | + } |
|
186 | + |
|
187 | + function is_server_https() { |
|
188 | + return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'); |
|
189 | + } |
|
190 | + |
|
191 | + function make_self_url_path() { |
|
192 | + $url_path = (is_server_https() ? 'https://' : 'http://') . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
193 | + |
|
194 | + return $url_path; |
|
195 | + } |
|
196 | 196 | |
197 | 197 | ?> |
198 | 198 | |
@@ -202,32 +202,32 @@ discard block |
||
202 | 202 | |
203 | 203 | <?php |
204 | 204 | |
205 | - if (file_exists("../config.php")) { |
|
206 | - require "../config.php"; |
|
205 | + if (file_exists("../config.php")) { |
|
206 | + require "../config.php"; |
|
207 | 207 | |
208 | - if (!defined('_INSTALLER_IGNORE_CONFIG_CHECK')) { |
|
209 | - print_error("Error: config.php already exists in tt-rss directory; aborting."); |
|
208 | + if (!defined('_INSTALLER_IGNORE_CONFIG_CHECK')) { |
|
209 | + print_error("Error: config.php already exists in tt-rss directory; aborting."); |
|
210 | 210 | |
211 | - print "<form method='GET' action='../index.php'> |
|
211 | + print "<form method='GET' action='../index.php'> |
|
212 | 212 | <button type='submit' dojoType='dijit.form.Button' class='alt-primary'>Return to Tiny Tiny RSS</button> |
213 | 213 | </form>"; |
214 | - exit; |
|
215 | - } |
|
216 | - } |
|
217 | - |
|
218 | - @$op = $_REQUEST['op']; |
|
219 | - |
|
220 | - @$DB_HOST = strip_tags($_POST['DB_HOST']); |
|
221 | - @$DB_TYPE = strip_tags($_POST['DB_TYPE']); |
|
222 | - @$DB_USER = strip_tags($_POST['DB_USER']); |
|
223 | - @$DB_NAME = strip_tags($_POST['DB_NAME']); |
|
224 | - @$DB_PASS = strip_tags($_POST['DB_PASS']); |
|
225 | - @$DB_PORT = strip_tags($_POST['DB_PORT']); |
|
226 | - @$SELF_URL_PATH = strip_tags($_POST['SELF_URL_PATH']); |
|
227 | - |
|
228 | - if (!$SELF_URL_PATH) { |
|
229 | - $SELF_URL_PATH = preg_replace("/\/install\/$/", "/", make_self_url_path()); |
|
230 | - } |
|
214 | + exit; |
|
215 | + } |
|
216 | + } |
|
217 | + |
|
218 | + @$op = $_REQUEST['op']; |
|
219 | + |
|
220 | + @$DB_HOST = strip_tags($_POST['DB_HOST']); |
|
221 | + @$DB_TYPE = strip_tags($_POST['DB_TYPE']); |
|
222 | + @$DB_USER = strip_tags($_POST['DB_USER']); |
|
223 | + @$DB_NAME = strip_tags($_POST['DB_NAME']); |
|
224 | + @$DB_PASS = strip_tags($_POST['DB_PASS']); |
|
225 | + @$DB_PORT = strip_tags($_POST['DB_PORT']); |
|
226 | + @$SELF_URL_PATH = strip_tags($_POST['SELF_URL_PATH']); |
|
227 | + |
|
228 | + if (!$SELF_URL_PATH) { |
|
229 | + $SELF_URL_PATH = preg_replace("/\/install\/$/", "/", make_self_url_path()); |
|
230 | + } |
|
231 | 231 | ?> |
232 | 232 | |
233 | 233 | <form action="" method="post"> |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | <h2>Database settings</h2> |
237 | 237 | |
238 | 238 | <?php |
239 | - $issel_pgsql = $DB_TYPE == "pgsql" ? "selected='selected'" : ""; |
|
240 | - $issel_mysql = $DB_TYPE == "mysql" ? "selected='selected'" : ""; |
|
241 | - ?> |
|
239 | + $issel_pgsql = $DB_TYPE == "pgsql" ? "selected='selected'" : ""; |
|
240 | + $issel_mysql = $DB_TYPE == "mysql" ? "selected='selected'" : ""; |
|
241 | + ?> |
|
242 | 242 | |
243 | 243 | <fieldset> |
244 | 244 | <label>Database type:</label> |
@@ -292,87 +292,87 @@ discard block |
||
292 | 292 | <h2>Checking configuration</h2> |
293 | 293 | |
294 | 294 | <?php |
295 | - $errors = sanity_check($DB_TYPE); |
|
295 | + $errors = sanity_check($DB_TYPE); |
|
296 | 296 | |
297 | - if (count($errors) > 0) { |
|
298 | - print "<p>Some configuration tests failed. Please correct them before continuing.</p>"; |
|
297 | + if (count($errors) > 0) { |
|
298 | + print "<p>Some configuration tests failed. Please correct them before continuing.</p>"; |
|
299 | 299 | |
300 | - print "<ul>"; |
|
300 | + print "<ul>"; |
|
301 | 301 | |
302 | - foreach ($errors as $error) { |
|
303 | - print "<li style='color : red'>$error</li>"; |
|
304 | - } |
|
302 | + foreach ($errors as $error) { |
|
303 | + print "<li style='color : red'>$error</li>"; |
|
304 | + } |
|
305 | 305 | |
306 | - print "</ul>"; |
|
306 | + print "</ul>"; |
|
307 | 307 | |
308 | - exit; |
|
309 | - } |
|
308 | + exit; |
|
309 | + } |
|
310 | 310 | |
311 | - $notices = array(); |
|
311 | + $notices = array(); |
|
312 | 312 | |
313 | - if (!function_exists("curl_init")) { |
|
314 | - array_push($notices, "It is highly recommended to enable support for CURL in PHP."); |
|
315 | - } |
|
313 | + if (!function_exists("curl_init")) { |
|
314 | + array_push($notices, "It is highly recommended to enable support for CURL in PHP."); |
|
315 | + } |
|
316 | 316 | |
317 | - if (function_exists("curl_init") && ini_get("open_basedir")) { |
|
318 | - array_push($notices, "CURL and open_basedir combination breaks support for HTTP redirects. See the FAQ for more information."); |
|
319 | - } |
|
317 | + if (function_exists("curl_init") && ini_get("open_basedir")) { |
|
318 | + array_push($notices, "CURL and open_basedir combination breaks support for HTTP redirects. See the FAQ for more information."); |
|
319 | + } |
|
320 | 320 | |
321 | - if (!function_exists("idn_to_ascii")) { |
|
322 | - array_push($notices, "PHP support for Internationalization Functions is required to handle Internationalized Domain Names."); |
|
323 | - } |
|
321 | + if (!function_exists("idn_to_ascii")) { |
|
322 | + array_push($notices, "PHP support for Internationalization Functions is required to handle Internationalized Domain Names."); |
|
323 | + } |
|
324 | 324 | |
325 | 325 | if ($DB_TYPE == "mysql" && !function_exists("mysqli_connect")) { |
326 | 326 | array_push($notices, "PHP extension for MySQL (mysqli) is missing. This may prevent legacy plugins from working."); |
327 | 327 | } |
328 | 328 | |
329 | 329 | if ($DB_TYPE == "pgsql" && !function_exists("pg_connect")) { |
330 | - array_push($notices, "PHP extension for PostgreSQL is missing. This may prevent legacy plugins from working."); |
|
330 | + array_push($notices, "PHP extension for PostgreSQL is missing. This may prevent legacy plugins from working."); |
|
331 | 331 | } |
332 | 332 | |
333 | - if (count($notices) > 0) { |
|
334 | - print_notice("Configuration check succeeded with minor problems:"); |
|
333 | + if (count($notices) > 0) { |
|
334 | + print_notice("Configuration check succeeded with minor problems:"); |
|
335 | 335 | |
336 | - print "<ul>"; |
|
336 | + print "<ul>"; |
|
337 | 337 | |
338 | - foreach ($notices as $notice) { |
|
339 | - print "<li>$notice</li>"; |
|
340 | - } |
|
338 | + foreach ($notices as $notice) { |
|
339 | + print "<li>$notice</li>"; |
|
340 | + } |
|
341 | 341 | |
342 | - print "</ul>"; |
|
343 | - } else { |
|
344 | - print_notice("Configuration check succeeded."); |
|
345 | - } |
|
342 | + print "</ul>"; |
|
343 | + } else { |
|
344 | + print_notice("Configuration check succeeded."); |
|
345 | + } |
|
346 | 346 | |
347 | - ?> |
|
347 | + ?> |
|
348 | 348 | |
349 | 349 | <h2>Checking database</h2> |
350 | 350 | |
351 | 351 | <?php |
352 | - $pdo = pdo_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE, $DB_PORT); |
|
352 | + $pdo = pdo_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE, $DB_PORT); |
|
353 | 353 | |
354 | - if (!$pdo) { |
|
355 | - print_error("Unable to connect to database using specified parameters (driver: $DB_TYPE)."); |
|
356 | - exit; |
|
357 | - } |
|
354 | + if (!$pdo) { |
|
355 | + print_error("Unable to connect to database using specified parameters (driver: $DB_TYPE)."); |
|
356 | + exit; |
|
357 | + } |
|
358 | 358 | |
359 | - print_notice("Database test succeeded."); |
|
360 | - ?> |
|
359 | + print_notice("Database test succeeded."); |
|
360 | + ?> |
|
361 | 361 | |
362 | 362 | <h2>Initialize database</h2> |
363 | 363 | |
364 | 364 | <p>Before you can start using tt-rss, database needs to be initialized. Click on the button below to do that now.</p> |
365 | 365 | |
366 | 366 | <?php |
367 | - $res = $pdo->query("SELECT true FROM ttrss_feeds"); |
|
367 | + $res = $pdo->query("SELECT true FROM ttrss_feeds"); |
|
368 | 368 | |
369 | - if ($res && $res->fetch()) { |
|
370 | - print_error("Some tt-rss data already exists in this database. If you continue with database initialization your current data <b>WILL BE LOST</b>."); |
|
371 | - $need_confirm = true; |
|
372 | - } else { |
|
373 | - $need_confirm = false; |
|
374 | - } |
|
375 | - ?> |
|
369 | + if ($res && $res->fetch()) { |
|
370 | + print_error("Some tt-rss data already exists in this database. If you continue with database initialization your current data <b>WILL BE LOST</b>."); |
|
371 | + $need_confirm = true; |
|
372 | + } else { |
|
373 | + $need_confirm = false; |
|
374 | + } |
|
375 | + ?> |
|
376 | 376 | |
377 | 377 | <table><tr><td> |
378 | 378 | <form method="post"> |
@@ -415,44 +415,44 @@ discard block |
||
415 | 415 | |
416 | 416 | <?php |
417 | 417 | |
418 | - } else if ($op == 'installschema' || $op == 'skipschema') { |
|
418 | + } else if ($op == 'installschema' || $op == 'skipschema') { |
|
419 | 419 | |
420 | - $pdo = pdo_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE, $DB_PORT); |
|
420 | + $pdo = pdo_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE, $DB_PORT); |
|
421 | 421 | |
422 | - if (!$pdo) { |
|
423 | - print_error("Unable to connect to database using specified parameters."); |
|
424 | - exit; |
|
425 | - } |
|
422 | + if (!$pdo) { |
|
423 | + print_error("Unable to connect to database using specified parameters."); |
|
424 | + exit; |
|
425 | + } |
|
426 | 426 | |
427 | - if ($op == 'installschema') { |
|
427 | + if ($op == 'installschema') { |
|
428 | 428 | |
429 | - print "<h2>Initializing database...</h2>"; |
|
429 | + print "<h2>Initializing database...</h2>"; |
|
430 | 430 | |
431 | - $lines = explode(";", preg_replace("/[\r\n]/", "", |
|
431 | + $lines = explode(";", preg_replace("/[\r\n]/", "", |
|
432 | 432 | file_get_contents("../schema/ttrss_schema_".basename($DB_TYPE).".sql"))); |
433 | 433 | |
434 | - foreach ($lines as $line) { |
|
435 | - if (strpos($line, "--") !== 0 && $line) { |
|
436 | - $res = $pdo->query($line); |
|
434 | + foreach ($lines as $line) { |
|
435 | + if (strpos($line, "--") !== 0 && $line) { |
|
436 | + $res = $pdo->query($line); |
|
437 | 437 | |
438 | - if (!$res) { |
|
439 | - print_notice("Query: $line"); |
|
440 | - print_error("Error: " . implode(", ", $pdo->errorInfo())); |
|
438 | + if (!$res) { |
|
439 | + print_notice("Query: $line"); |
|
440 | + print_error("Error: " . implode(", ", $pdo->errorInfo())); |
|
441 | 441 | } |
442 | - } |
|
443 | - } |
|
442 | + } |
|
443 | + } |
|
444 | 444 | |
445 | - print_notice("Database initialization completed."); |
|
445 | + print_notice("Database initialization completed."); |
|
446 | 446 | |
447 | - } else { |
|
448 | - print_notice("Database initialization skipped."); |
|
449 | - } |
|
447 | + } else { |
|
448 | + print_notice("Database initialization skipped."); |
|
449 | + } |
|
450 | 450 | |
451 | - print "<h2>Generated configuration file</h2>"; |
|
451 | + print "<h2>Generated configuration file</h2>"; |
|
452 | 452 | |
453 | - print "<p>Copy following text and save as <code>config.php</code> in tt-rss main directory. It is suggested to read through the file to the end in case you need any options changed fom default values.</p>"; |
|
453 | + print "<p>Copy following text and save as <code>config.php</code> in tt-rss main directory. It is suggested to read through the file to the end in case you need any options changed fom default values.</p>"; |
|
454 | 454 | |
455 | - print "<p>After copying the file, you will be able to login with default username and password combination: <code>admin</code> and <code>password</code>. Don't forget to change the password immediately!</p>"; ?> |
|
455 | + print "<p>After copying the file, you will be able to login with default username and password combination: <code>admin</code> and <code>password</code>. Don't forget to change the password immediately!</p>"; ?> |
|
456 | 456 | |
457 | 457 | <form action="" method="post"> |
458 | 458 | <input type="hidden" name="op" value="saveconfig"> |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | <input type="hidden" name="DB_TYPE" value="<?php echo $DB_TYPE ?>"/> |
465 | 465 | <input type="hidden" name="SELF_URL_PATH" value="<?php echo $SELF_URL_PATH ?>"/> |
466 | 466 | <?php print "<textarea rows='20' style='width : 100%'>"; |
467 | - echo make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, |
|
468 | - $DB_PORT, $SELF_URL_PATH); |
|
469 | - print "</textarea>"; ?> |
|
467 | + echo make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, |
|
468 | + $DB_PORT, $SELF_URL_PATH); |
|
469 | + print "</textarea>"; ?> |
|
470 | 470 | |
471 | 471 | <hr/> |
472 | 472 | |
@@ -476,40 +476,40 @@ discard block |
||
476 | 476 | <p><button type="submit" dojoType='dijit.form.Button' class='alt-primary'>Save configuration</button></p> |
477 | 477 | </form> |
478 | 478 | <?php } else { |
479 | - print_error("Unfortunately, parent directory is not writable, so we're unable to save config.php automatically."); |
|
480 | - } |
|
479 | + print_error("Unfortunately, parent directory is not writable, so we're unable to save config.php automatically."); |
|
480 | + } |
|
481 | 481 | |
482 | - print_notice("You can generate the file again by changing the form above."); |
|
482 | + print_notice("You can generate the file again by changing the form above."); |
|
483 | 483 | |
484 | - } else if ($op == "saveconfig") { |
|
484 | + } else if ($op == "saveconfig") { |
|
485 | 485 | |
486 | - print "<h2>Saving configuration file to parent directory...</h2>"; |
|
486 | + print "<h2>Saving configuration file to parent directory...</h2>"; |
|
487 | 487 | |
488 | - if (!file_exists("../config.php")) { |
|
488 | + if (!file_exists("../config.php")) { |
|
489 | 489 | |
490 | - $fp = fopen("../config.php", "w"); |
|
490 | + $fp = fopen("../config.php", "w"); |
|
491 | 491 | |
492 | - if ($fp) { |
|
493 | - $written = fwrite($fp, make_config($DB_TYPE, $DB_HOST, |
|
494 | - $DB_USER, $DB_NAME, $DB_PASS, |
|
495 | - $DB_PORT, $SELF_URL_PATH)); |
|
492 | + if ($fp) { |
|
493 | + $written = fwrite($fp, make_config($DB_TYPE, $DB_HOST, |
|
494 | + $DB_USER, $DB_NAME, $DB_PASS, |
|
495 | + $DB_PORT, $SELF_URL_PATH)); |
|
496 | 496 | |
497 | - if ($written > 0) { |
|
498 | - print_notice("Successfully saved config.php. You can try <a href=\"..\">loading tt-rss now</a>."); |
|
497 | + if ($written > 0) { |
|
498 | + print_notice("Successfully saved config.php. You can try <a href=\"..\">loading tt-rss now</a>."); |
|
499 | 499 | |
500 | - } else { |
|
501 | - print_notice("Unable to write into config.php in tt-rss directory."); |
|
502 | - } |
|
500 | + } else { |
|
501 | + print_notice("Unable to write into config.php in tt-rss directory."); |
|
502 | + } |
|
503 | 503 | |
504 | - fclose($fp); |
|
505 | - } else { |
|
506 | - print_error("Unable to open config.php in tt-rss directory for writing."); |
|
507 | - } |
|
508 | - } else { |
|
509 | - print_error("config.php already present in tt-rss directory, refusing to overwrite."); |
|
510 | - } |
|
511 | - } |
|
512 | - ?> |
|
504 | + fclose($fp); |
|
505 | + } else { |
|
506 | + print_error("Unable to open config.php in tt-rss directory for writing."); |
|
507 | + } |
|
508 | + } else { |
|
509 | + print_error("config.php already present in tt-rss directory, refusing to overwrite."); |
|
510 | + } |
|
511 | + } |
|
512 | + ?> |
|
513 | 513 | |
514 | 514 | </div> |
515 | 515 |