| 1 | <?php
|
|---|
| 2 | $_CONFIG = true;
|
|---|
| 3 |
|
|---|
| 4 | # $db->config
|
|---|
| 5 | $CFG_DBENGINE = 'mysqli';
|
|---|
| 6 | $CFG_USER = 'wikihelp';
|
|---|
| 7 | $CFG_PASSWORD = 'wikihelp';
|
|---|
| 8 | $CFG_SERVER = 'localhost';
|
|---|
| 9 | $CFG_DATABASE = 'wikihelp';
|
|---|
| 10 |
|
|---|
| 11 | # this is the return address for emails
|
|---|
| 12 | $CFG_RETURN_ADDRESS = 'do-not-reply@wikihelp.ca';
|
|---|
| 13 |
|
|---|
| 14 | # Authentification provider
|
|---|
| 15 | $CFG_AUTH_TYPE = 'sql'; #(native use REMOTE_USER and SQL )
|
|---|
| 16 |
|
|---|
| 17 | $config = array('can_register' => true,
|
|---|
| 18 | 'can_login' => ($CFG_AUTH_TYPE != 'native'),
|
|---|
| 19 | 'can_switch_lang' => true,
|
|---|
| 20 | 'show_logo' => false,
|
|---|
| 21 | 'show_nav' => false,
|
|---|
| 22 | 'title' => 'WikiHelp',
|
|---|
| 23 | 'multi_wiki' => false,
|
|---|
| 24 | 'public' => false);
|
|---|
| 25 |
|
|---|
| 26 | $UPLOAD_PATH = "../uploads/"; # relative to /handlers/
|
|---|
| 27 |
|
|---|
| 28 | error_reporting(E_ALL); # report all errors
|
|---|
| 29 | ini_set("display_errors", "0"); # but do not echo the errors
|
|---|
| 30 |
|
|---|
| 31 | /**
|
|---|
| 32 | * Setup the AdoDb object and store it in the registry
|
|---|
| 33 | */
|
|---|
| 34 | require_once('class/adodb5/adodb-exceptions.inc.php');
|
|---|
| 35 | require_once('class/adodb5/adodb.inc.php');
|
|---|
| 36 | require_once('class/registry.php');
|
|---|
| 37 | require_once('class/request.php');
|
|---|
| 38 | require_once('class/user.php');
|
|---|
| 39 | require_once('class/Zend/Loader.php');
|
|---|
| 40 | set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/class');
|
|---|
| 41 |
|
|---|
| 42 | // To autoload Zend Framework component
|
|---|
| 43 | function __autoload($class)
|
|---|
| 44 | {
|
|---|
| 45 | Zend_Loader::loadClass($class);
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | $db = ADONewConnection($CFG_DBENGINE);
|
|---|
| 49 | try {
|
|---|
| 50 | $db->Connect($CFG_SERVER, $CFG_USER, $CFG_PASSWORD, $CFG_DATABASE);
|
|---|
| 51 |
|
|---|
| 52 | // Use field name instead of id
|
|---|
| 53 | $db->SetFetchMode(ADODB_FETCH_ASSOC);
|
|---|
| 54 |
|
|---|
| 55 | // Store it in a main object holder to be able to access it easily via registry::get('db')
|
|---|
| 56 | registry::getInstance()->store('db', $db);
|
|---|
| 57 |
|
|---|
| 58 | // Store a copy for rw acces
|
|---|
| 59 | registry::getInstance()->store('db-rw', $db);
|
|---|
| 60 |
|
|---|
| 61 | // Store a copy (for now) for the password access (Should be a different user/db)
|
|---|
| 62 | registry::getInstance()->store('db-private', $db);
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 | } catch (Exception $ex) {
|
|---|
| 66 | $fatal = 'ERROR : Wikihelp is unable to connect to specified database. ';
|
|---|
| 67 |
|
|---|
| 68 | // Only print DB Error if the user is localhost
|
|---|
| 69 | if (Request::server('REMOTE_ADDR') == '127.0.0.1')
|
|---|
| 70 | $fatal .= $ex->msg;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | // Hard coded wiki and host id
|
|---|
| 74 | registry::getInstance()->store('host', 1);
|
|---|
| 75 | registry::getInstance()->store('wiki', 1);
|
|---|
| 76 |
|
|---|
| 77 | if ( file_exists('config.local.php') )
|
|---|
| 78 | include_once('config.local.php');
|
|---|
| 79 |
|
|---|
| 80 | session_start();
|
|---|
| 81 |
|
|---|
| 82 | // Create an anonymous user if no user exists
|
|---|
| 83 | if(!isset($_SESSION['user_object']) || !$_SESSION['user_object'] instanceof User) {
|
|---|
| 84 | $_SESSION['user_object'] = new User_Anonymous();
|
|---|
| 85 | } |
|---|