33 lines
957 B
PHP
33 lines
957 B
PHP
|
|
#!/usr/bin/env php
|
||
|
|
<?php
|
||
|
|
/**
|
||
|
|
* 二次风控 Session 与 visit 日志防重复写库
|
||
|
|
*/
|
||
|
|
if (PHP_SAPI !== 'cli') {
|
||
|
|
exit(1);
|
||
|
|
}
|
||
|
|
|
||
|
|
$root = dirname(__DIR__);
|
||
|
|
require_once $root . '/cong.php';
|
||
|
|
require_once $root . '/lib/Cloak/VisitorVisitContext.php';
|
||
|
|
require_once $root . '/lib/Cloak/RiskSecondarySession.php';
|
||
|
|
|
||
|
|
$_SESSION = [];
|
||
|
|
|
||
|
|
RiskSecondarySession::markWaitLog(42);
|
||
|
|
$tests = [];
|
||
|
|
$tests['wait_binds_visit_log'] = VisitorVisitContext::currentLogId() === 42;
|
||
|
|
$tests['wait_should_update'] = VisitorVisitContext::shouldPersistAsUpdate();
|
||
|
|
|
||
|
|
$_SESSION['visit_to_3'] = 3;
|
||
|
|
VisitorVisitContext::finalizeVisit('true');
|
||
|
|
$tests['skip_fp_after_fcheck'] = RiskSecondarySession::shouldSkipFpPageLog();
|
||
|
|
|
||
|
|
RiskSecondarySession::clear();
|
||
|
|
VisitorVisitContext::clear();
|
||
|
|
$tests['clear_resets'] = VisitorVisitContext::currentLogId() === 0;
|
||
|
|
|
||
|
|
$ok = !in_array(false, $tests, true);
|
||
|
|
echo json_encode(['ok' => $ok, 'tests' => $tests], JSON_UNESCAPED_UNICODE) . "\n";
|
||
|
|
exit($ok ? 0 : 1);
|