echo 'Feilet<br>' . $rfid->error; } } else { echo 'Mangler obligatorisk variabel.'; } } else { if ($index_a[1] == 'search') { echo '<div class="padding">'; if (!isset($_POST['rfid'])) { //Display info echo "Skan RFID<form id='formy' action='" . URL_ROOT . "rfid/search' method='POST'><input type='hidden' name='rfid' /></form>"; display_rfid_script("search"); } else { //Display results require 'rfid.class.php'; $rfid = new RFID(); $res = $rfid->search($_POST['rfid']); if ($res != false) { header("Location: " . URL_ROOT . $res['type'] . "s/info/" . $res['id']); } else { echo "Feilet.<br>" . $rfid->error . "<br><br>Prøv å scanne på nytt"; display_rfid_script("search"); } } echo '</div>'; } else { echo 'Mangler obligatorisk variabel.'; } } } } else {
<?php if (!defined('ROOT')) { define('ROOT', getcwd() . '/'); } require '../../koble_til_database.php'; session_start(); $error = array('multiple_user_rfid' => 'Du kan bare skanne 1 bruker-enhet.', 'no_book_rfid' => 'Du må skanne minst 1 bok.', 'failed_to_lend_book' => 'Klarte ikke å låne boken.', 'no_user_rfid' => 'For å låne bøker må du skanne en bruker-enhet.', 'nonexistant_book' => 'Boken ble ikke funnet i databasen.', 'failed_to_deliver_book' => 'Klarte ikke å levere boken.', 'deliver_success' => '', 'lend_success' => '', 'only_one_action_allowed' => 'Du kan ikke låne og levere samtidig.'); $post_vars = array('obligatory' => array('rfid')); //Array that contains all the post information $vars = $post->verify($post_vars); $vars['rfid'] = trim($vars['rfid'], ";"); $rfid_arr = explode(";", $vars['rfid']); //Require and initialize the rfid class require 'rfid.class.php'; $rfid = new RFID(); $user = -1; $books = array(); for ($i = 0; $i < count($rfid_arr); $i++) { $res = $rfid->type($rfid_arr[$i]); if ($res[0] == 'user') { if ($user == -1) { $user = $res[1]; } else { //Two user RFID's are selected j_die($error['multiple_user_rfid']); } } else { if ($res[0] == 'book') { $books[] = array('bookID' => $res[1], 'rfid' => $rfid_arr[$i], 'shelfID' => $res[2]); }
$rfid = trim($_POST['rfid'], ";") . ";" . trim($_POST['userrfid'], ";"); $type = $_POST['type']; $value = $_POST['value']; //Verify the type of feedback if (!($type == "comment" || $type == "star")) { j_die($error['unknown_feedback']); } if ($type == "star" && $value == 0 || $value == "") { j_die(""); } //Verify the RFIDs $rfid = trim($rfid, ";"); $rfids = explode(";", $rfid); if (count($rfids) == 2) { require 'rfid.class.php'; $rfid = new RFID(); $user = -1; $book = -1; for ($i = 0; $i < count($rfids); $i++) { $res = $rfid->type($rfids[$i]); if ($res[0] == 'user') { if ($user === -1) { $user = $rfids[$i]; } else { j_die($error['wrong_rfid_types']); } } else { if ($res[0] == 'book') { if ($book === -1) { $book = $rfids[$i]; } else {