-
Notifications
You must be signed in to change notification settings - Fork 9
/
install.php
362 lines (290 loc) · 9.69 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<?php
/*
* This file is part of FEED ON FEEDS - http://feedonfeeds.com/
*
* install.php - creates tables and cache directory, if they don't exist
*
*
* Copyright (C) 2004-2007 Stephen Minutillo
* [email protected] - http://minutillo.com/steve/
*
* Distributed under the GPL - see LICENSE
*
*/
$fof_no_login = true;
$fof_installer = true;
include_once("fof-main.php");
fof_set_content_type();
// compatibility testing code lifted from SimplePie
function get_curl_version()
{
if (is_array($curl = curl_version()))
{
$curl = $curl['version'];
}
else if (preg_match('/curl\/(\S+)(\s|$)/', $curl, $match))
{
$curl = $match[1];
}
else
{
$curl = 0;
}
return $curl;
}
$php_ok = (function_exists('version_compare') && version_compare(phpversion(), '4.3.2', '>='));
$xml_ok = extension_loaded('xml');
$pcre_ok = extension_loaded('pcre');
$mysql_ok = extension_loaded('mysql');
$curl_ok = (extension_loaded('curl') && version_compare(get_curl_version(), '7.10.5', '>='));
$zlib_ok = extension_loaded('zlib');
$mbstring_ok = extension_loaded('mbstring');
$iconv_ok = extension_loaded('iconv');
?>
<!DOCTYPE html>
<html>
<head><title>feed on feeds - installation</title>
<link rel="stylesheet" href="fof.css" media="screen" />
<script src="fof.js" type="text/javascript"></script>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
<style>
body
{
font-family: georgia;
font-size: 16px;
}
div
{
background: #eee;
border: 1px solid black;
width: 75%;
margin: 5em auto;
padding: 1.5em;
}
hr
{
height:0;
border:0;
border-top:1px solid #999;
}
.fail { color: red; }
.pass { color: green; }
.warn { color: #a60; }
</style>
</head>
<body><div> <center style="font-size: 20px;"><a href="http://feedonfeeds.com/">Feed on Feeds</a> - Installation</center><br>
<?php
if($_GET['password'] && $_GET['password'] == $_GET['password2'] )
{
$password_hash = md5($_GET['password'] . 'admin');
fof_safe_query("insert into $FOF_USER_TABLE (user_id, user_name, user_password_hash, user_level) values (1, 'admin', '%s', 'admin')", $password_hash);
echo '<center><b>OK! Setup complete! <a href=".">Login as admin</a>, and start subscribing!</center></b></div></body></html>';
}
else
{
if($_GET['password'] != $_GET['password2'] )
{
echo '<center><font color="red">Passwords do not match!</font></center><br><br>';
}
?>
Checking compatibility...
<?php
if($php_ok) echo "<span class='pass'>PHP ok...</span> ";
else
{
echo "<br><span class='fail'>Your PHP version is too old!</span> Feed on Feeds requires at least PHP 4.3.2. Sorry!";
echo "</div></body></html>";
exit;
}
if($xml_ok) echo "<span class='pass'>XML ok...</span> ";
else
{
echo "<br><span class='fail'>Your PHP installation is missing the XML extension!</span> This is required by Feed on Feeds. Sorry!";
echo "</div></body></html>";
exit;
}
if($pcre_ok) echo "<span class='pass'>PCRE ok...</span> ";
else
{
echo "<br><span class='fail'>Your PHP installation is missing the PCRE extension!</span> This is required by Feed on Feeds. Sorry!";
echo "</div></body></html>";
exit;
}
if($mysql_ok) echo "<span class='pass'>MySQL ok...</span> ";
else
{
echo "<br><span class='fail'>Your PHP installation is missing the MySQL extension!</span> This is required by Feed on Feeds. Sorry!";
echo "</div></body></html>";
exit;
}
if($curl_ok) echo "<span class='pass'>cURL ok...</span> ";
else
{
echo "<br><span class='warn'>Your PHP installation is either missing the cURL extension, or it is too old!</span> cURL version 7.10.5 or later is required to be able to subscribe to https or digest authenticated feeds.<br>";
}
if($zlib_ok) echo "<span class='pass'>Zlib ok...</span> ";
else
{
echo "<br><span class='warn'>Your PHP installation is missing the Zlib extension!</span> Feed on Feeds will not be able to save bandwidth by requesting compressed feeds.<br>";
}
if($iconv_ok) echo "<span class='pass'>iconv ok...</span> ";
else
{
echo "<br><span class='warn'>Your PHP installation is missing the iconv extension!</span> The number of international languages that Feed on Feeds can handle will be reduced.<br>";
}
if($mbstring_ok) echo "<span class='pass'>mbstring ok...</span> ";
else
{
echo "<br><span class='warn'>Your PHP installation is missing the mbstring extension!</span> The number of international languages that Feed on Feeds can handle will be reduced.<br>";
}
?>
<br>Minimum requirements met!
<hr>
Creating tables...
<?php
$tables[] = <<<EOQ
CREATE TABLE IF NOT EXISTS `$FOF_FEED_TABLE` (
`feed_id` int(11) NOT NULL auto_increment,
`feed_url` text NOT NULL,
`feed_title` text NOT NULL,
`feed_link` text NOT NULL,
`feed_description` text NOT NULL,
`feed_image` text,
`feed_image_cache_date` int(11) default '0',
`feed_cache_date` int(11) default '0',
`feed_cache_attempt_date` int(11) default '0',
`feed_cache` text,
PRIMARY KEY (`feed_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
EOQ;
$tables[] = <<<EOQ
CREATE TABLE IF NOT EXISTS `$FOF_ITEM_TABLE` (
`item_id` int(11) NOT NULL auto_increment,
`feed_id` int(11) NOT NULL default '0',
`item_guid` text NOT NULL,
`item_link` text NOT NULL,
`item_cached` int(11) NOT NULL default '0',
`item_published` int(11) NOT NULL default '0',
`item_updated` int(11) NOT NULL default '0',
`item_title` text NOT NULL,
`item_content` text NOT NULL,
PRIMARY KEY (`item_id`),
KEY `feed_id` (`feed_id`),
KEY `item_guid` (`item_guid`(255)),
KEY `feed_id_item_cached` (`feed_id`,`item_cached`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
EOQ;
$tables[] = <<<EOQ
CREATE TABLE IF NOT EXISTS `$FOF_ITEM_TAG_TABLE` (
`user_id` int(11) NOT NULL default '0',
`item_id` int(11) NOT NULL default '0',
`tag_id` int(11) NOT NULL default '0',
PRIMARY KEY (`user_id`,`item_id`,`tag_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
EOQ;
$tables[] = <<<EOQ
CREATE TABLE IF NOT EXISTS `$FOF_SUBSCRIPTION_TABLE` (
`feed_id` int(11) NOT NULL default '0',
`user_id` int(11) NOT NULL default '0',
`subscription_prefs` text,
PRIMARY KEY (`feed_id`,`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
EOQ;
$tables[] = <<<EOQ
CREATE TABLE IF NOT EXISTS `$FOF_TAG_TABLE` (
`tag_id` int(11) NOT NULL auto_increment,
`tag_name` char(100) NOT NULL default '',
PRIMARY KEY (`tag_id`),
UNIQUE KEY (`tag_name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
EOQ;
$tables[] = <<<EOQ
CREATE TABLE IF NOT EXISTS `$FOF_USER_TABLE` (
`user_id` int(11) NOT NULL auto_increment,
`user_name` varchar(100) NOT NULL default '',
`user_password_hash` varchar(32) NOT NULL default '',
`user_level` enum('user','admin') NOT NULL default 'user',
`user_prefs` text,
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
EOQ;
foreach($tables as $table)
{
if(!fof_db_query($table, 1))
{
exit ("Can't create table. MySQL says: <b>" . mysql_error() . "</b><br>" );
}
}
?>
Tables exist.<hr>
<?php
$result = fof_db_query("show columns from $FOF_FEED_TABLE like 'feed_image_cache_date'");
if(mysql_num_rows($result) == 0)
{
print "Upgrading schema...";
fof_db_query("ALTER TABLE $FOF_FEED_TABLE ADD `feed_image_cache_date` INT( 11 ) DEFAULT '0' AFTER `feed_image` ;");
print "Done.<hr>";
}
?>
<?php
$result = fof_db_query("show columns from $FOF_USER_TABLE like 'user_password_hash'");
if(mysql_num_rows($result) == 0)
{
print "Upgrading schema...";
fof_db_query("ALTER TABLE $FOF_USER_TABLE CHANGE `user_password` `user_password_hash` VARCHAR( 32 ) NOT NULL");
fof_db_query("update $FOF_USER_TABLE set user_password_hash = md5(concat(user_password_hash, user_name))");
print "Done.<hr>";
}
?>
<?php
$result = fof_db_query("show columns from $FOF_FEED_TABLE like 'feed_cache_attempt_date'");
if(mysql_num_rows($result) == 0)
{
print "Upgrading schema...";
fof_db_query("ALTER TABLE $FOF_FEED_TABLE ADD `feed_cache_attempt_date` INT( 11 ) DEFAULT '0' AFTER `feed_cache_date` ;");
print "Done.<hr>";
}
?>
Inserting initial data...
<?php
fof_db_query("insert into $FOF_TAG_TABLE (tag_id, tag_name) values (1, 'unread')", 1);
fof_db_query("insert into $FOF_TAG_TABLE (tag_id, tag_name) values (2, 'star')", 1);
?>
Done.<hr>
Checking cache directory...
<?php
if ( ! file_exists( "cache" ) )
{
$status = @mkdir( "cache", 0755 );
if ( ! $status )
{
echo "<font color='red'>Can't create directory <code>" . getcwd() . "/cache/</code>.<br>You will need to create it yourself, and make it writeable by your PHP process.<br>Then, reload this page.</font>";
echo "</div></body></html>";
exit;
}
}
if(!is_writable( "cache" ))
{
echo "<font color='red'>The directory <code>" . getcwd() . "/cache/</code> exists, but is not writable.<br>You will need to make it writeable by your PHP process.<br>Then, reload this page.</font>";
echo "</div></body></html>";
exit;
}
?>
Cache directory exists and is writable.<hr>
<?php
$result = fof_db_query("select * from $FOF_USER_TABLE where user_name = 'admin'");
if(mysql_num_rows($result) == 0) {
?>
You now need to choose an initial password for the 'admin' account:<br>
<form>
<table>
<tr><td>Password:</td><td><input type=password name=password></td></tr>
<tr><td>Password again:</td><td><input type=password name=password2></td></tr>
</table>
<input type=submit value="Set Password">
</form>
<?php } else { ?>
'admin' account already exists.<br>
<br><b><center>OK! Setup complete! <a href=".">Login as admin</a>, and start subscribing!</center></b>
<?php } } ?>
</div></body></html>