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
/
disconnectRepo.php
165 lines (124 loc) · 5.35 KB
/
disconnectRepo.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!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 muutettu 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($_GET['id'])) && ((isset($_GET['repoid'])) || (isset($_GET['sourceid'])))) {
// Tiedoston käsittelyn muuttujat
$input_id = $_GET['id'];
$input_repo_id = $_GET['repoid'];
if (isset($_GET['sourceid'])) {
$input_repo_source_id = $_GET['sourceid'];
// Neo4j parameters {id}, {repo_id} and {repo_source_id} are used
// to avoid hacking injection
$query_string = "MATCH (:Person:" . $userid .
" {id:{id}})-[:BIRTH]->(b)-[r:BIRTH_SOURCE]-(:Source
{id:{repo_source_id}})-[:REPO_SOURCE]-(:Repo {id:{repo_id}}) DELETE r";
$query_array = array('id' => $input_id, 'repo_source_id' => $input_repo_source_id, 'repo_id' => $input_repo_id);
$query = new Everyman\Neo4j\Cypher\Query($sukudb, $query_string, $query_array);
$result = $query->getResultSet();
}
else {
// Neo4j parameters {id} and {repo_id} are used to avoid hacking injection
$query_string = "MATCH (:Person:" . $userid .
" {id:{id}})-[:BIRTH]->(b)-[r:BIRTH_REPO]-(:Repo {id:{repo_id}}) DELETE r";
$query_array = array('id' => $input_id, 'repo_id' => $input_repo_id);
$query = new Everyman\Neo4j\Cypher\Query($sukudb, $query_string, $query_array);
$result = $query->getResultSet();
}
// Neo4j parameter {id} is used to avoid hacking injection
$query_string = "MATCH (n:Person:" . $userid . ") WHERE n.id={id} RETURN n";
$query_array = array('id' => $input_id);
$query = new Everyman\Neo4j\Cypher\Query($sukudb, $query_string, $query_array);
$result = $query->getResultSet();
foreach ($result as $rows)
{
$id = $rows[0]->getProperty('id'); // This variable is used for later MATCHs
}
$query_string = "MATCH (n:Person:" . $userid .
")-[: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:" . $userid .
")-[: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:" . $userid .
")-[: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:" . $userid .
")-[:BIRTH]->(b)-[p:BIRTH_SOURCE]-(s:Source)-[:REPO_SOURCE]-(r:Repo)
WHERE n.id='" . $id . "' RETURN r,s,p";
$query = new Everyman\Neo4j\Cypher\Query($sukudb, $query_string);
$result = $query->getResultSet();
foreach ($result as $rows)
{
$repo_name[] = $rows[0]->getProperty('name');
$repo_source[] = $rows[1]->getProperty('title');
$repo_page[] = $rows[2]->getProperty('page');
}
$query_string = "MATCH (n:Person:" . $userid .
")-[:BIRTH]->(b)-[p:BIRTH_REPO]-(r:Repo) WHERE n.id='" . $id .
"' RETURN r,p";
$query = new Everyman\Neo4j\Cypher\Query($sukudb, $query_string);
$result = $query->getResultSet();
foreach ($result as $rows)
{
$repo_name_only[] = $rows[0]->getProperty('name');
$repo_page_only[] = $rows[1]->getProperty('page');
}
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>";
echo "<tr><th> <th colspan='4'>Repo/Source<th>Sivu</tr>";
for ($i=0; $i<sizeof($repo_source); $i++) {
echo "<tr><td rowspan='2'></td><td colspan='4'> " . $repo_name[$i] .
"</td></tr>";
echo "<tr><td colspan='4'> " . $repo_source[$i] .
"</td><td>" . $repo_page[$i] . "</td></tr>";
}
for ($i=0; $i<sizeof($repo_name_only); $i++) {
echo "<tr><td></td><td colspan='4'> " . $repo_name_only[$i] .
"</td><td>" . $repo_page_only[$i] . "</td></tr>";
}
echo "</table>";
}
?>
</body>
</html>