Subversion Repositories php_clientchallenge

Compare Revisions

Regard whitespace Rev 4 → Rev 3

/trunk/example/config.inc.php
File deleted
/trunk/example/ajax_example.php
23,18 → 23,12
 
require_once __DIR__ . '/../ClientChallenge.class.php';
 
require_once __DIR__ . '/config.inc.php';
define('MAX_TIME', 10); // seconds
 
if (isset($_REQUEST['action']) && ($_REQUEST['action'] === 'add_numbers')) {
 
// Check request field "vts_validation_result" for valid response of the Challenge
try {
\ViaThinkSoft\RateLimitingChallenge\ClientChallenge::checkValidation(MAX_TIME, VTS_CS_SERVER_SECRET);
} catch (\Exception $e) {
$res = array("error" => $e->getMessage());
header('Content-Type:application/json');
die(json_encode($res));
}
\ViaThinkSoft\RateLimitingChallenge\ClientChallenge::checkValidation(MAX_TIME);
 
// Do your stuff here. Example:
$a = $_REQUEST['a'];
/trunk/example/ajax_get_challenge.php
23,6 → 23,6
 
require_once __DIR__ . '/../ClientChallenge.class.php';
 
require_once __DIR__ . '/config.inc.php';
define('COMPLEXITY', 500000);
 
\ViaThinkSoft\RateLimitingChallenge\ClientChallenge::createChallenge(COMPLEXITY, VTS_CS_SERVER_SECRET);
\ViaThinkSoft\RateLimitingChallenge\ClientChallenge::createChallenge(COMPLEXITY);
/trunk/example/index.html
28,12 → 28,7
"b": params['b']
},
success: function(data) {
if ("error" in data) {
$("#out").val('ERROR');
alert(data["error"]);
} else {
$("#out").val(data["result"]);
}
},
error: error_cb
});