1 |
<?php |
2 |
// vim: ts=4 foldcolumn=4 foldmethod=marker |
3 |
/** |
4 |
* Initializes Refeed. |
5 |
* |
6 |
* This file is part of Reblog, |
7 |
* a derivative work of Feed On Feeds. |
8 |
* |
9 |
* Distributed under the Gnu Public License. |
10 |
* |
11 |
* @package Refeed |
12 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
13 |
* @author Michal Migurski <mike@stamen.com> |
14 |
* @author Michael Frumin <mfrumin@eyebeam.org> |
15 |
* @copyright ©2004 Michael Frumin, Michal Migurski |
16 |
* @link http://reblog.org Reblog |
17 |
* @link http://feedonfeeds.com Feed On Feeds |
18 |
* @version $Revision: 1.56 $ |
19 |
* |
20 |
* @uses REF_TIMEZONE Assigned to TZ environment variable for correct client time |
21 |
* @uses get_configured_dsn() Passed to database on initial connection |
22 |
* @uses get_configured_cache_dir() Set as cookie save path |
23 |
* @uses get_configured_cookielifetime() Set as cookie lifetime |
24 |
* @uses get_refeed_root() Used to determine cookie path |
25 |
* @uses initialize_globals() |
26 |
* @uses RF_Controller::RF_Controller() Passed to initialize_globals() |
27 |
* @uses RF_User::_authenticate() Passed to initialize_globals() |
28 |
* @uses RF_Install_Controller::RF_Install_Controller() Instantiated to check that Refeed 2.x is fully installed |
29 |
* @uses RF_Install_Controller::refeedInstalled() Used to check whether Refeed 2.x is installed at the beginning of each request |
30 |
*/ |
31 |
|
32 |
require_once(dirname(__FILE__) . '/includes.php'); |
33 |
require_once(dirname(__FILE__) . '/config.php'); |
34 |
|
35 |
// session crap |
36 |
|
37 |
|
38 |
if(php_sapi_name() != 'cli') { |
39 |
session_save_path(get_configured_cache_dir()); |
40 |
session_set_cookie_params(get_configured_cookielifetime(), get_refeed_root(dirname(__FILE__))); |
41 |
session_start(); |
42 |
initialize_session_variables(); |
43 |
} |
44 |
|
45 |
// time zone setup |
46 |
|
47 |
initialize_timezone(); |
48 |
|
49 |
// pear db library setup |
50 |
|
51 |
$dbh = & DB::connect(get_configured_dsn(), |
52 |
array('debug' => REF_DB_DEBUG_LEVEL, 'portability' => DB_PORTABILITY_NONE)); |
53 |
|
54 |
if(DB::isError($dbh)) |
55 |
die(sprintf('<p><b>%s.</b></p><pre>%s</pre>', htmlspecialchars($dbh->getMessage()), htmlspecialchars($dbh->getDebugInfo()))); |
56 |
|
57 |
|
58 |
// determine authetication method |
59 |
|
60 |
$auth_class = 'RF_User'; |
61 |
if(defined('REBLOG_AUTH_TYPE') && REBLOG_AUTH_TYPE) { |
62 |
$class = sprintf('%s_User', strtoupper(REBLOG_AUTH_TYPE)); |
63 |
$auth_file = sprintf('%s/library/RF/%s.class.php', dirname(__FILE__), $class); |
64 |
if(file_exists($auth_file)) { |
65 |
require_once($auth_file); |
66 |
$auth_class = $class; |
67 |
} |
68 |
} |
69 |
|
70 |
|
71 |
// global(s) setup |
72 |
|
73 |
initialize_globals(new RF_Controller($dbh, $dbh), |
74 |
call_user_func(array($auth_class, '_authenticate'), $dbh), |
75 |
new RF_Page()); |
76 |
|
77 |
// check installation |
78 |
|
79 |
if(empty($installing) && empty($SUPPRESS_INSTALL_VERIFY)) { |
80 |
$install_controller = new RF_Install_Controller($GLOBALS['REBLOG_CONTROLLER']); |
81 |
|
82 |
if(!$install_controller->refeedInstalled()) |
83 |
die("I can't find a usable cache directory. Have you tried <a href=\"install.php\">installing Refeed</a>?"); |
84 |
} |
85 |
|
86 |
?> |