mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
announce use new checkClient()
This commit is contained in:
@@ -62,7 +62,8 @@ class Test extends Command
|
|||||||
$peerId = '-TR2920-9bqp8iu7v9se';
|
$peerId = '-TR2920-9bqp8iu7v9se';
|
||||||
$agent = 'Transmission/2.92';
|
$agent = 'Transmission/2.92';
|
||||||
$rep = new AgentAllowRepository();
|
$rep = new AgentAllowRepository();
|
||||||
$r = $rep->checkClient($peerId, $agent, true);
|
// $r = $rep->checkClient($peerId, $agent, true);
|
||||||
|
$r = array_slice([1,2], 1, 3);
|
||||||
dd($r);
|
dd($r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ class AgentAllowRepository extends BaseRepository
|
|||||||
throw new NexusException(sprintf('pattern: %s can not match start: %s', $pattern, $start));
|
throw new NexusException(sprintf('pattern: %s can not match start: %s', $pattern, $start));
|
||||||
}
|
}
|
||||||
$matchCount = count($matches) - 1;
|
$matchCount = count($matches) - 1;
|
||||||
if ($matchNum > $matchCount) {
|
//due to old data may be matchNum > matchCount
|
||||||
|
if ($matchNum > $matchCount && !IN_NEXUS) {
|
||||||
throw new NexusException("pattern: $pattern match start: $start got matches count: $matchCount, but require $matchNum.");
|
throw new NexusException("pattern: $pattern match start: $start got matches count: $matchCount, but require $matchNum.");
|
||||||
}
|
}
|
||||||
return array_slice($matches, 1, $matchNum);
|
return array_slice($matches, 1, $matchNum);
|
||||||
|
|||||||
+17
-2
@@ -90,11 +90,26 @@ unset($GLOBALS['CURUSER']);
|
|||||||
$CURUSER = $GLOBALS["CURUSER"] = $az;
|
$CURUSER = $GLOBALS["CURUSER"] = $az;
|
||||||
|
|
||||||
//3. CHECK IF CLIENT IS ALLOWED
|
//3. CHECK IF CLIENT IS ALLOWED
|
||||||
$clicheck_res = check_client($peer_id,$agent,$client_familyid);
|
//$clicheck_res = check_client($peer_id,$agent,$client_familyid);
|
||||||
|
/**
|
||||||
|
* refactor check client
|
||||||
|
*
|
||||||
|
* @since v1.6.0-beta14
|
||||||
|
*/
|
||||||
|
$agentAllowRep = new \App\Repositories\AgentAllowRepository();
|
||||||
|
$clicheck_res = '';
|
||||||
|
try {
|
||||||
|
$checkClientResult = $agentAllowRep->checkClient($peer_id, $agent);
|
||||||
|
$client_familyid = $checkClientResult->id;
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
$clicheck_res = $exception->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
if($clicheck_res){
|
if($clicheck_res){
|
||||||
if ($az['showclienterror'] == 'no')
|
if ($az['showclienterror'] == 'no')
|
||||||
{
|
{
|
||||||
sql_query("UPDATE users SET showclienterror = 'yes' WHERE id = ".sqlesc($userid));
|
// sql_query("UPDATE users SET showclienterror = 'yes' WHERE id = ".sqlesc($userid));
|
||||||
|
$USERUPDATESET[] = "showclienterror = 'yes'";
|
||||||
$Cache->delete_value('user_passkey_'.$passkey.'_content');
|
$Cache->delete_value('user_passkey_'.$passkey.'_content');
|
||||||
}
|
}
|
||||||
err($clicheck_res);
|
err($clicheck_res);
|
||||||
|
|||||||
Reference in New Issue
Block a user