Пример #1
0
 if ($server_checksum != $message_checksum) {
     $database_logs->log(Locale_Translate::_("Checksum error while receiving list of books from server"), Filter_Roles::TRANSLATOR_LEVEL);
     continue;
 }
 // Any books not on the server, delete them from the client as well.
 $client_books = array_diff($client_books, $server_books);
 foreach ($client_books as $book) {
     $database_bibles->deleteBook($bible, $book);
     $book_name = $database_books->getEnglishFromId($book);
     $database_logs->log(Locale_Translate::_("Deleting book because the server does not have it") . ": {$bible} {$book_name}", Filter_Roles::TRANSLATOR_LEVEL);
 }
 // The client goes through all the books as on the server, and deals with each of them.
 foreach ($server_books as $book) {
     $book_name = $database_books->getEnglishFromId($book);
     // Compare the checksum for the whole book on the client with the same on the server to see if this book is in sync.
     $client_checksum = Checksum_Logic::getBook($bible, $book);
     $post = array("b" => $bible, "bk" => $book, "a" => "book");
     $server_checksum = Sync_Logic::post($post, $url);
     if ($server_checksum === false) {
         $database_logs->log(Locale_Translate::_("Failure getting book checksum"), Filter_Roles::TRANSLATOR_LEVEL);
         continue;
     }
     if ($client_checksum == $server_checksum) {
         continue;
     }
     // The client requests all chapters per book from the server.
     $client_chapters = $database_bibles->getChapters($bible, $book);
     $post = array("b" => $bible, "bk" => $book, "a" => "chapters");
     $server_chapters = Sync_Logic::post($post, $url);
     if ($server_chapters === false) {
         $bookname = $database_books->getEnglishFromId($book);
Пример #2
0
 } 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") {
                     // The server responds with the list of books in the Bible book.
                     $server_chapters = $database_bibles->getChapters($bible, $book);
                     $server_chapters = implode("\n", $server_chapters);
                     $checksum = Checksum_Logic::get($server_chapters);
                     echo "{$checksum}\n{$server_chapters}";
                 } else {
                     if ($action == "chapter") {
                         // The server responds with the checksum of the whole chapter.
                         $server_checksum = Checksum_Logic::getChapter($bible, $book, $chapter);
                         echo $server_checksum;
                     } else {
                         if ($action == "get") {
Пример #3
0
 public function testGetBook2()
 {
     $checksum = Checksum_Logic::getBook("phpunit3", 1);
     $this->assertEquals("d41d8cd98f00b204e9800998ecf8427e", $checksum);
 }