init.php 1.36 KB
<?php
set_include_path('.' . PATH_SEPARATOR . '/vhost/zend/library/' . PATH_SEPARATOR . get_include_path());

include("Zend/Config.php");
include("Zend/Config/Ini.php");
include("Zend/Log.php");
include("Zend/Log/Writer/Stream.php");
include("Zend/Acl.php");
include("Zend/Date.php");
include("Zend/Db.php");
include("Zend/Auth.php");
include("Zend/Form.php");
include("Zend/Validate.php");
include("Zend/Layout.php");

### TODO ### ### ###
$configfilepath = '/vhost/lippukauppa09/config.ini';



# # # # #
# Initialize log writing
# # # # #
$logwriter = new Zend_Log_Writer_Stream('/tmp/logfile');
$log = new Zend_Log($logwriter);


# # # # # 
# Object reading config.ini
# # # # #
$conf = new Zend_Config_Ini($configfilepath, NULL);


# # # # #
# Common database object
# # # # #
$dbconf = array(    'host'      => $conf->db->host, 
                    'username'  => $conf->db->username, 
                    'password'  => $conf->db->password, 
                    'dbname'    => $conf->db->database
                );
$db = Zend_Db::factory($conf->db->type, $dbconf);
try {
    $db->fetchall("SELECT 1");
} catch(Exception $e) {
    $log->emerg($e->getMessage() . " in " . $e->getFile() . " line " . $e->getLine());
    
    if($conf->common->debug == True) {
        die("Error: " . $e->getMessage());
    } else {
        die("Virhe, ota yhteys " . $conf->common->email);
    }
}