2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

merged rev. 505

This commit is contained in:
Alex
2015-11-26 18:11:39 +03:00

View File

@@ -57,9 +57,9 @@ function sRandomChars($length = 15,$pattern="23456789abcdefghijkmnpqrstuvwxyz")
for($i=0;$i<$length;$i++) for($i=0;$i<$length;$i++)
{ {
if(isset($key)) if(isset($key))
$key .= $pattern{rand(0,$patternlength)}; $key .= $pattern{mt_rand(0,$patternlength)};
else else
$key = $pattern{rand(0,$patternlength)}; $key = $pattern{mt_rand(0,$patternlength)};
} }
return $key; return $key;
} }
@@ -354,8 +354,19 @@ function add_case($sample_id,$questionnaire_id,$operator_id = "NULL",$testing =
{ {
global $db; global $db;
$ttries = 0;
do {
$token = sRandomChars(); $token = sRandomChars();
$sql = "SELECT count(*) as c
FROM `case`
WHERE token = '$token'";
$ttries++;
} while ($db->GetOne($sql) > 0 && $ttries < 10);
$sql = "INSERT INTO `case` (case_id, sample_id, questionnaire_id, last_call_id, current_operator_id, current_call_id, current_outcome_id,token) $sql = "INSERT INTO `case` (case_id, sample_id, questionnaire_id, last_call_id, current_operator_id, current_call_id, current_outcome_id,token)
VALUES (NULL, $sample_id, $questionnaire_id, NULL, $operator_id, NULL, '$current_outcome_id','$token')"; VALUES (NULL, $sample_id, $questionnaire_id, NULL, $operator_id, NULL, '$current_outcome_id','$token')";
@@ -716,6 +727,7 @@ function get_case_id($operator_id, $create = false)
} }
$r2 = $db->GetRow($sql); $r2 = $db->GetRow($sql);
if (empty($r2)) if (empty($r2))
{ {