public function testHex2binThree() { $data = "וּמִפְּרִ֣י הָעֵץ֮ אֲשֶׁ֣ר בְּתוֹךְ־הַגָּן֒ אָמַ֣ר אֱלֹהִ֗ים לֹ֤א תֹֽאכְלוּ֙ מִמֶּ֔נּוּ וְלֹ֥א תִגְּע֖וּ בּ֑וֹ פֶּן־תְּמֻתֽוּן׃ "; $hex = bin2hex($data); $this->assertEquals($data, hex2bin($hex)); $this->assertEquals($data, Filter_Hex::hex2bin($hex)); }
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ require_once "../bootstrap/bootstrap.php"; $username = $_GET['user']; $username = Filter_Hex::hex2bin($username); $password = $_GET['pass']; $database_users = Database_Users::getInstance(); if ($database_users->usernameExists($username)) { $md5 = $database_users->getmd5($username); if ($password == $md5) { // The credentials of the client have been accepted. // Return the level to the client. echo $database_users->getUserLevel($username); die; } } // The credentials were not accepted. echo 0;
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ require_once "../bootstrap/bootstrap.php"; $database_users = Database_Users::getInstance(); $database_logs = Database_Logs::getInstance(); $database_bibles = Database_Bibles::getInstance(); $database_books = Database_Books::getInstance(); $session_logic = Session_Logic::getInstance(); $database_mail = Database_Mail::getInstance(); @($username = Filter_Hex::hex2bin($_POST['u'])); @($password = $_POST['p']); @($bible = $_POST['b']); @($book = $_POST['bk']); @($chapter = $_POST['c']); $action = $_POST['a']; if ($action == "total") { // The server reads the credentials from the client's user, // checks which Bibles this user has access to, // calculate the checksum of all chapters in those Bibles, // and returns this checksum to the client. $user_ok = $database_users->usernameExists($username); if (!$user_ok) { $database_logs->log("Non existing user {$username}", Filter_Roles::MANAGER_LEVEL); } $pass_ok = $password == $database_users->getmd5($username);
$database_logs->log("A client provides incorrect password for user {$user}", Filter_Roles::MANAGER_LEVEL); // Test it. die; } $bibles = Access_Bible::bibles($user); $lowId = $_POST['l']; $highId = $_POST['h']; $identifiers = $database_notes->getNotesInRangeForBibles($lowId, $highId, $bibles); $checksum = $database_notes->getMultipleChecksum($identifiers); $response['t'] = count($identifiers); $response['c'] = $checksum; die_if_databases_unhealthy_or_busy(); echo serialize($response); } else { if ($action == "identifiers") { $user = Filter_Hex::hex2bin($_POST['u']); if (!$database_users->usernameExists($user)) { die; } $md5 = $_POST['p']; if ($md5 != $database_users->getmd5($user)) { die; } $bibles = Access_Bible::bibles($user); $lowId = $_POST['l']; $highId = $_POST['h']; $identifiers = $database_notes->getNotesInRangeForBibles($lowId, $highId, $bibles); $checksums = array(); foreach ($identifiers as $identifier) { $checksum = $database_notes->getChecksum($identifier); $checksums[] = $checksum;