예제 #1
0
     return;
 } else {
     $newGUID = "";
     if ($entryType == "Test" || $entryType == "Pilot") {
         $idtest = uniqid();
         $newGUID = "NDAR_INVTEST" . strtoupper(substr($idtest, -4));
         $ar['alternateID'] = getAlternateID();
     } else {
         include $_SERVER["DOCUMENT_ROOT"] . "/ids/idServer.php";
         $newGUID = getNewGUID($site);
         if ($newGUID == -1) {
             echo "{ \"message\": \" ERROR: no more free GUIDS\" }";
         }
         if ($newGUID != -1) {
             // we have a valid id, lets create a new ID
             $ar['alternateID'] = getAlternateID();
         }
     }
     $ar['score'] = -1;
     $ar['pGUID'] = $newGUID;
     $ar['NDA_GUID'] = -1;
 }
 // get the eventType
 $eventType = "";
 if (isset($_POST['eventType'])) {
     $eventType = urldecode($_POST['eventType']);
 } else {
     echo "{ \"message\": \" ERROR: no eventType found\" }";
     return;
 }
 // get the eventNotes
예제 #2
0
    $alternateID = struuid(false);
    $alternateID = 'A' . substr($alternateID, -7);
    sleep(1);
    return $alternateID;
}
// modification time before we change something
$mtimebefore = stat($location)['mtime'];
$data = json_decode(file_get_contents($location), true);
echo "Data read, found " . count($data) . " participants\n";
// now we do the actual work
$c = 0;
foreach ($data as &$part) {
    if (isset($part['alternateID']) && strlen($part['alternateID']) == 8) {
        continue;
    }
    $newaid = getAlternateID();
    echo "SET " . $part['pGUID'] . " -> " . $newaid . "\n";
    $part['alternateID'] = $newaid;
    $c = $c + 1;
}
if ($c > 0) {
    // test the modification time again
    $mtimeafter = stat($location)['mtime'];
    if ($mtimeafter == $mtimebefore) {
        file_put_contents($location, json_encode($data, JSON_PRETTY_PRINT));
        echo "Warning: The file " . $location . " has been changed! Please check for correctness!\n";
    } else {
        // error!
        echo "Error: could not write the new IDs, file changed while we are working";
        return;
    }