init.php
1.36 KB
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
<?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);
}
}