setFallbackAutoloader ( true ); /* Read in the confiuration file * Options: * 'staging' for home server config * 'development' for uc math development server config * 'production' for uc math production server config * Set it to the global registry */ switch ($_SERVER ['SERVER_NAME']) { case 'res.dnsalias.org' : $config = new Zend_Config_Ini ( '../library/config.ini', 'staging' ); break; case 'mathbsd1.math.canterbury.ac.nz' : $config = new Zend_Config_Ini ( '../library/config.ini', 'development' ); break; default : $config = new Zend_Config_Ini ( '../library/config.ini', 'production' ); } Zend_Registry::set ( 'config', $config ); /* Configure and start the session management for * retaining user information between page loads */ Zend_Session::setOptions ( array ('save_path' => $config->home->path . $config->session->path, 'remember_me_seconds' => 7200 ) ); Zend_Session::start (); $session = new Zend_Session_Namespace ( $config->namespace ); Zend_Registry::set ( 'session', $session ); /* Bring in Smarty for the template system */ require_once $config->smarty->path . 'Smarty.class.php'; $smarty = new Smarty (); $smarty->template_dir = $config->home->path . $config->smarty->template_dir; $smarty->compile_dir = $config->home->path . $config->smarty->compile_dir; $smarty->cache_dir = $config->home->path . $config->smarty->cache_dir; $smarty->config_dir = $config->home->path . $config->smarty->config_dir; $smarty->assign ( 'title', '' ); $smarty->assign ( 'config', $config ); $smarty->assign ( 'session', $session ); Zend_Registry::set ( 'smarty', $smarty ); /* Establish a database connection */ $database = new mysqli ( $config->db->host, $config->db->username, $config->db->password, $config->db->dbname ); Zend_Registry::set ( 'database', $database ); /* Setup the email system */ $mail = new Zend_Mail ('utf-8'); if (isset ( $config->mail->smtphost )) { if (isset ( $config->mail->conf )) { $mailconf = $config->mail->conf->toArray (); } else { $mailconf = array (); } $tr = new Zend_Mail_Transport_Smtp ( $config->mail->smtphost, $mailconf ); Zend_Mail::setDefaultTransport ( $tr ); unset ( $mailconf ); } $mail->setFrom ( $config->mail->from->email, $config->mail->from->name ); Zend_Registry::set ( 'mail', $mail ); /* Windows needs to have checkdnsrr function defined */ if (! function_exists ( 'checkdnsrr' )) { function checkdnsrr($host, $type = 'MX') { return win_checkdnsrr ( $host, $type ); } } /* Pass over control */ app_start (); ?>