forked from ashutoshdhundhara/Geo-Graphs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
160 lines (134 loc) · 5.43 KB
/
index.php
File metadata and controls
160 lines (134 loc) · 5.43 KB
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
<?php
/**
* Default script.
*/
/**
* Get all required libraries.
*/
require_once 'libraries/common.inc.php';
if (isset($_REQUEST['show_overlay'])) {
$sql_query = 'SELECT html FROM entity_information WHERE source = \'' . $_REQUEST['src'] . '\' AND destination = \'' . $_REQUEST['dst_node'] . '\'';
$result = $GLOBALS['dbi']->executeQuery($sql_query, array());
if ($result->rowCount() == 0) {
echo '<div>Sorry, no further data available.</div>';
} else {
$row = $result->fetch();
echo $row['html'];
}
exit;
}
if (isset($_REQUEST['save_review'])) {
$sql_query = 'INSERT INTO social(`name`, `source`, `review`) VALUES (:name, :source, :review)';
$result = $GLOBALS['dbi']->executeQuery($sql_query, array(':name' => $_REQUEST['name'], ':source' => $source, ':review' => $_REQUEST['review']));
// $connect=mysql_connect("localhost","root","logMein");
// $select=mysql_select_db("GeoGraphs",$connect);
// $query="INSERT INTO social(`name`, `source`, `review`) values (kartik,kartik,kartik)";
// $vertex_list1=mysql_execute($query);
}
$response = GG_Response::getInstance();
$header = $response->getHeader();
$header->setTitle('Home');
$html_output = '';
$html_output .= '<div id="cy"></div>';
if (isset($_REQUEST['source']) && isset($_REQUEST['type'])) {
$html_output .= "<script>
$(document).ready(function () {
var cy = cytoscape({
container: document.getElementById('cy'),
style: cytoscape.stylesheet()
.selector('node')
.css({
'content': 'data(title)',
'background-color': '#6272A3',
'color': '#A3567E',
'width': 40,
'height': 40,
'cursor': 'pointer'
})
.selector('edge')
.css({
'target-arrow-shape': 'triangle',
'line-color': '#A3567E',
'target-arrow-color': '#A3567E',
'width': 6
})
.selector('.highlighted')
.css({
'background-color': '#61bffc',
'line-color': '#61bffc',
'target-arrow-color': '#61bffc',
'transition-property': 'background-color, line-color, target-arrow-color',
'transition-duration': '0.5s'
})
.selector('node#course')
.css({
'width': 76,
'height': 76
}),
elements: { ";
$source = $_GET['source'];
$type = $_GET['type'];
$connect=mysql_connect("localhost","root","root");
$select=mysql_select_db("GeoGraphs",$connect);
//$source = 'a';
$query="SELECT destination FROM edge_list WHERE lower(source) = " . '\''.$source.'\'' . " AND type = '" . $type . "'";
$vertex_list=mysql_query($query);
$string = "nodes : [";
$string .= "{ data: { id: '". $source. "', title: '". $source . "' } },";
//{ data: { id: 'course', title: 'Engineering Mathematics' } },
while($rows=mysql_fetch_array($vertex_list))
{
//echo $rows['destination']."<br>";
$node = $rows['destination'];
$line = "{ data: { id: '". $node. "', title: '". $node . "' } },";
$string .= $line;
}
$string .= '], edges: [';
$query="SELECT source,destination FROM edge_list WHERE lower(source) = " . '\''.$source.'\''. "AND type = '" . $type . "'";
$vertex_list=mysql_query($query);
//{ data: { id: 'ae', weight: 2, source: 'a', target: 'e' } },
while($rows=mysql_fetch_array($vertex_list))
{
//echo $rows['destination']."<br>";
$source = $rows['source'];
$destination = $rows['destination'];
$line = "{ data: { id: '". $source . $destination . "', source: '". $source . "', target: '". $destination . "' } },";
$string .= $line;
}
$string .= "]}, layout: {
name: 'concentric',
fit: false,
directed: true,
roots: '{$source}',
padding: 5,
minNodeSpacing: 80
}
}); cy.elements('node').on('tap', function (evt) {
handle_click(evt);
}); }); ";
if ($type == 'information') {
$string .= ' var show_overlay = true; ';
} else {
$string .= ' var show_overlay = false; ';
}
$string .= " var source = '{$source}'; var type = '{$type}'; </script>";
$html_output .= $string;
$html_output .= '<form class="check_in" method="POST"><input type="hidden" name="save_review" value="1">';
$sql_query = 'SELECT * FROM social WHERE source = \'' . $source . '\'';
$result = $GLOBALS['dbi']->executeQuery($sql_query, array());
$html_output .= '<div><textarea name="review" placeholder="Add a review"></textarea></div>'
. '<div><input type="text" name="name" placeholder="Enter Your Name"></div>'
. '<div><button>Submit</button></div>';
if ($result->rowCount() > 0) {
$html_output .= '<div style="font-weight: bolder; color: #c0151f">What others are saying about ' . $source . '</div>'
. '<ul class="reviews" style="font-size: 1.2em;">';
while ($row = $result->fetch()) {
$html_output .= '<li><i>' . $row . '</i> says ' .$row['review'] . '</li>';
}
$html_output .= '</ul>';
}
$html_output .= '<a href="external_links.php?source=' .$source . '">External Links: </a>' . '</form>' ;
}
$response->addHTML($html_output);
$response->response();
?>