Пример #1
0
 public static function log($sMsg)
 {
     $oLogger = Yaf_Logger::getInstance();
     $oLogger->setLogLevel(1);
     $oLogger->debug(date('[Y-m-d H:i:s]') . $sMsg, self::$sLogName);
     echo date('[Y-m-d H:i:s]') . $sMsg;
 }
Пример #2
0
 /**
  * 构造函数
  */
 private static function init()
 {
     self::$_bInit = true;
     self::$_aConfig = Yaf_G::getConf(null, 'logger');
     $sBaseDir = self::$_aConfig['sBaseDir'];
     unset(self::$_aConfig['sBaseDir']);
     foreach (self::$_aConfig as $sKey => $mConfig) {
         $sDir = isset(self::$_aConfig[$sKey]['sDir']) ? self::$_aConfig[$sKey]['sDir'] : $sKey;
         self::$_aConfig[$sKey]['sPath'] = $sBaseDir . DIRECTORY_SEPARATOR . $sDir . DIRECTORY_SEPARATOR;
         if (!is_dir(self::$_aConfig[$sKey]['sPath'])) {
             umask(00);
             if (false === mkdir(self::$_aConfig[$sKey]['sPath'], 0755, true)) {
                 throw new Exception(__CLASS__ . ': can not create path(' . self::$_aConfig[$sKey]['sPath'] . ').');
                 return false;
             }
         }
     }
 }
Пример #3
0
 /**
  * 支付宝
  */
 public function notifyAction()
 {
     $aParam = $this->getParams();
     Yaf_Logger::debug('notify: ' . json_encode($aParam, JSON_UNESCAPED_UNICODE) . "\n", 'alipay');
     $bRet = Payment_Alipay::callback($aParam);
     $iOrderID = $aParam['out_trade_no'];
     $iMoney = $aParam['total_fee'];
     if ($bRet) {
         // 支付成功
         $this->logPay($aParam);
         $aArg = array('iPayType' => Model_Finance::TYPE_ALIPAY, 'sPayAccount' => $aParam['buyer_email'], 'sPayOrder' => $aParam['trade_no']);
         Model_Finance::pay($iOrderID, $iMoney, $aArg);
         echo "success";
     } else {
         // 支付失败
         echo "fail";
     }
     return false;
 }
Пример #4
0
 public static function log($sMsg)
 {
     Yaf_Logger::debug(date('[Y-m-d H:i:s]') . $sMsg, self::$sLogName);
     echo date('[Y-m-d H:i:s]') . $sMsg;
 }
Пример #5
0
 /**
  * Dispatch an HTTP request to a controller/action.
  *
  * @param Yaf_Request_Abstract|null $request
  *
  * @return void Yaf_Response_Abstract
  */
 public function dispatch()
 {
     $request = $this->getRequest();
     if (!$request instanceof Yaf_Request_Abstract) {
         throw new Yaf_Exception('Expect a Yaf_Request_Abstract instance');
     }
     if ($request instanceof Yaf_Request_Http) {
         $response = new Yaf_Response_Http();
     } elseif ($request instanceof Yaf_Request_Cli) {
         $response = new Yaf_Response_Cli();
     }
     // 选择路由
     $router = $this->getRouter();
     foreach ($this->_plugins as $plugin) {
         $plugin->routerStartup($request, $response);
     }
     $router->route($request);
     $this->_fixDefault($request);
     foreach ($this->_plugins as $plugin) {
         $plugin->routerShutdown($request, $response);
     }
     // 执行Action
     try {
         $view = $this->initView();
         foreach ($this->_plugins as $plugin) {
             $plugin->dispatchLoopStartup($request, $response);
         }
         $nested = Yaf_G::getConf('forward_limit');
         $nested = empty($nested) ? 5 : $nested;
         do {
             foreach ($this->_plugins as $plugin) {
                 $plugin->preDispatch($request, $response, $view);
             }
             $this->handle($request, $response, $view);
             $this->_fixDefault($request);
             foreach ($this->_plugins as $plugin) {
                 $plugin->postDispatch($request, $response);
             }
             $nested--;
         } while (!$request->isDispatched() && $nested > 0);
         foreach ($this->_plugins as $plugin) {
             $plugin->dispatchLoopShutdown($request, $response);
         }
     } catch (Exception $oExp) {
         if (Yaf_G::isDebug() || $request->getMethod() == 'CLI') {
             if ($request->getMethod() == 'CLI') {
                 Yaf_Logger::error(Yaf_G::parseException($oExp));
                 echo Yaf_G::parseException($oExp);
             } else {
                 echo "<pre>";
                 echo Yaf_G::parseException($oExp);
                 echo "</pre>";
             }
         } else {
             $response->setResponseCode(404);
             $view->display('404.phtml');
         }
     }
     if ($nested == 0 && !$request->isDispatched()) {
         throw new Yaf_Exception('The max dispatch nesting ' . Yaf_G::getConf('forward_limit') . ' was reached');
     }
     if ($this->returnResponse() == false) {
         $response->response();
     }
     return $response;
 }
Пример #6
0
 public static function debug($msg)
 {
     Yaf_Logger::debug($msg . "\n", 'wxpay');
 }
Пример #7
0
 /**
  * 获取实例
  * @return Yaf_Logger
  */
 static function getInstance()
 {
     if (!self::$_oInstance instanceof self) {
         self::$_oInstance = new self();
     }
     return self::$_oInstance;
 }