protected function _setupEnvironment() { error_reporting(E_ALL | E_STRICT); set_include_path($this->getPath('library') . PATH_SEPARATOR . $this->getPath('models') . PATH_SEPARATOR . $this->getPath('controllers') . PATH_SEPARATOR . get_include_path()); require_once 'WebVista/Model/ORM.php'; require_once 'User.php'; require_once 'Person.php'; require_once 'Zend/Session.php'; require_once 'WebVista/Session/SaveHandler.php'; Zend_Session::setSaveHandler(new WebVista_Session_SaveHandler()); Zend_Session::start(); require_once 'Zend/Loader.php'; Zend_Loader::registerAutoLoad(); $sessionTimeout = ini_get('session.gc_maxlifetime') - 5 * 60; Zend_Registry::set('sessionTimeout', $sessionTimeout); $this->_config = new Zend_Config_Ini($this->getPath('application') . "/config/app.ini", APPLICATION_ENVIRONMENT); Zend_Registry::set('config', $this->_config); Zend_Registry::set('baseUrl', substr($_SERVER['PHP_SELF'], 0, strpos(strtolower($_SERVER['PHP_SELF']), 'index.php'))); Zend_Registry::set('basePath', $this->getPath('base') . DIRECTORY_SEPARATOR); try { date_default_timezone_set(Zend_Registry::get('config')->date->timezone); } catch (Zend_Exception $e) { die($e->getMessage()); } AuditLog::setDbConfig($this->_config->database->toArray()); // this MUST be required as this is used as DB connection // register shutdown function register_shutdown_function(array('AuditLog', 'closeConnection')); ob_start(); // this MUST be required after register shutdown return $this; }
public static function execute($subject, $to, $from, $body) { sfOpenPNEApplicationConfiguration::registerZend(); $subject = mb_convert_kana($subject, 'KV'); $mailer = new Zend_Mail('iso-2022-jp'); $mailer->setHeaderEncoding(Zend_Mime::ENCODING_BASE64)->setFrom($from)->addTo($to)->setSubject(mb_encode_mimeheader($subject, 'iso-2022-jp'))->setBodyText(mb_convert_encoding($body, 'JIS', 'UTF-8'), 'iso-2022-jp', Zend_Mime::ENCODING_7BIT); $result = $mailer->send(); Zend_Loader::registerAutoLoad('Zend_Loader', false); return $result; }
public function init() { file_put_contents('/tmp/ldb.log', "\ninit started", FILE_APPEND); error_reporting(E_ALL | E_STRICT); set_include_path($this->getPath('library') . PATH_SEPARATOR . $this->getPath('models') . PATH_SEPARATOR . $this->getPath('controllers') . PATH_SEPARATOR . get_include_path()); require_once 'Zend/Loader.php'; Zend_Loader::registerAutoLoad(); $config = new Zend_Config_Ini($this->getPath('application') . '/config/app.ini', APPLICATION_ENVIRONMENT); Zend_Registry::set('config', $config); date_default_timezone_set($config->date->timezone); try { $dbConfig = $config->database; $dbAdapter = Zend_Db::factory($dbConfig); $dbAdapter->query("SET NAMES 'utf8'"); } catch (Zend_Exception $e) { $error = $e->getMessage(); file_put_contents('/tmp/ldb.log', "\n{$error}", FILE_APPEND); die($error); } Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter); Zend_Registry::set('dbAdapter', $dbAdapter); file_put_contents('/tmp/ldb.log', "\ninit done", FILE_APPEND); return $this; }
public static function unregisterZend() { if (!self::$zendLoaded) { return true; } require_once 'Zend/Loader.php'; Zend_Loader::registerAutoLoad('Zend_Loader', false); self::$zendLoaded = false; }
public static function execute($subject, $to, $from, $body) { if (!$to) { return false; } self::initialize(); opApplicationConfiguration::registerZend(); $subject = mb_convert_kana($subject, 'KV'); $mailer = new Zend_Mail('iso-2022-jp'); $mailer->setHeaderEncoding(Zend_Mime::ENCODING_BASE64)->setFrom($from)->addTo($to)->setSubject(mb_encode_mimeheader($subject, 'iso-2022-jp'))->setBodyText(mb_convert_encoding($body, 'JIS', 'UTF-8'), 'iso-2022-jp', Zend_Mime::ENCODING_7BIT); if ($envelopeFrom = sfConfig::get('op_mail_envelope_from')) { $mailer->setReturnPath($envelopeFrom); } $result = $mailer->send(); Zend_Loader::registerAutoLoad('Zend_Loader', false); return $result; }
$path = array($chAppPath, $chLibraryPath, $chModelsPath, $chTestsPath, get_include_path()); set_include_path(implode(PATH_SEPARATOR, $path)); if (is_readable($chTestsPath . DIRECTORY_SEPARATOR . 'TestConfiguration.php')) { require_once $chTestsPath . DIRECTORY_SEPARATOR . 'TestConfiguration.php'; } else { require_once $chTestsPath . DIRECTORY_SEPARATOR . 'TestConfiguration.php.dist'; } /** * WebVista */ require_once 'WebVista/App.php'; /** * Zend_Loader */ require_once 'Zend/Loader.php'; Zend_Loader::registerAutoLoad(); $frontendOptions = array('lifetime' => 3600, 'automatic_serialization' => true); $backendOptions = array('file_name_prefix' => 'clearhealth', 'hashed_directory_level' => 1, 'cache_dir' => '/tmp/', 'hashed_directory_umask' => 0700); $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); Zend_Registry::set('cache', $cache); $cache = new Memcache(); $cache->connect('127.0.0.1', 11211); $status = $cache->getServerStatus('127.0.0.1', 11211); if ($status === 0) { // memcache server failed, do error trapping? } Zend_Registry::set('memcache', $cache); $config = new Zend_Config_Ini($chAppPath . "/config/app.ini", TESTS_APPLICATION_ENVIRONMENT); Zend_Registry::set('config', $config); try { $dbAdapter = Zend_Db::factory(Zend_Registry::get('config')->database);
public static function execute($subject, $to, $from, $body) { if (!$to) { return false; } self::initialize(); opApplicationConfiguration::registerZend(); $subject = mb_convert_kana($subject, 'KV'); $mailer = new Zend_Mail('iso-2022-jp'); $mailer->setHeaderEncoding(Zend_Mime::ENCODING_BASE64)->setFrom($from)->addTo($to)->setSubject(mb_encode_mimeheader($subject, 'iso-2022-jp'))->setBodyText(mb_convert_encoding($body, 'JIS', 'UTF-8'), 'iso-2022-jp', Zend_Mime::ENCODING_7BIT); if ($envelopeFrom = sfConfig::get('op_mail_envelope_from')) { $mailer->setReturnPath($envelopeFrom); } try { $result = $mailer->send(); } catch (Zend_Mail_Protocol_Exception $e) { if (sfContext::getInstance()->getActionName() === null) { error_log('Mail Send Error'); } else { $action = sfContext::getInstance()->getActionStack()->getFirstEntry()->getActionInstance(); $action->redirect('default/mailError'); } } Zend_Loader::registerAutoLoad('Zend_Loader', false); return $result; }