'.__('You are not authorized to view this section').''); } if (isset($_GET['z3950_SRU_source'])) { $zserver = trim(urldecode($_GET['z3950_SRU_source'])); } else { $zserver = 'http://z3950.loc.gov:7090/voyager?'; } /* RECORD OPERATION */ if (isset($_POST['saveZ']) AND isset($_SESSION['z3950result'])) { require MDLBS.'bibliography/biblio_utils.inc.php'; $gmd_cache = array(); $publ_cache = array(); $place_cache = array(); $lang_cache = array(); $author_cache = array(); $subject_cache = array(); $input_date = date('Y-m-d H:i:s'); // create dbop object $sql_op = new simbio_dbop($dbs); $r = 0; foreach ($_POST['zrecord'] as $id) { // get record detail $record = $_SESSION['z3950result'][$id]; // insert record to database if ($record) { // create dbop object $sql_op = new simbio_dbop($dbs); // escape all string value foreach ($record as $field => $content) { if (is_string($content)) { $biblio[$field] = $dbs->escape_string(trim($content)); } } // gmd $biblio['gmd_id'] = utility::getID($dbs, 'mst_gmd', 'gmd_id', 'gmd_name', $record['gmd'], $gmd_cache); unset($biblio['gmd']); // publisher $biblio['publisher_id'] = utility::getID($dbs, 'mst_publisher', 'publisher_id', 'publisher_name', $record['publisher'], $publ_cache); unset($biblio['publisher']); // publish place $biblio['publish_place_id'] = utility::getID($dbs, 'mst_place', 'place_id', 'place_name', $record['publish_place'], $place_cache); unset($biblio['publish_place']); // language $biblio['language_id'] = utility::getID($dbs, 'mst_language', 'language_id', 'language_name', $record['language']['name'], $lang_cache); unset($biblio['language']); // authors $authors = array(); if (isset($record['authors'])) { $authors = $record['authors']; unset($biblio['authors']); } // subject $subjects = array(); if (isset($record['subjects'])) { $subjects = $record['subjects']; unset($biblio['subjects']); } $biblio['input_date'] = $biblio['create_date']; // $biblio['last_update'] = $biblio['modified_date']; $biblio['last_update'] = date('Y-m-d H:i:s'); // remove unneeded elements unset($biblio['manuscript']); unset($biblio['collection']); unset($biblio['resource_type']); unset($biblio['genre_authority']); unset($biblio['genre']); unset($biblio['issuance']); unset($biblio['location']); unset($biblio['id']); unset($biblio['create_date']); unset($biblio['modified_date']); unset($biblio['origin']); // fot debugging purpose // var_dump($biblio); // die(); // insert biblio data $sql_op->insert('biblio', $biblio); echo '
'.$sql_op->error.'
'; $biblio_id = $sql_op->insert_id; if ($biblio_id < 1) { continue; } // insert authors if ($authors) { $author_id = 0; foreach ($authors as $author) { $author_id = getAuthorID($author['name'], strtolower(substr($author['author_type'], 0, 1)), $author_cache); @$dbs->query("INSERT IGNORE INTO biblio_author (biblio_id, author_id, level) VALUES ($biblio_id, $author_id, ".$author['level'].")"); } } // insert subject/topical terms if ($subjects) { foreach ($subjects as $subject) { if ($subject['term_type'] == 'Temporal') { $subject_type = 'tm'; } else if ($subject['term_type'] == 'Genre') { $subject_type = 'gr'; } else if ($subject['term_type'] == 'Occupation') { $subject_type = 'oc'; } else { $subject_type = strtolower(substr($subject['term_type'], 0, 1)); } $subject_id = getSubjectID($subject['term'], $subject_type, $subject_cache); @$dbs->query("INSERT IGNORE INTO biblio_topic (biblio_id, topic_id, level) VALUES ($biblio_id, $subject_id, 1)"); } } if ($biblio_id) { // write to logs utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'bibliography', $_SESSION['realname'].' insert bibliographic data from P2P service (server:'.$p2pserver.') with ('.$biblio['title'].') and biblio_id ('.$biblio_id.')'); $r++; } } } // destroy result Z3950 session unset($_SESSION['z3950result']); utility::jsAlert($r.' records inserted to database.'); echo ''; exit(); } /* RECORD OPERATION END */ /* SEARCH OPERATION */ if (isset($_GET['keywords']) AND $can_read) { require LIB.'modsxmlslims.inc.php'; $_SESSION['z3950result'] = array(); if ($_GET['index'] != 0) { $index = trim($_GET['index']).' any '; $keywords = urlencode($index.'"'.trim($_GET['keywords'].'"')); } else { $keywords = urlencode('"'.trim($_GET['keywords']).'"'); } $query = ''; if ($keywords) { $sru_server = $zserver.'?version=1.1&operation=searchRetrieve&query='.$keywords.'&startRecord=1&maximumRecords=20&recordSchema=mods'; // parse SRU Server XML $sru_xml = new SimpleXMLElement($sru_server, LIBXML_NSCLEAN, true); // below is for debugging purpose // echo '
'; var_dump($sru_xml); echo ''; exit(); $zs_xml = $sru_xml->children('http://www.loc.gov/zing/srw/'); $hits = $zs_xml->numberOfRecords; if ($hits > 0) { echo '