2008-09-26 05:21:11 +02:00
|
|
|
<?php
|
|
|
|
define('S_OK', 'OK');
|
|
|
|
define('S_BAD_OTP', 'BAD_OTP');
|
|
|
|
define('S_BAD_CLIENT', 'BAD_CLIENT'); // New, added by paul 20080920
|
|
|
|
define('S_REPLAYED_OTP', 'REPLAYED_OTP');
|
|
|
|
define('S_BAD_SIGNATURE', 'BAD_SIGNATURE');
|
|
|
|
define('S_MISSING_PARAMETER', 'MISSING_PARAMETER');
|
|
|
|
//define('S_NO_SUCH_CLIENT', 'NO_SUCH_CLIENT'); // Deprecated by paul 20080920
|
|
|
|
define('S_OPERATION_NOT_ALLOWED', 'OPERATION_NOT_ALLOWED');
|
|
|
|
define('S_BACKEND_ERROR', 'BACKEND_ERROR');
|
|
|
|
|
2008-09-26 07:00:41 +02:00
|
|
|
function debug($msg, $exit = false) {
|
2008-09-26 05:21:11 +02:00
|
|
|
global $trace;
|
|
|
|
if ($trace) {
|
|
|
|
if (is_array($msg)) {
|
|
|
|
print_r($msg);
|
|
|
|
} else {
|
2008-09-26 07:00:41 +02:00
|
|
|
echo 'debug> ' . $msg;
|
2008-09-26 05:21:11 +02:00
|
|
|
}
|
|
|
|
echo "\n";
|
|
|
|
}
|
|
|
|
if ($exit) {
|
2008-09-26 07:00:41 +02:00
|
|
|
die('<font color=red><h4>Exit</h4></font>');
|
2008-09-26 05:21:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-26 07:00:41 +02:00
|
|
|
function genRandRaw($len) {
|
|
|
|
$h = hash_hmac('sha1', rand(9999,9999999), 'dj*ccbcuiiurubrvnubcdluul', true);
|
|
|
|
$a = str_split($h);
|
|
|
|
//print_r($a);
|
|
|
|
$a = array_slice($a, 0, $len);
|
|
|
|
//print_r($a);
|
|
|
|
$s = implode($a);
|
|
|
|
//outputToFile('out', $s);
|
|
|
|
return $s;
|
2008-09-26 05:21:11 +02:00
|
|
|
}
|
|
|
|
|
2008-09-26 07:00:41 +02:00
|
|
|
function outputToFile($outFname, $content, $mode, $append = false) {
|
|
|
|
$out = fopen($outFname, ($append ? "a" : "w"));
|
|
|
|
fwrite($out, $content);
|
|
|
|
fclose($out);
|
2008-09-26 05:21:11 +02:00
|
|
|
}
|
|
|
|
?>
|