One Hat Cyber Team
Your IP :
216.73.216.148
Server IP :
194.44.31.54
Server :
Linux zen.imath.kiev.ua 4.18.0-553.77.1.el8_10.x86_64 #1 SMP Fri Oct 3 14:30:23 UTC 2025 x86_64
Server Software :
Apache/2.4.37 (Rocky Linux) OpenSSL/1.1.1k
PHP Version :
5.6.40
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
vo
/
mfat
/
View File Name :
getit-issues
#!/usr/bin/php <?php $startyear = "1995"; $endyear = "1995"; $startissue = "1"; // issue and year are independent $endissue = "4"; $outFile = $startyear . '-' . $endyear . '_' . $startissue . '-' . $endissue . '.xml'; $m = mysqli_connect('localhost','mfat','yumber','mfat'); mysqli_query($m, "set character_set_results='utf8'"); mysqli_query($m, "SET NAMES 'utf8'"); mysqli_query($m, "SET CHARACTER SET utf8"); mysqli_query($m, "SET SESSION collation_connection = 'utf8_unicode_ci'"); $sql = "select distinct article_year, article_item from articles"; $sql = $sql . " where article_print='Y' and article_year >= $startyear and article_year <= $endyear"; $sql = $sql . " and article_item >= $startissue and article_item <= $endissue"; $sql = $sql . " order by article_year, article_item"; // echo $sql; $res = mysqli_query($m, $sql); $out = new DOMDocument('1.0'); $out->preserveWhiteSpace = false; $out->formatOutput = true; $lang = [ 1 => "uk", 2 => "ru", 3 => "en"]; $issueId = 0; $articleId = 0; $authId = 0; $rootNode = $out->createElementNS('http://pkp.sfu.ca', "issues"); // for each year and issue while ($row = mysqli_fetch_assoc($res)) { $year = $row['article_year']; $issue = $row['article_item']; $volume = $year - 1994; if ($year == 1995) $month = 12; if ($year == 1996) $month = 4*$issue; else $month = 3*$issue; if ($month<10) $month="0" . $month; $datePublished = $year . "-" . $month . "-25"; $dateModified = date("Y-m-d"); $dateSubmitted = $datePublished; $issueId++; // Issue $issueNode = $out->createElementNS('http://pkp.sfu.ca', "issue"); $issueNode->setAttribute("xmlns:xsi", 'http://www.w3.org/2001/XMLSchema-instance'); $issueNode->setAttribute("published", "1"); $issueNode->setAttribute("current", "0"); $issueNode->setAttribute("access_status", "1"); // Issue Id $issueIdNode = $out->createElement("id", $issueId); $issueIdNode->setAttribute("type", "internal"); $issueIdNode->setAttribute("advice", "ignore"); $issueNode->appendChild($issueIdNode); // Issue identification $issueIdentificationNode = $out->createElement("issue_identification"); $volumeNode = $out->createElement("volume", $volume); $numberNode = $out->createElement("number", $issue); $yearNode = $out->createElement("year", $year); $issueIdentificationNode->appendChild($volumeNode); $issueIdentificationNode->appendChild($numberNode); $issueIdentificationNode->appendChild($yearNode); $issueNode->appendChild($issueIdentificationNode); // Dates $dateNode = $out->createElement("date_published", $datePublished); $issueNode->appendChild($dateNode); $lastModifiedNode = $out->createElement("last_modified", $dateModified); $issueNode->appendChild($lastModifiedNode); // Sections $sectionsNode = $out->createElement("sections"); $sectionNode = $out->createElement("section"); $sectionNode->setAttribute("ref", "ART"); $sectionNode->setAttribute("seq", "1"); $sectionNode->setAttribute("editor_restricted", "0"); $sectionNode->setAttribute("meta_indexed", "1"); $sectionNode->setAttribute("meta_reviewed", "1"); $sectionNode->setAttribute("abstracts_not_required", "0"); $sectionNode->setAttribute("hide_title", "0"); $sectionNode->setAttribute("hide_author", "0"); $sectionNode->setAttribute("abstract_word_count", "0"); $sectionSubNode = $out->createElement("id", "1"); $sectionSubNode->setAttribute("type", "internal"); $sectionSubNode->setAttribute("advice", "ignore"); $sectionNode->appendChild($sectionSubNode); $sectionSubNode = $out->createElement("abbrev", "ART"); $sectionSubNode->setAttribute("locale", "en_US"); $sectionNode->appendChild($sectionSubNode); $sectionSubNode = $out->createElement("title", "Articles"); $sectionSubNode->setAttribute("locale", "en_US"); $sectionNode->appendChild($sectionSubNode); $sectionsNode->appendChild($sectionNode); $issueNode->appendChild($sectionsNode); // Issue coverpage // Issue galleys $issueGalleysNode = $out->createElementNS('http://pkp.sfu.ca', "issue_galleys"); $issueGalleysNode->setAttribute("xmlns:xsi", 'http://www.w3.org/2001/XMLSchema-instance'); $issueGalleysNode->setAttribute('xsi:schemaLocation', "http://pkp.sfu.ca native.xsd"); $issueNode->appendChild($issueGalleysNode); // Articles $articlesNode = $out->createElementNS('http://pkp.sfu.ca', "articles"); $articlesNode->setAttribute("xmlns:xsi", 'http://www.w3.org/2001/XMLSchema-instance'); $articlesNode->setAttribute('xsi:schemaLocation', "http://pkp.sfu.ca native.xsd"); $sql = "SELECT * FROM articles"; $sql = $sql . " WHERE article_print='Y' AND article_year = " . $row['article_year'] ; $sql = $sql . " AND article_item = " . $row['article_item']; $sql = $sql . " ORDER BY CAST(SUBSTRING_INDEX(article_pages, '-', 1) AS signed)"; // Article $resArt = mysqli_query($m, $sql); $artSeq = 0; while ($rowArt = mysqli_fetch_assoc($resArt)) { echo $rowArt['article_id'] .' '; $artSeq++; $articleLocale = "en_US"; $dateSubmitted = $rowArt['article_received_text']; $dateSubmitted = preg_replace("|Received (\d\d).(\d\d).(\d\d\d\d).*|", "$3-$2-$1", $dateSubmitted); if (!$dateSubmitted) $dateSubmitted = $datePublished; // Create article $articleNode = $out->createElementNS('http://pkp.sfu.ca', "article"); $articleNode->setAttribute("xmlns:xsi", 'http://www.w3.org/2001/XMLSchema-instance'); $articleNode->setAttribute("date_submitted", $dateSubmitted); $articleNode->setAttribute("status", "3"); $articleNode->setAttribute("submission_progress", "0"); $articleNode->setAttribute("current_publication_id", $rowArt['article_id']); $articleNode->setAttribute("stage", "production"); // Article id $articleIdNode = $out->createElement('id', $rowArt['article_id']); $articleIdNode->setAttribute("type", "internal"); $articleIdNode->setAttribute("advice", "ignore"); $articleNode->appendChild($articleIdNode); // Submission files $basepath = '/home/mfat/public_html/article/'; $subdir = $rowArt['article_item']; if ($subdir < 10) $subdir = '0' . $subdir; $dirpath = $basepath . $year . '/' . $subdir . '/'; if($rowArt['article_pdf']){ $path = $dirpath . $rowArt['article_pdf']; $filename = basename($path); $size = filesize($path); $contents = file_get_contents($path); $submissionNode = $out->createElementNS('http://pkp.sfu.ca', 'submission_file'); $submissionNode->setAttribute("xmlns:xsi", 'http://www.w3.org/2001/XMLSchema-instance'); $submissionNode->setAttribute('xsi:schemaLocation', "http://pkp.sfu.ca native.xsd"); $submissionNode->setAttribute('stage', 'proof'); $submissionNode->setAttribute('id', $rowArt['article_id']); $revisionNode = $out->createElement('revision'); $revisionNode->setAttribute('number', '1'); $revisionNode->setAttribute('genre', 'Article text (PDF)'); $revisionNode->setAttribute('filename', $rowArt['article_pdf']); $revisionNode->setAttribute('viewable', 'true'); $revisionNode->setAttribute('date_uploaded', date("Y-m-d")); $revisionNode->setAttribute('date_modified', date("Y-m-d")); $revisionNode->setAttribute('filesize', $size); $revisionNode->setAttribute('filetype', 'application/pdf'); $revisionNode->setAttribute('uploader', 'admin'); $nameNode = $out->createElement('name', 'Imported: ' . $filename); $nameNode->setAttribute('locale', 'en_US'); $revisionNode->appendChild($nameNode); $embedNode = $out->createElement('embed'); $embedNode->setAttribute('encoding', 'base64'); $embedNode->nodeValue = base64_encode($contents); $revisionNode->appendChild($embedNode); $submissionNode->appendChild($revisionNode); $articleNode->appendChild($submissionNode); } // Create publication $publicationNode = $out->createElementNS('http://pkp.sfu.ca', "publication"); $publicationNode->setAttribute("xmlns:xsi", 'http://www.w3.org/2001/XMLSchema-instance'); $publicationNode->setAttribute('xsi:schemaLocation', "http://pkp.sfu.ca native.xsd"); $publicationNode->setAttribute("locale", $articleLocale); $publicationNode->setAttribute("version", "1"); $publicationNode->setAttribute("status", "3"); $publicationNode->setAttribute("primary_contact_id", $authId + 1); $publicationNode->setAttribute("seq", $artSeq); $publicationNode->setAttribute("date_submitted", $dateSubmitted); $publicationNode->setAttribute("date_published", $datePublished); $publicationNode->setAttribute("section_ref", 'ART'); $publicationNode->setAttribute("access_status", "0"); // Publication id $publicationIdNode = $out->createElement('id', $rowArt['article_id']); $publicationIdNode->setAttribute("type", "internal"); $publicationIdNode->setAttribute("advice", "ignore"); $publicationNode->appendChild($publicationIdNode); // Title $data = $rowArt['article_title']; $articleTitleNode = $out->createElement('title'); $cdata = $out->createCDATASection($data); $articleTitleNode->appendChild($cdata); $articleTitleNode->setAttribute("locale", "en_US"); $publicationNode->appendChild($articleTitleNode); // Abstract $data = $rowArt['article_abstract']; $data = preg_replace('/<[\/]*a[^>]*>/i', '', $data); $articleAbstractNode = $out->createElement('abstract'); $cdata = $out->createCDATASection($data); $articleAbstractNode->appendChild($cdata); $articleAbstractNode->setAttribute("locale", "en_US"); $publicationNode->appendChild($articleAbstractNode); // Copyright $articleCopyrightHolderEnNode = $out->createElement('copyrightHolder'); $articleCopyrightHolderEnNode->setAttribute("locale", "en_US"); $publicationNode->appendChild($articleCopyrightHolderEnNode); $articleCopyrightYearNode = $out->createElement('copyrightYear', $year); $publicationNode->appendChild($articleCopyrightYearNode); // Keywords $data = $rowArt['article_key_words']; $data = str_replace("\r", "", $data); $data = str_replace("\n", "", $data); $keyWords = preg_split('/,/', $data); // print_r($keyWords); $keywordsNode = $out->createElement("keywords"); $keywordsNode->setAttribute("locale", "en_US"); foreach($keyWords as $keyword){ $keyword = trim($keyword, " .,"); $keywordNode = $out->createElement("keyword", $keyword); $keywordsNode->appendChild($keywordNode); } $publicationNode->appendChild($keywordsNode); // Authors $authorsNode = $out->createElementNS('http://pkp.sfu.ca', "authors"); $authorsNode->setAttribute("xmlns:xsi", 'http://www.w3.org/2001/XMLSchema-instance'); $authorsNode->setAttribute('xsi:schemaLocation', "http://pkp.sfu.ca native.xsd"); $authSeq = 0; $sql = "SELECT distinct a.author_name as name, a.author_institute as author_institute, a.author_email as author_email, a.author_orcid as author_orcid, b.author_order as author_order FROM authors a, authors_to_article b WHERE b.article_id='" . $rowArt["article_id"] . "' and b.author_id=a.author_id ORDER BY author_order"; $resAuth = mysqli_query($m, $sql); if (mysqli_num_rows($resAuth) == 0) { echo "\nNo authors for " . $rowArt["article_id"] . "!\n"; die; } $authorsEn = []; $affil = $rowArt['article_affiliation']; $affil = str_replace("\r", "", $affil); $affil = str_replace("\n", "", $affil); // $affil = html_entity_decode($affil); // echo $affil; $aaArray = preg_split ("|</p><p>|" , $affil); echo "\n\n"; $aus = []; $afs = []; foreach ($aaArray as $auAndAf){ // echo $auAndAf; $auAndAf = preg_replace("|(<p>)?(.+?)(</p>)?|", "$2", $auAndAf); $arr = preg_split("|<br />|", $auAndAf); $aus[] = strip_tags($arr[0]); $afs[] = $arr[1]; } while ($rowAuth = mysqli_fetch_assoc($resAuth)) { $authSeq++; $authId++; $nameEn = $rowAuth['name']; array_push($authorsEn, $nameEn); $givenNameEn = ""; $nameParts = explode(",", $nameEn); $familyNameEn = array_shift($nameParts); if($nameParts[0] == "Board") $familyNameEn = $familyNameEn . array_shift($nameParts); $givenNameEn .= implode(",", $nameParts); $givenNameEn = trim($givenNameEn); if ($givenNameEn == ""){ $givenNameEn = $familyNameEn; $familyNameEn = ""; } if ($givenNameEn == ""){ echo "No English name for " . $rowArt['article_id']; die; } $authorNode = $out->createElement('author'); // $authorNode->setAttribute('primary_contact', 'true'); $authorNode->setAttribute('include_in_browse', 'true'); $authorNode->setAttribute('user_group_ref', 'Author'); $authorNode->setAttribute('seq', $authSeq); $authorNode->setAttribute('id', $authId); $givenNameNode = $out->createElement('givenname', $givenNameEn); $givenNameNode->setAttribute('locale','en_US'); $authorNode->appendChild($givenNameNode); $familyNameNode = $out->createElement('familyname', $familyNameEn); $familyNameNode->setAttribute('locale','en_US'); $authorNode->appendChild($familyNameNode); // Affiliation echo $givenNameEn . " " . $familyNameEn . " = " . array_shift($aus) . "\n"; $affiliation = array_shift($afs); $affiliationNode = $out->createElement('affiliation'); $cdata = $out->createCDATASection($affiliation); $affiliationNode->appendChild($cdata); $affiliationNode->setAttribute('locale','en_US'); $authorNode->appendChild($affiliationNode); // Country // $countryNode = $out->createElement('country', 'UA'); // $authorNode->appendChild($countryNode); // Email $emailNode = $out->createElement('email', $rowAuth['author_email']); $authorNode->appendChild($emailNode); $emailNode = $out->createElement('orcid', 'https://orcid.org/'.$rowAuth['author_orcid']); if ($rowAuth['author_orcid']) $authorNode->appendChild($emailNode); $authorsNode->appendChild($authorNode); } $articleCopyrightHolderEnNode->nodeValue = implode("; ", $authorsEn); $publicationNode->appendChild($authorsNode); // Article galleys $galleyNode = $out->createElementNS('http://pkp.sfu.ca', 'article_galley'); $galleyNode->setAttribute("xmlns:xsi", 'http://www.w3.org/2001/XMLSchema-instance'); $galleyNode->setAttribute('xsi:schemaLocation', "http://pkp.sfu.ca native.xsd"); $galleyNode->setAttribute('approved', 'true'); $galleyIdNode = $out->createElement('id', $rowArt['article_id'] . '.0'); $galleyIdNode->setAttribute('type', 'internal'); $galleyIdNode->setAttribute('advice', 'ignore'); $galleyNode->appendChild($galleyIdNode); $galleyNameNode = $out->createElement('name', 'PDF'); $galleyNameNode->setAttribute('locale', $articleLocale); $galleyNode->appendChild($galleyNameNode); $galleySeqNode = $out->createElement('seq', '0'); $galleyNode->appendChild($galleySeqNode); $galleySubNode = $out->createElement('submission_file_ref'); $galleySubNode->setAttribute('id', $rowArt['article_id']); $galleySubNode->setAttribute('revision', '1'); $galleyNode->appendChild($galleySubNode); if($rowArt['article_pdf']) $publicationNode->appendChild($galleyNode); // Pages $pagesNode = $out->createElement('pages', $rowArt['article_pages']); $publicationNode->appendChild($pagesNode); $articleNode->appendChild($publicationNode); $articlesNode->appendChild($articleNode); $articlesNode->appendChild($articleNode); // Citations $data = $rowArt['article_references']; $data = str_replace("\r", "", $data); $data = str_replace("\n", "", $data); $cite = new DOMDocument(); if($data){ $cite->loadHTML($data); $xpath = new DOMXpath($cite); $citations = $xpath->query("//*/cite"); // print_r($citations); $citationsNode = $out->createElement("citations"); foreach($citations as $citation){ $data = $citation->C14N(); $data = preg_replace("|<cite[^>]*>(.*?)</cite>|", "$1", $data); $cdata = $out->createCDATASection($data); $citationNode = $out->createElement("citation"); $citationNode->appendChild($cdata); $citationsNode->appendChild($citationNode); } $publicationNode->appendChild($citationsNode); } } $issueNode->appendChild($articlesNode); $rootNode->appendChild($issueNode); } $rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', "xmlns:xsi" , 'http://www.w3.org/2001/XMLSchema-instance'); $rootNode->setAttribute('xsi:schemaLocation', "http://pkp.sfu.ca native.xsd"); $out->appendChild($rootNode); $out->save($outFile); // echo $out->saveXML(); die; ?>