]> git.wh0rd.org - tt-rss.git/blob - sanity_check.php
simplepie: enable digest authentication
[tt-rss.git] / sanity_check.php
1 <?php
2 require_once "functions.php";
3
4 define('EXPECTED_CONFIG_VERSION', 20);
5 define('SCHEMA_VERSION', 78);
6
7 if (!file_exists("config.php")) {
8 print "<b>Fatal Error</b>: You forgot to copy
9 <b>config.php-dist</b> to <b>config.php</b> and edit it.\n";
10 exit;
11 }
12
13 require_once "config.php";
14
15 if (CONFIG_VERSION != EXPECTED_CONFIG_VERSION) {
16 $err_msg = "config: your config file version is incorrect. See config.php-dist.\n";
17 }
18
19 $purifier_cache_dir = "lib/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer";
20
21 if (!is_writable($purifier_cache_dir)) {
22 $err_msg = "config: HTMLPurifier cache directory should be writable by anyone (chmod -R 777 $purifier_cache_dir)";
23 }
24
25 if (defined('RSS_BACKEND_TYPE')) {
26 print "<b>Fatal error</b>: RSS_BACKEND_TYPE is deprecated. Please remove this
27 option from config.php\n";
28 exit;
29 }
30
31 if (file_exists("xml-export.php") || file_exists("xml-import.php")) {
32 print "<b>Fatal Error</b>: XML Import/Export tools (<b>xml-export.php</b>
33 and <b>xml-import.php</b>) could be used maliciously. Please remove them
34 from your TT-RSS instance.\n";
35 exit;
36 }
37
38 if (SINGLE_USER_MODE && DAEMON_UPDATE_LOGIN_LIMIT > 0) {
39 print "<b>Fatal Error</b>: Please set DAEMON_UPDATE_LOGIN_LIMIT
40 to 0 in single user mode.\n";
41 exit;
42 }
43
44 if (USE_CURL_FOR_ICONS && ! function_exists("curl_init")) {
45 print "<b>Fatal Error</b>: You have enabled USE_CURL_FOR_ICONS, but your PHP
46 doesn't seem to support CURL functions.";
47 exit;
48 }
49
50 if (!defined('SESSION_EXPIRE_TIME')) {
51 $err_msg = "config: SESSION_EXPIRE_TIME is undefined";
52 }
53
54 if (SESSION_EXPIRE_TIME < 60) {
55 $err_msg = "config: SESSION_EXPIRE_TIME is too low (less than 60)";
56 }
57
58 if (SESSION_EXPIRE_TIME < SESSION_COOKIE_LIFETIME) {
59 $err_msg = "config: SESSION_EXPIRE_TIME should be greater or equal to" .
60 "SESSION_COOKIE_LIFETIME";
61 }
62
63 /* if (defined('DISABLE_SESSIONS')) {
64 $err_msg = "config: you have enabled DISABLE_SESSIONS. Please disable this option.";
65 } */
66
67 if (DATABASE_BACKED_SESSIONS && SINGLE_USER_MODE) {
68 $err_msg = "config: DATABASE_BACKED_SESSIONS is incompatible with SINGLE_USER_MODE";
69 }
70
71 if (DATABASE_BACKED_SESSIONS && DB_TYPE == "mysql") {
72 $err_msg = "config: DATABASE_BACKED_SESSIONS are currently broken with MySQL";
73 }
74
75 if (SINGLE_USER_MODE) {
76 $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
77
78 if ($link) {
79 $result = db_query($link, "SELECT id FROM ttrss_users WHERE id = 1");
80
81 if (db_num_rows($result) != 1) {
82 $err_msg = "config: SINGLE_USER_MODE is enabled but default admin account (UID=1) is not found.";
83 }
84 }
85 }
86
87 if (defined('MAIL_FROM')) {
88 $err_msg = "config: MAIL_FROM has been split into DIGEST_FROM_NAME and DIGEST_FROM_ADDRESS";
89 }
90
91 if (!defined('COUNTERS_MAX_AGE')) {
92 $err_msg = "config: option COUNTERS_MAX_AGE expected, but not defined";
93 }
94
95 if (defined('DAEMON_REFRESH_ONLY')) {
96 $err_msg = "config: option DAEMON_REFRESH_ONLY is obsolete. Please remove this option and read about other ways to update feeds on the <a href='http://tt-rss.org/wiki/UpdatingFeeds'>wiki</a>.";
97
98 }
99
100 if (defined('ENABLE_SIMPLEPIE')) {
101 $err_msg = "config: ENABLE_SIMPLEPIE is obsolete and replaced with DEFAULT_UPDATE_METHOD. Please adjust your config.php.";
102 }
103
104 if (!defined('DEFAULT_UPDATE_METHOD') || (DEFAULT_UPDATE_METHOD != 0 &&
105 DEFAULT_UPDATE_METHOD != 1)) {
106 $err_msg = "config: DEFAULT_UPDATE_METHOD should be either 0 or 1.";
107 }
108
109 if (!is_writable(ICONS_DIR)) {
110 $err_msg = "config: your ICONS_DIR (" . ICONS_DIR . ") is not writable.\n";
111 }
112
113 if (ini_get("open_basedir")) {
114 $err_msg = "php.ini: open_basedir is not supported.";
115 }
116
117 if (!ini_get("allow_url_fopen")) {
118 $err_msg = "php.ini: allow_url_fopen is required.";
119 }
120
121 if (!function_exists("json_encode")) {
122 $err_msg = "PHP: json functions not found.";
123 }
124
125 if (DB_TYPE == "mysql" && !function_exists("mysql_connect")) {
126 $err_msg = "PHP: MySQL functions not found.";
127 }
128
129 if (DB_TYPE == "pgsql" && !function_exists("pg_connect")) {
130 $err_msg = "PHP: PostgreSQL functions not found.";
131 }
132
133 if (!function_exists("mb_strlen")) {
134 $err_msg = "PHP: mbstring functions not found.";
135 }
136
137 if (ini_get("safe_mode")) {
138 $err_msg = "php.ini: Safe mode is not supported. If you wish to continue, remove this test from sanity_check.php and proceeed at your own risk. Please note that your bug reports will not be accepted or reviewed.";
139 }
140
141 if ($err_msg) {
142 print "<b>Fatal Error</b>: $err_msg\n";
143 exit;
144 }
145
146 ?>