Files
huntingclubroster/tests/resource_worker.php

10 lines
546 B
PHP

<?php
if(PHP_SAPI!=='cli')exit;
require __DIR__.'/../classes/Base.php';
if(!preg_match('/\Ahcr_http_test_[a-f0-9]{12}\z/',getenv('HCR_DB_NAME')?:''))throw new RuntimeException('Disposable database required.');
$_SESSION=[Base::USER_SERIAL=>(int)$argv[1]];
$start=(float)$argv[3];if($start>microtime(true)+5)throw new RuntimeException('Invalid start time.');
while(microtime(true)<$start)usleep(1000);
try{(new ClubResources())->consume((int)$argv[2],'export');echo 'allowed';}
catch(AppException $e){if($e->status!==429)throw $e;echo 'limited';}