3 # global configuration object
5 // default configuration, overwritten in config.php
9 array('name' => 'Just another µB'),
11 array('phptype' => 'mysql',
12 'username' => 'stoica',
13 'password' => 'apasswd',
14 'hostspec' => 'localhost',
15 'database' => 'thedb')
18 'portability' => DB_PORTABILITY_ALL));
20 require_once(INSTALLDIR . '/config.php');
21 require_once('DB.php');
23 function common_database() {
25 $db =& DB::connect($config['dsn'], $config['dboptions']);
26 if (PEAR::isError($db)) {
27 common_server_error($db->getMessage());
33 function common_read_database() {
34 // XXX: read from slave server
35 return common_database();
38 function common_server_error($msg) {
39 header('Status: 500 Server Error');
40 header('Content-type: text/plain');
46 function common_user_error($msg) {
47 common_show_header('Error');
48 common_element('div', array('class' => 'error'), $msg);
52 function common_element_start($tag, $attrs=NULL) {
54 if (is_array($attrs)) {
55 foreach ($attrs as $name => $value) {
56 print " $name='$value'";
58 } else if (is_string($attrs)) {
59 print " class='$attrs'";
64 function common_element_end($tag) {
68 function common_element($tag, $attrs=NULL, $content=NULL) {
69 common_element_start($tag, $attrs);
70 if ($content) print $content;
71 common_element_end($tag);
74 function common_show_header($pagetitle) {
76 common_element_start('html');
77 common_element_start('head');
78 common_element('title', NULL, $pagetitle . " - " . $config['site']['name']);
79 common_element_end('head');
80 common_element_start('body');
83 function common_show_footer() {
84 common_element_end('body');
85 common_element_end('html');
88 // TODO: set up gettext
90 function _t($str) { $str }