Exemple #1
0
    die;
}
$database_logs->log(Locale_Translate::_("Bibles") . ": " . implode(", ", $server_bibles), Filter_Roles::TRANSLATOR_LEVEL);
// The client now has a list of Bibles the user has access to on the server.
// The client deletes all local Bibles not in this list.
// No change Bible actions to be recorded for this operation.
$bibles = $database_bibles->getBibles();
$bibles = array_diff($bibles, $server_bibles);
foreach ($bibles as $bible) {
    $database_bibles->deleteBible($bible);
    $database_logs->log(Locale_Translate::_("Deleting Bible because the server did not grant access to it") . ": " . $bible, Filter_Roles::TRANSLATOR_LEVEL);
}
// The client goes through all the Bibles, and deals with each of them.
foreach ($server_bibles as $bible) {
    // Compare the checksum of the whole Bible on client and server to see if this Bible is in sync.
    $client_checksum = Checksum_Logic::getBible($bible);
    $post = array("b" => $bible, "a" => "bible");
    $server_checksum = Sync_Logic::post($post, $url);
    if ($server_checksum === false) {
        $database_logs->log(Locale_Translate::_("Failure getting Bible checksum"), Filter_Roles::TRANSLATOR_LEVEL);
        continue;
    }
    if ($client_checksum == $server_checksum) {
        $database_logs->log(Locale_Translate::_("The Bible is up to date") . ": {$bible}", Filter_Roles::TRANSLATOR_LEVEL);
        continue;
    }
    // Request all books in the $bible on the server.
    $client_books = $database_bibles->getBooks($bible);
    $post = array("b" => $bible, "a" => "books");
    $server_books = Sync_Logic::post($post, $url);
    if ($server_books === false) {
Exemple #2
0
 if ($action == "bibles") {
     // The server reads the credentials from the client's user,
     // and responds with a list of Bibles this user has access to.
     if ($password != $database_users->getmd5($username)) {
         // Unauthorized.
         http_response_code(401);
         die;
     }
     $bibles = Access_Bible::bibles($username);
     $bibles = implode("\n", $bibles);
     $checksum = Checksum_Logic::get($bibles);
     echo "{$checksum}\n{$bibles}";
 } else {
     if ($action == "bible") {
         // The server responds with the checksum for the whole Bible.
         $server_checksum = Checksum_Logic::getBible($bible);
         echo $server_checksum;
     } else {
         if ($action == "books") {
             // The server responds with a checksum and then the list of books in the Bible.
             $server_books = $database_bibles->getBooks($bible);
             $server_books = implode("\n", $server_books);
             $checksum = Checksum_Logic::get($server_books);
             echo "{$checksum}\n{$server_books}";
         } else {
             if ($action == "book") {
                 // The server responds with the checksum of the whole book.
                 $server_checksum = Checksum_Logic::getBook($bible, $book);
                 echo $server_checksum;
             } else {
                 if ($action == "chapters") {
Exemple #3
0
 public function testGetBible2()
 {
     $checksum = Checksum_Logic::getBible("phpunit2");
     $this->assertEquals("ee84a85bac14adb35e887c3d89bc80ab", $checksum);
 }