debug
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
// 应用公共文件
|
||||
|
||||
namespace {
|
||||
@@ -863,4 +864,5 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,10 +21,6 @@ class AutoSwitchViewModel
|
||||
throw new HttpException(404, 'Site config not Found');
|
||||
}
|
||||
|
||||
// echo $DomainModel->getFomartSubject('NV_SHENG_URL');
|
||||
|
||||
// exit;
|
||||
|
||||
$TemplatesModel = TemplatesModel::getTemplateOnCacheByTId($DomainModel->t_id);
|
||||
|
||||
if (empty($DomainModel)) {
|
||||
|
||||
@@ -22,6 +22,60 @@ class GanRaoMaModel extends MongoModel
|
||||
*/
|
||||
protected $strCollection = 'gan_rao_ma';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static public $arrSelfClosing = [
|
||||
'<meta name="%s" content="%s" id="%s" class="%s">',
|
||||
'<input type="hidden" name="%s" value="%s" id="%s" class="%s">',
|
||||
'<link rel="%s" href="%s" id="%s" class="%s">',
|
||||
'<base href="%s" id="%s" class="%s">',
|
||||
'<param name="%s" value="%s" id="%s" class="%s">',
|
||||
'<col span="%s" id="%s" class="%s">',
|
||||
'<area shape="rect" coords="%s" href="%s" id="%s" class="%s">',
|
||||
'<span id="%s" class="%s" style="display:none;">%s</span>',
|
||||
'<div id="%s" class="%s" style="display:none;">%s</div>',
|
||||
'<p id="%s" class="%s" style="display:none;">%s</p>',
|
||||
'<strong id="%s" class="%s" style="display:none;">%s</strong>',
|
||||
'<em id="%s" class="%s" style="display:none;">%s</em>',
|
||||
];
|
||||
|
||||
const LETTERS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
|
||||
const CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
|
||||
public static function generateRandomStrings(int $count): array
|
||||
{
|
||||
static $lettersLength = null;
|
||||
static $charsLength = null;
|
||||
|
||||
if ($lettersLength === null) {
|
||||
$lettersLength = strlen(self::LETTERS) - 1;
|
||||
$charsLength = strlen(self::CHARS) - 1;
|
||||
}
|
||||
|
||||
|
||||
$result = array_fill(0, $count, '');
|
||||
|
||||
array_walk($result, function (&$value) use ($lettersLength, $charsLength) {
|
||||
$length = random_int(5, 10);
|
||||
$value = self::LETTERS[random_int(0, $lettersLength)];
|
||||
$i = 1;
|
||||
while ($i < $length) {
|
||||
$value .= self::CHARS[random_int(0, $charsLength)];
|
||||
$i++;
|
||||
}
|
||||
});
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
@@ -35,7 +89,31 @@ class GanRaoMaModel extends MongoModel
|
||||
*/
|
||||
static public function getGrmCode($strDomain, $strPageCode, $intLine, $strDifference, $intStartNumber, $intEndNumber): string
|
||||
{
|
||||
// TODO 干扰码功能实现
|
||||
return (string)mt_rand(1, 100);
|
||||
$arrFilter = [
|
||||
'grm_domain' => (string) $strDomain,
|
||||
'grm_page_code' => (string) $strPageCode,
|
||||
'grm_page_line' => (string)$intLine,
|
||||
'grm_page_diff' => (string) $strDifference,
|
||||
];
|
||||
$arrGrm = self::getInstance()->getOne($arrFilter);
|
||||
|
||||
if (empty($arrGrm)) {
|
||||
$intNum = mt_rand($intStartNumber, $intEndNumber);
|
||||
$arrGrmCode = self::$arrSelfClosing;
|
||||
shuffle($arrGrmCode);
|
||||
$arrGrmCode = array_slice($arrGrmCode, 0, $intNum);
|
||||
$strGrmCode = implode('', $arrGrmCode);
|
||||
$intRandNum = substr_count($strGrmCode, '%s');
|
||||
$arrRandStr = self::generateRandomStrings($intRandNum);
|
||||
$strGrmCode = sprintf($strGrmCode, ...$arrRandStr);
|
||||
|
||||
$arrData = $arrFilter;
|
||||
$arrData['grm_code'] = $strGrmCode;
|
||||
self::getInstance()->insert($arrData);
|
||||
} else {
|
||||
$strGrmCode = $arrGrm['grm_code'];
|
||||
}
|
||||
|
||||
return $strGrmCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,22 @@ use think\facade\Cache;
|
||||
*/
|
||||
abstract class MongoModel
|
||||
{
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var GanRaoMaModel
|
||||
*/
|
||||
static public $obj;
|
||||
|
||||
static public function getInstance()
|
||||
{
|
||||
if (static::$obj == NULL) {
|
||||
static::$obj = new static;
|
||||
}
|
||||
return static::$obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* collection name
|
||||
*
|
||||
@@ -115,4 +131,16 @@ abstract class MongoModel
|
||||
Cache::set($strKey, $mixedData, $intLifeTime);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $arrData
|
||||
* @return mixed
|
||||
*/
|
||||
public function insert(array $arrData, array $arrOptions = []): mixed
|
||||
{
|
||||
$Result = $this->getCol()->insertOne($arrData);
|
||||
return $Result->getInsertedId();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user