//FETCH FROM ARXIV if (isset($_POST['fetch-arxiv']) && !empty($arxiv_id) && empty($doi) && isset($_POST['fetch-arxiv'])) { $response = array(); fetch_from_arxiv($arxiv_id); $_POST = array_merge($_POST, $response); } //FETCH FROM PUBMED if (isset($_POST['fetch-pubmed']) && (!empty($pmid) || !empty($doi)) && isset($_POST['fetch-pubmed'])) { $response = array(); fetch_from_pubmed($doi, $pmid); $_POST = array_merge($_POST, $response); } // FETCH FROM NASA ADS if (isset($_POST['fetch-nasaads']) && (!empty($doi) || !empty($nasa_id)) && empty($pmid) && isset($_POST['fetch-nasaads'])) { $response = array(); fetch_from_nasaads($doi, $nasa_id); $_POST = array_merge($_POST, $response); } // FETCH FROM CROSSREF if (!empty($doi) && empty($pmid)) { $response = array(); fetch_from_crossref($doi); $_POST = array_merge($_POST, $response); } ########## check for duplicate titles in table library ########## database_connect($database_path, 'library'); if (!empty($_POST['doi'])) { $doi_query = $dbHandle->quote($_POST['doi']); $result = $dbHandle->query("SELECT id,title FROM library WHERE doi={$doi_query} LIMIT 1"); } else { $title_query = $dbHandle->quote(substr($_POST['title'], 0, -2) . "%");
} if (isset($_GET['database_crossref']) && $_GET['database_crossref'] == '1' && empty($title)) { fetch_from_crossref($doi); extract($response); } //TRY AGAIN WITH DOI ONE CHARACTER SHORTER if (empty($title)) { $doi = substr($doi, 0, -1); if (isset($_GET['database_pubmed']) && $_GET['database_pubmed'] == '1') { fetch_from_pubmed($doi, ''); extract($response); $uid = join("|", (array) $uid); $url = join("|", (array) $url); } if (isset($_GET['database_nasaads']) && $_GET['database_nasaads'] == '1' && empty($title)) { fetch_from_nasaads($doi, ''); extract($response); $uid = join("|", (array) $uid); $url = join("|", (array) $url); } if (isset($_GET['database_crossref']) && $_GET['database_crossref'] == '1' && empty($title)) { fetch_from_crossref($doi); extract($response); } } if (empty($title)) { if (isset($_GET['failed']) && $_GET['failed'] == '1') { $string = preg_replace($patterns, ' ', $string); $string = preg_replace('/(^|\\s)\\S{1,2}(\\s|$)/', ' ', $string); $string = preg_replace('/\\s{2,}/', " ", $string); $fulltext_array = array();