Subversion Repositories php_clientchallenge

Compare Revisions

Regard whitespace Rev 8 → Rev 7

/trunk/ClientChallenge.class.php
21,6 → 21,8
 
class ClientChallenge {
 
const OPEN_TRANS_DIR = __DIR__.'/cache';
 
private static function tryDownloadPhpSha3() {
// Download file if required (usually composer should do it)
if (file_exists(__DIR__.'/Sha3.php')) include_once __DIR__.'/Sha3.php';
54,11 → 56,8
}
 
private static function getOpenTransFileName($ip_target, $random) {
$dir = defined('VTS_CS_OPEN_TRANS_DIR') ? VTS_CS_OPEN_TRANS_DIR : __DIR__.'/cache';
if ($dir == '') $dir = '.'; /** @phpstan-ignore-line */
 
// First, delete challenges which were never completed
$files = glob($dir.'/*.tmp');
// Delete challenges which were never completed
$files = glob(self::OPEN_TRANS_DIR.'/*.tmp');
$expire = strtotime('-3 DAYS');
foreach ($files as $file) {
if (!is_file($file)) continue;
66,7 → 65,7
@unlink($file);
}
 
return $dir.'/'.self::sha3_512($ip_target.'/'.$random).'.tmp';
return self::OPEN_TRANS_DIR.'/'.self::sha3_512($ip_target.'/'.$random).'.tmp';
}
 
public static function checkValidation($client_response, $max_time=10, $server_secret) {
/trunk/example/config.inc.php
17,7 → 17,6
* limitations under the License.
*/
 
define('VTS_CS_OPEN_TRANS_DIR', __DIR__.'/../cache/');
define('VTS_CS_SERVER_SECRET', '1234567890'); // PLEASE CHANGE THIS VALUE TO SOMETHING RANDOM!
define('MAX_TIME', 15); // seconds
define('COMPLEXITY', 50000);