-
Notifications
You must be signed in to change notification settings - Fork 1
/
index41.php
532 lines (400 loc) · 15.8 KB
/
index41.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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
<?php
include "common.php";
require_once __DIR__ . '/vendor/autoload.php';
use Phpml\Regression\SVR;
use Phpml\Classification\KNearestNeighbors;
use Phpml\Classification\SVC;
use Phpml\SupportVectorMachine\Kernel;
$user_id=$_SESSION['id'] ;
if (!isset($_SESSION['email'])) {
header('location: login.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!--Latest compiled and minified JavaScript-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.row_style{
margin-top:10px;
}
</style>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>HOme</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<link href="index.css" rel="stylesheet" type="text/css"/>
<link href="css/blog-home.css" rel="stylesheet">
<link href="css/clean-blog.min.css" rel="stylesheet">
</head>
<body>
<!-- Navigation -->
<?php include 'header.php'?>
<!-- Page Header -->
<header class="masthead" style="background-image: url('img/home-bg.jpg')">
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-10 mx-auto">
<div class="site-heading">
<h1>Xplatform-experimental</h1>
<span class="subheading"></span>
</div>
</div>
</div>
</header>
<?php
$user_id = $_SESSION['id'];
$samples0=array(array());
$targets0=array();
$result1 = mysqli_query($con,"select * from user_thread");
$result3 = mysqli_query($con,"SELECT * FROM threads , users,tags_thread where users.id='$user_id' and tags_thread.tag1 = users.tag1 or tags_thread.tag2 = users.tag2 or tags_thread.tag3 = users.tag3 ORDER BY date DESC ");
$i=0;
while($row = mysqli_fetch_assoc($result1)) {
$samples0[$i][0] = $row['user_id'];
$targets0[$i] = $row['th_id'];
$i = $i + 1;
}
$classifier = new SVC(Kernel::LINEAR, $cost = 1000);
$classifier->train($samples0, $targets0);
$pred0=$classifier->predict([$user_id]) ;
$result9 = mysqli_query($con,"SELECT * FROM threads where th_id='$pred0 'ORDER BY date DESc");
$row9=mysqli_fetch_assoc($result9);
?>
<div class="container">
++
<div class="row">
<div class="col-md-4">
<div class="card text-white bg-info mb-3" style="max-width: 18rem;">
<div class="card-header">THREAD TO FOLLOW</div>
<div class="card-body">
<h2 class="card-title"><?php echo '<h2>'.$row9['title'].'</h2>';?></h2>
<p class="card-text"><?php $body = substr($row9['body'], 0, 100);
echo nl2br($body).'...<br/>';?></p>
</div>
<?php echo '<a href="post_view.php?id='.$row9['th_id'].'" class="btn btn-primary">Read More</a> | ';
?>
</div>
<h3 class="my-4">FROM COMMUNITIES YOU JOINED
<small></small>
</h3>
<?php
$result = mysqli_query($con,"SELECT * FROM threads , user_communities where user_communities.user_id='$user_id' and threads.c_id = user_communities.c_id ORDER BY date DESc");
if(!mysqli_num_rows($result)) {
echo 'No posts yet.';
} else {
while($row = mysqli_fetch_assoc($result)) {?>
<div class="card mb-4">
<img class="card-img-top" src="http://placehold.it/750x300" alt="Card image cap">
<div class="card-body">
<h2 class="card-title"><?php echo '<h2>'.$row['title'].'</h2>';?></h2>
<p class="card-text"><?php $body = substr($row['body'], 0, 300);
echo nl2br($body).'...<br/>';?></p>
<?php echo '<a href="post_view.php?id='.$row['th_id'].'" class="btn btn-primary">Read More</a> | ';
?>
</div>
<div class="card-footer text-muted">
</div>
</div>
<?php
}}
$result1 = mysqli_query($con,"select * from user_thread");
$result3 = mysqli_query($con,"SELECT * FROM threads , users,tags_thread where users.id='$user_id' and tags_thread.tag1 = users.tag1 or tags_thread.tag2 = users.tag2 or tags_thread.tag3 = users.tag3 ORDER BY date DESC ");
$i=0;
while($row = mysqli_fetch_assoc($result1)) {
$samples0[$i][0] = $row['user_id'];
$targets0[$i] = $row['th_id'];
$i = $i + 1;
}
$classifier = new SVC(Kernel::LINEAR, $cost = 1000);
$classifier->train($samples0, $targets0);
$pred5=$classifier->predict([$user_id]) ;
$c=date("y/m/d");
$result5 = mysqli_query($con,"SELECT * FROM threads where th_id='$pred5' and date='$c' ORDER BY date DESc");
$row5=mysqli_fetch_assoc($result5);
?>
</div>
<div class="col-md-4">
<div class="card text-white bg-secondary mb-3" style="max-width: 18rem;">
<div class="card-header">THREAD TO FOLLOW</div>
<div class="card-header">TRENDING TODAY</div>
<div class="card-body">
<h2 class="card-title"><?php echo '<h2>'.$row5['title'].'</h2>';?></h2>
<p class="card-text"><?php $body = substr($row5['body'], 0, 100);
echo nl2br($body).'...<br/>';?></p>
</div>
<?php echo '<a href="post_view.php?id='.$row9['th_id'].'" class="btn btn-primary">Read More</a> | ';
?>
</div>
<h3 class="my-4">threads YOU FOLLOW
<small></small>
</h3>
<?php
$result = mysqli_query($con,"SELECT * FROM threads , user_thread where user_thread.user_id='$user_id' and threads.th_id = user_thread.th_id ORDER BY date DESC ");
if(!mysqli_num_rows($result)) {
echo 'No posts yet.';
} else {
while($row = mysqli_fetch_assoc($result)) {?>
<div class="card mb-4">
<img class="card-img-top" src="http://placehold.it/750x300" alt="Card image cap">
<div class="card-body">
<h2 class="card-title"><?php echo '<h2>'.$row['title'].'</h2>';?></h2>
<p class="card-text"><?php $body = substr($row['body'], 0, 300);
echo nl2br($body).'...<br/>';?></p>
<?php echo '<a href="post_view.php?id='.$row['th_id'].'" class="btn btn-primary">Read More</a> | ';
?>
</div>
<div class="card-footer text-muted">
</div>
</div>
<?php
}}?>
</div>
<script>
$(document).ready(function() {
$('input.search').typeahead({
name: 'search',
remote: 'search_suggest.php?query=%QUERY'
});
})
</script>
<div class="col-md-4">
<a href="index3.php" type="button" class="btn btn-SUCCESS" style="width:100%">ADD community</a> <br><br>
<a href="communities.php?id=1" type="button" class="btn btn-danger" style="width:100%">SOS community</a>
<div class="card my-4">
<h5 class="card-header">Search</h5>
<div class="card-body">
<form method="POST" action="search.php">
<div class="input-group">
<input type="text" name="search" class="form-control" class="search" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-secondary" type="submit">Go!</button>
</span>
</form>
</div>
</div>
</div>
<?php
$result8 = mysqli_query($con,"SELECT * FROM communities ORDER BY user_joined DESc limit 5");
?>
<div class="card my-4">
<h5 class="card-header">Top COMMUNITIES</h5>
<div class="card-body">
<?php while($row8=mysqli_fetch_assoc($result8)){?>
<div class="card">
<div class="card-body">
<h2 class="card-title"><?php echo '<h2>'.$row8['name'].'</h2>';?></h2>
<?php echo '<a href="communities.php?id='.$row['c_id'].'" class="btn btn-primary">Read More</a> | ';
?>
</div>
</div>
<?php }?>
</div>
</div>
<?php
$samples=array(array());
$targets=array();
$result6 = mysqli_query($con,"SELECT * FROM threads");
$i=0;
$j=0;
while($row = mysqli_fetch_assoc($result6)) {
$samples[$i][0] = $row['user_joined'];
$samples[$i][1] = $row['total_reply'];
$targets[$i] = $row['th_id'];
$i = $i + 1;
}
print $samples[0][1];
$classifier = new SVC(Kernel::LINEAR, $cost = 1000);
$classifier->train($samples, $targets);
?>
<div class="card my-4">
<h5 class="card-header">Trending COMMUNITIES</h5>
<div class="card-body">
</div>
</div>
<div class="card my-4">
<h5 class="card-header">Trending THREADS</h5>
<?php
for( $i = 0; $i<5; $i++ ) {
$predict=$classifier->predict([15,rand(80,100)]);
$result5 = mysqli_query($con,"SELECT * FROM threads where th_id = '$predict' ORDER BY date DESC ");
$row5=mysqli_fetch_assoc($result5);?>
<div class="card mb-4">
<img class="card-img-top" src="http://placehold.it/750x300" alt="Card image cap">
<div class="card-body">
<h2 class="card-title"><?php echo '<h2>'.$row5['title'].'</h2>';?></h2>
<?php echo '<a href="post_view.php?id='.$row5['th_id'].'" class="btn btn-primary">Read More</a> | ';
?>
</div>
</div>
<?php }
?>
</div></div></div>
<br><br><br>
<?php
$samples=array(array());
$targets=array();
$result3 = mysqli_query($con,"SELECT * FROM threads , users,tags_thread where users.id='$user_id' and tags_thread.tag1 = users.tag1 or tags_thread.tag2 = users.tag2 or tags_thread.tag3 = users.tag3 ORDER BY date DESC ");
$i=0;
$j=0;
while($row = mysqli_fetch_assoc($result3)) {
$samples[$i][0] = $row['user_joined'];
$samples[$i][1] = $row['total_reply'];
$targets[$i] = $row['th_id'];
$i = $i + 1;
}
print $samples[0][1];
$classifier = new SVC(Kernel::LINEAR, $cost = 1000);
$classifier->train($samples, $targets);
?>
//////////////suggestion by tagsssss
<h3>suggested...only for YOU
<small></small>
</h3>
<div class="row">
<div class="col-4">
<h3>light discussion</h3>
<?php
for( $i = 0; $i<5; $i++ ) {
$pred=$classifier->predict([15,rand(1,3)]);
$result = mysqli_query($con,"SELECT * FROM threads where th_id = '$pred' ORDER BY date DESC ");
$row=mysqli_fetch_assoc($result);?>
<div class="card mb-4">
<img class="card-img-top" src="http://placehold.it/750x300" alt="Card image cap">
<div class="card-body">
<h2 class="card-title"><?php echo '<h2>'.$row['title'].'</h2>';?></h2>
<p class="card-text"><?php $body = substr($row['body'], 0, 300);
echo nl2br($body).'...<br/>';?></p>
<?php echo '<a href="post_view.php?id='.$row['th_id'].'" class="btn btn-primary">Read More</a> | ';
?>
</div>
<div class="card-footer text-muted">
</div>
</div>
<?php }
?></div>
<div class="col-4">
<h3>Heavy discussion</h3>
<?php
for( $i = 0; $i<5; $i++ ) {
$pred=$classifier->predict([15,rand(3,30)]);
$result = mysqli_query($con,"SELECT * FROM threads where th_id = '$pred' ORDER BY date DESC ");
$row=mysqli_fetch_assoc($result);?>
<div class="card mb-4">
<img class="card-img-top" src="http://placehold.it/750x300" alt="Card image cap">
<div class="card-body">
<h2 class="card-title"><?php echo '<h2>'.$row['title'].'</h2>';?></h2>
<p class="card-text"><?php $body = substr($row['body'], 0, 300);
echo nl2br($body).'...<br/>';?></p>
<?php echo '<a href="post_view.php?id='.$row['th_id'].'" class="btn btn-primary">Read More</a> | ';
?>
</div>
<div class="card-footer text-muted">
</div>
</div>
<?php } ?>
</div>
<div class="col-4">
<h3>moderate discussion</h3>
<?php
for( $i = 0; $i<5; $i++ ) {
$pred=$classifier->predict([15,rand(50,100)]);
$result = mysqli_query($con,"SELECT * FROM threads where th_id = '$pred' ORDER BY date DESC ");
$row=mysqli_fetch_assoc($result);?>
<div class="card mb-4">
<img class="card-img-top" src="http://placehold.it/750x300" alt="Card image cap">
<div class="card-body">
<h2 class="card-title"><?php echo '<h2>'.$row['title'].'</h2>';?></h2>
<p class="card-text"><?php $body = substr($row['body'], 0, 300);
echo nl2br($body).'...<br/>';?></p>
<?php echo '<a href="post_view.php?id='.$row['th_id'].'" class="btn btn-primary">Read More</a> | ';
?>
</div>
<div class="card-footer text-muted">
</div>
</div>
<?php }
?>
</div>
</div>
<!-- <div class="card mb-4">
<img class="card-img-right" src="http://placehold.it/750x300" alt="Card image cap">
<div class="card-body">
<h2 class="card-title">Post Title</h2>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reiciendis aliquid atque, nulla? Quos cum ex quis soluta, a laboriosam. Dicta expedita corporis animi vero voluptate voluptatibus possimus, veniam magni quis!</p>
<a href="#" class="btn btn-primary">Read More →</a>
</div>
<div class="card-footer text-muted">
Posted on January 1, 2017 by
<a href="#">SHISHIR</a>
</div>
</div>
<div class="card mb-4">
<img class="card-img-top" src="http://placehold.it/750x300" alt="Card image cap">
<div class="card-body">
<h2 class="card-title">Post Title</h2>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reiciendis aliquid atque, nulla? Quos cum ex quis soluta, a laboriosam. Dicta expedita corporis animi vero voluptate voluptatibus possimus, veniam magni quis!</p>
<a href="#" class="btn btn-primary">Read More →</a>
</div>
<div class="card-footer text-muted">
Posted on January 1, 2017 by
<a href="#">SHIshir</a>
</div>
</div>
<!-- Pagination
<ul class="pagination justify-content-center mb-4">
<li class="page-item">
<a class="page-link" href="#">← Older</a>
</li>
<li class="page-item disabled">
<a class="page-link" href="#">Newer →</a>
</li>
</ul>
</div>
-->
</div>
<footer>
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-10 mx-auto">
<ul class="list-inline text-center">
<li class="list-inline-item">
<a href="#">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<li class="list-inline-item">
<a href="#">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<li class="list-inline-item">
<a href="#">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-github fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
</ul>
<p class="copyright text-muted">Copyright © Your Website 2017</p>
</div>
</div>
</div>
</footer>
</body>
</html>