@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | // 1) templates/register_notice.txt - displayed above the registration form |
5 | 5 | // 2) register_expire_do.php - contains user expiration queries when necessary |
6 | 6 | |
7 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
7 | + set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
8 | 8 | get_include_path()); |
9 | 9 | |
10 | 10 | require_once "autoload.php"; |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | |
26 | 26 | print '<?xml version="1.0" encoding="utf-8"?>'; |
27 | 27 | print "<feed xmlns=\"http://www.w3.org/2005/Atom\"> |
28 | - <id>".htmlspecialchars(SELF_URL_PATH . "/register.php")."</id> |
|
28 | + <id>".htmlspecialchars(SELF_URL_PATH."/register.php")."</id> |
|
29 | 29 | <title>Tiny Tiny RSS registration slots</title> |
30 | - <link rel=\"self\" href=\"".htmlspecialchars(SELF_URL_PATH . "/register.php?format=feed")."\"/> |
|
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 | 33 | if (ENABLE_REGISTRATION) { |
34 | - $result = db_query( "SELECT COUNT(*) AS cu FROM ttrss_users"); |
|
34 | + $result = db_query("SELECT COUNT(*) AS cu FROM ttrss_users"); |
|
35 | 35 | $num_users = db_fetch_result($result, 0, "cu"); |
36 | 36 | |
37 | 37 | $num_users = REG_MAX_USERS - $num_users; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | print "<entry> |
46 | 46 | <id>".htmlspecialchars(SELF_URL_PATH)."/register.php?$num_users"."</id> |
47 | - <link rel=\"alternate\" href=\"".htmlspecialchars(SELF_URL_PATH . "/register.php")."\"/>"; |
|
47 | + <link rel=\"alternate\" href=\"".htmlspecialchars(SELF_URL_PATH."/register.php")."\"/>"; |
|
48 | 48 | |
49 | 49 | print "<title>$num_users slots are currently available, registration $reg_suffix</title>"; |
50 | 50 | print "<summary>$num_users slots are currently available, registration $reg_suffix</summary>"; |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | /* Remove users which didn't login after receiving their registration information */ |
60 | 60 | |
61 | 61 | if (DB_TYPE == "pgsql") { |
62 | - db_query( "DELETE FROM ttrss_users WHERE last_login IS NULL |
|
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 | 64 | } else { |
65 | - db_query( "DELETE FROM ttrss_users WHERE last_login IS NULL |
|
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 | |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | if ($action == "check") { |
74 | 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 | 81 | $is_registered = db_num_rows($result) > 0; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | ?> |
198 | 198 | |
199 | 199 | <?php if (REG_MAX_USERS > 0) { |
200 | - $result = db_query( "SELECT COUNT(*) AS cu FROM ttrss_users"); |
|
200 | + $result = db_query("SELECT COUNT(*) AS cu FROM ttrss_users"); |
|
201 | 201 | $num_users = db_fetch_result($result, 0, "cu"); |
202 | 202 | } ?> |
203 | 203 | |
@@ -241,9 +241,9 @@ 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 | 248 | if (!$login || !$email || !$test) { |
249 | 249 | print_error(__("Your registration information is incomplete.")); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | |
256 | 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 | 261 | $is_registered = db_num_rows($result) > 0; |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
273 | 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 | 282 | if (db_num_rows($result) != 1) { |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | |
289 | 289 | $new_uid = db_fetch_result($result, 0, "id"); |
290 | 290 | |
291 | - initialize_user( $new_uid); |
|
291 | + initialize_user($new_uid); |
|
292 | 292 | |
293 | 293 | $reg_text = "Hi!\n". |
294 | 294 | "\n". |
@@ -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 |
@@ -18,7 +18,9 @@ discard block |
||
18 | 18 | |
19 | 19 | $action = $_REQUEST["action"]; |
20 | 20 | |
21 | - if (!init_plugins()) return; |
|
21 | + if (!init_plugins()) { |
|
22 | + return; |
|
23 | + } |
|
22 | 24 | |
23 | 25 | if ($_REQUEST["format"] == "feed") { |
24 | 26 | header("Content-Type: text/xml"); |
@@ -35,7 +37,9 @@ discard block |
||
35 | 37 | $num_users = db_fetch_result($result, 0, "cu"); |
36 | 38 | |
37 | 39 | $num_users = REG_MAX_USERS - $num_users; |
38 | - if ($num_users < 0) $num_users = 0; |
|
40 | + if ($num_users < 0) { |
|
41 | + $num_users = 0; |
|
42 | + } |
|
39 | 43 | $reg_suffix = "enabled"; |
40 | 44 | } else { |
41 | 45 | $num_users = 0; |
@@ -310,7 +314,9 @@ discard block |
||
310 | 314 | "subject" => "Registration information for Tiny Tiny RSS", |
311 | 315 | "message" => $reg_text]); |
312 | 316 | |
313 | - if (!$rc) print_error($mailer->error()); |
|
317 | + if (!$rc) { |
|
318 | + print_error($mailer->error()); |
|
319 | + } |
|
314 | 320 | |
315 | 321 | $reg_text = "Hi!\n". |
316 | 322 | "\n". |
@@ -324,7 +330,9 @@ discard block |
||
324 | 330 | "subject" => "Registration notice for Tiny Tiny RSS", |
325 | 331 | "message" => $reg_text]); |
326 | 332 | |
327 | - if (!$rc) print_error($mailer->error()); |
|
333 | + if (!$rc) { |
|
334 | + print_error($mailer->error()); |
|
335 | + } |
|
328 | 336 | |
329 | 337 | print_notice(__("Account created successfully.")); |
330 | 338 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
2 | + set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
3 | 3 | get_include_path()); |
4 | 4 | |
5 | 5 | $op = $_REQUEST["op"]; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | "fbexport", "logout", "pubsub"); |
17 | 17 | |
18 | 18 | if (array_search($op, $public_calls) !== false) { |
19 | - header("Location: public.php?" . $_SERVER['QUERY_STRING']); |
|
19 | + header("Location: public.php?".$_SERVER['QUERY_STRING']); |
|
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | if (SINGLE_USER_MODE) { |
45 | - authenticate_user( "admin", null); |
|
45 | + authenticate_user("admin", null); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | if ($_SESSION["uid"]) { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | print error_json(6); |
52 | 52 | return; |
53 | 53 | } |
54 | - load_user_plugins( $_SESSION["uid"]); |
|
54 | + load_user_plugins($_SESSION["uid"]); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $purge_intervals = array( |
@@ -1,130 +1,130 @@ |
||
1 | 1 | <?php |
2 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
3 | - get_include_path()); |
|
4 | - |
|
5 | - $op = $_REQUEST["op"]; |
|
6 | - @$method = $_REQUEST['subop'] ? $_REQUEST['subop'] : $_REQUEST["method"]; |
|
7 | - |
|
8 | - if (!$method) |
|
9 | - $method = 'index'; |
|
10 | - else |
|
11 | - $method = strtolower($method); |
|
12 | - |
|
13 | - /* Public calls compatibility shim */ |
|
14 | - |
|
15 | - $public_calls = array("globalUpdateFeeds", "rss", "getUnread", "getProfiles", "share", |
|
16 | - "fbexport", "logout", "pubsub"); |
|
17 | - |
|
18 | - if (array_search($op, $public_calls) !== false) { |
|
19 | - header("Location: public.php?" . $_SERVER['QUERY_STRING']); |
|
20 | - return; |
|
21 | - } |
|
22 | - |
|
23 | - @$csrf_token = $_REQUEST['csrf_token']; |
|
24 | - |
|
25 | - require_once "autoload.php"; |
|
26 | - require_once "sessions.php"; |
|
27 | - require_once "functions.php"; |
|
28 | - require_once "config.php"; |
|
29 | - require_once "db.php"; |
|
30 | - require_once "db-prefs.php"; |
|
31 | - |
|
32 | - startup_gettext(); |
|
33 | - |
|
34 | - $script_started = microtime(true); |
|
35 | - |
|
36 | - if (!init_plugins()) return; |
|
37 | - |
|
38 | - header("Content-Type: text/json; charset=utf-8"); |
|
39 | - |
|
40 | - if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { |
|
41 | - ob_start("ob_gzhandler"); |
|
42 | - } |
|
43 | - |
|
44 | - if (SINGLE_USER_MODE) { |
|
45 | - authenticate_user( "admin", null); |
|
46 | - } |
|
47 | - |
|
48 | - if ($_SESSION["uid"]) { |
|
49 | - if (!validate_session()) { |
|
50 | - header("Content-Type: text/json"); |
|
51 | - print error_json(6); |
|
52 | - return; |
|
53 | - } |
|
54 | - load_user_plugins( $_SESSION["uid"]); |
|
55 | - } |
|
56 | - |
|
57 | - $purge_intervals = array( |
|
58 | - 0 => __("Use default"), |
|
59 | - -1 => __("Never purge"), |
|
60 | - 5 => __("1 week old"), |
|
61 | - 14 => __("2 weeks old"), |
|
62 | - 31 => __("1 month old"), |
|
63 | - 60 => __("2 months old"), |
|
64 | - 90 => __("3 months old")); |
|
65 | - |
|
66 | - $update_intervals = array( |
|
67 | - 0 => __("Default interval"), |
|
68 | - -1 => __("Disable updates"), |
|
69 | - 15 => __("15 minutes"), |
|
70 | - 30 => __("30 minutes"), |
|
71 | - 60 => __("Hourly"), |
|
72 | - 240 => __("4 hours"), |
|
73 | - 720 => __("12 hours"), |
|
74 | - 1440 => __("Daily"), |
|
75 | - 10080 => __("Weekly")); |
|
76 | - |
|
77 | - $update_intervals_nodefault = array( |
|
78 | - -1 => __("Disable updates"), |
|
79 | - 15 => __("15 minutes"), |
|
80 | - 30 => __("30 minutes"), |
|
81 | - 60 => __("Hourly"), |
|
82 | - 240 => __("4 hours"), |
|
83 | - 720 => __("12 hours"), |
|
84 | - 1440 => __("Daily"), |
|
85 | - 10080 => __("Weekly")); |
|
86 | - |
|
87 | - $access_level_names = array( |
|
88 | - 0 => __("User"), |
|
89 | - 5 => __("Power User"), |
|
90 | - 10 => __("Administrator")); |
|
91 | - |
|
92 | - $op = str_replace("-", "_", $op); |
|
93 | - |
|
94 | - $override = PluginHost::getInstance()->lookup_handler($op, $method); |
|
95 | - |
|
96 | - if (class_exists($op) || $override) { |
|
97 | - |
|
98 | - if ($override) { |
|
99 | - $handler = $override; |
|
100 | - } else { |
|
101 | - $handler = new $op($_REQUEST); |
|
102 | - } |
|
103 | - |
|
104 | - if ($handler && implements_interface($handler, 'IHandler')) { |
|
105 | - if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) { |
|
106 | - if ($handler->before($method)) { |
|
107 | - if ($method && method_exists($handler, $method)) { |
|
108 | - $handler->$method(); |
|
109 | - } else { |
|
110 | - if (method_exists($handler, "catchall")) { |
|
111 | - $handler->catchall($method); |
|
112 | - } |
|
113 | - } |
|
114 | - $handler->after(); |
|
115 | - return; |
|
116 | - } else { |
|
117 | - header("Content-Type: text/json"); |
|
118 | - print error_json(6); |
|
119 | - return; |
|
120 | - } |
|
121 | - } else { |
|
122 | - header("Content-Type: text/json"); |
|
123 | - print error_json(6); |
|
124 | - return; |
|
125 | - } |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - header("Content-Type: text/json"); |
|
130 | - print error_json(13); |
|
2 | + set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
3 | + get_include_path()); |
|
4 | + |
|
5 | + $op = $_REQUEST["op"]; |
|
6 | + @$method = $_REQUEST['subop'] ? $_REQUEST['subop'] : $_REQUEST["method"]; |
|
7 | + |
|
8 | + if (!$method) |
|
9 | + $method = 'index'; |
|
10 | + else |
|
11 | + $method = strtolower($method); |
|
12 | + |
|
13 | + /* Public calls compatibility shim */ |
|
14 | + |
|
15 | + $public_calls = array("globalUpdateFeeds", "rss", "getUnread", "getProfiles", "share", |
|
16 | + "fbexport", "logout", "pubsub"); |
|
17 | + |
|
18 | + if (array_search($op, $public_calls) !== false) { |
|
19 | + header("Location: public.php?" . $_SERVER['QUERY_STRING']); |
|
20 | + return; |
|
21 | + } |
|
22 | + |
|
23 | + @$csrf_token = $_REQUEST['csrf_token']; |
|
24 | + |
|
25 | + require_once "autoload.php"; |
|
26 | + require_once "sessions.php"; |
|
27 | + require_once "functions.php"; |
|
28 | + require_once "config.php"; |
|
29 | + require_once "db.php"; |
|
30 | + require_once "db-prefs.php"; |
|
31 | + |
|
32 | + startup_gettext(); |
|
33 | + |
|
34 | + $script_started = microtime(true); |
|
35 | + |
|
36 | + if (!init_plugins()) return; |
|
37 | + |
|
38 | + header("Content-Type: text/json; charset=utf-8"); |
|
39 | + |
|
40 | + if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { |
|
41 | + ob_start("ob_gzhandler"); |
|
42 | + } |
|
43 | + |
|
44 | + if (SINGLE_USER_MODE) { |
|
45 | + authenticate_user( "admin", null); |
|
46 | + } |
|
47 | + |
|
48 | + if ($_SESSION["uid"]) { |
|
49 | + if (!validate_session()) { |
|
50 | + header("Content-Type: text/json"); |
|
51 | + print error_json(6); |
|
52 | + return; |
|
53 | + } |
|
54 | + load_user_plugins( $_SESSION["uid"]); |
|
55 | + } |
|
56 | + |
|
57 | + $purge_intervals = array( |
|
58 | + 0 => __("Use default"), |
|
59 | + -1 => __("Never purge"), |
|
60 | + 5 => __("1 week old"), |
|
61 | + 14 => __("2 weeks old"), |
|
62 | + 31 => __("1 month old"), |
|
63 | + 60 => __("2 months old"), |
|
64 | + 90 => __("3 months old")); |
|
65 | + |
|
66 | + $update_intervals = array( |
|
67 | + 0 => __("Default interval"), |
|
68 | + -1 => __("Disable updates"), |
|
69 | + 15 => __("15 minutes"), |
|
70 | + 30 => __("30 minutes"), |
|
71 | + 60 => __("Hourly"), |
|
72 | + 240 => __("4 hours"), |
|
73 | + 720 => __("12 hours"), |
|
74 | + 1440 => __("Daily"), |
|
75 | + 10080 => __("Weekly")); |
|
76 | + |
|
77 | + $update_intervals_nodefault = array( |
|
78 | + -1 => __("Disable updates"), |
|
79 | + 15 => __("15 minutes"), |
|
80 | + 30 => __("30 minutes"), |
|
81 | + 60 => __("Hourly"), |
|
82 | + 240 => __("4 hours"), |
|
83 | + 720 => __("12 hours"), |
|
84 | + 1440 => __("Daily"), |
|
85 | + 10080 => __("Weekly")); |
|
86 | + |
|
87 | + $access_level_names = array( |
|
88 | + 0 => __("User"), |
|
89 | + 5 => __("Power User"), |
|
90 | + 10 => __("Administrator")); |
|
91 | + |
|
92 | + $op = str_replace("-", "_", $op); |
|
93 | + |
|
94 | + $override = PluginHost::getInstance()->lookup_handler($op, $method); |
|
95 | + |
|
96 | + if (class_exists($op) || $override) { |
|
97 | + |
|
98 | + if ($override) { |
|
99 | + $handler = $override; |
|
100 | + } else { |
|
101 | + $handler = new $op($_REQUEST); |
|
102 | + } |
|
103 | + |
|
104 | + if ($handler && implements_interface($handler, 'IHandler')) { |
|
105 | + if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) { |
|
106 | + if ($handler->before($method)) { |
|
107 | + if ($method && method_exists($handler, $method)) { |
|
108 | + $handler->$method(); |
|
109 | + } else { |
|
110 | + if (method_exists($handler, "catchall")) { |
|
111 | + $handler->catchall($method); |
|
112 | + } |
|
113 | + } |
|
114 | + $handler->after(); |
|
115 | + return; |
|
116 | + } else { |
|
117 | + header("Content-Type: text/json"); |
|
118 | + print error_json(6); |
|
119 | + return; |
|
120 | + } |
|
121 | + } else { |
|
122 | + header("Content-Type: text/json"); |
|
123 | + print error_json(6); |
|
124 | + return; |
|
125 | + } |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + header("Content-Type: text/json"); |
|
130 | + print error_json(13); |
@@ -5,10 +5,11 @@ discard block |
||
5 | 5 | $op = $_REQUEST["op"]; |
6 | 6 | @$method = $_REQUEST['subop'] ? $_REQUEST['subop'] : $_REQUEST["method"]; |
7 | 7 | |
8 | - if (!$method) |
|
9 | - $method = 'index'; |
|
10 | - else |
|
11 | - $method = strtolower($method); |
|
8 | + if (!$method) { |
|
9 | + $method = 'index'; |
|
10 | + } else { |
|
11 | + $method = strtolower($method); |
|
12 | + } |
|
12 | 13 | |
13 | 14 | /* Public calls compatibility shim */ |
14 | 15 | |
@@ -33,7 +34,9 @@ discard block |
||
33 | 34 | |
34 | 35 | $script_started = microtime(true); |
35 | 36 | |
36 | - if (!init_plugins()) return; |
|
37 | + if (!init_plugins()) { |
|
38 | + return; |
|
39 | + } |
|
37 | 40 | |
38 | 41 | header("Content-Type: text/json; charset=utf-8"); |
39 | 42 |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
2 | + set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
3 | 3 | get_include_path()); |
4 | 4 | |
5 | 5 | require_once "autoload.php"; |
@@ -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); |
@@ -14,7 +14,9 @@ |
||
14 | 14 | |
15 | 15 | $script_started = microtime(true); |
16 | 16 | |
17 | - if (!init_plugins()) return; |
|
17 | + if (!init_plugins()) { |
|
18 | + return; |
|
19 | + } |
|
18 | 20 | |
19 | 21 | if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { |
20 | 22 | ob_start("ob_gzhandler"); |
@@ -33,6 +33,6 @@ |
||
33 | 33 | return Db::get()->last_query_error(); |
34 | 34 | } |
35 | 35 | |
36 | -function db_quote($str){ |
|
36 | +function db_quote($str) { |
|
37 | 37 | return Db::get()->quote($str); |
38 | 38 | } |
@@ -1,38 +1,38 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function db_escape_string($s, $strip_tags = true) { |
4 | - return Db::get()->escape_string($s, $strip_tags); |
|
4 | + return Db::get()->escape_string($s, $strip_tags); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | function db_query($query, $die_on_error = true) { |
8 | - return Db::get()->query($query, $die_on_error); |
|
8 | + return Db::get()->query($query, $die_on_error); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | function db_fetch_assoc($result) { |
12 | - return Db::get()->fetch_assoc($result); |
|
12 | + return Db::get()->fetch_assoc($result); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | |
16 | 16 | function db_num_rows($result) { |
17 | - return Db::get()->num_rows($result); |
|
17 | + return Db::get()->num_rows($result); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | function db_fetch_result($result, $row, $param) { |
21 | - return Db::get()->fetch_result($result, $row, $param); |
|
21 | + return Db::get()->fetch_result($result, $row, $param); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | function db_affected_rows($result) { |
25 | - return Db::get()->affected_rows($result); |
|
25 | + return Db::get()->affected_rows($result); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | function db_last_error() { |
29 | - return Db::get()->last_error(); |
|
29 | + return Db::get()->last_error(); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | function db_last_query_error() { |
33 | - return Db::get()->last_query_error(); |
|
33 | + return Db::get()->last_query_error(); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | function db_quote($str){ |
37 | - return Db::get()->quote($str); |
|
37 | + return Db::get()->quote($str); |
|
38 | 38 | } |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | function make_self_url() { |
18 | 18 | $proto = is_server_https() ? 'https' : 'http'; |
19 | 19 | |
20 | - return $proto . '://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; |
|
20 | + return $proto.'://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | function make_self_url_path() { |
24 | 24 | $proto = is_server_https() ? 'https' : 'http'; |
25 | - $url_path = $proto . '://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
25 | + $url_path = $proto.'://'.$_SERVER["HTTP_HOST"].parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
26 | 26 | |
27 | 27 | return $url_path; |
28 | 28 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
72 | - array_push($errors, "PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . "."); |
|
72 | + array_push($errors, "PHP version 5.6.0 or newer required. You're using ".PHP_VERSION."."); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if (!class_exists("UConverter")) { |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | array_push($errors, "Configuration file (config.php) has incorrect version. Update it with new options from config.php-dist and set CONFIG_VERSION to the correct value."); |
81 | 81 | } |
82 | 82 | |
83 | - if (!is_writable(CACHE_DIR . "/images")) { |
|
83 | + if (!is_writable(CACHE_DIR."/images")) { |
|
84 | 84 | array_push($errors, "Image cache is not writable (chmod -R 777 ".CACHE_DIR."/images)"); |
85 | 85 | } |
86 | 86 | |
87 | - if (!is_writable(CACHE_DIR . "/upload")) { |
|
87 | + if (!is_writable(CACHE_DIR."/upload")) { |
|
88 | 88 | array_push($errors, "Upload cache is not writable (chmod -R 777 ".CACHE_DIR."/upload)"); |
89 | 89 | } |
90 | 90 | |
91 | - if (!is_writable(CACHE_DIR . "/export")) { |
|
91 | + if (!is_writable(CACHE_DIR."/export")) { |
|
92 | 92 | array_push($errors, "Data export cache is not writable (chmod -R 777 ".CACHE_DIR."/export)"); |
93 | 93 | } |
94 | 94 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | if (isset($_SERVER["HTTP_HOST"]) && |
126 | 126 | (!defined('_SKIP_SELF_URL_PATH_CHECKS') || !_SKIP_SELF_URL_PATH_CHECKS) && |
127 | - SELF_URL_PATH != $ref_self_url_path && SELF_URL_PATH != mb_substr($ref_self_url_path, 0, mb_strlen($ref_self_url_path)-1)) { |
|
127 | + SELF_URL_PATH != $ref_self_url_path && SELF_URL_PATH != mb_substr($ref_self_url_path, 0, mb_strlen($ref_self_url_path) - 1)) { |
|
128 | 128 | array_push($errors, |
129 | 129 | "Please set SELF_URL_PATH to the correct value detected for your server: <b>$ref_self_url_path</b>"); |
130 | 130 | } |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | array_push($bad_tables_fmt, sprintf("%s (%s)", $bt['table_name'], $bt['engine'])); |
188 | 188 | } |
189 | 189 | |
190 | - $msg = "<p>The following tables use an unsupported MySQL engine: <b>" . |
|
191 | - implode(", ", $bad_tables_fmt) . "</b>.</p>"; |
|
190 | + $msg = "<p>The following tables use an unsupported MySQL engine: <b>". |
|
191 | + implode(", ", $bad_tables_fmt)."</b>.</p>"; |
|
192 | 192 | |
193 | 193 | $msg .= "<p>The only supported engine on MySQL is InnoDB. MyISAM lacks functionality to run |
194 | 194 | tt-rss. |
@@ -1,190 +1,190 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - function make_self_url() { |
|
4 | - $proto = is_server_https() ? 'https' : 'http'; |
|
3 | + function make_self_url() { |
|
4 | + $proto = is_server_https() ? 'https' : 'http'; |
|
5 | 5 | |
6 | - return $proto . '://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; |
|
7 | - } |
|
6 | + return $proto . '://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; |
|
7 | + } |
|
8 | 8 | |
9 | - function make_self_url_path() { |
|
10 | - $proto = is_server_https() ? 'https' : 'http'; |
|
11 | - $url_path = $proto . '://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
9 | + function make_self_url_path() { |
|
10 | + $proto = is_server_https() ? 'https' : 'http'; |
|
11 | + $url_path = $proto . '://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
|
12 | 12 | |
13 | - return $url_path; |
|
14 | - } |
|
13 | + return $url_path; |
|
14 | + } |
|
15 | 15 | |
16 | - function check_mysql_tables() { |
|
17 | - $pdo = Db::pdo(); |
|
16 | + function check_mysql_tables() { |
|
17 | + $pdo = Db::pdo(); |
|
18 | 18 | |
19 | - $sth = $pdo->prepare("SELECT engine, table_name FROM information_schema.tables WHERE |
|
19 | + $sth = $pdo->prepare("SELECT engine, table_name FROM information_schema.tables WHERE |
|
20 | 20 | table_schema = ? AND table_name LIKE 'ttrss_%' AND engine != 'InnoDB'"); |
21 | - $sth->execute([DB_NAME]); |
|
21 | + $sth->execute([DB_NAME]); |
|
22 | 22 | |
23 | - $bad_tables = []; |
|
23 | + $bad_tables = []; |
|
24 | 24 | |
25 | - while ($line = $sth->fetch()) { |
|
26 | - array_push($bad_tables, $line); |
|
27 | - } |
|
25 | + while ($line = $sth->fetch()) { |
|
26 | + array_push($bad_tables, $line); |
|
27 | + } |
|
28 | 28 | |
29 | - return $bad_tables; |
|
30 | - } |
|
29 | + return $bad_tables; |
|
30 | + } |
|
31 | 31 | |
32 | - function initial_sanity_check() { |
|
32 | + function initial_sanity_check() { |
|
33 | 33 | |
34 | - $errors = array(); |
|
34 | + $errors = array(); |
|
35 | 35 | |
36 | - if (!file_exists("config.php")) { |
|
37 | - array_push($errors, "Configuration file not found. Looks like you forgot to copy config.php-dist to config.php and edit it."); |
|
38 | - } else { |
|
36 | + if (!file_exists("config.php")) { |
|
37 | + array_push($errors, "Configuration file not found. Looks like you forgot to copy config.php-dist to config.php and edit it."); |
|
38 | + } else { |
|
39 | 39 | |
40 | - require_once "sanity_config.php"; |
|
40 | + require_once "sanity_config.php"; |
|
41 | 41 | |
42 | - if (file_exists("install") && !file_exists("config.php")) { |
|
43 | - array_push($errors, "Please copy config.php-dist to config.php or run the installer in install/"); |
|
44 | - } |
|
42 | + if (file_exists("install") && !file_exists("config.php")) { |
|
43 | + array_push($errors, "Please copy config.php-dist to config.php or run the installer in install/"); |
|
44 | + } |
|
45 | 45 | |
46 | - if (strpos(PLUGINS, "auth_") === false) { |
|
47 | - array_push($errors, "Please enable at least one authentication module via PLUGINS constant in config.php"); |
|
48 | - } |
|
46 | + if (strpos(PLUGINS, "auth_") === false) { |
|
47 | + array_push($errors, "Please enable at least one authentication module via PLUGINS constant in config.php"); |
|
48 | + } |
|
49 | 49 | |
50 | - if (function_exists('posix_getuid') && posix_getuid() == 0) { |
|
51 | - array_push($errors, "Please don't run this script as root."); |
|
52 | - } |
|
50 | + if (function_exists('posix_getuid') && posix_getuid() == 0) { |
|
51 | + array_push($errors, "Please don't run this script as root."); |
|
52 | + } |
|
53 | 53 | |
54 | - if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
|
55 | - array_push($errors, "PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . "."); |
|
56 | - } |
|
54 | + if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
|
55 | + array_push($errors, "PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . "."); |
|
56 | + } |
|
57 | 57 | |
58 | - if (!class_exists("UConverter")) { |
|
59 | - array_push($errors, "PHP UConverter class is missing, it's provided by the Internationalization (intl) module."); |
|
60 | - } |
|
58 | + if (!class_exists("UConverter")) { |
|
59 | + array_push($errors, "PHP UConverter class is missing, it's provided by the Internationalization (intl) module."); |
|
60 | + } |
|
61 | 61 | |
62 | - if (CONFIG_VERSION != EXPECTED_CONFIG_VERSION) { |
|
63 | - array_push($errors, "Configuration file (config.php) has incorrect version. Update it with new options from config.php-dist and set CONFIG_VERSION to the correct value."); |
|
64 | - } |
|
62 | + if (CONFIG_VERSION != EXPECTED_CONFIG_VERSION) { |
|
63 | + array_push($errors, "Configuration file (config.php) has incorrect version. Update it with new options from config.php-dist and set CONFIG_VERSION to the correct value."); |
|
64 | + } |
|
65 | 65 | |
66 | - if (!is_writable(CACHE_DIR . "/images")) { |
|
67 | - array_push($errors, "Image cache is not writable (chmod -R 777 ".CACHE_DIR."/images)"); |
|
68 | - } |
|
66 | + if (!is_writable(CACHE_DIR . "/images")) { |
|
67 | + array_push($errors, "Image cache is not writable (chmod -R 777 ".CACHE_DIR."/images)"); |
|
68 | + } |
|
69 | 69 | |
70 | - if (!is_writable(CACHE_DIR . "/upload")) { |
|
71 | - array_push($errors, "Upload cache is not writable (chmod -R 777 ".CACHE_DIR."/upload)"); |
|
72 | - } |
|
70 | + if (!is_writable(CACHE_DIR . "/upload")) { |
|
71 | + array_push($errors, "Upload cache is not writable (chmod -R 777 ".CACHE_DIR."/upload)"); |
|
72 | + } |
|
73 | 73 | |
74 | - if (!is_writable(CACHE_DIR . "/export")) { |
|
75 | - array_push($errors, "Data export cache is not writable (chmod -R 777 ".CACHE_DIR."/export)"); |
|
76 | - } |
|
74 | + if (!is_writable(CACHE_DIR . "/export")) { |
|
75 | + array_push($errors, "Data export cache is not writable (chmod -R 777 ".CACHE_DIR."/export)"); |
|
76 | + } |
|
77 | 77 | |
78 | - if (GENERATED_CONFIG_CHECK != EXPECTED_CONFIG_VERSION) { |
|
79 | - array_push($errors, |
|
80 | - "Configuration option checker sanity_config.php is outdated, please recreate it using ./utils/regen_config_checks.sh"); |
|
81 | - } |
|
78 | + if (GENERATED_CONFIG_CHECK != EXPECTED_CONFIG_VERSION) { |
|
79 | + array_push($errors, |
|
80 | + "Configuration option checker sanity_config.php is outdated, please recreate it using ./utils/regen_config_checks.sh"); |
|
81 | + } |
|
82 | 82 | |
83 | - foreach ($required_defines as $d) { |
|
84 | - if (!defined($d)) { |
|
85 | - array_push($errors, |
|
86 | - "Required configuration file parameter $d is not defined in config.php. You might need to copy it from config.php-dist."); |
|
87 | - } |
|
88 | - } |
|
83 | + foreach ($required_defines as $d) { |
|
84 | + if (!defined($d)) { |
|
85 | + array_push($errors, |
|
86 | + "Required configuration file parameter $d is not defined in config.php. You might need to copy it from config.php-dist."); |
|
87 | + } |
|
88 | + } |
|
89 | 89 | |
90 | - if (SINGLE_USER_MODE && class_exists("PDO")) { |
|
91 | - $pdo = DB::pdo(); |
|
90 | + if (SINGLE_USER_MODE && class_exists("PDO")) { |
|
91 | + $pdo = DB::pdo(); |
|
92 | 92 | |
93 | - $res = $pdo->query("SELECT id FROM ttrss_users WHERE id = 1"); |
|
93 | + $res = $pdo->query("SELECT id FROM ttrss_users WHERE id = 1"); |
|
94 | 94 | |
95 | - if (!$res->fetch()) { |
|
96 | - array_push($errors, "SINGLE_USER_MODE is enabled in config.php but default admin account is not found."); |
|
97 | - } |
|
98 | - } |
|
95 | + if (!$res->fetch()) { |
|
96 | + array_push($errors, "SINGLE_USER_MODE is enabled in config.php but default admin account is not found."); |
|
97 | + } |
|
98 | + } |
|
99 | 99 | |
100 | - $ref_self_url_path = make_self_url_path(); |
|
101 | - $ref_self_url_path = preg_replace("/\w+\.php$/", "", $ref_self_url_path); |
|
100 | + $ref_self_url_path = make_self_url_path(); |
|
101 | + $ref_self_url_path = preg_replace("/\w+\.php$/", "", $ref_self_url_path); |
|
102 | 102 | |
103 | - if (SELF_URL_PATH == "http://example.org/tt-rss/") { |
|
104 | - array_push($errors, |
|
105 | - "Please set SELF_URL_PATH to the correct value for your server (possible value: <b>$ref_self_url_path</b>)"); |
|
106 | - } |
|
103 | + if (SELF_URL_PATH == "http://example.org/tt-rss/") { |
|
104 | + array_push($errors, |
|
105 | + "Please set SELF_URL_PATH to the correct value for your server (possible value: <b>$ref_self_url_path</b>)"); |
|
106 | + } |
|
107 | 107 | |
108 | - if (isset($_SERVER["HTTP_HOST"]) && |
|
109 | - (!defined('_SKIP_SELF_URL_PATH_CHECKS') || !_SKIP_SELF_URL_PATH_CHECKS) && |
|
110 | - SELF_URL_PATH != $ref_self_url_path && SELF_URL_PATH != mb_substr($ref_self_url_path, 0, mb_strlen($ref_self_url_path)-1)) { |
|
111 | - array_push($errors, |
|
112 | - "Please set SELF_URL_PATH to the correct value detected for your server: <b>$ref_self_url_path</b>"); |
|
113 | - } |
|
108 | + if (isset($_SERVER["HTTP_HOST"]) && |
|
109 | + (!defined('_SKIP_SELF_URL_PATH_CHECKS') || !_SKIP_SELF_URL_PATH_CHECKS) && |
|
110 | + SELF_URL_PATH != $ref_self_url_path && SELF_URL_PATH != mb_substr($ref_self_url_path, 0, mb_strlen($ref_self_url_path)-1)) { |
|
111 | + array_push($errors, |
|
112 | + "Please set SELF_URL_PATH to the correct value detected for your server: <b>$ref_self_url_path</b>"); |
|
113 | + } |
|
114 | 114 | |
115 | - if (!is_writable(ICONS_DIR)) { |
|
116 | - array_push($errors, "ICONS_DIR defined in config.php is not writable (chmod -R 777 ".ICONS_DIR.").\n"); |
|
117 | - } |
|
115 | + if (!is_writable(ICONS_DIR)) { |
|
116 | + array_push($errors, "ICONS_DIR defined in config.php is not writable (chmod -R 777 ".ICONS_DIR.").\n"); |
|
117 | + } |
|
118 | 118 | |
119 | - if (!is_writable(LOCK_DIRECTORY)) { |
|
120 | - array_push($errors, "LOCK_DIRECTORY defined in config.php is not writable (chmod -R 777 ".LOCK_DIRECTORY.").\n"); |
|
121 | - } |
|
119 | + if (!is_writable(LOCK_DIRECTORY)) { |
|
120 | + array_push($errors, "LOCK_DIRECTORY defined in config.php is not writable (chmod -R 777 ".LOCK_DIRECTORY.").\n"); |
|
121 | + } |
|
122 | 122 | |
123 | - if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) { |
|
124 | - 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."); |
|
125 | - } |
|
123 | + if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) { |
|
124 | + 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."); |
|
125 | + } |
|
126 | 126 | |
127 | - if (!function_exists("json_encode")) { |
|
128 | - array_push($errors, "PHP support for JSON is required, but was not found."); |
|
129 | - } |
|
127 | + if (!function_exists("json_encode")) { |
|
128 | + array_push($errors, "PHP support for JSON is required, but was not found."); |
|
129 | + } |
|
130 | 130 | |
131 | - if (DB_TYPE == "mysql" && !function_exists("mysqli_connect")) { |
|
132 | - array_push($errors, "PHP support for MySQL is required for configured DB_TYPE in config.php."); |
|
133 | - } |
|
131 | + if (DB_TYPE == "mysql" && !function_exists("mysqli_connect")) { |
|
132 | + array_push($errors, "PHP support for MySQL is required for configured DB_TYPE in config.php."); |
|
133 | + } |
|
134 | 134 | |
135 | - if (DB_TYPE == "pgsql" && !function_exists("pg_connect")) { |
|
136 | - array_push($errors, "PHP support for PostgreSQL is required for configured DB_TYPE in config.php"); |
|
137 | - } |
|
135 | + if (DB_TYPE == "pgsql" && !function_exists("pg_connect")) { |
|
136 | + array_push($errors, "PHP support for PostgreSQL is required for configured DB_TYPE in config.php"); |
|
137 | + } |
|
138 | 138 | |
139 | - if (!class_exists("PDO")) { |
|
140 | - array_push($errors, "PHP support for PDO is required but was not found."); |
|
141 | - } |
|
139 | + if (!class_exists("PDO")) { |
|
140 | + array_push($errors, "PHP support for PDO is required but was not found."); |
|
141 | + } |
|
142 | 142 | |
143 | - if (!function_exists("mb_strlen")) { |
|
144 | - array_push($errors, "PHP support for mbstring functions is required but was not found."); |
|
145 | - } |
|
143 | + if (!function_exists("mb_strlen")) { |
|
144 | + array_push($errors, "PHP support for mbstring functions is required but was not found."); |
|
145 | + } |
|
146 | 146 | |
147 | - if (!function_exists("hash")) { |
|
148 | - array_push($errors, "PHP support for hash() function is required but was not found."); |
|
149 | - } |
|
147 | + if (!function_exists("hash")) { |
|
148 | + array_push($errors, "PHP support for hash() function is required but was not found."); |
|
149 | + } |
|
150 | 150 | |
151 | - if (ini_get("safe_mode")) { |
|
152 | - array_push($errors, "PHP safe mode setting is obsolete and not supported by tt-rss."); |
|
153 | - } |
|
151 | + if (ini_get("safe_mode")) { |
|
152 | + array_push($errors, "PHP safe mode setting is obsolete and not supported by tt-rss."); |
|
153 | + } |
|
154 | 154 | |
155 | - if (!function_exists("mime_content_type")) { |
|
156 | - array_push($errors, "PHP function mime_content_type() is missing, try enabling fileinfo module."); |
|
157 | - } |
|
155 | + if (!function_exists("mime_content_type")) { |
|
156 | + array_push($errors, "PHP function mime_content_type() is missing, try enabling fileinfo module."); |
|
157 | + } |
|
158 | 158 | |
159 | - if (!class_exists("DOMDocument")) { |
|
160 | - array_push($errors, "PHP support for DOMDocument is required, but was not found."); |
|
161 | - } |
|
159 | + if (!class_exists("DOMDocument")) { |
|
160 | + array_push($errors, "PHP support for DOMDocument is required, but was not found."); |
|
161 | + } |
|
162 | 162 | |
163 | - if (DB_TYPE == "mysql") { |
|
164 | - $bad_tables = check_mysql_tables(); |
|
163 | + if (DB_TYPE == "mysql") { |
|
164 | + $bad_tables = check_mysql_tables(); |
|
165 | 165 | |
166 | - if (count($bad_tables) > 0) { |
|
167 | - $bad_tables_fmt = []; |
|
166 | + if (count($bad_tables) > 0) { |
|
167 | + $bad_tables_fmt = []; |
|
168 | 168 | |
169 | - foreach ($bad_tables as $bt) { |
|
170 | - array_push($bad_tables_fmt, sprintf("%s (%s)", $bt['table_name'], $bt['engine'])); |
|
171 | - } |
|
169 | + foreach ($bad_tables as $bt) { |
|
170 | + array_push($bad_tables_fmt, sprintf("%s (%s)", $bt['table_name'], $bt['engine'])); |
|
171 | + } |
|
172 | 172 | |
173 | - $msg = "<p>The following tables use an unsupported MySQL engine: <b>" . |
|
174 | - implode(", ", $bad_tables_fmt) . "</b>.</p>"; |
|
173 | + $msg = "<p>The following tables use an unsupported MySQL engine: <b>" . |
|
174 | + implode(", ", $bad_tables_fmt) . "</b>.</p>"; |
|
175 | 175 | |
176 | - $msg .= "<p>The only supported engine on MySQL is InnoDB. MyISAM lacks functionality to run |
|
176 | + $msg .= "<p>The only supported engine on MySQL is InnoDB. MyISAM lacks functionality to run |
|
177 | 177 | tt-rss. |
178 | 178 | Please backup your data (via OPML) and re-import the schema before continuing.</p> |
179 | 179 | <p><b>WARNING: importing the schema would mean LOSS OF ALL YOUR DATA.</b></p>"; |
180 | 180 | |
181 | 181 | |
182 | - array_push($errors, $msg); |
|
183 | - } |
|
184 | - } |
|
185 | - } |
|
182 | + array_push($errors, $msg); |
|
183 | + } |
|
184 | + } |
|
185 | + } |
|
186 | 186 | |
187 | - if (count($errors) > 0 && $_SERVER['REQUEST_URI']) { ?> |
|
187 | + if (count($errors) > 0 && $_SERVER['REQUEST_URI']) { ?> |
|
188 | 188 | <!DOCTYPE html> |
189 | 189 | <html> |
190 | 190 | <head> |
@@ -211,22 +211,22 @@ discard block |
||
211 | 211 | </html> |
212 | 212 | |
213 | 213 | <?php |
214 | - die; |
|
215 | - } else if (count($errors) > 0) { |
|
216 | - echo "Tiny Tiny RSS was unable to start properly. This usually means a misconfiguration or an incomplete upgrade.\n"; |
|
217 | - echo "Please fix errors indicated by the following messages:\n\n"; |
|
214 | + die; |
|
215 | + } else if (count($errors) > 0) { |
|
216 | + echo "Tiny Tiny RSS was unable to start properly. This usually means a misconfiguration or an incomplete upgrade.\n"; |
|
217 | + echo "Please fix errors indicated by the following messages:\n\n"; |
|
218 | 218 | |
219 | - foreach ($errors as $error) { |
|
220 | - echo " * $error\n"; |
|
221 | - } |
|
219 | + foreach ($errors as $error) { |
|
220 | + echo " * $error\n"; |
|
221 | + } |
|
222 | 222 | |
223 | - echo "\nYou might want to check tt-rss wiki or the forums for more information.\n"; |
|
224 | - echo "Please search the forums before creating new topic for your question.\n"; |
|
223 | + echo "\nYou might want to check tt-rss wiki or the forums for more information.\n"; |
|
224 | + echo "Please search the forums before creating new topic for your question.\n"; |
|
225 | 225 | |
226 | - exit(-1); |
|
227 | - } |
|
228 | - } |
|
226 | + exit(-1); |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | - initial_sanity_check(); |
|
230 | + initial_sanity_check(); |
|
231 | 231 | |
232 | 232 | ?> |
@@ -15,9 +15,9 @@ |
||
15 | 15 | // 3. plugin classes are loaded by PluginHandler from plugins.local/ and plugins/ (TODO: use generic autoloader?) |
16 | 16 | |
17 | 17 | if ($namespace && $class_name) { |
18 | - $class_file = "$root_dir/vendor/$namespace/" . str_replace('\\', '/', $class_name) . ".php"; |
|
18 | + $class_file = "$root_dir/vendor/$namespace/".str_replace('\\', '/', $class_name).".php"; |
|
19 | 19 | } else { |
20 | - $class_file = "$root_dir/classes/" . str_replace("_", "/", strtolower($class)) . ".php"; |
|
20 | + $class_file = "$root_dir/classes/".str_replace("_", "/", strtolower($class)).".php"; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (file_exists($class_file)) |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | - require_once "functions.php"; |
|
2 | + require_once "functions.php"; |
|
3 | 3 | |
4 | - spl_autoload_register(function($class) { |
|
5 | - $namespace = ''; |
|
6 | - $class_name = $class; |
|
4 | + spl_autoload_register(function($class) { |
|
5 | + $namespace = ''; |
|
6 | + $class_name = $class; |
|
7 | 7 | |
8 | - if (strpos($class, '\\') !== false) |
|
9 | - list ($namespace, $class_name) = explode('\\', $class, 2); |
|
8 | + if (strpos($class, '\\') !== false) |
|
9 | + list ($namespace, $class_name) = explode('\\', $class, 2); |
|
10 | 10 | |
11 | - $root_dir = dirname(__DIR__); // we're in tt-rss/include |
|
11 | + $root_dir = dirname(__DIR__); // we're in tt-rss/include |
|
12 | 12 | |
13 | - // 1. third party libraries with namespaces are loaded from vendor/ |
|
14 | - // 2. internal tt-rss classes are loaded from classes/ and use special naming logic instead of namespaces |
|
15 | - // 3. plugin classes are loaded by PluginHandler from plugins.local/ and plugins/ (TODO: use generic autoloader?) |
|
13 | + // 1. third party libraries with namespaces are loaded from vendor/ |
|
14 | + // 2. internal tt-rss classes are loaded from classes/ and use special naming logic instead of namespaces |
|
15 | + // 3. plugin classes are loaded by PluginHandler from plugins.local/ and plugins/ (TODO: use generic autoloader?) |
|
16 | 16 | |
17 | - if ($namespace && $class_name) { |
|
18 | - $class_file = "$root_dir/vendor/$namespace/" . str_replace('\\', '/', $class_name) . ".php"; |
|
19 | - } else { |
|
20 | - $class_file = "$root_dir/classes/" . str_replace("_", "/", strtolower($class)) . ".php"; |
|
21 | - } |
|
17 | + if ($namespace && $class_name) { |
|
18 | + $class_file = "$root_dir/vendor/$namespace/" . str_replace('\\', '/', $class_name) . ".php"; |
|
19 | + } else { |
|
20 | + $class_file = "$root_dir/classes/" . str_replace("_", "/", strtolower($class)) . ".php"; |
|
21 | + } |
|
22 | 22 | |
23 | - if (file_exists($class_file)) |
|
24 | - include $class_file; |
|
23 | + if (file_exists($class_file)) |
|
24 | + include $class_file; |
|
25 | 25 | |
26 | - }); |
|
26 | + }); |
@@ -5,8 +5,9 @@ discard block |
||
5 | 5 | $namespace = ''; |
6 | 6 | $class_name = $class; |
7 | 7 | |
8 | - if (strpos($class, '\\') !== false) |
|
9 | - list ($namespace, $class_name) = explode('\\', $class, 2); |
|
8 | + if (strpos($class, '\\') !== false) { |
|
9 | + list ($namespace, $class_name) = explode('\\', $class, 2); |
|
10 | + } |
|
10 | 11 | |
11 | 12 | $root_dir = dirname(__DIR__); // we're in tt-rss/include |
12 | 13 | |
@@ -20,7 +21,8 @@ discard block |
||
20 | 21 | $class_file = "$root_dir/classes/" . str_replace("_", "/", strtolower($class)) . ".php"; |
21 | 22 | } |
22 | 23 | |
23 | - if (file_exists($class_file)) |
|
24 | - include $class_file; |
|
24 | + if (file_exists($class_file)) { |
|
25 | + include $class_file; |
|
26 | + } |
|
25 | 27 | |
26 | 28 | }); |
@@ -1,3 +1,3 @@ |
||
1 | 1 | <?php # This file has been generated at: Thu Nov 22 22:14:43 MSK 2018 |
2 | 2 | define('GENERATED_CONFIG_CHECK', 26); |
3 | -$required_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'SINGLE_USER_MODE', 'SIMPLE_UPDATE_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'AUTH_AUTO_CREATE', 'AUTH_AUTO_LOGIN', 'FORCE_ARTICLE_PURGE', 'SPHINX_SERVER', 'SPHINX_INDEX', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'CHECK_FOR_UPDATES', 'ENABLE_GZIP_OUTPUT', 'PLUGINS', 'LOG_DESTINATION', 'CONFIG_VERSION'); ?> |
|
3 | +$required_defines = array('DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'SINGLE_USER_MODE', 'SIMPLE_UPDATE_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'AUTH_AUTO_CREATE', 'AUTH_AUTO_LOGIN', 'FORCE_ARTICLE_PURGE', 'SPHINX_SERVER', 'SPHINX_INDEX', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'CHECK_FOR_UPDATES', 'ENABLE_GZIP_OUTPUT', 'PLUGINS', 'LOG_DESTINATION', 'CONFIG_VERSION'); ?> |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | if (!is_object($a)) { |
14 | 14 | array_push($fmt_args, $a); |
15 | 15 | } else { |
16 | - array_push($fmt_args, "[" . get_class($a) . "]"); |
|
16 | + array_push($fmt_args, "[".get_class($a)."]"); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | } |
20 | 20 | |
21 | - $filename = str_replace(dirname(__DIR__) . "/", "", $e["file"]); |
|
21 | + $filename = str_replace(dirname(__DIR__)."/", "", $e["file"]); |
|
22 | 22 | |
23 | 23 | $rv .= sprintf("%d. %s(%s): %s(%s)\n", |
24 | 24 | $idx, $filename, $e["line"], $e["function"], implode(", ", $fmt_args)); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $errno = $error["type"]; |
53 | 53 | $file = $error["file"]; |
54 | 54 | $line = $error["line"]; |
55 | - $errstr = $error["message"]; |
|
55 | + $errstr = $error["message"]; |
|
56 | 56 | |
57 | 57 | if (!$errno) return false; |
58 | 58 |
@@ -32,16 +32,19 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | function ttrss_error_handler($errno, $errstr, $file, $line, $context) { |
35 | - if (error_reporting() == 0 || !$errno) return false; |
|
35 | + if (error_reporting() == 0 || !$errno) { |
|
36 | + return false; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1); |
38 | 40 | |
39 | 41 | $context = format_backtrace(debug_backtrace()); |
40 | 42 | $errstr = truncate_middle($errstr, 16384, " (...) "); |
41 | 43 | |
42 | - if (class_exists("Logger")) |
|
43 | - return Logger::get()->log_error($errno, $errstr, $file, $line, $context); |
|
44 | -} |
|
44 | + if (class_exists("Logger")) { |
|
45 | + return Logger::get()->log_error($errno, $errstr, $file, $line, $context); |
|
46 | + } |
|
47 | + } |
|
45 | 48 | |
46 | 49 | function ttrss_fatal_handler() { |
47 | 50 | global $last_query; |
@@ -54,16 +57,21 @@ discard block |
||
54 | 57 | $line = $error["line"]; |
55 | 58 | $errstr = $error["message"]; |
56 | 59 | |
57 | - if (!$errno) return false; |
|
60 | + if (!$errno) { |
|
61 | + return false; |
|
62 | + } |
|
58 | 63 | |
59 | 64 | $context = format_backtrace(debug_backtrace()); |
60 | 65 | |
61 | 66 | $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1); |
62 | 67 | |
63 | - if ($last_query) $errstr .= " [Last query: $last_query]"; |
|
68 | + if ($last_query) { |
|
69 | + $errstr .= " [Last query: $last_query]"; |
|
70 | + } |
|
64 | 71 | |
65 | - if (class_exists("Logger")) |
|
66 | - return Logger::get()->log_error($errno, $errstr, $file, $line, $context); |
|
72 | + if (class_exists("Logger")) { |
|
73 | + return Logger::get()->log_error($errno, $errstr, $file, $line, $context); |
|
74 | + } |
|
67 | 75 | } |
68 | 76 | |
69 | 77 | return false; |
@@ -1,72 +1,72 @@ |
||
1 | 1 | <?php |
2 | 2 | function format_backtrace($trace) { |
3 | - $rv = ""; |
|
4 | - $idx = 1; |
|
5 | - |
|
6 | - if (is_array($trace)) { |
|
7 | - foreach ($trace as $e) { |
|
8 | - if (isset($e["file"]) && isset($e["line"])) { |
|
9 | - $fmt_args = []; |
|
10 | - |
|
11 | - if (is_array($e["args"])) { |
|
12 | - foreach ($e["args"] as $a) { |
|
13 | - if (!is_object($a)) { |
|
14 | - array_push($fmt_args, $a); |
|
15 | - } else { |
|
16 | - array_push($fmt_args, "[" . get_class($a) . "]"); |
|
17 | - } |
|
18 | - } |
|
19 | - } |
|
20 | - |
|
21 | - $filename = str_replace(dirname(__DIR__) . "/", "", $e["file"]); |
|
22 | - |
|
23 | - $rv .= sprintf("%d. %s(%s): %s(%s)\n", |
|
24 | - $idx, $filename, $e["line"], $e["function"], implode(", ", $fmt_args)); |
|
25 | - |
|
26 | - $idx++; |
|
27 | - } |
|
28 | - } |
|
29 | - } |
|
30 | - |
|
31 | - return $rv; |
|
3 | + $rv = ""; |
|
4 | + $idx = 1; |
|
5 | + |
|
6 | + if (is_array($trace)) { |
|
7 | + foreach ($trace as $e) { |
|
8 | + if (isset($e["file"]) && isset($e["line"])) { |
|
9 | + $fmt_args = []; |
|
10 | + |
|
11 | + if (is_array($e["args"])) { |
|
12 | + foreach ($e["args"] as $a) { |
|
13 | + if (!is_object($a)) { |
|
14 | + array_push($fmt_args, $a); |
|
15 | + } else { |
|
16 | + array_push($fmt_args, "[" . get_class($a) . "]"); |
|
17 | + } |
|
18 | + } |
|
19 | + } |
|
20 | + |
|
21 | + $filename = str_replace(dirname(__DIR__) . "/", "", $e["file"]); |
|
22 | + |
|
23 | + $rv .= sprintf("%d. %s(%s): %s(%s)\n", |
|
24 | + $idx, $filename, $e["line"], $e["function"], implode(", ", $fmt_args)); |
|
25 | + |
|
26 | + $idx++; |
|
27 | + } |
|
28 | + } |
|
29 | + } |
|
30 | + |
|
31 | + return $rv; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | function ttrss_error_handler($errno, $errstr, $file, $line, $context) { |
35 | - if (error_reporting() == 0 || !$errno) return false; |
|
35 | + if (error_reporting() == 0 || !$errno) return false; |
|
36 | 36 | |
37 | - $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1); |
|
37 | + $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1); |
|
38 | 38 | |
39 | - $context = format_backtrace(debug_backtrace()); |
|
40 | - $errstr = truncate_middle($errstr, 16384, " (...) "); |
|
39 | + $context = format_backtrace(debug_backtrace()); |
|
40 | + $errstr = truncate_middle($errstr, 16384, " (...) "); |
|
41 | 41 | |
42 | - if (class_exists("Logger")) |
|
43 | - return Logger::get()->log_error($errno, $errstr, $file, $line, $context); |
|
42 | + if (class_exists("Logger")) |
|
43 | + return Logger::get()->log_error($errno, $errstr, $file, $line, $context); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | function ttrss_fatal_handler() { |
47 | - global $last_query; |
|
47 | + global $last_query; |
|
48 | 48 | |
49 | - $error = error_get_last(); |
|
49 | + $error = error_get_last(); |
|
50 | 50 | |
51 | - if ($error !== null) { |
|
52 | - $errno = $error["type"]; |
|
53 | - $file = $error["file"]; |
|
54 | - $line = $error["line"]; |
|
55 | - $errstr = $error["message"]; |
|
51 | + if ($error !== null) { |
|
52 | + $errno = $error["type"]; |
|
53 | + $file = $error["file"]; |
|
54 | + $line = $error["line"]; |
|
55 | + $errstr = $error["message"]; |
|
56 | 56 | |
57 | - if (!$errno) return false; |
|
57 | + if (!$errno) return false; |
|
58 | 58 | |
59 | - $context = format_backtrace(debug_backtrace()); |
|
59 | + $context = format_backtrace(debug_backtrace()); |
|
60 | 60 | |
61 | - $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1); |
|
61 | + $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1); |
|
62 | 62 | |
63 | - if ($last_query) $errstr .= " [Last query: $last_query]"; |
|
63 | + if ($last_query) $errstr .= " [Last query: $last_query]"; |
|
64 | 64 | |
65 | - if (class_exists("Logger")) |
|
66 | - return Logger::get()->log_error($errno, $errstr, $file, $line, $context); |
|
67 | - } |
|
65 | + if (class_exists("Logger")) |
|
66 | + return Logger::get()->log_error($errno, $errstr, $file, $line, $context); |
|
67 | + } |
|
68 | 68 | |
69 | - return false; |
|
69 | + return false; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | register_shutdown_function('ttrss_fatal_handler'); |
@@ -3,7 +3,7 @@ |
||
3 | 3 | header("Location: install/"); |
4 | 4 | } |
5 | 5 | |
6 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
6 | + set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
7 | 7 | get_include_path()); |
8 | 8 | |
9 | 9 | if (!file_exists("config.php")) { |
@@ -1,29 +1,29 @@ discard block |
||
1 | 1 | <?php |
2 | - if (file_exists("install") && !file_exists("config.php")) { |
|
3 | - header("Location: install/"); |
|
4 | - } |
|
2 | + if (file_exists("install") && !file_exists("config.php")) { |
|
3 | + header("Location: install/"); |
|
4 | + } |
|
5 | 5 | |
6 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
7 | - get_include_path()); |
|
6 | + set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
7 | + get_include_path()); |
|
8 | 8 | |
9 | - if (!file_exists("config.php")) { |
|
10 | - print "<b>Fatal Error</b>: You forgot to copy |
|
9 | + if (!file_exists("config.php")) { |
|
10 | + print "<b>Fatal Error</b>: You forgot to copy |
|
11 | 11 | <b>config.php-dist</b> to <b>config.php</b> and edit it.\n"; |
12 | - exit; |
|
13 | - } |
|
12 | + exit; |
|
13 | + } |
|
14 | 14 | |
15 | - require_once "autoload.php"; |
|
16 | - require_once "sessions.php"; |
|
17 | - require_once "functions.php"; |
|
18 | - require_once "sanity_check.php"; |
|
19 | - require_once "config.php"; |
|
20 | - require_once "db-prefs.php"; |
|
15 | + require_once "autoload.php"; |
|
16 | + require_once "sessions.php"; |
|
17 | + require_once "functions.php"; |
|
18 | + require_once "sanity_check.php"; |
|
19 | + require_once "config.php"; |
|
20 | + require_once "db-prefs.php"; |
|
21 | 21 | |
22 | - if (!init_plugins()) return; |
|
22 | + if (!init_plugins()) return; |
|
23 | 23 | |
24 | - login_sequence(); |
|
24 | + login_sequence(); |
|
25 | 25 | |
26 | - header('Content-Type: text/html; charset=utf-8'); |
|
26 | + header('Content-Type: text/html; charset=utf-8'); |
|
27 | 27 | ?> |
28 | 28 | <!DOCTYPE html> |
29 | 29 | <html> |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | <meta name="viewport" content="initial-scale=1,width=device-width" /> |
33 | 33 | |
34 | 34 | <?php if ($_SESSION["uid"]) { |
35 | - $theme = get_pref("USER_CSS_THEME", false, false); |
|
36 | - if ($theme && theme_exists("$theme")) { |
|
37 | - echo stylesheet_tag(get_theme_path($theme), 'theme_css'); |
|
38 | - } |
|
39 | - } |
|
40 | - ?> |
|
35 | + $theme = get_pref("USER_CSS_THEME", false, false); |
|
36 | + if ($theme && theme_exists("$theme")) { |
|
37 | + echo stylesheet_tag(get_theme_path($theme), 'theme_css'); |
|
38 | + } |
|
39 | + } |
|
40 | + ?> |
|
41 | 41 | |
42 | 42 | <?php print_user_stylesheet() ?> |
43 | 43 | |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | </script> |
57 | 57 | |
58 | 58 | <?php |
59 | - foreach (array("lib/prototype.js", |
|
60 | - "lib/scriptaculous/scriptaculous.js?load=effects,controls", |
|
61 | - "lib/dojo/dojo.js", |
|
62 | - "lib/dojo/tt-rss-layer.js", |
|
63 | - "js/common.js", |
|
64 | - "js/prefs.js", |
|
65 | - "errors.php?mode=js") as $jsfile) { |
|
59 | + foreach (array("lib/prototype.js", |
|
60 | + "lib/scriptaculous/scriptaculous.js?load=effects,controls", |
|
61 | + "lib/dojo/dojo.js", |
|
62 | + "lib/dojo/tt-rss-layer.js", |
|
63 | + "js/common.js", |
|
64 | + "js/prefs.js", |
|
65 | + "errors.php?mode=js") as $jsfile) { |
|
66 | 66 | |
67 | - echo javascript_tag($jsfile); |
|
67 | + echo javascript_tag($jsfile); |
|
68 | 68 | |
69 | - } ?> |
|
69 | + } ?> |
|
70 | 70 | |
71 | 71 | <script type="text/javascript"> |
72 | 72 | require({cache:{}}); |
@@ -74,22 +74,22 @@ discard block |
||
74 | 74 | |
75 | 75 | <script type="text/javascript"> |
76 | 76 | <?php |
77 | - foreach (PluginHost::getInstance()->get_plugins() as $n => $p) { |
|
78 | - if (method_exists($p, "get_prefs_js")) { |
|
79 | - $script = $p->get_prefs_js(); |
|
77 | + foreach (PluginHost::getInstance()->get_plugins() as $n => $p) { |
|
78 | + if (method_exists($p, "get_prefs_js")) { |
|
79 | + $script = $p->get_prefs_js(); |
|
80 | 80 | |
81 | - if ($script) { |
|
82 | - echo "try { |
|
81 | + if ($script) { |
|
82 | + echo "try { |
|
83 | 83 | $script |
84 | 84 | } catch (e) { |
85 | 85 | console.warn('failed to initialize plugin JS: $n', e); |
86 | 86 | }"; |
87 | - } |
|
88 | - } |
|
89 | - } |
|
87 | + } |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - init_js_translations(); |
|
92 | - ?> |
|
91 | + init_js_translations(); |
|
92 | + ?> |
|
93 | 93 | </script> |
94 | 94 | |
95 | 95 | <style type="text/css"> |
@@ -26,7 +26,9 @@ |
||
26 | 26 | require_once "config.php"; |
27 | 27 | require_once "db-prefs.php"; |
28 | 28 | |
29 | - if (!init_plugins()) return; |
|
29 | + if (!init_plugins()) { |
|
30 | + return; |
|
31 | + } |
|
30 | 32 | |
31 | 33 | login_sequence(); |
32 | 34 |