Authored by 郝肖肖

找回丢失的代码,台秤

... ... @@ -1111,4 +1111,18 @@ class Helpers
{
return strtr($url, array('http://' => '//'));
}
/**
* 获取当前页面是http还是https
* @return string
*/
public static function getHttpOrHttps() {
if ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ||
(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] === 443) ||
(isset($_SERVER['HTTP_REFERER']) && substr($_SERVER['HTTP_REFERER'], 0, 5) === 'https')) {
return 'https:';
}
return 'http:';
}
}
... ...
<?php
namespace WebPlugin\Pay;
use WebPlugin\Helpers;
abstract class PayAbstract implements PayInterface {
/**
... ... @@ -14,14 +14,14 @@ abstract class PayAbstract implements PayInterface {
*
* @var
*/
public $baseNoticeUrl = "http://www.yohobuy.com/pay/";
public $baseNoticeUrl = "//www.yohobuy.com/pay/";
/**
* 测试的回调地址
* Enter description here ...
* @var string
*/
public $testBaseNoticeUrl = "http://www.yohobuy.com/pay/";
public $testBaseNoticeUrl = "//www.yohobuy.com/pay/";
/**
* 获取支付的基地址
... ... @@ -30,7 +30,7 @@ abstract class PayAbstract implements PayInterface {
* @return string
*/
public function getBaseNoticeUrl($isTest){
return $isTest ? $this->testBaseNoticeUrl : $this->baseNoticeUrl;
return Helpers::getHttpOrHttps() . ($isTest ? $this->testBaseNoticeUrl : $this->baseNoticeUrl);
}
/**
... ...