示例#1
0
 public static function get()
 {
     if (self::$_instance === null) {
         self::$_instance = new Bbx_Config();
     }
     return self::$_instance;
 }
示例#2
0
文件: Mail.php 项目: rdallasgray/bbx
 public static function instance()
 {
     $args = func_get_args();
     $userOptions = array();
     if (count($args) > 0) {
         $userOptions = $args[0];
     }
     if (self::$_instance === null) {
         $options = array();
         if (isset(Bbx_Config::get()->site->smtp_username)) {
             $options = array('auth' => 'login', 'username' => Bbx_Config::get()->site->smtp_username, 'password' => Bbx_Config::get()->site->smtp_password);
         }
         if (isset(Bbx_Config::get()->site->smtp_port)) {
             $options['port'] = Bbx_Config::get()->site->smtp_port;
         }
         if (isset(Bbx_Config::get()->site->smtp_ssl)) {
             $options['ssl'] = Bbx_Config::get()->site->smtp_ssl;
         }
         $port = array_key_exists('port', $options) ? $options['port'] : 25;
         $options = array_merge($options, $userOptions);
         $transport = new Zend_Mail_Transport_Smtp(Bbx_Config::get()->site->smtp_server, $options);
         Zend_Mail::setDefaultTransport($transport);
         self::$_instance = new Bbx_Mail();
     }
     return self::$_instance;
 }
示例#3
0
文件: Media.php 项目: rdallasgray/bbx
 public function __construct()
 {
     parent::__construct();
     $cdnType = @Bbx_Config::get()->site->cdn->type;
     if ($cdnType != null) {
         $this->_initCdn($cdnType);
     }
 }
示例#4
0
文件: S3.php 项目: rdallasgray/bbx
 protected function __construct()
 {
     $this->_endpoint = Bbx_Config::get()->site->cdn->endpoint;
     $accessKey = Bbx_Config::get()->site->cdn->accessKey;
     $secretKey = Bbx_Config::get()->site->cdn->secretKey;
     $this->_service = new Zend_Service_Amazon_S3($accessKey, $secretKey);
     $this->_service->registerStreamWrapper('s3');
     $this->_service->setEndpoint($this->_endpoint);
     $this->_bucket = Bbx_Config::get()->site->cdn->bucket;
 }
示例#5
0
文件: Admin.php 项目: rdallasgray/bbx
 protected function _doCdnSync()
 {
     $cdnType = @Bbx_Config::get()->site->cdn->type;
     if (APPLICATION_ENV == 'production' && $cdnType != null) {
         Bbx_Log::write('Doing CDN sync');
         $pid = exec('nice php ' . APPLICATION_PATH . '/../library/Bbx/bin/cdn-sync.php /www/media ' . $cdnType . ' 2>&1 &', $out, $result);
         if ($result !== 0) {
             Bbx_Log::write("CDN command failed with the following output: ");
             Bbx_Log::write(print_r($out, true));
         }
     } else {
         Bbx_Log::write('App env is ' . APPLICATION_ENV . '; cdnType is ' . $cdnType);
     }
 }
示例#6
0
文件: Error.php 项目: rdallasgray/bbx
 public function notify(Exception $e)
 {
     if (isset(Bbx_Config::get()->site->support_address) && APPLICATION_ENV != 'development') {
         try {
             $mail = Bbx_Mail::instance();
             $mail->setFrom('error@' . Bbx_Config::get()->site->location, Bbx_Config::get()->site->location);
             $mail->setBodyText($this->getRequest()->getRequestUri() . "\n\n" . $e->getMessage());
             $mail->addTo(Bbx_Config::get()->site->support_address);
             $mail->setSubject('Error at ' . Bbx_Config::get()->site->location);
             $mail->sendAsync();
         } catch (Exception $exc) {
             Bbx_Log::debug(print_r($e, true));
             Bbx_Log::debug("Couldn't send mail: " . $exc->getMessage());
         }
     } else {
         Bbx_Log::debug(print_r($e, true));
     }
 }
示例#7
0
文件: Tools.php 项目: rdallasgray/bbx
 public function regenerateImageAction()
 {
     $this->_helper->authenticate();
     set_time_limit(86400);
     $id = $this->_getParam('id');
     if (empty($id)) {
         return;
     }
     $cdnType = @Bbx_Config::get()->site->cdn->type;
     $img = Bbx_Model::load('Image')->find($id);
     $img->regenerateSizedMedia(null, true);
     if (APPLICATION_ENV == 'production' && $cdnType != null) {
         Bbx_Log::write('Doing CDN sync');
         $pid = exec('nice php ' . APPLICATION_PATH . '/../library/Bbx/bin/cdn-sync.php /www/media ' . $cdnType . ' > /dev/null 2>&1 &');
     }
     // TODO send a JSON response
     $this->getResponse()->sendResponse();
     exit;
 }
示例#8
0
 protected function _httpAuth()
 {
     $config = array('accept_schemes' => 'digest', 'realm' => Bbx_Config::get()->site->location, 'digest_domains' => '/', 'nonce_timeout' => 3600);
     $adaptor = new Zend_Auth_Adapter_Http($config);
     $this->_resolver = new Bbx_Auth_Resolver_Db();
     $adaptor->setDigestResolver($this->_resolver)->setRequest($this->getRequest())->setResponse($this->getResponse());
     try {
         $auth = $adaptor->authenticate();
         if (!$auth->isValid()) {
             if (isset($this->_redirect)) {
                 $body = $this->_getRedirectBody();
             } else {
                 $body = $this->_get403Body();
             }
             $this->getResponse()->setHttpResponseCode(401)->setBody($body)->sendResponse();
             exit;
         }
         return $auth->isValid();
     } catch (Exception $e) {
         Bbx_Log::write('Exception during authentication: ' . $e->getMessage());
         throw new Bbx_Controller_Rest_Exception(null, 401);
     }
 }
示例#9
0
<?php

require 'init.php';
$u = Bbx_Config::get()->resources->db->params->username;
$p = Bbx_Config::get()->resources->db->params->password;
$d = Bbx_Config::get()->resources->db->params->dbname;
$path = APPLICATION_PATH . '/scripts/migrations';
$cmd = "mysql --user={$u} --password='******' < {$path}/schema.sql";
exec($cmd);
示例#10
0
文件: lib.php 项目: rdallasgray/bbx
function bbx_escape($string)
{
    return htmlspecialchars((string) $string, ENT_COMPAT, Bbx_Config::get()->locale->charset);
}
示例#11
0
文件: User.php 项目: rdallasgray/bbx
 protected function _beforeSave()
 {
     if (empty($this->_oldData) || ($this->password !== $this->_oldData['password'] || $this->username !== $this->_oldData['username'])) {
         $this->password = md5($this->username . ':' . Bbx_Config::get()->site->location . ':' . $this->password);
     }
 }
示例#12
0
 public function config()
 {
     return Bbx_Config::get();
 }
示例#13
0
文件: Date.php 项目: rdallasgray/bbx
 protected static function _getFinalDate($timestamp, $parts, $format)
 {
     if ($format === null) {
         $format = Bbx_Config::get()->locale->datetime_format;
     }
     $formatArray = self::_parseFormat($format);
     $finalFormatArray = array();
     foreach ($formatArray as $key => $value) {
         if (array_key_exists($key, $parts)) {
             $finalFormatArray[$key] = $formatArray[$key];
         }
     }
     $format = implode('', $finalFormatArray);
     return date($format, $timestamp);
 }
示例#14
0
 protected function _initLocale()
 {
     if (function_exists('mb_internal_encoding')) {
         mb_internal_encoding(Bbx_Config::get()->locale->charset);
     }
 }