Exemple #1
0
if ($server_total == $client_total) {
    if ($server_checksum == $client_checksum) {
        if ($main_script) {
            $database_logs->log("The Consultation Notes are up to date", Filter_Roles::TRANSLATOR_LEVEL);
        }
        die;
    }
}
// At this stage the total note count and/or their checksum on the client differs
// from the total note count and/or their checksum on the server.
// This applies to a certain range of notes for certain Bibles.
// The script knows the total number of notes.
// It the total note count is too high, it divides the range of notes into smaller ranges,
// and then starts one script for each range.
if ($server_total > 20) {
    $ranges = Sync_Logic::create_range($lowId, $highId);
    foreach ($ranges as $range) {
        $low = $range[0];
        $high = $range[1];
        Tasks_Logic::queue(Tasks_Logic::PHP, array(__DIR__ . "/syncnotes.php", "{$low}", "{$high}"));
    }
    die;
}
// At this stage the total note count is small enough that the script can
// start to deal with the individual notes.
// It requests the note identifiers, their checksums,
// and compares them with the local notes.
// If needed, it downloads the notes from the server.
// If needed, the client removes local notes no longer available on the server.
// Get note identifiers and checksums as on the server.
$post = array("a" => "identifiers", "u" => bin2hex($user), "p" => $md5, "l" => $lowId, "h" => $highId);
Exemple #2
0
 public function testCreateRange()
 {
     $ranges = Sync_Logic::create_range(100000000, 999999999);
     $standard = array(array(100000000, 189999998), array(189999999, 279999997), array(279999998, 369999996), array(369999997, 459999995), array(459999996, 549999994), array(549999995, 639999993), array(639999994, 729999992), array(729999993, 819999991), array(819999992, 909999990), array(909999991, 999999999));
     $this->assertEquals($standard, $ranges);
     $ranges = Sync_Logic::create_range(100000000, 100000100);
     $standard = array(array(100000000, 100000009), array(100000010, 100000019), array(100000020, 100000029), array(100000030, 100000039), array(100000040, 100000049), array(100000050, 100000059), array(100000060, 100000069), array(100000070, 100000079), array(100000080, 100000089), array(100000090, 100000100));
     $this->assertEquals($standard, $ranges);
 }