This repository has been archived by the owner on Mar 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddHiskiLink.php
106 lines (79 loc) · 3.32 KB
/
addHiskiLink.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi" lang="fi">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Taapeli aineiston ylläpito kannassa</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div class="goback">
<a href="index.php">Paluu</a></div>
<h1>Taapeli testiylläpito</h1>
<p>Tiedot lisätty neo4j-tietokantaan.</p>
<?php
include "inc/dbconnect.php";
/*-------------------------- Tiedoston luku ----------------------------*/
/*
* Simple file Upload system with PHP by Tech Stream
* http://techstream.org/Web-Development/PHP/Single-File-Upload-With-PHP
*/
if(isset($_POST['id']) && isset($_POST['hiski'])) {
// Tiedoston käsittelyn muuttujat
$id = $_POST['id'];
$input_hiski = $_POST['hiski'];
// Neo4j parameter {hiski} is used to avoid hacking injection
$query_string = "MATCH (n:Person {id:'" . $id .
"'}) MERGE (m:Source {hiski_link:{hiski}}) MERGE (n)-[:HISKI_LINK]->(m)";
$query_array = array('hiski' => $input_hiski);
$query = new Everyman\Neo4j\Cypher\Query($sukudb, $query_string, $query_array);
$result = $query->getResultSet();
$query_string = "MATCH (n:Person)-[:BIRTH]->(b) WHERE n.id='" . $id .
"' RETURN b";
$query = new Everyman\Neo4j\Cypher\Query($sukudb, $query_string);
$result = $query->getResultSet();
foreach ($result as $rows)
{
$birth_date = $rows[0]->getProperty('birth_date');
}
$query_string = "MATCH (n:Person)-[:BIRTH]->(b)-[:BIRTH_PLACE]->(p) WHERE n.id='" . $id .
"' RETURN p";
$query = new Everyman\Neo4j\Cypher\Query($sukudb, $query_string);
$result = $query->getResultSet();
foreach ($result as $rows)
{
$birth_place = $rows[0]->getProperty('name');
}
$query_string = "MATCH (n:Person)-[:HAS_NAME]-(m) WHERE n.id='" . $id . "' RETURN m";
$query = new Everyman\Neo4j\Cypher\Query($sukudb, $query_string);
$result = $query->getResultSet();
foreach ($result as $rows)
{
$first_name = $rows[0]->getProperty('first_name');
$last_name = $rows[0]->getProperty('last_name');
$later_names = $rows[0]->getProperty('later_names');
}
$query_string = "MATCH (n:Person)-[:HISKI_LINK]-(m:Source) WHERE n.id='" . $id . "' RETURN m";
$query = new Everyman\Neo4j\Cypher\Query($sukudb, $query_string);
$result = $query->getResultSet();
foreach ($result as $rows)
{
$hiski_link[] = $rows[0]->getProperty('hiski_link');
}
echo '<table class="tulos">';
echo '<tr><th>id<th>Etunimet<th>Sukunimi<th>Myöh. sukunimi<th>Syntymäaika<th>Syntymäpaikka</tr>';
echo "<tr><td>" . $id .
"</td><td> " . $first_name .
"</td><td> " . $last_name .
"</td><td> " . $later_names .
"</td><td> " . $birth_date .
"</td><td> " . $birth_place .
"</td></tr>";
for ($i=0; $i<sizeof($hiski_link); $i++) {
echo "<tr><td></td><td>Hiski-linkki:<td><a href='http://hiski.genealogia.fi/hiski?fi+t" . $hiski_link[$i] . "' target='_blank'>" . $hiski_link[$i] .
"</a></td><td></td><td></td><td></td></tr>";
}
echo "</table>";
}
?>
</body>
</html>