-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathview_article.php
More file actions
634 lines (610 loc) · 30.7 KB
/
view_article.php
File metadata and controls
634 lines (610 loc) · 30.7 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
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
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
<?php session_start(); ?>
<?php
//include("like_dislike.php");
include_once("./include/head_line.inc.php");
include_once("./include/db/configure.php");
include_once("./include/db/db_func.php");
include_once("./include/commonFunction.php");
echo "<br><br><br><br><br>";
include_once("userRating.php");
include_once("./include/mysql_connect.inc.php");
$db_conn = connect2db($dbhost, $dbuser, $dbpwd, $dbname);
?>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inconsolata">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>
<!--script type="text/javascript" src="jquery"></script>
<script type="text/javascript" src="jquery-3.3.1.min.js"></script-->
<script type="text/javascript" src="jquery.cycle.all.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="prism.css">
<!--link rel="stylesheet" type="text/css" href="main.css"-->
<link rel="stylesheet" type="text/css" href="prism.css">
<script type="text/javascript" src="prism.js"></script>
<style>
.out {
position: static;
float: center;
}
body,
html {
height: 100%;
font-family: "Inconsolata", sans-serif;
color: black;
background: "#rgb(207, 223, 226)";
}
.td {
width: 50px;
}
table {
height: 10%;
left: 50%;
position: static;
width: 880px;
border-top: 3px #333333 solid;
border-bottom: 3px #333333 solid;
border-left: 3px #EEE solid;
border-right: 3px #EEE solid;
border-collapse: collapse;
border-spacing: 0;
}
thead th {
background: #555555;
width: 880px;
color: #FFF;
font-family: 'Lato', font-family:DFKai-sb;
font-size: 16px;
text-align: left;
font-weight: 100;
letter-spacing: 2px;
text-transform: uppercase;
}
tr {
color: #333333;
background: #fff; /*#e1eaf4*/
/*border-collapse: collapse;*/
width: 880px;
margin-bottom: 5px;
}
th,
td {
font-family: 'Lato', serif;
font-style: style="font-family:DFKai-sb";
font-weight: 400;
width: 880px;
padding: 10px;
text-align: left;
padding: 8px;
color:#333333;
border-bottom: 1px solid #ddd;
}
/*第一欄第一列:左上*/
tr:first-child td:first-child th:first-child thead:first-child{
border-top-left-radius: 10px;
}
/*第一欄最後列:左下*/
tr:last-child td:first-child th:first-child thead:first-child{
border-bottom-left-radius: 10px;
}
/*最後欄第一列:右上*/
tr:first-child td:last-child th:last-child thead:last-child{
border-top-right-radius: 10px;
}
/*最後欄第一列:右下*/
tr:last-child td:last-child th:last-child thead:last-child{
border-bottom-right-radius: 10px;
}
a {
outline: none;
text-decoration: none;
}
select {
width: 150px;
padding: 10px 10px;
border: none;
float: left;
border-radius: 10px;
margin: 2px;
color: #fff;
background-color: #333333;
}
#Sidebar {
width: 0px;
float: left;
height: 100%;
text-align: center;
line-height: 280px;
font-size: 15px;
color: #ffffff;
font-weight: lighter;
}
#Sidebar_right{
width:120px;
height:400px;
right:50%;
text-align:center;
line-height:400px;
float:right;
}
#header{
height:80px;
text-align:right;
float:right;
top:10%;
right:5%;
position:absolute;
}
.rating {
display: inline-block;
position: relative;
bottom: 500px;
top: 10px;
left : 650px;
height: 25px;
width: 400px;
line-height: 25px;
font-size: 25px;
}
.rating label {
position: absolute;
bottom: 500px;
top: 0;
left: 10px;
height: 0;
cursor: pointer;
}
.rating label:last-child {
position: absolute;
}
.rating label:nth-child(1) {
z-index: 5;
}
.rating label:nth-child(2) {
z-index: 4;
}
.rating label:nth-child(3) {
z-index: 3;
}
.rating label:nth-child(4) {
z-index: 2;
}
.rating label:nth-child(5) {
z-index: 1;
}
.rating label input {
position: absolute;
top: 0px;
left: 10%;
opacity: 0;
}
.rating label .icon {
float: center;
color: transparent;
}
.rating label:last-child .icon {
color: #dddddd;
}
.rating:not(:hover) label input:checked ~ .icon,
.rating:hover label:hover input ~ .icon {
color: #ffdd6b;
}
.rating label input:focus:not(:checked) ~ .icon:last-child {
color: #dddddd;
text-shadow: 0 0 5px #ffdd6b;
}
#all {
background: #fff;
}
</style>
</head>
<body id="all">
<?php
//種類選擇
//echo $_GET['kind']."<br>";
//echo $_SESSION['Category']."<br>";
if(!isset($_GET['kind']) && isset($_SESSION['Category'])) {
if($_SESSION['Category'] == 'c') {
$sql3 = "SELECT * FROM tsc_post WHERE tsc_post.Category = '0' AND tsc_post.Permisseion = '0' AND Valid = '0'";
}
else if($_SESSION['Category'] == 'cpp') {
$sql3 = "SELECT * FROM tsc_post WHERE tsc_post.Category = '1' AND tsc_post.Permission = '0' AND Valid = '0'";
}
else {
$sql3 = "SELECT * FROM tsc_post WHERE tsc_post.Permission = '0' AND Valid = '0'";
}
}
else {
if($_GET['kind'] == 'c') {
$sql3 = "SELECT * FROM tsc_post WHERE tsc_post.Category = '0' AND tsc_post.Permission = '0' AND Valid = '0'";
}
else if($_GET['kind'] == 'cpp') {
$sql3 = "SELECT * FROM tsc_post WHERE tsc_post.Category = '1' AND tsc_post.Permission = '0' AND Valid = '0'";
}
else {
$sql3 = "SELECT * FROM tsc_post WHERE tsc_post.Permission = '0' AND Valid = '0'";
}
$_SESSION['Category'] = $_GET['kind'];
}
//結束 種類選擇
?>
<?php
//echo $_GET['OrderBy']."<br>";
//echo $_SESSION['OrderBy']."<br>";
//排序選擇
if(!isset($_GET['OrderBy']) && isset($_SESSION['OrderBy'])) {
if($_SESSION['OrderBy'] == 'TimeOld') {
$sql3 .= " ORDER BY Date";
}
else if($_SESSION['OrderBy'] == 'RatingHigh' ) {
$sql3 .= " ORDER BY Stars DESC, Date DESC";
}
else if($_SESSION['OrderBy'] == 'RatingLow') {
$sql3 .= " ORDER BY Stars, Date DESC";
}
else {
$sql3 .= " ORDER BY Date DESC";
$_SESSION['OrderBy'] = 'TimeNew';
}
}
else {
if (empty($_GET['OrderBy'])) {
$sql3 .= " ORDER BY Date DESC";
$_SESSION['OrderBy'] = 'TimeNew';
$_GET['OrderBy'] = 'TimeNew';
}
else if($_GET['OrderBy'] == 'TimeOld') {
$sql3 .= " ORDER BY Date";
$_SESSION['OrderBy'] = $_GET['OrderBy'];
}
else if($_GET['OrderBy'] == 'RatingHigh' ) {
$sql3 .= " ORDER BY Stars DESC, Date DESC";
$_SESSION['OrderBy'] = $_GET['OrderBy'];
}
else if($_GET['OrderBy'] == 'RatingLow') {
$sql3 .= " ORDER BY Stars, Date DESC";
$_SESSION['OrderBy'] = $_GET['OrderBy'];
}
else if($_GET['OrderBy'] == 'TimeNew'){
$sql3 .= " ORDER BY Date DESC";
$_SESSION['OrderBy'] = 'TimeNew';
}
}
//echo $sql3."<br>";
//echo $_GET['OrderBy']."<br>";
//echo $_SESSION['OrderBy']."<br>";
//結束 排序選擇
?>
<div id="header">
<?php if(!isset($_GET['PostIndex'])) {?>
<form action='searchKeyword.php' method='POST' style="margin-left: 20px;text-align:left;display:inline;">
<input type="text" name="keyword" placeholder=" Key word" style="margin-top: 5px;padding: 3px 3px;">
<input type="submit" value="search" style="margin-top: 5px;padding: 3px 3px;">
</form>
<form class='custom' action='' method='GET' style="text-align:center;display:inline;">
<Select name='kind' onchange="submit();" id="kind">
<option value='All'<?php if($_SESSION['Category']=='All') echo 'selected'; ?>>All</option>
<option value='c'<?php if($_SESSION['Category']=='c') echo 'selected'; ?>>C</option>
<option value='cpp'<?php if($_SESSION['Category']=='cpp') echo 'selected'; ?>>C++</option>
</Select>
<Select name='OrderBy' onchange="submit();" id="OrderBy" style="margin-left: 20px;">
<option value = 'TimeNew' <?php if($_SESSION['OrderBy'] == 'TimeNew') echo 'selected'; ?>>New -> Old</option>
<option value = 'TimeOld' <?php if($_SESSION['OrderBy'] == 'TimeOld') echo 'selected'; ?>>Old -> New</option>
<option value = 'RatingHigh' <?php if($_SESSION['OrderBy'] == 'RatingHigh') echo 'selected'; ?>>Hard -> Easy</option>
<option value = 'RatingLow' <?php if($_SESSION['OrderBy'] == 'RatingLow') echo 'selected'; ?>>Easy -> Hard</option>
</Select>
</form>
<?php }?>
</div>
<div class="out"><br><br>
<?php
$ret = querydb($sql3, $db_conn);
$count = count($ret);
$per = 3;
$pages = ceil($count/$per);
if(!isset($_GET['page'])) {
$page = 1;
}
else {
$page = intval($_GET['page']);
}
$start = ($page-1)*$per;
$sql4 = $sql3.' LIMIT '.$start.', '.$per;
//echo $sql4;
if(isset($_GET['PostIndex'])) {
$sql4 = "SELECT * FROM tsc_post WHERE PostIndex = ".$_GET['PostIndex']." AND Valid = '0' AND Permission = '0'";
$count = 1;
$pages = 1;
}
//echo "<script>console.log(".$sql4.")</script>";
$list = array();
$list = $db_conn->query($sql4);
try {
foreach($db_conn->query($sql4) as $k => $v){ ?>
<div class="container">
<div class="CSSTableGenerator">
<table align="center" style="width:880px;">
<thead>
<th colspan="2" style="text-align: left;">
<h5 style="text-align: left;color:#fcdd5c;">
<font style="color:#fff;left:0px;right:880px;position:relative;">
<a href=view_article.php?PostIndex=<?php echo $v['PostIndex'];?> target="_blank" style="text-decoration:none;"><?php echo $v['Title']?></a></font>
<font style="font-size:120%;"> ★</font>
<span id = 'rating_<?php echo $v['PostIndex'] ?>'>
<?php echo getRatingOfStar($v['PostIndex']); ?>
</span>
<span id = 'people_<?php echo $v['PostIndex'] ?>'>
<?php echo "(".getPeopleNumber($v['PostIndex']).")"; ?>
</span>
</h5>
<?php if(!empty($_SESSION['uid'])) {?>
<h6>
<div class="rating rating1" data-id="<?php echo $v['PostIndex']; ?>">
<input type="hidden" name="postIndex" value="<?php echo $v['PostIndex']; ?>">
<label>
<input type="radio" name="stars" value="1" data-id="<?php echo $v['PostIndex']; ?>"/>
<span class="icon">★</span>
</label>
<label>
<input type="radio" name="stars" value="2" data-id="<?php echo $v['PostIndex']; ?>"/>
<span class="icon">★</span>
<span class="icon">★</span>
</label>
<label>
<input type="radio" name="stars" value="3" data-id="<?php echo $v['PostIndex']; ?>"/>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
</label>
<label>
<input type="radio" name="stars" value="4" data-id="<?php echo $v['PostIndex']; ?>"/>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
</label>
<label>
<input type="radio" name="stars" value="5" data-id="<?php echo $v['PostIndex']; ?>"/>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
</label>
</div>
</h6>
<?php } else {echo "<br>";}?>
</th>
</thead>
<tr>
<td colspan="2" style="text-align: left;border-left: 1px solid #ddd;border-right: 1px solid #ddd;"><!--Username-->
<?php
//$db_conn = connect2db($dbhost, $dbuser, $dbpwd, $dbname);
$userid = $v['UserIndex'];
$sql_getUsername = "SELECT * FROM tsc_account WHERE UserIndex = '$userid'";
$ret_getUsername = querydb($sql_getUsername, $db_conn);
echo "<h5 style='text-align:left;'>Post By : ".nl2br($ret_getUsername[0]['Username'])."</h5>";
?>
<?php
$date_post = $v['Date'];
echo "<div style='text-align:right;color:#aaa;width:100%;'>$date_post</div>";
?>
</td>
</tr>
<tr>
<td style="width:10%;border-left: 1px solid #ddd;">
<?php
$date_post = $v['Date'];
if($v['Category'] == 0) echo "<div style='background-color:#555;color:#fff;border-radius: 10px;text-align:center;width:50px;'>C</div>";
else if($v['Category'] == 1) echo "<div style='background-color:#555;color:#fff;border-radius: 10px;text-align:center;width:50px;'>C++</div>";
?>
</td>
<td style="width:90%;border-right: 1px solid #ddd;">
<?php echo "<div style='text-align:left;'>".nl2br($v['PostContent'])."</div>";?>
</td>
</tr>
<tr>
<td style="border-left: 1px solid #ddd;"></td>
<td style="border-right: 1px solid #ddd;">
<?php
$db_conn2 = connect2db($dbhost, $dbuser, $dbpwd, $dbname);
$codeid = $v['CodeIndex'];
$sql_getCode = "SELECT * FROM tsc_code WHERE CodeIndex = '$codeid'";
$ret_getCode = querydb($sql_getCode, $db_conn2);
//echo "<pre><div style='text-align:left;'>".$ret_getCode[0]['CodeContent']."</div><pre>";
$ret_getCode = str_replace("......", "'",$ret_getCode[0]['CodeContent']);
$ret_getCode = str_replace("@@@@@@", "\r\n", $ret_getCode);
$ret_getCode = str_replace("++++++", "\\n",$ret_getCode);
?>
<figure class="ce ce-lift ce-twist"><!--figcaption class="ce_caption">CODE CAPTION</figcaption--><pre class="line-number" ><code spellcheck="false" class="language-clike" style="display:inline-block;width:880px;"><?php echo $ret_getCode;?></code></pre></figure>
</td>
</tr>
<?php if(empty($_SESSION['uid'])) { ?>
<tr>
<td colspan="2" style="border-left: 1px solid #ddd;border-right: 1px solid #ddd;">
<?php echo "<a href = 'login.php'><h6 style = 'color:#f86a6a;display:inline;text-align:center;width:100%;'>Login for leave your comment!</h6></a>"; ?>
</td>
</tr>
<?php }?>
<tr>
<th colspan="2" style="text-align: left;border-left: 1px solid #ddd;border-right: 1px solid #ddd;">
<?php
$require = "SELECT * FROM tsc_comment WHERE Valid = '0' ORDER BY Time DESC";
$ret = querydb($require, $db_conn);
$acc = 0;
foreach($ret as $c){
if($v['PostIndex'] == $c['PostIndex']) {
$userIDSql = "SELECT * FROM tsc_account WHERE UserIndex = ".$c['UserIndex']." AND Valid = '0'";
$arr = querydb($userIDSql, $db_conn);
$uesrID = $arr[0]['Username'];
echo "<h6 style='text-align:left;background-color:#fff;color:#333333;border:2px #bfbfbf solid;border-radius: 10px;padding :10px;height:80px;'>";
echo $arr[0]['Username']." : ".nl2br($c['CommentContent']);
echo "<p style='text-align:right;color:#BBB;'>";
echo $c['Time']."</p>"."</h6>";
$acc++;
?>
<div style="width: 450px;" id = "replyBlock">
<?php
$rs = "SELECT * FROM tsc_reply
WHERE Valid = '0' AND
CommentIndex = '" . $c["CommentIndex"] . "' ORDER BY tsc_reply.Time";
$r = querydb($rs, $db_conn);
if(count($r) > 0) {
$cc = 0;
foreach ($r as $eachReply) {
$cc++;
$rUI = $eachReply['UserIndex'];
$rDate = $eachReply['Time'];
$rData = $eachReply['ReplyContent'];
$userIDSql = "SELECT * FROM tsc_account WHERE Valid = '0' AND UserIndex = ".$rUI;
$arr = querydb($userIDSql, $db_conn);
$uesrID = $arr[0]['Username'];
echo "<h6 style='text-align:left;background-color:#EEE;color:#333333;border-radius: 10px;padding :10px ; clear: right;height:80px;'>";
echo $uesrID." : ".$rData."<br>";
echo "<p style='text-align:right;color:#888; '>";
echo $rDate."</p>"."</h6>";
}
?>
<?php }// show reply ?>
<?php if(isset($_SESSION['uid'])) {?>
<input type="text" name="commentReply" id="<?php echo "commentReply_".$c['CommentIndex']; ?>"
style="bottom:20px;width:450px;height:40px;background-color:#666;color:#FFF;padding:20px;border:0px blue none; text-align: left; display: none;border-radius:5px;" placeholder=" Enter your reply!">
<input type="button" name="replyButton" id="<?php echo "replyButton_".$c['CommentIndex']; ?>"
value="Reply" data-id="<?php echo $c['CommentIndex']; ?>" class="reply"
style="width:100px;height:30px;border:0px blue none;color:#fff;background: #a4b0c6;position:relative;float: right;">
<input type="button" name="trueReplyButton" id="<?php echo "trueReplyButton_".$c['CommentIndex']; ?>" data-id="<?php echo $c['CommentIndex']; ?>" class="trueReply"
value="Reply"
style="left:120px;bottom:30px;width:100px;height:30px;border:0px blue none;color:#fff;background: #a4b0c6;position:relative;float: right; display:none;">
<br><br>
<?php }?>
<?php } // end if ?>
</div>
<?php } // end foreach
if($acc == 0) echo "<p style='text-align: center;color:#AAAAAA;'>"."======== No comment Now!========"."</p>";
?>
</th>
</tr>
<?php if(!empty($_SESSION["uid"])) { ?>
<tr>
<th colspan="2" style="text-align: right;border-left: 1px solid #ddd;border-right: 1px solid #ddd;">
<form>
<input type="text" style="background-color:#666;width:450px;height:40px;color:#FFF;padding:20px;border:0px blue none; text-align: left;border-radius:5px;" name="comment" id="<?php echo "comment".$v["PostIndex"]; ?>" placeholder=" Enter your comment!" />
<input type="hidden" name="post_id" id="<?php echo "post_id".$v["PostIndex"]; ?>" value='<?php echo $v["PostIndex"]?>' />
<input type="hidden" name="myid" id="<?php echo "myid".$v["PostIndex"]; ?>" value='<?php echo $_SESSION["uid"] ?>' />
<input type="submit" name="submit" id="<?php echo "commentButton".$v["PostIndex"]; ?>" class="commentButton" data-id="<?php echo $v['PostIndex']; ?>" value="Comment" style="width:100px;height:40px;border:0px blue none;color:#fff;background: #a4b0c6;position:relative;right:0px;" />
</form>
</th>
</tr>
<?php } ?>
</table>
</div>
</div>
<?php
echo "<br>";
}
echo "<br>";
}
catch(PDOException $e){
}
?>
</div>
<footer style="background-color:#555555; padding:10;text-align:center;">
<div style="text-align:center;">
<?php
echo "<a href=?page=1&kind=".$_SESSION['Category']."&OrderBy=".$_SESSION['OrderBy']." style='color:#a6aed0'><font size='+1'>1... </font></a>";
for($i = 1; $i <= $pages; $i++) {
if($i == $page) {
echo "<a href=?page=".$i."&kind=".$_SESSION['Category']."&OrderBy=".$_SESSION['OrderBy']."><font size='+4' color=#ffa5c8> ".$i." </font></a>";
}
else if($page-2 < $i && $i < $page + 2) {
if($i < $page) echo "<a href=?page=".$i."&kind=".$_SESSION['Category']."&OrderBy=".$_SESSION['OrderBy']."><font color=#aec1e3 size='+2'><strong> < </strong></font></a>";
if($i > $page) echo "<a href=?page=".$i."&kind=".$_SESSION['Category']."&OrderBy=".$_SESSION['OrderBy']."><font color=#a7bbe0 size='+2'><strong> > </strong></font></a>";
}
}
echo "<a href=?page=".$pages."&kind=".$_SESSION['Category']."&OrderBy=".$_SESSION['OrderBy']." style='color:#a6aed0' > <font size='+1'>...$pages</font></a>";
echo "<p style='color:#c7c7c7;'>Total: <font color=#f07e7e>".$count."</font> article(s)</p>";
?>
</div>
</footer>
</body>
</html>
<script>
$(':radio').change(function() {
console.log('New star rating: ' + this.value);
});
</script>
<script>
$(':radio').on('click', function() {
stars = this.value;
var postIndex = $(this).attr('data-id');
console.log('New star rating: ' + stars);
$.ajax({
url: 'userRating.php',
type: 'POST',
data: {
'stars': stars,
'PostIndex': postIndex,
'ID': "<?php echo $_SESSION['uid']; ?>"
},
success: function(data) {
var obj = jQuery.parseJSON (data);
alert("You give " + stars + " stars.");
$('#rating_'+postIndex).text(obj.rating);
$('#people_'+postIndex).text("("+obj.people+")");
}
})
});
$('.reply').on('click', function() {
var commentIndex = $(this).attr('data-id');
var replyData = $('#commentReply_'+commentIndex).val();
$('#commentReply_' + commentIndex).show();
$('#replyButton_' + commentIndex).hide();
$('#trueReplyButton_' + commentIndex).show();
});
$('.trueReply').on('click', function() {
var commentIndex = $(this).attr('data-id');
var replyData = $('#commentReply_'+commentIndex).val();
$.ajax({
url: 'comment_reply.php',
type: 'POST',
data: {
'commentIndex': commentIndex,
'ID': "<?php echo $_SESSION['uid']; ?>",
'text': replyData
},
success: function(data) {
//var callback = JSON.stringify(data.sql);
alert("回覆成功\n");// + data.sql);
history.go(0);
$('#commentReply_' + commentIndex).hide();
$('#replyButton_' + commentIndex).show();
$('#trueReplyButton_' + commentIndex).hide();
}
})
});
$('.commentButton').click(function() {
var postIndex = $(this).attr('data-id');
//comment, post_id, myid
var comment = $('#comment' + postIndex).val();
var post_id = $('#post_id' + postIndex).val();
var myid = $('#myid' + postIndex).val();
$.ajax({
url: 'comment_function.php',
type: 'POST',
data: {
'comment': comment,
'post_id': post_id,
'myid': myid
},
success: function(data) {
alert("留言成功");
window.location.reload();
}
});
});
</script>