Beispiel #1
0
        $proxy_port = $_SESSION['proxy_port'];
    }
    if (isset($_SESSION['proxy_username'])) {
        $proxy_username = $_SESSION['proxy_username'];
    }
    if (isset($_SESSION['proxy_password'])) {
        $proxy_password = $_SESSION['proxy_password'];
    }
}
include_once 'functions.php';
##########	reference fetching from PubMed	##########
if (isset($_GET['id'])) {
    ##########	open efetch, read xml	##########
    if (!empty($_GET['id'])) {
        $request_url = 'http://ieeexplore.ieee.org/xpl/downloadCitations?reload=true&citations-format=citation-abstract&download-format=download-ris&recordIds=' . urlencode($_GET['id']);
        $ris = proxy_file_get_contents($request_url, $proxy_name, $proxy_port, $proxy_username, $proxy_password);
        if (empty($ris)) {
            die('Error! I, Librarian could not connect with an external web service. This usually indicates that you access the Web through a proxy server.
            Enter your proxy details in Tools->Settings. Alternatively, the external service may be temporarily down. Try again later.');
        }
        function trim_arr(&$v, $k)
        {
            $v = trim($v);
        }
        $file_records = explode('ER  -', $ris);
        array_walk($file_records, 'trim_arr');
        $file_records = array_filter($file_records);
        if (isset($file_records[0])) {
            $record = $file_records[0];
        }
        $record = html_entity_decode($record);
 // ADD DISCIPLINE
 $discipline = '';
 if ($_GET['springer_discipline'] !== "0") {
     $discipline = '&facet-discipline="' . urlencode($_GET['springer_discipline']) . '"';
 }
 // SHOW ALL?
 $showall = '&showAll=true';
 if (!empty($_GET['springer_showall'])) {
     $showall = '&showAll=false';
 }
 // FINAL URL
 $springer_url = 'http://link.springer.com/search/csv?sortOrder=newestFirst' . $showall . $query . $title . $author . $year_mode . $year_start . $year_end . $discipline;
 // IF NO STORAGE, SEARCH SPRINGER AND SAVE RESULTS
 if (!file_exists($temp_dir . DIRECTORY_SEPARATOR . 'lib_' . session_id() . DIRECTORY_SEPARATOR . 'springer_' . md5($springer_url) . '.sq3')) {
     $csv_string = '';
     $csv_string = proxy_file_get_contents($springer_url, $proxy_name, $proxy_port, $proxy_username, $proxy_password);
     //        if (empty($csv_string))
     //            die('Error! I, Librarian could not connect with an external web service. This usually indicates that you access the Web through a proxy server.
     //            Enter your proxy details in Tools->Settings. Alternatively, the external service may be temporarily down. Try again later.');
     $csv_string = str_replace("\n\"", "{newline}\"", $csv_string);
     $csv_array = explode("{newline}", $csv_string);
     $index = array();
     if (isset($csv_array[0])) {
         unset($csv_array[0]);
     }
     // OPEN STORAGE
     try {
         $dbHandle2 = new PDO('sqlite:' . $temp_dir . DIRECTORY_SEPARATOR . 'lib_' . session_id() . DIRECTORY_SEPARATOR . 'springer_' . md5($springer_url) . '.sq3');
     } catch (PDOException $e) {
         print "Error: " . $e->getMessage() . "<br/>";
         print "PHP extensions PDO and PDO_SQLite must be installed.";
Beispiel #3
0
     ##########	no form data, only PDF, try to fetch DOI and PMID	##########
 } elseif (isset($_POST['form_sent']) && (isset($_FILES['form_new_file']) && is_uploaded_file($_FILES['form_new_file']['tmp_name']) || !empty($_POST['form_new_file_link']))) {
     $dir = dirname(__FILE__);
     $rand = uniqid('lib_' . mt_rand(10, 99));
     if (isset($_FILES['form_new_file']) && is_uploaded_file($_FILES['form_new_file']['tmp_name'])) {
         $pdf_contents = file_get_contents($_FILES['form_new_file']['tmp_name'], NULL, NULL, 0, 100);
         if (stripos($pdf_contents, '%PDF') === 0) {
             move_uploaded_file($_FILES['form_new_file']['tmp_name'], $temp_dir . DIRECTORY_SEPARATOR . $rand . ".pdf");
             $_POST['title'] = $_FILES['form_new_file']['name'];
             $_POST['tempfile'] = $rand . ".pdf";
         } else {
             $error[] = "Error! No PDF was found.";
         }
     }
     if (!empty($_POST['form_new_file_link'])) {
         $pdf_contents = proxy_file_get_contents($_POST['form_new_file_link'], $proxy_name, $proxy_port, $proxy_username, $proxy_password);
         if (stripos($pdf_contents, '%PDF') === 0) {
             if (!empty($pdf_contents)) {
                 file_put_contents($temp_dir . DIRECTORY_SEPARATOR . $rand . ".pdf", $pdf_contents);
             }
             $_POST['title'] = $rand . ".pdf";
             $_POST['tempfile'] = $rand . ".pdf";
         } else {
             die('Error! I, Librarian could not find the PDF. Possible reasons:<br><br>You access the Web through a proxy server. Enter your proxy details in Tools->Settings.<br><br>The external service may be temporarily down. Try again later.<br><br>The link you provided is not for a PDF.');
         }
     }
     if (is_readable($temp_dir . DIRECTORY_SEPARATOR . $rand . ".pdf")) {
         ##########	try to find DOI on the first page	##########
         system(select_pdftotext() . '-l 1 "' . $temp_dir . DIRECTORY_SEPARATOR . $rand . '.pdf" "' . $temp_dir . DIRECTORY_SEPARATOR . $rand . '.txt"', $ret);
         if (is_file($temp_dir . DIRECTORY_SEPARATOR . $rand . ".txt")) {
             $string = file_get_contents($temp_dir . DIRECTORY_SEPARATOR . $rand . ".txt");