-
Notifications
You must be signed in to change notification settings - Fork 3
/
page-backup.php
330 lines (305 loc) · 17.3 KB
/
page-backup.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<!doctype html>
<html lang="en">
<?
require 'connection.php';
require 'functions.php';
?>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Pythrons - Political Opinion Sentiment Analysis</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.min.css">
<link href="assets/vendor/fonts/circular-std/style.css" rel="stylesheet">
<link rel="stylesheet" href="assets/libs/css/style.css">
<link rel="stylesheet" href="assets/vendor/fonts/fontawesome/css/fontawesome-all.css">
</head>
<body>
<!-- ============================================================== -->
<!-- main wrapper -->
<!-- ============================================================== -->
<div class="dashboard-main-wrapper">
<!-- ============================================================== -->
<!-- navbar -->
<!-- ============================================================== -->
<div class="dashboard-header">
<nav class="navbar navbar-expand-lg bg-white fixed-top">
<a class="navbar-brand" href="page.php">Pythrons</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto navbar-right-top">
<li class="nav-item">
<div id="custom-search" class="top-search-bar">
<input class="form-control" type="text" placeholder="Search..">
</div>
</li>
</ul>
</div>
</nav>
</div>
<!-- ============================================================== -->
<!-- end navbar -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- left sidebar -->
<!-- ============================================================== -->
<div class="nav-left-sidebar sidebar-dark">
<div class="menu-list">
<nav class="navbar navbar-expand-lg navbar-light">
<a class="d-xl-none d-lg-none" href="page.php">Dashboard</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav flex-column">
<li class="nav-divider">
Menu
</li>
<li class="nav-item ">
<a class="nav-link active" href="visualizations.php" data-toggle="collapse" aria-expanded="false" data-target="#submenu-1" aria-controls="submenu-1"><i class="fas fa-fw fa-chart-pie"></i>Visualizations<span class="badge badge-success">6</span></a>
<div id="submenu-1" class="collapse submenu" style="">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link" href="visualizations.php">Statistics<span class="badge badge-secondary">Statistics</span></a>
</li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="collapse" aria-expanded="false" data-target="#submenu-2" aria-controls="submenu-2"><i class="fa fa-fw fa-rocket"></i>Subscriptions</a>
<div id="submenu-2" class="collapse submenu" style="">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link" href="modi_sub.php">Modi<span class="badge badge-secondary">Modi</span></a>
</li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="map.php" data-toggle="collapse" aria-expanded="false" data-target="#submenu-5" aria-controls="submenu-5"><i class="fas fa-fw fa-table"></i>Live Map Feed</a>
<div id="submenu-5" class="collapse submenu" style="">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link" href="map_aap.php">AAP<span class="badge badge-secondary">AAP/</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="map_congress.php">Congress<span class="badge badge-secondary">Congress/</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="map_bjp.php">BJP<span class="badge badge-secondary">BJP/</span></a>
</li>
</ul>
</div>
</li>
</ul>
</div>
</nav>
</div>
</div>
<!-- ============================================================== -->
<!-- end left sidebar -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- wrapper -->
<!-- ============================================================== -->
<div class="dashboard-wrapper">
<div class="container-fluid dashboard-content">
<!-- ============================================================== -->
<!-- pageheader -->
<!-- ============================================================== -->
<div class="row">
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
<div class="page-header">
<h2 class="pageheader-title">Some Detailed Analytics on your search term </h2>
<p class="pageheader-text">Proin placerat ante duiullam scelerisque a velit ac porta, fusce sit amet vestibulum mi. Morbi lobortis pulvinar quam.</p>
<div class="page-breadcrumb">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="#" class="breadcrumb-link">Dashboard</a></li>
<li class="breadcrumb-item"><a href="#" class="breadcrumb-link">Pages</a></li>
<li class="breadcrumb-item active" aria-current="page">Analysis</li>
</ol>
</nav>
</div>
</div>
</div>
</div>
<!-- ============================================================== -->
<!-- end pageheader -->
<!-- ============================================================== -->
<div class="row">
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
<div class="card">
<h5 class="card-header">Enter Search Term: </h5>
<div class="card-body">
<form name="search" method="get">
<div class="form-group">
<!-- <label for="inputText3" class="col-form-label">Input Text</label>-->
<input id="inputText3" type="text" class="form-control" name="search">
</div>
<button type="submit" class="btn btn-primary">Primary</button>
</form>
</div>
</div>
</div>
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
<?php
$string = "";
if(isset($_GET["search"])) {
$keyword=$_GET["search"];
$keywordurl=str_replace(" ","+",$keyword);
$url ="https://api.social-searcher.com/v2/search?q=" . $keywordurl . "&key=5125c917b806a166cfdf1865c9ab8f47&fields=posted,text,sentiment,popularity,tags,user_mentions,user&limit=50&network=web,twitter,reddit,instagram&lang=en";
$res=CallAPI("GET",$url);
$jsonres=json_decode($res,true);
$x=$jsonres["posts"];
$stop=0;
foreach($x as $r) {
$usermentions="";
$tags="";
$count=0;
$posted="";
$text="";
$sentiment="";
$username="";
$imageurl="";
$location="";
foreach($r as $k=>$v) {
if($k=="user_mentions") {
foreach($v as $iter) {
$usermentions.=$iter["text"];
$usermentions.=" ";
}
}
else if($k=="tags") {
foreach($v as $iter) {
$tags.=$iter["text"];
$tags.=" ";
}
}
else if($k=="popularity") {
foreach($v as $iter) {
$count+=$iter["count"];
}
}
else if($k=="posted") {
$posted=$v;
}
else if($k == "text") {
$text=$v;
if($stop<10) {
$string .= $text;
$string .= " ";
$stop++;
}
}
else if($k=="sentiment"){
$sentiment=$v;
}
else if($k=="user") {
$username=$v["name"];
$imageurl=$v["image"];
if(!isset($v["location"]))
$location="Mumbai, India";
else
$location=$v["location"];
}
else {
echo("else");
}
}
$sql="insert into posts(posted,text,sentiment,count,usermentions,tags,username,imageurl,location,keyword) values( '$posted' ,'$text','$sentiment',$count,'$usermentions', '$tags','$username', '$imageurl', '$location','$keyword')";
$res= $con->query($sql);
}
$sql="select * from posts order by posted desc limit 50";
$result = $con->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
if(!isset($v["imageurl"]))
$imagepath=$row["imageurl"];
else
$imagepath="./avatar.png";
echo "
<div class='card'>
<div class='card-header'>
" . $row["posted"] . " - " . $row["location"] ."
</div>
<div class='card-body'>
<blockquote class='blockquote mb-0'>
<img src=". $imagepath .">
<p>" . $row["text"] . "</p>
<footer class='blockquote-footer'>
<cite title='Source Title'>" . $row["username"] ." </cite>
</footer>
</blockquote>
</div>
</div>";
}
} else {
echo "0 results";
}
// echo $string;
$result=WatsonCall($string,$keyword);
if(isset($result)) {
$jsonres=json_decode($result,true);
$x=$jsonres["keywords"];
$e=$jsonres["emotion"];
$keywords="";
$sadness="";
$joy="";
$fear="";
$disgust="";
$anger="";
foreach($x as $r) {
foreach($r as $k=>$v) {
if($k=="text") {
$keywords .= $v;
$keywords .= " ";
}
}
}
foreach($e as $r) {
foreach($r as $k=>$v) {
if($k=="emotion") {
$sadness = $v["emotion"]["sadness"];
$joy = $v["emotion"]["joy"];
$fear = $v["emotion"]["fear"];
$disgust = $v["emotion"]["disgust"];
$anger = $v["emotion"]["anger"];
}
}
}
$sql="insert into keywords(keyword,sadness,joy,fear,disgust,anger,words) values( '$keyword' , '$sadness','$joy', '$fear', '$disgust','$anger','$keywords')";
$res= $con->query($sql);
echo $res;
}
}
//$string = 'RT @shibuchandran28: Day by day love for Modi keeps multiplying....#TNWelcomesModi';
?>
</div>
</div>
</div>
<!-- ============================================================== -->
<!-- footer -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- end footer -->
<!-- ============================================================== -->
</div>
<!-- ============================================================== -->
<!-- end main wrapper -->
<!-- ============================================================== -->
</div>
<!-- ============================================================== -->
<!-- end main wrapper -->
<!-- ============================================================== -->
<!-- Optional JavaScript -->
<script src="assets/vendor/jquery/jquery-3.3.1.min.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="assets/vendor/slimscroll/jquery.slimscroll.js"></script>
<script src="assets/libs/js/main-js.js"></script>
</body>
</html>