//Override le timeout du serveur mysql, pour être sûr que le socket dure assez longtemps pour aller jusqu'aux ajouts des résultats dans la base.
$sql = "set wait_timeout = 120";
pmb_mysql_query($sql);
yaz_wait($options);
$dt = time() - $t1;
$msgz = str_replace('!!time!!', $dt, $msg['z3950_zmsg_endw']);
hideJoke();
affiche_jsscript($msgz, "", $mioframe);
showButRes();
////////////////////////////////////////////////////////////////////
// Fase 3: Now get the results from the biblios
// obviously if the query was ok and there weren't errors
///////////////////////////////////////////////////////////////////
while (list($bib_id, $id) = each($map)) {
    $error = yaz_error($id);
    $error_info = yaz_addinfo($id);
    if (!empty($error)) {
        $msg1 = $msg[z3950_echec_rech] . " : " . $error . ", " . $error_info;
        affiche_jsscript($msg1, "z3950_failed", $bib_id);
        yaz_close($id);
    } else {
        $hits = yaz_hits($id);
        $hits += 0;
        if ($hits > $limite_notices) {
            $lim_recherche = $limite_notices;
            $msg1 = str_replace("!!limite!!", $limite_notices, $msg[z3950_recup_encours]);
            $msg1 = str_replace("!!hits!!", $hits, $msg1);
            affiche_jsscript($msg1, "", $bib_id);
        } else {
            $lim_recherche = $hits;
            $msg1 = str_replace("!!hits!!", $hits, $msg[z3950_recup]);
        yaz_element($id[$ptr], "F");
        //echo "sending: $qry <br />";
        if (!yaz_search($id[$ptr], $srchType, $qry)) {
            trigger_error($lookLoc->getText("lookup_badQuery") . "<br />", E_USER_NOTICE);
        }
    }
}
$waitOpts = array("timeout" => $postVars[timeout]);
//echo "<br /> waiting $waitOpts[timeout] seconds for responses. <br />";
//yaz_wait($waitOpts);
yaz_wait();
$ttlHits = 0;
for ($i = 0; $i < $numHosts; $i++) {
    ## did we make it?
    //			$ptr = ($useHost == -1)?$i:$useHost;
    $ptr = $i;
    $error = yaz_error($id[$ptr]);
    if (!empty($error)) {
        ## NO
        //trigger_error("Z39.50 error <br />", E_USER_ERROR);
        echo $lookLoc->getText("lookup_YAZerror") . $error . " (";
        echo yaz_errno($id[$ptr]) . ') ' . yaz_addinfo($id[$ptr]);
        echo "<br />";
    } else {
        ## YES, we got a response!!
        $hits[$ptr] = yaz_hits($id[$ptr]);
        $ttlHits += $hits[$ptr];
        //echo "Host #$ptr {$postVars[hosts][$ptr][name]} result Count: $hits[$ptr] <br />";
    }
}
//echo "Total Hits=$ttlHits <br />";
示例#3
0
文件: hbz.php 项目: stweil/malibu
if (!empty($error)) {
    echo "Error Number: " . yaz_errno($id);
    echo "Error Description: " . $error;
    echo "Additional Error Information: " . yaz_addinfo($id);
}
$outputString = "<?xml version=\"1.0\"?>\n";
$outputString .= "<datei>\n";
$outputArray = [];
for ($p = 1; $p <= yaz_hits($id); $p++) {
    $record = yaz_record($id, $p, "render;charset=iso5426,utf8");
    //render;charset=iso5426,utf8
    $error = yaz_error($id);
    if (!empty($error)) {
        echo "Error Number: " . yaz_errno($id);
        echo "Error Description: " . $error;
        echo "Additional Error Information: " . yaz_addinfo($id);
    }
    $recordArray = explode("", $record);
    $header = substr($recordArray[0], 0, 24);
    $recordContent = '<datensatz id="" typ="' . substr($header, 23, 1) . '" status="' . substr($header, 5, 1) . '" mabVersion="' . substr($header, 6, 4) . '">' . "\n";
    $recordContent .= printLine(substr($recordArray[0], 24));
    for ($j = 1; $j < count($recordArray); $j++) {
        $recordContent .= printLine($recordArray[$j]);
    }
    $recordContent .= '</datensatz>' . "\n";
    $outputString .= $recordContent;
    array_push($outputArray, $recordContent);
}
$outputString .= "</datei>";
yaz_close($id);
$map = $standardMabMap;
示例#4
0
 function getEnrichment($notice_id, $source_id, $type = "", $enrich_params = array())
 {
     global $charset;
     $enrichment = array();
     $this->noticeToEnrich = $notice_id;
     // récupération du code sudoc (PPN) de la notice stocké dans le champ perso de type "resolve" avec pour label "SUDOC"
     $mes_pp = new parametres_perso("notices");
     $mes_pp->get_values($notice_id);
     $values = $mes_pp->values;
     foreach ($values as $field_id => $vals) {
         if ($mes_pp->t_fields[$field_id]['TYPE'] == "resolve") {
             $field_options = _parser_text_no_function_("<?xml version='1.0' encoding='" . $charset . "'?>\n" . $mes_pp->t_fields[$field_id]['OPTIONS'], "OPTIONS");
             foreach ($field_options['RESOLVE'] as $resolve) {
                 if (strtoupper($resolve['LABEL']) == "SUDOC") {
                     $infos = explode('|', $vals[0]);
                     $ppn = $infos[0];
                 }
             }
         }
     }
     if ($ppn == "") {
         return $this->build_error();
     }
     $url = "carmin.sudoc.abes.fr";
     $port = "210";
     $base = "abes-z39-public";
     $format = "unimarc";
     $term = "@attr 1=12 @attr 2=3 \"{$ppn}\" ";
     $id = yaz_connect("{$url}:{$port}/{$base}", array("piggyback" => false));
     yaz_range($id, 1, 1);
     yaz_syntax($id, strtolower($format));
     yaz_search($id, "rpn", $term);
     $options = array("timeout" => 45);
     //Override le timeout du serveur mysql, pour être sûr que le socket dure assez longtemps pour aller jusqu'aux ajouts des résultats dans la base.
     $sql = "set wait_timeout = 120";
     mysql_query($sql);
     yaz_wait($options);
     $error = yaz_error($id);
     $error_info = yaz_addinfo($id);
     if (!empty($error)) {
         yaz_close($id);
         return $this->build_error();
     } else {
         $hits = yaz_hits($id);
         $hits += 0;
         if ($hits) {
             $rec = yaz_record($id, 1, "raw");
             $record = new iso2709_record($rec);
             if (!$record->valid()) {
                 yaz_close($id);
                 return $this->build_error();
             }
             $lines = "";
             $document->document_type = $record->inner_guide[dt];
             $document->bibliographic_level = $record->inner_guide[bl];
             $document->hierarchic_level = $record->inner_guide[hl];
             if ($document->hierarchic_level == "") {
                 if ($document->bibliographic_level == "s") {
                     $document->hierarchic_level = "1";
                 }
                 if ($document->bibliographic_level == "m") {
                     $document->hierarchic_level = "0";
                 }
             }
             $indicateur = array();
             $cle_list = array();
             for ($i = 0; $i < count($record->inner_directory); $i++) {
                 $cle = $record->inner_directory[$i]['label'];
                 $indicateur[$cle][] = substr($record->inner_data[$i]['content'], 0, 2);
                 $field_array = $record->get_subfield_array_array($cle);
                 $line = "";
                 if (!$cle_list[$cle]) {
                     foreach ($field_array as $field) {
                         $line .= $cle . "  ";
                         foreach ($field as $ss_field) {
                             $line .= "\$" . $ss_field["label"] . $ss_field["content"];
                         }
                         $line .= "<br>";
                     }
                 }
                 $cle_list[$cle] = 1;
                 $lines .= $line;
             }
             if ($lines == "") {
                 yaz_close($id);
                 return $this->build_error();
             }
         } else {
             yaz_close($id);
             return $this->build_error();
         }
     }
     yaz_close($id);
     $enrichment['sudoc']['content'] = $lines;
     $enrichment['source_label'] = $this->msg['sudoc_enrichment_source'];
     return $enrichment;
 }
 function _getLookupResult($server, $isbn)
 {
     // Now support YAZ only.
     $query = '@attr 1=7 ' . $isbn;
     $conn = yaz_connect($server['host'], array('user' => $server['user'], 'password' => $server['pw']));
     if (!$conn) {
         return array('error' => 'could not connect lookup');
     }
     yaz_database($conn, $server['db']);
     yaz_syntax($conn, "usmarc");
     yaz_element($conn, "F");
     //echo "sending: $qry <br />";
     if (!yaz_search($conn, 'rpn', $query)) {
         return array('error' => 'bad query');
     }
     $param = array('timeout' => 5);
     yaz_wait($param);
     $error = yaz_error($conn);
     if (!empty($error)) {
         return array('error' => 'lookup response error (' . yaz_errno($conn) . ') : ' . yaz_addinfo($conn));
     }
     if (yaz_hits($conn) < 1) {
         return array('error' => 'no result');
     }
     // For bulk actions, auto select first record
     require_once "../lookup2/lookupYazFunc.php";
     $data = extract_marc_fields(yaz_record($conn, 1, 'array'), true, 1, 1, $server['charset']);
     if (empty($data['callNmbr1']) && empty($data['050a']) || empty($data['100a'])) {
         // Require callNmbr1, continue search
         return array('error' => 'no result');
     }
     return $data;
 }
 function doZSearch($zid, $rpn, $start, $number)
 {
     yaz_range($zid, (int) $start, (int) $number);
     yaz_syntax($zid, $this->z_syntax);
     if ($this->z_sort) {
         yaz_sort($zid, $this->z_sort);
     }
     yaz_element($zid, 'F');
     yaz_search($zid, "rpn", $rpn);
     yaz_wait($options = array('timeout' => $this->z_timeout));
     if (yaz_errno($zid)) {
         $error_msg = yaz_error($zid);
         if ($error_info = yaz_addinfo($zid)) {
             $error_msg .= ' - ' . $error_info;
         }
         $this->addError("error", sprintf(_("Fehler bei der Suche: %s"), $error_msg));
         return false;
     } else {
         return yaz_hits($zid);
     }
 }
示例#7
0
     } else {
         yaz_element($id, "F");
     }
     yaz_syntax($id, $syntax);
     yaz_range($id, $start, $number);
 }
 yaz_wait();
 $host_url = "term=" . urlencode($term) . "&field=";
 $host_url .= urlencode($field) . "&";
 $host_url .= "element={$element}&syntax={$syntax}";
 for ($i = 0; $i < $num_hosts; $i++) {
     $id = $ids[$i];
     if ($id <= 0) {
         continue;
     }
     $error = yaz_error($id);
     $errno = yaz_errno($id);
     $addinfo = yaz_addinfo($id);
     echo '<tr>';
     $attempt = $reintentar + 1;
     if ($errno) {
         echo '<td align="center">';
         echo '<table cellspacing="0" cellpadding="2" width="97%" border="0"><tr><td>';
         echo $msgstr["attempt"] . ": {$attempt} &nbsp; ";
         //   	echo "$host[$i] &nbsp; ";
         echo "Error: {$error} (code {$errno}) {$addinfo}";
         echo "</td></tr></table>\n";
         echo "</td></tr>";
     } else {
         echo '<td align="center">';
         echo '<table cellspacing="0" cellpadding="2" width="97%" border="0"><tr><td>';